(function(g){var window=this;'use strict';var jRO=function(l,y){return g.BO(l,y)},S$w=function(l){if(l instanceof g.Cr)return l;
if(typeof l.kq=="function")return l.kq(!1);if(g.CC(l)){let y=0;const k=new g.Cr;k.next=function(){for(;;){if(y>=l.length)return g.Hb;if(y in l)return g.bL(l[y++]);y++}};
return k}throw Error("Not implemented");},nA2=function(l,y,k){if(g.CC(l))g.Fy(l,y,k);
else for(l=S$w(l);;){const {done:z,value:r}=l.next();if(z)break;y.call(k,r,void 0,l)}},eh=function(l){g.ke(l,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^g.T5()).toString(36));
return l},Ah=function(l,y,k){Array.isArray(k)||(k=[String(k)]);
g.e5(l.V,y,k)},FLf=function(l,y){const k=[];
nA2(y,function(z){let r;try{r=g.pW.prototype.jX.call(this,z,!0)}catch(Z){if(Z=="Storage: Invalid value was encountered")return;throw Z;}r===void 0?k.push(z):g.Ya(r)&&k.push(z)},l);
return k},oAR=function(l,y){FLf(l,y).forEach(function(k){g.pW.prototype.remove.call(this,k)},l)},N5e=function(l){if(l.MW){if(l.MW.locationOverrideToken)return{locationOverrideToken:l.MW.locationOverrideToken};
if(l.MW.latitudeE7!=null&&l.MW.longitudeE7!=null)return{latitudeE7:l.MW.latitudeE7,longitudeE7:l.MW.longitudeE7}}return null},sRf=function(l,y){g.ro(l,y)||l.push(y)},$3=function(l){let y=0;
for(const k in l)y++;return y},LL2=function(l){try{return g.aC.JSON.parse(l)}catch(y){}l=String(l);
if(/^\s*$/.test(l)?0:/^[\],:{}\s\u2028\u2029]*$/.test(l.replace(/\\["\\\/bfnrtu]/g,"@").replace(/(?:"[^"\\\n\r\u2028\u2029\x00-\x08\x0a-\x1f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)[\s\u2028\u2029]*(?=:|,|]|}|$)/g,"]").replace(/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,"")))try{return eval("("+l+")")}catch(y){}throw Error("Invalid JSON string: "+l);},Qf=function(l){if(g.aC.JSON)try{return g.aC.JSON.parse(l)}catch(y){}return LL2(l)},vAL=function(l,y,k,z){const r=new g.sX(null);
l&&g.Lf(r,l);y&&g.vc(r,y);k&&g.Hc(r,k);z&&(r.C=z);return r},B5v=function(l,y){return new g.DFQ(l,y)},th=function(l,y){return Object.prototype.hasOwnProperty.call(l,y)},HUp=function(l,y){return l===y},OA=function(l,y){this.C={};
this.Z=[];this.Ds=this.size=0;var k=arguments.length;if(k>1){if(k%2)throw Error("Uneven number of arguments");for(var z=0;z<k;z+=2)this.set(arguments[z],arguments[z+1])}else if(l)if(l instanceof OA)for(k=l.e8(),z=0;z<k.length;z++)this.set(k[z],l.get(k[z]));else for(z in l)this.set(z,l[z])},d_=function(l){if(l.size!=l.Z.length){for(var y=0,k=0;y<l.Z.length;){var z=l.Z[y];
th(l.C,z)&&(l.Z[k++]=z);y++}l.Z.length=k}if(l.size!=l.Z.length){y={};for(z=k=0;k<l.Z.length;){const r=l.Z[k];th(y,r)||(l.Z[z++]=r,y[r]=1);k++}l.Z.length=z}},w_=function(l){this.name=this.id="";
this.clientName="UNKNOWN_INTERFACE";this.app="";this.type="REMOTE_CONTROL";this.ownerObfuscatedGaiaId=this.obfuscatedGaiaId=this.avatar=this.username="";this.capabilities=new Set;this.compatibleSenderThemes=new Set;this.experiments=new Set;this.theme="u";new OA;this.model=this.brand="";this.year=0;this.chipset=this.osVersion=this.os="";this.mdxDialServerType="MDX_DIAL_SERVER_TYPE_UNKNOWN";l&&(this.id=l.id||l.name,this.name=l.name,this.clientName=l.clientName?l.clientName.toUpperCase():"UNKNOWN_INTERFACE",
this.app=l.app,this.type=l.type||"REMOTE_CONTROL",this.username=l.user||"",this.avatar=l.userAvatarUri||"",this.obfuscatedGaiaId=l.obfuscatedGaiaId||"",this.ownerObfuscatedGaiaId=l.ownerObfuscatedGaiaId||"",this.theme=l.theme||"u",R$e(this,l.capabilities||""),DGv(this,l.compatibleSenderThemes||""),lXo(this,l.experiments||""),this.brand=l.brand||"",this.model=l.model||"",this.year=l.year||0,this.os=l.os||"",this.osVersion=l.osVersion||"",this.chipset=l.chipset||"",this.mdxDialServerType=l.mdxDialServerType||
"MDX_DIAL_SERVER_TYPE_UNKNOWN",l=l.deviceInfo)&&(l=JSON.parse(l),this.brand=l.brand||"",this.model=l.model||"",this.year=l.year||0,this.os=l.os||"",this.osVersion=l.osVersion||"",this.chipset=l.chipset||"",this.clientName=l.clientName?l.clientName.toUpperCase():"UNKNOWN_INTERFACE",this.mdxDialServerType=l.mdxDialServerType||"MDX_DIAL_SERVER_TYPE_UNKNOWN")},R$e=function(l,y){l.capabilities.clear();
g.oC(y.split(","),g.IC(jRO,yT2)).forEach(k=>{l.capabilities.add(k)})},DGv=function(l,y){l.compatibleSenderThemes.clear();
g.oC(y.split(","),g.IC(jRO,kWB)).forEach(k=>{l.compatibleSenderThemes.add(k)})},lXo=function(l,y){l.experiments.clear();
y.split(",").forEach(k=>{l.experiments.add(k)})},hh=function(l){l=l||{};
this.name=l.name||"";this.id=l.id||l.screenId||"";this.token=l.token||l.loungeToken||"";this.uuid=l.uuid||l.dialId||"";this.idType=l.screenIdType||"normal";this.secret=l.screenIdSecret||""},GO=function(l,y){return!!y&&(l.id==y||l.uuid==y)},zt2=function(l){return{name:l.name,
screenId:l.id,loungeToken:l.token,dialId:l.uuid,screenIdType:l.idType,screenIdSecret:l.secret}},rTL=function(l){return new hh(l)},ZBL=function(l){return Array.isArray(l)?g.sT(l,rTL):[]},ac=function(l){return l?`{name:"${l.name}",id:${l.id.substr(0,6)}..,token:${l.token?".."+l.token.slice(-6):"-"},uuid:${l.uuid?".."+l.uuid.slice(-6):"-"},idType:${l.idType},secret:${l.secret?".."+l.secret.slice(-6):"-"}}`:"null"},i1=function(l){return Array.isArray(l)?"["+g.sT(l,ac).join(",")+"]":"null"},UA=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,
function(l){const y=Math.random()*16|0;
return(l=="x"?y:y&3|8).toString(16)})},et2=function(l){return g.sT(l,function(y){return{key:y.id,
name:y.name}})},MT=function(l,y){return g.Dg(l,function(k){return k||y?!k!=!y?!1:k.id==y.id:!0})},Xz=function(l,y){return g.Dg(l,function(k){return GO(k,y)})},ATO=function(){const l=g.ZA.X1();
l&&oAR(l,l.My.kq(!0))},cP=function(){const l=g.Ay("yt-remote-connected-devices")||[];
g.b2(l);return l},$i2=function(l){if(l.length==0)return[];
const y=l[0].indexOf("#"),k=y==-1?l[0]:l[0].substring(0,y);return g.sT(l,function(z,r){return r==0?z:z.substring(k.length)})},QVw=function(l){g.eY("yt-remote-connected-devices",l,86400)},b1=function(){if(CI)return CI;
let l=g.Ay("yt-remote-device-id");l||(l=UA(),g.eY("yt-remote-device-id",l,31536E3));const y=cP();let k=1,z=l;for(;g.ro(y,z);)k++,z=l+"#"+k;return CI=z},u1=function(){let l=cP();
const y=b1();g.QE()&&g.KR(l,y);l=$i2(l);if(l.length==0)try{g.AD("remote_sid")}catch(k){}else try{g.ZY("remote_sid",l.join(","),-1)}catch(k){}},tOO=function(){return g.Ay("yt-remote-session-browser-channel")},OB1=function(){return g.Ay("yt-remote-local-screens")||[]},dif=function(){g.eY("yt-remote-lounge-token-expiration",!0,86400)},wQo=function(l){l.length>5&&(l=l.slice(l.length-5));
const y=g.sT(OB1(),function(z){return z.loungeToken}),k=g.sT(l,function(z){return z.loungeToken});
g.He(k,function(z){return!g.ro(y,z)})&&dif();
g.eY("yt-remote-local-screens",l,31536E3)},x3=function(l){l||(g.$F("yt-remote-session-screen-id"),g.$F("yt-remote-session-video-id"));
u1();l=cP();g.Ap(l,b1());QVw(l)},htp=function(){if(!my){const l=g.nW();
l&&(my=new g.IS(l))}},GWx=function(){htp();
return my?!!my.get("yt-remote-use-staging-server"):!1},qT=function(l,y){g.HS[l]=!0;
const k=g.vS();k&&k.publish.apply(k,arguments);g.HS[l]=!1},WP=function(){let l=window.navigator.userAgent.match(/Chrome\/([0-9]+)/);
return l?parseInt(l[1],10):0},aXe=function(l){return!!document.currentScript&&(document.currentScript.src.indexOf("?"+l)!=-1||document.currentScript.src.indexOf("&"+l)!=-1)},iBv=function(){return typeof window.__onGCastApiAvailable=="function"?window.__onGCastApiAvailable:null},Ic=function(l){l.length?Uiy(l.shift(),function(){Ic(l)}):TO()},TO=function(){let l=iBv();
l&&l(!1,"No cast extension found")},Uiy=function(l,y,k){let z=document.createElement("script");
z.onerror=y;k&&(z.onload=k);g.$v(z,g.zp(l));(document.head||document.documentElement).appendChild(z)},MOR=function(l){return"chrome-extension://"+l+"/cast_sender.js"},XQ2=function(){const l=WP(),y=[];
if(l>1){const k=l-1;y.push("//www.gstatic.com/eureka/clank/"+l+"/cast_sender.js");y.push("//www.gstatic.com/eureka/clank/"+k+"/cast_sender.js")}return y},Vf=function(){if(cT2){var l=2,y=iBv(),k=function(){l--;
l==0&&y&&y(!0)};
window.__onGCastApiAvailable=k;Uiy("//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js",TO,k)}},CAx=function(){Vf();
let l=XQ2();l.push("//www.gstatic.com/eureka/clank/cast_sender.js");Ic(l)},u9f=function(){Vf();
let l=XQ2();l.push(...bB2.map(MOR));l.push("//www.gstatic.com/eureka/clank/cast_sender.js");Ic(l)},PP=function(l,y,k){g.zP.call(this);
this.S=k!=null?(0,g.We)(l,k):l;this.h6=y;this.J=(0,g.We)(this.dl,this);this.Z=!1;this.C=0;this.N=this.Aj=null;this.V=[]},Jh=function(){this.Z=g.T5()},xi1=function(){Y3||(Y3=new Jh)},miB=function(){Y3||(Y3=new Jh)},pI=function(){g.$c.call(this,"p")},KI=function(){g.$c.call(this,"o")},g_=function(){return qQL=qQL||new g.Wd},Wg2=function(l){g.$c.call(this,"serverreachability",l)},EA=function(l){const y=g_();
y.dispatchEvent(new Wg2(y,l))},IXB=function(l){g.$c.call(this,"statevent",l)},fI=function(l){const y=g_();
y.dispatchEvent(new IXB(y,l))},T2o=function(l,y,k,z){g.$c.call(this,"timingevent",l);
this.size=y;this.rtt=k;this.retries=z},jh=function(l,y){if(typeof l!=="function")throw Error("Fn must not be null and must be a function");
return g.aC.setTimeout(function(){l()},y)},Sh=function(){},nI=function(l,y,k,z){this.N=l;
this.V=y;this.MW=k;this.hv=z||1;this.Oj=new g.Q8(this);this.gb=45E3;this.RR=null;this.S=!1;this.D=this.Xr=this.A=this.rb=this.b0=this.xz=this.C_=null;this.Y=[];this.Z=null;this.K=0;this.J=this.sj=null;this.kz=-1;this.HG=!1;this.mK=0;this.PG=null;this.T7=this.u0=this.WG=this.Ja=!1;this.C=new VOo},VOo=function(){this.N=null;
this.Z="";this.C=!1},Fz=function(l,y,k){l.rb=1;
l.A=eh(y.clone());l.D=k;l.Ja=!0;PA1(l,null)},PA1=function(l,y){l.b0=Date.now();
oc(l);l.Xr=l.A.clone();Ah(l.Xr,"t",l.hv);l.K=0;const k=l.N.u0;l.C=new VOo;l.Z=JT2(l.N,k?y:null,!l.D);l.mK>0&&(l.PG=new g.iv((0,g.We)(l.Ql,l,l.Z),l.mK));l.Oj.listen(l.Z,"readystatechange",l.zp);y=l.RR?g.r4(l.RR):{};l.D?(l.sj||(l.sj="POST"),y["Content-Type"]="application/x-www-form-urlencoded",l.Z.send(l.Xr,l.sj,l.D,y)):(l.sj="GET",l.Z.send(l.Xr,l.sj,null,y));EA(1)},pQL=function(l){if(!YQL(l))return g.KS(l.Z);
const y=g.gm(l.Z);if(y==="")return"";let k="";const z=y.length,r=g.J9(l.Z)==4;if(!l.C.N){if(typeof TextDecoder==="undefined")return NT(l),sA(l),"";l.C.N=new g.aC.TextDecoder}for(let Z=0;Z<z;Z++)l.C.C=!0,k+=l.C.N.decode(y[Z],{stream:!(r&&Z==z-1)});y.length=0;l.C.Z+=k;l.K=0;return l.C.Z},YQL=function(l){return l.Z?l.sj=="GET"&&l.rb!=2&&l.N.S2:!1},gwf=function(l,y){var k=l.K,z=y.indexOf("\n",k);
if(z==-1)return LI;k=Number(y.substring(k,z));if(isNaN(k))return Kg2;z+=1;if(z+k>y.length)return LI;y=y.slice(z,z+k);l.K=z+k;return y},oc=function(l){l.xz=Date.now()+l.gb;
Ewx(l,l.gb)},Ewx=function(l,y){if(l.C_!=null)throw Error("WatchDog timer not null");
l.C_=jh((0,g.We)(l.kx,l),y)},vP=function(l){l.C_&&(g.aC.clearTimeout(l.C_),l.C_=null)},sA=function(l){l.N.AC()||l.HG||fX2(l.N,l)},NT=function(l){vP(l);
g.yb(l.PG);l.PG=null;l.Oj.removeAll();if(l.Z){const y=l.Z;l.Z=null;y.abort();y.dispose()}},rA=function(l,y){try{var k=l.N;
if(k.cw!=0&&(k.Z==l||BP(k.C,l)))if(!l.u0&&BP(k.C,l)&&k.cw==3){try{var z=k.Xz.Z.parse(y)}catch(t){z=null}if(Array.isArray(z)&&z.length==3){var r=z;if(r[0]==0)a:{if(!k.A){if(k.Z)if(k.Z.b0+3E3<l.b0)HP(k),Rc(k);else break a;DI(k);fI(18)}}else k.q_=r[1],0<k.q_-k.rb&&r[2]<37500&&k.PG&&k.Y==0&&!k.C_&&(k.C_=jh((0,g.We)(k.Tp,k),6E3));if(lV(k.C)<=1&&k.kz){try{k.kz()}catch(t){}k.kz=void 0}}else yn(k,11)}else if((l.u0||k.Z==l)&&HP(k),!g.G0(y))for(r=k.Xz.Z.parse(y),y=0;y<r.length;y++){let t=r[y];const O=t[0];
if(!(O<=k.rb))if(k.rb=O,t=t[1],k.cw==2)if(t[0]=="c"){k.V=t[1];k.MW=t[2];const d=t[3];d!=null&&(k.rU=d);const w=t[5];w!=null&&typeof w==="number"&&w>0&&(k.mK=1.5*w);z=k;const h=l.O4();if(h){const U=g.fS(h,"X-Client-Wire-Protocol");if(U){var Z=z.C;!Z.Z&&(g.ag(U,"spdy")||g.ag(U,"quic")||g.ag(U,"h2"))&&(Z.V=Z.J,Z.Z=new Set,Z.C&&(kx(Z,Z.C),Z.C=null))}if(z.Ja){const u=g.fS(h,"X-HTTP-Session-Id");u&&(z.TJ=u,g.ke(z.RR,z.Ja,u))}}k.cw=3;k.J&&k.J.uu();k.PF&&(k.SN=Date.now()-l.b0);z=k;var e=l;z.jN=jVB(z,z.u0?
z.MW:null,z.g4);if(e.u0){SQ1(z.C,e);var A=e,Q=z.mK;Q&&A.setTimeout(Q);A.C_&&(vP(A),oc(A));z.Z=e}else nwo(z);k.N.length>0&&zm(k)}else t[0]!="stop"&&t[0]!="close"||yn(k,7);else k.cw==3&&(t[0]=="stop"||t[0]=="close"?t[0]=="stop"?yn(k,7):k.disconnect():t[0]!="noop"&&k.J&&k.J.Lq(t),k.Y=0)}EA(4)}catch(t){}},Fgx=function(l){this.J=l||10;
g.aC.PerformanceNavigationTiming?(l=g.aC.performance.getEntriesByType("navigation"),l=l.length>0&&(l[0].nextHopProtocol=="hq"||l[0].nextHopProtocol=="h2")):l=!!(g.aC.chrome&&g.aC.chrome.loadTimes&&g.aC.chrome.loadTimes()&&g.aC.chrome.loadTimes().wasFetchedViaSpdy);this.V=l?this.J:1;this.Z=null;this.V>1&&(this.Z=new Set);this.C=null;this.N=[]},owL=function(l){return l.C?!0:l.Z?l.Z.size>=l.V:!1},lV=function(l){return l.C?1:l.Z?l.Z.size:0},BP=function(l,y){return l.C?l.C==y:l.Z?l.Z.has(y):!1},kx=function(l,
y){l.Z?l.Z.add(y):l.C=y},SQ1=function(l,y){l.C&&l.C==y?l.C=null:l.Z&&l.Z.has(y)&&l.Z.delete(y)},ZR=function(l){if(l.C!=null)return l.N.concat(l.C.Y);
if(l.Z!=null&&l.Z.size!==0){let y=l.N;for(const k of l.Z.values())y=y.concat(k.Y);return y}return g.tp(l.N)},N2v=function(l,y){const k=new Sh;
if(g.aC.Image){const z=new Image;z.onload=g.IC(et,k,"TestLoadImage: loaded",!0,y,z);z.onerror=g.IC(et,k,"TestLoadImage: error",!1,y,z);z.onabort=g.IC(et,k,"TestLoadImage: abort",!1,y,z);z.ontimeout=g.IC(et,k,"TestLoadImage: timeout",!1,y,z);g.aC.setTimeout(function(){if(z.ontimeout)z.ontimeout()},1E4);
z.src=l}else y(!1)},sVO=function(l,y){const k=new Sh,z=new AbortController,r=setTimeout(()=>{z.abort();
et(k,"TestPingServer: timeout",!1,y)},1E4);
fetch(l,{signal:z.signal}).then(Z=>{clearTimeout(r);Z.ok?et(k,"TestPingServer: ok",!0,y):et(k,"TestPingServer: server error",!1,y)}).catch(()=>{clearTimeout(r);
et(k,"TestPingServer: error",!1,y)})},et=function(l,y,k,z,r){try{r&&(r.onload=null,r.onerror=null,r.onabort=null,r.ontimeout=null),z(k)}catch(Z){}},Lgy=function(){this.Z=new Ad},$x=function(l,y,k){return k&&k.UN?k.UN[l]||y:y},vw1=function(l){this.N=[];
this.MW=this.jN=this.RR=this.g4=this.Z=this.TJ=this.Ja=this.HG=this.K=this.WG=this.D=null;this.Cp=this.Xr=0;this.Cf=$x("failFast",!1,l);this.PG=this.C_=this.A=this.S=this.J=null;this.R7=!0;this.q_=this.rb=-1;this.hv=this.Y=this.b0=0;this.wY=$x("baseRetryDelayMs",5E3,l);this.va=$x("retryDelaySeedMs",1E4,l);this.O1=$x("forwardChannelMaxRetries",2,l);this.hj=$x("forwardChannelRequestTimeoutMs",2E4,l);this.vn=l&&l.jpa||void 0;this.zA=l&&l.nwb||void 0;this.S2=l&&l.llb||!1;this.mK=void 0;this.u0=l&&l.PX||
!1;this.V="";this.C=new Fgx(l&&l.Zp_);this.BF=Math.min(l&&l.L$z||1E3,1E3);this.Xz=new Lgy;this.Oj=l&&l.gd_||!1;this.xz=l&&l.R8R||!1;this.Oj&&this.xz&&(this.xz=!1);this.Fg=l&&l.kM$||!1;l&&l.mxj&&(this.R7=!1);this.PF=!this.Oj&&this.R7&&l&&l.rsj||!1;this.OA=void 0;l&&l.cQ&&l.cQ>0&&(this.OA=l.cQ);this.kz=void 0;this.SN=0;this.gb=!1;this.T7=this.sj=null},Rc=function(l){l.Z&&(Qn(l),l.Z.cancel(),l.Z=null)},B2L=function(l){Rc(l);
l.A&&(g.aC.clearTimeout(l.A),l.A=null);HP(l);l.C.cancel();l.S&&(typeof l.S==="number"&&g.aC.clearTimeout(l.S),l.S=null)},zm=function(l){owL(l.C)||l.S||(l.S=!0,g.o4(l.R0,l),l.b0=0)},Rtw=function(l,y){if(lV(l.C)>=l.C.V-(l.S?1:0))return!1;
if(l.S)return l.N=y.Y.concat(l.N),!0;if(l.cw==1||l.cw==2||l.b0>=(l.Cf?0:l.O1))return!1;l.S=jh((0,g.We)(l.R0,l,y),HBy(l,l.b0));l.b0++;return!0},lLw=function(l,y){var k;
y?k=y.MW:k=l.Xr++;const z=l.RR.clone();g.ke(z,"SID",l.V);g.ke(z,"RID",k);g.ke(z,"AID",l.rb);td(l,z);l.K&&l.D&&g.$e(z,l.K,l.D);k=new nI(l,l.V,k,l.b0+1);l.K===null&&(k.RR=l.D);y&&(l.N=y.Y.concat(l.N));y=Di2(l,k,l.BF);k.setTimeout(Math.round(l.hj*.5)+Math.round(l.hj*.5*Math.random()));kx(l.C,k);Fz(k,z,y)},td=function(l,y){l.HG&&g.fR(l.HG,function(k,z){g.ke(y,z,k)});
l.J&&g.fR({},function(k,z){g.ke(y,z,k)})},Di2=function(l,y,k){k=Math.min(l.N.length,k);
const z=l.J?(0,g.We)(l.J.t5,l.J,l):null;a:{var r=l.N;let A=-1;for(;;){const Q=["count="+k];A==-1?k>0?(A=r[0].Z,Q.push("ofs="+A)):A=0:Q.push("ofs="+A);let t=!0;for(let O=0;O<k;O++){var Z=r[O].Z;const d=r[O].map;Z-=A;if(Z<0)A=Math.max(0,r[O].Z-100),t=!1;else try{Z="req"+Z+"_"||"";try{var e=d instanceof Map?d:Object.entries(d);for(const [w,h]of e){let U=h;g.uQ(h)&&(U=g.cU(h));Q.push(Z+w+"="+encodeURIComponent(U))}}catch(w){throw Q.push(Z+"type="+encodeURIComponent("_badmap")),w;}}catch(w){z&&z(d)}}if(t){e=
Q.join("&");break a}}e=void 0}l=l.N.splice(0,k);y.Y=l;return e},nwo=function(l){l.Z||l.A||(l.hv=1,g.o4(l.HR,l),l.Y=0)},DI=function(l){if(l.Z||l.A||l.Y>=3)return!1;
l.hv++;l.A=jh((0,g.We)(l.HR,l),HBy(l,l.Y));l.Y++;return!0},Qn=function(l){l.sj!=null&&(g.aC.clearTimeout(l.sj),l.sj=null)},yMv=function(l){l.Z=new nI(l,l.V,"rpc",l.hv);
l.K===null&&(l.Z.RR=l.D);l.Z.mK=0;var y=l.jN.clone();g.ke(y,"RID","rpc");g.ke(y,"SID",l.V);g.ke(y,"AID",l.rb);g.ke(y,"CI",l.PG?"0":"1");!l.PG&&l.OA&&g.ke(y,"TO",l.OA);g.ke(y,"TYPE","xmlhttp");td(l,y);l.K&&l.D&&g.$e(y,l.K,l.D);l.mK&&l.Z.setTimeout(l.mK);var k=l.Z;l=l.MW;k.rb=1;k.A=eh(y.clone());k.D=null;k.Ja=!0;PA1(k,l)},HP=function(l){l.C_!=null&&(g.aC.clearTimeout(l.C_),l.C_=null)},fX2=function(l,y){var k=null;
if(l.Z==y){HP(l);Qn(l);l.Z=null;var z=2}else if(BP(l.C,y))k=y.Y,SQ1(l.C,y),z=1;else return;if(l.cw!=0)if(y.S)if(z==1){k=y.D?y.D.length:0;y=Date.now()-y.b0;var r=l.b0;z=g_();z.dispatchEvent(new T2o(z,k,y,r));zm(l)}else nwo(l);else{var Z=y.kz;r=y.getLastError();if(r==3||r==0&&Z>0||!(z==1&&Rtw(l,y)||z==2&&DI(l)))switch(k&&k.length>0&&(y=l.C,y.N=y.N.concat(k)),r){case 1:yn(l,5);break;case 4:yn(l,10);break;case 3:yn(l,6);break;default:yn(l,2)}}},HBy=function(l,y){let k=l.wY+Math.floor(Math.random()*l.va);
l.isActive()||(k*=2);return k*y},yn=function(l,y){if(y==2){var k=(0,g.We)(l.EY,l),z=l.zA;
const r=!z;z=new g.sX(z||"//www.google.com/images/cleardot.gif");g.aC.location&&g.aC.location.protocol=="http"||g.Lf(z,"https");eh(z);r?N2v(z.toString(),k):sVO(z.toString(),k)}else fI(2);l.cw=0;l.J&&l.J.UM(y);kq1(l);B2L(l)},kq1=function(l){l.cw=0;
l.T7=[];if(l.J){const y=ZR(l.C);if(y.length!=0||l.N.length!=0)g.Gx(l.T7,y),g.Gx(l.T7,l.N),l.C.N.length=0,g.tp(l.N),l.N.length=0;l.J.vR()}},zUw=function(l){if(l.cw==0)return l.T7;
let y=[];g.Gx(y,ZR(l.C));g.Gx(y,l.N);return y},jVB=function(l,y,k){var z=g.Ie(k);
z.Z!=""?(y&&g.vc(z,y+"."+z.Z),g.Hc(z,z.N)):(z=g.aC.location,z=vAL(z.protocol,y?y+"."+z.hostname:z.hostname,+z.port,k));y=l.Ja;k=l.TJ;y&&k&&g.ke(z,y,k);g.ke(z,"VER",l.rU);td(l,z);return z},JT2=function(l,y,k){if(y&&!l.u0)throw Error("Can't create secondary domain capable XhrIo object.");
y=l.S2&&!l.vn?new g.qm(new g.So({r3:k})):new g.qm(l.vn);y.K=l.u0;return y},rMB=function(){},Z6L=function(){},dA=function(l,y){g.Wd.call(this);
this.Z=new vw1(y);this.S=l;this.C=y&&y.Nr||null;l=y&&y.sO||null;y&&y.h8$&&(l?l["X-Client-Protocol"]="webchannel":l={"X-Client-Protocol":"webchannel"});this.Z.D=l;l=y&&y.ZEr||null;y&&y.QH&&(l?l["X-WebChannel-Content-Type"]=y.QH:l={"X-WebChannel-Content-Type":y.QH});y&&y.BH&&(l?l["X-WebChannel-Client-Profile"]=y.BH:l={"X-WebChannel-Client-Profile":y.BH});this.Z.WG=l;(l=y&&y.cCK)&&!g.G0(l)&&(this.Z.K=l);this.K=y&&y.PX||!1;this.J=y&&y.spe||!1;(y=y&&y.oP)&&!g.G0(y)&&(this.Z.Ja=y,g.vO(this.C,y)&&(l=this.C,
y in l&&delete l[y]));this.N=new Od(this)},eUf=function(l){pI.call(this);
l.__headers__&&(this.headers=l.__headers__,this.statusCode=l.__status__,delete l.__headers__,delete l.__status__);const y=l.__sm__;y?this.data=(this.Z=g.oe(y))?g.ko(y,this.Z):y:this.data=l},AM2=function(l){KI.call(this);
this.status=1;this.errorCode=l},Od=function(l){this.Z=l},wA=function(l,y){this.V=l;
this.Z=y},hd=function(l,y){if(typeof l!=="function")throw Error("Fn must not be null and must be a function");
return g.aC.setTimeout(function(){l()},y)},aP=function(){Gm.dispatchEvent(new $0x)},iV=function(l,y,k,z){this.Z=l;
this.V=y;this.K=k;this.S=z||1;this.C=45E3;this.N=new g.Q8(this);this.J=new g.rm;this.J.setInterval(250)},tK1=function(l,y,k){l.VP=1;
l.hI=eh(y.clone());l.V2=k;l.Ja=!0;Q4o(l,null)},Ud=function(l,y,k,z,r){l.VP=1;
l.hI=eh(y.clone());l.V2=null;l.Ja=k;r&&(l.lJ=!1);Q4o(l,z)},Q4o=function(l,y){l.bl=Date.now();
MY(l);l.sz=l.hI.clone();Ah(l.sz,"t",l.S);l.qM=0;l.aF=l.Z.AT(l.Z.MO()?y:null);l.BM>0&&(l.MM=new g.iv((0,g.We)(l.PR,l,l.aF),l.BM));l.N.listen(l.aF,"readystatechange",l.Dw);y=l.NI?g.r4(l.NI):{};l.V2?(l.J1="POST",y["Content-Type"]="application/x-www-form-urlencoded",l.aF.send(l.sz,l.J1,l.V2,y)):(l.J1="GET",l.lJ&&!g.tV&&(y.Connection="close"),l.aF.send(l.sz,l.J1,null,y));l.Z.Y_(1)},d0x=function(l,y){var k=l.qM,z=y.indexOf("\n",k);
if(z==-1)return Xq;k=Number(y.substring(k,z));if(isNaN(k))return O62;z+=1;if(z+k>y.length)return Xq;y=y.slice(z,z+k);l.qM=z+k;return y},MY=function(l){l.yL=Date.now()+l.C;
wdB(l,l.C)},wdB=function(l,y){if(l.B6!=null)throw Error("WatchDog timer not null");
l.B6=hd((0,g.We)(l.Wp,l),y)},hUR=function(l){l.B6&&(g.aC.clearTimeout(l.B6),l.B6=null)},c8=function(l){l.Z.AC()||l.Zz||l.Z.x5(l)},CH=function(l){hUR(l);
g.yb(l.MM);l.MM=null;l.J.stop();l.N.removeAll();if(l.aF){const y=l.aF;l.aF=null;y.abort();y.dispose()}l.xp&&(l.xp=null)},Gq1=function(l,y){try{l.Z.I0(l,y),l.Z.Y_(4)}catch(k){}},i6w=function(l,y,k,z,r){if(z==0)k(!1);
else{var Z=r||0;z--;aLv(l,y,function(e){e?k(!0):g.aC.setTimeout(function(){i6w(l,y,k,z,Z)},Z)})}},aLv=function(l,y,k){const z=new Image;
z.onload=function(){try{bV(z),k(!0)}catch(r){}};
z.onerror=function(){try{bV(z),k(!1)}catch(r){}};
z.onabort=function(){try{bV(z),k(!1)}catch(r){}};
z.ontimeout=function(){try{bV(z),k(!1)}catch(r){}};
g.aC.setTimeout(function(){if(z.ontimeout)z.ontimeout()},y);
z.src=l},bV=function(l){l.onload=null;
l.onerror=null;l.onabort=null;l.ontimeout=null},U0O=function(l){this.Z=l;
this.C=new Ad},MKL=function(l){const y=uV(l.Z,l.XQ,"/mail/images/cleardot.gif");
eh(y);i6w(y.toString(),5E3,(0,g.We)(l.UZ,l),3,2E3);l.Y_(1)},mz=function(l){var y=l.Z.S;
y!=null?(aP(),y?(aP(),xx(l.Z,l,!1)):(aP(),xx(l.Z,l,!0))):(l.cZ=new iV(l),l.cZ.NI=l.wv,y=l.Z,y=uV(y,y.MO()?l.ov:null,l.fb),aP(),Ah(y,"TYPE","xmlhttp"),Ud(l.cZ,y,!1,l.ov,!1))},qY=function(l,y,k){this.Z=1;
this.C=[];this.N=[];this.J=new Ad;this.D=l||null;this.S=y!=null?y:null;this.A=k||!1},Xd2=function(l,y){this.Z=l;
this.map=y;this.context=null},cMB=function(l,y,k,z){g.$c.call(this,"timingevent",l);
this.size=y;this.rtt=k;this.retries=z},CDo=function(l){g.$c.call(this,"serverreachability",l)},b6O=function(l){l.Yx(1,0);
l.QP=uV(l,null,l.Fh);W8(l)},uSR=function(l){l.sT&&(l.sT.abort(),l.sT=null);
l.zJ&&(l.zJ.cancel(),l.zJ=null);l.b4&&(g.aC.clearTimeout(l.b4),l.b4=null);IP(l);l.Uv&&(l.Uv.cancel(),l.Uv=null);l.Oe&&(g.aC.clearTimeout(l.Oe),l.Oe=null)},Tm=function(l,y){if(l.Z==0)throw Error("Invalid operation: sending map when state is closed");
l.C.push(new Xd2(l.cN++,y));l.Z!=2&&l.Z!=3||W8(l)},x0e=function(l){let y=0;
l.zJ&&y++;l.Uv&&y++;return y},W8=function(l){l.Uv||l.Oe||(l.Oe=hd((0,g.We)(l.gU,l),0),l.AU=0)},qi2=function(l,y){if(l.Z==1){if(!y){l.NO=Math.floor(Math.random()*1E5);
y=l.NO++;const k=new iV(l,"",y);k.NI=l.G$;const z=Vn(l),r=l.QP.clone();g.ke(r,"RID",y);g.ke(r,"CVER","1");P8(l,r);tK1(k,r,z);l.Uv=k;l.Z=2}}else l.Z==3&&(y?m01(l,y):l.C.length==0||l.Uv||m01(l))},m01=function(l,y){if(y)if(l.Jc>6){l.C=l.N.concat(l.C);
l.N.length=0;var k=l.NO-1;y=Vn(l)}else k=y.K,y=y.V2;else k=l.NO++,y=Vn(l);const z=l.QP.clone();g.ke(z,"SID",l.V);g.ke(z,"RID",k);g.ke(z,"AID",l.w8);P8(l,z);k=new iV(l,l.V,k,l.AU+1);k.NI=l.G$;k.setTimeout(1E4+Math.round(1E4*Math.random()));l.Uv=k;tK1(k,z,y)},P8=function(l,y){l.Zd&&(l=l.Zd.At())&&g.fR(l,function(k,z){g.ke(y,z,k)})},Vn=function(l){const y=Math.min(l.C.length,1E3),k=["count="+y];
let z;l.Jc>6&&y>0?(z=l.C[0].Z,k.push("ofs="+z)):z=0;for(let r=0;r<y;r++){let Z=l.C[r].Z;const e=l.C[r].map;Z=l.Jc<=6?r:Z-z;try{g.fR(e,function(A,Q){k.push("req"+Z+"_"+Q+"="+encodeURIComponent(A))})}catch(A){k.push("req"+Z+"_type="+encodeURIComponent("_badmap"))}}l.N=l.N.concat(l.C.splice(0,y));
return k.join("&")},WO1=function(l){l.zJ||l.b4||(l.K=1,l.b4=hd((0,g.We)(l.EM,l),0),l.yF=0)},Jd=function(l){if(l.zJ||l.b4||l.yF>=3)return!1;
l.K++;l.b4=hd((0,g.We)(l.EM,l),ILR(l,l.yF));l.yF++;return!0},xx=function(l,y,k){l.Wk=l.S==null?k:!l.S;
l.F6=y.er;l.A||b6O(l)},IP=function(l){l.qI!=null&&(g.aC.clearTimeout(l.qI),l.qI=null)},ILR=function(l,y){let k=5E3+Math.floor(Math.random()*1E4);
l.isActive()||(k*=2);return k*y},Yx=function(l,y){if(y==2||y==9){var k=null;
l.Zd&&(k=null);var z=(0,g.We)(l.XY,l);k||(k=new g.sX("//www.google.com/images/cleardot.gif"),eh(k));aLv(k.toString(),1E4,z)}else aP();TsR(l,y)},TsR=function(l,y){l.Z=0;
l.Zd&&l.Zd.Kq(y);VKo(l);uSR(l)},VKo=function(l){l.Z=0;
l.F6=-1;if(l.Zd)if(l.N.length==0&&l.C.length==0)l.Zd.O9();else{const y=g.tp(l.N),k=g.tp(l.C);l.N.length=0;l.C.length=0;l.Zd.O9(y,k)}},uV=function(l,y,k){let z=g.Ie(k);
if(z.Z!="")y&&g.vc(z,y+"."+z.Z),g.Hc(z,z.N);else{const r=window.location;z=vAL(r.protocol,y?y+"."+r.hostname:r.hostname,+r.port,k)}l.sy&&g.fR(l.sy,function(r,Z){g.ke(z,Z,r)});
g.ke(z,"VER",l.Jc);P8(l,z);return z},PDR=function(){},JM2=function(){this.Z=[];
this.C=[]},YiL=function(l,y){this.action=l;
this.params=y||{}},pH=function(l,y){g.zP.call(this);
this.Z=new g.B_(this.e_,0,this);g.x(this,this.Z);this.h6=5E3;this.retryCount=this.fm=0;if(typeof l==="function")y&&(l=(0,g.We)(l,y));else if(l&&typeof l.handleEvent==="function")l=(0,g.We)(l.handleEvent,l);else throw Error("Invalid listener argument");this.C=l},KH=function(l,y,k=!1,z=()=>"",r=!1,Z=!1,e=!1,A=()=>g.SK({}),Q=!1,t,O){this.u0=l;
this.b0=y;this.K=new g.W9;this.S=O;this.C=(this.N=!!t)?t(()=>{this.Mk()}):new pH(this.Mk,this);
this.Z=null;this.D=!1;this.Y=null;this.Ja="";this.sj=this.C_=0;this.V=[];this.kz=k;this.RR=z;this.A=Z;this.rb=A;this.WG=e;this.HG=null;this.J=g.SK();this.T7=r;this.Oj=Q;this.gb=new pdy;this.PG=new KOO;this.xz=new gcR;this.mK=new Ec1;this.Xr=new fL1;this.hv=new j4O;this.MW=new Siw},ncL=function(l,y,k,z,r){gA(l);
if(l.Z){const Z=g.Y("ID_TOKEN"),e=l.Z.G$||{};Z?e["x-youtube-identity-token"]=Z:delete e["x-youtube-identity-token"];l.Z.G$=e}z?(z.getState()!=3&&x0e(z)==0||z.getState(),l.Z.connect(y,k,l.b0,z.V,z.w8)):r?l.Z.connect(y,k,l.b0,r.sessionId,r.arrayId):l.Z.connect(y,k,l.b0);l.N&&!l.C.isActive()&&l.C.start();l.S&&l.S.ger()},ocf=function(l,y){return l.Oj?!Object.values(FOR).includes(y):!1},Nsx=async function(l){try{await Ed(l)}finally{var y=l.V;
l.V=[];var k=y;y=y.length;for(let z=0;z<y;++z)Tm(l.Z,k[z]);fH(l);fH(l)}},fH=function(l){l.publish("handlerOpened");
l.gb.Z("BROWSER_CHANNEL")},gA=function(l){if(l.Z){const y=l.RR(),k=l.Z.G$||{};
y?k["x-youtube-lounge-xsrf-token"]=y:delete k["x-youtube-lounge-xsrf-token"];l.Z.G$=k}},Ed=function(l){if(!l.WG)return s4R(l);
l.HG===null&&(l.HG=s4R(l));return l.HG},s4R=function(l){return g.vd(l.rb().then(y=>{if(l.Z){let k=l.Z.G$||{};
y&&Object.keys(y).length>0?k={...k,...y}:delete k.Authorization;l.Z.G$=k}}).Ya(()=>{}),()=>{l.HG=null})},jt=function(l){this.scheme="https";
this.port=this.domain="";this.Z="/api/lounge";this.C=!0;l=l||document.location.href;const y=Number(g.ee(l)[4]||null)||"";y&&(this.port=":"+y);this.domain=g.$7(l)||"";l=g.Xv();l.search("MSIE")>=0&&(l=l.match(/MSIE ([\d.]+)/)[1],g.Mg(l,"10.0")<0&&(this.C=!1))},St=function(l,y){let k=l.Z;
l.C&&(k=l.scheme+"://"+l.domain+l.port+l.Z);return g.UI(k+y,{})},LOf=function(l){g.iD(l.channel,"m",()=>{l.S=3;
l.N.reset();l.A=null;l.K=0;for(const y of l.Y)l.channel&&l.channel.send(y);l.Y=[];l.publish("webChannelOpened");l.RR.Z("WEB_CHANNEL")});
g.iD(l.channel,"n",()=>{l.S=0;l.N.isActive()||l.publish("webChannelClosed");const y=l.channel?.V().N();y&&(l.Y=[...y]);l.sj.Z("WEB_CHANNEL")});
g.iD(l.channel,"p",y=>{const k=y.data;k[0]==="gracefulReconnect"?(l.N.start(),l.channel&&l.channel.close()):l.publish("webChannelMessage",new YiL(k[0],k[1]));l.I9=y.statusCode;l.HG.Z("WEB_CHANNEL")});
g.iD(l.channel,"o",()=>{l.I9===401||l.N.start();l.publish("webChannelError");l.Ja.Z("WEB_CHANNEL","")})},nH=function(l){const y=l.b0();
y?l.V["x-youtube-lounge-xsrf-token"]=y:delete l.V["x-youtube-lounge-xsrf-token"]},RUp=function(l,y,k=()=>"",z,r){const Z=()=>new KH(St(l,"/bc"),y,!1,k,z);
return g.EJ("enable_mdx_web_channel_desktop")?new vcv(()=>new BsR(St(l,"/wc"),y,k)):new H6R(Z,r)},k8R=function(){var l=D0o;
lZp();Fq.push(l);y9R()},oP=function(l,y){lZp();
const k=z4y(l,String(y));Fq.length==0?r9v(k):(y9R(),g.Fy(Fq,function(z){z(k)}))},NY=function(l){oP("CP",l)},lZp=function(){Fq||(Fq=g.UT("yt.mdx.remote.debug.handlers_")||[],g.iQ("yt.mdx.remote.debug.handlers_",Fq))},r9v=function(l){const y=(sd+1)%50;
sd=y;LH[y]=l;v8||(v8=y==49)},y9R=function(){var l=Fq;
if(LH[0]){var y=v8?sd:-1;do{y=(y+1)%50;const k=LH[y];g.Fy(l,function(z){z(k)})}while(y!=sd);
LH=Array(50);sd=-1;v8=!1}},z4y=function(l,y){let k=(Date.now()-ZSx)/1E3;
k.toFixed&&(k=k.toFixed(3));const z=[];z.push("[",k+"s","] ");z.push("[","yt.mdx.remote","] ");z.push(l+": "+y,"\n");return z.join("")},B8=function(l){g.z1.call(this);
this.S=l;this.screens=[]},e4y=function(l,y){const k=l.get(y.uuid)||l.get(y.id);
if(k)return l=k.name,k.id=y.id||k.id,k.name=y.name,k.token=y.token,k.uuid=y.uuid||k.uuid,k.name!=l;l.screens.push(y);return!0},A9v=function(l,y){let k=l.screens.length!=y.length;
l.screens=g.oC(l.screens,function(r){return!!MT(y,r)});
const z=y.length;for(let r=0;r<z;r++)k=e4y(l,y[r])||k;return k},$mB=function(l,y){const k=l.screens.length;
l.screens=g.oC(l.screens,function(z){return!(z||y?!z!=!y?0:z.id==y.id:1)});
return l.screens.length<k},RP=function(l){B8.call(this,"LocalScreenService");
this.C=l;this.Z=NaN;H8(this);this.info("Initializing with "+i1(this.screens))},Q72=function(l){if(l.screens.length){const y=g.sT(l.screens,function(z){return z.id}),k=St(l.C,"/pairing/get_lounge_token_batch");
l.C.sendRequest("POST",k,{screen_ids:y.join(",")},(0,g.We)(l.ZC,l),(0,g.We)(l.hq,l))}},H8=function(l){if(g.EJ("deprecate_pair_servlet_enabled"))return A9v(l,[]);
var y=ZBL(OB1());y=g.oC(y,function(k){return!k.uuid});
return A9v(l,y)},DR=function(l,y){wQo(g.sT(l.screens,zt2));
y&&dif()},lK=function(l){oP("OnlineScreenService",l)},yg=function(l){isNaN(l.N)||g.pl(l.N);
l.N=g.JK((0,g.We)(l.K,l),l.V>0&&l.V<g.T5()?2E4:1E4)},kB=function(l,y){a:if($3(y)!=$3(l.Z))var k=!1;
else{k=g.LR(y);var z=k.length;for(let r=0;r<z;++r)if(!l.Z[k[r]]){k=!1;break a}k=!0}k||(lK("Updated online screens: "+g.cU(l.Z)),l.Z=y,l.publish("screenChange"));t9w(l)},zt=function(l,y,k){const z=St(l.J,"/pairing/get_screen_availability");
l.J.sendRequest("POST",z,{lounge_token:y.token},(0,g.We)(function(r){r=r.screens||[];const Z=r.length;for(let e=0;e<Z;++e)if(r[e].loungeToken==y.token){k(r[e].status=="online");return}k(!1)},l),(0,g.We)(function(){k(!1)},l))},t9w=function(l){l=g.LR(g.jf(l.Z,function(y){return y}));
g.b2(l);l.length?g.eY("yt-remote-online-screen-ids",l.join(","),60):g.$F("yt-remote-online-screen-ids")},OSy=function(l){const y={};
g.Fy(l.S(),function(k){k.token?y[k.token]=k.id:this.JC("Requesting availability of screen w/o lounge token.")});
return y},rI=function(l,y=!1){B8.call(this,"ScreenService");
this.V=l;this.K=y;this.Z=this.C=null;this.N=[];this.J={};dmw(this)},h4L=function(l,y,k,z,r,Z){l.info("getAutomaticScreenByIds "+k+" / "+y);
k||(k=l.J[y]);const e=l.QG();let A=k?Xz(e,k):null;k&&(l.K||A)||(A=Xz(e,y));if(A){A.uuid=y;const Q=Zt(l,A);zt(l.Z,Q,function(t){r(t?Q:null)})}else k?wU1(l,k,(0,g.We)(function(Q){const t=Zt(this,new hh({name:z,
screenId:k,loungeToken:Q,dialId:y||""}));zt(this.Z,t,function(O){r(O?t:null)})},l),Z):r(null)},G8w=function(l,y){const k=l.screens.length;
for(let z=0;z<k;++z)if(l.screens[z].name==y)return l.screens[z];return null},aZ2=function(l,y,k){zt(l.Z,y,k)},wU1=function(l,y,k,z){l.info("requestLoungeToken_ for "+y);
const r={postParams:{screen_ids:y},method:"POST",context:l,onSuccess:function(Z,e){Z=e&&e.screens||[];Z[0]&&Z[0].screenId==y?k(Z[0].loungeToken):z(Error("Missing lounge token in token response"))},
onError:function(){z(Error("Request screen lounge token failed"))}};
g.o3(St(l.V,"/pairing/get_lounge_token_batch"),r)},iSp=function(l){l.screens=l.C.QG();
var y=l.J;const k={};for(var z in y)k[y[z]]=z;y=l.screens.length;for(z=0;z<y;++z){const r=l.screens[z];r.uuid=k[r.id]||""}l.info("Updated manual screens: "+i1(l.screens))},dmw=function(l){eH(l);
l.C=new RP(l.V);l.C.subscribe("screenChange",(0,g.We)(l.sN,l));iSp(l);l.K||(l.N=ZBL(g.Ay("yt-remote-automatic-screen-cache")||[]));eH(l);l.info("Initializing automatic screens: "+i1(l.N));l.Z=new Um2(l.V,(0,g.We)(l.QG,l,!0));l.Z.subscribe("screenChange",(0,g.We)(function(){this.publish("onlineScreenChange")},l))},Zt=function(l,y){var k=l.get(y.id);
k?(k.uuid=y.uuid,y=k):((k=Xz(l.N,y.uuid))?(k.id=y.id,k.token=y.token,y=k):l.N.push(y),l.K||M9x(l));eH(l);l.J[y.uuid]=y.id;g.eY("yt-remote-device-id-map",l.J,31536E3);return y},M9x=function(l){l=g.oC(l.N,y=>y.idType!="shortLived");
g.eY("yt-remote-automatic-screen-cache",g.sT(l,zt2))},eH=function(l){l.J=g.Ay("yt-remote-device-id-map")||{}},Az=function(l,y,k){g.z1.call(this);
this.Ja=k;this.V=l;this.C=y;this.Z=null},$B=function(l,y){l.Z=y;
l.publish("sessionScreen",l.Z)},XUv=function(l,y){l.Z&&(l.Z.token=y,Zt(l.V,l.Z));
l.publish("sessionScreen",l.Z)},Qg=function(l,y){oP(l.Ja,y)},CnR=function(l,y){g.pl(l.C_);
l.C_=0;y?l.config_.enableCastLoungeToken&&y.loungeToken?y.deviceId?l.Z&&l.Z.uuid==y.deviceId||(y.loungeTokenRefreshIntervalMs?c91(l,{name:l.C.friendlyName,screenId:y.screenId,loungeToken:y.loungeToken,dialId:y.deviceId,screenIdType:"shortLived"},y.loungeTokenRefreshIntervalMs):(g.tK(Error(`No loungeTokenRefreshIntervalMs presents in mdxSessionStatusData: ${JSON.stringify(y)}.`)),tz(l,y.screenId))):(g.tK(Error(`No device id presents in mdxSessionStatusData: ${JSON.stringify(y)}.`)),tz(l,y.screenId)):
tz(l,y.screenId):l.O7(Error("Waiting for session status timed out."))},bSv=function(l){g.pl(l.D);
l.D=0;g.pl(l.K);l.K=0;g.pl(l.C_);l.C_=0;g.pl(l.J);l.J=0;g.pl(l.A);l.A=0},uZx=function(l,y){l.info("sendYoutubeMessage_: "+y+" "+g.cU());
const k={};k.type=y;l.N?l.N.sendMessage("urn:x-cast:com.google.youtube.mdx",k,()=>{},(0,g.We)(function(){Qg(this,"Failed to send message: "+y+".")},l)):Qg(l,"Sending yt message without session: "+g.cU(k))},mmf=function(l){uZx(l,"getLoungeToken");
g.pl(l.J);l.J=g.JK(()=>{xm2(l,null)},3E4)},O8=function(l,y){g.pl(l.A);
l.A=0;y==0?mmf(l):l.A=g.JK(()=>{mmf(l)},y)},xm2=function(l,y){g.pl(l.J);
l.J=0;let k=null;y?y.loungeToken?l.Z?.token==y.loungeToken&&(k="staleLoungeToken"):k="missingLoungeToken":k="noLoungeTokenResponse";k?(l.info("Did not receive a new lounge token in onLoungeToken_ with "+`data: ${JSON.stringify(y)}, error: ${k}`),O8(l,3E4)):(XUv(l,y.loungeToken),O8(l,y.loungeTokenRefreshIntervalMs))},tz=function(l,y){y?(l.info("onConnectedScreenId_: Received screenId: "+y),l.Z&&l.Z.id==y||l.HG(y,k=>{$B(l,k)},()=>l.O7(),5)):l.O7(Error("Waiting for session status timed out."))},qWf=
function(l,y,k,z){g.pl(l.K);
l.K=0;aZ2(l.V,y,r=>{r||z<0?k(r):l.K=g.JK(()=>{qWf(l,y,k,z-1)},300)})},c91=function(l,y,k){l.info(`onConnectedScreenData_: Received screenData: ${JSON.stringify(y)}`);
const z=new hh(y);qWf(l,z,r=>{r?(Zt(l.V,z),$B(l,z),O8(l,k)):(g.tK(Error(`CastSession, RemoteScreen from screenData: ${JSON.stringify(y)} is not online.`)),l.O7())},5)},dI=function(l){return new Promise(y=>{l.b0=UA();
if(l.RR){const k=new chrome.cast.DialLaunchResponse(!0,W5B(l));y(k);IZx(l)}else l.Y=()=>{g.pl(l.C_);l.Y=()=>{};
l.C_=NaN;const k=new chrome.cast.DialLaunchResponse(!0,W5B(l));y(k);IZx(l)},l.C_=g.JK(()=>{l.Y()},100)})},Tmo=function(l){g.pl(l.K);
l.K=0;g.pl(l.A);l.A=0;l.J();l.J=()=>{};
g.pl(l.C_)},wI=function(l){return!(!l.config_.enableDialLoungeToken||!l.N?.getDialAppInfo)},hz=function(l,y){l.info(`getDialAppInfoWithTimeout_ ${y}`);
wI(l)&&(g.pl(l.A),l.A=0,y==0?V9p(l):l.A=g.JK(()=>{V9p(l)},y))},IZx=function(l){l.J=l.V.xX(l.b0,l.C.label,l.C.friendlyName,wI(l),(y,k)=>{l.J=()=>{};
$B(l,y);y.idType=="shortLived"&&k>0&&hz(l,k)},y=>{l.J=()=>{};
l.O7(y)})},W5B=function(l){var y={};
y.pairingCode=l.b0;y.theme=l.rb;GWx()&&(y.env_useStageMdx=1);return g.iI(y)},PnB=function(l,y){const k=l.D.receiver.label,z=l.C.friendlyName;
return(new Promise(r=>{h4L(l.V,k,y,z,Z=>{Z&&Z.token&&$B(l,Z);r(Z)},Z=>{Qg(l,"Failed to get DIAL screen: "+Z);
r(null)})})).then(r=>r&&r.token?new chrome.cast.DialLaunchResponse(!1):dI(l))},YWe=function(l,y,k){l.info(`initOnConnectedScreenDataPromise_: Received screenData: ${JSON.stringify(y)}`);
const z=new hh(y);return(new Promise(r=>{J9x(l,z,Z=>{Z?(Zt(l.V,z),$B(l,z),hz(l,k)):g.tK(Error(`DialSession, RemoteScreen from screenData: ${JSON.stringify(y)} is not online.`));r(Z)},5)})).then(r=>r?new chrome.cast.DialLaunchResponse(!1):dI(l))},J9x=function(l,y,k,z){g.pl(l.K);
l.K=0;aZ2(l.V,y,r=>{r||z<0?k(r):l.K=g.JK(()=>{J9x(l,y,k,z-1)},300)})},V9p=function(l){wI(l)&&l.N.getDialAppInfo(y=>{l.info(`getDialAppInfo dialLaunchData: ${JSON.stringify(y)}`);
y=y.extraData||{};let k=null;y.loungeToken?l.Z?.token==y.loungeToken&&(k="staleLoungeToken"):k="missingLoungeToken";k?hz(l,3E4):(XUv(l,y.loungeToken),hz(l,y.loungeTokenRefreshIntervalMs))},y=>{l.info(`getDialAppInfo error: ${y}`);
hz(l,3E4)})},D0o=function(l){window.chrome&&chrome.cast&&chrome.cast.logMessage&&chrome.cast.logMessage(l)},K5f=function(l){const y=l.C.wU();
let k=l.Z&&l.Z.C;l=g.sT(y,function(z){k&&GO(z,k.label)&&(k=null);const r=z.uuid?z.uuid:z.id;let Z=pUL(this,z);Z?(Z.label=r,Z.friendlyName=z.name):(Z=new chrome.cast.Receiver(r,z.name),Z.receiverType=chrome.cast.ReceiverType.CUSTOM);return Z},l);
k&&(k.receiverType!=chrome.cast.ReceiverType.CUSTOM&&(k=new chrome.cast.Receiver(k.label,k.friendlyName),k.receiverType=chrome.cast.ReceiverType.CUSTOM),l.push(k));return l},Gt=function(l){return l.A||!!l.N.length||!!l.Z},ax=function(l){oP("Controller",l)},iK=function(l,y,k){y!=l.Z&&(g.yb(l.Z),(l.Z=y)?(k?l.publish("yt-remote-cast2-receiver-resumed",y.C):l.publish("yt-remote-cast2-receiver-selected",y.C),y.subscribe("sessionScreen",(0,g.We)(l.C_,l,y)),y.subscribe("sessionFailed",()=>gJB(l,y)),y.Z?
l.publish("yt-remote-cast2-session-change",y.Z):k&&l.Z.S(null)):l.publish("yt-remote-cast2-session-change",null))},pUL=function(l,y){return y?g.Dg(l.N,function(k){return GO(y,k.label)},l):null},gJB=function(l,y){l.Z==y&&l.publish("yt-remote-cast2-session-failed")},F5p=function(l,y,k,z){z.disableCastApi?U8("Cannot initialize because disabled by Mdx config."):EJ1()?fZx(y,z)&&(MD(!0),window.chrome&&chrome.cast&&chrome.cast.isAvailable?j7L(l,k):(window.__onGCastApiAvailable=function(r,Z){r?j7L(l,k):(XT("Failed to load cast API: "+
Z),c1(!1),MD(!1),g.$F("yt-remote-cast-available"),g.$F("yt-remote-cast-receiver"),SWw(),k(!1))},z.loadCastApiSetupScript?g.k6(nJp):window.navigator.userAgent.indexOf("Android")>=0&&window.navigator.userAgent.indexOf("Chrome/")>=0&&window.navigator.presentation?WP()>=60&&CAx():!window.chrome||!window.navigator.presentation||window.navigator.userAgent.indexOf("Edge")>=0?TO():WP()>=89?u9f():(Vf(),Ic(bB2.map(MOR))))):U8("Cannot initialize because not running Chrome")},SWw=function(){U8("dispose");
const l=Cn();l&&l.dispose();g.iQ("yt.mdx.remote.cloudview.instance_",null);oJf(!1);g.lP(bK);bK.length=0},uK=function(){return!!g.Ay("yt-remote-cast-installed")},NmR=function(){const l=g.Ay("yt-remote-cast-receiver");
return l?l.friendlyName:null},s7o=function(){U8("clearCurrentReceiver");
g.$F("yt-remote-cast-receiver")},L5v=function(){return uK()?Cn()?Cn().getCastSession():(XT("getCastSelector: Cast is not initialized."),null):(XT("getCastSelector: Cast API is not installed!"),null)},mj=function(){uK()?Cn()?xB()?(U8("Requesting cast selector."),Cn().requestSession()):(U8("Wait for cast API to be ready to request the session."),bK.push(g.Du("yt-remote-cast2-api-ready",mj))):XT("requestCastSelector: Cast is not initialized."):XT("requestCastSelector: Cast API is not installed!")},qD=
function(l,y){xB()?Cn().setConnectedScreenStatus(l,y):XT("setConnectedScreenStatus called before ready.")},EJ1=function(){var l=g.Xv().search(/ (CrMo|Chrome|CriOS)\//)>=0;
return g.Mx||l},vJe=function(l,y){Cn().init(l,y)},fZx=function(l,y){let k=!1;
Cn()||(l=new W1(l,y),l.subscribe("yt-remote-cast2-availability-change",function(z){g.eY("yt-remote-cast-available",z);qT("yt-remote-cast2-availability-change",z)}),l.subscribe("yt-remote-cast2-receiver-selected",function(z){U8("onReceiverSelected: "+z.friendlyName);
g.eY("yt-remote-cast-receiver",z);qT("yt-remote-cast2-receiver-selected",z)}),l.subscribe("yt-remote-cast2-receiver-resumed",function(z){U8("onReceiverResumed: "+z.friendlyName);
g.eY("yt-remote-cast-receiver",z);qT("yt-remote-cast2-receiver-resumed",z)}),l.subscribe("yt-remote-cast2-session-change",function(z){U8("onSessionChange: "+ac(z));
z||g.$F("yt-remote-cast-receiver");qT("yt-remote-cast2-session-change",z)}),g.iQ("yt.mdx.remote.cloudview.instance_",l),k=!0);
U8("cloudview.createSingleton_: "+k);return k},Cn=function(){return g.UT("yt.mdx.remote.cloudview.instance_")},j7L=function(l,y){c1(!0);
MD(!1);vJe(l,function(k){k?(oJf(!0),g.yD("yt-remote-cast2-api-ready")):(XT("Failed to initialize cast API."),c1(!1),g.$F("yt-remote-cast-available"),g.$F("yt-remote-cast-receiver"),SWw());y(k)})},U8=function(l){oP("cloudview",l)},XT=function(l){oP("cloudview",l)},c1=function(l){U8("setCastInstalled_ "+l);
g.eY("yt-remote-cast-installed",l)},xB=function(){return!!g.UT("yt.mdx.remote.cloudview.apiReady_")},oJf=function(l){U8("setApiReady_ "+l);
g.iQ("yt.mdx.remote.cloudview.apiReady_",l)},MD=function(l){g.iQ("yt.mdx.remote.cloudview.initializing_",l)},Ix=function(l){this.index=-1;
this.videoId=this.listId="";this.volume=this.playerState=-1;this.muted=!1;this.audioTrackId=null;this.J=this.S=0;this.trackData=null;this.hasNext=this.hasPrevious=!1;this.loadedTime=this.N=this.K=this.C=0;this.Z=NaN;this.V=!1;this.reset(l)},Tt=function(l){l.audioTrackId=null;
l.trackData=null;l.playerState=-1;l.hasPrevious=!1;l.hasNext=!1;l.S=0;l.J=g.T5();l.C=0;l.K=0;l.N=0;l.loadedTime=0;l.Z=NaN;l.V=!1},Vg=function(l){return l.isPlaying()?(g.T5()-l.J)/1E3:0},P1=function(l,y){l.S=y;
l.J=g.T5()},Jz=function(l){switch(l.playerState){case 1:case 1081:return(g.T5()-l.J)/1E3+l.S;
case -1E3:return 0}return l.S},BmL=function(l){return l.V?l.K+Vg(l):l.K},YB=function(l,y,k){const z=l.videoId;
l.videoId=y;l.index=k;y!=z&&Tt(l)},pn=function(l){const y={};
y.index=l.index;y.listId=l.listId;y.videoId=l.videoId;y.playerState=l.playerState;y.volume=l.volume;y.muted=l.muted;y.audioTrackId=l.audioTrackId;y.trackData=g.Ze(l.trackData);y.hasPrevious=l.hasPrevious;y.hasNext=l.hasNext;y.playerTime=l.S;y.playerTimeAt=l.J;y.seekableStart=l.C;y.seekableEnd=l.K;y.duration=l.N;y.loadedTime=l.loadedTime;y.liveIngestionTime=l.Z;return y},HSe=function(l){g.Fy("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange multiStateLoopEnabled loopModeChange".split(" "),
function(y){this.K.push(this.V.subscribe(y,g.IC(this.u0,y),this))},l)},Kn=function(l,y){l.C&&(l.C.removeUpdateListener(l.Y),l.C.removeMediaListener(l.D),l.S(null));
l.C=y;l.C&&(NY("Setting cast session: "+l.C.sessionId),l.C.addUpdateListener(l.Y),l.C.addMediaListener(l.D),l.C.media.length&&l.S(l.C.media[0]))},gI=function(l){return new Ix(l.V.getPlayerContextData())},E8=function(l){return l.getState()==1},jH=function(l,y,k){return(0,g.We)(function(z){this.JC("Failed to "+y+" with cast v2 channel. Error code: "+z.code);
z.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.JC("Retrying "+y+" using MDx browser channel."),fn(this,y,k))},l)},fn=function(l,y,k){l.V.sendMessage(y,k)},nn=function(l,y,k){const z=gI(l);
P1(z,k);z.playerState!=-1E3&&(z.playerState=y);SH(l,z)},FT=function(l,y){var k=l.J;
k.Z.length+k.C.length<50&&l.J.enqueue(y)},SH=function(l,y){R4R(l);
l.V.setPlayerContextData(pn(y));HSe(l)},R4R=function(l){g.Fy(l.K,function(y){this.V.unsubscribeByKey(y)},l);
l.K.length=0},Dme=function(l){const y=l.Z.media,k=l.Z.customData;
if(y&&k){var z=gI(l);y.contentId!=z.videoId&&NY("Cast changing video to: "+y.contentId);z.videoId=y.contentId;z.playerState=k.playerState;P1(z,l.Z.getEstimatedTime());SH(l,z)}else NY("No cast media video. Ignoring state update.")},lWR=function(l){ox("Channel opened");
l.HG&&(l.HG=!1,ND(l),l.Ja=g.JK(()=>{ox("Timing out waiting for a screen.");l.K(1)},15E3))},du2=function(l,y){y=y.message;
y.params?ox("Received: action="+y.action+", params="+g.cU(y.params)):ox("Received: action="+y.action+" {}");switch(y.action){case "loungeStatus":y=Qf(y.params.devices);l.N=g.sT(y,function(z){return new w_(z)});
y=!!g.Dg(l.N,function(z){return z.type=="LOUNGE_SCREEN"});
yno(l,y);y=l.Xr("mlm");l.publish("multiStateLoopEnabled",y);break;case "loungeScreenDisconnected":g.$2(l.N,function(z){return z.type=="LOUNGE_SCREEN"});
yno(l,!1);break;case "remoteConnected":let k=new w_(Qf(y.params.device));g.Dg(l.N,function(z){return z.equals(k)})||sRf(l.N,k);
break;case "remoteDisconnected":k=new w_(Qf(y.params.device));g.$2(l.N,function(z){return z.equals(k)});
break;case "gracefulDisconnect":break;case "playlistModified":kwy(l,y,"QUEUE_MODIFIED");break;case "nowPlaying":zQv(l,y);break;case "onStateChange":rny(l,y);break;case "onAdStateChange":Zfy(l,y);break;case "onVolumeChanged":eQL(l,y);break;case "onSubtitlesTrackChanged":AnL(l,y);break;case "nowAutoplaying":$uw(l,y);break;case "autoplayDismissed":l.publish("autoplayDismissed");break;case "autoplayUpNext":QjO(l,y);break;case "onAutoplayModeChanged":toO(l,y);break;case "onHasPreviousNextChanged":OfR(l,
y);break;case "requestAssistedSignIn":l.publish("assistedSignInRequested",y.params.authCode);break;case "onLoopModeChanged":l.publish("loopModeChange",y.params.loopMode);break;default:ox("Unrecognized action: "+y.action)}},ox=function(l){oP("conn",l)},wce=function(l){l.S=g.JK(()=>{ox("Connecting timeout");
l.K(1)},2E4)},s8=function(l,y){l.publish("proxyStateChange",y)},Ln=function(l){g.pl(l.S);
l.S=NaN},v1=function(l){g.pl(l.sj);
l.sj=NaN},ND=function(l){g.pl(l.Ja);
l.Ja=NaN},hQ2=function(l){return g.Dg(l.N,function(y){return y.type=="LOUNGE_SCREEN"})},B1=function(l,y,k){k?ox("Sending: action="+y+", params="+g.cU(k)):ox("Sending: action="+y);
l.C.sendMessage(y,k)},Gwf=function(l){v1(l);
l.sj=g.JK(()=>{B1(l,"getNowPlaying")},2E4)},aWo=function(l){g.pl(l.Y);
l.Y=g.JK(()=>{l.K(1)},864E5)},yno=function(l,y){var k=null;
if(y){const z=hQ2(l);z&&(k={clientName:z.clientName,deviceMake:z.brand,deviceModel:z.model,osVersion:z.osVersion})}g.iQ("yt.mdx.remote.remoteClient_",k);y&&(Ln(l),ND(l));k=l.C.hN()&&isNaN(l.S);y==k?y&&(s8(l,1),B1(l,"getSubtitlesTrack")):y?(l.PG()&&l.Z.reset(),s8(l,1),B1(l,"getNowPlaying"),aWo(l)):l.K(1)},AnL=function(l,y){const k=y.params.videoId;
delete y.params.videoId;k==l.Z.videoId&&(g.DB(y.params)?l.Z.trackData=null:l.Z.trackData=y.params,l.publish("remotePlayerChange"))},kwy=function(l,y,k){const z=y.params.videoId||y.params.video_id,r=parseInt(y.params.currentIndex,10);
l.Z.listId=y.params.listId||l.Z.listId;YB(l.Z,z,r);l.publish("remoteQueueChange",k)},rny=function(l,y){var k=parseInt(y.params.currentTime||y.params.current_time,10);
P1(l.Z,isNaN(k)?0:k);k=parseInt(y.params.state,10);k=isNaN(k)?-1:k;k==-1&&l.Z.playerState==-1E3&&(k=-1E3);l.Z.playerState=k;k=Number(y.params.loadedTime);l.Z.loadedTime=isNaN(k)?0:k;l.Z.BZ(Number(y.params.duration));k=l.Z;var z=Number(y.params.liveIngestionTime);k.Z=z;k.V=isNaN(z)?!1:!0;k=l.Z;z=Number(y.params.seekableStartTime);y=Number(y.params.seekableEndTime);k.C=isNaN(z)?0:z;k.K=isNaN(y)?0:y;l.Z.playerState==1?Gwf(l):v1(l);l.publish("remotePlayerChange")},zQv=function(l,y){y.params=y.params||
{};
kwy(l,y,"NOW_PLAYING_MAY_CHANGE");rny(l,y);l.publish("autoplayDismissed")},Zfy=function(l,y){if(l.Z.playerState!=-1E3){var k=1085;
switch(parseInt(y.params.adState,10)){case 1:k=1081;break;case 2:k=1084;break;case 0:k=1083}l.Z.playerState=k;y=parseInt(y.params.currentTime,10);P1(l.Z,isNaN(y)?0:y);l.publish("remotePlayerChange")}},eQL=function(l,y){const k=y.params.muted=="true";
l.Z.volume=parseInt(y.params.volume,10);l.Z.muted=k;l.publish("remotePlayerChange")},$uw=function(l,y){l.A=y.params.videoId;
l.publish("nowAutoplaying",parseInt(y.params.timeout,10))},QjO=function(l,y){l.A=y.params.videoId||null;
l.publish("autoplayUpNext",l.A)},toO=function(l,y){l.J=y.params.autoplayMode;
l.publish("autoplayModeChange",l.J);l.J=="DISABLED"&&l.publish("autoplayDismissed")},OfR=function(l,y){const k=y.params.hasNext=="true";
l.Z.hasPrevious=y.params.hasPrevious=="true";l.Z.hasNext=k;l.publish("previousNextChange")},Xc1=function(l,y){htp();
if(!my||!my.get("yt-remote-disable-remote-module-for-dev")){y=g.Y("MDX_CONFIG")||y;ATO();u1();H1||(H1=new jt(y?y.loungeApiHost:void 0),GWx()&&(H1.Z="/api/loungedev"));Rx||(Rx=g.UT("yt.mdx.remote.deferredProxies_")||[],g.iQ("yt.mdx.remote.deferredProxies_",Rx));ife();var k=Dt();if(!k){const r=new rI(H1,y?y.disableAutomaticScreenCache||!1:!1);g.iQ("yt.mdx.remote.screenService_",r);k=Dt();var z={};y&&(z={appId:y.appId,disableDial:y.disableDial,theme:y.theme,loadCastApiSetupScript:y.loadCastApiSetupScript,
disableCastApi:y.disableCastApi,enableDialLoungeToken:y.enableDialLoungeToken,enableCastLoungeToken:y.enableCastLoungeToken,forceMirroring:y.forceMirroring});g.iQ("yt.mdx.remote.enableConnectWithInitialState_",y?y.enableConnectWithInitialState||!1:!1);F5p(l,r,function(Z){Z?lF()&&qD(lF(),"YouTube TV"):r.subscribe("onlineScreenChange",function(){qT("yt-remote-receiver-availability-change")})},z)}y&&!g.UT("yt.mdx.remote.initialized_")&&(g.iQ("yt.mdx.remote.initialized_",!0),yl("Initializing: "+g.cU(y)),
kS.push(g.Du("yt-remote-cast2-api-ready",function(){qT("yt-remote-api-ready")})),kS.push(g.Du("yt-remote-cast2-availability-change",function(){qT("yt-remote-receiver-availability-change")})),kS.push(g.Du("yt-remote-cast2-receiver-selected",function(){zb(null);
qT("yt-remote-auto-connect","cast-selector-receiver")})),kS.push(g.Du("yt-remote-cast2-receiver-resumed",function(){qT("yt-remote-receiver-resumed","cast-selector-receiver")})),kS.push(g.Du("yt-remote-cast2-session-change",Uuw)),kS.push(g.Du("yt-remote-connection-change",function(r){r?qD(lF(),"YouTube TV"):rT()||(qD(null,null),s7o())})),kS.push(g.Du("yt-remote-cast2-session-failed",()=>{qT("yt-remote-connection-failed")})),l=Zk(),y.isAuto&&(l.id+="#dial"),z=y.capabilities||[],z.length>0&&(l.capabilities=
z),l.name=y.device,l.app=y.app,(y=y.theme)&&(l.theme=y),yl(" -- with channel params: "+g.cU(l)),l?(g.eY("yt-remote-session-app",l.app),g.eY("yt-remote-session-name",l.name)):(g.$F("yt-remote-session-app"),g.$F("yt-remote-session-name")),g.iQ("yt.mdx.remote.channelParams_",l),k.start(),lF()||Mo1())}},cn2=function(){var l=Dt().NV.$_gos();
const y=eC();y&&Ae()&&(MT(l,y)||l.push(y));return et2(l)},$S=function(){let l=CJp();
!l&&uK()&&NmR()&&(l={key:"cast-selector-receiver",name:NmR()});return l},CJp=function(){const l=cn2();
let y=eC();y||(y=rT());return g.Dg(l,function(k){return y&&GO(y,k.key)?!0:!1})},eC=function(){const l=lF();
if(!l)return null;const y=Dt().QG();return Xz(y,l)},Uuw=function(l){yl("remote.onCastSessionChange_: "+ac(l));
if(l){var y=eC();if(y&&y.id==l.id){if(qD(y.id,"YouTube TV"),l.idType=="shortLived"&&(l=l.token))Ql&&(Ql.token=l),(y=Ae())&&y.IV(l)}else y&&te(),Oh(l,1)}else Ae()&&te()},te=function(){xB()?Cn().stopSession():XT("stopSession called before API ready.");
const l=Ae();l&&(l.disconnect(1),dT(null))},wT=function(){const l=Ae();
return!!l&&l.getProxyState()!=3},yl=function(l){oP("remote",l)},Dt=function(){if(!he){const l=g.UT("yt.mdx.remote.screenService_");
he=l?new bf2(l):null}return he},lF=function(){return g.UT("yt.mdx.remote.currentScreenId_")},u7R=function(l){g.iQ("yt.mdx.remote.currentScreenId_",l)},xuR=function(){return g.UT("yt.mdx.remote.connectData_")},zb=function(l){g.iQ("yt.mdx.remote.connectData_",l)},Ae=function(){return g.UT("yt.mdx.remote.connection_")},dT=function(l){const y=Ae();
zb(null);l||u7R("");g.iQ("yt.mdx.remote.connection_",l);Rx&&(g.Fy(Rx,function(k){k(l)}),Rx.length=0);
y&&!l?qT("yt-remote-connection-change",!1):!y&&l&&qT("yt-remote-connection-change",!0)},rT=function(){const l=g.QE();
if(!l)return null;var y=Dt();if(!y)return null;y=y.QG();return Xz(y,l)},Oh=function(l,y){lF();
eC()&&eC();if(Gb)Ql=l;else{u7R(l.id);var k=g.UT("yt.mdx.remote.enableConnectWithInitialState_")||!1;l=new aJ(l,k);l.connect(y,xuR());l.subscribe("beforeDisconnect",function(z){qT("yt-remote-before-disconnect",z)});
l.subscribe("beforeDispose",function(){Ae()&&(Ae(),dT(null))});
l.subscribe("browserChannelAuthError",()=>{const z=eC();z&&z.idType=="shortLived"&&(xB()?Cn().handleBrowserChannelAuthError():XT("refreshLoungeToken called before API ready."))});
dT(l)}},Mo1=function(){const l=rT();
l?(yl("Resume connection to: "+ac(l)),Oh(l,0)):(x3(),s7o(),yl("Skipping connecting because no session screen found."))},ife=function(){var l=Zk();
if(g.DB(l)){l=b1();var y=g.Ay("yt-remote-session-name")||"";const k=g.Ay("yt-remote-session-app")||"";l={device:"REMOTE_CONTROL",id:l,name:y,app:k,mdxVersion:3};l.authuser=String(g.Y("SESSION_INDEX","0"));(y=g.Y("DELEGATED_SESSION_ID"))&&(l.pageId=String(y));g.iQ("yt.mdx.remote.channelParams_",l)}},Zk=function(){return g.UT("yt.mdx.remote.channelParams_")||{}},mue=function(l,y){if(iF(l)){l.WF.unsubscribe("remotePlayerChange",l.J,l);
const k=Math.round(y.volume);y=!!y.muted;const z=gI(l.WF);if(k!==z.volume||y!==z.muted)l.WF.setVolume(k,y),l.Y.start();l.WF.subscribe("remotePlayerChange",l.J,l)}},iF=function(l){return gI(l.WF).videoId===Uh(l).videoId},Ma=function(l,y){let k,z;
var r=l.L.getPlaylist();r?.listId&&(k=r.index,z=r.listId.toString());r=Uh(l);l.WF.playVideo(r.videoId,y,k,z,r.playerParams,r.Y,N5e(r));l.e2(new g.U5(1))},XM=function(l,y){if(iF(l)&&!l.S){let k=null;
y&&(k={style:l.L.getSubtitlesUserSettings()},Object.assign(k,y));l.WF.A(Uh(l).videoId,k);l.V=gI(l.WF).trackData}},qXv=function(l,y){if(y){const k=l.L.getOption("captions","tracklist",{r6:1});
k&&k.length?(l.L.setOption("captions","track",y),l.S=!1):(l.L.loadModule("captions"),l.S=!0)}else l.L.setOption("captions","track",{})},W0B=function(l){l.Pn(0);
l.C.stop();l.e2(new g.U5(64))},Uh=function(l){return l.L.getVideoData({playerType:1})},IWB=function(l){const y=l.player.O();
return!y.X("mdx_enable_privacy_disclosure_ui")||l.isLoggedIn()||l.He||!l.t8?!1:g.xp(y)||g.JA(y)},T3w=function(l,y,k){l.fp=k;
l.player.publish("presentingplayerstatechange",new g.WK(k,y))},cg=function(l,y,...k){l.loaded&&l.KA.Vs(y,...k)},Ch=function(l){l.Q6&&(l.player.removeEventListener("presentingplayerstatechange",l.Q6),l.Q6=null)},bF=function(l,y){if(y.key!==l.VT.key)if(y.key===l.uN.key)te();
else if(IWB(l)&&Vov(l),l.VT=y,!g.ow(l.player.O())){{const Z=l.player.getPlaylistId();var k=l.player.getVideoData({playerType:1});const e=k.videoId;if(!Z&&!e||(l.player.getAppState()===2||l.player.getAppState()===1)&&l.player.O().X("should_clear_video_data_on_player_cued_unstarted"))k=null;else{var z=l.player.getPlaylist();if(z){var r=[];for(let A=0;A<z.length;A++)r[A]=g.pJ(z,A).videoId}else r=[e];z=l.player.getCurrentTime(1);l={videoIds:r,listId:Z,videoId:e,playerParams:k.playerParams,clickTrackingParams:k.Y,
index:Math.max(l.player.getPlaylistIndex(),0),currentTime:z===0?void 0:z};(k=N5e(k))&&(l.locationInfo=k);k=l}}yl("Connecting to: "+g.cU(y));y.key=="cast-selector-receiver"?(zb(k||null),y=k||null,xB()?Cn().setLaunchParams(y):XT("setLaunchParams called before ready.")):!k&&wT()&&lF()==y.key?qT("yt-remote-connection-change",!0):(te(),zb(k||null),k=Dt().QG(),(y=Xz(k,y.key))&&Oh(y,1))}},Vov=function(l){l.player.getPlayerStateObject().isPlaying()?l.player.pauseVideo():(l.Q6=y=>{!l.He&&y.tj(8)&&(l.player.pauseVideo(),
Ch(l))},l.player.addEventListener("presentingplayerstatechange",l.Q6));
l.t8&&l.t8.Bn();Ae()||(Gb=!0)};
g.hc.prototype.mC=g.k4(46,function(){this.app.yu().mC()});
g.Rz.prototype.mC=g.k4(45,function(){this.xe=null});
g.hc.prototype.tO=g.k4(44,function(l){this.app.yu().tO(l)});
g.Rz.prototype.tO=g.k4(43,function(l){this.xe=l});
g.Au.prototype.fY=g.k4(1,function(){return g.$h(this,3)});
g.kE.prototype.fY=g.k4(0,function(){return g.$h(this,11)});
var pdy=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/channel/opened",g.mg("channel_type"))}Z(l){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/channel/opened",l)}},KOO=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/channel/closed",g.mg("channel_type"))}Z(l){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/channel/closed",l)}},Ec1=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/channel/message_received",
g.mg("channel_type"))}Z(l){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/channel/message_received",l)}},gcR=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/channel/success")}Z(){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/channel/success")}},fL1=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/channel/error",g.mg("channel_type"),g.mg("error_type"))}Z(l,y){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/channel/error",
l,y)}},j4O=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}Z(){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}},Siw=class{constructor(){var l=g.sP();this.C=l;g.dm(l,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}Z(){g.h9(this.C,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}};g.b=OA.prototype;
g.b.s2=function(){d_(this);const l=[];for(let y=0;y<this.Z.length;y++)l.push(this.C[this.Z[y]]);return l};
g.b.e8=function(){d_(this);return this.Z.concat()};
g.b.has=function(l){return th(this.C,l)};
g.b.equals=function(l,y){if(this===l)return!0;if(this.size!=l.size)return!1;y=y||HUp;d_(this);let k;for(let z=0;k=this.Z[z];z++)if(!y(this.get(k),l.get(k)))return!1;return!0};
g.b.isEmpty=function(){return this.size==0};
g.b.clear=function(){this.C={};this.Ds=this.size=this.Z.length=0};
g.b.remove=function(l){return this.delete(l)};
g.b.delete=function(l){return th(this.C,l)?(delete this.C[l],--this.size,this.Ds++,this.Z.length>2*this.size&&d_(this),!0):!1};
g.b.get=function(l,y){return th(this.C,l)?this.C[l]:y};
g.b.set=function(l,y){th(this.C,l)||(this.size+=1,this.Z.push(l),this.Ds++);this.C[l]=y};
g.b.forEach=function(l,y){const k=this.e8();for(let z=0;z<k.length;z++){const r=k[z],Z=this.get(r);l.call(y,Z,r,this)}};
g.b.clone=function(){return new OA(this)};
g.b.keys=function(){return g.XA(this.kq(!0)).Z()};
g.b.values=function(){return g.XA(this.kq(!1)).Z()};
g.b.entries=function(){const l=this;return B5v(this.keys(),function(y){return[y,l.get(y)]})};
g.b.kq=function(l){d_(this);let y=0;const k=this.Ds,z=this,r=new g.Cr;r.next=function(){if(k!=z.Ds)throw Error("The map has changed since the iterator was created");if(y>=z.Z.length)return g.Hb;const Z=z.Z[y++];return g.bL(l?Z:z.C[Z])};
return r};
var yT2={u6:"atp",bPK:"ska",Ir7:"que",Jx:"mus",C5b:"sus",vD:"dsp",jRG:"seq",c8:"mic",nI:"dpa",N2:"mlm",Ii:"dsdtr",v8:"ntb",zJ7:"vsp",l9:"scn",nz7:"rpe",LI:"dcn",u9:"dcp",ih:"pas",ai:"drq",nu:"opf",i9:"els",fI:"isg",k7b:"svq",Vn:"mvp",pk:"ads",rvr:"stcp",teG:"sads",P4:"dloc",Eu:"dcw",v5:"asw",Rl:"apw",U$:"wrc",C00:"pcw",Uc:"ipv",Im:"ndt",e9:"ctops",qZ:"gsrm"},kWB={dW$:"u",Os:"cl",IE:"k",Oa:"i",oi:"cr",q2:"m",CT:"g",y$:"up"},FOR={Lu:"nowPlaying",Ku:"onStateChange",XH:"adPlaying",E0:"onAdStateChange",
uh:"nowPlayingShorts",g9:"onShortsStateChange"};w_.prototype.equals=function(l){return l?this.id==l.id:!1};
var CI="",my=null,cT2=aXe("loadCastFramework")||aXe("loadCastApplicationFramework"),bB2=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];g.J5(PP,g.zP);g.b=PP.prototype;g.b.Gp=function(l){this.V=arguments;this.Z=!1;this.Aj?this.N=g.T5()+this.h6:this.Aj=g.ZZ(this.J,this.h6)};
g.b.stop=function(){this.Aj&&(g.aC.clearTimeout(this.Aj),this.Aj=null);this.N=null;this.Z=!1;this.V=[]};
g.b.pause=function(){++this.C};
g.b.resume=function(){this.C&&(--this.C,!this.C&&this.Z&&(this.Z=!1,this.S.apply(null,this.V)))};
g.b.Vj=function(){this.stop();PP.Ws.Vj.call(this)};
g.b.dl=function(){this.Aj&&(g.aC.clearTimeout(this.Aj),this.Aj=null);this.N?(this.Aj=g.ZZ(this.J,this.N-g.T5()),this.N=null):this.C?this.Z=!0:(this.Z=!1,this.S.apply(null,this.V))};var Y3=null;Jh.prototype.set=function(l){this.Z=l};
Jh.prototype.reset=function(){this.set(g.T5())};
Jh.prototype.get=function(){return this.Z};g.J5(miB,xi1);var Ad=class{stringify(l){return g.aC.JSON.stringify(l,void 0)}parse(l){return g.aC.JSON.parse(l,void 0)}};g.J5(pI,g.$c);g.J5(KI,g.$c);var qQL=null;g.J5(Wg2,g.$c);g.J5(IXB,g.$c);g.J5(T2o,g.$c);Sh.prototype.debug=function(){};
Sh.prototype.info=function(){};
Sh.prototype.warning=function(){};var Kg2={},LI={};g.b=nI.prototype;g.b.setTimeout=function(l){this.gb=l};
g.b.zp=function(l){l=l.target;const y=this.PG;y&&g.J9(l)==3?y.V():this.Ql(l)};
g.b.Ql=function(l){try{if(l==this.Z)a:{const r=g.J9(this.Z),Z=this.Z.C,e=this.Z.getStatus();if(!(r<3)&&(r!=3||this.Z&&(this.C.C||g.KS(this.Z)||g.gm(this.Z)))){this.HG||r!=4||Z==7||(Z==8||e<=0?EA(3):EA(2));vP(this);var y=this.Z.getStatus();this.kz=y;var k=pQL(this);if(this.S=y==200){if(this.WG&&!this.u0){b:{if(this.Z){const A=g.fS(this.Z,"X-HTTP-Initial-Response");if(A&&!g.G0(A)){var z=A;break b}}z=null}if(l=z)this.u0=!0,rA(this,l);else{this.S=!1;this.J=3;fI(12);NT(this);sA(this);break a}}if(this.Ja){l=
!0;let A;for(;!this.HG&&this.K<k.length;)if(A=gwf(this,k),A==LI){r==4&&(this.J=4,fI(14),l=!1);break}else if(A==Kg2){this.J=4;fI(15);l=!1;break}else rA(this,A);YQL(this)&&this.K!=0&&(this.C.Z=this.C.Z.slice(this.K),this.K=0);r!=4||k.length!=0||this.C.C||(this.J=1,fI(16),l=!1);this.S=this.S&&l;l?k.length>0&&!this.T7&&(this.T7=!0,this.N.yY(this)):(NT(this),sA(this))}else rA(this,k);r==4&&NT(this);this.S&&!this.HG&&(r==4?fX2(this.N,this):(this.S=!1,oc(this)))}else g.EW(this.Z),y==400&&k.indexOf("Unknown SID")>
0?(this.J=3,fI(12)):(this.J=0,fI(13)),NT(this),sA(this)}}}catch(r){}finally{}};
g.b.cancel=function(){this.HG=!0;NT(this)};
g.b.kx=function(){this.C_=null;const l=Date.now();l-this.xz>=0?(this.rb!=2&&(EA(3),fI(17)),NT(this),this.J=2,sA(this)):Ewx(this,this.xz-l)};
g.b.getLastError=function(){return this.J};
g.b.O4=function(){return this.Z};var PJ1=class{constructor(l,y){this.Z=l;this.map=y;this.context=null}};Fgx.prototype.cancel=function(){this.N=ZR(this);if(this.C)this.C.cancel(),this.C=null;else if(this.Z&&this.Z.size!==0){for(const l of this.Z.values())l.cancel();this.Z.clear()}};g.b=vw1.prototype;g.b.rU=8;g.b.cw=1;g.b.connect=function(l,y,k,z){fI(0);this.g4=l;this.HG=y||{};k&&z!==void 0&&(this.HG.OSID=k,this.HG.OAID=z);this.PG=this.R7;this.RR=jVB(this,null,this.g4);zm(this)};
g.b.disconnect=function(){B2L(this);if(this.cw==3){var l=this.Xr++,y=this.RR.clone();g.ke(y,"SID",this.V);g.ke(y,"RID",l);g.ke(y,"TYPE","terminate");td(this,y);l=new nI(this,this.V,l);l.rb=2;l.A=eh(y.clone());y=!1;if(g.aC.navigator&&g.aC.navigator.sendBeacon)try{y=g.aC.navigator.sendBeacon(l.A.toString(),"")}catch{}!y&&g.aC.Image&&((new Image).src=l.A,y=!0);y||(l.Z=JT2(l.N,null),l.Z.send(l.A));l.b0=Date.now();oc(l)}kq1(this)};
g.b.AC=function(){return this.cw==0};
g.b.getState=function(){return this.cw};
g.b.R0=function(l){if(this.S)if(this.S=null,this.cw==1){if(!l){this.Xr=Math.floor(Math.random()*1E5);l=this.Xr++;const r=new nI(this,"",l);let Z=this.D;this.WG&&(Z?(Z=g.r4(Z),g.Am(Z,this.WG)):Z=this.WG);this.K!==null||this.xz||(r.RR=Z,Z=null);if(this.Oj)a:{var y=0;for(var k=0;k<this.N.length;k++){b:{var z=this.N[k];if("__data__"in z.map&&(z=z.map.__data__,typeof z==="string")){z=z.length;break b}z=void 0}if(z===void 0)break;y+=z;if(y>4096){y=k;break a}if(y===4096||k===this.N.length-1){y=k+1;break a}}y=
this.BF}else y=this.BF;y=Di2(this,r,y);k=this.RR.clone();g.ke(k,"RID",l);g.ke(k,"CVER",22);this.Ja&&g.ke(k,"X-HTTP-Session-Id",this.Ja);td(this,k);Z&&(this.xz?y="headers="+g.am(g.Ag(Z))+"&"+y:this.K&&g.$e(k,this.K,Z));kx(this.C,r);this.Fg&&g.ke(k,"TYPE","init");this.Oj?(g.ke(k,"$req",y),g.ke(k,"SID","null"),r.WG=!0,Fz(r,k,null)):Fz(r,k,y);this.cw=2}}else this.cw==3&&(l?lLw(this,l):this.N.length==0||owL(this.C)||lLw(this))};
g.b.HR=function(){this.A=null;yMv(this);if(this.PF&&!(this.gb||this.Z==null||this.SN<=0)){var l=4*this.SN;this.sj=jh((0,g.We)(this.nH,this),l)}};
g.b.nH=function(){this.sj&&(this.sj=null,this.PG=!1,this.gb=!0,fI(10),Rc(this),yMv(this))};
g.b.yY=function(l){this.Z==l&&this.PF&&!this.gb&&(Qn(this),this.gb=!0,fI(11))};
g.b.Tp=function(){this.C_!=null&&(this.C_=null,Rc(this),DI(this),fI(19))};
g.b.EY=function(l){l?fI(2):fI(1)};
g.b.isActive=function(){return!!this.J&&this.J.isActive(this)};
g.b=rMB.prototype;g.b.uu=function(){};
g.b.Lq=function(){};
g.b.UM=function(){};
g.b.vR=function(){};
g.b.isActive=function(){return!0};
g.b.t5=function(){};g.J5(dA,g.Wd);dA.prototype.open=function(){this.Z.J=this.N;this.K&&(this.Z.u0=!0);this.Z.connect(this.S,this.C||void 0)};
dA.prototype.close=function(){this.Z.disconnect()};
dA.prototype.send=function(l){var y=this.Z;if(typeof l==="string"){var k={};k.__data__=l;l=k}else this.J&&(k={},k.__data__=g.cU(l),l=k);y.N.push(new PJ1(y.Cp++,l));y.cw==3&&zm(y)};
dA.prototype.Vj=function(){this.Z.J=null;delete this.N;this.Z.disconnect();delete this.Z;dA.Ws.Vj.call(this)};
g.J5(eUf,pI);g.J5(AM2,KI);g.J5(Od,rMB);Od.prototype.uu=function(){this.Z.dispatchEvent("m")};
Od.prototype.Lq=function(l){this.Z.dispatchEvent(new eUf(l))};
Od.prototype.UM=function(l){this.Z.dispatchEvent(new AM2(l))};
Od.prototype.vR=function(){this.Z.dispatchEvent("n")};
dA.prototype.V=function(){return new wA(this,this.Z)};
wA.prototype.C=function(){return lV(this.Z.C)};
wA.prototype.N=function(){return zUw(this.Z).map(l=>{var y=this.V;l=l.map;"__data__"in l?(l=l.__data__,y=y.J?LL2(l):l):y=l;return y})};
wA.prototype.commit=function(l){this.Z.kz=l};var Gm=new g.Wd,$0x=class extends g.$c{constructor(){super("statevent",Gm)}};g.b=iV.prototype;g.b.NI=null;g.b.Ff=!1;g.b.B6=null;g.b.yL=null;g.b.bl=null;g.b.VP=null;g.b.hI=null;g.b.sz=null;g.b.V2=null;g.b.aF=null;g.b.qM=0;g.b.xp=null;g.b.J1=null;g.b.m_=null;g.b.Cj=-1;g.b.lJ=!0;g.b.Zz=!1;g.b.BM=0;g.b.MM=null;var O62={},Xq={};g.b=iV.prototype;g.b.setTimeout=function(l){this.C=l};
g.b.Dw=function(l){l=l.target;const y=this.MM;y&&g.J9(l)==3?y.V():this.PR(l)};
g.b.PR=function(l){try{if(l==this.aF)a:{const y=g.J9(this.aF),k=this.aF.C,z=this.aF.getStatus();if(g.tV&&!g.KK("420+")){if(y<4)break a}else if(y<3||y==3&&!g.KS(this.aF))break a;this.Zz||y!=4||k==7||(k==8||z<=0?this.Z.Y_(3):this.Z.Y_(2));hUR(this);const r=this.aF.getStatus();this.Cj=r;const Z=g.KS(this.aF);if(this.Ff=r==200){y==4&&CH(this);if(this.Ja){for(l=!0;!this.Zz&&this.qM<Z.length;){const e=d0x(this,Z);if(e==Xq){y==4&&(this.m_=4,aP(),l=!1);break}else if(e==O62){this.m_=4;aP();l=!1;break}else Gq1(this,
e)}y==4&&Z.length==0&&(this.m_=1,aP(),l=!1);this.Ff=this.Ff&&l;l||(CH(this),c8(this))}else Gq1(this,Z);this.Ff&&!this.Zz&&(y==4?this.Z.x5(this):(this.Ff=!1,MY(this)))}else this.m_=r==400&&Z.indexOf("Unknown SID")>0?3:0,aP(),CH(this),c8(this)}}catch(y){}finally{}};
g.b.cancel=function(){this.Zz=!0;CH(this)};
g.b.Wp=function(){this.B6=null;const l=Date.now();l-this.yL>=0?(this.VP!=2&&this.Z.Y_(3),CH(this),this.m_=2,aP(),c8(this)):wdB(this,this.yL-l)};
g.b.getLastError=function(){return this.m_};g.b=U0O.prototype;g.b.wv=null;g.b.cZ=null;g.b.jT=!1;g.b.fb=null;g.b.O6=null;g.b.er=-1;g.b.ov=null;g.b.XQ=null;g.b.connect=function(l){this.fb=l;l=uV(this.Z,null,this.fb);aP();Date.now();const y=this.Z.D;y!=null?(this.ov=y[0],(this.XQ=y[1])?(this.O6=1,MKL(this)):(this.O6=2,mz(this))):(Ah(l,"MODE","init"),this.cZ=new iV(this),this.cZ.NI=this.wv,Ud(this.cZ,l,!1,null,!0),this.O6=0)};
g.b.UZ=function(l){if(l)this.O6=2,mz(this);else{aP();var y=this.Z;y.F6=y.sT.er;Yx(y,9)}l&&this.Y_(2)};
g.b.AT=function(l){return this.Z.AT(l)};
g.b.abort=function(){this.cZ&&(this.cZ.cancel(),this.cZ=null);this.er=-1};
g.b.AC=function(){return!1};
g.b.I0=function(l,y){this.er=l.Cj;if(this.O6==0)if(y){try{var k=this.C.parse(y)}catch(z){l=this.Z;l.F6=this.er;Yx(l,2);return}this.ov=k[0];this.XQ=k[1]}else l=this.Z,l.F6=this.er,Yx(l,2);else this.O6==2&&(this.jT?(aP(),Date.now()):y=="11111"?(aP(),this.jT=!0,Date.now(),this.er=200,this.cZ.cancel(),aP(),xx(this.Z,this,!0)):(aP(),Date.now(),this.jT=!1))};
g.b.x5=function(){this.er=this.cZ.Cj;if(this.cZ.Ff)this.O6==0?this.XQ?(this.O6=1,MKL(this)):(this.O6=2,mz(this)):this.O6==2&&(this.jT?(aP(),xx(this.Z,this,!0)):(aP(),xx(this.Z,this,!1)));else{this.O6==0?aP():this.O6==2&&aP();var l=this.Z;this.cZ.getLastError();l.F6=this.er;Yx(l,2)}};
g.b.MO=function(){return this.Z.MO()};
g.b.isActive=function(){return this.Z.isActive()};
g.b.Y_=function(l){this.Z.Y_(l)};g.b=qY.prototype;g.b.G$=null;g.b.sy=null;g.b.Uv=null;g.b.zJ=null;g.b.Fh=null;g.b.QP=null;g.b.Sh=null;g.b.jt=null;g.b.NO=0;g.b.cN=0;g.b.Zd=null;g.b.Oe=null;g.b.b4=null;g.b.qI=null;g.b.sT=null;g.b.Wk=null;g.b.w8=-1;g.b.XM=-1;g.b.F6=-1;g.b.AU=0;g.b.yF=0;g.b.Jc=8;var Jnv={OK:0,mdj:2,Go:4,P8:5,GEz:6,STOP:7,vN:8,nV:9,a5:10,Sv:11,Lk:12};g.J5(cMB,g.$c);g.J5(CDo,g.$c);g.b=qY.prototype;
g.b.connect=function(l,y,k,z,r){aP();this.Fh=y;this.sy=k||{};z&&r!==void 0&&(this.sy.OSID=z,this.sy.OAID=r);this.A?(hd((0,g.We)(this.ws,this,l),100),b6O(this)):this.ws(l)};
g.b.disconnect=function(){uSR(this);if(this.Z==3){var l=this.NO++;const y=this.QP.clone();g.ke(y,"SID",this.V);g.ke(y,"RID",l);g.ke(y,"TYPE","terminate");P8(this,y);l=new iV(this,this.V,l);l.VP=2;l.hI=eh(y.clone());(new Image).src=l.hI.toString();l.bl=Date.now();MY(l)}VKo(this)};
g.b.ws=function(l){this.sT=new U0O(this);this.sT.wv=this.G$;this.sT.C=this.J;this.sT.connect(l)};
g.b.AC=function(){return this.Z==0};
g.b.getState=function(){return this.Z};
g.b.gU=function(l){this.Oe=null;qi2(this,l)};
g.b.EM=function(){this.b4=null;this.zJ=new iV(this,this.V,"rpc",this.K);this.zJ.NI=this.G$;this.zJ.BM=0;var l=this.Sh.clone();g.ke(l,"RID","rpc");g.ke(l,"SID",this.V);g.ke(l,"CI",this.Wk?"0":"1");g.ke(l,"AID",this.w8);P8(this,l);g.ke(l,"TYPE","xmlhttp");Ud(this.zJ,l,!0,this.jt,!1)};
g.b.I0=function(l,y){if(this.Z!=0&&(this.zJ==l||this.Uv==l))if(this.F6=l.Cj,this.Uv==l&&this.Z==3)if(this.Jc>7){try{var k=this.J.parse(y)}catch(z){k=null}if(Array.isArray(k)&&k.length==3)if(l=k,l[0]==0)a:{if(!this.b4){if(this.zJ)if(this.zJ.bl+3E3<this.Uv.bl)IP(this),this.zJ.cancel(),this.zJ=null;else break a;Jd(this);aP()}}else this.XM=l[1],0<this.XM-this.w8&&l[2]<37500&&this.Wk&&this.yF==0&&!this.qI&&(this.qI=hd((0,g.We)(this.hw,this),6E3));else Yx(this,11)}else y!="y2f%"&&Yx(this,11);else if(this.zJ==
l&&IP(this),!g.G0(y))for(l=this.J.parse(y),y=0;y<l.length;y++)k=l[y],this.w8=k[0],k=k[1],this.Z==2?k[0]=="c"?(this.V=k[1],this.jt=k[2],k=k[3],k!=null?this.Jc=k:this.Jc=6,this.Z=3,this.Zd&&this.Zd.BR(),this.Sh=uV(this,this.MO()?this.jt:null,this.Fh),WO1(this)):k[0]=="stop"&&Yx(this,7):this.Z==3&&(k[0]=="stop"?Yx(this,7):k[0]!="noop"&&this.Zd&&this.Zd.mA(k),this.yF=0)};
g.b.hw=function(){this.qI!=null&&(this.qI=null,this.zJ.cancel(),this.zJ=null,Jd(this),aP())};
g.b.x5=function(l){if(this.zJ==l){IP(this);this.zJ=null;var y=2}else if(this.Uv==l)this.Uv=null,y=1;else return;this.F6=l.Cj;if(this.Z!=0)if(l.Ff)if(y==1){y=l.V2?l.V2.length:0;l=Date.now()-l.bl;var k=Gm;k.dispatchEvent(new cMB(k,y,l,this.AU));W8(this);this.Zd&&this.Zd.yl(this,this.N);this.N.length=0}else WO1(this);else{k=l.getLastError();var z;if(!(z=k==3||k==7||k==0&&this.F6>0)){if(z=y==1)this.Uv||this.Oe||this.Z==1||this.AU>=2?z=!1:(this.Oe=hd((0,g.We)(this.gU,this,l),ILR(this,this.AU)),this.AU++,
z=!0);z=!(z||y==2&&Jd(this))}if(z)switch(k){case 1:Yx(this,5);break;case 4:Yx(this,10);break;case 3:Yx(this,6);break;case 7:Yx(this,12);break;default:Yx(this,2)}}};
g.b.Yx=function(l){if(!g.ro(arguments,this.Z))throw Error("Unexpected channel state: "+this.Z);};
g.b.XY=function(l){l?aP():(aP(),TsR(this,8))};
g.b.AT=function(l){if(l)throw Error("Can't create secondary domain capable XhrIo object.");l=new g.qm;l.K=!1;return l};
g.b.isActive=function(){return!!this.Zd&&this.Zd.isActive(this)};
g.b.Y_=function(l){const y=Gm;y.dispatchEvent(new CDo(y,l))};
g.b.MO=function(){return!1};
new miB;g.b=PDR.prototype;g.b.BR=function(){};
g.b.mA=function(){};
g.b.yl=function(){};
g.b.Kq=function(){};
g.b.O9=function(){};
g.b.At=function(){return{}};
g.b.isActive=function(){return!0};g.b=JM2.prototype;g.b.enqueue=function(l){this.C.push(l)};
g.b.isEmpty=function(){return this.Z.length===0&&this.C.length===0};
g.b.clear=function(){this.Z=[];this.C=[]};
g.b.contains=function(l){return g.ro(this.Z,l)||g.ro(this.C,l)};
g.b.remove=function(l){{var y=this.Z;const k=Array.prototype.lastIndexOf.call(y,l,y.length-1);k>=0?(g.ef(y,k),y=!0):y=!1}return y||g.Ap(this.C,l)};
g.b.s2=function(){const l=[];for(var y=this.Z.length-1;y>=0;--y)l.push(this.Z[y]);y=this.C.length;for(let k=0;k<y;++k)l.push(this.C[k]);return l};var YX1=class extends g.$c{constructor(l){super("channelMessage");this.message=l}},pco=class extends g.$c{constructor(l){super("channelError");this.error=l}};g.J5(pH,g.zP);g.b=pH.prototype;g.b.e_=function(){this.retryCount++;this.h6=Math.min(3E5,this.h6*2);this.C();this.fm&&this.start()};
g.b.fY=function(){return this.retryCount};
g.b.start=function(){const l=this.h6+15E3*Math.random();this.Z.Kl(l);this.fm=Date.now()+l};
g.b.stop=function(){this.Z.stop();this.fm=0};
g.b.isActive=function(){return this.Z.isActive()};
g.b.reset=function(){this.Z.stop();this.retryCount=0;this.h6=5E3};g.J5(KH,PDR);g.b=KH.prototype;g.b.subscribe=function(l,y,k){return this.K.subscribe(l,y,k)};
g.b.unsubscribe=function(l,y,k){return this.K.unsubscribe(l,y,k)};
g.b.Dl=function(l){return this.K.Dl(l)};
g.b.publish=function(l,y){return this.K.publish.apply(this.K,arguments)};
g.b.dispose=function(){this.D||(this.D=!0,g.yb(this.K),this.disconnect(),g.yb(this.C),this.C=null,this.RR=()=>"",this.rb=()=>g.SK({}))};
g.b.IR=function(){return this.D};
g.b.connect=async function(l,y,k){try{this.A&&await this.J}finally{if(this.D||this.Z&&this.Z.getState()==2&&!this.N)return;this.Ja="";this.N||this.C.stop();this.Y=l||null;this.C_=y||0;const z=this.u0+"/test",r=this.u0+"/bind";l=new qY(k?k.firstTestResults:null,k?k.secondTestResults:null,this.kz);const Z=this.Z;Z&&(Z.Zd=null);l.Zd=this;this.Z=l;if(this.A)return this.J=Ed(this).then(()=>ncL(this,z,r,Z,k)),this.J.then(()=>{this.J=g.SK()});
ncL(this,z,r,Z,k)}};
g.b.disconnect=function(l){try{this.A&&(this.J.cancel(),this.J=g.SK())}finally{this.sj=l||0,this.C&&this.C.stop(),gA(this),this.Z&&(this.Z.getState()==3&&qi2(this.Z),this.Z.disconnect()),this.sj=0}};
g.b.sendMessage=async function(l,y){try{this.A&&await this.J}finally{if(this.D)return;const k={_sc:l};y&&g.Am(k,y);if(this.C.isActive()||(this.Z?this.Z.getState():0)==2)this.V.push(k);else if(this.hN())try{this.A&&!ocf(this,l)&&await Ed(this)}finally{this.hN()&&(ocf(this,l),gA(this),Tm(this.Z,k))}}};
g.b.BR=function(){this.S&&this.C&&this.C.fY()>0&&(this.S.RZr(this.C.fY(),this.N,!0),this.S.vw$());this.S&&this.S.TYa();this.N?(this.C.stop(),g.yb(this.C),this.C=new pH(this.Mk,this),this.N=!1):this.C.reset();this.Y=null;this.C_=0;if(this.V.length)if(this.A)Nsx(this);else{var l=this.V;this.V=[];var y=l.length;for(let k=0;k<y;++k)Tm(this.Z,l[k]);fH(this);fH(this)}else fH(this)};
g.b.Kq=function(l){var y=l==2&&this.Z.F6==401;l==4||y||(this.N&&!this.C.isActive()&&(g.yb(this.C),this.C=new pH(this.Mk,this),this.N=!1),this.C.start());this.publish("handlerError",l,y);y=Object.keys(Jnv).find(k=>Jnv[k]===l);
this.Xr.Z("BROWSER_CHANNEL",y??"UNKNOWN")};
g.b.O9=function(l,y){if(!this.C.isActive())this.publish("handlerClosed");else if(y){const k=y.length;for(let z=0;z<k;++z){const r=y[z].map;r&&this.V.push(r)}}this.PG.Z("BROWSER_CHANNEL");l&&g.wm(this.hv.C,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps",l.length);y&&g.wm(this.MW.C,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps",y.length)};
g.b.yl=function(l,y){y!=null&&l!=null&&this.xz.Z()};
g.b.At=function(){const l={v:2};this.Ja&&(l.gsessionid=this.Ja);this.C_!=0&&(l.ui=""+this.C_);this.sj!=0&&(l.ui=""+this.sj);this.Y&&g.Am(l,this.Y);return l};
g.b.mA=function(l){l[0]=="S"?this.Ja=l[1]:l[0]=="gracefulReconnect"?(this.C.start(),this.Z.disconnect()):this.publish("handlerMessage",new YiL(l[0],l[1]));this.mK.Z("BROWSER_CHANNEL")};
g.b.hN=function(){return!!this.Z&&this.Z.getState()==3};
g.b.IV=function(l){(this.b0.loungeIdToken=l)||this.C.stop();if(this.T7&&this.Z){const y=this.Z.G$||{};l?y["X-YouTube-LoungeId-Token"]=l:delete y["X-YouTube-LoungeId-Token"];this.Z.G$=y}};
g.b.getDeviceId=function(){return this.b0.id};
g.b.yT=function(){return this.C.isActive()?this.C.fm-Date.now():NaN};
g.b.tN=function(){var l=this.C;g.H_(l.Z);l.start()};
g.b.Mk=function(){this.C.isActive();x0e(this.Z)==0&&this.connect(this.Y,this.C_)};jt.prototype.sendRequest=function(l,y,k,z,r,Z,e){l={format:Z?"RAW":"JSON",method:l,context:this,timeout:5E3,withCredentials:!!e,onSuccess:g.IC(this.V,z,!Z),onError:g.IC(this.N,r),onTimeout:g.IC(this.J,r)};k&&(l.postParams=k,l.headers={"Content-Type":"application/x-www-form-urlencoded"});return g.o3(y,l)};
jt.prototype.V=function(l,y,k,z){y?l(z):l({text:k.responseText})};
jt.prototype.N=function(l,y){l(Error("Request error: "+y.status))};
jt.prototype.J=function(l){l(Error("request timed out"))};var H6R=class extends g.Wd{constructor(l,y){super();this.handler=l();this.handler.subscribe("handlerOpened",this.Z,this);this.handler.subscribe("handlerClosed",this.onClosed,this);this.handler.subscribe("handlerError",(k,z)=>{this.onError(z)});
this.handler.subscribe("handlerMessage",this.onMessage,this);this.C=y}connect(l,y,k){this.handler.connect(l,y,k)}disconnect(l){this.handler.disconnect(l)}tN(){this.handler.tN()}getDeviceId(){return this.handler.getDeviceId()}yT(){return this.handler.yT()}hN(){return this.handler.hN()}Z(){this.dispatchEvent("channelOpened");var l=this.handler,y=this.C;g.eY("yt-remote-session-browser-channel",{firstTestResults:[""],secondTestResults:!l.Z.Wk,sessionId:l.Z.V,arrayId:l.Z.w8});g.eY("yt-remote-session-screen-id",
y);l=cP();y=b1();g.ro(l,y)||l.push(y);QVw(l);u1()}onClosed(){this.dispatchEvent("channelClosed")}onMessage(l){this.dispatchEvent(new YX1(l))}onError(l){this.dispatchEvent(new pco(l?1:0))}sendMessage(l,y){this.handler.sendMessage(l,y)}IV(l){this.handler.IV(l)}dispose(){this.handler.dispose()}};var BsR=class{constructor(l,y,k=()=>""){new Z6L;
var z=new g.W9;this.pathPrefix=l;this.Z=y;this.b0=k;this.J=z;this.A=null;this.D=this.K=0;this.channel=null;this.S=0;this.N=new pH(()=>{this.N.isActive();this.channel?.V().C()===0&&this.connect(this.A,this.K)});
this.V={};this.C={};this.C_=!1;this.logger=null;this.Y=[];this.I9=void 0;this.RR=new pdy;this.sj=new KOO;this.HG=new Ec1;this.Ja=new fL1}connect(l={},y=0){this.S!==2&&(this.N.stop(),this.A=l,this.K=y,nH(this),(l=g.Y("ID_TOKEN"))?this.V["x-youtube-identity-token"]=l:delete this.V["x-youtube-identity-token"],this.Z&&(this.C.device=this.Z.device,this.C.name=this.Z.name,this.C.app=this.Z.app,this.C.id=this.Z.id,this.Z.ZF&&(this.C.mdxVersion=`${this.Z.ZF}`),this.Z.theme&&(this.C.theme=this.Z.theme),this.Z.capabilities&&
(this.C.capabilities=this.Z.capabilities),this.Z.An&&(this.C.cst=this.Z.An),this.Z.authuser&&(this.C.authuser=this.Z.authuser),this.Z.pageId&&(this.C.pageId=this.Z.pageId)),this.K!==0?this.C.ui=`${this.K}`:delete this.C.ui,Object.assign(this.C,this.A),this.channel=new dA(this.pathPrefix,{oP:"gsessionid",sO:this.V,Nr:this.C}),this.channel.open(),this.S=2,LOf(this))}disconnect(l=0){this.D=l;this.N.stop();nH(this);this.channel&&(this.D!==0?this.C.ui=`${this.D}`:delete this.C.ui,this.channel.close());
this.D=0}yT(){return this.N.isActive()?this.N.fm-Date.now():NaN}tN(){var l=this.N;g.H_(l.Z);l.start()}sendMessage(l,y){this.channel&&(nH(this),this.channel.send({_sc:l,...y}))}IV(l){l||this.N.stop();l?this.V["X-YouTube-LoungeId-Token"]=l:delete this.V["X-YouTube-LoungeId-Token"]}getDeviceId(){return this.Z?this.Z.id:""}publish(l,...y){return this.J.publish(l,...y)}subscribe(l,y,k){return this.J.subscribe(l,y,k)}unsubscribe(l,y,k){return this.J.unsubscribe(l,y,k)}Dl(l){return this.J.Dl(l)}dispose(){this.C_||
(this.C_=!0,g.yb(this.J),this.disconnect(),g.yb(this.N),this.b0=()=>"")}IR(){return this.C_}};var vcv=class extends g.Wd{constructor(l){super();this.Z=l();this.Z.subscribe("webChannelOpened",this.C,this);this.Z.subscribe("webChannelClosed",this.onClosed,this);this.Z.subscribe("webChannelError",this.onError,this);this.Z.subscribe("webChannelMessage",this.onMessage,this)}connect(l,y){this.Z.connect(l,y)}disconnect(l){this.Z.disconnect(l)}tN(){this.Z.tN()}getDeviceId(){return this.Z.getDeviceId()}yT(){return this.Z.yT()}hN(){return this.Z.S===3}C(){this.dispatchEvent("channelOpened")}onClosed(){this.dispatchEvent("channelClosed")}onMessage(l){this.dispatchEvent(new YX1(l))}onError(){this.dispatchEvent(new pco(this.Z.I9===
401?1:0))}sendMessage(l,y){this.Z.sendMessage(l,y)}IV(l){this.Z.IV(l)}dispose(){this.Z.dispose()}};var ZSx=Date.now(),Fq=null,LH=Array(50),sd=-1,v8=!1;g.J5(B8,g.z1);B8.prototype.QG=function(){return this.screens};
B8.prototype.contains=function(l){return!!MT(this.screens,l)};
B8.prototype.get=function(l){return l?Xz(this.screens,l):null};
B8.prototype.info=function(l){oP(this.S,l)};var gCp=class extends g.z1{constructor(l,y,k,z,r){super();this.V=l;this.Y=y;this.A=k;this.C_=z;this.D=r;this.C=0;this.Z=null;this.Aj=NaN}start(){!this.Z&&isNaN(this.Aj)&&this.N()}stop(){this.Z&&(this.Z.abort(),this.Z=null);isNaN(this.Aj)||(g.pl(this.Aj),this.Aj=NaN)}Vj(){this.stop();super.Vj()}N(){this.Aj=NaN;this.Z=g.o3(St(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:this.Y},timeout:5E3,onSuccess:(0,g.We)(this.S,this),onError:(0,g.We)(this.J,this),onTimeout:(0,g.We)(this.K,
this)})}S(l,y){this.Z=null;l=y.screen||{};l.dialId=this.A;l.name=this.C_;y=-1;this.D&&l.shortLivedLoungeToken&&l.shortLivedLoungeToken.value&&l.shortLivedLoungeToken.refreshIntervalMs&&(l.screenIdType="shortLived",l.loungeToken=l.shortLivedLoungeToken.value,y=l.shortLivedLoungeToken.refreshIntervalMs);this.publish("pairingComplete",new hh(l),y)}J(l){this.Z=null;l.status&&l.status==404?this.C>=K0o.length?this.publish("pairingFailed",Error("DIAL polling timed out")):(l=K0o[this.C],this.Aj=g.JK((0,g.We)(this.N,
this),l),this.C++):this.publish("pairingFailed",Error("Server error "+l.status))}K(){this.Z=null;this.publish("pairingFailed",Error("Server not responding"))}},K0o=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.J5(RP,B8);g.b=RP.prototype;g.b.start=function(){H8(this)&&this.publish("screenChange");!g.Ay("yt-remote-lounge-token-expiration")&&Q72(this);g.pl(this.Z);this.Z=g.JK((0,g.We)(this.start,this),1E4)};
g.b.add=function(l,y){H8(this);e4y(this,l);DR(this,!1);this.publish("screenChange");y(l);l.token||Q72(this)};
g.b.remove=function(l,y){let k=H8(this);$mB(this,l)&&(DR(this,!1),k=!0);y(l);k&&this.publish("screenChange")};
g.b.T0=function(l,y,k,z){let r=H8(this);const Z=this.get(l.id);Z?(Z.name!=y&&(Z.name=y,DR(this,!1),r=!0),k(l)):z(Error("no such local screen."));r&&this.publish("screenChange")};
g.b.Vj=function(){g.pl(this.Z);RP.Ws.Vj.call(this)};
g.b.ZC=function(l){H8(this);let y=this.screens.length;l=l&&l.screens||[];const k=l.length;for(let z=0;z<k;++z){const r=l[z],Z=this.get(r.screenId);Z&&(Z.token=r.loungeToken,--y)}DR(this,!y);y&&oP(this.S,"Missed "+y+" lounge tokens.")};
g.b.hq=function(l){oP(this.S,"Requesting lounge tokens failed: "+l)};var Um2=class extends g.z1{constructor(l,y){super();this.S=y;y=(y=g.Ay("yt-remote-online-screen-ids")||"")?y.split(","):[];const k={},z=this.S(),r=z.length;for(let Z=0;Z<r;++Z){const e=z[Z].id;k[e]=g.ro(y,e)}this.Z=k;this.J=l;this.N=this.V=NaN;this.C=null;lK("Initialized with "+g.cU(this.Z))}start(){const l=parseInt(g.Ay("yt-remote-fast-check-period")||"0",10);(this.V=g.T5()-144E5<l?0:l)?yg(this):(this.V=g.T5()+3E5,g.eY("yt-remote-fast-check-period",this.V),this.K())}isEmpty(){return g.DB(this.Z)}update(){lK("Updating availability on schedule.");
const l=this.S(),y=g.jf(this.Z,function(k,z){return k&&!!Xz(l,z)},this);
kB(this,y)}Vj(){g.pl(this.N);this.N=NaN;this.C&&(this.C.abort(),this.C=null);super.Vj()}K(){g.pl(this.N);this.N=NaN;this.C&&this.C.abort();const l=OSy(this);if($3(l)){var y=St(this.J,"/pairing/get_screen_availability"),k={lounge_token:g.LR(l).join(",")};this.C=this.J.sendRequest("POST",y,k,(0,g.We)(this.D,this,l),(0,g.We)(this.A,this))}else kB(this,{}),yg(this)}D(l,y){this.C=null;var k=g.LR(OSy(this));if(g.u2(k,g.LR(l))){y=y.screens||[];k={};var z=y.length;for(let r=0;r<z;++r)k[l[y[r].loungeToken]]=
y[r].status=="online";kB(this,k);yg(this)}else this.JC("Changing Screen set during request."),this.K()}A(l){this.JC("Screen availability failed: "+l);this.C=null;yg(this)}JC(l){oP("OnlineScreenService",l)}};g.J5(rI,B8);g.b=rI.prototype;g.b.start=function(){this.C.start();this.Z.start();this.screens.length&&(this.publish("screenChange"),this.Z.isEmpty()||this.publish("onlineScreenChange"))};
g.b.add=function(l,y,k){this.C.add(l,y,k)};
g.b.remove=function(l,y,k){this.C.remove(l,y,k);this.Z.update()};
g.b.T0=function(l,y,k,z){this.C.contains(l)?this.C.T0(l,y,k,z):(l="Updating name of unknown screen: "+l.name,oP(this.S,l),z(Error(l)))};
g.b.QG=function(l){return l?this.screens:g.QL(this.screens,g.oC(this.N,function(y){return!this.contains(y)},this))};
g.b.wU=function(){return g.oC(this.QG(!0),function(l){return!!this.Z.Z[l.id]},this)};
g.b.xX=function(l,y,k,z,r,Z){this.info("getDialScreenByPairingCode "+l+" / "+y);const e=new gCp(this.V,l,y,k,z);e.subscribe("pairingComplete",(A,Q)=>{g.yb(e);r(Zt(this,A),Q)});
e.subscribe("pairingFailed",A=>{g.yb(e);Z(A)});
e.start();return(0,g.We)(e.stop,e)};
g.b.Z1=function(l,y,k,z){g.o3(St(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:l},timeout:5E3,onSuccess:(0,g.We)(function(r,Z){r=new hh(Z.screen||{});if(!r.name||G8w(this,r.name)){a:{Z=r.name;let e=2,A=y(Z,e);for(;G8w(this,A);){e++;if(e>20)break a;A=y(Z,e)}Z=A}r.name=Z}k(Zt(this,r))},this),
onError:(0,g.We)(function(r){z(Error("pairing request failed: "+r.status))},this),
onTimeout:(0,g.We)(function(){z(Error("pairing request timed out."))},this)})};
g.b.Vj=function(){g.yb(this.C);g.yb(this.Z);rI.Ws.Vj.call(this)};
g.b.sN=function(){iSp(this);this.publish("screenChange");this.Z.update()};
rI.prototype.dispose=rI.prototype.dispose;g.J5(Az,g.z1);g.b=Az.prototype;g.b.O7=function(l){this.IR()||(l&&(Qg(this,""+l),this.publish("sessionFailed")),this.Z=null,this.publish("sessionScreen",null))};
g.b.info=function(l){oP(this.Ja,l)};
g.b.fq=function(){return null};
g.b.sB=function(l){const y=this.C;l?(y.displayStatus=new chrome.cast.ReceiverDisplayStatus(l,[]),y.displayStatus.showStop=!0):y.displayStatus=null;chrome.cast.setReceiverDisplayStatus(y,(0,g.We)(function(){this.info("Updated receiver status for "+y.friendlyName+": "+l)},this),(0,g.We)(function(){Qg(this,"Failed to update receiver status for: "+y.friendlyName)},this))};
g.b.Vj=function(){this.sB("");Az.Ws.Vj.call(this)};var uF=class extends Az{constructor(l,y,k){super(l,y,"CastSession");this.config_=k;this.N=null;this.Y=(0,g.We)(this.RR,this);this.b0=(0,g.We)(this.rb,this);this.C_=g.JK(()=>{CnR(this,null)},12E4);
this.A=this.J=this.K=this.D=0}sj(l){if(this.N){if(this.N==l)return;Qg(this,"Overriding cast session with new session object");bSv(this);this.N.removeUpdateListener(this.Y);this.N.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.b0)}this.N=l;this.N.addUpdateListener(this.Y);this.N.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.b0);uZx(this,"getMdxSessionStatus")}S(l){this.info("launchWithParams no-op for Cast: "+g.cU(l))}stop(){this.N?this.N.stop((0,g.We)(function(){this.O7()},
this),(0,g.We)(function(){this.O7(Error("Failed to stop receiver app."))},this)):this.O7(Error("Stopping cast device without session."))}sB(){}Vj(){this.info("disposeInternal");
bSv(this);this.N&&(this.N.removeUpdateListener(this.Y),this.N.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.b0));this.N=null;super.Vj()}rb(l,y){if(!this.IR())if(y)if(y=Qf(y),g.uQ(y))switch(l=""+y.type,y=y.data||{},this.info("onYoutubeMessage_: "+l+" "+g.cU(y)),l){case "mdxSessionStatus":CnR(this,y);break;case "loungeToken":xm2(this,y);break;default:Qg(this,"Unknown youtube message: "+l)}else Qg(this,"Unable to parse message.");else Qg(this,"No data in message.")}HG(l,y,k,z){g.pl(this.D);
this.D=0;h4L(this.V,this.C.label,l,this.C.friendlyName,(0,g.We)(function(r){r?y(r):z>=0?(Qg(this,"Screen "+l+" appears to be offline. "+z+" retries left."),this.D=g.JK((0,g.We)(this.HG,this,l,y,k,z-1),300)):k(Error("Unable to fetch screen."))},this),k)}fq(){return this.N}RR(l){this.IR()||l||(Qg(this,"Cast session died."),this.O7())}};var EC2=class extends Az{constructor(l,y,k,z){super(l,y,"DialSession");this.config_=z;this.N=this.D=null;this.b0="";this.rb=k;this.RR=null;this.Y=()=>{};
this.C_=NaN;this.HG=(0,g.We)(this.u0,this);this.J=()=>{};
this.A=this.K=0}sj(l){this.N=l;this.N.addUpdateListener(this.HG)}S(l){this.RR=l;this.Y()}stop(){Tmo(this);this.N?this.N.stop((0,g.We)(this.O7,this,null),(0,g.We)(this.O7,this,"Failed to stop DIAL device.")):this.O7()}Vj(){Tmo(this);this.N&&this.N.removeUpdateListener(this.HG);this.N=null;super.Vj()}u0(l){this.IR()||l||(Qg(this,"DIAL session died."),this.J(),this.J=()=>{},this.O7())}};var fW1=class extends Az{constructor(l,y){super(l,y,"ManualSession");this.N=g.JK((0,g.We)(this.S,this,null),150)}stop(){this.O7()}sj(){}S(){g.pl(this.N);this.N=NaN;const l=Xz(this.V.QG(),this.C.label);l?$B(this,l):this.O7(Error("No such screen"))}Vj(){g.pl(this.N);this.N=NaN;super.Vj()}};var W1=class extends g.z1{constructor(l,y){super();this.config_=y;this.C=l;this.sj=y.appId||"233637DE";this.V=y.theme||"cl";this.Ja=y.disableCastApi||!1;this.K=y.forceMirroring||!1;this.Z=null;this.A=!1;this.N=[];this.S=(0,g.We)(this.RR,this)}init(l,y){chrome.cast.timeout.requestSession=3E4;var k=new chrome.cast.SessionRequest(this.sj,[chrome.cast.Capability.AUDIO_OUT]);g.EJ("desktop_enable_cast_connect")&&(k.androidReceiverCompatible=!0);this.Ja||(k.dialRequest=new chrome.cast.DialRequest("YouTube"));
const z=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;l=l||this.K?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;const r=(0,g.We)(this.rb,this);k=new chrome.cast.ApiConfig(k,(0,g.We)(this.D,this),r,z,l);k.customDialLaunchCallback=(0,g.We)(this.HG,this);chrome.cast.initialize(k,(0,g.We)(function(){this.IR()||(chrome.cast.addReceiverActionListener(this.S),k8R(),this.C.subscribe("onlineScreenChange",(0,g.We)(this.J,this)),this.N=K5f(this),chrome.cast.setCustomReceivers(this.N,
()=>{},(0,g.We)(function(Z){this.JC("Failed to set initial custom receivers: "+g.cU(Z))},this)),this.publish("yt-remote-cast2-availability-change",Gt(this)),y(!0))},this),(0,g.We)(function(Z){this.JC("Failed to initialize API: "+g.cU(Z));
y(!1)},this))}PG(l,y){ax("Setting connected screen ID: "+l+" -> "+y);
if(this.Z){var k=this.Z.Z;if(!l||k&&k.id!=l)ax("Unsetting old screen status: "+this.Z.C.friendlyName),iK(this,null)}if(l&&y){if(!this.Z){l=Xz(this.C.QG(),l);if(!l){ax("setConnectedScreenStatus: Unknown screen.");return}if(l.idType=="shortLived"){ax("setConnectedScreenStatus: Screen with id type to be short lived.");return}k=pUL(this,l);k||(ax("setConnectedScreenStatus: Connected receiver not custom..."),k=new chrome.cast.Receiver(l.uuid?l.uuid:l.id,l.name),k.receiverType=chrome.cast.ReceiverType.CUSTOM,
this.N.push(k),chrome.cast.setCustomReceivers(this.N,()=>{},(0,g.We)(function(z){this.JC("Failed to set initial custom receivers: "+g.cU(z))},this)));
ax("setConnectedScreenStatus: new active receiver: "+k.friendlyName);iK(this,new fW1(this.C,k),!0)}this.Z.sB(y)}else ax("setConnectedScreenStatus: no screen.")}Xr(l){this.IR()?this.JC("Setting connection data on disposed cast v2"):this.Z?this.Z.S(l):this.JC("Setting connection data without a session")}b0(){this.IR()?this.JC("Stopping session on disposed cast v2"):this.Z?(this.Z.stop(),iK(this,null)):ax("Stopping non-existing session")}requestSession(){chrome.cast.requestSession((0,g.We)(this.D,this),
(0,g.We)(this.u0,this))}Vj(){this.C.unsubscribe("onlineScreenChange",(0,g.We)(this.J,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.S);var l=D0o;const y=g.UT("yt.mdx.remote.debug.handlers_");g.Ap(y||[],l);g.yb(this.Z);super.Vj()}JC(l){oP("Controller",l)}C_(l,y){this.Z==l&&(y||iK(this,null),this.publish("yt-remote-cast2-session-change",y))}RR(l,y){if(!this.IR())if(l)switch(l.friendlyName=chrome.cast.unescape(l.friendlyName),ax("onReceiverAction_ "+l.label+" / "+l.friendlyName+
"-- "+y),y){case chrome.cast.ReceiverAction.CAST:if(this.Z)if(this.Z.C.label!=l.label)ax("onReceiverAction_: Stopping active receiver: "+this.Z.C.friendlyName),this.Z.stop();else{ax("onReceiverAction_: Casting to active receiver.");this.Z.Z&&this.publish("yt-remote-cast2-session-change",this.Z.Z);break}switch(l.receiverType){case chrome.cast.ReceiverType.CUSTOM:iK(this,new fW1(this.C,l));break;case chrome.cast.ReceiverType.DIAL:iK(this,new EC2(this.C,l,this.V,this.config_));break;case chrome.cast.ReceiverType.CAST:iK(this,
new uF(this.C,l,this.config_));break;default:this.JC("Unknown receiver type: "+l.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.Z&&this.Z.C.label==l.label?this.Z.stop():this.JC("Stopping receiver w/o session: "+l.friendlyName)}else this.JC("onReceiverAction_ called without receiver.")}HG(l){if(this.IR())return Promise.reject(Error("disposed"));var y=l.receiver;y.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.JC("Not DIAL receiver: "+y.friendlyName),y.receiverType=chrome.cast.ReceiverType.DIAL);
var k=this.Z?this.Z.C:null;if(!k||k.label!=y.label)return this.JC("Receiving DIAL launch request for non-clicked DIAL receiver: "+y.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(k&&k.label==y.label&&k.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.Z.Z)return ax("Reselecting dial screen."),this.publish("yt-remote-cast2-session-change",this.Z.Z),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.JC('Changing CAST intent from "'+k.receiverType+'" to "dial" for '+y.friendlyName);
iK(this,new EC2(this.C,y,this.V,this.config_))}y=this.Z;y.D=l;y.D.appState==chrome.cast.DialAppState.RUNNING?(l=y.D.extraData||{},k=l.screenId||null,wI(y)&&l.loungeToken?l.loungeTokenRefreshIntervalMs?l=YWe(y,{name:y.C.friendlyName,screenId:l.screenId,loungeToken:l.loungeToken,dialId:y.D.receiver.label,screenIdType:"shortLived"},l.loungeTokenRefreshIntervalMs):(g.tK(Error(`No loungeTokenRefreshIntervalMs presents in additionalData: ${JSON.stringify(l)}.`)),l=PnB(y,k)):l=PnB(y,k)):l=dI(y);return l}D(l){if(!this.IR()&&
!this.K){ax("New cast session ID: "+l.sessionId);var y=l.receiver;if(y.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.Z)if(y.receiverType==chrome.cast.ReceiverType.CAST)ax("Got resumed cast session before resumed mdx connection."),y.friendlyName=chrome.cast.unescape(y.friendlyName),iK(this,new uF(this.C,y,this.config_),!0);else{this.JC("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var k=this.Z.C,z=Xz(this.C.QG(),k.label);z&&GO(z,y.label)&&k.receiverType!=
chrome.cast.ReceiverType.CAST&&y.receiverType==chrome.cast.ReceiverType.CAST&&(ax("onSessionEstablished_: manual to cast session change "+y.friendlyName),g.yb(this.Z),this.Z=new uF(this.C,y,this.config_),this.Z.subscribe("sessionScreen",(0,g.We)(this.C_,this,this.Z)),this.Z.subscribe("sessionFailed",()=>gJB(this,this.Z)),this.Z.S(null));
this.Z.sj(l)}}}Y(){return this.Z?this.Z.fq():null}u0(l){this.IR()||(this.JC("Failed to estabilish a session: "+g.cU(l)),l.code!=chrome.cast.ErrorCode.CANCEL&&iK(this,null),this.publish("yt-remote-cast2-session-failed"))}rb(l){ax("Receiver availability updated: "+l);if(!this.IR()){var y=Gt(this);this.A=l==chrome.cast.ReceiverAvailability.AVAILABLE;Gt(this)!=y&&this.publish("yt-remote-cast2-availability-change",Gt(this))}}J(){this.IR()||(this.N=K5f(this),ax("Updating custom receivers: "+g.cU(this.N)),
chrome.cast.setCustomReceivers(this.N,()=>{},(0,g.We)(function(){this.JC("Failed to set custom receivers.")},this)),this.publish("yt-remote-cast2-availability-change",Gt(this)))}};
W1.prototype.setLaunchParams=W1.prototype.Xr;W1.prototype.setConnectedScreenStatus=W1.prototype.PG;W1.prototype.stopSession=W1.prototype.b0;W1.prototype.getCastSession=W1.prototype.Y;W1.prototype.requestSession=W1.prototype.requestSession;W1.prototype.init=W1.prototype.init;W1.prototype.dispose=W1.prototype.dispose;var bK=[],nJp=(0,g.vZ)`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js`;g.b=Ix.prototype;
g.b.reset=function(l){this.listId="";this.index=-1;this.videoId="";Tt(this);this.volume=-1;this.muted=!1;l&&(this.index=l.index,this.listId=l.listId,this.videoId=l.videoId,this.playerState=l.playerState,this.volume=l.volume,this.muted=l.muted,this.audioTrackId=l.audioTrackId,this.trackData=l.trackData,this.hasPrevious=l.hasPrevious,this.hasNext=l.hasNext,this.S=l.playerTime,this.J=l.playerTimeAt,this.C=l.seekableStart,this.K=l.seekableEnd,this.N=l.duration,this.loadedTime=l.loadedTime,this.Z=l.liveIngestionTime,
this.V=!isNaN(this.Z))};
g.b.isPlaying=function(){return this.playerState==1};
g.b.isBuffering=function(){return this.playerState==3};
g.b.BZ=function(l){this.N=isNaN(l)?0:l};
g.b.getDuration=function(){return this.V?this.N+Vg(this):this.N};
g.b.clone=function(){return new Ix(pn(this))};var jj2=class extends g.z1{constructor(){var l=Ae();super();this.N=0;this.V=l;this.K=[];this.J=new JM2;this.C=this.Z=null;this.Y=(0,g.We)(this.RR,this);this.D=(0,g.We)(this.S,this);this.C_=(0,g.We)(this.HG,this);this.Ja=(0,g.We)(this.rb,this);let y=0;l?(y=l.getProxyState(),y!=3&&(l.subscribe("proxyStateChange",this.sj,this),HSe(this))):y=3;y!=0&&g.JK(()=>{this.sj(y)},0);
(l=L5v())&&Kn(this,l);this.subscribe("yt-remote-cast2-session-change",this.Ja)}getState(){return this.N}yT(){return this.V.getReconnectTimeout()}tN(){this.V.reconnect()}play(){E8(this)?(this.Z?this.Z.play(null,g.Vq,jH(this,"play")):fn(this,"play"),nn(this,1,Jz(gI(this))),this.publish("remotePlayerChange")):FT(this,this.play)}pause(){E8(this)?(this.Z?this.Z.pause(null,g.Vq,jH(this,"pause")):fn(this,"pause"),nn(this,2,Jz(gI(this))),this.publish("remotePlayerChange")):FT(this,this.pause)}seekTo(l){if(E8(this)){if(this.Z){const y=
gI(this),k=new chrome.cast.media.SeekRequest;k.currentTime=l;y.isPlaying()||y.isBuffering()?k.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:k.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.Z.seek(k,g.Vq,jH(this,"seekTo",{newTime:l}))}else fn(this,"seekTo",{newTime:l});nn(this,3,l);this.publish("remotePlayerChange")}else FT(this,g.IC(this.seekTo,l))}stop(){if(E8(this)){this.Z?this.Z.stop(null,g.Vq,jH(this,"stopVideo")):fn(this,"stopVideo");var l=gI(this);l.index=-1;l.videoId=
"";Tt(l);SH(this,l);this.publish("remotePlayerChange")}else FT(this,this.stop)}setVolume(l,y){if(E8(this)){var k=gI(this);if(this.C){if(k.volume!=l){const z=Math.round(l)/100;this.C.setReceiverVolumeLevel(z,(0,g.We)(function(){NY("set receiver volume: "+z)},this),(0,g.We)(function(){this.JC("failed to set receiver volume.")},this))}k.muted!=y&&this.C.setReceiverMuted(y,(0,g.We)(function(){NY("set receiver muted: "+y)},this),(0,g.We)(function(){this.JC("failed to set receiver muted.")},this))}else{const z=
{volume:l,
muted:y};k.volume!=-1&&(z.delta=l-k.volume);fn(this,"setVolume",z)}k.muted=y;k.volume=l;SH(this,k)}else FT(this,g.IC(this.setVolume,l,y))}A(l,y){if(E8(this)){var k=gI(this);l={videoId:l};y&&(k.trackData={trackName:y.name,languageCode:y.languageCode,sourceLanguageCode:y.translationLanguage?y.translationLanguage.languageCode:"",languageName:y.languageName,kind:y.kind},l.style=g.cU(y.style),g.Am(l,k.trackData));fn(this,"setSubtitlesTrack",l);SH(this,k)}else FT(this,g.IC(this.A,l,y))}setAudioTrack(l,
y){E8(this)?(y=y.getLanguageInfo().getId(),fn(this,"setAudioTrack",{videoId:l,audioTrackId:y}),l=gI(this),l.audioTrackId=y,SH(this,l)):FT(this,g.IC(this.setAudioTrack,l,y))}playVideo(l,y,k,z=null,r=null,Z=null,e=null){const A=gI(this),Q={videoId:l};k!==void 0&&(Q.currentIndex=k);YB(A,l,k||0);y!==void 0&&(P1(A,y),Q.currentTime=y);z&&(Q.listId=z);r&&(Q.playerParams=r);Z&&(Q.clickTrackingParams=Z);e&&(Q.locationInfo=g.cU(e));fn(this,"setPlaylist",Q);z||SH(this,A)}ST(l,y){if(E8(this)){if(l&&y){const k=
gI(this);YB(k,l,y);SH(this,k)}fn(this,"previous")}else FT(this,g.IC(this.ST,l,y))}nextVideo(l,y){if(E8(this)){if(l&&y){const k=gI(this);YB(k,l,y);SH(this,k)}fn(this,"next")}else FT(this,g.IC(this.nextVideo,l,y))}IQ(){if(E8(this)){fn(this,"clearPlaylist");var l=gI(this);l.reset();SH(this,l);this.publish("remotePlayerChange")}else FT(this,this.IQ)}b0(){E8(this)?fn(this,"dismissAutoplay"):FT(this,this.b0)}dispose(){if(this.N!=3){const l=this.N;this.N=3;this.publish("proxyStateChange",l,this.N)}super.dispose()}Vj(){R4R(this);
this.V=null;this.J.clear();Kn(this,null);super.Vj()}sj(l){if((l!=this.N||l==2)&&this.N!=3&&l!=0){var y=this.N;this.N=l;this.publish("proxyStateChange",y,l);if(l==1)for(;!this.J.isEmpty();)y=l=this.J,y.Z.length===0&&(y.Z=y.C,y.Z.reverse(),y.C=[]),l.Z.pop().apply(this);else l==3&&this.dispose()}}u0(l,y){this.publish(l,y)}RR(l){if(!l)this.S(null),Kn(this,null);else if(this.C.receiver.volume){l=this.C.receiver.volume;const y=gI(this),k=Math.round(100*l.level||0);if(y.volume!=k||y.muted!=l.muted)NY("Cast volume update: "+
l.level+(l.muted?" muted":"")),y.volume=k,y.muted=!!l.muted,SH(this,y)}}S(l){NY("Cast media: "+!!l);this.Z&&this.Z.removeUpdateListener(this.C_);if(this.Z=l)this.Z.addUpdateListener(this.C_),Dme(this),this.publish("remotePlayerChange")}HG(l){l?(Dme(this),this.publish("remotePlayerChange")):this.S(null)}xo(){fn(this,"sendDebugCommand",{debugCommand:"stats4nerds "})}rb(){const l=L5v();l&&Kn(this,l)}JC(l){oP("CP",l)}};var aJ=class extends g.z1{constructor(l,y=!1){var k=H1,z=Zk();super();this.S=NaN;this.HG=!1;this.Y=this.C_=this.sj=this.Ja=NaN;this.b0=[];this.J=this.A=this.V=this.Z=this.C=null;this.mK=k;this.u0=y;this.b0.push(g.DY(window,"beforeunload",()=>{this.K(2)}));
this.N=[];this.Z=new Ix;this.xz=l.id;this.rb=l.idType;this.C=RUp(this.mK,z,this.RR,this.rb=="shortLived",this.xz);this.C.listen("channelOpened",()=>{lWR(this)});
this.C.listen("channelClosed",()=>{ox("Channel closed");isNaN(this.S)?x3(!0):x3();this.dispose()});
this.C.listen("channelError",r=>{x3();isNaN(this.D())?(r==1&&this.rb=="shortLived"&&this.publish("browserChannelAuthError",r),ox(`Channel error: ${r} without reconnection`),this.dispose()):(this.HG=!0,ox("Channel error: "+r+" with reconnection in "+this.D()+" ms"),s8(this,2))});
this.C.listen("channelMessage",r=>{du2(this,r)});
this.C.IV(l.token);this.subscribe("remoteQueueChange",()=>{var r=this.Z.videoId;g.QE()&&g.eY("yt-remote-session-video-id",r)})}connect(l,y){if(y){var k=y.listId;
const z=y.videoId,r=y.videoIds,Z=y.playerParams,e=y.clickTrackingParams,A=y.index,Q={videoId:z},t=y.currentTime,O=y.locationInfo;y=y.loopMode;t!==void 0&&(Q.currentTime=t<=5?0:t);Z&&(Q.playerParams=Z);O&&(Q.locationInfo=O);e&&(Q.clickTrackingParams=e);k&&(Q.listId=k);r&&r.length>0&&(Q.videoIds=r.join(","));A!==void 0&&(Q.currentIndex=A);this.u0&&(Q.loopMode=y||"LOOP_MODE_OFF");k&&(this.Z.listId=k);this.Z.videoId=z;this.Z.index=A||0;this.Z.state=3;P1(this.Z,t);this.J="UNSUPPORTED";k=this.u0?"setInitialState":
"setPlaylist";ox(`Connecting with ${k} and params: ${g.cU(Q)}`);this.C.connect({method:k,params:g.cU(Q)},l,tOO())}else ox("Connecting without params"),this.C.connect({},l,tOO());wce(this)}IV(l){this.C.IV(l)}dispose(){this.IR()||(g.iQ("yt.mdx.remote.remoteClient_",null),this.publish("beforeDispose"),s8(this,3));super.dispose()}Vj(){Ln(this);v1(this);ND(this);g.pl(this.C_);this.C_=NaN;g.pl(this.Y);this.Y=NaN;this.V=null;g.lw(this.b0);this.b0.length=0;this.C.dispose();super.Vj();this.J=this.A=this.N=
this.Z=this.C=null}Xr(l){if(!this.N||this.N.length===0)return!1;for(const y of this.N)if(!y.capabilities.has(l))return!1;return!0}T7(){let l=3;this.IR()||(l=0,isNaN(this.D())?this.C.hN()&&isNaN(this.S)&&(l=1):l=2);return l}K(l){ox("Disconnecting with "+l);g.iQ("yt.mdx.remote.remoteClient_",null);Ln(this);this.publish("beforeDisconnect",l);l==1&&x3();this.C.disconnect(l);this.dispose()}WG(){let l=this.Z;this.V&&(l=this.Z.clone(),YB(l,this.V,l.index));return pn(l)}MW(l){const y=new Ix(l);y.videoId&&
y.videoId!=this.Z.videoId&&(this.V=y.videoId,g.pl(this.C_),this.C_=g.JK(()=>{if(this.V){const z=this.V;this.V=null;this.Z.videoId!=z&&B1(this,"getNowPlaying")}},5E3));
const k=[];this.Z.listId==y.listId&&this.Z.videoId==y.videoId&&this.Z.index==y.index||k.push("remoteQueueChange");this.Z.playerState==y.playerState&&this.Z.volume==y.volume&&this.Z.muted==y.muted&&Jz(this.Z)==Jz(y)&&g.cU(this.Z.trackData)==g.cU(y.trackData)||k.push("remotePlayerChange");this.Z.reset(l);g.Fy(k,function(z){this.publish(z)},this)}PG(){const l=this.C.getDeviceId(),y=g.Dg(this.N,function(k){return k.type=="REMOTE_CONTROL"&&k.id!=l});
return y?y.id:""}D(){return this.C.yT()}Oj(){return this.J||"UNSUPPORTED"}kz(){return this.A||""}gb(){!isNaN(this.D())&&this.C.tN()}hv(l,y){B1(this,l,y);aWo(this)}RR(){var l=g.e_("SAPISID","")||g.e_("__Secure-1PAPISID")||"",y=g.e_("__Secure-3PAPISID","")||"";if(!l&&!y)return"";l=g.px(g.PG(l),2);y=g.px(g.PG(y),2);return g.px(g.PG(`,${l},${y}`),2)}};aJ.prototype.subscribe=aJ.prototype.subscribe;aJ.prototype.unsubscribeByKey=aJ.prototype.Dl;aJ.prototype.getProxyState=aJ.prototype.T7;
aJ.prototype.disconnect=aJ.prototype.K;aJ.prototype.getPlayerContextData=aJ.prototype.WG;aJ.prototype.setPlayerContextData=aJ.prototype.MW;aJ.prototype.getOtherConnectedRemoteId=aJ.prototype.PG;aJ.prototype.getReconnectTimeout=aJ.prototype.D;aJ.prototype.getAutoplayMode=aJ.prototype.Oj;aJ.prototype.getAutoplayVideoId=aJ.prototype.kz;aJ.prototype.reconnect=aJ.prototype.gb;aJ.prototype.sendMessage=aJ.prototype.hv;aJ.prototype.getXsrfToken=aJ.prototype.RR;
aJ.prototype.isCapabilitySupportedOnConnectedDevices=aJ.prototype.Xr;var bf2=class extends B8{constructor(l){super("ScreenServiceProxy");this.NV=l;this.Z=[];this.Z.push(this.NV.$_s("screenChange",(0,g.We)(this.C,this)));this.Z.push(this.NV.$_s("onlineScreenChange",(0,g.We)(this.N,this)))}QG(l){return this.NV.$_gs(l)}contains(l){return!!this.NV.$_c(l)}get(l){return this.NV.$_g(l)}start(){this.NV.$_st()}add(l,y,k){this.NV.$_a(l,y,k)}remove(l,y,k){this.NV.$_r(l,y,k)}T0(l,y,k,z){this.NV.$_un(l,y,k,z)}Vj(){const l=this.Z.length;for(let y=0;y<l;++y)this.NV.$_ubk(this.Z[y]);
this.Z.length=0;this.NV=null;super.Vj()}C(){this.publish("screenChange")}N(){this.publish("onlineScreenChange")}};rI.prototype.$_st=rI.prototype.start;rI.prototype.$_gspc=rI.prototype.Z1;rI.prototype.$_gsppc=rI.prototype.xX;rI.prototype.$_c=rI.prototype.contains;rI.prototype.$_g=rI.prototype.get;rI.prototype.$_a=rI.prototype.add;rI.prototype.$_un=rI.prototype.T0;rI.prototype.$_r=rI.prototype.remove;rI.prototype.$_gs=rI.prototype.QG;rI.prototype.$_gos=rI.prototype.wU;rI.prototype.$_s=rI.prototype.subscribe;
rI.prototype.$_ubk=rI.prototype.Dl;var Ql=null,Gb=!1,H1=null,Rx=null,he=null,kS=[];var SXy=class extends g.zP{constructor(l,y,k){super();this.Z=l;this.L=y;this.WF=k;this.events=new g.cI(this);this.S=!1;this.A=new g.U5(64);this.C=new g.B_(this.RR,500,this);this.N=new g.B_(this.rb,1E3,this);this.C_=new PP(this.xz,0,this);this.V={};this.Y=new g.B_(this.PG,1E3,this);this.D=new g.iv(this.seekTo,1E3,this);this.Xr=this.events.j(this.L,"onVolumeChange",z=>{mue(this,z)});
g.x(this,this.events);this.events.j(y,"onCaptionsTrackListChanged",this.gb);this.events.j(y,"captionschanged",this.mK);this.events.j(y,"captionssettingschanged",this.u0);this.events.j(y,"videoplayerreset",this.K);this.events.j(y,"mdxautoplaycancel",()=>{this.WF.b0()});
y.X("enable_mdx_video_play_directly")&&this.events.j(y,"videodatachange",()=>{IWB(this.Z)||iF(this)||Ma(this,0)});
l=this.WF;l.IR();l.subscribe("proxyStateChange",this.HG,this);l.subscribe("remotePlayerChange",this.J,this);l.subscribe("remoteQueueChange",this.K,this);l.subscribe("previousNextChange",this.Ja,this);l.subscribe("nowAutoplaying",this.sj,this);l.subscribe("autoplayDismissed",this.b0,this);g.x(this,this.C);g.x(this,this.N);g.x(this,this.C_);g.x(this,this.Y);g.x(this,this.D);this.u0();this.K();this.J()}Vj(){super.Vj();this.C.stop();this.N.stop();this.C_.stop();const l=this.WF;l.unsubscribe("proxyStateChange",
this.HG,this);l.unsubscribe("remotePlayerChange",this.J,this);l.unsubscribe("remoteQueueChange",this.K,this);l.unsubscribe("previousNextChange",this.Ja,this);l.unsubscribe("nowAutoplaying",this.sj,this);l.unsubscribe("autoplayDismissed",this.b0,this);this.WF=this.Z=null}Vs(l,...y){if(this.WF.N!=2)if(iF(this)){if(gI(this.WF).playerState!=1081||l!=="control_seek")switch(l){case "control_toggle_play_pause":gI(this.WF).isPlaying()?this.WF.pause():this.WF.play();break;case "control_play":this.WF.play();
break;case "control_pause":this.WF.pause();break;case "control_seek":this.D.V(y[0],y[1]);break;case "control_subtitles_set_track":XM(this,y[0]);break;case "control_set_audio_track":this.setAudioTrack(y[0])}}else switch(l){case "control_toggle_play_pause":case "control_play":case "control_pause":l=this.L.getCurrentTime();Ma(this,l===0?void 0:l);break;case "control_seek":Ma(this,y[0]);break;case "control_subtitles_set_track":XM(this,y[0]);break;case "control_set_audio_track":this.setAudioTrack(y[0])}}mK(l){this.C_.Gp(l)}xz(l){this.Vs("control_subtitles_set_track",
g.DB(l)?null:l)}u0(){const l=this.L.getOption("captions","track");g.DB(l)||XM(this,l)}Pn(l){this.Z.Pn(l,this.L.getVideoData().lengthSeconds)}gb(){g.DB(this.V)||qXv(this,this.V);this.S=!1}HG(l,y){this.N.stop();y===2&&this.rb()}J(){if(iF(this)){this.C.stop();var l=gI(this.WF);switch(l.playerState){case 1080:case 1081:case 1084:case 1085:this.Z.Jl=1;break;case 1082:case 1083:this.Z.Jl=0;break;default:this.Z.Jl=-1}switch(l.playerState){case 1081:case 1:this.e2(new g.U5(8));this.RR();break;case 1085:case 3:this.e2(new g.U5(9));
break;case 1083:case 0:this.e2(new g.U5(2));this.D.stop();this.Pn(this.L.getVideoData().lengthSeconds);break;case 1084:this.e2(new g.U5(4));break;case 2:this.e2(new g.U5(4));this.Pn(Jz(l));break;case -1:this.e2(new g.U5(64));break;case -1E3:this.e2(new g.U5(128,{errorCode:"mdx.remoteerror",errorMessage:"Video n\u00e0y kh\u00f4ng kh\u1ea3 d\u1ee5ng \u0111\u1ec3 ph\u00e1t l\u1ea1i t\u1eeb xa.",kf:2}))}const k=gI(this.WF).trackData;l=k;var y=this.V;(l||y?l&&y&&l.trackName==y.trackName&&l.languageCode==
y.languageCode&&l.languageName==y.languageName&&l.kind==y.kind:1)||(this.V=k,qXv(this,k));l=gI(this.WF);l.volume===-1||Math.round(this.L.getVolume())===l.volume&&this.L.isMuted()===l.muted||this.Y.isActive()||this.PG()}else W0B(this)}Ja(){this.L.publish("mdxpreviousnextchange")}K(){iF(this)||W0B(this)}sj(l){isNaN(l)||this.L.publish("mdxnowautoplaying",l)}b0(){this.L.publish("mdxautoplaycanceled")}setAudioTrack(l){iF(this)&&this.WF.setAudioTrack(Uh(this).videoId,l)}seekTo(l,y){gI(this.WF).playerState===
-1?Ma(this,l):y&&this.WF.seekTo(l)}PG(){if(iF(this)){var l=gI(this.WF);this.events.uq(this.Xr);l.muted?this.L.mute():this.L.unMute();this.L.setVolume(l.volume);this.Xr=this.events.j(this.L,"onVolumeChange",y=>{mue(this,y)})}}RR(){this.C.stop();
if(!this.WF.IR()){var l=gI(this.WF);l.isPlaying()&&this.e2(new g.U5(8));this.Pn(Jz(l));this.C.start()}}rb(){this.N.stop();this.C.stop();const l=this.WF.yT();this.WF.N==2&&!isNaN(l)&&this.N.start()}e2(l){this.N.stop();const y=this.A;if(!g.ut(y,l)){const k=l.Z(2);k!==this.A.Z(2)&&this.L.on(k);this.A=l;T3w(this.Z,y,l)}}};var nCy=class extends g.BE{constructor(l,y){super(l);this.Z=y}getCurrentTime(){return this.Z.getCurrentTime()}getDuration(){return this.Z.getDuration()}QK(){return this.Z.QK()}qS(){return this.Z.qS()}L2(){return this.Z.L2()}ET(){return this.Z.ET()}getPlayerState(){return this.Z.fp}isAtLiveHead(){return this.Z.isAtLiveHead()}pauseVideo(){cg(this.Z,"control_pause")}async playVideo(){cg(this.Z,"control_play")}seekTo(l,y){cg(this.Z,"control_seek",l,!y?.Ef)}LR(l){cg(this.Z,"control_set_audio_track",l);
return!0}};var F01=class extends g.H{constructor(){super({U:"div",B:"ytp-mdx-popup-dialog",G:{role:"dialog"},W:[{U:"div",B:"ytp-mdx-popup-dialog-inner-content",W:[{U:"div",B:"ytp-mdx-popup-title",Nd:"B\u1ea1n \u0111\u00e3 \u0111\u0103ng xu\u1ea5t"},{U:"div",B:"ytp-mdx-popup-description",Nd:"C\u00e1c video m\u00e0 b\u1ea1n xem c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o nh\u1eadt k\u00fd xem v\u00e0 g\u00e2y \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn ph\u1ea7n \u0111\u1ec1 xu\u1ea5t tr\u00ean TV. \u0110\u1ec3 tr\u00e1nh \u0111i\u1ec1u n\u00e0y, h\u00e3y h\u1ee7y r\u1ed3i \u0111\u0103ng nh\u1eadp v\u00e0o YouTube tr\u00ean m\u00e1y t\u00ednh."},
{U:"div",B:"ytp-mdx-privacy-popup-buttons",W:[{U:"button",L_:["ytp-button","ytp-mdx-privacy-popup-cancel"],Nd:"H\u1ee7y"},{U:"button",L_:["ytp-button","ytp-mdx-privacy-popup-confirm"],Nd:"X\u00e1c nh\u1eadn"}]}]}]});this.fade=new g.oT(this,250);this.cancelButton=this.qd("ytp-mdx-privacy-popup-cancel");this.confirmButton=this.qd("ytp-mdx-privacy-popup-confirm");g.x(this,this.fade);this.j(this.cancelButton,"click",this.Z);this.j(this.confirmButton,"click",this.C)}Bn(){this.fade.show()}Xv(){this.fade.hide()}Z(){qT("mdx-privacy-popup-cancel");
this.Xv()}C(){qT("mdx-privacy-popup-confirm");this.Xv()}};var oC2=class extends g.H{constructor(l){super({U:"div",B:"ytp-remote",W:[{U:"div",B:"ytp-remote-display-status",W:[{U:"div",B:"ytp-remote-display-status-icon",W:[g.xSs()]},{U:"div",B:"ytp-remote-display-status-text",Nd:"{{statustext}}"}]}]});this.api=l;this.fade=new g.oT(this,250);g.x(this,this.fade);this.j(l,"presentingplayerstatechange",this.onStateChange);this.IU(l.getPlayerStateObject())}onStateChange(l){this.IU(l.state)}IU(l){if(this.api.getPresentingPlayerType()===3){const y={RECEIVER_NAME:this.api.getOption("remote",
"currentReceiver").name};l=l.Z(128)?g.Ts("L\u1ed7i tr\u00ean $RECEIVER_NAME",y):l.isPlaying()||l.isPaused()?g.Ts("\u0110ang ph\u00e1t tr\u00ean $RECEIVER_NAME",y):g.Ts("\u0110\u00e3 k\u1ebft n\u1ed1i v\u1edbi $RECEIVER_NAME",y);this.updateValue("statustext",l);this.fade.show()}else this.fade.hide()}};var N3e=class extends g.p1{constructor(l,y){super("Ph\u00e1t tr\u00ean",1,l,y);this.L=l;this.aD={};this.j(l,"onMdxReceiversChange",this.S);this.j(l,"presentingplayerstatechange",this.S);this.S()}S(){var l=this.L.getOption("remote","receivers");l&&l.length>1&&!this.L.getOption("remote","quickCast")?(this.aD=g.Ey(l,this.J,this),this.V(g.sT(l,this.J)),l=this.L.getOption("remote","currentReceiver"),l=this.J(l),this.options[l]&&this.C(l),this.enable(!0)):this.enable(!1)}J(l){return l.key}N(l){return l===
"cast-selector-receiver"?"Truy\u1ec1n...":this.aD[l].name}Z(l){super.Z(l);this.L.setOption("remote","currentReceiver",this.aD[l]);this.eN.Xv()}};g.EZ("remote",class extends g.f1{constructor(l){super(l);this.uN={key:UA(),name:"M\u00e1y t\u00ednh n\u00e0y"};this.KA=null;this.subscriptions=[];this.L$=this.WF=null;this.aD=[this.uN];this.VT=this.uN;this.fp=new g.U5(64);this.yN=0;this.Jl=-1;this.He=!1;this.xe=this.Q6=this.t8=null;if(!g.aq(this.player.O())&&!g.ow(this.player.O())){l=this.player;var y=g.Ci(l);y&&(y=y.Kf())&&(y=new N3e(l,y),g.x(this,y));y=new oC2(l);g.x(this,y);g.pi(l,y.element,4);this.t8=new F01;g.x(this,this.t8);g.pi(l,this.t8.element,
4);this.He=!!rT()}}create(){var l=this.player.O();const y=g.U9(l);l={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:l.X("mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:l.X("enable_dial_short_lived_lounge_token"),enableCastLoungeToken:l.X("enable_cast_short_lived_lounge_token")};Xc1(y,l);this.subscriptions.push(g.Du("yt-remote-before-disconnect",this.Sj,this));this.subscriptions.push(g.Du("yt-remote-connection-change",this.wi,this));this.subscriptions.push(g.Du("yt-remote-receiver-availability-change",
this.dR,this));this.subscriptions.push(g.Du("yt-remote-auto-connect",this.y3,this));this.subscriptions.push(g.Du("yt-remote-receiver-resumed",this.Bl,this));this.subscriptions.push(g.Du("mdx-privacy-popup-confirm",this.nN,this));this.subscriptions.push(g.Du("mdx-privacy-popup-cancel",this.S_,this));this.dR()}load(){this.player.cancelPlayback();super.load();this.xe=new nCy(this.player.O(),this);this.player.tO(this.xe);this.KA=new SXy(this,this.player,this.WF);var l=(l=xuR())?l.currentTime:0;const y=
wT()?new jj2:null;l==0&&y&&(l=Jz(gI(y)));l!==0&&this.Pn(l);T3w(this,this.fp,this.fp);this.player.iN(6)}unload(){this.player.publish("mdxautoplaycanceled");this.player.mC();this.VT=this.uN;g.kj(this.KA,this.WF);this.WF=this.xe=this.KA=null;super.unload();this.player.iN(5);Ch(this)}Vj(){g.lP(this.subscriptions);super.Vj()}getAdState(){return this.Jl}hasPrevious(){return this.WF?gI(this.WF).hasPrevious:!1}hasNext(){return this.WF?gI(this.WF).hasNext:!1}Pn(l,y){this.yN=l||0;this.player.publish("progresssync",
l,y);g.M1(this.player,"onVideoProgress",l||0)}getCurrentTime(){return this.yN}getDuration(){return gI(this.WF).getDuration()||0}QK(){var l=gI(this.WF);return l.V?l.Z+Vg(l):l.Z}qS(){return gI(this.WF).loadedTime}L2(){return BmL(gI(this.WF))}ET(){var l=gI(this.WF);return l.C>0?l.C+Vg(l):l.C}getProgressState(){const l=gI(this.WF),y=this.player.getVideoData();return{airingStart:0,airingEnd:0,allowSeeking:l.playerState!=1081&&this.player.wq(),clipEnd:y.clipEnd,clipStart:y.clipStart,current:this.getCurrentTime(),
displayedStart:-1,duration:this.getDuration(),ingestionTime:this.QK(),isAtLiveHead:this.isAtLiveHead(),loaded:this.qS(),seekableEnd:this.L2(),seekableStart:this.ET(),offset:0,viewerLivestreamJoinMediaTime:0}}isAtLiveHead(){return BmL(gI(this.WF))-this.getCurrentTime()<=1}nextVideo(){this.WF&&this.WF.nextVideo()}ST(){this.WF&&this.WF.ST()}Sj(l){l===1&&(this.L$=this.WF?gI(this.WF):null)}wi(){var l=wT()?new jj2:null;if(l){const y=this.VT;this.loaded&&this.unload();this.WF=l;this.L$=null;y.key!==this.uN.key&&
(this.VT=y,this.load())}else g.yb(this.WF),this.WF=null,this.loaded&&(this.unload(),(l=this.L$)&&l.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(l.videoId,Jz(l)));this.player.publish("videodatachange","newdata",this.player.getVideoData(),3)}dR(){var l=[this.uN],y=l.concat;const k=cn2();uK()&&g.Ay("yt-remote-cast-available")&&k.push({key:"cast-selector-receiver",name:"Cast..."});this.aD=y.call(l,k);l=$S()||this.uN;bF(this,l);g.M1(this.player,"onMdxReceiversChange")}y3(){const l=
$S();bF(this,l)}Bl(){this.VT=$S()}nN(){this.He=!0;Ch(this);Gb=!1;Ql&&Oh(Ql,1);Ql=null}S_(){this.He=!1;Ch(this);bF(this,this.uN);this.VT=this.uN;Gb=!1;Ql=null;this.player.playVideo()}ef(l,y){switch(l){case "casting":return this.loaded;case "receivers":return this.aD;case "currentReceiver":return y&&(y.key==="cast-selector-receiver"?mj():bF(this,y)),this.loaded?this.VT:this.uN;case "quickCast":return this.aD.length===2&&this.aD[1].key==="cast-selector-receiver"?(y&&mj(),!0):!1}}xo(){this.WF.xo()}Xf(){return!1}getOptions(){return["casting",
"receivers","currentReceiver","quickCast"]}isLoggedIn(){return g.Y("PLAYER_CONFIG")?.args?.authuser!==void 0?!0:!(!g.Y("SESSION_INDEX")&&!g.Y("LOGGED_IN"))}});})(_yt_player);
