import{cn as V,i as O,K as D,X as q}from"./index-BbBXKozi.js";import{b as M}from"./index-CDnJG_qv.js";import{a as j,c as T,g as G}from"./__federation_shared_react-xoJ64Y1K.js";const Q=i=>i?i>1e6?`${Math.round(i/1e6)}M`:i>1e3?`${Math.round(i/1e3)}K`:`${i}`:"UNKNOWN",K=i=>i?`${i.height}/${Q(i.bitrate)}`:"UNKNOWN",J=async({broadcastId:i,clientId:n,isAuthenticated:l,startTime:e,selectedQualityHeight:y,activeQuality:c})=>{const S=`${y??"AUTO"}`,p=K(c),v=await fetch(`${V}/v1/broadcasts/etph`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({broadcastId:i,clientId:n,isAuthenticated:l,startTime:e,selectedQuality:S,activeQuality:p})});if(!v.ok)throw new Error(`HTTP error, status = ${v.status}`)};let H=null;const Y=()=>{if(H!==null)return H;const i=document.createElement("canvas"),n=i.getContext("2d"),l=`It's b3En a BL4ST. !
\r <🚀😊😎😁>`;if(i.height=200,i.width=500,!n)return;n.textBaseline="top",n.font="14px 'Arial'",n.textBaseline="alphabetic",n.fillStyle="#f60",n.fillRect(125,1,62,20),n.fillStyle="#069",n.fillText(l,2,15),n.fillStyle="rgba(102, 204, 0, 0.7)",n.fillText(l,4,17),n.globalCompositeOperation="multiply",n.fillStyle="rgb(255,0,255)",n.beginPath(),n.arc(50,50,50,0,Math.PI*2,!0),n.closePath(),n.fill(),n.fillStyle="rgb(0,255,255)",n.beginPath(),n.arc(100,50,50,0,Math.PI*2,!0),n.closePath(),n.fill(),n.fillStyle="rgb(255,255,0)",n.beginPath(),n.arc(75,100,50,0,Math.PI*2,!0),n.closePath(),n.fill(),n.fillStyle="rgb(255,0,255)",n.arc(75,75,75,0,Math.PI*2,!0),n.arc(75,75,25,0,Math.PI*2,!0),n.fill("evenodd");const e=i.toDataURL();return H=e,e};let E=null;const X=()=>{if(E!==null)return E;const i=document.createElement("canvas"),n=256,l=128;i.width=n,i.height=l;const e=i.getContext("webgl2")||i.getContext("experimental-webgl2")||i.getContext("webgl")||i.getContext("experimental-webgl")||i.getContext("moz-webgl");if(!e)return;try{const S="attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}",p="precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}",v=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,v);const _=new Float32Array([-.2,-.9,0,.4,-.26,0,0,.7321,0]);e.bufferData(e.ARRAY_BUFFER,_,e.STATIC_DRAW)(v.itemSize=3)(v.numItems=3);const u=e.createProgram(),g=e.createShader(e.VERTEX_SHADER);e.shaderSource(g,S),e.compileShader(g);const A=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(A,p),e.compileShader(A),e.attachShader(u,g),e.attachShader(u,A),e.linkProgram(u),e.useProgram(u),u.vertexPosAttrib=e.getAttribLocation(u,"attrVertex"),u.offsetUniform=e.getUniformLocation(u,"uniformOffset"),e.enableVertexAttribArray(u.vertexPosArray),e.vertexAttribPointer(u.vertexPosAttrib,v.itemSize,e.FLOAT,!1,0,0),e.uniform2f(u.offsetUniform,1,1),e.drawArrays(e.TRIANGLE_STRIP,0,v.numItems)}catch{}let y="";const c=new Uint8Array(n*l*4);return e.readPixels(0,0,n,l,e.RGBA,e.UNSIGNED_BYTE,c),E=y=JSON.stringify(c).replace(/,?"[0-9]+":/g,""),y};var k={exports:{}};function Z(i){throw new Error('Could not dynamically require "'+i+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var F={exports:{}};const tt={},et=Object.freeze(Object.defineProperty({__proto__:null,default:tt},Symbol.toStringTag,{value:"Module"})),rt=j(et);var L;function nt(){return L||(L=1,function(i,n){(function(l,e){i.exports=e()})(T,function(){var l=l||function(e,y){var c;if(typeof window<"u"&&window.crypto&&(c=window.crypto),typeof self<"u"&&self.crypto&&(c=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(c=globalThis.crypto),!c&&typeof window<"u"&&window.msCrypto&&(c=window.msCrypto),!c&&typeof T<"u"&&T.crypto&&(c=T.crypto),!c&&typeof Z=="function")try{c=rt}catch{}var S=function(){if(c){if(typeof c.getRandomValues=="function")try{return c.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof c.randomBytes=="function")try{return c.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||function(){function t(){}return function(r){var o;return t.prototype=r,o=new t,t.prototype=null,o}}(),v={},_=v.lib={},u=_.Base=function(){return{extend:function(t){var r=p(this);return t&&r.mixIn(t),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),g=_.WordArray=u.extend({init:function(t,r){t=this.words=t||[],r!=y?this.sigBytes=r:this.sigBytes=t.length*4},toString:function(t){return(t||B).stringify(this)},concat:function(t){var r=this.words,o=t.words,s=this.sigBytes,h=t.sigBytes;if(this.clamp(),s%4)for(var d=0;d<h;d++){var m=o[d>>>2]>>>24-d%4*8&255;r[s+d>>>2]|=m<<24-(s+d)%4*8}else for(var w=0;w<h;w+=4)r[s+w>>>2]=o[w>>>2];return this.sigBytes+=h,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var t=u.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],o=0;o<t;o+=4)r.push(S());return new g.init(r,t)}}),A=v.enc={},B=A.Hex={stringify:function(t){for(var r=t.words,o=t.sigBytes,s=[],h=0;h<o;h++){var d=r[h>>>2]>>>24-h%4*8&255;s.push((d>>>4).toString(16)),s.push((d&15).toString(16))}return s.join("")},parse:function(t){for(var r=t.length,o=[],s=0;s<r;s+=2)o[s>>>3]|=parseInt(t.substr(s,2),16)<<24-s%8*4;return new g.init(o,r/2)}},b=A.Latin1={stringify:function(t){for(var r=t.words,o=t.sigBytes,s=[],h=0;h<o;h++){var d=r[h>>>2]>>>24-h%4*8&255;s.push(String.fromCharCode(d))}return s.join("")},parse:function(t){for(var r=t.length,o=[],s=0;s<r;s++)o[s>>>2]|=(t.charCodeAt(s)&255)<<24-s%4*8;return new g.init(o,r)}},a=A.Utf8={stringify:function(t){try{return decodeURIComponent(escape(b.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return b.parse(unescape(encodeURIComponent(t)))}},f=_.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(t){typeof t=="string"&&(t=a.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var r,o=this._data,s=o.words,h=o.sigBytes,d=this.blockSize,m=d*4,w=h/m;t?w=e.ceil(w):w=e.max((w|0)-this._minBufferSize,0);var R=w*d,C=e.min(R*4,h);if(R){for(var P=0;P<R;P+=d)this._doProcessBlock(s,P);r=s.splice(0,R),o.sigBytes-=C}return new g.init(r,C)},clone:function(){var t=u.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});_.Hasher=f.extend({cfg:u.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:16,_createHelper:function(t){return function(r,o){return new t.init(o).finalize(r)}},_createHmacHelper:function(t){return function(r,o){return new x.HMAC.init(t,o).finalize(r)}}});var x=v.algo={};return v}(Math);return l})}(F)),F.exports}(function(i,n){(function(l,e){i.exports=e(nt())})(T,function(l){return function(e){var y=l,c=y.lib,S=c.WordArray,p=c.Hasher,v=y.algo,_=[],u=[];(function(){function B(x){for(var t=e.sqrt(x),r=2;r<=t;r++)if(!(x%r))return!1;return!0}function b(x){return(x-(x|0))*4294967296|0}for(var a=2,f=0;f<64;)B(a)&&(f<8&&(_[f]=b(e.pow(a,1/2))),u[f]=b(e.pow(a,1/3)),f++),a++})();var g=[],A=v.SHA256=p.extend({_doReset:function(){this._hash=new S.init(_.slice(0))},_doProcessBlock:function(B,b){for(var a=this._hash.words,f=a[0],x=a[1],t=a[2],r=a[3],o=a[4],s=a[5],h=a[6],d=a[7],m=0;m<64;m++){if(m<16)g[m]=B[b+m]|0;else{var w=g[m-15],R=(w<<25|w>>>7)^(w<<14|w>>>18)^w>>>3,C=g[m-2],P=(C<<15|C>>>17)^(C<<13|C>>>19)^C>>>10;g[m]=R+g[m-7]+P+g[m-16]}var U=o&s^~o&h,$=f&x^f&t^x&t,z=(f<<30|f>>>2)^(f<<19|f>>>13)^(f<<10|f>>>22),W=(o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25),I=d+W+U+u[m]+g[m],N=z+$;d=h,h=s,s=o,o=r+I|0,r=t,t=x,x=f,f=I+N|0}a[0]=a[0]+f|0,a[1]=a[1]+x|0,a[2]=a[2]+t|0,a[3]=a[3]+r|0,a[4]=a[4]+o|0,a[5]=a[5]+s|0,a[6]=a[6]+h|0,a[7]=a[7]+d|0},_doFinalize:function(){var B=this._data,b=B.words,a=this._nDataBytes*8,f=B.sigBytes*8;return b[f>>>5]|=128<<24-f%32,b[(f+64>>>9<<4)+14]=e.floor(a/4294967296),b[(f+64>>>9<<4)+15]=a,B.sigBytes=b.length*4,this._process(),this._hash},clone:function(){var B=p.clone.call(this);return B._hash=this._hash.clone(),B}});y.SHA256=p._createHelper(A),y.HmacSHA256=p._createHmacHelper(A)}(Math),l.SHA256})})(k);var it=k.exports;const ot=G(it),at=()=>{const{userAgent:i,languages:n}=navigator,{innerHeight:l,innerWidth:e}=window,y=Array.from(document.fonts,p=>p.family),c={userAgent:i,languages:n,screen:{innerHeight:l,innerWidth:e},fonts:y,canvasFingerprint:Y(),webGLFingerprint:X()};return ot(JSON.stringify(c)).toString()},{useCallback:st,useRef:ct,useState:ft}=await O("react");function ut(){const[i]=ft(()=>at()),n=ct(D().isAuthenticated),l=st(e=>J({...e,clientId:i,isAuthenticated:n.current}),[i]);return q({mutationFn:l,retry:2,retryDelay:500})}const{useCallback:lt,useEffect:ht,useState:vt}=await O("react");function pt(i,n){const[l,e]=vt(!1),{mutate:y}=ut(),{activeQuality:c,selectedQualityHeight:S,startTime:p}=n||{},v=lt(()=>{if(!(!i||!p))return y({broadcastId:i,startTime:p,activeQuality:c,selectedQualityHeight:S})},[y,i,p,c,S]);ht(()=>{e(_=>{if(_===!0)return!0;const u=!!i&&!!n?.startTime&&!!n?.activeQuality;return _===!1&&u===!0&&v(),u})},[i,n?.startTime,n?.activeQuality,v]),M(()=>{v()},l?60*1e3:null)}export{pt as u};
//# sourceMappingURL=useTrackLiveViews-3q1r18Cs.js.map