armcloud-rtc 1.5.3-beta.5 → 1.5.3-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -19,5 +19,5 @@ return e.mode.CTRGladman=function(){var t=e.lib.BlockCipherMode.extend();functio
19
19
  */
20
20
  return function(){var t=e,n=t.lib,r=n.WordArray,i=n.Hasher,o=t.algo,s=r.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),a=r.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=r.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=r.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),d=r.create([0,1518500249,1859775393,2400959708,2840853838]),l=r.create([1352829926,1548603684,1836072691,2053994217,0]),h=o.RIPEMD160=i.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,h,y,S,b,k,E,T,C,I,w,R=this._hash.words,A=d.words,O=l.words,x=s.words,P=a.words,D=c.words,M=u.words;for(k=o=R[0],E=h=R[1],T=y=R[2],C=S=R[3],I=b=R[4],n=0;n<80;n+=1)w=o+e[t+x[n]]|0,w+=n<16?p(h,y,S)+A[0]:n<32?f(h,y,S)+A[1]:n<48?v(h,y,S)+A[2]:n<64?m(h,y,S)+A[3]:_(h,y,S)+A[4],w=(w=g(w|=0,D[n]))+b|0,o=b,b=S,S=g(y,10),y=h,h=w,w=k+e[t+P[n]]|0,w+=n<16?_(E,T,C)+O[0]:n<32?m(E,T,C)+O[1]:n<48?v(E,T,C)+O[2]:n<64?f(E,T,C)+O[3]:p(E,T,C)+O[4],w=(w=g(w|=0,M[n]))+I|0,k=I,I=C,C=g(T,10),T=E,E=w;w=R[1]+y+C|0,R[1]=R[2]+S+I|0,R[2]=R[3]+b+k|0,R[3]=R[4]+o+E|0,R[4]=R[0]+h+T|0,R[0]=w},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,n){return e^t^n}function f(e,t,n){return e&t|~e&n}function v(e,t,n){return(e|~t)^n}function m(e,t,n){return e&n|t&~n}function _(e,t,n){return e^(t|~n)}function g(e,t){return e<<t|e>>>32-t}t.RIPEMD160=i._createHelper(h),t.HmacRIPEMD160=i._createHmacHelper(h)}(),e.RIPEMD160}(n5())),j5(),G5||(G5=1,H5.exports=function(e){return r=(n=(t=e).lib).Base,i=n.WordArray,s=(o=t.algo).SHA256,a=o.HMAC,c=o.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:s,iterations:25e4}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n=this.cfg,r=a.create(n.hasher,e),o=i.create(),s=i.create([1]),c=o.words,u=s.words,d=n.keySize,l=n.iterations;c.length<d;){var h=r.update(t).finalize(s);r.reset();for(var p=h.words,f=p.length,v=h,m=1;m<l;m++){v=r.finalize(v),r.reset();for(var _=v.words,g=0;g<f;g++)p[g]^=_[g]}o.concat(h),u[0]++}return o.sigBytes=4*d,o}}),t.PBKDF2=function(e,t,n){return c.create(n).compute(e,t)},e.PBKDF2;var t,n,r,i,o,s,a,c}(n5(),I5(),j5())),z5(),Y5(),Q5(),t6(),i6(),a6(),c6||(c6=1,u6.exports=function(e){return e.mode.ECB=((t=e.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t),e.mode.ECB;var t}(n5(),Y5())),d6||(d6=1,l6.exports=function(e){return e.pad.AnsiX923={pad:function(e,t){var n=e.sigBytes,r=4*t,i=r-n%r,o=n+i-1;e.clamp(),e.words[o>>>2]|=i<<24-o%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923}(n5(),Y5())),h6||(h6=1,p6.exports=function(e){return e.pad.Iso10126={pad:function(t,n){var r=4*n,i=r-t.sigBytes%r;t.concat(e.lib.WordArray.random(i-1)).concat(e.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126}(n5(),Y5())),f6||(f6=1,v6.exports=function(e){return e.pad.Iso97971={pad:function(t,n){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,n)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971}(n5(),Y5())),m6||(m6=1,_6.exports=function(e){return e.pad.ZeroPadding={pad:function(e,t){var n=4*t;e.clamp(),e.sigBytes+=n-(e.sigBytes%n||n)},unpad:function(e){var t=e.words,n=e.sigBytes-1;for(n=e.sigBytes-1;n>=0;n--)if(t[n>>>2]>>>24-n%4*8&255){e.sigBytes=n+1;break}}},e.pad.ZeroPadding}(n5(),Y5())),g6||(g6=1,y6.exports=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding}(n5(),Y5())),S6||(S6=1,b6.exports=function(e){return n=(t=e).lib.CipherParams,r=t.enc.Hex,t.format.Hex={stringify:function(e){return e.ciphertext.toString(r)},parse:function(e){var t=r.parse(e);return n.create({ciphertext:t})}},e.format.Hex;var t,n,r}(n5(),Y5())),k6||(k6=1,E6.exports=function(e){return function(){var t=e,n=t.lib.BlockCipher,r=t.algo,i=[],o=[],s=[],a=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var n=0,r=0;for(t=0;t<256;t++){var f=r^r<<1^r<<2^r<<3^r<<4;f=f>>>8^255&f^99,i[n]=f,o[f]=n;var v=e[n],m=e[v],_=e[m],g=257*e[f]^16843008*f;s[n]=g<<24|g>>>8,a[n]=g<<16|g>>>16,c[n]=g<<8|g>>>24,u[n]=g,g=16843009*_^65537*m^257*v^16843008*n,d[f]=g<<24|g>>>8,l[f]=g<<16|g>>>16,h[f]=g<<8|g>>>24,p[f]=g,n?(n=v^e[e[e[_^v]]],r^=e[e[r]]):n=r=1}}();var f=[0,1,2,4,8,16,32,64,128,27,54],v=r.AES=n.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,n=e.sigBytes/4,r=4*((this._nRounds=n+6)+1),o=this._keySchedule=[],s=0;s<r;s++)s<n?o[s]=t[s]:(u=o[s-1],s%n?n>6&&s%n==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=f[s/n|0]<<24),o[s]=o[s-n]^u);for(var a=this._invKeySchedule=[],c=0;c<r;c++){if(s=r-c,c%4)var u=o[s];else u=o[s-4];a[c]=c<4||s<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,u,i)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),n=e[t+1],e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,s,a){for(var c=this._nRounds,u=e[t]^n[0],d=e[t+1]^n[1],l=e[t+2]^n[2],h=e[t+3]^n[3],p=4,f=1;f<c;f++){var v=r[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^s[255&h]^n[p++],m=r[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^s[255&u]^n[p++],_=r[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^s[255&d]^n[p++],g=r[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^s[255&l]^n[p++];u=v,d=m,l=_,h=g}v=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[l>>>8&255]<<8|a[255&h])^n[p++],m=(a[d>>>24]<<24|a[l>>>16&255]<<16|a[h>>>8&255]<<8|a[255&u])^n[p++],_=(a[l>>>24]<<24|a[h>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^n[p++],g=(a[h>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&l])^n[p++],e[t]=v,e[t+1]=m,e[t+2]=_,e[t+3]=g},keySize:8});t.AES=n._createHelper(v)}(),e.AES}(n5(),f5(),S5(),z5(),Y5())),I6(),w6||(w6=1,R6.exports=function(e){return function(){var t=e,n=t.lib.StreamCipher,r=t.algo,i=r.RC4=n.extend({_doReset:function(){for(var e=this._key,t=e.words,n=e.sigBytes,r=this._S=[],i=0;i<256;i++)r[i]=i;i=0;for(var o=0;i<256;i++){var s=i%n,a=t[s>>>2]>>>24-s%4*8&255;o=(o+r[i]+a)%256;var c=r[i];r[i]=r[o],r[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,n=this._j,r=0,i=0;i<4;i++){n=(n+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[n],e[n]=o,r|=e[(e[t]+e[n])%256]<<24-8*i}return this._i=t,this._j=n,r}t.RC4=n._createHelper(i);var s=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});t.RC4Drop=n._createHelper(s)}(),e.RC4}(n5(),f5(),S5(),z5(),Y5())),A6||(A6=1,O6.exports=function(e){return function(){var t=e,n=t.lib.StreamCipher,r=t.algo,i=[],o=[],s=[],a=r.Rabbit=n.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,n=0;n<4;n++)e[n]=16711935&(e[n]<<8|e[n]>>>24)|4278255360&(e[n]<<24|e[n]>>>8);var r=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];for(this._b=0,n=0;n<4;n++)c.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),l=u>>>16|4294901760&d,h=d<<16|65535&u;for(i[0]^=u,i[1]^=l,i[2]^=d,i[3]^=h,i[4]^=u,i[5]^=l,i[6]^=d,i[7]^=h,n=0;n<4;n++)c.call(this)}},_doProcessBlock:function(e,t){var n=this._X;c.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,n=0;n<8;n++)o[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,a=r>>>16,c=((i*i>>>17)+i*a>>>15)+a*a,u=((4294901760&r)*r|0)+((65535&r)*r|0);s[n]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.Rabbit=n._createHelper(a)}(),e.Rabbit}(n5(),f5(),S5(),z5(),Y5())),x6||(x6=1,P6.exports=function(e){return function(){var t=e,n=t.lib.StreamCipher,r=t.algo,i=[],o=[],s=[],a=r.RabbitLegacy=n.extend({_doReset:function(){var e=this._key.words,t=this.cfg.iv,n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],r=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)c.call(this);for(i=0;i<8;i++)r[i]^=n[i+4&7];if(t){var o=t.words,s=o[0],a=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),d=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),l=u>>>16|4294901760&d,h=d<<16|65535&u;for(r[0]^=u,r[1]^=l,r[2]^=d,r[3]^=h,r[4]^=u,r[5]^=l,r[6]^=d,r[7]^=h,i=0;i<4;i++)c.call(this)}},_doProcessBlock:function(e,t){var n=this._X;c.call(this),i[0]=n[0]^n[5]>>>16^n[3]<<16,i[1]=n[2]^n[7]>>>16^n[5]<<16,i[2]=n[4]^n[1]>>>16^n[7]<<16,i[3]=n[6]^n[3]>>>16^n[1]<<16;for(var r=0;r<4;r++)i[r]=16711935&(i[r]<<8|i[r]>>>24)|4278255360&(i[r]<<24|i[r]>>>8),e[t+r]^=i[r]},blockSize:4,ivSize:2});function c(){for(var e=this._X,t=this._C,n=0;n<8;n++)o[n]=t[n];for(t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0<o[0]>>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0<o[1]>>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0<o[2]>>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0<o[3]>>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0<o[4]>>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0<o[5]>>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0<o[6]>>>0?1:0)|0,this._b=t[7]>>>0<o[7]>>>0?1:0,n=0;n<8;n++){var r=e[n]+t[n],i=65535&r,a=r>>>16,c=((i*i>>>17)+i*a>>>15)+a*a,u=((4294901760&r)*r|0)+((65535&r)*r|0);s[n]=c^u}e[0]=s[0]+(s[7]<<16|s[7]>>>16)+(s[6]<<16|s[6]>>>16)|0,e[1]=s[1]+(s[0]<<8|s[0]>>>24)+s[7]|0,e[2]=s[2]+(s[1]<<16|s[1]>>>16)+(s[0]<<16|s[0]>>>16)|0,e[3]=s[3]+(s[2]<<8|s[2]>>>24)+s[1]|0,e[4]=s[4]+(s[3]<<16|s[3]>>>16)+(s[2]<<16|s[2]>>>16)|0,e[5]=s[5]+(s[4]<<8|s[4]>>>24)+s[3]|0,e[6]=s[6]+(s[5]<<16|s[5]>>>16)+(s[4]<<16|s[4]>>>16)|0,e[7]=s[7]+(s[6]<<8|s[6]>>>24)+s[5]|0}t.RabbitLegacy=n._createHelper(a)}(),e.RabbitLegacy}(n5(),f5(),S5(),z5(),Y5())),N6());var L6=q(Q4.exports);const U6=0,V6=-1,F6=1,B6=0,j6=1;var G6;!function(e){e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e[e.AUDIO_VIDEO=3]="AUDIO_VIDEO"}(G6||(G6={}));const H6={code:100,msg:"WS开始连接"},W6={code:101,msg:"WS连接成功"},K6={code:102,msg:"WS连接关闭"},z6={code:103,msg:"WS连接出错"},q6={code:104,msg:"WS重连中"},J6={code:200,msg:"收到加入房间信息"},Y6={code:201,msg:"设置offer信息成功"},X6={code:202,msg:"设置offer信息失败"},$6={code:203,msg:"发送answer信息"},Q6={code:204,msg:"发送answer信息失败"},Z6={code:205,msg:"添加ICE信息成功"},e8={code:206,msg:"添加ICE信息失败"},t8={code:207,msg:"发送ICE信息"},n8={code:300,msg:"RTC正在连接"},r8={code:301,msg:"RTC连接成功"},i8={code:302,msg:"RTC断开连接"},o8={code:303,msg:"RTC连接关闭"},s8={code:304,msg:"RTC连接失败"},a8={code:305,msg:"RTC接收VIDEO流"},c8={code:307,msg:"RTC消息通道连接成功"},u8={code:308,msg:"RTC消息通道连接失败"},d8={code:309,msg:"VIDEO加载成功当未收到云机的UI信息"},l8={code:310,msg:"VIDEO第一帧渲染成功"};class h8{constructor(e,t,n){this.params=null,this.pingTimer=null,this.callbacks=null,this.socket=null,this.reconnectAttempts=0,this.maxReconnectAttempts=3,this.reconnectDelay=1500,this.sourceArr=[],this.params=e,this.callbacks=n,t.length&&this.joinRoom(t)}close(){clearInterval(this.pingTimer),this.sourceArr?.forEach((e=>{e.cancel()})),this.sourceArr=[],this.socket?.close(),this.socket=null}sendMessage(e){this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.send(e)}startHeartbeat(){this.pingTimer=setInterval((()=>{this.socket?.readyState!==WebSocket.OPEN?clearInterval(this.pingTimer):this.socket.send(JSON.stringify({event:"ping"}))}),5e3)}initSocket(e,t){const{isWsProxy:n}=this.params;let r=`${"https:"===location.protocol?"wss":"ws"}://${location.host}/sdk-ws/${t}`;n||(r=`${e}/${t}`),this.socket=new WebSocket(r),this.socket.onopen=()=>{this.reconnectAttempts=0,this.startHeartbeat()},this.socket.onerror=n=>{this.callbacks?.onGroupControlError({code:n.code||"WS_ERROR",msg:n.message||"WebSocket 连接出错"}),this.handleReconnect(e,t)}}handleReconnect(e,t){this.reconnectAttempts<this.maxReconnectAttempts?setTimeout((()=>{this.reconnectAttempts++,console.log(`正在尝试第 ${this.reconnectAttempts} 次重连...`),this.initSocket(e,t)}),this.reconnectDelay):(console.log("达到最大重连次数,停止重连。"),this.callbacks?.onGroupControlError({code:"MAX_RECONNECT_ATTEMPTS",msg:"达到最大重连次数,无法连接到服务器。"}))}joinRoom(e){const t=_n.CancelToken.source();this.sourceArr.push(t);const{userId:n,videoStream:r,uuid:i,token:o,manageToken:s}=this.params,a=s?"/manage/rtc/room/share/applyToken":"/sdk/rtc/open/room/sdk/share/applyToken",c=s||o;_n.post(a,{userId:n,uuid:i,terminal:"h5",pushPublicStream:!1,pads:e.map((e=>({padCode:e,videoStream:{resolution:7,frameRate:5,bitrate:13},userId:n})))},{headers:s?{Authorization:c}:{token:c},cancelToken:t.token}).then((e=>{const{signalServer:t,roomToken:n}=e?.data?.data;this.socket||this.initSocket(t,n)})).catch((e=>{if(_n.isCancel(e))return;const t=new Error("加入房间出错");t.code="JOIN_ROOM_ERR",this.callbacks?.onGroupControlError({code:t.code,msg:t.message})}))}}class p8{constructor(e,t){this.masterIdPrefix=e,this.remoteUserId=t,this.eventListeners=[],this.videoDomId=`${this.masterIdPrefix}_${this.remoteUserId}_armcloudVideo`,this.remoteVideoId=`${this.masterIdPrefix}_${this.remoteUserId}_remoteVideo`,this.containerId=`${this.masterIdPrefix}_${this.remoteUserId}_remoteVideoContainer`,this.remoteVideo=this.createRemoteVideoElement()}getVideoDomId(){return this.videoDomId}getRemoteVideoId(){return this.remoteVideoId}getContainerId(){return this.containerId}getRemoteVideo(){return this.remoteVideo}createElements(){const e=this.createDivElement(this.videoDomId),t=this.createDiv("100%","100%","relative","hidden"),n=this.createDiv("100%","100%","absolute","hidden",this.containerId);return n.appendChild(this.remoteVideo),t.appendChild(n),e.appendChild(t),e}createRemoteVideoElement(){const e=document.createElement("video");return e.setAttribute("id",this.remoteVideoId),e.setAttribute("playsinline",""),e.setAttribute("webkit-playsinline",""),e.setAttribute("x5-playsinline",""),e.setAttribute("x5-video-player-type","h5"),e.controls=!1,e.muted=!0,e.style.width="100%",e.style.height="100%",e.style.objectFit="contain",e.style.transform="scale(1)",e}bindDomEvent(e,t){const n=document.getElementById(this.videoDomId);if(n){const r=n=>{"wheel"!==e&&n.preventDefault(),t(n)};n.addEventListener(e,r),this.eventListeners.push({type:e,listener:r,element:n})}}removeAllEvents(){this.eventListeners.forEach((({type:e,listener:t,element:n})=>{n.removeEventListener(e,t)})),this.eventListeners=[]}createDivElement(e){const t=document.createElement("div");return t.setAttribute("id",e),t}createDiv(e,t,n,r,i){const o=document.createElement("div");return o.style.width=e,o.style.height=t,o.style.position=n,o.style.overflow=r,i&&o.setAttribute("id",i),o}destroy(){this.removeAllEvents();const e=document.getElementById(this.videoDomId);e&&e.parentNode&&e.parentNode.removeChild(e),this.remoteVideo=null,this.eventListeners=[]}}class f8{constructor(e,t,n){this.initDomId="",this.videoDomId="",this.remoteVideoContainerId="",this.remoteVideoId="",this.pingTimer=null,this.hasPushDown=!1,this.refreshUiMsgNumber=0,this.isVideoFirstFrame=!1,this.enableMicrophone=!0,this.enableCamera=!0,this.videoDeviceId="",this.audioDeviceId="",this.isCameraInject=!1,this.isMicrophoneInject=!1,this.groupControlSync=!0,this.promiseMap={streamStatus:{resolve:()=>{},reject:()=>{}},injectStatus:{resolve:null,reject:null}},this.remoteResolution={width:0,height:0},this.roomMessage={inputStateIsOpen:!1,isVertical:!0},this.remotePc=null,this.autoRecoveryTimer=null,this.runInfoTimer=null,this.touchConfig={action:0,widthPixels:document.body.clientWidth,heightPixels:document.body.clientHeight,pointCount:1,touchType:x4.GESTURE,properties:[],coords:[]},this.touchInfo=G4(),this.enterkeyhintObj={2:"go",3:"search",4:"send",5:"next",6:"done",7:"previous"},this.callbacks={},this.videoStreams=[],this.audioStreams=[],this.videoSenders=[],this.audioSenders=[],this.senderVideoTracks=[],this.senderAudioTracks=[],this.isGroupControl=!1,this.groupRtc=null,this.groupPads=[],this.masterIdPrefix="",this.stopOperation=!1,this.initDomId=e,this.options=t;const r=["onAutoRecoveryTime"];n&&Object.keys(n).forEach((e=>{const t=n[e];this.callbacks[e]=(...n)=>{this.stopOperation&&!r.includes(e)||t?.(...n)}})),this.enableMicrophone=t.enableMicrophone,this.enableCamera=t.enableCamera,this.remoteUserId=t.padCode,this.retryCount=t.retryCount,this.retryCountBackup=t.retryCount,this.retryTime=t.retryTime,this.masterIdPrefix=t.masterIdPrefix,this.videoDeviceId=t.videoDeviceId||"",this.audioDeviceId=t.audioDeviceId||"";const i=document.getElementById(this.initDomId);this.videoElement=new p8(this.masterIdPrefix,this.remoteUserId),this.videoDomId=this.videoElement?.getVideoDomId(),this.remoteVideoContainerId=this.videoElement?.getContainerId(),this.remoteVideoId=this.videoElement?.getRemoteVideoId();const o=this.videoElement?.createElements();i?.appendChild(o),this.options.disable||q4(this,!0);const s=this.decryptAES(this.options.signalServer,this.options.padCode),{isWsProxy:a}=this.options;let c=`${"https:"===location.protocol?"wss":"ws"}://${location.host}/sdk-ws/${this.options.roomToken}`;a||(c=`${s}/${this.options.roomToken}`);const u=this.decryptAES(this.options.stuns,this.options.padCode),d=JSON.parse(u),l=this.decryptAES(this.options.turns,this.options.padCode),h=JSON.parse(l),p={iceServers:[{urls:[d?.[0]?.uri]},{urls:[h[0].uri],username:h[0].username,credential:h[0].pwd}]},f=document.createElement("audio");f.id=`${this.masterIdPrefix}_${this.remoteUserId}_remoteAudio`,f.style.display="none",f.setAttribute("playsinline",""),f.setAttribute("webkit-playsinline",""),f.setAttribute("x5-playsinline",""),f.setAttribute("x5-video-player-type","h5"),i?.appendChild(f),this.socketParams={wsUrl:c,rtcConfig:p,remoteVideo:this.videoElement?.getRemoteVideo(),remoteAudio:f},this.remotePc=new RTCPeerConnection(this.socketParams.rtcConfig)}decryptAES(e,t){try{const n=L6.enc.Base64.parse(e),r=L6.format.Hex.parse(n.toString());let i=t.padEnd(16,"0");i.length>16&&(i=i.slice(0,16));const o=L6.enc.Utf8.parse(i),s=L6.AES.decrypt(r,o,{mode:L6.mode.ECB,padding:L6.pad.Pkcs7});return L6.enc.Utf8.stringify(s)}catch(e){return null}}getMsgTemplate(e,t){return JSON.stringify({touchType:e,content:JSON.stringify(t)})}getEquipmentInfo(e){this.stopOperation||this.sendUserMessage(this.getMsgTemplate(x4.EQUIPMENT_INFO,{type:e}))}toggleGroupControlSync(e=!0){this.isGroupControl&&(this.groupControlSync=e)}appUnInstall(e){this.stopOperation||this.sendUserMessage(this.getMsgTemplate(x4.APP_UNINSTALL,e))}triggerKeyboardShortcut(e,t,n=!0){const r=JSON.stringify({touchType:D4.SHORTCUT_KEY,metaState:e+"",keyCode:t+""});this.sendUserMessage(r,n)}setScreenshotRotation(e=0){}takeScreenshot(e=0){this.screenShotInstance?.takeScreenshot(e)}resizeScreenshot(e,t){this.screenShotInstance?.resizeScreenshot(e,t)}showScreenShot(){this.screenShotInstance?.showScreenShot()}hideScreenShot(){this.screenShotInstance?.hideScreenShot()}clearScreenShot(){this.screenShotInstance?.clearScreenShot()}setViewSize(e,t,n=0){const r=document.getElementById(this.videoDomId),i=document.getElementById(this.remoteVideoContainerId),o=document.getElementById(this.remoteVideoId);if(r&&o){const s=(e,t,n)=>{e.style.width=t+"px",e.style.height=n+"px"};if(s(r,e,t),s(i,e,t),1==n)return void s(o,t,e);s(o,e,t)}}async getMediaStream(e,t){const n={video:!1,audio:!1};return e===U4.VIDEO?n.video=!this.videoDeviceId||{deviceId:{exact:this.videoDeviceId||(t?.isFront?"user":"environment")}}:n.audio=!this.audioDeviceId||{deviceId:{exact:this.audioDeviceId}},await navigator.mediaDevices.getUserMedia(n)}async setVideoDeviceId(e){if(!this.stopOperation&&(this.videoDeviceId=e,this.isCameraInject))try{await this.smoothTrackReplace(U4.VIDEO)}catch(e){throw e}}async setAudioDeviceId(e){if(!this.stopOperation&&(this.audioDeviceId=e,this.isMicrophoneInject))try{await this.smoothTrackReplace(U4.AUDIO)}catch(e){throw e}}async captureVideo(e){if(!this.stopOperation)try{if(this.videoSenders.length)return void await this.smoothTrackReplace(U4.VIDEO,e);const t=await this.getMediaStream(U4.VIDEO,e);this.videoStreams.push(t);const n=t.getVideoTracks()[0];this.senderVideoTracks.push(n),this.videoSenders.push(this.remotePc.addTrack(n,t)),this.callbacks?.onVideoInit()}catch(e){throw this.callbacks.onVideoError({code:V6,msg:e?.message||e?.name||String(e)}),e}}getRotateType(){return this.options.rotateType}async captureAudio(){if(!this.stopOperation)try{if(this.audioSenders.length)return void await this.smoothTrackReplace(U4.AUDIO);const e=await this.getMediaStream(U4.AUDIO);this.audioStreams.push(e);const t=e.getAudioTracks()[0];this.senderAudioTracks.push(t),this.audioSenders.push(this.remotePc.addTrack(t,e)),this.callbacks.onAudioInit()}catch(e){throw this.callbacks.onAudioError({code:V6,msg:e?.message||e?.name||String(e)}),e}}stopTracksAndStreams(e){const t=e===U4.VIDEO?this.senderVideoTracks:this.senderAudioTracks,n=e===U4.VIDEO?this.videoStreams:this.audioStreams;if(t.length)try{t.forEach((e=>{e.stop()}))}catch(t){console.log(`停止${e}轨道失败: ${t.message}`,"error")}n.length&&n.forEach((e=>{e.getTracks().forEach((e=>{try{e.stop()}catch(e){console.log(`停止流轨道失败: ${e.message}`,"error")}}))})),e===U4.VIDEO?(this.senderVideoTracks=[],this.videoStreams=[]):(this.senderAudioTracks=[],this.audioStreams=[])}async smoothTrackReplace(e,t){const n=e===U4.VIDEO?this.videoSenders:this.audioSenders,r=e===U4.VIDEO?this.senderVideoTracks:this.senderAudioTracks,i=e===U4.VIDEO?this.videoStreams:this.audioStreams,o=await this.getMediaStream(e,t),s=e===U4.VIDEO?o.getVideoTracks()[0]:o.getAudioTracks()[0],a=n.filter((e=>!!e.transport||(this.remotePc.removeTrack(e),!1)));a.forEach((e=>e.replaceTrack(s))),console.log(`${e}轨道已平滑切换`),r.forEach((e=>e.stop())),i.forEach((e=>e.getTracks().forEach((e=>e.stop())))),e===U4.VIDEO?(this.videoSenders=a,this.senderVideoTracks=[s],this.videoStreams=[o]):(this.audioSenders=a,this.senderAudioTracks=[s],this.audioStreams=[o])}startHeartbeat(){this.pingTimer=setInterval((()=>{this.socket?.readyState!==WebSocket.OPEN?clearInterval(this.pingTimer):this.socket.send(JSON.stringify({event:P4.PING}))}),5e3)}async microphoneInject(){try{await this.stopMediaStream(O4.AUDIO),await this.startMediaStream(O4.AUDIO),this.callbacks.onAudioInit()}catch(e){throw this.callbacks.onAudioError(e),e}}async cameraInject(e){try{await this.stopMediaStream(O4.VIDEO),await this.startMediaStream(O4.VIDEO,e),this.callbacks.onVideoInit()}catch(e){throw this.callbacks.onVideoError(e),e}}async startMediaStream(e,t){if(!this.stopOperation)try{e===O4.VIDEO&&(await this.notifyInject(M4.INJECTION_CAMERA,!0),await this.captureVideo(t),this.isCameraInject=!0),e===O4.AUDIO&&(await this.notifyInject(M4.INJECTION_AUDIO,!0),await this.captureAudio(),this.isMicrophoneInject=!0),e===O4.AUDIO_AND_VIDEO&&(await this.notifyInject(M4.INJECTION_AUDIO,!0),await this.notifyInject(M4.INJECTION_CAMERA,!0),await this.captureVideo(t),this.isCameraInject=!0,await this.captureAudio(),this.isMicrophoneInject=!0)}catch(e){throw e}}async notifyInject(e,t){await this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:e,isOpen:t}),!0)}setScreenResolution(e,t=!0){const n=e.type===D4.UPDATE_DENSITY?{type:e.type,width:e.width,height:e.height,density:e.dpi}:{type:e.type},r=this.getMsgTemplate(x4.EVENT_SDK,n);this.sendUserMessage(r,t)}triggerClickEvent(e,t=!1){}triggerPointerEvent(e,t,n=!1){}async stopMediaStream(e){if(!this.stopOperation)try{e===O4.VIDEO&&(await this.notifyInject(M4.INJECTION_CAMERA,!1),await this.stopTracksAndStreams(U4.VIDEO),this.isCameraInject=!1),e===O4.AUDIO&&(await this.notifyInject(M4.INJECTION_AUDIO,!1),await this.stopTracksAndStreams(U4.AUDIO),this.isMicrophoneInject=!1),e===O4.AUDIO_AND_VIDEO&&(await this.notifyInject(M4.INJECTION_CAMERA,!1),await this.notifyInject(M4.INJECTION_AUDIO,!1),await this.stopTracksAndStreams(U4.VIDEO),this.isCameraInject=!1,await this.stopTracksAndStreams(U4.AUDIO),this.isMicrophoneInject=!1)}catch(e){throw e}}setupWebSocket(){let e=!1;const t=[];this.callbacks.onProgress(H6),this.socket=new WebSocket(this.socketParams?.wsUrl),this.socket.onopen=()=>{this.retryCount=this.retryCountBackup,this.callbacks.onSocketCallback({code:U6}),this.callbacks.onProgress(W6),this.isGroupControl&&this.createWebGroupRtc(this.groupPads),this.startHeartbeat(),this.setupPeerConnectionEvents(),this.setupDataChannelEvents(),this.setupTouchEvents()},this.socket.onclose=e=>{console.log("WebSocket closed. Code: ",e.code," Reason: ",e.reason),this.retryCount===this.retryCountBackup&&(this.callbacks.onSocketCallback({code:F6}),this.callbacks.onProgress(K6))},this.socket.onerror=e=>{this.retryCount--,this.retryCount>0?(setTimeout((()=>{this.setupWebSocket()}),this.retryTime),this.callbacks.onProgress(q6)):(this.callbacks.onSocketCallback({code:V6}),this.callbacks.onProgress(z6),this.stopOperations())};const n=e=>{this.remotePc?.addIceCandidate({candidate:e.candidate,sdpMLiineIndex:e.label,sdpMid:e.id}).then((()=>{this.callbacks.onProgress(Z6)})).catch((e=>{this.callbacks.onProgress(e8)}))};this.socket.onmessage=async r=>{const i=JSON.parse(r.data);if(i.event===P4.SPECIFIED_MSG){const r=JSON.parse(i.data);if(r.key===D4.RE_ANSWER){const e=JSON.parse(r.value)?.sdp;this.receiveAnswer(e)}if(r.key===D4.OFFER){const i=JSON.parse(r.value);await this.receiveOffer(i.sdp),await this.sendAnswer(),e=!0;for(const e of t)n(e)}if(r.key===D4.ICE_CANDIDATE){const i=JSON.parse(r.value);e?n(i):t.push(i)}}else i.event===P4.OWN_JOIN_ROOM&&this.callbacks.onProgress(J6)}}muted(){this.stopOperation||this.handleMediaPlay(O4.AUDIO,!1)}unmuted(){if(this.stopOperation)return;const e=Number(this.options.mediaType),{remoteAudio:t}=this.socketParams;this.handleMediaPlay(O4.AUDIO,!0),e===O4.VIDEO&&(t.muted=!1,t.play())}startPlay(){if(this.stopOperation)return;const e=Number(this.options.mediaType),{remoteVideo:t,remoteAudio:n}=this.socketParams;[G6.AUDIO_VIDEO,G6.VIDEO_ONLY].includes(e)&&t.play(),[G6.AUDIO_ONLY,G6.AUDIO_VIDEO].includes(e)&&(n.play(),n.muted=!1)}sendGroupMag(e){this.groupRtc?.sendMessage(JSON.stringify({event:P4.BROADCAST_MSG,data:e}))}kickItOutRoom(e){this.stopOperation||this.groupRtc?.sendMessage(JSON.stringify({event:P4.BROADCAST_MSG,data:JSON.stringify({touchType:x4.KICK_OUT_USER,content:JSON.stringify(e)})}))}joinGroupRoom(e){if(this.stopOperation)return;const t=e?.filter((e=>e!==this.remoteUserId));t.length&&this.groupRtc?.joinRoom(t)}createWebGroupRtc(e){const t=e?.filter((e=>e!==this.remoteUserId));this.groupRtc=new h8(this.options,t,this.callbacks)}handleVideoWheel(e){this.videoElement.bindDomEvent("wheel",(t=>{if(this.options.disable)return;let{offsetX:n,offsetY:r,deltaY:i}=t;const o={coords:[{pressure:1,size:1,x:n,y:r}],widthPixels:e.clientWidth,heightPixels:e.clientHeight,pointCount:1,properties:[{id:0,toolType:1}],touchType:x4.GESTURE_SWIPE,swipe:i>0?-1:1},s=JSON.stringify(o);this.sendUserMessage(s)}))}handleVideoMouseleave(){this.videoElement.bindDomEvent("mouseleave",(e=>{if(this.options.disable)return;if(!this.hasPushDown)return;this.touchConfig.action=1;const t=JSON.stringify(this.touchConfig);this.sendUserMessage(t)}))}handleVideoMousedown(e,t,n){this.videoElement.bindDomEvent(e,(e=>{if(this.options.disable)return;this.hasPushDown=!0;const{allowLocalIMEInCloud:r,keyboard:i}=this.options,{inputStateIsOpen:o}=this.roomMessage,s=r&&"pad"===i||"local"===i;this.inputElement&&s&&"boolean"==typeof o&&(o?this.inputElement.focus():this.inputElement.blur()),this.touchInfo=G4();const a=n.getBoundingClientRect(),c=a.top,u=a.left;this.touchConfig.properties=[],this.touchConfig.coords=[];const d=t?e?.touches?.length:1;this.touchConfig.action=0,this.touchConfig.pointCount=d;const l=n.clientWidth>n.clientHeight?n.clientWidth:n.clientHeight,h=n.clientWidth>n.clientHeight?n.clientHeight:n.clientWidth;this.touchConfig.widthPixels=1==this.options.rotateType?l:h,this.touchConfig.heightPixels=1==this.options.rotateType?h:l,1==this.options.rotateType&&this.remoteResolution.height>this.remoteResolution.width?(this.touchConfig.widthPixels=h,this.touchConfig.heightPixels=l):0==this.options.rotateType&&this.remoteResolution.width>this.remoteResolution.height&&(this.touchConfig.widthPixels=l,this.touchConfig.heightPixels=h);for(let n=0;n<d;n+=1){const r=t?e.touches[n]:e;this.touchConfig.properties[n]={id:n,toolType:1};let i=r.offsetX,o=r.offsetY;null==i&&(i=r.clientX-u,o=r.clientY-c,1==this.options.rotateType&&this.remoteResolution.height>this.remoteResolution.width?(i=a.bottom-r.clientY,o=r.clientX-u):0==this.options.rotateType&&this.remoteResolution.width>this.remoteResolution.height&&(i=r.clientY-c,o=a.right-r.clientX)),this.touchConfig.coords.push({...this.touchInfo,orientation:.01*Math.random(),x:i,y:o})}const p={action:d>1?261:0,widthPixels:this.touchConfig.widthPixels,heightPixels:this.touchConfig.heightPixels,pointCount:d,touchType:x4.GESTURE,properties:this.touchConfig.properties,coords:this.touchConfig.coords},f=JSON.stringify(p);this.sendUserMessage(f)}))}handleVideoMousemove(e,t,n){this.videoElement.bindDomEvent(e,(e=>{if(this.options.disable)return;if(!this.hasPushDown)return;const r=n.getBoundingClientRect(),i=r.top,o=r.left,s=t?e?.touches?.length:1;this.touchConfig.action=2,this.touchConfig.pointCount=s,this.touchConfig.coords=[];const a=[];for(let n=0;n<s;n+=1){const s=t?e.touches[n]:e;this.touchConfig.properties[n]={id:n,toolType:1};let c=s.offsetX,u=s.offsetY;null==c&&(c=s.clientX-o,u=s.clientY-i,1==this.options.rotateType&&this.remoteResolution.height>this.remoteResolution.width?(c=r.bottom-s.clientY,u=s.clientX-o):0==this.options.rotateType&&this.remoteResolution.width>this.remoteResolution.height&&(c=s.clientY-i,u=r.right-s.clientX)),a.push({...this.touchInfo,orientation:.01*Math.random(),x:c,y:u})}this.touchConfig.coords=a;const c={action:2,widthPixels:this.touchConfig.widthPixels,heightPixels:this.touchConfig.heightPixels,pointCount:s,touchType:x4.GESTURE,properties:this.touchConfig.properties,coords:this.touchConfig.coords},u=JSON.stringify(c);this.sendUserMessage(u)}))}handleVideoMouseup(e,t){this.videoElement.bindDomEvent(e,(e=>{if(!this.options.disable&&(this.hasPushDown=!1,this.touchConfig.action=1,!t||t&&0===e.touches.length)){const e=JSON.stringify(this.touchConfig);this.sendUserMessage(e)}}))}start(e=!1,t=[]){this.stopOperation||(this.isGroupControl=e,this.groupPads=t,this.setupWebSocket())}setupPeerConnectionEvents(){this.remotePc.addEventListener("icecandidate",(e=>{if(e.candidate){const t={event:P4.SPECIFIED_MSG,targetUserIds:[this.remoteUserId],data:JSON.stringify({key:D4.ICE_CANDIDATE,value:JSON.stringify({candidate:e.candidate?.candidate,label:e.candidate.sdpMLineIndex,id:e.candidate.sdpMid})})},n=JSON.stringify(t);this.socket.send(n),this.callbacks.onProgress(t8)}})),this.remotePc.addEventListener("track",(e=>{const{remoteVideo:t,remoteAudio:n}=this.socketParams,r=Number(this.options.mediaType);switch(e?.track?.kind){case"video":const i=new MediaStream([e?.track]);t.srcObject=i,t.addEventListener("loadeddata",(e=>{t.play().catch((e=>{console.error("播放失败:",e),this.callbacks.onAutoplayFailed({userId:this.options.userId,kind:"video"})})),this.isVideoFirstFrame=!0,this.refreshUiMsgNumber>0&&this.renderedFirstFrame()})),this.callbacks.onProgress(a8);break;case"audio":const o=new MediaStream([e?.track]);n.srcObject=o,n.addEventListener("loadeddata",(e=>{const t=[G6.AUDIO_ONLY,G6.AUDIO_VIDEO].includes(r);n.muted=!t,t&&n.play().catch((e=>{console.error("播放失败:",e),this.callbacks.onAutoplayFailed({userId:this.options.userId,kind:"audio"})}))}))}})),this.remotePc.addEventListener("connectionstatechange",(e=>{switch(this.remotePc.connectionState){case"new":case"connecting":this.callbacks.onProgress(n8);break;case"connected":this.triggerRecoveryTimeCallback(),this.callbacks.onConnectSuccess(),this.callbacks.onProgress(r8);break;case"disconnected":console.log("disconnected",this.remoteUserId),this.callbacks.onConnectFail({code:V6,msg:"云机连接断开"}),this.callbacks.onProgress(i8),this.stopOperations();break;case"closed":console.log("rtc closed"),this.callbacks.onProgress(o8),this.stopOperations();break;case"failed":console.log("failed",this.remoteUserId),this.callbacks.onConnectFail({code:V6,msg:"云机连接失败"}),this.callbacks.onProgress(s8),this.stopOperations()}}))}setupDataChannelEvents(){this.dataChannel=this.remotePc.createDataChannel("dataChannel"),this.dataChannel.addEventListener("open",(()=>{if(this.handleMediaPlay(this.options.mediaType,!0),this.remotePc){if(this.runInfoTimer&&(clearInterval(this.runInfoTimer),this.runInfoTimer=null),this.stopOperation)return;this.runInfoTimer=setInterval((()=>{this.getStats()}),2e3)}this.onCheckInputState(),this.setKeyboardStyle(this.options.keyboard),this.getCameraState();const e={touchType:x4.EVENT_SDK,content:JSON.stringify({type:M4.UPDATE_UI_H5})},t=JSON.stringify(e);this.sendUserMessage(t),this.callbacks.onProgress(c8)})),this.dataChannel.addEventListener("error",(e=>{console.error("dataChannel error: ",e.errorDetail,e.message,e),clearInterval(this.runInfoTimer),this.callbacks.onErrorMessage({code:j6,msg:e.message||e.name}),this.callbacks.onProgress(u8),this.stopOperations()})),this.onRoomMessageReceived()}setupTouchEvents(){const e=document.getElementById(this.videoDomId),t=W4()||H4();let n="touchstart",r="touchmove",i="touchend";t||(n="mousedown",r="mousemove",i="mouseup"),this.handleVideoWheel(e),this.handleVideoMousedown(n,t,e),this.handleVideoMousemove(r,t,e),this.handleVideoMouseup(i,t),this.handleVideoMouseleave()}async sendOffer(){try{const e=await this.remotePc.createOffer();await this.remotePc.setLocalDescription(e);const t={event:P4.SPECIFIED_MSG,targetUserIds:[this.remoteUserId],data:JSON.stringify({key:D4.RE_OFFER,value:JSON.stringify({sdp:e.sdp})})},n=JSON.stringify(t);this.socket.send(n)}catch(e){console.error("发送webrtc offer失败:",e)}}async receiveOffer(e){const t={type:D4.OFFER,sdp:e};try{await this.remotePc.setRemoteDescription(t),this.callbacks.onProgress(Y6)}catch(e){console.error("接收webrtc offer失败:",e),this.callbacks.onProgress(X6)}}getInjectStreamStatus(e,t=0){return new Promise((n=>{let r=null;0!==t&&(r=setTimeout((()=>{n({status:"unknown",type:e})}),t));(()=>{switch(e){case"video":try{Object.assign(this.promiseMap.streamStatus,{resolve:e=>{r&&clearTimeout(r),n(e)}}),this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:D4.INJECTION_VIDEO_STATS}),!0)}catch(t){r&&clearTimeout(r),n({status:"unknown",type:e})}break;case"camera":r&&clearTimeout(r),n({status:this.isCameraInject?"live":"offline",type:e});break;case"audio":r&&clearTimeout(r),n({status:this.isMicrophoneInject?"live":"offline",type:e})}})()}))}injectVideoStream(e,t,n=0,r=!0){return new Promise((async i=>{let o=null;n&&(o=setTimeout((()=>{i({type:e,status:"timeout",result:null})}),n));try{Object.assign(this.promiseMap.injectStatus,{resolve:e=>{o&&clearTimeout(o),i(e)}});const n=this.getMsgTemplate(x4.EVENT_SDK,e===D4.START_INJECTION_VIDEO?{type:e,fileUrl:t?.fileUrl,isLoop:t?.isLoop??!0,fileName:t?.fileName}:{type:e});await this.sendUserMessage(n,r)}catch{i({type:e,status:"unknown",result:null})}}))}getCameraState(){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.GET_CAMERA_STATE}))}async receiveAnswer(e){try{const t={type:D4.ANSWER,sdp:e};await this.remotePc.setRemoteDescription(t)}catch(e){throw console.log("接收remote answer失败:",e),e}}negotiateOffer(){let e=!1,t=!1;const n=async()=>{if(!e){e=!0;try{for(;t&&(t=!1,"stable"===this.remotePc.signalingState);)await this.sendOffer()}catch(e){console.error("negotiateOffer error:",e)}finally{e=!1}}};this.remotePc.addEventListener("negotiationneeded",(()=>{t=!0,n()}))}async sendAnswer(){try{const e=await this.remotePc.createAnswer();await this.remotePc.setLocalDescription(e);const t={event:P4.SPECIFIED_MSG,targetUserIds:[this.remoteUserId],data:JSON.stringify({key:D4.RE_ANSWER,value:JSON.stringify({sdp:e.sdp})})},n=JSON.stringify(t);this.socket.send(n),this.callbacks.onProgress($6),this.negotiateOffer()}catch(e){console.error("发送webrtc answer失败:",e),this.callbacks.onProgress(Q6)}}renderedFirstFrame(){this.stopOperation||(this.callbacks.onRenderedFirstFrame(),this.callbacks.onProgress(l8))}subscribeStream(e){return new Promise((t=>{this.handleMediaPlay(e,!0),t()}))}executeAdbCommand(e){this.options.clientId;const t=JSON.stringify({touchType:x4.EVENT_SDK,content:JSON.stringify({type:M4.INPUT_ADB,content:e})});this.sendUserMessage(t,!1)}async unsubscribeStream(e){return this.handleMediaPlay(e,!1),Promise.resolve()}handleMediaPlay(e,t){switch(Number(e)){case O4.AUDIO:this.sendUserMessage(this.handleSendData({type:L4.OPEN_AUDIO,isOpen:t}));break;case O4.VIDEO:this.sendUserMessage(this.handleSendData({type:L4.OPEN_VIDEO,isOpen:t}));break;case O4.AUDIO_AND_VIDEO:this.sendUserMessage(this.handleSendData({type:L4.OPEN_AUDIO_AND_VIDEO,isOpen:t}))}}waitForFirstFrameRendered(e){this.stopOperation||(e.currentTime>0?this.isVideoFirstFrame&&this.refreshUiMsgNumber<=0&&this.callbacks.onProgress(d8):!this.stopOperation&&requestAnimationFrame((()=>{this.waitForFirstFrameRendered(e)})))}stopOperations(){this.stopOperation=!0,clearTimeout(this.autoRecoveryTimer),clearInterval(this.runInfoTimer),clearInterval(this.pingTimer),this.autoRecoveryTimer=null,this.runInfoTimer=null,this.pingTimer=null,this.videoElement?.removeAllEvents()}close(){this.stopOperations(),this.remotePc&&(this.remotePc?.getSenders()?.forEach((e=>this.remotePc.removeTrack(e))),this.remotePc?.close(),this.dataChannel?.close(),this.remotePc=null,this.dataChannel=null,this.stopTracksAndStreams(U4.VIDEO),this.stopTracksAndStreams(U4.AUDIO),this.videoSenders=null,this.audioSenders=null,this.senderVideoTracks=null,this.senderAudioTracks=null,this.videoStreams=null,this.audioStreams=null,this.remotePc?.close()),this.socket?.close(),this.groupRtc?.close(),this.groupRtc=null,this.socket=null}destroy(){this.close(),this.inputElement?.remove(),this.videoElement?.destroy(),this.socketParams?.remoteVideo?.remove(),this.socketParams?.remoteAudio?.remove(),this.screenShotInstance?.destroy(),this.screenShotInstance=null,this.videoElement=null,this.socketParams=null}stop(){this.destroy()}async getStats(){try{const e=await(this.remotePc?.getStats());let t="0";e.forEach((e=>{if("candidate-pair"===e.type&&"succeeded"===e.state){const n=e.currentRoundTripTime||0;t=(1e3*n).toFixed(2)}}));const n={userId:this.options.userId,audioStats:null,videoStats:{rtt:t,statsInterval:2e3}};this.callbacks.onRunInformation(n)}catch(e){console.error("获取统计信息时出错:",e),this.callbacks.onErrorMessage({code:B6,msg:e.message||e.name})}}isSupported(){const e={RTCPeerConnection:"undefined"!=typeof RTCPeerConnection,RTCDataChannel:"undefined"!=typeof RTCDataChannel};return e.RTCPeerConnection&&e.RTCDataChannel}triggerRecoveryTimeCallback(){this.options.disable||!this.options.autoRecoveryTime||this.isCameraInject||this.isMicrophoneInject||(this.autoRecoveryTimer&&(clearTimeout(this.autoRecoveryTimer),this.autoRecoveryTimer=null),this.stopOperation||(this.autoRecoveryTimer=setTimeout((()=>{this.destroy(),this.callbacks.onAutoRecoveryTime()}),1e3*this.options.autoRecoveryTime)))}async sendUserMessage(e,t=!1){this.stopOperation||(!t&&this.groupControlSync&&(this.sendGroupMag(e),this.triggerRecoveryTimeCallback()),this.dataChannel&&await(this.dataChannel?.send(e)))}setMicrophone(e){this.stopOperation||(this.enableMicrophone=e)}setCamera(e){this.stopOperation||(this.enableCamera=e)}setMonitorOperation(e,t=!0){}onRoomMessageReceived(){const e=e=>{const[t,n]=e?.split("*").map(Number);return{width:t,height:n}};this.remotePc.addEventListener("datachannel",(t=>{const n=t.channel,r=async t=>{const n=JSON.parse(t||"{}");if([D4.VIDEO_AND_AUDIO_CONTROL].includes(n.key)){const e=JSON.parse(n.data)||{};if(console.log("VIDEO_AND_AUDIO_CONTROL",n),this.callbacks.onMediaDevicesToggle({type:"media",enabled:e.isOpen,isFront:e.isFront}),!this.enableMicrophone&&!this.enableCamera)return;const t=this.enableMicrophone&&this.enableCamera?O4.AUDIO_AND_VIDEO:this.enableCamera?O4.VIDEO:O4.AUDIO;e.isOpen?this.enableCamera&&this.enableMicrophone?await Promise.allSettled([this.cameraInject(e),this.microphoneInject()]):this.enableCamera?await this.cameraInject(e):this.enableMicrophone&&await this.microphoneInject():await this.stopMediaStream(t)}if([D4.AUDIO_CONTROL].includes(n.key)){const{isOpen:e}=JSON.parse(n.data)||{};console.log("AUDIO_CONTROL",n),e?await this.microphoneInject():await this.stopMediaStream(O4.AUDIO)}if(n.key===D4.MESSAGE&&this.callbacks.onTransparentMsg(0,n.data),n.key===D4.INPUT_ADB&&this.callbacks?.onAdbOutput(JSON.parse(n.data||{})),n.key===D4.EQUIPMENT_INFO&&this.callbacks?.onEquipmentInfo(JSON.parse(n.data||[])),n.key===D4.CALL_BACK_EVENT){const t=JSON.parse(n.data),r=JSON.parse(t.data);switch(t.type){case D4.DEFINITION:this.callbacks.onChangeResolution({from:e(r.from),to:e(r.to)});break;case D4.STOP_INJECTION_VIDEO:case D4.START_INJECTION_VIDEO:const{resolve:n}=this.promiseMap.injectStatus;n&&(n({type:t.type,status:r?.isSuccess?"success":"error",result:r}),this.promiseMap.injectStatus.resolve=null),this.callbacks?.onInjectVideoResult(t.type,r);break;case D4.INJECTION_VIDEO_STATS:const{resolve:i}=this.promiseMap.streamStatus;i({path:r.path,status:r.status||(r.path?"live":"offline"),type:"video"})}}if(n.key===D4.REFRESH_UI_TYPE){const e=JSON.parse(n.data);if(e.width==this.remoteResolution.width&&e.height==this.remoteResolution.height)return!1;this.isVideoFirstFrame&&this.refreshUiMsgNumber<=0&&this.callbacks.onProgress(d8),this.roomMessage.isVertical=e.isVertical,this.remoteResolution.width=e.width,this.remoteResolution.height=e.height,(W4()||H4())&&(this.options.rotateType=0);const{rotateType:t}=this.options;let r;r=0==t||1==t?t:e.width>e.height?1:0,this.rotateScreen(r),this.refreshUiMsgNumber++,this.isVideoFirstFrame&&this.renderedFirstFrame()}if(n.key===D4.INPUT_STATE&&this.inputElement){const e=JSON.parse(n.data);this.roomMessage.inputStateIsOpen=e.isOpen;const{allowLocalIMEInCloud:t,keyboard:r}=this.options,{inputStateIsOpen:i}=this.roomMessage,o=t&&"pad"===r||"local"===r,s=this.enterkeyhintObj[e.imeOptions];this.inputElement.setAttribute("enterkeyhint",s),console.log("inputStateIsOpen",i),this.inputElement&&o&&"boolean"==typeof i&&(i?this.inputElement.focus():this.inputElement.blur())}if(n.key===D4.CLIPBOARD&&this.options.saveCloudClipboard){const e=JSON.parse(n.data);this.callbacks.onOutputClipper(e)}};n.addEventListener("message",(e=>{if(e.data)switch((n=e.data)instanceof ArrayBuffer?"ArrayBuffer":n instanceof Blob?"Blob":"String"){case"ArrayBuffer":r((e=>{if("undefined"!=typeof TextDecoder)return new TextDecoder("utf-8").decode(e);return String.fromCharCode.apply(null,new Uint8Array(e))})(e.data));break;case"Blob":(t=e.data,new Promise(((e,n)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{n(new Error("Failed to read blob as text"))},r.readAsText(t)}))).then((e=>{r(e)}));break;default:r(e.data)}var t,n}))}))}async sendInputClipper(e){if(this.stopOperation)return;const t=JSON.stringify({text:e,touchType:x4.CLIPBOARD});await this.sendUserMessage(t)}sendGroupInputClipper(e,t){this.stopOperation||t?.map(((t,n)=>{const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.CLIPBOARD});this.groupRtc?.sendMessage(JSON.stringify({event:P4.BROADCAST_MSG,data:r}))}))}sendGroupInputString(e,t){t?.map(((t,n)=>{const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.INPUT_BOX});this.groupRtc?.sendMessage(JSON.stringify({event:P4.BROADCAST_MSG,data:r}))}))}async sendInputString(e){if(this.stopOperation)return;const t=JSON.stringify({text:e,touchType:x4.INPUT_BOX});await this.sendUserMessage(t)}sendShakeInfo(e){if(this.stopOperation)return;(new j4).startShakeSimulation(e,(e=>{const t=t=>JSON.stringify({coords:[],heightPixels:0,isOpenScreenFollowRotation:!1,keyCode:0,pointCount:0,properties:[],text:"",touchType:x4.EVENT_SDK,widthPixels:0,action:0,content:JSON.stringify({...e,type:M4.SDK_SENSOR,sensorType:t})});this.sendUserMessage(t(N4.GYROSCOPE)),this.sendUserMessage(t(N4.GRAVITY)),this.sendUserMessage(t(N4.ACCELERATION))}))}setStreamConfig(e){if(this.stopOperation)return;const t=/^[1-9]\d*$/;if(e.definitionId&&e.framerateId&&e.bitrateId){if(Object.values(e).every((e=>t.test(e)))&&e.definitionId>=7&&e.definitionId<=20&&e.framerateId>=1&&e.framerateId<=9&&e.bitrateId>=1&&e.bitrateId<=15){const t={type:M4.DEFINITION_UPDATE,definitionId:e.definitionId,framerateId:e.framerateId,bitrateId:e.bitrateId},n={touchType:x4.EVENT_SDK,content:JSON.stringify(t)},r=JSON.stringify(n);this.sendUserMessage(r)}}}handleSendData(e){const t={touchType:x4.EVENT_SDK,content:JSON.stringify(e)};return JSON.stringify(t)}pauseAllSubscribedStream(e=3){this.triggerRecoveryTimeCallback(),this.handleMediaPlay(e,!1)}resumeAllSubscribedStream(e=3){this.triggerRecoveryTimeCallback(),this.handleMediaPlay(e,!0)}saveScreenShotToLocal(){if(!this.stopOperation)return new Promise(((e,t)=>{try{const t=document.getElementById(this.remoteVideoId),n=document.createElement("canvas"),r=n.getContext("2d");n.width=t.videoWidth,n.height=t.videoHeight,r.drawImage(t,0,0,n.width,n.height);e(r.getImageData(0,0,n.width,n.height))}catch(e){t(e)}}))}saveScreenShotToRemote(){if(this.stopOperation)return;const e={type:M4.LOCAL_SCREENSHOT},t={touchType:x4.EVENT_SDK,content:JSON.stringify(e)},n=JSON.stringify(t);this.sendUserMessage(n)}setPhoneRotation(e){this.stopOperation||(this.triggerRecoveryTimeCallback(),this.rotateScreen(e))}async rotateScreen(e){this.options.rotateType=e;try{await(this.callbacks?.onBeforeRotate(e))}catch(e){}const t=document.getElementById(this.initDomId);let n=t?.clientWidth,r=t?.clientHeight,i=r,o=n;n>r&&(i=n,o=r),1==e?(n=i,r=o):(n=o,r=i),t.style.width=n+"px",t.style.height=r+"px";const s=this.remoteResolution.width>this.remoteResolution.height,a=document.getElementById(this.remoteVideoContainerId);let c=a.clientWidth,u=a.clientHeight,d=0,l=0,h=0,p=0,f=0;if(1==e){const e=s?this.remoteResolution.width:this.remoteResolution.height,t=s?this.remoteResolution.height:this.remoteResolution.width,i=Math.min(n/e,r/t);d=e*i,l=t*i,c=d,u=l,s?(h=0,p=0,f=0):(h=-90,p=(l-d)/2,f=(d-l)/2,c=l,u=d)}else{const e=s?this.remoteResolution.height:this.remoteResolution.width,t=s?this.remoteResolution.width:this.remoteResolution.height,i=Math.min(n/e,r/t);d=e*i,l=t*i,c=s?l:d,u=s?d:l,h=s?90:0,p=s?(l-d)/2:0,f=s?(d-l)/2:0}const v=document.getElementById(this.videoDomId);v.style.width=`${d}px`,v.style.height=`${l}px`,a.style.width=`${c}px`,a.style.height=`${u}px`,a.style.top=`${p}px`,a.style.left=`${f}px`,a.style.transform=`rotate(${h}deg)`,this.callbacks.onChangeRotate(e,{width:d,height:l})}setGPS(e,t){if(this.stopOperation)return;const n={latitude:t,longitude:e,time:(new Date).getTime()},r={type:M4.SDK_LOCATION,content:JSON.stringify(n)},i={touchType:x4.EVENT_SDK,content:JSON.stringify(r)},o=JSON.stringify(i);this.sendUserMessage(o)}setKeyboardStyle(e){if(this.stopOperation)return;const t={type:M4.KEYBOARD_TYPE,isLocalKeyBoard:"local"===e},n={touchType:x4.EVENT_SDK,content:JSON.stringify(t)},r=JSON.stringify(n);this.options.keyboard=e,this.sendUserMessage(r)}async onCheckInputState(){if(this.stopOperation)return;const e=JSON.stringify({touchType:x4.INPUT_STATE});this.sendUserMessage(e)}setAutoRecycleTime(e){this.stopOperation||(this.options.autoRecoveryTime=e,this.triggerRecoveryTimeCallback())}getAutoRecycleTime(){if(!this.stopOperation)return this.options.autoRecoveryTime}sendCommand(e){if(this.stopOperation)return;const t={back:4,home:3,menu:187}[e]??e,n={action:1,touchType:x4.KEYSTROKE,keyCode:t,text:""},r=JSON.stringify(n);this.options.clientId&&this.sendUserMessage(r)}goAppUpPage(){const e={action:1,touchType:x4.KEYSTROKE,keyCode:4,text:""},t=this.options.clientId,n=JSON.stringify(e);t&&this.sendUserMessage(n)}goAppHome(){const e={action:1,touchType:x4.KEYSTROKE,keyCode:3,text:""},t=this.options.clientId,n=JSON.stringify(e);t&&this.sendUserMessage(n)}goAppMenu(){const e={action:1,touchType:x4.KEYSTROKE,keyCode:187,text:""},t=this.options.clientId,n=JSON.stringify(e);t&&this.sendUserMessage(n)}increaseVolume(){if(this.stopOperation)return;const e={action:1,touchType:x4.KEYSTROKE,keyCode:24,text:""},t=JSON.stringify(e);this.sendUserMessage(t)}decreaseVolume(){if(this.stopOperation)return;const e={action:1,touchType:x4.KEYSTROKE,keyCode:25,text:""},t=JSON.stringify(e);this.sendUserMessage(t)}saveCloudClipboard(e){this.stopOperation||(this.options.saveCloudClipboard=e)}}var v8,m8,_8,g8,y8,S8;exports.KeyboardMode=void 0,(v8=exports.KeyboardMode||(exports.KeyboardMode={})).LOCAL="local",v8.PAD="pad",exports.EquipmentInfoType=void 0,(m8=exports.EquipmentInfoType||(exports.EquipmentInfoType={})).APP="app",m8.ATTR="attr",exports.InjectStreamStatusType=void 0,(_8=exports.InjectStreamStatusType||(exports.InjectStreamStatusType={})).VIDEO="video",_8.CAMERA="camera",_8.AUDIO="audio",exports.MediaDeviceType=void 0,(g8=exports.MediaDeviceType||(exports.MediaDeviceType={})).MEDIA="media",g8.CAMERA="camera",g8.MICROPHONE="microphone",exports.AndroidKeyCode=void 0,(y8=exports.AndroidKeyCode||(exports.AndroidKeyCode={}))[y8.KEYCODE_UNKNOWN=0]="KEYCODE_UNKNOWN",y8[y8.KEYCODE_HOME=172]="KEYCODE_HOME",y8[y8.KEYCODE_BACK=158]="KEYCODE_BACK",y8[y8.KEYCODE_CALL=5]="KEYCODE_CALL",y8[y8.KEYCODE_ENDCALL=6]="KEYCODE_ENDCALL",y8[y8.KEYCODE_0=7]="KEYCODE_0",y8[y8.KEYCODE_1=8]="KEYCODE_1",y8[y8.KEYCODE_2=9]="KEYCODE_2",y8[y8.KEYCODE_3=10]="KEYCODE_3",y8[y8.KEYCODE_4=11]="KEYCODE_4",y8[y8.KEYCODE_5=12]="KEYCODE_5",y8[y8.KEYCODE_6=13]="KEYCODE_6",y8[y8.KEYCODE_7=14]="KEYCODE_7",y8[y8.KEYCODE_8=15]="KEYCODE_8",y8[y8.KEYCODE_9=16]="KEYCODE_9",y8[y8.KEYCODE_STAR=17]="KEYCODE_STAR",y8[y8.KEYCODE_POUND=18]="KEYCODE_POUND",y8[y8.KEYCODE_DPAD_UP=19]="KEYCODE_DPAD_UP",y8[y8.KEYCODE_DPAD_DOWN=20]="KEYCODE_DPAD_DOWN",y8[y8.KEYCODE_DPAD_LEFT=21]="KEYCODE_DPAD_LEFT",y8[y8.KEYCODE_DPAD_RIGHT=22]="KEYCODE_DPAD_RIGHT",y8[y8.KEYCODE_DPAD_CENTER=23]="KEYCODE_DPAD_CENTER",y8[y8.KEYCODE_VOLUME_UP=58]="KEYCODE_VOLUME_UP",y8[y8.KEYCODE_VOLUME_DOWN=59]="KEYCODE_VOLUME_DOWN",y8[y8.KEYCODE_POWER=26]="KEYCODE_POWER",y8[y8.KEYCODE_CAMERA=27]="KEYCODE_CAMERA",y8[y8.KEYCODE_CLEAR=28]="KEYCODE_CLEAR",y8[y8.KEYCODE_MENU=139]="KEYCODE_MENU",y8[y8.KEYCODE_NOTIFICATION=83]="KEYCODE_NOTIFICATION",y8[y8.KEYCODE_SEARCH=84]="KEYCODE_SEARCH",y8[y8.KEYCODE_MEDIA_PLAY_PAUSE=85]="KEYCODE_MEDIA_PLAY_PAUSE",y8[y8.KEYCODE_MEDIA_STOP=86]="KEYCODE_MEDIA_STOP",y8[y8.KEYCODE_MEDIA_PREVIOUS=87]="KEYCODE_MEDIA_PREVIOUS",y8[y8.KEYCODE_MEDIA_NEXT=88]="KEYCODE_MEDIA_NEXT",y8[y8.KEYCODE_MEDIA_REWIND=89]="KEYCODE_MEDIA_REWIND",y8[y8.KEYCODE_MEDIA_FAST_FORWARD=90]="KEYCODE_MEDIA_FAST_FORWARD",y8[y8.KEYCODE_FOCUS=80]="KEYCODE_FOCUS",y8[y8.KEYCODE_ENTER=66]="KEYCODE_ENTER",y8[y8.KEYCODE_SPACE=62]="KEYCODE_SPACE",y8[y8.KEYCODE_DEL=67]="KEYCODE_DEL",y8[y8.KEYCODE_TAB=61]="KEYCODE_TAB",y8[y8.KEYCODE_ESCAPE=111]="KEYCODE_ESCAPE",exports.RotateDirection=void 0,(S8=exports.RotateDirection||(exports.RotateDirection={}))[S8.PORTRAIT=0]="PORTRAIT",S8[S8.LANDSCAPE=1]="LANDSCAPE";
21
21
  /*! For license information please see index.mjs.LICENSE.txt */
22
- var b8={206:(e,t,n)=>{e.exports=n(57)},387:(e,t,n)=>{var r=n(485),i=n(570),o=n(940),s=n(581),a=n(574),c=n(845),u=n(338),d=n(524),l=n(141),h=n(132);e.exports=function(e){return new Promise((function(t,n){var p,f=e.data,v=e.headers,m=e.responseType;function _(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}r.isFormData(f)&&delete v["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var y=e.auth.username||"",S=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(y+":"+S)}var b=a(e.baseURL,e.url);function k(){if(g){var r="getAllResponseHeaders"in g?c(g.getAllResponseHeaders()):null,o={data:m&&"text"!==m&&"json"!==m?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};i((function(e){t(e),_()}),(function(e){n(e),_()}),o),g=null}}if(g.open(e.method.toUpperCase(),s(b,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=k:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(k)},g.onabort=function(){g&&(n(d("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(d("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(d(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var E=(e.withCredentials||u(b))&&e.xsrfCookieName?o.read(e.xsrfCookieName):void 0;E&&(v[e.xsrfHeaderName]=E)}"setRequestHeader"in g&&r.forEach(v,(function(e,t){void 0===f&&"content-type"===t.toLowerCase()?delete v[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),m&&"json"!==m&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(e){g&&(n(!e||e&&e.type?new h("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),f||(f=null),g.send(f)}))}},57:(e,t,n)=>{var r=n(485),i=n(875),o=n(29),s=n(941),a=function e(t){var n=new o(t),a=i(o.prototype.request,n);return r.extend(a,o.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(141));a.Axios=o,a.Cancel=n(132),a.CancelToken=n(603),a.isCancel=n(475),a.VERSION=n(345).version,a.all=function(e){return Promise.all(e)},a.spread=n(739),a.isAxiosError=n(835),e.exports=a,e.exports.default=a},132:e=>{function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},603:(e,t,n)=>{var r=n(132);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},475:e=>{e.exports=function(e){return!(!e||!e.__CANCEL__)}},29:(e,t,n)=>{var r=n(485),i=n(581),o=n(96),s=n(9),a=n(941),c=n(144),u=c.validators;function d(e){this.defaults=e,this.interceptors={request:new o,response:new o}}d.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!r){var d=[s,void 0];for(Array.prototype.unshift.apply(d,n),d=d.concat(o),i=Promise.resolve(e);d.length;)i=i.then(d.shift(),d.shift());return i}for(var l=e;n.length;){var h=n.shift(),p=n.shift();try{l=h(l)}catch(e){p(e);break}}try{i=s(l)}catch(e){return Promise.reject(e)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},d.prototype.getUri=function(e){return e=a(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){d.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){d.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=d},96:(e,t,n)=>{var r=n(485);function i(){this.handlers=[]}i.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},574:(e,t,n)=>{var r=n(642),i=n(288);e.exports=function(e,t){return e&&!r(t)?i(e,t):t}},524:(e,t,n)=>{var r=n(953);e.exports=function(e,t,n,i,o){var s=new Error(e);return r(s,t,n,i,o)}},9:(e,t,n)=>{var r=n(485),i=n(212),o=n(475),s=n(141),a=n(132);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(e){return c(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return c(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(c(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},953:e=>{e.exports=function(e,t,n,r,i){return e.config=t,n&&(e.code=n),e.request=r,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},941:(e,t,n)=>{var r=n(485);e.exports=function(e,t){t=t||{};var n={};function i(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function o(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:i(void 0,e[n]):i(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return i(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:i(void 0,e[n]):i(void 0,t[n])}function c(n){return n in t?i(e[n],t[n]):n in e?i(void 0,e[n]):void 0}var u={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,i=t(e);r.isUndefined(i)&&t!==c||(n[e]=i)})),n}},570:(e,t,n)=>{var r=n(524);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},212:(e,t,n)=>{var r=n(485),i=n(141);e.exports=function(e,t,n){var o=this||i;return r.forEach(n,(function(n){e=n.call(o,e,t)})),e}},141:(e,t,n)=>{var r=n(485),i=n(446),o=n(953),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=n(387)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e){if(r.isString(e))try{return(0,JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||u.transitional,n=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||i&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw o(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){u.headers[e]=r.merge(s)})),e.exports=u},345:e=>{e.exports={version:"0.24.0"}},875:e=>{e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},581:(e,t,n)=>{var r=n(485);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(i(t)+"="+i(e))})))})),o=s.join("&")}if(o){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}},288:e=>{e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},940:(e,t,n)=>{var r=n(485);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},642:e=>{e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},835:e=>{e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},338:(e,t,n)=>{var r=n(485);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=r.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},446:(e,t,n)=>{var r=n(485);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},845:(e,t,n)=>{var r=n(485),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,o,s={};return e?(r.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t){if(s[t]&&i.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},739:e=>{e.exports=function(e){return function(t){return e.apply(null,t)}}},144:(e,t,n)=>{var r=n(345).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(i(r," has been removed"+(t?" in "+t:"")));return t&&!o[r]&&(o[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],s=t[o];if(s){var a=e[o],c=void 0===a||s(a,o,e);if(!0!==c)throw new TypeError("option "+o+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+o)}},validators:i}},485:(e,t,n)=>{var r=n(875),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===i.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),o(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:c,isUndefined:s,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:u,isStream:function(e){return a(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:d,merge:function e(){var t={};function n(n,r){c(t[r])&&c(n)?t[r]=e(t[r],n):c(n)?t[r]=e({},n):o(n)?t[r]=n.slice():t[r]=n}for(var r=0,i=arguments.length;r<i;r++)d(arguments[r],n);return t},extend:function(e,t,n){return d(t,(function(t,i){e[i]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},943:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},677:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],o=0;o<4;o++)8*r+6*o<=8*e.length?n.push(t.charAt(i>>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},112:function(e,t,n){var r;e.exports=(r=r||function(e){var t;if("undefined"!=typeof window&&window.crypto&&(t=window.crypto),"undefined"!=typeof self&&self.crypto&&(t=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(t=globalThis.crypto),!t&&"undefined"!=typeof window&&window.msCrypto&&(t=window.msCrypto),!t&&void 0!==n.g&&n.g.crypto&&(t=n.g.crypto),!t)try{t=n(429)}catch(e){}var r=function(){if(t){if("function"==typeof t.getRandomValues)try{return t.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof t.randomBytes)try{return t.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},s=o.lib={},a=s.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new c.init(t,e)}}),u=o.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,o=r.sigBytes,s=this.blockSize,a=o/(4*s),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*u,o);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(i,l);n=i.splice(0,u),r.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(s.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new f.HMAC.init(e,n).finalize(t)}}}),o.algo={});return o}(Math),r)},652:function(e,t,n){var r;e.exports=(r=n(112),n(232),n(456),r.HmacSHA256)},456:function(e,t,n){var r,i,o;e.exports=(i=(r=n(112)).lib.Base,o=r.enc.Utf8,void(r.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),s=this._iKey=t.clone(),a=i.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;i.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},232:function(e,t,n){var r;e.exports=(r=n(112),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(a[i]=n(e.pow(r,.5))),c[i]=n(e.pow(r,1/3)),i++),r++}();var u=[],d=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],d=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var f=u[p-15],v=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=u[p-2],_=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=v+u[p-7]+_+u[p-16]}var g=r&i^r&o^i&o,y=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&d^~a&l)+c[p]+u[p];h=l,l=d,d=a,a=s+S|0,s=o,o=i,i=r,r=S+(y+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+d|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(d),t.HmacSHA256=o._createHmacHelper(d)}(Math),r.SHA256)},408:function(e){var t;t=()=>(()=>{var e={944:function(e){e.exports=(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=o(e))||t){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(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,i,o=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw i}}return o}}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.d(t,{default:()=>a});var a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.allowExtra=t,this.defaults=new Map,this.types=new Map,this.optional=new Set,this.required=new Set}var t;return(t=[{key:"setDefaults",value:function(e){var t=this;return Object.entries(e).forEach((function(e){var n=i(e,2),r=n[0],o=n[1];return t.defaults.set(r,o)})),this}},{key:"setTypes",value:function(e){var t=this;return Object.entries(e).forEach((function(e){var n=i(e,2),r=n[0],o=n[1];return t.types.set(r,o)})),this}},{key:"setOptional",value:function(e){var t=this;return e.forEach((function(e){return t.optional.add(e)})),this}},{key:"setRequired",value:function(e){var t=this;return e.forEach((function(e){return t.required.add(e)})),this}},{key:"resolve",value:function(e){var t=Object.assign(this.getDefaults(),e);return this.validate(t),t}},{key:"getDefaults",value:function(){var e,t={},n=r(this.defaults);try{for(n.s();!(e=n.n()).done;){var o=i(e.value,2),s=o[0],a=o[1];t[s]=a}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"validate",value:function(e){for(var t in e){if(!this.optionExists(t))throw new Error('Unkown option "'.concat(t,'".'));this.checkType(t,e[t])}var n,i=r(this.required.values());try{for(i.s();!(n=i.n()).done;){var o=n.value;if(void 0===e[o])throw new Error('Option "'.concat(o,'" is required.'))}}catch(e){i.e(e)}finally{i.f()}}},{key:"checkType",value:function(e,t){if(this.types.has(e)){var r=this.types.get(e),i=n(t);if(i!==r)throw new Error('Wrong value for option "'.concat(e,'". Expected type "').concat(r,'" but got "').concat(i,'".'))}}},{key:"optionExists",value:function(e){return!!this.allowExtra||this.defaults.has(e)||this.optional.has(e)||this.required.has(e)||this.types.has(e)}}])&&function(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)}}(e.prototype,t),e}();return t.default})()},162:function(e){e.exports=(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>n});var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._events={},this.on=this.addEventListener,this.off=this.removeEventListener}var t;return(t=[{key:"emit",value:function(e,t){if(Object.prototype.hasOwnProperty.call(this._events,e))for(var n=this._events[e],r={type:e,detail:t},i=n.length,o=0;o<i;o++)this.handle(n[o],r)}},{key:"handle",value:function(e,t){e(t)}},{key:"addEventListener",value:function(e,t){Object.prototype.hasOwnProperty.call(this._events,e)||(this._events[e]=[]),this._events[e].indexOf(t)<0&&this._events[e].push(t)}},{key:"removeEventListener",value:function(e,t){if(Object.prototype.hasOwnProperty.call(this._events,e)){var n=this._events[e],r=n.indexOf(t);r>=0&&n.splice(r,1),0===n.length&&delete this._events[e]}}}])&&function(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)}}(e.prototype,t),e}();return t.default})()}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{GamepadHandler:()=>h,GamepadListener:()=>y});var e=n(162),t=n.n(e),i=n(944),o=n.n(i);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function a(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,(i=function(e){if("object"!==s(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===s(i)?i:String(i)),r)}var i}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e,t){if(t&&("object"===s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var h=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(h,e);var t,n,r,i,o,s=(i=h,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=l(i);if(o){var n=l(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return u(this,e)});function h(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(n=s.call(this)).index=e,n.options=n.constructor.resolveOptions(r),n.sticks=new Array(Math.ceil(t.axes.length/2)).fill(null).map((function(){return[null,null]})),n.buttons=new Array(t.buttons.length).fill(null),n.updateStick=n.updateStick.bind(d(n)),n.updateButton=n.updateButton.bind(d(n)),n}return t=h,r=[{key:"resolveOptions",value:function(e){var t=void 0!==e.stick,n=void 0!==e.button,r={stick:this.optionResolver.resolve(t?e.stick:n?{}:e),button:this.optionResolver.resolve(n?e.button:t?{}:e)};return r.stick.deadZone=Math.max(Math.min(r.stick.deadZone,1),0),r.button.deadZone=Math.max(Math.min(r.button.deadZone,1),0),r.stick.precision=r.stick.precision?Math.pow(10,r.stick.precision):0,r.button.precision=r.button.precision?Math.pow(10,r.button.precision):0,r}}],(n=[{key:"update",value:function(e){for(var t=0,n=this.sticks.length,r=0;r<n;r++)for(var i=0;i<2;i++)this.updateStick(e,r,i,e.axes[t++]);var o=this.buttons.length;for(t=0;t<o;t++)this.updateButton(e,e.buttons[t],t)}},{key:"updateStick",value:function(e,t,n,r){var i=this.options.stick,o=i.deadZone,s=i.analog,a=i.precision;o&&r<o&&r>-o&&(r=0),s?a&&(r=Math.round(r*a)/a):r=r>0?1:r<0?-1:0,this.sticks[t][n]!==r&&(this.sticks[t][n]=r,this.emit("axis",{gamepad:e,stick:t,axis:n,value:r,index:this.index}))}},{key:"updateButton",value:function(e,t,n){var r=this.options.button,i=r.deadZone,o=r.analog,s=r.precision,a=t.value,c=t.pressed,u=a;i&&t.value<i&&t.value>-i&&(u=0),o?s&&(u=Math.round(u*s)/s):u=c?1:0,this.buttons[n]!==u&&(this.buttons[n]=u,this.emit("button",{gamepad:e,button:n,pressed:c,value:u,index:this.index}))}}])&&a(t.prototype,n),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),h}(t());function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}h.optionResolver=(new(o())).setDefaults({analog:!0,deadZone:0,precision:0}).setTypes({analog:"boolean",deadZone:"number",precision:"number"});var f=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.callback=t,this.frame=null,this.update=this.update.bind(this)}var t,n;return t=e,(n=[{key:"setCallback",value:function(e){this.callback=e}},{key:"start",value:function(){this.frame||(this.frame=window.requestAnimationFrame(this.update))}},{key:"stop",value:function(){this.frame&&(window.cancelAnimationFrame(this.frame),this.frame=null)}},{key:"update",value:function(){this.frame=window.requestAnimationFrame(this.update),this.callback()}}])&&function(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,(i=function(e){if("object"!==p(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===p(i)?i:String(i)),r)}var i}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(s,e);var t,n,r,i,o=(r=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=g(r);if(i){var n=g(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}(this,e)});function s(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),e=o.call(this),"function"!=typeof navigator.getGamepads)throw new Error("This browser does not support gamepad API.");return e.options=t,e.onAxis=e.onAxis.bind(_(e)),e.update=e.update.bind(_(e)),e.start=e.start.bind(_(e)),e.stop=e.stop.bind(_(e)),e.discover=e.discover.bind(_(e)),e.onButton=e.onButton.bind(_(e)),e.handlers=new Array(4).fill(null),e.loop=new f(e.update),window.addEventListener("error",e.stop),e}return t=s,(n=[{key:"start",value:function(){this.loop.start()}},{key:"stop",value:function(){this.loop.stop()}},{key:"update",value:function(){var e=navigator.getGamepads();this.discover(e[0],0),this.discover(e[1],1),this.discover(e[2],2),this.discover(e[3],3)}},{key:"discover",value:function(e,t){e?(this.handlers[t]||this.registerHandler(t,e),this.handlers[t].update(e)):this.handlers[t]&&this.removeGamepad(t)}},{key:"registerHandler",value:function(e,t){if(this.handlers[e])throw new Error("Gamepad #".concat(e," is already registered."));var n=new h(e,t,this.options);this.handlers[e]=n,n.addEventListener("axis",this.onAxis),n.addEventListener("button",this.onButton),this.emit("gamepad:connected",{index:e,gamepad:t}),this.emit("gamepad:".concat(e,":connected"),{index:e,gamepad:t})}},{key:"removeGamepad",value:function(e){if(!this.handlers[e])throw new Error("Gamepad #".concat(e," is not registered."));this.handlers[e].removeEventListener("axis",this.onAxis),this.handlers[e].removeEventListener("button",this.onButton),this.handlers[e]=null,this.emit("gamepad:disconnected",{index:e}),this.emit("gamepad:".concat(e,":disconnected"),{index:e})}},{key:"onAxis",value:function(e){var t=e.detail.index;this.emit("gamepad:axis",e.detail),this.emit("gamepad:".concat(t,":axis"),e.detail),this.emit("gamepad:".concat(t,":axis:").concat(e.detail.axis),e.detail)}},{key:"onButton",value:function(e){var t=e.detail.index;this.emit("gamepad:button",e.detail),this.emit("gamepad:".concat(t,":button"),e.detail),this.emit("gamepad:".concat(t,":button:").concat(e.detail.button),e.detail)}}])&&function(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,(i=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===v(i)?i:String(i)),r)}var i}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),s}(t())})(),r})(),e.exports=t()},809:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},586:(e,t,n)=>{var r,i,o,s,a;r=n(677),i=n(943).utf8,o=n(809),s=n(943).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,d=-271733879,l=-1732584194,h=271733878,p=0;p<n.length;p++)n[p]=16711935&(n[p]<<8|n[p]>>>24)|4278255360&(n[p]<<24|n[p]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=a._ff,v=a._gg,m=a._hh,_=a._ii;for(p=0;p<n.length;p+=16){var g=u,y=d,S=l,b=h;u=f(u,d,l,h,n[p+0],7,-680876936),h=f(h,u,d,l,n[p+1],12,-389564586),l=f(l,h,u,d,n[p+2],17,606105819),d=f(d,l,h,u,n[p+3],22,-1044525330),u=f(u,d,l,h,n[p+4],7,-176418897),h=f(h,u,d,l,n[p+5],12,1200080426),l=f(l,h,u,d,n[p+6],17,-1473231341),d=f(d,l,h,u,n[p+7],22,-45705983),u=f(u,d,l,h,n[p+8],7,1770035416),h=f(h,u,d,l,n[p+9],12,-1958414417),l=f(l,h,u,d,n[p+10],17,-42063),d=f(d,l,h,u,n[p+11],22,-1990404162),u=f(u,d,l,h,n[p+12],7,1804603682),h=f(h,u,d,l,n[p+13],12,-40341101),l=f(l,h,u,d,n[p+14],17,-1502002290),u=v(u,d=f(d,l,h,u,n[p+15],22,1236535329),l,h,n[p+1],5,-165796510),h=v(h,u,d,l,n[p+6],9,-1069501632),l=v(l,h,u,d,n[p+11],14,643717713),d=v(d,l,h,u,n[p+0],20,-373897302),u=v(u,d,l,h,n[p+5],5,-701558691),h=v(h,u,d,l,n[p+10],9,38016083),l=v(l,h,u,d,n[p+15],14,-660478335),d=v(d,l,h,u,n[p+4],20,-405537848),u=v(u,d,l,h,n[p+9],5,568446438),h=v(h,u,d,l,n[p+14],9,-1019803690),l=v(l,h,u,d,n[p+3],14,-187363961),d=v(d,l,h,u,n[p+8],20,1163531501),u=v(u,d,l,h,n[p+13],5,-1444681467),h=v(h,u,d,l,n[p+2],9,-51403784),l=v(l,h,u,d,n[p+7],14,1735328473),u=m(u,d=v(d,l,h,u,n[p+12],20,-1926607734),l,h,n[p+5],4,-378558),h=m(h,u,d,l,n[p+8],11,-2022574463),l=m(l,h,u,d,n[p+11],16,1839030562),d=m(d,l,h,u,n[p+14],23,-35309556),u=m(u,d,l,h,n[p+1],4,-1530992060),h=m(h,u,d,l,n[p+4],11,1272893353),l=m(l,h,u,d,n[p+7],16,-155497632),d=m(d,l,h,u,n[p+10],23,-1094730640),u=m(u,d,l,h,n[p+13],4,681279174),h=m(h,u,d,l,n[p+0],11,-358537222),l=m(l,h,u,d,n[p+3],16,-722521979),d=m(d,l,h,u,n[p+6],23,76029189),u=m(u,d,l,h,n[p+9],4,-640364487),h=m(h,u,d,l,n[p+12],11,-421815835),l=m(l,h,u,d,n[p+15],16,530742520),u=_(u,d=m(d,l,h,u,n[p+2],23,-995338651),l,h,n[p+0],6,-198630844),h=_(h,u,d,l,n[p+7],10,1126891415),l=_(l,h,u,d,n[p+14],15,-1416354905),d=_(d,l,h,u,n[p+5],21,-57434055),u=_(u,d,l,h,n[p+12],6,1700485571),h=_(h,u,d,l,n[p+3],10,-1894986606),l=_(l,h,u,d,n[p+10],15,-1051523),d=_(d,l,h,u,n[p+1],21,-2054922799),u=_(u,d,l,h,n[p+8],6,1873313359),h=_(h,u,d,l,n[p+15],10,-30611744),l=_(l,h,u,d,n[p+6],15,-1560198380),d=_(d,l,h,u,n[p+13],21,1309151649),u=_(u,d,l,h,n[p+4],6,-145523070),h=_(h,u,d,l,n[p+11],10,-1120210379),l=_(l,h,u,d,n[p+2],15,718787259),d=_(d,l,h,u,n[p+9],21,-343485551),u=u+g>>>0,d=d+y>>>0,l=l+S>>>0,h=h+b>>>0}return r.endian([u,d,l,h])})._ff=function(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._gg=function(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._hh=function(e,t,n,r,i,o,s){var a=e+(t^n^r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._ii=function(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(a(e,t));return t&&t.asBytes?n:t&&t.asString?s.bytesToString(n):r.bytesToHex(n)}},23:function(e,t,n){var r;e=n.nmd(e),function(){var i={function:!0,object:!0},o=i[typeof window]&&window||this,s=i[typeof t]&&t,a=e&&!e.nodeType&&e,c=s&&a&&"object"==typeof n.g&&n.g;!c||c.global!==c&&c.window!==c&&c.self!==c||(o=c);var u=Math.pow(2,53)-1,d=/\bOpera/,l=Object.prototype,h=l.hasOwnProperty,p=l.toString;function f(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function v(e){return e=S(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function m(e,t){for(var n in e)h.call(e,n)&&t(e[n],n,e)}function _(e){return null==e?f(e):p.call(e).slice(8,-1)}function g(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function y(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=u)for(;++n<r;)t(e[n],n);else m(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function S(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=o,r=t&&"object"==typeof t&&"String"!=_(t);r&&(n=t,t=null);var i=n.navigator||{},s=i.userAgent||"";t||(t=s);var a,c,u,l,h=r?!!i.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(p.toString()),f="Object",b=r?f:"ScriptBridgingProxyObject",k=r?f:"Environment",E=r&&n.java?"JavaPackage":_(n.java),T=r?f:"RuntimeObject",C=/\bJava/.test(E)&&n.java,I=C&&_(n.environment)==k,w=C?"a":"α",R=C?"b":"β",A=n.document||{},O=n.operamini||n.opera,x=d.test(x=r&&O?O["[[Class]]"]:_(O))?x:O=null,P=t,D=[],M=null,N=t==s,L=N&&O&&"function"==typeof O.version&&O.version(),U=y([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||g(n))+"\\b","i").exec(t)&&(n.label||n)})),V=y(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"],(function(e,n){return e||RegExp("\\b"+(n.pattern||g(n))+"\\b","i").exec(t)&&(n.label||n)})),F=G([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),B=y({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}},(function(e,n,r){return e||(n[F]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(F)]||RegExp("\\b"+g(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r})),j=y(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "],(function(e,n){var r=n.pattern||g(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),v(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}));function G(e){return y(e,(function(e,n){var r=n.pattern||g(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=v(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function H(e){return y(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(U&&(U=[U]),/\bAndroid\b/.test(j)&&!F&&(a=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(F=S(a[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),B&&!F?F=G([B]):B&&F&&(F=F.replace(RegExp("^("+g(B)+")[-_.\\s]","i"),B+" ").replace(RegExp("^("+g(B)+")[-_.]?(\\w)","i"),B+" $2")),(a=/\bGoogle TV\b/.exec(F))&&(F=a[0]),/\bSimulator\b/i.test(t)&&(F=(F?F+" ":"")+"Simulator"),"Opera Mini"==V&&/\bOPiOS\b/.test(t)&&D.push("running in Turbo/Uncompressed mode"),"IE"==V&&/\blike iPhone OS\b/.test(t)?(B=(a=e(t.replace(/like iPhone OS/,""))).manufacturer,F=a.product):/^iP/.test(F)?(V||(V="Safari"),j="iOS"+((a=/ OS ([\d_]+)/i.exec(t))?" "+a[1].replace(/_/g,"."):"")):"Konqueror"==V&&/^Linux\b/i.test(j)?j="Kubuntu":B&&"Google"!=B&&(/Chrome/.test(V)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(F))||/\bAndroid\b/.test(j)&&/^Chrome/.test(V)&&/\bVersion\//i.test(t)?(V="Android Browser",j=/\bAndroid\b/.test(j)?j:"Android"):"Silk"==V?(/\bMobi/i.test(t)||(j="Android",D.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&D.unshift("accelerated")):"UC Browser"==V&&/\bUCWEB\b/.test(t)?D.push("speed mode"):"PaleMoon"==V&&(a=/\bFirefox\/([\d.]+)\b/.exec(t))?D.push("identifying as Firefox "+a[1]):"Firefox"==V&&(a=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(j||(j="Firefox OS"),F||(F=a[1])):!V||(a=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(V))?(V&&!F&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(a+"/")+8))&&(V=null),(a=F||B||j)&&(F||B||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(j))&&(V=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(j)?j:a)+" Browser")):"Electron"==V&&(a=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&D.push("Chromium "+a),L||(L=H(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",g(V),"(?:Firefox|Minefield|NetFront)"])),(a=("iCab"==U&&parseFloat(L)>3?"WebKit":/\bOpera\b/.test(V)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(U)&&"WebKit"||!U&&/\bMSIE\b/i.test(t)&&("Mac OS"==j?"Tasman":"Trident")||"WebKit"==U&&/\bPlayStation\b(?! Vita\b)/i.test(V)&&"NetFront")&&(U=[a]),"IE"==V&&(a=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(V+=" Mobile",j="Windows Phone "+(/\+$/.test(a)?a:a+".x"),D.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(V="IE Mobile",j="Windows Phone 8.x",D.unshift("desktop mode"),L||(L=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=V&&"Trident"==U&&(a=/\brv:([\d.]+)/.exec(t))&&(V&&D.push("identifying as "+V+(L?" "+L:"")),V="IE",L=a[1]),N){if(l=null!=(u=n)?typeof u.global:"number",/^(?:boolean|number|string|undefined)$/.test(l)||"object"==l&&!u.global)_(a=n.runtime)==b?(V="Adobe AIR",j=a.flash.system.Capabilities.os):_(a=n.phantom)==T?(V="PhantomJS",L=(a=a.version||null)&&a.major+"."+a.minor+"."+a.patch):"number"==typeof A.documentMode&&(a=/\bTrident\/(\d+)/i.exec(t))?(L=[L,A.documentMode],(a=+a[1]+4)!=L[1]&&(D.push("IE "+L[1]+" mode"),U&&(U[1]=""),L[1]=a),L="IE"==V?String(L[1].toFixed(1)):L[0]):"number"==typeof A.documentMode&&/^(?:Chrome|Firefox)\b/.test(V)&&(D.push("masking as "+V+" "+L),V="IE",L="11.0",U=["Trident"],j="Windows");else if(C&&(P=(a=C.lang.System).getProperty("os.arch"),j=j||a.getProperty("os.name")+" "+a.getProperty("os.version")),I){try{L=n.require("ringo/engine").version.join("."),V="RingoJS"}catch(e){(a=n.system)&&a.global.system==n.system&&(V="Narwhal",j||(j=a[0].os||null))}V||(V="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(a=n.process)&&("object"==typeof a.versions&&("string"==typeof a.versions.electron?(D.push("Node "+a.versions.node),V="Electron",L=a.versions.electron):"string"==typeof a.versions.nw&&(D.push("Chromium "+L,"Node "+a.versions.node),V="NW.js",L=a.versions.nw)),V||(V="Node.js",P=a.arch,j=a.platform,L=(L=/[\d.]+/.exec(a.version))?L[0]:null));j=j&&v(j)}if(L&&(a=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(L)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(N&&i.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(M=/b/i.test(a)?"beta":"alpha",L=L.replace(RegExp(a+"\\+?$"),"")+("beta"==M?R:w)+(/\d+\+?/.exec(a)||"")),"Fennec"==V||"Firefox"==V&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(j))V="Firefox Mobile";else if("Maxthon"==V&&L)L=L.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(F))"Xbox 360"==F&&(j=null),"Xbox 360"==F&&/\bIEMobile\b/.test(t)&&D.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(V)&&(!V||F||/Browser|Mobi/.test(V))||"Windows CE"!=j&&!/Mobi/i.test(t))if("IE"==V&&N)try{null===n.external&&D.unshift("platform preview")}catch(e){D.unshift("embedded")}else(/\bBlackBerry\b/.test(F)||/\bBB10\b/.test(t))&&(a=(RegExp(F.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||L)?(j=((a=[a,/BB10/.test(t)])[1]?(F=null,B="BlackBerry"):"Device Software")+" "+a[0],L=null):this!=m&&"Wii"!=F&&(N&&O||/Opera/.test(V)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==V&&/\bOS X (?:\d+\.){2,}/.test(j)||"IE"==V&&(j&&!/^Win/.test(j)&&L>5.5||/\bWindows XP\b/.test(j)&&L>8||8==L&&!/\bTrident\b/.test(t)))&&!d.test(a=e.call(m,t.replace(d,"")+";"))&&a.name&&(a="ing as "+a.name+((a=a.version)?" "+a:""),d.test(V)?(/\bIE\b/.test(a)&&"Mac OS"==j&&(j=null),a="identify"+a):(a="mask"+a,V=x?v(x.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(a)&&(j=null),N||(L=null)),U=["Presto"],D.push(a));else V+=" Mobile";(a=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(a=[parseFloat(a.replace(/\.(\d)$/,".0$1")),a],"Safari"==V&&"+"==a[1].slice(-1)?(V="WebKit Nightly",M="alpha",L=a[1].slice(0,-1)):L!=a[1]&&L!=(a[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(L=null),a[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==a[0]&&537.36==a[2]&&parseFloat(a[1])>=28&&"WebKit"==U&&(U=["Blink"]),N&&(h||a[1])?(U&&(U[1]="like Chrome"),a=a[1]||((a=a[0])<530?1:a<532?2:a<532.05?3:a<533?4:a<534.03?5:a<534.07?6:a<534.1?7:a<534.13?8:a<534.16?9:a<534.24?10:a<534.3?11:a<535.01?12:a<535.02?"13+":a<535.07?15:a<535.11?16:a<535.19?17:a<536.05?18:a<536.1?19:a<537.01?20:a<537.11?"21+":a<537.13?23:a<537.18?24:a<537.24?25:a<537.36?26:"Blink"!=U?"27":"28")):(U&&(U[1]="like Safari"),a=(a=a[0])<400?1:a<500?2:a<526?3:a<533?4:a<534?"4+":a<535?5:a<537?6:a<538?7:a<601?8:a<602?9:a<604?10:a<606?11:a<608?12:"12"),U&&(U[1]+=" "+(a+="number"==typeof a?".x":/[.+]/.test(a)?"":"+")),"Safari"==V&&(!L||parseInt(L)>45)?L=a:"Chrome"==V&&/\bHeadlessChrome/i.test(t)&&D.unshift("headless")),"Opera"==V&&(a=/\bzbov|zvav$/.exec(j))?(V+=" ",D.unshift("desktop mode"),"zvav"==a?(V+="Mini",L=null):V+="Mobile",j=j.replace(RegExp(" *"+a+"$"),"")):"Safari"==V&&/\bChrome\b/.exec(U&&U[1])?(D.unshift("desktop mode"),V="Chrome Mobile",L=null,/\bOS X\b/.test(j)?(B="Apple",j="iOS 4.3+"):j=null):/\bSRWare Iron\b/.test(V)&&!L&&(L=H("Chrome")),L&&0==L.indexOf(a=/[\d.]+$/.exec(j))&&t.indexOf("/"+a+"-")>-1&&(j=S(j.replace(a,""))),j&&-1!=j.indexOf(V)&&!RegExp(V+" OS").test(j)&&(j=j.replace(RegExp(" *"+g(V)+" *"),"")),U&&!/\b(?:Avant|Nook)\b/.test(V)&&(/Browser|Lunascape|Maxthon/.test(V)||"Safari"!=V&&/^iOS/.test(j)&&/\bSafari\b/.test(U[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(V)&&U[1])&&(a=U[U.length-1])&&D.push(a),D.length&&(D=["("+D.join("; ")+")"]),B&&F&&F.indexOf(B)<0&&D.push("on "+B),F&&D.push((/^on /.test(D[D.length-1])?"":"on ")+F),j&&(a=/ ([\d.+]+)$/.exec(j),c=a&&"/"==j.charAt(j.length-a[0].length-1),j={architecture:32,family:a&&!c?j.replace(a[0],""):j,version:a?a[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(a=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(P))&&!/\bi686\b/i.test(P)?(j&&(j.architecture=64,j.family=j.family.replace(RegExp(" *"+a),"")),V&&(/\bWOW64\b/i.test(t)||N&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(t))&&D.unshift("32-bit")):j&&/^OS X/.test(j.family)&&"Chrome"==V&&parseFloat(L)>=39&&(j.architecture=64),t||(t=null);var W={};return W.description=t,W.layout=U&&U[0],W.manufacturer=B,W.name=V,W.prerelease=M,W.product=F,W.ua=t,W.version=V&&L,W.os=j||{architecture:null,family:null,version:null,toString:function(){return"null"}},W.parse=e,W.toString=function(){return this.description||""},W.version&&D.unshift(L),W.name&&D.unshift(V),j&&V&&(j!=String(j).split(" ")[0]||j!=V.split(" ")[0]&&!F)&&D.push(F?"("+j+")":"on "+j),D.length&&(W.description=D.join(" ")),W}();o.platform=b,void 0===(r=function(){return b}.call(t,n,t,e))||(e.exports=r)}.call(this)},226:(e,t,n)=>{var r=n(347);function i(e,t,n,i,o){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":o||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var c="msid:"+(i?i.id:"-")+" "+a+"\r\n";s+="a="+c,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),s=r(t.parameters.apt,i);return o&&s&&o.name.toLowerCase()===s.name.toLowerCase()};return e.codecs.forEach((function(r){for(var o=0;o<t.codecs.length;o++){var s=t.codecs[o];if(r.name.toLowerCase()===s.name.toLowerCase()&&r.clockRate===s.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&s.parameters.apt&&!i(r,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(r.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter((function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}})),n}function s(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function a(e,t){var n=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return n||e.addRemoteCandidate(t),!n}function c(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}e.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var d=function(n){var i=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){i[e]=o[e].bind(o)})),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",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var s=n.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},d.prototype.addTrack=function(t,n){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},d.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach((function(t){n.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",(function(e){n.enabled=e.enabled}))})),r.getTracks().forEach((function(e){n.addTrack(e,r)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find((function(e){return e.rtpSender===t}));if(!n)throw c("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var n=t.getSenders().find((function(t){return t.track===e}));n&&t.removeTrack(n)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,n){var i=this,o=this.transceivers[n].iceGatherer;if(!o.onlocalcandidate){var s=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,c=!a||0===Object.keys(a).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),a.component=1,a.ufrag=o.getLocalParameters().usernameFragment;var u=r.writeCandidate(a);s.candidate=Object.assign(s.candidate,r.parseCandidate(u)),s.candidate.candidate=u,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var d=r.getMediaSections(i._localDescription.sdp);d[s.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=r.getDescription(i._localDescription.sdp)+d.join("");var l=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",s),l&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){s.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,n,i){var s=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(s.encodings=e.sendEncodingParameters,s.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(s.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(s)),i&&e.rtpReceiver&&s.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?s.encodings=e.recvEncodingParameters:s.encodings=[{}],s.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(s.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(s.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(s))},d.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!s("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=r.splitSections(e.sdp),n=t.shift(),t.forEach((function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=r.splitSections(i._remoteDescription.sdp),n=t.shift();var a=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach((function(e,t){var s=i.transceivers[t],c=s.iceGatherer,u=s.iceTransport,d=s.dtlsTransport,l=s.localCapabilities,h=s.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length||s.rejected)){var p=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);a&&(f.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===u.state&&u.start(c,p,a?"controlling":"controlled"),"new"===d.state&&d.start(f));var v=o(l,h);i._transceive(s,v.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(i){var d=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!s("setRemoteDescription",i.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+d.signalingState));var l={};d.remoteStreams.forEach((function(e){l[e.id]=e}));var h=[],p=r.splitSections(i.sdp),f=p.shift(),v=r.matchPrefix(f,"a=ice-lite").length>0,m=r.matchPrefix(f,"a=group:BUNDLE ").length>0;d.usingBundle=m;var _=r.matchPrefix(f,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,p.forEach((function(s,c){var u=r.splitLines(s),p=r.getKind(s),_=r.isRejected(s)&&0===r.matchPrefix(s,"a=bundle-only").length,g=u[0].substr(2).split(" ")[2],y=r.getDirection(s,f),S=r.parseMsid(s),b=r.getMid(s)||r.generateIdentifier();if(_||"application"===p&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))d.transceivers[c]={mid:b,kind:p,protocol:g,rejected:!0};else{var k,E,T,C,I,w,R,A,O;!_&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(p,!0));var x,P,D=r.parseRtpParameters(s);_||(x=r.getIceParameters(s,f),(P=r.getDtlsParameters(s,f)).role="client"),R=r.parseRtpEncodingParameters(s);var M=r.parseRtcpParameters(s),N=r.matchPrefix(s,"a=end-of-candidates",f).length>0,L=r.matchPrefix(s,"a=candidate:").map((function(e){return r.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!_&&m&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==i.type||_)"answer"!==i.type||_||(E=(k=d.transceivers[c]).iceGatherer,T=k.iceTransport,C=k.dtlsTransport,I=k.rtpReceiver,w=k.sendEncodingParameters,A=k.localCapabilities,d.transceivers[c].recvEncodingParameters=R,d.transceivers[c].remoteCapabilities=D,d.transceivers[c].rtcpParameters=M,L.length&&"new"===T.state&&(!v&&!N||m&&0!==c?L.forEach((function(e){a(k.iceTransport,e)})):T.setRemoteCandidates(L)),m&&0!==c||("new"===T.state&&T.start(E,x,"controlling"),"new"===C.state&&C.start(P)),!o(k.localCapabilities,k.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&k.sendEncodingParameters[0].rtx&&delete k.sendEncodingParameters[0].rtx,d._transceive(k,"sendrecv"===y||"recvonly"===y,"sendrecv"===y||"sendonly"===y),!I||"sendrecv"!==y&&"sendonly"!==y?delete k.rtpReceiver:(O=I.track,S?(l[S.stream]||(l[S.stream]=new e.MediaStream),n(O,l[S.stream]),h.push([O,I,l[S.stream]])):(l.default||(l.default=new e.MediaStream),n(O,l.default),h.push([O,I,l.default]))));else{(k=d.transceivers[c]||d._createTransceiver(p)).mid=b,k.iceGatherer||(k.iceGatherer=d._createIceGatherer(c,m)),L.length&&"new"===k.iceTransport.state&&(!N||m&&0!==c?L.forEach((function(e){a(k.iceTransport,e)})):k.iceTransport.setRemoteCandidates(L)),A=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(A.codecs=A.codecs.filter((function(e){return"rtx"!==e.name}))),w=k.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,V=!1;"sendrecv"===y||"sendonly"===y?(V=!k.rtpReceiver,I=k.rtpReceiver||new e.RTCRtpReceiver(k.dtlsTransport,p),V&&(O=I.track,S&&"-"===S.stream||(S?(l[S.stream]||(l[S.stream]=new e.MediaStream,Object.defineProperty(l[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(O,"id",{get:function(){return S.track}}),U=l[S.stream]):(l.default||(l.default=new e.MediaStream),U=l.default)),U&&(n(O,U),k.associatedRemoteMediaStreams.push(U)),h.push([O,I,U]))):k.rtpReceiver&&k.rtpReceiver.track&&(k.associatedRemoteMediaStreams.forEach((function(t){var n=t.getTracks().find((function(e){return e.id===k.rtpReceiver.track.id}));n&&function(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(n,t)})),k.associatedRemoteMediaStreams=[]),k.localCapabilities=A,k.remoteCapabilities=D,k.rtpReceiver=I,k.rtcpParameters=M,k.sendEncodingParameters=w,k.recvEncodingParameters=R,d._transceive(d.transceivers[c],!1,V)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===i.type?"active":"passive"),d._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(l).forEach((function(t){var n=l[t];if(n.getTracks().length){if(-1===d.remoteStreams.indexOf(n)){d.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout((function(){d._dispatchEvent("addstream",r)}))}h.forEach((function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(d,t,r,[n])}))}})),h.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},d.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter((function(e){return"audio"===e.kind})).length,s=n.transceivers.filter((function(e){return"video"===e.kind})).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(o=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(s=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach((function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--s<0&&(e.wantReceive=!1)}));o>0||s>0;)o>0&&(n._createTransceiver("audio"),o--),s>0&&(n._createTransceiver("video"),s--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach((function(i,o){var s=i.track,a=i.kind,c=i.mid||r.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(o,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(a);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];s&&t>=15019&&"video"===a&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=u,i.sendEncodingParameters=d})),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach((function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var s=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(s+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n";var a=r.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach((function(e,r){if(!(r+1>a)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?s+="m=application 0 DTLS/SCTP 5000\r\n":s+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?s+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(s+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(s+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;e.stream&&("audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}));var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,s+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(s+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(u)},d.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,o){if(!n._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u<n.transceivers.length;u++)if(n.transceivers[u].mid===e.sdpMid){s=u;break}var d=n.transceivers[s];if(!d)return o(c("OperationError","Can not add ICE candidate"));if(d.rejected)return i();var l=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return i();if(l.component&&1!==l.component)return i();if((0===s||s>0&&d.iceTransport!==n.transceivers[0].iceTransport)&&!a(d.iceTransport,l))return o(c("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n._remoteDescription.sdp))[s]+="a="+(l.type?h:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),(t=r.getMediaSections(n._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);i()}))},d.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)})),!n)throw c("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&r.push(e[t].getStats())}))})),Promise.all(r).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])})),t}))}}}));var l=["createOffer","createAnswer"];return l.forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(l=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),d}},995:(e,t)=>{const{hasOwnProperty:n}=Object.prototype,r=h();r.configure=h,r.stringify=r,r.default=r,t.stringify=r,t.configure=h,e.exports=r;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function o(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function s(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){const n=e[t];let r=t;for(;0!==r&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return void 0!==a.call(e)&&0!==e.length}function u(e,t,n){e.length<n&&(n=e.length);const r=","===t?"":" ";let i=`"0":${r}${e[0]}`;for(let o=1;o<n;o++)i+=`${t}"${o}":${r}${e[o]}`;return i}function d(e,t){let r;if(n.call(e,t)){if(r=e[t],"number"!=typeof r)throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return void 0===r?1/0:r}function l(e){return 1===e?"1 item":`${e} items`}function h(e){const t=function(e){if(n.call(e,"strict")){const t=e.strict;if("boolean"!=typeof t)throw new TypeError('The "strict" argument must be of type boolean');if(t)return e=>{let t="Object can not safely be stringified. Received type "+typeof e;throw"function"!=typeof e&&(t+=` (${e.toString()})`),new Error(t)}}}(e={...e});t&&(void 0===e.bigint&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));const r=function(e){if(n.call(e,"circularValue")){const t=e.circularValue;if("string"==typeof t)return`"${t}"`;if(null==t)return t;if(t===Error||t===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}(e),i=function(e,t){let r;if(n.call(e,t)&&(r=e[t],"boolean"!=typeof r))throw new TypeError('The "bigint" argument must be of type boolean');return void 0===r||r}(e,"bigint"),a=function(e){let t;if(n.call(e,"deterministic")&&(t=e.deterministic,"boolean"!=typeof t&&"function"!=typeof t))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return void 0===t||t}(e),h="function"==typeof a?a:void 0,p=d(e,"maximumDepth"),f=d(e,"maximumBreadth");function v(e,n,u,d,m,_){let g=n[e];switch("object"==typeof g&&null!==g&&"function"==typeof g.toJSON&&(g=g.toJSON(e)),g=d.call(n,e,g),typeof g){case"string":return o(g);case"object":{if(null===g)return"null";if(-1!==u.indexOf(g))return r;let e="",t=",";const n=_;if(Array.isArray(g)){if(0===g.length)return"[]";if(p<u.length+1)return'"[Array]"';u.push(g),""!==m&&(e+=`\n${_+=m}`,t=`,\n${_}`);const r=Math.min(g.length,f);let i=0;for(;i<r-1;i++){const n=v(String(i),g,u,d,m,_);e+=void 0!==n?n:"null",e+=t}const o=v(String(i),g,u,d,m,_);return e+=void 0!==o?o:"null",g.length-1>f&&(e+=`${t}"... ${l(g.length-f-1)} not stringified"`),""!==m&&(e+=`\n${n}`),u.pop(),`[${e}]`}let i=Object.keys(g);const y=i.length;if(0===y)return"{}";if(p<u.length+1)return'"[Object]"';let S="",b="";""!==m&&(t=`,\n${_+=m}`,S=" ");const k=Math.min(y,f);a&&!c(g)&&(i=s(i,h)),u.push(g);for(let n=0;n<k;n++){const r=i[n],s=v(r,g,u,d,m,_);void 0!==s&&(e+=`${b}${o(r)}:${S}${s}`,b=t)}return y>f&&(e+=`${b}"...":${S}"${l(y-f)} not stringified"`,b=t),""!==m&&b.length>1&&(e=`\n${_}${e}\n${n}`),u.pop(),`{${e}}`}case"number":return isFinite(g)?String(g):t?t(g):"null";case"boolean":return!0===g?"true":"false";case"undefined":return;case"bigint":if(i)return String(g);default:return t?t(g):void 0}}function m(e,n,s,a,c,u){switch("object"==typeof n&&null!==n&&"function"==typeof n.toJSON&&(n=n.toJSON(e)),typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if(-1!==s.indexOf(n))return r;const e=u;let t="",i=",";if(Array.isArray(n)){if(0===n.length)return"[]";if(p<s.length+1)return'"[Array]"';s.push(n),""!==c&&(t+=`\n${u+=c}`,i=`,\n${u}`);const r=Math.min(n.length,f);let o=0;for(;o<r-1;o++){const e=m(String(o),n[o],s,a,c,u);t+=void 0!==e?e:"null",t+=i}const d=m(String(o),n[o],s,a,c,u);return t+=void 0!==d?d:"null",n.length-1>f&&(t+=`${i}"... ${l(n.length-f-1)} not stringified"`),""!==c&&(t+=`\n${e}`),s.pop(),`[${t}]`}s.push(n);let d="";""!==c&&(i=`,\n${u+=c}`,d=" ");let h="";for(const e of a){const r=m(e,n[e],s,a,c,u);void 0!==r&&(t+=`${h}${o(e)}:${d}${r}`,h=i)}return""!==c&&h.length>1&&(t=`\n${u}${t}\n${e}`),s.pop(),`{${t}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}function _(e,n,d,v,m){switch(typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if("function"==typeof n.toJSON){if("object"!=typeof(n=n.toJSON(e)))return _(e,n,d,v,m);if(null===n)return"null"}if(-1!==d.indexOf(n))return r;const t=m;if(Array.isArray(n)){if(0===n.length)return"[]";if(p<d.length+1)return'"[Array]"';d.push(n);let e=`\n${m+=v}`;const r=`,\n${m}`,i=Math.min(n.length,f);let o=0;for(;o<i-1;o++){const t=_(String(o),n[o],d,v,m);e+=void 0!==t?t:"null",e+=r}const s=_(String(o),n[o],d,v,m);return e+=void 0!==s?s:"null",n.length-1>f&&(e+=`${r}"... ${l(n.length-f-1)} not stringified"`),e+=`\n${t}`,d.pop(),`[${e}]`}let i=Object.keys(n);const g=i.length;if(0===g)return"{}";if(p<d.length+1)return'"[Object]"';const y=`,\n${m+=v}`;let S="",b="",k=Math.min(g,f);c(n)&&(S+=u(n,y,f),i=i.slice(n.length),k-=n.length,b=y),a&&(i=s(i,h)),d.push(n);for(let e=0;e<k;e++){const t=i[e],r=_(t,n[t],d,v,m);void 0!==r&&(S+=`${b}${o(t)}: ${r}`,b=y)}return g>f&&(S+=`${b}"...": "${l(g-f)} not stringified"`,b=y),""!==b&&(S=`\n${m}${S}\n${t}`),d.pop(),`{${S}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}function g(e,n,d){switch(typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if("function"==typeof n.toJSON){if("object"!=typeof(n=n.toJSON(e)))return g(e,n,d);if(null===n)return"null"}if(-1!==d.indexOf(n))return r;let t="";const i=void 0!==n.length;if(i&&Array.isArray(n)){if(0===n.length)return"[]";if(p<d.length+1)return'"[Array]"';d.push(n);const e=Math.min(n.length,f);let r=0;for(;r<e-1;r++){const e=g(String(r),n[r],d);t+=void 0!==e?e:"null",t+=","}const i=g(String(r),n[r],d);return t+=void 0!==i?i:"null",n.length-1>f&&(t+=`,"... ${l(n.length-f-1)} not stringified"`),d.pop(),`[${t}]`}let v=Object.keys(n);const m=v.length;if(0===m)return"{}";if(p<d.length+1)return'"[Object]"';let _="",y=Math.min(m,f);i&&c(n)&&(t+=u(n,",",f),v=v.slice(n.length),y-=n.length,_=","),a&&(v=s(v,h)),d.push(n);for(let e=0;e<y;e++){const r=v[e],i=g(r,n[r],d);void 0!==i&&(t+=`${_}${o(r)}:${i}`,_=",")}return m>f&&(t+=`${_}"...":"${l(m-f)} not stringified"`),d.pop(),`{${t}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}return function(e,t,n){if(arguments.length>1){let r="";if("number"==typeof n?r=" ".repeat(Math.min(n,10)):"string"==typeof n&&(r=n.slice(0,10)),null!=t){if("function"==typeof t)return v("",{"":e},[],t,r,"");if(Array.isArray(t))return m("",e,[],function(e){const t=new Set;for(const n of e)"string"!=typeof n&&"number"!=typeof n||t.add(String(n));return t}(t),r,"")}if(0!==r.length)return _("",e,[],r,"")}return g("",e,[])}}},347:e=>{var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var o=r[i],s=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var a=t.parseRtpMap(s),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(a.parameters=c.length?t.parseFmtp(c[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),n.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){n.headerExtensions.push(t.parseExtmap(e))})),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=a.length>0&&a[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var s=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var o=t.writeRtpDescription(e.kind,n);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";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\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t},429:()=>{}},k8={};function E8(e){var t=k8[e];if(void 0!==t)return t.exports;var n=k8[e]={id:e,loaded:!1,exports:{}};return b8[e].call(n.exports,n,n.exports,E8),n.loaded=!0,n.exports}E8.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return E8.d(t,{a:t}),t},E8.d=(e,t)=>{for(var n in t)E8.o(t,n)&&!E8.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},E8.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),E8.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),E8.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},E8.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var T8={};(()=>{E8.d(T8,{p:()=>Ai,Z:()=>xi});var e={};E8.r(e),E8.d(e,{fixNegotiationNeeded:()=>R,shimAddTrackRemoveTrack:()=>I,shimAddTrackRemoveTrackWithNative:()=>C,shimGetDisplayMedia:()=>y,shimGetSendersWithDtmf:()=>k,shimGetStats:()=>E,shimGetUserMedia:()=>g,shimMediaStream:()=>S,shimOnTrack:()=>b,shimPeerConnection:()=>w,shimSenderReceiverGetStats:()=>T});var t={};E8.r(t),E8.d(t,{shimGetDisplayMedia:()=>P,shimGetUserMedia:()=>x,shimPeerConnection:()=>D,shimReplaceTrack:()=>M});var n={};E8.r(n),E8.d(n,{shimAddTransceiver:()=>H,shimCreateAnswer:()=>z,shimCreateOffer:()=>K,shimGetDisplayMedia:()=>L,shimGetParameters:()=>W,shimGetUserMedia:()=>N,shimOnTrack:()=>U,shimPeerConnection:()=>V,shimRTCDataChannel:()=>G,shimReceiverGetStats:()=>B,shimRemoveStream:()=>j,shimSenderGetStats:()=>F});var r={};E8.r(r),E8.d(r,{shimAudioContext:()=>te,shimCallbacksAPI:()=>Y,shimConstraints:()=>$,shimCreateOfferLegacy:()=>ee,shimGetUserMedia:()=>X,shimLocalStreamsAPI:()=>q,shimRTCIceServerUrls:()=>Q,shimRemoteStreamsAPI:()=>J,shimTrackEventTransceiver:()=>Z});var i={};E8.r(i),E8.d(i,{removeExtmapAllowMixed:()=>ce,shimAddIceCandidateNullOrEmpty:()=>ue,shimConnectionState:()=>ae,shimMaxMessageSize:()=>oe,shimRTCIceCandidate:()=>ie,shimSendThrowTypeError:()=>se});let o=!0,s=!0;function a(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function c(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function u(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(o=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function d(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(s=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function l(){if("object"==typeof window){if(o)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function h(e,t){s&&console.warn(e+" is deprecated, please use "+t+" instead.")}function p(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){return p(e)?Object.keys(e).reduce((function(t,n){const r=p(e[n]),i=r?f(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function v(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?v(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{v(e,e.get(t),n)}))})))}function m(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&v(e,n,i)}))})),i}const _=l;function g(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let s=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&n.length&&t.includes("back")&&(s=n[n.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),_("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return _("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function y(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((t=>{const r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function S(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function b(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else c(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function k(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function E(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach((e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){n(o(i(e)))};return t.apply(this,[r,e])}return new Promise(((e,n)=>{t.apply(this,[function(t){e(o(i(t)))},n])})).then(n,r)}}function T(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>m(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),c(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>m(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach((n=>{n.track===e&&(t?r=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?r=!0:n=t),t.track===e))),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function C(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function I(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return C(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find((e=>e.track===t));if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[n.id];if(o)o.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function w(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function R(e,t){c(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var A=E8(226),O=E8.n(A);function x(e){const t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function P(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 D(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const n=new Event("enabled");n.enabled=e,this.dispatchEvent(n)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const n=O()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let n=e.urls||e.url;e.url&&!e.urls&&h("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof n;return r&&(n=[n]),n=n.filter((e=>{if(0===e.indexOf("stun:"))return!1;const n=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return n&&!t?(t=!0,!0):n&&!t})),delete e.url,e.urls=r?n[0]:n,!!n.length}}))}(e.iceServers,t.version),l("ICE servers after filtering:",e.iceServers)),new n(e)},e.RTCPeerConnection.prototype=n.prototype}function M(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function N(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){h("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function L(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}function U(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function V(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const 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(){const[e,i,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(i,o)}}function F(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function B(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),c(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function j(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){h("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function G(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function H(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function W(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function K(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function z(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function q(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function J(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function Y(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let a=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,n){const r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=a}function X(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n($(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function $(e){return e&&void 0!==e.video?Object.assign({},e,{video:f(e.video)}):e}function Q(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(h("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Z(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ee(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video")}return t.apply(this,arguments)}}function te(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ne=E8(347),re=E8.n(ne);function ie(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const n=new t(e),r=re().parseCandidate(e.candidate),i=Object.assign(n,r);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,c(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function oe(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n},r=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=re().matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r},i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=re().splitSections(e.sdp);return t.shift(),t.some((e=>{const t=re().parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),t=n(e),i=r(arguments[0],e);let o;o=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>o}),this._sctp=s}return i.apply(this,arguments)}}function se(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},c(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ae(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function ce(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function ue(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const de=function({window:o}={},s={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const c=l,h=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=a(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=a(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=a(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=a(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(o),p={browserDetails:h,commonShim:i,extractVersion:a,disableLog:u,disableWarnings:d};switch(h.browser){case"chrome":if(!e||!w||!s.shimChrome)return c("Chrome shim is not included in this adapter release."),p;if(null===h.version)return c("Chrome shim can not determine version, not shimming."),p;c("adapter.js shimming chrome."),p.browserShim=e,ue(o,h),g(o,h),S(o),w(o,h),b(o),I(o,h),k(o),E(o),T(o),R(o,h),ie(o),ae(o),oe(o,h),se(o),ce(o,h);break;case"firefox":if(!n||!V||!s.shimFirefox)return c("Firefox shim is not included in this adapter release."),p;c("adapter.js shimming firefox."),p.browserShim=n,ue(o,h),N(o,h),V(o,h),U(o),j(o),F(o),B(o),G(o),H(o),W(o),K(o),z(o),ie(o),ae(o),oe(o,h),se(o);break;case"edge":if(!t||!D||!s.shimEdge)return c("MS edge shim is not included in this adapter release."),p;c("adapter.js shimming edge."),p.browserShim=t,x(o),P(o),D(o,h),M(o),oe(o,h),se(o);break;case"safari":if(!r||!s.shimSafari)return c("Safari shim is not included in this adapter release."),p;c("adapter.js shimming safari."),p.browserShim=r,ue(o,h),Q(o),ee(o),Y(o),q(o),J(o),Z(o),X(o),te(o),ie(o),oe(o,h),se(o),ce(o,h);break;default:c("Unsupported browser!")}return p}({window:"undefined"==typeof window?void 0:window}),le=de;var he,pe,fe,ve,me,_e,ge,ye,Se,be,ke,Ee,Te="2.1.4.beta.1111";!function(e){e.LOADING="loading",e.PLAYING="playing",e.ENDED="ended"}(he||(he={})),function(e){e.LOADING="loading",e.PLAYING="playing",e.ENDED="ended"}(pe||(pe={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.ESTABLISHED=2]="ESTABLISHED"}(fe||(fe={})),function(e){e[e.LOCAL=0]="LOCAL",e[e.REMOTE_SRC=1]="REMOTE_SRC",e[e.REMOTE_DRAW=2]="REMOTE_DRAW",e[e.REMOTE_CUSTOM=3]="REMOTE_CUSTOM",e[e.REMOTE_SRC_POS=4]="REMOTE_SRC_POS",e[e.FRONT_DRAW_DELTA_POS=5]="FRONT_DRAW_DELTA_POS"}(ve||(ve={})),function(e){e[e.CREATE_OFFER_FAILED=-2]="CREATE_OFFER_FAILED",e[e.NEED_RECONNECT=-1]="NEED_RECONNECT",e[e.MANUAL_CLOSE=0]="MANUAL_CLOSE",e[e.OTHER_KICK=1]="OTHER_KICK",e[e.HEARTBEAT_TIMEOUT=2]="HEARTBEAT_TIMEOUT",e[e.CONNECT_FAILED=3]="CONNECT_FAILED",e[e.TOKEN_ERROR=4]="TOKEN_ERROR"}(me||(me={})),function(e){e[e.TOO_FREQUENTLY=-1]="TOO_FREQUENTLY",e[e.AUTO_RECONNECTING=-2]="AUTO_RECONNECTING",e[e.EXCEEDED_LIMIT_RERTY_TIMES=-3]="EXCEEDED_LIMIT_RERTY_TIMES",e[e.FETCH_ERROR=-4]="FETCH_ERROR",e[e.INVALID_SERVER_SESSION=-5]="INVALID_SERVER_SESSION",e[e.MODE_FORBIDDEN=-6]="MODE_FORBIDDEN"}(_e||(_e={})),function(e){e.ACK="ack",e.HB="hb",e.CD="cd",e.KM="km",e.SVR="svr",e.SV="sv",e.CLOUD_DEVICE="cloud_device"}(ge||(ge={})),function(e){e[e.CLOSE_HIGH_FREQUENCY=0]="CLOSE_HIGH_FREQUENCY",e[e.UNPACKAGE_SEND=1]="UNPACKAGE_SEND",e[e.PACKAGE_SEND=2]="PACKAGE_SEND",e[e.LIMIT_LENGTH=3]="LIMIT_LENGTH"}(ye||(ye={})),function(e){e[e.touchstart=0]="touchstart",e[e.touchmove=1]="touchmove",e[e.touchend=2]="touchend",e[e.touchcancel=2]="touchcancel"}(Se||(Se={})),function(e){e[e.mousedown=0]="mousedown",e[e.mousemove=1]="mousemove",e[e.mouseup=2]="mouseup"}(be||(be={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STREAM_NOT_FOUND=4e3]="STREAM_NOT_FOUND",e[e.STREAM_EXIST=4001]="STREAM_EXIST",e[e.PARAM_ERROR=4002]="PARAM_ERROR",e[e.SERVER_ERROR=5e3]="SERVER_ERROR",e[e.BACK_TO_SOURCE_ERROR=5001]="BACK_TO_SOURCE_ERROR",e[e.BACK_TO_SOURCE_REQ_PARAM_ERROR=5002]="BACK_TO_SOURCE_REQ_PARAM_ERROR",e[e.BACK_TO_SOURCE_RES_PARAM_ERROR=5003]="BACK_TO_SOURCE_RES_PARAM_ERROR"}(ke||(ke={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.BUSY=1]="BUSY",e[e.TOKEN_ERROR=2]="TOKEN_ERROR",e[e.SDP_ERROR=6]="SDP_ERROR",e[e.WAIT_HOST=8]="WAIT_HOST",e[e.PLAYERS_NUMBER_OR_ROLE_LIMIT=9]="PLAYERS_NUMBER_OR_ROLE_LIMIT",e[e.PROXY_ERROR=100]="PROXY_ERROR"}(Ee||(Ee={}));const Ce="function"==typeof atob,Ie="function"==typeof btoa,we="function"==typeof Buffer,Re="function"==typeof TextDecoder?new TextDecoder:void 0,Ae="function"==typeof TextEncoder?new TextEncoder:void 0,Oe=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),xe=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(Oe),Pe=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,De=String.fromCharCode.bind(String),Me="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=e=>e)=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),Ne=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Le=Ie?e=>btoa(e):we?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,i,o="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(i=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|i,o+=Oe[t>>18&63]+Oe[t>>12&63]+Oe[t>>6&63]+Oe[63&t]}return s?o.slice(0,s-3)+"===".substring(s):o},Ue=we?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(De.apply(null,e.subarray(n,n+4096)));return Le(t.join(""))},Ve=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?De(192|t>>>6)+De(128|63&t):De(224|t>>>12&15)+De(128|t>>>6&63)+De(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return De(240|t>>>18&7)+De(128|t>>>12&63)+De(128|t>>>6&63)+De(128|63&t)},Fe=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Be=we?e=>Buffer.from(e,"utf8").toString("base64"):Ae?e=>Ue(Ae.encode(e)):e=>Le(e.replace(Fe,Ve)),je=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Ge=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return De(55296+(t>>>10))+De(56320+(1023&t));case 3:return De((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return De((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},He=Ce?e=>atob(Ne(e)):we?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!Pe.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,i="";for(let o=0;o<e.length;)t=xe[e.charAt(o++)]<<18|xe[e.charAt(o++)]<<12|(n=xe[e.charAt(o++)])<<6|(r=xe[e.charAt(o++)]),i+=64===n?De(t>>16&255):64===r?De(t>>16&255,t>>8&255):De(t>>16&255,t>>8&255,255&t);return i},We=we?e=>Me(Buffer.from(e,"base64")):e=>Me(He(e),(e=>e.charCodeAt(0))),Ke=we?e=>Buffer.from(e,"base64").toString("utf8"):Re?e=>Re.decode(We(e)):e=>He(e).replace(je,Ge),ze=(e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(Be(e)):Be(e),qe=e=>Ke(Ne(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))));var Je=E8(23),Ye=E8.n(Je),Xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},$e=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Qe=function(){return!(!document.fullscreenElement&&!document.webkitIsFullScreen)},Ze=function(){return!!(/Android|iPhone|iPad|iOS|Phone/i.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>0)},et=function(e,t){for(var n=0,r=t-"".concat(e).length;n<r;n++)e="0".concat(e);return"".concat(e)},tt=function(e,t){return t.replace(/yyyy|YYYY/,e.getFullYear()).replace(/yy|YY/,et(e.getFullYear()%100,2)).replace(/mm|MM/,et(e.getMonth()+1,2)).replace(/m|M/g,e.getMonth()+1).replace(/dd|DD/,et(e.getDate(),2)).replace(/d|D/g,e.getDate()).replace(/hh|HH/,et(e.getHours(),2)).replace(/h|H/g,e.getHours()).replace(/ii|II/,et(e.getMinutes(),2)).replace(/i|I/g,e.getMinutes()).replace(/ss|SS/,et(e.getSeconds(),2)).replace(/s|S/g,e.getSeconds()).replace(/w/g,e.getDay()).replace(/W/g,["日","一","二","三","四","五","六"][e.getDay()])},nt=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},rt=function(){var e=!1,t=navigator.userAgent,n=function(e,t){var n,r,i=navigator.mimeTypes;try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(i),s=o.next();!s.done;s=o.next())if(s.value[e]===t)return!0}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1};if(t.indexOf("QihooBrowser")>-1||t.indexOf("QHBrowser"),t.indexOf("360EE"),t.indexOf("360SE"),t.indexOf("2345Explorer")>-1||t.indexOf("Mb2345Browser")>-1||t.indexOf("2345chrome"),t.indexOf("Mobi")>-1||t.indexOf("iPh")>-1||t.indexOf("480"),window.chrome){var r=t.replace(/^.*Chrome\/([\d]+).*$/,"$1");window.chrome.adblock2345||window.chrome.common2345||(n("type","application/360softmgrplugin")||n("type","application/mozilla-npqihooquicklogin")||r>36&&window.showModalDialog?e=!0:r>45&&!(e=n("type","application/vnd.chromium.remoting-viewer"))&&r>=69&&(e=n("type","application/hwepass2001.installepass2001")||n("type","application/asx")))}return e},it=function(e,t){return void 0===t&&(t=2),Math.floor(10*e*t)/(10*t)},ot=function(){return+(+new Date+Math.round(1e4*Math.random()))},st={},at=function(){var e,t,n=Xe(null===(t=null===(e=null===Ye()||void 0===Ye()?void 0:Ye().os)||void 0===e?void 0:e.version)||void 0===t?void 0:t.split("."),2),r=n[0],i=n[1];return r&&i?+"".concat(r,".").concat(i):0},ct=function(){return!(function(){var e,t,n;return(null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===e?void 0:e.includes("iOS"))||(null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===t?void 0:t.includes("iPhone"))||(null===(n=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===n?void 0:n.includes("iPad"))}()&&at()<15.4)},ut=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(void 0,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(t){switch(t.label){case 0:return[4,new Blob($e([],Xe(e),!1)).arrayBuffer()];case 1:return[2,t.sent()]}}))}))},dt=E8(586),lt=E8.n(dt),ht={"120p":{width:160,height:120,frameRate:30,bitrate:200,type:"120p"},"180p":{width:320,height:180,frameRate:30,bitrate:350,type:"180p"},"240p":{width:320,height:240,frameRate:30,bitrate:400,type:"240p"},"360p":{width:640,height:360,frameRate:30,bitrate:800,type:"360p"},"480p":{width:640,height:480,frameRate:30,bitrate:900,type:"480p"},"720p":{width:1280,height:720,frameRate:30,bitrate:1500,type:"720p"},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2e3,type:"1080p"}},pt=function(){function e(){this.requestQueue=[]}return e.prototype.startBlocking=function(){var e,t=new Promise((function(t){return e=t}));return this.requestQueue.push(e),t},e.prototype.nextTask=function(){this.requestQueue.length<=0||this.requestQueue.shift()()},e.prototype.clearQueue=function(){this.requestQueue=[]},e}(),ft=function(){return ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ft.apply(this,arguments)},vt=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},mt=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},_t={},gt=function(){function e(e){var t=e.sdk;this.forceShowCursor=!1,this.forceLockCursor=!1,this.showCursor=!0,this.remoteCursorMode=ve.LOCAL,this.mobileCursorScale=1,this.mobileShowCursor=!0,this.originCursorStyle="",this.hotSpot={x:0,y:0},this.remoteCursorImage="",this.token="",this.keepLastFrame=!1,this.serverSideDescription="",this.latestActionTime=+new Date,this.receivedOnloadedmetadataCallback=!1,this.connectBeginTime=0,this.connectTimeoutCount=0,this.connectStatus=fe.DISCONNECTED,this.heartbeatTimer=null,this.newConnectTimeout=60,this.noflowTimeout=10,this.peerConnection=null,this.kmDataChannel=null,this.ackDataChannel=null,this.hbDataChannel=null,this.cdDataChannel=null,this.svrDataChannel=null,this.cloudDeviceDataChannel=null,this.customDataChannel=new Map,this.ackDataChannelTimer=null,this.mediaStream=null,this.audioMediaStream=null,this.camera=null,this.mic=null,this.cameraMediaStream=null,this.micMediaStream=null,this.audioTransceiver=null,this.videoTransceiver=null,this.cameraProfile=ht["720p"],this.micProfile={sampleRate:44100,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,deviceId:null},this.switchCameraRequestQueue=new pt,this.switchCameraRequesting=!1,this.switchMicRequestQueue=new pt,this.switchMicRequesting=!1,this.clientSideDescription=null,this.requestId="",this.firstHitInput=!0,this.dataChannelCallbacks={},this.dataChannelRetryTimers={},this.checkMouseShowInterval=null,this.idleThreshold=3e5,this.idleTimes=0,this.lastInputStatus=!1,this.noFlowCount=0,this.gameStatus="playing",this.streamPushStat=null,this._webrtcStartTime=null,this.sdk=null,this.mount=null,this.sdk=t}return Object.defineProperty(e.prototype,"webrtcStartTime",{get:function(){return this._webrtcStartTime},enumerable:!1,configurable:!0}),e.prototype.init=function(e){var t,n,r=this;if(this.sdk.log("CloudGamingWebRTC init"),this.forceShowCursor=null!==(t=e.forceShowCursor)&&void 0!==t&&t,this.idleThreshold=e.idleThreshold?1e3*e.idleThreshold:3e5,this.keepLastFrame=null!==(n=e.keepLastFrame)&&void 0!==n&&n,this.mount=e.mount,this.peerConnection)return this.sdk.log("please disconnect(this.sdk.destroy()) before init"),this.sdk.onInitSuccess({code:-2,msg:"please disconnect(this.sdk.destroy()) before init"});var i=5,o=function(){return vt(r,0,void 0,(function(){var e,t=this;return mt(this,(function(n){switch(n.label){case 0:if(this.sdk.isMobileGame&&!this.sdk.getInitOptions().mobileVpx&&(r=!1,!(window.RTCRtpReceiver&&(null===RTCRtpReceiver||void 0===RTCRtpReceiver?void 0:RTCRtpReceiver.getCapabilities)?(RTCRtpReceiver.getCapabilities("video").codecs.forEach((function(e){"video/H264"!==e.mimeType||(r=!0)})),r):(console.log("RTCRtpReceiver.getCapabilities is not a function"),1))))return setTimeout((function(){return vt(t,0,void 0,(function(){var e;return mt(this,(function(t){switch(t.label){case 0:return 0!=(i-=1)?[3,2]:(e=this,[4,this.newWebRtcConnect()]);case 1:return e.clientSideDescription=t.sent(),this.sdk.onInitSuccess({code:-1,description:this.clientSideDescription}),[2];case 2:return[4,o()];case 3:return t.sent(),[2]}}))}))}),100),this.sdk.onWebrtcStatusChange({code:-2}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),e=this,[4,this.newWebRtcConnect()];case 2:return e.clientSideDescription=n.sent(),this.sdk.onInitSuccess({code:0,msg:"ok",description:this.clientSideDescription}),[3,4];case 3:return n.sent(),this.sdk.onInitSuccess({code:-1,msg:"your browser without webrtc support",description:this.clientSideDescription}),[3,4];case 4:return[2]}var r}))}))};o()},Object.defineProperty(e.prototype,"debugSetting",{get:function(){return this.sdk.getInitOptions().debugSetting||{}},enumerable:!1,configurable:!0}),e.prototype.sendKmData=function(e){this.idleTimes=0,this.latestActionTime=+new Date,this.debugSetting.showSendKmData&&console.log("sendKmData",e),this.dataChannelSend(this.kmDataChannel,e)},e.prototype.sendAckData=function(e){var t=e.data,n=void 0===t?_t:t,r=e.retry,i=void 0===r?0:r,o=e.callback,s=void 0===o?nt:o,a=e.interval,c=void 0===a?1e3:a,u=n.type;"cursor_state"!==u&&"keys_clean"!==u&&(this.latestActionTime=+new Date,this.idleTimes=0);var d=ot();this.dataChannelSendWithCallback({dataChannel:this.ackDataChannel,ackMsg:{seq:d,data:n},retry:i,callback:s,interval:c}),this.debugSetting.showSendAckData&&("cursor_state"===u||console.log("sendAckData:",n,d))},e.prototype.sendCloudDeviceData=function(e){this.debugSetting.showSendCloudDeviceData&&console.log("sendCloudDeviceData",e),this.dataChannelSend(this.cloudDeviceDataChannel,e)},e.prototype.connect=function(e){var t,n,r;void 0===e&&(e=""),this.sdk.log("connect->"),this.sdk.showStats.setServerSessionTime(+new Date);var i=+new Date;if(i-this.connectBeginTime<5e3)return this.sdk.log("connect too frequently, last is ".concat(Math.ceil((i-this.connectBeginTime)/1e3),"s")),this.clearPeerConnection(),void this.sdk.onConnectFailed({code:_e.TOO_FREQUENTLY,msg:"connect too frequently"});"connected"!==(null===(t=this.peerConnection)||void 0===t?void 0:t.connectionState)&&"connecting"!==(null===(n=this.peerConnection)||void 0===n?void 0:n.connectionState)||this.sdk.log("peerConnection status is ".concat(null===(r=this.peerConnection)||void 0===r?void 0:r.connectionState,", please clear current connection before call this.sdk.start()")),this.connectBeginTime=i,this.connectTimeoutCount=0,this.connectStatus=fe.CONNECTING;try{this.serverSideDescription=qe(e)}catch(e){throw"serverSession is not base64 string format"}this.serverSideDescription?this.onAnswer(this.serverSideDescription):this.sdk.onWebrtcStatusChange({code:-1,msg:"set server description failed, please try again later."})},e.prototype.getClientSideDescription=function(e){void 0===e&&(e=!0),this.clientSideDescription||console.error("webrtc is not initialized");try{return e?ze(JSON.stringify(this.clientSideDescription)):this.clientSideDescription}catch(e){console.error("clientSideDescription is not jsonString or encoding failure")}},e.prototype.newWebRtcConnect=function(){return vt(this,0,void 0,(function(){var e,t,n,r=this;return mt(this,(function(i){switch(i.label){case 0:this._webrtcStartTime=+new Date;try{this.peerConnection=new RTCPeerConnection({sdpSemantics:"unified-plan"})}catch(e){if(this.sdk.log("new RTCPeerConnection error",e),"ReferenceError"===e.name&&e.message.includes("RTCPeerConnection"))throw this.sdk.onWebrtcStatusChange({code:255,msg:"your browser without webrtc support"}),console.log("your browser without webrtc support"),"your browser without webrtc support";return[2]}return this.connectStatus=fe.CONNECTING,this.peerConnection.ontrack=function(e){return r.onTrack(e)},this.peerConnection.onconnectionstatechange=function(){var e;r.sdk.log("onconnectionstatechange",null===(e=r.peerConnection)||void 0===e?void 0:e.connectionState)},this.peerConnection.oniceconnectionstatechange=function(){return r.onIceConnectionStateChange()},this.peerConnection.onicecandidate=function(){},this.peerConnection.onnegotiationneeded=function(){r.sdk.log("onnegotiationneeded")},(null===navigator||void 0===navigator?void 0:navigator.mediaDevices)&&(navigator.mediaDevices.ondevicechange=function(e){r.sdk.onDeviceChange(e)}),this.createKmDataChannel(),this.createHbDataChannel(),this.createAckDataChannel(),this.createSvrDataChannel(),this.createCloudDeviceDataChannel(),this.sdk.showStats.toggleMetricReportBulk(!0),e=this.sdk.getInitOptions(),t=e.mic,n=e.camera,null===this.mic&&(this.mic=t),null===this.camera&&(this.camera=n),[4,this.createOffer({mic:this.mic,camera:this.camera})];case 1:return[2,i.sent()]}}))}))},e.prototype.startHeartbeatReport=function(){var e=this;clearInterval(this.heartbeatTimer),this.sdk.log("startHeartbeatReport ->"),this.heartbeatTimer=setInterval((function(){return vt(e,0,void 0,(function(){var e,t,n;return mt(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.peerConnection)||void 0===n?void 0:n.getStats(null)];case 1:return e=r.sent(),t=[],null==e||e.forEach((function(e){void 0===e&&(e={}),"inbound-rtp"!==e.type&&"track"!==e.type&&"codec"!==e.type||t.push(e)})),0===t.length&&(t=[{type:"inbound-rtp",mediaType:"video"},{type:"track",jitterBufferDelay:100*Math.random()%30+10}]),this.sdk.showStats.setStat(t,e),this.reportStat(),[2]}}))}))}),1e3)},e.prototype.getCursorShowStatus=function(){return!(!this.sdk.isMobileGame&&"touch"!==this.sdk.pageEvent.getClientInteractMode())||this.showCursor},e.prototype.mouseDeltaMove=function(){return this.remoteCursorMode===ve.REMOTE_SRC_POS||this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS},e.prototype.lockMouse=function(e){var t,n,r;return vt(this,0,void 0,(function(){var i;return mt(this,(function(o){switch(o.label){case 0:if("touch"===this.sdk.pageEvent.getClientInteractMode())return[2];if(!e)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,null===(n=(t=this.sdk.getVideoElement()).requestPointerLock)||void 0===n?void 0:n.call(t)];case 2:return o.sent(),[3,4];case 3:return i=o.sent(),this.sdk.log("requestPointerLock error",i),this.sdk.onEvent({type:"pointerlockerror"}),[3,4];case 4:return[3,6];case 5:try{null===(r=document.exitPointerLock)||void 0===r||r.call(document)}catch(e){this.sdk.log("exitPointerLock error",e)}o.label=6;case 6:return this.remoteCursorMode===ve.REMOTE_SRC_POS&&(e?this.sdk.pageEvent.setDropMouseEvent(!1):this.sdk.pageEvent.setDropMouseEvent(!0)),[2]}}))}))},e.prototype.isMouseLocked=function(){return document.pointerLockElement===this.sdk.getVideoElement()},e.prototype.setForceShowCursor=function(e){this.forceShowCursor=e},e.prototype.setForceLockCursor=function(e){this.forceLockCursor=e},e.prototype.getForceShowCursor=function(){return this.forceShowCursor},e.prototype.clearPeerConnection=function(){if(this.mediaStream&&(this.mediaStream.getTracks().forEach((function(e){e.stop()})),this.mediaStream=null),this.dataChannelCallbacks={},this.peerConnection){this.kmDataChannel&&(this.kmDataChannel.close(),this.kmDataChannel=null),this.hbDataChannel&&(this.hbDataChannel.close(),this.hbDataChannel=null),this.ackDataChannel&&(this.ackDataChannel.close(),this.ackDataChannel=null),this.cdDataChannel&&(this.cdDataChannel.close(),this.cdDataChannel=null),this.svrDataChannel&&(this.svrDataChannel.close(),this.svrDataChannel=null),this.customDataChannel.size&&(this.customDataChannel.forEach((function(e){return e.close()})),this.customDataChannel.clear()),this.videoTransceiver&&(this.switchTrack({type:"video",status:"remove",userMedia:this.cameraMediaStream}),this.videoTransceiver=null),this.audioTransceiver&&(this.switchTrack({type:"audio",status:"remove",userMedia:this.micMediaStream}),this.audioTransceiver=null),this.peerConnection.close(),this.peerConnection.ontrack=null,this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onicecandidate=null,this.peerConnection=null;var e=this.sdk.getVideoElement();(null==e?void 0:e.srcObject)&&(e.srcObject=null)}this.clientSideDescription=null,this.serverSideDescription=null,clearInterval(this.heartbeatTimer),this.checkMouseShowInterval&&(clearInterval(this.checkMouseShowInterval),this.checkMouseShowInterval=null),this.sdk.showStats.toggleMetricReportBulk(!1),this.sdk.pageEvent.clearEvent(),this.receivedOnloadedmetadataCallback=null},e.prototype.disconnected=function(e){var t,n=e.message,r=void 0===n?"":n,i=e.code,o=void 0===i?null:i;this.sdk.log("disconnected",o,r),this.connectStatus=fe.DISCONNECTED,this.keepLastFrame&&(null===(t=this.sdk.getVideoElement())||void 0===t||t.pause()),o===me.OTHER_KICK&&this.sdk.getRestartElement()&&(this.sdk.getRestartElement().style.display="block"),this.clearPeerConnection(),this.sdk.getInitOptions().reconnect&&o===me.NEED_RECONNECT?this.reconnect({message:r}):(this.sdk.log("destroy code: ".concat(o," and clear reconnect token")),this.sdk.watchdog.setReconnectInfo({serverIp:"",token:""})),this.sdk.onDisconnect({code:o,msg:r}),this.sdk.log("call onDisconnect, code",o)},e.prototype.reconnect=function(e){var t=e.message,n=void 0===t?"":t;this.sdk.log("reconnect, setup reconnect server_ip=".concat(this.gameConfig.server_ip," and token=").concat(this.token)),this.sdk.watchdog.setReconnectInfo({serverIp:this.gameConfig.server_ip,token:this.token}),this.sdk.watchdog.autoReconnect({message:n})},e.prototype.getRemoteCursorState=function(e){this.sendAckData({data:{type:e}})},e.prototype.getIdleTime=function(){return+new Date-this.latestActionTime},e.prototype.checkUserIdle=function(){var e=this.getIdleTime();if(e>this.idleThreshold){var t=Math.floor(e/this.idleThreshold);t>this.idleTimes&&(this.sdk.onNetworkChange({status:"idle",times:t}),this.sdk.onEvent({type:"idle",data:{times:t}}),this.idleTimes=t)}},e.prototype.setCursorMode=function(e){var t=this,n=e;e===ve.REMOTE_SRC_POS&&(n=ve.REMOTE_SRC);var r=n===ve.REMOTE_DRAW;if(this.sendAckData({data:{type:"set_cursor",show:n},callback:function(){t.setCursorShowStatus(!r)}}),this.remoteCursorMode=e,e===ve.REMOTE_SRC||e===ve.FRONT_DRAW_DELTA_POS?this.createCdDataChannel():this.cdDataChannel&&(this.cdDataChannel.close(),this.cdDataChannel=null),e===ve.LOCAL){var i=this.sdk.getVideoElement();i&&(this.sdk.log("videoElement.style.cursor will set to origin style",this.originCursorStyle),i.style.cursor="url(".concat(this.originCursorStyle,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto"))}e===ve.FRONT_DRAW_DELTA_POS&&this.lockMouse(!0)},e.prototype.getCursorMode=function(){return this.remoteCursorMode},e.prototype.getCursorHotSpot=function(){return this.hotSpot},e.prototype.setMobileCursorScale=function(e){this.mobileCursorScale=e},e.prototype.getDisplayRect=function(){var e,t=(null===(e=this.sdk.getVideoElement())||void 0===e?void 0:e.getBoundingClientRect())||_t,n=t.width,r=void 0===n?0:n,i=t.height,o=void 0===i?0:i,s=t.left,a=void 0===s?0:s,c=t.top;return{left:a,top:void 0===c?0:c,width:r,height:o,pixelRatio:window.devicePixelRatio||1}},e.prototype.setDefaultCursorImage=function(e){if(Ze()){var t=this.sdk.getCursorElement();"dot"===e?(t.style.width="3px",t.style.height="3px",t.style.borderRadius="50%",t.style.backgroundColor="#2dc7ef"):(t.style.width="26px",t.style.height="26px",t.style.backgroundImage="url(".concat(e,")"))}else{var n=this.sdk.getVideoElement();this.originCursorStyle=null!=e?e:"",n.style.cursor="url(".concat(e,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto")}},e.prototype.setNewConnectTimeout=function(e){void 0===e&&(e=60),this.newConnectTimeout=e},e.prototype.setNoflowTimeout=function(e){void 0===e&&(e=10),this.noflowTimeout=e},e.prototype.setKeepLastFrame=function(e){void 0===e&&(e=!1),this.keepLastFrame=e},e.prototype.setMobileShowCursor=function(e){void 0===e&&(e=!0),this.mobileShowCursor=e},e.prototype.setGameStatus=function(e){this.gameStatus=e},e.prototype.createCustomDataChannel=function(e){var t,n,r,i=e.destPort,o=void 0===i?1:i,s=e.maxRetransmits,a=e.maxPacketLifeTime,c=e.onMessage,u=void 0===c?nt:c,d=e.onClose,l=void 0===d?nt:d,h=e.onError,p=void 0===h?nt:h,f=e.label,v=void 0===f?"":f,m=e.protocol,_=void 0===m?"text":m,g=e.type,y=void 0===g?"":g;return vt(this,0,Promise,(function(){var e,i=this;return mt(this,(function(c){switch(c.label){case 0:return"open"!==(null===(t=this.ackDataChannel)||void 0===t?void 0:t.readyState)?[2,{code:1,msg:"ack dataChannel does not open, please try again later."}]:(v||(v="cs".concat(y?"_".concat(y):"","_").concat(o)),this.sdk.log("start createCustomDataChannel, destPort: ".concat(o,", ackDataChannel state: ").concat(null===(n=this.ackDataChannel)||void 0===n?void 0:n.readyState,", label: ").concat(v,", protocol: ").concat(_,", maxRetransmits: ").concat(s,", maxRetransmits: ").concat(a)),(e=null===(r=this.peerConnection)||void 0===r?void 0:r.createDataChannel(v,{ordered:!0,maxRetransmits:s,maxPacketLifeTime:a}))?(e.onmessage=function(e){var t,n;i.sdk.log("dataChannel:".concat(v," onmessage"),"string"==typeof e.data?null===(t=e.data)||void 0===t?void 0:t.length:null===(n=e.data)||void 0===n?void 0:n.byteLength),u(e.data)},e.onclose=function(e){return l(e)},e.onerror=function(e){return p(e)},this.customDataChannel.set(o,e),[4,new Promise((function(e){i.sendAckData({data:{type:"udp_trans",dest_port:o,protocol:_,label:v},callback:function(t){var n=t.data;i.sdk.log("createCustomDataChannel label:".concat(v," destPort:").concat(o," success"),n),e({code:n.code,msg:n.msg})}}),i.sdk.log("customDataChannels",i.customDataChannel),setTimeout((function(){e({code:3,msg:"request timeout, please try again later."})}),5e3)}))]):[3,2]);case 1:return[2,c.sent()];case 2:return this.sdk.log("createCustomDataChannel fail"),[2,{code:1}]}}))}))},e.prototype.sendCustomDataChannelMessage=function(e){var t=e.destPort,n=void 0===t?0:t,r=e.msg,i=void 0===r?"":r,o=this.customDataChannel.get(n);"open"===(null==o?void 0:o.readyState)&&(this.sdk.log("sendCustomDataChannelMessage",i.length,n,null==o?void 0:o.readyState),o.send(i))},e.prototype.setTrackEnable=function(e){var t=e.type,n=void 0===t?"audio":t,r=e.enable,i=void 0===r||r;if(this.sdk.log("setTrackEnable type",n,"enable",i),"audio"===n)return this.audioTransceiver.sender?(this.audioTransceiver.sender.track.enabled=i,this.sdk.log("audioTransceiver.sender",this.audioTransceiver.sender,i),{code:0}):{code:1,message:"audioTransceiver.sender is null"}},e.prototype.switchTrack=function(e){var t,n,r,i,o=e.type,s=e.status,a=e.userMedia;return vt(this,0,Promise,(function(){var e;return mt(this,(function(c){switch(c.label){case 0:return this.sdk.log("switchTrack type",o,"status",s),"audio"!==o?[3,6]:this.audioTransceiver.sender?"add"!==s?[3,2]:(e=null===(t=null==a?void 0:a.getAudioTracks())||void 0===t?void 0:t[0],[4,this.audioTransceiver.sender.replaceTrack(e)]):[3,5];case 1:c.sent(),c.label=2;case 2:return"remove"!==s?[3,4]:[4,this.audioTransceiver.sender.replaceTrack(null)];case 3:c.sent(),null===(n=null==a?void 0:a.getAudioTracks()[0])||void 0===n||n.stop(),c.label=4;case 4:return[2,{code:0,message:"success"}];case 5:return[2,{code:1,message:"audioTransceiver.sender is null"}];case 6:return"video"!==o?[3,12]:this.videoTransceiver.sender?"add"!==s?[3,8]:(e=null===(r=null==a?void 0:a.getVideoTracks())||void 0===r?void 0:r[0],[4,this.videoTransceiver.sender.replaceTrack(e)]):[3,11];case 7:c.sent(),c.label=8;case 8:return"remove"!==s?[3,10]:[4,this.videoTransceiver.sender.replaceTrack(null)];case 9:c.sent(),null===(i=null==a?void 0:a.getVideoTracks()[0])||void 0===i||i.stop(),c.label=10;case 10:return[2,{code:0,message:"success"}];case 11:return[2,{code:2,message:"videoTransceiver.sender is null"}];case 12:return[2]}}))}))},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.getUserMedia=function(){var e,t,n=new MediaStream;return null===(e=this.cameraMediaStream)||void 0===e||e.getTracks().forEach((function(e){n.addTrack(e)})),null===(t=this.micMediaStream)||void 0===t||t.getTracks().forEach((function(e){n.addTrack(e)})),n},e.prototype.switchMic=function(e){var t,n=e.status,r=e.profile;return vt(this,0,Promise,(function(){var e,i,o,s,a,c;return mt(this,(function(u){switch(u.label){case 0:if(this.sdk.log("switchMic status",n,r),"open"!==n)return[3,5];if(null===(t=this.audioTransceiver.sender)||void 0===t?void 0:t.track)return this.sdk.log("mic opened, audioTransceiver sender",this.audioTransceiver.sender),[2,{code:1,msg:"mic opened",userMedia:null}];u.label=1;case 1:return u.trys.push([1,4,,5]),e=this,[4,this.createUserMedia({mic:null==r||r})];case 2:return e.micMediaStream=u.sent(),[4,this.switchTrack({type:"audio",status:"add",userMedia:this.micMediaStream})];case 3:return i=u.sent(),a=i.code,c=i.message,this.mic=r,this.sdk.onGetUserMediaStatusChange({msg:"mic open",type:"mic",userMedia:this.micMediaStream}),this.sendAckData({data:{type:"switch_mic",status:"open"}}),[2,{code:a,msg:c,userMedia:this.micMediaStream}];case 4:return o=u.sent(),this.sdk.onGetUserMediaStatusChange({msg:o,type:"mic"}),[2,{code:1,msg:o,userMedia:null}];case 5:return"close"!==n?[3,7]:[4,this.switchTrack({type:"audio",status:"remove",userMedia:this.micMediaStream})];case 6:return s=u.sent(),a=s.code,c=s.message,this.mic=!1,this.sdk.onGetUserMediaStatusChange({msg:"mic close",type:"mic"}),this.sendAckData({data:{type:"switch_mic",status:"close"}}),[2,{code:a,msg:c,userMedia:null}];case 7:return[2]}}))}))},e.prototype.switchCamera=function(e){var t,n=e.status,r=e.profile;return vt(this,0,Promise,(function(){var e,i,o,s,a,c;return mt(this,(function(u){switch(u.label){case 0:if(this.sdk.log("switchCamera status",n),"open"!==n)return[3,5];if(null===(t=this.videoTransceiver.sender)||void 0===t?void 0:t.track)return this.sdk.log("camera opened, videoTransceiver sender",this.videoTransceiver.sender),[2,{code:1,msg:"camera opened",userMedia:null}];u.label=1;case 1:return u.trys.push([1,4,,5]),e=this,[4,this.createUserMedia({camera:null==r||r})];case 2:return e.cameraMediaStream=u.sent(),[4,this.switchTrack({type:"video",status:"add",userMedia:this.cameraMediaStream})];case 3:return i=u.sent(),a=i.code,c=i.message,this.camera=r,this.sdk.onGetUserMediaStatusChange({msg:"camera open",type:"camera",userMedia:this.cameraMediaStream}),this.sendAckData({data:{type:"switch_camera",status:"open"}}),[2,{code:a,msg:c,userMedia:this.cameraMediaStream}];case 4:return o=u.sent(),this.sdk.onGetUserMediaStatusChange({msg:o,type:"camera"}),[2,{code:1,msg:o,userMedia:null}];case 5:return"close"!==n?[3,7]:[4,this.switchTrack({type:"video",status:"remove",userMedia:this.cameraMediaStream})];case 6:return s=u.sent(),a=s.code,c=s.message,this.camera=!1,this.sendAckData({data:{type:"switch_camera",status:"close"}}),this.sdk.onGetUserMediaStatusChange({msg:"camera close",type:"camera"}),[2,{code:a,msg:c,userMedia:this.cameraMediaStream}];case 7:return[2]}}))}))},e.prototype.setMicProfile=function(e){var t,n;return vt(this,0,Promise,(function(){var r,i;return mt(this,(function(o){switch(o.label){case 0:if(this.sdk.log("setMicProfile",e),!this.mic)return this.sdk.log("please open mic"),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r=this,[4,this.createUserMedia({mic:e})];case 2:return r.micMediaStream=o.sent(),this.micMediaStream?(null===(t=this.audioTransceiver.sender)||void 0===t||t.replaceTrack(null===(n=this.micMediaStream.getAudioTracks())||void 0===n?void 0:n[0]),this.sdk.onGetUserMediaStatusChange({msg:"setMicProfile success",type:"mic",userMedia:this.micMediaStream}),[2,{code:0,msg:"success",userMedia:this.micMediaStream}]):[3,4];case 3:return i=o.sent(),this.sdk.onGetUserMediaStatusChange({msg:i,type:"mic"}),[2,{code:1,msg:i,userMedia:null}];case 4:return[2]}}))}))},e.prototype.setCameraProfile=function(e){var t,n;return vt(this,0,Promise,(function(){var r,i;return mt(this,(function(o){switch(o.label){case 0:if(this.sdk.log("setCameraProfile",e),!this.camera)return this.sdk.log("please open camera"),[2];if("string"==typeof e&&e===this.cameraProfile.type)return this.sdk.log("profile is same as last value"),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r=this,[4,this.createUserMedia({camera:e})];case 2:return r.cameraMediaStream=o.sent(),this.cameraMediaStream?(null===(t=this.videoTransceiver.sender)||void 0===t||t.replaceTrack(null===(n=this.cameraMediaStream.getVideoTracks())||void 0===n?void 0:n[0]),this.sdk.onGetUserMediaStatusChange({msg:"setCameraProfile success",type:"camera",userMedia:this.cameraMediaStream}),[2,{code:0,msg:"success",userMedia:this.cameraMediaStream}]):[3,4];case 3:return i=o.sent(),this.sdk.onGetUserMediaStatusChange({msg:i,type:"camera"}),[2,{code:1,msg:i,userMedia:null}];case 4:return[2]}}))}))},e.prototype.setCameraBitrate=function(e){return vt(this,0,void 0,(function(){var t,n;return mt(this,(function(r){switch(r.label){case 0:if(!("RTCRtpSender"in window)||!("setParameters"in window.RTCRtpSender.prototype))return[3,7];if(!this.videoTransceiver.sender)return[3,5];(t=this.videoTransceiver.sender.getParameters()).encodings||(t.encodings=[{}]),"unlimited"===e?delete t.encodings[0].maxBitrate:t.encodings[0].maxBitrate=1e3*e,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.videoTransceiver.sender.setParameters(t)];case 2:return r.sent(),this.sdk.log("setCameraBitrate success ".concat("number"==typeof e?e:"unlimited"," kbps")),[3,4];case 3:return n=r.sent(),this.sdk.log("setCameraBitrate error",n),[3,4];case 4:return[3,6];case 5:this.sdk.log("camera sender is not found"),r.label=6;case 6:return[3,8];case 7:this.sdk.log("can not find RTCRtpSender in window"),r.label=8;case 8:return[2]}}))}))},e.prototype.getDevices=function(){return vt(this,0,void 0,(function(){var e,t,n;return mt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,navigator.mediaDevices.enumerateDevices()];case 1:return e=r.sent(),this.sdk.log("getDevices",e),t=null==e?void 0:e.filter((function(e){return e.kind.includes("input")&&"default"!==e.deviceId})),this.sdk.log("inputDevices",t),[2,t];case 2:throw n=r.sent(),this.sdk.log("getDevices error",n),n;case 3:return[2]}}))}))},e.prototype.getRequestId=function(){return this.requestId},e.prototype.getWebrtcConnectStatus=function(){return this.connectStatus},Object.defineProperty(e.prototype,"gameConfig",{get:function(){return this.sdk.gameConfig.getConfig({clientId:this.mount})},enumerable:!1,configurable:!0}),e.prototype.renegotiation=function(e){return vt(this,0,void 0,(function(){var t,n,r;return mt(this,(function(i){switch(i.label){case 0:if(this.sdk.log("renegotiation"),!ct())return this.sdk.log("renegotiation not support"),this.sdk.log("ios version is",at()),[2];i.label=1;case 1:return i.trys.push([1,3,,4]),this.sdk.log("renegotiation setRemoteDescription"),[4,this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:e,type:"offer"}))];case 2:return i.sent(),[3,4];case 3:return t=i.sent(),this.sdk.log("renegotiation setRemoteDescription exception->",t,t.message),this.sdk.onWebrtcStatusChange({code:-1,msg:"setRemoteDescription failed."}),[3,4];case 4:return i.trys.push([4,7,,8]),[4,this.peerConnection.createAnswer()];case 5:return n=i.sent(),this.sdk.log("renegotiation setLocalDescription"),[4,this.peerConnection.setLocalDescription(n)];case 6:return i.sent(),this.sendAckData({data:{type:"user_update",sdp:n.sdp}}),[3,8];case 7:return r=i.sent(),this.sdk.log("renegotiation setLocalDescription exception->",r,r.message),[3,8];case 8:return[2]}}))}))},e.prototype.onAnswer=function(e){var t,n;return void 0===e&&(e=""),vt(this,0,void 0,(function(){var r,i,o,s,a,c,u,d,l,h,p,f;return mt(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,5,,6]),r=JSON.parse(e),this.sdk.log("onAnswer-> serverSideDescriptionObject",r),!r)return[2,this.sdk.onConnectFailed({code:_e.INVALID_SERVER_SESSION,msg:"Server session not available "})];i=r.game_config,o=r.code,s=r.message,a=r.screen_config,c=r.plat,u=r.request_id,this.requestId=u,d=a.orientation,l=a.width,h=a.height,v.label=1;case 1:return v.trys.push([1,3,,4]),[4,this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:r.sdp,type:"answer"}))];case 2:return v.sent(),this.sdk.gameConfig.setConfig({clientId:this.mount,config:r}),this.setGameConfig(i),this.sdk.setServerSideDescription({serverSideDescription:r}),[3,4];case 3:return p=v.sent(),this.sdk.log("setRemoteDescription exception->",p),this.sdk.onWebrtcStatusChange({code:-1,msg:"setRemoteDescription 失败,请稍后重试."}),[3,4];case 4:return"android"===(null==c?void 0:c.toLocaleLowerCase())&&(this.sdk.mobileGame=!0,this.sdk.pageEvent.remoteScreenResolutionChange({width:null!==(t="portrait"===d?l:h)&&void 0!==t?t:0,height:null!==(n="portrait"===d?h:l)&&void 0!==n?n:0,left:0,top:0})),this.sdk.onWebrtcStatusChange({code:o>1e3?Ee.PROXY_ERROR:o,msg:s}),this.sdk.pageEvent.setRemoteScreenConfig(a),this.sdk.pageEvent.initOrientationDetector(),[3,6];case 5:return f=v.sent(),this.sdk.log("parse serverSideDescription error",f),this.sdk.onWebrtcStatusChange({code:-1,msg:"parse serverSideDescription error"}),[3,6];case 6:return[2]}}))}))},e.prototype.setGameConfig=function(e){void 0===e&&(e=_t);var t=e.sdk_conf;if(t){var n=this.sdk.getInitOptions().keepLastFrame;t.connect_timeout&&this.setNewConnectTimeout(t.connect_timeout),t.noflow_timeout&&this.setNoflowTimeout(t.noflow_timeout),t.cursor_scale&&this.setMobileCursorScale(t.cursor_scale),t.cursor_style&&this.sdk.setRemoteCursorStyle(t.cursor_style),"boolean"==typeof t.keep_lastframe&&void 0===n&&this.setKeepLastFrame(t.keep_lastframe),"boolean"==typeof t.mobile_show_cursor&&this.setMobileShowCursor(t.mobile_show_cursor)}},e.prototype.createUserMedia=function(e){var t=e.mic,n=void 0!==t&&t,r=e.camera,i=void 0!==r&&r;return vt(this,0,void 0,(function(){var e,t,r,o,s,a,c,u,d,l,h;return mt(this,(function(p){switch(p.label){case 0:return n?(this.sdk.log("createUserMedia mic",n),e=null,"object"!=typeof n?[3,2]:(this.micProfile=ft(ft({},this.micProfile),n),u=this.micProfile.deviceId,[4,this.getDevices()])):[3,6];case 1:d=p.sent().map((function(e){return e.deviceId})),this.sdk.log("deviceId",u),this.sdk.log("deviceIds",d),e=ft(ft({},this.micProfile),{deviceId:d.includes(u)?{exact:u}:void 0}),p.label=2;case 2:"boolean"==typeof n&&(e=n),this.sdk.log("micProfile",this.micProfile),this.sdk.log("micConstraints",e),p.label=3;case 3:return p.trys.push([3,5,,6]),[4,navigator.mediaDevices.getUserMedia({audio:e})];case 4:return[2,p.sent()];case 5:throw t=p.sent(),this.sdk.log("getUserMedia mic error",t,null==t?void 0:t.name),t.name;case 6:return i?(this.sdk.log("createUserMedia camera",i),r=null,"string"==typeof i&&(Object.keys(ht).includes(i)?this.cameraProfile=ht[i]:this.sdk.log("".concat(i," is not included in camera profile types, use default settings"))),"object"==typeof i&&(this.cameraProfile=ft(ft({},this.cameraProfile),i)),o=this.cameraProfile,s=o.width,a=o.height,c=o.frameRate,u=o.deviceId,!Ze()||"user"!==u&&"environment"!==u?[3,7]:(r={facingMode:{exact:u}},[3,10])):[3,14];case 7:return p.trys.push([7,9,,10]),[4,this.getDevices()];case 8:return d=p.sent().map((function(e){return e.deviceId})),this.sdk.log("deviceId",u),this.sdk.log("deviceIds",d),r={width:{ideal:s},height:{ideal:a},frameRate:c,deviceId:d.includes(u)?{exact:u}:void 0},[3,10];case 9:return l=p.sent(),this.sdk.log("getDevices error, use default cameraConstraints",l.message),r={width:{ideal:s},height:{ideal:a},frameRate:c},[3,10];case 10:"boolean"==typeof i&&(r=i),this.sdk.log("cameraConstraints",r),p.label=11;case 11:return p.trys.push([11,13,,14]),[4,navigator.mediaDevices.getUserMedia({video:r})];case 12:return[2,p.sent()];case 13:throw h=p.sent(),this.sdk.log("getUserMedia camera error",h,null==h?void 0:h.name),h.name;case 14:return[2]}}))}))},e.prototype.createOffer=function(e){var t=e.mic,n=void 0!==t&&t,r=e.camera,i=void 0!==r&&r;return vt(this,0,void 0,(function(){var e,t;return mt(this,(function(r){switch(r.label){case 0:return this.sdk.log("create offer","mic",n,"camera",i),this.videoTransceiver=this.peerConnection.addTransceiver("video",{direction:"sendrecv"}),this.audioTransceiver=this.peerConnection.addTransceiver("audio",{direction:"sendrecv"}),n?[4,this.switchMic({status:"open",profile:n})]:[3,2];case 1:r.sent(),r.label=2;case 2:return i?[4,this.switchCamera({status:"open",profile:i})]:[3,4];case 3:r.sent(),r.label=4;case 4:return r.trys.push([4,7,,8]),e=this.onOffer,[4,this.peerConnection.createOffer()];case 5:return[4,e.apply(this,[r.sent()])];case 6:return[2,r.sent()];case 7:return t=r.sent(),this.sdk.log("create offer error",t),this.disconnected({message:"create offer is failed",code:me.CREATE_OFFER_FAILED}),[3,8];case 8:return[2]}}))}))},e.prototype.onOffer=function(e){return vt(this,0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d,l,h;return mt(this,(function(p){switch(p.label){case 0:this.sdk.log("onOffer->",e),t=e.sdp,n=e.type,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.peerConnection.setLocalDescription({type:n,sdp:t})];case 2:return p.sent(),r=this.peerConnection.localDescription,i=function(e){void 0===e&&(e="");var t=[];return e.split("\r\n").forEach((function(e){e.includes("profile-level-id")&&(e=e.split("profile-level-id").pop().slice(1),t.push(e))})),t}(r.sdp),this.sdk.log("available profile-level-ids: ",i.join(",")),o=this.sdk.getInitOptions(),s=o.remoteDesktopResolution,a=o.streaming,c=(void 0===a?{}:a).videoCodecList,u=void 0===c?[]:c,d=o.streamProfile,l=o.userId,this.clientSideDescription={sdp:t,type:n,deviceInfo:{platform:Ze()?"mobile":"pc",user_agent:rt()?"".concat(null===navigator||void 0===navigator?void 0:navigator.userAgent," 360 browser"):null===navigator||void 0===navigator?void 0:navigator.userAgent},sdkType:"JS",desktopResolution:(null==s?void 0:s.width)&&(null==s?void 0:s.height)?"".concat(s.width,"x").concat(null==s?void 0:s.height):null,preferredCodecList:u.map((function(e){return e.toUpperCase()})),streamProfile:d,userId:l},[2,this.clientSideDescription];case 3:throw h=p.sent(),this.sdk.log("onOffer exception->",null==h?void 0:h.message,null==h?void 0:h.name),null==h?void 0:h.message;case 4:return[2]}}))}))},e.prototype.checkAckDataChannelStatus=function(){var e,t,n=this;this.sdk.log("checkAckDataChannelStatus",null===(e=this.ackDataChannel)||void 0===e?void 0:e.readyState),"open"===(null===(t=this.ackDataChannel)||void 0===t?void 0:t.readyState)?(clearInterval(this.ackDataChannelTimer),this.ackDataChannelTimer=null,this.onLoadedMetaData()):this.ackDataChannelTimer||(this.ackDataChannelTimer=setInterval((function(){n.checkAckDataChannelStatus()}),500))},e.prototype.onTrack=function(e){var t=this;if(this.sdk.log("onTrack",e.track.kind,e.track),"audio"===e.track.kind&&e.track.label.includes("|")){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(e.track.label.split("|"),2),r=n[0],i=n[1];return this.sdk.log("on audio Track",e.track.label,r,i,e.streams[0].id),this.sdk.createAudioAndAddTrack({id:i,source:e.streams[0]})}this.mediaStream||(this.mediaStream=new MediaStream),this.audioMediaStream||(this.audioMediaStream=new MediaStream),"video"===e.track.kind&&0===this.mediaStream.getVideoTracks().length&&(this.sdk.log("add video stream"),this.mediaStream.addTrack(e.track)),"audio"===e.track.kind&&0===this.mediaStream.getAudioTracks().length&&(this.sdk.log("add audio stream"),this.audioMediaStream.addTrack(e.track),function(){var e;return null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===e?void 0:e.toLocaleLowerCase().includes("huawei")}()&&this.sdk.createAudioAndAddTrack({id:"tcg-audio-huawei",source:this.audioMediaStream}));var o=this.sdk.getVideoElement();o&&(o.srcObject||(o.srcObject=this.mediaStream),"video"===e.track.kind&&(this.sdk.log("on video Track"),"onloadedmetadata"in HTMLVideoElement.prototype?(this.sdk.log("onloadedmetadata in HTMLVideoElement.prototype"),o.onloadedmetadata=function(){t.receivedOnloadedmetadataCallback||(t.sdk.log("onloadedmetadata callback"),t.receivedOnloadedmetadataCallback=!0,t.checkAckDataChannelStatus())},setTimeout((function(){t.receivedOnloadedmetadataCallback||(t.sdk.log("onloadedmetadata timeout, check status"),t.receivedOnloadedmetadataCallback=!0,t.checkAckDataChannelStatus())}),1e3)):this.checkAckDataChannelStatus()));var s=this.sdk.getAudioElement();s&&(s.srcObject||(s.srcObject=this.audioMediaStream),"audio"===e.track.kind&&this.sdk.log("on audio Track"))},e.prototype.onLoadedMetaData=function(){var e,t,n,r,i,o,s=this;if(this.sdk.log("onLoadedMetaData->"),this.connectStatus===fe.DISCONNECTED)return this.sdk.log("connectStatus is disconnected, onLoadedMetaData return");this.sdk.getCloudGamingContainerElement()&&(this.sdk.getCloudGamingContainerElement().style.display="flex"),this.sdk.getProgressBarElement()&&(this.sdk.getProgressBarElement().style.display="none"),this.sdk.getRestartElement()&&(this.sdk.getRestartElement().style.display="none"),this.sdk.getVideoElement().focus(),null===(n=null===(t=null===(e=this.sdk.getVideoElement())||void 0===e?void 0:e.play())||void 0===t?void 0:t.then((function(){s.sdk.log("video play success"),s.sdk.onEvent({type:"autoplay",data:{code:0,mediaType:"video",message:"video play success"}}),s.sdk.reshapeWindow()})))||void 0===n||n.catch((function(e){s.sdk.log("video play error, ",e,e.name),s.sdk.onEvent({type:"autoplay",data:{mediaType:"video",code:-1,message:e}})})),null===(o=null===(i=null===(r=this.sdk.getAudioElement())||void 0===r?void 0:r.play())||void 0===i?void 0:i.then((function(){s.sdk.log("audio play success"),s.sdk.onEvent({type:"autoplay",data:{code:0,message:"audio play success",mediaType:"audio"}}),s.sdk.reshapeWindow()})))||void 0===o||o.catch((function(e){s.sdk.log("audio play error, ",e,e.name),s.sdk.onEvent({type:"autoplay",data:{code:-1,message:e,mediaType:"audio"}})})),this.sdk.showStats.setConnectSuccessTime(+new Date),this.connectStatus=fe.ESTABLISHED,this.checkMouseShowInterval||(this.checkMouseShowInterval=setInterval((function(){s.checkUserIdle()}),100)),this.startHeartbeatReport(),this.sdk.onWebrtcStatsChange(pe.PLAYING,this.mount),this.sdk.onConnectSuccess({code:0,seat_index:this.gameConfig.input_seat,role:this.gameConfig.role}),this.sdk.onConfigurationChange({screen_config:this.sdk.pageEvent.getRemoteScreenConfig()})},e.prototype.onIceConnectionStateChange=function(){this.sdk.log("onIceConnectionStateChange",this.peerConnection.iceConnectionState),this.peerConnection?("connected"===this.peerConnection.iceConnectionState&&(this.sdk.showStats.setIceConnectedTime(+new Date),this.sdk.onEvent({type:"ice_state",data:{value:"connected"}})),"disconnected"===this.peerConnection.iceConnectionState&&(this.sdk.onEvent({type:"ice_state",data:{value:"disconnected"}}),this.sdk.log("The ICE disconnected, please check the network."),this.sdk.log("Follow the link, https://cloud.tencent.com/document/product/1547/75988, and check your network."),this.disconnected({message:"The ICE disconnected, please check the network.",code:me.NEED_RECONNECT}),this.sdk.onEvent({type:"ice_state",data:{value:"disconnected"}}))):this.sdk.log("The peerConnection disconnected")},e.prototype.createKmDataChannel=function(){var e=this;this.sdk.log("start createKmDataChannel"),this.kmDataChannel=this.peerConnection.createDataChannel(ge.KM,{ordered:!0,maxRetransmits:10}),this.kmDataChannel.onmessage=function(t){return e.onKmMessage(t)},this.kmDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.kmDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.kmDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createHbDataChannel=function(){var e=this;this.sdk.log("start createHbDataChannel"),this.hbDataChannel=this.peerConnection.createDataChannel(ge.HB,{ordered:!0,maxRetransmits:0}),this.hbDataChannel.onmessage=function(t){return e.onHbMessage(t)},this.hbDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.hbDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.hbDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createAckDataChannel=function(){var e=this;this.sdk.log("start createAckDataChannel"),this.ackDataChannel=this.peerConnection.createDataChannel(ge.ACK,{ordered:!0,maxRetransmits:10}),this.ackDataChannel.onmessage=function(t){return e.onAckMessage(t)},this.ackDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.ackDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.ackDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createCdDataChannel=function(){var e,t=this;this.sdk.log("start createCdDataChannel"),this.cdDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.CD,{ordered:!0,maxRetransmits:0}),this.cdDataChannel&&(this.cdDataChannel.onmessage=function(e){return t.onCdMessage(e)},this.cdDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.cdDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.cdDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.createSvrDataChannel=function(){var e,t=this;this.sdk.log("start createSvrDataChannel"),this.svrDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.SVR,{ordered:!0,maxRetransmits:0}),this.svrDataChannel&&(this.svrDataChannel.onmessage=function(e){return t.onSvrMessage(e)},this.svrDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.svrDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.svrDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.createCloudDeviceDataChannel=function(){var e,t=this;this.sdk.log("start createCloudDeviceDataChannel"),this.cloudDeviceDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.CLOUD_DEVICE,{ordered:!0,maxRetransmits:0}),this.cloudDeviceDataChannel&&(this.cloudDeviceDataChannel.onmessage=function(e){return t.onCloudDeviceMessage(e)},this.cloudDeviceDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.cloudDeviceDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.cloudDeviceDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.onDataChannelError=function(e){var t=e||{},n=t.target,r=t.error;this.sdk.log("".concat(n.label," datachannel error->"),null==r?void 0:r.message)},e.prototype.onDataChannelOpen=function(e){var t=(e||{}).target;this.sdk.log("".concat(t.label," datachannel open->"),t.readyState,t.label),"hb"===t.label&&this.startHeartbeatReport()},e.prototype.onDataChannelClose=function(e){var t=(e||{}).target;this.sdk.log("".concat(t.label," datachannel close->"),t.readyState)},e.prototype.onKmMessage=function(e){var t=JSON.parse(e.data);this.debugSetting.showOnKmMessage&&console.log("onKmMessage",t);var n=t.screen_width,r=t.screen_height,i=t.screen_left,o=t.screen_top,s=t.cursor_showing;this.sdk.pageEvent.remoteScreenResolutionChange({width:n,height:r,left:i,top:o}),this.sdk.showStats.setCpuAndGpuUsage({cpu:t.cpu_usage,gpu:t.gpu_usage}),this.setCursorShowStatus(null==s||s)},e.prototype.onHbMessage=function(e){var t=JSON.parse(e.data),n=t.token,r=t.code,i=t.user_id,o=t.timestamp,s=t.message,a=t.stream_push_state;if(n&&(this.token=n),this.debugSetting.showOnHbMessage&&console.log("onHbMessage",t),r>=0&&(this.sdk.log("onHbMessage",s),this.disconnected({message:s,code:r})),i&&this.sdk.onNetworkChange({status:"stats",stats:t}),o){var c=+new Date-+o;this.sdk.showStats.setRTT(c)&&(i?this.gameConfig.user_id===i&&this.sdk.onNetworkChange({status:"jitter",data:{value:c,message:"NETWORK_JITTER"}}):this.sdk.onNetworkChange({status:"jitter",data:{value:c,message:"NETWORK_JITTER"}}))}this.streamPushStat!==a&&(this.streamPushStat=a,this.sdk.onStreamPushStateChange({stream_push_state:this.streamPushStat}))},e.prototype.onAckMessage=function(e){try{var t=JSON.parse(e.data),n=t.data,r=void 0===n?_t:n,i=t.seq;if(this.debugSetting.showOnAckMessage&&("cursor_state"===r.type||"keys_clean"===r.type||console.log("onAckMessage",r,i)),"seats_info_sync"===r.type)return;var o=this.dataChannelCallbacks[i];if(i&&(this.sdk.showStats.setInputEnd(i),o)){var s=o.callback;delete this.dataChannelCallbacks[i],this.dataChannelRetryTimers[i]&&(clearTimeout(this.dataChannelRetryTimers[i]),delete this.dataChannelRetryTimers[i]),null==s||s({code:0,msg:"on ack message",data:r})}switch(r.type){case"cursor_state":if(!r.state)return;this.setCursorShowStatus("showing"===r.state);break;case"game_launched":this.sdk.log("game_launched",r),this.sdk.onNetworkChange({status:"gamelaunched",data:{begin:r.launch_begin,finish:r.launch_complete}});break;case"input_seat":this.sdk.log("got new input_seat",r),this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{input_seat:r.input_seat}});break;case"user_state":this.sdk.log("user state update",r),this.sdk.onMultiPlayerChange({user_state:{user_id:r.user_id,state:r.state}});break;case"open_url":this.sdk.log("got open_url",r),this.sdk.onNetworkChange({status:"openurl",data:{value:r.url}}),this.sdk.onEvent({type:"openurl",data:{value:r.url}});break;case"vmaf_test":default:break;case"user_sdk_update":this.sdk.log("user_sdk_update",r),this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:r.sdp,type:"answer"}));break;case"user_update":this.sdk.log("user_update"),this.renegotiation(r.sdp);break;case"sync_seats":this.sdk.log("sync_seats",r),o||this.sdk.onMultiPlayerChange({seats_info:{players:r.players,viewers:r.viewers}});var a=this.gameConfig.user_id,c=r.players.find((function(e){return e.name===a}));c&&(0!==c.mic_status&&1!==c.mic_status||this.setTrackEnable({type:"audio",enable:!1}),2===c.mic_status&&this.setTrackEnable({type:"audio",enable:!0}));break;case"submit_seat_change":this.sdk.log("submit_seat_change",r),o||this.sdk.onMultiPlayerChange({submit_seat_change:{user_id:r.user_id,to_role:r.to_role,seat_index:r.seat_index}});break;case"cursor_pos":if(this.remoteCursorMode===ve.REMOTE_SRC_POS){var u=r.x,d=r.y,l=this.sdk.pageEvent.transferLocalScale({width:u-this.hotSpot.x,height:d-this.hotSpot.y}),h=l.width,p=l.height;this.sdk.pageEvent.updateCursorPosition({displayX:h,displayY:p})}}}catch(e){this.sdk.log("onAckMessage exception->",null==e?void 0:e.message)}},e.prototype.onCdMessage=function(e){var t=this,n=e.data;if(n)try{var r=JSON.parse(n),i=r.data,o=r.hotspotx,s=void 0===o?0:o,a=r.hotspoty,c=void 0===a?0:a;this.debugSetting.showOnCdMessage&&this.sdk.log("onCdMessage image data->".concat(i.length," ").concat(lt()(i)),"hotspotx",s,"hotspoty",c),this.hotSpot.x=s,this.hotSpot.y=c;var u="data:image/png;base64,".concat(i);this.remoteCursorImage=u;var d=new Image;d.onload=function(){if(t.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS)(e=t.sdk.getCursorElement()).style.backgroundImage="url(".concat(u,")"),e.style.top="auto",e.style.left="auto",t.resizeMobileCursor({width:d.width,height:d.height});else if(Ze()||t.remoteCursorMode===ve.REMOTE_SRC_POS){var e;(e=t.sdk.getCursorElement()).style.backgroundImage="url(".concat(u,")"),t.resizeMobileCursor({width:16,height:16})}else{var n=t.sdk.getVideoElement();n&&(n.style.cursor="url(".concat(u,") ").concat(t.hotSpot.x," ").concat(t.hotSpot.y,", auto"))}},d.onerror=function(e){this.sdk.log("onCdMessage image data load failed",e)},d.src=u}catch(e){this.sdk.log("onCdMessage data parse failed",e)}else this.sdk.log("onCdMessage no data")},e.prototype.onSvrMessage=function(e){var t=e.data;return vt(this,0,void 0,(function(){var e,n,r,i,o,s,a,c,u,d,l,h,p,f,v,m,_,g,y;return mt(this,(function(S){switch(S.label){case 0:if(!t)return[3,48];S.label=1;case 1:switch(S.trys.push([1,46,,47]),e=JSON.parse(t),n=e.type,r=e.data,this.debugSetting.showOnSvMessage&&this.sdk.log("onSvMessage","type: ",n,"data",t),n){case"game_start_complete":return[3,2];case"game_stopped":return[3,3];case"archive_load_status":return[3,4];case"archive_save_status":return[3,5];case"metric_sig_key":return[3,6];case"screen_config_change":return[3,7];case"hit_input":return[3,8];case"ime":return[3,13];case"camera_status":return[3,14];case"mic_status":return[3,31]}return[3,44];case 2:return this.sdk.onGameStartComplete(r),[3,45];case 3:return this.sdk.onGameStop(r),[3,45];case 4:return this.sdk.onLoadGameArchive(r),[3,45];case 5:return this.sdk.onSaveGameArchive(r),[3,45];case 6:return this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{sig_key:r.sig_key}}),[3,45];case 7:return i=r,this.sdk.pageEvent.setRemoteScreenConfig(i),[3,45];case 8:return s=(o=r).field_type,a=o.status,c=o.text,u=o.start_index,this.sdk.onInputStatusChange({field_type:s,status:a}),this.sdk.log("ime type",this.sdk.pageEvent.IMEType,this.sdk.isMobileGame),this.sdk.isMobileGame?(d=this.sdk.getFakeInputElement(),"normal_input"!==s?[3,11]:this.firstHitInput?[4,new Promise((function(e){setTimeout(e,200)}))]:[3,10]):[3,12];case 9:S.sent(),S.label=10;case 10:return this.firstHitInput=!1,d.value=c,d.focus(),d.setRangeText("",u,u,"end"),[3,12];case 11:d.blur(),d.value="",S.label=12;case 12:return[3,45];case 13:return l=r.ime_type,this.sdk.pageEvent.IMEType=l,[3,45];case 14:return p=(h=r).status,f=h.height,v=h.width,this.sdk.log("onSvMessage camera_status",p,f,v,this.camera),this.sdk.getInitOptions().autoSwitchCamera?this.switchCameraRequesting?[4,this.switchCameraRequestQueue.startBlocking()]:[3,16]:[3,30];case 15:S.sent(),S.label=16;case 16:this.switchCameraRequesting=!0,S.label=17;case 17:return S.trys.push([17,28,29,30]),"open_front"!==p?[3,21]:this.camera?[4,this.switchCamera({status:"close"})]:[3,19];case 18:S.sent(),S.label=19;case 19:return[4,this.switchCamera({status:"open",profile:Ze()?{deviceId:"user"}:this.sdk.isMobileGame?{width:720,height:1280}:null})];case 20:S.sent(),S.label=21;case 21:return"open_back"!==p?[3,25]:this.camera?[4,this.switchCamera({status:"close"})]:[3,23];case 22:S.sent(),S.label=23;case 23:return[4,this.switchCamera({status:"open",profile:Ze()?{deviceId:"environment"}:this.sdk.isMobileGame?{width:720,height:1280}:null})];case 24:S.sent(),S.label=25;case 25:return"close"!==p?[3,27]:[4,this.switchCamera({status:"close"})];case 26:S.sent(),S.label=27;case 27:return this.switchCameraRequesting=!1,[3,30];case 28:return m=S.sent(),this.sdk.log("camera_status switch camera error,",m.message),this.switchCameraRequesting=!1,[3,30];case 29:return this.switchCameraRequesting=!1,this.switchCameraRequestQueue.nextTask(),[7];case 30:return this.sdk.onEvent({type:"camera_status",data:{status:p,width:v,height:f}}),[3,45];case 31:return _=r.status,this.sdk.log("onSvMessage mic_status",_,this.mic),this.sdk.getInitOptions().autoSwitchMic?this.switchMicRequesting?[4,this.switchMicRequestQueue.startBlocking()]:[3,33]:[3,43];case 32:S.sent(),S.label=33;case 33:this.switchMicRequesting=!0,S.label=34;case 34:return S.trys.push([34,41,42,43]),"open"!==_?[3,38]:this.mic?[4,this.switchMic({status:"close"})]:[3,36];case 35:S.sent(),S.label=36;case 36:return[4,this.switchMic({status:"open",profile:this.mic})];case 37:S.sent(),S.label=38;case 38:return"close"!==_?[3,40]:[4,this.switchMic({status:"close"})];case 39:S.sent(),S.label=40;case 40:return[3,43];case 41:return g=S.sent(),this.sdk.log("mic_status switch mic error,",g.message),this.switchMicRequesting=!1,[3,43];case 42:return this.switchMicRequesting=!1,this.switchMicRequestQueue.nextTask(),[7];case 43:return this.sdk.onEvent({type:"mic_status",data:{status:_}}),[3,45];case 44:return[3,45];case 45:return[3,47];case 46:return y=S.sent(),this.sdk.log("onSvMessage data parse failed",y),[3,47];case 47:return[3,49];case 48:this.sdk.log("onSvMessage no data"),S.label=49;case 49:return[2]}}))}))},e.prototype.onCloudDeviceMessage=function(e){var t=e.data;return vt(this,0,void 0,(function(){var e,n,r,i,o,s,a;return mt(this,(function(c){switch(c.label){case 0:if(!t)return[3,18];c.label=1;case 1:switch(c.trys.push([1,16,,17]),e=JSON.parse(t),n=e.type,r=e.data,this.debugSetting.showOnCloudDeviceMessage&&this.sdk.log("onCloudDeviceData","type: ",n,"data",t,"cloudDeviceData",r),n){case"trans_message":return[3,2];case"system_usage":return[3,3];case"clipboard_event":return[3,4];case"notification_event":return[3,9];case"system_status":return[3,10];case"distribute_progress_event":return[3,11];case"join":return[3,12];case"set_sync_list":return[3,13]}return[3,14];case 2:return this.sdk.onAndroidInstanceEvent({type:"trans_message",data:r}),[3,15];case 3:return this.sdk.onAndroidInstanceEvent({type:"system_usage",data:r}),[3,15];case 4:i=!0,o=r.text,c.label=5;case 5:return c.trys.push([5,7,,8]),[4,navigator.clipboard.writeText(o)];case 6:return c.sent(),[3,8];case 7:return s=c.sent(),console.log("navigator.clipboard.writeText failed",s),i=!1,[3,8];case 8:return this.sdk.onAndroidInstanceEvent({type:"clipboard_event",data:{text:o,writeText:i}}),[3,15];case 9:return this.sdk.onAndroidInstanceEvent({type:"notification_event",data:r}),[3,15];case 10:return this.sdk.onAndroidInstanceEvent({type:"system_status",data:r}),[3,15];case 11:return this.sdk.onAndroidInstanceEvent({type:"distribute_progress_event",data:r}),[3,15];case 12:return this.sdk.onAndroidInstanceEvent({type:"join",data:r}),[3,15];case 13:return this.sdk.onAndroidInstanceEvent({type:"set_sync_list",data:r}),[3,15];case 14:return[3,15];case 15:return[3,17];case 16:return a=c.sent(),this.sdk.log("onCloudDeviceData data parse failed",a),[3,17];case 17:return[3,19];case 18:this.sdk.log("onCloudDeviceData no data"),c.label=19;case 19:return[2]}}))}))},e.prototype.resizeMobileCursor=function(e){var t=e.width,n=void 0===t?16:t,r=e.height,i=void 0===r?16:r,o=this.sdk.getCursorElement();o.style.width="".concat(Math.round(n*this.mobileCursorScale),"px"),o.style.height="".concat(Math.round(i*this.mobileCursorScale),"px"),o.style.borderRadius=null,o.style.backgroundColor=null},e.prototype.reportStat=function(){var e=this.sdk.showStats.getStats(),t=e.fps;if(this.connectStatus===fe.CONNECTING&&(this.connectTimeoutCount+=1,this.connectTimeoutCount>=this.newConnectTimeout&&(this.sdk.log("connect timeout, no-flow notify"),this.sdk.onNetworkChange({status:"noflow"}),this.sdk.onEvent({type:"noflow"}),this.disconnected({message:"connect timeout, please reconnect",code:me.NEED_RECONNECT}),this.connectTimeoutCount=0)),this.connectStatus===fe.ESTABLISHED&&(0===t&&"playing"===this.gameStatus?(this.noFlowCount+=1,this.noFlowCount>=this.noflowTimeout&&(this.sdk.log("noFlowCount reach, no-flow notify"),this.sdk.onNetworkChange({status:"noflowcenter"}),this.sdk.onEvent({type:"noflowcenter"}),this.noFlowCount=0)):this.noFlowCount=0),!this.hbDataChannel)return this.sdk.log("hbDataChannel has been closed");if(e.timestamp=+new Date,this.connectStatus!==fe.DISCONNECTED){var n=e.fps,r=e.delay,i=e.bit_rate,o=e.packet_lost,s=e.nack,a=e.packet_received,c=ft(ft({},e),{fps:"".concat(n),delay:"".concat(r),bit_rate:"".concat(8*i),packet_lost:"".concat(o),nack:"".concat(s),packet_received:"".concat(a)});this.dataChannelSend(this.hbDataChannel,c),this.debugSetting.showSendHbData&&console.log("sendHbData",c),this.sdk.onNetworkChange({status:"stats",stats:e}),this.sdk.onEvent({type:"webrtc_stats",data:e});var u=this.sdk.showStats.getMediaStats();this.sdk.onEvent({type:"media_stats",data:u})}this.sdk.showStats.addReportStat()},e.prototype.dataChannelSend=function(e,t){"open"===(null==e?void 0:e.readyState)&&e.send(JSON.stringify(t))},e.prototype.dataChannelSendWithCallback=function(e){var t=this,n=e.dataChannel,r=void 0===n?null:n,i=e.ackMsg,o=void 0===i?_t:i,s=e.retry,a=void 0===s?0:s,c=e.callback,u=void 0===c?nt:c,d=e.interval,l=void 0===d?1e3:d;if("open"===(null==r?void 0:r.readyState))try{var h=o.seq;if(h||(h=ot(),this.sdk.showStats.setInputStart(h)),r.send(JSON.stringify(o)),this.dataChannelCallbacks[h]={ackMsg:o,retry:a,callback:u,interval:l,retryAction:function(){if(!t.dataChannelCallbacks[h])return t.sdk.log(r.label,h,"ackItem not exist");var e=t.dataChannelCallbacks[h];if(e.retry>=1||-1===e.retry)t.sdk.log(r.label,h,"ackItem retry, remain ".concat(e.retry," times")),e.retry=e.retry>=1?e.retry-1:e.retry,t.dataChannelSendWithCallback({dataChannel:r,ackMsg:e.ackMsg,retry:e.retry,callback:e.callback,interval:e.interval});else{var n=e.callback;delete t.dataChannelCallbacks[h],t.dataChannelRetryTimers[h]&&(t.sdk.showStats.setInputEnd(h),clearTimeout(t.dataChannelRetryTimers[h]),delete t.dataChannelRetryTimers[h],t.sdk.log("ack msg timer timeout clear:",h)),n({code:1,msg:"send ack message timeout"}),t.sdk.log("send ack message timeout:",h)}}},a>0){var p=setTimeout((function(){var e;null===(e=t.dataChannelCallbacks[h])||void 0===e||e.retryAction()}),l);this.dataChannelRetryTimers[h]=p}}catch(e){this.sdk.log("ack msg exception:",e)}},e.prototype.setCursorShowStatus=function(e){var t,n;if(this.connectStatus===fe.ESTABLISHED){this.forceShowCursor?this.lockMouse(!1):this.forceLockCursor?this.lockMouse(!0):e?this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?this.sdk.getCursorElement().style.display="block":this.lockMouse(!1):this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?this.sdk.getCursorElement().style.display="none":this.lockMouse(!0),this.forceLockCursor?this.showCursor=!1:(e!==this.showCursor&&(this.sdk.log("cursor show stat will set to",e),this.sdk.onCursorShowStatChange({oldStatus:this.showCursor,newStatus:e})),this.showCursor=e);var r=null===(t=this.sdk)||void 0===t?void 0:t.getVideoElement(),i=null===(n=this.sdk)||void 0===n?void 0:n.getCursorElement();if(this.remoteCursorMode!==ve.REMOTE_SRC_POS){if(this.remoteCursorMode===ve.REMOTE_DRAW)return r.style.cursor="none";r&&(this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?r.style.cursor="auto":e||this.forceShowCursor||"touch"===this.sdk.pageEvent.getClientInteractMode()?r.style.cursor="url(".concat(this.remoteCursorImage?this.remoteCursorImage:this.originCursorStyle,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto"):r.style.cursor="none"),Ze()&&((e||this.forceShowCursor||"touch"===this.sdk.pageEvent.getClientInteractMode())&&this.mobileShowCursor?i.style.display="block":i.style.display="none")}else(e||this.forceShowCursor)&&this.mobileShowCursor?i.style.display="block":i.style.display="none"}},e}();const yt=gt;var St,bt=function(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t,n,r,o,s,a,c,u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];var l=["video-stream","cursor"];"keyEvent"===e&&l.push("cloud-gaming-container");var h=u[0].target.className,p=(null===(t=this.sdk)||void 0===t?void 0:t.getInitOptions()).mount;((null===(n=u[0].target.parentNode)||void 0===n?void 0:n.id)===p||(null===(o=null===(r=u[0].target.parentNode)||void 0===r?void 0:r.parentNode)||void 0===o?void 0:o.id)===p||(null===(c=null===(a=null===(s=u[0].target.parentNode)||void 0===s?void 0:s.parentNode)||void 0===a?void 0:a.parentNode)||void 0===c?void 0:c.id)===p)&&(this.enableEventIntercept&&!l.includes(h)||i.apply(this,u))},r}};!function(e){e[e.Backspace=8]="Backspace",e[e.Tab=9]="Tab",e[e.Enter=13]="Enter",e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.PauseBreak=19]="PauseBreak",e[e.CapsLock=20]="CapsLock",e[e.Escape=27]="Escape",e[e.Space=32]="Space",e[e.PageUp=33]="PageUp",e[e.PageDown=34]="PageDown",e[e.End=35]="End",e[e.Home=36]="Home",e[e.LeftArrow=37]="LeftArrow",e[e.UpArrow=38]="UpArrow",e[e.RightArrow=39]="RightArrow",e[e.DownArrow=40]="DownArrow",e[e.Insert=45]="Insert",e[e.Delete=46]="Delete",e[e.Zero=48]="Zero",e[e.ClosedParen=48]="ClosedParen",e[e.One=49]="One",e[e.ExclamationMark=49]="ExclamationMark",e[e.Two=50]="Two",e[e.AtSign=50]="AtSign",e[e.Three=51]="Three",e[e.PoundSign=51]="PoundSign",e[e.Hash=51]="Hash",e[e.Four=52]="Four",e[e.DollarSign=52]="DollarSign",e[e.Five=53]="Five",e[e.PercentSign=53]="PercentSign",e[e.Six=54]="Six",e[e.Caret=54]="Caret",e[e.Hat=54]="Hat",e[e.Seven=55]="Seven",e[e.Ampersand=55]="Ampersand",e[e.Eight=56]="Eight",e[e.Star=56]="Star",e[e.Asterik=56]="Asterik",e[e.Nine=57]="Nine",e[e.OpenParen=57]="OpenParen",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.LeftWindowKey=91]="LeftWindowKey",e[e.RightWindowKey=92]="RightWindowKey",e[e.SelectKey=93]="SelectKey",e[e.Numpad0=96]="Numpad0",e[e.Numpad1=97]="Numpad1",e[e.Numpad2=98]="Numpad2",e[e.Numpad3=99]="Numpad3",e[e.Numpad4=100]="Numpad4",e[e.Numpad5=101]="Numpad5",e[e.Numpad6=102]="Numpad6",e[e.Numpad7=103]="Numpad7",e[e.Numpad8=104]="Numpad8",e[e.Numpad9=105]="Numpad9",e[e.Multiply=106]="Multiply",e[e.Add=107]="Add",e[e.Subtract=109]="Subtract",e[e.DecimalPoint=110]="DecimalPoint",e[e.Divide=111]="Divide",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NumLock=144]="NumLock",e[e.ScrollLock=145]="ScrollLock",e[e.SemiColon=186]="SemiColon",e[e.Equals=187]="Equals",e[e.Comma=188]="Comma",e[e.Dash=189]="Dash",e[e.Period=190]="Period",e[e.UnderScore=189]="UnderScore",e[e.PlusSign=187]="PlusSign",e[e.ForwardSlash=191]="ForwardSlash",e[e.Tilde=192]="Tilde",e[e.GraveAccent=192]="GraveAccent",e[e.Backquote=192]="Backquote",e[e.OpenBracket=219]="OpenBracket",e[e.ClosedBracket=221]="ClosedBracket",e[e.Quote=222]="Quote"}(St||(St={}));var kt=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some((function(e,r){return e[0]===t&&(n=r,!0)})),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];e.call(t,i[1],i[0])}},t}()}(),Et="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Tt=void 0!==E8.g&&E8.g.Math===Math?E8.g:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),Ct="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(Tt):function(e){return setTimeout((function(){return e(Date.now())}),1e3/60)},It=["top","right","bottom","left","width","height","size","weight"],wt="undefined"!=typeof MutationObserver,Rt=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(e){var t=!1,n=!1,r=0;function i(){t&&(t=!1,e()),n&&s()}function o(){Ct(i)}function s(){var e=Date.now();if(t){if(e-r<2)return;n=!0}else t=!0,n=!1,setTimeout(o,20);r=e}return s}(this.refresh.bind(this))}return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var e=this.observers_.filter((function(e){return e.gatherActive(),e.hasActive()}));return e.forEach((function(e){return e.broadcastActive()})),e.length>0},e.prototype.connect_=function(){Et&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),wt?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){Et&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;It.some((function(e){return!!~n.indexOf(e)}))&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),At=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e},Ot=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||Tt},xt=Nt(0,0,0,0);function Pt(e){return parseFloat(e)||0}function Dt(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce((function(t,n){return t+Pt(e["border-"+n+"-width"])}),0)}var Mt="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof Ot(e).SVGGraphicsElement}:function(e){return e instanceof Ot(e).SVGElement&&"function"==typeof e.getBBox};function Nt(e,t,n,r){return{x:e,y:t,width:n,height:r}}var Lt=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Nt(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=function(e){return Et?Mt(e)?function(e){var t=e.getBBox();return Nt(0,0,t.width,t.height)}(e):function(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return xt;var r=Ot(e).getComputedStyle(e),i=function(e){for(var t={},n=0,r=["top","right","bottom","left"];n<r.length;n++){var i=r[n],o=e["padding-"+i];t[i]=Pt(o)}return t}(r),o=i.left+i.right,s=i.top+i.bottom,a=Pt(r.width),c=Pt(r.height);if("border-box"===r.boxSizing&&(Math.round(a+o)!==t&&(a-=Dt(r,"left","right")+o),Math.round(c+s)!==n&&(c-=Dt(r,"top","bottom")+s)),!function(e){return e===Ot(e).document.documentElement}(e)){var u=Math.round(a+o)-t,d=Math.round(c+s)-n;1!==Math.abs(u)&&(a-=u),1!==Math.abs(d)&&(c-=d)}return Nt(i.left,i.top,a,c)}(e):xt}(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),Ut=function(e,t){var n=function(e){var t=e.x,n=e.y,r=e.width,i=e.height,o="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,s=Object.create(o.prototype);return At(s,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),s}(t);At(this,{target:e,contentRect:n})},Vt=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new kt,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof Ot(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new Lt(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof Ot(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach((function(t){t.isActive()&&e.activeObservations_.push(t)}))},e.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map((function(e){return new Ut(e.target,e.broadcastRect())}));this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),Ft="undefined"!=typeof WeakMap?new WeakMap:new kt,Bt=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=Rt.getInstance(),r=new Vt(t,n,this);Ft.set(this,r)};["observe","unobserve","disconnect"].forEach((function(e){Bt.prototype[e]=function(){var t;return(t=Ft.get(this))[e].apply(t,arguments)}}));const jt=void 0!==Tt.ResizeObserver?Tt.ResizeObserver:Bt;var Gt,Ht,Wt,Kt={},zt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],qt=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(zt,1)[0];try{for(var Jt=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(zt),Yt=Jt.next();!Yt.done;Yt=Jt.next()){var Xt=Yt.value;if(Xt[1]in document){Wt=Xt;break}}}catch(e){Gt={error:e}}finally{try{Yt&&!Yt.done&&(Ht=Jt.return)&&Ht.call(Jt)}finally{if(Gt)throw Gt.error}}if(Wt)for(var $t=0;$t<Wt.length;$t++)Kt[qt[$t]]=Wt[$t];const Qt=Kt;var Zt=function(){return Zt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zt.apply(this,arguments)},en=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},tn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},nn=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},rn=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},on=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},sn=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},an=function(){function e(e){var t=e.sdk,n=this;this.moveSensitivity=1,this.touchesForDelta=null,this.touchesIdentifierMap=new Map,this.touchesMap=new Map,this.touchState=null,this.mousePosition={x:0,y:0,movementX:0,movementY:0,remoteX:0,remoteY:0},this.remoteMousePosition={x:0,y:0,sent:!1},this.mouseClickPosition={x:0,y:0},this.mouseState=null,this.enableMouseEventOnMobile=!1,this.enableMousemoveV2=!0,this.tabletModeLastPosition=null,this.kmStatus={keyboard:!0,mouse:!0},this.keyboardBanList=[],this.enablePaste=!0,this.keyboardPressedKeys=new Map,this.wheeling=!1,this.deltaMoveToCalcX=0,this.deltaMoveToCalcY=0,this.escPressTime=null,this.tabletMode=!1,this.clickToFullscreen=!1,this.clickBodyToPlay=!0,this.mutedVideo=!1,this.webDraftLevel=ye.CLOSE_HIGH_FREQUENCY,this.enableEventIntercept=!0,this.videoWidth=0,this.videoHeight=0,this.videoLeft=0,this.videoTop=0,this.videoStatus="pause",this.audioStatus="pause",this.remoteScreenWidth=0,this.remoteScreenHeight=0,this.remoteScreenLeft=0,this.remoteScreenTop=0,this.remoteScreenConfig=null,this.dropMouseEvent=!1,this.videoOrientation=0,this.pageOrientation=null,this.resizeObserver=null,this.mountResizeObserver=null,this.doubleTap=!1,this.doubleTapResponse=[],this.addKMHandlerFlag=!1,this.clientInteractMode="cursor",this.visibilityState="visible",this.sdk=null,this.transformMouseOffset={x:0,y:0},this.mount=null,this.ime=null,this._inputConfig={isComposing:!1,selectionStart:null},window.addEventListener("online",(function(e){n.onNetwork(e)}),!1),window.addEventListener("offline",(function(e){n.onNetwork(e)}),!1),this.onTouch=this.onTouch.bind(this),this.onResize=this.onResize.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onVideoPlaying=this.onVideoPlaying.bind(this),this.onVideoPause=this.onVideoPause.bind(this),this.onVideoEnd=this.onVideoEnd.bind(this),this.onAudioPlaying=this.onAudioPlaying.bind(this),this.onAudioPause=this.onAudioPause.bind(this),this.onAudioEnd=this.onAudioEnd.bind(this),this.onVideoElementClick=this.onVideoElementClick.bind(this),this.onOrientationChange=this.onOrientationChange.bind(this),this.onFakeInputChange=this.onFakeInputChange.bind(this),this.onFakeInputFocus=this.onFakeInputFocus.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.onFocusChange=this.onFocusChange.bind(this),this.sdk=t}return e.prototype.init=function(e){var t,n,r,i,o,s;this.tabletMode=e.tabletMode,this.clickToFullscreen=e.clickToFullscreen,this.clickBodyToPlay=null===(t=e.clickBodyToPlay)||void 0===t||t,this.webDraftLevel=null!==(n=e.webDraftLevel)&&void 0!==n?n:ye.CLOSE_HIGH_FREQUENCY,this.enableEventIntercept=null===(r=e.enableEventIntercept)||void 0===r||r,this.clientInteractMode=e.clientInteractMode||"cursor",this.enablePaste=null!==(i=e.enablePaste)&&void 0!==i?i:this.enablePaste,this.enableMousemoveV2=null===(o=e.enableMousemoveV2)||void 0===o||o,this.enableMouseEventOnMobile=null!==(s=e.enableMouseEventOnMobile)&&void 0!==s&&s,this.mount=e.mount},e.prototype.clearEvent=function(){this.resizeObserver=null,this.mountResizeObserver=null,window.removeEventListener("resize",this.onResize,!1),window.removeEventListener("visibilitychange",this.onVisibilityChange,!1),window.removeEventListener("orientationchange",this.onOrientationChange,!1),window.removeEventListener("focus",this.onFocusChange,!1),window.removeEventListener("blur",this.onFocusChange,!1),document.body.removeEventListener("click",this.onBodyClick,!1),this.sdk.getVideoElement()&&(this.sdk.getVideoElement().removeEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().removeEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().removeEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().removeEventListener("click",this.onVideoElementClick,!1)),this.sdk.getAudioElement()&&(this.sdk.getAudioElement().removeEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().removeEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().removeEventListener("ended",this.onAudioEnd,!1))},e.prototype.addEventHandler=function(){var e=this;this.addKMHandler(),this.addTouchHandler(),Ze()||this.sdk.gamepad.addGamepadHandler(),document.body.removeEventListener("click",this.onBodyClick,!1),document.body.addEventListener("click",this.onBodyClick,!1),this.sdk.getVideoElement().removeEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().addEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().removeEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().addEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().removeEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().addEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().removeEventListener("click",this.onVideoElementClick,!1),this.sdk.getVideoElement().addEventListener("click",this.onVideoElementClick,!1),this.sdk.getAudioElement().removeEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().addEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().removeEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().addEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().removeEventListener("ended",this.onAudioEnd,!1),this.sdk.getAudioElement().addEventListener("ended",this.onAudioEnd,!1),window.removeEventListener("orientationchange",this.onOrientationChange,!1),window.addEventListener("orientationchange",this.onOrientationChange,!1),window.addEventListener("resize",this.onResize,!1),document.addEventListener("pointerlockerror",(function(){e.sdk.onEvent({type:"pointerlockerror"})}),!1)},Object.defineProperty(e.prototype,"IMEType",{get:function(){return this.ime},set:function(e){this.ime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputConfig",{get:function(){return this._inputConfig},set:function(e){this._inputConfig=Zt(Zt({},this._inputConfig),e)},enumerable:!1,configurable:!0}),e.prototype.initOrientationDetector=function(){Ze()?this.addOrientationDetector():this.sdk.isMobileGame&&this.addCloudGamingMountOrientationDetector()},e.prototype.setTabletMode=function(e){this.tabletMode=e},e.prototype.setMoveSensitivity=function(e){this.moveSensitivity=1/e},e.prototype.getMoveSensitivity=function(){return this.moveSensitivity},e.prototype.remoteScreenResolutionChange=function(e){var t=e.width,n=e.height,r=e.left,i=e.top;this.remoteScreenWidth===t&&this.remoteScreenHeight===n&&this.remoteScreenLeft===r&&this.remoteScreenTop===i||(this.remoteScreenWidth=t,this.remoteScreenHeight=n,this.remoteScreenLeft=r,this.remoteScreenTop=i,this.sdk.onRemoteScreenResolutionChange({width:t,height:n,top:i,left:r}),this.sdk.log("remoteScreenResolutionChange->".concat(t," ").concat(n," ").concat(r," ").concat(i," ")),this.reshapeWindow())},e.prototype.getRemoteScreenConfig=function(){return this.remoteScreenConfig},e.prototype.setRemoteScreenConfig=function(e){var t=e.degree,n=e.orientation,r=0;"landscape"===n&&(r=270),"portrait"===n&&(r=0),"0_degree"===t&&(r=0),"90_degree"===t&&(r=270),"180_degree"===t&&(r=180),"270_degree"===t&&(r=90),this.remoteScreenConfig=Zt(Zt({},e),{deg:r}),this.sdk.cloudGamingWebRTC.getWebrtcConnectStatus()===fe.ESTABLISHED&&this.sdk.onConfigurationChange({screen_config:this.remoteScreenConfig}),Ze()||this.cloudGamingMountResizeHandler()},e.prototype.clearRemoteKeys=function(){this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"keys_clean"}})},e.prototype.transferLocalScale=function(e){var t=e.width,n=void 0===t?1:t,r=e.height,i=void 0===r?1:r,o=this.videoWidth/this.remoteScreenWidth*n,s=this.videoHeight/this.remoteScreenHeight*i;return 90===this.videoOrientation&&(o=this.videoHeight/this.remoteScreenWidth*i,s=this.videoWidth/this.remoteScreenHeight*n),{width:o,height:s}},e.prototype.mouseMove=function(e,t,n,r){var i,o,s=this.sdk.cloudGamingWebRTC.getDisplayRect(),a=s.left,c=s.top,u=s.width,d=s.height;if(this.tabletMode?(this.tabletModeLastPosition||(this.tabletModeLastPosition={x:n,y:r}),this.mousePosition.x=this.mousePosition.x+(n-this.tabletModeLastPosition.x),this.mousePosition.y=this.mousePosition.y+(r-this.tabletModeLastPosition.y),this.mousePosition.x<=a&&(this.mousePosition.x=a),this.mousePosition.x>=u+a&&(this.mousePosition.x=u+a),this.mousePosition.y<=c&&(this.mousePosition.y=c),this.mousePosition.y>=d+c&&(this.mousePosition.y=d+c),this.tabletModeLastPosition={x:n,y:r}):this.mousePosition={x:n,y:r,movementX:n-this.mousePosition.x,movementY:r-this.mousePosition.y},90===this.videoOrientation?(i=this.mousePosition.y-c,o=this.videoWidth-this.mousePosition.x+a):(i=this.mousePosition.x-a,o=this.mousePosition.y-c),this.updateCursorPosition({displayX:i,displayY:o}),"touchstart"===t)if(this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var l=this.moveTo(i,o),h=l.remoteX,p=l.remoteY;this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:h,y:p}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:h,y:p})}else this.sdk.log("cursor is not showing, cursor will not move");if("touchmove"===t)if(this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var f=this.moveTo(i,o);h=f.remoteX,p=f.remoteY,this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:h,y:p}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:h,y:p})}else{var v=this.deltaMoveTo(this.mousePosition.movementX,this.mousePosition.movementY),m=v.remoteDeltaX,_=v.remoteDeltaY;90===this.videoOrientation?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:_,y:-m}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:m,y:_})}"touchend"!==t&&"touchcancel"!==t||(this.tabletModeLastPosition=null)},e.prototype.mobileTouchMove=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=e.width,s=e.height,a=e.timestamp;this.sdk.cloudGamingWebRTC.sendKmData({type:"event_touch",finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}),this.sdk.onAndroidInstanceEvent({type:"touch_event",data:{finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}})},e.prototype.mobileTouchMoveWebsocket=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=e.width,s=e.height,a=e.timestamp;this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"event_touch",finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}})},e.prototype.fullscreen=function(e){var t;return void 0===e&&(e=document.documentElement),tn(this,0,void 0,(function(){return nn(this,(function(n){switch(n.label){case 0:this.sdk.log("enter fullscreen"),n.label=1;case 1:return n.trys.push([1,6,,7]),Qt.requestFullscreen?[4,e[Qt.requestFullscreen]()]:[3,3];case 2:return n.sent(),[3,5];case 3:return[4,e.webkitEnterFullScreen()];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:throw n.sent();case 7:if(window.self===window.top)try{null===(t=null===navigator||void 0===navigator?void 0:navigator.keyboard)||void 0===t||t.lock(["Escape","F11"])}catch(e){this.sdk.log("lockKeyboard",e)}return[2]}}))}))},e.prototype.exitFullscreen=function(e){var t,n;return void 0===e&&(e=document.documentElement),tn(this,0,void 0,(function(){return nn(this,(function(r){return this.sdk.log("exit fullscreen"),Qt.exitFullscreen?null===(n=null===(t=document[Qt.exitFullscreen]())||void 0===t?void 0:t.catch)||void 0===n||n.call(t,(function(e){return console.log("exit full screen failed, ",null==e?void 0:e.message)})):e.webkitExitFullScreen(),[2]}))}))},e.prototype.resetLastPosition=function(e){var t=e.x,n=void 0===t?0:t,r=e.y,i=void 0===r?0:r;this.mousePosition.x=n,this.mousePosition.y=i},e.prototype.updateCursorPosition=function(e){var t=e.displayX,n=e.displayY,r=this.sdk.getCursorElement();90===this.videoOrientation?(t>this.videoHeight&&(t=this.videoHeight),n>this.videoWidth&&(n=this.videoWidth)):(t>this.videoWidth&&(t=this.videoWidth),n>this.videoHeight&&(n=this.videoHeight)),t<0&&(t=0),n<0&&(n=0),r&&(r.style.top="".concat(n+(90===this.videoOrientation?this.videoLeft:this.videoTop),"px"),r.style.left="".concat(t+(90===this.videoOrientation?this.videoTop:this.videoLeft),"px"),r.style.zIndex="100")},e.prototype.setDropMouseEvent=function(e){this.dropMouseEvent=e},e.prototype.setWebDraftLevel=function(e){void 0===e&&(e=0),this.webDraftLevel=e},e.prototype.setEnableEventIntercept=function(e){void 0===e&&(e=!0),this.enableEventIntercept=e},e.prototype.setVideoOrientation=function(e){var t,n=e.deg,r=void 0===n?0:n,i=e.rotateContainer,o=void 0===i||i,s=e.rotateMountPoint,a=void 0!==s&&s;if(this.sdk.log("setVideoOrientation",r,o,a),function(e){var t=new CustomEvent(e.name,{bubbles:!0,detail:e.data});window.dispatchEvent(t)}({name:"this.sdk:VideoOrientation",data:{deg:r,rotateContainer:o,rotateMountPoint:a}}),o||a){var c=document.querySelector("html");if(a&&(c=this.sdk.isMobileGame?this.sdk.getCloudGamingStreamContainerElement():document.getElementById(null===(t=this.sdk.getInitOptions())||void 0===t?void 0:t.mount)),c)if(c.className=c.className.split(" rotate-html-".concat(this.videoOrientation)).join(""),90===r&&(c.className="".concat(c.className," rotate-html-90")),180===r&&(c.className="".concat(c.className," rotate-html-180")),270===r&&(c.className="".concat(c.className," rotate-html-270")),0===r||180===r)a?(c.style.width=null,c.style.height=null):o&&(c.className="",c.style.width=null,c.style.height=null);else if(Ze())(this.sdk.isMobileGame||a)&&(window.innerHeight>window.innerWidth?(c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px")):setTimeout((function(){c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px")}),100));else if(a){var u=null===document||void 0===document?void 0:document.querySelector("#".concat(this.mount)),d=u.clientWidth,l=u.clientHeight;c.style.width="".concat(l,"px"),c.style.height="".concat(d,"px")}else o&&(c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px"));else this.sdk.log("setVideoOrientation -> can not find mount point")}this.videoOrientation=r,this.reshapeWindow()},e.prototype.getPageOrientation=function(){return this.pageOrientation},e.prototype.reshapeWindow=function(){var e=this;this.sdk.log("reshapeWindow");var t=this.sdk.getVideoElement();if(t){var n=this.sdk.getCloudGamingContainerElement(),r=this.sdk.getInitOptions().fullVideoToScreen,i=void 0===r||r;if(t.videoWidth&&t.videoHeight&&n.clientWidth>t.videoWidth&&n.clientHeight>t.videoHeight&&i&&(n.clientWidth/n.clientHeight>t.videoWidth/t.videoHeight?(t.style.height="100%",t.style.width=null):(t.style.width="100%",t.style.height=null)),(n.clientWidth<t.videoWidth||n.clientHeight<t.videoHeight)&&(t.style.width=null,t.style.height=null),this.sdk.isMobileGame){var o=this.sdk.getCloudGamingStreamContainerElement(),s=o.clientWidth,a=o.clientHeight,c=t.videoWidth;a/s>t.videoHeight/c?(t.style.width="100%",t.style.height=null):(t.style.height="100%",t.style.width=null)}var u=function(){var n=t.getBoundingClientRect(),r=n.width,i=n.height,o=n.top,s=n.left;e.videoWidth=r,e.videoHeight=i,e.videoLeft=s,e.videoTop=o,e.sdk.log("videoResolutionChange-> width: ".concat(e.videoWidth,", height: ").concat(e.videoHeight,", left: ").concat(e.videoLeft,", top: ").concat(e.videoTop))};u(),this.resizeObserver||(this.resizeObserver=new jt((function(){u()})),this.resizeObserver.observe(t))}},e.prototype.setKMStatus=function(e){var t=e.keyboard,n=void 0===t||t,r=e.mouse,i=void 0===r||r;this.kmStatus={keyboard:n,mouse:i}},e.prototype.setKeyboardBanList=function(e){var t=e.keyList;this.keyboardBanList=t},e.prototype.setPaste=function(e){this.enablePaste=e},e.prototype.setVideoMuted=function(e){this.mutedVideo=e},e.prototype.setClientInteractMode=function(e){void 0===e&&(e="cursor"),this.clientInteractMode=e},e.prototype.getClientInteractMode=function(){return this.clientInteractMode},e.prototype.getVisibilityState=function(){return this.visibilityState},Object.defineProperty(e.prototype,"remoteScreenSize",{get:function(){return{width:this.remoteScreenWidth,height:this.remoteScreenHeight,top:this.remoteScreenTop,left:this.remoteScreenLeft}},enumerable:!1,configurable:!0}),e.prototype.addKMHandler=function(){var e=this;if(!this.addKMHandlerFlag){this.addKMHandlerFlag=!0,Ze()&&!this.enableMouseEventOnMobile||(this.webDraftLevel===ye.CLOSE_HIGH_FREQUENCY?document.addEventListener("mousemove",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseMove(t):e.onMouseMove2(t)}),!1):document.addEventListener("pointermove",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseMove(t):e.onMouseMove2(t)}),!1),document.addEventListener("mousedown",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseDown(t):e.onMouseDown2(t)}),!1),document.addEventListener("mouseup",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseUp(t):e.onMouseUp2(t)}),!1)),document.addEventListener("wheel",(function(t){e.onWheel(t)}),!1),document.addEventListener("keydown",(function(t){e.onKeyEvent(t)}),!1),document.addEventListener("keyup",(function(t){e.onKeyEvent(t)}),!1),document.addEventListener("keypress",(function(){e.onKeyPress()}),!1),document.addEventListener("contextmenu",(function(t){e.onContextMenu(t)}),!1),document.addEventListener("fullscreenchange",(function(){if(Qe()){e.sdk.log("enter fullscreenChange");try{e.sdk.getVideoElement().focus()}catch(t){e.sdk.log("fullscreenChange error,",t)}}e.reshapeWindow()}),!1),window.addEventListener("visibilitychange",(function(){e.onVisibilityChange()}),!1),window.addEventListener("focus",(function(){e.onFocusChange()}),!1),window.addEventListener("blur",(function(){e.onFocusChange()}),!1),document.addEventListener("pointerlockchange",(function(){e.pointerlockchange()})),document.addEventListener("paste",(function(t){e.onPaste(t)}));var t=this.sdk.getFakeInputElement();t.removeEventListener("input",this.onFakeInputChange,!1),t.addEventListener("input",this.onFakeInputChange,!1),t.addEventListener("focus",this.onFakeInputFocus,!1),t.addEventListener("compositionstart",(function(){e._inputConfig.isComposing=!0})),t.addEventListener("compositionend",(function(){e._inputConfig.isComposing=!1,e.sdk.androidInstance.inputText({content:t.value,mode:"override",index_after_override:e.inputConfig.selectionStart})}))}},e.prototype.addTouchHandler=function(){var e=this.sdk.getCloudGamingContainerElement();e.removeEventListener("touchmove",this.onTouch,!1),e.removeEventListener("touchstart",this.onTouch,!1),e.removeEventListener("touchend",this.onTouch,!1),e.removeEventListener("touchcancel",this.onTouch,!1),e.addEventListener("touchmove",this.onTouch,!1),e.addEventListener("touchstart",this.onTouch,!1),e.addEventListener("touchend",this.onTouch,!1),e.addEventListener("touchcancel",this.onTouch,!1),document.addEventListener("gesturestart",(function(e){e.preventDefault()}))},e.prototype.onResize=function(){var e=this;this.sdk.log("onresize","window.innerWidth",window.innerWidth,"window.innerHeight",window.innerHeight),setTimeout((function(){e.reshapeWindow()}),0)},e.prototype.addOrientationDetector=function(){var e=this,t=this.sdk.getInitOptions(),n=t.autoRotateContainer,r=t.autoRotateMountPoint,i=window.matchMedia("(orientation: portrait)"),o=function(t){if(t.matches){e.pageOrientation="portrait",(n||r)&&e.setVideoOrientation({deg:e.sdk.isMobileGame&&e.isPortraitStream?0:90,rotateContainer:n,rotateMountPoint:r});try{e.sdk.onOrientationChange({type:"portrait"})}catch(t){e.sdk.log("onOrientationChange callback error",t)}}else{e.pageOrientation="landscape",(n||r)&&e.setVideoOrientation({deg:e.sdk.isMobileGame&&e.isPortraitStream?270:0,rotateContainer:n,rotateMountPoint:r});try{e.sdk.onOrientationChange({type:"landscape"})}catch(t){e.sdk.log("onOrientationChange callback error",t)}}};o(i),i.addListener(o)},e.prototype.cloudGamingMountResizeHandler=function(){var e,t;if(this.sdk.isMobileGame&&this.sdk.getGameMountPoint()){var n=this.getRemoteScreenConfig(),r=n.orientation,i=n.degree,o=0;"landscape"===r&&(o=270),"portrait"===r&&(o=0),"0_degree"===i&&(o=0),"90_degree"===i&&(o=270),"180_degree"===i&&(o=180),"270_degree"===i&&(o=90),(null===(t=null===(e=this.sdk.getInitOptions())||void 0===e?void 0:e.androidInstance)||void 0===t?void 0:t.autoRotateOnPC)&&this.setVideoOrientation({rotateMountPoint:!0,deg:o})}},e.prototype.addCloudGamingMountOrientationDetector=function(){var e=this,t=this.sdk.getGameMountPoint();this.mountResizeObserver||(this.mountResizeObserver=new jt((function(){e.cloudGamingMountResizeHandler()})),this.mountResizeObserver.observe(t))},Object.defineProperty(e.prototype,"isPortraitStream",{get:function(){var e=this.sdk.getRemoteStreamResolution(),t=e.width;return e.height>t},enumerable:!1,configurable:!0}),e.prototype.onVisibilityChange=function(){var e=this;this.clearRemoteKeys(),this.sdk.log("visibilitychange",document.hidden?"hidden":"visible"),document.hidden?(this.visibilityState="hidden",Ze()&&(this.touchesIdentifierMap.clear(),this.sdk.clearRemoteKeys(),setTimeout((function(){e.sdk.isMobileGame||e.sdk.sendMouseEvent({type:"mouseleft",down:!1}),e.touchesMap.clear()}),100))):(this.visibilityState="visible","websocket"===this.sdk.streamingMode&&this.sdk.getVideoElement().play()),this.sdk.onVisibilityChange({status:this.visibilityState})},e.prototype.onNetwork=function(e){this.sdk.log("onNetwork",e.type),this.sdk.onNetworkChange({status:e.type})},e.prototype.onFocusChange=function(){this.clearRemoteKeys()},e.prototype.pointerlockchange=function(){},e.prototype.onPaste=function(e){console.log("onPaste",e,e.clipboardData.getData("text/plain"))},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.transferRemotePosition=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=Math.round(n*this.remoteScreenWidth/this.videoWidth/s)+this.remoteScreenLeft,c=Math.round(i*this.remoteScreenHeight/this.videoHeight/s)+this.remoteScreenTop;return 90!==this.videoOrientation&&270!==this.videoOrientation||(a=Math.round(n*this.remoteScreenWidth/this.videoHeight/s)+this.remoteScreenLeft,c=Math.round(i*this.remoteScreenHeight/this.videoWidth/s)+this.remoteScreenTop),{x:a,y:c}},e.prototype.transferRemotePositionV2=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=n/this.videoWidth/s,c=i/this.videoHeight/s;return 90!==this.videoOrientation&&270!==this.videoOrientation||(a=n/this.videoHeight/s,c=i/this.videoWidth/s),{x:Math.round(8192*a),y:Math.round(8192*c)}},e.prototype.transferRemotePositionDeltaMove=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=n*this.remoteScreenWidth/this.videoWidth/s,c=i*this.remoteScreenHeight/this.videoHeight/s,u=a+this.transformMouseOffset.x,d=c+this.transformMouseOffset.y,l=Math.round(u)+this.remoteScreenLeft,h=Math.round(d)+this.remoteScreenTop;if(this.transformMouseOffset.x=u-Math.round(u),this.transformMouseOffset.y=d-Math.round(d),90===this.videoOrientation||270===this.videoOrientation){var p=n*this.remoteScreenWidth/this.videoHeight/s,f=i*this.remoteScreenHeight/this.videoWidth/s;l=Math.round(p)+this.remoteScreenLeft,h=Math.round(f)+this.remoteScreenTop,this.transformMouseOffset.x=Math.round(p)-p,this.transformMouseOffset.y=Math.round(f)-f}return{x:l,y:h}},Object.defineProperty(e.prototype,"touchesList",{get:function(){var e,t,n=[];if(this.touchesMap.size)try{for(var r=rn(this.touchesMap.values()),i=r.next();!i.done;i=r.next()){var o=i.value;n.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),e.prototype.onTouch=function(e){var t,n,r=this,i=e.type,o=e.timeStamp,s=e.targetTouches,a=e.changedTouches,c=function(e){var t=e.pageX,n=e.pageY,s=e.identifier,a=u.transferRemotePosition({displayX:t-u.videoLeft,displayY:n-u.videoTop}),c=a.x,d=a.y;c-=u.remoteScreenLeft,d-=u.remoteScreenTop;var l=u.touchesForDelta||{lastX:c,lastY:d},h=(c-l.lastX)/u.moveSensitivity,p=(d-l.lastY)/u.moveSensitivity;if(u.touchesForDelta={lastX:c,lastY:d},"touchstart"===i&&(sn([],on(u.touchesIdentifierMap.values()),!1).includes(u.touchesIdentifierMap.size)?u.touchesIdentifierMap.set(s,u.touchesIdentifierMap.size+1):u.touchesIdentifierMap.set(s,u.touchesIdentifierMap.size)),u.sdk.isMobileGame||"touch"===u.clientInteractMode){var f=i;if(270===u.videoOrientation){var v=u.transferRemotePosition({displayX:u.videoHeight-n+u.videoTop,displayY:t-u.videoLeft}),m=v.x,_=v.y;c=m-u.remoteScreenLeft,d=_-u.remoteScreenTop}if(90===u.videoOrientation){var g=u.transferRemotePosition({displayX:n-u.videoTop,displayY:u.videoWidth-t+u.videoLeft});m=g.x,_=g.y,c=m-u.remoteScreenLeft,d=_-u.remoteScreenTop}if("touch"===u.clientInteractMode&&(c>u.remoteScreenWidth&&(c=u.remoteScreenWidth),d>u.remoteScreenHeight&&(d=u.remoteScreenHeight),c<0&&(c=0),d<0&&(d=0)),u.mobileTouchMove({finger_id:u.touchesIdentifierMap.get(s),event_type:Se[f],x:c,y:d,width:u.remoteScreenWidth,height:u.remoteScreenHeight,timestamp:o}),"touch"===u.clientInteractMode){var y=void 0,S=void 0;90===u.videoOrientation?(y=n-u.videoTop,S=u.videoWidth-t+u.videoLeft):(y=t-u.videoLeft,S=n-u.videoTop),u.updateCursorPosition({displayX:y,displayY:S})}}var b={id:s,type:i,x:c,y:d,pageX:t,pageY:n,movementX:h,movementY:p};u.touchesMap.set(s,b),"touchend"!==i&&"touchcancel"!==i||(u.touchesIdentifierMap.delete(s),setTimeout((function(){r.touchesMap.delete(s)}),100)),"touchstart"!==i||u.sdk.isMobileGame||(u.doubleTapResponse.push(b),u.doubleTap?u.sdk.onDoubleTap(u.doubleTapResponse):(u.doubleTap=!0,setTimeout((function(){r.doubleTap=!1,r.doubleTapResponse=[]}),300)))},u=this;try{for(var d=rn("touchend"===i||"touchcancel"===i||this.sdk.isMobileGame||"touch"===this.clientInteractMode?a:s),l=d.next();!l.done;l=d.next())c(l.value)}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this.sdk.isMobileGame||"touch"===this.clientInteractMode||this.sdk.onTouchEvent(this.touchesList)},e.prototype.onMouseMove=function(e){var t,n;if(!1!==this.kmStatus.mouse&&!this.dropMouseEvent){var r="getCoalescedEvents"in e?e.getCoalescedEvents():[e],i=null;this.webDraftLevel===ye.UNPACKAGE_SEND&&r.length>3?(this.sdk.log("webDraftLevel 1, event length is ".concat(r.length,", only pick 3 events")),r.splice(0,r.length-3)):this.webDraftLevel===ye.PACKAGE_SEND&&(this.sdk.log("webDraftLevel 2, event length is ".concat(r.length,", will send seq events")),i=[]);try{for(var o=rn(r),s=o.next();!s.done;s=o.next()){var a=s.value,c=a.offsetX,u=a.offsetY,d=a.movementX,l=a.movementY,h=c,p=u;if(h<0&&(h=0),p<0&&(p=0),this.sdk.cloudGamingWebRTC.getCursorMode()===ve.FRONT_DRAW_DELTA_POS)if(this.sdk.cloudGamingWebRTC.isMouseLocked()){if(!this.remoteMousePosition.sent){var f=this.remoteMousePosition,v=f.x,m=f.y;this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:v,y:m}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:v,y:m}),this.remoteMousePosition.sent=!0}var _=this.deltaMoveTo(d,l),g=_.remoteDeltaX,y=_.remoteDeltaY;this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:g,y:y}),this.drawMouseDeltaPosition(d,l)}else{var S=this.moveTo(h,p),b=S.remoteX,k=S.remoteY;this.remoteMousePosition.x=b,this.remoteMousePosition.y=k,this.remoteMousePosition.sent=!1,this.mousePosition.deltaX=h,this.mousePosition.deltaY=p}else if(this.sdk.cloudGamingWebRTC.mouseDeltaMove()||!this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var E=this.deltaMoveTo(d,l);g=E.remoteDeltaX,y=E.remoteDeltaY,i?i.push({type:"mousedeltamove",x:g,y:y}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:g,y:y})}else{var T=this.moveTo(h,p);if(b=T.remoteX,k=T.remoteY,i)this.enableMousemoveV2?i.push({type:"mousemove_v2",x:b,y:k}):i.push({type:"mousemove",x:b,y:k});else if(this.sdk.isMobileGame||"touch"===this.clientInteractMode){if(this.mousePosition.remoteX=b,this.mousePosition.remoteY=k,this.touchState!==Se.touchstart)return;this.mobileTouchMove({finger_id:0,event_type:Se.touchmove,x:b,y:k,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}else this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:b,y:k}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:b,y:k})}this.mousePosition.x=h,this.mousePosition.y=p}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this.webDraftLevel===ye.PACKAGE_SEND&&this.sdk.cloudGamingWebRTC.sendKmData({type:"key_seq",keys:i.map((function(e){return JSON.stringify(e)}))})}},e.prototype.onMouseMove2=function(e){var t,n;if(!1!==this.kmStatus.mouse&&!this.dropMouseEvent){var r="getCoalescedEvents"in e?e.getCoalescedEvents():[e];try{for(var i=rn(r),o=i.next();!o.done;o=i.next()){var s=o.value,a=s.offsetX,c=s.offsetY,u=a,d=c;u<0&&(u=0),d<0&&(d=0);var l=this.moveTo(u,d),h=l.remoteX,p=l.remoteY;if(this.mousePosition.remoteX=h,this.mousePosition.remoteY=p,this.sdk.isMobileGame&&this.touchState!==Se.touchstart)return;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchmove,x:h,y:p,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},e.prototype.drawMouseDeltaPosition=function(e,t){var n=this.sdk.cloudGamingWebRTC.getCursorShowStatus();this.sdk.getCursorElement().style.display=n?"block":"none";var r=this.sdk.cloudGamingWebRTC.getDisplayRect(),i=r.width,o=r.height;this.mousePosition.deltaX=this.mousePosition.deltaX+e,this.mousePosition.deltaY=this.mousePosition.deltaY+t,this.mousePosition.deltaX<=0&&(this.mousePosition.deltaX=0),this.mousePosition.deltaX>=i&&(this.mousePosition.deltaX=i),this.mousePosition.deltaY<=0&&(this.mousePosition.deltaY=0),this.mousePosition.deltaY>=o&&(this.mousePosition.deltaY=o);var s=this.sdk.cloudGamingWebRTC.getCursorHotSpot();this.updateCursorPosition({displayX:this.mousePosition.deltaX-s.x,displayY:this.mousePosition.deltaY-s.y})},e.prototype.moveTo=function(e,t){if(this.enableMousemoveV2&&!this.sdk.isMobileGame&&"touch"!==this.clientInteractMode){var n=this.transferRemotePositionV2({displayX:e,displayY:t});return{remoteX:n.x,remoteY:n.y}}var r=this.transferRemotePosition({displayX:e,displayY:t}),i=r.x,o=r.y;return i>=this.remoteScreenWidth+this.remoteScreenLeft&&(i=this.remoteScreenWidth+this.remoteScreenLeft-1),i<0&&(i=0),o>=this.remoteScreenHeight+this.remoteScreenTop&&(o=this.remoteScreenHeight+this.remoteScreenTop-1),o<0&&(o=0),{remoteX:i,remoteY:o}},e.prototype.deltaMoveTo=function(e,t){var n=this.transferRemotePositionDeltaMove({displayX:e,displayY:t,moveSensitivity:this.moveSensitivity}),r=n.x,i=n.y,o=r-this.remoteScreenLeft,s=i-this.remoteScreenTop;return this.deltaMoveToCalcX+=o,this.deltaMoveToCalcY+=s,this.deltaMoveToCalcX<0&&(this.deltaMoveToCalcX=0),this.deltaMoveToCalcY<0&&(this.deltaMoveToCalcY=0),this.deltaMoveToCalcX>this.remoteScreenWidth&&(this.deltaMoveToCalcX=this.remoteScreenWidth),this.deltaMoveToCalcY>this.remoteScreenHeight&&(this.deltaMoveToCalcX=this.remoteScreenHeight),{remoteDeltaX:o,remoteDeltaY:s}},e.prototype.isRightClick=function(e){return"which"in e?3===e.which:"button"in e?2===e.button:void 0},e.prototype.determineButtonType=function(e){var t;return null!==(t=["mouseleft","mousemiddle","mouseright","mousebackward","mouseforward","unused","unused"][e.button])&&void 0!==t?t:""},e.prototype.onMouseDown=function(e){if(!1!==this.kmStatus.mouse){var t=e.offsetX,n=e.offsetY;if(this.mouseClickPosition={x:t,y:n},this.sdk.isMobileGame||"touch"===this.clientInteractMode){var r=this.determineButtonType(e);if(this.sdk.isMobileGame&&"mouseleft"!==r)return;var i=this.mousePosition,o=i.remoteX,s=i.remoteY;this.mobileTouchMove({finger_id:0,event_type:Se.touchstart,x:o,y:s,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchstart}else this.sdk.cloudGamingWebRTC.sendKmData({type:this.determineButtonType(e),down:!0}),this.mouseState=be.mousedown,this.isRightClick(e)&&this.tryToCursorLock();3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onMouseDown2=function(e){if(!1!==this.kmStatus.mouse){var t=this.mousePosition,n=t.remoteX,r=t.remoteY;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchstart,x:n,y:r,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchstart,3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onMouseUp=function(e){if(!1!==this.kmStatus.mouse)if(this.sdk.isMobileGame||"touch"===this.clientInteractMode){var t=this.determineButtonType(e);if(this.sdk.isMobileGame&&"mouseleft"!==t)return;if(this.touchState===Se.touchstart){var n=this.mousePosition,r=n.remoteX,i=n.remoteY;this.mobileTouchMove({finger_id:0,event_type:Se.touchend,x:r,y:i,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}this.touchState=Se.touchend}else this.mouseState===be.mousedown&&this.sdk.cloudGamingWebRTC.sendKmData({type:this.determineButtonType(e),down:!1}),this.mouseState=be.mouseup},e.prototype.onMouseUp2=function(e){if(!1!==this.kmStatus.mouse){var t=this.mousePosition,n=t.remoteX,r=t.remoteY;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchend,x:n,y:r,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchend,3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onWheel=function(e){var t,n=this,r=e.deltaX,i=e.deltaY,o=Math.abs(i)>=Math.abs(r)?"vertical":"horizontal",s=this.mousePosition,a=s.remoteX,c=s.remoteY,u=function(e){var t=e.delta,r=e.type;n.sdk.cloudGamingWebRTC.sendKmData({type:r,delta:t,x:a,y:c,width:n.remoteScreenWidth,height:n.remoteScreenHeight})};if(null===(t=Ye().ua)||void 0===t?void 0:t.includes("Mac")){if(!0===this.wheeling)return;this.wheeling=!0,"vertical"===o&&u({delta:i,type:"mousescroll"}),"horizontal"===o&&u({delta:r,type:"mousehorizontalscroll"}),setTimeout((function(){n.wheeling=!1}),100)}else"vertical"===o&&u({delta:i,type:"mousescroll"}),"horizontal"===o&&u({delta:r,type:"mousehorizontalscroll"})},e.prototype.onKeyEvent=function(e){var t,n,r,i=this;if(e.preventDefault(),!1!==this.kmStatus.keyboard){var o=e.which||e.keyCode,s=e.ctrlKey,a=e.altKey,c=e.type,u=e.metaKey,d=e.location,l=e.key;if(!this.keyboardBanList.includes(o)){if("keyup"===c){if(s){if(o===St.Space)return this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!0}),void setTimeout((function(){i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!1})}),10);o===St.Backquote&&this.sdk.showStats.toggleStatisticsView()}o===St.Escape&&(+new Date-this.escPressTime>300&&this.sdk.cloudGamingWebRTC.lockMouse(!1),this.escPressTime=null),(null===(t=Ye().ua)||void 0===t?void 0:t.includes("Mac"))&&"Meta"===l&&sn([],on(this.keyboardPressedKeys.keys()),!1).forEach((function(e){e!==St.LeftWindowKey&&e!==St.SelectKey&&i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:e,down:!1}),i.keyboardPressedKeys.delete(e)}))}if("keydown"===c){if((null===(n=Ye().ua)||void 0===n?void 0:n.includes("Mac"))&&this.keyboardPressedKeys.set(o,e),o===St.X&&a||o===St.Escape?(o===St.X&&a&&this.sdk.cloudGamingWebRTC.lockMouse(!1),o===St.Escape&&(this.escPressTime||(this.escPressTime=+new Date))):this.tryToCursorLock(),this.enablePaste&&(u||s)&&o===St.V)return void(navigator.clipboard?navigator.clipboard.readText().then((function(e){i.sdk.sendText(e)})).catch((function(e){i.sdk.log("Failed to read clipboard contents: ",e),i.sdk.onEvent({type:"readclipboarderror",data:{message:e.message}})})):this.sdk.onEvent({type:"readclipboarderror"}));if(a&&o===St.F4)return void this.sdk.log("alt + f4 is forbidden")}if((null===(r=Ye().ua)||void 0===r?void 0:r.includes("Mac"))&&o===St.CapsLock)return this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!0}),void setTimeout((function(){i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!1})}),10);"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:"keydown"===c,location:d}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"keyboard",key:o,down:"keydown"===c,location:d}})}}},e.prototype.onKeyPress=function(){},e.prototype.onBodyClick=function(){var e,t=this;if(this.clickBodyToPlay){var n=this.sdk.getVideoElement(),r=this.sdk.getAudioElement();if(n&&this.sdk.cloudGamingWebRTC.getWebrtcConnectStatus()===fe.ESTABLISHED){this.mutedVideo||(r.muted=!1);try{"pause"===this.videoStatus&&n.pause(),n.play().then((function(){})).catch((function(e){t.sdk.log("onbody click play error",e)})),r.play().catch((function(e){t.sdk.log("onbody click play audio error",e)}))}catch(e){this.sdk.log("play video error",e)}}if("websocket"===this.sdk.streamingMode){var i=document.querySelector(".".concat(this.mount," .cloud-gaming-audio-stream-socket"));n&&n.play().catch((function(e){t.sdk.log("onbody click play error",e)})),i&&(null===(e=this.sdk.cloudGamingWebsocket.getMuxer("video"))||void 0===e||e.playCurrent(),this.mutedVideo||(i.muted=!1),i.play().catch((function(e){t.sdk.log("onbody click play audio error",e)})))}var o=this.sdk.getHuaweiAudioElement();o&&(this.mutedVideo||(o.muted=!1),o.play()),Ze()||Qe()||!this.clickToFullscreen||(this.sdk.log("click to fullscreen->",this.clickToFullscreen),this.fullscreen())}},e.prototype.onVideoPlaying=function(e){this.videoStatus="playing","webrtc"===this.sdk.streamingMode&&(this.sdk.log("video state",e.type),this.reshapeWindow(),this.sdk.onEvent({type:"video_state",data:{code:0,message:"playing"}}))},e.prototype.onVideoPause=function(e){this.sdk.log("video state",e.type),this.videoStatus="pause",this.sdk.onEvent({type:"video_state",data:{code:1,message:"pause"}})},e.prototype.onVideoEnd=function(e){this.sdk.log("video state",e.type),this.videoStatus="pause",this.sdk.onEvent({type:"video_state",data:{code:2,message:"ended"}})},e.prototype.onAudioPlaying=function(e){this.sdk.log("audio state",e.type),this.audioStatus="playing",this.sdk.onEvent({type:"audio_state",data:{code:0,message:"playing"}})},e.prototype.onAudioPause=function(e){this.sdk.log("audio state",e.type),this.audioStatus="pause",this.sdk.onEvent({type:"audio_state",data:{code:1,message:"pause"}})},e.prototype.onAudioEnd=function(e){this.sdk.log("audio state",e.type),this.audioStatus="pause",this.sdk.onEvent({type:"audio_state",data:{code:2,message:"ended"}})},e.prototype.onVideoElementClick=function(){this.sdk.getVideoElement().focus(),this.sdk.cloudGamingWebRTC.getCursorMode()===ve.FRONT_DRAW_DELTA_POS&&this.sdk.cloudGamingWebRTC.lockMouse(!0)},e.prototype.onFakeInputFocus=function(){if("local"===this.IMEType){var e=this.sdk.getFakeInputElement(),t=this.sdk.getCloudGamingContainerElement();e&&t&&(e.style.top="".concat(this.mouseClickPosition.y+(t.clientHeight-this.videoHeight)/2-5,"px"),e.style.left="".concat(this.mouseClickPosition.x+(t.clientWidth-this.videoWidth)/2,"px"))}},e.prototype.onFakeInputChange=function(e){var t=e.target,n=t.value,r=t.selectionStart;this.inputConfig.selectionStart=r,this.inputConfig.isComposing||this.sdk.androidInstance.inputText({content:n,mode:"override",index_after_override:r})},e.prototype.onOrientationChange=function(){var e=this;this.sdk.log("orientationchange"),setTimeout((function(){e.reshapeWindow()}),0)},e.prototype.tryToCursorLock=function(){if(!this.sdk.cloudGamingWebRTC.getForceShowCursor()){var e=document.pointerLockElement;e||this.sdk.cloudGamingWebRTC.getCursorShowStatus()&&!this.sdk.cloudGamingWebRTC.mouseDeltaMove()||(this.sdk.cloudGamingWebRTC.lockMouse(!0),this.sdk.log("tryToCursorLock",e,"forceShowCursor",this.sdk.cloudGamingWebRTC.getForceShowCursor()),this.sdk.log("toggleMouseLock true, auto run requestPointerLock"))}},en([bt()],e.prototype,"onContextMenu",null),en([bt()],e.prototype,"onTouch",null),en([bt()],e.prototype,"onMouseMove",null),en([bt()],e.prototype,"onMouseMove2",null),en([bt()],e.prototype,"onMouseDown",null),en([bt()],e.prototype,"onMouseDown2",null),en([bt()],e.prototype,"onMouseUp2",null),en([bt()],e.prototype,"onWheel",null),en([bt("keyEvent")],e.prototype,"onKeyEvent",null),e}();const cn=an;var un,dn='\n<div class="cloud-gaming-container" tabindex="-1">\n\n <div class="cloud-gaming-stream-container">\n <video class="video-stream" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay muted preload="auto"></video>\n <audio class="audio-stream" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay preload="auto"></audio>\n <audio class="cloud-gaming-audio-stream-socket" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay preload="auto"></audio>\n <div class="cursor" id="cursor"></div>\n <input class="tcg-fake-input"></input>\n </div>\n\n '.concat('\n<div class="qcloud-stat">\n \n <div class="qcloud-video">\n <div class="qcloud-stat-video">\n <div class="qcloud-stat-left">Video</div>\n </div>\n </div>\n\n <div class="qcloud-audio">\n <div class="qcloud-stat-audio">\n <div class="qcloud-stat-left">Audio</div>\n </div>\n </div>\n\n <div class="qcloud-info">\n <div class="qcloud-stat-info">\n <div class="qcloud-stat-left">Info</div>\n </div>\n </div>\n\n</div>','\n\n <div class="progress-bar-container">\n <div class="spinner"> </div>\n <p class="starting">正在启动云渲染服务</p>\n <p id="speed" class="starting"></p>\n </div>\n\n <a class="restart" href="javascript:window.location.reload();">重新连接</a>\n</div>'),ln=E8(206),hn=E8.n(ln),pn=E8(652),fn=E8.n(pn),vn={packetsReceived:0,packetsLost:0,nack:0,rttAverage:0,rttVariance:0,nackRate:0,packetsLostRate:0};!function(e){e[e.NETWORK_NORMAL=0]="NETWORK_NORMAL",e[e.NETWORK_CONGESTION=1]="NETWORK_CONGESTION",e[e.NACK_RISING=2]="NACK_RISING",e[e.HIGH_DELAY=3]="HIGH_DELAY",e[e.NETWORK_JITTER=4]="NETWORK_JITTER"}(un||(un={}));var mn=function(e){var t=e.packetsReceived,n=void 0===t?0:t,r=e.packetsLost,i=void 0===r?0:r,o=e.nack,s=void 0===o?0:o,a=e.rtt,c=void 0===a?[]:a,u=e.featureSwitch,d=void 0===u?{}:u,l=n-vn.packetsReceived;vn.packetsReceived=n;var h=i-vn.packetsLost;vn.packetsLost=i,vn.packetsLostRate=h/l;var p=i-vn.nack;vn.nack=s,vn.nackRate=p/l,vn.rttAverage=c.reduce((function(e,t){return e+t}),0)/c.length,vn.rttVariance=function(e){if(void 0===e&&(e=[]),!e.length)return 0;var t=e.reduce((function(e,t){return e+t}),0),n=e.length,r=t/n,i=0;return e.forEach((function(e){i+=(e-r)*(e-r)})),i/=n,Math.floor(i)}(c);var f=d.network_event_script,v=void 0===f?{}:f,m=v.loss_rate_threshold,_=v.nack_rate_threshold,g=v.rtt_avg_threshold,y=v.rtt_dev_threshold;return vn.packetsLostRate>m?un.NETWORK_CONGESTION:vn.nackRate>_?un.NACK_RISING:vn.rttAverage>g?un.HIGH_DELAY:vn.rttVariance>y?un.NETWORK_JITTER:un.NETWORK_NORMAL},_n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},gn=function(){function e(e){var t=e.sdk;this.inputDelay=0,this.inputSeqMap={},this.rttSum=0,this.rttCount=0,this.rttArray=[],this.rtt=0,this.rawRTT=0,this.latency={times:0,status:null},this.fps=null,this.delay=null,this.cpu="0",this.bitrate=null,this.lastBytesRevc=0,this.packetLost=null,this.nack=null,this.packetsReceived=null,this.framesDecoded=null,this.framesDropped=null,this.framesReceived=null,this.firCount=null,this.pliCount=null,this.decodems=null,this.interfameDelayMaxMs=null,this.frameWidth=null,this.frameHeight=null,this.packetsLossRate=0,this.codec="",this.jitterBuffer=0,this.lastFramesReceived=0,this.gpu="",this.audioFps=null,this.audioLevel=0,this.audioBitrate=null,this.audioLastBytesRevc=0,this.audioPacketsLost=null,this.audioPacketsReceived=null,this.audioNack=null,this.audioConcealedSamples=0,this.audioConcealmentEvents=0,this.audioJitterBuffer=0,this.audioTotalSamplesReceived=0,this.audioTotalSamplesDuration=0,this.audioSampleRate=0,this.audioChannels=0,this.audioPacketsLossRate=0,this.audioCodec="",this.metricBulk=[],this.reportTimer=null,this.serverSessionCost=0,this.connectSuccessTimeCost=0,this.iceConnectedCost=0,this.sdk=null,this.mount=null,this.sdk=t}return Object.defineProperty(e.prototype,"isShowing",{get:function(){return!!this.getQcloudStatElement()&&"none"!==this.getQcloudStatElement().style.display},enumerable:!1,configurable:!0}),e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.show=function(e){this.getQcloudStatElement()&&(this.getQcloudStatElement().style.display=e?"block":"none")},e.prototype.toggleStatisticsView=function(){var e=document.querySelector("#__vconsole");this.show(!this.isShowing),e&&(e.style.display=this.isShowing?"":"none")},e.prototype.getStats=function(){var e=this.sdk.gameConfig.getConfig({clientId:this.mount}).user_id;return{fps:this.fps,delay:this.delay,rtt:this.rtt,cpu:this.cpu,load_cost_time:this.connectSuccessTimeCost-this.serverSessionCost,bit_rate:this.bitrate,packet_lost:this.packetLost,nack:this.nack,packet_received:this.packetsReceived,gpu:this.gpu,input_delay:this.inputDelay,user_id:e,timestamp:+new Date}},e.prototype.getMediaStats=function(){return{videoStats:{fps:this.fps,rtt:this.rtt,bit_rate:it(+this.bitrate/1024/1024*8),packet_lost:this.packetLost,packet_received:this.packetsReceived,packet_loss_rate:this.packetsLossRate,nack:this.nack,jitter_buffer:this.jitterBuffer,width:this.frameWidth,height:this.frameHeight,codec:this.codec,timestamp:+new Date},audioStats:{sample_rate:this.audioSampleRate,channels:this.audioChannels,bit_rate:it(+this.audioBitrate/1024/1024*8),packet_lost:this.audioPacketsLost,packet_received:this.audioPacketsReceived,packet_loss_rate:this.audioPacketsLossRate,nack:this.audioNack,jitter_buffer:this.audioJitterBuffer,concealed_samples:this.audioConcealedSamples,concealment_events:this.audioConcealmentEvents,codec:this.audioCodec}}},e.prototype.setStat=function(e,t){var n,r,i,o,s,a=[],c=[];e.forEach((function(e){"inbound-rtp"===e.type&&("video"!==e.mediaType&&"video"!==e.kind||c.push(e),"audio"!==e.mediaType&&"audio"!==e.kind||a.push(e)),"track"===e.type&&(e.frameHeight||e.frameWidth||"video"===e.kind)&&c.push(e),"track"!==e.type||e.frameHeight&&e.frameWidth||a.push(e)}));try{for(var u=_n(c),d=u.next();!d.done;d=u.next()){var l=d.value,h=l.type,p=l.frameWidth,f=void 0===p?0:p,v=l.frameHeight,m=void 0===v?0:v,_=l.framesPerSecond,g=l.framerateMean,y=l.totalDecodeTime,S=void 0===y?0:y,b=l.framesDropped,k=void 0===b?0:b,E=l.firCount,T=void 0===E?0:E,C=l.pliCount,I=void 0===C?0:C,w=l.jitterBufferDelay,R=void 0===w?0:w,A=l.bytesReceived,O=void 0===A?0:A,x=l.nackCount,P=void 0===x?0:x,D=l.packetsLost,M=void 0===D?0:D,N=l.packetsReceived,L=void 0===N?0:N,U=l.framesReceived,V=void 0===U?0:U,F=l.jitter,B=l.totalInterFrameDelay,j=void 0===B?0:B,G=l.codecId,H=void 0===G?"":G,W=l.remoteSource,K=l.transportId,z=l.framesDecoded,q=void 0===z?0:z,J=l.jitterBufferEmittedCount;if((ue=void 0===J?0:J)||(ue=1),q||(q=1),"track"===h&&(W&&this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:"".concat(f,"x").concat(m),point:"qcloud-video"}),!(null===(s=Ye().name)||void 0===s?void 0:s.toLowerCase().includes("safari"))&&_||!W||(this.fps=V-this.lastFramesReceived,this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"}),this.lastFramesReceived=V),this.jitterBuffer=it(R/ue*1e3),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"})),"inbound-rtp"===h){this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:"".concat(f,"x").concat(m),point:"qcloud-video"}),this.frameWidth===f&&this.frameHeight===m||(this.frameWidth=f,this.frameHeight=m,this.sdk.onVideoStreamConfigChange({width:f,height:m}),this.sdk.log("video stream resolution changed ->".concat(f," ").concat(m)));var Y=((null==t?void 0:t.get(H))||{}).mimeType,X=void 0===Y?"":Y;this.modifyStatElement({name:"Codec",tag:"video-codec",stat:X,point:"qcloud-video"}),this.codec=X,_&&(this.fps=_,this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"})),g&&(this.fps=Math.floor(g),this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"}),this.jitterBuffer=Math.floor(1e3*F),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"})),this.bitrate=O-this.lastBytesRevc;var $=it(+this.bitrate/1024/1024*8);this.modifyStatElement({name:"VideoBitrate",tag:"video-bitrates",stat:"".concat($,"Mbit/s"),point:"qcloud-video"}),this.lastBytesRevc=O;var Q=it((M-this.packetLost)/(L-this.packetsReceived));this.packetsLossRate=Q,this.packetLost=M,this.packetsReceived=L,this.packetLost=M<0?0:M,this.modifyStatElement({name:"PacketLost",tag:"video-packet-lost",stat:"".concat(this.packetLost),point:"qcloud-video"}),this.nack=P,this.modifyStatElement({name:"NACK",tag:"video-nack",stat:"".concat(this.nack),point:"qcloud-video"}),this.jitterBuffer=it(R/ue*1e3),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"}),this.delay=it(+(S/q*1e3+this.jitterBuffer)),this.modifyStatElement({name:"Delay",tag:"video-delay",stat:"".concat(this.delay,"ms"),point:"qcloud-video"}),this.packetsReceived=L,this.framesDecoded=q,this.framesDropped=k,this.framesReceived=V,this.decodems=Math.floor(S/q*1e3),this.interfameDelayMaxMs=Math.floor(j/q*1e3),this.firCount=T,this.pliCount=I;var Z=(this.sdk.gameConfig.getConfig({clientId:this.mount}).feature_switch||{}).network_event_script;if(Z){var ee=Z.notify_threshold,te=void 0===ee?5:ee,ne=mn({packetsReceived:L,packetsLost:M,nack:P,rtt:this.rttArray,featureSwitch:this.sdk.gameConfig.getConfig({clientId:this.mount}).feature_switch});this.latency.status===ne?(this.latency.times=this.latency.times+1,this.latency.times===te&&this.latency.status!==un.NETWORK_NORMAL&&(this.sdk.onNetworkChange({status:"latency",data:{value:ne,message:un[ne]}}),this.sdk.onEvent({type:"latency",data:{value:ne,message:un[ne]}}),this.latency.times=0)):(this.latency.status=ne,this.latency.times=0)}var re=((null==t?void 0:t.get(K))||{}).selectedCandidatePairId,ie=void 0===re?"":re,oe=(ie&&((null==t?void 0:t.get(ie))||{})).currentRoundTripTime,se=void 0===oe?0:oe;this.rawRTT=se}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}try{for(var ae=_n(a),ce=ae.next();!ce.done;ce=ae.next()){var ue,de=ce.value,le=(h=de.type,de.packetsLost),he=(M=void 0===le?0:le,de.packetsReceived),pe=(L=void 0===he?0:he,de.bytesReceived),fe=(O=void 0===pe?0:pe,de.audioLevel),ve=void 0===fe?0:fe,me=de.nackCount,_e=(P=void 0===me?0:me,de.codecId),ge=(H=void 0===_e?"":_e,de.jitterBufferDelay),ye=(R=void 0===ge?0:ge,de.concealedSamples),Se=void 0===ye?0:ye,be=de.concealmentEvents,ke=void 0===be?0:be,Ee=de.totalSamplesReceived,Te=de.totalSamplesDuration,Ce=de.jitterBufferEmittedCount;if((ue=void 0===Ce?0:Ce)||(ue=1),"inbound-rtp"===h){var Ie=(null==t?void 0:t.get(H))||{},we=Ie.mimeType,Re=(X=void 0===we?"":we,Ie.channels);if(X){this.audioConcealedSamples=Se,this.audioConcealmentEvents=ke,this.audioChannels=Re,this.modifyStatElement({name:"Codec",tag:"audio-codec",stat:X,point:"qcloud-audio"}),this.audioCodec=X;var Ae=Math.round((Ee-this.audioTotalSamplesReceived)/(Te-this.audioTotalSamplesDuration));this.audioSampleRate=Ae,this.audioTotalSamplesDuration=Te,this.audioTotalSamplesReceived=Ee,this.audioBitrate=O-this.audioLastBytesRevc,$=it(+this.audioBitrate/1024/1024*8),this.modifyStatElement({name:"AudioBitrate",tag:"audio-bitrates",stat:"".concat($,"Mbit/s"),point:"qcloud-audio"}),this.audioLastBytesRevc=O,this.modifyStatElement({name:"PacketLost",tag:"audio-packet-lost",stat:"".concat(this.audioPacketsLost),point:"qcloud-audio"}),Q=it((M-this.audioPacketsLost)/(L-this.audioPacketsReceived)),this.audioPacketsLossRate=Q,this.audioPacketsLost=M,this.audioPacketsReceived=L,this.audioNack=P,this.modifyStatElement({name:"NACK",tag:"audio-nack",stat:"".concat(this.audioNack),point:"qcloud-audio"}),this.audioJitterBuffer=it(R/ue*1e3),this.jitterBuffer&&this.modifyStatElement({name:"JitterBuffer",tag:"audio-jitter-buffer",stat:"".concat(this.audioJitterBuffer,"ms"),point:"qcloud-audio"})}"track"===h&&this.modifyStatElement({name:"AudioLevel",tag:"audio-level",stat:"".concat(it(ve)),point:"qcloud-audio"})}}}catch(e){i={error:e}}finally{try{ce&&!ce.done&&(o=ae.return)&&o.call(ae)}finally{if(i)throw i.error}}},e.prototype.setInputStart=function(e){this.inputSeqMap[e]=(new Date).getTime()},e.prototype.setInputEnd=function(e){void 0===e&&(e=0),this.inputSeqMap[e]&&(this.inputDelay=Math.round((+new Date-this.inputSeqMap[e])/2),delete this.inputSeqMap[e])},e.prototype.setRTT=function(e){this.rtt=e,this.modifyStatElement({name:"RTT",tag:"video-rtt",stat:"".concat(e.toString(),"ms"),point:"qcloud-video"}),5===this.rttArray.length&&this.rttArray.shift(),this.rttArray.push(e),this.rttSum+=e,this.rttCount+=1;var t=e/(this.rttSum/this.rttCount)>2;return this.rttCount>60&&(this.rttSum=0,this.rttCount=0),t},e.prototype.setCpuAndGpuUsage=function(e){var t=e.cpu,n=void 0===t?"":t,r=e.gpu,i=void 0===r?"":r;this.cpu=n,+n&&this.modifyStatElement({name:"CpuUsage",tag:"cpu-usage",stat:n,point:"qcloud-info"}),this.gpu=i,+i&&this.modifyStatElement({name:"GpuUsage",tag:"gpu-usage",stat:i,point:"qcloud-info"})},e.prototype.setStaticStat=function(e){var t,n=e.serverIp,r=void 0===n?"":n,i=e.region,o=void 0===i?"":i,s=e.instanceId,a=void 0===s?"":s,c=e.instanceType,u=void 0===c?"":c,d=e.hostName,l=void 0===d?"":d,h=e.requestId,p=void 0===h?"":h,f=e.videoMimeType,v=void 0===f?"":f,m=e.audioMimeType,_=void 0===m?"":m,g=e.resolution,y=void 0===g?"":g;if(this.modifyStatElement({name:"Version",tag:"sdk-version",stat:Te,point:"qcloud-info"}),r&&this.modifyStatElement({name:"ServerIp",tag:"server-ip",stat:r,point:"qcloud-info"}),o&&this.modifyStatElement({name:"Region",tag:"region",stat:o,point:"qcloud-info"}),a&&this.modifyStatElement({name:"InstanceId",tag:"instance-id",stat:a,point:"qcloud-info"}),u&&this.modifyStatElement({name:"InstanceType",tag:"instance-type",stat:u,point:"qcloud-info"}),p&&this.modifyStatElement({name:"RequestId",tag:"request-id",stat:p,point:"qcloud-info"}),v&&this.modifyStatElement({name:"Codec",tag:"video-codec",stat:v,point:"qcloud-video"}),_&&this.modifyStatElement({name:"Codec",tag:"audio-codec",stat:_,point:"qcloud-audio"}),y&&this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:y,point:"qcloud-video"}),!document.querySelector(".qcloud-host")&&this.sdk.isMobileGame){var S=document.createElement("div");S.className="qcloud-stat-row qcloud-host",S.innerHTML="<div class='qcloud-stat-left'>HostName</div><div class='qcloud-stat-right'>".concat(l,"</div>"),l&&(null===(t=this.getQcloudStatElement())||void 0===t||t.appendChild(S))}},e.prototype.modifyStatElement=function(e){var t,n,r,i=e.name,o=void 0===i?"":i,s=e.tag,a=void 0===s?"":s,c=e.stat,u=void 0===c?"":c,d=e.point,l=void 0===d?null:d;if(null===(t=this.getQcloudStatElement())||void 0===t?void 0:t.querySelector(".qcloud-".concat(a)))this.getQcloudStatElement()&&(this.getQcloudStatElement().querySelector(".qcloud-".concat(a," .qcloud-stat-right")).innerHTML=u);else{var h=document.createElement("div");h.className="qcloud-stat-row qcloud-".concat(a),h.innerHTML="<div class='qcloud-stat-left'>".concat(o,"</div><div class='qcloud-stat-right'>").concat(u,"</div>"),null===(r=null===(n=this.getQcloudStatElement())||void 0===n?void 0:n.querySelector(".".concat(l)))||void 0===r||r.appendChild(h)}},e.prototype.setServerSessionTime=function(e){var t=this;this.serverSessionCost=e,setTimeout((function(){t.modifyStatElement({name:"ServerSessionTime",tag:"server-session",stat:"".concat(it((e-t.sdk.initStartTime)/1e3),"s"),point:"qcloud-info"})}),0)},e.prototype.setIceConnectedTime=function(e){this.iceConnectedCost=e},e.prototype.setConnectSuccessTime=function(e){this.connectSuccessTimeCost=e,this.modifyStatElement({name:"ConnectSuccessTime",tag:"connect-success",stat:"".concat(it((e-this.sdk.initStartTime)/1e3),"s"),point:"qcloud-info"})},e.prototype.addReportStat=function(){var e,t,n=this.sdk.gameConfig.getConfig({clientId:this.mount}),r=n.server_ip,i=n.request_id,o=n.server_version,s=n.user_id,a=n.app_id,c=n.game_id;this.metricBulk.push({user_id:s,request_id:i,server_ip:r,server_version:o,timestamp:+new Date,bit_rate:8*this.bitrate,packet_lost:this.packetLost,packet_received:this.packetsReceived,bytes_received:this.lastBytesRevc,audio_packet_lost:this.audioPacketsLost,audio_packet_received:this.audioPacketsReceived,fps:this.fps,delay:this.delay,nack:this.nack,cpu:+this.cpu,gpu:this.gpu,load_cost_time:this.iceConnectedCost-this.serverSessionCost,first_frame:this.connectSuccessTimeCost-this.serverSessionCost,jitter_buffer:this.jitterBuffer,input_delay:this.inputDelay,rtt:this.rtt,frame_decoded:this.framesDecoded,frame_dropped:this.framesDropped,frame_received:this.framesReceived,render_frame_rate:this.framesDecoded,receive_frame_rate:this.framesReceived,decoded_frame_rate:this.framesDecoded,decode_ms:this.decodems,version:"".concat(Te),platform:"0",pli_count:this.pliCount,fir_count:this.firCount,browser:"".concat(null===(e=Ye().os)||void 0===e?void 0:e.family,"/").concat(null===(t=Ye().os)||void 0===t?void 0:t.version,"/").concat(Ye().name),app_id:"".concat(null!=a?a:0),game_id:c,raw_rtt:1e3*this.rawRTT})},e.prototype.toggleMetricReportBulk=function(e){var t=this;"websocket"!==this.sdk.streamingMode&&(e?(clearInterval(this.reportTimer),this.reportTimer=setInterval((function(){t.metricReportBulk(),t.sdk.reportLogInner()}),1e4)):(clearInterval(this.reportTimer),this.sdk.reportLogInner()))},e.prototype.metricReportBulk=function(){return e=this,n=function(){var e,t,n,r,i,o,s,a;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:e=JSON.stringify({metric:"cg_client_stat",bulk:this.metricBulk}),t=this.sdk.gameConfig.getConfig({clientId:this.mount}).sig_key,n=null;try{n=t&&fn()(e.slice(0,128),t).toString()}catch(e){this.sdk.log("encode sig_key error",e)}r=n?" https://metrics-cloud-gaming.crtrcloud.com/report_metric_bulk?sig=".concat(n):" https://metrics-cloud-gaming.crtrcloud.com/report_metric_bulk",c.label=1;case 1:return c.trys.push([1,3,,4]),[4,hn().post(r,e)];case 2:return i=c.sent(),o=i.status,s=i.data,200===o||this.sdk.log("metricReportBulk failed",s),this.metricBulk=[],[3,4];case 3:return a=c.sent(),this.sdk.log("catch metricReportBulk failed",a.message,a.name),[3,4];case 4:return[2]}}))},new((t=void 0)||(t=Promise))((function(r,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(o,s)}a((n=n.apply(e,[])).next())}));var e,t,n},e.prototype.getQcloudStatElement=function(){var e;return null===(e=null===document||void 0===document?void 0:document.querySelector("#".concat(this.mount)))||void 0===e?void 0:e.querySelector(".qcloud-stat")},e}();const yn=gn;var Sn=function(){function e(){this._events={}}return e.prototype.clear=function(){this._events={}},e.prototype.on=function(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t)-1},e.prototype.trigger=function(e,t){var n=this;if("error"!==e){var r=this._events[e];(null==r?void 0:r.length)&&r.forEach((function(e){e(t)}))}else setTimeout((function(){var r=n._events[e];(null==r?void 0:r.length)&&r.forEach((function(e){e(t)}))}),100)},e.prototype.off=function(e,t,n){var r=this._events[e];if(null==r?void 0:r.length)if(void 0!==n)r.splice(n,1);else{var i=r.findIndex((function(e){return e===t}));i>-1&&r.splice(i,1)}},e.prototype.offAll=function(){this._events={}},e.prototype.once=function(e,t){var n=this;this._events[e]||(this._events[e]=[]);var r=null,i=function(o){t(o),n.off(e,i,r)};r=this.on(e,i)},e}(),bn=E8(995);bn.configure;const kn=bn;var En,Tn=(En=function(e,t){return En=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},En(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}En(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Cn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},In=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},wn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.logStr=[],t.allLogs=[],t.externalLogHandler=nt,t.serverSideDescription={},t.loggerConfig={mount:null},t}return Tn(t,e),t.prototype.initLoggerConfig=function(e){this.loggerConfig=e},t.prototype.setServerSideDescription=function(e){var t=e.serverSideDescription;this.serverSideDescription=t},t.prototype.log=function(){for(var e,t,n,r,i,o,s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];(null===(r=null===(n=this.loggerConfig)||void 0===n?void 0:n.debugSetting)||void 0===r?void 0:r.showLog)&&console.log.apply(console,function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(s),!1));var c="";try{for(var u=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),d=u.next();!d.done;d=u.next()){var l=d.value;try{c+="".concat("object"==typeof l?kn(l):l," ")}catch(e){console.log("Error stringify object:",e.message)}}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}var h=this.serverSideDescription,p=h.request_id,f=void 0===p?"":p,v=h.server_ip,m=void 0===v?"":v,_=h.user_id,g=void 0===_?"":_,y=null!==(i=m||f)&&void 0!==i?i:"";c="[TCG/".concat(y,"][").concat(g,"]:").concat(c),null===(o=this.externalLogHandler)||void 0===o||o.call(this,c);var S=new Date,b={timestamp:+S,server_ip:m,request_id:f,user_id:g,content:"".concat(tt(S,"yyyy-mm-dd hh:ii:ss")," ").concat(c,"\n")};this.logStr.push(b),this.allLogs.push({request_id:b.request_id,user_id:b.user_id,content:b.content})},t.prototype.getLog=function(){var e=this.serverSideDescription,t=e.request_id,n=void 0===t?"":t,r=e.server_ip,i=void 0===r?"":r;return this.logStr.forEach((function(e){e.server_ip||(e.server_ip=i),e.request_id||(e.request_id=n)})),this.logStr},t.prototype.getAllLogs=function(){var e=this.serverSideDescription.request_id,t=void 0===e?"":e;return this.allLogs.forEach((function(e){e.request_id||(e.request_id=t)})),this.allLogs},t.prototype.reportLogInner=function(){return Cn(this,0,void 0,(function(){return In(this,(function(e){return[2,this.metricLogReport(this.getLog())]}))}))},t.prototype.setExternalLog=function(e){void 0===e&&(e=nt),this.externalLogHandler=e},t.prototype.metricLogReport=function(e){return Cn(this,0,void 0,(function(){var t,n,r,i,o,s,a,c;return In(this,(function(u){switch(u.label){case 0:if(0===this.logStr.length)return[2];t="";try{t=kn({metric:"cg_client_log",bulk:e})}catch(e){console.log("Error stringify object:",e.message)}n=this.serverSideDescription.sig_key,r=null;try{r=n&&fn()(t.slice(0,128),n).toString()}catch(e){this.log("encode sig_key error",e)}i=r?"https://metrics-cloud-gaming.crtrcloud.com/report_log_bulk?sig=".concat(r):"https://metrics-cloud-gaming.crtrcloud.com/report_log_bulk",u.label=1;case 1:return u.trys.push([1,3,,4]),[4,hn().post(i,t)];case 2:return o=u.sent(),s=o.status,a=o.data,200===s?(this.log("metricReportLog",a),this.logStr=[],[2,a]):(this.log("metricReportLog failed",null==a?void 0:a.message),[2,{code:-1,message:"failed"}]);case 3:return c=u.sent(),this.log("catch metricReportLog failed",c.message,c.name),[2,{code:-1,message:"failed"}];case 4:return[2]}}))}))},t}(Sn);const Rn=wn;var An=E8(408),On=function(){function e(e){var t=e.sdk;this.gamepad="function"==typeof navigator.getGamepads?new An.GamepadListener:null,this.sdk=null,this.sdk=t}return e.prototype.addGamepadHandler=function(){var e=this,t=new Map;t.set(12,1),t.set(13,2),t.set(14,4),t.set(15,8),t.set(2,16384),t.set(3,32768),t.set(0,4096),t.set(1,8192),t.set(8,32),t.set(9,16),t.set(10,64),t.set(11,128),t.set(4,256),t.set(5,512),this.gamepad&&(this.gamepad.on("gamepad:connected",(function(t){var n=t.detail;e.sdk.log("gamepad:connected detail",n);var r=n.index,i=n.gamepad;e.sdk.log("gamepad connect, gamepad index is",r),e.sdk.sendGamepadEvent({type:"gamepadconnect"}),e.sdk.onGamepadConnectChange({status:"gamepadconnect",index:r,gamepad:i})})),this.gamepad.on("gamepad:disconnected",(function(t){var n=t.detail;e.sdk.log("gamepad:disconnected detail",n);var r=n.index;e.sdk.log("gamepad disconnected, gamepad index is",r),e.sdk.sendGamepadEvent({type:"gamepaddisconnect"}),e.sdk.onGamepadConnectChange({status:"gamepaddisconnect",index:r})})),this.gamepad.on("gamepad:button",(function(n){var r=n.detail,i=r.button,o=r.pressed,s=r.value,a=t.get(i);6===i||7===i?(6===i&&e.sdk.sendGamepadEvent({type:"lt",x:parseInt("".concat(255*s),10),down:o}),7===i&&e.sdk.sendGamepadEvent({type:"rt",x:parseInt("".concat(255*s),10),down:o})):e.sdk.sendGamepadEvent({type:"gamepadkey",key:a,down:o})})),this.gamepad.on("gamepad:axis",(function(t){var n=t.detail,r=n.stick,i=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(n.gamepad.axes,4),o=i[0],s=i[1],a=i[2],c=i[3];0===r&&e.sdk.sendGamepadEvent({type:"axisleft",x:parseInt("".concat(32767*o),10),y:-parseInt("".concat(32767*s),10)}),1===r&&e.sdk.sendGamepadEvent({type:"axisright",x:parseInt("".concat(32767*a),10),y:-parseInt("".concat(32767*c),10)})})),this.gamepad.start())},e}();const xn=On;var Pn=function(){return Pn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pn.apply(this,arguments)},Dn=function(e){var t,n,r=e.url,i=e.data,o=e.timeout,s=e.headers;return n=function(){var e,t,n;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(a){switch(a.label){case 0:return e=new AbortController,t=setTimeout((function(){return e.abort()}),null!=o?o:1e4),[4,fetch(r,{body:JSON.stringify(i),cache:"no-cache",credentials:"same-origin",headers:Pn({"content-type":"application/json"},s),method:"POST",mode:"cors",signal:e.signal}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.text()})).then((function(e){try{return JSON.parse(e)}catch(t){return e}})).catch((function(e){throw"AbortError"===e.name?new Error("request timeout"):new Error("".concat(e.name,": ").concat(e.message))}))];case 1:return n=a.sent(),clearTimeout(t),[2,n]}}))},new((t=void 0)||(t=Promise))((function(e,r){function i(e){try{s(n.next(e))}catch(e){r(e)}}function o(e){try{s(n.throw(e))}catch(e){r(e)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,o)}s((n=n.apply(undefined,[])).next())}))},Mn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},Nn=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ln=function(){function e(e){var t=e.sdk,n=this;this.token="",this.serverIp="",this.retryTimes=0,this.maxRetryTimes=10,this.retryInterval=6e3,this.sdk=null,this.mount=null,this.startRetry=function(e){var t=e.message;n.sdk.log("Watchdog, reconnect proxy failed, try again, startRetry, times",n.retryTimes),setTimeout((function(){if(n.retryTimes>=n.maxRetryTimes)return n.sdk.cloudGamingWebRTC.clearPeerConnection(),n.sdk.onConnectFailed({code:_e.EXCEEDED_LIMIT_RERTY_TIMES,msg:"Retries exceeded"});n.autoReconnect({message:t}),n.retryTimes=n.retryTimes+1,n.sdk.onConnectFailed({code:_e.AUTO_RECONNECTING,msg:"auto connecting"})}),n.retryInterval)},this.sdk=t}return e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.autoReconnect=function(e){var t=e.message;return Mn(this,0,void 0,(function(){var e,n,r,i,o,s,a,c,u,d,l,h,p,f,v,m;return Nn(this,(function(_){switch(_.label){case 0:return this.sdk.cloudGamingWebRTC.clearPeerConnection(),[4,this.sdk.cloudGamingWebRTC.newWebRtcConnect()];case 1:if(_.sent(),this.sdk.cloudGamingWebRTC.startHeartbeatReport(),this.sdk.isMobileGame)return[2,this.androidInstanceReconnect({message:t})];if(!this.serverIp||!this.token)return this.sdk.log("Watchdog, autoReconnect, serverIp:".concat(this.serverIp," or token:").concat(this.token," is not set, abort")),[2,this.sdk.onConnectFailed({code:me.CONNECT_FAILED,msg:"reconnect failed"})];e=this.sdk.cloudGamingWebRTC.getClientSideDescription(!1),n=this.sdk.gameConfig.getConfig({clientId:this.mount}),r=n.user_id,i=n.server_port,o=n.instance_id,s=i||7392,_.label=2;case 2:return _.trys.push([2,4,,5]),this.sdk.log("Watchdog, reconnect, serverIp:".concat(this.serverIp,", token:").concat(this.token)),a="host=".concat(this.serverIp,"&port=").concat(s,"&token=").concat(this.token,"&uid=").concat(r),c=this.sdk.accessInfo.getInstanceAccessInfo({instanceId:o}).WebRTCAddress,u="".concat("https://cgproxy.cloud-gaming.myqcloud.com","/reconnect?").concat(a),c&&(u="".concat(c,"/reconnect?").concat(a)),[4,Dn({url:u,data:e})];case 3:return d=_.sent(),l=d.Code,h=d.ServerSession,this.sdk.log("Watchdog, reconnect response code: ".concat(l)),0===l?(p=this.checkServerSession(h),f=p.code,v=p.message,0===f?(this.sdk.log("Watchdog, reconnect proxy success"),this.sdk.cloudGamingWebRTC.connect(ze(h)),this.retryTimes=0):(this.sdk.cloudGamingWebRTC.clearPeerConnection(),this.sdk.onConnectFailed({code:f,msg:v}),this.sdk.log("Watchdog, reconnect proxy failed"))):this.startRetry({message:t}),[3,5];case 4:return m=_.sent(),this.sdk.log("Watchdog post error",m),this.startRetry({message:null==m?void 0:m.message}),[3,5];case 5:return[2]}}))}))},e.prototype.setReconnectInfo=function(e){var t=e.serverIp,n=void 0===t?"":t,r=e.token,i=void 0===r?"":r;this.serverIp=n,this.token=i},e.prototype.checkServerSession=function(e){try{var t=JSON.parse(e),n=t.code,r=t.WebrtcResponse,i=t.Code,o=t.Msg,s=t.message,a=null!=n?n:i,c=s||o||(null==r?void 0:r.Msg);return this.sdk.log("Watchdog, server session code: ".concat(a,", message: ").concat(c)),{code:a,message:c}}catch(e){this.sdk.log("Watchdog, parse ServerSession error")}},e.prototype.androidInstanceReconnect=function(e){var t=e.message;return Mn(this,0,void 0,(function(){var e,n,r,i,o,s;return Nn(this,(function(a){switch(a.label){case 0:return e=this.sdk.gameConfig.getConfig({clientId:this.mount}).instance_id,this.sdk.log("Watchdog reconnect android instance, instance id is ".concat(e,", message: ").concat(t)),e?this.sdk.androidInstance.groupControl.groupControlId?(this.sdk.destroy({code:_e.MODE_FORBIDDEN,message:"Could not reconnect in group control mode"}),this.sdk.onConnectFailed({code:_e.MODE_FORBIDDEN,msg:"Could not reconnect in group control mode"}),[3,4]):[3,1]:[3,5];case 1:return a.trys.push([1,3,,4]),[4,this.sdk.accessInfo.createWebRTCSession({instanceId:e,clientSession:this.sdk.getClientSession()})];case 2:return n=a.sent(),r=n.ServerSession,i=n.Code,o=n.Message,this.sdk.log("Watchdog, reconnect response code: ".concat(i,", message: ").concat(o)),0===i?(this.sdk.log("Watchdog, reconnect proxy success"),this.sdk.cloudGamingWebRTC.connect(r),this.retryTimes=0):(this.sdk.log("Watchdog reconnect error",o),this.startRetry({message:o})),[3,4];case 3:return s=a.sent(),this.sdk.log("Watchdog reconnect cache error",s.name,s.message),this.startRetry({message:s.message}),[3,4];case 4:return[3,6];case 5:this.sdk.log("Watchdog reconnect error, instance id is not set"),a.label=6;case 6:return[2]}}))}))},e}();const Un=Ln;var Vn=function(){return Vn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Vn.apply(this,arguments)},Fn=function(){function e(e){var t=e.sdk;this.sdk=null,this.configBatch=new Map,this.sdk=t}return e.prototype.setConfig=function(e){var t=e.clientId,n=e.config,r=n.game_config,i=n.feature_switch,o=void 0===i?st:i,s=n.server_ip,a=n.region,c=n.instance_id,u=n.instance_type,d=n.host_name,l=n.request_id,h=n.video_mime_type,p=n.audio_mime_type;this.setSDKConfig(null==r?void 0:r.sdk_conf);var f=o.network_event_script;f&&(f=JSON.parse(f)),this.configBatch.set(t,Vn(Vn({},n),{feature_switch:{network_event_script:f}})),this.sdk.showStats.setStaticStat({serverIp:s,region:a,instanceId:c,instanceType:u,hostName:d,requestId:l,videoMimeType:h,audioMimeType:p})},e.prototype.updateConfig=function(e){var t=e.clientId,n=e.config;this.configBatch.set(t,Vn(Vn({},this.configBatch.get(t)),n))},e.prototype.setSDKConfig=function(e){if(e){var t=this.sdk.getInitOptions(),n=t.webDraftLevel,r=t.tabletMode;"number"==typeof e.webdraft_level&&void 0!==n&&this.sdk.pageEvent.setWebDraftLevel(e.webdraft_level),"boolean"==typeof e.tablet_mode&&void 0===r&&this.sdk.mouseTabletMode(e.tablet_mode)}},e.prototype.getConfig=function(e){var t=e.clientId;return this.configBatch.get(t)||st},e}();const Bn=Fn,jn={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Gn;const Hn=new Uint8Array(16),Wn=[];for(let e=0;e<256;++e)Wn.push((e+256).toString(16).slice(1));const Kn=function(e,t,n){if(jn.randomUUID&&!t&&!e)return jn.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!Gn){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Gn=crypto.getRandomValues.bind(crypto)}return Gn(Hn)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(Wn[e[t+0]]+Wn[e[t+1]]+Wn[e[t+2]]+Wn[e[t+3]]+"-"+Wn[e[t+4]]+Wn[e[t+5]]+"-"+Wn[e[t+6]]+Wn[e[t+7]]+"-"+Wn[e[t+8]]+Wn[e[t+9]]+"-"+Wn[e[t+10]]+Wn[e[t+11]]+Wn[e[t+12]]+Wn[e[t+13]]+Wn[e[t+14]]+Wn[e[t+15]]).toLowerCase()}(r)};var zn,qn;!function(e){e[e.opus=101]="opus",e[e.aac=102]="aac",e[e.h264=103]="h264",e[e.h265=104]="h265",e[e.vp8=105]="vp8",e[e.vp9=106]="vp9"}(zn||(zn={})),function(e){e[e.open=10]="open",e[e.message=11]="message"}(qn||(qn={}));var Jn,Yn,Xn=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},$n=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};function Qn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Jn&&Jn.apply(void 0,$n([e],Xn(t),!1))}function Zn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Yn&&Yn.apply(void 0,$n([e],Xn(t),!1))}var er=function(){function e(t){this.stype=null,this.isfmb=!1,this.isvcl=null,this.payload=null,this.ntype=null,this.payload=t,this.ntype=31&this.payload[0],this.isvcl=this.ntype===e.NDR||this.ntype===e.IDR}return Object.defineProperty(e,"NDR",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"IDR",{get:function(){return 5},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SEI",{get:function(){return 6},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SPS",{get:function(){return 7},enumerable:!1,configurable:!0}),Object.defineProperty(e,"PPS",{get:function(){return 8},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AUD",{get:function(){return 9},enumerable:!1,configurable:!0}),e.prototype.type=function(){return this.ntype},e.prototype.isKeyframe=function(){return this.ntype===e.IDR},e.prototype.getPayload=function(){return this.payload},e.prototype.getPayloadSize=function(){return this.payload.byteLength},e.prototype.getSize=function(){return 4+this.getPayloadSize()},e.prototype.getData=function(){var e=new Uint8Array(this.getSize());return new DataView(e.buffer).setUint32(0,this.getSize()-4),e.set(this.getPayload(),4),e},e}();function tr(e,t){var n=new Uint8Array((0|e.byteLength)+(0|t.byteLength));return n.set(e,0),n.set(t,0|e.byteLength),n}var nr=function(e){for(var t=0,n=e.byteLength,r=[],i=-1;t<n;)t+2<n&&0===e[t]&&0===e[t+1]&&1===e[t+2]?(-1!==i&&r.push(e.slice(i,t)),i=t+3,t+=3):t+3<n&&0===e[t]&&0===e[t+1]&&0===e[t+2]&&1===e[t+3]?(-1!==i&&r.push(e.slice(i,t)),i=t+4,t+=4):t+=1;return-1!==i&&r.push(e.slice(i)),r};const rr=function(){function e(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}return e.prototype.loadWord=function(){var e=this.data,t=this.bytesAvailable,n=e.byteLength-t,r=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");r.set(e.subarray(n,n+i)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},e.prototype.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},e.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;if(e>32&&console.log("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?n<<t|this.readBits(t):n},e.prototype.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},e.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},e.prototype.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},e.prototype.readBoolean=function(){return 1===this.readBits(1)},e.prototype.readUByte=function(){return this.readBits(8)},e.prototype.readUShort=function(){return this.readBits(16)},e.prototype.readUInt=function(){return this.readBits(32)},e}();var ir=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return e.parseHeader=function(e){var t=new rr(e.getPayload());t.readUByte(),e.isfmb=0===t.readUEG(),e.stype=t.readUEG()},e.prototype.parseNAL=function(e){if(!e)return!1;var t=!1;switch(e.type()){case er.IDR:case er.NDR:t=!0;break;case er.PPS:this.track.pps||(this.parsePPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case er.SPS:this.track.sps||(this.parseSPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&(this.remuxer.readyToDecode=!0)),t=!0;case er.AUD:case er.SEI:}return t},e.prototype.skipScalingList=function(e,t){for(var n=8,r=8,i=0;i<t;i++)0!==r&&(r=(n+e.readEG()+256)%256),n=0===r?n:r},e.prototype.readSPS=function(e){var t,n,r,i=new rr(e),o=0,s=0,a=0,c=0,u=i.readUByte.bind(i),d=i.readBits.bind(i),l=i.readUEG.bind(i),h=i.readBoolean.bind(i),p=i.skipBits.bind(i),f=i.skipEG.bind(i),v=i.skipUEG.bind(i),m=this.skipScalingList.bind(this);u();var _=u();if(d(5),p(3),u(),v(),100===_||110===_||122===_||244===_||44===_||83===_||86===_||118===_||128===_){var g=l();if(3===g&&p(1),v(),v(),p(1),h())for(n=3!==g?8:12,r=0;r<n;r++)h()&&m(r<6?16:64,i)}v();var y=l();if(0===y)l();else if(1===y)for(p(1),f(),f(),t=l(),r=0;r<t;r++)f();v(),p(1);var S=l(),b=l(),k=d(1);0===k&&p(1),p(1),h()&&(o=l(),s=l(),a=l(),c=l());var E=[1,1];if(h()&&h())switch(u()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(S+1)-2*o-2*s),height:(2-k)*(b+1)*16-(k?2:4)*(a+c),pixelRatio:E}},e.prototype.parseSPS=function(e){var t=this.readSPS(new Uint8Array(e));this.track.width=t.width,this.track.height=t.height,this.track.sps=[new Uint8Array(e)],this.track.codec="avc1.";for(var n=new DataView(e.buffer,e.byteOffset+1,4),r=0;r<3;++r){var i=n.getUint8(r).toString(16);i.length<2&&(i="0".concat(i)),this.track.codec+=i}},e.prototype.parsePPS=function(e){this.track.pps=[new Uint8Array(e)]},e}(),or=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return Object.defineProperty(e,"samplingRateMap",{get:function(){return[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]},enumerable:!1,configurable:!0}),e.getHeaderLength=function(e){return 1&e[1]?7:9},e.getFrameLength=function(e){return(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5},e.isAACPattern=function(e){return!(255!==e[0]||240&~e[1]||6&e[1])},e.extractAAC=function(t){var n,r=0,i=t.byteLength,o=[];if(!e.isAACPattern(t))return console.error("Invalid ADTS audio format"),o;var s=e.getHeaderLength(t);for(e.aacHeader||(e.aacHeader=t.subarray(0,s));r<i;)n=e.getFrameLength(t),o.push(t.subarray(s,n)),t=t.slice(n),r+=n;return o},e.prototype.setAACConfig=function(){var t,n=new Uint8Array(2),r=e.aacHeader;if(r){var i=1+((192&r[2])>>>6),o=(60&r[2])>>>2;t=(1&r[2])<<2,t|=(192&r[3])>>>6,n[0]=i<<3,n[0]|=(14&o)>>1,n[1]|=(1&o)<<7,n[1]|=t<<3,this.track.codec="mp4a.40.".concat(i),this.track.channelCount=t,this.track.config=n,this.remuxer.readyToDecode=!0}},e}();const sr=function(){function e(e){this.type="",this.listener={},this.type=e}return e.prototype.on=function(e,t){return this.listener[e]||(this.listener[e]=[]),this.listener[e].push(t),!0},e.prototype.off=function(e,t){if(this.listener[e]){var n=this.listener[e].indexOf(t);return n>-1&&this.listener[e].splice(n,1),!0}return!1},e.prototype.offAll=function(){this.listener={}},e.prototype.dispatch=function(e,t){return!!this.listener[e]&&(this.listener[e].forEach((function(e){e.apply(null,[t])})),!0)},e}();var ar=function(){function e(){}return e.prototype.init=function(){var e;for(e in this.types={avc1:[],avcC:[],hev1:[],hvcC:[],hvc1:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],Opus:[],dOps:[]},this.types)this.types.hasOwnProperty(e)&&(this.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);this.HDLR_TYPES={video:t,audio:n};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);this.STTS=this.STSC=this.STCO=i,this.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),this.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),this.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),this.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);this.FTYP=this.box(this.types.ftyp,o,a,o,s),this.DINF=this.box(this.types.dinf,this.box(this.types.dref,r))},e.prototype.box=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r,i=8,o=t.length,s=o;o--;)i+=t[o].byteLength;for((r=new Uint8Array(i))[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),o=0,i=8;o<s;++o)r.set(t[o],i),i+=t[o].byteLength;return r},e.prototype.hdlr=function(e){return this.box(this.types.hdlr,this.HDLR_TYPES[e])},e.prototype.mdat=function(e){return this.box(this.types.mdat,e)},e.prototype.mdhd=function(e,t){return this.box(this.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,85,196,0,0]))},e.prototype.mdia=function(e){return this.box(this.types.mdia,this.mdhd(e.timescale,e.duration),this.hdlr(e.type),this.minf(e))},e.prototype.mfhd=function(e){return this.box(this.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},e.prototype.minf=function(e){return"audio"===e.type?this.box(this.types.minf,this.box(this.types.smhd,this.SMHD),this.DINF,this.stbl(e)):this.box(this.types.minf,this.box(this.types.vmhd,this.VMHD),this.DINF,this.stbl(e))},e.prototype.moof=function(e,t,n){return this.box(this.types.moof,this.mfhd(e),this.traf(n,t))},e.prototype.moov=function(e,t,n){for(var r=e.length,i=[];r--;)i[r]=this.trak(e[r]);return this.box.apply(null,[this.types.moov,this.mvhd(n,t)].concat(i).concat(this.mvex(e)))},e.prototype.mvex=function(e){for(var t=e.length,n=[];t--;)n[t]=this.trex(e[t]);return this.box.apply(null,[this.types.mvex].concat(n))},e.prototype.mvhd=function(e,t){var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,e>>24&255,e>>16&255,e>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return this.box(this.types.mvhd,n)},e.prototype.sdtp=function(e){var t,n,r=e.samples||[],i=new Uint8Array(4+r.length);for(n=0;n<r.length;n++)t=r[n].flags,i[n+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return this.box(this.types.sdtp,i)},e.prototype.stbl=function(e){return this.box(this.types.stbl,this.stsd(e),this.box(this.types.stts,this.STTS),this.box(this.types.stsc,this.STSC),this.box(this.types.stsz,this.STSZ),this.box(this.types.stco,this.STCO))},e.prototype.avc1=function(e){var t,n,r,i=[],o=[];for(t=0;t<e.sps.length;t++)r=(n=e.sps[t]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(n));for(t=0;t<e.pps.length;t++)r=(n=e.pps[t]).byteLength,o.push(r>>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(n));var s=this.box(this.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(o))),a=e.width,c=e.height;return this.box(this.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,98,105,110,101,108,112,114,111,46,114,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s)},e.prototype.hvc1=function(e){for(var t=e.params,n=[e.vps,e.sps,e.pps],r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,+t.frame_rate.fps,3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),n.length]),i=r.length,o=0;o<n.length;o+=1){i+=3;for(var s=0;s<n[o].length;s+=1)i+=2+n[o][s].length}var a=new Uint8Array(i);a.set(r,0),i=r.length;var c=n.length-1;for(o=0;o<n.length;o+=1)for(a.set(new Uint8Array([32+o|(o===c?128:0),0,n[o].length]),i),i+=3,s=0;s<n[o].length;s+=1)a.set(new Uint8Array([n[o][s].length>>8,255&n[o][s].length]),i),i+=2,a.set(n[o][s],i),i+=n[o][s].length;var u=this.box(this.types.hvcC,a),d=e.width,l=e.height;return this.box(this.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,255&d,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,this.box(this.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},e.prototype.esds=function(e){var t=e.config.byteLength,n=new Uint8Array(26+t+3);return n.set([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5,t]),n.set(e.config,26),n.set([6,1,2],26+t),n},e.prototype.mp4a=function(e){var t=e.audiosamplerate;return this.box(this.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),this.box(this.types.esds,this.esds(e)))},e.prototype.dOps=function(e){var t=e.outputChannelCount,n=void 0===t?2:t,r=e.preSkip,i=void 0===r?0:r,o=e.inputSampleRate,s=void 0===o?48e3:o,a=e.outputGain,c=void 0===a?0:a,u=e.channelMappingFamily,d=void 0===u?0:u,l=new Uint8Array(19),h=new DataView(l.buffer);return h.setUint8(0,0),h.setUint8(1,n),h.setUint16(2,i,!1),h.setUint32(4,s,!1),h.setInt16(8,c,!1),h.setUint8(10,d),this.box(this.types.dOps,l)},e.prototype.getUint16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e),t},e.prototype.Opus=function(e){var t=e.channelCount,n=e.config;return this.box(this.types.Opus,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,this.getUint16(48e3),0,0]),this.dOps(n))},e.prototype.stsd=function(e){return"opus"===e.codec?this.box(this.types.stsd,this.STSD,this.Opus(e)):"audio"===e.type?this.box(this.types.stsd,this.STSD,this.mp4a(e)):e.codec.includes("hvc1")?this.box(this.types.stsd,this.STSD,this.hvc1(e)):this.box(this.types.stsd,this.STSD,this.avc1(e))},e.prototype.tkhd=function(e){var t=e.id,n=e.duration,r=e.width,i=e.height,o=e.volume;return this.box(this.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,255&o,o%1*10&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},e.prototype.traf=function(e,t){var n=this.sdtp(e),r=e.id;return this.box(this.types.traf,this.box(this.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),this.box(this.types.tfdt,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t])),this.trun(e,n.length+16+16+8+16+8+8),n)},e.prototype.trak=function(e){return"video"===e.type&&(e.duration=e.duration||4294967295),this.box(this.types.trak,this.tkhd(e),this.mdia(e))},e.prototype.trex=function(e){var t=e.id;return this.box(this.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.prototype.trun=function(e,t){var n,r,i,o,s,a,c=e.samples||[],u=c.length,d=12+16*u,l=new Uint8Array(d);for(t+=8+d,l.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),n=0;n<u;n++)i=(r=c[n]).duration,o=r.size,s=r.flags,a=r.cts,l.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*n);return this.box(this.types.trun,l)},e.prototype.initSegment=function(e,t,n){this.types||this.init();var r=this.moov(e,t,n),i=new Uint8Array(this.FTYP.byteLength+r.byteLength);return i.set(this.FTYP),i.set(r,this.FTYP.byteLength),i},e.prototype.initTypes=function(){this.types||this.init()},e}();const cr=new ar;var ur=1,dr=function(){function e(){this.mp4track={len:0,samples:[]},this.readyToDecode=!1,this.samples=[]}return e.getTrackID=function(){return ur++},e.prototype.flush=function(){this.mp4track.len=0,this.mp4track.samples=[]},e.prototype.isReady=function(){return!(!this.readyToDecode||!this.samples.length)||null},e}(),lr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),hr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"audio",channelCount:0,len:0,fragmented:!0,timescale:1e3,duration:0,samples:[],config:"",codec:""},r.dts=0,r.readyToDecode=!1,r.samples=[],r.nextDts=0,r.aac=new or(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return lr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.codec="",this.mp4track.channelCount=0,this.mp4track.config="",this.mp4track.timescale=1e3,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){if(e.length>0)for(var t=0;t<e.length;t++){var n=e[t],r=n.units,i=r.byteLength;this.samples.push({units:r,size:i,duration:n.duration}),this.mp4track.len+=i,this.readyToDecode||this.aac.setAACConfig()}},t.prototype.getPayload=function(){if(!this.isReady())return null;var e,t,n=new Uint8Array(this.mp4track.len),r=0,i=this.mp4track.samples;for(this.dts=this.nextDts;this.samples.length;){var o=this.samples.shift();o.units,(t=o.duration)<=0?(Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(t)),this.mp4track.len-=o.size):(this.nextDts+=t,e={size:o.size,duration:t,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},n.set(o.units,r),r+=o.size,i.push(e))}return i.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t.prototype.getAacParser=function(){return this.aac},t}(dr),pr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},vr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"video",len:0,fragmented:!0,sps:null,pps:null,codec:"",fps:30,width:0,height:0,timescale:1e3,duration:0,samples:[]},r.readyToDecode=!1,r.dts=0,r.samples=[],r.nextDts=0,r.h264Parser=new ir(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return pr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.sps=null,this.mp4track.pps=null,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n,r,i;try{for(var o=fr(e),s=o.next();!s.done;s=o.next()){var a=s.value,c=0,u=a.units,d=a.keyFrame,l=a.duration,h=a.compositionTimeOffset;try{for(var p=(r=void 0,fr(a.units)),f=p.next();!f.done;f=p.next()){var v=f.value;this.h264Parser.parseNAL(v)&&(c+=v.getSize())}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}u.length>0&&this.readyToDecode&&(this.mp4track.len+=c,this.samples.push({units:u,size:c,keyFrame:d,duration:l,compositionTimeOffset:h}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){var e,t;if(!this.isReady())return null;var n=new Uint8Array(this.mp4track.len),r=0;for(this.dts=this.nextDts;this.samples.length;){var i=this.samples.shift(),o=i.units,s=i.size,a=i.duration,c=i.compositionTimeOffset,u=i.keyFrame;if(a<=0)Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(a)),this.mp4track.len-=s;else{this.nextDts+=a;var d={size:s,duration:a,cts:c||0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,isNonSync:u?0:1,dependsOn:u?2:1}};try{for(var l=(e=void 0,fr(o)),h=l.next();!h.done;h=l.next()){var p=h.value;n.set(p.getData(),r),r+=p.getSize()}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}this.mp4track.samples.push(d)}}return this.mp4track.samples.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t}(dr),mr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_r=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.mp4track={id:dr.getTrackID(),type:"audio",channelCount:2,len:0,timescale:48e3,duration:960,sampleRate:48e3,samples:[],config:{},codec:"opus"},t.dts=0,t.readyToDecode=!1,t.samples=[],t.nextDts=0,t}return mr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),i=r.next();!i.done;i=r.next()){var o=i.value,s=o.unit,a=o.duration,c=s.byteLength;this.samples.push({units:s,size:c,duration:a}),this.mp4track.len+=c,this.readyToDecode||(this.readyToDecode=!0)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){if(!this.isReady())return null;var e=new Uint8Array(this.mp4track.len),t=0,n=this.mp4track.samples;for(this.dts=this.nextDts;this.samples.length;){var r=this.samples.shift(),i=r.duration,o=r.units,s=r.size;this.nextDts+=i;var a={size:s,duration:i,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}};e.set(o,t),t+=s,n.push(a)}return n.length?new Uint8Array(e.buffer,0,this.mp4track.len):null},t}(dr),gr="mp4a.40.2",yr="opus",Sr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},br=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},kr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Er=function(){function e(e){var t=e.name,n=e.contents,r=void 0===n?[]:n,i=e.children,o=void 0===i?[]:i;this._name=null,this._contents=null,this._children=null,this._name=t,this._contents=r,this._children=o}return e.stringToByteArray=function(e){return br([],Sr(e),!1).map((function(e){return e.charCodeAt(0)}))},e.getFloat64=function(e){var t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e),t},e.getUint64=function(e){var t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e)),t},e.getUint32=function(e){var t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t},e.getUint16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e),t},e.getInt16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setInt16(0,e),t},e.flatten=function(t){var n,r,i,o,s,a;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),n=kr(t),r=n.next(),c.label=1;case 1:return r.done?[3,6]:(i=r.value,Array.isArray(i)?[5,kr(e.flatten(i))]:[3,3]);case 2:return c.sent(),[3,5];case 3:return[4,i];case 4:c.sent(),c.label=5;case 5:return r=n.next(),[3,1];case 6:return[3,9];case 7:return o=c.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 9:return[2]}}))},Object.defineProperty(e.prototype,"contents",{get:function(){var t,n,r=new Uint8Array(this.length),i=this.buildContents(),o=0;try{for(var s=kr(e.flatten(i)),a=s.next();!a.done;a=s.next()){var c=a.value;"object"!=typeof c?(r[o]=c,o++):(r.set(c,o),o+=c.length)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.buildLength()},enumerable:!1,configurable:!0}),e.prototype.buildContents=function(){return br([this._contents],Sr(this._children.map((function(e){return e.buildContents()}))),!1)},e.prototype.buildLength=function(){return(Array.isArray(this._contents)?this._contents.reduce((function(e,t){return e+(void 0===t.length?1:t.length)}),0):void 0===this._contents.length?1:this._contents.length)+this._children.reduce((function(e,t){return e+t.length}),0)},e.prototype.addChild=function(e){this._children.push(e)},e}();const Tr=Er;var Cr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ir=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},wr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Rr=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.contents,o=r.children;return e.call(this,{name:t,contents:i,children:o})||this}return Cr(t,e),t.prototype.buildContents=function(){return wr(wr(wr([],Ir(this._lengthBytes),!1),Ir(Tr.stringToByteArray(this._name)),!1),Ir(e.prototype.buildContents.call(this)),!1)},t.prototype.buildLength=function(){return this._length||(this._length=4+this._name.length+e.prototype.buildLength.call(this),this._lengthBytes=Tr.getUint32(this._length)),this._length},t}(Tr);const Ar=Rr;var Or=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),xr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Pr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Dr=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.contents,o=r.tags;return e.call(this,{name:t,contents:i,children:o})||this}return Or(t,e),t.getLength=function(e){var t=Tr.getUint32(e);return t.every((function(e,t,n){return 0===e&&(n[t]=128,!0)})),t},t.prototype.buildContents=function(){return Pr(Pr([this._name],xr(this._lengthBytes),!1),xr(e.prototype.buildContents.call(this)),!1)},t.prototype.buildLength=function(){if(!this._length){var n=e.prototype.buildLength.call(this);this._lengthBytes=t.getLength(n),this._length=1+n+this._lengthBytes.length}return this._length},t.prototype.addTag=function(e){this.addChild(e)},t}(Tr);const Mr=Dr;var Nr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Lr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Ur=function(){function e(e){this.codec="opus",this.codec=e}return e.prototype.getInitializationSegment=function(e){var t=e.header;return new Tr({children:[new Ar("ftyp",{contents:[Ar.stringToByteArray("iso5"),0,0,2,0,Ar.stringToByteArray("iso6mp41")]}),new Ar("moov",{children:[new Ar("mvhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2]}),new Ar("trak",{children:[new Ar("tkhd",{contents:[0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("mdia",{children:[new Ar("mdhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,Ar.getUint32(t.sampleRate),0,0,0,0,85,196,0,0]}),new Ar("hdlr",{contents:[0,0,0,0,Ar.stringToByteArray("mhlr"),Ar.stringToByteArray("soun"),0,0,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("minf",{children:[new Ar("stbl",{children:[new Ar("stsd",{contents:[0,0,0,0,0,0,0,1],children:[this.getCodecBox(t)]}),new Ar("stts",{contents:[0,0,0,0,0,0,0,0]}),new Ar("stsc",{contents:[0,0,0,0,0,0,0,0]}),new Ar("stsz",{contents:[0,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("stco",{contents:[0,0,0,0,0,0,0,0]})]})]})]})]}),new Ar("mvex",{children:[new Ar("trex",{contents:[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]})]})]})]}).contents},e.prototype.getMediaSegment=function(e){var t=e.frames,n=e.sequenceNumber,r=e.baseMediaDecodeTime,i=e.track.samples,o=Nr(i,1)[0],s=o.flags,a=o.duration,c=o.size,u=o.cts,d=function(){var e,t,n=new Uint8Array(4+i.length);for(t=0;t<i.length;t++)e=i[t].flags,n[t+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return new Ar("sdtp",{contents:n})}();return new Tr({children:[new Ar("moof",{children:[new Ar("mfhd",{contents:[0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]}),new Ar("traf",{children:[new Ar("tfhd",{contents:[0,2,0,0,0,0,0,1]}),new Ar("tfdt",{contents:[0,0,0,0,Ar.getUint32(r)]}),new Ar("trun",{contents:[0,0,15,1,Ar.getUint32(t.length),Ar.getUint32(92+d.length+16*t.length),Ar.getUint32(a),Ar.getUint32(c),s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,Ar.getUint32(u)]}),d]})]}),new Ar("mdat",{contents:this.getFrameData(t)})]}).contents},e.prototype.getCodecBox=function(e){switch(this.codec){case"mp3":return this.getMp4a(e,107);case gr:return this.getMp4a(e,64);case yr:return this.getOpus(e);case"flac":return this.getFlaC(e)}},e.prototype.getOpus=function(e){var t=e.sampleRate,n=void 0===t?48e3:t,r=e.channels,i=void 0===r?2:r,o=e.bitDepth,s=void 0===o?16:o,a=e.preSkip,c=void 0===a?0:a,u=e.inputSampleRate,d=void 0===u?48e3:u,l=e.outputGain,h=void 0===l?0:l,p=e.channelMappingFamily,f=void 0===p?0:p,v=e.streamCount,m=void 0===v?0:v,_=e.coupledStreamCount,g=void 0===_?0:_,y=e.channelMappingTable,S=void 0===y?0:y;return new Ar("Opus",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,s,0,0,0,0,Ar.getUint16(n),0,0],children:[new Ar("dOps",{contents:[0,i,Ar.getUint16(c),Ar.getUint32(d),Ar.getInt16(h),f,0!==f?[m,g,S]:[]]})]})},e.prototype.getFlaC=function(e){return new Ar("fLaC",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channels,0,e.bitDepth,0,0,0,0,Ar.getUint16(e.sampleRate),0,0],children:[new Ar("dfLa",{contents:Lr([0,0,0,0],Nr(e.streamInfo||[128,0,0,34,Ar.getUint16(e.blockSize),Ar.getUint16(e.blockSize),0,0,0,0,0,0,Ar.getUint32(e.sampleRate<<12|e.channels<<8|e.bitDepth-1<<4),0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),!1)})]})},e.prototype.getMp4a=function(e,t){var n=new Mr(4,{contents:[t,21,0,0,0,0,0,0,0,0,0,0,0]});return 64===t&&n.addTag(new Mr(5,{contents:e.audioSpecificConfig})),new Ar("mp4a",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channels,0,16,0,0,0,0,Ar.getUint16(e.sampleRate),0,0],children:[new Ar("esds",{contents:[0,0,0,0],children:[new Mr(3,{contents:[0,1,0],tags:[n,new Mr(6,{contents:2})]})]})]})},e.prototype.getSamplesPerFrame=function(e){return this.codec===gr?e.map((function(e){var t=e.data,n=e.header;return Ar.getUint32(t.length-n.length)})):e.map((function(e){var t=e.data;return Ar.getUint32(t.length)}))},e.prototype.getFrameData=function(e){return this.codec===gr?e.map((function(e){var t=e.data,n=e.header;return t.subarray(n.length)})):e.map((function(e){return e.data}))},e}(),Vr=new Ur(yr),Fr=function(){function e(t){this.stype=null,this.isfmb=!1,this.isvcl=null,this.payload=null,this.ntype=null,this.payload=t,this.ntype=this.payload[0]>>1&63,this.isvcl=this.ntype===e.NDR||this.ntype===e.IDR}return Object.defineProperty(e,"NDR",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"IDR",{get:function(){return 19},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VPS",{get:function(){return 32},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SPS",{get:function(){return 33},enumerable:!1,configurable:!0}),Object.defineProperty(e,"PPS",{get:function(){return 34},enumerable:!1,configurable:!0}),e.prototype.type=function(){return this.ntype},e.prototype.isKeyframe=function(){return this.ntype===e.IDR},e.prototype.getPayload=function(){return this.payload},e.prototype.getPayloadSize=function(){return this.payload.byteLength},e.prototype.getSize=function(){return 4+this.getPayloadSize()},e.prototype.getData=function(){var e=new Uint8Array(this.getSize());return new DataView(e.buffer).setUint32(0,this.getSize()-4),e.set(this.getPayload(),4),e},e}(),Br=function(){return Br=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Br.apply(this,arguments)},jr=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return e.parseHeader=function(e){var t=new rr(e.getPayload());t.readUByte(),e.isfmb=0===t.readUEG(),e.stype=t.readUEG()},e.prototype.parseNAL=function(e){if(!e)return!1;var t=!1;switch(e.type()){case Fr.IDR:case Fr.NDR:t=!0;break;case Fr.PPS:this.track.pps||(this.parsePPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case Fr.SPS:this.track.sps||(this.parseSPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case Fr.VPS:this.track.sps||(this.parseVPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0}return t},e.prototype.ebsp2rbsp=function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0;r<e.byteLength;r++)r>=2&&3===e[r]&&0===e[r-1]&&0===e[r-2]||(t[n]=e[r],n++);return new Uint8Array(t.buffer,0,n)},e.prototype.skipScalingList=function(e,t){for(var n=8,r=8,i=0;i<t;i++)0!==r&&(r=(n+e.readEG()+256)%256),n=0===r?n:r},e.prototype.readVPS=function(e){var t=new rr(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}},e.prototype.readSPS=function(e){var t=new rr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var n=t.readBits(3);t.readBoolean();for(var r=t.readBits(2),i=t.readBoolean(),o=t.readBits(5),s=t.readUByte(),a=t.readUByte(),c=t.readUByte(),u=t.readUByte(),d=t.readUByte(),l=t.readUByte(),h=t.readUByte(),p=t.readUByte(),f=t.readUByte(),v=t.readUByte(),m=t.readUByte(),_=[],g=[],y=0;y<n;y++)_.push(t.readBoolean()),g.push(t.readBoolean());if(n>0)for(y=n;y<8;y++)t.readBits(2);for(y=0;y<n;y++)_[y]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),g[y]&&t.readUByte();t.readUEG();var S=t.readUEG();3===S&&t.skipBits(1);var b=t.readUEG(),k=t.readUEG(),E=t.readBoolean(),T=0,C=0,I=0,w=0;E&&(T+=t.readUEG(),C+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG());var R=t.readUEG(),A=t.readUEG(),O=t.readUEG();for(y=t.readBoolean()?0:n;y<=n;y++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(var x=0;x<4;x++)for(var P=0;P<(3===x?2:6);P++)if(t.readBoolean()){var D=Math.min(64,1<<4+(x<<1));for(x>1&&t.readEG(),y=0;y<D;y++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());var M=t.readUEG(),N=0;for(y=0;y<M;y++){var L=!1;if(0!==y&&(L=t.readBoolean()),L){y===M&&t.readUEG(),t.readBoolean(),t.readUEG();for(var U=0,V=0;V<=N;V++){var F=t.readBoolean(),B=!1;F||(B=t.readBoolean()),(F||B)&&U++}N=U}else{var j=t.readUEG(),G=t.readUEG();for(N=j+G,V=0;V<j;V++)t.readUEG(),t.readBoolean();for(V=0;V<G;V++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){var H=t.readUEG();for(y=0;y<H;y++){for(V=0;V<O+4;V++)t.readBits(1);t.readBits(1)}}var W=0,K=1,z=1,q=!0,J=1,Y=0;t.readBoolean(),t.readBoolean();var X=!1;if(t.readBoolean()){if(t.readBoolean()){var $=t.readUByte();$>0&&$<16?(K=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][$-1],z=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][$-1]):255===$&&(K=t.readBits(16),z=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),(X=t.readBoolean())&&(T+=t.readUEG(),C+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG()),t.readBoolean()&&(J=t.readBits(32),Y=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){var Q=t.readBoolean(),Z=t.readBoolean(),ee=!1;for((Q||Z)&&((ee=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ee&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5)),y=0;y<=n;y++){var te=!1;(q=t.readBoolean())||t.readBoolean()?t.readEG():te=t.readBoolean();var ne=te?1:t.readUEG()+1;if(Q)for(V=0;V<ne;V++)t.readUEG(),t.readUEG(),ee&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Z)for(V=0;V<ne;V++)t.readUEG(),t.readUEG(),ee&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),W=t.readUEG())}var re=b,ie=k;if(E||X){var oe=1,se=1;1===S?oe=se=2:2===S&&(oe=2),re=b-oe*C-oe*T,ie=k-se*w-se*I}var ae=r?["A","B","C"][r]:"",ce=s<<24|a<<16|c<<8|u,ue=0;for(y=0;y<32;y++)ue=(ue|(ce>>y&1)<<31-y)>>>0;var de=ue.toString(16);1===o&&"2"===de&&(de="6");var le=i?"H":"L";return{codecString:"hvc1.".concat(ae).concat(o,".").concat(de,".").concat(le).concat(m,".B0"),params:{general_tier_flag:i,general_profile_idc:o,general_profile_space:r,general_profile_compatibility_flags:[s,a,c,u],general_constraint_indicator_flags:[d,l,h,p,f,v],general_level_idc:m,bit_depth:R+8,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:A,min_spatial_segmentation_idc:W,chroma_format_idc:S,frame_rate:{fixed:q,fps:Y/J}},width:re,height:ie,pixelRatio:[K,z]}},e.prototype.readPPS=function(e){var t=new rr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var n=t.readBoolean(),r=t.readBoolean(),i=1;return r&&n?i=0:r?i=3:n&&(i=2),{parallelismType:i}},e.prototype.parseSPS=function(e){var t=this.readSPS(e);this.track.width=t.width,this.track.height=t.height,this.track.pixelRatio=t.pixelRatio,this.track.codec=t.codecString,this.track.params=Br(Br({},this.track.params),t.params),this.track.sps=[new Uint8Array(e)],console.log("resolution",this.track.width,this.track.height)},e.prototype.parsePPS=function(e){var t=this.readPPS(e);this.track.params=Br(Br({},this.track.params),t),this.track.pps=[new Uint8Array(e)]},e.prototype.parseVPS=function(e){this.track.params=Br(Br({},this.track.params),this.readVPS(e)),this.track.vps=[new Uint8Array(e)]},e}(),Gr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Hr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Wr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"video",len:0,fragmented:!0,vps:null,sps:null,pps:null,codec:"hvc1.1.6.L150.B0",fps:30,pixelRatio:[0,0],params:{},width:0,height:0,timescale:1e3,duration:0,samples:[]},r.readyToDecode=!1,r.dts=0,r.samples=[],r.nextDts=0,r.h265=new jr(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return Gr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.sps=null,this.mp4track.pps=null,this.mp4track.vps=null,this.mp4track.params={},this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n,r,i;try{for(var o=Hr(e),s=o.next();!s.done;s=o.next()){var a=s.value,c=0,u=a.units,d=a.keyFrame,l=a.duration,h=a.compositionTimeOffset;try{for(var p=(r=void 0,Hr(a.units)),f=p.next();!f.done;f=p.next()){var v=f.value;this.h265.parseNAL(v)&&(c+=v.getSize())}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}u.length>0&&this.readyToDecode&&(this.mp4track.len+=c,this.samples.push({units:u,size:c,keyFrame:d,duration:l,compositionTimeOffset:h}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){var e,t;if(!this.isReady())return null;var n=new Uint8Array(this.mp4track.len),r=0;for(this.dts=this.nextDts;this.samples.length;){var i=this.samples.shift(),o=i.units,s=i.size,a=i.duration,c=i.compositionTimeOffset,u=i.keyFrame;if(a<=0)Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(a)),this.mp4track.len-=s;else{this.nextDts+=a;var d={size:s,duration:a,cts:c||0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,isNonSync:u?0:1,dependsOn:u?2:1}};try{for(var l=(e=void 0,Hr(o)),h=l.next();!h.done;h=l.next()){var p=h.value;n.set(p.getData(),r),r+=p.getSize()}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}this.mp4track.samples.push(d)}}return this.mp4track.samples.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t}(dr),Kr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},qr=function(e){function t(){var t=e.call(this,"remuxer")||this;return t.tracks={},t.initialized=!1,t.trackTypes=[],t.videoSeq=1,t.audioSeq=1,t.timescale=1e3,t.mediaDuration=0,t.opusConfig={sampleRate:48e3,channels:2,bitDepth:16,duration:960},t}return Kr(t,e),t.prototype.addTrack=function(e,t){var n=(void 0===t?{}:t).config;if("avc"===e&&(this.tracks.avc=new vr(this.timescale,this.mediaDuration),this.trackTypes.push("avc")),"hevc"===e&&(this.tracks.hevc=new Wr(this.timescale,this.mediaDuration),this.trackTypes.push("hevc")),"aac"===e){var r=new hr(this.timescale,this.mediaDuration);this.tracks.aac=r,this.trackTypes.push("aac")}"opus"===e&&(this.tracks.opus=new _r,this.trackTypes.push("opus"),this.opusConfig=n)},t.prototype.reset=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value;this.tracks[i].resetTrack()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.initialized=!1},t.prototype.destroy=function(){this.tracks={},this.offAll()},t.prototype.isReady=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value;if(!this.tracks[i].readyToDecode||!this.tracks[i].samples.length)return!1}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return!0},t.prototype.remux=function(e){var t=e.avc,n=e.hevc,r=e.aac,i=e.opus;(null==t?void 0:t.length)>0&&this.tracks.avc.remux(t),(null==n?void 0:n.length)>0&&this.tracks.hevc.remux(n),(null==r?void 0:r.length)>0&&this.tracks.aac.remux(r),(null==i?void 0:i.length)>0&&this.tracks.opus.remux(i),this.flush(Object.keys(e))},t.prototype.flush=function(e){if(this.initialized){var t,n;if(e.includes("opus")&&(null==(n=(t=this.tracks.opus).getPayload())?void 0:n.byteLength)){var r={type:"opus",payload:Vr.getMediaSegment({frames:[{data:n}],sequenceNumber:this.audioSeq,baseMediaDecodeTime:t.dts,track:t.mp4track}),dts:t.dts};this.dispatch("buffer",r),t.flush(),this.audioSeq=this.audioSeq+1}e.includes("avc")&&(null==(n=(t=this.tracks.avc).getPayload())?void 0:n.byteLength)&&(r={type:"avc",payload:tr(cr.moof(this.videoSeq,t.dts,t.mp4track),cr.mdat(n)),dts:t.dts,fps:t.mp4track.fps},this.dispatch("buffer",r),t.flush(),this.videoSeq=this.videoSeq+1),e.includes("hevc")&&(null==(n=(t=this.tracks.hevc).getPayload())?void 0:n.byteLength)&&(r={type:"hevc",payload:tr(cr.moof(this.videoSeq,t.dts,t.mp4track),cr.mdat(n)),dts:t.dts,fps:t.mp4track.fps},this.dispatch("buffer",r),t.flush(),this.videoSeq=this.videoSeq+1)}else this.isReady()&&(this.dispatch("ready"),this.initSegment(),this.initialized=!0,this.flush(e))},t.prototype.initSegment=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value,o=null;if("avc"===i&&(cr.initTypes(),o=cr.initSegment([this.tracks.avc.mp4track],this.mediaDuration,this.timescale)),"hevc"===i&&(cr.initTypes(),o=cr.initSegment([this.tracks.hevc.mp4track],this.mediaDuration,this.timescale)),"opus"===i){var s=this.opusConfig,a=s.sampleRate,c=s.channels,u=s.bitDepth;s.duration,o=Vr.getInitializationSegment({header:{sampleRate:a,channels:c,bitDepth:u,preSkip:3840,inputSampleRate:a,outputGain:0,channelMappingFamily:0}})}var d={type:i,payload:o,eventType:"init"};this.dispatch("buffer",d)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t}(sr);const Jr=qr;var Yr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Xr=function(e){function t(t,n){var r=e.call(this,"buffer")||this;return r.bufferType=null,r.queue=new Uint8Array,r.cleaning=!1,r.pendingCleaning=0,r.cleanOffset=10,r.cleanRanges=[],r.sourceBuffer=null,r.needDestroyBuffer=!1,r.bufferType=n,r.sourceBuffer=t,r.sourceBuffer.addEventListener("updateend",(function(){r.pendingCleaning>0&&(r.initCleanup(r.pendingCleaning),r.pendingCleaning=0),r.cleaning=!1,r.cleanRanges.length?r.doCleanup():r.needDestroyBuffer&&(r.destroyBuffer(),r.needDestroyBuffer=!1)})),r.sourceBuffer.addEventListener("error",(function(e){Qn("sourceBuffer on error",e),r.dispatch("error",{type:r.bufferType,name:"buffer",error:"buffer error"})})),r}return Yr(t,e),t.prototype.destroy=function(){this.sourceBuffer.updating?this.needDestroyBuffer=!0:this.destroyBuffer(),this.queue=null,this.sourceBuffer=null,this.offAll()},t.prototype.destroyBuffer=function(){var e;if((null===(e=this.sourceBuffer.buffered)||void 0===e?void 0:e.length)&&!this.cleaning)for(var t=0;t<this.sourceBuffer.buffered.length;++t){var n=this.sourceBuffer.buffered.start(t),r=this.sourceBuffer.buffered.end(t);this.sourceBuffer.remove(n,r)}},t.prototype.doCleanup=function(){if(this.cleanRanges.length){var e=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(this.cleanRanges.shift(),2),t=e[0],n=e[1];Qn("".concat(this.bufferType," remove range [").concat(t," - ").concat(n,")")),this.cleaning=!0,this.sourceBuffer.remove(t,n)}else this.cleaning=!1},t.prototype.initCleanup=function(e){var t;try{if(this.sourceBuffer.updating)return void(this.pendingCleaning=e);if((null===(t=this.sourceBuffer.buffered)||void 0===t?void 0:t.length)&&!this.cleaning){for(var n=0;n<this.sourceBuffer.buffered.length;++n){var r=this.sourceBuffer.buffered.start(n),i=this.sourceBuffer.buffered.end(n);e-r>this.cleanOffset&&r<(i=e-this.cleanOffset)&&this.cleanRanges.push([r,i])}this.doCleanup()}}catch(e){Zn("Error occured while cleaning ".concat(this.bufferType," buffer - ").concat(e.name,": ").concat(e.message))}},t.prototype.doAppend=function(){if(this.queue.length&&this.sourceBuffer&&!this.sourceBuffer.updating)try{this.sourceBuffer.appendBuffer(this.queue),this.queue=new Uint8Array}catch(t){var e="unexpectedError";Qn("doAppend error, ",t,t.name),"QuotaExceededError"===t.name?(Qn("".concat(this.bufferType," buffer quota full")),e="QuotaExceeded"):(Zn("Error occured while appending ".concat(this.bufferType," buffer - ").concat(t.name,": ").concat(t.message)),e="InvalidStateError"),this.dispatch("error",{type:this.bufferType,name:e,error:"buffer error"})}},t.prototype.feed=function(e){this.queue=tr(this.queue,e),this.doAppend()},t}(sr);const $r=Xr;var Qr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Zr=function(){return Zr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zr.apply(this,arguments)},ei=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ti=function(e){function t(t){var n,r,i,o=this;return(o=e.call(this,"muxer")||this).isMSESupported=null,o.node=null,o.mseReady=null,o.mseEnded=null,o.videoStarted=null,o.interval=null,o.mediaSource=null,o.url=null,o.options={node:"",mode:null,flushingTime:0,maxDelay:100,clearBuffer:!0,fps:30,readFpsFromTrack:!1,debug:!1,opusConfig:{SampleRate:48e3,SampleFormat:16,Channels:2,PcmFrameSize:960},onReady:nt,onData:nt,onError:nt,onMissingVideoFrames:nt,onMissingAudioFrames:nt,onEvent:nt},o.isReset=!1,o.frameDuration=1e3/o.options.fps|0,o.remuxController=null,o.bufferControllers=null,o.lastCleaningTime=null,o.kfPosition=null,o.kfCounter=null,o.options=Zr(Zr({},o.options),t),o.options.debug&&(Jn=console.log,Yn=console.error),o.frameDuration=1e3/o.options.fps|0,o.remuxController=new Jr,(null===(n=o.options.mode)||void 0===n?void 0:n.avc)&&o.remuxController.addTrack("avc"),(null===(r=o.options.mode)||void 0===r?void 0:r.hevc)&&o.remuxController.addTrack("hevc"),(null===(i=o.options.mode)||void 0===i?void 0:i.opus)&&o.remuxController.addTrack("opus",{config:{sampleRate:o.options.opusConfig.SampleRate,channels:o.options.opusConfig.Channels,bitDepth:o.options.opusConfig.SampleFormat,duration:o.options.opusConfig.PcmFrameSize}}),o.initData(),o.remuxController.on("buffer",o.onBuffer.bind(o)),o.remuxController.on("ready",o.createBuffer.bind(o)),o.initBrowser(),o}return Qr(t,e),t.isSupported=function(e){var t;return null===(t=window.MediaSource)||void 0===t?void 0:t.isTypeSupported(e)},t.prototype.feed=function(e){var t={};if(e&&this.remuxController){var n,r=e.avc,i=e.hevc,o=e.aac,s=e.opus,a=e.duration,c=void 0===a?0:a,u=e.compositionTimeOffset;if(r&&this.options.mode.avc&&((n=nr(r)).length>0?t.avc=this.getVideoFrames(n,c,u):"function"==typeof this.options.onMissingVideoFrames&&this.options.onMissingVideoFrames.call(null,e)),i&&this.options.mode.hevc&&((n=nr(i)).length>0?t.hevc=this.getHevcVideoFrames(n,c,u):"function"==typeof this.options.onMissingVideoFrames&&this.options.onMissingVideoFrames.call(null,e)),o&&this.options.mode.aac){var d=or.extractAAC(o);d.length>0?t.aac=this.getAudioFrames(d,c):(Qn("Failed to extract audio data from:",o),"function"==typeof this.options.onMissingAudioFrames&&this.options.onMissingAudioFrames.call(null,e))}if(s&&this.options.mode.opus){if(!this.options.mode.opus)return;t.opus=this.getOpusFrames([s],this.options.opusConfig.PcmFrameSize)}this.remuxController.remux(t)}},t.prototype.destroy=function(){var e,t,n,r;this.stopInterval(),this.remuxController&&(this.remuxController.destroy(),this.remuxController=null),this.bufferControllers&&(null===(e=this.bufferControllers.avc)||void 0===e||e.destroy(),null===(t=this.bufferControllers.hevc)||void 0===t||t.destroy(),null===(n=this.bufferControllers.aac)||void 0===n||n.destroy(),null===(r=this.bufferControllers.opus)||void 0===r||r.destroy(),this.bufferControllers=null,this.endMSE()),this.node=null,this.mseReady=!1,this.videoStarted=!1,this.mediaSource=null},t.prototype.reset=function(){var e,t,n,r;this.stopInterval(),this.isReset=!0,this.node.pause(),this.remuxController&&this.remuxController.reset(),this.bufferControllers&&(null===(e=this.bufferControllers.avc)||void 0===e||e.destroy(),null===(t=this.bufferControllers.hevc)||void 0===t||t.destroy(),null===(n=this.bufferControllers.aac)||void 0===n||n.destroy(),null===(r=this.bufferControllers.opus)||void 0===r||r.destroy(),this.bufferControllers=null,this.endMSE()),this.initData(),this.initBrowser(),Qn("Muxer was reset")},t.prototype.playCurrent=function(){var e,t;if((null===(t=null===(e=this.node)||void 0===e?void 0:e.buffered)||void 0===t?void 0:t.length)>0&&!this.node.seeking){var n=this.node.buffered.end(0);this.node.currentTime=n-.001}},t.prototype.getVideoResolution=function(e){var t,n=e.type,r=null===(t=this.remuxController.tracks[n])||void 0===t?void 0:t.mp4track;return{width:r.width,height:r.height}},t.prototype.initData=function(){this.lastCleaningTime=Date.now(),this.kfPosition=[],this.kfCounter=0,this.startInterval()},t.prototype.initBrowser=function(){"string"==typeof this.options.node&&""===this.options.node&&Zn("no video element were found to render, provide a valid video element"),this.node="string"==typeof this.options.node?document.querySelector(this.options.node):this.options.node,this.mseReady=!1,this.setupMSE()},t.prototype.setupMSE=function(){if(window.MediaSource=window.MediaSource||window.WebKitMediaSource||window.ManagedMediaSource,!window.MediaSource)throw"Oops! Browser does not support Media Source Extension or Managed Media Source (IOS 17+).";if(this.isMSESupported=!!window.MediaSource,this.mediaSource=new window.MediaSource,this.url=URL.createObjectURL(this.mediaSource),window.MediaSource===window.ManagedMediaSource)try{this.node.removeAttribute("src"),this.node.disableRemotePlayback=!0;var e=document.createElement("source");e.type="video/mp4",e.src=this.url,this.node.appendChild(e),this.node.load()}catch(e){console.log("ManagedMediaSource error",e),this.node.src=this.url}else this.node.src=this.url;this.mseEnded=!1,this.mediaSource.addEventListener("sourceopen",this.onMSEOpen.bind(this)),this.mediaSource.addEventListener("sourceclose",this.onMSEClose.bind(this)),this.mediaSource.addEventListener("webkitsourceopen",this.onMSEOpen.bind(this)),this.mediaSource.addEventListener("webkitsourceclose",this.onMSEClose.bind(this))},t.prototype.endMSE=function(){if(!this.mseEnded)try{this.mseEnded=!0,this.mediaSource.endOfStream()}catch(e){Qn("mediaSource is not available to end",e)}},t.prototype.getVideoFrames=function(e,t,n){var r,i,o=[],s=[],a=!1;try{for(var c=ei(e),u=c.next();!u.done;u=c.next()){var d=u.value,l=new er(d);l.type()!==er.IDR&&l.type()!==er.NDR||ir.parseHeader(l),s.push(l),a=l.isKeyframe(),l.isvcl&&l.isfmb&&(o.push({units:s,keyFrame:a,duration:t||this.frameDuration,compositionTimeOffset:n}),this.kfCounter=this.kfCounter+1,a&&this.options.clearBuffer&&this.kfPosition.push(this.kfCounter*(t||this.frameDuration)/1e3))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return o},t.prototype.getHevcVideoFrames=function(e,t,n){var r,i,o=[],s=[],a=!1;try{for(var c=ei(e),u=c.next();!u.done;u=c.next()){var d=u.value,l=new Fr(d);l.type()!==Fr.IDR&&l.type()!==Fr.NDR||jr.parseHeader(l),s.push(l),a=l.isKeyframe(),l.isvcl&&(o.push({units:s,keyFrame:a,duration:t||this.frameDuration,compositionTimeOffset:n}),this.kfCounter=this.kfCounter+1,a&&this.options.clearBuffer&&this.kfPosition.push(this.kfCounter*(t||this.frameDuration)/1e3))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return o},t.prototype.getAudioFrames=function(e,t){var n,r,i,o=[],s=0;try{for(var a=ei(e),c=a.next();!c.done;c=a.next()){var u=c.value;o.push({units:u})}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i=t?t/o.length|0:this.frameDuration,s=t?t-i*o.length:0,o.forEach((function(e){e.duration=i,s>0&&(e.duration=e.duration+1,s-=1)})),o},t.prototype.getOpusFrames=function(e,t){var n,r,i=[];try{for(var o=ei(e),s=o.next();!s.done;s=o.next()){var a=s.value;i.push({unit:a,duration:t})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},t.prototype.createBuffer=function(){var e;if(this.mseReady&&(null===(e=this.remuxController)||void 0===e?void 0:e.isReady())&&!this.bufferControllers)for(var n in this.bufferControllers={},this.remuxController.tracks){var r=n,i=this.remuxController.tracks[r],o="opus"===n||"aac"===n?"audio":"video";if(!t.isSupported("".concat(o,'/mp4; codecs="').concat(i.mp4track.codec,'"')))return Zn("Browser does not support codec"),!1;var s=this.mediaSource.addSourceBuffer("".concat(o,'/mp4; codecs="').concat(i.mp4track.codec,'"'));this.bufferControllers[r]=new $r(s,r),this.bufferControllers[r].on("error",this.onBufferError.bind(this))}},t.prototype.startInterval=function(){var e=this;this.interval=setInterval((function(){e.cancelDelay()}),1e3)},t.prototype.stopInterval=function(){this.interval&&clearInterval(this.interval)},t.prototype.cancelDelay=function(){var e;if((null===(e=this.node.buffered)||void 0===e?void 0:e.length)>0&&!this.node.seeking){var t=this.node.buffered.end(0);t-this.node.currentTime>this.options.maxDelay/1e3&&(this.node.currentTime=t-.001)}},t.prototype.applyAndClearBuffer=function(){this.bufferControllers&&this.clearBuffer()},t.prototype.getSafeClearOffsetOfBuffer=function(e){for(var t,n=(this.options.mode.aac||this.options.mode.opus)&&e||0,r=0;r<this.kfPosition.length&&!(this.kfPosition[r]>=e);r++)t=this.kfPosition[r];return t&&(this.kfPosition=this.kfPosition.filter((function(e){return e<t&&(n=e),e>=t}))),n},t.prototype.clearBuffer=function(){var e,t;if(this.options.clearBuffer&&Date.now()-this.lastCleaningTime>1e4){if(this.bufferControllers.avc||this.bufferControllers.hevc){var n=this.getSafeClearOffsetOfBuffer(this.node.currentTime);null===(e=this.bufferControllers.avc)||void 0===e||e.initCleanup(n),null===(t=this.bufferControllers.hevc)||void 0===t||t.initCleanup(n)}this.bufferControllers.opus&&this.bufferControllers.opus.initCleanup(this.node.currentTime),this.lastCleaningTime=Date.now()}},t.prototype.onBuffer=function(e){var t,n,r,i,o,s,a,c,u,d,l=e.payload,h=e.type,p=e.fps,f=e.eventType;this.options.readFpsFromTrack&&void 0!==p&&this.options.fps!==p&&(this.options.fps=p,this.frameDuration=Math.ceil(1e3/p),Qn("Muxer changed FPS to ".concat(p," from track data"))),this.bufferControllers&&("avc"===h&&(null===(n=null===(t=this.bufferControllers)||void 0===t?void 0:t.avc)||void 0===n||n.feed(l)),"hevc"===h&&(null===(i=null===(r=this.bufferControllers)||void 0===r?void 0:r.hevc)||void 0===i||i.feed(l)),"aac"===h&&(null===(s=null===(o=this.bufferControllers)||void 0===o?void 0:o.aac)||void 0===s||s.feed(l)),"opus"===h&&(null===(c=null===(a=this.bufferControllers)||void 0===a?void 0:a.opus)||void 0===c||c.feed(l))),this.options.onData&&this.options.onData({data:e}),0===this.options.flushingTime&&this.applyAndClearBuffer(),"init"===f&&(null===(d=(u=this.options).onReady)||void 0===d||d.call(u))},t.prototype.onMSEOpen=function(){this.mseReady=!0,URL.revokeObjectURL(this.url)},t.prototype.onMSEClose=function(){this.mseReady=!1,this.videoStarted=!1},t.prototype.onBufferError=function(e){if(Qn("onBufferError",e),"QuotaExceeded"===e.name)return Qn("Muxer cleaning ".concat(e.type," buffer due to QuotaExceeded error")),void this.bufferControllers[e.type].initCleanup(this.node.currentTime);"InvalidStateError"===e.name?this.reset():this.endMSE(),"function"==typeof this.options.onError&&this.options.onError.call(null,e)},t}(sr);const ni=ti;var ri=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},ii=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},oi=function(){function e(e){var t=e.sdk;this.sdk=null,this.token=null,this.instanceId=null,this.url="",this.socket=null,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder,this.heartbeatTimer=null,this.streamPushStat=null,this.videoState="play",this.videoMuxer=null,this.audioMuxer=null,this.sessionInfo=null,this.lastVideoFrameTimeStamp=0,this.dataChannelCallbacks={},this.dataChannelRetryTimers={},this.mount=null,this.sdk=t}return e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.connect=function(e){var t=e.url,n=e.protocols,r=void 0===n?["media-v1"]:n,i=e.token,o=e.instanceId,s=e.videoCodecList,a=void 0===s?["h264","h265"]:s;return ri(this,0,void 0,(function(){return ii(this,(function(e){switch(e.label){case 0:return this.token=i,this.instanceId=o,this.url=t,t?[4,this.createSocket({url:"".concat(t,"/play?token=").concat(i,"&instance_id=").concat(o,"&video_codec_list=").concat(a.join(",")),protocols:r})]:[3,2];case 1:return e.sent(),[3,3];case 2:this.sdk.log("websocket connect url is empty",t),e.label=3;case 3:return[2]}}))}))},e.prototype.connectGroupControl=function(e){var t=e.url,n=e.protocols,r=void 0===n?["media-v1"]:n,i=e.tokenInfos,o=e.videoCodecList,s=void 0===o?["h264","h265"]:o;return ri(this,0,void 0,(function(){return ii(this,(function(e){switch(e.label){case 0:return this.url=t,[4,this.createSocket({url:"".concat(t,"/group/play?video_codec_list=").concat(s.join(",")),protocols:r})];case 1:return 0===e.sent().code&&this.createGroupSession({tokenInfos:i}),[2]}}))}))},e.prototype.joinGroupControl=function(e){var t=e.tokenInfos,n=e.groupControlId;return ri(this,0,void 0,(function(){return ii(this,(function(e){return this.sdk.log("websocket join group session"),this.sendText({Type:"JoinGroupSession",RequestId:Kn(),Data:{TokenInfos:t,GroupControlId:n}}),[2]}))}))},e.prototype.dataChannelSend=function(e){var t=e.label,n=e.binary,r=void 0===n?0:n,i=e.data;return ri(this,0,void 0,(function(){var e,n,o,s,a,c;return ii(this,(function(u){switch(u.label){case 0:return e=new Uint8Array([qn.message,r]).buffer,n=this.textEncoder.encode(t).buffer,o=new ArrayBuffer(4),new DataView(o).setUint32(0,n.byteLength),s=this.textEncoder.encode(JSON.stringify(i)).buffer,a=new ArrayBuffer(4),new DataView(a).setUint32(0,s.byteLength),[4,ut(e,o,n,a,s)];case 1:return c=u.sent(),this.socket.send(c),[2]}}))}))},e.prototype.destroy=function(e){var t,n,r=e.code,i=e.message;this.socket.close(),this.clearIntervals(),this.sdk.onDisconnect({code:r,msg:i}),null===(t=this.videoMuxer)||void 0===t||t.destroy(),null===(n=this.audioMuxer)||void 0===n||n.destroy()},e.prototype.reconnect=function(e){var t=e.message;this.sdk.log("websocket reconnect, message",t),this.connect({token:this.token,url:this.url,instanceId:this.instanceId})},e.prototype.getMuxer=function(e){return"video"===e?this.videoMuxer:"audio"===e?this.audioMuxer:void 0},e.prototype.setMediaState=function(e){var t=e.type,n=e.state;"video"===t&&(this.videoState=n)},e.prototype.createSocket=function(e){var t=e.url,n=e.protocols;return ri(this,0,void 0,(function(){var e=this;return ii(this,(function(r){return[2,new Promise((function(r){e.socket=new WebSocket(t,n),e.socket.binaryType="arraybuffer",e.socket.onopen=function(){e.sdk.log("socket onopen, socket binaryType",e.socket.binaryType),r({code:0,message:"onopen"})},e.socket.onmessage=function(t){var n,r=t.data;(n=r)&&n instanceof ArrayBuffer&&void 0!==n.byteLength?e.onArrayBufferMessage(r):e.onTextMessage(r)},e.socket.onclose=function(t){e.sdk.log("socket onclose",t),e.clearIntervals(),r({code:1,message:"onclose"})},e.socket.onerror=function(t){e.sdk.log("socket onerror",t),e.clearIntervals(),r({code:2,message:"onerror"})}}))]}))}))},e.prototype.onTextMessage=function(e){try{var t=JSON.parse(e),n=t.Type,r=t.Data,i=r.Code;switch(n){case"CreateSession":case"CreateGroupSession":0===i&&this.onCreateSessionSuccess(r)}}catch(e){this.sdk.log("Parse text message error",e)}},e.prototype.onArrayBufferMessage=function(e){var t=new DataView(e),n=t.getUint8(0);if(n===zn.h264||n===zn.h265){var r=t.getUint32(1),i=e.slice(5,e.byteLength);this.processVideoFrameBuffer({frame:i,duration:(r-this.lastVideoFrameTimeStamp)/90}),this.lastVideoFrameTimeStamp=r}if(n===zn.opus&&(i=e.slice(5,e.byteLength),this.processOpusFrameBuffer(i)),n===qn.message){var o=t.getUint32(2),s=e.slice(6,6+o),a=e.slice(2+o+4+4,e.byteLength),c=this.textDecoder.decode(s);i=this.textDecoder.decode(a),c===ge.KM&&this.onKmMessage(i),c===ge.SV&&this.onSvrMessage(i),c===ge.HB&&this.onHbMessage(i),c===ge.CLOUD_DEVICE&&this.onCloudDeviceMessage(i),c===ge.ACK&&this.onAckMessage(i)}},e.prototype.processVideoFrameBuffer=function(e){var t,n,r,i=e.frame,o=e.duration;"play"===this.videoState&&(null===(t=this.videoMuxer)||void 0===t||t.feed({avc:"h264"===(null===(n=this.sessionInfo)||void 0===n?void 0:n.Video)?new Uint8Array(i):void 0,hevc:"h265"===(null===(r=this.sessionInfo)||void 0===r?void 0:r.Video)?new Uint8Array(i):void 0,duration:o}))},e.prototype.processOpusFrameBuffer=function(e){var t;null===(t=this.audioMuxer)||void 0===t||t.feed({opus:new Uint8Array(e)})},e.prototype.createSession=function(e){var t=e.Token,n=e.InstanceId;this.sdk.log("websocket createSession, instanceId",n),this.sendText({Type:"CreateSession",Data:{Token:t,AndroidInstanceId:n,VideoCodecList:["h264"]}})},e.prototype.createGroupSession=function(e){var t=e.tokenInfos;this.sdk.log("websocket create group session"),this.sendText({Type:"CreateGroupSession",RequestId:Kn(),Data:{TokenInfos:t}})},e.prototype.sendText=function(e){this.sdk.log("websocket sendText",e),this.socket.send(JSON.stringify(e))},e.prototype.onCreateSessionSuccess=function(e){var t=this;this.sessionInfo=e;var n=e.Video,r=e.Audio,i=e.GroupControlId;this.sdk.log("Video",n,"Audio",r,"GroupControlId",i),this.sdk.androidInstance.groupControl.groupControlId=i,this.sdk.androidInstance.groupControl.onConnectSuccess(),this.sdk.gameConfig.setConfig({clientId:this.mount,config:{video_mime_type:"video/".concat(n.toLowerCase()),audio_mime_type:"audio/".concat(null==r?void 0:r.Codec.toLowerCase())}});var o="h265"===n?"hevc":"avc";this.videoMuxer=new ni({node:".".concat(this.mount," .video-stream"),mode:{avc:"h264"===n||void 0,hevc:"h265"===n||void 0},debug:this.debugSetting.showMuxer,onReady:function(){var e,n,r;t.sdk.getCloudGamingContainerElement()&&(t.sdk.getCloudGamingContainerElement().style.display="flex"),t.sdk.getProgressBarElement()&&(t.sdk.getProgressBarElement().style.display="none"),t.sdk.getRestartElement()&&(t.sdk.getRestartElement().style.display="none"),t.sdk.getVideoElement().focus(),t.startHeartbeatReport(),t.sdk.pageEvent.addEventHandler(),t.sdk.onConnectSuccess({code:0});var i=t.videoMuxer.getVideoResolution({type:o}),s=i.width,a=i.height;t.sdk.showStats.setStaticStat({resolution:"".concat(s,"x").concat(a)}),null===(r=null===(n=null===(e=t.sdk.getVideoElement())||void 0===e?void 0:e.play())||void 0===n?void 0:n.then((function(){t.sdk.log("video play success"),t.sdk.onEvent({type:"autoplay",data:{code:0,message:"video play success"}}),t.sdk.reshapeWindow()})))||void 0===r||r.catch((function(e){t.sdk.log("video play error, ",e,e.name),t.sdk.onEvent({type:"autoplay",data:{code:-1,message:e}})}))}});var s=r.Channels,a=r.SampleRate,c=r.PcmFrameSize;this.audioMuxer=new ni({node:".".concat(this.mount," .cloud-gaming-audio-stream-socket"),mode:{opus:!0},maxDelay:1e3,opusConfig:{SampleRate:a,SampleFormat:16,Channels:s,PcmFrameSize:c},debug:this.debugSetting.showMuxer})},e.prototype.createDataChannel=function(e){var t=e.label;return ri(this,0,void 0,(function(){var e,n;return ii(this,(function(r){switch(r.label){case 0:return this.sdk.log("create ".concat(t," data channel")),e=this.textEncoder.encode(t),[4,ut(new Uint8Array([qn.open]).buffer,e.buffer)];case 1:return n=r.sent(),this.socket.send(n),[2]}}))}))},e.prototype.startHeartbeatReport=function(){var e=this;clearInterval(this.heartbeatTimer),this.sdk.log("startHeartbeatReport ->"),this.heartbeatTimer=setInterval((function(){return ri(e,0,void 0,(function(){return ii(this,(function(e){return this.dataChannelSend({label:ge.HB,data:{user_id:this.instanceId,timestamp:+new Date}}),[2]}))}))}),5e3)},Object.defineProperty(e.prototype,"debugSetting",{get:function(){return this.sdk.getInitOptions().debugSetting||{}},enumerable:!1,configurable:!0}),e.prototype.onKmMessage=function(e){try{var t=JSON.parse(e);this.debugSetting.showOnKmMessage&&console.log("onKmMessage",t);var n=t.screen_width,r=t.screen_height,i=t.screen_left,o=t.screen_top;this.sdk.pageEvent.remoteScreenResolutionChange({width:n,height:r,left:i,top:o})}catch(e){this.sdk.log("parse km message error",e)}},e.prototype.onSvrMessage=function(e){if(e)try{var t=JSON.parse(e),n=t.type,r=t.data;switch(this.debugSetting.showOnSvMessage&&this.sdk.log("onSvMessage","type: ",n,"data",e),n){case"metric_sig_key":this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{sig_key:r.sig_key}});break;case"screen_config_change":this.sdk.onConfigurationChange({screen_config:r});break;case"hit_input":var i=r,o=i.field_type,s=i.status;this.sdk.onInputStatusChange({field_type:o,status:s});break;case"camera_status":r.status}}catch(e){this.sdk.log("onSvMessage data parse failed",e)}else this.sdk.log("onSvMessage no data")},e.prototype.onHbMessage=function(e){try{var t=JSON.parse(e),n=t.timestamp,r=t.token,i=t.stream_push_state;if(this.debugSetting.showOnHbMessage&&console.log("onHbMessage",t),this.token=r,n){var o=+new Date-+n;this.sdk.showStats.setRTT(o)&&this.sdk.onNetworkChange({status:"jitter",data:{value:o,message:"NETWORK_JITTER"}})}i&&this.streamPushStat!==i&&(this.streamPushStat=i,this.sdk.onStreamPushStateChange({stream_push_state:this.streamPushStat}))}catch(e){this.sdk.log("parse hb message error",e)}},e.prototype.onCloudDeviceMessage=function(e){return ri(this,0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d;return ii(this,(function(l){switch(l.label){case 0:if(!e)return[3,14];l.label=1;case 1:switch(l.trys.push([1,12,,13]),t=JSON.parse(e),n=t.type,r=t.data,this.debugSetting.showOnCloudDeviceMessage&&this.sdk.log("onCloudDeviceData","type: ",n,"data",e,"cloudDeviceData",r),n){case"trans_message":return[3,2];case"system_usage":return[3,3];case"clipboard_event":return[3,4];case"notification_event":return[3,9]}return[3,10];case 2:return this.sdk.onAndroidInstanceEvent({type:"trans_message",data:r}),[3,11];case 3:return this.sdk.onAndroidInstanceEvent({type:"system_usage",data:r}),o=(i=r).cpu_usage,s=i.gpu_usage,this.sdk.showStats.setCpuAndGpuUsage({cpu:"".concat(it(o)),gpu:"".concat(it(s))}),[3,11];case 4:a=!0,c=r.text,l.label=5;case 5:return l.trys.push([5,7,,8]),[4,navigator.clipboard.writeText(c)];case 6:return l.sent(),[3,8];case 7:return u=l.sent(),this.sdk.log("navigator.clipboard.writeText failed",u),a=!1,[3,8];case 8:return this.sdk.onAndroidInstanceEvent({type:"clipboard_event",data:{text:c,writeText:a}}),[3,11];case 9:return this.sdk.onAndroidInstanceEvent({type:"notification_event",data:r}),[3,11];case 10:return[3,11];case 11:return[3,13];case 12:return d=l.sent(),this.sdk.log("onCloudDeviceData data parse failed",d),[3,13];case 13:return[3,15];case 14:this.sdk.log("onCloudDeviceData no data"),l.label=15;case 15:return[2]}}))}))},e.prototype.onAckMessage=function(e){if(e)try{var t=JSON.parse(e),n=t.data,r=void 0===n?st:n,i=t.seq;this.debugSetting.showOnAckMessage&&("cursor_state"===r.type||"keys_clean"===r.type||console.log("onAckMessage",r,i));var o=this.dataChannelCallbacks[i];if(i&&(this.sdk.showStats.setInputEnd(i),o)){var s=o.callback;delete this.dataChannelCallbacks[i],this.dataChannelRetryTimers[i]&&(clearTimeout(this.dataChannelRetryTimers[i]),delete this.dataChannelRetryTimers[i]),null==s||s({code:0,msg:"on ack message",data:r})}"open_url"===r.type&&(this.sdk.log("got open_url",r),this.sdk.onNetworkChange({status:"openurl",data:{value:r.url}}),this.sdk.onEvent({type:"openurl",data:{value:r.url}}))}catch(e){this.sdk.log("onAckMessage exception->",null==e?void 0:e.message)}else this.sdk.log("onAckMessage no data")},e.prototype.clearIntervals=function(){clearInterval(this.heartbeatTimer)},e}();const si=oi;var ai=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},ci=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ui=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},di=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},li={Token:"",Zone:"",OperatorAddress:"",WebSocketAddress:"",WebSocketSecureAddress:"",WebRTCAddress:"",EdgeProxyAddress:"",InstanceInfo:null},hi=function(){function e(e){var t=e.sdk;this.sdk=null,this.instanceAccessInfo=new Map,this.accessInfo=[],this.sdk=t}return e.prototype.setInstanceAccessInfo=function(e){var t=this,n=e.AccessInfo,r=e.Token;try{n=qe(n)}catch(e){this.sdk.log("Decode AccessInfo error",e.message)}try{var i=JSON.parse(n).AccessInfo;this.accessInfo=di(di([],ui(this.accessInfo),!1),ui(i),!1),null==i||i.forEach((function(e){var n=e.Zone,i=e.InstanceIds,o=e.OperatorAddress,s=e.WebSocketAddress,a=e.WebSocketSecureAddress,c=e.WebRTCAddress,u=e.EdgeProxyAddress,d=e.InstancesInfo,l=void 0===d?[]:d;i.forEach((function(e){var i=(null==l?void 0:l.find((function(t){return t.InstanceId===e})))||{},d=i.Data,h=i.InstanceId,p=null;h&&d&&(p={InstanceId:h,Data:d}),t.instanceAccessInfo.set(e,{Token:r,Zone:n,OperatorAddress:o,WebSocketAddress:s,WebSocketSecureAddress:a,WebRTCAddress:c,EdgeProxyAddress:u,InstanceInfo:p})}))}))}catch(e){this.sdk.log("Parse AccessInfo error",e.message)}},e.prototype.getInstanceAccessInfo=function(e){var t=e.instanceId;return this.instanceAccessInfo.get(t)||li},e.prototype.getTokenInfos=function(e){var t=this,n=e.instanceIds,r=[],i=[];return n.forEach((function(e){var n=t.getInstanceAccessInfo({instanceId:e}).Token;n?r.push({Token:n,AndroidInstanceId:e}):(t.sdk.log("Token is not set",e),i.push(e))})),i.length&&this.sdk.onEvent({type:"token_not_found",data:{instance_ids:i}}),r},e.prototype.createWebRTCSession=function(e){var t=e.instanceId,n=e.clientSession;return ai(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p;return ci(this,(function(f){switch(f.label){case 0:if(!t||!n)return[3,5];if(e=this.getInstanceAccessInfo({instanceId:t}),r=e.Token,i=e.WebRTCAddress,o=e.EdgeProxyAddress,!(s=o||i))return[3,4];a="".concat(s,"/play"),c={Authorization:"Bearer ".concat(r)},(u=this.getInstanceInfoHeader({instanceId:t,encode:"url_encode"}).instanceInfo)&&(c["Crtr-Proxy-Instance-Info"]=u),f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Dn({url:a,data:{RequestID:this.sdk.getRequestId()||Kn(),Token:r,AndroidInstanceId:t,ClientSession:n},headers:c})];case 2:return d=f.sent(),l=d.ServerSession,h=d.Code,p=d.Message,[2,{ServerSession:l,Code:h,Message:p}];case 3:throw f.sent();case 4:this.sdk.log("play requestAddress is not found"),f.label=5;case 5:return this.sdk.log("Create session error, instanceId or clientSession is empty"),[2]}}))}))},e.prototype.createWebRTCGroupSession=function(e){var t=e.instanceIds,n=e.clientSessions;return ai(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v;return ci(this,(function(m){switch(m.label){case 0:if(e=this.getTokenInfos({instanceIds:t}),r=this.getInstanceAccessInfo({instanceId:t[0]}),i=r.Token,o=r.EdgeProxyAddress,s=r.WebRTCAddress,a=this.getInstancesInfo({instanceIds:t}).InstancesInfo,!(c=o||s))return[3,4];u="".concat(c,"/group/play"),d={Authorization:"Bearer ".concat(i)},m.label=1;case 1:return m.trys.push([1,3,,4]),[4,Dn({url:u,data:{RequestID:Kn(),TokenInfos:e,ClientSessions:n,InstancesInfo:a},headers:d})];case 2:return l=m.sent(),h=l.GroupControlId,p=l.ServerSessions,f=l.Code,v=l.Message,this.sdk.log("Create WebRTC GroupSession",h,p),[2,{Code:f,Message:v,GroupControlId:h,ServerSessions:p}];case 3:throw m.sent();case 4:return this.sdk.log("requestAddress is not found"),[2]}}))}))},e.prototype.joinWebRTCGroupSession=function(e){var t=e.instanceIds,n=e.clientSessions,r=e.groupControlId;return ai(this,0,void 0,(function(){var e,i,o,s,a,c,u,d,l,h,p;return ci(this,(function(f){switch(f.label){case 0:if(e=this.getTokenInfos({instanceIds:t}),i=this.getInstanceAccessInfo({instanceId:t[0]}),o=i.Token,s=i.WebRTCAddress,a=i.EdgeProxyAddress,c=this.getInstancesInfo({instanceIds:t}).InstancesInfo,!(u=a||s))return[3,4];d="".concat(u,"/group/join"),l={Authorization:"Bearer ".concat(o)},f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Dn({url:d,data:{RequestID:Kn(),GroupControlId:r,TokenInfos:e,ClientSessions:n,InstancesInfo:c},headers:l})];case 2:return h=f.sent().ServerSessions,p=void 0===h?[]:h,this.sdk.log("Join WebRTC GroupSession",p),[2,{ServerSessions:(null==p?void 0:p.length)?p:[]}];case 3:throw f.sent();case 4:return this.sdk.log("group play requestAddress is not found"),[2]}}))}))},e.prototype.getInstancesInfo=function(e){var t=this,n=e.instanceIds,r=[];return n.forEach((function(e){var n=t.getInstanceAccessInfo({instanceId:e}).InstanceInfo;n&&r.push(n)})),{InstancesInfo:r}},e.prototype.getInstanceInfoHeader=function(e){var t=e.instanceId,n=e.method,r=void 0===n?"POST":n,i=e.encode,o=void 0===i?"base64":i,s=this.getInstanceAccessInfo({instanceId:t}).InstanceInfo;if(s){var a=s.InstanceId,c=s.Data,u="";if(a&&c)try{u="url_encode"===o?encodeURIComponent(JSON.stringify({InstanceId:a,Data:c})):ze(JSON.stringify({InstanceId:a,Data:c}))}catch(e){this.sdk.log("stringify instanceInfo string error",e.name,e.message)}else this.sdk.log("InstanceId, Data is not found",a,c);return"GET"===r&&(u="&instance_info=".concat(u)),{instanceInfo:u}}return{instanceInfo:""}},e}();const pi=hi;var fi=function(){return fi=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},fi.apply(this,arguments)},vi=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},mi=function(){function e(e){var t=e.sdk;this.masterInstanceId="",this.instanceIds=[],this._groupControlId="",this.imageEventTimer=null,this.options={image:{interval:1,quality:20}},this.sdk=null,this.sdk=t}return Object.defineProperty(e.prototype,"groupControlId",{get:function(){return this._groupControlId},set:function(e){this._groupControlId=e},enumerable:!1,configurable:!0}),e.prototype.init=function(e){this.options=fi(fi({},this.options),e)},e.prototype.start=function(e){var t=e.instanceIds,n=e.serverSessions,r=e.groupControlId;try{this.instanceIds=t;var i=vi(t,1)[0];this.masterInstanceId=i,this._groupControlId=r;var o=n[0];this.sdk.cloudGamingWebRTC.connect(o)}catch(e){this.sdk.log("serverSession 解析失败",e)}},e.prototype.startWebSocket=function(e){var t=e.url,n=e.tokenInfos,r=e.instanceIds;this.instanceIds=r;var i=vi(r,1)[0];this.masterInstanceId=i,this.sdk.cloudGamingWebsocket.connectGroupControl({url:t,tokenInfos:n})},e.prototype.requestStream=function(e){var t=e.instanceId,n=e.status,r=e.level,i=void 0===r?"normal":r;"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"streaming_request",user:t,data:{status:n,level:i}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"streaming_request",user:t,data:{status:n,level:i}})},e.prototype.setSyncList=function(e){var t=e.list,n=void 0===t?[]:t;"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"set_sync_list",data:{user_list:n}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"set_sync_list",data:{user_list:n}})},e.prototype.startSync=function(e){var t=e.instanceIds,n=void 0===t?[]:t;this.setSyncList({list:n.length?n:this.instanceIds})},e.prototype.stopSync=function(){this.setSyncList({list:[]})},e.prototype.setMaster=function(e){var t=e.instanceId;this.masterInstanceId=t,this.sdk.log("setMaster",t),"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"set_master",user:t,data:{status:"on"}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"set_master",user:t,data:{status:"on"}}),this.requestStream({instanceId:t,status:"open",level:"high"}),this.sdk.playVideo("play")},e.prototype.setImageEvent=function(e){var t=e.interval,n=e.quality;this.sdk.log("setImageEvent","interval",t,"quality",n),this.options.image=fi(fi({},this.options.image),{interval:t,quality:n}),this._groupControlId&&this.startImageEventInterval()},e.prototype.onConnectSuccess=function(){this.setMaster({instanceId:this.masterInstanceId}),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval()},e.prototype.join=function(e){var t,n,r,i=e.instanceIds,o=e.clientSessions,s=void 0===o?[]:o;return t=this,r=function(){var e,t,n,r,o;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,7]),"websocket"!==this.sdk.streamingMode?[3,2]:(e=this.sdk.accessInfo.getTokenInfos({instanceIds:i}),[4,this.sdk.cloudGamingWebsocket.joinGroupControl({tokenInfos:e,groupControlId:this.groupControlId})]);case 1:return a.sent(),[3,5];case 2:return a.trys.push([2,4,,5]),[4,this.sdk.accessInfo.joinWebRTCGroupSession({instanceIds:i,clientSessions:s,groupControlId:this.groupControlId})];case 3:return a.sent().ServerSessions.length,console.log("this.sdk.accessInfo",this.sdk.accessInfo),t=this.sdk.accessInfo.getInstancesInfo({instanceIds:i}).InstancesInfo,this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"join",data:{group_control_id:this.groupControlId,instances_info:t.map((function(e){return{instance_id:e.InstanceId,data:e.Data}})),client_sessions:s}}),[3,5];case 4:return n=a.sent(),this.sdk.log("join group error",n.message),[3,5];case 5:return(o=this.instanceIds).push.apply(o,function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([],vi(i),!1)),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval(),[3,7];case 6:return r=a.sent(),this.sdk.log("join serverSession parse error",r),[3,7];case 7:return[2]}}))},new((n=void 0)||(n=Promise))((function(e,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(t,[])).next())}))},e.prototype.leave=function(e){var t=e.instanceIds;this.instanceIds=this.instanceIds.filter((function(e){return!t.includes(e)})),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval()},e.prototype.getInstanceIds=function(){return this.instanceIds},e.prototype.destroy=function(){clearTimeout(this.imageEventTimer)},e.prototype.startImageEventInterval=function(){var e=this;clearTimeout(this.imageEventTimer);var t=function(){var n=[];e.instanceIds.forEach((function(t){var r;if(e.sdk.androidInstance.operator.getInstanceOperator({instanceId:t}).OperatorAddress){var i=e.sdk.androidInstance.getInstanceImage({instanceId:t,quality:null===(r=e.options.image)||void 0===r?void 0:r.quality}).url;n.push({instanceId:t,url:i})}})),e.sdk.onImageEvent({type:"screenshot",data:n}),e.imageEventTimer=setTimeout((function(){t()}),1e3*e.options.image.interval)};t()},e}(),_i=function(){return _i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_i.apply(this,arguments)},gi=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},yi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Si=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},bi=function(){function e(e){var t=e.sdk;this.sdk=null,this.sdk=t}return e.prototype.getInstanceOperator=function(e){var t=e.instanceId,n=this.sdk.accessInfo.getInstanceAccessInfo({instanceId:t}),r=n.Token,i=void 0===r?"":r,o=n.Zone,s=void 0===o?"":o,a=n.OperatorAddress;return{Token:i,Zone:s,OperatorAddress:void 0===a?"":a,EdgeProxyAddress:n.EdgeProxyAddress}},e.prototype.getInstanceImage=function(e){var t=e.instanceId,n=e.quality,r=void 0===n?20:n,i=e.screenshot_width,o=void 0===i?720:i,s=e.screenshot_height,a=void 0===s?1280:s,c=this.getInstanceOperator({instanceId:t}),u=c.Token,d=c.OperatorAddress,l=c.EdgeProxyAddress;if(u&&d){var h=l||d,p=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{url:"".concat(h,"/CAIScreenshot?instance_id=").concat(t,"&screenshot_quality=").concat(r,"&token=").concat(u,"&timestamp=").concat(+new Date)+"".concat(o?"&screenshot_width=".concat(o):"")+"".concat(a?"&screenshot_height=".concat(a):"")+"".concat(p||"")}}return{url:null}},e.prototype.upload=function(e){var t=e.instanceId,n=e.files;return gi(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v,m=this;return yi(this,(function(_){switch(_.label){case 0:if(e=this.getInstanceOperator({instanceId:t}),r=e.Token,i=e.OperatorAddress,o=e.EdgeProxyAddress,!r||!i)return[3,5];s="".concat(o||i,"/CAIUpload?instance_id=").concat(t,"&token=").concat(r),a={},(c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t}).instanceInfo)&&(a["Crtr-Proxy-Instance-Info"]=c),u=new FormData,n.forEach((function(e,t){var n=e.file,r=e.path;return gi(m,0,void 0,(function(){return yi(this,(function(e){return u.append("file_".concat(t+1,"_path"),r),u.append("file_".concat(t+1),n),[2]}))}))})),d={Code:1,Message:"Upload failed",FileStatus:null},_.label=1;case 1:return _.trys.push([1,3,,4]),[4,fetch(s,{body:u,cache:"no-cache",method:"POST",mode:"cors",headers:a}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.json()})).catch((function(e){throw new Error("".concat(e.name,": ").concat(e.message))}))];case 2:return l=_.sent(),h=l.Code,p=l.FileStatus,f=l.Msg,d.Code=h,d.Message=f,d.FileStatus=p,[3,4];case 3:return v=_.sent(),d.Code=1,d.Message="".concat(v.name,": ").concat(v.message),[3,4];case 4:return[2,d];case 5:return[2,{Code:2,Message:"Token or OperatorAddress is empty"}]}}))}))},e.prototype.uploadMedia=function(e){var t=e.instanceId,n=e.files;return gi(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v=this;return yi(this,(function(m){switch(m.label){case 0:if(e=this.getInstanceOperator({instanceId:t}),r=e.Token,i=e.OperatorAddress,o=e.EdgeProxyAddress,!r||!i)return[3,5];s="".concat(o||i,"/CAIUploadMedia?instance_id=").concat(t,"&token=").concat(r),a={},(c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t}).instanceInfo)&&(a["Crtr-Proxy-Instance-Info"]=c),u=new FormData,n.forEach((function(e,t){var n=e.file;return gi(v,0,void 0,(function(){return yi(this,(function(e){return u.append("file_".concat(t+1),n),[2]}))}))})),d={Code:1,Message:"Upload media failed",FileStatus:null},m.label=1;case 1:return m.trys.push([1,3,,4]),[4,fetch(s,{body:u,cache:"no-cache",method:"POST",mode:"cors",headers:a}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.json()})).catch((function(e){throw new Error("".concat(e.name,": ").concat(e.message))}))];case 2:return l=m.sent(),h=l.Code,p=l.Msg,d.Code=h,d.Message=p,[3,4];case 3:return f=m.sent(),d.Code=1,d.Message="".concat(f.name,": ").concat(f.message),[3,4];case 4:return[2,d];case 5:return[2,{Code:2,Message:"Token or OperatorAddress is empty"}]}}))}))},e.prototype.getInstanceDownloadAddress=function(e){var t=e.instanceId,n=e.path,r=this.getInstanceOperator({instanceId:t}),i=r.Token,o=r.OperatorAddress,s=r.EdgeProxyAddress;if(i&&o){var a=s||o,c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{address:"".concat(a,"/CAIDownload?instance_id=").concat(t,"&path=").concat(n,"&token=").concat(i)+"".concat(c||"")}}return{address:null}},e.prototype.getInstanceDownloadLogcatAddress=function(e){var t=e.instanceId,n=e.recentDays,r=this.getInstanceOperator({instanceId:t}),i=r.Token,o=r.OperatorAddress,s=r.EdgeProxyAddress;if(i&&o){var a=s||o,c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{address:"".concat(a,"/CAIDownloadLogcat?instance_id=").concat(t,"&recent_day=").concat(n,"&token=").concat(i)+"".concat(c||"")}}return{address:null}},e.prototype.batchTask=function(e){var t,n,r,i,o=e.taskType,s=e.params;return gi(this,0,void 0,(function(){var e,a,c,u,d,l,h,p;return yi(this,(function(f){switch(f.label){case 0:e={},this.sdk.log("batchTask taskType",o,"batchTask params",s),a=this.getOperatorAddresses({instanceIds:Object.keys(s)}),f.label=1;case 1:f.trys.push([1,7,8,13]),c=function(){var t,n,r,a,c,l,p,f,v,m,_,g,y,S,b,k,E,T,C,I,w,R,A,O;return yi(this,(function(x){switch(x.label){case 0:i=h.value,d=!1,t=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(i,2),n=t[0],r=t[1],a="".concat(n,"/CAIOperator/BatchTask"),c={},(l=u.sdk.accessInfo.getInstanceInfoHeader({instanceId:r[0]}).instanceInfo)&&(c.InstanceInfo=l),p=u.sdk.accessInfo.getInstancesInfo({instanceIds:r}).InstancesInfo,f={},v=u.sdk.accessInfo.getTokenInfos({instanceIds:r}),r.forEach((function(e){f[e]="ModifySensor"===o?_i(_i({},s[e]),{Accuracy:3}):s[e]})),x.label=1;case 1:return x.trys.push([1,3,,4]),[4,Dn({url:a,data:{RequestID:Kn(),TaskType:o,TokenInfos:v,InstancesInfo:p,Params:f},headers:c})];case 2:if(m=x.sent(),_=m.Code,g=m.Message,y=m.SuccResult,S=m.FailResult,0===_)e=_i(_i(_i({},e),y),S);else try{for(w=void 0,b=Si(r),k=b.next();!k.done;k=b.next())I=k.value,e[I]={Code:_,Msg:g}}catch(e){w={error:e}}finally{try{k&&!k.done&&(R=b.return)&&R.call(b)}finally{if(w)throw w.error}}return[3,4];case 3:E=x.sent();try{for(A=void 0,T=Si(r),C=T.next();!C.done;C=T.next())I=C.value,e[I]={Code:-1,Msg:E.message}}catch(e){A={error:e}}finally{try{C&&!C.done&&(O=T.return)&&O.call(T)}finally{if(A)throw A.error}}return[3,4];case 4:return[2]}}))},u=this,d=!0,l=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Si(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}(Object.entries(a)),f.label=2;case 2:return[4,l.next()];case 3:return h=f.sent(),(t=h.done)?[3,6]:[5,c()];case 4:f.sent(),f.label=5;case 5:return d=!0,[3,2];case 6:return[3,13];case 7:return p=f.sent(),n={error:p},[3,13];case 8:return f.trys.push([8,,11,12]),d||t||!(r=l.return)?[3,10]:[4,r.call(l)];case 9:f.sent(),f.label=10;case 10:return[3,12];case 11:if(n)throw n.error;return[7];case 12:return[7];case 13:return[2,e]}}))}))},e.prototype.getOperatorAddresses=function(e){var t=this,n=e.instanceIds,r={};return n.forEach((function(e){var n=t.getInstanceOperator({instanceId:e})||{},i=n.OperatorAddress,o=n.EdgeProxyAddress||i;o?r[o]?r[o].push(e):r[o]=[e]:t.sdk.log("getOperatorAddresses instanceId",e,"not found")})),r},e}();const ki=bi;var Ei=function(){return Ei=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ei.apply(this,arguments)},Ti=function(){function e(e){var t=e.sdk;this.groupControl=null,this.operator=null,this.initOptions=null,this.sdk=null,this.sdk=t,this.groupControl=new mi({sdk:t}),this.operator=new ki({sdk:t})}return e.prototype.init=function(e){this.initOptions=Ei(Ei({},this.initOptions),e),this.groupControl.init(e.groupControl)},e.prototype.access=function(){},e.prototype.destroy=function(){this.groupControl.destroy()},e.prototype.requestStream=function(e){var t=e.instanceId,n=e.status,r=e.level,i=void 0===r?"normal":r;this.groupControl.requestStream({instanceId:t,status:n,level:i})},e.prototype.setSyncList=function(e){var t=e.list,n=void 0===t?[]:t;this.groupControl.setSyncList({list:n})},e.prototype.startSync=function(e){var t=e.instanceIds,n=void 0===t?[]:t;this.groupControl.startSync({instanceIds:n})},e.prototype.stopSync=function(){this.groupControl.stopSync()},e.prototype.setMaster=function(e){var t=e.instanceId;this.groupControl.setMaster({instanceId:t})},e.prototype.setImageEvent=function(e){var t=e.interval,n=e.quality;this.groupControl.setImageEvent({interval:t,quality:n})},e.prototype.joinGroupControl=function(e){var t=e.instanceIds,n=e.clientSessions,r=void 0===n?[]:n;this.groupControl.join({instanceIds:t,clientSessions:r})},e.prototype.leaveGroupControl=function(e){var t=e.instanceIds;this.groupControl.leave({instanceIds:t})},e.prototype.transMessage=function(e){var t=e.packageName,n=e.message;this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"trans_message",data:{package_name:t,msg:n}})},e.prototype.inputText=function(e){var t=e.content,n=void 0===t?"":t,r=e.mode,i=void 0===r?"append":r,o=e.index_after_override;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"input_text",content:n,mode:i,index_after_override:o}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"input_text",content:n,mode:i}})},e.prototype.switchIME=function(e){var t=e.ime;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"switch_ime",ime:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"switch_ime",ime:t}}),this.sdk.pageEvent.IMEType=t},e.prototype.distributeApp=function(e){var t=e.packageName;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"distribute_app",data:{package_name:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"distribute_app",data:{package_name:t}}})},e.prototype.preserveCleanApp=function(e){var t=e.preservePackageNames;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"preserve_clean_app",data:{preserve_package_names:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"preserve_clean_app",data:{preserve_package_names:t}}})},e.prototype.keepFrontApp=function(e){var t=e.packageName,n=e.enable;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"keep_front_app",data:{package_name:t,enable:n}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"keep_front_app",data:{package_name:t,enable:n}}})},e.prototype.getInstanceImage=function(e){var t=e.instanceId,n=e.quality,r=void 0===n?20:n;return this.operator.getInstanceImage({instanceId:t,quality:r})},e.prototype.upload=function(e){var t=e.instanceId,n=e.files;return this.operator.upload({instanceId:t,files:n})},e.prototype.uploadMedia=function(e){var t=e.instanceId,n=e.files;return this.operator.uploadMedia({instanceId:t,files:n})},e.prototype.getInstanceDownloadAddress=function(e){var t=e.instanceId,n=e.path;return this.operator.getInstanceDownloadAddress({instanceId:t,path:n})},e.prototype.getInstanceDownloadLogcatAddress=function(e){var t=e.instanceId,n=e.recentDays;return this.operator.getInstanceDownloadLogcatAddress({instanceId:t,recentDays:n})},e.prototype.setLocation=function(e){var t,n,r,i;return n=this,i=function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(n){return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?[2,this.operator.batchTask({taskType:"ModifyGPS",params:e})]:[2,{Code:1,Message:"params object is empty"}]}))},new((r=void 0)||(r=Promise))((function(e,t){function o(e){try{a(i.next(e))}catch(e){t(e)}}function s(e){try{a(i.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(o,s)}a((i=i.apply(n,[])).next())}))},e.prototype.setResolution=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyResolution",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.paste=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Paste",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setSensor=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifySensor",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.sendClipboard=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SendClipboard",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.shake=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Shake",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.sendTransMessage=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SendTransMessage",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeInstanceProperties=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeInstanceProperties",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.modifyInstanceProperties=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyInstanceProperties",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.listUserApps=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ListUserApps",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.modifyKeepFrontAppStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyKeepFrontAppStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeKeepFrontAppStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeKeepFrontAppStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.unInstallByPackageName=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"UnInstallByPackageName",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.startApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StartApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.stopApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StopApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearAppData=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearAppData",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.enableApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"EnableApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.disableApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DisableApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.startCameraMediaPlay=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StartCameraMediaPlay",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.stopCameraMediaPlay=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StopCameraMediaPlay",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeCameraMediaPlayStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeCameraMediaPlayStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.displayCameraImage=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DisplayCameraImage",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.addKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"AddKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.removeKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"RemoveKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SetKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.mute=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Mute",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.mediaSearch=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"MediaSearch",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.reboot=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Reboot",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.listAllApps=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ListAllApps",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.moveAppBackground=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"MoveAppBackground",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.addAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"AddAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.removeAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"RemoveAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SetAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.getNavVisibleStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"GetNavVisibleStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.getSystemMusicVolume=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"GetSystemMusicVolume",params:e}):{Code:1,Message:"params object is empty"}},e}(),Ci=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ii=function(){return Ii=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ii.apply(this,arguments)},wi=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},Ri=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ai=function(e){function t(){var t=e.call(this)||this;return t.version=Te,t.cloudGamingWebRTC=null,t.pageEvent=null,t.cloudGamingWebsocket=null,t.androidInstance=null,t.accessInfo=null,t.gamepad=null,t.watchdog=null,t.gameConfig=null,t.showStats=null,t.initOptions={mount:null,reconnect:!0,autoSwitchCamera:!0,autoSwitchMic:!0,streaming:{mode:"webrtc"},androidInstance:{autoRotateOnPC:!0}},t.uuid=null,t.sdkInitStartTime=null,t._mobileGame=!1,t.cloudGamingWebRTC=new yt({sdk:t}),t.pageEvent=new cn({sdk:t}),t.androidInstance=new Ti({sdk:t}),t.accessInfo=new pi({sdk:t}),t.gamepad=new xn({sdk:t}),t.watchdog=new Un({sdk:t}),t.gameConfig=new Bn({sdk:t}),t.showStats=new yn({sdk:t}),t.cloudGamingWebsocket=new si({sdk:t}),t.uuid=+new Date,t}return Ci(t,e),Object.defineProperty(t.prototype,"mountPoint",{get:function(){return null===document||void 0===document?void 0:document.querySelector("#".concat(this.initOptions.mount))},enumerable:!1,configurable:!0}),t.prototype.init=function(e){this.initLoggerConfig(e),this.sdkInitStartTime=+new Date,this.initOptions=Ii(Ii({},this.initOptions),e);var t=e.mount,n=e.loadingText,r=e.showLoading,i=e.restartText,o=e.accessToken,s=e.mobileGame;this._mobileGame=s,this.mountGamePoint({mount:t,loadingText:n,showLoading:r,restartText:i}),this.log("init tcgsdk version->",Te,"options->",e),this.log("webrtc-adapter",le.browserDetails.browser,le.browserDetails.version),e.onLog&&this.setExternalLog(e.onLog),(null==o?void 0:o.accessInfo)&&this.accessInfo.setInstanceAccessInfo({AccessInfo:o.accessInfo,Token:o.token}),this.pageEvent.init(e),this.showStats.init({mount:this.initOptions.mount}),this.watchdog.init({mount:this.initOptions.mount}),this.androidInstance.init(e),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.init(e):(this.cloudGamingWebsocket.init({mount:this.initOptions.mount}),this.onInitSuccess({code:0,msg:"ok"})),this.setDebugMode(e.debugSetting),this.log("init->",this.initOptions),this.log("userAgent",null===navigator||void 0===navigator?void 0:navigator.userAgent)},Object.defineProperty(t.prototype,"streamingMode",{get:function(){var e;return(null===(e=this.initOptions.streaming)||void 0===e?void 0:e.mode)||"webrtc"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"initStartTime",{get:function(){return this.cloudGamingWebRTC.webrtcStartTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isMobileGame",{get:function(){return this._mobileGame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mobileGame",{set:function(e){this._mobileGame=e},enumerable:!1,configurable:!0}),t.prototype.getIsMobileGame=function(){return this._mobileGame},t.prototype.getAndroidInstance=function(){return this.androidInstance},t.prototype.getInitOptions=function(){return this.initOptions},t.prototype.getClientSession=function(){return this.cloudGamingWebRTC.getClientSideDescription(!0)},t.prototype.getServerSession=function(e){var t=(void 0===e?st:e).clientId,n=void 0===t?this.initOptions.mount:t;return this.gameConfig.getConfig({clientId:n})},t.prototype.start=function(e){void 0===e&&(e=""),this.cloudGamingWebRTC.connect(e)},t.prototype.setAccessToken=function(e){var t=e.accessInfo,n=e.token;this.accessInfo.setInstanceAccessInfo({AccessInfo:t,Token:n})},t.prototype.access=function(e){var t=e.instanceId,n=void 0===t?"":t,r=e.instanceIds,i=void 0===r?[]:r,o=e.groupControl,s=void 0!==o&&o;return wi(this,0,void 0,(function(){var e,t,r,o,a,c,u,d,l,h,p,f,v,m,_;return Ri(this,(function(g){switch(g.label){case 0:if("websocket"===this.streamingMode)return e=this.accessInfo.getInstanceAccessInfo({instanceId:s?i[0]:n}),t=e.Token,r=e.WebSocketAddress,o=e.WebSocketSecureAddress,a=o,"http:"===window.location.protocol&&(a=r),s?(c=this.accessInfo.getTokenInfos({instanceIds:i}),[2,this.androidInstance.groupControl.startWebSocket({tokenInfos:c,url:a,instanceIds:i})]):[2,this.cloudGamingWebsocket.connect({url:a,protocols:["media-v1"],token:t,instanceId:n,videoCodecList:this.initOptions.streaming.videoCodecList})];if(!s)return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,this.accessInfo.createWebRTCGroupSession({instanceIds:i,clientSessions:[this.getClientSession()]})];case 2:return u=g.sent(),d=u.GroupControlId,l=u.ServerSessions,v=u.Code,m=u.Message,0===v?this.androidInstance.groupControl.start({instanceIds:i,groupControlId:d,serverSessions:l}):this.onConnectFailed({code:v,msg:m}),[3,4];case 3:return h=g.sent(),this.onConnectFailed({code:_e.FETCH_ERROR,msg:"fetch group server session error, ".concat(h.message)}),[3,4];case 4:return[3,8];case 5:return g.trys.push([5,7,,8]),[4,this.accessInfo.createWebRTCSession({instanceId:n,clientSession:this.getClientSession()})];case 6:return p=g.sent(),f=p.ServerSession,v=p.Code,m=p.Message,0===v?this.cloudGamingWebRTC.connect(f):this.onConnectFailed({code:v,msg:m}),[3,8];case 7:return _=g.sent(),this.onConnectFailed({code:_e.FETCH_ERROR,msg:"fetch server session error, ".concat(_.message)}),[3,8];case 8:return[2]}}))}))},t.prototype.destroy=function(e){var t=void 0===e?st:e,n=t.message,r=void 0===n?"主动关闭":n,i=t.code,o=void 0===i?me.MANUAL_CLOSE:i;this.log("destroy->","message: ",r,"code: ",o),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.disconnected({message:r,code:o}):this.cloudGamingWebsocket.destroy({message:r,code:o}),this.androidInstance.groupControl.destroy()},t.prototype.reconnect=function(){"webrtc"===this.streamingMode?(this.cloudGamingWebRTC.clearPeerConnection(),this.cloudGamingWebRTC.reconnect({message:"manual reconnect"})):this.cloudGamingWebsocket.reconnect({message:"manual reconnect"})},t.prototype.gameRestart=function(){this.log("gameRestart->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"restart"}}),this.clearRemoteKeys()},t.prototype.gamePause=function(e){var t=(void 0===e?st:e).media;this.log("gamePause->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"pause",media:t}}),this.cloudGamingWebRTC.setGameStatus("pause"),this.clearRemoteKeys()},t.prototype.gameResume=function(e){var t=(void 0===e?st:e).media;this.log("gameResume->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"resume",media:t}}),this.cloudGamingWebRTC.setGameStatus("playing"),this.clearRemoteKeys()},t.prototype.sendKeyboardEvent=function(e){var t=e.key,n=e.down,r=e.location,i=void 0===r?0:r;"websocket"===this.streamingMode?this.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"keyboard",key:t,down:n,location:i}}):this.cloudGamingWebRTC.sendKmData({type:"keyboard",key:t,down:n,location:i})},t.prototype.sendMouseEvent=function(e){var t=e.type,n=e.down,r=e.delta;this.cloudGamingWebRTC.sendKmData({type:t,down:n,delta:r})},t.prototype.sendGamepadEvent=function(e){var t=e.type,n=e.down,r=e.key,i=e.x,o=e.y;this.cloudGamingWebRTC.sendKmData({type:t,down:n,key:r,x:i,y:o})},t.prototype.sendRawEvent=function(e){switch(this.log("sendRawEvent->",e),"object"!=typeof e&&console.error("data is not an object"),!0){case"keyboard"===e.type:this.sendKeyboardEvent(e);break;case e.type.includes("mouse"):this.sendMouseEvent(e);break;case e.type.includes("gamepad")||e.type.includes("axis")||e.type.includes("lt")||e.type.includes("rt"):this.sendGamepadEvent(e);break;default:this.cloudGamingWebRTC.sendAckData({data:e})}},t.prototype.sendKmData=function(e){this.cloudGamingWebRTC.sendKmData(e)},t.prototype.setMoveSensitivity=function(e){this.log("setMoveSensitivity->",e),"number"!=typeof e&&console.error("input value must be number"),(e-.01<Number.EPSILON||e-100>Number.EPSILON)&&console.error("sensitivity is out of range"),this.pageEvent.setMoveSensitivity(e)},t.prototype.sendSeqRawEvents=function(e){this.log("sendSeqRawEvents->",e),this.cloudGamingWebRTC.sendKmData({type:"key_seq",keys:e.map((function(e){return JSON.stringify(e)}))})},t.prototype.getMoveSensitivity=function(){return this.pageEvent?1/this.pageEvent.getMoveSensitivity():1},t.prototype.setMouseCanLock=function(e){this.log("setMouseCanLock->",e),this.cloudGamingWebRTC.lockMouse(e),this.cloudGamingWebRTC.setForceShowCursor(!e)},t.prototype.lockMouse=function(e){this.log("lockMouse->",e),this.cloudGamingWebRTC.setForceLockCursor(e),this.cloudGamingWebRTC.lockMouse(e)},t.prototype.mouseMove=function(e,t,n,r){this.pageEvent.mouseMove(e,t,n,r)},t.prototype.mouseTabletMode=function(e){this.log("mouseTabletMode->",e),this.pageEvent.setTabletMode(e)},t.prototype.setRemoteCursor=function(e){void 0===e&&(e=0),this.log("setRemoteCursor->",e),this.cloudGamingWebRTC.setCursorMode(e)},t.prototype.setCursorShowStat=function(e){this.log("setCursorShowStat->",e),this.cloudGamingWebRTC.setForceShowCursor(e)},t.prototype.setCursorShowStatus=function(e){this.log("setCursorShowStat->",e),this.cloudGamingWebRTC.setForceShowCursor(e)},t.prototype.setCursorState=function(e){"forceShow"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!0),this.lockMouse(!1)),"forceLock"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!1),this.lockMouse(!0)),"auto"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!1),this.cloudGamingWebRTC.setForceLockCursor(!1))},t.prototype.getCursorShowStat=function(){return this.log("getCursorShowStat->",this.cloudGamingWebRTC.getCursorShowStatus()),this.cloudGamingWebRTC.getCursorShowStatus()},t.prototype.setMobileCursorScale=function(e){this.log("setMobileCursorScale->",e),this.cloudGamingWebRTC.setMobileCursorScale(e)},t.prototype.setRemoteCursorStyle=function(e){this.log("setRemoteCursorStyle->",e),this.cloudGamingWebRTC.sendAckData({data:{type:"set_pointer_style",style:e}})},t.prototype.clearRemoteKeys=function(){this.log("clearRemoteKeys->"),this.pageEvent.clearRemoteKeys()},t.prototype.resetRemoteCapsLock=function(){this.log("resetRemoteCapsLock->"),this.cloudGamingWebRTC.sendAckData({data:{type:"reset_capslock"}})},t.prototype.setDefaultCursorImage=function(e){this.log("setDefaultCursorImage->",e),e&&this.cloudGamingWebRTC.setDefaultCursorImage(e)},t.prototype.setKMStatus=function(e){var t=e.keyboard,n=void 0===t||t,r=e.mouse,i=void 0===r||r;this.pageEvent.setKMStatus({keyboard:n,mouse:i})},t.prototype.setKeyboardBanList=function(e){var t=e.keyList;this.pageEvent.setKeyboardBanList({keyList:t})},t.prototype.setPaste=function(e){this.pageEvent.setPaste(e)},t.prototype.mobileTouchMove=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=this.pageEvent.remoteScreenSize,s=o.width,a=o.height;this.pageEvent.mobileTouchMove({finger_id:t,event_type:n,x:r,y:i,width:s,height:a,timestamp:+new Date})},t.prototype.setDebugMode=function(e){var t=void 0===e?{}:e,n=t.showStats,r=void 0!==n&&n,i=t.showLog,o=void 0!==i&&i,s=t.showOnAckMessage,a=void 0!==s&&s,c=t.showOnCdMessage,u=void 0!==c&&c,d=t.showOnHbMessage,l=void 0!==d&&d,h=t.showOnKmMessage,p=void 0!==h&&h,f=t.showOnSvMessage,v=void 0!==f&&f,m=t.showOnCloudDeviceMessage,_=void 0!==m&&m,g=t.showSendAckData,y=void 0!==g&&g,S=t.showSendHbData,b=void 0!==S&&S,k=t.showSendKmData,E=void 0!==k&&k,T=t.showSendCloudDeviceData,C=void 0!==T&&T,I=t.showMuxer,w=void 0!==I&&I;this.showStats.show(r),this.initOptions.debugSetting||(this.initOptions.debugSetting={}),this.initOptions.debugSetting=Ii(Ii({},this.initOptions.debugSetting),{showLog:o,showOnAckMessage:a,showOnCdMessage:u,showOnHbMessage:l,showOnKmMessage:p,showOnSvMessage:v,showOnCloudDeviceMessage:_,showSendAckData:y,showSendHbData:b,showSendKmData:E,showSendCloudDeviceData:C,showMuxer:w})},t.prototype.reportLog=function(){return this.log("reportLog, user manual upload"),this.reportLogInner()},t.prototype.setLogHandler=function(e){void 0===e&&(e=nt),this.log("setLogHandler"),this.setExternalLog(e)},t.prototype.toggleMetricReportBulk=function(e){void 0===e&&(e=!1),this.showStats.toggleMetricReportBulk(e)},t.prototype.playVideo=function(e){var t=this.getVideoElement();return"play"===e?null==t?void 0:t.play():"pause"===e?null==t?void 0:t.pause():void 0},t.prototype.playAudio=function(e){var t=this.getAudioElement();"play"===e&&(null==t||t.play()),"pause"===e&&(null==t||t.pause());var n=this.getHuaweiAudioElement();n&&("play"===e&&n.play(),"pause"===e&&n.pause())},t.prototype.setVideoOrientation=function(e){var t=void 0===e?{}:e,n=t.deg,r=void 0===n?0:n,i=t.rotateContainer,o=void 0===i||i,s=t.rotateMountPoint,a=void 0!==s&&s;this.log("setVideoOrientation",r,o),this.pageEvent.setVideoOrientation({deg:r,rotateContainer:o,rotateMountPoint:a})},t.prototype.getPageSize=function(){return{width:window.innerWidth,height:window.innerHeight}},t.prototype.setStreamProfile=function(e,t){var n,r;void 0===t&&(t=nt),this.log("setStreamProfile->",e);var i=this.pageEvent.getRemoteScreenConfig().deg,o=e.video_width,s=e.video_height;90===i||270===i?null===(n=this.cloudGamingWebRTC)||void 0===n||n.sendAckData({data:Ii(Ii({},e),{video_width:s,video_height:o,type:"res_mode"}),callback:t}):null===(r=this.cloudGamingWebRTC)||void 0===r||r.sendAckData({data:Ii(Ii({},e),{type:"res_mode"}),callback:t})},t.prototype.getDisplayRect=function(){return this.cloudGamingWebRTC.getDisplayRect()},t.prototype.setVideoVolume=function(e){this.log("setVideoVolume->",e),this.getVideoElement().volume=e,0===e?(this.getVideoElement().muted=!0,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().muted=!0,this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!0)):(this.getVideoElement().muted=!1,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!1),this.playVideo("play"))},t.prototype.setAudioVolume=function(e){this.log("setAudioVolume->",e);var t=this.getHuaweiAudioElement();t&&(this.log("huawei setVideoVolume->",e),t.volume=e);var n=this.getAudioElement();n.volume=e,0===e?(n.muted=!0,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().muted=!0,this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!0)):(n.muted=!1,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!1),this.playAudio("play"))},t.prototype.getAudioVolume=function(){var e;return null!==(e=this.getAudioElement().volume)&&void 0!==e?e:0},t.prototype.getVideoVolume=function(){var e;return null!==(e=this.getVideoElement().volume)&&void 0!==e?e:0},t.prototype.switchMic=function(e){var t=e.status,n=e.profile;return this.cloudGamingWebRTC.switchMic({status:t,profile:n})},t.prototype.switchCamera=function(e){var t=e.status,n=e.profile;return this.cloudGamingWebRTC.switchCamera({status:t,profile:n})},t.prototype.setMicProfile=function(e){return this.cloudGamingWebRTC.setMicProfile(e)},t.prototype.setCameraProfile=function(e){return this.cloudGamingWebRTC.setCameraProfile(e)},t.prototype.getDevices=function(){return this.cloudGamingWebRTC.getDevices()},t.prototype.setPageBackground=function(e){void 0===e&&(e=""),this.log("setPageBackground->",e);var t=this.getCloudGamingStreamContainerElement();t&&(t.style.background="url(".concat(e,")"))},t.prototype.sendText=function(e,t){void 0===e&&(e=""),void 0===t&&(t=nt),this.log("sendText",e),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.sendAckData({data:{type:"paste",content:e},callback:t}):this.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"paste",content:e}})},t.prototype.setClientInteractMode=function(e){void 0===e&&(e="cursor"),this.log("setClientInteractMode->",e),this.pageEvent.setClientInteractMode(e)},t.prototype.setRemoteDesktopResolution=function(e){var t=this,n=e.width,r=e.height;return this.log("setRemoteDesktopResolution, width",n,"height",r),new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"desktop_res",width:Math.floor(n),height:Math.floor(r)},callback:function(t){var n=t.data;e(void 0===n?{code:-1}:n)}})}))},t.prototype.getRemoteStreamResolution=function(){if(this.getVideoElement().videoWidth&&this.getVideoElement().videoHeight)return{width:this.getVideoElement().videoWidth,height:this.getVideoElement().videoHeight};var e=this.gameConfig.getConfig({clientId:this.initOptions.mount}).video,t=void 0===e?{}:e,n=t.width,r=void 0===n?0:n,i=t.height;return{width:r,height:void 0===i?0:i}},t.prototype.reshapeWindow=function(){this.pageEvent.reshapeWindow()},t.prototype.getUserMedia=function(){return this.cloudGamingWebRTC.getUserMedia()},t.prototype.screenShot=function(e){var t=e.name,n=void 0===t?"tcgsdk-".concat(+new Date):t,r=e.width,i=void 0===r?this.getVideoElement().videoWidth:r,o=e.height,s=void 0===o?this.getVideoElement().videoHeight:o,a=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n}(i,s);a.getContext("2d").drawImage(this.getVideoElement(),0,0,i,s);var c=document.createElement("a");c.setAttribute("download","".concat(n,".png")),a.toBlob((function(e){var t=URL.createObjectURL(e);c.setAttribute("href",t),c.click()}))},t.prototype.createCustomDataChannel=function(e){var t=e.destPort,n=e.maxRetransmits,r=e.maxPacketLifeTime,i=e.onMessage,o=e.protocol,s=void 0===o?"text":o,a=e.type,c=void 0===a?"":a;return wi(this,0,void 0,(function(){var e,o,a,u=this;return Ri(this,(function(d){switch(d.label){case 0:return[4,this.cloudGamingWebRTC.createCustomDataChannel({destPort:t,maxRetransmits:n,maxPacketLifeTime:r,protocol:s,type:c,onMessage:i,onError:function(e){u.log("createCustomDataChannel onerror",e)},onClose:function(e){u.log("createCustomDataChannel onclose",e)}})];case 1:return e=d.sent(),o=e.code,a=e.msg,[2,{sendMessage:function(e){u.cloudGamingWebRTC.sendCustomDataChannelMessage({destPort:t,msg:e})},code:o,msg:a}]}}))}))},t.prototype.getPlayerVolume=function(e){return document.getElementById("".concat(e,"A")).volume},t.prototype.setPlayerVolume=function(e,t){this.log("setPlayerVolume->",t);var n=document.getElementById("".concat(e,"A"));0===t?n.muted=!0:(n.muted=!1,n.volume=t,n.play())},t.prototype.getSeats=function(){var e=this;return new Promise((function(t){e.cloudGamingWebRTC.sendAckData({data:{type:"sync_seats"},callback:function(e){var n=e.code,r=e.data,i=r.players,o=r.viewers;0===n&&t({players:i,viewers:o})}})}))},t.prototype.submitSeatChange=function(e){var t=this,n=e.user_id,r=e.to_role,i=e.seat_index,o=void 0===i?0:i;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"submit_seat_change",user_id:n,to_role:r,seat_index:o},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r;t.log("submit_seat_change res",i),e(i)}})}))},t.prototype.seatChange=function(e){var t=this,n=e.user_id,r=e.to_role,i=e.seat_index,o=void 0===i?0:i;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"seat_change",user_id:n,to_role:r,seat_index:o},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r;t.log("seat_change res",i),e(i)}})}))},t.prototype.changeMicStatus=function(e){var t=this,n=e.status,r=e.user_id;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"mic_status",user_id:r,status:n},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r,o=i.code,s=i.status,a=i.user_id,c=t.gameConfig.getConfig({clientId:t.initOptions.mount}).user_id;0===o&&a===c&&(t.log("changeMicStatus",i),0!==s&&1!==s||a&&t.cloudGamingWebRTC.setTrackEnable({type:"audio",enable:!1}),2===s&&a&&t.cloudGamingWebRTC.setTrackEnable({type:"audio",enable:!0})),e(i)}})}))},t.prototype.onInitSuccess=function(e){var t,n;null===(n=(t=this.initOptions).onInitSuccess)||void 0===n||n.call(t,e),this.trigger("InitSuccess",e)},t.prototype.onConnectSuccess=function(e){var t,n;this.log("onConnectSuccess ->"),null===(n=(t=this.initOptions).onConnectSuccess)||void 0===n||n.call(t,e),this.trigger("ConnectSuccess",e),this.androidInstance.groupControl.groupControlId&&"webrtc"===this.streamingMode&&this.androidInstance.groupControl.onConnectSuccess()},t.prototype.onDisconnect=function(e){var t,n;null===(n=(t=this.initOptions).onDisconnect)||void 0===n||n.call(t,e),this.trigger("Disconnected",e)},t.prototype.onConnectFailed=function(e){var t,n;null===(n=(t=this.initOptions).onConnectFail)||void 0===n||n.call(t,e),this.trigger("ConnectFailed",e)},t.prototype.onEvent=function(e){var t,n;null===(n=(t=this.initOptions).onEvent)||void 0===n||n.call(t,e),this.trigger("Event",e)},t.prototype.onOrientationChange=function(e){var t,n;null===(n=(t=this.initOptions).onOrientationChange)||void 0===n||n.call(t,e),this.trigger("OrientationChange",e)},t.prototype.onVisibilityChange=function(e){var t,n;null===(n=(t=this.initOptions).onVisibilityChange)||void 0===n||n.call(t,e),this.trigger("VisibilityChange",e)},t.prototype.onNetworkChange=function(e){var t,n;null===(n=(t=this.initOptions).onNetworkChange)||void 0===n||n.call(t,e),this.trigger("NetworkChange",e)},t.prototype.onWebrtcStatusChange=function(e){var t,n,r,i;null===(n=(t=this.initOptions).onWebrtcStat)||void 0===n||n.call(t,e),null===(i=(r=this.initOptions).onWebrtcStatusChange)||void 0===i||i.call(r,e),this.trigger("WebrtcStatusChange",e)},t.prototype.onGameStartComplete=function(e){var t,n;null===(n=(t=this.initOptions).onGameStartComplete)||void 0===n||n.call(t,e),this.trigger("GameStartComplete",e)},t.prototype.onGameStop=function(e){var t,n;null===(n=(t=this.initOptions).onGameStop)||void 0===n||n.call(t,e),this.trigger("GameStop",e)},t.prototype.onLoadGameArchive=function(e){var t,n;null===(n=(t=this.initOptions).onLoadGameArchive)||void 0===n||n.call(t,e),this.trigger("LoadGameArchive",e)},t.prototype.onSaveGameArchive=function(e){var t,n;null===(n=(t=this.initOptions).onSaveGameArchive)||void 0===n||n.call(t,e),this.trigger("SaveGameArchive",e)},t.prototype.onInputStatusChange=function(e){var t,n;null===(n=(t=this.initOptions).onInputStatusChange)||void 0===n||n.call(t,e),this.trigger("InputStatusChange",e)},t.prototype.onTouchEvent=function(e){var t,n;null===(n=(t=this.initOptions).onTouchEvent)||void 0===n||n.call(t,e),this.trigger("TouchEvent",e)},t.prototype.onCursorShowStatChange=function(e){var t,n;null===(n=(t=this.initOptions).onCursorShowStatChange)||void 0===n||n.call(t,e),this.trigger("CursorShowStatChange",e)},t.prototype.onGamepadConnectChange=function(e){var t,n;null===(n=(t=this.initOptions).onGamepadConnectChange)||void 0===n||n.call(t,e),this.trigger("GamepadConnectChange",e)},t.prototype.onConfigurationChange=function(e){var t,n;null===(n=(t=this.initOptions).onConfigurationChange)||void 0===n||n.call(t,e),this.trigger("ConfigurationChange",e)},t.prototype.onRemoteScreenResolutionChange=function(e){var t,n;null===(n=(t=this.initOptions).onRemoteScreenResolutionChange)||void 0===n||n.call(t,e),this.trigger("RemoteScreenResolutionChange",e)},t.prototype.onVideoStreamConfigChange=function(e){var t,n;null===(n=(t=this.initOptions).onVideoStreamConfigChange)||void 0===n||n.call(t,e),this.trigger("VideoStreamConfigChange",e)},t.prototype.onDoubleTap=function(e){var t,n;null===(n=(t=this.initOptions).onDoubleTap)||void 0===n||n.call(t,e),this.trigger("DoubleTap",e)},t.prototype.onStreamPushStateChange=function(e){var t,n;null===(n=(t=this.initOptions).onStreamPushStateChange)||void 0===n||n.call(t,e),this.trigger("StreamPushStateChange",e)},t.prototype.onDeviceChange=function(e){var t,n;this.log("onDeviceChange",Event),null===(n=(t=this.initOptions).onDeviceChange)||void 0===n||n.call(t,e),this.trigger("DeviceChange",e)},t.prototype.onGetUserMediaStatusChange=function(e){var t,n,r=e.msg,i=e.type,o=e.userMedia,s="",a=0;switch(r){case"NotFoundError":case"DevicesNotFoundError":s="NotFoundError",a=1;break;case"NotAllowedError":case"PermissionDeniedError":s="NotAllowedError",a=2;break;case"OverconstrainedError":s="OverconstrainedError",a=3;break;default:s=r}null===(n=(t=this.initOptions).onGetUserMediaStatusChange)||void 0===n||n.call(t,{code:a,msg:s,type:i,userMedia:o}),this.trigger("GetUserMediaStatusChange",{code:a,msg:s,type:i,userMedia:o})},t.prototype.onMultiPlayerChange=function(e){var t,n;null===(n=(t=this.initOptions).onMultiPlayerChange)||void 0===n||n.call(t,e),this.trigger("MultiPlayerChange",e)},t.prototype.onAndroidInstanceEvent=function(e){var t,n;null===(n=(t=this.initOptions).onAndroidInstanceEvent)||void 0===n||n.call(t,e),this.trigger("AndroidInstanceEvent",e)},t.prototype.onImageEvent=function(e){var t,n;null===(n=(t=this.initOptions).onImageEvent)||void 0===n||n.call(t,e),this.trigger("ImageEvent",e)},t.prototype.onWebrtcStatsChange=function(e,t){var n,r,i;if(e===pe.PLAYING){this.pageEvent.addEventHandler();var o=this.gameConfig.getConfig({clientId:t}).game_config,s=(void 0===o?st:o).sdk_conf,a=void 0===s?st:s;a||(a=st),this.setDefaultCursorImage(null!==(n=this.initOptions.defaultCursorImgUrl)&&void 0!==n?n:a.default_cursor_url),this.setRemoteCursor(null!==(r=this.initOptions.cursorMode)&&void 0!==r?r:a.cursor_mode),this.setPageBackground(null!==(i=this.initOptions.bgImgUrl)&&void 0!==i?i:a.bgimg_url)}},t.prototype.setFullscreen=function(e,t){return void 0===t&&(t=document.documentElement),wi(this,0,void 0,(function(){return Ri(this,(function(n){switch(n.label){case 0:this.log("setFullscreen->",e),n.label=1;case 1:return n.trys.push([1,6,,7]),e?[4,this.pageEvent.fullscreen(t)]:[3,3];case 2:return n.sent(),[3,5];case 3:return[4,this.pageEvent.exitFullscreen(t)];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:throw n.sent();case 7:return[2]}}))}))},t.prototype.getFullscreen=function(){return Qe()},t.prototype.getPageOrientation=function(){return this.pageEvent.getPageOrientation()},t.prototype.isMobile=function(){return Ze()},t.prototype.getGameConfig=function(e){var t=(void 0===e?st:e).clientId,n=void 0===t?this.initOptions.mount:t;return this.gameConfig.getConfig({clientId:n}).game_config},t.prototype.supportRenegotiation=function(){return ct()},t.prototype.getRequestId=function(){return this.cloudGamingWebRTC.getRequestId()},t.prototype.getGameMountPoint=function(){return document.getElementById(this.initOptions.mount)},t.prototype.getVideoElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".video-stream")},t.prototype.getAudioElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".audio-stream")},t.prototype.getAudioElementWebsocket=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-audio-stream-socket")},t.prototype.getHuaweiAudioElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector("#tcg-audio-huawei")},t.prototype.getProgressBarElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".progress-bar-container")},t.prototype.getCursorElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector("#cursor")},t.prototype.getCloudGamingContainerElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-container")},t.prototype.getCloudGamingStreamContainerElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-stream-container")},t.prototype.getRestartElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".restart")},t.prototype.createAudioAndAddTrack=function(e){var t=e.id,n=e.source,r=document.getElementById(t);r||((r=document.createElement("audio")).id=t,r.autoplay=!0,r.className="audio-stream",r.setAttribute("playsinline","true"),r.setAttribute("webkit-playsinline","true"),r.setAttribute("x5-playsinline","true")),r.srcObject=n,this.getCloudGamingStreamContainerElement().appendChild(r)},t.prototype.getFakeInputElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".tcg-fake-input")},t.prototype.showTouchPosition=function(e){this.cloudGamingWebRTC.sendAckData({data:{type:"show_touch_pos",show:e}})},t.prototype.mountGamePoint=function(e){var t=e.mount,n=void 0===t?"":t,r=e.loadingText,i=void 0===r?"正在启动云渲染":r,o=e.showLoading,s=void 0===o||o,a=e.restartText,c=void 0===a?"重新连接":a,u=document.createElement("style");document.querySelector("head").append(u),u.appendChild(document.createTextNode("\n.cloud-gaming-container {\n position: relative;\n width: 100%;\n height: 100%;\n // justify-content: center;\n // align-items: center;\n display: none;\n}\n.cloud-gaming-stream-container {\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n background-size: cover !important;\n}\n.cloud-gaming-audio-stream-socket {\n display: none;\n}\n.tcg-fake-input {\n position: absolute;\n z-index: -5;\n opacity: 0;\n}\n.qcloud-stat {\n position: absolute;\n right: 10px;\n top: 0px;\n line-height: 18px;\n padding: 5px 10px;\n z-index: 5;\n color: #eee;\n background: rgba(0, 0, 0, .5);\n border-radius: 5px;\n text-align: left;\n font-size: 12px;\n pointer-events: none;\n display: none;\n flex-direction: column;\n width: 220px;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n}\n.qcloud-request-id, .qcloud-instance-id {\n pointer-events: all;\n}\n.qcloud-stat-left {\n width: 120px;\n}\n.qcloud-stat-right {\n flex: 1;\n}\n.qcloud-stat-row {\n text-align: left;\n display: flex;\n}\n\n@keyframes spinner {\n to {transform: rotate(360deg);}\n}\n.progress-bar-container {\n text-align: center;\n position: absolute;\n width: 40%;\n height: 15%;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.starting {\n color:white;\n font-weight:bold;\n margin-top:30px;\n}\n.spinner:before {\n content: '';\n box-sizing: border-box;\n position: absolute;\n top: 60px;\n width: 20px;\n height: 20px;\n margin-top: -5px;\n margin-left: -10px;\n border-radius: 50%;\n border: 4px solid #ccc;\n border-top-color: #000;\n animation: spinner .6s linear infinite;\n}\n.restart {\n position: absolute;\n width: 350px;\n text-align: center;\n height: 30px;\n line-height: 30px;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n align-items: center;\n font-size: 24px;\n color: #fff;\n display: none;\n}\n.cursor {\n position: absolute;\n width: 0px;\n height: 0px;\n top: 0px;\n left: 0px;\n z-index: 1;\n background-size: cover;\n display: none;\n}\n.audio-stream {\n width: 0px;\n}\n.video-stream {\n max-width: 100%;\n max-height: 100%;\n outline: none;\n border: 0;\n}\n.video-stream:focus {\n outline :none;\n}\n.rotate-html-90 {\n transform: rotate(90deg);\n transform-origin: left top;\n width: 100vh;\n width: 100svh;\n height: 100vw;\n overflow-x: hidden;\n position: absolute;\n top: 0;\n left: 100%;\n}\n\n.rotate-html-180 {\n transform: rotate(180deg);\n transform-origin: center;\n}\n\n.rotate-html-270 {\n transform: rotate(270deg);\n transform-origin: left top;\n overflow-x: hidden;\n position: absolute;\n top: 100%;\n left: 0;\n}"));var d=document.getElementById(n);d||console.error("mount point is not found"),d.innerHTML=dn,s||(console.log("mountPoint",this.mountPoint),this.getProgressBarElement().style.display="none"),d.querySelector(".starting").innerHTML=i,d.querySelector(".restart").innerHTML=c},t}(Rn),Oi=new Ai;window.TCGSDK=Oi;const xi=Oi})();var C8,I8=T8.p;!function(e){e.MESSAGE="message",e.INITIALIZED="initialized",e.CALLBACK="callBack"}(C8||(C8={}));class w8{constructor(e,t){this.TCGSDK=e,this.destPort=t,this.events=new Map,this.TCGSDK=e}async init(e){const{sendMessage:t,code:n}=await this.TCGSDK.createCustomDataChannel({destPort:this.destPort||10005,type:e,onMessage:e=>{try{const t=JSON.parse(e),{key:n,data:r}=t;switch(console.log("onMessage",t),n){case C8.CALLBACK:this.emit(C8.CALLBACK,JSON.parse(r));break;case C8.INITIALIZED:this.emit(C8.INITIALIZED);break;default:this.emit(C8.MESSAGE,t)}}catch(e){console.error("CustomDataChannel onMessage error",e)}}});if(this.sendMessage=t,this.code=n,0==n){t(JSON.stringify({touchType:x4.EVENT_SDK,content:JSON.stringify({type:"PullStreamConnected"})}))}}send(e){this.sendMessage?.(e)}on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),this}once(e,t){const n=r=>{this.off(e,n),t(r)};return this.on(e,n),this}off(e,t){return this.events.has(e)?(this.events.set(e,this.events.get(e).filter((e=>e!==t))),this):this}emit(e,t){this.events.get(e)?.forEach((e=>e(t)))}getCode(){return this.code}}const R8={7:{width:144,height:256},8:{width:216,height:384},9:{width:288,height:512},10:{width:360,height:640},11:{width:480,height:848},12:{width:540,height:960},13:{width:600,height:1024},14:{width:480,height:1280},15:{width:720,height:1280},16:{width:720,height:1920},17:{width:1080,height:1920},18:{width:1440,height:1920},19:{width:1600,height:2560},20:{width:2880,height:1080}},A8={1:{fps:20},2:{fps:25},3:{fps:30},4:{fps:60},5:{fps:1},6:{fps:5},7:{fps:10},8:{fps:15},9:{fps:2}},O8={1:{kbps:1e3},2:{kbps:1500},3:{kbps:2e3},4:{kbps:2500},5:{kbps:3e3},6:{kbps:3500},7:{kbps:4e3},8:{kbps:5e3},9:{kbps:6e3},10:{kbps:8e3},11:{kbps:1e4},12:{kbps:12e3},13:{kbps:200},14:{kbps:400},15:{kbps:600}};function x8(e){return R8[e]}function P8(e){return A8[e].fps}function D8(e){return O8[e].kbps}class M8{constructor(e,t,n){this.initDomId=e,this.options=t,this.callbacks=n,this.remoteUserId="",this.abortController=null,this.dataChannel=null,this.groupDataChannel=null,this.isGroupControl=!1,this.groupPads=[],this.promiseMap={streamStatus:{},injectStatus:{}},this.isCameraInject=!1,this.isMicrophoneInject=!1,this.enableCamera=!1,this.enableMicrophone=!1,this.videoDeviceId="",this.audioDeviceId="",this.inputElement=null,this.rotateType=void 0,this.remoteInputState={isOpen:!1,imeOptions:""},this.lastStreamResolution={width:0,height:0},this.remoteDesktopResolution={width:0,height:0},this.enterkeyhintObj={2:"go",3:"search",4:"send",5:"next",6:"done",7:"previous"},this.TCGSDK=new I8,this.androidInstance=this.TCGSDK.getAndroidInstance(),this.enableMicrophone=this.options.enableMicrophone,this.enableCamera=this.options.enableCamera,this.videoDeviceId=this.options.videoDeviceId||"",this.audioDeviceId=this.options.audioDeviceId||"",this.remoteUserId=this.options.clientId,this.TCGSDK.setKMStatus({keyboard:!1,mouse:!0}),this.TCGSDK.setPaste(!1)}getMsgTemplate(e,t){return JSON.stringify({touchType:e,content:JSON.stringify(t)})}setMicrophone(e){this.enableMicrophone=e}setCamera(e){this.enableCamera=e}async setVideoDeviceId(e){if(this.videoDeviceId=e,this.isCameraInject)return this.cameraInject()}async setAudioDeviceId(e){if(this.audioDeviceId=e,this.isMicrophoneInject)return this.microphoneInject()}setMonitorOperation(e,t=!0){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:"operateSwitch",isOpen:e}),t)}triggerRecoveryTimeCallback(){}setVideoEncoder(e,t){}muted(){this.unsubscribeStream(O4.AUDIO)}getRequestId(){return this.TCGSDK.getRequestId()}unmuted(){this.subscribeStream(O4.AUDIO)}startPlay(){this.TCGSDK?.playVideo("play")}async sendGroupRoomMessage(e){}getEquipmentInfo(e){const t=this.getMsgTemplate(x4.EQUIPMENT_INFO,{type:e});this.sendUserMessage(t,!0)}getInjectStreamStatus(e,t=0){return new Promise((n=>{let r=null;0!==t&&(r=setTimeout((()=>{n({status:"unknown",type:e})}),t));(()=>{switch(e){case exports.InjectStreamStatusType.VIDEO:try{Object.assign(this.promiseMap.streamStatus,{resolve:e=>{r&&clearTimeout(r),n(e)}}),this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:D4.INJECTION_VIDEO_STATS}),!0)}catch(t){r&&clearTimeout(r),n({status:"unknown",type:e})}break;case exports.InjectStreamStatusType.CAMERA:r&&clearTimeout(r),n({status:this.isCameraInject?"live":"offline",type:e});break;case exports.InjectStreamStatusType.AUDIO:r&&clearTimeout(r),n({status:this.isMicrophoneInject?"live":"offline",type:e})}})()}))}appUnInstall(e){const t=this.getMsgTemplate(x4.APP_UNINSTALL,e);this.sendUserMessage(t)}async notifyInject(e,t){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:e,isOpen:t}))}async startMediaStream(e,t){try{if([O4.VIDEO,O4.AUDIO_AND_VIDEO].includes(e)){await this.notifyInject(M4.INJECTION_CAMERA,!0);const e=this.videoDeviceId||(t?.isFront?"user":!1===t?.isFront?"environment":void 0),n=e?{deviceId:e}:void 0;await this.TCGSDK.switchCamera({status:"open",profile:n});this.isCameraInject=!0}if([O4.AUDIO,O4.AUDIO_AND_VIDEO].includes(e)){await this.notifyInject(M4.INJECTION_AUDIO,!0);const e=this.audioDeviceId?{deviceId:this.audioDeviceId}:void 0;await this.TCGSDK.switchMic({status:"open",profile:e});this.isMicrophoneInject=!0}}catch(e){return Promise.reject(e)}}async stopMediaStream(e){try{const t=[];switch(e!==O4.VIDEO&&e!==O4.AUDIO_AND_VIDEO||(await this.notifyInject(M4.INJECTION_CAMERA,!1),t.push(this.TCGSDK.switchCamera({status:"close"}))),e!==O4.AUDIO&&e!==O4.AUDIO_AND_VIDEO||(await this.notifyInject(M4.INJECTION_AUDIO,!1),t.push(this.TCGSDK.switchMic({status:"close"}))),await Promise.allSettled(t),e){case O4.VIDEO:this.isCameraInject=!1;break;case O4.AUDIO:this.isMicrophoneInject=!1;break;case O4.AUDIO_AND_VIDEO:this.isCameraInject=!1,this.isMicrophoneInject=!1}}catch(e){return Promise.reject(e)}}async cameraInject(e){try{await this.stopMediaStream(O4.VIDEO),await this.startMediaStream(O4.VIDEO,e),this.callbacks.onVideoInit()}catch(e){return this.callbacks.onVideoError(e),Promise.reject(e)}}async microphoneInject(){try{await this.stopMediaStream(O4.AUDIO),await this.startMediaStream(O4.AUDIO),this.callbacks.onAudioInit()}catch(e){return this.callbacks.onAudioError(e),Promise.reject(e)}}kickItOutRoom(e){this.isGroupControl&&(e=e.filter((e=>e!==this.options.clientId))).length&&(this.groupPads=this.groupPads.filter((t=>!e.includes(t))),this.androidInstance.leaveGroupControl({instanceIds:e}))}async getAndroidInstanceToken(e){return new Promise(((t,n)=>{const{baseUrl:r}=this.options,i=r?`${r}/rtc/open/room/sdk/share/applyToken`:"https://openapi.armcloud.net/rtc/open/room/sdk/share/applyToken",{userId:o,uuid:s,token:a,manageToken:c}=this.options,u=c?"/manage/rtc/room/share/applyToken":i,d=c||a;this.abortController=new AbortController,_n.post(u,{userId:o,uuid:s,terminal:"h5",expire:36e4,pushPublicStream:!1,pads:e?.map((e=>({padCode:e,userId:o})))},{headers:c?{Authorization:d}:{token:d},signal:this.abortController.signal}).then((e=>{t(e?.data?.data||{})})).catch((e=>{_n.isCancel(e)||n(e)}))}))}joinGroupRoom(e){this.isGroupControl&&(e=e.filter((e=>e!==this.options.clientId))).length&&(this.groupPads=Array.from(new Set([...this.groupPads,...e])),this.getAndroidInstanceToken(e).then((t=>{const{accessInfo:n,roomToken:r}=t||{};this.TCGSDK.setAccessToken({accessInfo:n,token:r}),this.androidInstance.joinGroupControl({instanceIds:e})})))}toggleGroupControlSync(e=!0){this.isGroupControl&&(e?this.androidInstance.startSync({}):this.androidInstance.stopSync())}onRemoteVideoFirstFrame(){let{width:e,height:t}=this.TCGSDK.getRemoteStreamResolution();this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:1}),this.metricsReporter.instant(Y4.FIRST_FRAME),this.callbacks?.onRenderedFirstFrame?.({userId:this.options.clientId,width:e,height:t,isScreen:!1})}setupInputElement(){const{disable:e,disableLocalIME:t}=this.options;this.inputElement||e||t||q4(this,!0)}getRemoteInputState(){this.sendUserMessage(JSON.stringify({touchType:x4.INPUT_STATE}))}syncInputFocusState(e){const{allowLocalIMEInCloud:t,keyboard:n}=this.options,{isOpen:r,imeOptions:i}=e,o=this.enterkeyhintObj[i??""];o&&(this.inputElement.enterKeyHint=o);(t&&"pad"===n||"local"===n)&&"boolean"==typeof r&&setTimeout((()=>{r?this.inputElement?.focus():this.inputElement?.blur()}),150),this.remoteInputState={isOpen:r??!1,imeOptions:i??""}}matchResolution(e,t){let{width:n,height:r}=this.remoteDesktopResolution;if(!n||!r)return{width:e,height:t};const i=n/r,o=e/t;let s=e,a=t;return Math.abs(o-i)>.01&&(o>i?s=Math.round(t*i):a=Math.round(e/i)),s=s%2==0?s:s+1,a=a%2==0?a:a+1,{width:s,height:a}}setDomResolution(e,t){const n=document.getElementById(this.initDomId);if(!n)return;n.style.width="",n.style.height="";const r=n.getBoundingClientRect(),i=r.width,o=r.height,s=e/t;let a=i,c=o;i/o>s?(c=o,a=o*s):(a=i,c=i/s),n.style.position="relative",n.style.width=`${a}px`,n.style.height=`${c}px`}setupStreamResolution(e,t){let{width:n,height:r}=this.matchResolution(e,t);this.TCGSDK.setStreamProfile({video_width:n,video_height:r})}setMediaStreamRender(e){e===O4.VIDEO?this.unsubscribeStream(O4.AUDIO):e===O4.AUDIO&&this.unsubscribeStream(O4.VIDEO)}hideATags(){let e=document.styleSheets[0];e.insertRule(".cloud-gaming-container .restart { display: none !important; }",e.cssRules.length)}setupSDK(e=!1,t=[]){const{roomToken:n,padCode:r,accessInfo:i,videoStream:o,mediaType:s}=this.options,{resolution:a,frameRate:c,bitrate:u}=o,{width:d,height:l}=x8(a),h=P8(c),p=D8(u);this.isGroupControl=e,this.groupPads=t;const f=this;this.TCGSDK.init({mount:this.initDomId,mobileGame:!0,showLoading:!1,restartText:"",clickBodyToPlay:!1,debugSetting:{},streaming:{mode:"webrtc"},accessToken:{token:n,accessInfo:i||""},androidInstance:{autoRotateOnPC:!1},autoRotateMountPoint:!1,streamProfile:{fps:h,max_bitrate:p,min_bitrate:p,unit:"Kbps"},onConnectFail:e=>{this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:0}),this.metricsReporter.instant(Y4.FIRST_FRAME);const t=e.code;if(t>0)return void this.callbacks?.onConnectionStateChanged?.({state:1,code:t,msg:e.msg});const n={"-3":1,"-2":4,"-1":6}[t];this.callbacks?.onConnectionStateChanged?.({state:n,code:t,msg:e.msg})},onConnectSuccess:()=>{this.setupInputElement(),this.setupDataChannel(),this.setMediaStreamRender(s),this.hideATags(),this.joinGroupRoom(t)},onConfigurationChange:e=>{let{orientation:t,deg:n,width:r,height:i}=e.screen_config;this.remoteDesktopResolution={width:r,height:i};const{resolution:o}=this.options.videoStream,{width:s,height:a}=x8(o);this.setupStreamResolution(s,a);const c=t&&"portrait"!==t?exports.RotateDirection.LANDSCAPE:exports.RotateDirection.PORTRAIT;this.screenRotation(c,n??0)},onInitSuccess:()=>{this.callbacks?.onConnectSuccess?.(),e?this.TCGSDK.access({groupControl:e,instanceIds:[r]}):this.TCGSDK.access({instanceId:r})},onVideoStreamConfigChange:e=>{let{width:t,height:n}=this.lastStreamResolution;this.callbacks?.onChangeResolution?.({from:{width:t,height:n},to:e}),Object.assign(this.lastStreamResolution,e)},onAndroidInstanceEvent(e){const{type:t,data:n}=e;n?.event_type||f.syncInputFocusState(f.remoteInputState)},onEvent:e=>{const{type:t,data:n}=e;switch(t){case"video_state":-1===n?.code&&this.callbacks?.onAutoplayFailed?.({kind:"video",userId:r});break;case"audio_state":-1===n?.code&&this.callbacks?.onAutoplayFailed?.({kind:"audio",userId:r});break;case"media_stats":this.callbacks?.onRunInformation?.({userId:this.options.clientId,audioStats:{audioLossRate:n.audioStats.packet_lost/n.audioStats.packet_received,receivedKBitrate:n.audioStats.bit_rate,rtt:n.videoStats.rtt,jitterBufferDelay:n.audioStats.jitter_buffer,numChannels:n.audioStats.channels,receivedSampleRate:n.audioStats.sample_rate,concealedSamples:n.audioStats.concealed_samples,concealmentEvent:n.audioStats.concealment_events,codecType:n.audioStats.codec},videoStats:{width:n.videoStats.width,height:n.videoStats.height,videoLossRate:n.videoStats.packet_lost/n.videoStats.packet_received,receivedKBitrate:n.videoStats.bit_rate,decoderOutputFrameRate:n.videoStats.fps,rtt:n.videoStats.rtt,codecType:n.videoStats.codec}});break;case"autoplay":0===n?.code&&"video"===n?.mediaType&&this.onRemoteVideoFirstFrame?.()}}})}setPhoneRotation(e){this.screenRotation(e,e==exports.RotateDirection.LANDSCAPE?270:0)}async triggerChangeRotateEvent(e){((e,t)=>{const n=new ResizeObserver((r=>{for(const i of r){const{width:r,height:o}=i.target.getBoundingClientRect();r&&o&&(t(r,o),n.unobserve(e),n.disconnect())}}));n.observe(e)})(document.querySelector(`#${this.initDomId} video`),((t,n)=>{this.callbacks?.onChangeRotate?.(e,{width:t,height:n})}))}async screenRotation(e,t){const n=this.options.rotateType;void 0!==n&&(e=n,t=n===exports.RotateDirection.LANDSCAPE?270:0),(W4()||H4())&&(e=exports.RotateDirection.PORTRAIT,t=0);const r=document.getElementById(this.initDomId);if(!r)return;const i=r.getBoundingClientRect();let{width:o,height:s}=i;const a=this.rotateType;let c=o,u=s;void 0!==a?(a===exports.RotateDirection.PORTRAIT&&e===exports.RotateDirection.LANDSCAPE||a===exports.RotateDirection.LANDSCAPE&&e===exports.RotateDirection.PORTRAIT)&&([c,u]=[s,o]):e===exports.RotateDirection.LANDSCAPE&&([c,u]=[s,o]),r.style.width=`${c}px`,r.style.height=`${u}px`,await(async e=>{e.offsetWidth,await K4()})(r),this.TCGSDK.setVideoOrientation({deg:t??0,rotateMountPoint:!0}),this.triggerChangeRotateEvent(e),this.rotateType=e}async setupDataChannel(){if(this.dataChannel=new w8(this.TCGSDK,23332),await this.dataChannel.init("android"),this.isGroupControl){const e=()=>{this.callbacks?.onUserJoined?.({userInfo:{userId:this.options.clientId}})};this.groupDataChannel=new w8(this.TCGSDK,23331),await this.groupDataChannel.init("android_broadcast"),this.groupDataChannel.on(C8.INITIALIZED,e)}const e=e=>{const[t,n]=e?.split("*").map(Number);return{width:t,height:n}},t=(e,t)=>{try{return JSON.parse(e)}catch{return t}},n={[D4.CLIPBOARD]:e=>{const n=t(e,{content:""});this.callbacks?.onOutputClipper?.(n)},[D4.INPUT_STATE]:e=>{const n=t(e,{isOpen:!1,imeOptions:""});this.syncInputFocusState(n)},[D4.EQUIPMENT_INFO]:e=>{const n=t(e,{info:""});this.callbacks?.onEquipmentInfo?.(n)},[D4.INPUT_ADB]:e=>{const n=t(e,{isSuccess:!1,content:""});this.callbacks?.onAdbOutput?.(n)},[D4.VIDEO_AND_AUDIO_CONTROL]:e=>{const n=t(e,{}),r=!!n.isOpen;if(this.callbacks?.onMediaDevicesToggle?.({type:exports.MediaDeviceType.MEDIA,enabled:r,isFront:n.isFront}),!this.enableMicrophone&&!this.enableCamera)return;const i=this.enableMicrophone&&this.enableCamera?O4.AUDIO_AND_VIDEO:this.enableCamera?O4.VIDEO:O4.AUDIO;r?(this.enableCamera&&this.cameraInject(n),this.enableMicrophone&&this.microphoneInject()):this.stopMediaStream(i)},[D4.AUDIO_CONTROL]:e=>{const{isOpen:n=!1}=t(e,{});this.callbacks?.onMediaDevicesToggle?.({type:exports.MediaDeviceType.MICROPHONE,enabled:n}),this.enableMicrophone&&(n?this.microphoneInject():this.stopMediaStream(O4.AUDIO))},[D4.DEFINITION]:n=>{const r=t(n,{});this.callbacks?.onChangeResolution?.({from:e(r.from),to:e(r.to)})},[D4.START_INJECTION_VIDEO]:e=>{const n=t(e,{}),r=this?.promiseMap?.injectStatus?.resolve;"function"==typeof r&&(r({type:D4.START_INJECTION_VIDEO,status:n?.isSuccess?"success":"error",result:n}),this.promiseMap.injectStatus.resolve=null),this.callbacks?.onInjectVideoResult?.(D4.START_INJECTION_VIDEO,n)},[D4.STOP_INJECTION_VIDEO]:e=>{const n=t(e,{}),r=this?.promiseMap?.injectStatus?.resolve;"function"==typeof r&&(r({type:D4.STOP_INJECTION_VIDEO,status:n?.isSuccess?"success":"error",result:n}),this.promiseMap.injectStatus.resolve=null),this.callbacks?.onInjectVideoResult?.(D4.STOP_INJECTION_VIDEO,n)},[D4.INJECTION_VIDEO_STATS]:e=>{const n=t(e,{}),r=this?.promiseMap?.streamStatus?.resolve;"function"==typeof r&&r({path:n.path,status:n.status||(n.path?"live":"offline"),type:"video"})}},r={[D4.VIDEO_AND_AUDIO_CONTROL]:500,[D4.AUDIO_CONTROL]:500};Object.entries(r).forEach((([e,t])=>{const r=n[e];r&&t&&(n[e]=((e,t)=>{let n=null,r=null;return(...i)=>{r=i,n&&clearTimeout(n),n=setTimeout((()=>{r&&(e(...r),r=null),n=null}),t)}})(r,t))}));this.dataChannel.on(C8.INITIALIZED,(()=>{this.callbacks?.onUserJoined?.({userInfo:{userId:this.options.clientId}}),this.getRemoteInputState(),this.getCameraState()})).on(C8.MESSAGE,(e=>{const{key:t,data:r}=e,i=n[t];i?i(r):console.debug(`[dataChannel] Unknown key: ${this.options.clientId}`,t,"raw:",r)})).on(C8.CALLBACK,(e=>{const{type:t,data:r}=e,i=n[t];i?i(r):console.debug(`[dataChannel] Unknown type: ${this.options.clientId}`,t,"raw:",r)}))}sendUserMessage(e,t=!1,n=!1){this.isGroupControl&&!t&&this.groupDataChannel?.send(e),n||this.dataChannel?.send(e)}sendGroupInputString(e,t){this.isGroupControl&&t?.map(((t,n)=>{if(e[n]){const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.INPUT_BOX});this.sendUserMessage(r,!1,!0)}}))}sendGroupInputClipper(e,t){this.isGroupControl&&t?.map(((t,n)=>{if(e[n]){const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.CLIPBOARD});this.sendUserMessage(r,!1,!0)}}))}executeAdbCommand(e,t=!0){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:D4.INPUT_ADB,content:e}),t)}start(e=!1,t=[]){this.metricsReporter=new X4({endpoint:`${this.options.baseUrl}/traffic-info/open/traffic/rtcMonitor`,commonParams:{padCode:this.remoteUserId,streamType:this.options.streamType,sdkTerminal:"h5"},onceOnlyKeys:[Y4.FIRST_FRAME],useBeacon:!1,enableLog:!0}),this.metricsReporter.addParam(Y4.FIRST_FRAME,{joinRoomTime:Date.now()}),setTimeout((()=>{this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:0}),this.metricsReporter.instant(Y4.FIRST_FRAME)}),5e3),this.setupSDK(e,t)}onUserLeave(){}setViewSize(e,t,n=0){}getCameraState(){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.GET_CAMERA_STATE}),!0)}triggerClickEvent(e,t=!1){}triggerPointerEvent(e,t,n=!1){}async stop(){this.TCGSDK.destroy(),this.abortController?.abort(),this.abortController=null;const e=document.getElementById(this.initDomId);e&&(e.innerHTML=""),this.inputElement=null}sendShakeInfo(e){}async sendInputClipper(e,t=!1){const n=JSON.stringify({text:e,touchType:x4.CLIPBOARD});this.sendUserMessage(n,t)}async sendInputString(e,t=!1){const n=JSON.stringify({text:e,touchType:x4.INPUT_BOX});this.sendUserMessage(n,t)}setStreamConfig(e){const{definitionId:t,framerateId:n,bitrateId:r}=e,{width:i,height:o}=x8(t),s=P8(n),a=D8(r),{width:c,height:u}=this.matchResolution(i,o);this.TCGSDK.setStreamProfile({video_width:c,video_height:u,fps:s,max_bitrate:a,unit:"Kbps"});const{resolution:d,frameRate:l,bitrate:h}=this.options.videoStream;Object.assign(this.options.videoStream,{resolution:t??d,frameRate:n??l,bitrate:r??h})}async setScreenResolution(e,t=!0){const n=e.type===D4.UPDATE_DENSITY?{type:e.type,width:e.width,height:e.height,density:e.dpi}:{type:e.type},r=this.getMsgTemplate(x4.EVENT_SDK,n);this.sendUserMessage(r,t)}async subscribeStream(e){const t={1:{media:"audio"},2:{media:"video"},3:void 0}[e];await this.TCGSDK.gameResume(t)}setScreenshotRotation(e=0){}takeScreenshot(e=0){}resizeScreenshot(e,t){}showScreenShot(){}hideScreenShot(){}clearScreenShot(){}async unsubscribeStream(e){const t={1:{media:"audio"},2:{media:"video"},3:void 0}[e];await this.TCGSDK.gamePause(t)}async saveScreenShotToLocal(){return this.TCGSDK.screenShot({name:this.options.clientId})}saveScreenShotToRemote(){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.LOCAL_SCREENSHOT}),!0)}getRotateType(){return this.rotateType}setGPS(e,t){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.SDK_LOCATION,content:JSON.stringify({latitude:t,longitude:e,time:(new Date).getTime()})}),!0)}setKeyboardStyle(e){this.options.keyboard=e,this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.KEYBOARD_TYPE,isLocalKeyBoard:e===exports.KeyboardMode.LOCAL}))}setAutoRecycleTime(e){}getAutoRecycleTime(){}sendCommand(e){const t={back:4,home:3,menu:187}[e]??e,n={action:1,touchType:x4.KEYSTROKE,keyCode:t,text:""};this.sendUserMessage(JSON.stringify(n))}triggerKeyboardShortcut(e,t,n=!0){const r=JSON.stringify({touchType:D4.SHORTCUT_KEY,metaState:e+"",keyCode:t+""});this.options.clientId,this.sendUserMessage(r,n)}injectVideoStream(e,t,n=0){return new Promise((async r=>{let i=null;n&&(i=setTimeout((()=>{r({type:e,status:"timeout",result:null})}),n));try{Object.assign(this.promiseMap.injectStatus,{resolve:e=>{i&&clearTimeout(i),r(e)}});const n=this.getMsgTemplate(x4.EVENT_SDK,e===D4.START_INJECTION_VIDEO?{type:e,fileUrl:t?.fileUrl,isLoop:t?.isLoop??!0,fileName:t?.fileName}:{type:e});this.sendUserMessage(n,!0)}catch{r({type:e,status:"unknown",result:null})}}))}increaseVolume(){this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_UP,down:!0}),this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_UP,down:!1})}decreaseVolume(){this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_DOWN,down:!0}),this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_DOWN,down:!1})}saveCloudClipboard(e){this.options.saveCloudClipboard=e}}exports.ArmcloudEngine=class{constructor(e){this.version="1.5.3-beta.5",this.rtcInstance=null,this.rtcOptions=null,this.callbacks=null,this.streamType=null,this.axiosSource=null,this.axiosSource=_n.CancelToken.source(),this.setupInitConfig(e),this.setupCallbacks(e);const t=[];if(e.token||t.push("token"),e.deviceInfo||t.push("deviceInfo"),e.deviceInfo&&(e.deviceInfo.padCode||t.push("deviceInfo.padCode"),e.deviceInfo.userId||t.push("deviceInfo.userId")),e.viewId||t.push("viewId"),e.callbacks||t.push("callbacks"),t.length>0){const e=`初始化参数缺失,请检查参数: ${t.join(", ")}`;throw new Error(e)}if(!/^[a-zA-Z0-9_\-@]{1,128}$/.test(this.rtcOptions?.userId||""))throw new Error('deviceInfo.userId 格式不正确,允许数字、字母、"_"、"-" 、"@",长度为1~128个字符');if(!this.rtcOptions?.baseUrl)throw new Error("baseUrl 不能为空");let n=this.rtcOptions?.uuid||"";n||(n=localStorage.getItem("armcloud_uuid")||this.generateUUID(),localStorage.setItem("armcloud_uuid",n||""));const r=`${e.baseUrl}/rtc/open/room/applyToken`,i={sdkTerminal:"h5",userId:this.rtcOptions.userId,padCode:this.rtcOptions.padCode,uuid:n,expire:86400,videoStream:this.rtcOptions.videoStream};_n.post(r,i,{headers:{"Content-Type":"application/json",token:this.rtcOptions.token},cancelToken:this.axiosSource.token}).then((t=>{200===t.data.code?(this.streamType=t.data.data.streamType,this.rtcOptions.streamType=this.streamType,1==this.streamType?(this.rtcOptions.uuid=n,this.rtcOptions.appId=t.data.data.appId,this.rtcOptions.roomCode=t.data.data.roomCode,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcInstance=new $4(e.viewId,this.rtcOptions,this.callbacks),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n})):2==this.streamType?(this.rtcOptions.uuid=n,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcOptions.signalServer=t.data.data.signalServer,this.rtcOptions.stuns=t.data.data.stuns,this.rtcOptions.turns=t.data.data.turns,this.rtcInstance=new f8(e.viewId,this.rtcOptions,this.callbacks),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n})):3==this.streamType&&(this.rtcOptions.accessInfo=t.data.data.accessInfo,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcInstance=new M8(e.viewId,this.rtcOptions,this.callbacks),console.log(t.data.data),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n}))):this.callbacks?.onInit?.({code:t?.data?.code||V6,msg:t?.data?.msg,streamType:this.streamType||void 0,uuid:n||""})})).catch((e=>{_n.isCancel(e)||(console.error("获取初始化配置失败:",e),this.callbacks?.onInit?.({code:V6,msg:e.message||e.name,uuid:n||""}))}))}static isSupported(){if(!window.RTCPeerConnection)return!1;try{const e=new RTCPeerConnection;return e.createDataChannel("test"),e.close(),!0}catch(e){return!1}}triggerKeyboardShortcut(e,t,n){this.rtcInstance?.triggerKeyboardShortcut?.(e,t,n)}setupInitConfig(e){this.rtcOptions={appId:"",roomCode:"",roomToken:"",signalServer:"",stuns:"",turns:"",token:e.token,uuid:e.uuid||"",clientId:e.deviceInfo.padCode,padCode:e.deviceInfo.padCode,userId:e.deviceInfo.userId,retryCount:e.retryCount??2,retryTime:e.retryTime??2e3,isLog:e.isLog??!0,disable:e.disable??!1,enableMicrophone:e.enableMicrophone??!0,enableCamera:e.enableCamera??!0,baseUrl:e.baseUrl,isWsProxy:!!e.isWsProxy&&JSON.parse(e.isWsProxy),manageToken:e.manageToken??"",masterIdPrefix:e.masterIdPrefix??"",videoStream:{resolution:e?.deviceInfo?.videoStream?.resolution??12,frameRate:e?.deviceInfo?.videoStream?.frameRate??2,bitrate:e?.deviceInfo?.videoStream?.bitrate??3},disableLocalIME:e.deviceInfo.disableLocalIME??!1,allowLocalIMEInCloud:e.deviceInfo.allowLocalIMEInCloud??!1,autoRecoveryTime:e.deviceInfo.autoRecoveryTime??300,mediaType:e.deviceInfo.mediaType??2,rotateType:e.deviceInfo.rotateType,keyboard:e.deviceInfo.keyboard??exports.KeyboardMode.PAD,disableContextMenu:e.deviceInfo.disableContextMenu??!1,saveCloudClipboard:e.deviceInfo.saveCloudClipboard??!0,videoDeviceId:e.deviceInfo.videoDeviceId,audioDeviceId:e.deviceInfo.audioDeviceId}}setupCallbacks(e){this.callbacks={onInit:e.callbacks?.onInit||(()=>{}),onConnectSuccess:e.callbacks?.onConnectSuccess||(()=>{}),onConnectFail:e.callbacks?.onConnectFail||(()=>{}),onAutoRecoveryTime:e.callbacks?.onAutoRecoveryTime||(()=>{}),onAutoplayFailed:e.callbacks?.onAutoplayFailed||(()=>{}),onRunInformation:e.callbacks?.onRunInformation||(()=>{}),onChangeResolution:e.callbacks?.onChangeResolution||(()=>{}),onChangeRotate:e.callbacks?.onChangeRotate||(()=>{}),onTransparentMsg:e.callbacks?.onTransparentMsg||(()=>{}),onConnectionStateChanged:e.callbacks?.onConnectionStateChanged||(()=>{}),onErrorMessage:e.callbacks?.onErrorMessage||(()=>{}),onOutputClipper:e.callbacks?.onOutputClipper||(()=>{}),onBeforeRotate:e.callbacks?.onBeforeRotate||(()=>{}),onRenderedFirstFrame:e.callbacks?.onRenderedFirstFrame||(()=>{}),onVideoInit:e.callbacks?.onVideoInit||(()=>{}),onVideoError:e.callbacks?.onVideoError||(()=>{}),onAudioInit:e.callbacks?.onAudioInit||(()=>{}),onAudioError:e.callbacks?.onAudioError||(()=>{}),onProgress:e.callbacks?.onProgress||(()=>{}),onSocketCallback:e.callbacks?.onSocketCallback||(()=>{}),onUserJoined:e.callbacks?.onUserJoined||(()=>{}),onUserLeave:e.callbacks?.onUserLeave||(()=>{}),onUserLeaveOrJoin:e.callbacks?.onUserLeaveOrJoin||(()=>{}),onGroupControlError:e.callbacks?.onGroupControlError||(()=>{}),onEquipmentInfo:e.callbacks?.onEquipmentInfo||(()=>{}),onSendUserError:e.callbacks?.onSendUserError||(()=>{}),onAdbOutput:e.callbacks?.onAdbOutput||(()=>{}),onNetworkQuality:e.callbacks?.onNetworkQuality||(()=>{}),onInjectVideoResult:e.callbacks?.onInjectVideoResult||(()=>{}),onMediaDevicesToggle:e.callbacks?.onMediaDevicesToggle||(()=>{}),onMonitorOperation:e.callbacks?.onMonitorOperation||(()=>{})}}setMonitorOperation(e,t){this.rtcInstance&&this.rtcInstance.setMonitorOperation(e,t)}getInjectStreamStatus(e,t){if(this.rtcInstance)return this.rtcInstance.getInjectStreamStatus(e,t)}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}getRequestId(){return this.rtcInstance?.getRequestId()}triggerClickEvent(e,t){this.rtcInstance&&this.rtcInstance.triggerClickEvent(e,t)}triggerPointerEvent(e,t,n){this.rtcInstance&&this.rtcInstance.triggerPointerEvent(e,t,n)}setMicrophone(e){this.rtcInstance&&this.rtcInstance.setMicrophone(e)}setCamera(e){this.rtcInstance&&this.rtcInstance.setCamera(e)}startPlay(){this.rtcInstance&&this.rtcInstance.startPlay()}setViewSize(e,t,n=0){this.rtcInstance&&this.rtcInstance.setViewSize(e,t,n)}start(e=!1,t=[]){this.rtcInstance&&this.rtcInstance.start(e,t)}joinGroupRoom(e=[]){this.rtcInstance&&this.rtcInstance.joinGroupRoom(e)}kickItOutRoom(e=[]){this.rtcInstance&&this.rtcInstance.kickItOutRoom(e)}toggleGroupControlSync(e=!0){this.rtcInstance?.toggleGroupControlSync?.(e)}async stop(){return this.axiosSource?.cancel(),this.axiosSource=null,this?.rtcInstance?.stop()}muted(){this.rtcInstance&&this.rtcInstance.muted()}unmuted(){this.rtcInstance&&this.rtcInstance.unmuted()}appUnInstall(e){this.rtcInstance&&this.rtcInstance.appUnInstall(e)}getEquipmentInfo(e){this.rtcInstance&&this.rtcInstance.getEquipmentInfo(e)}setVideoDeviceId(e){this.rtcInstance&&this.rtcInstance.setVideoDeviceId(e)}setAudioDeviceId(e){this.rtcInstance&&this.rtcInstance.setAudioDeviceId(e)}sendInputClipper(e,t){this.rtcInstance&&this.rtcInstance.sendInputClipper(e,t)}sendGroupInputClipper(e,t){this.rtcInstance&&this.rtcInstance.sendGroupInputClipper(e,t)}sendGroupInputString(e,t){this.rtcInstance&&this.rtcInstance.sendGroupInputString(e,t)}sendInputString(e,t){this.rtcInstance&&this.rtcInstance.sendInputString(e,t)}setStreamConfig(e,t){this.rtcInstance&&this.rtcInstance.setStreamConfig(e,t)}pauseAllSubscribedStream(e=3){if(this.rtcInstance)return this.rtcInstance.unsubscribeStream(e)}resumeAllSubscribedStream(e=3){if(this.rtcInstance)return this.rtcInstance.subscribeStream(e)}subscribeStream(e=2){return this.rtcInstance?this.rtcInstance.subscribeStream(e):Promise.reject(new Error("RTC instance does not exist and cannot subscribe to the media stream"))}unsubscribeStream(e=2){return this.rtcInstance?this.rtcInstance?.unsubscribeStream(e):Promise.reject(new Error("RTC instance does not exist and cannot unsubscribe from media stream"))}saveScreenShotToLocal(){return new Promise(((e,t)=>{if(this.rtcInstance)try{this.rtcInstance.saveScreenShotToLocal().then((t=>{e(t)}))}catch(e){t(e)}}))}setScreenResolution(e,t){this.rtcInstance&&this.rtcInstance.setScreenResolution(e,t)}saveScreenShotToRemote(){this.rtcInstance&&this.rtcInstance.saveScreenShotToRemote()}resizeScreenshot(e,t){this.rtcInstance?.resizeScreenshot(e,t)}showScreenShot(){this.rtcInstance?.showScreenShot()}hideScreenShot(){this.rtcInstance?.hideScreenShot()}setScreenshotRotation(e=0){this.rtcInstance?.setScreenshotRotation(e)}takeScreenshot(e=0){this.rtcInstance?.takeScreenshot(e)}clearScreenShot(){this.rtcInstance?.clearScreenShot()}setPhoneRotation(e){this.rtcInstance&&this.rtcInstance.setPhoneRotation(e)}setGPS(e,t){this.rtcInstance&&this.rtcInstance.setGPS(e,t)}executeAdbCommand(e,t){this.rtcInstance&&this.rtcInstance?.executeAdbCommand(e,t)}setKeyboardStyle(e){this.rtcInstance&&this.rtcInstance.setKeyboardStyle(e)}setAutoRecycleTime(e){this.rtcInstance&&this.rtcInstance.setAutoRecycleTime(e)}getAutoRecycleTime(){if(this.rtcInstance)return this.rtcInstance.getAutoRecycleTime()}sendCommand(e,t){this.rtcInstance&&this.rtcInstance.sendCommand(e,t)}increaseVolume(e){this.rtcInstance&&this.rtcInstance.increaseVolume(e)}decreaseVolume(e){this.rtcInstance&&this.rtcInstance.decreaseVolume(e)}saveCloudClipboard(e){this.rtcInstance&&this.rtcInstance.saveCloudClipboard(e)}startMediaStream(e){if(this.rtcInstance)return this.rtcInstance.startMediaStream(e)}stopMediaStream(e){if(this.rtcInstance)return this.rtcInstance.stopMediaStream(e)}injectVideoStream(e,t,n,r){if(this.rtcInstance)return this.rtcInstance.injectVideoStream(e,t,n,r)}sendShake(e){this.rtcInstance&&this.rtcInstance.sendShakeInfo(e??1500)}getRotateType(){if(this.rtcInstance)return this.rtcInstance.getRotateType()}};
22
+ var b8={206:(e,t,n)=>{e.exports=n(57)},387:(e,t,n)=>{var r=n(485),i=n(570),o=n(940),s=n(581),a=n(574),c=n(845),u=n(338),d=n(524),l=n(141),h=n(132);e.exports=function(e){return new Promise((function(t,n){var p,f=e.data,v=e.headers,m=e.responseType;function _(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}r.isFormData(f)&&delete v["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var y=e.auth.username||"",S=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";v.Authorization="Basic "+btoa(y+":"+S)}var b=a(e.baseURL,e.url);function k(){if(g){var r="getAllResponseHeaders"in g?c(g.getAllResponseHeaders()):null,o={data:m&&"text"!==m&&"json"!==m?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};i((function(e){t(e),_()}),(function(e){n(e),_()}),o),g=null}}if(g.open(e.method.toUpperCase(),s(b,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=k:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(k)},g.onabort=function(){g&&(n(d("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(d("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(d(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var E=(e.withCredentials||u(b))&&e.xsrfCookieName?o.read(e.xsrfCookieName):void 0;E&&(v[e.xsrfHeaderName]=E)}"setRequestHeader"in g&&r.forEach(v,(function(e,t){void 0===f&&"content-type"===t.toLowerCase()?delete v[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),m&&"json"!==m&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(e){g&&(n(!e||e&&e.type?new h("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),f||(f=null),g.send(f)}))}},57:(e,t,n)=>{var r=n(485),i=n(875),o=n(29),s=n(941),a=function e(t){var n=new o(t),a=i(o.prototype.request,n);return r.extend(a,o.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(141));a.Axios=o,a.Cancel=n(132),a.CancelToken=n(603),a.isCancel=n(475),a.VERSION=n(345).version,a.all=function(e){return Promise.all(e)},a.spread=n(739),a.isAxiosError=n(835),e.exports=a,e.exports.default=a},132:e=>{function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},603:(e,t,n)=>{var r=n(132);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},475:e=>{e.exports=function(e){return!(!e||!e.__CANCEL__)}},29:(e,t,n)=>{var r=n(485),i=n(581),o=n(96),s=n(9),a=n(941),c=n(144),u=c.validators;function d(e){this.defaults=e,this.interceptors={request:new o,response:new o}}d.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!r){var d=[s,void 0];for(Array.prototype.unshift.apply(d,n),d=d.concat(o),i=Promise.resolve(e);d.length;)i=i.then(d.shift(),d.shift());return i}for(var l=e;n.length;){var h=n.shift(),p=n.shift();try{l=h(l)}catch(e){p(e);break}}try{i=s(l)}catch(e){return Promise.reject(e)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},d.prototype.getUri=function(e){return e=a(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){d.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){d.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=d},96:(e,t,n)=>{var r=n(485);function i(){this.handlers=[]}i.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},574:(e,t,n)=>{var r=n(642),i=n(288);e.exports=function(e,t){return e&&!r(t)?i(e,t):t}},524:(e,t,n)=>{var r=n(953);e.exports=function(e,t,n,i,o){var s=new Error(e);return r(s,t,n,i,o)}},9:(e,t,n)=>{var r=n(485),i=n(212),o=n(475),s=n(141),a=n(132);function c(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(e){return c(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return c(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(c(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},953:e=>{e.exports=function(e,t,n,r,i){return e.config=t,n&&(e.code=n),e.request=r,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},941:(e,t,n)=>{var r=n(485);e.exports=function(e,t){t=t||{};var n={};function i(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function o(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:i(void 0,e[n]):i(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return i(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:i(void 0,e[n]):i(void 0,t[n])}function c(n){return n in t?i(e[n],t[n]):n in e?i(void 0,e[n]):void 0}var u={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,i=t(e);r.isUndefined(i)&&t!==c||(n[e]=i)})),n}},570:(e,t,n)=>{var r=n(524);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},212:(e,t,n)=>{var r=n(485),i=n(141);e.exports=function(e,t,n){var o=this||i;return r.forEach(n,(function(n){e=n.call(o,e,t)})),e}},141:(e,t,n)=>{var r=n(485),i=n(446),o=n(953),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(c=n(387)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e){if(r.isString(e))try{return(0,JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||u.transitional,n=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||i&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw o(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){u.headers[e]=r.merge(s)})),e.exports=u},345:e=>{e.exports={version:"0.24.0"}},875:e=>{e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},581:(e,t,n)=>{var r=n(485);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o;if(n)o=n(t);else if(r.isURLSearchParams(t))o=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(i(t)+"="+i(e))})))})),o=s.join("&")}if(o){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}},288:e=>{e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},940:(e,t,n)=>{var r=n(485);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,i,o,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(i)&&a.push("path="+i),r.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},642:e=>{e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},835:e=>{e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},338:(e,t,n)=>{var r=n(485);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=r.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},446:(e,t,n)=>{var r=n(485);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},845:(e,t,n)=>{var r=n(485),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,o,s={};return e?(r.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=r.trim(e.substr(0,o)).toLowerCase(),n=r.trim(e.substr(o+1)),t){if(s[t]&&i.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},739:e=>{e.exports=function(e){return function(t){return e.apply(null,t)}}},144:(e,t,n)=>{var r=n(345).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var o={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(i(r," has been removed"+(t?" in "+t:"")));return t&&!o[r]&&(o[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),i=r.length;i-- >0;){var o=r[i],s=t[o];if(s){var a=e[o],c=void 0===a||s(a,o,e);if(!0!==c)throw new TypeError("option "+o+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+o)}},validators:i}},485:(e,t,n)=>{var r=n(875),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===i.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),o(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:c,isUndefined:s,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:u,isStream:function(e){return a(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:d,merge:function e(){var t={};function n(n,r){c(t[r])&&c(n)?t[r]=e(t[r],n):c(n)?t[r]=e({},n):o(n)?t[r]=n.slice():t[r]=n}for(var r=0,i=arguments.length;r<i;r++)d(arguments[r],n);return t},extend:function(e,t,n){return d(t,(function(t,i){e[i]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},943:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},677:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var i=e[r]<<16|e[r+1]<<8|e[r+2],o=0;o<4;o++)8*r+6*o<=8*e.length?n.push(t.charAt(i>>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r<e.length;i=++r%4)0!=i&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*i+8)-1)<<2*i|t.indexOf(e.charAt(r))>>>6-2*i);return n}},e.exports=n},112:function(e,t,n){var r;e.exports=(r=r||function(e){var t;if("undefined"!=typeof window&&window.crypto&&(t=window.crypto),"undefined"!=typeof self&&self.crypto&&(t=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(t=globalThis.crypto),!t&&"undefined"!=typeof window&&window.msCrypto&&(t=window.msCrypto),!t&&void 0!==n.g&&n.g.crypto&&(t=n.g.crypto),!t)try{t=n(429)}catch(e){}var r=function(){if(t){if("function"==typeof t.getRandomValues)try{return t.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof t.randomBytes)try{return t.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),o={},s=o.lib={},a=s.Base={extend:function(e){var t=i(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(var a=0;a<i;a+=4)t[r+a>>>2]=n[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new c.init(t,e)}}),u=o.enc={},d=u.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new c.init(n,t/2)}},l=u.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new c.init(n,t)}},h=u.Utf8={stringify:function(e){try{return decodeURIComponent(escape(l.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return l.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,o=r.sigBytes,s=this.blockSize,a=o/(4*s),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*u,o);if(u){for(var l=0;l<u;l+=s)this._doProcessBlock(i,l);n=i.splice(0,u),r.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),f=(s.Hasher=p.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new f.HMAC.init(e,n).finalize(t)}}}),o.algo={});return o}(Math),r)},652:function(e,t,n){var r;e.exports=(r=n(112),n(232),n(456),r.HmacSHA256)},456:function(e,t,n){var r,i,o;e.exports=(i=(r=n(112)).lib.Base,o=r.enc.Utf8,void(r.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),s=this._iKey=t.clone(),a=i.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;i.sigBytes=s.sigBytes=r,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))},232:function(e,t,n){var r;e.exports=(r=n(112),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,s=t.algo,a=[],c=[];!function(){function t(t){for(var n=e.sqrt(t),r=2;r<=n;r++)if(!(t%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,i=0;i<64;)t(r)&&(i<8&&(a[i]=n(e.pow(r,.5))),c[i]=n(e.pow(r,1/3)),i++),r++}();var u=[],d=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],d=n[5],l=n[6],h=n[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var f=u[p-15],v=(f<<25|f>>>7)^(f<<14|f>>>18)^f>>>3,m=u[p-2],_=(m<<15|m>>>17)^(m<<13|m>>>19)^m>>>10;u[p]=v+u[p-7]+_+u[p-16]}var g=r&i^r&o^i&o,y=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),S=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&d^~a&l)+c[p]+u[p];h=l,l=d,d=a,a=s+S|0,s=o,o=i,i=r,r=S+(y+g)|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0,n[5]=n[5]+d|0,n[6]=n[6]+l|0,n[7]=n[7]+h|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=e.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,t.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=o._createHelper(d),t.HmacSHA256=o._createHmacHelper(d)}(Math),r.SHA256)},408:function(e){var t;t=()=>(()=>{var e={944:function(e){e.exports=(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=o(e))||t){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(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){c=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw s}}}}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,i,o=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw i}}return o}}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}e.d(t,{default:()=>a});var a=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.allowExtra=t,this.defaults=new Map,this.types=new Map,this.optional=new Set,this.required=new Set}var t;return(t=[{key:"setDefaults",value:function(e){var t=this;return Object.entries(e).forEach((function(e){var n=i(e,2),r=n[0],o=n[1];return t.defaults.set(r,o)})),this}},{key:"setTypes",value:function(e){var t=this;return Object.entries(e).forEach((function(e){var n=i(e,2),r=n[0],o=n[1];return t.types.set(r,o)})),this}},{key:"setOptional",value:function(e){var t=this;return e.forEach((function(e){return t.optional.add(e)})),this}},{key:"setRequired",value:function(e){var t=this;return e.forEach((function(e){return t.required.add(e)})),this}},{key:"resolve",value:function(e){var t=Object.assign(this.getDefaults(),e);return this.validate(t),t}},{key:"getDefaults",value:function(){var e,t={},n=r(this.defaults);try{for(n.s();!(e=n.n()).done;){var o=i(e.value,2),s=o[0],a=o[1];t[s]=a}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"validate",value:function(e){for(var t in e){if(!this.optionExists(t))throw new Error('Unkown option "'.concat(t,'".'));this.checkType(t,e[t])}var n,i=r(this.required.values());try{for(i.s();!(n=i.n()).done;){var o=n.value;if(void 0===e[o])throw new Error('Option "'.concat(o,'" is required.'))}}catch(e){i.e(e)}finally{i.f()}}},{key:"checkType",value:function(e,t){if(this.types.has(e)){var r=this.types.get(e),i=n(t);if(i!==r)throw new Error('Wrong value for option "'.concat(e,'". Expected type "').concat(r,'" but got "').concat(i,'".'))}}},{key:"optionExists",value:function(e){return!!this.allowExtra||this.defaults.has(e)||this.optional.has(e)||this.required.has(e)||this.types.has(e)}}])&&function(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)}}(e.prototype,t),e}();return t.default})()},162:function(e){e.exports=(()=>{var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>n});var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._events={},this.on=this.addEventListener,this.off=this.removeEventListener}var t;return(t=[{key:"emit",value:function(e,t){if(Object.prototype.hasOwnProperty.call(this._events,e))for(var n=this._events[e],r={type:e,detail:t},i=n.length,o=0;o<i;o++)this.handle(n[o],r)}},{key:"handle",value:function(e,t){e(t)}},{key:"addEventListener",value:function(e,t){Object.prototype.hasOwnProperty.call(this._events,e)||(this._events[e]=[]),this._events[e].indexOf(t)<0&&this._events[e].push(t)}},{key:"removeEventListener",value:function(e,t){if(Object.prototype.hasOwnProperty.call(this._events,e)){var n=this._events[e],r=n.indexOf(t);r>=0&&n.splice(r,1),0===n.length&&delete this._events[e]}}}])&&function(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)}}(e.prototype,t),e}();return t.default})()}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{GamepadHandler:()=>h,GamepadListener:()=>y});var e=n(162),t=n.n(e),i=n(944),o=n.n(i);function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function a(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,(i=function(e){if("object"!==s(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===s(i)?i:String(i)),r)}var i}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(e,t){if(t&&("object"===s(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}var h=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c(e,t)}(h,e);var t,n,r,i,o,s=(i=h,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=l(i);if(o){var n=l(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return u(this,e)});function h(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h),(n=s.call(this)).index=e,n.options=n.constructor.resolveOptions(r),n.sticks=new Array(Math.ceil(t.axes.length/2)).fill(null).map((function(){return[null,null]})),n.buttons=new Array(t.buttons.length).fill(null),n.updateStick=n.updateStick.bind(d(n)),n.updateButton=n.updateButton.bind(d(n)),n}return t=h,r=[{key:"resolveOptions",value:function(e){var t=void 0!==e.stick,n=void 0!==e.button,r={stick:this.optionResolver.resolve(t?e.stick:n?{}:e),button:this.optionResolver.resolve(n?e.button:t?{}:e)};return r.stick.deadZone=Math.max(Math.min(r.stick.deadZone,1),0),r.button.deadZone=Math.max(Math.min(r.button.deadZone,1),0),r.stick.precision=r.stick.precision?Math.pow(10,r.stick.precision):0,r.button.precision=r.button.precision?Math.pow(10,r.button.precision):0,r}}],(n=[{key:"update",value:function(e){for(var t=0,n=this.sticks.length,r=0;r<n;r++)for(var i=0;i<2;i++)this.updateStick(e,r,i,e.axes[t++]);var o=this.buttons.length;for(t=0;t<o;t++)this.updateButton(e,e.buttons[t],t)}},{key:"updateStick",value:function(e,t,n,r){var i=this.options.stick,o=i.deadZone,s=i.analog,a=i.precision;o&&r<o&&r>-o&&(r=0),s?a&&(r=Math.round(r*a)/a):r=r>0?1:r<0?-1:0,this.sticks[t][n]!==r&&(this.sticks[t][n]=r,this.emit("axis",{gamepad:e,stick:t,axis:n,value:r,index:this.index}))}},{key:"updateButton",value:function(e,t,n){var r=this.options.button,i=r.deadZone,o=r.analog,s=r.precision,a=t.value,c=t.pressed,u=a;i&&t.value<i&&t.value>-i&&(u=0),o?s&&(u=Math.round(u*s)/s):u=c?1:0,this.buttons[n]!==u&&(this.buttons[n]=u,this.emit("button",{gamepad:e,button:n,pressed:c,value:u,index:this.index}))}}])&&a(t.prototype,n),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),h}(t());function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}h.optionResolver=(new(o())).setDefaults({analog:!0,deadZone:0,precision:0}).setTypes({analog:"boolean",deadZone:"number",precision:"number"});var f=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.callback=t,this.frame=null,this.update=this.update.bind(this)}var t,n;return t=e,(n=[{key:"setCallback",value:function(e){this.callback=e}},{key:"start",value:function(){this.frame||(this.frame=window.requestAnimationFrame(this.update))}},{key:"stop",value:function(){this.frame&&(window.cancelAnimationFrame(this.frame),this.frame=null)}},{key:"update",value:function(){this.frame=window.requestAnimationFrame(this.update),this.callback()}}])&&function(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,(i=function(e){if("object"!==p(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===p(i)?i:String(i)),r)}var i}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}var y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}(s,e);var t,n,r,i,o=(r=s,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=g(r);if(i){var n=g(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===v(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _(e)}(this,e)});function s(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),e=o.call(this),"function"!=typeof navigator.getGamepads)throw new Error("This browser does not support gamepad API.");return e.options=t,e.onAxis=e.onAxis.bind(_(e)),e.update=e.update.bind(_(e)),e.start=e.start.bind(_(e)),e.stop=e.stop.bind(_(e)),e.discover=e.discover.bind(_(e)),e.onButton=e.onButton.bind(_(e)),e.handlers=new Array(4).fill(null),e.loop=new f(e.update),window.addEventListener("error",e.stop),e}return t=s,(n=[{key:"start",value:function(){this.loop.start()}},{key:"stop",value:function(){this.loop.stop()}},{key:"update",value:function(){var e=navigator.getGamepads();this.discover(e[0],0),this.discover(e[1],1),this.discover(e[2],2),this.discover(e[3],3)}},{key:"discover",value:function(e,t){e?(this.handlers[t]||this.registerHandler(t,e),this.handlers[t].update(e)):this.handlers[t]&&this.removeGamepad(t)}},{key:"registerHandler",value:function(e,t){if(this.handlers[e])throw new Error("Gamepad #".concat(e," is already registered."));var n=new h(e,t,this.options);this.handlers[e]=n,n.addEventListener("axis",this.onAxis),n.addEventListener("button",this.onButton),this.emit("gamepad:connected",{index:e,gamepad:t}),this.emit("gamepad:".concat(e,":connected"),{index:e,gamepad:t})}},{key:"removeGamepad",value:function(e){if(!this.handlers[e])throw new Error("Gamepad #".concat(e," is not registered."));this.handlers[e].removeEventListener("axis",this.onAxis),this.handlers[e].removeEventListener("button",this.onButton),this.handlers[e]=null,this.emit("gamepad:disconnected",{index:e}),this.emit("gamepad:".concat(e,":disconnected"),{index:e})}},{key:"onAxis",value:function(e){var t=e.detail.index;this.emit("gamepad:axis",e.detail),this.emit("gamepad:".concat(t,":axis"),e.detail),this.emit("gamepad:".concat(t,":axis:").concat(e.detail.axis),e.detail)}},{key:"onButton",value:function(e){var t=e.detail.index;this.emit("gamepad:button",e.detail),this.emit("gamepad:".concat(t,":button"),e.detail),this.emit("gamepad:".concat(t,":button:").concat(e.detail.button),e.detail)}}])&&function(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,(i=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!==v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(r.key),"symbol"===v(i)?i:String(i)),r)}var i}(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),s}(t())})(),r})(),e.exports=t()},809:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},586:(e,t,n)=>{var r,i,o,s,a;r=n(677),i=n(943).utf8,o=n(809),s=n(943).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,u=1732584193,d=-271733879,l=-1732584194,h=271733878,p=0;p<n.length;p++)n[p]=16711935&(n[p]<<8|n[p]>>>24)|4278255360&(n[p]<<24|n[p]>>>8);n[c>>>5]|=128<<c%32,n[14+(c+64>>>9<<4)]=c;var f=a._ff,v=a._gg,m=a._hh,_=a._ii;for(p=0;p<n.length;p+=16){var g=u,y=d,S=l,b=h;u=f(u,d,l,h,n[p+0],7,-680876936),h=f(h,u,d,l,n[p+1],12,-389564586),l=f(l,h,u,d,n[p+2],17,606105819),d=f(d,l,h,u,n[p+3],22,-1044525330),u=f(u,d,l,h,n[p+4],7,-176418897),h=f(h,u,d,l,n[p+5],12,1200080426),l=f(l,h,u,d,n[p+6],17,-1473231341),d=f(d,l,h,u,n[p+7],22,-45705983),u=f(u,d,l,h,n[p+8],7,1770035416),h=f(h,u,d,l,n[p+9],12,-1958414417),l=f(l,h,u,d,n[p+10],17,-42063),d=f(d,l,h,u,n[p+11],22,-1990404162),u=f(u,d,l,h,n[p+12],7,1804603682),h=f(h,u,d,l,n[p+13],12,-40341101),l=f(l,h,u,d,n[p+14],17,-1502002290),u=v(u,d=f(d,l,h,u,n[p+15],22,1236535329),l,h,n[p+1],5,-165796510),h=v(h,u,d,l,n[p+6],9,-1069501632),l=v(l,h,u,d,n[p+11],14,643717713),d=v(d,l,h,u,n[p+0],20,-373897302),u=v(u,d,l,h,n[p+5],5,-701558691),h=v(h,u,d,l,n[p+10],9,38016083),l=v(l,h,u,d,n[p+15],14,-660478335),d=v(d,l,h,u,n[p+4],20,-405537848),u=v(u,d,l,h,n[p+9],5,568446438),h=v(h,u,d,l,n[p+14],9,-1019803690),l=v(l,h,u,d,n[p+3],14,-187363961),d=v(d,l,h,u,n[p+8],20,1163531501),u=v(u,d,l,h,n[p+13],5,-1444681467),h=v(h,u,d,l,n[p+2],9,-51403784),l=v(l,h,u,d,n[p+7],14,1735328473),u=m(u,d=v(d,l,h,u,n[p+12],20,-1926607734),l,h,n[p+5],4,-378558),h=m(h,u,d,l,n[p+8],11,-2022574463),l=m(l,h,u,d,n[p+11],16,1839030562),d=m(d,l,h,u,n[p+14],23,-35309556),u=m(u,d,l,h,n[p+1],4,-1530992060),h=m(h,u,d,l,n[p+4],11,1272893353),l=m(l,h,u,d,n[p+7],16,-155497632),d=m(d,l,h,u,n[p+10],23,-1094730640),u=m(u,d,l,h,n[p+13],4,681279174),h=m(h,u,d,l,n[p+0],11,-358537222),l=m(l,h,u,d,n[p+3],16,-722521979),d=m(d,l,h,u,n[p+6],23,76029189),u=m(u,d,l,h,n[p+9],4,-640364487),h=m(h,u,d,l,n[p+12],11,-421815835),l=m(l,h,u,d,n[p+15],16,530742520),u=_(u,d=m(d,l,h,u,n[p+2],23,-995338651),l,h,n[p+0],6,-198630844),h=_(h,u,d,l,n[p+7],10,1126891415),l=_(l,h,u,d,n[p+14],15,-1416354905),d=_(d,l,h,u,n[p+5],21,-57434055),u=_(u,d,l,h,n[p+12],6,1700485571),h=_(h,u,d,l,n[p+3],10,-1894986606),l=_(l,h,u,d,n[p+10],15,-1051523),d=_(d,l,h,u,n[p+1],21,-2054922799),u=_(u,d,l,h,n[p+8],6,1873313359),h=_(h,u,d,l,n[p+15],10,-30611744),l=_(l,h,u,d,n[p+6],15,-1560198380),d=_(d,l,h,u,n[p+13],21,1309151649),u=_(u,d,l,h,n[p+4],6,-145523070),h=_(h,u,d,l,n[p+11],10,-1120210379),l=_(l,h,u,d,n[p+2],15,718787259),d=_(d,l,h,u,n[p+9],21,-343485551),u=u+g>>>0,d=d+y>>>0,l=l+S>>>0,h=h+b>>>0}return r.endian([u,d,l,h])})._ff=function(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._gg=function(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._hh=function(e,t,n,r,i,o,s){var a=e+(t^n^r)+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._ii=function(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+(i>>>0)+s;return(a<<o|a>>>32-o)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(a(e,t));return t&&t.asBytes?n:t&&t.asString?s.bytesToString(n):r.bytesToHex(n)}},23:function(e,t,n){var r;e=n.nmd(e),function(){var i={function:!0,object:!0},o=i[typeof window]&&window||this,s=i[typeof t]&&t,a=e&&!e.nodeType&&e,c=s&&a&&"object"==typeof n.g&&n.g;!c||c.global!==c&&c.window!==c&&c.self!==c||(o=c);var u=Math.pow(2,53)-1,d=/\bOpera/,l=Object.prototype,h=l.hasOwnProperty,p=l.toString;function f(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function v(e){return e=S(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function m(e,t){for(var n in e)h.call(e,n)&&t(e[n],n,e)}function _(e){return null==e?f(e):p.call(e).slice(8,-1)}function g(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function y(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=u)for(;++n<r;)t(e[n],n);else m(e,t)}(e,(function(r,i){n=t(n,r,i,e)})),n}function S(e){return String(e).replace(/^ +| +$/g,"")}var b=function e(t){var n=o,r=t&&"object"==typeof t&&"String"!=_(t);r&&(n=t,t=null);var i=n.navigator||{},s=i.userAgent||"";t||(t=s);var a,c,u,l,h=r?!!i.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(p.toString()),f="Object",b=r?f:"ScriptBridgingProxyObject",k=r?f:"Environment",E=r&&n.java?"JavaPackage":_(n.java),T=r?f:"RuntimeObject",C=/\bJava/.test(E)&&n.java,I=C&&_(n.environment)==k,w=C?"a":"α",R=C?"b":"β",A=n.document||{},O=n.operamini||n.opera,x=d.test(x=r&&O?O["[[Class]]"]:_(O))?x:O=null,P=t,D=[],M=null,N=t==s,L=N&&O&&"function"==typeof O.version&&O.version(),U=y([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||g(n))+"\\b","i").exec(t)&&(n.label||n)})),V=y(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"],(function(e,n){return e||RegExp("\\b"+(n.pattern||g(n))+"\\b","i").exec(t)&&(n.label||n)})),F=G([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),B=y({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}},(function(e,n,r){return e||(n[F]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(F)]||RegExp("\\b"+g(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r})),j=y(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "],(function(e,n){var r=n.pattern||g(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),v(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}));function G(e){return y(e,(function(e,n){var r=n.pattern||g(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=v(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function H(e){return y(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(U&&(U=[U]),/\bAndroid\b/.test(j)&&!F&&(a=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(F=S(a[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),B&&!F?F=G([B]):B&&F&&(F=F.replace(RegExp("^("+g(B)+")[-_.\\s]","i"),B+" ").replace(RegExp("^("+g(B)+")[-_.]?(\\w)","i"),B+" $2")),(a=/\bGoogle TV\b/.exec(F))&&(F=a[0]),/\bSimulator\b/i.test(t)&&(F=(F?F+" ":"")+"Simulator"),"Opera Mini"==V&&/\bOPiOS\b/.test(t)&&D.push("running in Turbo/Uncompressed mode"),"IE"==V&&/\blike iPhone OS\b/.test(t)?(B=(a=e(t.replace(/like iPhone OS/,""))).manufacturer,F=a.product):/^iP/.test(F)?(V||(V="Safari"),j="iOS"+((a=/ OS ([\d_]+)/i.exec(t))?" "+a[1].replace(/_/g,"."):"")):"Konqueror"==V&&/^Linux\b/i.test(j)?j="Kubuntu":B&&"Google"!=B&&(/Chrome/.test(V)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(F))||/\bAndroid\b/.test(j)&&/^Chrome/.test(V)&&/\bVersion\//i.test(t)?(V="Android Browser",j=/\bAndroid\b/.test(j)?j:"Android"):"Silk"==V?(/\bMobi/i.test(t)||(j="Android",D.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&D.unshift("accelerated")):"UC Browser"==V&&/\bUCWEB\b/.test(t)?D.push("speed mode"):"PaleMoon"==V&&(a=/\bFirefox\/([\d.]+)\b/.exec(t))?D.push("identifying as Firefox "+a[1]):"Firefox"==V&&(a=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(j||(j="Firefox OS"),F||(F=a[1])):!V||(a=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(V))?(V&&!F&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(a+"/")+8))&&(V=null),(a=F||B||j)&&(F||B||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(j))&&(V=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(j)?j:a)+" Browser")):"Electron"==V&&(a=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&D.push("Chromium "+a),L||(L=H(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",g(V),"(?:Firefox|Minefield|NetFront)"])),(a=("iCab"==U&&parseFloat(L)>3?"WebKit":/\bOpera\b/.test(V)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(U)&&"WebKit"||!U&&/\bMSIE\b/i.test(t)&&("Mac OS"==j?"Tasman":"Trident")||"WebKit"==U&&/\bPlayStation\b(?! Vita\b)/i.test(V)&&"NetFront")&&(U=[a]),"IE"==V&&(a=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(V+=" Mobile",j="Windows Phone "+(/\+$/.test(a)?a:a+".x"),D.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(V="IE Mobile",j="Windows Phone 8.x",D.unshift("desktop mode"),L||(L=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=V&&"Trident"==U&&(a=/\brv:([\d.]+)/.exec(t))&&(V&&D.push("identifying as "+V+(L?" "+L:"")),V="IE",L=a[1]),N){if(l=null!=(u=n)?typeof u.global:"number",/^(?:boolean|number|string|undefined)$/.test(l)||"object"==l&&!u.global)_(a=n.runtime)==b?(V="Adobe AIR",j=a.flash.system.Capabilities.os):_(a=n.phantom)==T?(V="PhantomJS",L=(a=a.version||null)&&a.major+"."+a.minor+"."+a.patch):"number"==typeof A.documentMode&&(a=/\bTrident\/(\d+)/i.exec(t))?(L=[L,A.documentMode],(a=+a[1]+4)!=L[1]&&(D.push("IE "+L[1]+" mode"),U&&(U[1]=""),L[1]=a),L="IE"==V?String(L[1].toFixed(1)):L[0]):"number"==typeof A.documentMode&&/^(?:Chrome|Firefox)\b/.test(V)&&(D.push("masking as "+V+" "+L),V="IE",L="11.0",U=["Trident"],j="Windows");else if(C&&(P=(a=C.lang.System).getProperty("os.arch"),j=j||a.getProperty("os.name")+" "+a.getProperty("os.version")),I){try{L=n.require("ringo/engine").version.join("."),V="RingoJS"}catch(e){(a=n.system)&&a.global.system==n.system&&(V="Narwhal",j||(j=a[0].os||null))}V||(V="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(a=n.process)&&("object"==typeof a.versions&&("string"==typeof a.versions.electron?(D.push("Node "+a.versions.node),V="Electron",L=a.versions.electron):"string"==typeof a.versions.nw&&(D.push("Chromium "+L,"Node "+a.versions.node),V="NW.js",L=a.versions.nw)),V||(V="Node.js",P=a.arch,j=a.platform,L=(L=/[\d.]+/.exec(a.version))?L[0]:null));j=j&&v(j)}if(L&&(a=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(L)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(N&&i.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(M=/b/i.test(a)?"beta":"alpha",L=L.replace(RegExp(a+"\\+?$"),"")+("beta"==M?R:w)+(/\d+\+?/.exec(a)||"")),"Fennec"==V||"Firefox"==V&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(j))V="Firefox Mobile";else if("Maxthon"==V&&L)L=L.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(F))"Xbox 360"==F&&(j=null),"Xbox 360"==F&&/\bIEMobile\b/.test(t)&&D.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(V)&&(!V||F||/Browser|Mobi/.test(V))||"Windows CE"!=j&&!/Mobi/i.test(t))if("IE"==V&&N)try{null===n.external&&D.unshift("platform preview")}catch(e){D.unshift("embedded")}else(/\bBlackBerry\b/.test(F)||/\bBB10\b/.test(t))&&(a=(RegExp(F.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||L)?(j=((a=[a,/BB10/.test(t)])[1]?(F=null,B="BlackBerry"):"Device Software")+" "+a[0],L=null):this!=m&&"Wii"!=F&&(N&&O||/Opera/.test(V)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==V&&/\bOS X (?:\d+\.){2,}/.test(j)||"IE"==V&&(j&&!/^Win/.test(j)&&L>5.5||/\bWindows XP\b/.test(j)&&L>8||8==L&&!/\bTrident\b/.test(t)))&&!d.test(a=e.call(m,t.replace(d,"")+";"))&&a.name&&(a="ing as "+a.name+((a=a.version)?" "+a:""),d.test(V)?(/\bIE\b/.test(a)&&"Mac OS"==j&&(j=null),a="identify"+a):(a="mask"+a,V=x?v(x.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(a)&&(j=null),N||(L=null)),U=["Presto"],D.push(a));else V+=" Mobile";(a=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(a=[parseFloat(a.replace(/\.(\d)$/,".0$1")),a],"Safari"==V&&"+"==a[1].slice(-1)?(V="WebKit Nightly",M="alpha",L=a[1].slice(0,-1)):L!=a[1]&&L!=(a[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(L=null),a[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==a[0]&&537.36==a[2]&&parseFloat(a[1])>=28&&"WebKit"==U&&(U=["Blink"]),N&&(h||a[1])?(U&&(U[1]="like Chrome"),a=a[1]||((a=a[0])<530?1:a<532?2:a<532.05?3:a<533?4:a<534.03?5:a<534.07?6:a<534.1?7:a<534.13?8:a<534.16?9:a<534.24?10:a<534.3?11:a<535.01?12:a<535.02?"13+":a<535.07?15:a<535.11?16:a<535.19?17:a<536.05?18:a<536.1?19:a<537.01?20:a<537.11?"21+":a<537.13?23:a<537.18?24:a<537.24?25:a<537.36?26:"Blink"!=U?"27":"28")):(U&&(U[1]="like Safari"),a=(a=a[0])<400?1:a<500?2:a<526?3:a<533?4:a<534?"4+":a<535?5:a<537?6:a<538?7:a<601?8:a<602?9:a<604?10:a<606?11:a<608?12:"12"),U&&(U[1]+=" "+(a+="number"==typeof a?".x":/[.+]/.test(a)?"":"+")),"Safari"==V&&(!L||parseInt(L)>45)?L=a:"Chrome"==V&&/\bHeadlessChrome/i.test(t)&&D.unshift("headless")),"Opera"==V&&(a=/\bzbov|zvav$/.exec(j))?(V+=" ",D.unshift("desktop mode"),"zvav"==a?(V+="Mini",L=null):V+="Mobile",j=j.replace(RegExp(" *"+a+"$"),"")):"Safari"==V&&/\bChrome\b/.exec(U&&U[1])?(D.unshift("desktop mode"),V="Chrome Mobile",L=null,/\bOS X\b/.test(j)?(B="Apple",j="iOS 4.3+"):j=null):/\bSRWare Iron\b/.test(V)&&!L&&(L=H("Chrome")),L&&0==L.indexOf(a=/[\d.]+$/.exec(j))&&t.indexOf("/"+a+"-")>-1&&(j=S(j.replace(a,""))),j&&-1!=j.indexOf(V)&&!RegExp(V+" OS").test(j)&&(j=j.replace(RegExp(" *"+g(V)+" *"),"")),U&&!/\b(?:Avant|Nook)\b/.test(V)&&(/Browser|Lunascape|Maxthon/.test(V)||"Safari"!=V&&/^iOS/.test(j)&&/\bSafari\b/.test(U[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(V)&&U[1])&&(a=U[U.length-1])&&D.push(a),D.length&&(D=["("+D.join("; ")+")"]),B&&F&&F.indexOf(B)<0&&D.push("on "+B),F&&D.push((/^on /.test(D[D.length-1])?"":"on ")+F),j&&(a=/ ([\d.+]+)$/.exec(j),c=a&&"/"==j.charAt(j.length-a[0].length-1),j={architecture:32,family:a&&!c?j.replace(a[0],""):j,version:a?a[1]:null,toString:function(){var e=this.version;return this.family+(e&&!c?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(a=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(P))&&!/\bi686\b/i.test(P)?(j&&(j.architecture=64,j.family=j.family.replace(RegExp(" *"+a),"")),V&&(/\bWOW64\b/i.test(t)||N&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(t))&&D.unshift("32-bit")):j&&/^OS X/.test(j.family)&&"Chrome"==V&&parseFloat(L)>=39&&(j.architecture=64),t||(t=null);var W={};return W.description=t,W.layout=U&&U[0],W.manufacturer=B,W.name=V,W.prerelease=M,W.product=F,W.ua=t,W.version=V&&L,W.os=j||{architecture:null,family:null,version:null,toString:function(){return"null"}},W.parse=e,W.toString=function(){return this.description||""},W.version&&D.unshift(L),W.name&&D.unshift(V),j&&V&&(j!=String(j).split(" ")[0]||j!=V.split(" ")[0]&&!F)&&D.push(F?"("+j+")":"on "+j),D.length&&(W.description=D.join(" ")),W}();o.platform=b,void 0===(r=function(){return b}.call(t,n,t,e))||(e.exports=r)}.call(this)},226:(e,t,n)=>{var r=n(347);function i(e,t,n,i,o){var s=r.writeRtpDescription(e.kind,t);if(s+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":o||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var c="msid:"+(i?i.id:"-")+" "+a+"\r\n";s+="a="+c,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),s}function o(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var o=r(e.parameters.apt,n),s=r(t.parameters.apt,i);return o&&s&&o.name.toLowerCase()===s.name.toLowerCase()};return e.codecs.forEach((function(r){for(var o=0;o<t.codecs.length;o++){var s=t.codecs[o];if(r.name.toLowerCase()===s.name.toLowerCase()&&r.clockRate===s.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&s.parameters.apt&&!i(r,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(r.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter((function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}})),n}function s(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}function a(e,t){var n=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return n||e.addRemoteCandidate(t),!n}function c(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}e.exports=function(e,t){function n(t,n){n.addTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,n,r,i){var o=new Event("track");o.track=n,o.receiver=r,o.transceiver={receiver:r},o.streams=i,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var d=function(n){var i=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){i[e]=o[e].bind(o)})),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",n=JSON.parse(JSON.stringify(n||{})),this.usingBundle="max-bundle"===n.bundlePolicy,"negotiate"===n.rtcpMuxPolicy)throw c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(n.rtcpMuxPolicy||(n.rtcpMuxPolicy="require"),n.iceTransportPolicy){case"all":case"relay":break;default:n.iceTransportPolicy="all"}switch(n.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:n.bundlePolicy="balanced"}if(n.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(n=!0,!0)})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(n.iceServers||[],t),this._iceGatherers=[],n.iceCandidatePoolSize)for(var s=n.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:n.iceServers,gatherPolicy:n.iceTransportPolicy}));else n.iceCandidatePoolSize=0;this._config=n,this.transceivers=[],this._sdpSessionId=r.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var n=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&n)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();r.iceTransport=i.iceTransport,r.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(r),r},d.prototype.addTrack=function(t,n){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var r;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(r=this.transceivers[i]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(n)&&this.localStreams.push(n),r.track=t,r.stream=n,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},d.prototype.addStream=function(e){var n=this;if(t>=15025)e.getTracks().forEach((function(t){n.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",(function(e){n.enabled=e.enabled}))})),r.getTracks().forEach((function(e){n.addTrack(e,r)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var n=this.transceivers.find((function(e){return e.rtpSender===t}));if(!n)throw c("InvalidAccessError","Sender was not created by this connection.");var r=n.stream;n.rtpSender.stop(),n.rtpSender=null,n.track=null,n.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var n=t.getSenders().find((function(t){return t.track===e}));n&&t.removeTrack(n)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,n){var r=this;if(n&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var n=!e.candidate||0===Object.keys(e.candidate).length;i.state=n?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,n){var i=this,o=this.transceivers[n].iceGatherer;if(!o.onlocalcandidate){var s=this.transceivers[n].bufferedCandidateEvents;this.transceivers[n].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[n].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&n>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:n};var a=e.candidate,c=!a||0===Object.keys(a).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),a.component=1,a.ufrag=o.getLocalParameters().usernameFragment;var u=r.writeCandidate(a);s.candidate=Object.assign(s.candidate,r.parseCandidate(u)),s.candidate.candidate=u,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var d=r.getMediaSections(i._localDescription.sdp);d[s.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=r.getDescription(i._localDescription.sdp)+d.join("");var l=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",s),l&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){s.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,n=new e.RTCIceTransport(null);n.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(n);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:n,dtlsTransport:r}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,n,i){var s=o(e.localCapabilities,e.remoteCapabilities);n&&e.rtpSender&&(s.encodings=e.sendEncodingParameters,s.rtcp={cname:r.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(s.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(s)),i&&e.rtpReceiver&&s.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?s.encodings=e.recvEncodingParameters:s.encodings=[{}],s.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(s.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(s.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(s))},d.prototype.setLocalDescription=function(e){var t,n,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!s("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=r.splitSections(e.sdp),n=t.shift(),t.forEach((function(e,t){var n=r.parseRtpParameters(e);i.transceivers[t].localCapabilities=n})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=r.splitSections(i._remoteDescription.sdp),n=t.shift();var a=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach((function(e,t){var s=i.transceivers[t],c=s.iceGatherer,u=s.iceTransport,d=s.dtlsTransport,l=s.localCapabilities,h=s.remoteCapabilities;if(!(r.isRejected(e)&&0===r.matchPrefix(e,"a=bundle-only").length||s.rejected)){var p=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);a&&(f.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===u.state&&u.start(c,p,a?"controlling":"controlled"),"new"===d.state&&d.start(f));var v=o(l,h);i._transceive(s,v.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(i){var d=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!s("setRemoteDescription",i.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+d.signalingState));var l={};d.remoteStreams.forEach((function(e){l[e.id]=e}));var h=[],p=r.splitSections(i.sdp),f=p.shift(),v=r.matchPrefix(f,"a=ice-lite").length>0,m=r.matchPrefix(f,"a=group:BUNDLE ").length>0;d.usingBundle=m;var _=r.matchPrefix(f,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,p.forEach((function(s,c){var u=r.splitLines(s),p=r.getKind(s),_=r.isRejected(s)&&0===r.matchPrefix(s,"a=bundle-only").length,g=u[0].substr(2).split(" ")[2],y=r.getDirection(s,f),S=r.parseMsid(s),b=r.getMid(s)||r.generateIdentifier();if(_||"application"===p&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))d.transceivers[c]={mid:b,kind:p,protocol:g,rejected:!0};else{var k,E,T,C,I,w,R,A,O;!_&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(p,!0));var x,P,D=r.parseRtpParameters(s);_||(x=r.getIceParameters(s,f),(P=r.getDtlsParameters(s,f)).role="client"),R=r.parseRtpEncodingParameters(s);var M=r.parseRtcpParameters(s),N=r.matchPrefix(s,"a=end-of-candidates",f).length>0,L=r.matchPrefix(s,"a=candidate:").map((function(e){return r.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!_&&m&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==i.type||_)"answer"!==i.type||_||(E=(k=d.transceivers[c]).iceGatherer,T=k.iceTransport,C=k.dtlsTransport,I=k.rtpReceiver,w=k.sendEncodingParameters,A=k.localCapabilities,d.transceivers[c].recvEncodingParameters=R,d.transceivers[c].remoteCapabilities=D,d.transceivers[c].rtcpParameters=M,L.length&&"new"===T.state&&(!v&&!N||m&&0!==c?L.forEach((function(e){a(k.iceTransport,e)})):T.setRemoteCandidates(L)),m&&0!==c||("new"===T.state&&T.start(E,x,"controlling"),"new"===C.state&&C.start(P)),!o(k.localCapabilities,k.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&k.sendEncodingParameters[0].rtx&&delete k.sendEncodingParameters[0].rtx,d._transceive(k,"sendrecv"===y||"recvonly"===y,"sendrecv"===y||"sendonly"===y),!I||"sendrecv"!==y&&"sendonly"!==y?delete k.rtpReceiver:(O=I.track,S?(l[S.stream]||(l[S.stream]=new e.MediaStream),n(O,l[S.stream]),h.push([O,I,l[S.stream]])):(l.default||(l.default=new e.MediaStream),n(O,l.default),h.push([O,I,l.default]))));else{(k=d.transceivers[c]||d._createTransceiver(p)).mid=b,k.iceGatherer||(k.iceGatherer=d._createIceGatherer(c,m)),L.length&&"new"===k.iceTransport.state&&(!N||m&&0!==c?L.forEach((function(e){a(k.iceTransport,e)})):k.iceTransport.setRemoteCandidates(L)),A=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(A.codecs=A.codecs.filter((function(e){return"rtx"!==e.name}))),w=k.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,V=!1;"sendrecv"===y||"sendonly"===y?(V=!k.rtpReceiver,I=k.rtpReceiver||new e.RTCRtpReceiver(k.dtlsTransport,p),V&&(O=I.track,S&&"-"===S.stream||(S?(l[S.stream]||(l[S.stream]=new e.MediaStream,Object.defineProperty(l[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(O,"id",{get:function(){return S.track}}),U=l[S.stream]):(l.default||(l.default=new e.MediaStream),U=l.default)),U&&(n(O,U),k.associatedRemoteMediaStreams.push(U)),h.push([O,I,U]))):k.rtpReceiver&&k.rtpReceiver.track&&(k.associatedRemoteMediaStreams.forEach((function(t){var n=t.getTracks().find((function(e){return e.id===k.rtpReceiver.track.id}));n&&function(t,n){n.removeTrack(t),n.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(n,t)})),k.associatedRemoteMediaStreams=[]),k.localCapabilities=A,k.remoteCapabilities=D,k.rtpReceiver=I,k.rtcpParameters=M,k.sendEncodingParameters=w,k.recvEncodingParameters=R,d._transceive(d.transceivers[c],!1,V)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===i.type?"active":"passive"),d._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(l).forEach((function(t){var n=l[t];if(n.getTracks().length){if(-1===d.remoteStreams.indexOf(n)){d.remoteStreams.push(n);var r=new Event("addstream");r.stream=n,e.setTimeout((function(){d._dispatchEvent("addstream",r)}))}h.forEach((function(e){var t=e[0],r=e[1];n.id===e[2].id&&u(d,t,r,[n])}))}})),h.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",n)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var n=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",n)}},d.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter((function(e){return"audio"===e.kind})).length,s=n.transceivers.filter((function(e){return"video"===e.kind})).length,a=arguments[0];if(a){if(a.mandatory||a.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==a.offerToReceiveAudio&&(o=!0===a.offerToReceiveAudio?1:!1===a.offerToReceiveAudio?0:a.offerToReceiveAudio),void 0!==a.offerToReceiveVideo&&(s=!0===a.offerToReceiveVideo?1:!1===a.offerToReceiveVideo?0:a.offerToReceiveVideo)}for(n.transceivers.forEach((function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--s<0&&(e.wantReceive=!1)}));o>0||s>0;)o>0&&(n._createTransceiver("audio"),o--),s>0&&(n._createTransceiver("video"),s--);var u=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach((function(i,o){var s=i.track,a=i.kind,c=i.mid||r.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=n._createIceGatherer(o,n.usingBundle));var u=e.RTCRtpSender.getCapabilities(a);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];s&&t>=15019&&"video"===a&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=u,i.sendEncodingParameters=d})),"max-compat"!==n._config.bundlePolicy&&(u+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",n.transceivers.forEach((function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===n.iceGatheringState||0!==t&&n.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+r.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var n=this;if(n._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==n.signalingState&&"have-local-pranswer"!==n.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+n.signalingState));var s=r.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.usingBundle&&(s+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),s+="a=ice-options:trickle\r\n";var a=r.getMediaSections(n._remoteDescription.sdp).length;n.transceivers.forEach((function(e,r){if(!(r+1>a)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?s+="m=application 0 DTLS/SCTP 5000\r\n":s+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?s+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(s+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(s+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;e.stream&&("audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}));var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,s+=i(e,u,"answer",e.stream,n._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(s+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(u)},d.prototype.addIceCandidate=function(e){var t,n=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,o){if(!n._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u<n.transceivers.length;u++)if(n.transceivers[u].mid===e.sdpMid){s=u;break}var d=n.transceivers[s];if(!d)return o(c("OperationError","Can not add ICE candidate"));if(d.rejected)return i();var l=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===l.protocol&&(0===l.port||9===l.port))return i();if(l.component&&1!==l.component)return i();if((0===s||s>0&&d.iceTransport!==n.transceivers[0].iceTransport)&&!a(d.iceTransport,l))return o(c("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=r.getMediaSections(n._remoteDescription.sdp))[s]+="a="+(l.type?h:"end-of-candidates")+"\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join("")}else for(var p=0;p<n.transceivers.length&&(n.transceivers[p].rejected||(n.transceivers[p].iceTransport.addRemoteCandidate({}),(t=r.getMediaSections(n._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",n._remoteDescription.sdp=r.getDescription(n._remoteDescription.sdp)+t.join(""),!n.usingBundle));p++);i()}))},d.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var n=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?n=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(n=e.rtpReceiver)})),!n)throw c("InvalidAccessError","Invalid selector.");return n.getStats()}var r=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&r.push(e[t].getStats())}))})),Promise.all(r).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var n=e[t];if(n&&n.prototype&&n.prototype.getStats){var r=n.prototype.getStats;n.prototype.getStats=function(){return r.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(n){var r;e[n].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(r=e[n]).type]||r.type,t.set(n,e[n])})),t}))}}}));var l=["createOffer","createAnswer"];return l.forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(l=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),d}},995:(e,t)=>{const{hasOwnProperty:n}=Object.prototype,r=h();r.configure=h,r.stringify=r,r.default=r,t.stringify=r,t.configure=h,e.exports=r;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function o(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function s(e,t){if(e.length>200||t)return e.sort(t);for(let t=1;t<e.length;t++){const n=e[t];let r=t;for(;0!==r&&e[r-1]>n;)e[r]=e[r-1],r--;e[r]=n}return e}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return void 0!==a.call(e)&&0!==e.length}function u(e,t,n){e.length<n&&(n=e.length);const r=","===t?"":" ";let i=`"0":${r}${e[0]}`;for(let o=1;o<n;o++)i+=`${t}"${o}":${r}${e[o]}`;return i}function d(e,t){let r;if(n.call(e,t)){if(r=e[t],"number"!=typeof r)throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return void 0===r?1/0:r}function l(e){return 1===e?"1 item":`${e} items`}function h(e){const t=function(e){if(n.call(e,"strict")){const t=e.strict;if("boolean"!=typeof t)throw new TypeError('The "strict" argument must be of type boolean');if(t)return e=>{let t="Object can not safely be stringified. Received type "+typeof e;throw"function"!=typeof e&&(t+=` (${e.toString()})`),new Error(t)}}}(e={...e});t&&(void 0===e.bigint&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));const r=function(e){if(n.call(e,"circularValue")){const t=e.circularValue;if("string"==typeof t)return`"${t}"`;if(null==t)return t;if(t===Error||t===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}(e),i=function(e,t){let r;if(n.call(e,t)&&(r=e[t],"boolean"!=typeof r))throw new TypeError('The "bigint" argument must be of type boolean');return void 0===r||r}(e,"bigint"),a=function(e){let t;if(n.call(e,"deterministic")&&(t=e.deterministic,"boolean"!=typeof t&&"function"!=typeof t))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return void 0===t||t}(e),h="function"==typeof a?a:void 0,p=d(e,"maximumDepth"),f=d(e,"maximumBreadth");function v(e,n,u,d,m,_){let g=n[e];switch("object"==typeof g&&null!==g&&"function"==typeof g.toJSON&&(g=g.toJSON(e)),g=d.call(n,e,g),typeof g){case"string":return o(g);case"object":{if(null===g)return"null";if(-1!==u.indexOf(g))return r;let e="",t=",";const n=_;if(Array.isArray(g)){if(0===g.length)return"[]";if(p<u.length+1)return'"[Array]"';u.push(g),""!==m&&(e+=`\n${_+=m}`,t=`,\n${_}`);const r=Math.min(g.length,f);let i=0;for(;i<r-1;i++){const n=v(String(i),g,u,d,m,_);e+=void 0!==n?n:"null",e+=t}const o=v(String(i),g,u,d,m,_);return e+=void 0!==o?o:"null",g.length-1>f&&(e+=`${t}"... ${l(g.length-f-1)} not stringified"`),""!==m&&(e+=`\n${n}`),u.pop(),`[${e}]`}let i=Object.keys(g);const y=i.length;if(0===y)return"{}";if(p<u.length+1)return'"[Object]"';let S="",b="";""!==m&&(t=`,\n${_+=m}`,S=" ");const k=Math.min(y,f);a&&!c(g)&&(i=s(i,h)),u.push(g);for(let n=0;n<k;n++){const r=i[n],s=v(r,g,u,d,m,_);void 0!==s&&(e+=`${b}${o(r)}:${S}${s}`,b=t)}return y>f&&(e+=`${b}"...":${S}"${l(y-f)} not stringified"`,b=t),""!==m&&b.length>1&&(e=`\n${_}${e}\n${n}`),u.pop(),`{${e}}`}case"number":return isFinite(g)?String(g):t?t(g):"null";case"boolean":return!0===g?"true":"false";case"undefined":return;case"bigint":if(i)return String(g);default:return t?t(g):void 0}}function m(e,n,s,a,c,u){switch("object"==typeof n&&null!==n&&"function"==typeof n.toJSON&&(n=n.toJSON(e)),typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if(-1!==s.indexOf(n))return r;const e=u;let t="",i=",";if(Array.isArray(n)){if(0===n.length)return"[]";if(p<s.length+1)return'"[Array]"';s.push(n),""!==c&&(t+=`\n${u+=c}`,i=`,\n${u}`);const r=Math.min(n.length,f);let o=0;for(;o<r-1;o++){const e=m(String(o),n[o],s,a,c,u);t+=void 0!==e?e:"null",t+=i}const d=m(String(o),n[o],s,a,c,u);return t+=void 0!==d?d:"null",n.length-1>f&&(t+=`${i}"... ${l(n.length-f-1)} not stringified"`),""!==c&&(t+=`\n${e}`),s.pop(),`[${t}]`}s.push(n);let d="";""!==c&&(i=`,\n${u+=c}`,d=" ");let h="";for(const e of a){const r=m(e,n[e],s,a,c,u);void 0!==r&&(t+=`${h}${o(e)}:${d}${r}`,h=i)}return""!==c&&h.length>1&&(t=`\n${u}${t}\n${e}`),s.pop(),`{${t}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}function _(e,n,d,v,m){switch(typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if("function"==typeof n.toJSON){if("object"!=typeof(n=n.toJSON(e)))return _(e,n,d,v,m);if(null===n)return"null"}if(-1!==d.indexOf(n))return r;const t=m;if(Array.isArray(n)){if(0===n.length)return"[]";if(p<d.length+1)return'"[Array]"';d.push(n);let e=`\n${m+=v}`;const r=`,\n${m}`,i=Math.min(n.length,f);let o=0;for(;o<i-1;o++){const t=_(String(o),n[o],d,v,m);e+=void 0!==t?t:"null",e+=r}const s=_(String(o),n[o],d,v,m);return e+=void 0!==s?s:"null",n.length-1>f&&(e+=`${r}"... ${l(n.length-f-1)} not stringified"`),e+=`\n${t}`,d.pop(),`[${e}]`}let i=Object.keys(n);const g=i.length;if(0===g)return"{}";if(p<d.length+1)return'"[Object]"';const y=`,\n${m+=v}`;let S="",b="",k=Math.min(g,f);c(n)&&(S+=u(n,y,f),i=i.slice(n.length),k-=n.length,b=y),a&&(i=s(i,h)),d.push(n);for(let e=0;e<k;e++){const t=i[e],r=_(t,n[t],d,v,m);void 0!==r&&(S+=`${b}${o(t)}: ${r}`,b=y)}return g>f&&(S+=`${b}"...": "${l(g-f)} not stringified"`,b=y),""!==b&&(S=`\n${m}${S}\n${t}`),d.pop(),`{${S}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}function g(e,n,d){switch(typeof n){case"string":return o(n);case"object":{if(null===n)return"null";if("function"==typeof n.toJSON){if("object"!=typeof(n=n.toJSON(e)))return g(e,n,d);if(null===n)return"null"}if(-1!==d.indexOf(n))return r;let t="";const i=void 0!==n.length;if(i&&Array.isArray(n)){if(0===n.length)return"[]";if(p<d.length+1)return'"[Array]"';d.push(n);const e=Math.min(n.length,f);let r=0;for(;r<e-1;r++){const e=g(String(r),n[r],d);t+=void 0!==e?e:"null",t+=","}const i=g(String(r),n[r],d);return t+=void 0!==i?i:"null",n.length-1>f&&(t+=`,"... ${l(n.length-f-1)} not stringified"`),d.pop(),`[${t}]`}let v=Object.keys(n);const m=v.length;if(0===m)return"{}";if(p<d.length+1)return'"[Object]"';let _="",y=Math.min(m,f);i&&c(n)&&(t+=u(n,",",f),v=v.slice(n.length),y-=n.length,_=","),a&&(v=s(v,h)),d.push(n);for(let e=0;e<y;e++){const r=v[e],i=g(r,n[r],d);void 0!==i&&(t+=`${_}${o(r)}:${i}`,_=",")}return m>f&&(t+=`${_}"...":"${l(m-f)} not stringified"`),d.pop(),`{${t}}`}case"number":return isFinite(n)?String(n):t?t(n):"null";case"boolean":return!0===n?"true":"false";case"undefined":return;case"bigint":if(i)return String(n);default:return t?t(n):void 0}}return function(e,t,n){if(arguments.length>1){let r="";if("number"==typeof n?r=" ".repeat(Math.min(n,10)):"string"==typeof n&&(r=n.slice(0,10)),null!=t){if("function"==typeof t)return v("",{"":e},[],t,r,"");if(Array.isArray(t))return m("",e,[],function(e){const t=new Set;for(const n of e)"string"!=typeof n&&"number"!=typeof n||t.add(String(n));return t}(t),r,"")}if(0!==r.length)return _("",e,[],r,"")}return g("",e,[])}}},347:e=>{var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:n[t[r]]=t[r+1]}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var o=r[i],s=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var a=t.parseRtpMap(s),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(a.parameters=c.length?t.parseFmtp(c[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),n.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){n.headerExtensions.push(t.parseExtmap(e))})),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),s=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=a.length>0&&a[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:s?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substr(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substr(19),10)),isNaN(n)&&(n=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:n};if(t.matchPrefix(e,"a=sctpmap:").length>0){var s=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,n,r,i){var o=t.writeRtpDescription(e.kind,n);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var s="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";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\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substr(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t},429:()=>{}},k8={};function E8(e){var t=k8[e];if(void 0!==t)return t.exports;var n=k8[e]={id:e,loaded:!1,exports:{}};return b8[e].call(n.exports,n,n.exports,E8),n.loaded=!0,n.exports}E8.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return E8.d(t,{a:t}),t},E8.d=(e,t)=>{for(var n in t)E8.o(t,n)&&!E8.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},E8.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),E8.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),E8.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},E8.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var T8={};(()=>{E8.d(T8,{p:()=>Ai,Z:()=>xi});var e={};E8.r(e),E8.d(e,{fixNegotiationNeeded:()=>R,shimAddTrackRemoveTrack:()=>I,shimAddTrackRemoveTrackWithNative:()=>C,shimGetDisplayMedia:()=>y,shimGetSendersWithDtmf:()=>k,shimGetStats:()=>E,shimGetUserMedia:()=>g,shimMediaStream:()=>S,shimOnTrack:()=>b,shimPeerConnection:()=>w,shimSenderReceiverGetStats:()=>T});var t={};E8.r(t),E8.d(t,{shimGetDisplayMedia:()=>P,shimGetUserMedia:()=>x,shimPeerConnection:()=>D,shimReplaceTrack:()=>M});var n={};E8.r(n),E8.d(n,{shimAddTransceiver:()=>H,shimCreateAnswer:()=>z,shimCreateOffer:()=>K,shimGetDisplayMedia:()=>L,shimGetParameters:()=>W,shimGetUserMedia:()=>N,shimOnTrack:()=>U,shimPeerConnection:()=>V,shimRTCDataChannel:()=>G,shimReceiverGetStats:()=>B,shimRemoveStream:()=>j,shimSenderGetStats:()=>F});var r={};E8.r(r),E8.d(r,{shimAudioContext:()=>te,shimCallbacksAPI:()=>Y,shimConstraints:()=>$,shimCreateOfferLegacy:()=>ee,shimGetUserMedia:()=>X,shimLocalStreamsAPI:()=>q,shimRTCIceServerUrls:()=>Q,shimRemoteStreamsAPI:()=>J,shimTrackEventTransceiver:()=>Z});var i={};E8.r(i),E8.d(i,{removeExtmapAllowMixed:()=>ce,shimAddIceCandidateNullOrEmpty:()=>ue,shimConnectionState:()=>ae,shimMaxMessageSize:()=>oe,shimRTCIceCandidate:()=>ie,shimSendThrowTypeError:()=>se});let o=!0,s=!0;function a(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function c(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function u(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(o=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function d(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(s=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function l(){if("object"==typeof window){if(o)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function h(e,t){s&&console.warn(e+" is deprecated, please use "+t+" instead.")}function p(e){return"[object Object]"===Object.prototype.toString.call(e)}function f(e){return p(e)?Object.keys(e).reduce((function(t,n){const r=p(e[n]),i=r?f(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function v(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?v(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{v(e,e.get(t),n)}))})))}function m(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&v(e,n,i)}))})),i}const _=l;function g(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let s=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&n.length&&t.includes("back")&&(s=n[n.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=r(e.video),_("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return _("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function y(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((t=>{const r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function S(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function b(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else c(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function k(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function E(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach((e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){n(o(i(e)))};return t.apply(this,[r,e])}return new Promise(((e,n)=>{t.apply(this,[function(t){e(o(i(t)))},n])})).then(n,r)}}function T(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>m(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),c(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>m(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach((n=>{n.track===e&&(t?r=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?r=!0:n=t),t.track===e))),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function C(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function I(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return C(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find((e=>e.track===t));if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[n.id];if(o)o.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function w(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function R(e,t){c(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var A=E8(226),O=E8.n(A);function x(e){const t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function P(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 D(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const n=new Event("enabled");n.enabled=e,this.dispatchEvent(n)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const n=O()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let n=e.urls||e.url;e.url&&!e.urls&&h("RTCIceServer.url","RTCIceServer.urls");const r="string"==typeof n;return r&&(n=[n]),n=n.filter((e=>{if(0===e.indexOf("stun:"))return!1;const n=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return n&&!t?(t=!0,!0):n&&!t})),delete e.url,e.urls=r?n[0]:n,!!n.length}}))}(e.iceServers,t.version),l("ICE servers after filtering:",e.iceServers)),new n(e)},e.RTCPeerConnection.prototype=n.prototype}function M(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function N(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){h("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function L(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}function U(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function V(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const 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(){const[e,i,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(i,o)}}function F(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function B(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),c(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function j(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){h("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function G(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function H(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],n=e&&"sendEncodings"in e;n&&e.sendEncodings.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function W(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function K(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function z(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function q(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function J(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function Y(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let a=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=a,a=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=a,a=function(e,t,n){const r=s.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=a}function X(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n($(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function $(e){return e&&void 0!==e.video?Object.assign({},e,{video:f(e.video)}):e}function Q(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];!r.hasOwnProperty("urls")&&r.hasOwnProperty("url")?(h("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Z(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ee(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video")}return t.apply(this,arguments)}}function te(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ne=E8(347),re=E8.n(ne);function ie(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const n=new t(e),r=re().parseCandidate(e.candidate),i=Object.assign(n,r);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,c(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function oe(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n},r=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=re().matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r},i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=re().splitSections(e.sdp);return t.shift(),t.some((e=>{const t=re().parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),t=n(e),i=r(arguments[0],e);let o;o=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>o}),this._sctp=s}return i.apply(this,arguments)}}function se(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},c(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ae(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function ce(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function ue(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const de=function({window:o}={},s={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const c=l,h=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=a(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=a(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(n.mediaDevices&&n.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=a(n.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=a(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(o),p={browserDetails:h,commonShim:i,extractVersion:a,disableLog:u,disableWarnings:d};switch(h.browser){case"chrome":if(!e||!w||!s.shimChrome)return c("Chrome shim is not included in this adapter release."),p;if(null===h.version)return c("Chrome shim can not determine version, not shimming."),p;c("adapter.js shimming chrome."),p.browserShim=e,ue(o,h),g(o,h),S(o),w(o,h),b(o),I(o,h),k(o),E(o),T(o),R(o,h),ie(o),ae(o),oe(o,h),se(o),ce(o,h);break;case"firefox":if(!n||!V||!s.shimFirefox)return c("Firefox shim is not included in this adapter release."),p;c("adapter.js shimming firefox."),p.browserShim=n,ue(o,h),N(o,h),V(o,h),U(o),j(o),F(o),B(o),G(o),H(o),W(o),K(o),z(o),ie(o),ae(o),oe(o,h),se(o);break;case"edge":if(!t||!D||!s.shimEdge)return c("MS edge shim is not included in this adapter release."),p;c("adapter.js shimming edge."),p.browserShim=t,x(o),P(o),D(o,h),M(o),oe(o,h),se(o);break;case"safari":if(!r||!s.shimSafari)return c("Safari shim is not included in this adapter release."),p;c("adapter.js shimming safari."),p.browserShim=r,ue(o,h),Q(o),ee(o),Y(o),q(o),J(o),Z(o),X(o),te(o),ie(o),oe(o,h),se(o),ce(o,h);break;default:c("Unsupported browser!")}return p}({window:"undefined"==typeof window?void 0:window}),le=de;var he,pe,fe,ve,me,_e,ge,ye,Se,be,ke,Ee,Te="2.1.5.alpha.1121";!function(e){e.LOADING="loading",e.PLAYING="playing",e.ENDED="ended"}(he||(he={})),function(e){e.LOADING="loading",e.PLAYING="playing",e.ENDED="ended"}(pe||(pe={})),function(e){e[e.DISCONNECTED=0]="DISCONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.ESTABLISHED=2]="ESTABLISHED"}(fe||(fe={})),function(e){e[e.LOCAL=0]="LOCAL",e[e.REMOTE_SRC=1]="REMOTE_SRC",e[e.REMOTE_DRAW=2]="REMOTE_DRAW",e[e.REMOTE_CUSTOM=3]="REMOTE_CUSTOM",e[e.REMOTE_SRC_POS=4]="REMOTE_SRC_POS",e[e.FRONT_DRAW_DELTA_POS=5]="FRONT_DRAW_DELTA_POS"}(ve||(ve={})),function(e){e[e.CREATE_OFFER_FAILED=-2]="CREATE_OFFER_FAILED",e[e.NEED_RECONNECT=-1]="NEED_RECONNECT",e[e.MANUAL_CLOSE=0]="MANUAL_CLOSE",e[e.OTHER_KICK=1]="OTHER_KICK",e[e.HEARTBEAT_TIMEOUT=2]="HEARTBEAT_TIMEOUT",e[e.CONNECT_FAILED=3]="CONNECT_FAILED",e[e.TOKEN_ERROR=4]="TOKEN_ERROR"}(me||(me={})),function(e){e[e.TOO_FREQUENTLY=-1]="TOO_FREQUENTLY",e[e.AUTO_RECONNECTING=-2]="AUTO_RECONNECTING",e[e.EXCEEDED_LIMIT_RERTY_TIMES=-3]="EXCEEDED_LIMIT_RERTY_TIMES",e[e.FETCH_ERROR=-4]="FETCH_ERROR",e[e.INVALID_SERVER_SESSION=-5]="INVALID_SERVER_SESSION",e[e.MODE_FORBIDDEN=-6]="MODE_FORBIDDEN"}(_e||(_e={})),function(e){e.ACK="ack",e.HB="hb",e.CD="cd",e.KM="km",e.SVR="svr",e.SV="sv",e.CLOUD_DEVICE="cloud_device"}(ge||(ge={})),function(e){e[e.CLOSE_HIGH_FREQUENCY=0]="CLOSE_HIGH_FREQUENCY",e[e.UNPACKAGE_SEND=1]="UNPACKAGE_SEND",e[e.PACKAGE_SEND=2]="PACKAGE_SEND",e[e.LIMIT_LENGTH=3]="LIMIT_LENGTH"}(ye||(ye={})),function(e){e[e.touchstart=0]="touchstart",e[e.touchmove=1]="touchmove",e[e.touchend=2]="touchend",e[e.touchcancel=2]="touchcancel"}(Se||(Se={})),function(e){e[e.mousedown=0]="mousedown",e[e.mousemove=1]="mousemove",e[e.mouseup=2]="mouseup"}(be||(be={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.STREAM_NOT_FOUND=4e3]="STREAM_NOT_FOUND",e[e.STREAM_EXIST=4001]="STREAM_EXIST",e[e.PARAM_ERROR=4002]="PARAM_ERROR",e[e.SERVER_ERROR=5e3]="SERVER_ERROR",e[e.BACK_TO_SOURCE_ERROR=5001]="BACK_TO_SOURCE_ERROR",e[e.BACK_TO_SOURCE_REQ_PARAM_ERROR=5002]="BACK_TO_SOURCE_REQ_PARAM_ERROR",e[e.BACK_TO_SOURCE_RES_PARAM_ERROR=5003]="BACK_TO_SOURCE_RES_PARAM_ERROR"}(ke||(ke={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.BUSY=1]="BUSY",e[e.TOKEN_ERROR=2]="TOKEN_ERROR",e[e.SDP_ERROR=6]="SDP_ERROR",e[e.WAIT_HOST=8]="WAIT_HOST",e[e.PLAYERS_NUMBER_OR_ROLE_LIMIT=9]="PLAYERS_NUMBER_OR_ROLE_LIMIT",e[e.PROXY_ERROR=100]="PROXY_ERROR"}(Ee||(Ee={}));const Ce="function"==typeof atob,Ie="function"==typeof btoa,we="function"==typeof Buffer,Re="function"==typeof TextDecoder?new TextDecoder:void 0,Ae="function"==typeof TextEncoder?new TextEncoder:void 0,Oe=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),xe=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(Oe),Pe=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,De=String.fromCharCode.bind(String),Me="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=e=>e)=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),Ne=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Le=Ie?e=>btoa(e):we?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,i,o="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(i=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|i,o+=Oe[t>>18&63]+Oe[t>>12&63]+Oe[t>>6&63]+Oe[63&t]}return s?o.slice(0,s-3)+"===".substring(s):o},Ue=we?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(De.apply(null,e.subarray(n,n+4096)));return Le(t.join(""))},Ve=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?De(192|t>>>6)+De(128|63&t):De(224|t>>>12&15)+De(128|t>>>6&63)+De(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return De(240|t>>>18&7)+De(128|t>>>12&63)+De(128|t>>>6&63)+De(128|63&t)},Fe=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Be=we?e=>Buffer.from(e,"utf8").toString("base64"):Ae?e=>Ue(Ae.encode(e)):e=>Le(e.replace(Fe,Ve)),je=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Ge=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return De(55296+(t>>>10))+De(56320+(1023&t));case 3:return De((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return De((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},He=Ce?e=>atob(Ne(e)):we?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!Pe.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,i="";for(let o=0;o<e.length;)t=xe[e.charAt(o++)]<<18|xe[e.charAt(o++)]<<12|(n=xe[e.charAt(o++)])<<6|(r=xe[e.charAt(o++)]),i+=64===n?De(t>>16&255):64===r?De(t>>16&255,t>>8&255):De(t>>16&255,t>>8&255,255&t);return i},We=we?e=>Me(Buffer.from(e,"base64")):e=>Me(He(e),(e=>e.charCodeAt(0))),Ke=we?e=>Buffer.from(e,"base64").toString("utf8"):Re?e=>Re.decode(We(e)):e=>He(e).replace(je,Ge),ze=(e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(Be(e)):Be(e),qe=e=>Ke(Ne(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))));var Je=E8(23),Ye=E8.n(Je),Xe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},$e=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Qe=function(){return!(!document.fullscreenElement&&!document.webkitIsFullScreen)},Ze=function(){return!!(/Android|iPhone|iPad|iOS|Phone/i.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>0)},et=function(e,t){for(var n=0,r=t-"".concat(e).length;n<r;n++)e="0".concat(e);return"".concat(e)},tt=function(e,t){return t.replace(/yyyy|YYYY/,e.getFullYear()).replace(/yy|YY/,et(e.getFullYear()%100,2)).replace(/mm|MM/,et(e.getMonth()+1,2)).replace(/m|M/g,e.getMonth()+1).replace(/dd|DD/,et(e.getDate(),2)).replace(/d|D/g,e.getDate()).replace(/hh|HH/,et(e.getHours(),2)).replace(/h|H/g,e.getHours()).replace(/ii|II/,et(e.getMinutes(),2)).replace(/i|I/g,e.getMinutes()).replace(/ss|SS/,et(e.getSeconds(),2)).replace(/s|S/g,e.getSeconds()).replace(/w/g,e.getDay()).replace(/W/g,["日","一","二","三","四","五","六"][e.getDay()])},nt=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},rt=function(){var e=!1,t=navigator.userAgent,n=function(e,t){var n,r,i=navigator.mimeTypes;try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(i),s=o.next();!s.done;s=o.next())if(s.value[e]===t)return!0}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1};if(t.indexOf("QihooBrowser")>-1||t.indexOf("QHBrowser"),t.indexOf("360EE"),t.indexOf("360SE"),t.indexOf("2345Explorer")>-1||t.indexOf("Mb2345Browser")>-1||t.indexOf("2345chrome"),t.indexOf("Mobi")>-1||t.indexOf("iPh")>-1||t.indexOf("480"),window.chrome){var r=t.replace(/^.*Chrome\/([\d]+).*$/,"$1");window.chrome.adblock2345||window.chrome.common2345||(n("type","application/360softmgrplugin")||n("type","application/mozilla-npqihooquicklogin")||r>36&&window.showModalDialog?e=!0:r>45&&!(e=n("type","application/vnd.chromium.remoting-viewer"))&&r>=69&&(e=n("type","application/hwepass2001.installepass2001")||n("type","application/asx")))}return e},it=function(e,t){return void 0===t&&(t=2),Math.floor(10*e*t)/(10*t)},ot=function(){return+(+new Date+Math.round(1e4*Math.random()))},st={},at=function(){var e,t,n=Xe(null===(t=null===(e=null===Ye()||void 0===Ye()?void 0:Ye().os)||void 0===e?void 0:e.version)||void 0===t?void 0:t.split("."),2),r=n[0],i=n[1];return r&&i?+"".concat(r,".").concat(i):0},ct=function(){return!(function(){var e,t,n;return(null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===e?void 0:e.includes("iOS"))||(null===(t=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===t?void 0:t.includes("iPhone"))||(null===(n=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===n?void 0:n.includes("iPad"))}()&&at()<15.4)},ut=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(void 0,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(t){switch(t.label){case 0:return[4,new Blob($e([],Xe(e),!1)).arrayBuffer()];case 1:return[2,t.sent()]}}))}))},dt=E8(586),lt=E8.n(dt),ht={"120p":{width:160,height:120,frameRate:30,bitrate:200,type:"120p"},"180p":{width:320,height:180,frameRate:30,bitrate:350,type:"180p"},"240p":{width:320,height:240,frameRate:30,bitrate:400,type:"240p"},"360p":{width:640,height:360,frameRate:30,bitrate:800,type:"360p"},"480p":{width:640,height:480,frameRate:30,bitrate:900,type:"480p"},"720p":{width:1280,height:720,frameRate:30,bitrate:1500,type:"720p"},"1080p":{width:1920,height:1080,frameRate:30,bitrate:2e3,type:"1080p"}},pt=function(){function e(){this.requestQueue=[]}return e.prototype.startBlocking=function(){var e,t=new Promise((function(t){return e=t}));return this.requestQueue.push(e),t},e.prototype.nextTask=function(){this.requestQueue.length<=0||this.requestQueue.shift()()},e.prototype.clearQueue=function(){this.requestQueue=[]},e}(),ft=function(){return ft=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ft.apply(this,arguments)},vt=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},mt=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},_t={},gt=function(){function e(e){var t=e.sdk;this.forceShowCursor=!1,this.forceLockCursor=!1,this.showCursor=!0,this.remoteCursorMode=ve.LOCAL,this.mobileCursorScale=1,this.mobileShowCursor=!0,this.originCursorStyle="",this.hotSpot={x:0,y:0},this.remoteCursorImage="",this.token="",this.keepLastFrame=!1,this.serverSideDescription="",this.latestActionTime=+new Date,this.receivedOnloadedmetadataCallback=!1,this.connectBeginTime=0,this.connectTimeoutCount=0,this.connectStatus=fe.DISCONNECTED,this.heartbeatTimer=null,this.newConnectTimeout=60,this.noflowTimeout=10,this.peerConnection=null,this.kmDataChannel=null,this.ackDataChannel=null,this.hbDataChannel=null,this.cdDataChannel=null,this.svrDataChannel=null,this.cloudDeviceDataChannel=null,this.customDataChannel=new Map,this.ackDataChannelTimer=null,this.mediaStream=null,this.audioMediaStream=null,this.camera=null,this.mic=null,this.cameraMediaStream=null,this.micMediaStream=null,this.audioTransceiver=null,this.videoTransceiver=null,this.cameraProfile=ht["720p"],this.micProfile={sampleRate:44100,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,deviceId:null},this.switchCameraRequestQueue=new pt,this.switchCameraRequesting=!1,this.switchMicRequestQueue=new pt,this.switchMicRequesting=!1,this.clientSideDescription=null,this.requestId="",this.firstHitInput=!0,this.dataChannelCallbacks={},this.dataChannelRetryTimers={},this.checkMouseShowInterval=null,this.idleThreshold=3e5,this.idleTimes=0,this.lastInputStatus=!1,this.noFlowCount=0,this.gameStatus="playing",this.streamPushStat=null,this._webrtcStartTime=null,this.sdk=null,this.mount=null,this.sdk=t}return Object.defineProperty(e.prototype,"webrtcStartTime",{get:function(){return this._webrtcStartTime},enumerable:!1,configurable:!0}),e.prototype.init=function(e){var t,n,r=this;if(this.sdk.log("CloudGamingWebRTC init"),this.forceShowCursor=null!==(t=e.forceShowCursor)&&void 0!==t&&t,this.idleThreshold=e.idleThreshold?1e3*e.idleThreshold:3e5,this.keepLastFrame=null!==(n=e.keepLastFrame)&&void 0!==n&&n,this.mount=e.mount,this.peerConnection)return this.sdk.log("please disconnect(this.sdk.destroy()) before init"),this.sdk.onInitSuccess({code:-2,msg:"please disconnect(this.sdk.destroy()) before init"});var i=5,o=function(){return vt(r,0,void 0,(function(){var e,t=this;return mt(this,(function(n){switch(n.label){case 0:if(this.sdk.isMobileGame&&!this.sdk.getInitOptions().mobileVpx&&(r=!1,!(window.RTCRtpReceiver&&(null===RTCRtpReceiver||void 0===RTCRtpReceiver?void 0:RTCRtpReceiver.getCapabilities)?(RTCRtpReceiver.getCapabilities("video").codecs.forEach((function(e){"video/H264"!==e.mimeType||(r=!0)})),r):(console.log("RTCRtpReceiver.getCapabilities is not a function"),1))))return setTimeout((function(){return vt(t,0,void 0,(function(){var e;return mt(this,(function(t){switch(t.label){case 0:return 0!=(i-=1)?[3,2]:(e=this,[4,this.newWebRtcConnect()]);case 1:return e.clientSideDescription=t.sent(),this.sdk.onInitSuccess({code:-1,description:this.clientSideDescription}),[2];case 2:return[4,o()];case 3:return t.sent(),[2]}}))}))}),100),this.sdk.onWebrtcStatusChange({code:-2}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),e=this,[4,this.newWebRtcConnect()];case 2:return e.clientSideDescription=n.sent(),this.sdk.onInitSuccess({code:0,msg:"ok",description:this.clientSideDescription}),[3,4];case 3:return n.sent(),this.sdk.onInitSuccess({code:-1,msg:"your browser without webrtc support",description:this.clientSideDescription}),[3,4];case 4:return[2]}var r}))}))};o()},Object.defineProperty(e.prototype,"debugSetting",{get:function(){return this.sdk.getInitOptions().debugSetting||{}},enumerable:!1,configurable:!0}),e.prototype.sendKmData=function(e){this.idleTimes=0,this.latestActionTime=+new Date,this.debugSetting.showSendKmData&&console.log("sendKmData",e),this.dataChannelSend(this.kmDataChannel,e)},e.prototype.sendAckData=function(e){var t=e.data,n=void 0===t?_t:t,r=e.retry,i=void 0===r?0:r,o=e.callback,s=void 0===o?nt:o,a=e.interval,c=void 0===a?1e3:a,u=n.type;"cursor_state"!==u&&"keys_clean"!==u&&(this.latestActionTime=+new Date,this.idleTimes=0);var d=ot();this.dataChannelSendWithCallback({dataChannel:this.ackDataChannel,ackMsg:{seq:d,data:n},retry:i,callback:s,interval:c}),this.debugSetting.showSendAckData&&("cursor_state"===u||console.log("sendAckData:",n,d))},e.prototype.sendCloudDeviceData=function(e){this.debugSetting.showSendCloudDeviceData&&console.log("sendCloudDeviceData",e),this.dataChannelSend(this.cloudDeviceDataChannel,e)},e.prototype.connect=function(e){var t,n,r;void 0===e&&(e=""),this.sdk.log("connect->"),this.sdk.showStats.setServerSessionTime(+new Date);var i=+new Date;if(i-this.connectBeginTime<5e3)return this.sdk.log("connect too frequently, last is ".concat(Math.ceil((i-this.connectBeginTime)/1e3),"s")),this.clearPeerConnection(),void this.sdk.onConnectFailed({code:_e.TOO_FREQUENTLY,msg:"connect too frequently"});"connected"!==(null===(t=this.peerConnection)||void 0===t?void 0:t.connectionState)&&"connecting"!==(null===(n=this.peerConnection)||void 0===n?void 0:n.connectionState)||this.sdk.log("peerConnection status is ".concat(null===(r=this.peerConnection)||void 0===r?void 0:r.connectionState,", please clear current connection before call this.sdk.start()")),this.connectBeginTime=i,this.connectTimeoutCount=0,this.connectStatus=fe.CONNECTING;try{this.serverSideDescription=qe(e)}catch(e){throw"serverSession is not base64 string format"}this.serverSideDescription?this.onAnswer(this.serverSideDescription):this.sdk.onWebrtcStatusChange({code:-1,msg:"set server description failed, please try again later."})},e.prototype.getClientSideDescription=function(e){void 0===e&&(e=!0),this.clientSideDescription||console.error("webrtc is not initialized");try{return e?ze(JSON.stringify(this.clientSideDescription)):this.clientSideDescription}catch(e){console.error("clientSideDescription is not jsonString or encoding failure")}},e.prototype.newWebRtcConnect=function(){return vt(this,0,void 0,(function(){var e,t,n,r=this;return mt(this,(function(i){switch(i.label){case 0:this._webrtcStartTime=+new Date;try{this.peerConnection=new RTCPeerConnection({sdpSemantics:"unified-plan"})}catch(e){if(this.sdk.log("new RTCPeerConnection error",e),"ReferenceError"===e.name&&e.message.includes("RTCPeerConnection"))throw this.sdk.onWebrtcStatusChange({code:255,msg:"your browser without webrtc support"}),console.log("your browser without webrtc support"),"your browser without webrtc support";return[2]}return this.connectStatus=fe.CONNECTING,this.peerConnection.ontrack=function(e){return r.onTrack(e)},this.peerConnection.onconnectionstatechange=function(){var e;r.sdk.log("onconnectionstatechange",null===(e=r.peerConnection)||void 0===e?void 0:e.connectionState)},this.peerConnection.oniceconnectionstatechange=function(){return r.onIceConnectionStateChange()},this.peerConnection.onicecandidate=function(){},this.peerConnection.onnegotiationneeded=function(){r.sdk.log("onnegotiationneeded")},(null===navigator||void 0===navigator?void 0:navigator.mediaDevices)&&(navigator.mediaDevices.ondevicechange=function(e){r.sdk.onDeviceChange(e)}),this.createKmDataChannel(),this.createHbDataChannel(),this.createAckDataChannel(),this.createSvrDataChannel(),this.createCloudDeviceDataChannel(),this.sdk.showStats.toggleMetricReportBulk(!0),e=this.sdk.getInitOptions(),t=e.mic,n=e.camera,null===this.mic&&(this.mic=t),null===this.camera&&(this.camera=n),[4,this.createOffer({mic:this.mic,camera:this.camera})];case 1:return[2,i.sent()]}}))}))},e.prototype.startHeartbeatReport=function(){var e=this;clearInterval(this.heartbeatTimer),this.sdk.log("startHeartbeatReport ->"),this.heartbeatTimer=setInterval((function(){return vt(e,0,void 0,(function(){var e,t,n;return mt(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.peerConnection)||void 0===n?void 0:n.getStats(null)];case 1:return e=r.sent(),t=[],null==e||e.forEach((function(e){void 0===e&&(e={}),"inbound-rtp"!==e.type&&"track"!==e.type&&"codec"!==e.type||t.push(e)})),0===t.length&&(t=[{type:"inbound-rtp",mediaType:"video"},{type:"track",jitterBufferDelay:100*Math.random()%30+10}]),this.sdk.showStats.setStat(t,e),this.reportStat(),[2]}}))}))}),1e3)},e.prototype.getCursorShowStatus=function(){return!(!this.sdk.isMobileGame&&"touch"!==this.sdk.getClientInteractMode())||this.showCursor},e.prototype.mouseDeltaMove=function(){return this.remoteCursorMode===ve.REMOTE_SRC_POS||this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS},e.prototype.lockMouse=function(e){var t,n,r;return vt(this,0,void 0,(function(){var i;return mt(this,(function(o){switch(o.label){case 0:if("touch"===this.sdk.getClientInteractMode())return[2];if(!e)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,null===(n=(t=this.sdk.getVideoElement()).requestPointerLock)||void 0===n?void 0:n.call(t)];case 2:return o.sent(),[3,4];case 3:return i=o.sent(),this.sdk.log("requestPointerLock error",i),this.sdk.onEvent({type:"pointerlockerror"}),[3,4];case 4:return[3,6];case 5:try{null===(r=document.exitPointerLock)||void 0===r||r.call(document)}catch(e){this.sdk.log("exitPointerLock error",e)}o.label=6;case 6:return this.remoteCursorMode===ve.REMOTE_SRC_POS&&(e?this.sdk.pageEvent.setDropMouseEvent(!1):this.sdk.pageEvent.setDropMouseEvent(!0)),[2]}}))}))},e.prototype.isMouseLocked=function(){return document.pointerLockElement===this.sdk.getVideoElement()},e.prototype.setForceShowCursor=function(e){this.forceShowCursor=e},e.prototype.setForceLockCursor=function(e){this.forceLockCursor=e},e.prototype.getForceShowCursor=function(){return this.forceShowCursor},e.prototype.clearPeerConnection=function(){if(this.mediaStream&&(this.mediaStream.getTracks().forEach((function(e){e.stop()})),this.mediaStream=null),this.dataChannelCallbacks={},this.peerConnection){this.kmDataChannel&&(this.kmDataChannel.close(),this.kmDataChannel=null),this.hbDataChannel&&(this.hbDataChannel.close(),this.hbDataChannel=null),this.ackDataChannel&&(this.ackDataChannel.close(),this.ackDataChannel=null),this.cdDataChannel&&(this.cdDataChannel.close(),this.cdDataChannel=null),this.svrDataChannel&&(this.svrDataChannel.close(),this.svrDataChannel=null),this.customDataChannel.size&&(this.customDataChannel.forEach((function(e){return e.close()})),this.customDataChannel.clear()),this.videoTransceiver&&(this.switchTrack({type:"video",status:"remove",userMedia:this.cameraMediaStream}),this.videoTransceiver=null),this.audioTransceiver&&(this.switchTrack({type:"audio",status:"remove",userMedia:this.micMediaStream}),this.audioTransceiver=null),this.peerConnection.close(),this.peerConnection.ontrack=null,this.peerConnection.oniceconnectionstatechange=null,this.peerConnection.onicecandidate=null,this.peerConnection=null;var e=this.sdk.getVideoElement();(null==e?void 0:e.srcObject)&&(e.srcObject=null)}this.clientSideDescription=null,this.serverSideDescription=null,clearInterval(this.heartbeatTimer),this.checkMouseShowInterval&&(clearInterval(this.checkMouseShowInterval),this.checkMouseShowInterval=null),this.sdk.showStats.toggleMetricReportBulk(!1),this.sdk.pageEvent.clearEvent(),this.receivedOnloadedmetadataCallback=null},e.prototype.disconnected=function(e){var t,n=e.message,r=void 0===n?"":n,i=e.code,o=void 0===i?null:i;this.sdk.log("disconnected",o,r),this.connectStatus=fe.DISCONNECTED,this.keepLastFrame&&(null===(t=this.sdk.getVideoElement())||void 0===t||t.pause()),o===me.OTHER_KICK&&this.sdk.getRestartElement()&&(this.sdk.getRestartElement().style.display="block"),this.clearPeerConnection(),this.sdk.getInitOptions().reconnect&&o===me.NEED_RECONNECT?this.reconnect({message:r}):(this.sdk.log("destroy code: ".concat(o," and clear reconnect token")),this.sdk.watchdog.setReconnectInfo({serverIp:"",token:""})),this.sdk.onDisconnect({code:o,msg:r}),this.sdk.log("call onDisconnect, code",o)},e.prototype.reconnect=function(e){var t=e.message,n=void 0===t?"":t;this.sdk.log("reconnect, setup reconnect server_ip=".concat(this.gameConfig.server_ip," and token=").concat(this.token)),this.sdk.watchdog.setReconnectInfo({serverIp:this.gameConfig.server_ip,token:this.token}),this.sdk.watchdog.autoReconnect({message:n})},e.prototype.getRemoteCursorState=function(e){this.sendAckData({data:{type:e}})},e.prototype.getIdleTime=function(){return+new Date-this.latestActionTime},e.prototype.checkUserIdle=function(){var e=this.getIdleTime();if(e>this.idleThreshold){var t=Math.floor(e/this.idleThreshold);t>this.idleTimes&&(this.sdk.onNetworkChange({status:"idle",times:t}),this.sdk.onEvent({type:"idle",data:{times:t}}),this.idleTimes=t)}},e.prototype.setCursorMode=function(e){var t=this,n=e;e===ve.REMOTE_SRC_POS&&(n=ve.REMOTE_SRC);var r=n===ve.REMOTE_DRAW;if(this.sendAckData({data:{type:"set_cursor",show:n},callback:function(){t.setCursorShowStatus(!r)}}),this.remoteCursorMode=e,e===ve.REMOTE_SRC||e===ve.FRONT_DRAW_DELTA_POS?this.createCdDataChannel():this.cdDataChannel&&(this.cdDataChannel.close(),this.cdDataChannel=null),e===ve.LOCAL){var i=this.sdk.getVideoElement();i&&(this.sdk.log("videoElement.style.cursor will set to origin style",this.originCursorStyle),i.style.cursor="url(".concat(this.originCursorStyle,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto"))}e===ve.FRONT_DRAW_DELTA_POS&&this.lockMouse(!0)},e.prototype.getCursorMode=function(){return this.remoteCursorMode},e.prototype.getCursorHotSpot=function(){return this.hotSpot},e.prototype.setMobileCursorScale=function(e){this.mobileCursorScale=e},e.prototype.getDisplayRect=function(){var e,t=(null===(e=this.sdk.getVideoElement())||void 0===e?void 0:e.getBoundingClientRect())||_t,n=t.width,r=void 0===n?0:n,i=t.height,o=void 0===i?0:i,s=t.left,a=void 0===s?0:s,c=t.top;return{left:a,top:void 0===c?0:c,width:r,height:o,pixelRatio:window.devicePixelRatio||1}},e.prototype.setDefaultCursorImage=function(e){if(Ze()){var t=this.sdk.getCursorElement();"dot"===e?(t.style.width="3px",t.style.height="3px",t.style.borderRadius="50%",t.style.backgroundColor="#2dc7ef"):(t.style.width="26px",t.style.height="26px",t.style.backgroundImage="url(".concat(e,")"))}else{var n=this.sdk.getVideoElement();this.originCursorStyle=null!=e?e:"",n.style.cursor="url(".concat(e,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto")}},e.prototype.setNewConnectTimeout=function(e){void 0===e&&(e=60),this.newConnectTimeout=e},e.prototype.setNoflowTimeout=function(e){void 0===e&&(e=10),this.noflowTimeout=e},e.prototype.setKeepLastFrame=function(e){void 0===e&&(e=!1),this.keepLastFrame=e},e.prototype.setMobileShowCursor=function(e){void 0===e&&(e=!0),this.mobileShowCursor=e},e.prototype.setGameStatus=function(e){this.gameStatus=e},e.prototype.createCustomDataChannel=function(e){var t,n,r,i=e.destPort,o=void 0===i?1:i,s=e.maxRetransmits,a=e.maxPacketLifeTime,c=e.onMessage,u=void 0===c?nt:c,d=e.onClose,l=void 0===d?nt:d,h=e.onError,p=void 0===h?nt:h,f=e.label,v=void 0===f?"":f,m=e.protocol,_=void 0===m?"text":m,g=e.type,y=void 0===g?"":g;return vt(this,0,Promise,(function(){var e,i=this;return mt(this,(function(c){switch(c.label){case 0:return"open"!==(null===(t=this.ackDataChannel)||void 0===t?void 0:t.readyState)?[2,{code:1,msg:"ack dataChannel does not open, please try again later."}]:(v||(v="cs".concat(y?"_".concat(y):"","_").concat(o)),this.sdk.log("start createCustomDataChannel, destPort: ".concat(o,", ackDataChannel state: ").concat(null===(n=this.ackDataChannel)||void 0===n?void 0:n.readyState,", label: ").concat(v,", protocol: ").concat(_,", maxRetransmits: ").concat(s,", maxRetransmits: ").concat(a)),(e=null===(r=this.peerConnection)||void 0===r?void 0:r.createDataChannel(v,{ordered:!0,maxRetransmits:s,maxPacketLifeTime:a}))?(e.onmessage=function(e){var t,n;i.sdk.log("dataChannel:".concat(v," onmessage"),"string"==typeof e.data?null===(t=e.data)||void 0===t?void 0:t.length:null===(n=e.data)||void 0===n?void 0:n.byteLength),u(e.data)},e.onclose=function(e){return l(e)},e.onerror=function(e){return p(e)},this.customDataChannel.set(o,e),[4,new Promise((function(e){i.sendAckData({data:{type:"udp_trans",dest_port:o,protocol:_,label:v},callback:function(t){var n=t.data;i.sdk.log("createCustomDataChannel label:".concat(v," destPort:").concat(o," success"),n),e({code:n.code,msg:n.msg})}}),i.sdk.log("customDataChannels",i.customDataChannel),setTimeout((function(){e({code:3,msg:"request timeout, please try again later."})}),5e3)}))]):[3,2]);case 1:return[2,c.sent()];case 2:return this.sdk.log("createCustomDataChannel fail"),[2,{code:1}]}}))}))},e.prototype.sendCustomDataChannelMessage=function(e){var t=e.destPort,n=void 0===t?0:t,r=e.msg,i=void 0===r?"":r,o=this.customDataChannel.get(n);"open"===(null==o?void 0:o.readyState)&&(this.sdk.log("sendCustomDataChannelMessage",i.length,n,null==o?void 0:o.readyState),o.send(i))},e.prototype.setTrackEnable=function(e){var t=e.type,n=void 0===t?"audio":t,r=e.enable,i=void 0===r||r;if(this.sdk.log("setTrackEnable type",n,"enable",i),"audio"===n)return this.audioTransceiver.sender?(this.audioTransceiver.sender.track.enabled=i,this.sdk.log("audioTransceiver.sender",this.audioTransceiver.sender,i),{code:0}):{code:1,message:"audioTransceiver.sender is null"}},e.prototype.switchTrack=function(e){var t,n,r,i,o=e.type,s=e.status,a=e.userMedia;return vt(this,0,Promise,(function(){var e;return mt(this,(function(c){switch(c.label){case 0:return this.sdk.log("switchTrack type",o,"status",s),"audio"!==o?[3,6]:this.audioTransceiver.sender?"add"!==s?[3,2]:(e=null===(t=null==a?void 0:a.getAudioTracks())||void 0===t?void 0:t[0],[4,this.audioTransceiver.sender.replaceTrack(e)]):[3,5];case 1:c.sent(),c.label=2;case 2:return"remove"!==s?[3,4]:[4,this.audioTransceiver.sender.replaceTrack(null)];case 3:c.sent(),null===(n=null==a?void 0:a.getAudioTracks()[0])||void 0===n||n.stop(),c.label=4;case 4:return[2,{code:0,message:"success"}];case 5:return[2,{code:1,message:"audioTransceiver.sender is null"}];case 6:return"video"!==o?[3,12]:this.videoTransceiver.sender?"add"!==s?[3,8]:(e=null===(r=null==a?void 0:a.getVideoTracks())||void 0===r?void 0:r[0],[4,this.videoTransceiver.sender.replaceTrack(e)]):[3,11];case 7:c.sent(),c.label=8;case 8:return"remove"!==s?[3,10]:[4,this.videoTransceiver.sender.replaceTrack(null)];case 9:c.sent(),null===(i=null==a?void 0:a.getVideoTracks()[0])||void 0===i||i.stop(),c.label=10;case 10:return[2,{code:0,message:"success"}];case 11:return[2,{code:2,message:"videoTransceiver.sender is null"}];case 12:return[2]}}))}))},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.getUserMedia=function(){var e,t,n=new MediaStream;return null===(e=this.cameraMediaStream)||void 0===e||e.getTracks().forEach((function(e){n.addTrack(e)})),null===(t=this.micMediaStream)||void 0===t||t.getTracks().forEach((function(e){n.addTrack(e)})),n},e.prototype.switchMic=function(e){var t,n=e.status,r=e.profile;return vt(this,0,Promise,(function(){var e,i,o,s,a,c;return mt(this,(function(u){switch(u.label){case 0:if(this.sdk.log("switchMic status",n,r),"open"!==n)return[3,5];if(null===(t=this.audioTransceiver.sender)||void 0===t?void 0:t.track)return this.sdk.log("mic opened, audioTransceiver sender",this.audioTransceiver.sender),[2,{code:1,msg:"mic opened",userMedia:null}];u.label=1;case 1:return u.trys.push([1,4,,5]),e=this,[4,this.createUserMedia({mic:null==r||r})];case 2:return e.micMediaStream=u.sent(),[4,this.switchTrack({type:"audio",status:"add",userMedia:this.micMediaStream})];case 3:return i=u.sent(),a=i.code,c=i.message,this.mic=r,this.sdk.onGetUserMediaStatusChange({msg:"mic open",type:"mic",userMedia:this.micMediaStream}),this.sendAckData({data:{type:"switch_mic",status:"open"}}),[2,{code:a,msg:c,userMedia:this.micMediaStream}];case 4:return o=u.sent(),this.sdk.onGetUserMediaStatusChange({msg:o,type:"mic"}),[2,{code:1,msg:o,userMedia:null}];case 5:return"close"!==n?[3,7]:[4,this.switchTrack({type:"audio",status:"remove",userMedia:this.micMediaStream})];case 6:return s=u.sent(),a=s.code,c=s.message,this.mic=!1,this.sdk.onGetUserMediaStatusChange({msg:"mic close",type:"mic"}),this.sendAckData({data:{type:"switch_mic",status:"close"}}),[2,{code:a,msg:c,userMedia:null}];case 7:return[2]}}))}))},e.prototype.switchCamera=function(e){var t,n=e.status,r=e.profile;return vt(this,0,Promise,(function(){var e,i,o,s,a,c;return mt(this,(function(u){switch(u.label){case 0:if(this.sdk.log("switchCamera status",n),"open"!==n)return[3,5];if(null===(t=this.videoTransceiver.sender)||void 0===t?void 0:t.track)return this.sdk.log("camera opened, videoTransceiver sender",this.videoTransceiver.sender),[2,{code:1,msg:"camera opened",userMedia:null}];u.label=1;case 1:return u.trys.push([1,4,,5]),e=this,[4,this.createUserMedia({camera:null==r||r})];case 2:return e.cameraMediaStream=u.sent(),[4,this.switchTrack({type:"video",status:"add",userMedia:this.cameraMediaStream})];case 3:return i=u.sent(),a=i.code,c=i.message,this.camera=r,this.sdk.onGetUserMediaStatusChange({msg:"camera open",type:"camera",userMedia:this.cameraMediaStream}),this.sendAckData({data:{type:"switch_camera",status:"open"}}),[2,{code:a,msg:c,userMedia:this.cameraMediaStream}];case 4:return o=u.sent(),this.sdk.onGetUserMediaStatusChange({msg:o,type:"camera"}),[2,{code:1,msg:o,userMedia:null}];case 5:return"close"!==n?[3,7]:[4,this.switchTrack({type:"video",status:"remove",userMedia:this.cameraMediaStream})];case 6:return s=u.sent(),a=s.code,c=s.message,this.camera=!1,this.sendAckData({data:{type:"switch_camera",status:"close"}}),this.sdk.onGetUserMediaStatusChange({msg:"camera close",type:"camera"}),[2,{code:a,msg:c,userMedia:this.cameraMediaStream}];case 7:return[2]}}))}))},e.prototype.setMicProfile=function(e){var t,n;return vt(this,0,Promise,(function(){var r,i;return mt(this,(function(o){switch(o.label){case 0:if(this.sdk.log("setMicProfile",e),!this.mic)return this.sdk.log("please open mic"),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r=this,[4,this.createUserMedia({mic:e})];case 2:return r.micMediaStream=o.sent(),this.micMediaStream?(null===(t=this.audioTransceiver.sender)||void 0===t||t.replaceTrack(null===(n=this.micMediaStream.getAudioTracks())||void 0===n?void 0:n[0]),this.sdk.onGetUserMediaStatusChange({msg:"setMicProfile success",type:"mic",userMedia:this.micMediaStream}),[2,{code:0,msg:"success",userMedia:this.micMediaStream}]):[3,4];case 3:return i=o.sent(),this.sdk.onGetUserMediaStatusChange({msg:i,type:"mic"}),[2,{code:1,msg:i,userMedia:null}];case 4:return[2]}}))}))},e.prototype.setCameraProfile=function(e){var t,n;return vt(this,0,Promise,(function(){var r,i;return mt(this,(function(o){switch(o.label){case 0:if(this.sdk.log("setCameraProfile",e),!this.camera)return this.sdk.log("please open camera"),[2];if("string"==typeof e&&e===this.cameraProfile.type)return this.sdk.log("profile is same as last value"),[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r=this,[4,this.createUserMedia({camera:e})];case 2:return r.cameraMediaStream=o.sent(),this.cameraMediaStream?(null===(t=this.videoTransceiver.sender)||void 0===t||t.replaceTrack(null===(n=this.cameraMediaStream.getVideoTracks())||void 0===n?void 0:n[0]),this.sdk.onGetUserMediaStatusChange({msg:"setCameraProfile success",type:"camera",userMedia:this.cameraMediaStream}),[2,{code:0,msg:"success",userMedia:this.cameraMediaStream}]):[3,4];case 3:return i=o.sent(),this.sdk.onGetUserMediaStatusChange({msg:i,type:"camera"}),[2,{code:1,msg:i,userMedia:null}];case 4:return[2]}}))}))},e.prototype.setCameraBitrate=function(e){return vt(this,0,void 0,(function(){var t,n;return mt(this,(function(r){switch(r.label){case 0:if(!("RTCRtpSender"in window)||!("setParameters"in window.RTCRtpSender.prototype))return[3,7];if(!this.videoTransceiver.sender)return[3,5];(t=this.videoTransceiver.sender.getParameters()).encodings||(t.encodings=[{}]),"unlimited"===e?delete t.encodings[0].maxBitrate:t.encodings[0].maxBitrate=1e3*e,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.videoTransceiver.sender.setParameters(t)];case 2:return r.sent(),this.sdk.log("setCameraBitrate success ".concat("number"==typeof e?e:"unlimited"," kbps")),[3,4];case 3:return n=r.sent(),this.sdk.log("setCameraBitrate error",n),[3,4];case 4:return[3,6];case 5:this.sdk.log("camera sender is not found"),r.label=6;case 6:return[3,8];case 7:this.sdk.log("can not find RTCRtpSender in window"),r.label=8;case 8:return[2]}}))}))},e.prototype.getDevices=function(){return vt(this,0,void 0,(function(){var e,t,n;return mt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,navigator.mediaDevices.enumerateDevices()];case 1:return e=r.sent(),this.sdk.log("getDevices",e),t=null==e?void 0:e.filter((function(e){return e.kind.includes("input")&&"default"!==e.deviceId})),this.sdk.log("inputDevices",t),[2,t];case 2:throw n=r.sent(),this.sdk.log("getDevices error",n),n;case 3:return[2]}}))}))},e.prototype.getRequestId=function(){return this.requestId},e.prototype.getWebrtcConnectStatus=function(){return this.connectStatus},Object.defineProperty(e.prototype,"gameConfig",{get:function(){return this.sdk.gameConfig.getConfig({clientId:this.mount})},enumerable:!1,configurable:!0}),e.prototype.renegotiation=function(e){return vt(this,0,void 0,(function(){var t,n,r;return mt(this,(function(i){switch(i.label){case 0:if(this.sdk.log("renegotiation"),!ct())return this.sdk.log("renegotiation not support"),this.sdk.log("ios version is",at()),[2];i.label=1;case 1:return i.trys.push([1,3,,4]),this.sdk.log("renegotiation setRemoteDescription"),[4,this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:e,type:"offer"}))];case 2:return i.sent(),[3,4];case 3:return t=i.sent(),this.sdk.log("renegotiation setRemoteDescription exception->",t,t.message),this.sdk.onWebrtcStatusChange({code:-1,msg:"setRemoteDescription failed."}),[3,4];case 4:return i.trys.push([4,7,,8]),[4,this.peerConnection.createAnswer()];case 5:return n=i.sent(),this.sdk.log("renegotiation setLocalDescription"),[4,this.peerConnection.setLocalDescription(n)];case 6:return i.sent(),this.sendAckData({data:{type:"user_update",sdp:n.sdp}}),[3,8];case 7:return r=i.sent(),this.sdk.log("renegotiation setLocalDescription exception->",r,r.message),[3,8];case 8:return[2]}}))}))},e.prototype.onAnswer=function(e){var t,n;return void 0===e&&(e=""),vt(this,0,void 0,(function(){var r,i,o,s,a,c,u,d,l,h,p,f;return mt(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,5,,6]),r=JSON.parse(e),this.sdk.log("onAnswer-> serverSideDescriptionObject",r),!r)return[2,this.sdk.onConnectFailed({code:_e.INVALID_SERVER_SESSION,msg:"Server session not available "})];i=r.game_config,o=r.code,s=r.message,a=r.screen_config,c=r.plat,u=r.request_id,this.requestId=u,d=a.orientation,l=a.width,h=a.height,v.label=1;case 1:return v.trys.push([1,3,,4]),[4,this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:r.sdp,type:"answer"}))];case 2:return v.sent(),this.sdk.gameConfig.setConfig({clientId:this.mount,config:r}),this.setGameConfig(i),this.sdk.setServerSideDescription({serverSideDescription:r}),[3,4];case 3:return p=v.sent(),this.sdk.log("setRemoteDescription exception->",p),this.sdk.onWebrtcStatusChange({code:-1,msg:"setRemoteDescription 失败,请稍后重试."}),[3,4];case 4:return"android"===(null==c?void 0:c.toLocaleLowerCase())&&(this.sdk.mobileGame=!0,this.sdk.pageEvent.remoteScreenResolutionChange({width:null!==(t="portrait"===d?l:h)&&void 0!==t?t:0,height:null!==(n="portrait"===d?h:l)&&void 0!==n?n:0,left:0,top:0})),this.sdk.onWebrtcStatusChange({code:o>1e3?Ee.PROXY_ERROR:o,msg:s}),this.sdk.pageEvent.setRemoteScreenConfig(a),this.sdk.pageEvent.initOrientationDetector(),[3,6];case 5:return f=v.sent(),this.sdk.log("parse serverSideDescription error",f),this.sdk.onWebrtcStatusChange({code:-1,msg:"parse serverSideDescription error"}),[3,6];case 6:return[2]}}))}))},e.prototype.setGameConfig=function(e){void 0===e&&(e=_t);var t=e.sdk_conf;if(t){var n=this.sdk.getInitOptions().keepLastFrame;t.connect_timeout&&this.setNewConnectTimeout(t.connect_timeout),t.noflow_timeout&&this.setNoflowTimeout(t.noflow_timeout),t.cursor_scale&&this.setMobileCursorScale(t.cursor_scale),t.cursor_style&&this.sdk.setRemoteCursorStyle(t.cursor_style),"boolean"==typeof t.keep_lastframe&&void 0===n&&this.setKeepLastFrame(t.keep_lastframe),"boolean"==typeof t.mobile_show_cursor&&this.setMobileShowCursor(t.mobile_show_cursor)}},e.prototype.createUserMedia=function(e){var t=e.mic,n=void 0!==t&&t,r=e.camera,i=void 0!==r&&r;return vt(this,0,void 0,(function(){var e,t,r,o,s,a,c,u,d,l,h;return mt(this,(function(p){switch(p.label){case 0:return n?(this.sdk.log("createUserMedia mic",n),e=null,"object"!=typeof n?[3,2]:(this.micProfile=ft(ft({},this.micProfile),n),u=this.micProfile.deviceId,[4,this.getDevices()])):[3,6];case 1:d=p.sent().map((function(e){return e.deviceId})),this.sdk.log("deviceId",u),this.sdk.log("deviceIds",d),e=ft(ft({},this.micProfile),{deviceId:d.includes(u)?{exact:u}:void 0}),p.label=2;case 2:"boolean"==typeof n&&(e=n),this.sdk.log("micProfile",this.micProfile),this.sdk.log("micConstraints",e),p.label=3;case 3:return p.trys.push([3,5,,6]),[4,navigator.mediaDevices.getUserMedia({audio:e})];case 4:return[2,p.sent()];case 5:throw t=p.sent(),this.sdk.log("getUserMedia mic error",t,null==t?void 0:t.name),t.name;case 6:return i?(this.sdk.log("createUserMedia camera",i),r=null,"string"==typeof i&&(Object.keys(ht).includes(i)?this.cameraProfile=ht[i]:this.sdk.log("".concat(i," is not included in camera profile types, use default settings"))),"object"==typeof i&&(this.cameraProfile=ft(ft({},this.cameraProfile),i)),o=this.cameraProfile,s=o.width,a=o.height,c=o.frameRate,u=o.deviceId,!Ze()||"user"!==u&&"environment"!==u?[3,7]:(r={facingMode:{exact:u}},[3,10])):[3,14];case 7:return p.trys.push([7,9,,10]),[4,this.getDevices()];case 8:return d=p.sent().map((function(e){return e.deviceId})),this.sdk.log("deviceId",u),this.sdk.log("deviceIds",d),r={width:{ideal:s},height:{ideal:a},frameRate:c,deviceId:d.includes(u)?{exact:u}:void 0},[3,10];case 9:return l=p.sent(),this.sdk.log("getDevices error, use default cameraConstraints",l.message),r={width:{ideal:s},height:{ideal:a},frameRate:c},[3,10];case 10:"boolean"==typeof i&&(r=i),this.sdk.log("cameraConstraints",r),p.label=11;case 11:return p.trys.push([11,13,,14]),[4,navigator.mediaDevices.getUserMedia({video:r})];case 12:return[2,p.sent()];case 13:throw h=p.sent(),this.sdk.log("getUserMedia camera error",h,null==h?void 0:h.name),h.name;case 14:return[2]}}))}))},e.prototype.createOffer=function(e){var t=e.mic,n=void 0!==t&&t,r=e.camera,i=void 0!==r&&r;return vt(this,0,void 0,(function(){var e,t;return mt(this,(function(r){switch(r.label){case 0:return this.sdk.log("create offer","mic",n,"camera",i),this.videoTransceiver=this.peerConnection.addTransceiver("video",{direction:"sendrecv"}),this.audioTransceiver=this.peerConnection.addTransceiver("audio",{direction:"sendrecv"}),n?[4,this.switchMic({status:"open",profile:n})]:[3,2];case 1:r.sent(),r.label=2;case 2:return i?[4,this.switchCamera({status:"open",profile:i})]:[3,4];case 3:r.sent(),r.label=4;case 4:return r.trys.push([4,7,,8]),e=this.onOffer,[4,this.peerConnection.createOffer()];case 5:return[4,e.apply(this,[r.sent()])];case 6:return[2,r.sent()];case 7:return t=r.sent(),this.sdk.log("create offer error",t),this.disconnected({message:"create offer is failed",code:me.CREATE_OFFER_FAILED}),[3,8];case 8:return[2]}}))}))},e.prototype.onOffer=function(e){return vt(this,0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d,l,h;return mt(this,(function(p){switch(p.label){case 0:this.sdk.log("onOffer->",e),t=e.sdp,n=e.type,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,this.peerConnection.setLocalDescription({type:n,sdp:t})];case 2:return p.sent(),r=this.peerConnection.localDescription,i=function(e){void 0===e&&(e="");var t=[];return e.split("\r\n").forEach((function(e){e.includes("profile-level-id")&&(e=e.split("profile-level-id").pop().slice(1),t.push(e))})),t}(r.sdp),this.sdk.log("available profile-level-ids: ",i.join(",")),o=this.sdk.getInitOptions(),s=o.remoteDesktopResolution,a=o.streaming,c=(void 0===a?{}:a).videoCodecList,u=void 0===c?[]:c,d=o.streamProfile,l=o.userId,this.clientSideDescription={sdp:t,type:n,deviceInfo:{platform:Ze()?"mobile":"pc",user_agent:rt()?"".concat(null===navigator||void 0===navigator?void 0:navigator.userAgent," 360 browser"):null===navigator||void 0===navigator?void 0:navigator.userAgent},sdkType:"JS",desktopResolution:(null==s?void 0:s.width)&&(null==s?void 0:s.height)?"".concat(s.width,"x").concat(null==s?void 0:s.height):null,preferredCodecList:u.map((function(e){return e.toUpperCase()})),streamProfile:d,userId:l},[2,this.clientSideDescription];case 3:throw h=p.sent(),this.sdk.log("onOffer exception->",null==h?void 0:h.message,null==h?void 0:h.name),null==h?void 0:h.message;case 4:return[2]}}))}))},e.prototype.checkAckDataChannelStatus=function(){var e,t,n=this;this.sdk.log("checkAckDataChannelStatus",null===(e=this.ackDataChannel)||void 0===e?void 0:e.readyState),"open"===(null===(t=this.ackDataChannel)||void 0===t?void 0:t.readyState)?(clearInterval(this.ackDataChannelTimer),this.ackDataChannelTimer=null,this.onLoadedMetaData()):this.ackDataChannelTimer||(this.ackDataChannelTimer=setInterval((function(){n.checkAckDataChannelStatus()}),500))},e.prototype.onTrack=function(e){var t=this;if(this.sdk.log("onTrack",e.track.kind,e.track),"audio"===e.track.kind&&e.track.label.includes("|")){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(e.track.label.split("|"),2),r=n[0],i=n[1];return this.sdk.log("on audio Track",e.track.label,r,i,e.streams[0].id),this.sdk.createAudioAndAddTrack({id:i,source:e.streams[0]})}this.mediaStream||(this.mediaStream=new MediaStream),this.audioMediaStream||(this.audioMediaStream=new MediaStream),"video"===e.track.kind&&0===this.mediaStream.getVideoTracks().length&&(this.sdk.log("add video stream"),this.mediaStream.addTrack(e.track)),"audio"===e.track.kind&&0===this.mediaStream.getAudioTracks().length&&(this.sdk.log("add audio stream"),this.audioMediaStream.addTrack(e.track),function(){var e;return null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgent)||void 0===e?void 0:e.toLocaleLowerCase().includes("huawei")}()&&this.sdk.createAudioAndAddTrack({id:"tcg-audio-huawei",source:this.audioMediaStream}));var o=this.sdk.getVideoElement();o&&(o.srcObject||(o.srcObject=this.mediaStream),"video"===e.track.kind&&(this.sdk.log("on video Track"),"onloadedmetadata"in HTMLVideoElement.prototype?(this.sdk.log("onloadedmetadata in HTMLVideoElement.prototype"),o.onloadedmetadata=function(){t.receivedOnloadedmetadataCallback||(t.sdk.log("onloadedmetadata callback"),t.receivedOnloadedmetadataCallback=!0,t.checkAckDataChannelStatus())},setTimeout((function(){t.receivedOnloadedmetadataCallback||(t.sdk.log("onloadedmetadata timeout, check status"),t.receivedOnloadedmetadataCallback=!0,t.checkAckDataChannelStatus())}),1e3)):this.checkAckDataChannelStatus()));var s=this.sdk.getAudioElement();s&&(s.srcObject||(s.srcObject=this.audioMediaStream),"audio"===e.track.kind&&this.sdk.log("on audio Track"))},e.prototype.onLoadedMetaData=function(){var e,t,n,r,i,o,s=this;if(this.sdk.log("onLoadedMetaData->"),this.connectStatus===fe.DISCONNECTED)return this.sdk.log("connectStatus is disconnected, onLoadedMetaData return");this.sdk.getCloudGamingContainerElement()&&(this.sdk.getCloudGamingContainerElement().style.display="flex"),this.sdk.getProgressBarElement()&&(this.sdk.getProgressBarElement().style.display="none"),this.sdk.getRestartElement()&&(this.sdk.getRestartElement().style.display="none"),null===(n=null===(t=null===(e=this.sdk.getVideoElement())||void 0===e?void 0:e.play())||void 0===t?void 0:t.then((function(){return vt(s,0,void 0,(function(){var e=this;return mt(this,(function(t){switch(t.label){case 0:return this.sdk.log("video play success"),[4,new Promise((function(t){var n=null,r=function(){clearTimeout(n);var i=e.sdk.getVideoElement(),o=i.videoWidth,s=i.videoHeight;e.sdk.log("videoWidth",o,"videoHeight",s),o&&s?t(null):n=setTimeout((function(){r()}),50)};r()}))];case 1:return t.sent(),this.sdk.onEvent({type:"autoplay",data:{code:0,mediaType:"video",message:"video play success"}}),this.sdk.reshapeWindow(),[2]}}))}))})))||void 0===n||n.catch((function(e){s.sdk.log("video play error, ",e,e.name),s.sdk.onEvent({type:"autoplay",data:{mediaType:"video",code:-1,message:e}})})),null===(o=null===(i=null===(r=this.sdk.getAudioElement())||void 0===r?void 0:r.play())||void 0===i?void 0:i.then((function(){s.sdk.log("audio play success"),s.sdk.onEvent({type:"autoplay",data:{code:0,message:"audio play success",mediaType:"audio"}}),s.sdk.reshapeWindow()})))||void 0===o||o.catch((function(e){s.sdk.log("audio play error, ",e,e.name),s.sdk.onEvent({type:"autoplay",data:{code:-1,message:e,mediaType:"audio"}})})),this.sdk.showStats.setConnectSuccessTime(+new Date),this.connectStatus=fe.ESTABLISHED,this.checkMouseShowInterval||(this.checkMouseShowInterval=setInterval((function(){s.checkUserIdle()}),100)),this.startHeartbeatReport(),this.sdk.onWebrtcStatsChange(pe.PLAYING,this.mount),this.sdk.onConnectSuccess({code:0,seat_index:this.gameConfig.input_seat,role:this.gameConfig.role}),this.sdk.onConfigurationChange({screen_config:this.sdk.getRemoteScreenConfig()})},e.prototype.onIceConnectionStateChange=function(){this.sdk.log("onIceConnectionStateChange",this.peerConnection.iceConnectionState),this.peerConnection?("connected"===this.peerConnection.iceConnectionState&&(this.sdk.showStats.setIceConnectedTime(+new Date),this.sdk.onEvent({type:"ice_state",data:{value:"connected"}})),"disconnected"===this.peerConnection.iceConnectionState&&(this.sdk.onEvent({type:"ice_state",data:{value:"disconnected"}}),this.sdk.log("The ICE disconnected, please check the network."),this.sdk.log("Follow the link, https://cloud.tencent.com/document/product/1547/75988, and check your network."),this.disconnected({message:"The ICE disconnected, please check the network.",code:me.NEED_RECONNECT}),this.sdk.onEvent({type:"ice_state",data:{value:"disconnected"}}))):this.sdk.log("The peerConnection disconnected")},e.prototype.createKmDataChannel=function(){var e=this;this.sdk.log("start createKmDataChannel"),this.kmDataChannel=this.peerConnection.createDataChannel(ge.KM,{ordered:!0,maxRetransmits:10}),this.kmDataChannel.onmessage=function(t){return e.onKmMessage(t)},this.kmDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.kmDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.kmDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createHbDataChannel=function(){var e=this;this.sdk.log("start createHbDataChannel"),this.hbDataChannel=this.peerConnection.createDataChannel(ge.HB,{ordered:!0,maxRetransmits:0}),this.hbDataChannel.onmessage=function(t){return e.onHbMessage(t)},this.hbDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.hbDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.hbDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createAckDataChannel=function(){var e=this;this.sdk.log("start createAckDataChannel"),this.ackDataChannel=this.peerConnection.createDataChannel(ge.ACK,{ordered:!0,maxRetransmits:10}),this.ackDataChannel.onmessage=function(t){return e.onAckMessage(t)},this.ackDataChannel.onopen=function(t){return e.onDataChannelOpen(t)},this.ackDataChannel.onclose=function(t){return e.onDataChannelClose(t)},this.ackDataChannel.onerror=function(t){return e.onDataChannelError(t)}},e.prototype.createCdDataChannel=function(){var e,t=this;this.sdk.log("start createCdDataChannel"),this.cdDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.CD,{ordered:!0,maxRetransmits:0}),this.cdDataChannel&&(this.cdDataChannel.onmessage=function(e){return t.onCdMessage(e)},this.cdDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.cdDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.cdDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.createSvrDataChannel=function(){var e,t=this;this.sdk.log("start createSvrDataChannel"),this.svrDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.SVR,{ordered:!0,maxRetransmits:0}),this.svrDataChannel&&(this.svrDataChannel.onmessage=function(e){return t.onSvrMessage(e)},this.svrDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.svrDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.svrDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.createCloudDeviceDataChannel=function(){var e,t=this;this.sdk.log("start createCloudDeviceDataChannel"),this.cloudDeviceDataChannel=null===(e=this.peerConnection)||void 0===e?void 0:e.createDataChannel(ge.CLOUD_DEVICE,{ordered:!0,maxRetransmits:0}),this.cloudDeviceDataChannel&&(this.cloudDeviceDataChannel.onmessage=function(e){return t.onCloudDeviceMessage(e)},this.cloudDeviceDataChannel.onopen=function(e){return t.onDataChannelOpen(e)},this.cloudDeviceDataChannel.onclose=function(e){return t.onDataChannelClose(e)},this.cloudDeviceDataChannel.onerror=function(e){return t.onDataChannelError(e)})},e.prototype.onDataChannelError=function(e){var t=e||{},n=t.target,r=t.error;this.sdk.log("".concat(n.label," datachannel error->"),null==r?void 0:r.message)},e.prototype.onDataChannelOpen=function(e){var t=(e||{}).target;this.sdk.log("".concat(t.label," datachannel open->"),t.readyState,t.label),"hb"===t.label&&this.startHeartbeatReport()},e.prototype.onDataChannelClose=function(e){var t=(e||{}).target;this.sdk.log("".concat(t.label," datachannel close->"),t.readyState)},e.prototype.onKmMessage=function(e){var t=JSON.parse(e.data);this.debugSetting.showOnKmMessage&&console.log("onKmMessage",t);var n=t.screen_width,r=t.screen_height,i=t.screen_left,o=t.screen_top,s=t.cursor_showing;this.sdk.pageEvent.remoteScreenResolutionChange({width:n,height:r,left:i,top:o}),this.sdk.showStats.setCpuAndGpuUsage({cpu:t.cpu_usage,gpu:t.gpu_usage}),this.setCursorShowStatus(null==s||s)},e.prototype.onHbMessage=function(e){var t=JSON.parse(e.data),n=t.token,r=t.code,i=t.user_id,o=t.timestamp,s=t.message,a=t.stream_push_state;if(n&&(this.token=n),this.debugSetting.showOnHbMessage&&console.log("onHbMessage",t),r>=0&&(this.sdk.log("onHbMessage",s),this.disconnected({message:s,code:r})),i&&this.sdk.onNetworkChange({status:"stats",stats:t}),o){var c=+new Date-+o;this.sdk.showStats.setRTT(c)&&(i?this.gameConfig.user_id===i&&this.sdk.onNetworkChange({status:"jitter",data:{value:c,message:"NETWORK_JITTER"}}):this.sdk.onNetworkChange({status:"jitter",data:{value:c,message:"NETWORK_JITTER"}}))}this.streamPushStat!==a&&(this.streamPushStat=a,this.sdk.onStreamPushStateChange({stream_push_state:this.streamPushStat}))},e.prototype.onAckMessage=function(e){try{var t=JSON.parse(e.data),n=t.data,r=void 0===n?_t:n,i=t.seq;if(this.debugSetting.showOnAckMessage&&("cursor_state"===r.type||"keys_clean"===r.type||console.log("onAckMessage",r,i)),"seats_info_sync"===r.type)return;var o=this.dataChannelCallbacks[i];if(i&&(this.sdk.showStats.setInputEnd(i),o)){var s=o.callback;delete this.dataChannelCallbacks[i],this.dataChannelRetryTimers[i]&&(clearTimeout(this.dataChannelRetryTimers[i]),delete this.dataChannelRetryTimers[i]),null==s||s({code:0,msg:"on ack message",data:r})}switch(r.type){case"cursor_state":if(!r.state)return;this.setCursorShowStatus("showing"===r.state);break;case"game_launched":this.sdk.log("game_launched",r),this.sdk.onNetworkChange({status:"gamelaunched",data:{begin:r.launch_begin,finish:r.launch_complete}});break;case"input_seat":this.sdk.log("got new input_seat",r),this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{input_seat:r.input_seat}});break;case"user_state":this.sdk.log("user state update",r),this.sdk.onMultiPlayerChange({user_state:{user_id:r.user_id,state:r.state}});break;case"open_url":this.sdk.log("got open_url",r),this.sdk.onNetworkChange({status:"openurl",data:{value:r.url}}),this.sdk.onEvent({type:"openurl",data:{value:r.url}});break;case"vmaf_test":default:break;case"user_sdk_update":this.sdk.log("user_sdk_update",r),this.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:r.sdp,type:"answer"}));break;case"user_update":this.sdk.log("user_update"),this.renegotiation(r.sdp);break;case"sync_seats":this.sdk.log("sync_seats",r),o||this.sdk.onMultiPlayerChange({seats_info:{players:r.players,viewers:r.viewers}});var a=this.gameConfig.user_id,c=r.players.find((function(e){return e.name===a}));c&&(0!==c.mic_status&&1!==c.mic_status||this.setTrackEnable({type:"audio",enable:!1}),2===c.mic_status&&this.setTrackEnable({type:"audio",enable:!0}));break;case"submit_seat_change":this.sdk.log("submit_seat_change",r),o||this.sdk.onMultiPlayerChange({submit_seat_change:{user_id:r.user_id,to_role:r.to_role,seat_index:r.seat_index}});break;case"cursor_pos":if(this.remoteCursorMode===ve.REMOTE_SRC_POS){var u=r.x,d=r.y,l=this.sdk.pageEvent.transferLocalScale({width:u-this.hotSpot.x,height:d-this.hotSpot.y}),h=l.width,p=l.height;this.sdk.pageEvent.updateCursorPosition({displayX:h,displayY:p})}}}catch(e){this.sdk.log("onAckMessage exception->",null==e?void 0:e.message)}},e.prototype.onCdMessage=function(e){var t=this,n=e.data;if(n)try{var r=JSON.parse(n),i=r.data,o=r.hotspotx,s=void 0===o?0:o,a=r.hotspoty,c=void 0===a?0:a;this.debugSetting.showOnCdMessage&&this.sdk.log("onCdMessage image data->".concat(i.length," ").concat(lt()(i)),"hotspotx",s,"hotspoty",c),this.hotSpot.x=s,this.hotSpot.y=c;var u="data:image/png;base64,".concat(i);this.remoteCursorImage=u;var d=new Image;d.onload=function(){if(t.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS)(e=t.sdk.getCursorElement()).style.backgroundImage="url(".concat(u,")"),e.style.top="auto",e.style.left="auto",t.resizeMobileCursor({width:d.width,height:d.height});else if(Ze()||t.remoteCursorMode===ve.REMOTE_SRC_POS){var e;(e=t.sdk.getCursorElement()).style.backgroundImage="url(".concat(u,")"),t.resizeMobileCursor({width:16,height:16})}else{var n=t.sdk.getVideoElement();n&&(n.style.cursor="url(".concat(u,") ").concat(t.hotSpot.x," ").concat(t.hotSpot.y,", auto"))}},d.onerror=function(e){this.sdk.log("onCdMessage image data load failed",e)},d.src=u}catch(e){this.sdk.log("onCdMessage data parse failed",e)}else this.sdk.log("onCdMessage no data")},e.prototype.onSvrMessage=function(e){var t=e.data;return vt(this,0,void 0,(function(){var e,n,r,i,o,s,a,c,u,d,l,h,p,f,v,m,_,g,y;return mt(this,(function(S){switch(S.label){case 0:if(!t)return[3,48];S.label=1;case 1:switch(S.trys.push([1,46,,47]),e=JSON.parse(t),n=e.type,r=e.data,this.debugSetting.showOnSvMessage&&this.sdk.log("onSvMessage","type: ",n,"data",t),n){case"game_start_complete":return[3,2];case"game_stopped":return[3,3];case"archive_load_status":return[3,4];case"archive_save_status":return[3,5];case"metric_sig_key":return[3,6];case"screen_config_change":return[3,7];case"hit_input":return[3,8];case"ime":return[3,13];case"camera_status":return[3,14];case"mic_status":return[3,31]}return[3,44];case 2:return this.sdk.onGameStartComplete(r),[3,45];case 3:return this.sdk.onGameStop(r),[3,45];case 4:return this.sdk.onLoadGameArchive(r),[3,45];case 5:return this.sdk.onSaveGameArchive(r),[3,45];case 6:return this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{sig_key:r.sig_key}}),[3,45];case 7:return i=r,this.sdk.pageEvent.setRemoteScreenConfig(i),[3,45];case 8:return s=(o=r).field_type,a=o.status,c=o.text,u=o.start_index,this.sdk.onInputStatusChange({field_type:s,status:a}),this.sdk.log("ime type",this.sdk.pageEvent.IMEType,this.sdk.isMobileGame),this.sdk.isMobileGame?(d=this.sdk.getFakeInputElement(),"normal_input"!==s?[3,11]:this.firstHitInput?[4,new Promise((function(e){setTimeout(e,200)}))]:[3,10]):[3,12];case 9:S.sent(),S.label=10;case 10:return this.firstHitInput=!1,d.value=c,d.focus(),d.setRangeText("",u,u,"end"),[3,12];case 11:d.blur(),d.value="",S.label=12;case 12:return[3,45];case 13:return l=r.ime_type,this.sdk.pageEvent.IMEType=l,[3,45];case 14:return p=(h=r).status,f=h.height,v=h.width,this.sdk.log("onSvMessage camera_status",p,f,v,this.camera),this.sdk.getInitOptions().autoSwitchCamera?this.switchCameraRequesting?[4,this.switchCameraRequestQueue.startBlocking()]:[3,16]:[3,30];case 15:S.sent(),S.label=16;case 16:this.switchCameraRequesting=!0,S.label=17;case 17:return S.trys.push([17,28,29,30]),"open_front"!==p?[3,21]:this.camera?[4,this.switchCamera({status:"close"})]:[3,19];case 18:S.sent(),S.label=19;case 19:return[4,this.switchCamera({status:"open",profile:Ze()?{deviceId:"user"}:this.sdk.isMobileGame?{width:720,height:1280}:null})];case 20:S.sent(),S.label=21;case 21:return"open_back"!==p?[3,25]:this.camera?[4,this.switchCamera({status:"close"})]:[3,23];case 22:S.sent(),S.label=23;case 23:return[4,this.switchCamera({status:"open",profile:Ze()?{deviceId:"environment"}:this.sdk.isMobileGame?{width:720,height:1280}:null})];case 24:S.sent(),S.label=25;case 25:return"close"!==p?[3,27]:[4,this.switchCamera({status:"close"})];case 26:S.sent(),S.label=27;case 27:return this.switchCameraRequesting=!1,[3,30];case 28:return m=S.sent(),this.sdk.log("camera_status switch camera error,",m.message),this.switchCameraRequesting=!1,[3,30];case 29:return this.switchCameraRequesting=!1,this.switchCameraRequestQueue.nextTask(),[7];case 30:return this.sdk.onEvent({type:"camera_status",data:{status:p,width:v,height:f}}),[3,45];case 31:return _=r.status,this.sdk.log("onSvMessage mic_status",_,this.mic),this.sdk.getInitOptions().autoSwitchMic?this.switchMicRequesting?[4,this.switchMicRequestQueue.startBlocking()]:[3,33]:[3,43];case 32:S.sent(),S.label=33;case 33:this.switchMicRequesting=!0,S.label=34;case 34:return S.trys.push([34,41,42,43]),"open"!==_?[3,38]:this.mic?[4,this.switchMic({status:"close"})]:[3,36];case 35:S.sent(),S.label=36;case 36:return[4,this.switchMic({status:"open",profile:this.mic})];case 37:S.sent(),S.label=38;case 38:return"close"!==_?[3,40]:[4,this.switchMic({status:"close"})];case 39:S.sent(),S.label=40;case 40:return[3,43];case 41:return g=S.sent(),this.sdk.log("mic_status switch mic error,",g.message),this.switchMicRequesting=!1,[3,43];case 42:return this.switchMicRequesting=!1,this.switchMicRequestQueue.nextTask(),[7];case 43:return this.sdk.onEvent({type:"mic_status",data:{status:_}}),[3,45];case 44:return[3,45];case 45:return[3,47];case 46:return y=S.sent(),this.sdk.log("onSvMessage data parse failed",y),[3,47];case 47:return[3,49];case 48:this.sdk.log("onSvMessage no data"),S.label=49;case 49:return[2]}}))}))},e.prototype.onCloudDeviceMessage=function(e){var t=e.data;return vt(this,0,void 0,(function(){var e,n,r,i,o,s,a;return mt(this,(function(c){switch(c.label){case 0:if(!t)return[3,18];c.label=1;case 1:switch(c.trys.push([1,16,,17]),e=JSON.parse(t),n=e.type,r=e.data,this.debugSetting.showOnCloudDeviceMessage&&this.sdk.log("onCloudDeviceData","type: ",n,"data",t,"cloudDeviceData",r),n){case"trans_message":return[3,2];case"system_usage":return[3,3];case"clipboard_event":return[3,4];case"notification_event":return[3,9];case"system_status":return[3,10];case"distribute_progress_event":return[3,11];case"join":return[3,12];case"set_sync_list":return[3,13]}return[3,14];case 2:return this.sdk.onAndroidInstanceEvent({type:"trans_message",data:r}),[3,15];case 3:return this.sdk.onAndroidInstanceEvent({type:"system_usage",data:r}),[3,15];case 4:i=!0,o=r.text,c.label=5;case 5:return c.trys.push([5,7,,8]),[4,navigator.clipboard.writeText(o)];case 6:return c.sent(),[3,8];case 7:return s=c.sent(),console.log("navigator.clipboard.writeText failed",s),i=!1,[3,8];case 8:return this.sdk.onAndroidInstanceEvent({type:"clipboard_event",data:{text:o,writeText:i}}),[3,15];case 9:return this.sdk.onAndroidInstanceEvent({type:"notification_event",data:r}),[3,15];case 10:return this.sdk.onAndroidInstanceEvent({type:"system_status",data:r}),[3,15];case 11:return this.sdk.onAndroidInstanceEvent({type:"distribute_progress_event",data:r}),[3,15];case 12:return this.sdk.onAndroidInstanceEvent({type:"join",data:r}),[3,15];case 13:return this.sdk.onAndroidInstanceEvent({type:"set_sync_list",data:r}),[3,15];case 14:return[3,15];case 15:return[3,17];case 16:return a=c.sent(),this.sdk.log("onCloudDeviceData data parse failed",a),[3,17];case 17:return[3,19];case 18:this.sdk.log("onCloudDeviceData no data"),c.label=19;case 19:return[2]}}))}))},e.prototype.resizeMobileCursor=function(e){var t=e.width,n=void 0===t?16:t,r=e.height,i=void 0===r?16:r,o=this.sdk.getCursorElement();o.style.width="".concat(Math.round(n*this.mobileCursorScale),"px"),o.style.height="".concat(Math.round(i*this.mobileCursorScale),"px"),o.style.borderRadius=null,o.style.backgroundColor=null},e.prototype.reportStat=function(){var e=this.sdk.showStats.getStats(),t=e.fps;if(this.connectStatus===fe.CONNECTING&&(this.connectTimeoutCount+=1,this.connectTimeoutCount>=this.newConnectTimeout&&(this.sdk.log("connect timeout, no-flow notify"),this.sdk.onNetworkChange({status:"noflow"}),this.sdk.onEvent({type:"noflow"}),this.disconnected({message:"connect timeout, please reconnect",code:me.NEED_RECONNECT}),this.connectTimeoutCount=0)),this.connectStatus===fe.ESTABLISHED&&(0===t&&"playing"===this.gameStatus?(this.noFlowCount+=1,this.noFlowCount>=this.noflowTimeout&&(this.sdk.log("noFlowCount reach, no-flow notify"),this.sdk.onNetworkChange({status:"noflowcenter"}),this.sdk.onEvent({type:"noflowcenter"}),this.noFlowCount=0)):this.noFlowCount=0),!this.hbDataChannel)return this.sdk.log("hbDataChannel has been closed");if(e.timestamp=+new Date,this.connectStatus!==fe.DISCONNECTED){var n=e.fps,r=e.delay,i=e.bit_rate,o=e.packet_lost,s=e.nack,a=e.packet_received,c=ft(ft({},e),{fps:"".concat(n),delay:"".concat(r),bit_rate:"".concat(8*i),packet_lost:"".concat(o),nack:"".concat(s),packet_received:"".concat(a)});this.dataChannelSend(this.hbDataChannel,c),this.debugSetting.showSendHbData&&console.log("sendHbData",c),this.sdk.onNetworkChange({status:"stats",stats:e}),this.sdk.onEvent({type:"webrtc_stats",data:e});var u=this.sdk.showStats.getMediaStats();this.sdk.onEvent({type:"media_stats",data:u})}this.sdk.showStats.addReportStat()},e.prototype.dataChannelSend=function(e,t){"open"===(null==e?void 0:e.readyState)&&e.send(JSON.stringify(t))},e.prototype.dataChannelSendWithCallback=function(e){var t=this,n=e.dataChannel,r=void 0===n?null:n,i=e.ackMsg,o=void 0===i?_t:i,s=e.retry,a=void 0===s?0:s,c=e.callback,u=void 0===c?nt:c,d=e.interval,l=void 0===d?1e3:d;if("open"===(null==r?void 0:r.readyState))try{var h=o.seq;if(h||(h=ot(),this.sdk.showStats.setInputStart(h)),r.send(JSON.stringify(o)),this.dataChannelCallbacks[h]={ackMsg:o,retry:a,callback:u,interval:l,retryAction:function(){if(!t.dataChannelCallbacks[h])return t.sdk.log(r.label,h,"ackItem not exist");var e=t.dataChannelCallbacks[h];if(e.retry>=1||-1===e.retry)t.sdk.log(r.label,h,"ackItem retry, remain ".concat(e.retry," times")),e.retry=e.retry>=1?e.retry-1:e.retry,t.dataChannelSendWithCallback({dataChannel:r,ackMsg:e.ackMsg,retry:e.retry,callback:e.callback,interval:e.interval});else{var n=e.callback;delete t.dataChannelCallbacks[h],t.dataChannelRetryTimers[h]&&(t.sdk.showStats.setInputEnd(h),clearTimeout(t.dataChannelRetryTimers[h]),delete t.dataChannelRetryTimers[h],t.sdk.log("ack msg timer timeout clear:",h)),n({code:1,msg:"send ack message timeout"}),t.sdk.log("send ack message timeout:",h)}}},a>0){var p=setTimeout((function(){var e;null===(e=t.dataChannelCallbacks[h])||void 0===e||e.retryAction()}),l);this.dataChannelRetryTimers[h]=p}}catch(e){this.sdk.log("ack msg exception:",e)}},e.prototype.setCursorShowStatus=function(e){var t,n;if(this.connectStatus===fe.ESTABLISHED){this.forceShowCursor?this.lockMouse(!1):this.forceLockCursor?this.lockMouse(!0):e?this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?this.sdk.getCursorElement().style.display="block":this.lockMouse(!1):this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?this.sdk.getCursorElement().style.display="none":this.lockMouse(!0),this.forceLockCursor?this.showCursor=!1:(e!==this.showCursor&&(this.sdk.log("cursor show stat will set to",e),this.sdk.onCursorShowStatChange({oldStatus:this.showCursor,newStatus:e})),this.showCursor=e);var r=null===(t=this.sdk)||void 0===t?void 0:t.getVideoElement(),i=null===(n=this.sdk)||void 0===n?void 0:n.getCursorElement();if(this.remoteCursorMode!==ve.REMOTE_SRC_POS){if(this.remoteCursorMode===ve.REMOTE_DRAW)return r.style.cursor="none";r&&(this.remoteCursorMode===ve.FRONT_DRAW_DELTA_POS?r.style.cursor="auto":e||this.forceShowCursor||"touch"===this.sdk.getClientInteractMode()?r.style.cursor="url(".concat(this.remoteCursorImage?this.remoteCursorImage:this.originCursorStyle,") ").concat(this.hotSpot.x," ").concat(this.hotSpot.y,", auto"):r.style.cursor="none"),Ze()&&((e||this.forceShowCursor||"touch"===this.sdk.getClientInteractMode())&&this.mobileShowCursor?i.style.display="block":i.style.display="none")}else(e||this.forceShowCursor)&&this.mobileShowCursor?i.style.display="block":i.style.display="none"}},e}();const yt=gt;var St,bt=function(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t,n,r,o,s,a,c,u=[],d=0;d<arguments.length;d++)u[d]=arguments[d];var l=["video-stream","cursor"];"keyEvent"===e&&l.push("cloud-gaming-container");var h=u[0].target.className,p=(null===(t=this.sdk)||void 0===t?void 0:t.getInitOptions()).mount;((null===(n=u[0].target.parentNode)||void 0===n?void 0:n.id)===p||(null===(o=null===(r=u[0].target.parentNode)||void 0===r?void 0:r.parentNode)||void 0===o?void 0:o.id)===p||(null===(c=null===(a=null===(s=u[0].target.parentNode)||void 0===s?void 0:s.parentNode)||void 0===a?void 0:a.parentNode)||void 0===c?void 0:c.id)===p)&&(this.enableEventIntercept&&!l.includes(h)||i.apply(this,u))},r}};!function(e){e[e.Backspace=8]="Backspace",e[e.Tab=9]="Tab",e[e.Enter=13]="Enter",e[e.Shift=16]="Shift",e[e.Ctrl=17]="Ctrl",e[e.Alt=18]="Alt",e[e.PauseBreak=19]="PauseBreak",e[e.CapsLock=20]="CapsLock",e[e.Escape=27]="Escape",e[e.Space=32]="Space",e[e.PageUp=33]="PageUp",e[e.PageDown=34]="PageDown",e[e.End=35]="End",e[e.Home=36]="Home",e[e.LeftArrow=37]="LeftArrow",e[e.UpArrow=38]="UpArrow",e[e.RightArrow=39]="RightArrow",e[e.DownArrow=40]="DownArrow",e[e.Insert=45]="Insert",e[e.Delete=46]="Delete",e[e.Zero=48]="Zero",e[e.ClosedParen=48]="ClosedParen",e[e.One=49]="One",e[e.ExclamationMark=49]="ExclamationMark",e[e.Two=50]="Two",e[e.AtSign=50]="AtSign",e[e.Three=51]="Three",e[e.PoundSign=51]="PoundSign",e[e.Hash=51]="Hash",e[e.Four=52]="Four",e[e.DollarSign=52]="DollarSign",e[e.Five=53]="Five",e[e.PercentSign=53]="PercentSign",e[e.Six=54]="Six",e[e.Caret=54]="Caret",e[e.Hat=54]="Hat",e[e.Seven=55]="Seven",e[e.Ampersand=55]="Ampersand",e[e.Eight=56]="Eight",e[e.Star=56]="Star",e[e.Asterik=56]="Asterik",e[e.Nine=57]="Nine",e[e.OpenParen=57]="OpenParen",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.LeftWindowKey=91]="LeftWindowKey",e[e.RightWindowKey=92]="RightWindowKey",e[e.SelectKey=93]="SelectKey",e[e.Numpad0=96]="Numpad0",e[e.Numpad1=97]="Numpad1",e[e.Numpad2=98]="Numpad2",e[e.Numpad3=99]="Numpad3",e[e.Numpad4=100]="Numpad4",e[e.Numpad5=101]="Numpad5",e[e.Numpad6=102]="Numpad6",e[e.Numpad7=103]="Numpad7",e[e.Numpad8=104]="Numpad8",e[e.Numpad9=105]="Numpad9",e[e.Multiply=106]="Multiply",e[e.Add=107]="Add",e[e.Subtract=109]="Subtract",e[e.DecimalPoint=110]="DecimalPoint",e[e.Divide=111]="Divide",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NumLock=144]="NumLock",e[e.ScrollLock=145]="ScrollLock",e[e.SemiColon=186]="SemiColon",e[e.Equals=187]="Equals",e[e.Comma=188]="Comma",e[e.Dash=189]="Dash",e[e.Period=190]="Period",e[e.UnderScore=189]="UnderScore",e[e.PlusSign=187]="PlusSign",e[e.ForwardSlash=191]="ForwardSlash",e[e.Tilde=192]="Tilde",e[e.GraveAccent=192]="GraveAccent",e[e.Backquote=192]="Backquote",e[e.OpenBracket=219]="OpenBracket",e[e.ClosedBracket=221]="ClosedBracket",e[e.Quote=222]="Quote"}(St||(St={}));var kt=function(){if("undefined"!=typeof Map)return Map;function e(e,t){var n=-1;return e.some((function(e,r){return e[0]===t&&(n=r,!0)})),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n=0,r=this.__entries__;n<r.length;n++){var i=r[n];e.call(t,i[1],i[0])}},t}()}(),Et="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,Tt=void 0!==E8.g&&E8.g.Math===Math?E8.g:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),Ct="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(Tt):function(e){return setTimeout((function(){return e(Date.now())}),1e3/60)},It=["top","right","bottom","left","width","height","size","weight"],wt="undefined"!=typeof MutationObserver,Rt=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(e){var t=!1,n=!1,r=0;function i(){t&&(t=!1,e()),n&&s()}function o(){Ct(i)}function s(){var e=Date.now();if(t){if(e-r<2)return;n=!0}else t=!0,n=!1,setTimeout(o,20);r=e}return s}(this.refresh.bind(this))}return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},e.prototype.updateObservers_=function(){var e=this.observers_.filter((function(e){return e.gatherActive(),e.hasActive()}));return e.forEach((function(e){return e.broadcastActive()})),e.length>0},e.prototype.connect_=function(){Et&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),wt?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){Et&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t;It.some((function(e){return!!~n.indexOf(e)}))&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),At=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e},Ot=function(e){return e&&e.ownerDocument&&e.ownerDocument.defaultView||Tt},xt=Nt(0,0,0,0);function Pt(e){return parseFloat(e)||0}function Dt(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce((function(t,n){return t+Pt(e["border-"+n+"-width"])}),0)}var Mt="undefined"!=typeof SVGGraphicsElement?function(e){return e instanceof Ot(e).SVGGraphicsElement}:function(e){return e instanceof Ot(e).SVGElement&&"function"==typeof e.getBBox};function Nt(e,t,n,r){return{x:e,y:t,width:n,height:r}}var Lt=function(){function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Nt(0,0,0,0),this.target=e}return e.prototype.isActive=function(){var e=function(e){return Et?Mt(e)?function(e){var t=e.getBBox();return Nt(0,0,t.width,t.height)}(e):function(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return xt;var r=Ot(e).getComputedStyle(e),i=function(e){for(var t={},n=0,r=["top","right","bottom","left"];n<r.length;n++){var i=r[n],o=e["padding-"+i];t[i]=Pt(o)}return t}(r),o=i.left+i.right,s=i.top+i.bottom,a=Pt(r.width),c=Pt(r.height);if("border-box"===r.boxSizing&&(Math.round(a+o)!==t&&(a-=Dt(r,"left","right")+o),Math.round(c+s)!==n&&(c-=Dt(r,"top","bottom")+s)),!function(e){return e===Ot(e).document.documentElement}(e)){var u=Math.round(a+o)-t,d=Math.round(c+s)-n;1!==Math.abs(u)&&(a-=u),1!==Math.abs(d)&&(c-=d)}return Nt(i.left,i.top,a,c)}(e):xt}(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),Ut=function(e,t){var n=function(e){var t=e.x,n=e.y,r=e.width,i=e.height,o="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,s=Object.create(o.prototype);return At(s,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),s}(t);At(this,{target:e,contentRect:n})},Vt=function(){function e(e,t,n){if(this.activeObservations_=[],this.observations_=new kt,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof Ot(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)||(t.set(e,new Lt(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof Ot(e).Element))throw new TypeError('parameter 1 is not of type "Element".');var t=this.observations_;t.has(e)&&(t.delete(e),t.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach((function(t){t.isActive()&&e.activeObservations_.push(t)}))},e.prototype.broadcastActive=function(){if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map((function(e){return new Ut(e.target,e.broadcastRect())}));this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),Ft="undefined"!=typeof WeakMap?new WeakMap:new kt,Bt=function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=Rt.getInstance(),r=new Vt(t,n,this);Ft.set(this,r)};["observe","unobserve","disconnect"].forEach((function(e){Bt.prototype[e]=function(){var t;return(t=Ft.get(this))[e].apply(t,arguments)}}));const jt=void 0!==Tt.ResizeObserver?Tt.ResizeObserver:Bt;var Gt,Ht,Wt,Kt={},zt=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],qt=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(zt,1)[0];try{for(var Jt=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(zt),Yt=Jt.next();!Yt.done;Yt=Jt.next()){var Xt=Yt.value;if(Xt[1]in document){Wt=Xt;break}}}catch(e){Gt={error:e}}finally{try{Yt&&!Yt.done&&(Ht=Jt.return)&&Ht.call(Jt)}finally{if(Gt)throw Gt.error}}if(Wt)for(var $t=0;$t<Wt.length;$t++)Kt[qt[$t]]=Wt[$t];const Qt=Kt;var Zt=function(){return Zt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zt.apply(this,arguments)},en=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},tn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},nn=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},rn=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},on=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},sn=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},an=function(){function e(e){var t=e.sdk,n=this;this.moveSensitivity=1,this.touchesForDelta=null,this.touchesIdentifierMap=new Map,this.touchesMap=new Map,this.touchState=null,this.mousePosition={x:0,y:0,movementX:0,movementY:0,remoteX:0,remoteY:0},this.remoteMousePosition={x:0,y:0,sent:!1},this.mouseClickPosition={x:0,y:0},this.mouseState=null,this.enableMouseEventOnMobile=!1,this.enableMousemoveV2=!0,this.tabletModeLastPosition=null,this.kmStatus={keyboard:!0,mouse:!0},this.keyboardBanList=[],this.enablePaste=!0,this.keyboardPressedKeys=new Map,this.wheeling=!1,this.deltaMoveToCalcX=0,this.deltaMoveToCalcY=0,this.escPressTime=null,this.tabletMode=!1,this.clickToFullscreen=!1,this.clickBodyToPlay=!0,this.mutedVideo=!1,this.webDraftLevel=ye.CLOSE_HIGH_FREQUENCY,this.enableEventIntercept=!0,this.videoWidth=0,this.videoHeight=0,this.videoLeft=0,this.videoTop=0,this.videoStatus="pause",this.audioStatus="pause",this.remoteScreenWidth=0,this.remoteScreenHeight=0,this.remoteScreenLeft=0,this.remoteScreenTop=0,this.remoteScreenConfig=null,this.dropMouseEvent=!1,this.videoOrientation=0,this.pageOrientation=null,this.resizeObserver=null,this.mountResizeObserver=null,this.doubleTap=!1,this.doubleTapResponse=[],this.addKMHandlerFlag=!1,this.clientInteractMode="cursor",this.visibilityState="visible",this.sdk=null,this.transformMouseOffset={x:0,y:0},this.mount=null,this.ime=null,this._inputConfig={isComposing:!1,selectionStart:null},window.addEventListener("online",(function(e){n.onNetwork(e)}),!1),window.addEventListener("offline",(function(e){n.onNetwork(e)}),!1),this.onTouch=this.onTouch.bind(this),this.onResize=this.onResize.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onVideoPlaying=this.onVideoPlaying.bind(this),this.onVideoPause=this.onVideoPause.bind(this),this.onVideoEnd=this.onVideoEnd.bind(this),this.onAudioPlaying=this.onAudioPlaying.bind(this),this.onAudioPause=this.onAudioPause.bind(this),this.onAudioEnd=this.onAudioEnd.bind(this),this.onVideoElementClick=this.onVideoElementClick.bind(this),this.onOrientationChange=this.onOrientationChange.bind(this),this.onFakeInputChange=this.onFakeInputChange.bind(this),this.onFakeInputFocus=this.onFakeInputFocus.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.onFocusChange=this.onFocusChange.bind(this),this.sdk=t}return e.prototype.init=function(e){var t,n,r,i,o,s;this.tabletMode=e.tabletMode,this.clickToFullscreen=e.clickToFullscreen,this.clickBodyToPlay=null===(t=e.clickBodyToPlay)||void 0===t||t,this.webDraftLevel=null!==(n=e.webDraftLevel)&&void 0!==n?n:ye.CLOSE_HIGH_FREQUENCY,this.enableEventIntercept=null===(r=e.enableEventIntercept)||void 0===r||r,this.clientInteractMode=e.clientInteractMode||"cursor",this.enablePaste=null!==(i=e.enablePaste)&&void 0!==i?i:this.enablePaste,this.enableMousemoveV2=null===(o=e.enableMousemoveV2)||void 0===o||o,this.enableMouseEventOnMobile=null!==(s=e.enableMouseEventOnMobile)&&void 0!==s&&s,this.mount=e.mount},e.prototype.clearEvent=function(){this.resizeObserver=null,this.mountResizeObserver=null,window.removeEventListener("resize",this.onResize,!1),window.removeEventListener("visibilitychange",this.onVisibilityChange,!1),window.removeEventListener("orientationchange",this.onOrientationChange,!1),window.removeEventListener("focus",this.onFocusChange,!1),window.removeEventListener("blur",this.onFocusChange,!1),document.body.removeEventListener("click",this.onBodyClick,!1),this.sdk.getVideoElement()&&(this.sdk.getVideoElement().removeEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().removeEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().removeEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().removeEventListener("click",this.onVideoElementClick,!1)),this.sdk.getAudioElement()&&(this.sdk.getAudioElement().removeEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().removeEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().removeEventListener("ended",this.onAudioEnd,!1))},e.prototype.addEventHandler=function(){var e=this;this.addKMHandler(),this.addTouchHandler(),Ze()||this.sdk.gamepad.addGamepadHandler(),document.body.removeEventListener("click",this.onBodyClick,!1),document.body.addEventListener("click",this.onBodyClick,!1),this.sdk.getVideoElement().removeEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().addEventListener("playing",this.onVideoPlaying,!1),this.sdk.getVideoElement().removeEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().addEventListener("pause",this.onVideoPause,!1),this.sdk.getVideoElement().removeEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().addEventListener("ended",this.onVideoEnd,!1),this.sdk.getVideoElement().removeEventListener("click",this.onVideoElementClick,!1),this.sdk.getVideoElement().addEventListener("click",this.onVideoElementClick,!1),this.sdk.getAudioElement().removeEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().addEventListener("playing",this.onAudioPlaying,!1),this.sdk.getAudioElement().removeEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().addEventListener("pause",this.onAudioPause,!1),this.sdk.getAudioElement().removeEventListener("ended",this.onAudioEnd,!1),this.sdk.getAudioElement().addEventListener("ended",this.onAudioEnd,!1),window.removeEventListener("orientationchange",this.onOrientationChange,!1),window.addEventListener("orientationchange",this.onOrientationChange,!1),window.addEventListener("resize",this.onResize,!1),document.addEventListener("pointerlockerror",(function(){e.sdk.onEvent({type:"pointerlockerror"})}),!1)},Object.defineProperty(e.prototype,"IMEType",{get:function(){return this.ime},set:function(e){this.ime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputConfig",{get:function(){return this._inputConfig},set:function(e){this._inputConfig=Zt(Zt({},this._inputConfig),e)},enumerable:!1,configurable:!0}),e.prototype.initOrientationDetector=function(){Ze()?this.addOrientationDetector():this.sdk.isMobileGame&&this.addCloudGamingMountOrientationDetector()},e.prototype.setTabletMode=function(e){this.tabletMode=e},e.prototype.setMoveSensitivity=function(e){this.moveSensitivity=1/e},e.prototype.getMoveSensitivity=function(){return this.moveSensitivity},e.prototype.remoteScreenResolutionChange=function(e){var t=e.width,n=e.height,r=e.left,i=e.top;this.remoteScreenWidth===t&&this.remoteScreenHeight===n&&this.remoteScreenLeft===r&&this.remoteScreenTop===i||(this.remoteScreenWidth=t,this.remoteScreenHeight=n,this.remoteScreenLeft=r,this.remoteScreenTop=i,this.sdk.onRemoteScreenResolutionChange({width:t,height:n,top:i,left:r}),this.sdk.log("remoteScreenResolutionChange->".concat(t," ").concat(n," ").concat(r," ").concat(i," ")),this.reshapeWindow())},e.prototype.getRemoteScreenConfig=function(){return this.remoteScreenConfig},e.prototype.setRemoteScreenConfig=function(e){var t=e.degree,n=e.orientation,r=0;"landscape"===n&&(r=270),"portrait"===n&&(r=0),"0_degree"===t&&(r=0),"90_degree"===t&&(r=270),"180_degree"===t&&(r=180),"270_degree"===t&&(r=90),this.remoteScreenConfig=Zt(Zt({},e),{deg:r}),this.sdk.cloudGamingWebRTC.getWebrtcConnectStatus()===fe.ESTABLISHED&&this.sdk.onConfigurationChange({screen_config:this.remoteScreenConfig}),Ze()||this.cloudGamingMountResizeHandler()},e.prototype.clearRemoteKeys=function(){this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"keys_clean"}})},e.prototype.transferLocalScale=function(e){var t=e.width,n=void 0===t?1:t,r=e.height,i=void 0===r?1:r,o=this.videoWidth/this.remoteScreenWidth*n,s=this.videoHeight/this.remoteScreenHeight*i;return 90===this.videoOrientation&&(o=this.videoHeight/this.remoteScreenWidth*i,s=this.videoWidth/this.remoteScreenHeight*n),{width:o,height:s}},e.prototype.mouseMove=function(e,t,n,r){var i,o,s=this.sdk.cloudGamingWebRTC.getDisplayRect(),a=s.left,c=s.top,u=s.width,d=s.height;if(this.tabletMode?(this.tabletModeLastPosition||(this.tabletModeLastPosition={x:n,y:r}),this.mousePosition.x=this.mousePosition.x+(n-this.tabletModeLastPosition.x),this.mousePosition.y=this.mousePosition.y+(r-this.tabletModeLastPosition.y),this.mousePosition.x<=a&&(this.mousePosition.x=a),this.mousePosition.x>=u+a&&(this.mousePosition.x=u+a),this.mousePosition.y<=c&&(this.mousePosition.y=c),this.mousePosition.y>=d+c&&(this.mousePosition.y=d+c),this.tabletModeLastPosition={x:n,y:r}):this.mousePosition={x:n,y:r,movementX:n-this.mousePosition.x,movementY:r-this.mousePosition.y},90===this.videoOrientation?(i=this.mousePosition.y-c,o=this.videoWidth-this.mousePosition.x+a):(i=this.mousePosition.x-a,o=this.mousePosition.y-c),this.updateCursorPosition({displayX:i,displayY:o}),"touchstart"===t)if(this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var l=this.moveTo(i,o),h=l.remoteX,p=l.remoteY;this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:h,y:p}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:h,y:p})}else this.sdk.log("cursor is not showing, cursor will not move");if("touchmove"===t)if(this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var f=this.moveTo(i,o);h=f.remoteX,p=f.remoteY,this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:h,y:p}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:h,y:p})}else{var v=this.deltaMoveTo(this.mousePosition.movementX,this.mousePosition.movementY),m=v.remoteDeltaX,_=v.remoteDeltaY;90===this.videoOrientation?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:_,y:-m}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:m,y:_})}"touchend"!==t&&"touchcancel"!==t||(this.tabletModeLastPosition=null)},e.prototype.mobileTouchMove=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=e.width,s=e.height,a=e.timestamp;this.sdk.cloudGamingWebRTC.sendKmData({type:"event_touch",finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}),this.sdk.onAndroidInstanceEvent({type:"touch_event",data:{finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}})},e.prototype.mobileTouchMoveWebsocket=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=e.width,s=e.height,a=e.timestamp;this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"event_touch",finger_id:t,event_type:n,x:r,y:i,width:o,height:s,timestamp:a}})},e.prototype.fullscreen=function(e){var t;return void 0===e&&(e=document.documentElement),tn(this,0,void 0,(function(){return nn(this,(function(n){switch(n.label){case 0:this.sdk.log("enter fullscreen"),n.label=1;case 1:return n.trys.push([1,6,,7]),Qt.requestFullscreen?[4,e[Qt.requestFullscreen]()]:[3,3];case 2:return n.sent(),[3,5];case 3:return[4,e.webkitEnterFullScreen()];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:throw n.sent();case 7:if(window.self===window.top)try{null===(t=null===navigator||void 0===navigator?void 0:navigator.keyboard)||void 0===t||t.lock(["Escape","F11"])}catch(e){this.sdk.log("lockKeyboard",e)}return[2]}}))}))},e.prototype.exitFullscreen=function(e){var t,n;return void 0===e&&(e=document.documentElement),tn(this,0,void 0,(function(){return nn(this,(function(r){return this.sdk.log("exit fullscreen"),Qt.exitFullscreen?null===(n=null===(t=document[Qt.exitFullscreen]())||void 0===t?void 0:t.catch)||void 0===n||n.call(t,(function(e){return console.log("exit full screen failed, ",null==e?void 0:e.message)})):e.webkitExitFullScreen(),[2]}))}))},e.prototype.resetLastPosition=function(e){var t=e.x,n=void 0===t?0:t,r=e.y,i=void 0===r?0:r;this.mousePosition.x=n,this.mousePosition.y=i},e.prototype.updateCursorPosition=function(e){var t=e.displayX,n=e.displayY,r=this.sdk.getCursorElement();90===this.videoOrientation?(t>this.videoHeight&&(t=this.videoHeight),n>this.videoWidth&&(n=this.videoWidth)):(t>this.videoWidth&&(t=this.videoWidth),n>this.videoHeight&&(n=this.videoHeight)),t<0&&(t=0),n<0&&(n=0),r&&(r.style.top="".concat(n+(90===this.videoOrientation?this.videoLeft:this.videoTop),"px"),r.style.left="".concat(t+(90===this.videoOrientation?this.videoTop:this.videoLeft),"px"),r.style.zIndex="100")},e.prototype.setDropMouseEvent=function(e){this.dropMouseEvent=e},e.prototype.setWebDraftLevel=function(e){void 0===e&&(e=0),this.webDraftLevel=e},e.prototype.setEnableEventIntercept=function(e){void 0===e&&(e=!0),this.enableEventIntercept=e},e.prototype.setVideoOrientation=function(e){var t,n=e.deg,r=void 0===n?0:n,i=e.rotateContainer,o=void 0===i||i,s=e.rotateMountPoint,a=void 0!==s&&s;if(this.sdk.log("setVideoOrientation",r,o,a),function(e){var t=new CustomEvent(e.name,{bubbles:!0,detail:e.data});window.dispatchEvent(t)}({name:"this.sdk:VideoOrientation",data:{deg:r,rotateContainer:o,rotateMountPoint:a}}),o||a){var c=document.querySelector("html");if(a&&(c=this.sdk.isMobileGame?this.sdk.getCloudGamingStreamContainerElement():document.getElementById(null===(t=this.sdk.getInitOptions())||void 0===t?void 0:t.mount)),c)if(c.className=c.className.split(" rotate-html-".concat(this.videoOrientation)).join(""),90===r&&(c.className="".concat(c.className," rotate-html-90")),180===r&&(c.className="".concat(c.className," rotate-html-180")),270===r&&(c.className="".concat(c.className," rotate-html-270")),0===r||180===r)a?(c.style.width=null,c.style.height=null):o&&(c.className="",c.style.width=null,c.style.height=null);else if(Ze())(this.sdk.isMobileGame||a)&&(window.innerHeight>window.innerWidth?(c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px")):setTimeout((function(){c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px")}),100));else if(a){var u=null===document||void 0===document?void 0:document.querySelector("#".concat(this.mount)),d=u.clientWidth,l=u.clientHeight;c.style.width="".concat(l,"px"),c.style.height="".concat(d,"px")}else o&&(c.style.width="".concat(window.innerHeight,"px"),c.style.height="".concat(window.innerWidth,"px"));else this.sdk.log("setVideoOrientation -> can not find mount point")}this.videoOrientation=r,this.reshapeWindow()},e.prototype.getPageOrientation=function(){return this.pageOrientation},e.prototype.reshapeWindow=function(){var e=this;this.sdk.log("reshapeWindow");var t=this.sdk.getVideoElement();if(t){var n=this.sdk.getCloudGamingContainerElement(),r=this.sdk.getInitOptions().fullVideoToScreen,i=void 0===r||r;if(t.videoWidth&&t.videoHeight&&n.clientWidth>t.videoWidth&&n.clientHeight>t.videoHeight&&i&&(n.clientWidth/n.clientHeight>t.videoWidth/t.videoHeight?(t.style.height="100%",t.style.width=null):(t.style.width="100%",t.style.height=null)),(n.clientWidth<t.videoWidth||n.clientHeight<t.videoHeight)&&(t.style.width=null,t.style.height=null),this.sdk.isMobileGame){var o=this.sdk.getCloudGamingStreamContainerElement(),s=o.clientWidth,a=o.clientHeight,c=t.videoWidth;a/s>t.videoHeight/c?(t.style.width="100%",t.style.height=null):(t.style.height="100%",t.style.width=null)}var u=function(){var n=t.getBoundingClientRect(),r=n.width,i=n.height,o=n.top,s=n.left;e.videoWidth=r,e.videoHeight=i,e.videoLeft=s,e.videoTop=o,e.sdk.log("videoResolutionChange-> width: ".concat(e.videoWidth,", height: ").concat(e.videoHeight,", left: ").concat(e.videoLeft,", top: ").concat(e.videoTop))};u(),this.resizeObserver||(this.resizeObserver=new jt((function(){u()})),this.resizeObserver.observe(t))}},e.prototype.setKMStatus=function(e){var t=e.keyboard,n=void 0===t||t,r=e.mouse,i=void 0===r||r;this.kmStatus={keyboard:n,mouse:i}},e.prototype.setKeyboardBanList=function(e){var t=e.keyList;this.keyboardBanList=t},e.prototype.setPaste=function(e){this.enablePaste=e},e.prototype.setVideoMuted=function(e){this.mutedVideo=e},e.prototype.setClientInteractMode=function(e){void 0===e&&(e="cursor"),this.clientInteractMode=e},e.prototype.getClientInteractMode=function(){return this.clientInteractMode},e.prototype.getVisibilityState=function(){return this.visibilityState},Object.defineProperty(e.prototype,"remoteScreenSize",{get:function(){return{width:this.remoteScreenWidth,height:this.remoteScreenHeight,top:this.remoteScreenTop,left:this.remoteScreenLeft}},enumerable:!1,configurable:!0}),e.prototype.addKMHandler=function(){var e=this;if(!this.addKMHandlerFlag){this.addKMHandlerFlag=!0,Ze()&&!this.enableMouseEventOnMobile||(this.webDraftLevel===ye.CLOSE_HIGH_FREQUENCY?document.addEventListener("mousemove",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseMove(t):e.onMouseMove2(t)}),!1):document.addEventListener("pointermove",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseMove(t):e.onMouseMove2(t)}),!1),document.addEventListener("mousedown",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseDown(t):e.onMouseDown2(t)}),!1),document.addEventListener("mouseup",(function(t){"webrtc"===e.sdk.streamingMode?e.onMouseUp(t):e.onMouseUp2(t)}),!1)),document.addEventListener("wheel",(function(t){e.onWheel(t)}),!1),document.addEventListener("keydown",(function(t){e.onKeyEvent(t)}),!1),document.addEventListener("keyup",(function(t){e.onKeyEvent(t)}),!1),document.addEventListener("keypress",(function(){e.onKeyPress()}),!1),document.addEventListener("contextmenu",(function(t){e.onContextMenu(t)}),!1),document.addEventListener("fullscreenchange",(function(){if(Qe()){e.sdk.log("enter fullscreenChange");try{e.sdk.getVideoElement().focus()}catch(t){e.sdk.log("fullscreenChange error,",t)}}e.reshapeWindow()}),!1),window.addEventListener("visibilitychange",(function(){e.onVisibilityChange()}),!1),window.addEventListener("focus",(function(){e.onFocusChange()}),!1),window.addEventListener("blur",(function(){e.onFocusChange()}),!1),document.addEventListener("pointerlockchange",(function(){e.pointerlockchange()})),document.addEventListener("paste",(function(t){e.onPaste(t)}));var t=this.sdk.getFakeInputElement();t.removeEventListener("input",this.onFakeInputChange,!1),t.addEventListener("input",this.onFakeInputChange,!1),t.addEventListener("focus",this.onFakeInputFocus,!1),t.addEventListener("compositionstart",(function(){e._inputConfig.isComposing=!0})),t.addEventListener("compositionend",(function(){e._inputConfig.isComposing=!1,e.sdk.androidInstance.inputText({content:t.value,mode:"override",index_after_override:e.inputConfig.selectionStart})}))}},e.prototype.addTouchHandler=function(){var e=this.sdk.getCloudGamingContainerElement();e.removeEventListener("touchmove",this.onTouch,!1),e.removeEventListener("touchstart",this.onTouch,!1),e.removeEventListener("touchend",this.onTouch,!1),e.removeEventListener("touchcancel",this.onTouch,!1),e.addEventListener("touchmove",this.onTouch,!1),e.addEventListener("touchstart",this.onTouch,!1),e.addEventListener("touchend",this.onTouch,!1),e.addEventListener("touchcancel",this.onTouch,!1),document.addEventListener("gesturestart",(function(e){e.preventDefault()}))},e.prototype.onResize=function(){var e=this;this.sdk.log("onresize","window.innerWidth",window.innerWidth,"window.innerHeight",window.innerHeight),setTimeout((function(){e.reshapeWindow()}),0)},e.prototype.addOrientationDetector=function(){var e=this,t=this.sdk.getInitOptions(),n=t.autoRotateContainer,r=t.autoRotateMountPoint,i=window.matchMedia("(orientation: portrait)"),o=function(t){if(t.matches){e.pageOrientation="portrait",(n||r)&&e.setVideoOrientation({deg:e.sdk.isMobileGame&&e.isPortraitStream?0:90,rotateContainer:n,rotateMountPoint:r});try{e.sdk.onOrientationChange({type:"portrait"})}catch(t){e.sdk.log("onOrientationChange callback error",t)}}else{e.pageOrientation="landscape",(n||r)&&e.setVideoOrientation({deg:e.sdk.isMobileGame&&e.isPortraitStream?270:0,rotateContainer:n,rotateMountPoint:r});try{e.sdk.onOrientationChange({type:"landscape"})}catch(t){e.sdk.log("onOrientationChange callback error",t)}}};o(i),i.addListener(o)},e.prototype.cloudGamingMountResizeHandler=function(){var e,t;if(this.sdk.isMobileGame&&this.sdk.getGameMountPoint()){var n=this.getRemoteScreenConfig(),r=n.orientation,i=n.degree,o=0;"landscape"===r&&(o=270),"portrait"===r&&(o=0),"0_degree"===i&&(o=0),"90_degree"===i&&(o=270),"180_degree"===i&&(o=180),"270_degree"===i&&(o=90),(null===(t=null===(e=this.sdk.getInitOptions())||void 0===e?void 0:e.androidInstance)||void 0===t?void 0:t.autoRotateOnPC)&&this.setVideoOrientation({rotateMountPoint:!0,deg:o})}},e.prototype.addCloudGamingMountOrientationDetector=function(){var e=this,t=this.sdk.getGameMountPoint();this.mountResizeObserver||(this.mountResizeObserver=new jt((function(){e.cloudGamingMountResizeHandler()})),this.mountResizeObserver.observe(t))},Object.defineProperty(e.prototype,"isPortraitStream",{get:function(){var e=this.sdk.getRemoteStreamResolution(),t=e.width;return e.height>t},enumerable:!1,configurable:!0}),e.prototype.onVisibilityChange=function(){var e=this;this.clearRemoteKeys(),this.sdk.log("visibilitychange",document.hidden?"hidden":"visible"),document.hidden?(this.visibilityState="hidden",Ze()&&(this.touchesIdentifierMap.clear(),this.sdk.clearRemoteKeys(),setTimeout((function(){e.sdk.isMobileGame||e.sdk.sendMouseEvent({type:"mouseleft",down:!1}),e.touchesMap.clear()}),100))):(this.visibilityState="visible","websocket"===this.sdk.streamingMode&&this.sdk.getVideoElement().play()),this.sdk.onVisibilityChange({status:this.visibilityState})},e.prototype.onNetwork=function(e){this.sdk.log("onNetwork",e.type),this.sdk.onNetworkChange({status:e.type})},e.prototype.onFocusChange=function(){this.clearRemoteKeys()},e.prototype.pointerlockchange=function(){},e.prototype.onPaste=function(e){console.log("onPaste",e,e.clipboardData.getData("text/plain"))},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.transferRemotePosition=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=Math.round(n*this.remoteScreenWidth/this.videoWidth/s)+this.remoteScreenLeft,c=Math.round(i*this.remoteScreenHeight/this.videoHeight/s)+this.remoteScreenTop;return 90!==this.videoOrientation&&270!==this.videoOrientation||(a=Math.round(n*this.remoteScreenWidth/this.videoHeight/s)+this.remoteScreenLeft,c=Math.round(i*this.remoteScreenHeight/this.videoWidth/s)+this.remoteScreenTop),{x:a,y:c}},e.prototype.transferRemotePositionV2=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=n/this.videoWidth/s,c=i/this.videoHeight/s;return 90!==this.videoOrientation&&270!==this.videoOrientation||(a=n/this.videoHeight/s,c=i/this.videoWidth/s),{x:Math.round(8192*a),y:Math.round(8192*c)}},e.prototype.transferRemotePositionDeltaMove=function(e){var t=e.displayX,n=void 0===t?1:t,r=e.displayY,i=void 0===r?1:r,o=e.moveSensitivity,s=void 0===o?1:o,a=n*this.remoteScreenWidth/this.videoWidth/s,c=i*this.remoteScreenHeight/this.videoHeight/s,u=a+this.transformMouseOffset.x,d=c+this.transformMouseOffset.y,l=Math.round(u)+this.remoteScreenLeft,h=Math.round(d)+this.remoteScreenTop;if(this.transformMouseOffset.x=u-Math.round(u),this.transformMouseOffset.y=d-Math.round(d),90===this.videoOrientation||270===this.videoOrientation){var p=n*this.remoteScreenWidth/this.videoHeight/s,f=i*this.remoteScreenHeight/this.videoWidth/s;l=Math.round(p)+this.remoteScreenLeft,h=Math.round(f)+this.remoteScreenTop,this.transformMouseOffset.x=Math.round(p)-p,this.transformMouseOffset.y=Math.round(f)-f}return{x:l,y:h}},Object.defineProperty(e.prototype,"touchesList",{get:function(){var e,t,n=[];if(this.touchesMap.size)try{for(var r=rn(this.touchesMap.values()),i=r.next();!i.done;i=r.next()){var o=i.value;n.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},enumerable:!1,configurable:!0}),e.prototype.onTouch=function(e){var t,n,r=this,i=e.type,o=e.timeStamp,s=e.targetTouches,a=e.changedTouches,c=function(e){var t=e.pageX,n=e.pageY,s=e.identifier,a=u.transferRemotePosition({displayX:t-u.videoLeft,displayY:n-u.videoTop}),c=a.x,d=a.y;c-=u.remoteScreenLeft,d-=u.remoteScreenTop;var l=u.touchesForDelta||{lastX:c,lastY:d},h=(c-l.lastX)/u.moveSensitivity,p=(d-l.lastY)/u.moveSensitivity;if(u.touchesForDelta={lastX:c,lastY:d},"touchstart"===i&&(sn([],on(u.touchesIdentifierMap.values()),!1).includes(u.touchesIdentifierMap.size)?u.touchesIdentifierMap.set(s,u.touchesIdentifierMap.size+1):u.touchesIdentifierMap.set(s,u.touchesIdentifierMap.size)),u.sdk.isMobileGame||"touch"===u.clientInteractMode){var f=i;if(270===u.videoOrientation){var v=u.transferRemotePosition({displayX:u.videoHeight-n+u.videoTop,displayY:t-u.videoLeft}),m=v.x,_=v.y;c=m-u.remoteScreenLeft,d=_-u.remoteScreenTop}if(90===u.videoOrientation){var g=u.transferRemotePosition({displayX:n-u.videoTop,displayY:u.videoWidth-t+u.videoLeft});m=g.x,_=g.y,c=m-u.remoteScreenLeft,d=_-u.remoteScreenTop}if("touch"===u.clientInteractMode&&(c>u.remoteScreenWidth&&(c=u.remoteScreenWidth),d>u.remoteScreenHeight&&(d=u.remoteScreenHeight),c<0&&(c=0),d<0&&(d=0)),u.mobileTouchMove({finger_id:u.touchesIdentifierMap.get(s),event_type:Se[f],x:c,y:d,width:u.remoteScreenWidth,height:u.remoteScreenHeight,timestamp:o}),"touch"===u.clientInteractMode){var y=void 0,S=void 0;90===u.videoOrientation?(y=n-u.videoTop,S=u.videoWidth-t+u.videoLeft):(y=t-u.videoLeft,S=n-u.videoTop),u.updateCursorPosition({displayX:y,displayY:S})}}var b={id:s,type:i,x:c,y:d,pageX:t,pageY:n,movementX:h,movementY:p};u.touchesMap.set(s,b),"touchend"!==i&&"touchcancel"!==i||(u.touchesIdentifierMap.delete(s),setTimeout((function(){r.touchesMap.delete(s)}),100)),"touchstart"!==i||u.sdk.isMobileGame||(u.doubleTapResponse.push(b),u.doubleTap?u.sdk.onDoubleTap(u.doubleTapResponse):(u.doubleTap=!0,setTimeout((function(){r.doubleTap=!1,r.doubleTapResponse=[]}),300)))},u=this;try{for(var d=rn("touchend"===i||"touchcancel"===i||this.sdk.isMobileGame||"touch"===this.clientInteractMode?a:s),l=d.next();!l.done;l=d.next())c(l.value)}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}this.sdk.isMobileGame||"touch"===this.clientInteractMode||this.sdk.onTouchEvent(this.touchesList)},e.prototype.onMouseMove=function(e){var t,n;if(!1!==this.kmStatus.mouse&&!this.dropMouseEvent){var r="getCoalescedEvents"in e?e.getCoalescedEvents():[e],i=null;this.webDraftLevel===ye.UNPACKAGE_SEND&&r.length>3?(this.sdk.log("webDraftLevel 1, event length is ".concat(r.length,", only pick 3 events")),r.splice(0,r.length-3)):this.webDraftLevel===ye.PACKAGE_SEND&&(this.sdk.log("webDraftLevel 2, event length is ".concat(r.length,", will send seq events")),i=[]);try{for(var o=rn(r),s=o.next();!s.done;s=o.next()){var a=s.value,c=a.offsetX,u=a.offsetY,d=a.movementX,l=a.movementY,h=c,p=u;if(h<0&&(h=0),p<0&&(p=0),this.sdk.cloudGamingWebRTC.getCursorMode()===ve.FRONT_DRAW_DELTA_POS)if(this.sdk.cloudGamingWebRTC.isMouseLocked()){if(!this.remoteMousePosition.sent){var f=this.remoteMousePosition,v=f.x,m=f.y;this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:v,y:m}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:v,y:m}),this.remoteMousePosition.sent=!0}var _=this.deltaMoveTo(d,l),g=_.remoteDeltaX,y=_.remoteDeltaY;this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:g,y:y}),this.drawMouseDeltaPosition(d,l)}else{var S=this.moveTo(h,p),b=S.remoteX,k=S.remoteY;this.remoteMousePosition.x=b,this.remoteMousePosition.y=k,this.remoteMousePosition.sent=!1,this.mousePosition.deltaX=h,this.mousePosition.deltaY=p}else if(this.sdk.cloudGamingWebRTC.mouseDeltaMove()||!this.sdk.cloudGamingWebRTC.getCursorShowStatus()){var E=this.deltaMoveTo(d,l);g=E.remoteDeltaX,y=E.remoteDeltaY,i?i.push({type:"mousedeltamove",x:g,y:y}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousedeltamove",x:g,y:y})}else{var T=this.moveTo(h,p);if(b=T.remoteX,k=T.remoteY,i)this.enableMousemoveV2?i.push({type:"mousemove_v2",x:b,y:k}):i.push({type:"mousemove",x:b,y:k});else if(this.sdk.isMobileGame||"touch"===this.clientInteractMode){if(this.mousePosition.remoteX=b,this.mousePosition.remoteY=k,this.touchState!==Se.touchstart)return;this.mobileTouchMove({finger_id:0,event_type:Se.touchmove,x:b,y:k,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}else this.enableMousemoveV2?this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove_v2",x:b,y:k}):this.sdk.cloudGamingWebRTC.sendKmData({type:"mousemove",x:b,y:k})}this.mousePosition.x=h,this.mousePosition.y=p}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}this.webDraftLevel===ye.PACKAGE_SEND&&this.sdk.cloudGamingWebRTC.sendKmData({type:"key_seq",keys:i.map((function(e){return JSON.stringify(e)}))})}},e.prototype.onMouseMove2=function(e){var t,n;if(!1!==this.kmStatus.mouse&&!this.dropMouseEvent){var r="getCoalescedEvents"in e?e.getCoalescedEvents():[e];try{for(var i=rn(r),o=i.next();!o.done;o=i.next()){var s=o.value,a=s.offsetX,c=s.offsetY,u=a,d=c;u<0&&(u=0),d<0&&(d=0);var l=this.moveTo(u,d),h=l.remoteX,p=l.remoteY;if(this.mousePosition.remoteX=h,this.mousePosition.remoteY=p,this.sdk.isMobileGame&&this.touchState!==Se.touchstart)return;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchmove,x:h,y:p,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}},e.prototype.drawMouseDeltaPosition=function(e,t){var n=this.sdk.cloudGamingWebRTC.getCursorShowStatus();this.sdk.getCursorElement().style.display=n?"block":"none";var r=this.sdk.cloudGamingWebRTC.getDisplayRect(),i=r.width,o=r.height;this.mousePosition.deltaX=this.mousePosition.deltaX+e,this.mousePosition.deltaY=this.mousePosition.deltaY+t,this.mousePosition.deltaX<=0&&(this.mousePosition.deltaX=0),this.mousePosition.deltaX>=i&&(this.mousePosition.deltaX=i),this.mousePosition.deltaY<=0&&(this.mousePosition.deltaY=0),this.mousePosition.deltaY>=o&&(this.mousePosition.deltaY=o);var s=this.sdk.cloudGamingWebRTC.getCursorHotSpot();this.updateCursorPosition({displayX:this.mousePosition.deltaX-s.x,displayY:this.mousePosition.deltaY-s.y})},e.prototype.moveTo=function(e,t){if(this.enableMousemoveV2&&!this.sdk.isMobileGame&&"touch"!==this.clientInteractMode){var n=this.transferRemotePositionV2({displayX:e,displayY:t});return{remoteX:n.x,remoteY:n.y}}var r=this.transferRemotePosition({displayX:e,displayY:t}),i=r.x,o=r.y;return i>=this.remoteScreenWidth+this.remoteScreenLeft&&(i=this.remoteScreenWidth+this.remoteScreenLeft-1),i<0&&(i=0),o>=this.remoteScreenHeight+this.remoteScreenTop&&(o=this.remoteScreenHeight+this.remoteScreenTop-1),o<0&&(o=0),{remoteX:i,remoteY:o}},e.prototype.deltaMoveTo=function(e,t){var n=this.transferRemotePositionDeltaMove({displayX:e,displayY:t,moveSensitivity:this.moveSensitivity}),r=n.x,i=n.y,o=r-this.remoteScreenLeft,s=i-this.remoteScreenTop;return this.deltaMoveToCalcX+=o,this.deltaMoveToCalcY+=s,this.deltaMoveToCalcX<0&&(this.deltaMoveToCalcX=0),this.deltaMoveToCalcY<0&&(this.deltaMoveToCalcY=0),this.deltaMoveToCalcX>this.remoteScreenWidth&&(this.deltaMoveToCalcX=this.remoteScreenWidth),this.deltaMoveToCalcY>this.remoteScreenHeight&&(this.deltaMoveToCalcX=this.remoteScreenHeight),{remoteDeltaX:o,remoteDeltaY:s}},e.prototype.isRightClick=function(e){return"which"in e?3===e.which:"button"in e?2===e.button:void 0},e.prototype.determineButtonType=function(e){var t;return null!==(t=["mouseleft","mousemiddle","mouseright","mousebackward","mouseforward","unused","unused"][e.button])&&void 0!==t?t:""},e.prototype.onMouseDown=function(e){if(!1!==this.kmStatus.mouse){var t=e.offsetX,n=e.offsetY;if(this.mouseClickPosition={x:t,y:n},this.sdk.isMobileGame||"touch"===this.clientInteractMode){var r=this.determineButtonType(e);if(this.sdk.isMobileGame&&"mouseleft"!==r)return;var i=this.mousePosition,o=i.remoteX,s=i.remoteY;this.mobileTouchMove({finger_id:0,event_type:Se.touchstart,x:o,y:s,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchstart}else this.sdk.cloudGamingWebRTC.sendKmData({type:this.determineButtonType(e),down:!0}),this.mouseState=be.mousedown,this.isRightClick(e)&&this.tryToCursorLock();3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onMouseDown2=function(e){if(!1!==this.kmStatus.mouse){var t=this.mousePosition,n=t.remoteX,r=t.remoteY;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchstart,x:n,y:r,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchstart,3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onMouseUp=function(e){if(!1!==this.kmStatus.mouse)if(this.sdk.isMobileGame||"touch"===this.clientInteractMode){var t=this.determineButtonType(e);if(this.sdk.isMobileGame&&"mouseleft"!==t)return;if(this.touchState===Se.touchstart){var n=this.mousePosition,r=n.remoteX,i=n.remoteY;this.mobileTouchMove({finger_id:0,event_type:Se.touchend,x:r,y:i,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date})}this.touchState=Se.touchend}else this.mouseState===be.mousedown&&this.sdk.cloudGamingWebRTC.sendKmData({type:this.determineButtonType(e),down:!1}),this.mouseState=be.mouseup},e.prototype.onMouseUp2=function(e){if(!1!==this.kmStatus.mouse){var t=this.mousePosition,n=t.remoteX,r=t.remoteY;this.mobileTouchMoveWebsocket({finger_id:0,event_type:Se.touchend,x:n,y:r,width:this.remoteScreenWidth,height:this.remoteScreenHeight,timestamp:+new Date}),this.touchState=Se.touchend,3!==e.button&&4!==e.button||e.preventDefault()}},e.prototype.onWheel=function(e){var t,n=this,r=e.deltaX,i=e.deltaY,o=Math.abs(i)>=Math.abs(r)?"vertical":"horizontal",s=this.mousePosition,a=s.remoteX,c=s.remoteY,u=function(e){var t=e.delta,r=e.type;n.sdk.cloudGamingWebRTC.sendKmData({type:r,delta:t,x:a,y:c,width:n.remoteScreenWidth,height:n.remoteScreenHeight})};if(null===(t=Ye().ua)||void 0===t?void 0:t.includes("Mac")){if(!0===this.wheeling)return;this.wheeling=!0,"vertical"===o&&u({delta:i,type:"mousescroll"}),"horizontal"===o&&u({delta:r,type:"mousehorizontalscroll"}),setTimeout((function(){n.wheeling=!1}),100)}else"vertical"===o&&u({delta:i,type:"mousescroll"}),"horizontal"===o&&u({delta:r,type:"mousehorizontalscroll"})},e.prototype.onKeyEvent=function(e){var t,n,r,i=this;if(e.preventDefault(),!1!==this.kmStatus.keyboard){var o=e.which||e.keyCode,s=e.ctrlKey,a=e.altKey,c=e.type,u=e.metaKey,d=e.location,l=e.key;if(!this.keyboardBanList.includes(o)){if("keyup"===c){if(s){if(o===St.Space)return this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!0}),void setTimeout((function(){i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!1})}),10);o===St.Backquote&&this.sdk.showStats.toggleStatisticsView()}o===St.Escape&&(+new Date-this.escPressTime>300&&this.sdk.cloudGamingWebRTC.lockMouse(!1),this.escPressTime=null),(null===(t=Ye().ua)||void 0===t?void 0:t.includes("Mac"))&&"Meta"===l&&sn([],on(this.keyboardPressedKeys.keys()),!1).forEach((function(e){e!==St.LeftWindowKey&&e!==St.SelectKey&&i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:e,down:!1}),i.keyboardPressedKeys.delete(e)}))}if("keydown"===c){if((null===(n=Ye().ua)||void 0===n?void 0:n.includes("Mac"))&&this.keyboardPressedKeys.set(o,e),o===St.X&&a||o===St.Escape?(o===St.X&&a&&this.sdk.cloudGamingWebRTC.lockMouse(!1),o===St.Escape&&(this.escPressTime||(this.escPressTime=+new Date))):this.tryToCursorLock(),this.enablePaste&&(u||s)&&o===St.V)return void(navigator.clipboard?navigator.clipboard.readText().then((function(e){i.sdk.sendText(e)})).catch((function(e){i.sdk.log("Failed to read clipboard contents: ",e),i.sdk.onEvent({type:"readclipboarderror",data:{message:e.message}})})):this.sdk.onEvent({type:"readclipboarderror"}));if(a&&o===St.F4)return void this.sdk.log("alt + f4 is forbidden")}if((null===(r=Ye().ua)||void 0===r?void 0:r.includes("Mac"))&&o===St.CapsLock)return this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!0}),void setTimeout((function(){i.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:!1})}),10);"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendKmData({type:"keyboard",key:o,down:"keydown"===c,location:d}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"keyboard",key:o,down:"keydown"===c,location:d}})}}},e.prototype.onKeyPress=function(){},e.prototype.onBodyClick=function(){var e,t=this;if(this.clickBodyToPlay){var n=this.sdk.getVideoElement(),r=this.sdk.getAudioElement();if(n&&this.sdk.cloudGamingWebRTC.getWebrtcConnectStatus()===fe.ESTABLISHED){this.mutedVideo||(r.muted=!1);try{"pause"===this.videoStatus&&n.pause(),n.play().then((function(){})).catch((function(e){t.sdk.log("onbody click play error",e)})),r.play().catch((function(e){t.sdk.log("onbody click play audio error",e)}))}catch(e){this.sdk.log("play video error",e)}}if("websocket"===this.sdk.streamingMode){var i=document.querySelector(".".concat(this.mount," .cloud-gaming-audio-stream-socket"));n&&n.play().catch((function(e){t.sdk.log("onbody click play error",e)})),i&&(null===(e=this.sdk.cloudGamingWebsocket.getMuxer("video"))||void 0===e||e.playCurrent(),this.mutedVideo||(i.muted=!1),i.play().catch((function(e){t.sdk.log("onbody click play audio error",e)})))}var o=this.sdk.getHuaweiAudioElement();o&&(this.mutedVideo||(o.muted=!1),o.play()),Ze()||Qe()||!this.clickToFullscreen||(this.sdk.log("click to fullscreen->",this.clickToFullscreen),this.fullscreen())}},e.prototype.onVideoPlaying=function(e){this.videoStatus="playing","webrtc"===this.sdk.streamingMode&&(this.sdk.log("video state",e.type),this.reshapeWindow(),this.sdk.onEvent({type:"video_state",data:{code:0,message:"playing"}}))},e.prototype.onVideoPause=function(e){this.sdk.log("video state",e.type),this.videoStatus="pause",this.sdk.onEvent({type:"video_state",data:{code:1,message:"pause"}})},e.prototype.onVideoEnd=function(e){this.sdk.log("video state",e.type),this.videoStatus="pause",this.sdk.onEvent({type:"video_state",data:{code:2,message:"ended"}})},e.prototype.onAudioPlaying=function(e){this.sdk.log("audio state",e.type),this.audioStatus="playing",this.sdk.onEvent({type:"audio_state",data:{code:0,message:"playing"}})},e.prototype.onAudioPause=function(e){this.sdk.log("audio state",e.type),this.audioStatus="pause",this.sdk.onEvent({type:"audio_state",data:{code:1,message:"pause"}})},e.prototype.onAudioEnd=function(e){this.sdk.log("audio state",e.type),this.audioStatus="pause",this.sdk.onEvent({type:"audio_state",data:{code:2,message:"ended"}})},e.prototype.onVideoElementClick=function(){this.sdk.getVideoElement().focus(),this.sdk.cloudGamingWebRTC.getCursorMode()===ve.FRONT_DRAW_DELTA_POS&&this.sdk.cloudGamingWebRTC.lockMouse(!0)},e.prototype.onFakeInputFocus=function(){if("local"===this.IMEType){var e=this.sdk.getFakeInputElement(),t=this.sdk.getCloudGamingContainerElement();e&&t&&(e.style.top="".concat(this.mouseClickPosition.y+(t.clientHeight-this.videoHeight)/2-5,"px"),e.style.left="".concat(this.mouseClickPosition.x+(t.clientWidth-this.videoWidth)/2,"px"))}},e.prototype.onFakeInputChange=function(e){var t=e.target,n=t.value,r=t.selectionStart;this.inputConfig.selectionStart=r,this.inputConfig.isComposing||this.sdk.androidInstance.inputText({content:n,mode:"override",index_after_override:r})},e.prototype.onOrientationChange=function(){var e=this;this.sdk.log("orientationchange"),setTimeout((function(){e.reshapeWindow()}),0)},e.prototype.tryToCursorLock=function(){if(!this.sdk.cloudGamingWebRTC.getForceShowCursor()){var e=document.pointerLockElement;e||this.sdk.cloudGamingWebRTC.getCursorShowStatus()&&!this.sdk.cloudGamingWebRTC.mouseDeltaMove()||(this.sdk.cloudGamingWebRTC.lockMouse(!0),this.sdk.log("tryToCursorLock",e,"forceShowCursor",this.sdk.cloudGamingWebRTC.getForceShowCursor()),this.sdk.log("toggleMouseLock true, auto run requestPointerLock"))}},en([bt()],e.prototype,"onContextMenu",null),en([bt()],e.prototype,"onTouch",null),en([bt()],e.prototype,"onMouseMove",null),en([bt()],e.prototype,"onMouseMove2",null),en([bt()],e.prototype,"onMouseDown",null),en([bt()],e.prototype,"onMouseDown2",null),en([bt()],e.prototype,"onMouseUp2",null),en([bt()],e.prototype,"onWheel",null),en([bt("keyEvent")],e.prototype,"onKeyEvent",null),e}();const cn=an;var un,dn='\n<div class="cloud-gaming-container" tabindex="-1">\n\n <div class="cloud-gaming-stream-container">\n <video class="video-stream" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay muted preload="auto"></video>\n <audio class="audio-stream" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay preload="auto"></audio>\n <audio class="cloud-gaming-audio-stream-socket" tabindex="-1" playsinline webkit-playsinline x5-playsinline autoplay preload="auto"></audio>\n <div class="cursor" id="cursor"></div>\n <input class="tcg-fake-input"></input>\n </div>\n\n '.concat('\n<div class="qcloud-stat">\n \n <div class="qcloud-video">\n <div class="qcloud-stat-video">\n <div class="qcloud-stat-left">Video</div>\n </div>\n </div>\n\n <div class="qcloud-audio">\n <div class="qcloud-stat-audio">\n <div class="qcloud-stat-left">Audio</div>\n </div>\n </div>\n\n <div class="qcloud-info">\n <div class="qcloud-stat-info">\n <div class="qcloud-stat-left">Info</div>\n </div>\n </div>\n\n</div>','\n\n <div class="progress-bar-container">\n <div class="spinner"> </div>\n <p class="starting">正在启动云渲染服务</p>\n <p id="speed" class="starting"></p>\n </div>\n\n <a class="restart" href="javascript:window.location.reload();">重新连接</a>\n</div>'),ln=E8(206),hn=E8.n(ln),pn=E8(652),fn=E8.n(pn),vn={packetsReceived:0,packetsLost:0,nack:0,rttAverage:0,rttVariance:0,nackRate:0,packetsLostRate:0};!function(e){e[e.NETWORK_NORMAL=0]="NETWORK_NORMAL",e[e.NETWORK_CONGESTION=1]="NETWORK_CONGESTION",e[e.NACK_RISING=2]="NACK_RISING",e[e.HIGH_DELAY=3]="HIGH_DELAY",e[e.NETWORK_JITTER=4]="NETWORK_JITTER"}(un||(un={}));var mn=function(e){var t=e.packetsReceived,n=void 0===t?0:t,r=e.packetsLost,i=void 0===r?0:r,o=e.nack,s=void 0===o?0:o,a=e.rtt,c=void 0===a?[]:a,u=e.featureSwitch,d=void 0===u?{}:u,l=n-vn.packetsReceived;vn.packetsReceived=n;var h=i-vn.packetsLost;vn.packetsLost=i,vn.packetsLostRate=h/l;var p=i-vn.nack;vn.nack=s,vn.nackRate=p/l,vn.rttAverage=c.reduce((function(e,t){return e+t}),0)/c.length,vn.rttVariance=function(e){if(void 0===e&&(e=[]),!e.length)return 0;var t=e.reduce((function(e,t){return e+t}),0),n=e.length,r=t/n,i=0;return e.forEach((function(e){i+=(e-r)*(e-r)})),i/=n,Math.floor(i)}(c);var f=d.network_event_script,v=void 0===f?{}:f,m=v.loss_rate_threshold,_=v.nack_rate_threshold,g=v.rtt_avg_threshold,y=v.rtt_dev_threshold;return vn.packetsLostRate>m?un.NETWORK_CONGESTION:vn.nackRate>_?un.NACK_RISING:vn.rttAverage>g?un.HIGH_DELAY:vn.rttVariance>y?un.NETWORK_JITTER:un.NETWORK_NORMAL},_n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},gn=function(){function e(e){var t=e.sdk;this.inputDelay=0,this.inputSeqMap={},this.rttSum=0,this.rttCount=0,this.rttArray=[],this.rtt=0,this.rawRTT=0,this.latency={times:0,status:null},this.fps=null,this.delay=null,this.cpu="0",this.bitrate=null,this.lastBytesRevc=0,this.packetLost=null,this.nack=null,this.packetsReceived=null,this.framesDecoded=null,this.framesDropped=null,this.framesReceived=null,this.firCount=null,this.pliCount=null,this.decodems=null,this.interfameDelayMaxMs=null,this.frameWidth=null,this.frameHeight=null,this.packetsLossRate=0,this.codec="",this.jitterBuffer=0,this.lastFramesReceived=0,this.gpu="",this.audioFps=null,this.audioLevel=0,this.audioBitrate=null,this.audioLastBytesRevc=0,this.audioPacketsLost=null,this.audioPacketsReceived=null,this.audioNack=null,this.audioConcealedSamples=0,this.audioConcealmentEvents=0,this.audioJitterBuffer=0,this.audioTotalSamplesReceived=0,this.audioTotalSamplesDuration=0,this.audioSampleRate=0,this.audioChannels=0,this.audioPacketsLossRate=0,this.audioCodec="",this.metricBulk=[],this.reportTimer=null,this.serverSessionCost=0,this.connectSuccessTimeCost=0,this.iceConnectedCost=0,this.sdk=null,this.mount=null,this.sdk=t}return Object.defineProperty(e.prototype,"isShowing",{get:function(){return!!this.getQcloudStatElement()&&"none"!==this.getQcloudStatElement().style.display},enumerable:!1,configurable:!0}),e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.show=function(e){this.getQcloudStatElement()&&(this.getQcloudStatElement().style.display=e?"block":"none")},e.prototype.toggleStatisticsView=function(){var e=document.querySelector("#__vconsole");this.show(!this.isShowing),e&&(e.style.display=this.isShowing?"":"none")},e.prototype.getStats=function(){var e=this.sdk.gameConfig.getConfig({clientId:this.mount}).user_id;return{fps:this.fps,delay:this.delay,rtt:this.rtt,cpu:this.cpu,load_cost_time:this.connectSuccessTimeCost-this.serverSessionCost,bit_rate:this.bitrate,packet_lost:this.packetLost,nack:this.nack,packet_received:this.packetsReceived,gpu:this.gpu,input_delay:this.inputDelay,user_id:e,timestamp:+new Date}},e.prototype.getMediaStats=function(){return{videoStats:{fps:this.fps,rtt:this.rtt,bit_rate:it(+this.bitrate/1024/1024*8),packet_lost:this.packetLost,packet_received:this.packetsReceived,packet_loss_rate:this.packetsLossRate,nack:this.nack,jitter_buffer:this.jitterBuffer,width:this.frameWidth,height:this.frameHeight,codec:this.codec,timestamp:+new Date},audioStats:{sample_rate:this.audioSampleRate,channels:this.audioChannels,bit_rate:it(+this.audioBitrate/1024/1024*8),packet_lost:this.audioPacketsLost,packet_received:this.audioPacketsReceived,packet_loss_rate:this.audioPacketsLossRate,nack:this.audioNack,jitter_buffer:this.audioJitterBuffer,concealed_samples:this.audioConcealedSamples,concealment_events:this.audioConcealmentEvents,codec:this.audioCodec}}},e.prototype.setStat=function(e,t){var n,r,i,o,s,a=[],c=[];e.forEach((function(e){"inbound-rtp"===e.type&&("video"!==e.mediaType&&"video"!==e.kind||c.push(e),"audio"!==e.mediaType&&"audio"!==e.kind||a.push(e)),"track"===e.type&&(e.frameHeight||e.frameWidth||"video"===e.kind)&&c.push(e),"track"!==e.type||e.frameHeight&&e.frameWidth||a.push(e)}));try{for(var u=_n(c),d=u.next();!d.done;d=u.next()){var l=d.value,h=l.type,p=l.frameWidth,f=void 0===p?0:p,v=l.frameHeight,m=void 0===v?0:v,_=l.framesPerSecond,g=l.framerateMean,y=l.totalDecodeTime,S=void 0===y?0:y,b=l.framesDropped,k=void 0===b?0:b,E=l.firCount,T=void 0===E?0:E,C=l.pliCount,I=void 0===C?0:C,w=l.jitterBufferDelay,R=void 0===w?0:w,A=l.bytesReceived,O=void 0===A?0:A,x=l.nackCount,P=void 0===x?0:x,D=l.packetsLost,M=void 0===D?0:D,N=l.packetsReceived,L=void 0===N?0:N,U=l.framesReceived,V=void 0===U?0:U,F=l.jitter,B=l.totalInterFrameDelay,j=void 0===B?0:B,G=l.codecId,H=void 0===G?"":G,W=l.remoteSource,K=l.transportId,z=l.framesDecoded,q=void 0===z?0:z,J=l.jitterBufferEmittedCount;if((ue=void 0===J?0:J)||(ue=1),q||(q=1),"track"===h&&(W&&this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:"".concat(f,"x").concat(m),point:"qcloud-video"}),!(null===(s=Ye().name)||void 0===s?void 0:s.toLowerCase().includes("safari"))&&_||!W||(this.fps=V-this.lastFramesReceived,this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"}),this.lastFramesReceived=V),this.jitterBuffer=it(R/ue*1e3),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"})),"inbound-rtp"===h){this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:"".concat(f,"x").concat(m),point:"qcloud-video"}),this.frameWidth===f&&this.frameHeight===m||(this.frameWidth=f,this.frameHeight=m,this.sdk.onVideoStreamConfigChange({width:f,height:m}),this.sdk.log("video stream resolution changed ->".concat(f," ").concat(m)));var Y=((null==t?void 0:t.get(H))||{}).mimeType,X=void 0===Y?"":Y;this.modifyStatElement({name:"Codec",tag:"video-codec",stat:X,point:"qcloud-video"}),this.codec=X,_&&(this.fps=_,this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"})),g&&(this.fps=Math.floor(g),this.modifyStatElement({name:"FPS",tag:"video-fps",stat:"".concat(this.fps),point:"qcloud-video"}),this.jitterBuffer=Math.floor(1e3*F),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"})),this.bitrate=O-this.lastBytesRevc;var $=it(+this.bitrate/1024/1024*8);this.modifyStatElement({name:"VideoBitrate",tag:"video-bitrates",stat:"".concat($,"Mbit/s"),point:"qcloud-video"}),this.lastBytesRevc=O;var Q=it((M-this.packetLost)/(L-this.packetsReceived));this.packetsLossRate=Q,this.packetLost=M,this.packetsReceived=L,this.packetLost=M<0?0:M,this.modifyStatElement({name:"PacketLost",tag:"video-packet-lost",stat:"".concat(this.packetLost),point:"qcloud-video"}),this.nack=P,this.modifyStatElement({name:"NACK",tag:"video-nack",stat:"".concat(this.nack),point:"qcloud-video"}),this.jitterBuffer=it(R/ue*1e3),this.modifyStatElement({name:"JitterBuffer",tag:"video-jitter-buffer",stat:"".concat(this.jitterBuffer,"ms"),point:"qcloud-video"}),this.delay=it(+(S/q*1e3+this.jitterBuffer)),this.modifyStatElement({name:"Delay",tag:"video-delay",stat:"".concat(this.delay,"ms"),point:"qcloud-video"}),this.packetsReceived=L,this.framesDecoded=q,this.framesDropped=k,this.framesReceived=V,this.decodems=Math.floor(S/q*1e3),this.interfameDelayMaxMs=Math.floor(j/q*1e3),this.firCount=T,this.pliCount=I;var Z=(this.sdk.gameConfig.getConfig({clientId:this.mount}).feature_switch||{}).network_event_script;if(Z){var ee=Z.notify_threshold,te=void 0===ee?5:ee,ne=mn({packetsReceived:L,packetsLost:M,nack:P,rtt:this.rttArray,featureSwitch:this.sdk.gameConfig.getConfig({clientId:this.mount}).feature_switch});this.latency.status===ne?(this.latency.times=this.latency.times+1,this.latency.times===te&&this.latency.status!==un.NETWORK_NORMAL&&(this.sdk.onNetworkChange({status:"latency",data:{value:ne,message:un[ne]}}),this.sdk.onEvent({type:"latency",data:{value:ne,message:un[ne]}}),this.latency.times=0)):(this.latency.status=ne,this.latency.times=0)}var re=((null==t?void 0:t.get(K))||{}).selectedCandidatePairId,ie=void 0===re?"":re,oe=(ie&&((null==t?void 0:t.get(ie))||{})).currentRoundTripTime,se=void 0===oe?0:oe;this.rawRTT=se}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}try{for(var ae=_n(a),ce=ae.next();!ce.done;ce=ae.next()){var ue,de=ce.value,le=(h=de.type,de.packetsLost),he=(M=void 0===le?0:le,de.packetsReceived),pe=(L=void 0===he?0:he,de.bytesReceived),fe=(O=void 0===pe?0:pe,de.audioLevel),ve=void 0===fe?0:fe,me=de.nackCount,_e=(P=void 0===me?0:me,de.codecId),ge=(H=void 0===_e?"":_e,de.jitterBufferDelay),ye=(R=void 0===ge?0:ge,de.concealedSamples),Se=void 0===ye?0:ye,be=de.concealmentEvents,ke=void 0===be?0:be,Ee=de.totalSamplesReceived,Te=de.totalSamplesDuration,Ce=de.jitterBufferEmittedCount;if((ue=void 0===Ce?0:Ce)||(ue=1),"inbound-rtp"===h){var Ie=(null==t?void 0:t.get(H))||{},we=Ie.mimeType,Re=(X=void 0===we?"":we,Ie.channels);if(X){this.audioConcealedSamples=Se,this.audioConcealmentEvents=ke,this.audioChannels=Re,this.modifyStatElement({name:"Codec",tag:"audio-codec",stat:X,point:"qcloud-audio"}),this.audioCodec=X;var Ae=Math.round((Ee-this.audioTotalSamplesReceived)/(Te-this.audioTotalSamplesDuration));this.audioSampleRate=Ae,this.audioTotalSamplesDuration=Te,this.audioTotalSamplesReceived=Ee,this.audioBitrate=O-this.audioLastBytesRevc,$=it(+this.audioBitrate/1024/1024*8),this.modifyStatElement({name:"AudioBitrate",tag:"audio-bitrates",stat:"".concat($,"Mbit/s"),point:"qcloud-audio"}),this.audioLastBytesRevc=O,this.modifyStatElement({name:"PacketLost",tag:"audio-packet-lost",stat:"".concat(this.audioPacketsLost),point:"qcloud-audio"}),Q=it((M-this.audioPacketsLost)/(L-this.audioPacketsReceived)),this.audioPacketsLossRate=Q,this.audioPacketsLost=M,this.audioPacketsReceived=L,this.audioNack=P,this.modifyStatElement({name:"NACK",tag:"audio-nack",stat:"".concat(this.audioNack),point:"qcloud-audio"}),this.audioJitterBuffer=it(R/ue*1e3),this.jitterBuffer&&this.modifyStatElement({name:"JitterBuffer",tag:"audio-jitter-buffer",stat:"".concat(this.audioJitterBuffer,"ms"),point:"qcloud-audio"})}"track"===h&&this.modifyStatElement({name:"AudioLevel",tag:"audio-level",stat:"".concat(it(ve)),point:"qcloud-audio"})}}}catch(e){i={error:e}}finally{try{ce&&!ce.done&&(o=ae.return)&&o.call(ae)}finally{if(i)throw i.error}}},e.prototype.setInputStart=function(e){this.inputSeqMap[e]=(new Date).getTime()},e.prototype.setInputEnd=function(e){void 0===e&&(e=0),this.inputSeqMap[e]&&(this.inputDelay=Math.round((+new Date-this.inputSeqMap[e])/2),delete this.inputSeqMap[e])},e.prototype.setRTT=function(e){this.rtt=e,this.modifyStatElement({name:"RTT",tag:"video-rtt",stat:"".concat(e.toString(),"ms"),point:"qcloud-video"}),5===this.rttArray.length&&this.rttArray.shift(),this.rttArray.push(e),this.rttSum+=e,this.rttCount+=1;var t=e/(this.rttSum/this.rttCount)>2;return this.rttCount>60&&(this.rttSum=0,this.rttCount=0),t},e.prototype.setCpuAndGpuUsage=function(e){var t=e.cpu,n=void 0===t?"":t,r=e.gpu,i=void 0===r?"":r;this.cpu=n,+n&&this.modifyStatElement({name:"CpuUsage",tag:"cpu-usage",stat:n,point:"qcloud-info"}),this.gpu=i,+i&&this.modifyStatElement({name:"GpuUsage",tag:"gpu-usage",stat:i,point:"qcloud-info"})},e.prototype.setStaticStat=function(e){var t,n=e.serverIp,r=void 0===n?"":n,i=e.region,o=void 0===i?"":i,s=e.instanceId,a=void 0===s?"":s,c=e.instanceType,u=void 0===c?"":c,d=e.hostName,l=void 0===d?"":d,h=e.requestId,p=void 0===h?"":h,f=e.videoMimeType,v=void 0===f?"":f,m=e.audioMimeType,_=void 0===m?"":m,g=e.resolution,y=void 0===g?"":g;if(this.modifyStatElement({name:"Version",tag:"sdk-version",stat:Te,point:"qcloud-info"}),r&&this.modifyStatElement({name:"ServerIp",tag:"server-ip",stat:r,point:"qcloud-info"}),o&&this.modifyStatElement({name:"Region",tag:"region",stat:o,point:"qcloud-info"}),a&&this.modifyStatElement({name:"InstanceId",tag:"instance-id",stat:a,point:"qcloud-info"}),u&&this.modifyStatElement({name:"InstanceType",tag:"instance-type",stat:u,point:"qcloud-info"}),p&&this.modifyStatElement({name:"RequestId",tag:"request-id",stat:p,point:"qcloud-info"}),v&&this.modifyStatElement({name:"Codec",tag:"video-codec",stat:v,point:"qcloud-video"}),_&&this.modifyStatElement({name:"Codec",tag:"audio-codec",stat:_,point:"qcloud-audio"}),y&&this.modifyStatElement({name:"Resolution",tag:"video-resolution",stat:y,point:"qcloud-video"}),!document.querySelector(".qcloud-host")&&this.sdk.isMobileGame){var S=document.createElement("div");S.className="qcloud-stat-row qcloud-host",S.innerHTML="<div class='qcloud-stat-left'>HostName</div><div class='qcloud-stat-right'>".concat(l,"</div>"),l&&(null===(t=this.getQcloudStatElement())||void 0===t||t.appendChild(S))}},e.prototype.modifyStatElement=function(e){var t,n,r,i=e.name,o=void 0===i?"":i,s=e.tag,a=void 0===s?"":s,c=e.stat,u=void 0===c?"":c,d=e.point,l=void 0===d?null:d;if(null===(t=this.getQcloudStatElement())||void 0===t?void 0:t.querySelector(".qcloud-".concat(a)))this.getQcloudStatElement()&&(this.getQcloudStatElement().querySelector(".qcloud-".concat(a," .qcloud-stat-right")).innerHTML=u);else{var h=document.createElement("div");h.className="qcloud-stat-row qcloud-".concat(a),h.innerHTML="<div class='qcloud-stat-left'>".concat(o,"</div><div class='qcloud-stat-right'>").concat(u,"</div>"),null===(r=null===(n=this.getQcloudStatElement())||void 0===n?void 0:n.querySelector(".".concat(l)))||void 0===r||r.appendChild(h)}},e.prototype.setServerSessionTime=function(e){var t=this;this.serverSessionCost=e,setTimeout((function(){t.modifyStatElement({name:"ServerSessionTime",tag:"server-session",stat:"".concat(it((e-t.sdk.initStartTime)/1e3),"s"),point:"qcloud-info"})}),0)},e.prototype.setIceConnectedTime=function(e){this.iceConnectedCost=e},e.prototype.setConnectSuccessTime=function(e){this.connectSuccessTimeCost=e,this.modifyStatElement({name:"ConnectSuccessTime",tag:"connect-success",stat:"".concat(it((e-this.sdk.initStartTime)/1e3),"s"),point:"qcloud-info"})},e.prototype.addReportStat=function(){var e,t,n=this.sdk.gameConfig.getConfig({clientId:this.mount}),r=n.server_ip,i=n.request_id,o=n.server_version,s=n.user_id,a=n.app_id,c=n.game_id;this.metricBulk.push({user_id:s,request_id:i,server_ip:r,server_version:o,timestamp:+new Date,bit_rate:8*this.bitrate,packet_lost:this.packetLost,packet_received:this.packetsReceived,bytes_received:this.lastBytesRevc,audio_packet_lost:this.audioPacketsLost,audio_packet_received:this.audioPacketsReceived,fps:this.fps,delay:this.delay,nack:this.nack,cpu:+this.cpu,gpu:this.gpu,load_cost_time:this.iceConnectedCost-this.serverSessionCost,first_frame:this.connectSuccessTimeCost-this.serverSessionCost,jitter_buffer:this.jitterBuffer,input_delay:this.inputDelay,rtt:this.rtt,frame_decoded:this.framesDecoded,frame_dropped:this.framesDropped,frame_received:this.framesReceived,render_frame_rate:this.framesDecoded,receive_frame_rate:this.framesReceived,decoded_frame_rate:this.framesDecoded,decode_ms:this.decodems,version:"".concat(Te),platform:"0",pli_count:this.pliCount,fir_count:this.firCount,browser:"".concat(null===(e=Ye().os)||void 0===e?void 0:e.family,"/").concat(null===(t=Ye().os)||void 0===t?void 0:t.version,"/").concat(Ye().name),app_id:"".concat(null!=a?a:0),game_id:c,raw_rtt:1e3*this.rawRTT})},e.prototype.toggleMetricReportBulk=function(e){var t=this;"websocket"!==this.sdk.streamingMode&&(e?(clearInterval(this.reportTimer),this.reportTimer=setInterval((function(){t.metricReportBulk(),t.sdk.reportLogInner()}),1e4)):(clearInterval(this.reportTimer),this.sdk.reportLogInner()))},e.prototype.metricReportBulk=function(){return e=this,n=function(){var e,t,n,r,i,o,s,a;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:e=JSON.stringify({metric:"cg_client_stat",bulk:this.metricBulk}),t=this.sdk.gameConfig.getConfig({clientId:this.mount}).sig_key,n=null;try{n=t&&fn()(e.slice(0,128),t).toString()}catch(e){this.sdk.log("encode sig_key error",e)}r=n?" https://metrics-cloud-gaming.crtrcloud.com/report_metric_bulk?sig=".concat(n):" https://metrics-cloud-gaming.crtrcloud.com/report_metric_bulk",c.label=1;case 1:return c.trys.push([1,3,,4]),[4,hn().post(r,e)];case 2:return i=c.sent(),o=i.status,s=i.data,200===o||this.sdk.log("metricReportBulk failed",s),this.metricBulk=[],[3,4];case 3:return a=c.sent(),this.sdk.log("catch metricReportBulk failed",a.message,a.name),[3,4];case 4:return[2]}}))},new((t=void 0)||(t=Promise))((function(r,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function s(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(o,s)}a((n=n.apply(e,[])).next())}));var e,t,n},e.prototype.getQcloudStatElement=function(){var e;return null===(e=null===document||void 0===document?void 0:document.querySelector("#".concat(this.mount)))||void 0===e?void 0:e.querySelector(".qcloud-stat")},e}();const yn=gn;var Sn=function(){function e(){this._events={}}return e.prototype.clear=function(){this._events={}},e.prototype.on=function(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t)-1},e.prototype.trigger=function(e,t){var n=this;if("error"!==e){var r=this._events[e];(null==r?void 0:r.length)&&r.forEach((function(e){e(t)}))}else setTimeout((function(){var r=n._events[e];(null==r?void 0:r.length)&&r.forEach((function(e){e(t)}))}),100)},e.prototype.off=function(e,t,n){var r=this._events[e];if(null==r?void 0:r.length)if(void 0!==n)r.splice(n,1);else{var i=r.findIndex((function(e){return e===t}));i>-1&&r.splice(i,1)}},e.prototype.offAll=function(){this._events={}},e.prototype.once=function(e,t){var n=this;this._events[e]||(this._events[e]=[]);var r=null,i=function(o){t(o),n.off(e,i,r)};r=this.on(e,i)},e}(),bn=E8(995);bn.configure;const kn=bn;var En,Tn=(En=function(e,t){return En=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},En(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}En(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),Cn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},In=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},wn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.logStr=[],t.allLogs=[],t.externalLogHandler=nt,t.serverSideDescription={},t.loggerConfig={mount:null},t}return Tn(t,e),t.prototype.initLoggerConfig=function(e){this.loggerConfig=e},t.prototype.setServerSideDescription=function(e){var t=e.serverSideDescription;this.serverSideDescription=t},t.prototype.log=function(){for(var e,t,n,r,i,o,s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];(null===(r=null===(n=this.loggerConfig)||void 0===n?void 0:n.debugSetting)||void 0===r?void 0:r.showLog)&&console.log.apply(console,function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(s),!1));var c="";try{for(var u=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),d=u.next();!d.done;d=u.next()){var l=d.value;try{c+="".concat("object"==typeof l?kn(l):l," ")}catch(e){console.log("Error stringify object:",e.message)}}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=u.return)&&t.call(u)}finally{if(e)throw e.error}}var h=this.serverSideDescription,p=h.request_id,f=void 0===p?"":p,v=h.server_ip,m=void 0===v?"":v,_=h.user_id,g=void 0===_?"":_,y=null!==(i=m||f)&&void 0!==i?i:"";c="[TCG/".concat(y,"][").concat(g,"]:").concat(c),null===(o=this.externalLogHandler)||void 0===o||o.call(this,c);var S=new Date,b={timestamp:+S,server_ip:m,request_id:f,user_id:g,content:"".concat(tt(S,"yyyy-mm-dd hh:ii:ss")," ").concat(c,"\n")};this.logStr.push(b),this.allLogs.push({request_id:b.request_id,user_id:b.user_id,content:b.content})},t.prototype.getLog=function(){var e=this.serverSideDescription,t=e.request_id,n=void 0===t?"":t,r=e.server_ip,i=void 0===r?"":r;return this.logStr.forEach((function(e){e.server_ip||(e.server_ip=i),e.request_id||(e.request_id=n)})),this.logStr},t.prototype.getAllLogs=function(){var e=this.serverSideDescription.request_id,t=void 0===e?"":e;return this.allLogs.forEach((function(e){e.request_id||(e.request_id=t)})),this.allLogs},t.prototype.reportLogInner=function(){return Cn(this,0,void 0,(function(){return In(this,(function(e){return[2,this.metricLogReport(this.getLog())]}))}))},t.prototype.setExternalLog=function(e){void 0===e&&(e=nt),this.externalLogHandler=e},t.prototype.metricLogReport=function(e){return Cn(this,0,void 0,(function(){var t,n,r,i,o,s,a,c;return In(this,(function(u){switch(u.label){case 0:if(0===this.logStr.length)return[2];t="";try{t=kn({metric:"cg_client_log",bulk:e})}catch(e){console.log("Error stringify object:",e.message)}n=this.serverSideDescription.sig_key,r=null;try{r=n&&fn()(t.slice(0,128),n).toString()}catch(e){this.log("encode sig_key error",e)}i=r?"https://metrics-cloud-gaming.crtrcloud.com/report_log_bulk?sig=".concat(r):"https://metrics-cloud-gaming.crtrcloud.com/report_log_bulk",u.label=1;case 1:return u.trys.push([1,3,,4]),[4,hn().post(i,t)];case 2:return o=u.sent(),s=o.status,a=o.data,200===s?(this.log("metricReportLog",a),this.logStr=[],[2,a]):(this.log("metricReportLog failed",null==a?void 0:a.message),[2,{code:-1,message:"failed"}]);case 3:return c=u.sent(),this.log("catch metricReportLog failed",c.message,c.name),[2,{code:-1,message:"failed"}];case 4:return[2]}}))}))},t}(Sn);const Rn=wn;var An=E8(408),On=function(){function e(e){var t=e.sdk;this.gamepad="function"==typeof navigator.getGamepads?new An.GamepadListener:null,this.sdk=null,this.sdk=t}return e.prototype.addGamepadHandler=function(){var e=this,t=new Map;t.set(12,1),t.set(13,2),t.set(14,4),t.set(15,8),t.set(2,16384),t.set(3,32768),t.set(0,4096),t.set(1,8192),t.set(8,32),t.set(9,16),t.set(10,64),t.set(11,128),t.set(4,256),t.set(5,512),this.gamepad&&(this.gamepad.on("gamepad:connected",(function(t){var n=t.detail;e.sdk.log("gamepad:connected detail",n);var r=n.index,i=n.gamepad;e.sdk.log("gamepad connect, gamepad index is",r),e.sdk.sendGamepadEvent({type:"gamepadconnect"}),e.sdk.onGamepadConnectChange({status:"gamepadconnect",index:r,gamepad:i})})),this.gamepad.on("gamepad:disconnected",(function(t){var n=t.detail;e.sdk.log("gamepad:disconnected detail",n);var r=n.index;e.sdk.log("gamepad disconnected, gamepad index is",r),e.sdk.sendGamepadEvent({type:"gamepaddisconnect"}),e.sdk.onGamepadConnectChange({status:"gamepaddisconnect",index:r})})),this.gamepad.on("gamepad:button",(function(n){var r=n.detail,i=r.button,o=r.pressed,s=r.value,a=t.get(i);6===i||7===i?(6===i&&e.sdk.sendGamepadEvent({type:"lt",x:parseInt("".concat(255*s),10),down:o}),7===i&&e.sdk.sendGamepadEvent({type:"rt",x:parseInt("".concat(255*s),10),down:o})):e.sdk.sendGamepadEvent({type:"gamepadkey",key:a,down:o})})),this.gamepad.on("gamepad:axis",(function(t){var n=t.detail,r=n.stick,i=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(n.gamepad.axes,4),o=i[0],s=i[1],a=i[2],c=i[3];0===r&&e.sdk.sendGamepadEvent({type:"axisleft",x:parseInt("".concat(32767*o),10),y:-parseInt("".concat(32767*s),10)}),1===r&&e.sdk.sendGamepadEvent({type:"axisright",x:parseInt("".concat(32767*a),10),y:-parseInt("".concat(32767*c),10)})})),this.gamepad.start())},e}();const xn=On;var Pn=function(){return Pn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Pn.apply(this,arguments)},Dn=function(e){var t,n,r=e.url,i=e.data,o=e.timeout,s=e.headers;return n=function(){var e,t,n;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(a){switch(a.label){case 0:return e=new AbortController,t=setTimeout((function(){return e.abort()}),null!=o?o:1e4),[4,fetch(r,{body:JSON.stringify(i),cache:"no-cache",credentials:"same-origin",headers:Pn({"content-type":"application/json"},s),method:"POST",mode:"cors",signal:e.signal}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.text()})).then((function(e){try{return JSON.parse(e)}catch(t){return e}})).catch((function(e){throw"AbortError"===e.name?new Error("request timeout"):new Error("".concat(e.name,": ").concat(e.message))}))];case 1:return n=a.sent(),clearTimeout(t),[2,n]}}))},new((t=void 0)||(t=Promise))((function(e,r){function i(e){try{s(n.next(e))}catch(e){r(e)}}function o(e){try{s(n.throw(e))}catch(e){r(e)}}function s(n){var r;n.done?e(n.value):(r=n.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,o)}s((n=n.apply(undefined,[])).next())}))},Mn=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},Nn=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ln=function(){function e(e){var t=e.sdk,n=this;this.token="",this.serverIp="",this.retryTimes=0,this.maxRetryTimes=10,this.retryInterval=6e3,this.sdk=null,this.mount=null,this.startRetry=function(e){var t=e.message;n.sdk.log("Watchdog, reconnect proxy failed, try again, startRetry, times",n.retryTimes),setTimeout((function(){if(n.retryTimes>=n.maxRetryTimes)return n.sdk.cloudGamingWebRTC.clearPeerConnection(),n.sdk.onConnectFailed({code:_e.EXCEEDED_LIMIT_RERTY_TIMES,msg:"Retries exceeded"});n.autoReconnect({message:t}),n.retryTimes=n.retryTimes+1,n.sdk.onConnectFailed({code:_e.AUTO_RECONNECTING,msg:"auto connecting"})}),n.retryInterval)},this.sdk=t}return e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.autoReconnect=function(e){var t=e.message;return Mn(this,0,void 0,(function(){var e,n,r,i,o,s,a,c,u,d,l,h,p,f,v,m;return Nn(this,(function(_){switch(_.label){case 0:return this.sdk.cloudGamingWebRTC.clearPeerConnection(),[4,this.sdk.cloudGamingWebRTC.newWebRtcConnect()];case 1:if(_.sent(),this.sdk.cloudGamingWebRTC.startHeartbeatReport(),this.sdk.isMobileGame)return[2,this.androidInstanceReconnect({message:t})];if(!this.serverIp||!this.token)return this.sdk.log("Watchdog, autoReconnect, serverIp:".concat(this.serverIp," or token:").concat(this.token," is not set, abort")),[2,this.sdk.onConnectFailed({code:me.CONNECT_FAILED,msg:"reconnect failed"})];e=this.sdk.cloudGamingWebRTC.getClientSideDescription(!1),n=this.sdk.gameConfig.getConfig({clientId:this.mount}),r=n.user_id,i=n.server_port,o=n.instance_id,s=i||7392,_.label=2;case 2:return _.trys.push([2,4,,5]),this.sdk.log("Watchdog, reconnect, serverIp:".concat(this.serverIp,", token:").concat(this.token)),a="host=".concat(this.serverIp,"&port=").concat(s,"&token=").concat(this.token,"&uid=").concat(r),c=this.sdk.accessInfo.getInstanceAccessInfo({instanceId:o}).WebRTCAddress,u="".concat("https://cgproxy.cloud-gaming.myqcloud.com","/reconnect?").concat(a),c&&(u="".concat(c,"/reconnect?").concat(a)),[4,Dn({url:u,data:e})];case 3:return d=_.sent(),l=d.Code,h=d.ServerSession,this.sdk.log("Watchdog, reconnect response code: ".concat(l)),0===l?(p=this.checkServerSession(h),f=p.code,v=p.message,0===f?(this.sdk.log("Watchdog, reconnect proxy success"),this.sdk.cloudGamingWebRTC.connect(ze(h)),this.retryTimes=0):(this.sdk.cloudGamingWebRTC.clearPeerConnection(),this.sdk.onConnectFailed({code:f,msg:v}),this.sdk.log("Watchdog, reconnect proxy failed"))):this.startRetry({message:t}),[3,5];case 4:return m=_.sent(),this.sdk.log("Watchdog post error",m),this.startRetry({message:null==m?void 0:m.message}),[3,5];case 5:return[2]}}))}))},e.prototype.setReconnectInfo=function(e){var t=e.serverIp,n=void 0===t?"":t,r=e.token,i=void 0===r?"":r;this.serverIp=n,this.token=i},e.prototype.checkServerSession=function(e){try{var t=JSON.parse(e),n=t.code,r=t.WebrtcResponse,i=t.Code,o=t.Msg,s=t.message,a=null!=n?n:i,c=s||o||(null==r?void 0:r.Msg);return this.sdk.log("Watchdog, server session code: ".concat(a,", message: ").concat(c)),{code:a,message:c}}catch(e){this.sdk.log("Watchdog, parse ServerSession error")}},e.prototype.androidInstanceReconnect=function(e){var t=e.message;return Mn(this,0,void 0,(function(){var e,n,r,i,o,s;return Nn(this,(function(a){switch(a.label){case 0:return e=this.sdk.gameConfig.getConfig({clientId:this.mount}).instance_id,this.sdk.log("Watchdog reconnect android instance, instance id is ".concat(e,", message: ").concat(t)),e?this.sdk.androidInstance.groupControl.groupControlId?(this.sdk.destroy({code:_e.MODE_FORBIDDEN,message:"Could not reconnect in group control mode"}),this.sdk.onConnectFailed({code:_e.MODE_FORBIDDEN,msg:"Could not reconnect in group control mode"}),[3,4]):[3,1]:[3,5];case 1:return a.trys.push([1,3,,4]),[4,this.sdk.accessInfo.createWebRTCSession({instanceId:e,clientSession:this.sdk.getClientSession()})];case 2:return n=a.sent(),r=n.ServerSession,i=n.Code,o=n.Message,this.sdk.log("Watchdog, reconnect response code: ".concat(i,", message: ").concat(o)),0===i?(this.sdk.log("Watchdog, reconnect proxy success"),this.sdk.cloudGamingWebRTC.connect(r),this.retryTimes=0):(this.sdk.log("Watchdog reconnect error",o),this.startRetry({message:o})),[3,4];case 3:return s=a.sent(),this.sdk.log("Watchdog reconnect cache error",s.name,s.message),this.startRetry({message:s.message}),[3,4];case 4:return[3,6];case 5:this.sdk.log("Watchdog reconnect error, instance id is not set"),a.label=6;case 6:return[2]}}))}))},e}();const Un=Ln;var Vn=function(){return Vn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Vn.apply(this,arguments)},Fn=function(){function e(e){var t=e.sdk;this.sdk=null,this.configBatch=new Map,this.sdk=t}return e.prototype.setConfig=function(e){var t=e.clientId,n=e.config,r=n.game_config,i=n.feature_switch,o=void 0===i?st:i,s=n.server_ip,a=n.region,c=n.instance_id,u=n.instance_type,d=n.host_name,l=n.request_id,h=n.video_mime_type,p=n.audio_mime_type;this.setSDKConfig(null==r?void 0:r.sdk_conf);var f=o.network_event_script;f&&(f=JSON.parse(f)),this.configBatch.set(t,Vn(Vn({},n),{feature_switch:{network_event_script:f}})),this.sdk.showStats.setStaticStat({serverIp:s,region:a,instanceId:c,instanceType:u,hostName:d,requestId:l,videoMimeType:h,audioMimeType:p})},e.prototype.updateConfig=function(e){var t=e.clientId,n=e.config;this.configBatch.set(t,Vn(Vn({},this.configBatch.get(t)),n))},e.prototype.setSDKConfig=function(e){if(e){var t=this.sdk.getInitOptions(),n=t.webDraftLevel,r=t.tabletMode;"number"==typeof e.webdraft_level&&void 0!==n&&this.sdk.pageEvent.setWebDraftLevel(e.webdraft_level),"boolean"==typeof e.tablet_mode&&void 0===r&&this.sdk.mouseTabletMode(e.tablet_mode)}},e.prototype.getConfig=function(e){var t=e.clientId;return this.configBatch.get(t)||st},e}();const Bn=Fn,jn={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Gn;const Hn=new Uint8Array(16),Wn=[];for(let e=0;e<256;++e)Wn.push((e+256).toString(16).slice(1));const Kn=function(e,t,n){if(jn.randomUUID&&!t&&!e)return jn.randomUUID();const r=(e=e||{}).random??e.rng?.()??function(){if(!Gn){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Gn=crypto.getRandomValues.bind(crypto)}return Gn(Hn)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(Wn[e[t+0]]+Wn[e[t+1]]+Wn[e[t+2]]+Wn[e[t+3]]+"-"+Wn[e[t+4]]+Wn[e[t+5]]+"-"+Wn[e[t+6]]+Wn[e[t+7]]+"-"+Wn[e[t+8]]+Wn[e[t+9]]+"-"+Wn[e[t+10]]+Wn[e[t+11]]+Wn[e[t+12]]+Wn[e[t+13]]+Wn[e[t+14]]+Wn[e[t+15]]).toLowerCase()}(r)};var zn,qn;!function(e){e[e.opus=101]="opus",e[e.aac=102]="aac",e[e.h264=103]="h264",e[e.h265=104]="h265",e[e.vp8=105]="vp8",e[e.vp9=106]="vp9"}(zn||(zn={})),function(e){e[e.open=10]="open",e[e.message=11]="message"}(qn||(qn={}));var Jn,Yn,Xn=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},$n=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))};function Qn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Jn&&Jn.apply(void 0,$n([e],Xn(t),!1))}function Zn(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];Yn&&Yn.apply(void 0,$n([e],Xn(t),!1))}var er=function(){function e(t){this.stype=null,this.isfmb=!1,this.isvcl=null,this.payload=null,this.ntype=null,this.payload=t,this.ntype=31&this.payload[0],this.isvcl=this.ntype===e.NDR||this.ntype===e.IDR}return Object.defineProperty(e,"NDR",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"IDR",{get:function(){return 5},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SEI",{get:function(){return 6},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SPS",{get:function(){return 7},enumerable:!1,configurable:!0}),Object.defineProperty(e,"PPS",{get:function(){return 8},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AUD",{get:function(){return 9},enumerable:!1,configurable:!0}),e.prototype.type=function(){return this.ntype},e.prototype.isKeyframe=function(){return this.ntype===e.IDR},e.prototype.getPayload=function(){return this.payload},e.prototype.getPayloadSize=function(){return this.payload.byteLength},e.prototype.getSize=function(){return 4+this.getPayloadSize()},e.prototype.getData=function(){var e=new Uint8Array(this.getSize());return new DataView(e.buffer).setUint32(0,this.getSize()-4),e.set(this.getPayload(),4),e},e}();function tr(e,t){var n=new Uint8Array((0|e.byteLength)+(0|t.byteLength));return n.set(e,0),n.set(t,0|e.byteLength),n}var nr=function(e){for(var t=0,n=e.byteLength,r=[],i=-1;t<n;)t+2<n&&0===e[t]&&0===e[t+1]&&1===e[t+2]?(-1!==i&&r.push(e.slice(i,t)),i=t+3,t+=3):t+3<n&&0===e[t]&&0===e[t+1]&&0===e[t+2]&&1===e[t+3]?(-1!==i&&r.push(e.slice(i,t)),i=t+4,t+=4):t+=1;return-1!==i&&r.push(e.slice(i)),r};const rr=function(){function e(e){this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}return e.prototype.loadWord=function(){var e=this.data,t=this.bytesAvailable,n=e.byteLength-t,r=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");r.set(e.subarray(n,n+i)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},e.prototype.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},e.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;if(e>32&&console.log("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?n<<t|this.readBits(t):n},e.prototype.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},e.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},e.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},e.prototype.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},e.prototype.readBoolean=function(){return 1===this.readBits(1)},e.prototype.readUByte=function(){return this.readBits(8)},e.prototype.readUShort=function(){return this.readBits(16)},e.prototype.readUInt=function(){return this.readBits(32)},e}();var ir=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return e.parseHeader=function(e){var t=new rr(e.getPayload());t.readUByte(),e.isfmb=0===t.readUEG(),e.stype=t.readUEG()},e.prototype.parseNAL=function(e){if(!e)return!1;var t=!1;switch(e.type()){case er.IDR:case er.NDR:t=!0;break;case er.PPS:this.track.pps||(this.parsePPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case er.SPS:this.track.sps||(this.parseSPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&(this.remuxer.readyToDecode=!0)),t=!0;case er.AUD:case er.SEI:}return t},e.prototype.skipScalingList=function(e,t){for(var n=8,r=8,i=0;i<t;i++)0!==r&&(r=(n+e.readEG()+256)%256),n=0===r?n:r},e.prototype.readSPS=function(e){var t,n,r,i=new rr(e),o=0,s=0,a=0,c=0,u=i.readUByte.bind(i),d=i.readBits.bind(i),l=i.readUEG.bind(i),h=i.readBoolean.bind(i),p=i.skipBits.bind(i),f=i.skipEG.bind(i),v=i.skipUEG.bind(i),m=this.skipScalingList.bind(this);u();var _=u();if(d(5),p(3),u(),v(),100===_||110===_||122===_||244===_||44===_||83===_||86===_||118===_||128===_){var g=l();if(3===g&&p(1),v(),v(),p(1),h())for(n=3!==g?8:12,r=0;r<n;r++)h()&&m(r<6?16:64,i)}v();var y=l();if(0===y)l();else if(1===y)for(p(1),f(),f(),t=l(),r=0;r<t;r++)f();v(),p(1);var S=l(),b=l(),k=d(1);0===k&&p(1),p(1),h()&&(o=l(),s=l(),a=l(),c=l());var E=[1,1];if(h()&&h())switch(u()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(S+1)-2*o-2*s),height:(2-k)*(b+1)*16-(k?2:4)*(a+c),pixelRatio:E}},e.prototype.parseSPS=function(e){var t=this.readSPS(new Uint8Array(e));this.track.width=t.width,this.track.height=t.height,this.track.sps=[new Uint8Array(e)],this.track.codec="avc1.";for(var n=new DataView(e.buffer,e.byteOffset+1,4),r=0;r<3;++r){var i=n.getUint8(r).toString(16);i.length<2&&(i="0".concat(i)),this.track.codec+=i}},e.prototype.parsePPS=function(e){this.track.pps=[new Uint8Array(e)]},e}(),or=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return Object.defineProperty(e,"samplingRateMap",{get:function(){return[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]},enumerable:!1,configurable:!0}),e.getHeaderLength=function(e){return 1&e[1]?7:9},e.getFrameLength=function(e){return(3&e[3])<<11|e[4]<<3|(224&e[5])>>>5},e.isAACPattern=function(e){return!(255!==e[0]||240&~e[1]||6&e[1])},e.extractAAC=function(t){var n,r=0,i=t.byteLength,o=[];if(!e.isAACPattern(t))return console.error("Invalid ADTS audio format"),o;var s=e.getHeaderLength(t);for(e.aacHeader||(e.aacHeader=t.subarray(0,s));r<i;)n=e.getFrameLength(t),o.push(t.subarray(s,n)),t=t.slice(n),r+=n;return o},e.prototype.setAACConfig=function(){var t,n=new Uint8Array(2),r=e.aacHeader;if(r){var i=1+((192&r[2])>>>6),o=(60&r[2])>>>2;t=(1&r[2])<<2,t|=(192&r[3])>>>6,n[0]=i<<3,n[0]|=(14&o)>>1,n[1]|=(1&o)<<7,n[1]|=t<<3,this.track.codec="mp4a.40.".concat(i),this.track.channelCount=t,this.track.config=n,this.remuxer.readyToDecode=!0}},e}();const sr=function(){function e(e){this.type="",this.listener={},this.type=e}return e.prototype.on=function(e,t){return this.listener[e]||(this.listener[e]=[]),this.listener[e].push(t),!0},e.prototype.off=function(e,t){if(this.listener[e]){var n=this.listener[e].indexOf(t);return n>-1&&this.listener[e].splice(n,1),!0}return!1},e.prototype.offAll=function(){this.listener={}},e.prototype.dispatch=function(e,t){return!!this.listener[e]&&(this.listener[e].forEach((function(e){e.apply(null,[t])})),!0)},e}();var ar=function(){function e(){}return e.prototype.init=function(){var e;for(e in this.types={avc1:[],avcC:[],hev1:[],hvcC:[],hvc1:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],Opus:[],dOps:[]},this.types)this.types.hasOwnProperty(e)&&(this.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);this.HDLR_TYPES={video:t,audio:n};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);this.STTS=this.STSC=this.STCO=i,this.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),this.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),this.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),this.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);this.FTYP=this.box(this.types.ftyp,o,a,o,s),this.DINF=this.box(this.types.dinf,this.box(this.types.dref,r))},e.prototype.box=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r,i=8,o=t.length,s=o;o--;)i+=t[o].byteLength;for((r=new Uint8Array(i))[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),o=0,i=8;o<s;++o)r.set(t[o],i),i+=t[o].byteLength;return r},e.prototype.hdlr=function(e){return this.box(this.types.hdlr,this.HDLR_TYPES[e])},e.prototype.mdat=function(e){return this.box(this.types.mdat,e)},e.prototype.mdhd=function(e,t){return this.box(this.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,85,196,0,0]))},e.prototype.mdia=function(e){return this.box(this.types.mdia,this.mdhd(e.timescale,e.duration),this.hdlr(e.type),this.minf(e))},e.prototype.mfhd=function(e){return this.box(this.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},e.prototype.minf=function(e){return"audio"===e.type?this.box(this.types.minf,this.box(this.types.smhd,this.SMHD),this.DINF,this.stbl(e)):this.box(this.types.minf,this.box(this.types.vmhd,this.VMHD),this.DINF,this.stbl(e))},e.prototype.moof=function(e,t,n){return this.box(this.types.moof,this.mfhd(e),this.traf(n,t))},e.prototype.moov=function(e,t,n){for(var r=e.length,i=[];r--;)i[r]=this.trak(e[r]);return this.box.apply(null,[this.types.moov,this.mvhd(n,t)].concat(i).concat(this.mvex(e)))},e.prototype.mvex=function(e){for(var t=e.length,n=[];t--;)n[t]=this.trex(e[t]);return this.box.apply(null,[this.types.mvex].concat(n))},e.prototype.mvhd=function(e,t){var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,e>>24&255,e>>16&255,e>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return this.box(this.types.mvhd,n)},e.prototype.sdtp=function(e){var t,n,r=e.samples||[],i=new Uint8Array(4+r.length);for(n=0;n<r.length;n++)t=r[n].flags,i[n+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return this.box(this.types.sdtp,i)},e.prototype.stbl=function(e){return this.box(this.types.stbl,this.stsd(e),this.box(this.types.stts,this.STTS),this.box(this.types.stsc,this.STSC),this.box(this.types.stsz,this.STSZ),this.box(this.types.stco,this.STCO))},e.prototype.avc1=function(e){var t,n,r,i=[],o=[];for(t=0;t<e.sps.length;t++)r=(n=e.sps[t]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(n));for(t=0;t<e.pps.length;t++)r=(n=e.pps[t]).byteLength,o.push(r>>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(n));var s=this.box(this.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|e.sps.length].concat(i).concat([e.pps.length]).concat(o))),a=e.width,c=e.height;return this.box(this.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,c>>8&255,255&c,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,98,105,110,101,108,112,114,111,46,114,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s)},e.prototype.hvc1=function(e){for(var t=e.params,n=[e.vps,e.sps,e.pps],r=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,+t.frame_rate.fps,3|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),n.length]),i=r.length,o=0;o<n.length;o+=1){i+=3;for(var s=0;s<n[o].length;s+=1)i+=2+n[o][s].length}var a=new Uint8Array(i);a.set(r,0),i=r.length;var c=n.length-1;for(o=0;o<n.length;o+=1)for(a.set(new Uint8Array([32+o|(o===c?128:0),0,n[o].length]),i),i+=3,s=0;s<n[o].length;s+=1)a.set(new Uint8Array([n[o][s].length>>8,255&n[o][s].length]),i),i+=2,a.set(n[o][s],i),i+=n[o][s].length;var u=this.box(this.types.hvcC,a),d=e.width,l=e.height;return this.box(this.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,d>>8&255,255&d,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),u,this.box(this.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))},e.prototype.esds=function(e){var t=e.config.byteLength,n=new Uint8Array(26+t+3);return n.set([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5,t]),n.set(e.config,26),n.set([6,1,2],26+t),n},e.prototype.mp4a=function(e){var t=e.audiosamplerate;return this.box(this.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),this.box(this.types.esds,this.esds(e)))},e.prototype.dOps=function(e){var t=e.outputChannelCount,n=void 0===t?2:t,r=e.preSkip,i=void 0===r?0:r,o=e.inputSampleRate,s=void 0===o?48e3:o,a=e.outputGain,c=void 0===a?0:a,u=e.channelMappingFamily,d=void 0===u?0:u,l=new Uint8Array(19),h=new DataView(l.buffer);return h.setUint8(0,0),h.setUint8(1,n),h.setUint16(2,i,!1),h.setUint32(4,s,!1),h.setInt16(8,c,!1),h.setUint8(10,d),this.box(this.types.dOps,l)},e.prototype.getUint16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e),t},e.prototype.Opus=function(e){var t=e.channelCount,n=e.config;return this.box(this.types.Opus,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,this.getUint16(48e3),0,0]),this.dOps(n))},e.prototype.stsd=function(e){return"opus"===e.codec?this.box(this.types.stsd,this.STSD,this.Opus(e)):"audio"===e.type?this.box(this.types.stsd,this.STSD,this.mp4a(e)):e.codec.includes("hvc1")?this.box(this.types.stsd,this.STSD,this.hvc1(e)):this.box(this.types.stsd,this.STSD,this.avc1(e))},e.prototype.tkhd=function(e){var t=e.id,n=e.duration,r=e.width,i=e.height,o=e.volume;return this.box(this.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,255&o,o%1*10&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},e.prototype.traf=function(e,t){var n=this.sdtp(e),r=e.id;return this.box(this.types.traf,this.box(this.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),this.box(this.types.tfdt,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t])),this.trun(e,n.length+16+16+8+16+8+8),n)},e.prototype.trak=function(e){return"video"===e.type&&(e.duration=e.duration||4294967295),this.box(this.types.trak,this.tkhd(e),this.mdia(e))},e.prototype.trex=function(e){var t=e.id;return this.box(this.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.prototype.trun=function(e,t){var n,r,i,o,s,a,c=e.samples||[],u=c.length,d=12+16*u,l=new Uint8Array(d);for(t+=8+d,l.set([0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),n=0;n<u;n++)i=(r=c[n]).duration,o=r.size,s=r.flags,a=r.cts,l.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*n);return this.box(this.types.trun,l)},e.prototype.initSegment=function(e,t,n){this.types||this.init();var r=this.moov(e,t,n),i=new Uint8Array(this.FTYP.byteLength+r.byteLength);return i.set(this.FTYP),i.set(r,this.FTYP.byteLength),i},e.prototype.initTypes=function(){this.types||this.init()},e}();const cr=new ar;var ur=1,dr=function(){function e(){this.mp4track={len:0,samples:[]},this.readyToDecode=!1,this.samples=[]}return e.getTrackID=function(){return ur++},e.prototype.flush=function(){this.mp4track.len=0,this.mp4track.samples=[]},e.prototype.isReady=function(){return!(!this.readyToDecode||!this.samples.length)||null},e}(),lr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),hr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"audio",channelCount:0,len:0,fragmented:!0,timescale:1e3,duration:0,samples:[],config:"",codec:""},r.dts=0,r.readyToDecode=!1,r.samples=[],r.nextDts=0,r.aac=new or(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return lr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.codec="",this.mp4track.channelCount=0,this.mp4track.config="",this.mp4track.timescale=1e3,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){if(e.length>0)for(var t=0;t<e.length;t++){var n=e[t],r=n.units,i=r.byteLength;this.samples.push({units:r,size:i,duration:n.duration}),this.mp4track.len+=i,this.readyToDecode||this.aac.setAACConfig()}},t.prototype.getPayload=function(){if(!this.isReady())return null;var e,t,n=new Uint8Array(this.mp4track.len),r=0,i=this.mp4track.samples;for(this.dts=this.nextDts;this.samples.length;){var o=this.samples.shift();o.units,(t=o.duration)<=0?(Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(t)),this.mp4track.len-=o.size):(this.nextDts+=t,e={size:o.size,duration:t,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},n.set(o.units,r),r+=o.size,i.push(e))}return i.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t.prototype.getAacParser=function(){return this.aac},t}(dr),pr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},vr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"video",len:0,fragmented:!0,sps:null,pps:null,codec:"",fps:30,width:0,height:0,timescale:1e3,duration:0,samples:[]},r.readyToDecode=!1,r.dts=0,r.samples=[],r.nextDts=0,r.h264Parser=new ir(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return pr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.sps=null,this.mp4track.pps=null,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n,r,i;try{for(var o=fr(e),s=o.next();!s.done;s=o.next()){var a=s.value,c=0,u=a.units,d=a.keyFrame,l=a.duration,h=a.compositionTimeOffset;try{for(var p=(r=void 0,fr(a.units)),f=p.next();!f.done;f=p.next()){var v=f.value;this.h264Parser.parseNAL(v)&&(c+=v.getSize())}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}u.length>0&&this.readyToDecode&&(this.mp4track.len+=c,this.samples.push({units:u,size:c,keyFrame:d,duration:l,compositionTimeOffset:h}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){var e,t;if(!this.isReady())return null;var n=new Uint8Array(this.mp4track.len),r=0;for(this.dts=this.nextDts;this.samples.length;){var i=this.samples.shift(),o=i.units,s=i.size,a=i.duration,c=i.compositionTimeOffset,u=i.keyFrame;if(a<=0)Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(a)),this.mp4track.len-=s;else{this.nextDts+=a;var d={size:s,duration:a,cts:c||0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,isNonSync:u?0:1,dependsOn:u?2:1}};try{for(var l=(e=void 0,fr(o)),h=l.next();!h.done;h=l.next()){var p=h.value;n.set(p.getData(),r),r+=p.getSize()}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}this.mp4track.samples.push(d)}}return this.mp4track.samples.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t}(dr),mr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_r=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.mp4track={id:dr.getTrackID(),type:"audio",channelCount:2,len:0,timescale:48e3,duration:960,sampleRate:48e3,samples:[],config:{},codec:"opus"},t.dts=0,t.readyToDecode=!1,t.samples=[],t.nextDts=0,t}return mr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n;try{for(var r=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),i=r.next();!i.done;i=r.next()){var o=i.value,s=o.unit,a=o.duration,c=s.byteLength;this.samples.push({units:s,size:c,duration:a}),this.mp4track.len+=c,this.readyToDecode||(this.readyToDecode=!0)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){if(!this.isReady())return null;var e=new Uint8Array(this.mp4track.len),t=0,n=this.mp4track.samples;for(this.dts=this.nextDts;this.samples.length;){var r=this.samples.shift(),i=r.duration,o=r.units,s=r.size;this.nextDts+=i;var a={size:s,duration:i,cts:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}};e.set(o,t),t+=s,n.push(a)}return n.length?new Uint8Array(e.buffer,0,this.mp4track.len):null},t}(dr),gr="mp4a.40.2",yr="opus",Sr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},br=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},kr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Er=function(){function e(e){var t=e.name,n=e.contents,r=void 0===n?[]:n,i=e.children,o=void 0===i?[]:i;this._name=null,this._contents=null,this._children=null,this._name=t,this._contents=r,this._children=o}return e.stringToByteArray=function(e){return br([],Sr(e),!1).map((function(e){return e.charCodeAt(0)}))},e.getFloat64=function(e){var t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e),t},e.getUint64=function(e){var t=new Uint8Array(8);return new DataView(t.buffer).setBigUint64(0,BigInt(e)),t},e.getUint32=function(e){var t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t},e.getUint16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e),t},e.getInt16=function(e){var t=new Uint8Array(2);return new DataView(t.buffer).setInt16(0,e),t},e.flatten=function(t){var n,r,i,o,s,a;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),n=kr(t),r=n.next(),c.label=1;case 1:return r.done?[3,6]:(i=r.value,Array.isArray(i)?[5,kr(e.flatten(i))]:[3,3]);case 2:return c.sent(),[3,5];case 3:return[4,i];case 4:c.sent(),c.label=5;case 5:return r=n.next(),[3,1];case 6:return[3,9];case 7:return o=c.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(s)throw s.error}return[7];case 9:return[2]}}))},Object.defineProperty(e.prototype,"contents",{get:function(){var t,n,r=new Uint8Array(this.length),i=this.buildContents(),o=0;try{for(var s=kr(e.flatten(i)),a=s.next();!a.done;a=s.next()){var c=a.value;"object"!=typeof c?(r[o]=c,o++):(r.set(c,o),o+=c.length)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this.buildLength()},enumerable:!1,configurable:!0}),e.prototype.buildContents=function(){return br([this._contents],Sr(this._children.map((function(e){return e.buildContents()}))),!1)},e.prototype.buildLength=function(){return(Array.isArray(this._contents)?this._contents.reduce((function(e,t){return e+(void 0===t.length?1:t.length)}),0):void 0===this._contents.length?1:this._contents.length)+this._children.reduce((function(e,t){return e+t.length}),0)},e.prototype.addChild=function(e){this._children.push(e)},e}();const Tr=Er;var Cr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ir=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},wr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Rr=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.contents,o=r.children;return e.call(this,{name:t,contents:i,children:o})||this}return Cr(t,e),t.prototype.buildContents=function(){return wr(wr(wr([],Ir(this._lengthBytes),!1),Ir(Tr.stringToByteArray(this._name)),!1),Ir(e.prototype.buildContents.call(this)),!1)},t.prototype.buildLength=function(){return this._length||(this._length=4+this._name.length+e.prototype.buildLength.call(this),this._lengthBytes=Tr.getUint32(this._length)),this._length},t}(Tr);const Ar=Rr;var Or=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),xr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Pr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Dr=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.contents,o=r.tags;return e.call(this,{name:t,contents:i,children:o})||this}return Or(t,e),t.getLength=function(e){var t=Tr.getUint32(e);return t.every((function(e,t,n){return 0===e&&(n[t]=128,!0)})),t},t.prototype.buildContents=function(){return Pr(Pr([this._name],xr(this._lengthBytes),!1),xr(e.prototype.buildContents.call(this)),!1)},t.prototype.buildLength=function(){if(!this._length){var n=e.prototype.buildLength.call(this);this._lengthBytes=t.getLength(n),this._length=1+n+this._lengthBytes.length}return this._length},t.prototype.addTag=function(e){this.addChild(e)},t}(Tr);const Mr=Dr;var Nr=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Lr=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},Ur=function(){function e(e){this.codec="opus",this.codec=e}return e.prototype.getInitializationSegment=function(e){var t=e.header;return new Tr({children:[new Ar("ftyp",{contents:[Ar.stringToByteArray("iso5"),0,0,2,0,Ar.stringToByteArray("iso6mp41")]}),new Ar("moov",{children:[new Ar("mvhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,232,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2]}),new Ar("trak",{children:[new Ar("tkhd",{contents:[0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("mdia",{children:[new Ar("mdhd",{contents:[0,0,0,0,0,0,0,0,0,0,0,0,Ar.getUint32(t.sampleRate),0,0,0,0,85,196,0,0]}),new Ar("hdlr",{contents:[0,0,0,0,Ar.stringToByteArray("mhlr"),Ar.stringToByteArray("soun"),0,0,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("minf",{children:[new Ar("stbl",{children:[new Ar("stsd",{contents:[0,0,0,0,0,0,0,1],children:[this.getCodecBox(t)]}),new Ar("stts",{contents:[0,0,0,0,0,0,0,0]}),new Ar("stsc",{contents:[0,0,0,0,0,0,0,0]}),new Ar("stsz",{contents:[0,0,0,0,0,0,0,0,0,0,0,0]}),new Ar("stco",{contents:[0,0,0,0,0,0,0,0]})]})]})]})]}),new Ar("mvex",{children:[new Ar("trex",{contents:[0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0]})]})]})]}).contents},e.prototype.getMediaSegment=function(e){var t=e.frames,n=e.sequenceNumber,r=e.baseMediaDecodeTime,i=e.track.samples,o=Nr(i,1)[0],s=o.flags,a=o.duration,c=o.size,u=o.cts,d=function(){var e,t,n=new Uint8Array(4+i.length);for(t=0;t<i.length;t++)e=i[t].flags,n[t+4]=e.dependsOn<<4|e.isDependedOn<<2|e.hasRedundancy;return new Ar("sdtp",{contents:n})}();return new Tr({children:[new Ar("moof",{children:[new Ar("mfhd",{contents:[0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]}),new Ar("traf",{children:[new Ar("tfhd",{contents:[0,2,0,0,0,0,0,1]}),new Ar("tfdt",{contents:[0,0,0,0,Ar.getUint32(r)]}),new Ar("trun",{contents:[0,0,15,1,Ar.getUint32(t.length),Ar.getUint32(92+d.length+16*t.length),Ar.getUint32(a),Ar.getUint32(c),s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,Ar.getUint32(u)]}),d]})]}),new Ar("mdat",{contents:this.getFrameData(t)})]}).contents},e.prototype.getCodecBox=function(e){switch(this.codec){case"mp3":return this.getMp4a(e,107);case gr:return this.getMp4a(e,64);case yr:return this.getOpus(e);case"flac":return this.getFlaC(e)}},e.prototype.getOpus=function(e){var t=e.sampleRate,n=void 0===t?48e3:t,r=e.channels,i=void 0===r?2:r,o=e.bitDepth,s=void 0===o?16:o,a=e.preSkip,c=void 0===a?0:a,u=e.inputSampleRate,d=void 0===u?48e3:u,l=e.outputGain,h=void 0===l?0:l,p=e.channelMappingFamily,f=void 0===p?0:p,v=e.streamCount,m=void 0===v?0:v,_=e.coupledStreamCount,g=void 0===_?0:_,y=e.channelMappingTable,S=void 0===y?0:y;return new Ar("Opus",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,s,0,0,0,0,Ar.getUint16(n),0,0],children:[new Ar("dOps",{contents:[0,i,Ar.getUint16(c),Ar.getUint32(d),Ar.getInt16(h),f,0!==f?[m,g,S]:[]]})]})},e.prototype.getFlaC=function(e){return new Ar("fLaC",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channels,0,e.bitDepth,0,0,0,0,Ar.getUint16(e.sampleRate),0,0],children:[new Ar("dfLa",{contents:Lr([0,0,0,0],Nr(e.streamInfo||[128,0,0,34,Ar.getUint16(e.blockSize),Ar.getUint16(e.blockSize),0,0,0,0,0,0,Ar.getUint32(e.sampleRate<<12|e.channels<<8|e.bitDepth-1<<4),0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),!1)})]})},e.prototype.getMp4a=function(e,t){var n=new Mr(4,{contents:[t,21,0,0,0,0,0,0,0,0,0,0,0]});return 64===t&&n.addTag(new Mr(5,{contents:e.audioSpecificConfig})),new Ar("mp4a",{contents:[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channels,0,16,0,0,0,0,Ar.getUint16(e.sampleRate),0,0],children:[new Ar("esds",{contents:[0,0,0,0],children:[new Mr(3,{contents:[0,1,0],tags:[n,new Mr(6,{contents:2})]})]})]})},e.prototype.getSamplesPerFrame=function(e){return this.codec===gr?e.map((function(e){var t=e.data,n=e.header;return Ar.getUint32(t.length-n.length)})):e.map((function(e){var t=e.data;return Ar.getUint32(t.length)}))},e.prototype.getFrameData=function(e){return this.codec===gr?e.map((function(e){var t=e.data,n=e.header;return t.subarray(n.length)})):e.map((function(e){return e.data}))},e}(),Vr=new Ur(yr),Fr=function(){function e(t){this.stype=null,this.isfmb=!1,this.isvcl=null,this.payload=null,this.ntype=null,this.payload=t,this.ntype=this.payload[0]>>1&63,this.isvcl=this.ntype===e.NDR||this.ntype===e.IDR}return Object.defineProperty(e,"NDR",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"IDR",{get:function(){return 19},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VPS",{get:function(){return 32},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SPS",{get:function(){return 33},enumerable:!1,configurable:!0}),Object.defineProperty(e,"PPS",{get:function(){return 34},enumerable:!1,configurable:!0}),e.prototype.type=function(){return this.ntype},e.prototype.isKeyframe=function(){return this.ntype===e.IDR},e.prototype.getPayload=function(){return this.payload},e.prototype.getPayloadSize=function(){return this.payload.byteLength},e.prototype.getSize=function(){return 4+this.getPayloadSize()},e.prototype.getData=function(){var e=new Uint8Array(this.getSize());return new DataView(e.buffer).setUint32(0,this.getSize()-4),e.set(this.getPayload(),4),e},e}(),Br=function(){return Br=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Br.apply(this,arguments)},jr=function(){function e(e){this.remuxer=null,this.track=null,this.remuxer=e,this.track=e.mp4track}return e.parseHeader=function(e){var t=new rr(e.getPayload());t.readUByte(),e.isfmb=0===t.readUEG(),e.stype=t.readUEG()},e.prototype.parseNAL=function(e){if(!e)return!1;var t=!1;switch(e.type()){case Fr.IDR:case Fr.NDR:t=!0;break;case Fr.PPS:this.track.pps||(this.parsePPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case Fr.SPS:this.track.sps||(this.parseSPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0;break;case Fr.VPS:this.track.sps||(this.parseVPS(e.getPayload()),!this.remuxer.readyToDecode&&this.track.pps&&this.track.sps&&this.track.vps&&(this.remuxer.readyToDecode=!0)),t=!0}return t},e.prototype.ebsp2rbsp=function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0;r<e.byteLength;r++)r>=2&&3===e[r]&&0===e[r-1]&&0===e[r-2]||(t[n]=e[r],n++);return new Uint8Array(t.buffer,0,n)},e.prototype.skipScalingList=function(e,t){for(var n=8,r=8,i=0;i<t;i++)0!==r&&(r=(n+e.readEG()+256)%256),n=0===r?n:r},e.prototype.readVPS=function(e){var t=new rr(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}},e.prototype.readSPS=function(e){var t=new rr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var n=t.readBits(3);t.readBoolean();for(var r=t.readBits(2),i=t.readBoolean(),o=t.readBits(5),s=t.readUByte(),a=t.readUByte(),c=t.readUByte(),u=t.readUByte(),d=t.readUByte(),l=t.readUByte(),h=t.readUByte(),p=t.readUByte(),f=t.readUByte(),v=t.readUByte(),m=t.readUByte(),_=[],g=[],y=0;y<n;y++)_.push(t.readBoolean()),g.push(t.readBoolean());if(n>0)for(y=n;y<8;y++)t.readBits(2);for(y=0;y<n;y++)_[y]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),g[y]&&t.readUByte();t.readUEG();var S=t.readUEG();3===S&&t.skipBits(1);var b=t.readUEG(),k=t.readUEG(),E=t.readBoolean(),T=0,C=0,I=0,w=0;E&&(T+=t.readUEG(),C+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG());var R=t.readUEG(),A=t.readUEG(),O=t.readUEG();for(y=t.readBoolean()?0:n;y<=n;y++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(var x=0;x<4;x++)for(var P=0;P<(3===x?2:6);P++)if(t.readBoolean()){var D=Math.min(64,1<<4+(x<<1));for(x>1&&t.readEG(),y=0;y<D;y++)t.readEG()}else t.readUEG();t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());var M=t.readUEG(),N=0;for(y=0;y<M;y++){var L=!1;if(0!==y&&(L=t.readBoolean()),L){y===M&&t.readUEG(),t.readBoolean(),t.readUEG();for(var U=0,V=0;V<=N;V++){var F=t.readBoolean(),B=!1;F||(B=t.readBoolean()),(F||B)&&U++}N=U}else{var j=t.readUEG(),G=t.readUEG();for(N=j+G,V=0;V<j;V++)t.readUEG(),t.readBoolean();for(V=0;V<G;V++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){var H=t.readUEG();for(y=0;y<H;y++){for(V=0;V<O+4;V++)t.readBits(1);t.readBits(1)}}var W=0,K=1,z=1,q=!0,J=1,Y=0;t.readBoolean(),t.readBoolean();var X=!1;if(t.readBoolean()){if(t.readBoolean()){var $=t.readUByte();$>0&&$<16?(K=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][$-1],z=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][$-1]):255===$&&(K=t.readBits(16),z=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),(X=t.readBoolean())&&(T+=t.readUEG(),C+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG()),t.readBoolean()&&(J=t.readBits(32),Y=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){var Q=t.readBoolean(),Z=t.readBoolean(),ee=!1;for((Q||Z)&&((ee=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ee&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5)),y=0;y<=n;y++){var te=!1;(q=t.readBoolean())||t.readBoolean()?t.readEG():te=t.readBoolean();var ne=te?1:t.readUEG()+1;if(Q)for(V=0;V<ne;V++)t.readUEG(),t.readUEG(),ee&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Z)for(V=0;V<ne;V++)t.readUEG(),t.readUEG(),ee&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),W=t.readUEG())}var re=b,ie=k;if(E||X){var oe=1,se=1;1===S?oe=se=2:2===S&&(oe=2),re=b-oe*C-oe*T,ie=k-se*w-se*I}var ae=r?["A","B","C"][r]:"",ce=s<<24|a<<16|c<<8|u,ue=0;for(y=0;y<32;y++)ue=(ue|(ce>>y&1)<<31-y)>>>0;var de=ue.toString(16);1===o&&"2"===de&&(de="6");var le=i?"H":"L";return{codecString:"hvc1.".concat(ae).concat(o,".").concat(de,".").concat(le).concat(m,".B0"),params:{general_tier_flag:i,general_profile_idc:o,general_profile_space:r,general_profile_compatibility_flags:[s,a,c,u],general_constraint_indicator_flags:[d,l,h,p,f,v],general_level_idc:m,bit_depth:R+8,bit_depth_luma_minus8:R,bit_depth_chroma_minus8:A,min_spatial_segmentation_idc:W,chroma_format_idc:S,frame_rate:{fixed:q,fps:Y/J}},width:re,height:ie,pixelRatio:[K,z]}},e.prototype.readPPS=function(e){var t=new rr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var n=t.readBoolean(),r=t.readBoolean(),i=1;return r&&n?i=0:r?i=3:n&&(i=2),{parallelismType:i}},e.prototype.parseSPS=function(e){var t=this.readSPS(e);this.track.width=t.width,this.track.height=t.height,this.track.pixelRatio=t.pixelRatio,this.track.codec=t.codecString,this.track.params=Br(Br({},this.track.params),t.params),this.track.sps=[new Uint8Array(e)],console.log("resolution",this.track.width,this.track.height)},e.prototype.parsePPS=function(e){var t=this.readPPS(e);this.track.params=Br(Br({},this.track.params),t),this.track.pps=[new Uint8Array(e)]},e.prototype.parseVPS=function(e){this.track.params=Br(Br({},this.track.params),this.readVPS(e)),this.track.vps=[new Uint8Array(e)]},e}(),Gr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Hr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Wr=function(e){function t(t,n){var r=e.call(this)||this;return r.mp4track={id:dr.getTrackID(),type:"video",len:0,fragmented:!0,vps:null,sps:null,pps:null,codec:"hvc1.1.6.L150.B0",fps:30,pixelRatio:[0,0],params:{},width:0,height:0,timescale:1e3,duration:0,samples:[]},r.readyToDecode=!1,r.dts=0,r.samples=[],r.nextDts=0,r.h265=new jr(r),r.mp4track.timescale=t,r.mp4track.duration=n,r}return Gr(t,e),t.prototype.resetTrack=function(){this.readyToDecode=!1,this.mp4track.sps=null,this.mp4track.pps=null,this.mp4track.vps=null,this.mp4track.params={},this.nextDts=0,this.dts=0},t.prototype.remux=function(e){var t,n,r,i;try{for(var o=Hr(e),s=o.next();!s.done;s=o.next()){var a=s.value,c=0,u=a.units,d=a.keyFrame,l=a.duration,h=a.compositionTimeOffset;try{for(var p=(r=void 0,Hr(a.units)),f=p.next();!f.done;f=p.next()){var v=f.value;this.h265.parseNAL(v)&&(c+=v.getSize())}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(r)throw r.error}}u.length>0&&this.readyToDecode&&(this.mp4track.len+=c,this.samples.push({units:u,size:c,keyFrame:d,duration:l,compositionTimeOffset:h}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},t.prototype.getPayload=function(){var e,t;if(!this.isReady())return null;var n=new Uint8Array(this.mp4track.len),r=0;for(this.dts=this.nextDts;this.samples.length;){var i=this.samples.shift(),o=i.units,s=i.size,a=i.duration,c=i.compositionTimeOffset,u=i.keyFrame;if(a<=0)Qn("remuxer: invalid sample duration at DTS: ".concat(this.nextDts," :").concat(a)),this.mp4track.len-=s;else{this.nextDts+=a;var d={size:s,duration:a,cts:c||0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,isNonSync:u?0:1,dependsOn:u?2:1}};try{for(var l=(e=void 0,Hr(o)),h=l.next();!h.done;h=l.next()){var p=h.value;n.set(p.getData(),r),r+=p.getSize()}}catch(t){e={error:t}}finally{try{h&&!h.done&&(t=l.return)&&t.call(l)}finally{if(e)throw e.error}}this.mp4track.samples.push(d)}}return this.mp4track.samples.length?new Uint8Array(n.buffer,0,this.mp4track.len):null},t}(dr),Kr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zr=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},qr=function(e){function t(){var t=e.call(this,"remuxer")||this;return t.tracks={},t.initialized=!1,t.trackTypes=[],t.videoSeq=1,t.audioSeq=1,t.timescale=1e3,t.mediaDuration=0,t.opusConfig={sampleRate:48e3,channels:2,bitDepth:16,duration:960},t}return Kr(t,e),t.prototype.addTrack=function(e,t){var n=(void 0===t?{}:t).config;if("avc"===e&&(this.tracks.avc=new vr(this.timescale,this.mediaDuration),this.trackTypes.push("avc")),"hevc"===e&&(this.tracks.hevc=new Wr(this.timescale,this.mediaDuration),this.trackTypes.push("hevc")),"aac"===e){var r=new hr(this.timescale,this.mediaDuration);this.tracks.aac=r,this.trackTypes.push("aac")}"opus"===e&&(this.tracks.opus=new _r,this.trackTypes.push("opus"),this.opusConfig=n)},t.prototype.reset=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value;this.tracks[i].resetTrack()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}this.initialized=!1},t.prototype.destroy=function(){this.tracks={},this.offAll()},t.prototype.isReady=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value;if(!this.tracks[i].readyToDecode||!this.tracks[i].samples.length)return!1}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return!0},t.prototype.remux=function(e){var t=e.avc,n=e.hevc,r=e.aac,i=e.opus;(null==t?void 0:t.length)>0&&this.tracks.avc.remux(t),(null==n?void 0:n.length)>0&&this.tracks.hevc.remux(n),(null==r?void 0:r.length)>0&&this.tracks.aac.remux(r),(null==i?void 0:i.length)>0&&this.tracks.opus.remux(i),this.flush(Object.keys(e))},t.prototype.flush=function(e){if(this.initialized){var t,n;if(e.includes("opus")&&(null==(n=(t=this.tracks.opus).getPayload())?void 0:n.byteLength)){var r={type:"opus",payload:Vr.getMediaSegment({frames:[{data:n}],sequenceNumber:this.audioSeq,baseMediaDecodeTime:t.dts,track:t.mp4track}),dts:t.dts};this.dispatch("buffer",r),t.flush(),this.audioSeq=this.audioSeq+1}e.includes("avc")&&(null==(n=(t=this.tracks.avc).getPayload())?void 0:n.byteLength)&&(r={type:"avc",payload:tr(cr.moof(this.videoSeq,t.dts,t.mp4track),cr.mdat(n)),dts:t.dts,fps:t.mp4track.fps},this.dispatch("buffer",r),t.flush(),this.videoSeq=this.videoSeq+1),e.includes("hevc")&&(null==(n=(t=this.tracks.hevc).getPayload())?void 0:n.byteLength)&&(r={type:"hevc",payload:tr(cr.moof(this.videoSeq,t.dts,t.mp4track),cr.mdat(n)),dts:t.dts,fps:t.mp4track.fps},this.dispatch("buffer",r),t.flush(),this.videoSeq=this.videoSeq+1)}else this.isReady()&&(this.dispatch("ready"),this.initSegment(),this.initialized=!0,this.flush(e))},t.prototype.initSegment=function(){var e,t;try{for(var n=zr(this.trackTypes),r=n.next();!r.done;r=n.next()){var i=r.value,o=null;if("avc"===i&&(cr.initTypes(),o=cr.initSegment([this.tracks.avc.mp4track],this.mediaDuration,this.timescale)),"hevc"===i&&(cr.initTypes(),o=cr.initSegment([this.tracks.hevc.mp4track],this.mediaDuration,this.timescale)),"opus"===i){var s=this.opusConfig,a=s.sampleRate,c=s.channels,u=s.bitDepth;s.duration,o=Vr.getInitializationSegment({header:{sampleRate:a,channels:c,bitDepth:u,preSkip:3840,inputSampleRate:a,outputGain:0,channelMappingFamily:0}})}var d={type:i,payload:o,eventType:"init"};this.dispatch("buffer",d)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},t}(sr);const Jr=qr;var Yr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Xr=function(e){function t(t,n){var r=e.call(this,"buffer")||this;return r.bufferType=null,r.queue=new Uint8Array,r.cleaning=!1,r.pendingCleaning=0,r.cleanOffset=10,r.cleanRanges=[],r.sourceBuffer=null,r.needDestroyBuffer=!1,r.bufferType=n,r.sourceBuffer=t,r.sourceBuffer.addEventListener("updateend",(function(){r.pendingCleaning>0&&(r.initCleanup(r.pendingCleaning),r.pendingCleaning=0),r.cleaning=!1,r.cleanRanges.length?r.doCleanup():r.needDestroyBuffer&&(r.destroyBuffer(),r.needDestroyBuffer=!1)})),r.sourceBuffer.addEventListener("error",(function(e){Qn("sourceBuffer on error",e),r.dispatch("error",{type:r.bufferType,name:"buffer",error:"buffer error"})})),r}return Yr(t,e),t.prototype.destroy=function(){this.sourceBuffer.updating?this.needDestroyBuffer=!0:this.destroyBuffer(),this.queue=null,this.sourceBuffer=null,this.offAll()},t.prototype.destroyBuffer=function(){var e;if((null===(e=this.sourceBuffer.buffered)||void 0===e?void 0:e.length)&&!this.cleaning)for(var t=0;t<this.sourceBuffer.buffered.length;++t){var n=this.sourceBuffer.buffered.start(t),r=this.sourceBuffer.buffered.end(t);this.sourceBuffer.remove(n,r)}},t.prototype.doCleanup=function(){if(this.cleanRanges.length){var e=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(this.cleanRanges.shift(),2),t=e[0],n=e[1];Qn("".concat(this.bufferType," remove range [").concat(t," - ").concat(n,")")),this.cleaning=!0,this.sourceBuffer.remove(t,n)}else this.cleaning=!1},t.prototype.initCleanup=function(e){var t;try{if(this.sourceBuffer.updating)return void(this.pendingCleaning=e);if((null===(t=this.sourceBuffer.buffered)||void 0===t?void 0:t.length)&&!this.cleaning){for(var n=0;n<this.sourceBuffer.buffered.length;++n){var r=this.sourceBuffer.buffered.start(n),i=this.sourceBuffer.buffered.end(n);e-r>this.cleanOffset&&r<(i=e-this.cleanOffset)&&this.cleanRanges.push([r,i])}this.doCleanup()}}catch(e){Zn("Error occured while cleaning ".concat(this.bufferType," buffer - ").concat(e.name,": ").concat(e.message))}},t.prototype.doAppend=function(){if(this.queue.length&&this.sourceBuffer&&!this.sourceBuffer.updating)try{this.sourceBuffer.appendBuffer(this.queue),this.queue=new Uint8Array}catch(t){var e="unexpectedError";Qn("doAppend error, ",t,t.name),"QuotaExceededError"===t.name?(Qn("".concat(this.bufferType," buffer quota full")),e="QuotaExceeded"):(Zn("Error occured while appending ".concat(this.bufferType," buffer - ").concat(t.name,": ").concat(t.message)),e="InvalidStateError"),this.dispatch("error",{type:this.bufferType,name:e,error:"buffer error"})}},t.prototype.feed=function(e){this.queue=tr(this.queue,e),this.doAppend()},t}(sr);const $r=Xr;var Qr=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Zr=function(){return Zr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Zr.apply(this,arguments)},ei=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ti=function(e){function t(t){var n,r,i,o=this;return(o=e.call(this,"muxer")||this).isMSESupported=null,o.node=null,o.mseReady=null,o.mseEnded=null,o.videoStarted=null,o.interval=null,o.mediaSource=null,o.url=null,o.options={node:"",mode:null,flushingTime:0,maxDelay:100,clearBuffer:!0,fps:30,readFpsFromTrack:!1,debug:!1,opusConfig:{SampleRate:48e3,SampleFormat:16,Channels:2,PcmFrameSize:960},onReady:nt,onData:nt,onError:nt,onMissingVideoFrames:nt,onMissingAudioFrames:nt,onEvent:nt},o.isReset=!1,o.frameDuration=1e3/o.options.fps|0,o.remuxController=null,o.bufferControllers=null,o.lastCleaningTime=null,o.kfPosition=null,o.kfCounter=null,o.options=Zr(Zr({},o.options),t),o.options.debug&&(Jn=console.log,Yn=console.error),o.frameDuration=1e3/o.options.fps|0,o.remuxController=new Jr,(null===(n=o.options.mode)||void 0===n?void 0:n.avc)&&o.remuxController.addTrack("avc"),(null===(r=o.options.mode)||void 0===r?void 0:r.hevc)&&o.remuxController.addTrack("hevc"),(null===(i=o.options.mode)||void 0===i?void 0:i.opus)&&o.remuxController.addTrack("opus",{config:{sampleRate:o.options.opusConfig.SampleRate,channels:o.options.opusConfig.Channels,bitDepth:o.options.opusConfig.SampleFormat,duration:o.options.opusConfig.PcmFrameSize}}),o.initData(),o.remuxController.on("buffer",o.onBuffer.bind(o)),o.remuxController.on("ready",o.createBuffer.bind(o)),o.initBrowser(),o}return Qr(t,e),t.isSupported=function(e){var t;return null===(t=window.MediaSource)||void 0===t?void 0:t.isTypeSupported(e)},t.prototype.feed=function(e){var t={};if(e&&this.remuxController){var n,r=e.avc,i=e.hevc,o=e.aac,s=e.opus,a=e.duration,c=void 0===a?0:a,u=e.compositionTimeOffset;if(r&&this.options.mode.avc&&((n=nr(r)).length>0?t.avc=this.getVideoFrames(n,c,u):"function"==typeof this.options.onMissingVideoFrames&&this.options.onMissingVideoFrames.call(null,e)),i&&this.options.mode.hevc&&((n=nr(i)).length>0?t.hevc=this.getHevcVideoFrames(n,c,u):"function"==typeof this.options.onMissingVideoFrames&&this.options.onMissingVideoFrames.call(null,e)),o&&this.options.mode.aac){var d=or.extractAAC(o);d.length>0?t.aac=this.getAudioFrames(d,c):(Qn("Failed to extract audio data from:",o),"function"==typeof this.options.onMissingAudioFrames&&this.options.onMissingAudioFrames.call(null,e))}if(s&&this.options.mode.opus){if(!this.options.mode.opus)return;t.opus=this.getOpusFrames([s],this.options.opusConfig.PcmFrameSize)}this.remuxController.remux(t)}},t.prototype.destroy=function(){var e,t,n,r;this.stopInterval(),this.remuxController&&(this.remuxController.destroy(),this.remuxController=null),this.bufferControllers&&(null===(e=this.bufferControllers.avc)||void 0===e||e.destroy(),null===(t=this.bufferControllers.hevc)||void 0===t||t.destroy(),null===(n=this.bufferControllers.aac)||void 0===n||n.destroy(),null===(r=this.bufferControllers.opus)||void 0===r||r.destroy(),this.bufferControllers=null,this.endMSE()),this.node=null,this.mseReady=!1,this.videoStarted=!1,this.mediaSource=null},t.prototype.reset=function(){var e,t,n,r;this.stopInterval(),this.isReset=!0,this.node.pause(),this.remuxController&&this.remuxController.reset(),this.bufferControllers&&(null===(e=this.bufferControllers.avc)||void 0===e||e.destroy(),null===(t=this.bufferControllers.hevc)||void 0===t||t.destroy(),null===(n=this.bufferControllers.aac)||void 0===n||n.destroy(),null===(r=this.bufferControllers.opus)||void 0===r||r.destroy(),this.bufferControllers=null,this.endMSE()),this.initData(),this.initBrowser(),Qn("Muxer was reset")},t.prototype.playCurrent=function(){var e,t;if((null===(t=null===(e=this.node)||void 0===e?void 0:e.buffered)||void 0===t?void 0:t.length)>0&&!this.node.seeking){var n=this.node.buffered.end(0);this.node.currentTime=n-.001}},t.prototype.getVideoResolution=function(e){var t,n=e.type,r=null===(t=this.remuxController.tracks[n])||void 0===t?void 0:t.mp4track;return{width:r.width,height:r.height}},t.prototype.initData=function(){this.lastCleaningTime=Date.now(),this.kfPosition=[],this.kfCounter=0,this.startInterval()},t.prototype.initBrowser=function(){"string"==typeof this.options.node&&""===this.options.node&&Zn("no video element were found to render, provide a valid video element"),this.node="string"==typeof this.options.node?document.querySelector(this.options.node):this.options.node,this.mseReady=!1,this.setupMSE()},t.prototype.setupMSE=function(){if(window.MediaSource=window.MediaSource||window.WebKitMediaSource||window.ManagedMediaSource,!window.MediaSource)throw"Oops! Browser does not support Media Source Extension or Managed Media Source (IOS 17+).";if(this.isMSESupported=!!window.MediaSource,this.mediaSource=new window.MediaSource,this.url=URL.createObjectURL(this.mediaSource),window.MediaSource===window.ManagedMediaSource)try{this.node.removeAttribute("src"),this.node.disableRemotePlayback=!0;var e=document.createElement("source");e.type="video/mp4",e.src=this.url,this.node.appendChild(e),this.node.load()}catch(e){console.log("ManagedMediaSource error",e),this.node.src=this.url}else this.node.src=this.url;this.mseEnded=!1,this.mediaSource.addEventListener("sourceopen",this.onMSEOpen.bind(this)),this.mediaSource.addEventListener("sourceclose",this.onMSEClose.bind(this)),this.mediaSource.addEventListener("webkitsourceopen",this.onMSEOpen.bind(this)),this.mediaSource.addEventListener("webkitsourceclose",this.onMSEClose.bind(this))},t.prototype.endMSE=function(){if(!this.mseEnded)try{this.mseEnded=!0,this.mediaSource.endOfStream()}catch(e){Qn("mediaSource is not available to end",e)}},t.prototype.getVideoFrames=function(e,t,n){var r,i,o=[],s=[],a=!1;try{for(var c=ei(e),u=c.next();!u.done;u=c.next()){var d=u.value,l=new er(d);l.type()!==er.IDR&&l.type()!==er.NDR||ir.parseHeader(l),s.push(l),a=l.isKeyframe(),l.isvcl&&l.isfmb&&(o.push({units:s,keyFrame:a,duration:t||this.frameDuration,compositionTimeOffset:n}),this.kfCounter=this.kfCounter+1,a&&this.options.clearBuffer&&this.kfPosition.push(this.kfCounter*(t||this.frameDuration)/1e3))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return o},t.prototype.getHevcVideoFrames=function(e,t,n){var r,i,o=[],s=[],a=!1;try{for(var c=ei(e),u=c.next();!u.done;u=c.next()){var d=u.value,l=new Fr(d);l.type()!==Fr.IDR&&l.type()!==Fr.NDR||jr.parseHeader(l),s.push(l),a=l.isKeyframe(),l.isvcl&&(o.push({units:s,keyFrame:a,duration:t||this.frameDuration,compositionTimeOffset:n}),this.kfCounter=this.kfCounter+1,a&&this.options.clearBuffer&&this.kfPosition.push(this.kfCounter*(t||this.frameDuration)/1e3))}}catch(e){r={error:e}}finally{try{u&&!u.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}return o},t.prototype.getAudioFrames=function(e,t){var n,r,i,o=[],s=0;try{for(var a=ei(e),c=a.next();!c.done;c=a.next()){var u=c.value;o.push({units:u})}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return i=t?t/o.length|0:this.frameDuration,s=t?t-i*o.length:0,o.forEach((function(e){e.duration=i,s>0&&(e.duration=e.duration+1,s-=1)})),o},t.prototype.getOpusFrames=function(e,t){var n,r,i=[];try{for(var o=ei(e),s=o.next();!s.done;s=o.next()){var a=s.value;i.push({unit:a,duration:t})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},t.prototype.createBuffer=function(){var e;if(this.mseReady&&(null===(e=this.remuxController)||void 0===e?void 0:e.isReady())&&!this.bufferControllers)for(var n in this.bufferControllers={},this.remuxController.tracks){var r=n,i=this.remuxController.tracks[r],o="opus"===n||"aac"===n?"audio":"video";if(!t.isSupported("".concat(o,'/mp4; codecs="').concat(i.mp4track.codec,'"')))return Zn("Browser does not support codec"),!1;var s=this.mediaSource.addSourceBuffer("".concat(o,'/mp4; codecs="').concat(i.mp4track.codec,'"'));this.bufferControllers[r]=new $r(s,r),this.bufferControllers[r].on("error",this.onBufferError.bind(this))}},t.prototype.startInterval=function(){var e=this;this.interval=setInterval((function(){e.cancelDelay()}),1e3)},t.prototype.stopInterval=function(){this.interval&&clearInterval(this.interval)},t.prototype.cancelDelay=function(){var e;if((null===(e=this.node.buffered)||void 0===e?void 0:e.length)>0&&!this.node.seeking){var t=this.node.buffered.end(0);t-this.node.currentTime>this.options.maxDelay/1e3&&(this.node.currentTime=t-.001)}},t.prototype.applyAndClearBuffer=function(){this.bufferControllers&&this.clearBuffer()},t.prototype.getSafeClearOffsetOfBuffer=function(e){for(var t,n=(this.options.mode.aac||this.options.mode.opus)&&e||0,r=0;r<this.kfPosition.length&&!(this.kfPosition[r]>=e);r++)t=this.kfPosition[r];return t&&(this.kfPosition=this.kfPosition.filter((function(e){return e<t&&(n=e),e>=t}))),n},t.prototype.clearBuffer=function(){var e,t;if(this.options.clearBuffer&&Date.now()-this.lastCleaningTime>1e4){if(this.bufferControllers.avc||this.bufferControllers.hevc){var n=this.getSafeClearOffsetOfBuffer(this.node.currentTime);null===(e=this.bufferControllers.avc)||void 0===e||e.initCleanup(n),null===(t=this.bufferControllers.hevc)||void 0===t||t.initCleanup(n)}this.bufferControllers.opus&&this.bufferControllers.opus.initCleanup(this.node.currentTime),this.lastCleaningTime=Date.now()}},t.prototype.onBuffer=function(e){var t,n,r,i,o,s,a,c,u,d,l=e.payload,h=e.type,p=e.fps,f=e.eventType;this.options.readFpsFromTrack&&void 0!==p&&this.options.fps!==p&&(this.options.fps=p,this.frameDuration=Math.ceil(1e3/p),Qn("Muxer changed FPS to ".concat(p," from track data"))),this.bufferControllers&&("avc"===h&&(null===(n=null===(t=this.bufferControllers)||void 0===t?void 0:t.avc)||void 0===n||n.feed(l)),"hevc"===h&&(null===(i=null===(r=this.bufferControllers)||void 0===r?void 0:r.hevc)||void 0===i||i.feed(l)),"aac"===h&&(null===(s=null===(o=this.bufferControllers)||void 0===o?void 0:o.aac)||void 0===s||s.feed(l)),"opus"===h&&(null===(c=null===(a=this.bufferControllers)||void 0===a?void 0:a.opus)||void 0===c||c.feed(l))),this.options.onData&&this.options.onData({data:e}),0===this.options.flushingTime&&this.applyAndClearBuffer(),"init"===f&&(null===(d=(u=this.options).onReady)||void 0===d||d.call(u))},t.prototype.onMSEOpen=function(){this.mseReady=!0,URL.revokeObjectURL(this.url)},t.prototype.onMSEClose=function(){this.mseReady=!1,this.videoStarted=!1},t.prototype.onBufferError=function(e){if(Qn("onBufferError",e),"QuotaExceeded"===e.name)return Qn("Muxer cleaning ".concat(e.type," buffer due to QuotaExceeded error")),void this.bufferControllers[e.type].initCleanup(this.node.currentTime);"InvalidStateError"===e.name?this.reset():this.endMSE(),"function"==typeof this.options.onError&&this.options.onError.call(null,e)},t}(sr);const ni=ti;var ri=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},ii=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},oi=function(){function e(e){var t=e.sdk;this.sdk=null,this.token=null,this.instanceId=null,this.url="",this.socket=null,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder,this.heartbeatTimer=null,this.streamPushStat=null,this.videoState="play",this.videoMuxer=null,this.audioMuxer=null,this.sessionInfo=null,this.lastVideoFrameTimeStamp=0,this.dataChannelCallbacks={},this.dataChannelRetryTimers={},this.mount=null,this.sdk=t}return e.prototype.init=function(e){var t=e.mount;this.mount=t},e.prototype.connect=function(e){var t=e.url,n=e.protocols,r=void 0===n?["media-v1"]:n,i=e.token,o=e.instanceId,s=e.videoCodecList,a=void 0===s?["h264","h265"]:s;return ri(this,0,void 0,(function(){return ii(this,(function(e){switch(e.label){case 0:return this.token=i,this.instanceId=o,this.url=t,t?[4,this.createSocket({url:"".concat(t,"/play?token=").concat(i,"&instance_id=").concat(o,"&video_codec_list=").concat(a.join(",")),protocols:r})]:[3,2];case 1:return e.sent(),[3,3];case 2:this.sdk.log("websocket connect url is empty",t),e.label=3;case 3:return[2]}}))}))},e.prototype.connectGroupControl=function(e){var t=e.url,n=e.protocols,r=void 0===n?["media-v1"]:n,i=e.tokenInfos,o=e.videoCodecList,s=void 0===o?["h264","h265"]:o;return ri(this,0,void 0,(function(){return ii(this,(function(e){switch(e.label){case 0:return this.url=t,[4,this.createSocket({url:"".concat(t,"/group/play?video_codec_list=").concat(s.join(",")),protocols:r})];case 1:return 0===e.sent().code&&this.createGroupSession({tokenInfos:i}),[2]}}))}))},e.prototype.joinGroupControl=function(e){var t=e.tokenInfos,n=e.groupControlId;return ri(this,0,void 0,(function(){return ii(this,(function(e){return this.sdk.log("websocket join group session"),this.sendText({Type:"JoinGroupSession",RequestId:Kn(),Data:{TokenInfos:t,GroupControlId:n}}),[2]}))}))},e.prototype.dataChannelSend=function(e){var t=e.label,n=e.binary,r=void 0===n?0:n,i=e.data;return ri(this,0,void 0,(function(){var e,n,o,s,a,c;return ii(this,(function(u){switch(u.label){case 0:return e=new Uint8Array([qn.message,r]).buffer,n=this.textEncoder.encode(t).buffer,o=new ArrayBuffer(4),new DataView(o).setUint32(0,n.byteLength),s=this.textEncoder.encode(JSON.stringify(i)).buffer,a=new ArrayBuffer(4),new DataView(a).setUint32(0,s.byteLength),[4,ut(e,o,n,a,s)];case 1:return c=u.sent(),this.socket.send(c),[2]}}))}))},e.prototype.destroy=function(e){var t,n,r=e.code,i=e.message;this.socket.close(),this.clearIntervals(),this.sdk.onDisconnect({code:r,msg:i}),null===(t=this.videoMuxer)||void 0===t||t.destroy(),null===(n=this.audioMuxer)||void 0===n||n.destroy()},e.prototype.reconnect=function(e){var t=e.message;this.sdk.log("websocket reconnect, message",t),this.connect({token:this.token,url:this.url,instanceId:this.instanceId})},e.prototype.getMuxer=function(e){return"video"===e?this.videoMuxer:"audio"===e?this.audioMuxer:void 0},e.prototype.setMediaState=function(e){var t=e.type,n=e.state;"video"===t&&(this.videoState=n)},e.prototype.createSocket=function(e){var t=e.url,n=e.protocols;return ri(this,0,void 0,(function(){var e=this;return ii(this,(function(r){return[2,new Promise((function(r){e.socket=new WebSocket(t,n),e.socket.binaryType="arraybuffer",e.socket.onopen=function(){e.sdk.log("socket onopen, socket binaryType",e.socket.binaryType),r({code:0,message:"onopen"})},e.socket.onmessage=function(t){var n,r=t.data;(n=r)&&n instanceof ArrayBuffer&&void 0!==n.byteLength?e.onArrayBufferMessage(r):e.onTextMessage(r)},e.socket.onclose=function(t){e.sdk.log("socket onclose",t),e.clearIntervals(),r({code:1,message:"onclose"})},e.socket.onerror=function(t){e.sdk.log("socket onerror",t),e.clearIntervals(),r({code:2,message:"onerror"})}}))]}))}))},e.prototype.onTextMessage=function(e){try{var t=JSON.parse(e),n=t.Type,r=t.Data,i=r.Code;switch(n){case"CreateSession":case"CreateGroupSession":0===i&&this.onCreateSessionSuccess(r)}}catch(e){this.sdk.log("Parse text message error",e)}},e.prototype.onArrayBufferMessage=function(e){var t=new DataView(e),n=t.getUint8(0);if(n===zn.h264||n===zn.h265){var r=t.getUint32(1),i=e.slice(5,e.byteLength);this.processVideoFrameBuffer({frame:i,duration:(r-this.lastVideoFrameTimeStamp)/90}),this.lastVideoFrameTimeStamp=r}if(n===zn.opus&&(i=e.slice(5,e.byteLength),this.processOpusFrameBuffer(i)),n===qn.message){var o=t.getUint32(2),s=e.slice(6,6+o),a=e.slice(2+o+4+4,e.byteLength),c=this.textDecoder.decode(s);i=this.textDecoder.decode(a),c===ge.KM&&this.onKmMessage(i),c===ge.SV&&this.onSvrMessage(i),c===ge.HB&&this.onHbMessage(i),c===ge.CLOUD_DEVICE&&this.onCloudDeviceMessage(i),c===ge.ACK&&this.onAckMessage(i)}},e.prototype.processVideoFrameBuffer=function(e){var t,n,r,i=e.frame,o=e.duration;"play"===this.videoState&&(null===(t=this.videoMuxer)||void 0===t||t.feed({avc:"h264"===(null===(n=this.sessionInfo)||void 0===n?void 0:n.Video)?new Uint8Array(i):void 0,hevc:"h265"===(null===(r=this.sessionInfo)||void 0===r?void 0:r.Video)?new Uint8Array(i):void 0,duration:o}))},e.prototype.processOpusFrameBuffer=function(e){var t;null===(t=this.audioMuxer)||void 0===t||t.feed({opus:new Uint8Array(e)})},e.prototype.createSession=function(e){var t=e.Token,n=e.InstanceId;this.sdk.log("websocket createSession, instanceId",n),this.sendText({Type:"CreateSession",Data:{Token:t,AndroidInstanceId:n,VideoCodecList:["h264"]}})},e.prototype.createGroupSession=function(e){var t=e.tokenInfos;this.sdk.log("websocket create group session"),this.sendText({Type:"CreateGroupSession",RequestId:Kn(),Data:{TokenInfos:t}})},e.prototype.sendText=function(e){this.sdk.log("websocket sendText",e),this.socket.send(JSON.stringify(e))},e.prototype.onCreateSessionSuccess=function(e){var t=this;this.sessionInfo=e;var n=e.Video,r=e.Audio,i=e.GroupControlId;this.sdk.log("Video",n,"Audio",r,"GroupControlId",i),this.sdk.androidInstance.groupControl.groupControlId=i,this.sdk.androidInstance.groupControl.onConnectSuccess(),this.sdk.gameConfig.setConfig({clientId:this.mount,config:{video_mime_type:"video/".concat(n.toLowerCase()),audio_mime_type:"audio/".concat(null==r?void 0:r.Codec.toLowerCase())}});var o="h265"===n?"hevc":"avc";this.videoMuxer=new ni({node:".".concat(this.mount," .video-stream"),mode:{avc:"h264"===n||void 0,hevc:"h265"===n||void 0},debug:this.debugSetting.showMuxer,onReady:function(){var e,n,r;t.sdk.getCloudGamingContainerElement()&&(t.sdk.getCloudGamingContainerElement().style.display="flex"),t.sdk.getProgressBarElement()&&(t.sdk.getProgressBarElement().style.display="none"),t.sdk.getRestartElement()&&(t.sdk.getRestartElement().style.display="none"),t.startHeartbeatReport(),t.sdk.pageEvent.addEventHandler(),t.sdk.onConnectSuccess({code:0});var i=t.videoMuxer.getVideoResolution({type:o}),s=i.width,a=i.height;t.sdk.showStats.setStaticStat({resolution:"".concat(s,"x").concat(a)}),null===(r=null===(n=null===(e=t.sdk.getVideoElement())||void 0===e?void 0:e.play())||void 0===n?void 0:n.then((function(){t.sdk.log("video play success"),t.sdk.onEvent({type:"autoplay",data:{code:0,message:"video play success"}}),t.sdk.reshapeWindow()})))||void 0===r||r.catch((function(e){t.sdk.log("video play error, ",e,e.name),t.sdk.onEvent({type:"autoplay",data:{code:-1,message:e}})}))}});var s=r.Channels,a=r.SampleRate,c=r.PcmFrameSize;this.audioMuxer=new ni({node:".".concat(this.mount," .cloud-gaming-audio-stream-socket"),mode:{opus:!0},maxDelay:1e3,opusConfig:{SampleRate:a,SampleFormat:16,Channels:s,PcmFrameSize:c},debug:this.debugSetting.showMuxer})},e.prototype.createDataChannel=function(e){var t=e.label;return ri(this,0,void 0,(function(){var e,n;return ii(this,(function(r){switch(r.label){case 0:return this.sdk.log("create ".concat(t," data channel")),e=this.textEncoder.encode(t),[4,ut(new Uint8Array([qn.open]).buffer,e.buffer)];case 1:return n=r.sent(),this.socket.send(n),[2]}}))}))},e.prototype.startHeartbeatReport=function(){var e=this;clearInterval(this.heartbeatTimer),this.sdk.log("startHeartbeatReport ->"),this.heartbeatTimer=setInterval((function(){return ri(e,0,void 0,(function(){return ii(this,(function(e){return this.dataChannelSend({label:ge.HB,data:{user_id:this.instanceId,timestamp:+new Date}}),[2]}))}))}),5e3)},Object.defineProperty(e.prototype,"debugSetting",{get:function(){return this.sdk.getInitOptions().debugSetting||{}},enumerable:!1,configurable:!0}),e.prototype.onKmMessage=function(e){try{var t=JSON.parse(e);this.debugSetting.showOnKmMessage&&console.log("onKmMessage",t);var n=t.screen_width,r=t.screen_height,i=t.screen_left,o=t.screen_top;this.sdk.pageEvent.remoteScreenResolutionChange({width:n,height:r,left:i,top:o})}catch(e){this.sdk.log("parse km message error",e)}},e.prototype.onSvrMessage=function(e){if(e)try{var t=JSON.parse(e),n=t.type,r=t.data;switch(this.debugSetting.showOnSvMessage&&this.sdk.log("onSvMessage","type: ",n,"data",e),n){case"metric_sig_key":this.sdk.gameConfig.updateConfig({clientId:this.mount,config:{sig_key:r.sig_key}});break;case"screen_config_change":this.sdk.onConfigurationChange({screen_config:r});break;case"hit_input":var i=r,o=i.field_type,s=i.status;this.sdk.onInputStatusChange({field_type:o,status:s});break;case"camera_status":r.status}}catch(e){this.sdk.log("onSvMessage data parse failed",e)}else this.sdk.log("onSvMessage no data")},e.prototype.onHbMessage=function(e){try{var t=JSON.parse(e),n=t.timestamp,r=t.token,i=t.stream_push_state;if(this.debugSetting.showOnHbMessage&&console.log("onHbMessage",t),this.token=r,n){var o=+new Date-+n;this.sdk.showStats.setRTT(o)&&this.sdk.onNetworkChange({status:"jitter",data:{value:o,message:"NETWORK_JITTER"}})}i&&this.streamPushStat!==i&&(this.streamPushStat=i,this.sdk.onStreamPushStateChange({stream_push_state:this.streamPushStat}))}catch(e){this.sdk.log("parse hb message error",e)}},e.prototype.onCloudDeviceMessage=function(e){return ri(this,0,void 0,(function(){var t,n,r,i,o,s,a,c,u,d;return ii(this,(function(l){switch(l.label){case 0:if(!e)return[3,14];l.label=1;case 1:switch(l.trys.push([1,12,,13]),t=JSON.parse(e),n=t.type,r=t.data,this.debugSetting.showOnCloudDeviceMessage&&this.sdk.log("onCloudDeviceData","type: ",n,"data",e,"cloudDeviceData",r),n){case"trans_message":return[3,2];case"system_usage":return[3,3];case"clipboard_event":return[3,4];case"notification_event":return[3,9]}return[3,10];case 2:return this.sdk.onAndroidInstanceEvent({type:"trans_message",data:r}),[3,11];case 3:return this.sdk.onAndroidInstanceEvent({type:"system_usage",data:r}),o=(i=r).cpu_usage,s=i.gpu_usage,this.sdk.showStats.setCpuAndGpuUsage({cpu:"".concat(it(o)),gpu:"".concat(it(s))}),[3,11];case 4:a=!0,c=r.text,l.label=5;case 5:return l.trys.push([5,7,,8]),[4,navigator.clipboard.writeText(c)];case 6:return l.sent(),[3,8];case 7:return u=l.sent(),this.sdk.log("navigator.clipboard.writeText failed",u),a=!1,[3,8];case 8:return this.sdk.onAndroidInstanceEvent({type:"clipboard_event",data:{text:c,writeText:a}}),[3,11];case 9:return this.sdk.onAndroidInstanceEvent({type:"notification_event",data:r}),[3,11];case 10:return[3,11];case 11:return[3,13];case 12:return d=l.sent(),this.sdk.log("onCloudDeviceData data parse failed",d),[3,13];case 13:return[3,15];case 14:this.sdk.log("onCloudDeviceData no data"),l.label=15;case 15:return[2]}}))}))},e.prototype.onAckMessage=function(e){if(e)try{var t=JSON.parse(e),n=t.data,r=void 0===n?st:n,i=t.seq;this.debugSetting.showOnAckMessage&&("cursor_state"===r.type||"keys_clean"===r.type||console.log("onAckMessage",r,i));var o=this.dataChannelCallbacks[i];if(i&&(this.sdk.showStats.setInputEnd(i),o)){var s=o.callback;delete this.dataChannelCallbacks[i],this.dataChannelRetryTimers[i]&&(clearTimeout(this.dataChannelRetryTimers[i]),delete this.dataChannelRetryTimers[i]),null==s||s({code:0,msg:"on ack message",data:r})}"open_url"===r.type&&(this.sdk.log("got open_url",r),this.sdk.onNetworkChange({status:"openurl",data:{value:r.url}}),this.sdk.onEvent({type:"openurl",data:{value:r.url}}))}catch(e){this.sdk.log("onAckMessage exception->",null==e?void 0:e.message)}else this.sdk.log("onAckMessage no data")},e.prototype.clearIntervals=function(){clearInterval(this.heartbeatTimer)},e}();const si=oi;var ai=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},ci=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},ui=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},di=function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))},li={Token:"",Zone:"",OperatorAddress:"",WebSocketAddress:"",WebSocketSecureAddress:"",WebRTCAddress:"",EdgeProxyAddress:"",InstanceInfo:null},hi=function(){function e(e){var t=e.sdk;this.sdk=null,this.instanceAccessInfo=new Map,this.accessInfo=[],this.sdk=t}return e.prototype.setInstanceAccessInfo=function(e){var t=this,n=e.AccessInfo,r=e.Token;try{n=qe(n)}catch(e){this.sdk.log("Decode AccessInfo error",e.message)}try{var i=JSON.parse(n).AccessInfo;this.accessInfo=di(di([],ui(this.accessInfo),!1),ui(i),!1),null==i||i.forEach((function(e){var n=e.Zone,i=e.InstanceIds,o=e.OperatorAddress,s=e.WebSocketAddress,a=e.WebSocketSecureAddress,c=e.WebRTCAddress,u=e.EdgeProxyAddress,d=e.InstancesInfo,l=void 0===d?[]:d;i.forEach((function(e){var i=(null==l?void 0:l.find((function(t){return t.InstanceId===e})))||{},d=i.Data,h=i.InstanceId,p=null;h&&d&&(p={InstanceId:h,Data:d}),t.instanceAccessInfo.set(e,{Token:r,Zone:n,OperatorAddress:o,WebSocketAddress:s,WebSocketSecureAddress:a,WebRTCAddress:c,EdgeProxyAddress:u,InstanceInfo:p})}))}))}catch(e){this.sdk.log("Parse AccessInfo error",e.message)}},e.prototype.getInstanceAccessInfo=function(e){var t=e.instanceId;return this.instanceAccessInfo.get(t)||li},e.prototype.getTokenInfos=function(e){var t=this,n=e.instanceIds,r=[],i=[];return n.forEach((function(e){var n=t.getInstanceAccessInfo({instanceId:e}).Token;n?r.push({Token:n,AndroidInstanceId:e}):(t.sdk.log("Token is not set",e),i.push(e))})),i.length&&this.sdk.onEvent({type:"token_not_found",data:{instance_ids:i}}),r},e.prototype.createWebRTCSession=function(e){var t=e.instanceId,n=e.clientSession;return ai(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p;return ci(this,(function(f){switch(f.label){case 0:if(!t||!n)return[3,5];if(e=this.getInstanceAccessInfo({instanceId:t}),r=e.Token,i=e.WebRTCAddress,o=e.EdgeProxyAddress,!(s=o||i))return[3,4];a="".concat(s,"/play"),c={Authorization:"Bearer ".concat(r)},(u=this.getInstanceInfoHeader({instanceId:t,encode:"url_encode"}).instanceInfo)&&(c["Crtr-Proxy-Instance-Info"]=u),f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Dn({url:a,data:{RequestID:this.sdk.getRequestId()||Kn(),Token:r,AndroidInstanceId:t,ClientSession:n},headers:c})];case 2:return d=f.sent(),l=d.ServerSession,h=d.Code,p=d.Message,[2,{ServerSession:l,Code:h,Message:p}];case 3:throw f.sent();case 4:this.sdk.log("play requestAddress is not found"),f.label=5;case 5:return this.sdk.log("Create session error, instanceId or clientSession is empty"),[2]}}))}))},e.prototype.createWebRTCGroupSession=function(e){var t=e.instanceIds,n=e.clientSessions;return ai(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v;return ci(this,(function(m){switch(m.label){case 0:if(e=this.getTokenInfos({instanceIds:t}),r=this.getInstanceAccessInfo({instanceId:t[0]}),i=r.Token,o=r.EdgeProxyAddress,s=r.WebRTCAddress,a=this.getInstancesInfo({instanceIds:t}).InstancesInfo,!(c=o||s))return[3,4];u="".concat(c,"/group/play"),d={Authorization:"Bearer ".concat(i)},m.label=1;case 1:return m.trys.push([1,3,,4]),[4,Dn({url:u,data:{RequestID:Kn(),TokenInfos:e,ClientSessions:n,InstancesInfo:a},headers:d})];case 2:return l=m.sent(),h=l.GroupControlId,p=l.ServerSessions,f=l.Code,v=l.Message,this.sdk.log("Create WebRTC GroupSession",h,p),[2,{Code:f,Message:v,GroupControlId:h,ServerSessions:p}];case 3:throw m.sent();case 4:return this.sdk.log("requestAddress is not found"),[2]}}))}))},e.prototype.joinWebRTCGroupSession=function(e){var t=e.instanceIds,n=e.clientSessions,r=e.groupControlId;return ai(this,0,void 0,(function(){var e,i,o,s,a,c,u,d,l,h,p;return ci(this,(function(f){switch(f.label){case 0:if(e=this.getTokenInfos({instanceIds:t}),i=this.getInstanceAccessInfo({instanceId:t[0]}),o=i.Token,s=i.WebRTCAddress,a=i.EdgeProxyAddress,c=this.getInstancesInfo({instanceIds:t}).InstancesInfo,!(u=a||s))return[3,4];d="".concat(u,"/group/join"),l={Authorization:"Bearer ".concat(o)},f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Dn({url:d,data:{RequestID:Kn(),GroupControlId:r,TokenInfos:e,ClientSessions:n,InstancesInfo:c},headers:l})];case 2:return h=f.sent().ServerSessions,p=void 0===h?[]:h,this.sdk.log("Join WebRTC GroupSession",p),[2,{ServerSessions:(null==p?void 0:p.length)?p:[]}];case 3:throw f.sent();case 4:return this.sdk.log("group play requestAddress is not found"),[2]}}))}))},e.prototype.getInstancesInfo=function(e){var t=this,n=e.instanceIds,r=[];return n.forEach((function(e){var n=t.getInstanceAccessInfo({instanceId:e}).InstanceInfo;n&&r.push(n)})),{InstancesInfo:r}},e.prototype.getInstanceInfoHeader=function(e){var t=e.instanceId,n=e.method,r=void 0===n?"POST":n,i=e.encode,o=void 0===i?"base64":i,s=this.getInstanceAccessInfo({instanceId:t}).InstanceInfo;if(s){var a=s.InstanceId,c=s.Data,u="";if(a&&c)try{u="url_encode"===o?encodeURIComponent(JSON.stringify({InstanceId:a,Data:c})):ze(JSON.stringify({InstanceId:a,Data:c}))}catch(e){this.sdk.log("stringify instanceInfo string error",e.name,e.message)}else this.sdk.log("InstanceId, Data is not found",a,c);return"GET"===r&&(u="&instance_info=".concat(u)),{instanceInfo:u}}return{instanceInfo:""}},e}();const pi=hi;var fi=function(){return fi=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},fi.apply(this,arguments)},vi=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},mi=function(){function e(e){var t=e.sdk;this.masterInstanceId="",this.instanceIds=[],this._groupControlId="",this.imageEventTimer=null,this.options={image:{interval:1,quality:20}},this.sdk=null,this.sdk=t}return Object.defineProperty(e.prototype,"groupControlId",{get:function(){return this._groupControlId},set:function(e){this._groupControlId=e},enumerable:!1,configurable:!0}),e.prototype.init=function(e){this.options=fi(fi({},this.options),e)},e.prototype.start=function(e){var t=e.instanceIds,n=e.serverSessions,r=e.groupControlId;try{this.instanceIds=t;var i=vi(t,1)[0];this.masterInstanceId=i,this._groupControlId=r;var o=n[0];this.sdk.cloudGamingWebRTC.connect(o)}catch(e){this.sdk.log("serverSession 解析失败",e)}},e.prototype.startWebSocket=function(e){var t=e.url,n=e.tokenInfos,r=e.instanceIds;this.instanceIds=r;var i=vi(r,1)[0];this.masterInstanceId=i,this.sdk.cloudGamingWebsocket.connectGroupControl({url:t,tokenInfos:n})},e.prototype.requestStream=function(e){var t=e.instanceId,n=e.status,r=e.level,i=void 0===r?"normal":r;"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"streaming_request",user:t,data:{status:n,level:i}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"streaming_request",user:t,data:{status:n,level:i}})},e.prototype.setSyncList=function(e){var t=e.list,n=void 0===t?[]:t;"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"set_sync_list",data:{user_list:n}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"set_sync_list",data:{user_list:n}})},e.prototype.startSync=function(e){var t=e.instanceIds,n=void 0===t?[]:t;this.setSyncList({list:n.length?n:this.instanceIds})},e.prototype.stopSync=function(){this.setSyncList({list:[]})},e.prototype.setMaster=function(e){var t=e.instanceId;this.masterInstanceId=t,this.sdk.log("setMaster",t),"websocket"===this.sdk.streamingMode?this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"set_master",user:t,data:{status:"on"}}}):this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"set_master",user:t,data:{status:"on"}}),this.requestStream({instanceId:t,status:"open",level:"high"}),this.sdk.playVideo("play")},e.prototype.setImageEvent=function(e){var t=e.interval,n=e.quality;this.sdk.log("setImageEvent","interval",t,"quality",n),this.options.image=fi(fi({},this.options.image),{interval:t,quality:n}),this._groupControlId&&this.startImageEventInterval()},e.prototype.onConnectSuccess=function(){this.setMaster({instanceId:this.masterInstanceId}),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval()},e.prototype.join=function(e){var t,n,r,i=e.instanceIds,o=e.clientSessions,s=void 0===o?[]:o;return t=this,r=function(){var e,t,n,r,o;return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(a){switch(a.label){case 0:return a.trys.push([0,6,,7]),"websocket"!==this.sdk.streamingMode?[3,2]:(e=this.sdk.accessInfo.getTokenInfos({instanceIds:i}),[4,this.sdk.cloudGamingWebsocket.joinGroupControl({tokenInfos:e,groupControlId:this.groupControlId})]);case 1:return a.sent(),[3,5];case 2:return a.trys.push([2,4,,5]),[4,this.sdk.accessInfo.joinWebRTCGroupSession({instanceIds:i,clientSessions:s,groupControlId:this.groupControlId})];case 3:return a.sent().ServerSessions.length,t=this.sdk.accessInfo.getInstancesInfo({instanceIds:i}).InstancesInfo,this.sdk.log("group join, instance ids",i),this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"join",data:{group_control_id:this.groupControlId,instances_info:t.map((function(e){return{instance_id:e.InstanceId,data:e.Data}})),client_sessions:s}}),[3,5];case 4:return n=a.sent(),this.sdk.log("join group error",n.message),[3,5];case 5:return(o=this.instanceIds).push.apply(o,function(e,t,n){if(2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}([],vi(i),!1)),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval(),[3,7];case 6:return r=a.sent(),this.sdk.log("join serverSession parse error",r),[3,7];case 7:return[2]}}))},new((n=void 0)||(n=Promise))((function(e,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(t,[])).next())}))},e.prototype.leave=function(e){var t=e.instanceIds;this.instanceIds=this.instanceIds.filter((function(e){return!t.includes(e)})),this.setSyncList({list:this.instanceIds}),this.startImageEventInterval()},e.prototype.getInstanceIds=function(){return this.instanceIds},e.prototype.destroy=function(){clearTimeout(this.imageEventTimer)},e.prototype.startImageEventInterval=function(){var e=this;clearTimeout(this.imageEventTimer);var t=function(){var n=[];e.instanceIds.forEach((function(t){var r;if(e.sdk.androidInstance.operator.getInstanceOperator({instanceId:t}).OperatorAddress){var i=e.sdk.androidInstance.getInstanceImage({instanceId:t,quality:null===(r=e.options.image)||void 0===r?void 0:r.quality}).url;n.push({instanceId:t,url:i})}})),e.sdk.onImageEvent({type:"screenshot",data:n}),e.imageEventTimer=setTimeout((function(){t()}),1e3*e.options.image.interval)};t()},e}(),_i=function(){return _i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},_i.apply(this,arguments)},gi=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},yi=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Si=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},bi=function(){function e(e){var t=e.sdk;this.sdk=null,this.sdk=t}return e.prototype.getInstanceOperator=function(e){var t=e.instanceId,n=this.sdk.accessInfo.getInstanceAccessInfo({instanceId:t}),r=n.Token,i=void 0===r?"":r,o=n.Zone,s=void 0===o?"":o,a=n.OperatorAddress;return{Token:i,Zone:s,OperatorAddress:void 0===a?"":a,EdgeProxyAddress:n.EdgeProxyAddress}},e.prototype.getInstanceImage=function(e){var t=e.instanceId,n=e.quality,r=void 0===n?20:n,i=e.screenshot_width,o=void 0===i?720:i,s=e.screenshot_height,a=void 0===s?1280:s,c=this.getInstanceOperator({instanceId:t}),u=c.Token,d=c.OperatorAddress,l=c.EdgeProxyAddress;if(u&&d){var h=l||d,p=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{url:"".concat(h,"/CAIScreenshot?instance_id=").concat(t,"&screenshot_quality=").concat(r,"&token=").concat(u,"&timestamp=").concat(+new Date)+"".concat(o?"&screenshot_width=".concat(o):"")+"".concat(a?"&screenshot_height=".concat(a):"")+"".concat(p||"")}}return{url:null}},e.prototype.upload=function(e){var t=e.instanceId,n=e.files;return gi(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v,m=this;return yi(this,(function(_){switch(_.label){case 0:if(e=this.getInstanceOperator({instanceId:t}),r=e.Token,i=e.OperatorAddress,o=e.EdgeProxyAddress,!r||!i)return[3,5];s="".concat(o||i,"/CAIUpload?instance_id=").concat(t,"&token=").concat(r),a={},(c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t}).instanceInfo)&&(a["Crtr-Proxy-Instance-Info"]=c),u=new FormData,n.forEach((function(e,t){var n=e.file,r=e.path;return gi(m,0,void 0,(function(){return yi(this,(function(e){return u.append("file_".concat(t+1,"_path"),r),u.append("file_".concat(t+1),n),[2]}))}))})),d={Code:1,Message:"Upload failed",FileStatus:null},_.label=1;case 1:return _.trys.push([1,3,,4]),[4,fetch(s,{body:u,cache:"no-cache",method:"POST",mode:"cors",headers:a}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.json()})).catch((function(e){throw new Error("".concat(e.name,": ").concat(e.message))}))];case 2:return l=_.sent(),h=l.Code,p=l.FileStatus,f=l.Msg,d.Code=h,d.Message=f,d.FileStatus=p,[3,4];case 3:return v=_.sent(),d.Code=1,d.Message="".concat(v.name,": ").concat(v.message),[3,4];case 4:return[2,d];case 5:return[2,{Code:2,Message:"Token or OperatorAddress is empty"}]}}))}))},e.prototype.uploadMedia=function(e){var t=e.instanceId,n=e.files;return gi(this,0,void 0,(function(){var e,r,i,o,s,a,c,u,d,l,h,p,f,v=this;return yi(this,(function(m){switch(m.label){case 0:if(e=this.getInstanceOperator({instanceId:t}),r=e.Token,i=e.OperatorAddress,o=e.EdgeProxyAddress,!r||!i)return[3,5];s="".concat(o||i,"/CAIUploadMedia?instance_id=").concat(t,"&token=").concat(r),a={},(c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t}).instanceInfo)&&(a["Crtr-Proxy-Instance-Info"]=c),u=new FormData,n.forEach((function(e,t){var n=e.file;return gi(v,0,void 0,(function(){return yi(this,(function(e){return u.append("file_".concat(t+1),n),[2]}))}))})),d={Code:1,Message:"Upload media failed",FileStatus:null},m.label=1;case 1:return m.trys.push([1,3,,4]),[4,fetch(s,{body:u,cache:"no-cache",method:"POST",mode:"cors",headers:a}).then((function(e){if(200!==e.status)throw new Error("status Code:".concat(e.status));return e.json()})).catch((function(e){throw new Error("".concat(e.name,": ").concat(e.message))}))];case 2:return l=m.sent(),h=l.Code,p=l.Msg,d.Code=h,d.Message=p,[3,4];case 3:return f=m.sent(),d.Code=1,d.Message="".concat(f.name,": ").concat(f.message),[3,4];case 4:return[2,d];case 5:return[2,{Code:2,Message:"Token or OperatorAddress is empty"}]}}))}))},e.prototype.getInstanceDownloadAddress=function(e){var t=e.instanceId,n=e.path,r=this.getInstanceOperator({instanceId:t}),i=r.Token,o=r.OperatorAddress,s=r.EdgeProxyAddress;if(i&&o){var a=s||o,c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{address:"".concat(a,"/CAIDownload?instance_id=").concat(t,"&path=").concat(n,"&token=").concat(i)+"".concat(c||"")}}return{address:null}},e.prototype.getInstanceDownloadLogcatAddress=function(e){var t=e.instanceId,n=e.recentDays,r=this.getInstanceOperator({instanceId:t}),i=r.Token,o=r.OperatorAddress,s=r.EdgeProxyAddress;if(i&&o){var a=s||o,c=this.sdk.accessInfo.getInstanceInfoHeader({instanceId:t,method:"GET"}).instanceInfo;return{address:"".concat(a,"/CAIDownloadLogcat?instance_id=").concat(t,"&recent_day=").concat(n,"&token=").concat(i)+"".concat(c||"")}}return{address:null}},e.prototype.batchTask=function(e){var t,n,r,i,o=e.taskType,s=e.params;return gi(this,0,void 0,(function(){var e,a,c,u,d,l,h,p;return yi(this,(function(f){switch(f.label){case 0:e={},this.sdk.log("batchTask taskType",o,"batchTask params",s),a=this.getOperatorAddresses({instanceIds:Object.keys(s)}),f.label=1;case 1:f.trys.push([1,7,8,13]),c=function(){var t,n,r,a,c,l,p,f,v,m,_,g,y,S,b,k,E,T,C,I,w,R,A,O;return yi(this,(function(x){switch(x.label){case 0:i=h.value,d=!1,t=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}(i,2),n=t[0],r=t[1],a="".concat(n,"/CAIOperator/BatchTask"),c={},(l=u.sdk.accessInfo.getInstanceInfoHeader({instanceId:r[0]}).instanceInfo)&&(c.InstanceInfo=l),p=u.sdk.accessInfo.getInstancesInfo({instanceIds:r}).InstancesInfo,f={},v=u.sdk.accessInfo.getTokenInfos({instanceIds:r}),r.forEach((function(e){f[e]="ModifySensor"===o?_i(_i({},s[e]),{Accuracy:3}):s[e]})),x.label=1;case 1:return x.trys.push([1,3,,4]),[4,Dn({url:a,data:{RequestID:Kn(),TaskType:o,TokenInfos:v,InstancesInfo:p,Params:f},headers:c})];case 2:if(m=x.sent(),_=m.Code,g=m.Message,y=m.SuccResult,S=m.FailResult,0===_)e=_i(_i(_i({},e),y),S);else try{for(w=void 0,b=Si(r),k=b.next();!k.done;k=b.next())I=k.value,e[I]={Code:_,Msg:g}}catch(e){w={error:e}}finally{try{k&&!k.done&&(R=b.return)&&R.call(b)}finally{if(w)throw w.error}}return[3,4];case 3:E=x.sent();try{for(A=void 0,T=Si(r),C=T.next();!C.done;C=T.next())I=C.value,e[I]={Code:-1,Msg:E.message}}catch(e){A={error:e}}finally{try{C&&!C.done&&(O=T.return)&&O.call(T)}finally{if(A)throw A.error}}return[3,4];case 4:return[2]}}))},u=this,d=!0,l=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Si(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}(Object.entries(a)),f.label=2;case 2:return[4,l.next()];case 3:return h=f.sent(),(t=h.done)?[3,6]:[5,c()];case 4:f.sent(),f.label=5;case 5:return d=!0,[3,2];case 6:return[3,13];case 7:return p=f.sent(),n={error:p},[3,13];case 8:return f.trys.push([8,,11,12]),d||t||!(r=l.return)?[3,10]:[4,r.call(l)];case 9:f.sent(),f.label=10;case 10:return[3,12];case 11:if(n)throw n.error;return[7];case 12:return[7];case 13:return[2,e]}}))}))},e.prototype.getOperatorAddresses=function(e){var t=this,n=e.instanceIds,r={};return n.forEach((function(e){var n=t.getInstanceOperator({instanceId:e})||{},i=n.OperatorAddress,o=n.EdgeProxyAddress||i;o?r[o]?r[o].push(e):r[o]=[e]:t.sdk.log("getOperatorAddresses instanceId",e,"not found")})),r},e}();const ki=bi;var Ei=function(){return Ei=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ei.apply(this,arguments)},Ti=function(){function e(e){var t=e.sdk;this.groupControl=null,this.operator=null,this.initOptions=null,this.sdk=null,this.sdk=t,this.groupControl=new mi({sdk:t}),this.operator=new ki({sdk:t})}return e.prototype.init=function(e){this.initOptions=Ei(Ei({},this.initOptions),e),this.groupControl.init(e.groupControl)},e.prototype.access=function(){},e.prototype.destroy=function(){this.groupControl.destroy()},e.prototype.requestStream=function(e){var t=e.instanceId,n=e.status,r=e.level,i=void 0===r?"normal":r;this.groupControl.requestStream({instanceId:t,status:n,level:i})},e.prototype.setSyncList=function(e){var t=e.list,n=void 0===t?[]:t;this.groupControl.setSyncList({list:n})},e.prototype.startSync=function(e){var t=e.instanceIds,n=void 0===t?[]:t;this.groupControl.startSync({instanceIds:n})},e.prototype.stopSync=function(){this.groupControl.stopSync()},e.prototype.setMaster=function(e){var t=e.instanceId;this.groupControl.setMaster({instanceId:t})},e.prototype.setImageEvent=function(e){var t=e.interval,n=e.quality;this.groupControl.setImageEvent({interval:t,quality:n})},e.prototype.joinGroupControl=function(e){var t=e.instanceIds,n=e.clientSessions,r=void 0===n?[]:n;this.groupControl.join({instanceIds:t,clientSessions:r})},e.prototype.leaveGroupControl=function(e){var t=e.instanceIds;this.groupControl.leave({instanceIds:t})},e.prototype.transMessage=function(e){var t=e.packageName,n=e.message;this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"trans_message",data:{package_name:t,msg:n}})},e.prototype.inputText=function(e){var t=e.content,n=void 0===t?"":t,r=e.mode,i=void 0===r?"append":r,o=e.index_after_override;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"input_text",content:n,mode:i,index_after_override:o}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"input_text",content:n,mode:i}})},e.prototype.switchIME=function(e){var t=e.ime;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendAckData({data:{type:"switch_ime",ime:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"switch_ime",ime:t}}),this.sdk.pageEvent.IMEType=t},e.prototype.distributeApp=function(e){var t=e.packageName;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"distribute_app",data:{package_name:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"distribute_app",data:{package_name:t}}})},e.prototype.preserveCleanApp=function(e){var t=e.preservePackageNames;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"preserve_clean_app",data:{preserve_package_names:t}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"preserve_clean_app",data:{preserve_package_names:t}}})},e.prototype.keepFrontApp=function(e){var t=e.packageName,n=e.enable;"webrtc"===this.sdk.streamingMode?this.sdk.cloudGamingWebRTC.sendCloudDeviceData({type:"keep_front_app",data:{package_name:t,enable:n}}):this.sdk.cloudGamingWebsocket.dataChannelSend({label:ge.CLOUD_DEVICE,data:{type:"keep_front_app",data:{package_name:t,enable:n}}})},e.prototype.getInstanceImage=function(e){var t=e.instanceId,n=e.quality,r=void 0===n?20:n,i=e.screenshot_width,o=e.screenshot_height;return this.operator.getInstanceImage({instanceId:t,quality:r,screenshot_width:i,screenshot_height:o})},e.prototype.upload=function(e){var t=e.instanceId,n=e.files;return this.operator.upload({instanceId:t,files:n})},e.prototype.uploadMedia=function(e){var t=e.instanceId,n=e.files;return this.operator.uploadMedia({instanceId:t,files:n})},e.prototype.getInstanceDownloadAddress=function(e){var t=e.instanceId,n=e.path;return this.operator.getInstanceDownloadAddress({instanceId:t,path:n})},e.prototype.getInstanceDownloadLogcatAddress=function(e){var t=e.instanceId,n=e.recentDays;return this.operator.getInstanceDownloadLogcatAddress({instanceId:t,recentDays:n})},e.prototype.setLocation=function(e){var t,n,r,i;return n=this,i=function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(n){return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?[2,this.operator.batchTask({taskType:"ModifyGPS",params:e})]:[2,{Code:1,Message:"params object is empty"}]}))},new((r=void 0)||(r=Promise))((function(e,t){function o(e){try{a(i.next(e))}catch(e){t(e)}}function s(e){try{a(i.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(o,s)}a((i=i.apply(n,[])).next())}))},e.prototype.setResolution=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyResolution",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.paste=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Paste",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setSensor=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifySensor",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.sendClipboard=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SendClipboard",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.shake=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Shake",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.sendTransMessage=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SendTransMessage",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeInstanceProperties=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeInstanceProperties",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.modifyInstanceProperties=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyInstanceProperties",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.listUserApps=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ListUserApps",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.modifyKeepFrontAppStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ModifyKeepFrontAppStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeKeepFrontAppStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeKeepFrontAppStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.unInstallByPackageName=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"UnInstallByPackageName",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.startApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StartApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.stopApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StopApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearAppData=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearAppData",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.enableApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"EnableApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.disableApp=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DisableApp",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.startCameraMediaPlay=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StartCameraMediaPlay",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.stopCameraMediaPlay=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"StopCameraMediaPlay",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeCameraMediaPlayStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeCameraMediaPlayStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.displayCameraImage=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DisplayCameraImage",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.addKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"AddKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.removeKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"RemoveKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SetKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearKeepAliveList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearKeepAliveList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.mute=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Mute",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.mediaSearch=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"MediaSearch",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.reboot=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"Reboot",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.listAllApps=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ListAllApps",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.moveAppBackground=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"MoveAppBackground",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.addAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"AddAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.removeAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"RemoveAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.setAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"SetAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.describeAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"DescribeAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.clearAppInstallBlackList=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"ClearAppInstallBlackList",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.getNavVisibleStatus=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"GetNavVisibleStatus",params:e}):{Code:1,Message:"params object is empty"}},e.prototype.getSystemMusicVolume=function(e){var t;return(null===(t=Object.keys(e))||void 0===t?void 0:t.length)?this.operator.batchTask({taskType:"GetSystemMusicVolume",params:e}):{Code:1,Message:"params object is empty"}},e}(),Ci=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ii=function(){return Ii=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ii.apply(this,arguments)},wi=function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))},Ri=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Ai=function(e){function t(){var t=e.call(this)||this;return t.version=Te,t.cloudGamingWebRTC=null,t.pageEvent=null,t.cloudGamingWebsocket=null,t.androidInstance=null,t.accessInfo=null,t.gamepad=null,t.watchdog=null,t.gameConfig=null,t.showStats=null,t.initOptions={mount:null,reconnect:!0,autoSwitchCamera:!0,autoSwitchMic:!0,streaming:{mode:"webrtc"},androidInstance:{autoRotateOnPC:!0}},t.uuid=null,t.sdkInitStartTime=null,t._mobileGame=!1,t.cloudGamingWebRTC=new yt({sdk:t}),t.pageEvent=new cn({sdk:t}),t.androidInstance=new Ti({sdk:t}),t.accessInfo=new pi({sdk:t}),t.gamepad=new xn({sdk:t}),t.watchdog=new Un({sdk:t}),t.gameConfig=new Bn({sdk:t}),t.showStats=new yn({sdk:t}),t.cloudGamingWebsocket=new si({sdk:t}),t.uuid=+new Date,t}return Ci(t,e),Object.defineProperty(t.prototype,"mountPoint",{get:function(){return null===document||void 0===document?void 0:document.querySelector("#".concat(this.initOptions.mount))},enumerable:!1,configurable:!0}),t.prototype.init=function(e){this.initLoggerConfig(e),this.sdkInitStartTime=+new Date,this.initOptions=Ii(Ii({},this.initOptions),e);var t=e.mount,n=e.loadingText,r=e.showLoading,i=e.restartText,o=e.accessToken,s=e.mobileGame;this._mobileGame=s,this.mountGamePoint({mount:t,loadingText:n,showLoading:r,restartText:i}),this.log("init tcgsdk version->",Te,"options->",e),this.log("webrtc-adapter",le.browserDetails.browser,le.browserDetails.version),e.onLog&&this.setExternalLog(e.onLog),(null==o?void 0:o.accessInfo)&&this.accessInfo.setInstanceAccessInfo({AccessInfo:o.accessInfo,Token:o.token}),this.pageEvent.init(e),this.showStats.init({mount:this.initOptions.mount}),this.watchdog.init({mount:this.initOptions.mount}),this.androidInstance.init(e),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.init(e):(this.cloudGamingWebsocket.init({mount:this.initOptions.mount}),this.onInitSuccess({code:0,msg:"ok"})),this.setDebugMode(e.debugSetting),this.log("init->",this.initOptions),this.log("userAgent",null===navigator||void 0===navigator?void 0:navigator.userAgent)},Object.defineProperty(t.prototype,"streamingMode",{get:function(){var e;return(null===(e=this.initOptions.streaming)||void 0===e?void 0:e.mode)||"webrtc"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"initStartTime",{get:function(){return this.cloudGamingWebRTC.webrtcStartTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isMobileGame",{get:function(){return this._mobileGame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mobileGame",{set:function(e){this._mobileGame=e},enumerable:!1,configurable:!0}),t.prototype.getIsMobileGame=function(){return this._mobileGame},t.prototype.getAndroidInstance=function(){return this.androidInstance},t.prototype.getInitOptions=function(){return this.initOptions},t.prototype.getClientSession=function(){return this.cloudGamingWebRTC.getClientSideDescription(!0)},t.prototype.getServerSession=function(e){var t=(void 0===e?st:e).clientId,n=void 0===t?this.initOptions.mount:t;return this.gameConfig.getConfig({clientId:n})},t.prototype.start=function(e){void 0===e&&(e=""),this.cloudGamingWebRTC.connect(e)},t.prototype.setAccessToken=function(e){var t=e.accessInfo,n=e.token;this.accessInfo.setInstanceAccessInfo({AccessInfo:t,Token:n})},t.prototype.access=function(e){var t=e.instanceId,n=void 0===t?"":t,r=e.instanceIds,i=void 0===r?[]:r,o=e.groupControl,s=void 0!==o&&o;return wi(this,0,void 0,(function(){var e,t,r,o,a,c,u,d,l,h,p,f,v,m,_;return Ri(this,(function(g){switch(g.label){case 0:if("websocket"===this.streamingMode)return e=this.accessInfo.getInstanceAccessInfo({instanceId:s?i[0]:n}),t=e.Token,r=e.WebSocketAddress,o=e.WebSocketSecureAddress,a=o,"http:"===window.location.protocol&&(a=r),s?(c=this.accessInfo.getTokenInfos({instanceIds:i}),[2,this.androidInstance.groupControl.startWebSocket({tokenInfos:c,url:a,instanceIds:i})]):[2,this.cloudGamingWebsocket.connect({url:a,protocols:["media-v1"],token:t,instanceId:n,videoCodecList:this.initOptions.streaming.videoCodecList})];if(!s)return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,this.accessInfo.createWebRTCGroupSession({instanceIds:i,clientSessions:[this.getClientSession()]})];case 2:return u=g.sent(),d=u.GroupControlId,l=u.ServerSessions,v=u.Code,m=u.Message,0===v?this.androidInstance.groupControl.start({instanceIds:i,groupControlId:d,serverSessions:l}):this.onConnectFailed({code:v,msg:m}),[3,4];case 3:return h=g.sent(),this.onConnectFailed({code:_e.FETCH_ERROR,msg:"fetch group server session error, ".concat(h.message)}),[3,4];case 4:return[3,8];case 5:return g.trys.push([5,7,,8]),[4,this.accessInfo.createWebRTCSession({instanceId:n,clientSession:this.getClientSession()})];case 6:return p=g.sent(),f=p.ServerSession,v=p.Code,m=p.Message,0===v?this.cloudGamingWebRTC.connect(f):this.onConnectFailed({code:v,msg:m}),[3,8];case 7:return _=g.sent(),this.onConnectFailed({code:_e.FETCH_ERROR,msg:"fetch server session error, ".concat(_.message)}),[3,8];case 8:return[2]}}))}))},t.prototype.destroy=function(e){var t=void 0===e?st:e,n=t.message,r=void 0===n?"主动关闭":n,i=t.code,o=void 0===i?me.MANUAL_CLOSE:i;this.log("destroy->","message: ",r,"code: ",o),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.disconnected({message:r,code:o}):this.cloudGamingWebsocket.destroy({message:r,code:o}),this.androidInstance.groupControl.destroy()},t.prototype.reconnect=function(){"webrtc"===this.streamingMode?(this.cloudGamingWebRTC.clearPeerConnection(),this.cloudGamingWebRTC.reconnect({message:"manual reconnect"})):this.cloudGamingWebsocket.reconnect({message:"manual reconnect"})},t.prototype.gameRestart=function(){this.log("gameRestart->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"restart"}}),this.clearRemoteKeys()},t.prototype.gamePause=function(e){var t=(void 0===e?st:e).media;this.log("gamePause->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"pause",media:t}}),this.cloudGamingWebRTC.setGameStatus("pause"),this.clearRemoteKeys()},t.prototype.gameResume=function(e){var t=(void 0===e?st:e).media;this.log("gameResume->"),this.cloudGamingWebRTC.sendAckData({data:{type:"game_op",op:"resume",media:t}}),this.cloudGamingWebRTC.setGameStatus("playing"),this.clearRemoteKeys()},t.prototype.sendKeyboardEvent=function(e){var t=e.key,n=e.down,r=e.location,i=void 0===r?0:r;"websocket"===this.streamingMode?this.cloudGamingWebsocket.dataChannelSend({label:ge.KM,data:{type:"keyboard",key:t,down:n,location:i}}):this.cloudGamingWebRTC.sendKmData({type:"keyboard",key:t,down:n,location:i})},t.prototype.sendMouseEvent=function(e){var t=e.type,n=e.down,r=e.delta;this.cloudGamingWebRTC.sendKmData({type:t,down:n,delta:r})},t.prototype.sendGamepadEvent=function(e){var t=e.type,n=e.down,r=e.key,i=e.x,o=e.y;this.cloudGamingWebRTC.sendKmData({type:t,down:n,key:r,x:i,y:o})},t.prototype.sendRawEvent=function(e){switch(this.log("sendRawEvent->",e),"object"!=typeof e&&console.error("data is not an object"),!0){case"keyboard"===e.type:this.sendKeyboardEvent(e);break;case e.type.includes("mouse"):this.sendMouseEvent(e);break;case e.type.includes("gamepad")||e.type.includes("axis")||e.type.includes("lt")||e.type.includes("rt"):this.sendGamepadEvent(e);break;default:this.cloudGamingWebRTC.sendAckData({data:e})}},t.prototype.sendKmData=function(e){this.cloudGamingWebRTC.sendKmData(e)},t.prototype.setMoveSensitivity=function(e){this.log("setMoveSensitivity->",e),"number"!=typeof e&&console.error("input value must be number"),(e-.01<Number.EPSILON||e-100>Number.EPSILON)&&console.error("sensitivity is out of range"),this.pageEvent.setMoveSensitivity(e)},t.prototype.sendSeqRawEvents=function(e){this.log("sendSeqRawEvents->",e),this.cloudGamingWebRTC.sendKmData({type:"key_seq",keys:e.map((function(e){return JSON.stringify(e)}))})},t.prototype.getMoveSensitivity=function(){return this.pageEvent?1/this.pageEvent.getMoveSensitivity():1},t.prototype.setMouseCanLock=function(e){this.log("setMouseCanLock->",e),this.cloudGamingWebRTC.lockMouse(e),this.cloudGamingWebRTC.setForceShowCursor(!e)},t.prototype.lockMouse=function(e){this.log("lockMouse->",e),this.cloudGamingWebRTC.setForceLockCursor(e),this.cloudGamingWebRTC.lockMouse(e)},t.prototype.mouseMove=function(e,t,n,r){this.pageEvent.mouseMove(e,t,n,r)},t.prototype.mouseTabletMode=function(e){this.log("mouseTabletMode->",e),this.pageEvent.setTabletMode(e)},t.prototype.setRemoteCursor=function(e){void 0===e&&(e=0),this.log("setRemoteCursor->",e),this.cloudGamingWebRTC.setCursorMode(e)},t.prototype.setCursorShowStat=function(e){this.log("setCursorShowStat->",e),this.cloudGamingWebRTC.setForceShowCursor(e)},t.prototype.setCursorShowStatus=function(e){this.log("setCursorShowStat->",e),this.cloudGamingWebRTC.setForceShowCursor(e)},t.prototype.setCursorState=function(e){"forceShow"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!0),this.lockMouse(!1)),"forceLock"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!1),this.lockMouse(!0)),"auto"===e&&(this.cloudGamingWebRTC.setForceShowCursor(!1),this.cloudGamingWebRTC.setForceLockCursor(!1))},t.prototype.getCursorShowStat=function(){return this.log("getCursorShowStat->",this.cloudGamingWebRTC.getCursorShowStatus()),this.cloudGamingWebRTC.getCursorShowStatus()},t.prototype.setMobileCursorScale=function(e){this.log("setMobileCursorScale->",e),this.cloudGamingWebRTC.setMobileCursorScale(e)},t.prototype.setRemoteCursorStyle=function(e){this.log("setRemoteCursorStyle->",e),this.cloudGamingWebRTC.sendAckData({data:{type:"set_pointer_style",style:e}})},t.prototype.clearRemoteKeys=function(){this.log("clearRemoteKeys->"),this.pageEvent.clearRemoteKeys()},t.prototype.resetRemoteCapsLock=function(){this.log("resetRemoteCapsLock->"),this.cloudGamingWebRTC.sendAckData({data:{type:"reset_capslock"}})},t.prototype.setDefaultCursorImage=function(e){this.log("setDefaultCursorImage->",e),e&&this.cloudGamingWebRTC.setDefaultCursorImage(e)},t.prototype.setKMStatus=function(e){var t=e.keyboard,n=void 0===t||t,r=e.mouse,i=void 0===r||r;this.pageEvent.setKMStatus({keyboard:n,mouse:i})},t.prototype.setKeyboardBanList=function(e){var t=e.keyList;this.pageEvent.setKeyboardBanList({keyList:t})},t.prototype.setPaste=function(e){this.pageEvent.setPaste(e)},t.prototype.mobileTouchMove=function(e){var t=e.finger_id,n=e.event_type,r=e.x,i=e.y,o=this.pageEvent.remoteScreenSize,s=o.width,a=o.height;this.pageEvent.mobileTouchMove({finger_id:t,event_type:n,x:r,y:i,width:s,height:a,timestamp:+new Date})},t.prototype.setDebugMode=function(e){var t=void 0===e?{}:e,n=t.showStats,r=void 0!==n&&n,i=t.showLog,o=void 0!==i&&i,s=t.showOnAckMessage,a=void 0!==s&&s,c=t.showOnCdMessage,u=void 0!==c&&c,d=t.showOnHbMessage,l=void 0!==d&&d,h=t.showOnKmMessage,p=void 0!==h&&h,f=t.showOnSvMessage,v=void 0!==f&&f,m=t.showOnCloudDeviceMessage,_=void 0!==m&&m,g=t.showSendAckData,y=void 0!==g&&g,S=t.showSendHbData,b=void 0!==S&&S,k=t.showSendKmData,E=void 0!==k&&k,T=t.showSendCloudDeviceData,C=void 0!==T&&T,I=t.showMuxer,w=void 0!==I&&I;this.showStats.show(r),this.initOptions.debugSetting||(this.initOptions.debugSetting={}),this.initOptions.debugSetting=Ii(Ii({},this.initOptions.debugSetting),{showLog:o,showOnAckMessage:a,showOnCdMessage:u,showOnHbMessage:l,showOnKmMessage:p,showOnSvMessage:v,showOnCloudDeviceMessage:_,showSendAckData:y,showSendHbData:b,showSendKmData:E,showSendCloudDeviceData:C,showMuxer:w})},t.prototype.reportLog=function(){return this.log("reportLog, user manual upload"),this.reportLogInner()},t.prototype.setLogHandler=function(e){void 0===e&&(e=nt),this.log("setLogHandler"),this.setExternalLog(e)},t.prototype.toggleMetricReportBulk=function(e){void 0===e&&(e=!1),this.showStats.toggleMetricReportBulk(e)},t.prototype.playVideo=function(e){var t=this.getVideoElement();return"play"===e?null==t?void 0:t.play():"pause"===e?null==t?void 0:t.pause():void 0},t.prototype.playAudio=function(e){var t=this.getAudioElement();"play"===e&&(null==t||t.play()),"pause"===e&&(null==t||t.pause());var n=this.getHuaweiAudioElement();n&&("play"===e&&n.play(),"pause"===e&&n.pause())},t.prototype.setVideoOrientation=function(e){var t=void 0===e?{}:e,n=t.deg,r=void 0===n?0:n,i=t.rotateContainer,o=void 0===i||i,s=t.rotateMountPoint,a=void 0!==s&&s;this.log("setVideoOrientation",r,o),this.pageEvent.setVideoOrientation({deg:r,rotateContainer:o,rotateMountPoint:a})},t.prototype.getPageSize=function(){return{width:window.innerWidth,height:window.innerHeight}},t.prototype.setStreamProfile=function(e,t){var n,r;void 0===t&&(t=nt),this.log("setStreamProfile->",e);var i=this.pageEvent.getRemoteScreenConfig().deg,o=e.video_width,s=e.video_height;90===i||270===i?null===(n=this.cloudGamingWebRTC)||void 0===n||n.sendAckData({data:Ii(Ii({},e),{video_width:s,video_height:o,type:"res_mode"}),callback:t}):null===(r=this.cloudGamingWebRTC)||void 0===r||r.sendAckData({data:Ii(Ii({},e),{type:"res_mode"}),callback:t})},t.prototype.getDisplayRect=function(){return this.cloudGamingWebRTC.getDisplayRect()},t.prototype.setVideoVolume=function(e){this.log("setVideoVolume->",e),this.getVideoElement().volume=e,0===e?(this.getVideoElement().muted=!0,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().muted=!0,this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!0)):(this.getVideoElement().muted=!1,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!1),this.playVideo("play"))},t.prototype.setAudioVolume=function(e){this.log("setAudioVolume->",e);var t=this.getHuaweiAudioElement();t&&(this.log("huawei setVideoVolume->",e),t.volume=e);var n=this.getAudioElement();n.volume=e,0===e?(n.muted=!0,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().muted=!0,this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!0)):(n.muted=!1,"websocket"===this.streamingMode&&(this.getAudioElementWebsocket().volume=e),this.pageEvent.setVideoMuted(!1),this.playAudio("play"))},t.prototype.getAudioVolume=function(){var e;return null!==(e=this.getAudioElement().volume)&&void 0!==e?e:0},t.prototype.getVideoVolume=function(){var e;return null!==(e=this.getVideoElement().volume)&&void 0!==e?e:0},t.prototype.switchMic=function(e){var t=e.status,n=e.profile;return this.cloudGamingWebRTC.switchMic({status:t,profile:n})},t.prototype.switchCamera=function(e){var t=e.status,n=e.profile;return this.cloudGamingWebRTC.switchCamera({status:t,profile:n})},t.prototype.setMicProfile=function(e){return this.cloudGamingWebRTC.setMicProfile(e)},t.prototype.setCameraProfile=function(e){return this.cloudGamingWebRTC.setCameraProfile(e)},t.prototype.getDevices=function(){return this.cloudGamingWebRTC.getDevices()},t.prototype.setPageBackground=function(e){void 0===e&&(e=""),this.log("setPageBackground->",e);var t=this.getCloudGamingStreamContainerElement();t&&(t.style.background="url(".concat(e,")"))},t.prototype.sendText=function(e,t){void 0===e&&(e=""),void 0===t&&(t=nt),this.log("sendText",e),"webrtc"===this.streamingMode?this.cloudGamingWebRTC.sendAckData({data:{type:"paste",content:e},callback:t}):this.cloudGamingWebsocket.dataChannelSend({label:ge.ACK,data:{type:"paste",content:e}})},t.prototype.setClientInteractMode=function(e){void 0===e&&(e="cursor"),this.log("setClientInteractMode->",e),this.pageEvent.setClientInteractMode(e)},t.prototype.setRemoteDesktopResolution=function(e){var t=this,n=e.width,r=e.height;return this.log("setRemoteDesktopResolution, width",n,"height",r),new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"desktop_res",width:Math.floor(n),height:Math.floor(r)},callback:function(t){var n=t.data;e(void 0===n?{code:-1}:n)}})}))},t.prototype.getRemoteStreamResolution=function(){if(this.getVideoElement().videoWidth&&this.getVideoElement().videoHeight)return{width:this.getVideoElement().videoWidth,height:this.getVideoElement().videoHeight};var e=this.gameConfig.getConfig({clientId:this.initOptions.mount}).video,t=void 0===e?{}:e,n=t.width,r=void 0===n?0:n,i=t.height;return{width:r,height:void 0===i?0:i}},t.prototype.reshapeWindow=function(){this.pageEvent.reshapeWindow()},t.prototype.getUserMedia=function(){return this.cloudGamingWebRTC.getUserMedia()},t.prototype.screenShot=function(e){var t=e.name,n=void 0===t?"tcgsdk-".concat(+new Date):t,r=e.width,i=void 0===r?this.getVideoElement().videoWidth:r,o=e.height,s=void 0===o?this.getVideoElement().videoHeight:o,a=function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n}(i,s);a.getContext("2d").drawImage(this.getVideoElement(),0,0,i,s);var c=document.createElement("a");c.setAttribute("download","".concat(n,".png")),a.toBlob((function(e){var t=URL.createObjectURL(e);c.setAttribute("href",t),c.click()}))},t.prototype.createCustomDataChannel=function(e){var t=e.destPort,n=e.maxRetransmits,r=e.maxPacketLifeTime,i=e.onMessage,o=e.protocol,s=void 0===o?"text":o,a=e.type,c=void 0===a?"":a;return wi(this,0,void 0,(function(){var e,o,a,u=this;return Ri(this,(function(d){switch(d.label){case 0:return[4,this.cloudGamingWebRTC.createCustomDataChannel({destPort:t,maxRetransmits:n,maxPacketLifeTime:r,protocol:s,type:c,onMessage:i,onError:function(e){u.log("createCustomDataChannel onerror",e)},onClose:function(e){u.log("createCustomDataChannel onclose",e)}})];case 1:return e=d.sent(),o=e.code,a=e.msg,[2,{sendMessage:function(e){u.cloudGamingWebRTC.sendCustomDataChannelMessage({destPort:t,msg:e})},code:o,msg:a}]}}))}))},t.prototype.getPlayerVolume=function(e){return document.getElementById("".concat(e,"A")).volume},t.prototype.setPlayerVolume=function(e,t){this.log("setPlayerVolume->",t);var n=document.getElementById("".concat(e,"A"));0===t?n.muted=!0:(n.muted=!1,n.volume=t,n.play())},t.prototype.getSeats=function(){var e=this;return new Promise((function(t){e.cloudGamingWebRTC.sendAckData({data:{type:"sync_seats"},callback:function(e){var n=e.code,r=e.data,i=r.players,o=r.viewers;0===n&&t({players:i,viewers:o})}})}))},t.prototype.submitSeatChange=function(e){var t=this,n=e.user_id,r=e.to_role,i=e.seat_index,o=void 0===i?0:i;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"submit_seat_change",user_id:n,to_role:r,seat_index:o},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r;t.log("submit_seat_change res",i),e(i)}})}))},t.prototype.seatChange=function(e){var t=this,n=e.user_id,r=e.to_role,i=e.seat_index,o=void 0===i?0:i;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"seat_change",user_id:n,to_role:r,seat_index:o},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r;t.log("seat_change res",i),e(i)}})}))},t.prototype.changeMicStatus=function(e){var t=this,n=e.status,r=e.user_id;return new Promise((function(e){t.cloudGamingWebRTC.sendAckData({data:{type:"mic_status",user_id:r,status:n},callback:function(n){var r=n.data,i=void 0===r?{code:-1}:r,o=i.code,s=i.status,a=i.user_id,c=t.gameConfig.getConfig({clientId:t.initOptions.mount}).user_id;0===o&&a===c&&(t.log("changeMicStatus",i),0!==s&&1!==s||a&&t.cloudGamingWebRTC.setTrackEnable({type:"audio",enable:!1}),2===s&&a&&t.cloudGamingWebRTC.setTrackEnable({type:"audio",enable:!0})),e(i)}})}))},t.prototype.onInitSuccess=function(e){var t,n;null===(n=(t=this.initOptions).onInitSuccess)||void 0===n||n.call(t,e),this.trigger("InitSuccess",e)},t.prototype.onConnectSuccess=function(e){var t,n;this.log("onConnectSuccess ->"),null===(n=(t=this.initOptions).onConnectSuccess)||void 0===n||n.call(t,e),this.trigger("ConnectSuccess",e),this.androidInstance.groupControl.groupControlId&&"webrtc"===this.streamingMode&&this.androidInstance.groupControl.onConnectSuccess()},t.prototype.onDisconnect=function(e){var t,n;null===(n=(t=this.initOptions).onDisconnect)||void 0===n||n.call(t,e),this.trigger("Disconnected",e)},t.prototype.onConnectFailed=function(e){var t,n;null===(n=(t=this.initOptions).onConnectFail)||void 0===n||n.call(t,e),this.trigger("ConnectFailed",e)},t.prototype.onEvent=function(e){var t,n;null===(n=(t=this.initOptions).onEvent)||void 0===n||n.call(t,e),this.trigger("Event",e)},t.prototype.onOrientationChange=function(e){var t,n;null===(n=(t=this.initOptions).onOrientationChange)||void 0===n||n.call(t,e),this.trigger("OrientationChange",e)},t.prototype.onVisibilityChange=function(e){var t,n;null===(n=(t=this.initOptions).onVisibilityChange)||void 0===n||n.call(t,e),this.trigger("VisibilityChange",e)},t.prototype.onNetworkChange=function(e){var t,n;null===(n=(t=this.initOptions).onNetworkChange)||void 0===n||n.call(t,e),this.trigger("NetworkChange",e)},t.prototype.onWebrtcStatusChange=function(e){var t,n,r,i;null===(n=(t=this.initOptions).onWebrtcStat)||void 0===n||n.call(t,e),null===(i=(r=this.initOptions).onWebrtcStatusChange)||void 0===i||i.call(r,e),this.trigger("WebrtcStatusChange",e)},t.prototype.onGameStartComplete=function(e){var t,n;null===(n=(t=this.initOptions).onGameStartComplete)||void 0===n||n.call(t,e),this.trigger("GameStartComplete",e)},t.prototype.onGameStop=function(e){var t,n;null===(n=(t=this.initOptions).onGameStop)||void 0===n||n.call(t,e),this.trigger("GameStop",e)},t.prototype.onLoadGameArchive=function(e){var t,n;null===(n=(t=this.initOptions).onLoadGameArchive)||void 0===n||n.call(t,e),this.trigger("LoadGameArchive",e)},t.prototype.onSaveGameArchive=function(e){var t,n;null===(n=(t=this.initOptions).onSaveGameArchive)||void 0===n||n.call(t,e),this.trigger("SaveGameArchive",e)},t.prototype.onInputStatusChange=function(e){var t,n;null===(n=(t=this.initOptions).onInputStatusChange)||void 0===n||n.call(t,e),this.trigger("InputStatusChange",e)},t.prototype.onTouchEvent=function(e){var t,n;null===(n=(t=this.initOptions).onTouchEvent)||void 0===n||n.call(t,e),this.trigger("TouchEvent",e)},t.prototype.onCursorShowStatChange=function(e){var t,n;null===(n=(t=this.initOptions).onCursorShowStatChange)||void 0===n||n.call(t,e),this.trigger("CursorShowStatChange",e)},t.prototype.onGamepadConnectChange=function(e){var t,n;null===(n=(t=this.initOptions).onGamepadConnectChange)||void 0===n||n.call(t,e),this.trigger("GamepadConnectChange",e)},t.prototype.onConfigurationChange=function(e){var t,n;null===(n=(t=this.initOptions).onConfigurationChange)||void 0===n||n.call(t,e),this.trigger("ConfigurationChange",e)},t.prototype.onRemoteScreenResolutionChange=function(e){var t,n;null===(n=(t=this.initOptions).onRemoteScreenResolutionChange)||void 0===n||n.call(t,e),this.trigger("RemoteScreenResolutionChange",e)},t.prototype.onVideoStreamConfigChange=function(e){var t,n;null===(n=(t=this.initOptions).onVideoStreamConfigChange)||void 0===n||n.call(t,e),this.trigger("VideoStreamConfigChange",e)},t.prototype.onDoubleTap=function(e){var t,n;null===(n=(t=this.initOptions).onDoubleTap)||void 0===n||n.call(t,e),this.trigger("DoubleTap",e)},t.prototype.onStreamPushStateChange=function(e){var t,n;null===(n=(t=this.initOptions).onStreamPushStateChange)||void 0===n||n.call(t,e),this.trigger("StreamPushStateChange",e)},t.prototype.onDeviceChange=function(e){var t,n;this.log("onDeviceChange",Event),null===(n=(t=this.initOptions).onDeviceChange)||void 0===n||n.call(t,e),this.trigger("DeviceChange",e)},t.prototype.onGetUserMediaStatusChange=function(e){var t,n,r=e.msg,i=e.type,o=e.userMedia,s="",a=0;switch(r){case"NotFoundError":case"DevicesNotFoundError":s="NotFoundError",a=1;break;case"NotAllowedError":case"PermissionDeniedError":s="NotAllowedError",a=2;break;case"OverconstrainedError":s="OverconstrainedError",a=3;break;default:s=r}null===(n=(t=this.initOptions).onGetUserMediaStatusChange)||void 0===n||n.call(t,{code:a,msg:s,type:i,userMedia:o}),this.trigger("GetUserMediaStatusChange",{code:a,msg:s,type:i,userMedia:o})},t.prototype.onMultiPlayerChange=function(e){var t,n;null===(n=(t=this.initOptions).onMultiPlayerChange)||void 0===n||n.call(t,e),this.trigger("MultiPlayerChange",e)},t.prototype.onAndroidInstanceEvent=function(e){var t,n;null===(n=(t=this.initOptions).onAndroidInstanceEvent)||void 0===n||n.call(t,e),this.trigger("AndroidInstanceEvent",e)},t.prototype.onImageEvent=function(e){var t,n;null===(n=(t=this.initOptions).onImageEvent)||void 0===n||n.call(t,e),this.trigger("ImageEvent",e)},t.prototype.onWebrtcStatsChange=function(e,t){var n,r,i;if(e===pe.PLAYING){this.pageEvent.addEventHandler();var o=this.gameConfig.getConfig({clientId:t}).game_config,s=(void 0===o?st:o).sdk_conf,a=void 0===s?st:s;a||(a=st),this.setDefaultCursorImage(null!==(n=this.initOptions.defaultCursorImgUrl)&&void 0!==n?n:a.default_cursor_url),this.setRemoteCursor(null!==(r=this.initOptions.cursorMode)&&void 0!==r?r:a.cursor_mode),this.setPageBackground(null!==(i=this.initOptions.bgImgUrl)&&void 0!==i?i:a.bgimg_url)}},t.prototype.setFullscreen=function(e,t){return void 0===t&&(t=document.documentElement),wi(this,0,void 0,(function(){return Ri(this,(function(n){switch(n.label){case 0:this.log("setFullscreen->",e),n.label=1;case 1:return n.trys.push([1,6,,7]),e?[4,this.pageEvent.fullscreen(t)]:[3,3];case 2:return n.sent(),[3,5];case 3:return[4,this.pageEvent.exitFullscreen(t)];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:throw n.sent();case 7:return[2]}}))}))},t.prototype.getFullscreen=function(){return Qe()},t.prototype.getPageOrientation=function(){return this.pageEvent.getPageOrientation()},t.prototype.isMobile=function(){return Ze()},t.prototype.getGameConfig=function(e){var t=(void 0===e?st:e).clientId,n=void 0===t?this.initOptions.mount:t;return this.gameConfig.getConfig({clientId:n}).game_config},t.prototype.supportRenegotiation=function(){return ct()},t.prototype.getRequestId=function(){return this.cloudGamingWebRTC.getRequestId()},t.prototype.getGameMountPoint=function(){return document.getElementById(this.initOptions.mount)},t.prototype.getVideoElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".video-stream")},t.prototype.getAudioElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".audio-stream")},t.prototype.getAudioElementWebsocket=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-audio-stream-socket")},t.prototype.getHuaweiAudioElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector("#tcg-audio-huawei")},t.prototype.getProgressBarElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".progress-bar-container")},t.prototype.getCursorElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector("#cursor")},t.prototype.getCloudGamingContainerElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-container")},t.prototype.getCloudGamingStreamContainerElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".cloud-gaming-stream-container")},t.prototype.getRestartElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".restart")},t.prototype.createAudioAndAddTrack=function(e){var t=e.id,n=e.source,r=document.getElementById(t);r||((r=document.createElement("audio")).id=t,r.autoplay=!0,r.className="audio-stream",r.setAttribute("playsinline","true"),r.setAttribute("webkit-playsinline","true"),r.setAttribute("x5-playsinline","true")),r.srcObject=n,this.getCloudGamingStreamContainerElement().appendChild(r)},t.prototype.getFakeInputElement=function(){var e;return null===(e=this.mountPoint)||void 0===e?void 0:e.querySelector(".tcg-fake-input")},t.prototype.getClientInteractMode=function(){return this.pageEvent.getClientInteractMode()},t.prototype.getRemoteScreenConfig=function(){return this.pageEvent.getRemoteScreenConfig()},t.prototype.showTouchPosition=function(e){this.cloudGamingWebRTC.sendAckData({data:{type:"show_touch_pos",show:e}})},t.prototype.mountGamePoint=function(e){var t=e.mount,n=void 0===t?"":t,r=e.loadingText,i=void 0===r?"正在启动云渲染":r,o=e.showLoading,s=void 0===o||o,a=e.restartText,c=void 0===a?"重新连接":a,u=document.createElement("style");document.querySelector("head").append(u),u.appendChild(document.createTextNode("\n.cloud-gaming-container {\n position: relative;\n width: 100%;\n height: 100%;\n // justify-content: center;\n // align-items: center;\n display: none;\n}\n.cloud-gaming-stream-container {\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n background-size: cover !important;\n}\n.cloud-gaming-audio-stream-socket {\n display: none;\n}\n.tcg-fake-input {\n position: absolute;\n z-index: -5;\n opacity: 0;\n}\n.qcloud-stat {\n position: absolute;\n right: 10px;\n top: 0px;\n line-height: 18px;\n padding: 5px 10px;\n z-index: 5;\n color: #eee;\n background: rgba(0, 0, 0, .5);\n border-radius: 5px;\n text-align: left;\n font-size: 12px;\n pointer-events: none;\n display: none;\n flex-direction: column;\n width: 220px;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n}\n.qcloud-request-id, .qcloud-instance-id {\n pointer-events: all;\n}\n.qcloud-stat-left {\n width: 120px;\n}\n.qcloud-stat-right {\n flex: 1;\n}\n.qcloud-stat-row {\n text-align: left;\n display: flex;\n}\n\n@keyframes spinner {\n to {transform: rotate(360deg);}\n}\n.progress-bar-container {\n text-align: center;\n position: absolute;\n width: 40%;\n height: 15%;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.starting {\n color:white;\n font-weight:bold;\n margin-top:30px;\n}\n.spinner:before {\n content: '';\n box-sizing: border-box;\n position: absolute;\n top: 60px;\n width: 20px;\n height: 20px;\n margin-top: -5px;\n margin-left: -10px;\n border-radius: 50%;\n border: 4px solid #ccc;\n border-top-color: #000;\n animation: spinner .6s linear infinite;\n}\n.restart {\n position: absolute;\n width: 350px;\n text-align: center;\n height: 30px;\n line-height: 30px;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n align-items: center;\n font-size: 24px;\n color: #fff;\n display: none;\n}\n.cursor {\n position: absolute;\n width: 0px;\n height: 0px;\n top: 0px;\n left: 0px;\n z-index: 1;\n background-size: cover;\n display: none;\n}\n.audio-stream {\n width: 0px;\n}\n.video-stream {\n max-width: 100%;\n max-height: 100%;\n outline: none;\n border: 0;\n}\n.video-stream:focus {\n outline :none;\n}\n.rotate-html-90 {\n transform: rotate(90deg);\n transform-origin: left top;\n width: 100vh;\n width: 100svh;\n height: 100vw;\n overflow-x: hidden;\n position: absolute;\n top: 0;\n left: 100%;\n}\n\n.rotate-html-180 {\n transform: rotate(180deg);\n transform-origin: center;\n}\n\n.rotate-html-270 {\n transform: rotate(270deg);\n transform-origin: left top;\n overflow-x: hidden;\n position: absolute;\n top: 100%;\n left: 0;\n}"));var d=document.getElementById(n);d||console.error("mount point is not found"),d.innerHTML=dn,s||(console.log("mountPoint",this.mountPoint),this.getProgressBarElement().style.display="none"),d.querySelector(".starting").innerHTML=i,d.querySelector(".restart").innerHTML=c},t}(Rn),Oi=new Ai;window.TCGSDK=Oi;const xi=Oi})();var C8,I8=T8.p;!function(e){e.MESSAGE="message",e.INITIALIZED="initialized",e.CALLBACK="callBack"}(C8||(C8={}));class w8{constructor(e,t){this.TCGSDK=e,this.destPort=t,this.events=new Map,this.TCGSDK=e}async init(e){const{sendMessage:t,code:n}=await this.TCGSDK.createCustomDataChannel({destPort:this.destPort||10005,type:e,onMessage:e=>{try{const t=JSON.parse(e),{key:n,data:r}=t;switch(console.log("onMessage",t),n){case C8.CALLBACK:this.emit(C8.CALLBACK,JSON.parse(r));break;case C8.INITIALIZED:this.emit(C8.INITIALIZED);break;default:this.emit(C8.MESSAGE,t)}}catch(e){console.error("CustomDataChannel onMessage error",e)}}});if(this.sendMessage=t,this.code=n,0==n){t(JSON.stringify({touchType:x4.EVENT_SDK,content:JSON.stringify({type:"PullStreamConnected"})}))}}send(e){this.sendMessage?.(e)}on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),this}once(e,t){const n=r=>{this.off(e,n),t(r)};return this.on(e,n),this}off(e,t){return this.events.has(e)?(this.events.set(e,this.events.get(e).filter((e=>e!==t))),this):this}emit(e,t){this.events.get(e)?.forEach((e=>e(t)))}getCode(){return this.code}}const R8={7:{width:144,height:256},8:{width:216,height:384},9:{width:288,height:512},10:{width:360,height:640},11:{width:480,height:848},12:{width:540,height:960},13:{width:600,height:1024},14:{width:480,height:1280},15:{width:720,height:1280},16:{width:720,height:1920},17:{width:1080,height:1920},18:{width:1440,height:1920},19:{width:1600,height:2560},20:{width:2880,height:1080}},A8={1:{fps:20},2:{fps:25},3:{fps:30},4:{fps:60},5:{fps:1},6:{fps:5},7:{fps:10},8:{fps:15},9:{fps:2}},O8={1:{kbps:1e3},2:{kbps:1500},3:{kbps:2e3},4:{kbps:2500},5:{kbps:3e3},6:{kbps:3500},7:{kbps:4e3},8:{kbps:5e3},9:{kbps:6e3},10:{kbps:8e3},11:{kbps:1e4},12:{kbps:12e3},13:{kbps:200},14:{kbps:400},15:{kbps:600}};function x8(e){return R8[e]}function P8(e){return A8[e].fps}function D8(e){return O8[e].kbps}class M8{constructor(e,t,n){this.initDomId=e,this.options=t,this.callbacks=n,this.remoteUserId="",this.abortController=null,this.dataChannel=null,this.groupDataChannel=null,this.isGroupControl=!1,this.groupPads=[],this.promiseMap={streamStatus:{},injectStatus:{}},this.isCameraInject=!1,this.isMicrophoneInject=!1,this.enableCamera=!1,this.enableMicrophone=!1,this.videoDeviceId="",this.audioDeviceId="",this.inputElement=null,this.rotateType=void 0,this.remoteInputState={isOpen:!1,imeOptions:""},this.lastStreamResolution={width:0,height:0},this.remoteDesktopResolution={width:0,height:0},this.enterkeyhintObj={2:"go",3:"search",4:"send",5:"next",6:"done",7:"previous"},this.TCGSDK=new I8,this.androidInstance=this.TCGSDK.getAndroidInstance(),this.enableMicrophone=this.options.enableMicrophone,this.enableCamera=this.options.enableCamera,this.videoDeviceId=this.options.videoDeviceId||"",this.audioDeviceId=this.options.audioDeviceId||"",this.remoteUserId=this.options.clientId,this.TCGSDK.setKMStatus({keyboard:!1,mouse:!0}),this.TCGSDK.setPaste(!1)}getMsgTemplate(e,t){return JSON.stringify({touchType:e,content:JSON.stringify(t)})}setMicrophone(e){this.enableMicrophone=e}setCamera(e){this.enableCamera=e}async setVideoDeviceId(e){if(this.videoDeviceId=e,this.isCameraInject)return this.cameraInject()}async setAudioDeviceId(e){if(this.audioDeviceId=e,this.isMicrophoneInject)return this.microphoneInject()}setMonitorOperation(e,t=!0){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:"operateSwitch",isOpen:e}),t)}triggerRecoveryTimeCallback(){}setVideoEncoder(e,t){}muted(){this.unsubscribeStream(O4.AUDIO)}getRequestId(){return this.TCGSDK.getRequestId()}unmuted(){this.subscribeStream(O4.AUDIO)}startPlay(){this.TCGSDK?.playVideo("play")}async sendGroupRoomMessage(e){}getEquipmentInfo(e){const t=this.getMsgTemplate(x4.EQUIPMENT_INFO,{type:e});this.sendUserMessage(t,!0)}getInjectStreamStatus(e,t=0){return new Promise((n=>{let r=null;0!==t&&(r=setTimeout((()=>{n({status:"unknown",type:e})}),t));(()=>{switch(e){case exports.InjectStreamStatusType.VIDEO:try{Object.assign(this.promiseMap.streamStatus,{resolve:e=>{r&&clearTimeout(r),n(e)}}),this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:D4.INJECTION_VIDEO_STATS}),!0)}catch(t){r&&clearTimeout(r),n({status:"unknown",type:e})}break;case exports.InjectStreamStatusType.CAMERA:r&&clearTimeout(r),n({status:this.isCameraInject?"live":"offline",type:e});break;case exports.InjectStreamStatusType.AUDIO:r&&clearTimeout(r),n({status:this.isMicrophoneInject?"live":"offline",type:e})}})()}))}appUnInstall(e){const t=this.getMsgTemplate(x4.APP_UNINSTALL,e);this.sendUserMessage(t)}async notifyInject(e,t){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:e,isOpen:t}))}async startMediaStream(e,t){try{if([O4.VIDEO,O4.AUDIO_AND_VIDEO].includes(e)){await this.notifyInject(M4.INJECTION_CAMERA,!0);const e=this.videoDeviceId||(t?.isFront?"user":!1===t?.isFront?"environment":void 0),n=e?{deviceId:e}:void 0;await this.TCGSDK.switchCamera({status:"open",profile:n});this.isCameraInject=!0}if([O4.AUDIO,O4.AUDIO_AND_VIDEO].includes(e)){await this.notifyInject(M4.INJECTION_AUDIO,!0);const e=this.audioDeviceId?{deviceId:this.audioDeviceId}:void 0;await this.TCGSDK.switchMic({status:"open",profile:e});this.isMicrophoneInject=!0}}catch(e){return Promise.reject(e)}}async stopMediaStream(e){try{const t=[];switch(e!==O4.VIDEO&&e!==O4.AUDIO_AND_VIDEO||(await this.notifyInject(M4.INJECTION_CAMERA,!1),t.push(this.TCGSDK.switchCamera({status:"close"}))),e!==O4.AUDIO&&e!==O4.AUDIO_AND_VIDEO||(await this.notifyInject(M4.INJECTION_AUDIO,!1),t.push(this.TCGSDK.switchMic({status:"close"}))),await Promise.allSettled(t),e){case O4.VIDEO:this.isCameraInject=!1;break;case O4.AUDIO:this.isMicrophoneInject=!1;break;case O4.AUDIO_AND_VIDEO:this.isCameraInject=!1,this.isMicrophoneInject=!1}}catch(e){return Promise.reject(e)}}async cameraInject(e){try{await this.stopMediaStream(O4.VIDEO),await this.startMediaStream(O4.VIDEO,e),this.callbacks.onVideoInit()}catch(e){return this.callbacks.onVideoError(e),Promise.reject(e)}}async microphoneInject(){try{await this.stopMediaStream(O4.AUDIO),await this.startMediaStream(O4.AUDIO),this.callbacks.onAudioInit()}catch(e){return this.callbacks.onAudioError(e),Promise.reject(e)}}kickItOutRoom(e){this.isGroupControl&&(e=e.filter((e=>e!==this.options.clientId))).length&&(this.groupPads=this.groupPads.filter((t=>!e.includes(t))),this.androidInstance.leaveGroupControl({instanceIds:e}))}async getAndroidInstanceToken(e){return new Promise(((t,n)=>{const{baseUrl:r}=this.options,i=r?`${r}/rtc/open/room/sdk/share/applyToken`:"https://openapi.armcloud.net/rtc/open/room/sdk/share/applyToken",{userId:o,uuid:s,token:a,manageToken:c}=this.options,u=c?"/manage/rtc/room/share/applyToken":i,d=c||a;this.abortController=new AbortController,_n.post(u,{userId:o,uuid:s,terminal:"h5",expire:36e4,pushPublicStream:!1,pads:e?.map((e=>({padCode:e,userId:o})))},{headers:c?{Authorization:d}:{token:d},signal:this.abortController.signal}).then((e=>{t(e?.data?.data||{})})).catch((e=>{_n.isCancel(e)||n(e)}))}))}joinGroupRoom(e){this.isGroupControl&&(e=e.filter((e=>e!==this.options.clientId))).length&&(this.groupPads=Array.from(new Set([...this.groupPads,...e])),this.getAndroidInstanceToken(e).then((t=>{const{accessInfo:n,roomToken:r}=t||{};this.TCGSDK.setAccessToken({accessInfo:n,token:r}),this.androidInstance.joinGroupControl({instanceIds:e})})))}toggleGroupControlSync(e=!0){this.isGroupControl&&(e?this.androidInstance.startSync({}):this.androidInstance.stopSync())}onRemoteVideoFirstFrame(){let{width:e,height:t}=this.TCGSDK.getRemoteStreamResolution();this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:1}),this.metricsReporter.instant(Y4.FIRST_FRAME),this.callbacks?.onRenderedFirstFrame?.({userId:this.options.clientId,width:e,height:t,isScreen:!1})}setupInputElement(){const{disable:e,disableLocalIME:t}=this.options;this.inputElement||e||t||q4(this,!0)}getRemoteInputState(){this.sendUserMessage(JSON.stringify({touchType:x4.INPUT_STATE}))}syncInputFocusState(e){const{allowLocalIMEInCloud:t,keyboard:n}=this.options,{isOpen:r,imeOptions:i}=e,o=this.enterkeyhintObj[i??""];o&&(this.inputElement.enterKeyHint=o);(t&&"pad"===n||"local"===n)&&"boolean"==typeof r&&setTimeout((()=>{r?this.inputElement?.focus():this.inputElement?.blur()}),150),this.remoteInputState={isOpen:r??!1,imeOptions:i??""}}matchResolution(e,t){let{width:n,height:r}=this.remoteDesktopResolution;if(!n||!r)return{width:e,height:t};const i=n/r,o=e/t;let s=e,a=t;return Math.abs(o-i)>.01&&(o>i?s=Math.round(t*i):a=Math.round(e/i)),s=s%2==0?s:s+1,a=a%2==0?a:a+1,{width:s,height:a}}setDomResolution(e,t){const n=document.getElementById(this.initDomId);if(!n)return;n.style.width="",n.style.height="";const r=n.getBoundingClientRect(),i=r.width,o=r.height,s=e/t;let a=i,c=o;i/o>s?(c=o,a=o*s):(a=i,c=i/s),n.style.position="relative",n.style.width=`${a}px`,n.style.height=`${c}px`}setupStreamResolution(e,t){let{width:n,height:r}=this.matchResolution(e,t);this.TCGSDK.setStreamProfile({video_width:n,video_height:r})}setMediaStreamRender(e){e===O4.VIDEO?this.unsubscribeStream(O4.AUDIO):e===O4.AUDIO&&this.unsubscribeStream(O4.VIDEO)}hideATags(){let e=document.styleSheets[0];e.insertRule(".cloud-gaming-container .restart { display: none !important; }",e.cssRules.length)}setupSDK(e=!1,t=[]){const{roomToken:n,padCode:r,accessInfo:i,videoStream:o,mediaType:s}=this.options,{resolution:a,frameRate:c,bitrate:u}=o,{width:d,height:l}=x8(a),h=P8(c),p=D8(u);this.isGroupControl=e,this.groupPads=t;const f=this;this.TCGSDK.init({mount:this.initDomId,mobileGame:!0,showLoading:!1,restartText:"",clickBodyToPlay:!1,debugSetting:{},streaming:{mode:"webrtc"},accessToken:{token:n,accessInfo:i||""},androidInstance:{autoRotateOnPC:!1},autoRotateMountPoint:!1,streamProfile:{fps:h,max_bitrate:p,min_bitrate:p,unit:"Kbps"},onConnectFail:e=>{this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:0}),this.metricsReporter.instant(Y4.FIRST_FRAME);const t=e.code;if(t>0)return void this.callbacks?.onConnectionStateChanged?.({state:1,code:t,msg:e.msg});const n={"-3":1,"-2":4,"-1":6}[t];this.callbacks?.onConnectionStateChanged?.({state:n,code:t,msg:e.msg})},onConnectSuccess:()=>{this.setupInputElement(),this.setupDataChannel(),this.setMediaStreamRender(s),this.hideATags(),this.joinGroupRoom(t)},onConfigurationChange:e=>{let{orientation:t,deg:n,width:r,height:i}=e.screen_config;this.remoteDesktopResolution={width:r,height:i};const{resolution:o}=this.options.videoStream,{width:s,height:a}=x8(o);this.setupStreamResolution(s,a);const c=t&&"portrait"!==t?exports.RotateDirection.LANDSCAPE:exports.RotateDirection.PORTRAIT;this.screenRotation(c,n??0)},onInitSuccess:()=>{this.callbacks?.onConnectSuccess?.(),e?this.TCGSDK.access({groupControl:e,instanceIds:[r]}):this.TCGSDK.access({instanceId:r})},onVideoStreamConfigChange:e=>{let{width:t,height:n}=this.lastStreamResolution;this.callbacks?.onChangeResolution?.({from:{width:t,height:n},to:e}),Object.assign(this.lastStreamResolution,e)},onAndroidInstanceEvent(e){const{type:t,data:n}=e;n?.event_type||f.syncInputFocusState(f.remoteInputState)},onEvent:e=>{const{type:t,data:n}=e;switch(t){case"video_state":-1===n?.code&&this.callbacks?.onAutoplayFailed?.({kind:"video",userId:r});break;case"audio_state":-1===n?.code&&this.callbacks?.onAutoplayFailed?.({kind:"audio",userId:r});break;case"media_stats":this.callbacks?.onRunInformation?.({userId:this.options.clientId,audioStats:{audioLossRate:n.audioStats.packet_lost/n.audioStats.packet_received,receivedKBitrate:n.audioStats.bit_rate,rtt:n.videoStats.rtt,jitterBufferDelay:n.audioStats.jitter_buffer,numChannels:n.audioStats.channels,receivedSampleRate:n.audioStats.sample_rate,concealedSamples:n.audioStats.concealed_samples,concealmentEvent:n.audioStats.concealment_events,codecType:n.audioStats.codec},videoStats:{width:n.videoStats.width,height:n.videoStats.height,videoLossRate:n.videoStats.packet_lost/n.videoStats.packet_received,receivedKBitrate:n.videoStats.bit_rate,decoderOutputFrameRate:n.videoStats.fps,rtt:n.videoStats.rtt,codecType:n.videoStats.codec}});break;case"autoplay":0===n?.code&&"video"===n?.mediaType&&this.onRemoteVideoFirstFrame?.()}}})}setPhoneRotation(e){this.screenRotation(e,e==exports.RotateDirection.LANDSCAPE?270:0)}async triggerChangeRotateEvent(e){((e,t)=>{const n=new ResizeObserver((r=>{for(const i of r){const{width:r,height:o}=i.target.getBoundingClientRect();r&&o&&(t(r,o),n.unobserve(e),n.disconnect())}}));n.observe(e)})(document.querySelector(`#${this.initDomId} video`),((t,n)=>{this.callbacks?.onChangeRotate?.(e,{width:t,height:n})}))}async screenRotation(e,t){const n=this.options.rotateType;void 0!==n&&(e=n,t=n===exports.RotateDirection.LANDSCAPE?270:0),(W4()||H4())&&(e=exports.RotateDirection.PORTRAIT,t=0);const r=document.getElementById(this.initDomId);if(!r)return;const i=r.getBoundingClientRect();let{width:o,height:s}=i;const a=this.rotateType;let c=o,u=s;void 0!==a?(a===exports.RotateDirection.PORTRAIT&&e===exports.RotateDirection.LANDSCAPE||a===exports.RotateDirection.LANDSCAPE&&e===exports.RotateDirection.PORTRAIT)&&([c,u]=[s,o]):e===exports.RotateDirection.LANDSCAPE&&([c,u]=[s,o]),r.style.width=`${c}px`,r.style.height=`${u}px`,await(async e=>{e.offsetWidth,await K4()})(r),this.TCGSDK.setVideoOrientation({deg:t??0,rotateMountPoint:!0}),this.triggerChangeRotateEvent(e),this.rotateType=e}async setupDataChannel(){if(this.dataChannel=new w8(this.TCGSDK,23332),await this.dataChannel.init("android"),this.isGroupControl){const e=()=>{this.callbacks?.onUserJoined?.({userInfo:{userId:this.options.clientId}})};this.groupDataChannel=new w8(this.TCGSDK,23331),await this.groupDataChannel.init("android_broadcast"),this.groupDataChannel.on(C8.INITIALIZED,e)}const e=e=>{const[t,n]=e?.split("*").map(Number);return{width:t,height:n}},t=(e,t)=>{try{return JSON.parse(e)}catch{return t}},n={[D4.CLIPBOARD]:e=>{const n=t(e,{content:""});this.callbacks?.onOutputClipper?.(n)},[D4.INPUT_STATE]:e=>{const n=t(e,{isOpen:!1,imeOptions:""});this.syncInputFocusState(n)},[D4.EQUIPMENT_INFO]:e=>{const n=t(e,{info:""});this.callbacks?.onEquipmentInfo?.(n)},[D4.INPUT_ADB]:e=>{const n=t(e,{isSuccess:!1,content:""});this.callbacks?.onAdbOutput?.(n)},[D4.VIDEO_AND_AUDIO_CONTROL]:e=>{const n=t(e,{}),r=!!n.isOpen;if(this.callbacks?.onMediaDevicesToggle?.({type:exports.MediaDeviceType.MEDIA,enabled:r,isFront:n.isFront}),!this.enableMicrophone&&!this.enableCamera)return;const i=this.enableMicrophone&&this.enableCamera?O4.AUDIO_AND_VIDEO:this.enableCamera?O4.VIDEO:O4.AUDIO;r?(this.enableCamera&&this.cameraInject(n),this.enableMicrophone&&this.microphoneInject()):this.stopMediaStream(i)},[D4.AUDIO_CONTROL]:e=>{const{isOpen:n=!1}=t(e,{});this.callbacks?.onMediaDevicesToggle?.({type:exports.MediaDeviceType.MICROPHONE,enabled:n}),this.enableMicrophone&&(n?this.microphoneInject():this.stopMediaStream(O4.AUDIO))},[D4.DEFINITION]:n=>{const r=t(n,{});this.callbacks?.onChangeResolution?.({from:e(r.from),to:e(r.to)})},[D4.START_INJECTION_VIDEO]:e=>{const n=t(e,{}),r=this?.promiseMap?.injectStatus?.resolve;"function"==typeof r&&(r({type:D4.START_INJECTION_VIDEO,status:n?.isSuccess?"success":"error",result:n}),this.promiseMap.injectStatus.resolve=null),this.callbacks?.onInjectVideoResult?.(D4.START_INJECTION_VIDEO,n)},[D4.STOP_INJECTION_VIDEO]:e=>{const n=t(e,{}),r=this?.promiseMap?.injectStatus?.resolve;"function"==typeof r&&(r({type:D4.STOP_INJECTION_VIDEO,status:n?.isSuccess?"success":"error",result:n}),this.promiseMap.injectStatus.resolve=null),this.callbacks?.onInjectVideoResult?.(D4.STOP_INJECTION_VIDEO,n)},[D4.INJECTION_VIDEO_STATS]:e=>{const n=t(e,{}),r=this?.promiseMap?.streamStatus?.resolve;"function"==typeof r&&r({path:n.path,status:n.status||(n.path?"live":"offline"),type:"video"})}},r={[D4.VIDEO_AND_AUDIO_CONTROL]:500,[D4.AUDIO_CONTROL]:500};Object.entries(r).forEach((([e,t])=>{const r=n[e];r&&t&&(n[e]=((e,t)=>{let n=null,r=null;return(...i)=>{r=i,n&&clearTimeout(n),n=setTimeout((()=>{r&&(e(...r),r=null),n=null}),t)}})(r,t))}));this.dataChannel.on(C8.INITIALIZED,(()=>{this.callbacks?.onUserJoined?.({userInfo:{userId:this.options.clientId}}),this.getRemoteInputState(),this.getCameraState()})).on(C8.MESSAGE,(e=>{const{key:t,data:r}=e,i=n[t];i?i(r):console.debug(`[dataChannel] Unknown key: ${this.options.clientId}`,t,"raw:",r)})).on(C8.CALLBACK,(e=>{const{type:t,data:r}=e,i=n[t];i?i(r):console.debug(`[dataChannel] Unknown type: ${this.options.clientId}`,t,"raw:",r)}))}sendUserMessage(e,t=!1,n=!1){this.isGroupControl&&!t&&this.groupDataChannel?.send(e),n||this.dataChannel?.send(e)}sendGroupInputString(e,t){this.isGroupControl&&t?.map(((t,n)=>{if(e[n]){const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.INPUT_BOX});this.sendUserMessage(r,!1,!0)}}))}sendGroupInputClipper(e,t){this.isGroupControl&&t?.map(((t,n)=>{if(e[n]){const r=JSON.stringify({text:t,pads:[e[n]],touchType:x4.CLIPBOARD});this.sendUserMessage(r,!1,!0)}}))}executeAdbCommand(e,t=!0){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:D4.INPUT_ADB,content:e}),t)}start(e=!1,t=[]){this.metricsReporter=new X4({endpoint:`${this.options.baseUrl}/traffic-info/open/traffic/rtcMonitor`,commonParams:{padCode:this.remoteUserId,streamType:this.options.streamType,sdkTerminal:"h5"},onceOnlyKeys:[Y4.FIRST_FRAME],useBeacon:!1,enableLog:!0}),this.metricsReporter.addParam(Y4.FIRST_FRAME,{joinRoomTime:Date.now()}),setTimeout((()=>{this.metricsReporter.addParam(Y4.FIRST_FRAME,{judgeTime:Date.now(),result:0}),this.metricsReporter.instant(Y4.FIRST_FRAME)}),5e3),this.setupSDK(e,t)}onUserLeave(){}setViewSize(e,t,n=0){}getCameraState(){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.GET_CAMERA_STATE}),!0)}triggerClickEvent(e,t=!1){}triggerPointerEvent(e,t,n=!1){}async stop(){this.TCGSDK.destroy(),this.abortController?.abort(),this.abortController=null;const e=document.getElementById(this.initDomId);e&&(e.innerHTML=""),this.inputElement=null}sendShakeInfo(e){}async sendInputClipper(e,t=!1){const n=JSON.stringify({text:e,touchType:x4.CLIPBOARD});this.sendUserMessage(n,t)}async sendInputString(e,t=!1){const n=JSON.stringify({text:e,touchType:x4.INPUT_BOX});this.sendUserMessage(n,t)}setStreamConfig(e){const{definitionId:t,framerateId:n,bitrateId:r}=e,{width:i,height:o}=x8(t),s=P8(n),a=D8(r),{width:c,height:u}=this.matchResolution(i,o);this.TCGSDK.setStreamProfile({video_width:c,video_height:u,fps:s,max_bitrate:a,unit:"Kbps"});const{resolution:d,frameRate:l,bitrate:h}=this.options.videoStream;Object.assign(this.options.videoStream,{resolution:t??d,frameRate:n??l,bitrate:r??h})}async setScreenResolution(e,t=!0){const n=e.type===D4.UPDATE_DENSITY?{type:e.type,width:e.width,height:e.height,density:e.dpi}:{type:e.type},r=this.getMsgTemplate(x4.EVENT_SDK,n);this.sendUserMessage(r,t)}async subscribeStream(e){const t={1:{media:"audio"},2:{media:"video"},3:void 0}[e];await this.TCGSDK.gameResume(t)}setScreenshotRotation(e=0){}takeScreenshot(e=0){}resizeScreenshot(e,t){}showScreenShot(){}hideScreenShot(){}clearScreenShot(){}async unsubscribeStream(e){const t={1:{media:"audio"},2:{media:"video"},3:void 0}[e];await this.TCGSDK.gamePause(t)}async saveScreenShotToLocal(){return this.TCGSDK.screenShot({name:this.options.clientId})}saveScreenShotToRemote(){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.LOCAL_SCREENSHOT}),!0)}getRotateType(){return this.rotateType}setGPS(e,t){this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.SDK_LOCATION,content:JSON.stringify({latitude:t,longitude:e,time:(new Date).getTime()})}),!0)}setKeyboardStyle(e){this.options.keyboard=e,this.sendUserMessage(this.getMsgTemplate(x4.EVENT_SDK,{type:M4.KEYBOARD_TYPE,isLocalKeyBoard:e===exports.KeyboardMode.LOCAL}))}setAutoRecycleTime(e){}getAutoRecycleTime(){}sendCommand(e){const t={back:4,home:3,menu:187}[e]??e,n={action:1,touchType:x4.KEYSTROKE,keyCode:t,text:""};this.sendUserMessage(JSON.stringify(n))}triggerKeyboardShortcut(e,t,n=!0){const r=JSON.stringify({touchType:D4.SHORTCUT_KEY,metaState:e+"",keyCode:t+""});this.options.clientId,this.sendUserMessage(r,n)}injectVideoStream(e,t,n=0){return new Promise((async r=>{let i=null;n&&(i=setTimeout((()=>{r({type:e,status:"timeout",result:null})}),n));try{Object.assign(this.promiseMap.injectStatus,{resolve:e=>{i&&clearTimeout(i),r(e)}});const n=this.getMsgTemplate(x4.EVENT_SDK,e===D4.START_INJECTION_VIDEO?{type:e,fileUrl:t?.fileUrl,isLoop:t?.isLoop??!0,fileName:t?.fileName}:{type:e});this.sendUserMessage(n,!0)}catch{r({type:e,status:"unknown",result:null})}}))}increaseVolume(){this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_UP,down:!0}),this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_UP,down:!1})}decreaseVolume(){this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_DOWN,down:!0}),this.TCGSDK.sendKeyboardEvent({key:exports.AndroidKeyCode.KEYCODE_VOLUME_DOWN,down:!1})}saveCloudClipboard(e){this.options.saveCloudClipboard=e}}exports.ArmcloudEngine=class{constructor(e){this.version="1.5.3-beta.6",this.rtcInstance=null,this.rtcOptions=null,this.callbacks=null,this.streamType=null,this.axiosSource=null,this.axiosSource=_n.CancelToken.source(),this.setupInitConfig(e),this.setupCallbacks(e);const t=[];if(e.token||t.push("token"),e.deviceInfo||t.push("deviceInfo"),e.deviceInfo&&(e.deviceInfo.padCode||t.push("deviceInfo.padCode"),e.deviceInfo.userId||t.push("deviceInfo.userId")),e.viewId||t.push("viewId"),e.callbacks||t.push("callbacks"),t.length>0){const e=`初始化参数缺失,请检查参数: ${t.join(", ")}`;throw new Error(e)}if(!/^[a-zA-Z0-9_\-@]{1,128}$/.test(this.rtcOptions?.userId||""))throw new Error('deviceInfo.userId 格式不正确,允许数字、字母、"_"、"-" 、"@",长度为1~128个字符');if(!this.rtcOptions?.baseUrl)throw new Error("baseUrl 不能为空");let n=this.rtcOptions?.uuid||"";n||(n=localStorage.getItem("armcloud_uuid")||this.generateUUID(),localStorage.setItem("armcloud_uuid",n||""));const r=`${e.baseUrl}/rtc/open/room/applyToken`,i={sdkTerminal:"h5",userId:this.rtcOptions.userId,padCode:this.rtcOptions.padCode,uuid:n,expire:86400,videoStream:this.rtcOptions.videoStream};_n.post(r,i,{headers:{"Content-Type":"application/json",token:this.rtcOptions.token},cancelToken:this.axiosSource.token}).then((t=>{200===t.data.code?(this.streamType=t.data.data.streamType,this.rtcOptions.streamType=this.streamType,1==this.streamType?(this.rtcOptions.uuid=n,this.rtcOptions.appId=t.data.data.appId,this.rtcOptions.roomCode=t.data.data.roomCode,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcInstance=new $4(e.viewId,this.rtcOptions,this.callbacks),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n})):2==this.streamType?(this.rtcOptions.uuid=n,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcOptions.signalServer=t.data.data.signalServer,this.rtcOptions.stuns=t.data.data.stuns,this.rtcOptions.turns=t.data.data.turns,this.rtcInstance=new f8(e.viewId,this.rtcOptions,this.callbacks),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n})):3==this.streamType&&(this.rtcOptions.accessInfo=t.data.data.accessInfo,this.rtcOptions.roomToken=t.data.data.roomToken,this.rtcInstance=new M8(e.viewId,this.rtcOptions,this.callbacks),console.log(t.data.data),this.callbacks?.onInit?.({code:U6,msg:"初始化成功",streamType:this.streamType,uuid:n}))):this.callbacks?.onInit?.({code:t?.data?.code||V6,msg:t?.data?.msg,streamType:this.streamType||void 0,uuid:n||""})})).catch((e=>{_n.isCancel(e)||(console.error("获取初始化配置失败:",e),this.callbacks?.onInit?.({code:V6,msg:e.message||e.name,uuid:n||""}))}))}static isSupported(){if(!window.RTCPeerConnection)return!1;try{const e=new RTCPeerConnection;return e.createDataChannel("test"),e.close(),!0}catch(e){return!1}}triggerKeyboardShortcut(e,t,n){this.rtcInstance?.triggerKeyboardShortcut?.(e,t,n)}setupInitConfig(e){this.rtcOptions={appId:"",roomCode:"",roomToken:"",signalServer:"",stuns:"",turns:"",token:e.token,uuid:e.uuid||"",clientId:e.deviceInfo.padCode,padCode:e.deviceInfo.padCode,userId:e.deviceInfo.userId,retryCount:e.retryCount??2,retryTime:e.retryTime??2e3,isLog:e.isLog??!0,disable:e.disable??!1,enableMicrophone:e.enableMicrophone??!0,enableCamera:e.enableCamera??!0,baseUrl:e.baseUrl,isWsProxy:!!e.isWsProxy&&JSON.parse(e.isWsProxy),manageToken:e.manageToken??"",masterIdPrefix:e.masterIdPrefix??"",videoStream:{resolution:e?.deviceInfo?.videoStream?.resolution??12,frameRate:e?.deviceInfo?.videoStream?.frameRate??2,bitrate:e?.deviceInfo?.videoStream?.bitrate??3},disableLocalIME:e.deviceInfo.disableLocalIME??!1,allowLocalIMEInCloud:e.deviceInfo.allowLocalIMEInCloud??!1,autoRecoveryTime:e.deviceInfo.autoRecoveryTime??300,mediaType:e.deviceInfo.mediaType??2,rotateType:e.deviceInfo.rotateType,keyboard:e.deviceInfo.keyboard??exports.KeyboardMode.PAD,disableContextMenu:e.deviceInfo.disableContextMenu??!1,saveCloudClipboard:e.deviceInfo.saveCloudClipboard??!0,videoDeviceId:e.deviceInfo.videoDeviceId,audioDeviceId:e.deviceInfo.audioDeviceId}}setupCallbacks(e){this.callbacks={onInit:e.callbacks?.onInit||(()=>{}),onConnectSuccess:e.callbacks?.onConnectSuccess||(()=>{}),onConnectFail:e.callbacks?.onConnectFail||(()=>{}),onAutoRecoveryTime:e.callbacks?.onAutoRecoveryTime||(()=>{}),onAutoplayFailed:e.callbacks?.onAutoplayFailed||(()=>{}),onRunInformation:e.callbacks?.onRunInformation||(()=>{}),onChangeResolution:e.callbacks?.onChangeResolution||(()=>{}),onChangeRotate:e.callbacks?.onChangeRotate||(()=>{}),onTransparentMsg:e.callbacks?.onTransparentMsg||(()=>{}),onConnectionStateChanged:e.callbacks?.onConnectionStateChanged||(()=>{}),onErrorMessage:e.callbacks?.onErrorMessage||(()=>{}),onOutputClipper:e.callbacks?.onOutputClipper||(()=>{}),onBeforeRotate:e.callbacks?.onBeforeRotate||(()=>{}),onRenderedFirstFrame:e.callbacks?.onRenderedFirstFrame||(()=>{}),onVideoInit:e.callbacks?.onVideoInit||(()=>{}),onVideoError:e.callbacks?.onVideoError||(()=>{}),onAudioInit:e.callbacks?.onAudioInit||(()=>{}),onAudioError:e.callbacks?.onAudioError||(()=>{}),onProgress:e.callbacks?.onProgress||(()=>{}),onSocketCallback:e.callbacks?.onSocketCallback||(()=>{}),onUserJoined:e.callbacks?.onUserJoined||(()=>{}),onUserLeave:e.callbacks?.onUserLeave||(()=>{}),onUserLeaveOrJoin:e.callbacks?.onUserLeaveOrJoin||(()=>{}),onGroupControlError:e.callbacks?.onGroupControlError||(()=>{}),onEquipmentInfo:e.callbacks?.onEquipmentInfo||(()=>{}),onSendUserError:e.callbacks?.onSendUserError||(()=>{}),onAdbOutput:e.callbacks?.onAdbOutput||(()=>{}),onNetworkQuality:e.callbacks?.onNetworkQuality||(()=>{}),onInjectVideoResult:e.callbacks?.onInjectVideoResult||(()=>{}),onMediaDevicesToggle:e.callbacks?.onMediaDevicesToggle||(()=>{}),onMonitorOperation:e.callbacks?.onMonitorOperation||(()=>{})}}setMonitorOperation(e,t){this.rtcInstance&&this.rtcInstance.setMonitorOperation(e,t)}getInjectStreamStatus(e,t){if(this.rtcInstance)return this.rtcInstance.getInjectStreamStatus(e,t)}generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}getRequestId(){return this.rtcInstance?.getRequestId()}triggerClickEvent(e,t){this.rtcInstance&&this.rtcInstance.triggerClickEvent(e,t)}triggerPointerEvent(e,t,n){this.rtcInstance&&this.rtcInstance.triggerPointerEvent(e,t,n)}setMicrophone(e){this.rtcInstance&&this.rtcInstance.setMicrophone(e)}setCamera(e){this.rtcInstance&&this.rtcInstance.setCamera(e)}startPlay(){this.rtcInstance&&this.rtcInstance.startPlay()}setViewSize(e,t,n=0){this.rtcInstance&&this.rtcInstance.setViewSize(e,t,n)}start(e=!1,t=[]){this.rtcInstance&&this.rtcInstance.start(e,t)}joinGroupRoom(e=[]){this.rtcInstance&&this.rtcInstance.joinGroupRoom(e)}kickItOutRoom(e=[]){this.rtcInstance&&this.rtcInstance.kickItOutRoom(e)}toggleGroupControlSync(e=!0){this.rtcInstance?.toggleGroupControlSync?.(e)}async stop(){return this.axiosSource?.cancel(),this.axiosSource=null,this?.rtcInstance?.stop()}muted(){this.rtcInstance&&this.rtcInstance.muted()}unmuted(){this.rtcInstance&&this.rtcInstance.unmuted()}appUnInstall(e){this.rtcInstance&&this.rtcInstance.appUnInstall(e)}getEquipmentInfo(e){this.rtcInstance&&this.rtcInstance.getEquipmentInfo(e)}setVideoDeviceId(e){this.rtcInstance&&this.rtcInstance.setVideoDeviceId(e)}setAudioDeviceId(e){this.rtcInstance&&this.rtcInstance.setAudioDeviceId(e)}sendInputClipper(e,t){this.rtcInstance&&this.rtcInstance.sendInputClipper(e,t)}sendGroupInputClipper(e,t){this.rtcInstance&&this.rtcInstance.sendGroupInputClipper(e,t)}sendGroupInputString(e,t){this.rtcInstance&&this.rtcInstance.sendGroupInputString(e,t)}sendInputString(e,t){this.rtcInstance&&this.rtcInstance.sendInputString(e,t)}setStreamConfig(e,t){this.rtcInstance&&this.rtcInstance.setStreamConfig(e,t)}pauseAllSubscribedStream(e=3){if(this.rtcInstance)return this.rtcInstance.unsubscribeStream(e)}resumeAllSubscribedStream(e=3){if(this.rtcInstance)return this.rtcInstance.subscribeStream(e)}subscribeStream(e=2){return this.rtcInstance?this.rtcInstance.subscribeStream(e):Promise.reject(new Error("RTC instance does not exist and cannot subscribe to the media stream"))}unsubscribeStream(e=2){return this.rtcInstance?this.rtcInstance?.unsubscribeStream(e):Promise.reject(new Error("RTC instance does not exist and cannot unsubscribe from media stream"))}saveScreenShotToLocal(){return new Promise(((e,t)=>{if(this.rtcInstance)try{this.rtcInstance.saveScreenShotToLocal().then((t=>{e(t)}))}catch(e){t(e)}}))}setScreenResolution(e,t){this.rtcInstance&&this.rtcInstance.setScreenResolution(e,t)}saveScreenShotToRemote(){this.rtcInstance&&this.rtcInstance.saveScreenShotToRemote()}resizeScreenshot(e,t){this.rtcInstance?.resizeScreenshot(e,t)}showScreenShot(){this.rtcInstance?.showScreenShot()}hideScreenShot(){this.rtcInstance?.hideScreenShot()}setScreenshotRotation(e=0){this.rtcInstance?.setScreenshotRotation(e)}takeScreenshot(e=0){this.rtcInstance?.takeScreenshot(e)}clearScreenShot(){this.rtcInstance?.clearScreenShot()}setPhoneRotation(e){this.rtcInstance&&this.rtcInstance.setPhoneRotation(e)}setGPS(e,t){this.rtcInstance&&this.rtcInstance.setGPS(e,t)}executeAdbCommand(e,t){this.rtcInstance&&this.rtcInstance?.executeAdbCommand(e,t)}setKeyboardStyle(e){this.rtcInstance&&this.rtcInstance.setKeyboardStyle(e)}setAutoRecycleTime(e){this.rtcInstance&&this.rtcInstance.setAutoRecycleTime(e)}getAutoRecycleTime(){if(this.rtcInstance)return this.rtcInstance.getAutoRecycleTime()}sendCommand(e,t){this.rtcInstance&&this.rtcInstance.sendCommand(e,t)}increaseVolume(e){this.rtcInstance&&this.rtcInstance.increaseVolume(e)}decreaseVolume(e){this.rtcInstance&&this.rtcInstance.decreaseVolume(e)}saveCloudClipboard(e){this.rtcInstance&&this.rtcInstance.saveCloudClipboard(e)}startMediaStream(e){if(this.rtcInstance)return this.rtcInstance.startMediaStream(e)}stopMediaStream(e){if(this.rtcInstance)return this.rtcInstance.stopMediaStream(e)}injectVideoStream(e,t,n,r){if(this.rtcInstance)return this.rtcInstance.injectVideoStream(e,t,n,r)}sendShake(e){this.rtcInstance&&this.rtcInstance.sendShakeInfo(e??1500)}getRotateType(){if(this.rtcInstance)return this.rtcInstance.getRotateType()}};
23
23
  //# sourceMappingURL=index.cjs.js.map