define(["baseTab","cardBuilder","connectionManager","layoutManager","focusManager","emby-itemscontainer"],function(BaseTab,cardBuilder,connectionManager,layoutManager,focusManager){"use strict";function TvFavoritesTab(view,params){BaseTab.apply(this,arguments),this.view=view,this.params=params,this.apiClient=connectionManager.getApiClient(params.serverId);var seriesItemsContainer=view.querySelector(".seriesItems");seriesItemsContainer.getListOptions=getSeriesListOptions,seriesItemsContainer.fetchData=function(items){var apiClient=this.apiClient,parentId=this.params.parentId;return apiClient.getItems(apiClient.getCurrentUserId(),{SortBy:"SortName",SortOrder:"Ascending",IncludeItemTypes:"Series",Recursive:!0,Fields:"PrimaryImageAspectRatio,BasicSyncInfo",ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Thumb",StartIndex:0,parentId:parentId,IsFavorite:!0})}.bind(this),seriesItemsContainer.parentContainer=view.querySelector(".favoriteSeriesSection"),this.seriesItemsContainer=seriesItemsContainer;var episodeItemsContainer=view.querySelector(".episodeItems");episodeItemsContainer.getListOptions=getEpisodesListOptions,episodeItemsContainer.fetchData=function(items){var apiClient=this.apiClient,parentId=this.params.parentId;return apiClient.getItems(apiClient.getCurrentUserId(),{SortBy:"SeriesName,SortName",SortOrder:"Ascending",IncludeItemTypes:"Episode",Recursive:!0,Fields:"PrimaryImageAspectRatio,BasicSyncInfo",ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Thumb",StartIndex:0,parentId:parentId,IsFavorite:!0})}.bind(this),episodeItemsContainer.parentContainer=view.querySelector(".favoriteEpisodesSection"),this.episodeItemsContainer=episodeItemsContainer,params.parentId&&(this.seriesItemsContainer.setAttribute("data-parentid",params.parentId),this.episodeItemsContainer.setAttribute("data-parentid",params.parentId))}function getSeriesListOptions(items){return{renderer:cardBuilder,options:{shape:"auto",centerText:!0,fields:["Name"]},virtualScrollLayout:"vertical-grid"}}function getEpisodesListOptions(items){return{renderer:cardBuilder,options:{shape:"auto",fields:["Name"],showParentTitle:!0,overlayText:!1,centerText:!0},virtualScrollLayout:"vertical-grid"}}return Object.assign(TvFavoritesTab.prototype,BaseTab.prototype),TvFavoritesTab.prototype.onResume=function(options){BaseTab.prototype.onResume.apply(this,arguments);var promises,view;this.apiClient;options.refresh&&(promises=[],this.params.parentId,promises.push(this.seriesItemsContainer.resume(options)),promises.push(this.episodeItemsContainer.resume(options)),view=this.view,Promise.all(promises).then(function(){options.autoFocus&&focusManager.autoFocus(view)}))},TvFavoritesTab.prototype.onPause=function(){BaseTab.prototype.onPause.apply(this,arguments);var seriesItemsContainer=this.seriesItemsContainer;seriesItemsContainer&&seriesItemsContainer.pause&&seriesItemsContainer.pause();var episodeItemsContainer=this.episodeItemsContainer;episodeItemsContainer&&episodeItemsContainer.pause&&episodeItemsContainer.pause()},TvFavoritesTab.prototype.destroy=function(){BaseTab.prototype.destroy.apply(this,arguments),this.view=null,this.params=null,this.apiClient=null,this.seriesItemsContainer=null,this.episodeItemsContainer=null},TvFavoritesTab});