K=null;g.b.d8=null;g.b.mS=!1;g.b.KS=null;g.b.mB=null;g.b.bu=-1;g.b.SF=null;g.b.FB=null;g.b.connect=function(D){this.KS=D;D=bf(this.L,null,this.KS);hf();Date.now();const X=this.L.N;X!=null?(this.SF=X[0],(this.FB=X[1])?(this.mB=1,i1K(this)):(this.mB=2,sE(this))):(yH(D,"MODE","init"),this.d8=new Jf(this),this.d8.Kg=this.gK,Ma(this.d8,D,!1,null,!0),this.mB=0)};
g.b.uC=function(D){if(D)this.mB=2,sE(this);else{hf();var X=this.L;X.nB=X.YH.bu;IP(X,9)}D&&this.Gy(2)};
g.b.Y5=function(D){return this.L.Y5(D)};
g.b.abort=function(){this.d8&&(this.d8.cancel(),this.d8=null);this.bu=-1};
g.b.Ew=function(){return!1};
g.b.IN=function(D,X){this.bu=D.Sg;if(this.mB==0)if(X){try{var B=this.Z.parse(X)}catch(C){D=this.L;D.nB=this.bu;IP(D,2);return}this.SF=B[0];this.FB=B[1]}else D=this.L,D.nB=this.bu,IP(D,2);else this.mB==2&&(this.mS?(hf(),Date.now()):X=="11111"?(hf(),this.mS=!0,Date.now(),this.bu=200,this.d8.cancel(),hf(),ko(this.L,this,!0)):(hf(),Date.now(),this.mS=!1))};
g.b.Dp=function(){this.bu=this.d8.Sg;if(this.d8.UZ)this.mB==0?this.FB?(this.mB=1,i1K(this)):(this.mB=2,sE(this)):this.mB==2&&(this.mS?(hf(),ko(this.L,this,!0)):(hf(),ko(this.L,this,!1)));else{this.mB==0?hf():this.mB==2&&hf();var D=this.L;this.d8.getLastError();D.nB=this.bu;IP(D,2)}};
g.b.XB=function(){return this.L.XB()};
g.b.isActive=function(){return this.L.isActive()};
g.b.Gy=function(D){this.L.Gy(D)};g.b=UE.prototype;g.b.rY=null;g.b.YR=null;g.b.va=null;g.b.Np=null;g.b.z3=null;g.b.yG=null;g.b.lA=null;g.b.wK=null;g.b.gx=0;g.b.hL=0;g.b.JV=null;g.b.o5=null;g.b.OO=null;g.b.Pt=null;g.b.YH=null;g.b.WW=null;g.b.pI=-1;g.b.aN=-1;g.b.nB=-1;g.b.ZO=0;g.b.kc=0;g.b.zO=8;var FMt={OK:0,wZa:2,E1:4,lH:5,mAG:6,STOP:7,u3:8,bZ:9,IR:10,aR:11,Gr:12};g.a$($E0,g.t1);g.a$(W1K,g.t1);g.b=UE.prototype;
g.b.connect=function(D,X,B,C,V){hf();this.z3=X;this.YR=B||{};C&&V!==void 0&&(this.YR.OSID=C,this.YR.OAID=V);this.K?(uf((0,g.U$)(this.D7,this,D),100),vmK(this)):this.D7(D)};
g.b.disconnect=function(){fT0(this);if(this.L==3){var D=this.gx++;const X=this.yG.clone();g.Xa(X,"SID",this.V);g.Xa(X,"RID",D);g.Xa(X,"TYPE","terminate");aP(this,X);D=new Jf(this,this.V,D);D.bB=2;D.Od=x5(X.clone());(new Image).src=D.Od.toString();D.yd=Date.now();Af(D)}jWJ(this)};
g.b.D7=function(D){this.YH=new mEt(this);this.YH.gK=this.rY;this.YH.Z=this.G;this.YH.connect(D)};
g.b.Ew=function(){return this.L==0};
g.b.getState=function(){return this.L};
g.b.Ot=function(D){this.o5=null;hZW(this,D)};
g.b.bA=function(){this.OO=null;this.Np=new Jf(this,this.V,"rpc",this.Y);this.Np.Kg=this.rY;this.Np.yB=0;var D=this.lA.clone();g.Xa(D,"RID","rpc");g.Xa(D,"SID",this.V);g.Xa(D,"CI",this.WW?"0":"1");g.Xa(D,"AID",this.pI);aP(this,D);g.Xa(D,"TYPE","xmlhttp");Ma(this.Np,D,!0,this.wK,!1)};
g.b.IN=function(D,X){if(this.L!=0&&(this.Np==D||this.va==D))if(this.nB=D.Sg,this.va==D&&this.L==3)if(this.zO>7){try{var B=this.G.parse(X)}catch(C){B=null}if(Array.isArray(B)&&B.length==3)if(D=B,D[0]==0)a:{if(!this.OO){if(this.Np)if(this.Np.yd+3E3<this.va.yd)cx(this),this.Np.cancel(),this.Np=null;else break a;Yo(this);hf()}}else this.aN=D[1],0<this.aN-this.pI&&D[2]<37500&&this.WW&&this.kc==0&&!this.Pt&&(this.Pt=uf((0,g.U$)(this.mI,this),6E3));else IP(this,11)}else X!="y2f%"&&IP(this,11);else if(this.Np==
D&&cx(this),!g.CR(X))for(D=this.G.parse(X),X=0;X<D.length;X++)B=D[X],this.pI=B[0],B=B[1],this.L==2?B[0]=="c"?(this.V=B[1],this.wK=B[2],B=B[3],B!=null?this.zO=B:this.zO=6,this.L=3,this.JV&&this.JV.yc(),this.lA=bf(this,this.XB()?this.wK:null,this.z3),JvA(this)):B[0]=="stop"&&IP(this,7):this.L==3&&(B[0]=="stop"?IP(this,7):B[0]!="noop"&&this.JV&&this.JV.Sf(B),this.kc=0)};
g.b.mI=function(){this.Pt!=null&&(this.Pt=null,this.Np.cancel(),this.Np=null,Yo(this),hf())};
g.b.Dp=function(D){if(this.Np==D){cx(this);this.Np=null;var X=2}else if(this.va==D)this.va=null,X=1;else return;this.nB=D.Sg;if(this.L!=0)if(D.UZ)if(X==1){X=D.wr?D.wr.length:0;D=Date.now()-D.yd;var B=pf;B.dispatchEvent(new $E0(B,X,D,this.ZO));RP(this);this.JV&&this.JV.XK(this,this.U);this.U.length=0}else JvA(this);else{B=D.getLastError();var C;if(!(C=B==3||B==7||B==0&&this.nB>0)){if(C=X==1)this.va||this.o5||this.L==1||this.ZO>=2?C=!1:(this.o5=uf((0,g.U$)(this.Ot,this,D),MvJ(this,this.ZO)),this.ZO++,
C=!0);C=!(C||X==2&&Yo(this))}if(C)switch(B){case 1:IP(this,5);break;case 4:IP(this,10);break;case 3:IP(this,6);break;case 7:IP(this,12);break;default:IP(this,2)}}};
g.b.xs=function(D){if(!g.XP(arguments,this.L))throw Error("Unexpected channel state: "+this.L);};
g.b.S$=function(D){D?hf():(hf(),AvN(this,8))};
g.b.Y5=function(D){if(D)throw Error("Can't create secondary domain capable XhrIo object.");D=new g.AE;D.Y=!1;return D};
g.b.isActive=function(){return!!this.JV&&this.JV.isActive(this)};
g.b.Gy=function(D){const X=pf;X.dispatchEvent(new W1K(X,D))};
g.b.XB=function(){return!1};
new pdt;g.b=H1X.prototype;g.b.yc=function(){};
g.b.Sf=function(){};
g.b.XK=function(){};
g.b.A9=function(){};
g.b.PT=function(){};
g.b.Y3=function(){return{}};
g.b.isActive=function(){return!0};g.b=F1t.prototype;g.b.enqueue=function(D){this.Z.push(D)};
g.b.isEmpty=function(){return this.L.length===0&&this.Z.length===0};
g.b.clear=function(){this.L=[];this.Z=[]};
g.b.contains=function(D){return g.XP(this.L,D)||g.XP(this.Z,D)};
g.b.remove=function(D){{var X=this.L;const B=Array.prototype.lastIndexOf.call(X,D,X.length-1);B>=0?(g.xg(X,B),X=!0):X=!1}return X||g.yN(this.Z,D)};
g.b.UJ=function(){const D=[];for(var X=this.L.length-1;X>=0;--X)D.push(this.L[X]);X=this.Z.length;for(let B=0;B<X;++B)D.push(this.Z[B]);return D};var z4t=class extends g.t1{constructor(D){super("channelMessage");this.message=D}},bQC=class extends g.t1{constructor(D){super("channelError");this.error=D}};g.a$(Kf,g.Sf);g.b=Kf.prototype;g.b.Z4=function(){this.retryCount++;this.Lh=Math.min(3E5,this.Lh*2);this.Z();this.pj&&this.start()};
g.b.oF=function(){return this.retryCount};
g.b.start=function(){const D=this.Lh+15E3*Math.random();this.L.MU(D);this.pj=Date.now()+D};
g.b.stop=function(){this.L.stop();this.pj=0};
g.b.isActive=function(){return this.L.isActive()};
g.b.reset=function(){this.L.stop();this.retryCount=0;this.Lh=5E3};g.a$(oP,H1X);g.b=oP.prototype;g.b.subscribe=function(D,X,B){return this.Y.subscribe(D,X,B)};
g.b.unsubscribe=function(D,X,B){return this.Y.unsubscribe(D,X,B)};
g.b.nH=function(D){return this.Y.nH(D)};
g.b.publish=function(D,X){return this.Y.publish.apply(this.Y,arguments)};
g.b.dispose=function(){this.N||(this.N=!0,g.wK(this.Y),this.disconnect(),g.wK(this.Z),this.Z=null,this.G2=()=>"",this.HZ=()=>g.Ym({}))};
g.b.S7=function(){return this.N};
g.b.connect=async function(D,X,B){try{this.K&&await this.G}finally{if(this.N||this.L&&this.L.getState()==2&&!this.U)return;this.U7="";this.U||this.Z.stop();this.J=D||null;this.Z3=X||0;const C=this.b0+"/test",V=this.b0+"/bind";D=new UE(B?B.firstTestResults:null,B?B.secondTestResults:null,this.xU);const x=this.L;x&&(x.JV=null);D.JV=this;this.L=D;if(this.K)return this.G=dQ(this).then(()=>qSt(this,C,V,x,B)),this.G.then(()=>{this.G=g.Ym()});
qSt(this,C,V,x,B)}};
g.b.disconnect=function(D){try{this.K&&(this.G.cancel(),this.G=g.Ym())}finally{this.s7=D||0,this.Z&&this.Z.stop(),ei(this),this.L&&(this.L.getState()==3&&hZW(this.L),this.L.disconnect()),this.s7=0}};
g.b.sendMessage=async function(D,X){try{this.K&&await this.G}finally{if(this.N)return;const B={_sc:D};X&&g.T8(B,X);if(this.Z.isActive()||(this.L?this.L.getState():0)==2)this.V.push(B);else if(this.l_())try{this.K&&!YS8(this,D)&&await dQ(this)}finally{this.l_()&&(YS8(this,D),ei(this),Na(this.L,B))}}};
g.b.yc=function(){this.S&&this.Z&&this.Z.oF()>0&&(this.S.cxc(this.Z.oF(),this.U,!0),this.S.I2Z());this.S&&this.S.WsG();this.U?(this.Z.stop(),g.wK(this.Z),this.Z=new Kf(this.uG,this),this.U=!1):this.Z.reset();this.J=null;this.Z3=0;if(this.V.length)if(this.K)IT0(this);else{var D=this.V;this.V=[];var X=D.length;for(let B=0;B<X;++B)Na(this.L,D[B]);Gk(this);Gk(this)}else Gk(this)};
g.b.A9=function(D){var X=D==2&&this.L.nB==401;D==4||X||(this.U&&!this.Z.isActive()&&(g.wK(this.Z),this.Z=new Kf(this.uG,this),this.U=!1),this.Z.start());this.publish("handlerError",D,X);X=Object.keys(FMt).find(B=>FMt[B]===D);
this.YU.L("BROWSER_CHANNEL",X??"UNKNOWN")};
g.b.PT=function(D,X){if(!this.Z.isActive())this.publish("handlerClosed");else if(X){const B=X.length;for(let C=0;C<B;++C){const V=X[C].map;V&&this.V.push(V)}}this.O7.L("BROWSER_CHANNEL");D&&g.Vk(this.Lr.Z,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps",D.length);X&&g.Vk(this.s2.Z,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps",X.length)};
g.b.XK=function(D,X){X!=null&&D!=null&&this.Cv.L()};
g.b.Y3=function(){const D={v:2};this.U7&&(D.gsessionid=this.U7);this.Z3!=0&&(D.ui=""+this.Z3);this.s7!=0&&(D.ui=""+this.s7);this.J&&g.T8(D,this.J);return D};
g.b.Sf=function(D){D[0]=="S"?this.U7=D[1]:D[0]=="gracefulReconnect"?(this.Z.start(),this.L.disconnect()):this.publish("handlerMessage",new zZN(D[0],D[1]));this.ww.L("BROWSER_CHANNEL")};
g.b.l_=function(){return!!this.L&&this.L.getState()==3};
g.b.jX=function(D){(this.pv.loungeIdToken=D)||this.Z.stop();if(this.mG&&this.L){const X=this.L.rY||{};D?X["X-YouTube-LoungeId-Token"]=D:delete X["X-YouTube-LoungeId-Token"];this.L.rY=X}};
g.b.getDeviceId=function(){return this.pv.id};
g.b.d1=function(){return this.Z.isActive()?this.Z.pj-Date.now():NaN};
g.b.GN=function(){var D=this.Z;g.OJ(D.L);D.start()};
g.b.uG=function(){this.Z.isActive();uCJ(this.L)==0&&this.connect(this.J,this.Z3)};Z7.prototype.sendRequest=function(D,X,B,C,V,x,y){D={format:x?"RAW":"JSON",method:D,context:this,timeout:5E3,withCredentials:!!y,onSuccess:g.R$(this.V,C,!x),onError:g.R$(this.U,V),onTimeout:g.R$(this.G,V)};B&&(D.postParams=B,D.headers={"Content-Type":"application/x-www-form-urlencoded"});return g.ns(X,D)};
Z7.prototype.V=function(D,X,B,C){X?D(C):D({text:B.responseText})};
Z7.prototype.U=function(D,X){D(Error("Request error: "+X.status))};
Z7.prototype.G=function(D){D(Error("request timed out"))};var Geg=class extends g.Jv{constructor(D,X){super();this.handler=D();this.handler.subscribe("handlerOpened",this.L,this);this.handler.subscribe("handlerClosed",this.onClosed,this);this.handler.subscribe("handlerError",(B,C)=>{this.onError(C)});
this.handler.subscribe("handlerMessage",this.onMessage,this);this.Z=X}connect(D,X,B){this.handler.connect(D,X,B)}disconnect(D){this.handler.disconnect(D)}GN(){this.handler.GN()}getDeviceId(){return this.handler.getDeviceId()}d1(){return this.handler.d1()}l_(){return this.handler.l_()}L(){this.dispatchEvent("channelOpened");var D=this.handler,X=this.Z;g.xk("yt-remote-session-browser-channel",{firstTestResults:[""],secondTestResults:!D.L.WW,sessionId:D.L.V,arrayId:D.L.pI});g.xk("yt-remote-session-screen-id",
X);D=jW();X=Fg();g.XP(D,X)||D.push(X);Ox8(D);zM()}onClosed(){this.dispatchEvent("channelClosed")}onMessage(D){this.dispatchEvent(new z4t(D))}onError(D){this.dispatchEvent(new bQC(D?1:0))}sendMessage(D,X){this.handler.sendMessage(D,X)}jX(D){this.handler.jX(D)}dispose(){this.handler.dispose()}};var dEg=class{constructor(D,X,B=()=>""){new TCW;
var C=new g.cs;this.pathPrefix=D;this.L=X;this.pv=B;this.G=C;this.K=null;this.N=this.Y=0;this.channel=null;this.S=0;this.U=new Kf(()=>{this.U.isActive();this.channel?.V().Z()===0&&this.connect(this.K,this.Y)});
this.V={};this.Z={};this.Z3=!1;this.logger=null;this.J=[];this.gf=void 0;this.G2=new b18;this.s7=new keh;this.vZ=new UEt;this.U7=new RZP}connect(D={},X=0){this.S!==2&&(this.U.stop(),this.K=D,this.Y=X,Lf(this),(D=g.e("ID_TOKEN"))?this.V["x-youtube-identity-token"]=D:delete this.V["x-youtube-identity-token"],this.L&&(this.Z.device=this.L.device,this.Z.name=this.L.name,this.Z.app=this.L.app,this.Z.id=this.L.id,this.L.m9&&(this.Z.mdxVersion=`${this.L.m9}`),this.L.theme&&(this.Z.theme=this.L.theme),this.L.capabilities&&
(this.Z.capabilities=this.L.capabilities),this.L.XP&&(this.Z.cst=this.L.XP),this.L.authuser&&(this.Z.authuser=this.L.authuser),this.L.pageId&&(this.Z.pageId=this.L.pageId)),this.Y!==0?this.Z.ui=`${this.Y}`:delete this.Z.ui,Object.assign(this.Z,this.K),this.channel=new vx(this.pathPrefix,{iF:"gsessionid",W3:this.V,JJ:this.Z}),this.channel.open(),this.S=2,om5(this))}disconnect(D=0){this.N=D;this.U.stop();Lf(this);this.channel&&(this.N!==0?this.Z.ui=`${this.N}`:delete this.Z.ui,this.channel.close());
this.N=0}d1(){return this.U.isActive()?this.U.pj-Date.now():NaN}GN(){var D=this.U;g.OJ(D.L);D.start()}sendMessage(D,X){this.channel&&(Lf(this),this.channel.send({_sc:D,...X}))}jX(D){D||this.U.stop();D?this.V["X-YouTube-LoungeId-Token"]=D:delete this.V["X-YouTube-LoungeId-Token"]}getDeviceId(){return this.L?this.L.id:""}publish(D,...X){return this.G.publish(D,...X)}subscribe(D,X,B){return this.G.subscribe(D,X,B)}unsubscribe(D,X,B){return this.G.unsubscribe(D,X,B)}nH(D){return this.G.nH(D)}dispose(){this.Z3||
(this.Z3=!0,g.wK(this.G),this.disconnect(),g.wK(this.U),this.pv=()=>"")}S7(){return this.Z3}};var eZ0=class extends g.Jv{constructor(D){super();this.L=D();this.L.subscribe("webChannelOpened",this.Z,this);this.L.subscribe("webChannelClosed",this.onClosed,this);this.L.subscribe("webChannelError",this.onError,this);this.L.subscribe("webChannelMessage",this.onMessage,this)}connect(D,X){this.L.connect(D,X)}disconnect(D){this.L.disconnect(D)}GN(){this.L.GN()}getDeviceId(){return this.L.getDeviceId()}d1(){return this.L.d1()}l_(){return this.L.S===3}Z(){this.dispatchEvent("channelOpened")}onClosed(){this.dispatchEvent("channelClosed")}onMessage(D){this.dispatchEvent(new z4t(D))}onError(){this.dispatchEvent(new bQC(this.L.gf===
401?1:0))}sendMessage(D,X){this.L.sendMessage(D,X)}jX(D){this.L.jX(D)}dispose(){this.L.dispose()}};var T5N=Date.now(),gQ=null,Tk=Array(50),wQ=-1,Si=!1;g.a$(Px,g.Bl);Px.prototype.HO=function(){return this.screens};
Px.prototype.contains=function(D){return!!M8(this.screens,D)};
Px.prototype.get=function(D){return D?Ap(this.screens,D):null};
Px.prototype.info=function(D){EE(this.S,D)};var sF5=class extends g.Bl{constructor(D,X,B,C,V){super();this.V=D;this.J=X;this.K=B;this.Z3=C;this.N=V;this.Z=0;this.L=null;this.Fw=NaN}start(){!this.L&&isNaN(this.Fw)&&this.U()}stop(){this.L&&(this.L.abort(),this.L=null);isNaN(this.Fw)||(g.oA(this.Fw),this.Fw=NaN)}u0(){this.stop();super.u0()}U(){this.Fw=NaN;this.L=g.ns(Ql(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:this.J},timeout:5E3,onSuccess:(0,g.U$)(this.S,this),onError:(0,g.U$)(this.G,this),onTimeout:(0,g.U$)(this.Y,
this)})}S(D,X){this.L=null;D=X.screen||{};D.dialId=this.K;D.name=this.Z3;X=-1;this.N&&D.shortLivedLoungeToken&&D.shortLivedLoungeToken.value&&D.shortLivedLoungeToken.refreshIntervalMs&&(D.screenIdType="shortLived",D.loungeToken=D.shortLivedLoungeToken.value,X=D.shortLivedLoungeToken.refreshIntervalMs);this.publish("pairingComplete",new fP(D),X)}G(D){this.L=null;D.status&&D.status==404?this.Z>=k9K.length?this.publish("pairingFailed",Error("DIAL polling timed out")):(D=k9K[this.Z],this.Fw=g.IA((0,g.U$)(this.U,
this),D),this.Z++):this.publish("pairingFailed",Error("Server error "+D.status))}Y(){this.L=null;this.publish("pairingFailed",Error("Server not responding"))}},k9K=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.a$(OE,Px);g.b=OE.prototype;g.b.start=function(){tf(this)&&this.publish("screenChange");!g.ys("yt-remote-lounge-token-expiration")&&O1K(this);g.oA(this.L);this.L=g.IA((0,g.U$)(this.start,this),1E4)};
g.b.add=function(D,X){tf(this);SSP(this,D);rQ(this,!1);this.publish("screenChange");X(D);D.token||O1K(this)};
g.b.remove=function(D,X){let B=tf(this);tvK(this,D)&&(rQ(this,!1),B=!0);X(D);B&&this.publish("screenChange")};
g.b.FF=function(D,X,B,C){let V=tf(this);const x=this.get(D.id);x?(x.name!=X&&(x.name=X,rQ(this,!1),V=!0),B(D)):C(Error("no such local screen."));V&&this.publish("screenChange")};
g.b.u0=function(){g.oA(this.L);OE.FJ.u0.call(this)};
g.b.nC=function(D){tf(this);let X=this.screens.length;D=D&&D.screens||[];const B=D.length;for(let C=0;C<B;++C){const V=D[C],x=this.get(V.screenId);x&&(x.token=V.loungeToken,--X)}rQ(this,!X);X&&EE(this.S,"Missed "+X+" lounge tokens.")};
g.b.Fx=function(D){EE(this.S,"Requesting lounge tokens failed: "+D)};var mDP=class extends g.Bl{constructor(D,X){super();this.S=X;X=(X=g.ys("yt-remote-online-screen-ids")||"")?X.split(","):[];const B={},C=this.S(),V=C.length;for(let x=0;x<V;++x){const y=C[x].id;B[y]=g.XP(X,y)}this.L=B;this.G=D;this.U=this.V=NaN;this.Z=null;Dj("Initialized with "+g.fj(this.L))}start(){const D=parseInt(g.ys("yt-remote-fast-check-period")||"0",10);(this.V=g.c1()-144E5<D?0:D)?XF(this):(this.V=g.c1()+3E5,g.xk("yt-remote-fast-check-period",this.V),this.Y())}isEmpty(){return g.Z2(this.L)}update(){Dj("Updating availability on schedule.");
const D=this.S(),X=g.Ut(this.L,function(B,C){return B&&!!Ap(D,C)},this);
Bv(this,X)}u0(){g.oA(this.U);this.U=NaN;this.Z&&(this.Z.abort(),this.Z=null);super.u0()}Y(){g.oA(this.U);this.U=NaN;this.Z&&this.Z.abort();const D=DDA(this);if(mZ(D)){var X=Ql(this.G,"/pairing/get_screen_availability"),B={lounge_token:g.IX(D).join(",")};this.Z=this.G.sendRequest("POST",X,B,(0,g.U$)(this.N,this,D),(0,g.U$)(this.K,this))}else Bv(this,{}),XF(this)}N(D,X){this.Z=null;var B=g.IX(DDA(this));if(g.FP(B,g.IX(D))){X=X.screens||[];B={};var C=X.length;for(let V=0;V<C;++V)B[D[X[V].loungeToken]]=
X[V].status=="online";Bv(this,B);XF(this)}else this.o3("Changing Screen set during request."),this.Y()}K(D){this.o3("Screen availability failed: "+D);this.Z=null;XF(this)}o3(D){EE("OnlineScreenService",D)}};g.a$(VX,Px);g.b=VX.prototype;g.b.start=function(){this.Z.start();this.L.start();this.screens.length&&(this.publish("screenChange"),this.L.isEmpty()||this.publish("onlineScreenChange"))};
g.b.add=function(D,X,B){this.Z.add(D,X,B)};
g.b.remove=function(D,X,B){this.Z.remove(D,X,B);this.L.update()};
g.b.FF=function(D,X,B,C){this.Z.contains(D)?this.Z.FF(D,X,B,C):(D="Updating name of unknown screen: "+D.name,EE(this.S,D),C(Error(D)))};
g.b.HO=function(D){return D?this.screens:g.ih(this.screens,g.gu(this.U,function(X){return!this.contains(X)},this))};
g.b.gM=function(){return g.gu(this.HO(!0),function(D){return!!this.L.L[D.id]},this)};
g.b.DC=function(D,X,B,C,V,x){this.info("getDialScreenByPairingCode "+D+" / "+X);const y=new sF5(this.V,D,X,B,C);y.subscribe("pairingComplete",(m,l)=>{g.wK(y);V(xV(this,m),l)});
y.subscribe("pairingFailed",m=>{g.wK(y);x(m)});
y.start();return(0,g.U$)(y.stop,y)};
g.b.ra=function(D,X,B,C){g.ns(Ql(this.V,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:D},timeout:5E3,onSuccess:(0,g.U$)(function(V,x){V=new fP(x.screen||{});if(!V.name||VL5(this,V.name)){a:{x=V.name;let y=2,m=X(x,y);for(;VL5(this,m);){y++;if(y>20)break a;m=X(x,y)}x=m}V.name=x}B(xV(this,V))},this),
onError:(0,g.U$)(function(V){C(Error("pairing request failed: "+V.status))},this),
onTimeout:(0,g.U$)(function(){C(Error("pairing request timed out."))},this)})};
g.b.u0=function(){g.wK(this.Z);g.wK(this.L);VX.FJ.u0.call(this)};
g.b.d2=function(){yEg(this);this.publish("screenChange");this.L.update()};
VX.prototype.dispose=VX.prototype.dispose;g.a$(mj,g.Bl);g.b=mj.prototype;g.b.xa=function(D){this.S7()||(D&&(lX(this,""+D),this.publish("sessionFailed")),this.L=null,this.publish("sessionScreen",null))};
g.b.info=function(D){EE(this.U7,D)};
g.b.Ka=function(){return null};
g.b.Z6=function(D){const X=this.Z;D?(X.displayStatus=new chrome.cast.ReceiverDisplayStatus(D,[]),X.displayStatus.showStop=!0):X.displayStatus=null;chrome.cast.setReceiverDisplayStatus(X,(0,g.U$)(function(){this.info("Updated receiver status for "+X.friendlyName+": "+D)},this),(0,g.U$)(function(){lX(this,"Failed to update receiver status for: "+X.friendlyName)},this))};
g.b.u0=function(){this.Z6("");mj.FJ.u0.call(this)};var bj=class extends mj{constructor(D,X,B){super(D,X,"CastSession");this.config_=B;this.U=null;this.J=(0,g.U$)(this.G2,this);this.pv=(0,g.U$)(this.HZ,this);this.Z3=g.IA(()=>{WXP(this,null)},12E4);
this.K=this.G=this.Y=this.N=0}s7(D){if(this.U){if(this.U==D)return;lX(this,"Overriding cast session with new session object");v4h(this);this.U.removeUpdateListener(this.J);this.U.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.pv)}this.U=D;this.U.addUpdateListener(this.J);this.U.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.pv);fih(this,"getMdxSessionStatus")}S(D){this.info("launchWithParams no-op for Cast: "+g.fj(D))}stop(){this.U?this.U.stop((0,g.U$)(function(){this.xa()},
this),(0,g.U$)(function(){this.xa(Error("Failed to stop receiver app."))},this)):this.xa(Error("Stopping cast device without session."))}Z6(){}u0(){this.info("disposeInternal");
v4h(this);this.U&&(this.U.removeUpdateListener(this.J),this.U.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.pv));this.U=null;super.u0()}HZ(D,X){if(!this.S7())if(X)if(X=i9(X),g.bY(X))switch(D=""+X.type,X=X.data||{},this.info("onYoutubeMessage_: "+D+" "+g.fj(X)),D){case "mdxSessionStatus":WXP(this,X);break;case "loungeToken":upg(this,X);break;default:lX(this,"Unknown youtube message: "+D)}else lX(this,"Unable to parse message.");else lX(this,"No data in message.")}vZ(D,X,B,C){g.oA(this.N);
this.N=0;C88(this.V,this.Z.label,D,this.Z.friendlyName,(0,g.U$)(function(V){V?X(V):C>=0?(lX(this,"Screen "+D+" appears to be offline. "+C+" retries left."),this.N=g.IA((0,g.U$)(this.vZ,this,D,X,B,C-1),300)):B(Error("Unable to fetch screen."))},this),B)}Ka(){return this.U}G2(D){this.S7()||D||(lX(this,"Cast session died."),this.xa())}};var U0A=class extends mj{constructor(D,X,B,C){super(D,X,"DialSession");this.config_=C;this.U=this.N=null;this.pv="";this.HZ=B;this.G2=null;this.J=()=>{};
this.Z3=NaN;this.vZ=(0,g.U$)(this.b0,this);this.G=()=>{};
this.K=this.Y=0}s7(D){this.U=D;this.U.addUpdateListener(this.vZ)}S(D){this.G2=D;this.J()}stop(){AEC(this);this.U?this.U.stop((0,g.U$)(this.xa,this,null),(0,g.U$)(this.xa,this,"Failed to stop DIAL device.")):this.xa()}u0(){AEC(this);this.U&&this.U.removeUpdateListener(this.vZ);this.U=null;super.u0()}b0(D){this.S7()||D||(lX(this,"DIAL session died."),this.G(),this.G=()=>{},this.xa())}};var R4C=class extends mj{constructor(D,X){super(D,X,"ManualSession");this.U=g.IA((0,g.U$)(this.S,this,null),150)}stop(){this.xa()}s7(){}S(){g.oA(this.U);this.U=NaN;const D=Ap(this.V.HO(),this.Z.label);D?iX(this,D):this.xa(Error("No such screen"))}u0(){g.oA(this.U);this.U=NaN;super.u0()}};var R2=class extends g.Bl{constructor(D,X){super();this.config_=X;this.Z=D;this.s7=X.appId||"233637DE";this.V=X.theme||"cl";this.U7=X.disableCastApi||!1;this.Y=X.forceMirroring||!1;this.L=null;this.K=!1;this.U=[];this.S=(0,g.U$)(this.G2,this)}init(D,X){chrome.cast.timeout.requestSession=3E4;var B=new chrome.cast.SessionRequest(this.s7,[chrome.cast.Capability.AUDIO_OUT]);g.GF("desktop_enable_cast_connect")&&(B.androidReceiverCompatible=!0);this.U7||(B.dialRequest=new chrome.cast.DialRequest("YouTube"));
const C=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;D=D||this.Y?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;const V=(0,g.U$)(this.HZ,this);B=new chrome.cast.ApiConfig(B,(0,g.U$)(this.N,this),V,C,D);B.customDialLaunchCallback=(0,g.U$)(this.vZ,this);chrome.cast.initialize(B,(0,g.U$)(function(){this.S7()||(chrome.cast.addReceiverActionListener(this.S),Emh(),this.Z.subscribe("onlineScreenChange",(0,g.U$)(this.G,this)),this.U=kv5(this),chrome.cast.setCustomReceivers(this.U,
()=>{},(0,g.U$)(function(x){this.o3("Failed to set initial custom receivers: "+g.fj(x))},this)),this.publish("yt-remote-cast2-availability-change",pd(this)),X(!0))},this),(0,g.U$)(function(x){this.o3("Failed to initialize API: "+g.fj(x));
X(!1)},this))}O7(D,X){hG("Setting connected screen ID: "+D+" -> "+X);
if(this.L){var B=this.L.L;if(!D||B&&B.id!=D)hG("Unsetting old screen status: "+this.L.Z.friendlyName),JG(this,null)}if(D&&X){if(!this.L){D=Ap(this.Z.HO(),D);if(!D){hG("setConnectedScreenStatus: Unknown screen.");return}if(D.idType=="shortLived"){hG("setConnectedScreenStatus: Screen with id type to be short lived.");return}B=bjW(this,D);B||(hG("setConnectedScreenStatus: Connected receiver not custom..."),B=new chrome.cast.Receiver(D.uuid?D.uuid:D.id,D.name),B.receiverType=chrome.cast.ReceiverType.CUSTOM,
this.U.push(B),chrome.cast.setCustomReceivers(this.U,()=>{},(0,g.U$)(function(C){this.o3("Failed to set initial custom receivers: "+g.fj(C))},this)));
hG("setConnectedScreenStatus: new active receiver: "+B.friendlyName);JG(this,new R4C(this.Z,B),!0)}this.L.Z6(X)}else hG("setConnectedScreenStatus: no screen.")}YU(D){this.S7()?this.o3("Setting connection data on disposed cast v2"):this.L?this.L.S(D):this.o3("Setting connection data without a session")}pv(){this.S7()?this.o3("Stopping session on disposed cast v2"):this.L?(this.L.stop(),JG(this,null)):hG("Stopping non-existing session")}requestSession(){chrome.cast.requestSession((0,g.U$)(this.N,this),
(0,g.U$)(this.b0,this))}u0(){this.Z.unsubscribe("onlineScreenChange",(0,g.U$)(this.G,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.S);var D=QW5;const X=g.MX("yt.mdx.remote.debug.handlers_");g.yN(X||[],D);g.wK(this.L);super.u0()}o3(D){EE("Controller",D)}Z3(D,X){this.L==D&&(X||JG(this,null),this.publish("yt-remote-cast2-session-change",X))}G2(D,X){if(!this.S7())if(D)switch(D.friendlyName=chrome.cast.unescape(D.friendlyName),hG("onReceiverAction_ "+D.label+" / "+D.friendlyName+
"-- "+X),X){case chrome.cast.ReceiverAction.CAST:if(this.L)if(this.L.Z.label!=D.label)hG("onReceiverAction_: Stopping active receiver: "+this.L.Z.friendlyName),this.L.stop();else{hG("onReceiverAction_: Casting to active receiver.");this.L.L&&this.publish("yt-remote-cast2-session-change",this.L.L);break}switch(D.receiverType){case chrome.cast.ReceiverType.CUSTOM:JG(this,new R4C(this.Z,D));break;case chrome.cast.ReceiverType.DIAL:JG(this,new U0A(this.Z,D,this.V,this.config_));break;case chrome.cast.ReceiverType.CAST:JG(this,
new bj(this.Z,D,this.config_));break;default:this.o3("Unknown receiver type: "+D.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.L&&this.L.Z.label==D.label?this.L.stop():this.o3("Stopping receiver w/o session: "+D.friendlyName)}else this.o3("onReceiverAction_ called without receiver.")}vZ(D){if(this.S7())return Promise.reject(Error("disposed"));var X=D.receiver;X.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.o3("Not DIAL receiver: "+X.friendlyName),X.receiverType=chrome.cast.ReceiverType.DIAL);
var B=this.L?this.L.Z:null;if(!B||B.label!=X.label)return this.o3("Receiving DIAL launch request for non-clicked DIAL receiver: "+X.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(B&&B.label==X.label&&B.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.L.L)return hG("Reselecting dial screen."),this.publish("yt-remote-cast2-session-change",this.L.L),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.o3('Changing CAST intent from "'+B.receiverType+'" to "dial" for '+X.friendlyName);
JG(this,new U0A(this.Z,X,this.V,this.config_))}X=this.L;X.N=D;X.N.appState==chrome.cast.DialAppState.RUNNING?(D=X.N.extraData||{},B=D.screenId||null,fd(X)&&D.loungeToken?D.loungeTokenRefreshIntervalMs?D=zUP(X,{name:X.Z.friendlyName,screenId:D.screenId,loungeToken:D.loungeToken,dialId:X.N.receiver.label,screenIdType:"shortLived"},D.loungeTokenRefreshIntervalMs):(g.WB(Error(`No loungeTokenRefreshIntervalMs presents in additionalData: ${JSON.stringify(D)}.`)),D=HjK(X,B)):D=HjK(X,B)):D=vv(X);return D}N(D){if(!this.S7()&&
!this.Y){hG("New cast session ID: "+D.sessionId);var X=D.receiver;if(X.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.L)if(X.receiverType==chrome.cast.ReceiverType.CAST)hG("Got resumed cast session before resumed mdx connection."),X.friendlyName=chrome.cast.unescape(X.friendlyName),JG(this,new bj(this.Z,X,this.config_),!0);else{this.o3("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var B=this.L.Z,C=Ap(this.Z.HO(),B.label);C&&u9(C,X.label)&&B.receiverType!=
chrome.cast.ReceiverType.CAST&&X.receiverType==chrome.cast.ReceiverType.CAST&&(hG("onSessionEstablished_: manual to cast session change "+X.friendlyName),g.wK(this.L),this.L=new bj(this.Z,X,this.config_),this.L.subscribe("sessionScreen",(0,g.U$)(this.Z3,this,this.L)),this.L.subscribe("sessionFailed",()=>sUJ(this,this.L)),this.L.S(null));
this.L.s7(D)}}}J(){return this.L?this.L.Ka():null}b0(D){this.S7()||(this.o3("Failed to estabilish a session: "+g.fj(D)),D.code!=chrome.cast.ErrorCode.CANCEL&&JG(this,null),this.publish("yt-remote-cast2-session-failed"))}HZ(D){hG("Receiver availability updated: "+D);if(!this.S7()){var X=pd(this);this.K=D==chrome.cast.ReceiverAvailability.AVAILABLE;pd(this)!=X&&this.publish("yt-remote-cast2-availability-change",pd(this))}}G(){this.S7()||(this.U=kv5(this),hG("Updating custom receivers: "+g.fj(this.U)),
chrome.cast.setCustomReceivers(this.U,()=>{},(0,g.U$)(function(){this.o3("Failed to set custom receivers.")},this)),this.publish("yt-remote-cast2-availability-change",pd(this)))}};
R2.prototype.setLaunchParams=R2.prototype.YU;R2.prototype.setConnectedScreenStatus=R2.prototype.O7;R2.prototype.stopSession=R2.prototype.pv;R2.prototype.getCastSession=R2.prototype.J;R2.prototype.requestSession=R2.prototype.requestSession;R2.prototype.init=R2.prototype.init;R2.prototype.dispose=R2.prototype.dispose;var zE=[],qUh=(0,g.d3)`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js`;g.b=cv.prototype;
g.b.reset=function(D){this.listId="";this.index=-1;this.videoId="";NQ(this);this.volume=-1;this.muted=!1;D&&(this.index=D.index,this.listId=D.listId,this.videoId=D.videoId,this.playerState=D.playerState,this.volume=D.volume,this.muted=D.muted,this.audioTrackId=D.audioTrackId,this.trackData=D.trackData,this.hasPrevious=D.hasPrevious,this.hasNext=D.hasNext,this.S=D.playerTime,this.G=D.playerTimeAt,this.Z=D.seekableStart,this.Y=D.seekableEnd,this.U=D.duration,this.loadedTime=D.loadedTime,this.L=D.liveIngestionTime,
this.V=!isNaN(this.L))};
g.b.isPlaying=function(){return this.playerState==1};
g.b.isBuffering=function(){return this.playerState==3};
g.b.fz=function(D){this.U=isNaN(D)?0:D};
g.b.getDuration=function(){return this.V?this.U+qQ(this):this.U};
g.b.clone=function(){return new cv(Kd(this))};var cgP=class extends g.Bl{constructor(){var D=mY();super();this.U=0;this.V=D;this.Y=[];this.G=new F1t;this.Z=this.L=null;this.J=(0,g.U$)(this.G2,this);this.N=(0,g.U$)(this.S,this);this.Z3=(0,g.U$)(this.vZ,this);this.U7=(0,g.U$)(this.HZ,this);let X=0;D?(X=D.getProxyState(),X!=3&&(D.subscribe("proxyStateChange",this.s7,this),GvU(this))):X=3;X!=0&&g.IA(()=>{this.s7(X)},0);
(D=o4J())&&o2(this,D);this.subscribe("yt-remote-cast2-session-change",this.U7)}getState(){return this.U}d1(){return this.V.getReconnectTimeout()}GN(){this.V.reconnect()}play(){dp(this)?(this.L?this.L.play(null,g.Fx,Zj(this,"play")):GE(this,"play"),Ld(this,1,YV(eq(this))),this.publish("remotePlayerChange")):gp(this,this.play)}pause(){dp(this)?(this.L?this.L.pause(null,g.Fx,Zj(this,"pause")):GE(this,"pause"),Ld(this,2,YV(eq(this))),this.publish("remotePlayerChange")):gp(this,this.pause)}seekTo(D){if(dp(this)){if(this.L){const X=
eq(this),B=new chrome.cast.media.SeekRequest;B.currentTime=D;X.isPlaying()||X.isBuffering()?B.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:B.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.L.seek(B,g.Fx,Zj(this,"seekTo",{newTime:D}))}else GE(this,"seekTo",{newTime:D});Ld(this,3,D);this.publish("remotePlayerChange")}else gp(this,g.R$(this.seekTo,D))}stop(){if(dp(this)){this.L?this.L.stop(null,g.Fx,Zj(this,"stopVideo")):GE(this,"stopVideo");var D=eq(this);D.index=-1;D.videoId=
"";NQ(D);QX(this,D);this.publish("remotePlayerChange")}else gp(this,this.stop)}setVolume(D,X){if(dp(this)){var B=eq(this);if(this.Z){if(B.volume!=D){const C=Math.round(D)/100;this.Z.setReceiverVolumeLevel(C,(0,g.U$)(function(){nf("set receiver volume: "+C)},this),(0,g.U$)(function(){this.o3("failed to set receiver volume.")},this))}B.muted!=X&&this.Z.setReceiverMuted(X,(0,g.U$)(function(){nf("set receiver muted: "+X)},this),(0,g.U$)(function(){this.o3("failed to set receiver muted.")},this))}else{const C=
{volume:D,
muted:X};B.volume!=-1&&(C.delta=D-B.volume);GE(this,"setVolume",C)}B.muted=X;B.volume=D;QX(this,B)}else gp(this,g.R$(this.setVolume,D,X))}K(D,X){if(dp(this)){var B=eq(this);D={videoId:D};X&&(B.trackData={trackName:X.name,languageCode:X.languageCode,sourceLanguageCode:X.translationLanguage?X.translationLanguage.languageCode:"",languageName:X.languageName,kind:X.kind},D.style=g.fj(X.style),g.T8(D,B.trackData));GE(this,"setSubtitlesTrack",D);QX(this,B)}else gp(this,g.R$(this.K,D,X))}setAudioTrack(D,
X){dp(this)?(X=X.getLanguageInfo().getId(),GE(this,"setAudioTrack",{videoId:D,audioTrackId:X}),D=eq(this),D.audioTrackId=X,QX(this,D)):gp(this,g.R$(this.setAudioTrack,D,X))}playVideo(D,X,B,C=null,V=null,x=null,y=null){const m=eq(this),l={videoId:D};B!==void 0&&(l.currentIndex=B);I2(m,D,B||0);X!==void 0&&(a2(m,X),l.currentTime=X);C&&(l.listId=C);V&&(l.playerParams=V);x&&(l.clickTrackingParams=x);y&&(l.locationInfo=g.fj(y));GE(this,"setPlaylist",l);C||QX(this,m)}zR(D,X){if(dp(this)){if(D&&X){const B=
eq(this);I2(B,D,X);QX(this,B)}GE(this,"previous")}else gp(this,g.R$(this.zR,D,X))}nextVideo(D,X){if(dp(this)){if(D&&X){const B=eq(this);I2(B,D,X);QX(this,B)}GE(this,"next")}else gp(this,g.R$(this.nextVideo,D,X))}ly(){if(dp(this)){GE(this,"clearPlaylist");var D=eq(this);D.reset();QX(this,D);this.publish("remotePlayerChange")}else gp(this,this.ly)}pv(){dp(this)?GE(this,"dismissAutoplay"):gp(this,this.pv)}dispose(){if(this.U!=3){const D=this.U;this.U=3;this.publish("proxyStateChange",D,this.U)}super.dispose()}u0(){ZjP(this);
this.V=null;this.G.clear();o2(this,null);super.u0()}s7(D){if((D!=this.U||D==2)&&this.U!=3&&D!=0){var X=this.U;this.U=D;this.publish("proxyStateChange",X,D);if(D==1)for(;!this.G.isEmpty();)X=D=this.G,X.L.length===0&&(X.L=X.Z,X.L.reverse(),X.Z=[]),D.L.pop().apply(this);else D==3&&this.dispose()}}b0(D,X){this.publish(D,X)}G2(D){if(!D)this.S(null),o2(this,null);else if(this.Z.receiver.volume){D=this.Z.receiver.volume;const X=eq(this),B=Math.round(100*D.level||0);if(X.volume!=B||X.muted!=D.muted)nf("Cast volume update: "+
D.level+(D.muted?" muted":"")),X.volume=B,X.muted=!!D.muted,QX(this,X)}}S(D){nf("Cast media: "+!!D);this.L&&this.L.removeUpdateListener(this.Z3);if(this.L=D)this.L.addUpdateListener(this.Z3),QUA(this),this.publish("remotePlayerChange")}vZ(D){D?(QUA(this),this.publish("remotePlayerChange")):this.S(null)}KG(){GE(this,"sendDebugCommand",{debugCommand:"stats4nerds "})}HZ(){const D=o4J();D&&o2(this,D)}o3(D){EE("CP",D)}};var h$=class extends g.Bl{constructor(D,X=!1){var B=tG,C=xc();super();this.S=NaN;this.vZ=!1;this.J=this.Z3=this.s7=this.U7=NaN;this.pv=[];this.G=this.K=this.V=this.L=this.Z=null;this.ww=B;this.b0=X;this.pv.push(g.OQ(window,"beforeunload",()=>{this.Y(2)}));
this.U=[];this.L=new cv;this.Cv=D.id;this.HZ=D.idType;this.Z=Z1N(this.ww,C,this.G2,this.HZ=="shortLived",this.Cv);this.Z.listen("channelOpened",()=>{LXW(this)});
this.Z.listen("channelClosed",()=>{En("Channel closed");isNaN(this.S)?b9(!0):b9();this.dispose()});
this.Z.listen("channelError",V=>{b9();isNaN(this.N())?(V==1&&this.HZ=="shortLived"&&this.publish("browserChannelAuthError",V),En(`Channel error: ${V} without reconnection`),this.dispose()):(this.vZ=!0,En("Channel error: "+V+" with reconnection in "+this.N()+" ms"),wp(this,2))});
this.Z.listen("channelMessage",V=>{XNK(this,V)});
this.Z.jX(D.token);this.subscribe("remoteQueueChange",()=>{var V=this.L.videoId;g.iV()&&g.xk("yt-remote-session-video-id",V)})}connect(D,X){if(X){var B=X.listId;
const C=X.videoId,V=X.videoIds,x=X.playerParams,y=X.clickTrackingParams,m=X.index,l={videoId:C},W=X.currentTime,v=X.locationInfo;X=X.loopMode;W!==void 0&&(l.currentTime=W<=5?0:W);x&&(l.playerParams=x);v&&(l.locationInfo=v);y&&(l.clickTrackingParams=y);B&&(l.listId=B);V&&V.length>0&&(l.videoIds=V.join(","));m!==void 0&&(l.currentIndex=m);this.b0&&(l.loopMode=X||"LOOP_MODE_OFF");B&&(this.L.listId=B);this.L.videoId=C;this.L.index=m||0;this.L.state=3;a2(this.L,W);this.G="UNSUPPORTED";B=this.b0?"setInitialState":
"setPlaylist";En(`Connecting with ${B} and params: ${g.fj(l)}`);this.Z.connect({method:B,params:g.fj(l)},D,rh5())}else En("Connecting without params"),this.Z.connect({},D,rh5());Bo0(this)}jX(D){this.Z.jX(D)}dispose(){this.S7()||(g.Jz("yt.mdx.remote.remoteClient_",null),this.publish("beforeDispose"),wp(this,3));super.dispose()}u0(){TE(this);Sq(this);nd(this);g.oA(this.Z3);this.Z3=NaN;g.oA(this.J);this.J=NaN;this.V=null;g.rO(this.pv);this.pv.length=0;this.Z.dispose();super.u0();this.G=this.K=this.U=
this.L=this.Z=null}YU(D){if(!this.U||this.U.length===0)return!1;for(const X of this.U)if(!X.capabilities.has(D))return!1;return!0}mG(){let D=3;this.S7()||(D=0,isNaN(this.N())?this.Z.l_()&&isNaN(this.S)&&(D=1):D=2);return D}Y(D){En("Disconnecting with "+D);g.Jz("yt.mdx.remote.remoteClient_",null);TE(this);this.publish("beforeDisconnect",D);D==1&&b9();this.Z.disconnect(D);this.dispose()}WZ(){let D=this.L;this.V&&(D=this.L.clone(),I2(D,this.V,D.index));return Kd(D)}s2(D){const X=new cv(D);X.videoId&&
X.videoId!=this.L.videoId&&(this.V=X.videoId,g.oA(this.Z3),this.Z3=g.IA(()=>{if(this.V){const C=this.V;this.V=null;this.L.videoId!=C&&Pv(this,"getNowPlaying")}},5E3));
const B=[];this.L.listId==X.listId&&this.L.videoId==X.videoId&&this.L.index==X.index||B.push("remoteQueueChange");this.L.playerState==X.playerState&&this.L.volume==X.volume&&this.L.muted==X.muted&&YV(this.L)==YV(X)&&g.fj(this.L.trackData)==g.fj(X.trackData)||B.push("remotePlayerChange");this.L.reset(D);g.Lu(B,function(C){this.publish(C)},this)}O7(){const D=this.Z.getDeviceId(),X=g.O$(this.U,function(B){return B.type=="REMOTE_CONTROL"&&B.id!=D});
return X?X.id:""}N(){return this.Z.d1()}BZ(){return this.G||"UNSUPPORTED"}xU(){return this.K||""}D3(){!isNaN(this.N())&&this.Z.GN()}Lr(D,X){Pv(this,D,X);x0X(this)}G2(){var D=g.m2("SAPISID","")||g.m2("__Secure-1PAPISID")||"",X=g.m2("__Secure-3PAPISID","")||"";if(!D&&!X)return"";D=g.s5(g.zK(D),2);X=g.s5(g.zK(X),2);return g.s5(g.zK(`,${D},${X}`),2)}};h$.prototype.subscribe=h$.prototype.subscribe;h$.prototype.unsubscribeByKey=h$.prototype.nH;h$.prototype.getProxyState=h$.prototype.mG;
h$.prototype.disconnect=h$.prototype.Y;h$.prototype.getPlayerContextData=h$.prototype.WZ;h$.prototype.setPlayerContextData=h$.prototype.s2;h$.prototype.getOtherConnectedRemoteId=h$.prototype.O7;h$.prototype.getReconnectTimeout=h$.prototype.N;h$.prototype.getAutoplayMode=h$.prototype.BZ;h$.prototype.getAutoplayVideoId=h$.prototype.xU;h$.prototype.reconnect=h$.prototype.D3;h$.prototype.sendMessage=h$.prototype.Lr;h$.prototype.getXsrfToken=h$.prototype.G2;
h$.prototype.isCapabilitySupportedOnConnectedDevices=h$.prototype.YU;var vy5=class extends Px{constructor(D){super("ScreenServiceProxy");this.Vp=D;this.L=[];this.L.push(this.Vp.$_s("screenChange",(0,g.U$)(this.Z,this)));this.L.push(this.Vp.$_s("onlineScreenChange",(0,g.U$)(this.U,this)))}HO(D){return this.Vp.$_gs(D)}contains(D){return!!this.Vp.$_c(D)}get(D){return this.Vp.$_g(D)}start(){this.Vp.$_st()}add(D,X,B){this.Vp.$_a(D,X,B)}remove(D,X,B){this.Vp.$_r(D,X,B)}FF(D,X,B,C){this.Vp.$_un(D,X,B,C)}u0(){const D=this.L.length;for(let X=0;X<D;++X)this.Vp.$_ubk(this.L[X]);
this.L.length=0;this.Vp=null;super.u0()}Z(){this.publish("screenChange")}U(){this.publish("onlineScreenChange")}};VX.prototype.$_st=VX.prototype.start;VX.prototype.$_gspc=VX.prototype.ra;VX.prototype.$_gsppc=VX.prototype.DC;VX.prototype.$_c=VX.prototype.contains;VX.prototype.$_g=VX.prototype.get;VX.prototype.$_a=VX.prototype.add;VX.prototype.$_un=VX.prototype.FF;VX.prototype.$_r=VX.prototype.remove;VX.prototype.$_gs=VX.prototype.HO;VX.prototype.$_gos=VX.prototype.gM;VX.prototype.$_s=VX.prototype.subscribe;
VX.prototype.$_ubk=VX.prototype.nH;var lj=null,pI=!1,tG=null,On=null,uj=null,Bf=[];var NoX=class extends g.Sf{constructor(D,X,B){super();this.L=D;this.A=X;this.iY=B;this.events=new g.Fj(this);this.S=!1;this.K=new g.u0(64);this.Z=new g.tM(this.G2,500,this);this.U=new g.tM(this.HZ,1E3,this);this.Z3=new q8(this.Cv,0,this);this.V={};this.J=new g.tM(this.O7,1E3,this);this.N=new g.M5(this.seekTo,1E3,this);this.YU=this.events.C(this.A,"onVolumeChange",C=>{pN0(this,C)});
g.U(this,this.events);this.events.C(X,"onCaptionsTrackListChanged",this.D3);this.events.C(X,"captionschanged",this.ww);this.events.C(X,"captionssettingschanged",this.b0);this.events.C(X,"videoplayerreset",this.Y);this.events.C(X,"mdxautoplaycancel",()=>{this.iY.pv()});
X.X("enable_mdx_video_play_directly")&&this.events.C(X,"videodatachange",()=>{MTh(this.L)||J$(this)||A$(this,0)});
D=this.iY;D.S7();D.subscribe("proxyStateChange",this.vZ,this);D.subscribe("remotePlayerChange",this.G,this);D.subscribe("remoteQueueChange",this.Y,this);D.subscribe("previousNextChange",this.U7,this);D.subscribe("nowAutoplaying",this.s7,this);D.subscribe("autoplayDismissed",this.pv,this);g.U(this,this.Z);g.U(this,this.U);g.U(this,this.Z3);g.U(this,this.J);g.U(this,this.N);this.b0();this.Y();this.G()}u0(){super.u0();this.Z.stop();this.U.stop();this.Z3.stop();const D=this.iY;D.unsubscribe("proxyStateChange",
this.vZ,this);D.unsubscribe("remotePlayerChange",this.G,this);D.unsubscribe("remoteQueueChange",this.Y,this);D.unsubscribe("previousNextChange",this.U7,this);D.unsubscribe("nowAutoplaying",this.s7,this);D.unsubscribe("autoplayDismissed",this.pv,this);this.iY=this.L=null}V1(D,...X){if(this.iY.U!=2)if(J$(this)){if(eq(this.iY).playerState!=1081||D!=="control_seek")switch(D){case "control_toggle_play_pause":eq(this.iY).isPlaying()?this.iY.pause():this.iY.play();break;case "control_play":this.iY.play();
break;case "control_pause":this.iY.pause();break;case "control_seek":this.N.V(X[0],X[1]);break;case "control_subtitles_set_track":j9(this,X[0]);break;case "control_set_audio_track":this.setAudioTrack(X[0])}}else switch(D){case "control_toggle_play_pause":case "control_play":case "control_pause":D=this.A.getCurrentTime();A$(this,D===0?void 0:D);break;case "control_seek":A$(this,X[0]);break;case "control_subtitles_set_track":j9(this,X[0]);break;case "control_set_audio_track":this.setAudioTrack(X[0])}}ww(D){this.Z3.fM(D)}Cv(D){this.V1("control_subtitles_set_track",
g.Z2(D)?null:D)}b0(){const D=this.A.getOption("captions","track");g.Z2(D)||j9(this,D)}Ki(D){this.L.Ki(D,this.A.getVideoData().lengthSeconds)}D3(){g.Z2(this.V)||h4N(this,this.V);this.S=!1}vZ(D,X){this.U.stop();X===2&&this.HZ()}G(){if(J$(this)){this.Z.stop();var D=eq(this.iY);switch(D.playerState){case 1080:case 1081:case 1084:case 1085:this.L.Qn=1;break;case 1082:case 1083:this.L.Qn=0;break;default:this.L.Qn=-1}switch(D.playerState){case 1081:case 1:this.Va(new g.u0(8));this.G2();break;case 1085:case 3:this.Va(new g.u0(9));
break;case 1083:case 0:this.Va(new g.u0(2));this.N.stop();this.Ki(this.A.getVideoData().lengthSeconds);break;case 1084:this.Va(new g.u0(4));break;case 2:this.Va(new g.u0(4));this.Ki(YV(D));break;case -1:this.Va(new g.u0(64));break;case -1E3:this.Va(new g.u0(128,{errorCode:"mdx.remoteerror",errorMessage:"This video is not available for remote playback.",dF:2}))}const B=eq(this.iY).trackData;D=B;var X=this.V;(D||X?D&&X&&D.trackName==X.trackName&&D.languageCode==X.languageCode&&D.languageName==X.languageName&&
D.kind==X.kind:1)||(this.V=B,h4N(this,B));D=eq(this.iY);D.volume===-1||Math.round(this.A.getVolume())===D.volume&&this.A.isMuted()===D.muted||this.J.isActive()||this.O7()}else Jgt(this)}U7(){this.A.publish("mdxpreviousnextchange")}Y(){J$(this)||Jgt(this)}s7(D){isNaN(D)||this.A.publish("mdxnowautoplaying",D)}pv(){this.A.publish("mdxautoplaycanceled")}setAudioTrack(D){J$(this)&&this.iY.setAudioTrack(Mu(this).videoId,D)}seekTo(D,X){eq(this.iY).playerState===-1?A$(this,D):X&&this.iY.seekTo(D)}O7(){if(J$(this)){var D=
eq(this.iY);this.events.D$(this.YU);D.muted?this.A.mute():this.A.unMute();this.A.setVolume(D.volume);this.YU=this.events.C(this.A,"onVolumeChange",X=>{pN0(this,X)})}}G2(){this.Z.stop();
if(!this.iY.S7()){var D=eq(this.iY);D.isPlaying()&&this.Va(new g.u0(8));this.Ki(YV(D));this.Z.start()}}HZ(){this.U.stop();this.Z.stop();const D=this.iY.d1();this.iY.U==2&&!isNaN(D)&&this.U.start()}Va(D){this.U.stop();const X=this.K;if(!g.jt(X,D)){const B=D.L(2);B!==this.K.L(2)&&this.A.CT(B);this.K=D;AgX(this.L,X,D)}}};var qjP=class extends g.SI{constructor(D,X){super(D);this.L=X}getCurrentTime(){return this.L.getCurrentTime()}getDuration(){return this.L.getDuration()}AO(){return this.L.AO()}V2(){return this.L.V2()}e_(){return this.L.e_()}F0(){return this.L.F0()}getPlayerState(){return this.L.rS}isAtLiveHead(){return this.L.isAtLiveHead()}pauseVideo(){Hf(this.L,"control_pause")}async playVideo(){Hf(this.L,"control_play")}seekTo(D,X){Hf(this.L,"control_seek",D,!X?.Bs)}BS(D){Hf(this.L,"control_set_audio_track",D);
return!0}};var a4N=class extends g.t{constructor(){super({O:"div",D:"ytp-mdx-popup-dialog",B:{role:"dialog"},W:[{O:"div",D:"ytp-mdx-popup-dialog-inner-content",W:[{O:"div",D:"ytp-mdx-popup-title",QV:"You're signed out"},{O:"div",D:"ytp-mdx-popup-description",QV:"Videos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer."},{O:"div",D:"ytp-mdx-privacy-popup-buttons",W:[{O:"button",l0:["ytp-button","ytp-mdx-privacy-popup-cancel"],
QV:"Cancel"},{O:"button",l0:["ytp-button","ytp-mdx-privacy-popup-confirm"],QV:"Confirm"}]}]}]});this.fade=new g.nJ(this,250);this.cancelButton=this.oa("ytp-mdx-privacy-popup-cancel");this.confirmButton=this.oa("ytp-mdx-privacy-popup-confirm");g.U(this,this.fade);this.C(this.cancelButton,"click",this.L);this.C(this.confirmButton,"click",this.Z)}xt(){this.fade.show()}Df(){this.fade.hide()}L(){sZ("mdx-privacy-popup-cancel");this.Df()}Z(){sZ("mdx-privacy-popup-confirm");this.Df()}};var YjA=class extends g.t{constructor(D){super({O:"div",D:"ytp-remote",W:[{O:"div",D:"ytp-remote-display-status",W:[{O:"div",D:"ytp-remote-display-status-icon",W:[g.Rjo()]},{O:"div",D:"ytp-remote-display-status-text",QV:"{{statustext}}"}]}]});this.api=D;this.fade=new g.nJ(this,250);g.U(this,this.fade);this.C(D,"presentingplayerstatechange",this.onStateChange);this.Po(D.getPlayerStateObject())}onStateChange(D){this.Po(D.state)}Po(D){if(this.api.getPresentingPlayerType()===3){const X={RECEIVER_NAME:this.api.getOption("remote",
"currentReceiver").name};D=D.L(128)?g.al("Error on $RECEIVER_NAME",X):D.isPlaying()||D.isPaused()?g.al("Playing on $RECEIVER_NAME",X):g.al("Connected to $RECEIVER_NAME",X);this.updateValue("statustext",D);this.fade.show()}else this.fade.hide()}};var I4J=class extends g.K4{constructor(D,X){super("Play on",1,D,X);this.A=D;this.B4={};this.C(D,"onMdxReceiversChange",this.S);this.C(D,"presentingplayerstatechange",this.S);this.S()}S(){var D=this.A.getOption("remote","receivers");D&&D.length>1&&!this.A.getOption("remote","quickCast")?(this.B4=g.bh(D,this.G,this),this.V(g.E$(D,this.G)),D=this.A.getOption("remote","currentReceiver"),D=this.G(D),this.options[D]&&this.Z(D),this.enable(!0)):this.enable(!1)}G(D){return D.key}U(D){return D==="cast-selector-receiver"?
"Cast...":this.B4[D].name}L(D){super.L(D);this.A.setOption("remote","currentReceiver",this.B4[D]);this.i7.Df()}};g.Z0("remote",class extends g.dv{constructor(D){super(D);this.zi={key:Jp(),name:"This computer"};this.jd=null;this.subscriptions=[];this.v6=this.iY=null;this.B4=[this.zi];this.DY=this.zi;this.rS=new g.u0(64);this.Xo=0;this.Qn=-1;this.DQ=!1;this.Rp=this.YJ=this.OP=null;if(!g.m4(this.player.j())&&!g.n9(this.player.j())){D=this.player;var X=g.Fw(D);X&&(X=X.Dy())&&(X=new I4J(D,X),g.U(this,X));X=new YjA(D);g.U(this,X);g.eK(D,X.element,4);this.OP=new a4N;g.U(this,this.OP);g.eK(D,this.OP.element,4);this.DQ=
!!VB()}}create(){var D=this.player.j();const X=g.lE(D);D={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:D.X("mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:D.X("enable_dial_short_lived_lounge_token"),enableCastLoungeToken:D.X("enable_cast_short_lived_lounge_token")};l4N(X,D);this.subscriptions.push(g.Oy("yt-remote-before-disconnect",this.cF,this));this.subscriptions.push(g.Oy("yt-remote-connection-change",this.DR,this));this.subscriptions.push(g.Oy("yt-remote-receiver-availability-change",
this.K3,this));this.subscriptions.push(g.Oy("yt-remote-auto-connect",this.Yy,this));this.subscriptions.push(g.Oy("yt-remote-receiver-resumed",this.X8,this));this.subscriptions.push(g.Oy("mdx-privacy-popup-confirm",this.OB,this));this.subscriptions.push(g.Oy("mdx-privacy-popup-cancel",this.b6,this));this.K3()}load(){this.player.cancelPlayback();super.load();this.Rp=new qjP(this.player.j(),this);this.player.VE(this.Rp);this.jd=new NoX(this,this.player,this.iY);var D=(D=uv5())?D.currentTime:0;const X=
fI()?new cgP:null;D==0&&X&&(D=YV(eq(X)));D!==0&&this.Ki(D);AgX(this,this.rS,this.rS);this.player.L8(6)}unload(){this.player.publish("mdxautoplaycanceled");this.player.F1();this.DY=this.zi;g.TX(this.jd,this.iY);this.iY=this.Rp=this.jd=null;super.unload();this.player.L8(5);FH(this)}u0(){g.rG(this.subscriptions);super.u0()}getAdState(){return this.Qn}hasPrevious(){return this.iY?eq(this.iY).hasPrevious:!1}hasNext(){return this.iY?eq(this.iY).hasNext:!1}Ki(D,X){this.Xo=D||0;this.player.publish("progresssync",
D,X);g.Ac(this.player,"onVideoProgress",D||0)}getCurrentTime(){return this.Xo}getDuration(){return eq(this.iY).getDuration()||0}AO(){var D=eq(this.iY);return D.V?D.L+qQ(D):D.L}V2(){return eq(this.iY).loadedTime}e_(){return dD8(eq(this.iY))}F0(){var D=eq(this.iY);return D.Z>0?D.Z+qQ(D):D.Z}getProgressState(){const D=eq(this.iY),X=this.player.getVideoData();return{airingStart:0,airingEnd:0,allowSeeking:D.playerState!=1081&&this.player.Mp(),clipEnd:X.clipEnd,clipStart:X.clipStart,current:this.getCurrentTime(),
displayedStart:-1,duration:this.getDuration(),ingestionTime:this.AO(),isAtLiveHead:this.isAtLiveHead(),loaded:this.V2(),seekableEnd:this.e_(),seekableStart:this.F0(),offset:0,viewerLivestreamJoinMediaTime:0}}isAtLiveHead(){return dD8(eq(this.iY))-this.getCurrentTime()<=1}nextVideo(){this.iY&&this.iY.nextVideo()}zR(){this.iY&&this.iY.zR()}cF(D){D===1&&(this.v6=this.iY?eq(this.iY):null)}DR(){var D=fI()?new cgP:null;if(D){const X=this.DY;this.loaded&&this.unload();this.iY=D;this.v6=null;X.key!==this.zi.key&&
(this.DY=X,this.load())}else g.wK(this.iY),this.iY=null,this.loaded&&(this.unload(),(D=this.v6)&&D.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(D.videoId,YV(D)));this.player.publish("videodatachange","newdata",this.player.getVideoData(),3)}K3(){var D=[this.zi],X=D.concat;const B=$08();bX()&&g.ys("yt-remote-cast-available")&&B.push({key:"cast-selector-receiver",name:"Cast..."});this.B4=X.call(D,B);D=ij()||this.zi;z2(this,D);g.Ac(this.player,"onMdxReceiversChange")}Yy(){const D=
ij();z2(this,D)}X8(){this.DY=ij()}OB(){this.DQ=!0;FH(this);pI=!1;lj&&Wf(lj,1);lj=null}b6(){this.DQ=!1;FH(this);z2(this,this.zi);this.DY=this.zi;pI=!1;lj=null;this.player.playVideo()}LO(D,X){switch(D){case "casting":return this.loaded;case "receivers":return this.B4;case "currentReceiver":return X&&(X.key==="cast-selector-receiver"?sn():z2(this,X)),this.loaded?this.DY:this.zi;case "quickCast":return this.B4.length===2&&this.B4[1].key==="cast-selector-receiver"?(X&&sn(),!0):!1}}KG(){this.iY.KG()}BM(){return!1}getOptions(){return["casting",
"receivers","currentReceiver","quickCast"]}isLoggedIn(){return g.e("PLAYER_CONFIG")?.args?.authuser!==void 0?!0:!(!g.e("SESSION_INDEX")&&!g.e("LOGGED_IN"))}});})(_yt_player);
Ә