define(["datetime","cardBuilder","apphost","imageLoader","emby-itemscontainer","scrollStyles"],function(datetime,cardBuilder,appHost,imageLoader){"use strict";function getUpcomingPromise(){Dashboard.showLoadingMsg();var query={Limit:40,Fields:"AirTime,UserData",UserId:Dashboard.getCurrentUserId(),ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Banner,Thumb",EnableTotalRecordCount:!1};return ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming",query))}function loadUpcoming(page,promise){promise.then(function(result){var items=result.Items;items.length?page.querySelector(".noItemsMessage").style.display="none":page.querySelector(".noItemsMessage").style.display="block";var elem=page.querySelector("#upcomingItems");renderUpcoming(elem,items),Dashboard.hideLoadingMsg()})}function enableScrollX(){return browserInfo.mobile}function getThumbShape(){return enableScrollX()?"overflowBackdrop":"backdrop"}function renderUpcoming(elem,items){var i,length,groups=[],currentGroupName="",currentGroup=[];for(i=0,length=items.length;i',html+='

'+group.name+"

";var allowBottomPadding=!0;enableScrollX()?(allowBottomPadding=!1,html+='
'):html+='
';var supportsImageAnalysis=appHost.supports("imageanalysis");html+=cardBuilder.getCardsHtml({items:group.items,showLocationTypeIndicator:!1,shape:getThumbShape(),showTitle:!0,preferThumb:!0,lazy:!0,showDetailsMenu:!0,centerText:!supportsImageAnalysis,context:"home-upcoming",overlayMoreButton:!supportsImageAnalysis,showParentTitle:!0,allowBottomPadding:allowBottomPadding,cardLayout:supportsImageAnalysis,vibrant:supportsImageAnalysis}),html+="
",html+="
"}elem.innerHTML=html,imageLoader.lazyChildren(elem)}return function(view,params,tabContent){var upcomingPromise,self=this;self.preRender=function(){upcomingPromise=getUpcomingPromise()},self.renderTab=function(){Dashboard.showLoadingMsg(),loadUpcoming(view,upcomingPromise)}}});