define(["layoutManager","loading","datetime","libraryBrowser","cardBuilder","apphost","imageLoader","scrollStyles","emby-itemscontainer"],function(layoutManager,loading,datetime,libraryBrowser,cardBuilder,appHost,imageLoader){"use strict";function getUpcomingPromise(context,params){loading.show();var query={Limit:48,Fields:"AirTime,UserData",UserId:Dashboard.getCurrentUserId(),ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Banner,Thumb",EnableTotalRecordCount:!1};return query.ParentId=params.topParentId,ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming",query))}function loadUpcoming(context,params,promise){promise.then(function(result){var items=result.Items;items.length?context.querySelector(".noItemsMessage").style.display="none":context.querySelector(".noItemsMessage").style.display="block";var elem=context.querySelector("#upcomingItems");renderUpcoming(elem,items),loading.hide()})}function enableScrollX(){return!layoutManager.desktop}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");supportsImageAnalysis=!1,html+=cardBuilder.getCardsHtml({items:group.items,showLocationTypeIndicator:!1,shape:getThumbShape(),showTitle:!0,preferThumb:!0,lazy:!0,showDetailsMenu:!0,centerText:!supportsImageAnalysis,showParentTitle:!0,overlayText:!1,allowBottomPadding:allowBottomPadding,cardLayout:supportsImageAnalysis,vibrant:supportsImageAnalysis,overlayMoreButton:!0}),html+="
",html+="
"}elem.innerHTML=html,imageLoader.lazyChildren(elem)}return function(view,params,tabContent){var upcomingPromise,self=this;self.preRender=function(){upcomingPromise=getUpcomingPromise(view,params)},self.renderTab=function(){loadUpcoming(tabContent,params,upcomingPromise)}}});