(function(g){var window=this;'use strict';var lta=function(p){if(p instanceof g.WK)return p;if(typeof p.q5=="function")return p.q5(!1);if(g.$m(p)){let a=0;const l=new g.WK;l.next=function(){for(;;){if(a>=p.length)return g.kM;if(a in p)return g.J0(p[a++]);a++}}; return l}throw Error("Not implemented");},Va_=function(){var p=yda; SXW();le.push(p);nZK()},X81=function(p,a){a=a.message; a.params?yf("Received: action="+a.action+", params="+g.Ad(a.params)):yf("Received: action="+a.action+" {}");switch(a.action){case "loungeStatus":a=S7(a.params.devices);p.U=g.Nx(a,function(y){return new nS(y)}); a=!!g.y_(p.U,function(y){return y.type=="LOUNGE_SCREEN"}); ZOl(p,a);a=p.ac("mlm");p.publish("multiStateLoopEnabled",a);break;case "loungeScreenDisconnected":g.r_(p.U,function(y){return y.type=="LOUNGE_SCREEN"}); ZOl(p,!1);break;case "remoteConnected":let l=new nS(S7(a.params.device));g.y_(p.U,function(y){return y.equals(l)})||oZK(p.U,l); break;case "remoteDisconnected":l=new nS(S7(a.params.device));g.r_(p.U,function(y){return y.equals(l)}); break;case "gracefulDisconnect":break;case "playlistModified":zZU(p,a,"QUEUE_MODIFIED");break;case "nowPlaying":dGc(p,a);break;case "onStateChange":GE1(p,a);break;case "onAdStateChange":B87(p,a);break;case "onVolumeChanged":cd_(p,a);break;case "onSubtitlesTrackChanged":rdG(p,a);break;case "nowAutoplaying":w82(p,a);break;case "autoplayDismissed":p.publish("autoplayDismissed");break;case "autoplayUpNext":$Gl(p,a);break;case "onAutoplayModeChanged":Pnl(p,a);break;case "onHasPreviousNextChanged":LQ1(p, a);break;case "requestAssistedSignIn":p.publish("assistedSignInRequested",a.params.authCode);break;case "onLoopModeChanged":p.publish("loopModeChange",a.params.loopMode);break;default:yf("Unrecognized action: "+a.action)}},Vf=function(p,a,l){g.YB.call(this); this.D=l!=null?(0,g.Qo)(p,l):p;this.mD=a;this.X=(0,g.Qo)(this.Di,this);this.L=!1;this.S=0;this.U=this.xE=null;this.j=[]},xGU=function(p){return!!document.currentScript&&(document.currentScript.src.indexOf("?"+p)!=-1||document.currentScript.src.indexOf("&"+p)!=-1)},Cn7=function(p,a){p.capabilities.clear(); g.B4(a.split(","),g.i_(FQa,EZU)).forEach(l=>{p.capabilities.add(l)})},KQ1=function(p,a){var l=p.G,y=a.indexOf("\n",l); if(y==-1)return ZZ;l=Number(a.substring(l,y));if(isNaN(l))return vZ8;y+=1;if(y+l>a.length)return ZZ;a=a.slice(y,y+l);p.G=y+l;return a},o3=function(p){let a=0; for(const l in p)a++;return a},bO2=function(p,a){eZc(p,a).forEach(function(l){g.eX.prototype.remove.call(this,l)},p)},It7=function(p){const a=p.L.media,l=p.L.customData; if(a&&l){var y=zn(p);a.contentId!=y.videoId&&dS("Cast changing video to: "+a.contentId);y.videoId=a.contentId;y.playerState=l.playerState;Gn(y,p.L.getEstimatedTime());BC(p,y)}else dS("No cast media video. Ignoring state update.")},cC=function(p,a){let l,y; var S=p.B.getPlaylist();S?.listId&&(l=S.index,y=S.listId.toString());S=p.B.getVideoData(1);p.Nc.playVideo(S.videoId,a,l,y,S.playerParams,S.jl,RZK(S));p.X7(new g.bB(1))},LS=function(p){const a=rS(); wS(null);p||uWG("");g.eo("yt.mdx.remote.connection_",p);$f&&(g.Ir($f,function(l){l(p)}),$f.length=0); a&&!p?PC("yt-remote-connection-change",!1):!a&&p&&PC("yt-remote-connection-change",!0)},LQ1=function(p,a){const l=a.params.hasNext=="true"; p.L.Bk=a.params.hasPrevious=="true";p.L.Wo=l;p.publish("previousNextChange")},OOc=function(){g.V2("yt-remote-lounge-token-expiration",!0,86400)},XQ=function(){g.Fc.call(this,"o")},FQa=function(p,a){return g.DK(p,a)},zn=function(p){return new xf(p.j.getPlayerContextData())},ZOl=function(p,a){var l=null; if(a){const y=kEB(p);y&&(l={clientName:y.clientName,deviceMake:y.brand,deviceModel:y.model,osVersion:y.osVersion})}g.eo("yt.mdx.remote.remoteClient_",l);a&&(FQ(p),EN(p));l=p.S.HH()&&isNaN(p.D);a==l?a&&(CS(p,1),vC(p,"getSubtitlesTrack")):a?(p.Rc()&&p.L.reset(),CS(p,1),vC(p,"getNowPlaying"),MaW(p)):p.G(1)},mGM=function(p){p.D=g.jQ(()=>{yf("Connecting timeout"); p.G(1)},2E4)},ta2=function(p){return p.L?p.jl=="GET"&&p.Bs!=2&&p.U.ir:!1},e7=function(p,a,l){p.Bs=1; p.K=KS(a.clone());p.C=l;p.w7=!0;jgK(p,null)},I3=function(p,a,l=!1,y=()=>"",S=!1,n=!1,V=!1,Z=()=>g.R2({}),z=!1,d,G=!1,B=!1,c=!1,w=!1){this.Bs=p; this.UO=a;this.D=new g.tj;this.S=new be(this.xb,this);this.L=null;this.G=!1;this.C=null;this.Sl="";this.N=this.K=0;this.U=[];this.Fu=l;this.w7=y;this.X=n;this.QY=Z;this.Ws=d;this.Lx=V;this.jl=null;this.j=g.R2();this.E6=S;this.NO=z;this.Ps=G;this.iT=B;this.Ha=c;this.VY=w;this.Ic=new WQl;this.Hs=new HOG;this.Tm=new DGc;this.ac=new iOl;this.Rc=new T8K;this.dG=new N8M;this.Ba=new sgW},Qg7=function(p){const a=p.S.m4(); let l=p.L&&p.L.S;p=g.Nx(a,function(y){l&&R3(y,l.label)&&(l=null);const S=y.uuid?y.uuid:y.id;let n=UG2(this,y);n?(n.label=S,n.friendlyName=y.name):(n=new chrome.cast.Receiver(S,y.name),n.receiverType=chrome.cast.ReceiverType.CUSTOM);return n},p); l&&(l.receiverType!=chrome.cast.ReceiverType.CUSTOM&&(l=new chrome.cast.Receiver(l.label,l.friendlyName),l.receiverType=chrome.cast.ReceiverType.CUSTOM),p.push(l));return p},ue=function(p,a,l){const y=zn(p); Gn(y,l);y.playerState!=-1E3&&(y.playerState=a);BC(p,y)},ON=function(p){p.X=g.Wk("yt-remote-device-id-map")||{}},kf=function(p,a){return g.y_(p,function(l){return R3(l,a)})},be=function(p,a){g.YB.call(this); this.L=new g.SF(this.FB,0,this);g.H(this,this.L);this.mD=5E3;this.S=0;if(typeof p==="function")a&&(p=(0,g.Qo)(p,a));else if(p&&typeof p.handleEvent==="function")p=(0,g.Qo)(p.handleEvent,p);else throw Error("Invalid listener argument");this.U=p},Adb=function(){const p=Mq(); p?(ti("Resume connection to: "+j7(p)),WC(p,0)):(HC(),hZG(),ti("Skipping connecting because no session screen found."))},DZ=function(p){p.length?gZG(p.shift(),function(){DZ(p)}):ie()},YX8=function(p){return g.Nx(p,function(a){return{key:a.id, name:a.name}})},Tn=function(){let p=window.navigator.userAgent.match(/Chrome\/([0-9]+)/); return p?parseInt(p[1],10):0},ie=function(){let p=qXc(); p&&p(!1,"No cast extension found")},UN=function(){let p=Nq(); const a=sN();g.X_()&&g.fc(p,a);p=Jda(p);if(p.length==0)try{g.ET("remote_sid")}catch(l){}else try{g.b7("remote_sid",p.join(","),-1)}catch(l){}},Qf=function(){g.Fc.call(this,"p")},ftM=function(){const p=g.O_.bO(); p&&bO2(p,p.Yp.q5(!0))},pZW=function(p){let a=0; p.jj&&a++;p.Al&&a++;return a},Nq=function(){const p=g.Wk("yt-remote-connected-devices")||[]; g.cL(p);return p},a1b=function(p){if(!ta2(p))return g.me(p.L); const a=g.gR(p.L);if(a==="")return"";let l="";const y=a.length,S=g.aU(p.L)==4;if(!p.S.S){if(typeof TextDecoder==="undefined")return hi(p),Ai(p),"";p.S.S=new g.mm.TextDecoder}for(let n=0;n{rqM(p,null)},3E4)},Pmb=function(){const p=$hK(); let a=$l();a||(a=Mq());return g.y_(p,function(l){return a&&R3(a,l.key)?!0:!1})},Ln7=function(p){g.V2("yt-remote-connected-devices",p,86400)},CS=function(p,a){p.publish("proxyStateChange",a)},BC=function(p,a){XZ_(p); p.j.setPlayerContextData(Po(a));xha(p)},LM=function(p){return zn(p.Nc).videoId===p.B.getVideoData(1).videoId},EJ8=function(p,a,l,y,S){if(y==0)l(!1); else{var n=S||0;y--;FnM(p,a,function(V){V?l(!0):g.mm.setTimeout(function(){EJ8(p,a,l,y,n)},n)})}},pM=function(){return!!g.o1("yt.mdx.remote.cloudview.apiReady_")},zxc=function(){return g.Wk("yt-remote-local-screens")||[]},Cm7=function(p,a){p.BN=Date.now(); X5(p);p.Ie=p.WN.clone();xl(p.Ie,"t",p.D);p.JB=0;p.uX=p.L.UP(p.L.Qc()?a:null);p.LF>0&&(p.TT=new g.J1((0,g.Qo)(p.Zt,p,p.uX),p.LF));p.U.listen(p.uX,"readystatechange",p.vU);a=p.fH?g.O1(p.fH):{};p.E1?(p.cT="POST",a["Content-Type"]="application/x-www-form-urlencoded",p.uX.send(p.Ie,p.cT,p.E1,a)):(p.cT="GET",p.j6&&!g.H5&&(a.Connection="close"),p.uX.send(p.Ie,p.cT,null,a));p.L.dN(1)},vJ2=function(p){const a=p.player.O(); return!a.A("mdx_enable_privacy_disclosure_ui")||p.isLoggedIn()||p.F9||!p.WC?!1:g.p8(a)||g.cy(a)},Eo=function(p){if(p.L||p.K||p.N>=3)return!1; p.Lx++;p.K=F5((0,g.Qo)(p.Te,p),Knc(p,p.N));p.N++;return!0},vo=function(p,a,l){const y=p.videoId; p.videoId=a;p.index=l;a!=y&&CM(p)},ex_=function(p,a){const l=new KM,y=new AbortController,S=setTimeout(()=>{y.abort(); Sr(l,"TestPingServer: timeout",!1,a)},1E4); fetch(p,{signal:y.signal}).then(n=>{clearTimeout(S);n.ok?Sr(l,"TestPingServer: ok",!0,a):Sr(l,"TestPingServer: server error",!1,a)}).catch(()=>{clearTimeout(S); Sr(l,"TestPingServer: error",!1,a)})},b2=function(p,a){a?(p.info("onConnectedScreenId_: Received screenId: "+a),p.L&&p.L.id==a||p.Ws(a,l=>{er(p,l)},()=>p.xf(),5)):p.xf(Error("Waiting for session status timed out."))},Io=function(p,a){this.S={}; this.L=[];this.Vn=this.size=0;var l=arguments.length;if(l>1){if(l%2)throw Error("Uneven number of arguments");for(var y=0;ya.length)return tH;a=a.slice(y,y+l);p.JB=y+l;return a},jr=function(p){return new Promise(a=>{p.Sl=oo(); if(p.QY){const l=new chrome.cast.DialLaunchResponse(!0,jal(p));a(l);WnW(p)}else p.N=()=>{g.tO(p.UO);p.N=()=>{}; p.UO=NaN;const l=new chrome.cast.DialLaunchResponse(!0,jal(p));a(l);WnW(p)},p.UO=g.jQ(()=>{p.N()},100)})},H7U=function(p){if(p.screens.length){const a=g.Nx(p.screens,function(y){return y.id}),l=Wo(p.S,"/pairing/get_lounge_token_batch"); p.S.sendRequest("POST",l,{screen_ids:a.join(",")},(0,g.Qo)(p.W$,p),(0,g.Qo)(p.dW,p))}},Dh_=function(p,a){if(p.L){let l=p.L.oQ||{}; a&&Object.keys(a).length>0?l={...l,...a}:delete l.Authorization;p.L.oQ=l}},PC=function(p,a){g.KD[p]=!0; const l=g.Gj();l&&l.publish.apply(l,arguments);g.KD[p]=!1},i72=function(p){Ho("setApiReady_ "+p); g.eo("yt.mdx.remote.cloudview.apiReady_",p)},NA1=function(p,a){p.compatibleSenderThemes.clear(); g.B4(a.split(","),g.i_(FQa,TAl)).forEach(l=>{p.compatibleSenderThemes.add(l)})},Nm=function(p,a){if(a.key!==p.EV.key)if(a.key===p.nE.key)ys(); else if(vJ2(p)&&saB(p),p.EV=a,!g.cf(p.player.O())){{const n=p.player.getPlaylistId();var l=p.player.getVideoData(1);const V=l.videoId;if(!n&&!V||(p.player.getAppState()===2||p.player.getAppState()===1)&&p.player.O().A("should_clear_video_data_on_player_cued_unstarted"))l=null;else{var y=p.player.getPlaylist();if(y){var S=[];for(let Z=0;Z0||!(y==1&&hxW(p,a)||y==2&&Eo(p)))switch(l&&l.length>0&&(a=p.S,a.U=a.U.concat(l)),S){case 1:AH(p,5);break;case 4:AH(p,10);break;case 3:AH(p,6);break;default:AH(p,2)}}},j7=function(p){return p?`{name:"${p.name}",id:${p.id.substr(0, 6)}..,`+`token:${p.token?".."+p.token.slice(-6):"-"},uuid:${p.uuid?".."+p.uuid.slice(-6):"-"},idType:${p.idType}}`:"null"},hZG=function(){Ho("clearCurrentReceiver"); g.IZ("yt-remote-cast-receiver")},Ycl=function(p,a,l,y){g.tO(p.G); p.G=0;gJl(p.j,a,S=>{S||y<0?l(S):p.G=g.jQ(()=>{Ycl(p,a,l,y-1)},300)})},Wo=function(p,a){let l=p.L; p.S&&(l=p.scheme+"://"+p.domain+p.port+p.L);return g.Re(l+a,{})},qm=function(p){if(p.size!=p.L.length){for(var a=0,l=0;a{p.experiments.add(l)})},yN=function(p,a,l){a!=p.L&&(g.Er(p.L),(p.L=a)?(l?p.publish("yt-remote-cast2-receiver-resumed",a.S):p.publish("yt-remote-cast2-receiver-selected",a.S),a.subscribe("sessionScreen",(0,g.Qo)(p.UO,p,a)),a.subscribe("sessionFailed",()=>Zhc(p,a)),a.L?p.publish("yt-remote-cast2-session-change",a.L):l&&p.L.D(null)):p.publish("yt-remote-cast2-session-change",null))},d4K=function(p,a){p.L=0; p.N3&&p.N3.P0(a);oDa(p);zOW(p)},jgK=function(p,a){p.Sl=Date.now(); Mm(p);p.ac=p.K.clone();xl(p.ac,"t",p.Lx);p.G=0;const l=p.U.Hs;p.S=new dhM;p.L=G1c(p.U,l?a:null,!p.C);p.Ic>0&&(p.Rc=new g.J1((0,g.Qo)(p.Ge,p,p.L),p.Ic));p.Ps.listen(p.L,"readystatechange",p.Ab);a=p.QY?g.O1(p.QY):{};p.C?(p.jl||(p.jl="POST"),a["Content-Type"]="application/x-www-form-urlencoded",p.L.send(p.ac,p.jl,p.C,a)):(p.jl="GET",p.L.send(p.ac,p.jl,null,a));SL(1)},nb=function(p){if(p.L){const a=p.w7(),l=p.L.oQ||{}; a?l["x-youtube-lounge-xsrf-token"]=a:delete l["x-youtube-lounge-xsrf-token"];p.L.oQ=l}},z_=function(p,a){SXW(); const l=SnU(p,String(a));le.length==0?BAb(l):(nZK(),g.Ir(le,function(y){y(l)}))},VN=function(p){p.L.Cv()||p.gx||p.L.XO(p)},BrK=function(){if(!Zg){const p=g.u7(); p&&(Zg=new g.Az(p))}},l11=function(p){g.Fc.call(this,"statevent",p)},cIU=function(p){return{name:p.name, screenId:p.id,loungeToken:p.token,dialId:p.uuid,screenIdType:p.idType}},Pf1=function(p,a,l=()=>"",y,S){const n=()=>new I3(Wo(p,"/bc"),a,!1,l,y); return g.nU("enable_mdx_web_channel_desktop")?new rIl(()=>new w4G(Wo(p,"/wc"),a,l)):new $47(n,S)},X4M=function(){ou(); let p=Lf_();p.push("//www.gstatic.com/eureka/clank/cast_sender.js");DZ(p)},Lf_=function(){const p=Tn(),a=[]; if(p>1){const l=p-1;a.push("//www.gstatic.com/eureka/clank/"+p+"/cast_sender.js");a.push("//www.gstatic.com/eureka/clank/"+l+"/cast_sender.js")}return a},Ff2=function(p){zC(p)&&p.U.getDialAppInfo(a=>{p.info(`getDialAppInfo dialLaunchData: ${JSON.stringify(a)}`); a=a.extraData||{};let l=null;a.loungeToken?p.L?.token==a.loungeToken&&(l="staleLoungeToken"):l="missingLoungeToken";l?dZ(p,3E4):(x4U(p,a.loungeToken),dZ(p,a.loungeTokenRefreshIntervalMs))},a=>{p.info(`getDialAppInfo error: ${a}`); dZ(p,3E4)})},GC=function(p,a){if(p.L==0)throw Error("Invalid operation: sending map when state is closed"); p.S.push(new a_U(p.G7++,a));p.L!=2&&p.L!=3||lI(p)},EDU=function(p){p.L=new Bo(p,p.j,"rpc",p.Lx); p.G===null&&(p.L.QY=p.C);p.L.Ic=0;var a=p.ZN.clone();g.tN(a,"RID","rpc");g.tN(a,"SID",p.j);g.tN(a,"AID",p.Bs);g.tN(a,"CI",p.Rc?"0":"1");!p.Rc&&p.Kx&&g.tN(a,"TO",p.Kx);g.tN(a,"TYPE","xmlhttp");Ro(p,a);p.G&&p.C&&g.KV(a,p.G,p.C);p.Ic&&p.L.setTimeout(p.Ic);var l=p.L;p=p.E6;l.Bs=1;l.K=KS(a.clone());l.C=null;l.w7=!0;jgK(l,p)},B87=function(p,a){if(p.L.playerState!=-1E3){var l=1085; switch(parseInt(a.params.adState,10)){case 1:l=1081;break;case 2:l=1084;break;case 0:l=1083}p.L.playerState=l;a=parseInt(a.params.currentTime,10);Gn(p.L,isNaN(a)?0:a);p.publish("remotePlayerChange")}},Cfl=function(p){g.tO(p.G); p.G=0;g.tO(p.K);p.K=0;p.X();p.X=()=>{}; g.tO(p.UO)},BI=function(p){p.publish("handlerOpened"); p.Ic.L("BROWSER_CHANNEL")},cI=function(p){p.d1!=null&&(g.mm.clearTimeout(p.d1),p.d1=null)},p4B=function(p){rZ(p); p.K&&(g.mm.clearTimeout(p.K),p.K=null);so(p);p.S.cancel();p.D&&(typeof p.D==="number"&&g.mm.clearTimeout(p.D),p.D=null)},Kf8=function(p,a,l,y,S,n){p.info("getAutomaticScreenByIds "+l+" / "+a); l||(l=p.X[a]);const V=p.EM();let Z=l?kf(V,l):null;l&&(p.G||Z)||(Z=kf(V,a));if(Z){Z.uuid=a;const z=wZ(p,Z);$y(p.L,z,function(d){S(d?z:null)})}else l?vDl(p,l,(0,g.Qo)(function(z){const d=wZ(this,new PI({name:y, screenId:l,loungeToken:z,dialId:a||""}));$y(this.L,d,function(G){S(G?d:null)})},p),n):S(null)},Xy=function(p,a,l){this.L=1; this.S=[];this.U=[];this.X=new Lb;this.C=p||null;this.D=a!=null?a:null;this.K=l||!1},$hK=function(){var p=T_().Wl.$_gos(); const a=$l();a&&rS()&&(pb(p,a)||p.push(a));return YX8(p)},eOG=function(p){p.Ly&&(g.mm.clearTimeout(p.Ly),p.Ly=null)},bhl=function(p){p.screens=p.S.EM(); var a=p.X;const l={};for(var y in a)l[a[y]]=y;a=p.screens.length;for(y=0;y{Kf8(p.j,l,a,y,n=>{n&&n.token&&er(p,n);S(n)},n=>{Fy(p,"Failed to get DIAL screen: "+n); S(null)})})).then(S=>S&&S.token?new chrome.cast.DialLaunchResponse(!1):jr(p))},F5=function(p,a){if(typeof p!=="function")throw Error("Fn must not be null and must be a function"); return g.mm.setTimeout(function(){p()},a)},b77=function(p,a,l){l=Math.min(p.U.length,l); const y=p.X?(0,g.Qo)(p.X.Rm,p.X,p):null;a:{var S=p.U;let Z=-1;for(;;){const z=["count="+l];Z==-1?l>0?(Z=S[0].L,z.push("ofs="+Z)):Z=0:z.push("ofs="+Z);let d=!0;for(let G=0;G=0&&window.navigator.userAgent.indexOf("Chrome/")>=0&&window.navigator.presentation?Tn()>=60&&X4M():!window.chrome||!window.navigator.presentation||window.navigator.userAgent.indexOf("Edge")>=0?ie():Tn()>=89?Wfc():(ou(),DZ(HhW.map(D4B))))):Ho("Cannot initialize because not running Chrome")}, TrW=function(p,a){if(LM(p)){p.Nc.unsubscribe("remotePlayerChange",p.X,p); const l=Math.round(a.volume);a=!!a.muted;const y=zn(p.Nc);if(l!==y.volume||a!==y.muted)p.Nc.setVolume(l,a),p.N.start();p.Nc.subscribe("remotePlayerChange",p.X,p)}},NrK=function(p,a){return new g.Ogh(p,a)},Uo=function(p){p.jl!=null&&(g.mm.clearTimeout(p.jl),p.jl=null)},eZc=function(p,a){const l=[]; shM(a,function(y){let S;try{S=g.eX.prototype.Xl.call(this,y,!0)}catch(n){if(n=="Storage: Invalid value was encountered")return;throw n;}S===void 0?l.push(y):g.wZr(S)&&l.push(y)},p); return l},$y=function(p,a,l){const y=Wo(p.X,"/pairing/get_screen_availability"); p.X.sendRequest("POST",y,{lounge_token:a.token},(0,g.Qo)(function(S){S=S.screens||[];const n=S.length;for(let V=0;V=3)return!1; p.G++;p.Ri=OE((0,g.Qo)(p.ze,p),uMM(p,p.S3));p.S3++;return!0},w82=function(p,a){p.K=a.params.videoId; p.publish("nowAutoplaying",parseInt(a.params.timeout,10))},ao=function(){return g.o1("yt.mdx.remote.cloudview.instance_")},hOc=function(p,a){if(a)if(p.w1>6){p.S=p.U.concat(p.S); p.U.length=0;var l=p.l2-1;a=MI(p)}else l=a.G,a=a.E1;else l=p.l2++,a=MI(p);const y=p.oe.clone();g.tN(y,"SID",p.j);g.tN(y,"RID",l);g.tN(y,"AID",p.j3);mk(p,y);l=new t4(p,p.j,l,p.US+1);l.fH=p.oQ;l.setTimeout(1E4+Math.round(1E4*Math.random()));p.Al=l;QhW(l,y,a)},xl=function(p,a,l){Array.isArray(l)||(l=[String(l)]); g.clo(p.j,a,l)},zC=function(p){return!(!p.config_.enableDialLoungeToken||!p.U?.getDialAppInfo)},AI8=function(p){return new PI(p)},gD_=function(p,a){try{p.L.ox(p,a),p.L.dN(4)}catch(l){}},yql=function(p){this.U=[]; this.E6=this.ZN=this.QY=this.Ha=this.L=this.tP=this.w7=this.Ws=this.G=this.NO=this.C=null;this.bf=this.ac=0;this.Wy=Oo("failFast",!1,p);this.Rc=this.UO=this.K=this.D=this.X=null;this.dG=!0;this.Ye=this.Bs=-1;this.Lx=this.N=this.Sl=0;this.PZ=Oo("baseRetryDelayMs",5E3,p);this.tN=Oo("retryDelaySeedMs",1E4,p);this.g$=Oo("forwardChannelMaxRetries",2,p);this.zn=Oo("forwardChannelRequestTimeoutMs",2E4,p);this.wq=p&&p.Xi9||void 0;this.r$=p&&p.FOz||void 0;this.ir=p&&p.j9c||!1;this.Ic=void 0;this.Hs=p&&p.QB|| !1;this.j="";this.S=new Yn8(p&&p.cgu);this.OC=new qnB;this.Ps=p&&p.fyl||!1;this.iT=p&&p.FSv||!1;this.Ps&&this.iT&&(this.iT=!1);this.Me=p&&p.aNs||!1;p&&p.EEs&&(this.dG=!1);this.Ba=!this.Ps&&this.dG&&p&&p.PMY||!1;this.Kx=void 0;p&&p.MU&&p.MU>0&&(this.Kx=p.MU);this.VY=void 0;this.Ro=0;this.Tm=!1;this.Fu=this.jl=null},JIa=function(){},D4B=function(p){return"chrome-extension://"+p+"/cast_sender.js"},jL=function(p,a){f__(g.Nx(p.screens,cIU)); a&&OOc()},Ro=function(p,a){p.Ws&&g.yo(p.Ws,function(l,y){g.tN(a,y,l)}); p.X&&g.yo({},function(l,y){g.tN(a,y,l)})},x4U=function(p,a){p.L&&(p.L.token=a,wZ(p.j,p.L)); p.publish("sessionScreen",p.L)},zOW=function(p){p.fN&&(p.fN.abort(),p.fN=null); p.jj&&(p.jj.cancel(),p.jj=null);p.Ri&&(g.mm.clearTimeout(p.Ri),p.Ri=null);cI(p);p.Al&&(p.Al.cancel(),p.Al=null);p.FJ&&(g.mm.clearTimeout(p.FJ),p.FJ=null)},WI=function(){return g.o1("yt.mdx.remote.channelParams_")||{}},Dg=function(p,a=!1){HI.call(this,"ScreenService"); this.j=p;this.G=a;this.L=this.S=null;this.U=[];this.X={};OhG(this)},p2U=function(p,a){this.action=p; this.params=a||{}},xha=function(p){g.Ir("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange multiStateLoopEnabled loopModeChange".split(" "),function(a){this.G.push(this.j.subscribe(a,g.i_(this.Hs,a),this))},p)},az2=function(){this.L=[]; this.S=[]},gJl=function(p,a,l){$y(p.L,a,l)},qq=function(p){this.L=p},UG2=function(p,a){return a?g.y_(p.U,function(l){return R3(a,l.label)},p):null},rS=function(){return g.o1("yt.mdx.remote.connection_")},Zhc=function(p,a){p.L==a&&p.publish("yt-remote-cast2-session-failed")},er=function(p,a){p.L=a; p.publish("sessionScreen",p.L)},dZ=function(p,a){p.info(`getDialAppInfoWithTimeout_ ${a}`); zC(p)&&(g.tO(p.K),p.K=0,a==0?Ff2(p):p.K=g.jQ(()=>{Ff2(p)},a))},GE1=function(p,a){var l=parseInt(a.params.currentTime||a.params.current_time,10); Gn(p.L,isNaN(l)?0:l);l=parseInt(a.params.state,10);l=isNaN(l)?-1:l;l==-1&&p.L.playerState==-1E3&&(l=-1E3);p.L.playerState=l;l=Number(a.params.loadedTime);p.L.K=isNaN(l)?0:l;p.L.aQ(Number(a.params.duration));l=p.L;var y=Number(a.params.liveIngestionTime);l.L=y;l.j=isNaN(y)?!1:!0;l=p.L;y=Number(a.params.seekableStartTime);a=Number(a.params.seekableEndTime);l.S=isNaN(y)?0:y;l.G=isNaN(a)?0:a;p.L.playerState==1?lza(p):iI(p);p.publish("remotePlayerChange")},dS=function(p){z_("CP",p)},ti=function(p){z_("remote", p)},TC=function(p){p.onload=null; p.onerror=null;p.onabort=null;p.ontimeout=null},yfc=function(p,a){const l=p.get(a.uuid)||p.get(a.id); if(l)return p=l.name,l.id=a.id||l.id,l.name=a.name,l.token=a.token,l.uuid=a.uuid||l.uuid,l.name!=p;p.screens.push(a);return!0},QhW=function(p,a,l){p.Kp=1; p.WN=KS(a.clone());p.E1=l;p.w7=!0;Cm7(p,null)},sN=function(){if(NI)return NI; let p=g.Wk("yt-remote-device-id");p||(p=oo(),g.V2("yt-remote-device-id",p,31536E3));const a=Nq();let l=1,y=p;for(;g.tU(a,y);)l++,y=p+"#"+l;return NI=y},XZ_=function(p){g.Ir(p.G,function(a){this.j.unsubscribeByKey(a)},p); p.G.length=0},tvB=function(){Ho("dispose"); const p=ao();p&&p.dispose();g.eo("yt.mdx.remote.cloudview.instance_",null);i72(!1);g.DC(EE);EE.length=0},sE=function(p,a){if(LM(p)&&!p.D){let l=null; a&&(l={style:p.B.getSubtitlesUserSettings()},Object.assign(l,a));p.Nc.K(p.B.getVideoData(1).videoId,l);p.j=zn(p.Nc).trackData}},S9a=function(p,a,l){p.Ch=l; p.player.publish("presentingplayerstatechange",new g.e2(l,a))},nH_=function(p,a,l,y){g.tO(p.G); p.G=0;gJl(p.j,a,S=>{S||y<0?l(S):p.G=g.jQ(()=>{nH_(p,a,l,y-1)},300)})},UE=function(p){if(p.S!=null)return p.U.concat(p.S.N); if(p.L!=null&&p.L.size!==0){let a=p.U;for(const l of p.L.values())a=a.concat(l.N);return a}return g.WW(p.U)},G1c=function(p,a,l){if(a&&!p.Hs)throw Error("Can't create secondary domain capable XhrIo object."); a=p.ir&&!p.wq?new g.Bj(new g.h$({aG:l})):new g.Bj(p.wq);a.G=p.Hs;return a},shM=function(p,a,l){if(g.$m(p))g.Ir(p,a,l); else for(p=lta(p);;){const {done:y,value:S}=p.next();if(y)break;a.call(l,S,void 0,p)}},Z7b=function(p,a){let l=p.screens.length!=a.length; p.screens=g.B4(p.screens,function(S){return!!pb(a,S)}); const y=a.length;for(let S=0;S{Ycl(p,y,n=>{n?(wZ(p.j,y),er(p,y),dZ(p,l)):g.Wp(Error(`DialSession, RemoteScreen from screenData: ${JSON.stringify(a)} is not online.`));S(n)},5)})).then(S=>S?new chrome.cast.DialLaunchResponse(!1):jr(p))},hxW=function(p,a){if(Iu(p.S)>=p.S.j-(p.D?1:0))return!1; if(p.D)return p.U=a.N.concat(p.U),!0;if(p.mN==1||p.mN==2||p.Sl>=(p.Wy?0:p.g$))return!1;p.D=F5((0,g.Qo)(p.pn,p,a),Knc(p,p.Sl));p.Sl++;return!0},MI=function(p){const a=Math.min(p.S.length,1E3),l=["count="+a]; let y;p.w1>6&&a>0?(y=p.S[0].L,l.push("ofs="+y)):y=0;for(let S=0;S0&&(l.Ic=1.5*c);y=l;const w=p.BP();if(w){const X=g.Ez(w,"X-Client-Wire-Protocol");if(X){var n=y.S;!n.L&&(g.uB(X,"spdy")||g.uB(X,"quic")||g.uB(X,"h2"))&&(n.j=n.X,n.L=new Set,n.S&&(u2(n,n.S),n.S=null))}if(y.w7){const v=g.Ez(w,"X-HTTP-Session-Id");v&&(y.tP=v,g.tN(y.QY,y.w7,v))}}l.mN=3;l.X&&l.X.i6();l.Ba&&(l.Ro=Date.now()-p.Sl);y=l;var V=p;y.ZN=oHM(y,y.Hs? y.E6:null,y.Ha);if(V.Hs){UhU(y.S,V);var Z=V,z=y.Ic;z&&Z.setTimeout(z);Z.UO&&(fS(Z),Mm(Z));y.L=V}else RxU(y);l.U.length>0&&hH(l)}else d[0]!="stop"&&d[0]!="close"||AH(l,7);else l.mN==3&&(d[0]=="stop"||d[0]=="close"?d[0]=="stop"?AH(l,7):l.disconnect():d[0]!="noop"&&l.X&&l.X.JU(d),l.N=0)}SL(4)}catch(d){}},d8B=function(p,a){g.tO(p.UO); p.UO=0;a?p.config_.enableCastLoungeToken&&a.loungeToken?a.deviceId?p.L&&p.L.uuid==a.deviceId||(a.loungeTokenRefreshIntervalMs?zw8(p,{name:p.S.friendlyName,screenId:a.screenId,loungeToken:a.loungeToken,dialId:a.deviceId,screenIdType:"shortLived"},a.loungeTokenRefreshIntervalMs):(g.Wp(Error(`No loungeTokenRefreshIntervalMs presents in mdxSessionStatusData: ${JSON.stringify(a)}.`)),b2(p,a.screenId))):(g.Wp(Error(`No device id presents in mdxSessionStatusData: ${JSON.stringify(a)}.`)),b2(p,a.screenId)): b2(p,a.screenId):p.xf(Error("Waiting for session status timed out."))},h4=function(p,a,...l){p.loaded&&p.p8.vW(a,...l)},GBa=function(p){g.kn(p.channel,"m",()=>{p.D=3; p.U.reset();p.K=null;p.G=0;for(const a of p.N)p.channel&&p.channel.send(a);p.N=[];p.publish("webChannelOpened");p.QY.L("WEB_CHANNEL")}); g.kn(p.channel,"n",()=>{p.D=0;p.U.isActive()||p.publish("webChannelClosed");const a=p.channel?.j().U();a&&(p.N=[...a]);p.jl.L("WEB_CHANNEL")}); g.kn(p.channel,"p",a=>{const l=a.data;l[0]==="gracefulReconnect"?(p.U.start(),p.channel&&p.channel.close()):p.publish("webChannelMessage",new p2U(l[0],l[1]));p.a9=a.statusCode;p.Ws.L("WEB_CHANNEL")}); g.kn(p.channel,"o",()=>{p.a9===401||p.U.start();p.publish("webChannelError");p.w7.L("WEB_CHANNEL","")})},Kb=function(p){HI.call(this,"LocalScreenService"); this.S=p;this.L=NaN;G_(this);this.info("Initializing with "+ZX(this.screens))},eL=function(p){g.eo("yt.mdx.remote.cloudview.initializing_",p)},Qa_=function(p,a,l,y){g.Fc.call(this,"timingevent",p); this.size=a;this.rtt=l;this.retries=y},A4=function(p){isNaN(p.U)||g.tO(p.U); p.U=g.jQ((0,g.Qo)(p.G,p),p.j>0&&p.j{},(0,g.Qo)(function(){Fy(this,"Failed to send message: "+a+".")},p)):Fy(p,"Sending yt message without session: "+g.Ad(l))},DX=function(){const p=rS(); return!!p&&p.getProxyState()!=3},T_=function(){if(!qI){const p=g.o1("yt.mdx.remote.screenService_"); qI=p?new w21(p):null}return qI},i2=function(){return g.o1("yt.mdx.remote.currentScreenId_")},Yn8=function(p){this.X=p||10; g.mm.PerformanceNavigationTiming?(p=g.mm.performance.getEntriesByType("navigation"),p=p.length>0&&(p[0].nextHopProtocol=="hq"||p[0].nextHopProtocol=="h2")):p=!!(g.mm.chrome&&g.mm.chrome.loadTimes&&g.mm.chrome.loadTimes()&&g.mm.chrome.loadTimes().wasFetchedViaSpdy);this.j=p?this.X:1;this.L=null;this.j>1&&(this.L=new Set);this.S=null;this.U=[]},Qs=function(p,a){return p.S?p.S==a:p.L?p.L.has(a):!1},$8_=function(p){yf("Channel opened"); p.Ws&&(p.Ws=!1,EN(p),p.w7=g.jQ(()=>{yf("Timing out waiting for a screen.");p.G(1)},15E3))},MaW=function(p){g.tO(p.N); p.N=g.jQ(()=>{p.G(1)},864E5)},SL=function(p){const a=gS(); a.dispatchEvent(new Scc(a,p))},Pg_=function(p){if(p.mN==0)return p.Fu; let a=[];g.nn(a,UE(p.S));g.nn(a,p.U);return a},LL1=function(p){XQ.call(this); this.status=1;this.errorCode=p},f1c=function(p){p.mN=0; p.Fu=[];if(p.X){const a=UE(p.S);if(a.length!=0||p.U.length!=0)g.nn(p.Fu,a),g.nn(p.Fu,p.U),p.S.U.length=0,g.WW(p.U),p.U.length=0;p.X.Ix()}},Ai=function(p){p.U.Cv()||p.Ws||Aql(p.U,p)},Ho=function(p){z_("cloudview",p)},J4=function(p){eOG(p); g.Er(p.TT);p.TT=null;p.X.stop();p.U.removeAll();if(p.uX){const a=p.uX;p.uX=null;a.abort();a.dispose()}p.YP&&(p.YP=null)},fb=function(p){p.Ws&&!p.X&&Dh_(p,p.Ws())},am=function(p,a){if(a==2||a==9){var l=null; p.N3&&(l=null);var y=(0,g.Qo)(p.R3,p);l||(l=new g.pr("//www.google.com/images/cleardot.gif"),KS(l));FnM(l.toString(),1E4,y)}else pK();d4K(p,a)},ls=function(p){const a=p.Sl(); a?p.j["x-youtube-lounge-xsrf-token"]=a:delete p.j["x-youtube-lounge-xsrf-token"]},y4=function(p){return p.isPlaying()?(g.eB()-p.X)/1E3:0},X2G=async function(p){try{await kl(p)}finally{var a=p.U; p.U=[];var l=a;a=a.length;for(let y=0;y{const y=$l();y&&y.idType=="shortLived"&&(pM()?ao().handleBrowserChannelAuthError():l2("refreshLoungeToken called before API ready."))}); LS(p)}},x8U=function(){return g.o1("yt.mdx.remote.connectData_")},au=function(p,a,l){let y=g.A6(l); if(y.L!="")a&&g.Ud(y,a+"."+y.L),g.Qa(y,y.U);else{const S=window.location;y=FLb(S.protocol,a?a+"."+S.hostname:S.hostname,+S.port,l)}p.DT&&g.yo(p.DT,function(S,n){g.tN(y,n,S)}); g.tN(y,"VER",p.w1);mk(p,y);return y},R3=function(p,a){return!!a&&(p.id==a||p.uuid==a)},Zr=function(p){var a=p.L.D; a!=null?(pK(),a?(pK(),Yy(p.L,p,!1)):(pK(),Yy(p.L,p,!0))):(p.Fv=new t4(p),p.Fv.fH=p.j2,a=p.L,a=au(a,a.Qc()?p.Zh:null,p.y_),pK(),xl(a,"TYPE","xmlhttp"),vI(p.Fv,a,!1,p.Zh,!1))},Fy=function(p,a){z_(p.w7,a)},hH=function(p){EHK(p.S)||p.D||(p.D=!0,g.XM(p.pn,p),p.Sl=0)},Yl=function(p,a){return Object.prototype.hasOwnProperty.call(p,a)},KLM=function(p,a){BrK(); if(!Zg||!Zg.get("yt-remote-disable-remote-module-for-dev")){a=g.R("MDX_CONFIG")||a;ftM();UN();om||(om=new z8(a?a.loungeApiHost:void 0),BMM()&&(om.L="/api/loungedev"));$f||($f=g.o1("yt.mdx.remote.deferredProxies_")||[],g.eo("yt.mdx.remote.deferredProxies_",$f));Cgc();var l=T_();if(!l){const S=new Dg(om,a?a.disableAutomaticScreenCache||!1:!1);g.eo("yt.mdx.remote.screenService_",S);l=T_();var y={};a&&(y={appId:a.appId,disableDial:a.disableDial,theme:a.theme,loadCastApiSetupScript:a.loadCastApiSetupScript, disableCastApi:a.disableCastApi,enableDialLoungeToken:a.enableDialLoungeToken,enableCastLoungeToken:a.enableCastLoungeToken,forceMirroring:a.forceMirroring});g.eo("yt.mdx.remote.enableConnectWithInitialState_",a?a.enableConnectWithInitialState||!1:!1);ih2(p,S,function(n){n?i2()&&dI(i2(),"YouTube TV"):S.subscribe("onlineScreenChange",function(){PC("yt-remote-receiver-availability-change")})},y)}a&&!g.o1("yt.mdx.remote.initialized_")&&(g.eo("yt.mdx.remote.initialized_",!0),ti("Initializing: "+g.Ad(a)), G8.push(g.HT("yt-remote-cast2-api-ready",function(){PC("yt-remote-api-ready")})),G8.push(g.HT("yt-remote-cast2-availability-change",function(){PC("yt-remote-receiver-availability-change")})),G8.push(g.HT("yt-remote-cast2-receiver-selected",function(){wS(null); PC("yt-remote-auto-connect","cast-selector-receiver")})),G8.push(g.HT("yt-remote-cast2-receiver-resumed",function(){PC("yt-remote-receiver-resumed","cast-selector-receiver")})),G8.push(g.HT("yt-remote-cast2-session-change",vHa)),G8.push(g.HT("yt-remote-connection-change",function(S){S?dI(i2(),"YouTube TV"):Mq()||(dI(null,null),hZG())})),G8.push(g.HT("yt-remote-cast2-session-failed",()=>{PC("yt-remote-connection-failed")})),p=WI(),a.isAuto&&(p.id+="#dial"),y=a.capabilities||[],y.length>0&&(p.capabilities= y),p.name=a.device,p.app=a.app,(a=a.theme)&&(p.theme=a),ti(" -- with channel params: "+g.Ad(p)),p?(g.V2("yt-remote-session-app",p.app),g.V2("yt-remote-session-name",p.name)):(g.IZ("yt-remote-session-app"),g.IZ("yt-remote-session-name")),g.eo("yt.mdx.remote.channelParams_",p),l.start(),i2()||Adb())}},ewc=function(p,a){if(p.Ly!=null)throw Error("WatchDog timer not null"); p.Ly=OE((0,g.Qo)(p.kM,p),a)},zw8=function(p,a,l){p.info(`onConnectedScreenData_: Received screenData: ${JSON.stringify(a)}`); const y=new PI(a);nH_(p,y,S=>{S?(wZ(p.j,y),er(p,y),uI(p,l)):(g.Wp(Error(`CastSession, RemoteScreen from screenData: ${JSON.stringify(a)} is not online.`)),p.xf())},5)},bPc=function(p){Qf.call(this); p.__headers__&&(this.headers=p.__headers__,this.statusCode=p.__status__,delete p.__headers__,delete p.__status__);const a=p.__sm__;a?this.data=(this.L=g.E9(a))?g.G0(a,this.L):a:this.data=p},Iza=function(p){this.L=p; this.S=new Lb},lza=function(p){iI(p); p.jl=g.jQ(()=>{vC(p,"getNowPlaying")},2E4)},CM=function(p){p.audioTrackId=null; p.trackData=null;p.playerState=-1;p.Bk=!1;p.Wo=!1;p.D=0;p.X=g.eB();p.S=0;p.G=0;p.U=0;p.K=0;p.L=NaN;p.j=!1},SXW=function(){le||(le=g.o1("yt.mdx.remote.debug.handlers_")||[],g.eo("yt.mdx.remote.debug.handlers_",le))},l2=function(p){z_("cloudview",p)},f__=function(p){p.length>5&&(p=p.slice(p.length-5)); const a=g.Nx(zxc(),function(y){return y.loungeToken}),l=g.Nx(p,function(y){return y.loungeToken}); g.K0(l,function(y){return!g.tU(a,y)})&&OOc(); g.V2("yt-remote-local-screens",p,31536E3)},Rw7=function(){},EHK=function(p){return p.S?!0:p.L?p.L.size>=p.j:!1},zZU=function(p,a,l){const y=a.params.videoId||a.params.video_id,S=parseInt(a.params.currentIndex,10); p.L.listId=a.params.listId||p.L.listId;vo(p.L,y,S);p.publish("remoteQueueChange",l)},Gn=function(p,a){p.D=a; p.X=g.eB()},B$=function(p,a){p.S&&(p.S.removeUpdateListener(p.N),p.S.removeMediaListener(p.C),p.D(null)); p.S=a;p.S&&(dS("Setting cast session: "+p.S.sessionId),p.S.addUpdateListener(p.N),p.S.addMediaListener(p.C),p.S.media.length&&p.D(p.S.media[0]))},JqM=function(p,a){const l=new KM; if(g.mm.Image){const y=new Image;y.onload=g.i_(Sr,l,"TestLoadImage: loaded",!0,a,y);y.onerror=g.i_(Sr,l,"TestLoadImage: error",!1,a,y);y.onabort=g.i_(Sr,l,"TestLoadImage: abort",!1,a,y);y.ontimeout=g.i_(Sr,l,"TestLoadImage: timeout",!1,a,y);g.mm.setTimeout(function(){if(y.ontimeout)y.ontimeout()},1E4); y.src=p}else a(!1)},Pnl=function(p,a){p.X=a.params.autoplayMode; p.publish("autoplayModeChange",p.X);p.X=="DISABLED"&&p.publish("autoplayDismissed")},vDl=function(p,a,l,y){p.info("requestLoungeToken_ for "+a); const S={postParams:{screen_ids:a},method:"POST",context:p,onSuccess:function(n,V){n=V&&V.screens||[];n[0]&&n[0].screenId==a?l(n[0].loungeToken):y(Error("Missing lounge token in token response"))}, onError:function(){y(Error("Request screen lounge token failed"))}}; g.$Y(Wo(p.j,"/pairing/get_lounge_token_batch"),S)},ug8=function(p){return p.j?p.G+y4(p):p.G},cd_=function(p,a){const l=a.params.muted=="true"; p.L.volume=parseInt(a.params.volume,10);p.L.muted=l;p.publish("remotePlayerChange")},saB=function(p){p.player.getPlayerStateObject().isPlaying()?p.player.pauseVideo():(p.CP=a=>{!p.F9&&a.j5(8)&&(p.player.pauseVideo(),gZ(p))},p.player.addEventListener("presentingplayerstatechange",p.CP)); p.WC&&p.WC.zR();rS()||(SW=!0)},OP1=function(p,a,l,y,S){nb(p); if(p.L){const n=g.R("ID_TOKEN"),V=p.L.oQ||{};n?V["x-youtube-identity-token"]=n:delete V["x-youtube-identity-token"];p.L.oQ=V}fb(p);y?(y.getState()!=3&&pZW(y)==0||y.getState(),p.L.connect(a,l,p.UO,y.j,y.j3)):S?p.L.connect(a,l,p.UO,S.sessionId,S.arrayId):p.L.connect(a,l,p.UO)},oHM=function(p,a,l){var y=g.A6(l); y.L!=""?(a&&g.Ud(y,a+"."+y.L),g.Qa(y,y.U)):(y=g.mm.location,y=FLb(y.protocol,a?a+"."+y.hostname:y.hostname,+y.port,l));a=p.w7;l=p.tP;a&&l&&g.tN(y,a,l);g.tN(y,"VER",p.MQ);Ro(p,y);return y},BMM=function(){BrK(); return Zg?!!Zg.get("yt-remote-use-staging-server"):!1},lI=function(p){p.Al||p.FJ||(p.FJ=OE((0,g.Qo)(p.xG,p),0),p.US=0)},rdG=function(p,a){const l=a.params.videoId; delete a.params.videoId;l==p.L.videoId&&(g.P6(a.params)?p.L.trackData=null:p.L.trackData=a.params,p.publish("remotePlayerChange"))},c$=function(p){return p.K||!!p.U.length||!!p.L},FLb=function(p,a,l,y){const S=new g.pr(null); p&&g.ID(S,p);a&&g.Ud(S,a);l&&g.Qa(S,l);y&&(S.S=y);return S},yf=function(p){z_("conn",p)},ROl=function(p){p=g.B4(p.U,a=>a.idType!="shortLived"); g.V2("yt-remote-automatic-screen-cache",g.Nx(p,cIU))},kBK=function(p,a){return p===a},rI=function(p){z_("OnlineScreenService",p)},X5=function(p){p.S2=Date.now()+p.S; ewc(p,p.S)},MBW=function(p,a){const l=p.screens.length; p.screens=g.B4(p.screens,function(y){return!(y||a?!y!=!a?0:y.id==a.id:1)}); return p.screens.length=0&&(p=p.match(/MSIE ([\d.]+)/)[1],g.iF(p,"10.0")<0&&(this.S=!1))},tBG=function(p){g.Fc.call(this,"serverreachability",p)},$4=function(p,a){a:if(o3(a)!=o3(p.L))var l=!1; else{l=g.WA(a);var y=l.length;for(let S=0;S=0; return g.TF||p},X7=function(p,a,l){return(0,g.Qo)(function(y){this.Wi("Failed to "+a+" with cast v2 channel. Error code: "+y.code); y.code!=chrome.cast.ErrorCode.TIMEOUT&&(this.Wi("Retrying "+a+" using MDx browser channel."),LK(this,a,l))},p)},sel=function(p){p.jj||p.Ri||(p.G=1,p.Ri=OE((0,g.Qo)(p.ze,p),0),p.S3=0)},O7l=function(p){return g.L9(p.QY().then(a=>{Dh_(p,a)}).Lo(()=>{}),()=>{p.jl=null})},U8M=function(p,a){if(p.L==1){if(!a){p.l2=Math.floor(Math.random()*1E5); a=p.l2++;const l=new t4(p,"",a);l.fH=p.oQ;const y=MI(p),S=p.oe.clone();g.tN(S,"RID",a);g.tN(S,"CVER","1");mk(p,S);QhW(l,S,y);p.Al=l;p.L=2}}else p.L==3&&(a?hOc(p,a):p.S.length==0||p.Al||hOc(p))},$l=function(){const p=i2(); if(!p)return null;const a=T_().EM();return kf(a,p)},wS=function(p){g.eo("yt.mdx.remote.connectData_",p)},nS=function(p){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 Io;this.model=this.brand="";this.year=0;this.chipset=this.osVersion=this.os="";this.mdxDialServerType="MDX_DIAL_SERVER_TYPE_UNKNOWN";p&&(this.id=p.id||p.name,this.name=p.name,this.clientName=p.clientName?p.clientName.toUpperCase():"UNKNOWN_INTERFACE", this.app=p.app,this.type=p.type||"REMOTE_CONTROL",this.username=p.user||"",this.avatar=p.userAvatarUri||"",this.obfuscatedGaiaId=p.obfuscatedGaiaId||"",this.ownerObfuscatedGaiaId=p.ownerObfuscatedGaiaId||"",this.theme=p.theme||"u",Cn7(this,p.capabilities||""),NA1(this,p.compatibleSenderThemes||""),Vvc(this,p.experiments||""),this.brand=p.brand||"",this.model=p.model||"",this.year=p.year||0,this.os=p.os||"",this.osVersion=p.osVersion||"",this.chipset=p.chipset||"",this.mdxDialServerType=p.mdxDialServerType|| "MDX_DIAL_SERVER_TYPE_UNKNOWN",p=p.deviceInfo)&&(p=JSON.parse(p),this.brand=p.brand||"",this.model=p.model||"",this.year=p.year||0,this.os=p.os||"",this.osVersion=p.osVersion||"",this.chipset=p.chipset||"",this.clientName=p.clientName?p.clientName.toUpperCase():"UNKNOWN_INTERFACE",this.mdxDialServerType=p.mdxDialServerType||"MDX_DIAL_SERVER_TYPE_UNKNOWN")},so=function(p){p.UO!=null&&(g.mm.clearTimeout(p.UO),p.UO=null)},Jda=function(p){if(p.length==0)return[]; const a=p[0].indexOf("#"),l=a==-1?p[0]:p[0].substring(0,a);return g.Nx(p,function(y,S){return S==0?y:y.substring(l.length)})},Qe7=function(p){g.tO(p.C); p.C=0;g.tO(p.G);p.G=0;g.tO(p.UO);p.UO=0;g.tO(p.X);p.X=0;g.tO(p.K);p.K=0},cf2=function(p,a){ao().init(p,a)},UhU=function(p,a){p.S&&p.S==a?p.S=null:p.L&&p.L.has(a)&&p.L.delete(a)},OE=function(p,a){if(typeof p!=="function")throw Error("Fn must not be null and must be a function"); return g.mm.setTimeout(function(){p()},a)},nZK=function(){var p=le; if(rc[0]){var a=wc?co:-1;do{a=(a+1)%50;const l=rc[a];g.Ir(p,function(y){y(l)})}while(a!=co); rc=Array(50);co=-1;wc=!1}},hwW=function(p,a){if(a){const l=p.B.getOption("captions","tracklist",{OH:1}); l&&l.length?(p.B.setOption("captions","track",a),p.D=!1):(p.B.loadModule("captions"),p.D=!0)}else p.B.setOption("captions","track",{})},WnW=function(p){p.X=p.j.NQ(p.Sl,p.S.label,p.S.friendlyName,zC(p),(a,l)=>{p.X=()=>{}; er(p,a);a.idType=="shortLived"&&l>0&&dZ(p,l)},a=>{p.X=()=>{}; p.xf(a)})},kWl=function(p,a){if(p.UO!=null)throw Error("WatchDog timer not null"); p.UO=F5((0,g.Qo)(p.s$,p),a)},LK=function(p,a,l){p.j.sendMessage(a,l)},mk=function(p,a){p.N3&&(p=p.N3.hU())&&g.yo(p,function(l,y){g.tN(a,y,l)})},dGc=function(p,a){a.params=a.params||{}; zZU(p,a,"NOW_PLAYING_MAY_CHANGE");GE1(p,a);p.publish("autoplayDismissed")},Knc=function(p,a){let l=p.PZ+Math.floor(Math.random()*p.tN); p.isActive()||(l*=2);return l*a},FnM=function(p,a,l){const y=new Image; y.onload=function(){try{TC(y),l(!0)}catch(S){}}; y.onerror=function(){try{TC(y),l(!1)}catch(S){}}; y.onabort=function(){try{TC(y),l(!1)}catch(S){}}; y.ontimeout=function(){try{TC(y),l(!1)}catch(S){}}; g.mm.setTimeout(function(){if(y.ontimeout)y.ontimeout()},a); y.src=p},HI=function(p){g.js.call(this); this.D=p;this.screens=[]},x4=function(p,a,l){g.js.call(this); this.w7=l;this.j=p;this.S=a;this.L=null},Wfc=function(){ou(); let p=Lf_();p.push(...HhW.map(D4B));p.push("//www.gstatic.com/eureka/clank/cast_sender.js");DZ(p)},Mvc=function(p,a){let l=!1; ao()||(p=new F7(p,a),p.subscribe("yt-remote-cast2-availability-change",function(y){g.V2("yt-remote-cast-available",y);PC("yt-remote-cast2-availability-change",y)}),p.subscribe("yt-remote-cast2-receiver-selected",function(y){Ho("onReceiverSelected: "+y.friendlyName); g.V2("yt-remote-cast-receiver",y);PC("yt-remote-cast2-receiver-selected",y)}),p.subscribe("yt-remote-cast2-receiver-resumed",function(y){Ho("onReceiverResumed: "+y.friendlyName); g.V2("yt-remote-cast-receiver",y);PC("yt-remote-cast2-receiver-resumed",y)}),p.subscribe("yt-remote-cast2-session-change",function(y){Ho("onSessionChange: "+j7(y)); y||g.IZ("yt-remote-cast-receiver");PC("yt-remote-cast2-session-change",y)}),g.eo("yt.mdx.remote.cloudview.instance_",p),l=!0); Ho("cloudview.createSingleton_: "+l);return l},Eu=function(p){return p.getState()==1},vC=function(p,a,l){l?yf("Sending: action="+a+", params="+g.Ad(l)):yf("Sending: action="+a); p.S.sendMessage(a,l)},Afc=function(){},t4=function(p,a,l,y){this.L=p; this.j=a;this.G=l;this.D=y||1;this.S=45E3;this.U=new g.hL(this);this.X=new g.Oy;this.X.setInterval(250)},RZK=function(p){if(p.tP){if(p.tP.locationOverrideToken)return{locationOverrideToken:p.tP.locationOverrideToken}; if(p.tP.latitudeE7!=null&&p.tP.longitudeE7!=null)return{latitudeE7:p.tP.latitudeE7,longitudeE7:p.tP.longitudeE7}}return null},rZ=function(p){p.L&&(Uo(p),p.L.cancel(),p.L=null)},dI=function(p,a){pM()?ao().setConnectedScreenStatus(p,a):l2("setConnectedScreenStatus called before ready.")},qnB=function(){this.L=new Lb},gHc=function(p,a,l,y){g.Fc.call(this,"timingevent",p); this.size=a;this.rtt=l;this.retries=y},uI=function(p,a){g.tO(p.K); p.K=0;a==0?wZ2(p):p.K=g.jQ(()=>{wZ2(p)},a)},Mq=function(){const p=g.X_(); if(!p)return null;var a=T_();if(!a)return null;a=a.EM();return kf(a,p)}; g.q0.prototype.wD=g.p3(49,function(){this.app.h3().wD()}); g.RI.prototype.wD=g.p3(48,function(){this.EU=null}); g.q0.prototype.Tu=g.p3(47,function(p){this.app.h3().Tu(p)}); g.RI.prototype.Tu=g.p3(46,function(p){this.EU=p}); var WQl=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/channel/opened",g.PN("channel_type"))}L(p){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/channel/opened",p)}},HOG=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/channel/closed",g.PN("channel_type"))}L(p){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/channel/closed",p)}},iOl=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/channel/message_received", g.PN("channel_type"))}L(p){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/channel/message_received",p)}},DGc=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/channel/success")}L(){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/channel/success")}},T8K=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/channel/error",g.PN("channel_type"),g.PN("error_type"))}L(p,a){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/channel/error", p,a)}},N8M=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}L(){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/browser_channel/pending_maps")}},sgW=class{constructor(){var p=Vs();this.S=p;g.lC(p,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}L(){g.tz(this.S,"/client_streamz/youtube/living_room/mdx/browser_channel/undelivered_maps")}};g.C=Io.prototype; g.C.Yc=function(){qm(this);const p=[];for(let a=0;a2*this.size&&qm(this),!0):!1}; g.C.get=function(p,a){return Yl(this.S,p)?this.S[p]:a}; g.C.set=function(p,a){Yl(this.S,p)||(this.size+=1,this.L.push(p),this.Vn++);this.S[p]=a}; g.C.forEach=function(p,a){const l=this.Ep();for(let y=0;y=y.L.length)return g.kM;const n=y.L[a++];return g.J0(p?n:y.S[n])}; return S}; var EZU={dS:"atp",qv:"ska",yK:"que",Fn:"mus",Z4:"sus",WE:"dsp",kI:"seq",iE:"mic",DB:"dpa",VJ:"mlm",BM:"dsdtr",Uf:"ntb",Mlu:"vsp",Ib:"scn",eH:"rpe",El:"dcn",wv:"dcp",sf:"pas",bD:"drq",Ef:"opf",pk:"els",Tk:"isg",nV:"svq",CR:"mvp",ek:"ads",mj:"stcp",r_:"sads",WM:"dloc",HM:"dcw",wk:"asw",Ez:"apw",dk:"wrc",IV:"pcw",yJ:"ipv",fA:"ndt",PF:"ctops"},TAl={nvv:"u",Ta:"cl",Wu:"k",KB:"i",Lk:"cr",hC:"m",FS:"g",dO:"up"},D81={Kf:"adPlaying",YM:"onAdStateChange"},iPc={X2:"nowPlaying",dV:"onStateChange",Kf:"adPlaying", YM:"onAdStateChange",C7:"nowPlayingShorts",LL:"onShortsStateChange"},TM2={C7:"nowPlayingShorts",LL:"onShortsStateChange"};nS.prototype.equals=function(p){return p?this.id==p.id:!1}; var NI="",Zg=null,nJB=class extends g.sIM{constructor(){super()}},nM,rf_=xGU("loadCastFramework")||xGU("loadCastApplicationFramework"),HhW=["pkedcjkdefgpdelpbcmbmeomcjbeemfm","enhhojjnijigcajfphajepfemndkmdlo"];g.yi(Vf,g.YB);g.C=Vf.prototype;g.C.Qd=function(p){this.j=arguments;this.L=!1;this.xE?this.U=g.eB()+this.mD:this.xE=g.Wu(this.X,this.mD)}; g.C.stop=function(){this.xE&&(g.mm.clearTimeout(this.xE),this.xE=null);this.U=null;this.L=!1;this.j=[]}; g.C.pause=function(){++this.S}; g.C.resume=function(){this.S&&(--this.S,!this.S&&this.L&&(this.L=!1,this.D.apply(null,this.j)))}; g.C.fz=function(){this.stop();Vf.SD.fz.call(this)}; g.C.Di=function(){this.xE&&(g.mm.clearTimeout(this.xE),this.xE=null);this.U?(this.xE=g.Wu(this.X,this.U-g.eB()),this.U=null):this.S?this.L=!0:(this.L=!1,this.D.apply(null,this.j))};var Lb=class{stringify(p){return g.mm.JSON.stringify(p,void 0)}parse(p){return g.mm.JSON.parse(p,void 0)}};g.yi(Qf,g.Fc);g.yi(XQ,g.Fc);var ZPU=null;g.yi(Scc,g.Fc);g.yi(l11,g.Fc);g.yi(Qa_,g.Fc);KM.prototype.debug=function(){}; KM.prototype.info=function(){}; KM.prototype.warning=function(){};var vZ8={},ZZ={};g.C=Bo.prototype;g.C.setTimeout=function(p){this.Tm=p}; g.C.Ab=function(p){p=p.target;const a=this.Rc;a&&g.aU(p)==3?a.j():this.Ge(p)}; g.C.Ge=function(p){try{if(p==this.L)a:{const S=g.aU(this.L),n=this.L.S,V=this.L.getStatus();if(!(S<3)&&(S!=3||this.L&&(this.S.U||g.me(this.L)||g.gR(this.L)))){this.Ws||S!=4||n==7||(n==8||V<=0?SL(3):SL(2));fS(this);var a=this.L.getStatus();this.VY=a;var l=a1b(this);if(this.D=a==200){if(this.NO&&!this.Hs){b:{if(this.L){const Z=g.Ez(this.L,"X-HTTP-Initial-Response");if(Z&&!g.o4(Z)){var y=Z;break b}}y=null}if(p=y)this.Hs=!0,QN(this,p);else{this.D=!1;this.X=3;Yf(12);hi(this);Ai(this);break a}}if(this.w7){p= !0;let Z;for(;!this.Ws&&this.G0&&!this.Fu&&(this.Fu=!0,this.U.O7(this)):(hi(this),Ai(this))}else QN(this,l);S==4&&hi(this);this.D&&!this.Ws&&(S==4?Aql(this.U,this):(this.D=!1,Mm(this)))}else g.q_h(this.L),a==400&&l.indexOf("Unknown SID")> 0?(this.X=3,Yf(12)):(this.X=0,Yf(13)),hi(this),Ai(this)}}}catch(S){}finally{}}; g.C.cancel=function(){this.Ws=!0;hi(this)}; g.C.s$=function(){this.UO=null;const p=Date.now();p-this.iT>=0?(this.Bs!=2&&(SL(3),Yf(17)),hi(this),this.X=2,Ai(this)):kWl(this,this.iT-p)}; g.C.getLastError=function(){return this.X}; g.C.BP=function(){return this.L};var Y9c=class{constructor(p,a){this.L=p;this.map=a;this.context=null}};Yn8.prototype.cancel=function(){this.U=UE(this);if(this.S)this.S.cancel(),this.S=null;else if(this.L&&this.L.size!==0){for(const p of this.L.values())p.cancel();this.L.clear()}};g.C=yql.prototype;g.C.MQ=8;g.C.mN=1;g.C.connect=function(p,a,l,y){Yf(0);this.Ha=p;this.Ws=a||{};l&&y!==void 0&&(this.Ws.OSID=l,this.Ws.OAID=y);this.Rc=this.dG;this.QY=oHM(this,null,this.Ha);hH(this)}; g.C.disconnect=function(){p4B(this);if(this.mN==3){var p=this.ac++,a=this.QY.clone();g.tN(a,"SID",this.j);g.tN(a,"RID",p);g.tN(a,"TYPE","terminate");Ro(this,a);p=new Bo(this,this.j,p);p.Bs=2;p.K=KS(a.clone());a=!1;if(g.mm.navigator&&g.mm.navigator.sendBeacon)try{a=g.mm.navigator.sendBeacon(p.K.toString(),"")}catch{}!a&&g.mm.Image&&((new Image).src=p.K,a=!0);a||(p.L=G1c(p.U,null),p.L.send(p.K));p.Sl=Date.now();Mm(p)}f1c(this)}; g.C.Cv=function(){return this.mN==0}; g.C.getState=function(){return this.mN}; g.C.pn=function(p){if(this.D)if(this.D=null,this.mN==1){if(!p){this.ac=Math.floor(Math.random()*1E5);p=this.ac++;const S=new Bo(this,"",p);let n=this.C;this.NO&&(n?(n=g.O1(n),g.C0(n,this.NO)):n=this.NO);this.G!==null||this.iT||(S.QY=n,n=null);if(this.Ps)a:{var a=0;for(var l=0;l4096){a=l;break a}if(a===4096||l===this.U.length-1){a=l+1;break a}}a= 1E3}else a=1E3;a=b77(this,S,a);l=this.QY.clone();g.tN(l,"RID",p);g.tN(l,"CVER",22);this.w7&&g.tN(l,"X-HTTP-Session-Id",this.w7);Ro(this,l);n&&(this.iT?a="headers="+g.qj(g.eqe(n))+"&"+a:this.G&&g.KV(l,this.G,n));u2(this.S,S);this.Me&&g.tN(l,"TYPE","init");this.Ps?(g.tN(l,"$req",a),g.tN(l,"SID","null"),S.NO=!0,e7(S,l,null)):e7(S,l,a);this.mN=2}}else this.mN==3&&(p?I1B(this,p):this.U.length==0||EHK(this.S)||I1B(this))}; g.C.Te=function(){this.K=null;EDU(this);if(this.Ba&&!(this.Tm||this.L==null||this.Ro<=0)){var p=4*this.Ro;this.jl=F5((0,g.Qo)(this.pK,this),p)}}; g.C.pK=function(){this.jl&&(this.jl=null,this.Rc=!1,this.Tm=!0,Yf(10),rZ(this),EDU(this))}; g.C.O7=function(p){this.L==p&&this.Ba&&!this.Tm&&(Uo(this),this.Tm=!0,Yf(11))}; g.C.HU=function(){this.UO!=null&&(this.UO=null,rZ(this),Eo(this),Yf(19))}; g.C.v5=function(p){p?Yf(2):Yf(1)}; g.C.isActive=function(){return!!this.X&&this.X.isActive(this)}; g.C=JIa.prototype;g.C.i6=function(){}; g.C.JU=function(){}; g.C.Kn=function(){}; g.C.Ix=function(){}; g.C.isActive=function(){return!0}; g.C.Rm=function(){};g.yi(Ji,g.lH);Ji.prototype.open=function(){this.L.X=this.U;this.G&&(this.L.Hs=!0);this.L.connect(this.D,this.S||void 0)}; Ji.prototype.close=function(){this.L.disconnect()}; Ji.prototype.send=function(p){var a=this.L;if(typeof p==="string"){var l={};l.__data__=p;p=l}else this.X&&(l={},l.__data__=g.Ad(p),p=l);a.U.push(new Y9c(a.bf++,p));a.mN==3&&hH(a)}; Ji.prototype.fz=function(){this.L.X=null;delete this.U;this.L.disconnect();delete this.L;Ji.SD.fz.call(this)}; g.yi(bPc,Qf);g.yi(LL1,XQ);g.yi(qq,JIa);qq.prototype.i6=function(){this.L.dispatchEvent("m")}; qq.prototype.JU=function(p){this.L.dispatchEvent(new bPc(p))}; qq.prototype.Kn=function(p){this.L.dispatchEvent(new LL1(p))}; qq.prototype.Ix=function(){this.L.dispatchEvent("n")}; Ji.prototype.j=function(){return new P$(this,this.L)}; P$.prototype.S=function(){return Iu(this.L.S)}; P$.prototype.U=function(){return Pg_(this.L).map(p=>{var a=this.j;p=p.map;"__data__"in p?(p=p.__data__,a=a.X?Vcl(p):p):a=p;return a})}; P$.prototype.commit=function(p){this.L.VY=p};var wI=new g.lH,m8c=class extends g.Fc{constructor(){super("statevent",wI)}};g.C=t4.prototype;g.C.fH=null;g.C.Cg=!1;g.C.Ly=null;g.C.S2=null;g.C.BN=null;g.C.Kp=null;g.C.WN=null;g.C.Ie=null;g.C.E1=null;g.C.uX=null;g.C.JB=0;g.C.YP=null;g.C.cT=null;g.C.Yk=null;g.C.b2=-1;g.C.j6=!0;g.C.gx=!1;g.C.LF=0;g.C.TT=null;var mhW={},tH={};g.C=t4.prototype;g.C.setTimeout=function(p){this.S=p}; g.C.vU=function(p){p=p.target;const a=this.TT;a&&g.aU(p)==3?a.j():this.Zt(p)}; g.C.Zt=function(p){try{if(p==this.uX)a:{const a=g.aU(this.uX),l=this.uX.S,y=this.uX.getStatus();if(g.H5&&!g.Nf("420+")){if(a<4)break a}else if(a<3||a==3&&!g.me(this.uX))break a;this.gx||a!=4||l==7||(l==8||y<=0?this.L.dN(3):this.L.dN(2));eOG(this);const S=this.uX.getStatus();this.b2=S;const n=g.me(this.uX);if(this.Cg=S==200){a==4&&J4(this);if(this.w7){for(p=!0;!this.gx&&this.JB0?3:0,pK(),J4(this),VN(this)}}catch(a){}finally{}}; g.C.cancel=function(){this.gx=!0;J4(this)}; g.C.kM=function(){this.Ly=null;const p=Date.now();p-this.S2>=0?(this.Kp!=2&&this.L.dN(3),J4(this),this.Yk=2,pK(),VN(this)):ewc(this,this.S2-p)}; g.C.getLastError=function(){return this.Yk};g.C=Iza.prototype;g.C.j2=null;g.C.Fv=null;g.C.JE=!1;g.C.y_=null;g.C.Zz=null;g.C.H8=-1;g.C.Zh=null;g.C.Bw=null;g.C.connect=function(p){this.y_=p;p=au(this.L,null,this.y_);pK();Date.now();const a=this.L.C;a!=null?(this.Zh=a[0],(this.Bw=a[1])?(this.Zz=1,WLG(this)):(this.Zz=2,Zr(this))):(xl(p,"MODE","init"),this.Fv=new t4(this),this.Fv.fH=this.j2,vI(this.Fv,p,!1,null,!0),this.Zz=0)}; g.C.oT=function(p){if(p)this.Zz=2,Zr(this);else{pK();var a=this.L;a.Ir=a.fN.H8;am(a,9)}p&&this.dN(2)}; g.C.UP=function(p){return this.L.UP(p)}; g.C.abort=function(){this.Fv&&(this.Fv.cancel(),this.Fv=null);this.H8=-1}; g.C.Cv=function(){return!1}; g.C.ox=function(p,a){this.H8=p.b2;if(this.Zz==0)if(a){try{var l=this.S.parse(a)}catch(y){p=this.L;p.Ir=this.H8;am(p,2);return}this.Zh=l[0];this.Bw=l[1]}else p=this.L,p.Ir=this.H8,am(p,2);else this.Zz==2&&(this.JE?(pK(),Date.now()):a=="11111"?(pK(),this.JE=!0,Date.now(),this.H8=200,this.Fv.cancel(),pK(),Yy(this.L,this,!0)):(pK(),Date.now(),this.JE=!1))}; g.C.XO=function(){this.H8=this.Fv.b2;if(this.Fv.Cg)this.Zz==0?this.Bw?(this.Zz=1,WLG(this)):(this.Zz=2,Zr(this)):this.Zz==2&&(this.JE?(pK(),Yy(this.L,this,!0)):(pK(),Yy(this.L,this,!1)));else{this.Zz==0?pK():this.Zz==2&&pK();var p=this.L;this.Fv.getLastError();p.Ir=this.H8;am(p,2)}}; g.C.Qc=function(){return this.L.Qc()}; g.C.isActive=function(){return this.L.isActive()}; g.C.dN=function(p){this.L.dN(p)};g.C=Xy.prototype;g.C.oQ=null;g.C.DT=null;g.C.Al=null;g.C.jj=null;g.C.e2=null;g.C.oe=null;g.C.qQ=null;g.C.fF=null;g.C.l2=0;g.C.G7=0;g.C.N3=null;g.C.FJ=null;g.C.Ri=null;g.C.d1=null;g.C.fN=null;g.C.oy=null;g.C.j3=-1;g.C.Or=-1;g.C.Ir=-1;g.C.US=0;g.C.S3=0;g.C.w1=8;var q9l={OK:0,g_:2,aH:4,yj:5,GmY:6,STOP:7,Vd:8,BF:9,WF:10,b3:11,Wh:12};g.yi(gHc,g.Fc);g.yi(tBG,g.Fc);g.C=Xy.prototype; g.C.connect=function(p,a,l,y,S){pK();this.e2=a;this.DT=l||{};y&&S!==void 0&&(this.DT.OSID=y,this.DT.OAID=S);this.K?(OE((0,g.Qo)(this.B7,this,p),100),l_M(this)):this.B7(p)}; g.C.disconnect=function(){zOW(this);if(this.L==3){var p=this.l2++;const a=this.oe.clone();g.tN(a,"SID",this.j);g.tN(a,"RID",p);g.tN(a,"TYPE","terminate");mk(this,a);p=new t4(this,this.j,p);p.Kp=2;p.WN=KS(a.clone());(new Image).src=p.WN.toString();p.BN=Date.now();X5(p)}oDa(this)}; g.C.B7=function(p){this.fN=new Iza(this);this.fN.j2=this.oQ;this.fN.S=this.X;this.fN.connect(p)}; g.C.Cv=function(){return this.L==0}; g.C.getState=function(){return this.L}; g.C.xG=function(p){this.FJ=null;U8M(this,p)}; g.C.ze=function(){this.Ri=null;this.jj=new t4(this,this.j,"rpc",this.G);this.jj.fH=this.oQ;this.jj.LF=0;var p=this.qQ.clone();g.tN(p,"RID","rpc");g.tN(p,"SID",this.j);g.tN(p,"CI",this.oy?"0":"1");g.tN(p,"AID",this.j3);mk(this,p);g.tN(p,"TYPE","xmlhttp");vI(this.jj,p,!0,this.fF,!1)}; g.C.ox=function(p,a){if(this.L!=0&&(this.jj==p||this.Al==p))if(this.Ir=p.b2,this.Al==p&&this.L==3)if(this.w1>7){try{var l=this.X.parse(a)}catch(y){l=null}if(Array.isArray(l)&&l.length==3)if(p=l,p[0]==0)a:{if(!this.Ri){if(this.jj)if(this.jj.BN+3E30)){if(y=a==1)this.Al||this.FJ||this.L==1||this.US>=2?y=!1:(this.FJ=OE((0,g.Qo)(this.xG,this,p),uMM(this,this.US)),this.US++, y=!0);y=!(y||a==2&&ky(this))}if(y)switch(l){case 1:am(this,5);break;case 4:am(this,10);break;case 3:am(this,6);break;case 7:am(this,12);break;default:am(this,2)}}}; g.C.tb=function(p){if(!g.tU(arguments,this.L))throw Error("Unexpected channel state: "+this.L);}; g.C.R3=function(p){p?pK():(pK(),d4K(this,8))}; g.C.UP=function(p){if(p)throw Error("Can't create secondary domain capable XhrIo object.");p=new g.Bj;p.G=!1;return p}; g.C.isActive=function(){return!!this.N3&&this.N3.isActive(this)}; g.C.dN=function(p){const a=wI;a.dispatchEvent(new tBG(a,p))}; g.C.Qc=function(){return!1}; g.C=Afc.prototype;g.C.Cn=function(){}; g.C.VW=function(){}; g.C.Fs=function(){}; g.C.P0=function(){}; g.C.EP=function(){}; g.C.hU=function(){return{}}; g.C.isActive=function(){return!0};g.C=az2.prototype;g.C.enqueue=function(p){this.S.push(p)}; g.C.isEmpty=function(){return this.L.length===0&&this.S.length===0}; g.C.clear=function(){this.L=[];this.S=[]}; g.C.contains=function(p){return g.tU(this.L,p)||g.tU(this.S,p)}; g.C.remove=function(p){{var a=this.L;const l=Array.prototype.lastIndexOf.call(a,p,a.length-1);l>=0?(g.s6(a,l),a=!0):a=!1}return a||g.yA(this.S,p)}; g.C.Yc=function(){const p=[];for(var a=this.L.length-1;a>=0;--a)p.push(this.L[a]);a=this.S.length;for(let l=0;l"",this.QY=()=>g.R2({}))}; g.C.nz=function(){return this.G}; g.C.connect=async function(p,a,l){try{this.X&&await this.j}finally{if(this.G||this.L&&this.L.getState()==2)return;this.Sl="";this.S.stop();this.C=p||null;this.K=a||0;const y=this.Bs+"/test",S=this.Bs+"/bind";p=new Xy(l?l.firstTestResults:null,l?l.secondTestResults:null,this.Fu);const n=this.L;n&&(n.N3=null);p.N3=this;this.L=p;if(this.X)return this.j=kl(this).then(()=>OP1(this,y,S,n,l)),this.j.then(()=>{this.j=g.R2()}); OP1(this,y,S,n,l)}}; g.C.disconnect=function(p){try{this.X&&(this.j.cancel(),this.j=g.R2())}finally{this.N=p||0,this.S&&this.S.stop(),nb(this),this.L&&(this.L.getState()==3&&U8M(this.L),this.L.disconnect()),this.N=0}}; g.C.sendMessage=async function(p,a){try{this.X&&await this.j}finally{if(this.G)return;const l={_sc:p};a&&g.C0(l,a);if(this.S.isActive()||(this.L?this.L.getState():0)==2)this.U.push(l);else if(this.HH())try{this.X&&!NMb(this,p)&&await kl(this)}finally{this.HH()&&(NMb(this,p)||fb(this),nb(this),GC(this.L,l))}}}; g.C.Cn=function(){this.S.reset();this.C=null;this.K=0;if(this.U.length)if(this.X)X2G(this);else{var p=this.U;this.U=[];var a=p.length;fb(this);for(let l=0;lq9l[l]===p); this.Rc.L("BROWSER_CHANNEL",a??"UNKNOWN")}; g.C.EP=function(p,a){if(!this.S.isActive())this.publish("handlerClosed");else if(a){const l=a.length;for(let y=0;y{this.onError(y)}); this.handler.subscribe("handlerMessage",this.onMessage,this);this.S=a}connect(p,a,l){this.handler.connect(p,a,l)}disconnect(p){this.handler.disconnect(p)}HA(){this.handler.HA()}getDeviceId(){return this.handler.getDeviceId()}uA(){return this.handler.uA()}HH(){return this.handler.HH()}L(){this.dispatchEvent("channelOpened");var p=this.handler,a=this.S;g.V2("yt-remote-session-browser-channel",{firstTestResults:[""],secondTestResults:!p.L.oy,sessionId:p.L.j,arrayId:p.L.j3});g.V2("yt-remote-session-screen-id", a);p=Nq();a=sN();g.tU(p,a)||p.push(a);Ln7(p);UN()}onClosed(){this.dispatchEvent("channelClosed")}onMessage(p){this.dispatchEvent(new Jfa(p))}onError(p){this.dispatchEvent(new fz2(p?1:0))}sendMessage(p,a){this.handler.sendMessage(p,a)}I6(p){this.handler.I6(p)}dispose(){this.handler.dispose()}};var w4G=class{constructor(p,a,l=()=>""){new Rw7; var y=new g.tj;this.pathPrefix=p;this.L=a;this.Sl=l;this.X=y;this.K=null;this.C=this.G=0;this.channel=null;this.D=0;this.U=new be(()=>{this.U.isActive();this.channel?.j().S()===0&&this.connect(this.K,this.G)}); this.j={};this.S={};this.UO=!1;this.logger=null;this.N=[];this.a9=void 0;this.QY=new WQl;this.jl=new HOG;this.Ws=new iOl;this.w7=new T8K}connect(p={},a=0){this.D!==2&&(this.U.stop(),this.K=p,this.G=a,ls(this),(p=g.R("ID_TOKEN"))?this.j["x-youtube-identity-token"]=p:delete this.j["x-youtube-identity-token"],this.L&&(this.S.device=this.L.device,this.S.name=this.L.name,this.S.app=this.L.app,this.S.id=this.L.id,this.L.fK&&(this.S.mdxVersion=`${this.L.fK}`),this.L.theme&&(this.S.theme=this.L.theme),this.L.capabilities&& (this.S.capabilities=this.L.capabilities),this.L.L5&&(this.S.cst=this.L.L5),this.L.authuser&&(this.S.authuser=this.L.authuser),this.L.pageId&&(this.S.pageId=this.L.pageId)),this.G!==0?this.S.ui=`${this.G}`:delete this.S.ui,Object.assign(this.S,this.K),this.channel=new Ji(this.pathPrefix,{AZ:"gsessionid",ge:this.j,b7:this.S}),this.channel.open(),this.D=2,GBa(this))}disconnect(p=0){this.C=p;this.U.stop();ls(this);this.channel&&(this.C!==0?this.S.ui=`${this.C}`:delete this.S.ui,this.channel.close()); this.C=0}uA(){return this.U.isActive()?this.U.S-Date.now():NaN}HA(){var p=this.U;g.si(p.L);p.start()}sendMessage(p,a){this.channel&&(ls(this),this.channel.send({_sc:p,...a}))}I6(p){p||this.U.stop();p?this.j["X-YouTube-LoungeId-Token"]=p:delete this.j["X-YouTube-LoungeId-Token"]}getDeviceId(){return this.L?this.L.id:""}publish(p,...a){return this.X.publish(p,...a)}subscribe(p,a,l){return this.X.subscribe(p,a,l)}unsubscribe(p,a,l){return this.X.unsubscribe(p,a,l)}h5(p){return this.X.h5(p)}dispose(){this.UO|| (this.UO=!0,g.Er(this.X),this.disconnect(),g.Er(this.U),this.Sl=()=>"")}nz(){return this.UO}};var rIl=class extends g.lH{constructor(p){super();this.L=p();this.L.subscribe("webChannelOpened",this.S,this);this.L.subscribe("webChannelClosed",this.onClosed,this);this.L.subscribe("webChannelError",this.onError,this);this.L.subscribe("webChannelMessage",this.onMessage,this)}connect(p,a){this.L.connect(p,a)}disconnect(p){this.L.disconnect(p)}HA(){this.L.HA()}getDeviceId(){return this.L.getDeviceId()}uA(){return this.L.uA()}HH(){return this.L.D===3}S(){this.dispatchEvent("channelOpened")}onClosed(){this.dispatchEvent("channelClosed")}onMessage(p){this.dispatchEvent(new Jfa(p))}onError(){this.dispatchEvent(new fz2(this.L.a9=== 401?1:0))}sendMessage(p,a){this.L.sendMessage(p,a)}I6(p){this.L.I6(p)}dispose(){this.L.dispose()}};var yIG=Date.now(),le=null,rc=Array(50),co=-1,wc=!1;g.yi(HI,g.js);HI.prototype.EM=function(){return this.screens}; HI.prototype.contains=function(p){return!!pb(this.screens,p)}; HI.prototype.get=function(p){return p?kf(this.screens,p):null}; HI.prototype.info=function(p){z_(this.D,p)};var an7=class extends g.js{constructor(p,a,l,y,S){super();this.j=p;this.N=a;this.K=l;this.UO=y;this.C=S;this.S=0;this.L=null;this.xE=NaN}start(){!this.L&&isNaN(this.xE)&&this.U()}stop(){this.L&&(this.L.abort(),this.L=null);isNaN(this.xE)||(g.tO(this.xE),this.xE=NaN)}fz(){this.stop();super.fz()}U(){this.xE=NaN;this.L=g.$Y(Wo(this.j,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:this.N},timeout:5E3,onSuccess:(0,g.Qo)(this.D,this),onError:(0,g.Qo)(this.X,this),onTimeout:(0,g.Qo)(this.G, this)})}D(p,a){this.L=null;p=a.screen||{};p.dialId=this.K;p.name=this.UO;a=-1;this.C&&p.shortLivedLoungeToken&&p.shortLivedLoungeToken.value&&p.shortLivedLoungeToken.refreshIntervalMs&&(p.screenIdType="shortLived",p.loungeToken=p.shortLivedLoungeToken.value,a=p.shortLivedLoungeToken.refreshIntervalMs);this.publish("pairingComplete",new PI(p),a)}X(p){this.L=null;p.status&&p.status==404?this.S>=psG.length?this.publish("pairingFailed",Error("DIAL polling timed out")):(p=psG[this.S],this.xE=g.jQ((0,g.Qo)(this.U, this),p),this.S++):this.publish("pairingFailed",Error("Server error "+p.status))}G(){this.L=null;this.publish("pairingFailed",Error("Server not responding"))}},psG=[2E3,2E3,1E3,1E3,1E3,2E3,2E3,5E3,5E3,1E4];g.yi(Kb,HI);g.C=Kb.prototype;g.C.start=function(){G_(this)&&this.publish("screenChange");!g.Wk("yt-remote-lounge-token-expiration")&&H7U(this);g.tO(this.L);this.L=g.jQ((0,g.Qo)(this.start,this),1E4)}; g.C.add=function(p,a){G_(this);yfc(this,p);jL(this,!1);this.publish("screenChange");a(p);p.token||H7U(this)}; g.C.remove=function(p,a){let l=G_(this);MBW(this,p)&&(jL(this,!1),l=!0);a(p);l&&this.publish("screenChange")}; g.C.i5=function(p,a,l,y){let S=G_(this);const n=this.get(p.id);n?(n.name!=a&&(n.name=a,jL(this,!1),S=!0),l(p)):y(Error("no such local screen."));S&&this.publish("screenChange")}; g.C.fz=function(){g.tO(this.L);Kb.SD.fz.call(this)}; g.C.W$=function(p){G_(this);let a=this.screens.length;p=p&&p.screens||[];const l=p.length;for(let y=0;y{g.Er(V);S(wZ(this,Z),z)}); V.subscribe("pairingFailed",Z=>{g.Er(V);n(Z)}); V.start();return(0,g.Qo)(V.stop,V)}; g.C.M4=function(p,a,l,y){g.$Y(Wo(this.j,"/pairing/get_screen"),{method:"POST",postParams:{pairing_code:p},timeout:5E3,onSuccess:(0,g.Qo)(function(S,n){S=new PI(n.screen||{});if(!S.name||U4_(this,S.name)){a:{n=S.name;let V=2,Z=a(n,V);for(;U4_(this,Z);){V++;if(V>20)break a;Z=a(n,V)}n=Z}S.name=n}l(wZ(this,S))},this), onError:(0,g.Qo)(function(S){y(Error("pairing request failed: "+S.status))},this), onTimeout:(0,g.Qo)(function(){y(Error("pairing request timed out."))},this)})}; g.C.fz=function(){g.Er(this.S);g.Er(this.L);Dg.SD.fz.call(this)}; g.C.Qq=function(){bhl(this);this.publish("screenChange");this.L.update()}; Dg.prototype.dispose=Dg.prototype.dispose;g.yi(x4,g.js);g.C=x4.prototype;g.C.xf=function(p){this.nz()||(p&&(Fy(this,""+p),this.publish("sessionFailed")),this.L=null,this.publish("sessionScreen",null))}; g.C.info=function(p){z_(this.w7,p)}; g.C.YG=function(){return null}; g.C.eJ=function(p){const a=this.S;p?(a.displayStatus=new chrome.cast.ReceiverDisplayStatus(p,[]),a.displayStatus.showStop=!0):a.displayStatus=null;chrome.cast.setReceiverDisplayStatus(a,(0,g.Qo)(function(){this.info("Updated receiver status for "+a.friendlyName+": "+p)},this),(0,g.Qo)(function(){Fy(this,"Failed to update receiver status for: "+a.friendlyName)},this))}; g.C.fz=function(){this.eJ("");x4.SD.fz.call(this)};var CK=class extends x4{constructor(p,a,l){super(p,a,"CastSession");this.config_=l;this.U=null;this.N=(0,g.Qo)(this.QY,this);this.Sl=(0,g.Qo)(this.Bs,this);this.UO=g.jQ(()=>{d8B(this,null)},12E4); this.K=this.X=this.G=this.C=0}jl(p){if(this.U){if(this.U==p)return;Fy(this,"Overriding cast session with new session object");Qe7(this);this.U.removeUpdateListener(this.N);this.U.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.Sl)}this.U=p;this.U.addUpdateListener(this.N);this.U.addMessageListener("urn:x-cast:com.google.youtube.mdx",this.Sl);cq_(this,"getMdxSessionStatus")}D(p){this.info("launchWithParams no-op for Cast: "+g.Ad(p))}stop(){this.U?this.U.stop((0,g.Qo)(function(){this.xf()}, this),(0,g.Qo)(function(){this.xf(Error("Failed to stop receiver app."))},this)):this.xf(Error("Stopping cast device without session."))}eJ(){}fz(){this.info("disposeInternal"); Qe7(this);this.U&&(this.U.removeUpdateListener(this.N),this.U.removeMessageListener("urn:x-cast:com.google.youtube.mdx",this.Sl));this.U=null;super.fz()}Bs(p,a){if(!this.nz())if(a)if(a=S7(a),g.pA(a))switch(p=""+a.type,a=a.data||{},this.info("onYoutubeMessage_: "+p+" "+g.Ad(a)),p){case "mdxSessionStatus":d8B(this,a);break;case "loungeToken":rqM(this,a);break;default:Fy(this,"Unknown youtube message: "+p)}else Fy(this,"Unable to parse message.");else Fy(this,"No data in message.")}Ws(p,a,l,y){g.tO(this.C); this.C=0;Kf8(this.j,this.S.label,p,this.S.friendlyName,(0,g.Qo)(function(S){S?a(S):y>=0?(Fy(this,"Screen "+p+" appears to be offline. "+y+" retries left."),this.C=g.jQ((0,g.Qo)(this.Ws,this,p,a,l,y-1),300)):l(Error("Unable to fetch screen."))},this),l)}YG(){return this.U}QY(p){this.nz()||p||(Fy(this,"Cast session died."),this.xf())}};var lnc=class extends x4{constructor(p,a,l,y){super(p,a,"DialSession");this.config_=y;this.U=this.C=null;this.Sl="";this.Bs=l;this.QY=null;this.N=()=>{}; this.UO=NaN;this.Ws=(0,g.Qo)(this.Hs,this);this.X=()=>{}; this.K=this.G=0}jl(p){this.U=p;this.U.addUpdateListener(this.Ws)}D(p){this.QY=p;this.N()}stop(){Cfl(this);this.U?this.U.stop((0,g.Qo)(this.xf,this,null),(0,g.Qo)(this.xf,this,"Failed to stop DIAL device.")):this.xf()}fz(){Cfl(this);this.U&&this.U.removeUpdateListener(this.Ws);this.U=null;super.fz()}Hs(p){this.nz()||p||(Fy(this,"DIAL session died."),this.X(),this.X=()=>{},this.xf())}};var ykG=class extends x4{constructor(p,a){super(p,a,"ManualSession");this.U=g.jQ((0,g.Qo)(this.D,this,null),150)}stop(){this.xf()}jl(){}D(){g.tO(this.U);this.U=NaN;const p=kf(this.j.EM(),this.S.label);p?er(this,p):this.xf(Error("No such screen"))}fz(){g.tO(this.U);this.U=NaN;super.fz()}};var F7=class extends g.js{constructor(p,a){super();this.config_=a;this.S=p;this.jl=a.appId||"233637DE";this.j=a.theme||"cl";this.w7=a.disableCastApi||!1;this.G=a.forceMirroring||!1;this.L=null;this.K=!1;this.U=[];this.D=(0,g.Qo)(this.QY,this)}init(p,a){chrome.cast.timeout.requestSession=3E4;var l=new chrome.cast.SessionRequest(this.jl,[chrome.cast.Capability.AUDIO_OUT]);g.nU("desktop_enable_cast_connect")&&(l.androidReceiverCompatible=!0);this.w7||(l.dialRequest=new chrome.cast.DialRequest("YouTube")); const y=chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;p=p||this.G?chrome.cast.DefaultActionPolicy.CAST_THIS_TAB:chrome.cast.DefaultActionPolicy.CREATE_SESSION;const S=(0,g.Qo)(this.Bs,this);l=new chrome.cast.ApiConfig(l,(0,g.Qo)(this.C,this),S,y,p);l.customDialLaunchCallback=(0,g.Qo)(this.Ws,this);chrome.cast.initialize(l,(0,g.Qo)(function(){this.nz()||(chrome.cast.addReceiverActionListener(this.D),Va_(),this.S.subscribe("onlineScreenChange",(0,g.Qo)(this.X,this)),this.U=Qg7(this),chrome.cast.setCustomReceivers(this.U, ()=>{},(0,g.Qo)(function(n){this.Wi("Failed to set initial custom receivers: "+g.Ad(n))},this)),this.publish("yt-remote-cast2-availability-change",c$(this)),a(!0))},this),(0,g.Qo)(function(n){this.Wi("Failed to initialize API: "+g.Ad(n)); a(!1)},this))}Rc(p,a){dc("Setting connected screen ID: "+p+" -> "+a); if(this.L){var l=this.L.L;if(!p||l&&l.id!=p)dc("Unsetting old screen status: "+this.L.S.friendlyName),yN(this,null)}if(p&&a){if(!this.L){p=kf(this.S.EM(),p);if(!p){dc("setConnectedScreenStatus: Unknown screen.");return}if(p.idType=="shortLived"){dc("setConnectedScreenStatus: Screen with id type to be short lived.");return}l=UG2(this,p);l||(dc("setConnectedScreenStatus: Connected receiver not custom..."),l=new chrome.cast.Receiver(p.uuid?p.uuid:p.id,p.name),l.receiverType=chrome.cast.ReceiverType.CUSTOM, this.U.push(l),chrome.cast.setCustomReceivers(this.U,()=>{},(0,g.Qo)(function(y){this.Wi("Failed to set initial custom receivers: "+g.Ad(y))},this))); dc("setConnectedScreenStatus: new active receiver: "+l.friendlyName);yN(this,new ykG(this.S,l),!0)}this.L.eJ(a)}else dc("setConnectedScreenStatus: no screen.")}ac(p){this.nz()?this.Wi("Setting connection data on disposed cast v2"):this.L?this.L.D(p):this.Wi("Setting connection data without a session")}Sl(){this.nz()?this.Wi("Stopping session on disposed cast v2"):this.L?(this.L.stop(),yN(this,null)):dc("Stopping non-existing session")}requestSession(){chrome.cast.requestSession((0,g.Qo)(this.C,this), (0,g.Qo)(this.Hs,this))}fz(){this.S.unsubscribe("onlineScreenChange",(0,g.Qo)(this.X,this));window.chrome&&chrome.cast&&chrome.cast.removeReceiverActionListener(this.D);var p=yda;const a=g.o1("yt.mdx.remote.debug.handlers_");g.yA(a||[],p);g.Er(this.L);super.fz()}Wi(p){z_("Controller",p)}UO(p,a){this.L==p&&(a||yN(this,null),this.publish("yt-remote-cast2-session-change",a))}QY(p,a){if(!this.nz())if(p)switch(p.friendlyName=chrome.cast.unescape(p.friendlyName),dc("onReceiverAction_ "+p.label+" / "+p.friendlyName+ "-- "+a),a){case chrome.cast.ReceiverAction.CAST:if(this.L)if(this.L.S.label!=p.label)dc("onReceiverAction_: Stopping active receiver: "+this.L.S.friendlyName),this.L.stop();else{dc("onReceiverAction_: Casting to active receiver.");this.L.L&&this.publish("yt-remote-cast2-session-change",this.L.L);break}switch(p.receiverType){case chrome.cast.ReceiverType.CUSTOM:yN(this,new ykG(this.S,p));break;case chrome.cast.ReceiverType.DIAL:yN(this,new lnc(this.S,p,this.j,this.config_));break;case chrome.cast.ReceiverType.CAST:yN(this, new CK(this.S,p,this.config_));break;default:this.Wi("Unknown receiver type: "+p.receiverType)}break;case chrome.cast.ReceiverAction.STOP:this.L&&this.L.S.label==p.label?this.L.stop():this.Wi("Stopping receiver w/o session: "+p.friendlyName)}else this.Wi("onReceiverAction_ called without receiver.")}Ws(p){if(this.nz())return Promise.reject(Error("disposed"));var a=p.receiver;a.receiverType!=chrome.cast.ReceiverType.DIAL&&(this.Wi("Not DIAL receiver: "+a.friendlyName),a.receiverType=chrome.cast.ReceiverType.DIAL); var l=this.L?this.L.S:null;if(!l||l.label!=a.label)return this.Wi("Receiving DIAL launch request for non-clicked DIAL receiver: "+a.friendlyName),Promise.reject(Error("illegal DIAL launch"));if(l&&l.label==a.label&&l.receiverType!=chrome.cast.ReceiverType.DIAL){if(this.L.L)return dc("Reselecting dial screen."),this.publish("yt-remote-cast2-session-change",this.L.L),Promise.resolve(new chrome.cast.DialLaunchResponse(!1));this.Wi('Changing CAST intent from "'+l.receiverType+'" to "dial" for '+a.friendlyName); yN(this,new lnc(this.S,a,this.j,this.config_))}a=this.L;a.C=p;a.C.appState==chrome.cast.DialAppState.RUNNING?(p=a.C.extraData||{},l=p.screenId||null,zC(a)&&p.loungeToken?p.loungeTokenRefreshIntervalMs?p=VBU(a,{name:a.S.friendlyName,screenId:p.screenId,loungeToken:p.loungeToken,dialId:a.C.receiver.label,screenIdType:"shortLived"},p.loungeTokenRefreshIntervalMs):(g.Wp(Error(`No loungeTokenRefreshIntervalMs presents in additionalData: ${JSON.stringify(p)}.`)),p=I_W(a,l)):p=I_W(a,l)):p=jr(a);return p}C(p){if(!this.nz()&& !this.G){dc("New cast session ID: "+p.sessionId);var a=p.receiver;if(a.receiverType!=chrome.cast.ReceiverType.CUSTOM){if(!this.L)if(a.receiverType==chrome.cast.ReceiverType.CAST)dc("Got resumed cast session before resumed mdx connection."),a.friendlyName=chrome.cast.unescape(a.friendlyName),yN(this,new CK(this.S,a,this.config_),!0);else{this.Wi("Got non-cast session without previous mdx receiver event, or mdx resume.");return}var l=this.L.S,y=kf(this.S.EM(),l.label);y&&R3(y,a.label)&&l.receiverType!= chrome.cast.ReceiverType.CAST&&a.receiverType==chrome.cast.ReceiverType.CAST&&(dc("onSessionEstablished_: manual to cast session change "+a.friendlyName),g.Er(this.L),this.L=new CK(this.S,a,this.config_),this.L.subscribe("sessionScreen",(0,g.Qo)(this.UO,this,this.L)),this.L.subscribe("sessionFailed",()=>Zhc(this,this.L)),this.L.D(null)); this.L.jl(p)}}}N(){return this.L?this.L.YG():null}Hs(p){this.nz()||(this.Wi("Failed to estabilish a session: "+g.Ad(p)),p.code!=chrome.cast.ErrorCode.CANCEL&&yN(this,null),this.publish("yt-remote-cast2-session-failed"))}Bs(p){dc("Receiver availability updated: "+p);if(!this.nz()){var a=c$(this);this.K=p==chrome.cast.ReceiverAvailability.AVAILABLE;c$(this)!=a&&this.publish("yt-remote-cast2-availability-change",c$(this))}}X(){this.nz()||(this.U=Qg7(this),dc("Updating custom receivers: "+g.Ad(this.U)), chrome.cast.setCustomReceivers(this.U,()=>{},(0,g.Qo)(function(){this.Wi("Failed to set custom receivers.")},this)),this.publish("yt-remote-cast2-availability-change",c$(this)))}}; F7.prototype.setLaunchParams=F7.prototype.ac;F7.prototype.setConnectedScreenStatus=F7.prototype.Rc;F7.prototype.stopSession=F7.prototype.Sl;F7.prototype.getCastSession=F7.prototype.N;F7.prototype.requestSession=F7.prototype.requestSession;F7.prototype.init=F7.prototype.init;F7.prototype.dispose=F7.prototype.dispose;var EE=[],jh8=(0,g.sZ)`https://www.gstatic.com/cv/js/sender/v1/cast_sender.js`;g.C=xf.prototype; g.C.reset=function(p){this.listId="";this.index=-1;this.videoId="";CM(this);this.volume=-1;this.muted=!1;p&&(this.index=p.index,this.listId=p.listId,this.videoId=p.videoId,this.playerState=p.playerState,this.volume=p.volume,this.muted=p.muted,this.audioTrackId=p.audioTrackId,this.trackData=p.trackData,this.Bk=p.hasPrevious,this.Wo=p.hasNext,this.D=p.playerTime,this.X=p.playerTimeAt,this.S=p.seekableStart,this.G=p.seekableEnd,this.U=p.duration,this.K=p.loadedTime,this.L=p.liveIngestionTime,this.j= !isNaN(this.L))}; g.C.isPlaying=function(){return this.playerState==1}; g.C.isBuffering=function(){return this.playerState==3}; g.C.aQ=function(p){this.U=isNaN(p)?0:p}; g.C.getDuration=function(){return this.j?this.U+y4(this):this.U}; g.C.clone=function(){return new xf(Po(this))};var SO1=class extends g.js{constructor(){var p=rS();super();this.U=0;this.j=p;this.G=[];this.X=new az2;this.S=this.L=null;this.N=(0,g.Qo)(this.QY,this);this.C=(0,g.Qo)(this.D,this);this.UO=(0,g.Qo)(this.Ws,this);this.w7=(0,g.Qo)(this.Bs,this);let a=0;p?(a=p.getProxyState(),a!=3&&(p.subscribe("proxyStateChange",this.jl,this),xha(this))):a=3;a!=0&&g.jQ(()=>{this.jl(a)},0); (p=HPa())&&B$(this,p);this.subscribe("yt-remote-cast2-session-change",this.w7)}getState(){return this.U}uA(){return this.j.getReconnectTimeout()}HA(){this.j.reconnect()}play(){Eu(this)?(this.L?this.L.play(null,g.a$,X7(this,"play")):LK(this,"play"),ue(this,1,m_(zn(this))),this.publish("remotePlayerChange")):Ru(this,this.play)}pause(){Eu(this)?(this.L?this.L.pause(null,g.a$,X7(this,"pause")):LK(this,"pause"),ue(this,2,m_(zn(this))),this.publish("remotePlayerChange")):Ru(this,this.pause)}seekTo(p){if(Eu(this)){if(this.L){const a= zn(this),l=new chrome.cast.media.SeekRequest;l.currentTime=p;a.isPlaying()||a.isBuffering()?l.resumeState=chrome.cast.media.ResumeState.PLAYBACK_START:l.resumeState=chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.L.seek(l,g.a$,X7(this,"seekTo",{newTime:p}))}else LK(this,"seekTo",{newTime:p});ue(this,3,p);this.publish("remotePlayerChange")}else Ru(this,g.i_(this.seekTo,p))}stop(){if(Eu(this)){this.L?this.L.stop(null,g.a$,X7(this,"stopVideo")):LK(this,"stopVideo");var p=zn(this);p.index=-1;p.videoId= "";CM(p);BC(this,p);this.publish("remotePlayerChange")}else Ru(this,this.stop)}setVolume(p,a){if(Eu(this)){var l=zn(this);if(this.S){if(l.volume!=p){const y=Math.round(p)/100;this.S.setReceiverVolumeLevel(y,(0,g.Qo)(function(){dS("set receiver volume: "+y)},this),(0,g.Qo)(function(){this.Wi("failed to set receiver volume.")},this))}l.muted!=a&&this.S.setReceiverMuted(a,(0,g.Qo)(function(){dS("set receiver muted: "+a)},this),(0,g.Qo)(function(){this.Wi("failed to set receiver muted.")},this))}else{const y= {volume:p, muted:a};l.volume!=-1&&(y.delta=p-l.volume);LK(this,"setVolume",y)}l.muted=a;l.volume=p;BC(this,l)}else Ru(this,g.i_(this.setVolume,p,a))}K(p,a){if(Eu(this)){var l=zn(this);p={videoId:p};a&&(l.trackData={trackName:a.name,languageCode:a.languageCode,sourceLanguageCode:a.translationLanguage?a.translationLanguage.languageCode:"",languageName:a.languageName,kind:a.kind},p.style=g.Ad(a.style),g.C0(p,l.trackData));LK(this,"setSubtitlesTrack",p);BC(this,l)}else Ru(this,g.i_(this.K,p,a))}setAudioTrack(p, a){Eu(this)?(a=a.getLanguageInfo().getId(),LK(this,"setAudioTrack",{videoId:p,audioTrackId:a}),p=zn(this),p.audioTrackId=a,BC(this,p)):Ru(this,g.i_(this.setAudioTrack,p,a))}playVideo(p,a,l,y=null,S=null,n=null,V=null){const Z=zn(this),z={videoId:p};l!==void 0&&(z.currentIndex=l);vo(Z,p,l||0);a!==void 0&&(Gn(Z,a),z.currentTime=a);y&&(z.listId=y);S&&(z.playerParams=S);n&&(z.clickTrackingParams=n);V&&(z.locationInfo=g.Ad(V));LK(this,"setPlaylist",z);y||BC(this,Z)}GU(p,a){if(Eu(this)){if(p&&a){const l= zn(this);vo(l,p,a);BC(this,l)}LK(this,"previous")}else Ru(this,g.i_(this.GU,p,a))}nextVideo(p,a){if(Eu(this)){if(p&&a){const l=zn(this);vo(l,p,a);BC(this,l)}LK(this,"next")}else Ru(this,g.i_(this.nextVideo,p,a))}V_(){if(Eu(this)){LK(this,"clearPlaylist");var p=zn(this);p.reset();BC(this,p);this.publish("remotePlayerChange")}else Ru(this,this.V_)}Sl(){Eu(this)?LK(this,"dismissAutoplay"):Ru(this,this.Sl)}dispose(){if(this.U!=3){const p=this.U;this.U=3;this.publish("proxyStateChange",p,this.U)}super.dispose()}fz(){XZ_(this); this.j=null;this.X.clear();B$(this,null);super.fz()}jl(p){if((p!=this.U||p==2)&&this.U!=3&&p!=0){var a=this.U;this.U=p;this.publish("proxyStateChange",a,p);if(p==1)for(;!this.X.isEmpty();)a=p=this.X,a.L.length===0&&(a.L=a.S,a.L.reverse(),a.S=[]),p.L.pop().apply(this);else p==3&&this.dispose()}}Hs(p,a){this.publish(p,a)}QY(p){if(!p)this.D(null),B$(this,null);else if(this.S.receiver.volume){p=this.S.receiver.volume;const a=zn(this),l=Math.round(100*p.level||0);if(a.volume!=l||a.muted!=p.muted)dS("Cast volume update: "+ p.level+(p.muted?" muted":"")),a.volume=l,a.muted=!!p.muted,BC(this,a)}}D(p){dS("Cast media: "+!!p);this.L&&this.L.removeUpdateListener(this.UO);if(this.L=p)this.L.addUpdateListener(this.UO),It7(this),this.publish("remotePlayerChange")}Ws(p){p?(It7(this),this.publish("remotePlayerChange")):this.D(null)}ZC(){LK(this,"sendDebugCommand",{debugCommand:"stats4nerds "})}Bs(){const p=HPa();p&&B$(this,p)}Wi(p){z_("CP",p)}};var V4=class extends g.js{constructor(p,a=!1){var l=om,y=WI();super();this.D=NaN;this.Ws=!1;this.N=this.UO=this.jl=this.w7=NaN;this.Sl=[];this.X=this.K=this.j=this.L=this.S=null;this.Ic=l;this.Hs=a;this.Sl.push(g.OB(window,"beforeunload",()=>{this.G(2)})); this.U=[];this.L=new xf;this.iT=p.id;this.Bs=p.idType;this.S=Pf1(this.Ic,y,this.QY,this.Bs=="shortLived",this.iT);this.S.listen("channelOpened",()=>{$8_(this)}); this.S.listen("channelClosed",()=>{yf("Channel closed");isNaN(this.D)?HC(!0):HC();this.dispose()}); this.S.listen("channelError",S=>{HC();isNaN(this.C())?(S==1&&this.Bs=="shortLived"&&this.publish("browserChannelAuthError",S),yf(`Channel error: ${S} without reconnection`),this.dispose()):(this.Ws=!0,yf("Channel error: "+S+" with reconnection in "+this.C()+" ms"),CS(this,2))}); this.S.listen("channelMessage",S=>{X81(this,S)}); this.S.I6(p.token);this.subscribe("remoteQueueChange",()=>{var S=this.L.videoId;g.X_()&&g.V2("yt-remote-session-video-id",S)})}connect(p,a){if(a){var l=a.listId; const y=a.videoId,S=a.videoIds,n=a.playerParams,V=a.clickTrackingParams,Z=a.index,z={videoId:y},d=a.currentTime,G=a.locationInfo;a=a.loopMode;d!==void 0&&(z.currentTime=d<=5?0:d);n&&(z.playerParams=n);G&&(z.locationInfo=G);V&&(z.clickTrackingParams=V);l&&(z.listId=l);S&&S.length>0&&(z.videoIds=S.join(","));Z!==void 0&&(z.currentIndex=Z);this.Hs&&(z.loopMode=a||"LOOP_MODE_OFF");l&&(this.L.listId=l);this.L.videoId=y;this.L.index=Z||0;this.L.state=3;Gn(this.L,d);this.X="UNSUPPORTED";l=this.Hs?"setInitialState": "setPlaylist";yf(`Connecting with ${l} and params: ${g.Ad(z)}`);this.S.connect({method:l,params:g.Ad(z)},p,qcb())}else yf("Connecting without params"),this.S.connect({},p,qcb());mGM(this)}I6(p){this.S.I6(p)}dispose(){this.nz()||(g.eo("yt.mdx.remote.remoteClient_",null),this.publish("beforeDispose"),CS(this,3));super.dispose()}fz(){FQ(this);iI(this);EN(this);g.tO(this.UO);this.UO=NaN;g.tO(this.N);this.N=NaN;this.j=null;g.wF(this.Sl);this.Sl.length=0;this.S.dispose();super.fz();this.X=this.K=this.U= this.L=this.S=null}ac(p){if(!this.U||this.U.length===0)return!1;for(const a of this.U)if(!a.capabilities.has(p))return!1;return!0}Fu(){let p=3;this.nz()||(p=0,isNaN(this.C())?this.S.HH()&&isNaN(this.D)&&(p=1):p=2);return p}G(p){yf("Disconnecting with "+p);g.eo("yt.mdx.remote.remoteClient_",null);FQ(this);this.publish("beforeDisconnect",p);p==1&&HC();this.S.disconnect(p);this.dispose()}NO(){let p=this.L;this.j&&(p=this.L.clone(),vo(p,this.j,p.index));return Po(p)}E6(p){const a=new xf(p);a.videoId&& a.videoId!=this.L.videoId&&(this.j=a.videoId,g.tO(this.UO),this.UO=g.jQ(()=>{if(this.j){const y=this.j;this.j=null;this.L.videoId!=y&&vC(this,"getNowPlaying")}},5E3)); const l=[];this.L.listId==a.listId&&this.L.videoId==a.videoId&&this.L.index==a.index||l.push("remoteQueueChange");this.L.playerState==a.playerState&&this.L.volume==a.volume&&this.L.muted==a.muted&&m_(this.L)==m_(a)&&g.Ad(this.L.trackData)==g.Ad(a.trackData)||l.push("remotePlayerChange");this.L.reset(p);g.Ir(l,function(y){this.publish(y)},this)}Rc(){const p=this.S.getDeviceId(),a=g.y_(this.U,function(l){return l.type=="REMOTE_CONTROL"&&l.id!=p}); return a?a.id:""}C(){return this.S.uA()}Ps(){return this.X||"UNSUPPORTED"}VY(){return this.K||""}Tm(){!isNaN(this.C())&&this.S.HA()}Lx(p,a){vC(this,p,a);MaW(this)}QY(){var p=g.D3("SAPISID","")||g.D3("__Secure-1PAPISID")||"",a=g.D3("__Secure-3PAPISID","")||"";if(!p&&!a)return"";p=g.dW(g.MA(p),2);a=g.dW(g.MA(a),2);return g.dW(g.MA(`,${p},${a}`),2)}};V4.prototype.subscribe=V4.prototype.subscribe;V4.prototype.unsubscribeByKey=V4.prototype.h5;V4.prototype.getProxyState=V4.prototype.Fu; V4.prototype.disconnect=V4.prototype.G;V4.prototype.getPlayerContextData=V4.prototype.NO;V4.prototype.setPlayerContextData=V4.prototype.E6;V4.prototype.getOtherConnectedRemoteId=V4.prototype.Rc;V4.prototype.getReconnectTimeout=V4.prototype.C;V4.prototype.getAutoplayMode=V4.prototype.Ps;V4.prototype.getAutoplayVideoId=V4.prototype.VY;V4.prototype.reconnect=V4.prototype.Tm;V4.prototype.sendMessage=V4.prototype.Lx;V4.prototype.getXsrfToken=V4.prototype.QY; V4.prototype.isCapabilitySupportedOnConnectedDevices=V4.prototype.ac;var w21=class extends HI{constructor(p){super("ScreenServiceProxy");this.Wl=p;this.L=[];this.L.push(this.Wl.$_s("screenChange",(0,g.Qo)(this.S,this)));this.L.push(this.Wl.$_s("onlineScreenChange",(0,g.Qo)(this.U,this)))}EM(p){return this.Wl.$_gs(p)}contains(p){return!!this.Wl.$_c(p)}get(p){return this.Wl.$_g(p)}start(){this.Wl.$_st()}add(p,a,l){this.Wl.$_a(p,a,l)}remove(p,a,l){this.Wl.$_r(p,a,l)}i5(p,a,l,y){this.Wl.$_un(p,a,l,y)}fz(){const p=this.L.length;for(let a=0;a{TrW(this,y)}); g.H(this,this.events);this.events.J(a,"onCaptionsTrackListChanged",this.Tm);this.events.J(a,"captionschanged",this.Ic);this.events.J(a,"captionssettingschanged",this.Hs);this.events.J(a,"videoplayerreset",this.G);this.events.J(a,"mdxautoplaycancel",()=>{this.Nc.Sl()}); a.A("enable_mdx_video_play_directly")&&this.events.J(a,"videodatachange",()=>{vJ2(this.L)||LM(this)||cC(this,0)}); p=this.Nc;p.nz();p.subscribe("proxyStateChange",this.Ws,this);p.subscribe("remotePlayerChange",this.X,this);p.subscribe("remoteQueueChange",this.G,this);p.subscribe("previousNextChange",this.w7,this);p.subscribe("nowAutoplaying",this.jl,this);p.subscribe("autoplayDismissed",this.Sl,this);g.H(this,this.S);g.H(this,this.U);g.H(this,this.UO);g.H(this,this.N);g.H(this,this.C);this.Hs();this.G();this.X()}fz(){super.fz();this.S.stop();this.U.stop();this.UO.stop();const p=this.Nc;p.unsubscribe("proxyStateChange", this.Ws,this);p.unsubscribe("remotePlayerChange",this.X,this);p.unsubscribe("remoteQueueChange",this.G,this);p.unsubscribe("previousNextChange",this.w7,this);p.unsubscribe("nowAutoplaying",this.jl,this);p.unsubscribe("autoplayDismissed",this.Sl,this);this.Nc=this.L=null}vW(p,...a){if(this.Nc.U!=2)if(LM(this)){if(zn(this.Nc).playerState!=1081||p!=="control_seek")switch(p){case "control_toggle_play_pause":zn(this.Nc).isPlaying()?this.Nc.pause():this.Nc.play();break;case "control_play":this.Nc.play(); break;case "control_pause":this.Nc.pause();break;case "control_seek":this.C.j(a[0],a[1]);break;case "control_subtitles_set_track":sE(this,a[0]);break;case "control_set_audio_track":this.setAudioTrack(a[0])}}else switch(p){case "control_toggle_play_pause":case "control_play":case "control_pause":p=this.B.getCurrentTime();cC(this,p===0?void 0:p);break;case "control_seek":cC(this,a[0]);break;case "control_subtitles_set_track":sE(this,a[0]);break;case "control_set_audio_track":this.setAudioTrack(a[0])}}Ic(p){this.UO.Qd(p)}iT(p){this.vW("control_subtitles_set_track", g.P6(p)?null:p)}Hs(){const p=this.B.getOption("captions","track");g.P6(p)||sE(this,p)}rq(p){this.L.rq(p,this.B.getVideoData().lengthSeconds)}Tm(){g.P6(this.j)||hwW(this,this.j);this.D=!1}Ws(p,a){this.U.stop();a===2&&this.Bs()}X(){if(LM(this)){this.S.stop();var p=zn(this.Nc);switch(p.playerState){case 1080:case 1081:case 1084:case 1085:this.L.eE=1;break;case 1082:case 1083:this.L.eE=0;break;default:this.L.eE=-1}switch(p.playerState){case 1081:case 1:this.X7(new g.bB(8));this.QY();break;case 1085:case 3:this.X7(new g.bB(9)); break;case 1083:case 0:this.X7(new g.bB(2));this.C.stop();this.rq(this.B.getVideoData().lengthSeconds);break;case 1084:this.X7(new g.bB(4));break;case 2:this.X7(new g.bB(4));this.rq(m_(p));break;case -1:this.X7(new g.bB(64));break;case -1E3:this.X7(new g.bB(128,{errorCode:"mdx.remoteerror",errorMessage:"Este v\u00eddeo no se puede reproducir de forma remota.",Y4:2}))}const l=zn(this.Nc).trackData;p=l;var a=this.j;(p||a?p&&a&&p.trackName==a.trackName&&p.languageCode==a.languageCode&&p.languageName== a.languageName&&p.kind==a.kind:1)||(this.j=l,hwW(this,l));p=zn(this.Nc);p.volume===-1||Math.round(this.B.getVolume())===p.volume&&this.B.isMuted()===p.muted||this.N.isActive()||this.Rc()}else je_(this)}w7(){this.B.publish("mdxpreviousnextchange")}G(){LM(this)||je_(this)}jl(p){isNaN(p)||this.B.publish("mdxnowautoplaying",p)}Sl(){this.B.publish("mdxautoplaycanceled")}setAudioTrack(p){LM(this)&&this.Nc.setAudioTrack(this.B.getVideoData(1).videoId,p)}seekTo(p,a){zn(this.Nc).playerState===-1?cC(this,p): a&&this.Nc.seekTo(p)}Rc(){if(LM(this)){var p=zn(this.Nc);this.events.Kt(this.ac);p.muted?this.B.mute():this.B.unMute();this.B.setVolume(p.volume);this.ac=this.events.J(this.B,"onVolumeChange",a=>{TrW(this,a)})}}QY(){this.S.stop(); if(!this.Nc.nz()){var p=zn(this.Nc);p.isPlaying()&&this.X7(new g.bB(8));this.rq(m_(p));this.S.start()}}Bs(){this.U.stop();this.S.stop();const p=this.Nc.uA();this.Nc.U==2&&!isNaN(p)&&this.U.start()}X7(p){this.U.stop();const a=this.K;if(!g.p_(a,p)){const l=p.L(2);l!==this.K.L(2)&&this.B.GY(l);this.K=p;S9a(this.L,a,p)}}};var Voc=class extends g.b1{constructor(p,a){super(p);this.L=a}getCurrentTime(){return this.L.getCurrentTime()}getDuration(){return this.L.getDuration()}By(){return this.L.By()}R1(){return this.L.R1()}cG(){return this.L.cG()}c8(){return this.L.c8()}getPlayerState(){return this.L.Ch}isAtLiveHead(){return this.L.isAtLiveHead()}pauseVideo(){h4(this.L,"control_pause")}async playVideo(){h4(this.L,"control_play")}seekTo(p,a){h4(this.L,"control_seek",p,!a?.eW)}OZ(p){h4(this.L,"control_set_audio_track",p); return!0}};var ZlB=class extends g.t{constructor(){super({W:"div",T:"ytp-mdx-popup-dialog",Z:{role:"dialog"},V:[{W:"div",T:"ytp-mdx-popup-dialog-inner-content",V:[{W:"div",T:"ytp-mdx-popup-title",yY:"No has iniciado sesi\u00f3n"},{W:"div",T:"ytp-mdx-popup-description",yY:"Los v\u00eddeos que veas podr\u00edan aparecer en el historial de reproducciones de la TV e influir en las recomendaciones. Puedes evitarlo si cancelas e inicias sesi\u00f3n en YouTube desde tu ordenador."},{W:"div",T:"ytp-mdx-privacy-popup-buttons", V:[{W:"button",A9:["ytp-button","ytp-mdx-privacy-popup-cancel"],yY:"Cancelar"},{W:"button",A9:["ytp-button","ytp-mdx-privacy-popup-confirm"],yY:"Confirmar"}]}]}]});this.fade=new g.Kg(this,250);this.cancelButton=this.d7("ytp-mdx-privacy-popup-cancel");this.confirmButton=this.d7("ytp-mdx-privacy-popup-confirm");g.H(this,this.fade);this.J(this.cancelButton,"click",this.L);this.J(this.confirmButton,"click",this.S)}zR(){this.fade.show()}ke(){this.fade.hide()}L(){PC("mdx-privacy-popup-cancel");this.ke()}S(){PC("mdx-privacy-popup-confirm"); this.ke()}};var oPU=class extends g.t{constructor(p){super({W:"div",T:"ytp-remote",V:[{W:"div",T:"ytp-remote-display-status",V:[{W:"div",T:"ytp-remote-display-status-icon",V:[g.rrE()]},{W:"div",T:"ytp-remote-display-status-text",yY:"{{statustext}}"}]}]});this.api=p;this.fade=new g.Kg(this,250);g.H(this,this.fade);this.J(p,"presentingplayerstatechange",this.onStateChange);this.cZ(p.getPlayerStateObject())}onStateChange(p){this.cZ(p.state)}cZ(p){if(this.api.getPresentingPlayerType()===3){const a={RECEIVER_NAME:this.api.getOption("remote", "currentReceiver").name};p=p.L(128)?g.L$("No se ha podido reproducir el v\u00eddeo en $RECEIVER_NAME",a):p.isPlaying()||p.isPaused()?g.L$("El v\u00eddeo se est\u00e1 reproduciendo en $RECEIVER_NAME",a):g.L$("Conectado a $RECEIVER_NAME",a);this.updateValue("statustext",p);this.fade.show()}else this.fade.hide()}};var zyl=class extends g.wz{constructor(p,a){super("Reproducir en",1,p,a);this.B=p;this.Qn={};this.J(p,"onMdxReceiversChange",this.G);this.J(p,"presentingplayerstatechange",this.G);this.G()}G(){var p=this.B.getOption("remote","receivers");p&&p.length>1&&!this.B.getOption("remote","quickCast")?(this.Qn=g.Rr(p,this.X,this),this.j(g.Nx(p,this.X)),p=this.B.getOption("remote","currentReceiver"),p=this.X(p),this.options[p]&&this.S(p),this.enable(!0)):this.enable(!1)}X(p){return p.key}U(p){return p==="cast-selector-receiver"? "Enviar...":this.Qn[p].name}L(p){super.L(p);this.B.setOption("remote","currentReceiver",this.Qn[p]);this.U6.ke()}};g.o5("remote",class extends g.LZ{constructor(p){super(p);this.nE={key:oo(),name:"Este ordenador"};this.p8=null;this.subscriptions=[];this.nj=this.Nc=null;this.Qn=[this.nE];this.EV=this.nE;this.Ch=new g.bB(64);this.f3=0;this.eE=-1;this.F9=!1;this.EU=this.CP=this.WC=null;if(!g.CP(this.player.O())&&!g.cf(this.player.O())){p=this.player;var a=g.HJ(p);a&&(a=a.GD())&&(a=new zyl(p,a),g.H(this,a));a=new oPU(p);g.H(this,a);g.g1(p,a.element,4);this.WC=new ZlB;g.H(this,this.WC);g.g1(p,this.WC.element,4);this.F9= !!Mq()}}create(){var p=this.player.O();const a=g.UO(p);p={device:"Desktop",app:"youtube-desktop",loadCastApiSetupScript:p.A("mdx_load_cast_api_bootstrap_script"),enableDialLoungeToken:p.A("enable_dial_short_lived_lounge_token"),enableCastLoungeToken:p.A("enable_cast_short_lived_lounge_token")};KLM(a,p);this.subscriptions.push(g.HT("yt-remote-before-disconnect",this.Tl,this));this.subscriptions.push(g.HT("yt-remote-connection-change",this.r9,this));this.subscriptions.push(g.HT("yt-remote-receiver-availability-change", this.eZ,this));this.subscriptions.push(g.HT("yt-remote-auto-connect",this.MW,this));this.subscriptions.push(g.HT("yt-remote-receiver-resumed",this.aA,this));this.subscriptions.push(g.HT("mdx-privacy-popup-confirm",this.Dm,this));this.subscriptions.push(g.HT("mdx-privacy-popup-cancel",this.Qw,this));this.eZ()}load(){this.player.cancelPlayback();super.load();this.EU=new Voc(this.player.O(),this);this.player.Tu(this.EU);this.p8=new nPb(this,this.player,this.Nc);var p=(p=x8U())?p.currentTime:0;const a= DX()?new SO1:null;p==0&&a&&(p=m_(zn(a)));p!==0&&this.rq(p);S9a(this,this.Ch,this.Ch);this.player.V5(6)}unload(){this.player.publish("mdxautoplaycanceled");this.player.wD();this.EV=this.nE;g.Fm(this.p8,this.Nc);this.Nc=this.EU=this.p8=null;super.unload();this.player.V5(5);gZ(this)}fz(){g.DC(this.subscriptions);super.fz()}getAdState(){return this.eE}Bk(){return this.Nc?zn(this.Nc).Bk:!1}Wo(){return this.Nc?zn(this.Nc).Wo:!1}rq(p,a){this.f3=p||0;this.player.publish("progresssync",p,a);g.OT(this.player, "onVideoProgress",p||0)}getCurrentTime(){return this.f3}getDuration(){return zn(this.Nc).getDuration()||0}By(){var p=zn(this.Nc);return p.j?p.L+y4(p):p.L}R1(){return zn(this.Nc).K}cG(){return ug8(zn(this.Nc))}c8(){var p=zn(this.Nc);return p.S>0?p.S+y4(p):p.S}getProgressState(){const p=zn(this.Nc),a=this.player.getVideoData();return{airingStart:0,airingEnd:0,allowSeeking:p.playerState!=1081&&this.player.h$(),clipEnd:a.clipEnd,clipStart:a.clipStart,current:this.getCurrentTime(),displayedStart:-1,duration:this.getDuration(), ingestionTime:this.By(),isAtLiveHead:this.isAtLiveHead(),loaded:this.R1(),seekableEnd:this.cG(),seekableStart:this.c8(),offset:0,viewerLivestreamJoinMediaTime:0}}isAtLiveHead(){return ug8(zn(this.Nc))-this.getCurrentTime()<=1}nextVideo(){this.Nc&&this.Nc.nextVideo()}GU(){this.Nc&&this.Nc.GU()}Tl(p){p===1&&(this.nj=this.Nc?zn(this.Nc):null)}r9(){var p=DX()?new SO1:null;if(p){const a=this.EV;this.loaded&&this.unload();this.Nc=p;this.nj=null;a.key!==this.nE.key&&(this.EV=a,this.load())}else g.Er(this.Nc), this.Nc=null,this.loaded&&(this.unload(),(p=this.nj)&&p.videoId===this.player.getVideoData().videoId&&this.player.cueVideoById(p.videoId,m_(p)));this.player.publish("videodatachange","newdata",this.player.getVideoData(),3)}eZ(){var p=[this.nE],a=p.concat;const l=$hK();JH()&&g.Wk("yt-remote-cast-available")&&l.push({key:"cast-selector-receiver",name:"Cast..."});this.Qn=a.call(p,l);p=fM()||this.nE;Nm(this,p);g.OT(this.player,"onMdxReceiversChange")}MW(){const p=fM();Nm(this,p)}aA(){this.EV=fM()}Dm(){this.F9= !0;gZ(this);SW=!1;nK&&WC(nK,1);nK=null}Qw(){this.F9=!1;gZ(this);Nm(this,this.nE);this.EV=this.nE;SW=!1;nK=null;this.player.playVideo()}Yg(p,a){switch(p){case "casting":return this.loaded;case "receivers":return this.Qn;case "currentReceiver":return a&&(a.key==="cast-selector-receiver"?Cb():Nm(this,a)),this.loaded?this.EV:this.nE;case "quickCast":return this.Qn.length===2&&this.Qn[1].key==="cast-selector-receiver"?(a&&Cb(),!0):!1}}ZC(){this.Nc.ZC()}bK(){return!1}getOptions(){return["casting","receivers", "currentReceiver","quickCast"]}isLoggedIn(){return g.R("PLAYER_CONFIG")?.args?.authuser!==void 0?!0:!(!g.R("SESSION_INDEX")&&!g.R("LOGGED_IN"))}});})(_yt_player);