(function(g){var window=this;'use strict';var WHa=function(a,b){a.La("onAutonavCoundownStarted",b)},g3=function(a,b,c){var d=b.Za();
g.L(a.element,"ytp-suggestion-set",!!d.videoId);var e=b.getPlaylistId();c=b.gf(c?c:"mqdefault.jpg");var f=null,h=null;b instanceof g.$F&&(b.lengthText?(f=b.lengthText||null,h=b.Sw||null):b.lengthSeconds&&(f=g.BK(b.lengthSeconds),h=g.BK(b.lengthSeconds,!0)));var l=!!e;e=l&&"RD"===(new g.VL(e.substr(0,2),e.substr(2))).type;var m=b instanceof g.$F?b.isLivePlayback:null,n=b instanceof g.$F?b.isUpcoming:null;d={title:b.title,author:b.author,author_and_views:d.shortViewCount?b.author+" \u2022 "+d.shortViewCount:
b.author,aria_label:b.Is||g.wI("Watch $TITLE",{TITLE:b.title}),duration:f,timestamp:h,url:b.Vm(),is_live:m,is_upcoming:n,is_list:l,is_mix:e,background:c?"background-image: url("+c+")":"",views_and_publish_time:d.shortViewCount?d.shortViewCount+" \u2022 "+d.publishedTimeText:d.publishedTimeText,autoplayAlternativeHeader:b.Ls};b instanceof g.WL&&(d.playlist_length=b.length);a.update(d)},h3=function(a){var b=a.T(),c=b.l;
g.W.call(this,{D:"a",K:"ytp-autonav-suggestion-card",U:{href:"{{url}}",target:c?b.C:"","aria-label":"{{aria_label}}","data-is-live":"{{is_live}}","data-is-list":"{{is_list}}","data-is-mix":"{{is_mix}}","data-is-upcoming":"{{is_upcoming}}"},S:[{D:"div",Ba:["ytp-autonav-endscreen-upnext-thumbnail","ytp-autonav-thumbnail-small"],U:{style:"{{background}}"},S:[{D:"div",U:{"aria-label":"{{timestamp}}"},Ba:["ytp-autonav-timestamp"],ma:"{{duration}}"},{D:"div",Ba:["ytp-autonav-live-stamp"],ma:"Live"},{D:"div",
Ba:["ytp-autonav-upcoming-stamp"],ma:"Upcoming"},{D:"div",K:"ytp-autonav-list-overlay",S:[{D:"div",K:"ytp-autonav-mix-text",ma:"Mix"},{D:"div",K:"ytp-autonav-mix-icon"}]}]},{D:"div",Ba:["ytp-autonav-endscreen-upnext-title","ytp-autonav-title-card"],ma:"{{title}}"},{D:"div",Ba:["ytp-autonav-endscreen-upnext-author","ytp-autonav-author-card"],ma:"{{author}}"},{D:"div",Ba:["ytp-autonav-endscreen-upnext-author","ytp-autonav-view-and-date-card"],ma:"{{views_and_publish_time}}"}]});this.G=a;this.suggestion=
null;this.i=c;this.Na("click",this.onClick);this.Na("keypress",this.l)},j3=function(a,b){b=void 0===b?!1:b;
g.W.call(this,{D:"div",K:"ytp-autonav-endscreen-countdown-container"});var c=this;this.C=b;this.l=0;b=a.T();var d=b.l;this.G=a;this.suggestion=null;this.i=new g.W({D:"div",K:"ytp-autonav-endscreen-upnext-container",U:{"aria-label":"{{aria_label}}","data-is-live":"{{is_live}}","data-is-list":"{{is_list}}","data-is-mix":"{{is_mix}}","data-is-upcoming":"{{is_upcoming}}"},S:[{D:"div",K:"ytp-autonav-endscreen-upnext-header"},{D:"div",K:"ytp-autonav-endscreen-upnext-alternative-header",ma:"{{autoplayAlternativeHeader}}"},
{D:"a",K:"ytp-autonav-endscreen-link-container",U:{href:"{{url}}",target:d?b.C:""},S:[{D:"div",K:"ytp-autonav-endscreen-upnext-thumbnail",U:{style:"{{background}}"},S:[{D:"div",U:{"aria-label":"{{timestamp}}"},Ba:["ytp-autonav-timestamp"],ma:"{{duration}}"},{D:"div",Ba:["ytp-autonav-live-stamp"],ma:"Live"},{D:"div",Ba:["ytp-autonav-upcoming-stamp"],ma:"Upcoming"}]},{D:"div",K:"ytp-autonav-endscreen-video-info",S:[{D:"div",K:"ytp-autonav-endscreen-premium-badge"},{D:"div",K:"ytp-autonav-endscreen-upnext-title",
ma:"{{title}}"},{D:"div",K:"ytp-autonav-endscreen-upnext-author",ma:"{{author}}"},{D:"div",K:"ytp-autonav-view-and-date",ma:"{{views_and_publish_time}}"},{D:"div",K:"ytp-autonav-author-and-view",ma:"{{author_and_views}}"}]}]}]});g.H(this,this.i);this.i.xa(this.element);d||this.N(this.i.ya("ytp-autonav-endscreen-link-container"),"click",this.vE);this.G.Zb(this.element,this,115127);this.G.Zb(this.i.ya("ytp-autonav-endscreen-link-container"),this,115128);this.overlay=new g.W({D:"div",K:"ytp-autonav-overlay"});
g.H(this,this.overlay);this.overlay.xa(this.element);this.u=new g.W({D:"div",K:"ytp-autonav-endscreen-button-container"});g.H(this,this.u);this.u.xa(this.element);this.cancelButton=new g.W({D:"button",Ba:["ytp-autonav-endscreen-upnext-button","ytp-autonav-endscreen-upnext-cancel-button"],U:{"aria-label":"Cancel autoplay"},ma:"Cancel"});g.H(this,this.cancelButton);this.cancelButton.xa(this.u.element);this.cancelButton.Na("click",this.oM,this);this.G.Zb(this.cancelButton.element,this,115129);this.playButton=
new g.W({D:"a",Ba:["ytp-autonav-endscreen-upnext-button","ytp-autonav-endscreen-upnext-play-button"],U:{href:"{{url}}",role:"button","aria-label":"Play next video"},ma:"Play Now"});g.H(this,this.playButton);this.playButton.xa(this.u.element);this.playButton.Na("click",this.vE,this);this.G.Zb(this.playButton.element,this,115130);this.B=new g.J(function(){i3(c)},500);
g.H(this,this.B);this.uE();this.N(a,"autonavvisibility",this.uE)},i3=function(a){var b=k3(a),c=Math.min(a.l?Date.now()-a.l:0,b);
l3(a,Math.ceil((b-c)/1E3));500>=b-c&&a.Ph()?a.select(!0):a.Ph()&&a.B.start()},k3=function(a){var b=a.G.Ro();
return 0<=b?b:g.T(a.G.T().experiments,"autoplay_time")||1E4},l3=function(a,b){b=void 0===b?-1:b;
a=a.i.ya("ytp-autonav-endscreen-upnext-header");g.Fe(a);if(0<=b){b=String(b);var c="Up next in $SECONDS".match(/\$SECONDS/gi)[0],d="Up next in $SECONDS".indexOf(c);if(0<=d){a.appendChild(g.Ee("Up next in $SECONDS".slice(0,d)));var e=g.De("span");g.gn(e,"ytp-autonav-endscreen-upnext-header-countdown-number");g.Ne(e,b);a.appendChild(e);a.appendChild(g.Ee("Up next in $SECONDS".slice(d+c.length)));return}}g.Ne(a,"Up next")},m3=function(a,b){g.W.call(this,{D:"div",
Ba:["html5-endscreen","ytp-player-content",b||"base-endscreen"]});this.created=!1;this.player=a},o3=function(a){g.W.call(this,{D:"div",
Ba:["ytp-upnext","ytp-player-content"],U:{"aria-label":"{{aria_label}}"},S:[{D:"div",K:"ytp-cued-thumbnail-overlay-image",U:{style:"{{background}}"}},{D:"span",K:"ytp-upnext-top",S:[{D:"span",K:"ytp-upnext-header",ma:"Up Next"},{D:"span",K:"ytp-upnext-title",ma:"{{title}}"},{D:"span",K:"ytp-upnext-author",ma:"{{author}}"}]},{D:"a",K:"ytp-upnext-autoplay-icon",U:{role:"button",href:"{{url}}","aria-label":"Play next video"},S:[{D:"svg",U:{height:"100%",version:"1.1",viewBox:"0 0 72 72",width:"100%"},
S:[{D:"circle",K:"ytp-svg-autoplay-circle",U:{cx:"36",cy:"36",fill:"#fff","fill-opacity":"0.3",r:"31.5"}},{D:"circle",K:"ytp-svg-autoplay-ring",U:{cx:"-36",cy:"36","fill-opacity":"0",r:"33.5",stroke:"#FFFFFF","stroke-dasharray":"211","stroke-dashoffset":"-211","stroke-width":"4",transform:"rotate(-90)"}},{D:"path",K:"ytp-svg-fill",U:{d:"M 24,48 41,36 24,24 V 48 z M 44,24 v 24 h 4 V 24 h -4 z"}}]}]},{D:"span",K:"ytp-upnext-bottom",S:[{D:"span",K:"ytp-upnext-cancel"},{D:"span",K:"ytp-upnext-paused",
ma:"Autoplay is paused"}]}]});this.api=a;this.cancelButton=null;this.C=this.ya("ytp-svg-autoplay-ring");this.u=this.notification=this.i=this.suggestion=null;this.B=new g.J(this.Uv,5E3,this);this.l=0;var b=this.ya("ytp-upnext-cancel");this.cancelButton=new g.W({D:"button",Ba:["ytp-upnext-cancel-button","ytp-button"],U:{tabindex:"0","aria-label":"Cancel autoplay"},ma:"Cancel"});g.H(this,this.cancelButton);this.cancelButton.Na("click",this.pM,this);this.cancelButton.xa(b);this.cancelButton&&this.api.Zb(this.cancelButton.element,
this,115129);g.H(this,this.B);this.api.Zb(this.element,this,18788);b=this.ya("ytp-upnext-autoplay-icon");this.N(b,"click",this.qM);this.api.Zb(b,this,115130);this.wE();this.N(a,"autonavvisibility",this.wE);this.N(a,"mdxnowautoplaying",this.JQ);this.N(a,"mdxautoplaycanceled",this.KQ);this.N(a,"mdxautoplayupnext",this.sK);n3(this)&&(a=(a=g.NL(this.api.ob()))?a.iO():null)&&this.sK(a);g.L(this.element,"ytp-upnext-mobile",this.api.T().i)},n3=function(a){return 3===a.api.getPresentingPlayerType()},XHa=
function(a,b){return b?b:0<=a.api.Ro()?a.api.Ro():g.T(a.api.T().experiments,"autoplay_time")||1E4},p3=function(a,b){b=XHa(a,b);
var c=Math,d=c.min;var e=(0,g.N)()-a.l;c=d.call(c,e,b);b=0===b?1:Math.min(c/b,1);a.C.setAttribute("stroke-dashoffset",""+-211*(b+1));1<=b&&a.Ph()&&!n3(a)?a.select(!0):a.Ph()&&a.i.start()},q3=function(a){m3.call(this,a,"autonav-endscreen");
this.overlay=this.videoData=this.suggestions=null;this.table=new g.W({D:"div",K:"ytp-suggestion-panel",S:[{D:"div",Ba:["ytp-autonav-endscreen-upnext-header","ytp-autonav-endscreen-more-videos"],ma:"More videos"}]});this.J=new g.W({D:"div",K:"ytp-suggestions-container"});this.videos=[];this.u=null;this.C=this.I=!1;this.l=new j3(this.player);g.H(this,this.l);this.l.xa(this.element);a.getVideoData().Kc?this.i=this.l:(this.i=new o3(a),g.RL(this.player,this.i.element,4),g.H(this,this.i));this.overlay=
new g.W({D:"div",K:"ytp-autonav-overlay-cancelled-state"});g.H(this,this.overlay);this.overlay.xa(this.element);this.B=new g.TL(this);g.H(this,this.B);g.H(this,this.table);this.table.xa(this.element);this.table.show();g.H(this,this.J);this.J.xa(this.table.element);this.hide()},YHa=function(a,b){return g.Oc(b.suggestions,function(c){c=g.oO(a.player.T(),c);
g.H(a,c);return c})},r3=function(a){var b=a.Xd();
b!==a.C&&(a.C=b,a.player.V("autonavvisibility"),a.C?(a.l!==a.i&&a.l.hide(),a.table.hide()):(a.l!==a.i&&a.l.show(),a.table.show()))},s3=function(a){m3.call(this,a,"subscribecard-endscreen");
this.i=new g.W({D:"div",K:"ytp-subscribe-card",S:[{D:"img",K:"ytp-author-image",U:{src:"{{profilePicture}}"}},{D:"div",K:"ytp-subscribe-card-right",S:[{D:"div",K:"ytp-author-name",ma:"{{author}}"},{D:"div",K:"html5-subscribe-button-container"}]}]});g.H(this,this.i);this.i.xa(this.element);var b=a.getVideoData();this.subscribeButton=new g.bN("Subscribe",null,"Unsubscribe",null,!0,!1,b.Yh,b.subscribed,"trailer-endscreen",null,null,a);g.H(this,this.subscribeButton);this.subscribeButton.xa(this.i.ya("html5-subscribe-button-container"));
this.N(a,"videodatachange",this.Ja);this.Ja();this.hide()},t3=function(a){var b=a.T(),c=g.wB||g.gg?{style:"will-change: opacity"}:void 0,d=b.l,e=["ytp-videowall-still"];
b.i&&e.push("ytp-videowall-show-text");g.W.call(this,{D:"a",Ba:e,U:{href:"{{url}}",target:d?b.C:"","aria-label":"{{aria_label}}","data-is-live":"{{is_live}}","data-is-list":"{{is_list}}","data-is-mix":"{{is_mix}}"},S:[{D:"div",K:"ytp-videowall-still-image",U:{style:"{{background}}"}},{D:"span",K:"ytp-videowall-still-info",S:[{D:"span",K:"ytp-videowall-still-info-bg",S:[{D:"span",K:"ytp-videowall-still-info-content",U:c,S:[{D:"span",K:"ytp-videowall-still-info-title",ma:"{{title}}"},{D:"span",K:"ytp-videowall-still-info-author",
ma:"{{author_and_views}}"},{D:"span",K:"ytp-videowall-still-info-live",ma:"Live"},{D:"span",K:"ytp-videowall-still-info-duration",ma:"{{duration}}"}]}]}]},{D:"span",Ba:["ytp-videowall-still-listlabel-regular","ytp-videowall-still-listlabel"],S:[{D:"span",K:"ytp-videowall-still-listlabel-icon"},"Playlist",{D:"span",K:"ytp-videowall-still-listlabel-length",S:[" (",{D:"span",ma:"{{playlist_length}}"},")"]}]},{D:"span",Ba:["ytp-videowall-still-listlabel-mix","ytp-videowall-still-listlabel"],S:[{D:"span",
K:"ytp-videowall-still-listlabel-mix-icon"},"Mix",{D:"span",K:"ytp-videowall-still-listlabel-length",ma:" (50+)"}]}]});this.suggestion=null;this.l=d;this.api=a;this.i=new g.TL(this);g.H(this,this.i);this.Na("click",this.onClick);this.Na("keypress",this.u);this.i.N(a,"videodatachange",this.fb);a.Lh(this.element,this);this.fb()},u3=function(a){m3.call(this,a,"videowall-endscreen");
var b=this;this.G=a;this.u=0;this.stills=[];this.B=this.videoData=this.suggestions=null;this.C=this.J=!1;this.L=null;this.l=new g.TL(this);g.H(this,this.l);this.I=new g.J(function(){g.K(b.element,"ytp-show-tiles")},0);
g.H(this,this.I);var c=new g.W({D:"button",Ba:["ytp-button","ytp-endscreen-previous"],U:{"aria-label":"Previous"},S:[g.$J()]});g.H(this,c);c.xa(this.element);c.Na("click",this.uM,this);this.table=new g.SJ({D:"div",K:"ytp-endscreen-content"});g.H(this,this.table);this.table.xa(this.element);c=new g.W({D:"button",Ba:["ytp-button","ytp-endscreen-next"],U:{"aria-label":"Next"},S:[g.aK()]});g.H(this,c);c.xa(this.element);c.Na("click",this.tM,this);a.getVideoData().Kc?this.i=new j3(a,!0):this.i=new o3(a);
g.H(this,this.i);g.RL(this.player,this.i.element,4);this.hide()},v3=function(a){return g.SL(a.player)&&a.Ks()&&!a.B},ZHa=function(a,b){return g.Oc(b.suggestions,function(c){c=g.oO(a.G.T(),c);
g.H(a,c);return c})},w3=function(a){var b=a.Xd();
b!==a.J&&(a.J=b,a.player.V("autonavvisibility"))},x3=function(a){g.aM.call(this,a);
var b=this;this.endScreen=null;this.i=this.l=this.u=!1;this.listeners=new g.TL(this);g.H(this,this.listeners);this.env=a.T();$Ha(a)?(this.u=!0,aIa(this),this.i?this.endScreen=new q3(a):this.endScreen=new u3(this.player)):this.env.Wc?this.endScreen=new s3(this.player):this.endScreen=new m3(this.player);g.H(this,this.endScreen);g.RL(this.player,this.endScreen.element,4);bIa(this);this.listeners.N(a,"videodatachange",this.fb,this);this.listeners.N(a,g.tw("endscreen"),function(c){b.ge(c)});
this.listeners.N(a,g.uw("endscreen"),function(c){b.ag(c)})},aIa=function(a){var b=a.player.getVideoData();
if(!b||a.i===b.Sf&&a.l===b.Kc)return!1;a.i=b.Sf;a.l=b.Kc;return!0},$Ha=function(a){a=a.T();
return a.Db&&!a.Wc},bIa=function(a){a.player.Df("endscreen");
var b=a.player.getVideoData();b=new g.pw(Math.max(1E3*(b.lengthSeconds-10),0),0x8000000000000,{id:"preload",namespace:"endscreen"});var c=new g.pw(0x8000000000000,0x8000000000000,{id:"load",priority:6,namespace:"endscreen"});a.player.Td([b,c])};
g.KL.prototype.Ro=g.ca(4,function(){return this.app.Ro()});
g.bW.prototype.Ro=g.ca(3,function(){return this.getVideoData().dF});
g.v(h3,g.W);h3.prototype.select=function(){(this.G.Oj(this.suggestion.Za().videoId,this.suggestion.ke,this.suggestion.getPlaylistId(),void 0,void 0,this.suggestion.sA||void 0)||this.G.ea("web_player_endscreen_double_log_fix_killswitch"))&&this.G.Kb(this.element)};
h3.prototype.onClick=function(a){g.tM(a,this.G,this.i,this.suggestion.ke||void 0)&&this.select()};
h3.prototype.l=function(a){switch(a.keyCode){case 13:case 32:g.ip(a)||(this.select(),g.hp(a))}};
h3.prototype.Ge=function(a){g.L(this.element,"ytp-suggestion-card-with-margin",a)};g.v(j3,g.W);g.k=j3.prototype;g.k.As=function(a){this.suggestion!==a&&(this.suggestion=a,g3(this.i,a),this.playButton.Oa("url",this.suggestion.Vm()),this.Ge())};
g.k.Ge=function(){var a=this.G.jj(!0,this.G.isFullscreen());g.L(this.element,"ytp-autonav-endscreen-small-mode",this.lf(a));g.L(this.element,"ytp-autonav-endscreen-is-premium",!!this.suggestion&&!!this.suggestion.Wx);g.L(this.G.getRootNode(),"ytp-autonav-endscreen-cancelled-state",!this.G.Xd());g.L(this.G.getRootNode(),"countdown-running",this.Ph());g.L(this.element,"ytp-player-content",this.G.Xd());g.dg(this.overlay.element,{width:a.width+"px"});if(!this.Ph()){this.G.Xd()?l3(this,Math.round(k3(this)/
1E3)):l3(this);a=!!this.suggestion&&!!this.suggestion.Ls;var b=this.G.Xd()||!a;g.L(this.element,"ytp-autonav-endscreen-upnext-alternative-header-only",!b&&a);g.L(this.element,"ytp-autonav-endscreen-upnext-no-alternative-header",b&&!a);g.VJ(this.u,this.G.Xd())}};
g.k.Ph=function(){return 0<this.l};
g.k.Or=function(){this.Ph()||(this.l=Date.now(),i3(this),WHa(this.G,k3(this)),g.L(this.G.getRootNode(),"countdown-running",this.Ph()))};
g.k.Ap=function(){this.cm();i3(this)};
g.k.cm=function(){this.Ph()&&(this.B.stop(),this.l=0)};
g.k.select=function(a){this.G.nextVideo(!1,void 0===a?!1:a);this.cm()};
g.k.vE=function(a){g.tM(a,this.G)&&(a.currentTarget===this.playButton.element?this.G.Kb(this.playButton.element):a.currentTarget===this.i.ya("ytp-autonav-endscreen-link-container")&&(a=this.i.ya("ytp-autonav-endscreen-link-container"),this.G.eb(a,!0),this.G.Kb(a)),this.select())};
g.k.oM=function(){this.G.Kb(this.cancelButton.element);g.ML(this.G,!0)};
g.k.uE=function(){var a=this.G.Xd();this.C&&this.vb!==a&&g.VJ(this,a);this.Ge();this.G.eb(this.element,a);this.G.eb(this.cancelButton.element,a);this.G.eb(this.i.ya("ytp-autonav-endscreen-link-container"),a);this.G.eb(this.playButton.element,a)};
g.k.lf=function(a){return 400>a.width||459>a.height};g.v(m3,g.W);g.k=m3.prototype;g.k.create=function(){this.created=!0};
g.k.destroy=function(){this.created=!1};
g.k.Ks=function(){return!1};
g.k.Xd=function(){return!1};
g.k.pH=function(){return!1};g.v(o3,g.W);g.k=o3.prototype;g.k.Uv=function(){this.notification&&(this.B.stop(),this.hc(this.u),this.u=null,this.notification.close(),this.notification=null)};
g.k.As=function(a){this.suggestion=a;g3(this,a,"hqdefault.jpg")};
g.k.wE=function(){g.VJ(this,this.api.Xd());this.api.eb(this.element,this.api.Xd());this.api.eb(this.ya("ytp-upnext-autoplay-icon"),this.api.Xd());this.cancelButton&&this.api.eb(this.cancelButton.element,this.api.Xd())};
g.k.WQ=function(){window.focus();this.Uv()};
g.k.Or=function(a){var b=this;this.Ph()||(g.Jo("a11y-announce","Up Next "+this.suggestion.title),this.l=(0,g.N)(),this.i=new g.J(function(){p3(b,a)},25),p3(this,a),WHa(this.api,XHa(this,a)));
g.kn(this.element,"ytp-upnext-autoplay-paused")};
g.k.hide=function(){g.W.prototype.hide.call(this)};
g.k.Ph=function(){return!!this.i};
g.k.Ap=function(){this.cm();this.l=(0,g.N)();p3(this);g.K(this.element,"ytp-upnext-autoplay-paused")};
g.k.cm=function(){this.Ph()&&(this.i.dispose(),this.i=null)};
g.k.select=function(a){a=void 0===a?!1:a;if(g.S(this.api.T().experiments,"autonav_notifications")&&a&&window.Notification&&document.hasFocus){var b=Notification.permission;"default"===b?Notification.requestPermission():"granted"!==b||document.hasFocus()||(b=this.suggestion.Za(),this.Uv(),this.notification=new Notification("Up Next",{body:b.title,icon:b.gf()}),this.u=this.N(this.notification,"click",this.WQ),this.B.start())}this.cm();this.api.nextVideo(!1,a)};
g.k.qM=function(a){!g.Me(this.cancelButton.element,g.dp(a))&&g.tM(a,this.api)&&(this.api.Xd()&&this.api.Kb(this.ya("ytp-upnext-autoplay-icon")),this.select())};
g.k.pM=function(){this.api.Xd()&&this.cancelButton&&this.api.Kb(this.cancelButton.element);g.ML(this.api,!0)};
g.k.JQ=function(a){n3(this);this.show();this.Or(a)};
g.k.sK=function(a){n3(this);this.suggestion&&this.suggestion.Za().videoId===a.Za().videoId||this.As(a)};
g.k.KQ=function(){n3(this);this.cm();this.hide()};
g.k.oa=function(){this.cm();this.Uv();g.W.prototype.oa.call(this)};g.v(q3,m3);g.k=q3.prototype;g.k.create=function(){m3.prototype.create.call(this);this.B.N(this.player,"appresize",this.Ge);this.B.N(this.player,"onVideoAreaChange",this.Ge);this.B.N(this.player,"videodatachange",this.fb);this.B.N(this.player,"autonavchange",this.xE);this.B.N(this.player,"autonavcancel",this.rM);this.fb()};
g.k.show=function(){m3.prototype.show.call(this);(this.I||this.u&&this.u!==this.videoData.clientPlaybackNonce)&&g.ML(this.player,!1);g.SL(this.player)&&this.Ks()&&!this.u?(r3(this),2===this.videoData.autonavState?this.player.T().ea("fast_autonav_in_background")&&3===this.player.getVisibilityState()?this.i.select(!0):this.i.Or():3===this.videoData.autonavState&&this.i.Ap()):(g.ML(this.player,!0),r3(this));this.Ge()};
g.k.hide=function(){m3.prototype.hide.call(this);this.i.Ap();r3(this)};
g.k.Ge=function(){var a=this.player.jj(!0,this.player.isFullscreen());r3(this);this.l.Ge();g.L(this.element,"ytp-autonav-cancelled-small-mode",this.lf(a));g.L(this.element,"ytp-autonav-cancelled-tiny-mode",this.Nw(a));g.L(this.element,"ytp-autonav-cancelled-mini-mode",400>=a.width||360>=a.height);this.overlay&&g.dg(this.overlay.element,{width:a.width+"px"});if(!this.C){a=g.q(this.videos.entries());for(var b=a.next();!b.done;b=a.next()){b=g.q(b.value);var c=b.next().value;b.next().value.Ge(1===c%2)}}};
g.k.fb=function(){var a=this.player.getVideoData();if(this.videoData!==a&&a){this.videoData=a;if((this.suggestions=YHa(this,a))&&this.suggestions.length)for(this.i.As(this.suggestions[0]),this.i!==this.l&&this.l.As(this.suggestions[0]),a=0;a<cIa.length;++a){var b=cIa[a];if(this.suggestions&&this.suggestions[b]){this.videos[a]=new h3(this.player);var c=this.videos[a];b=this.suggestions[b];c.suggestion!==b&&(c.suggestion=b,g3(c,b));g.H(this,this.videos[a]);this.videos[a].xa(this.J.element)}}this.Ge()}};
g.k.xE=function(a){1===a?(this.I=!1,this.u=this.videoData.clientPlaybackNonce,this.i.cm(),this.vb&&this.Ge()):(this.I=!0,this.Xd()&&(2===a?this.i.Or():3===a&&this.i.Ap()))};
g.k.rM=function(a){a?this.xE(1):(this.u=null,this.I=!1)};
g.k.Ks=function(){return 1!==this.videoData.autonavState};
g.k.lf=function(a){return(910>a.width||459>a.height)&&!this.Nw(a)&&!(400>=a.width||360>=a.height)};
g.k.Nw=function(a){return 800>a.width&&!(400>=a.width||360>=a.height)};
g.k.Xd=function(){return this.vb&&g.SL(this.player)&&this.Ks()&&!this.u};
var cIa=[1,3,2,4];g.v(s3,m3);s3.prototype.Ja=function(){var a=this.player.getVideoData();this.i.update({profilePicture:a.Wg,author:a.author});this.subscribeButton.channelId=a.Yh;var b=this.subscribeButton;a.subscribed?b.l():b.u()};g.v(t3,g.W);t3.prototype.select=function(){(this.api.Oj(this.suggestion.Za().videoId,this.suggestion.ke,this.suggestion.getPlaylistId(),void 0,void 0,this.suggestion.sA||void 0)||this.api.ea("web_player_endscreen_double_log_fix_killswitch"))&&this.api.Kb(this.element)};
t3.prototype.onClick=function(a){g.tM(a,this.api,this.l,this.suggestion.ke||void 0)&&this.select()};
t3.prototype.u=function(a){switch(a.keyCode){case 13:case 32:g.ip(a)||(this.select(),g.hp(a))}};
t3.prototype.fb=function(){var a=this.api.getVideoData(),b=this.api.T();this.l=a.C?!1:b.l};g.v(u3,m3);g.k=u3.prototype;g.k.create=function(){m3.prototype.create.call(this);var a=this.player.getVideoData();a&&(this.suggestions=ZHa(this,a),this.videoData=a);this.Ge();this.l.N(this.player,"appresize",this.Ge);this.l.N(this.player,"onVideoAreaChange",this.Ge);this.l.N(this.player,"videodatachange",this.fb);this.l.N(this.player,"autonavchange",this.nz);this.l.N(this.player,"autonavcancel",this.sM);a=this.videoData.autonavState;a!==this.L&&this.nz(a);this.l.N(this.element,"transitionend",this.jS)};
g.k.destroy=function(){g.$t(this.l);g.vi(this.stills);this.stills=[];this.suggestions=null;m3.prototype.destroy.call(this);g.kn(this.element,"ytp-show-tiles");this.I.stop();this.L=this.videoData.autonavState};
g.k.Ks=function(){return 1!==this.videoData.autonavState};
g.k.show=function(){m3.prototype.show.call(this);g.kn(this.element,"ytp-show-tiles");this.player.T().i?this.I.gh():this.I.start();(this.C||this.B&&this.B!==this.videoData.clientPlaybackNonce)&&g.ML(this.player,!1);v3(this)?(w3(this),2===this.videoData.autonavState?this.player.T().ea("fast_autonav_in_background")&&3===this.player.getVisibilityState()?this.i.select(!0):this.i.Or():3===this.videoData.autonavState&&this.i.Ap()):(g.ML(this.player,!0),w3(this))};
g.k.hide=function(){m3.prototype.hide.call(this);this.i.Ap();w3(this)};
g.k.jS=function(a){g.dp(a)===this.element&&this.Ge()};
g.k.Ge=function(){if(this.suggestions&&this.suggestions.length){g.K(this.element,"ytp-endscreen-paginate");var a=this.G.jj(!0,this.G.isFullscreen()),b=g.HL(this.G);b&&(b=b.Ve()?48:32,a.width-=2*b);var c=a.width/a.height,d=96/54,e=b=2,f=Math.max(a.width/96,2),h=Math.max(a.height/54,2),l=this.suggestions.length,m=Math.pow(2,2);var n=l*m+(Math.pow(2,2)-m);n+=Math.pow(2,2)-m;for(n-=m;0<n&&(b<f||e<h);){var p=b/2,r=e/2,t=b<=f-2&&n>=r*m,u=e<=h-2&&n>=p*m;if((p+1)/r*d/c>c/(p/(r+1)*d)&&u)n-=p*m,e+=2;else if(t)n-=
r*m,b+=2;else if(u)n-=p*m,e+=2;else break}d=!1;n>=3*m&&6>=l*m-n&&(4<=e||4<=b)&&(d=!0);m=96*b;n=54*e;c=m/n<c?a.height/n:a.width/m;c=Math.min(c,2);m=Math.floor(Math.min(a.width,m*c));n=Math.floor(Math.min(a.height,n*c));a=this.table.element;g.sg(a,m,n);g.dg(a,{marginLeft:m/-2+"px",marginTop:n/-2+"px"});this.i.As(this.suggestions[0]);this.i instanceof j3&&this.i.Ge();g.L(this.element,"ytp-endscreen-takeover",v3(this));w3(this);m+=4;n+=4;for(f=c=0;f<b;f++)for(h=0;h<e;h++)if(p=c,r=0,d&&f>=b-2&&h>=e-2?
r=1:0===h%2&&0===f%2&&(2>h&&2>f?0===h&&0===f&&(r=2):r=2),p=g.$d(p+this.u,l),0!==r){t=this.stills[c];t||(t=new t3(this.player),this.stills[c]=t,a.appendChild(t.element));u=Math.floor(n*h/e);var x=Math.floor(m*f/b),y=Math.floor(n*(h+r)/e)-u-4,E=Math.floor(m*(f+r)/b)-x-4;g.lg(t.element,x,u);g.sg(t.element,E,y);g.dg(t.element,"transitionDelay",(h+f)/20+"s");g.L(t.element,"ytp-videowall-still-mini",1===r);g.L(t.element,"ytp-videowall-still-large",2<r);r=t;p=this.suggestions[p];r.suggestion!==p&&(r.suggestion=
p,t=r.api.T(),u=g.hn(r.element,"ytp-videowall-still-large")?"hqdefault.jpg":"mqdefault.jpg",g3(r,p,u),g.BD(t)&&(t=p.Vm(),t=g.Id(t,g.YM("emb_rel_end")),r.Oa("url",t)),(p=(p=p.ke)&&p.itct)&&r.api.Jn(r.element,p));c++}g.L(this.element,"ytp-endscreen-paginate",c<l);for(b=this.stills.length-1;b>=c;b--)e=this.stills[b],g.He(e.element),g.ui(e);this.stills.length=c}};
g.k.fb=function(){var a=this.player.getVideoData();this.videoData!==a&&(this.u=0,this.suggestions=ZHa(this,a),this.videoData=a,this.Ge())};
g.k.tM=function(){this.u+=this.stills.length;this.Ge()};
g.k.uM=function(){this.u-=this.stills.length;this.Ge()};
g.k.pH=function(){return this.i.Ph()};
g.k.nz=function(a){1===a?(this.C=!1,this.B=this.videoData.clientPlaybackNonce,this.i.cm(),this.vb&&this.Ge()):(this.C=!0,this.vb&&v3(this)&&(2===a?this.i.Or():3===a&&this.i.Ap()))};
g.k.sM=function(a){if(a){for(a=0;a<this.stills.length;a++)this.G.eb(this.stills[a].element,!0);this.nz(1)}else this.B=null,this.C=!1;this.Ge()};
g.k.Xd=function(){return this.vb&&v3(this)};g.v(x3,g.aM);g.k=x3.prototype;g.k.Kp=function(){var a=this.player.getVideoData(),b=!!(a&&a.suggestions&&a.suggestions.length);b=!$Ha(this.player)||b;var c=a.Qd||g.LD(a.B),d=this.player.qt();a=a.mutedAutoplay;return b&&!c&&!d&&!a};
g.k.Xd=function(){return this.endScreen.Xd()};
g.k.PO=function(){return this.Xd()?this.endScreen.pH():!1};
g.k.oa=function(){this.player.Df("endscreen");g.aM.prototype.oa.call(this)};
g.k.load=function(){var a=this.player.getVideoData();var b=a.bF;if(b&&b.videoId){var c=this.player.ob().yd.get("heartbeat");a&&a.suggestions&&a.suggestions.length&&b.videoId===a.suggestions[0].id&&!a.ED?a=!1:(this.player.Oj(b.videoId,void 0,void 0,!0,!0,b),c&&c.Vw("HEARTBEAT_ACTION_TRIGGER_AT_STREAM_END","HEARTBEAT_ACTION_TRANSITION_REASON_HAS_NEW_STREAM_TRANSITION_ENDPOINT"),a=!0)}else a=!1;a||(g.aM.prototype.load.call(this),this.endScreen.show())};
g.k.unload=function(){g.aM.prototype.unload.call(this);this.endScreen.hide();this.endScreen.destroy()};
g.k.ge=function(a){this.Kp()&&(this.endScreen.created||this.endScreen.create(),"load"===a.getId()&&this.load())};
g.k.ag=function(a){"load"===a.getId()&&this.loaded&&this.unload()};
g.k.fb=function(){bIa(this);this.u&&aIa(this)&&(this.endScreen&&(this.endScreen.hide(),this.endScreen.created&&this.endScreen.destroy(),this.endScreen.dispose()),this.i?this.endScreen=new q3(this.player):this.endScreen=new u3(this.player),g.H(this,this.endScreen),g.RL(this.player,this.endScreen.element,4))};g.gM.endscreen=x3;})(_yt_player);
