(function(g){var window=this;var Cva=function(a,b){var c=[];g.Sl(b,function(a){var b;try{b=g.yD.prototype.o.call(this,a,!0)}catch(f){if("Storage: Invalid value was encountered"==f)return;throw f;}g.t(b)?g.xD(b)&&c.push(a):c.push(a)},a);
return c},Dva=function(a,b){var c=Cva(a,b);
(0,g.H)(c,function(a){g.yD.prototype.remove.call(this,a)},a)},j9=function(a,b){g.d1.call(this,g.U("YTP_MDX_TITLE"),0,a,b);
this.Y=a;this.F={};this.U(a,"onMdxReceiversChange",this.H);this.U(a,"presentingplayerstatechange",this.H);this.H()},Eva=function(a){return a.H?a.F+((0,g.G)()-a.A)/1E3:a.F},Fva=function(){var a=g.TG;
Dva(a,a.g.Od(!0))},k9=function(a){g.vH.call(this,"ScreenServiceProxy");
this.Wc=a;this.o=[];this.o.push(this.Wc.$_s("screenChange",(0,g.A)(this.CQ,this)));this.o.push(this.Wc.$_s("onlineScreenChange",(0,g.A)(this.VM,this)))},l9=function(a){g.iH("cloudview",a)},Gva=function(a){l9("setApiReady_ "+a);
g.u("yt.mdx.remote.cloudview.apiReady_",a,void 0)},m9=function(){return g.w("yt.mdx.remote.cloudview.instance_")},Hva=function(a){g.lG[a]&&(a=g.lG[a],(0,g.H)(a,function(a){g.jG[a]&&delete g.jG[a]}),a.length=0)},n9=function(){return g.w("yt.mdx.remote.connection_")},o9=function(a){g.u("yt.mdx.remote.connectData_",a,void 0)},Iva=function(a){g.u("yt.mdx.remote.currentScreenId_",a,void 0)},p9=function(){return g.w("yt.mdx.remote.currentScreenId_")},r9=function(){if(!q9){var a=g.w("yt.mdx.remote.screenService_");
q9=a?new k9(a):null}return q9},s9=function(a){g.u("yt.mdx.remote.cloudview.initializing_",a,void 0)},t9=function(){return!!g.w("yt.mdx.remote.cloudview.apiReady_")},u9=function(a){l9("setCastInstalled_ "+a);
g.VG("yt-remote-cast-installed",a)},v9=function(a){g.iH("cloudview",a)},Jva=function(a,b){m9().init(a,b)},w9=function(){return!!g.WG("yt-remote-cast-installed")},Kva=function(){l9("dispose");
var a=m9();a&&a.dispose();g.u("yt.mdx.remote.cloudview.instance_",null,void 0);Gva(!1);g.nG(x9);x9.length=0},Lva=function(){var a=window.document.createElement("a");
g.Pd(a,"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js");a=a.href.replace(/^[a-zA-Z]+:\/\//,"//");return"js-"+g.Sa(a)},Mva=function(a,b){var c=window.document.createElement("script");
c.id=a;c.onload=function(){b&&(0,window.setTimeout)(b,0)};
c.onreadystatechange=function(){switch(c.readyState){case "loaded":case "complete":c.onload()}};
c.src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js";var d=window.document.getElementsByTagName("head")[0]||window.document.body;d.insertBefore(c,d.firstChild);return c},Nva=function(a){var b=g.iG();
if(b)if(b.clear(a),a)Hva(a);else for(var c in g.lG)Hva(c)},y9=function(){return g.w("yt.mdx.remote.channelParams_")||{}},A9=function(a){var b=n9();
o9(null);a||Iva("");g.u("yt.mdx.remote.connection_",a,void 0);z9&&((0,g.H)(z9,function(b){b(a)}),z9.length=0);
b&&!a?g.qG("yt-remote-connection-change",!1):!b&&a&&g.qG("yt-remote-connection-change",!0)},Ova=function(){return g.w("yt.mdx.remote.connectData_")},B9=function(){var a=p9();
if(!a)return null;var b=r9().Td();return g.uH(b,a)},Pva=function(a,b){u9(!0);
s9(!1);Jva(a,function(a){a?(Gva(!0),g.oG("yt-remote-cast2-api-ready")):(v9("Failed to initialize cast API."),u9(!1),g.XG("yt-remote-cast-available"),g.XG("yt-remote-cast-receiver"),Kva());b(a)})},Qva=function(){return w9()?m9()?m9().getCastSession():(v9("getCastSelector: Cast is not initialized."),null):(v9("getCastSelector: Cast API is not installed!"),null)},Rva=function(){var a=Lva(),b=window.document.getElementById(a),c=b&&g.yF(b,"loaded");
c||b&&!c||(b=Mva(a,function(){g.yF(b,"loaded")||(g.zF(b,"loaded","true"),g.oG(a),g.GE(g.ya(Nva,a),0))}))},Sva=function(a){return(0,g.I)(a,function(a){return{key:a.id,
name:a.name}})},Tva=function(){if(g.Ioa){var a=2,b=g.Fh(),c=function(){a--;
0==a&&b&&b(!0)};
window.__onGCastApiAvailable=c;g.Kh("//www.gstatic.com/cast/sdk/libs/sender/1.0/cast_framework.js",g.Hh,c)}},D9=function(a,b){p9();
B9()&&B9();Iva(a.id);var c=new g.zI(C9,a,y9());c.connect(b,Ova());c.subscribe("beforeDisconnect",function(a){g.qG("yt-remote-before-disconnect",a)});
c.subscribe("beforeDispose",function(){n9()&&(n9(),A9(null))});
A9(c)},E9=function(){var a=g.AH();
if(!a)return null;var b=r9().Td();return g.uH(b,a)},F9=function(a){g.iH("remote",a)},G9=function(){var a=n9();
return!!a&&3!=a.getProxyState()},H9=function(){t9()?m9().stopSession():v9("stopSession called before API ready.");
var a=n9();a&&(a.disconnect(1),A9(null))},Uva=function(){var a;
a=r9().Wc.$_gos();var b=B9();b&&n9()&&(g.tH(a,b)||a.push(b));return Sva(a)},J9=function(a,b){g.ZF.call(this);
this.g=0;this.B=a;this.D=[];this.C=new g.MB;this.A=this.o=null;this.H=(0,g.A)(this.bL,this);this.F=(0,g.A)(this.Ak,this);this.G=(0,g.A)(this.aL,this);this.J=(0,g.A)(this.oL,this);var c=0;a?(c=a.getProxyState(),3!=c&&(a.subscribe("proxyStateChange",this.Vs,this),Vva(this))):c=3;0!=c&&(b?this.Vs(c):g.GE((0,g.A)(function(){this.Vs(c)},this),0));
var d=Qva();d&&I9(this,d);this.subscribe("yt-remote-cast2-session-change",this.J)},K9=function(a){return new g.oI(a.B.getPlayerContextData())},Wva=function(a,b,c,d,e){var f=K9(a),k=e||f.listId;
d=d||0;var l={videoId:b,currentIndex:d};g.sI(f,b,d);g.t(c)&&(g.qI(f,c),l.currentTime=c);g.t(k)&&(l.listId=k);L9(a,"setPlaylist",l);e||M9(a,f)},Vva=function(a){(0,g.H)("nowAutoplaying autoplayDismissed remotePlayerChange remoteQueueChange autoplayModeChange autoplayUpNext previousNextChange".split(" "),function(a){this.D.push(this.B.subscribe(a,g.ya(this.pN,a),this))},a)},Xva=function(a){(0,g.H)(a.D,function(a){this.B.unsubscribeByKey(a)},a);
a.D.length=0},N9=function(a,b){50>a.C.Gc()&&g.OB(a.C,b)},O9=function(a,b,c){var d=K9(a);
g.qI(d,c);-1E3!=d.g&&(d.g=b);M9(a,d)},L9=function(a,b,c){a.B.sendMessage(b,c)},M9=function(a,b){Xva(a);
a.B.setPlayerContextData(g.tI(b));Vva(a)},I9=function(a,b){a.A&&(a.A.removeUpdateListener(a.H),a.A.removeMediaListener(a.F),a.Ak(null));
a.A=b;a.A&&(P9("Setting cast session: "+a.A.sessionId),a.A.addUpdateListener(a.H),a.A.addMediaListener(a.F),a.A.media.length&&a.Ak(a.A.media[0]))},Yva=function(a){var b=a.o.media,c=a.o.customData;
if(b&&c){var d=K9(a);b.contentId!=d.videoId&&P9("Cast changing video to: "+b.contentId);d.videoId=b.contentId;d.g=c.playerState;g.qI(d,a.o.getEstimatedTime());M9(a,d)}else P9("No cast media video. Ignoring state update.")},P9=function(a){g.iH("CP",a)},Q9=function(a,b,c){return(0,g.A)(function(a){this.jc("Failed to "+b+" with cast v2 channel. Error code: "+a.code);
a.code!=window.chrome.cast.ErrorCode.TIMEOUT&&(this.jc("Retrying "+b+" using MDx browser channel."),L9(this,b,c))},a)},Zva=function(a){var b=!1;
m9()||(a=new g.iI(a),a.subscribe("yt-remote-cast2-availability-change",function(a){g.VG("yt-remote-cast-available",a);g.qG("yt-remote-cast2-availability-change",a)}),a.subscribe("yt-remote-cast2-receiver-selected",function(a){l9("onReceiverSelected: "+a.friendlyName);
g.VG("yt-remote-cast-receiver",a);g.qG("yt-remote-cast2-receiver-selected",a)}),a.subscribe("yt-remote-cast2-receiver-resumed",function(a){l9("onReceiverResumed: "+a.friendlyName);
g.VG("yt-remote-cast-receiver",a)}),a.subscribe("yt-remote-cast2-session-change",function(a){l9("onSessionChange: "+g.qH(a));
a||g.XG("yt-remote-cast-receiver");g.qG("yt-remote-cast2-session-change",a)}),g.u("yt.mdx.remote.cloudview.instance_",a,void 0),b=!0);
l9("cloudview.createSingleton_: "+b);return b},$va=function(){var a=0<=g.Gb.search(/\ (CrMo|Chrome|CriOS)\//);
return g.cF||a},R9=function(a,b){t9()?m9().setConnectedScreenStatus(a,b):v9("setConnectedScreenStatus called before ready.")},awa=function(){l9("clearCurrentReceiver");
g.XG("yt-remote-cast-receiver")},bwa=function(){if(0<=window.navigator.userAgent.indexOf("CriOS")){var a=window.__gCrWeb&&window.__gCrWeb.message&&window.__gCrWeb.message.invokeOnHost;
if(a){Tva();a({command:"cast.sender.init"});return}}if(window.chrome)if(Tva(),a=window.navigator.userAgent,0<=a.indexOf("Android")&&0<=a.indexOf("Chrome/")&&window.navigator.presentation){var a="",b=g.Dh();55<=b?a="55":50<=b&&(a="50");g.Kh("//www.gstatic.com/eureka/clank"+a+g.Ih,g.Hh)}else g.Lh(0);else g.Hh()},cwa=function(a){a?(g.VG("yt-remote-session-app",a.app),g.VG("yt-remote-session-name",a.name)):(g.XG("yt-remote-session-app"),g.XG("yt-remote-session-name"));
g.u("yt.mdx.remote.channelParams_",a,void 0)},dwa=function(){var a=y9();
if(g.Tb(a)){var a=g.zH(),b=g.WG("yt-remote-session-name")||"",c=g.WG("yt-remote-session-app")||"",a={device:"REMOTE_CONTROL",id:a,name:b,app:c,"mdx-version":3};g.u("yt.mdx.remote.channelParams_",a,void 0)}},ewa=function(){var a=E9();
a?(F9("Resume connection to: "+g.qH(a)),D9(a,0)):(g.IH(),awa(),F9("Skipping connecting because no session screen found."))},fwa=function(a){F9("remote.onCastSessionChange_: "+g.qH(a));
if(a){var b=B9();b&&b.id==a.id?R9(b.id,"YouTube TV"):(b&&H9(),D9(a,1))}else n9()&&H9()},gwa=function(){var a=Uva(),b=B9();
b||(b=E9());return g.Za(a,function(a){return b&&g.nH(b,a.key)?!0:!1})},hwa=function(){var a=g.WG("yt-remote-cast-receiver");
return a?a.friendlyName:null},iwa=function(a,b,c,d){$va()?Zva(b)&&(s9(!0),window.chrome&&window.chrome.cast&&window.chrome.cast.isAvailable?Pva(a,c):(window.__onGCastApiAvailable=function(b,d){b?Pva(a,c):(v9("Failed to load cast API: "+d),u9(!1),s9(!1),g.XG("yt-remote-cast-available"),g.XG("yt-remote-cast-receiver"),Kva(),c(!1))},d?window.spf?window.spf.script.load("https://www.gstatic.com/cv/js/sender/v1/cast_sender.js","",void 0):Rva():bwa())):l9("Cannot initialize because not running Chrome")},
jwa=function(a){this.port=this.A="";
this.g="/api/lounge";this.o=!0;a=a||window.document.location.href;var b=g.xg(a)||"";b&&(this.port=":"+b);this.A=g.wg(a)||"";a=g.Gb;0<=a.search("MSIE")&&(a=a.match(/MSIE ([\d.]+)/)[1],0>g.Ra(a,"10.0")&&(this.o=!1))},S9=function(){var a=gwa();
!a&&w9()&&hwa()&&(a={key:"cast-selector-receiver",name:hwa()});return a},kwa=function(){var a=Uva();
w9()&&g.WG("yt-remote-cast-available")&&a.push({key:"cast-selector-receiver",name:"Cast..."});return a},lwa=function(a){var b={device:"Desktop",
app:"youtube-desktop"};g.TG&&Fva();g.CH();C9||(C9=new jwa,g.KH()&&(C9.g="/api/loungedev"));z9||(z9=g.w("yt.mdx.remote.deferredProxies_")||[],g.u("yt.mdx.remote.deferredProxies_",z9,void 0));dwa();var c=r9();if(!c){var d=new g.VH(C9);g.u("yt.mdx.remote.screenService_",d,void 0);c=r9();iwa(a,d,function(a){a?p9()&&R9(p9(),"YouTube TV"):d.subscribe("onlineScreenChange",function(){g.qG("yt-remote-receiver-availability-change")})},!(!b||!b.loadCastApiSetupScript))}b&&!g.w("yt.mdx.remote.initialized_")&&
(g.u("yt.mdx.remote.initialized_",!0,void 0),F9("Initializing: "+g.Lc(b)),T9.push(g.mG("yt-remote-cast2-availability-change",function(){g.qG("yt-remote-receiver-availability-change")})),T9.push(g.mG("yt-remote-cast2-receiver-selected",function(){o9(null);
g.qG("yt-remote-auto-connect","cast-selector-receiver")})),T9.push(g.mG("yt-remote-cast2-receiver-resumed",function(){g.qG("yt-remote-receiver-resumed","cast-selector-receiver")})),T9.push(g.mG("yt-remote-cast2-session-change",fwa)),T9.push(g.mG("yt-remote-connection-change",function(a){a?R9(p9(),"YouTube TV"):E9()||(R9(null,null),awa())})),a=y9(),b.isAuto&&(a.id+="#dial"),g.eG("desktop_enable_autoplay")&&(a.capabilities=["atp"]),a.name=b.device,a.app=b.app,F9(" -- with channel params: "+g.Lc(a)),
cwa(a),c.start(),p9()||ewa())},U9=function(){w9()?m9()?t9()?(l9("Requesting cast selector."),m9().requestSession()):(l9("Wait for cast API to be ready to request the session."),x9.push(g.mG("yt-remote-cast2-api-ready",U9))):v9("requestCastSelector: Cast is not initialized."):v9("requestCastSelector: Cast API is not installed!")},V9=function(a,b,c){g.M.call(this);
this.J=a;this.Y=b;this.o=new g.OL(this);g.N(this,this.o);this.o.U(b,"onCaptionsTrackListChanged",this.oM);this.o.U(b,"captionschanged",this.ZK);this.o.U(b,"captionssettingschanged",this.DA);this.o.U(b,"videoplayerreset",this.xn);this.o.U(b,"mdxautoplaycancel",this.yF);this.M=this.o.U(b,"onVolumeChange",this.az);this.D=!1;this.g=c;c.subscribe("proxyStateChange",this.mz,this);c.subscribe("remotePlayerChange",this.Ck,this);c.subscribe("remoteQueueChange",this.xn,this);c.subscribe("autoplayUpNext",this.Ny,
this);c.subscribe("previousNextChange",this.jz,this);c.subscribe("nowAutoplaying",this.bz,this);c.subscribe("autoplayDismissed",this.My,this);this.suggestion=null;this.F=new g.YQ(64);this.A=new g.Jt(this.yA,500,this);g.N(this,this.A);this.B=new g.Jt(this.zA,1E3,this);g.N(this,this.B);this.C={};this.H=new g.Jt(this.NA,1E3,this);g.N(this,this.H);this.G=new g.qk(this.xS,1E3,this);g.N(this,this.G);this.L=g.y;this.DA();this.xn();this.Ck()},W9=function(a,b){var c=a.J,d=a.Y.ha().lengthSeconds;
c.H=b||0;c.g.V("progresssync",b,d)},mwa=function(a){W9(a,0);
a.A.stop();X9(a,new g.YQ(64))},$9=function(a,b){if(Y9(a)&&!a.D){var c=null;
b&&(c={style:a.Y.bl()},g.$b(c,b));a.g.sA(Z9(a),c);a.C=K9(a.g).o}},a$=function(a,b){var c=a.Y.Uf();
c?Wva(a.g,Z9(a),b,c.Rd(),c.listId.toString()):Wva(a.g,Z9(a),b);X9(a,new g.YQ(1))},nwa=function(a,b){if(b){var c=a.Y.Zc("captions","tracklist",{Zw:1});
c&&c.length?(a.Y.Ie("captions","track",b),a.D=!1):(a.Y.Xk("captions"),a.D=!0)}else a.Y.Ie("captions","track",{})},Y9=function(a){return K9(a.g).videoId==Z9(a)},Z9=function(a){return a.Y.ha().videoId},X9=function(a,b){a.B.stop();
var c=a.F;if(!g.dR(c,b)){var d=g.W(b,2);if(d!=g.W(a.F,2)){var e=a.Y;(e=g.lV(e.app,e.playerType||1))&&g.jU(e,d)}a.F=b;owa(a.J,c,b)}},b$=function(a){g.X.call(this,{K:"div",
W:"ytp-remote",O:[{K:"div",W:"ytp-remote-display-status",O:[{K:"div",W:"ytp-remote-display-status-icon",O:[g.cE()]},{K:"div",W:"ytp-remote-display-status-text",O:["{{statustext}}"]}]}]});this.g=new g.ZV(this,250);g.N(this,this.g);this.A=a;this.U(a,"presentingplayerstatechange",this.B);pwa(this,g.mV(a))},pwa=function(a,b){if(3==a.A.ab()){var c={RECEIVER_NAME:a.A.Zc("remote","currentReceiver").name},c=g.W(b,128)?g.U("YTP_MDX_STATUS_ERROR_2",c):b.vb()||g.W(b,4)?g.U("YTP_MDX_STATUS_PLAYING_2",c):g.U("YTP_MDX_STATUS_CONNECTED_2",
c);
a.Ca("statustext",c);a.g.show()}else g.aW(a.g)},c$=function(a){g.OV.call(this,a);
this.A={key:g.sH(),name:g.U("YTP_MDX_MY_COMPUTER")};this.C=null;this.D=[];this.J=this.o=null;this.G=[this.A];this.B=this.A;this.F=new g.YQ(64);this.H=0;var b=g.fV(a).D;b&&(b=b.A&&b.A.g)&&(b=new j9(a,b),g.N(this,b));b=new b$(a);g.N(this,b);g.DV(a,b.element,5)},owa=function(a,b,c){a.F=c;
a.g.V("presentingplayerstatechange",new g.$T(c,b))},d$=function(a,b){if(b.key!=a.B.key)if(b.key==a.A.key)H9();
else{a.B=b;var c;c=a.g.getPlaylistId();var d=a.g.ha().videoId;if(c||d){var e,f=a.g.Uf();if(f){e=[];for(var k=0;k<f.getLength();k++)e[k]=f.dc(k).videoId}else e=[a.g.ha().videoId];c={videoIds:e,listId:c,videoId:d,index:Math.max(a.g.jB(),0),currentTime:a.g.getCurrentTime()}}else c=null;F9("Connecting to: "+g.Lc(b));"cast-selector-receiver"==b.key?(o9(c||null),c=c||null,t9()?m9().setLaunchParams(c):v9("setLaunchParams called before ready.")):!c&&G9()&&p9()==b.key?g.qG("yt-remote-connection-change",!0):
(H9(),o9(c||null),c=r9().Td(),(c=g.uH(c,b.key))&&D9(c,1))}};
g.p(j9,g.d1);j9.prototype.H=function(){var a=this.Y.Zc("remote","receivers");a&&1<a.length&&!this.Y.Zc("remote","quickCast")?(this.F=g.Cb(a,this.B,this),g.f1(this,(0,g.I)(a,this.B)),a=this.Y.Zc("remote","currentReceiver"),g.e1(this,this.B(a)),this.enable(!0)):this.enable(!1)};
j9.prototype.B=function(a){return a.key};
j9.prototype.Ne=function(a){return"cast-selector-receiver"==a?g.U("YTP_MDX_CAST_SELECTOR"):this.F[a].name};
j9.prototype.hd=function(a){g.d1.prototype.hd.call(this,a);this.Y.Ie("remote","currentReceiver",this.F[a]);this.A.Xb()};
g.C(k9,g.vH);g.h=k9.prototype;g.h.Td=function(a){return this.Wc.$_gs(a)};
g.h.contains=function(a){return!!this.Wc.$_c(a)};
g.h.get=function(a){return this.Wc.$_g(a)};
g.h.start=function(){this.Wc.$_st()};
g.h.po=function(a,b,c){this.Wc.$_a(a,b,c)};
g.h.remove=function(a,b,c){this.Wc.$_r(a,b,c)};
g.h.ao=function(a,b,c,d){this.Wc.$_un(a,b,c,d)};
g.h.P=function(){for(var a=0,b=this.o.length;a<b;++a)this.Wc.$_ubk(this.o[a]);this.o.length=0;this.Wc=null;k9.R.P.call(this)};
g.h.CQ=function(){this.V("screenChange")};
g.h.VM=function(){this.V("onlineScreenChange")};
var q9=null,x9=[],z9=null,C9=null;g.C(J9,g.ZF);g.h=J9.prototype;g.h.play=function(){1==this.g?(this.o?this.o.play(null,g.y,Q9(this,"play")):L9(this,"play"),O9(this,1,g.rI(K9(this))),this.V("remotePlayerChange")):N9(this,this.play)};
g.h.pause=function(){1==this.g?(this.o?this.o.pause(null,g.y,Q9(this,"pause")):L9(this,"pause"),O9(this,2,g.rI(K9(this))),this.V("remotePlayerChange")):N9(this,this.pause)};
g.h.XA=function(a){if(1==this.g){if(this.o){var b=K9(this),c=new window.chrome.cast.media.SeekRequest;c.currentTime=a;c.resumeState=b.vb()||3==b.g?window.chrome.cast.media.ResumeState.PLAYBACK_START:window.chrome.cast.media.ResumeState.PLAYBACK_PAUSE;this.o.seek(c,g.y,Q9(this,"seekTo",{newTime:a}))}else L9(this,"seekTo",{newTime:a});O9(this,3,a);this.V("remotePlayerChange")}else N9(this,g.ya(this.XA,a))};
g.h.stop=function(){if(1==this.g){this.o?this.o.stop(null,g.y,Q9(this,"stopVideo")):L9(this,"stopVideo");var a=K9(this);a.index=-1;a.videoId="";g.pI(a);M9(this,a);this.V("remotePlayerChange")}else N9(this,this.stop)};
g.h.setVolume=function(a,b){if(1==this.g){var c=K9(this);if(this.A){if(c.volume!=a){var d=Math.round(a)/100;this.A.setReceiverVolumeLevel(d,(0,g.A)(function(){P9("set receiver volume: "+d)},this),(0,g.A)(function(){this.jc("failed to set receiver volume.")},this))}c.muted!=b&&this.A.setReceiverMuted(b,(0,g.A)(function(){P9("set receiver muted: "+b)},this),(0,g.A)(function(){this.jc("failed to set receiver muted.")},this))}else{var e={volume:a,
muted:b};-1!=c.volume&&(e.delta=a-c.volume);L9(this,"setVolume",e)}c.muted=b;c.volume=a;M9(this,c)}else N9(this,g.ya(this.setVolume,a,b))};
g.h.sA=function(a,b){if(1==this.g){var c=K9(this),d={videoId:a};b&&(c.o={trackName:b.name,languageCode:b.languageCode,sourceLanguageCode:b.translationLanguage?b.translationLanguage.languageCode:"",languageName:b.languageName,format:b.format,kind:b.kind},d.style=g.Lc(b.style),g.$b(d,c.o));L9(this,"setSubtitlesTrack",d);M9(this,c)}else N9(this,g.ya(this.sA,a,b))};
g.h.Us=function(a,b){if(1==this.g){L9(this,"setAudioTrack",{videoId:a,audioTrackId:b.Nc.id});var c=K9(this);c.audioTrackId=b.Nc.id;M9(this,c)}else N9(this,g.ya(this.Us,a,b))};
g.h.WA=function(a,b){if(1==this.g){if(a&&b){var c=K9(this);g.sI(c,a,b);M9(this,c)}L9(this,"previous")}else N9(this,g.ya(this.WA,a,b))};
g.h.VA=function(a,b){if(1==this.g){if(a&&b){var c=K9(this);g.sI(c,a,b);M9(this,c)}L9(this,"next")}else N9(this,g.ya(this.VA,a,b))};
g.h.Cv=function(){1==this.g?L9(this,"dismissAutoplay"):N9(this,this.Cv)};
g.h.dispose=function(){if(3!=this.g){var a=this.g;this.g=3;this.V("proxyStateChange",a,this.g)}J9.R.dispose.call(this)};
g.h.P=function(){Xva(this);this.B=null;this.C.clear();I9(this,null);J9.R.P.call(this)};
g.h.Vs=function(a){if((a!=this.g||2==a)&&3!=this.g&&0!=a){var b=this.g;this.g=a;this.V("proxyStateChange",b,a);if(1==a)for(;!this.C.isEmpty();)g.PB(this.C).apply(this);else 3==a&&this.dispose()}};
g.h.pN=function(a,b){this.V(a,b)};
g.h.bL=function(a){if(!a)this.Ak(null),I9(this,null);else if(this.A.receiver.volume){a=this.A.receiver.volume;var b=K9(this),c=Math.round(100*a.level||0);if(b.volume!=c||b.muted!=a.muted)P9("Cast volume update: "+a.level+(a.muted?" muted":"")),b.volume=c,b.muted=!!a.muted,M9(this,b)}};
g.h.Ak=function(a){P9("Cast media: "+!!a);this.o&&this.o.removeUpdateListener(this.G);if(this.o=a)this.o.addUpdateListener(this.G),Yva(this),this.V("remotePlayerChange")};
g.h.aL=function(a){a?(Yva(this),this.V("remotePlayerChange")):this.Ak(null)};
g.h.oL=function(){var a=Qva();a&&I9(this,a)};
g.h.jc=function(a){g.iH("CP",a)};
var T9=[];g.h=jwa.prototype;g.h.Ih=function(a,b,c){var d=this.g;if(g.t(c)?c:this.o)d="https://"+this.A+this.port+this.g;return g.Gg(d+a,b||{})};
g.h.Ts=function(a,b,c,d){c={format:"JSON",method:"POST",context:this,timeout:5E3,withCredentials:!1,Lb:g.ya(this.xQ,c,!0),onError:g.ya(this.wQ,d),Xc:g.ya(this.yQ,d)};b&&(c.Rb=b,c.headers={"Content-Type":"application/x-www-form-urlencoded"});return g.TE(a,c)};
g.h.xQ=function(a,b,c,d){b?a(d):a({text:c.responseText})};
g.h.wQ=function(a,b){a(Error("Request error: "+b.status))};
g.h.yQ=function(a){a(Error("request timed out"))};
g.C(V9,g.M);g.h=V9.prototype;g.h.P=function(){V9.R.P.call(this);this.A.stop();this.B.stop();this.L();this.g.unsubscribe("proxyStateChange",this.mz,this);this.g.unsubscribe("remotePlayerChange",this.Ck,this);this.g.unsubscribe("remoteQueueChange",this.xn,this);this.g.unsubscribe("autoplayUpNext",this.Ny,this);this.g.unsubscribe("previousNextChange",this.jz,this);this.g.unsubscribe("nowAutoplaying",this.bz,this);this.g.unsubscribe("autoplayDismissed",this.My,this);this.g=this.J=null};
g.h.IB=function(a,b){2==this.g.g||(Y9(this)?this.KG.apply(this,arguments):this.GG.apply(this,arguments))};
g.h.ZK=function(a){this.IB("control_subtitles_set_track",g.Tb(a)?null:a)};
g.h.DA=function(){var a=this.Y.Zc("captions","track");g.Tb(a)||$9(this,a)};
g.h.GG=function(a,b){var c=Array.prototype.slice.call(arguments,1);switch(a){case "control_toggle_play_pause":case "control_play":case "control_pause":a$(this,this.Y.getCurrentTime());break;case "control_seek":a$(this,c[0]);break;case "control_subtitles_set_track":$9(this,c[0]);break;case "control_set_audio_track":c=c[0],Y9(this)&&this.g.Us(Z9(this),c)}};
g.h.KG=function(a,b){if(1081!=K9(this.g).g||"control_seek"!=a){var c=Array.prototype.slice.call(arguments,1);switch(a){case "control_toggle_play_pause":K9(this.g).vb()?this.g.pause():this.g.play();break;case "control_play":this.g.play();break;case "control_pause":this.g.pause();break;case "control_seek":this.G.Pi(c[0],c[1]);break;case "control_subtitles_set_track":$9(this,c[0]);break;case "control_set_audio_track":c=c[0],Y9(this)&&this.g.Us(Z9(this),c)}}};
g.h.az=function(a){if(Y9(this)){this.g.unsubscribe("remotePlayerChange",this.Ck,this);var b=Math.round(a.volume);a=!!a.muted;var c=K9(this.g);if(b!=c.volume||a!=c.muted)this.g.setVolume(b,a),this.H.start();this.g.subscribe("remotePlayerChange",this.Ck,this)}};
g.h.oM=function(){g.Tb(this.C)||nwa(this,this.C);this.D=!1};
g.h.mz=function(a,b){this.B.stop();2==b&&this.zA()};
g.h.Ck=function(){if(Y9(this)){this.A.stop();var a=K9(this.g);switch(a.g){case 1081:X9(this,new g.YQ(8));break;case 1:this.yA();X9(this,new g.YQ(8));break;case 1083:case 3:X9(this,new g.YQ(9));break;case 0:X9(this,new g.YQ(2));this.G.stop();W9(this,this.Y.ha().lengthSeconds);break;case 1082:X9(this,new g.YQ(4));break;case 2:X9(this,new g.YQ(4));W9(this,g.rI(a));break;case -1:X9(this,new g.YQ(64));break;case -1E3:a={errorCode:"mdx.remoteerror",message:g.U("YTP_MDX_PLAYER_ERROR")},X9(this,new g.YQ(128,
a))}var a=K9(this.g).o,b=this.C;(a||b?a&&b&&a.trackName==b.trackName&&a.languageCode==b.languageCode&&a.languageName==b.languageName&&a.format==b.format&&a.kind==b.kind:1)||(this.C=a,nwa(this,a));a=K9(this.g);-1==a.volume||Math.round(this.Y.getVolume())==a.volume&&this.Y.Ge()==a.muted||this.H.isActive()||this.NA()}else mwa(this)};
g.h.jz=function(){this.Y.V("mdxpreviousnextchange")};
g.h.xn=function(){Y9(this)||mwa(this)};
g.h.yF=function(){this.g.Cv()};
g.h.Ny=function(a){a&&(a=g.TE("/watch_queue_ajax",{method:"GET",Rc:{action_get_watch_queue_item:1,video_id:a},Lb:(0,g.A)(this.qO,this)}))&&(this.L=(0,g.A)(a.abort,a))};
g.h.qO=function(a,b){var c=new g.pQ({videoId:b.videoId,title:b.title,author:b.author,murlmq_webp:b.url});this.suggestion=c;this.Y.V("mdxautoplayupnext",c)};
g.h.bz=function(a){(0,window.isNaN)(a)||this.Y.V("mdxnowautoplaying",a)};
g.h.My=function(){this.Y.V("mdxautoplaycanceled")};
g.h.xS=function(a,b){-1==K9(this.g).g?a$(this,a):b&&this.g.XA(a)};
g.h.NA=function(){if(Y9(this)){var a=K9(this.g);this.o.Ba(this.M);a.muted?this.Y.mute():this.Y.xg();this.Y.setVolume(a.volume);this.M=this.o.U(this.Y,"onVolumeChange",this.az)}};
g.h.yA=function(){this.A.stop();if(!this.g.ma()){var a=K9(this.g);a.vb()&&X9(this,new g.YQ(8));W9(this,g.rI(a));this.A.start()}};
g.h.zA=function(){this.B.stop();this.A.stop();var a=this.g.B.getReconnectTimeout();2==this.g.g&&!(0,window.isNaN)(a)&&this.B.start()};g.p(b$,g.X);b$.prototype.B=function(a){pwa(this,a.state)};g.C(c$,g.OV);g.h=c$.prototype;g.h.create=function(){lwa("embedded"==g.Y(this.g).g);this.D.push(g.mG("yt-remote-before-disconnect",this.WK,this));this.D.push(g.mG("yt-remote-connection-change",this.zN,this));this.D.push(g.mG("yt-remote-receiver-availability-change",this.kz,this));this.D.push(g.mG("yt-remote-auto-connect",this.xN,this));this.D.push(g.mG("yt-remote-receiver-resumed",this.wN,this));this.kz()};
g.h.load=function(){this.g.qp();c$.R.load.call(this);this.C=new V9(this,this.g,this.o);var a;a=(a=Ova())?a.currentTime:0;var b=G9()?new J9(n9(),void 0):null;0==a&&b&&(a=g.rI(K9(b)));0!=a&&(this.H=a||0,this.g.V("progresssync",a,void 0));owa(this,this.F,this.F);g.u2(this.g.app,6)};
g.h.unload=function(){this.g.V("mdxautoplaycanceled");this.B=this.A;g.Ue(this.C,this.o);this.o=this.C=null;c$.R.unload.call(this);g.u2(this.g.app,5)};
g.h.P=function(){g.nG(this.D);c$.R.P.call(this)};
g.h.il=function(a,b){this.loaded&&this.C.IB.apply(this.C,arguments)};
g.h.lG=function(){return this.loaded?this.C.suggestion:null};
g.h.Af=function(){return this.o?K9(this.o).Af:!1};
g.h.hasNext=function(){return this.o?K9(this.o).hasNext:!1};
g.h.getCurrentTime=function(){return this.H};
g.h.cS=function(){var a=K9(this.o),b=this.g.ha(),c=this.g.Dd(),d=b.clipEnd,b=b.clipStart,e=this.getCurrentTime(),f=a.getDuration(),k;k=a.H?a.B+((0,g.G)()-a.A)/1E3:a.B;var l=1>=Eva(a)-this.getCurrentTime(),m=a.J,n=Eva(a),a=0<a.C?a.C+((0,g.G)()-a.A)/1E3:a.C;return{allowSeeking:c,clipEnd:d,clipStart:b,current:e,displayedStart:-1,duration:f,ingestionTime:k,isPeggedToLive:l,loaded:m,seekableEnd:n,seekableStart:a}};
g.h.dS=function(){this.o&&this.o.VA()};
g.h.eS=function(){this.o&&this.o.WA()};
g.h.WK=function(a){1==a&&(this.J=this.o?K9(this.o):null)};
g.h.zN=function(){var a=G9()?new J9(n9(),void 0):null;if(a){var b=this.B;this.loaded&&this.unload();this.o=a;this.J=null;b.key!=this.A.key&&(this.B=b,this.load())}else g.Te(this.o),this.o=null,this.loaded&&(this.unload(),(a=this.J)&&a.videoId==this.g.ha().videoId&&this.g.gB(a.videoId,g.rI(a)));this.g.V("videodatachange","newdata",this.g.ha(),3)};
g.h.kz=function(){this.G=[this.A].concat(kwa());var a=S9()||this.A;d$(this,a);this.g.ya("onMdxReceiversChange")};
g.h.xN=function(){var a=S9();d$(this,a)};
g.h.wN=function(){this.B=S9()};
g.h.bS=function(a,b){switch(a){case "casting":return this.loaded;case "receivers":return this.G;case "currentReceiver":return b&&("cast-selector-receiver"==b.key?U9():d$(this,b)),this.loaded?this.B:this.A;case "quickCast":return 2==this.G.length&&"cast-selector-receiver"==this.G[1].key?(b&&U9(),!0):!1}};
g.h.fS=function(){L9(this.o,"sendDebugCommand",{debugCommand:"stats4nerds "})};
g.h.Id=function(){return!1};window._exportCheck==g.Ba&&g.u("ytmod.player.remote",c$,void 0);})(_yt_player);
