define(["baseTab","loading","connectionManager","focusManager","homeSections","emby-itemscontainer"],function(BaseTab,loading,connectionManager,focusManager,homeSections){"use strict";function HomeTab(view,params){BaseTab.apply(this,arguments),this.view=view,this.params=params,this.apiClient=connectionManager.currentApiClient(),this.sectionsContainer=view.querySelector(".sections"),view.querySelector(".sections").addEventListener("settingschange",function(){this.sectionsRendered=!1,this.paused||this.onResume({refresh:!0})}.bind(this))}function autoFocus(){!focusManager.autoFocus(this.view)&&this.retries<20?(this.retries++,setTimeout(autoFocus.bind(this),100)):(this.view=null,this.retries=null)}return Object.assign(HomeTab.prototype,BaseTab.prototype),HomeTab.prototype.onResume=function(options){if(BaseTab.prototype.onResume.apply(this,arguments),this.sectionsRendered){var sectionsContainer=this.sectionsContainer;return sectionsContainer?homeSections.resume(sectionsContainer,options):Promise.resolve()}this.refresh(options)},HomeTab.prototype.refresh=function(options){loading.show();var view=this.view,apiClient=this.apiClient;return this.destroyHomeSections(),this.sectionsRendered=!0,apiClient.getCurrentUser().then(function(user){return homeSections.loadSections(view.querySelector(".sections"),apiClient,user).then(function(){var state;options.autoFocus&&(focusManager.autoFocus(view)||(state={retries:0,view:view},setTimeout(autoFocus.bind(state),100))),loading.hide()})})},HomeTab.prototype.onPause=function(){BaseTab.prototype.onPause.apply(this,arguments);var sectionsContainer=this.sectionsContainer;sectionsContainer&&homeSections.pause(sectionsContainer)},HomeTab.prototype.destroy=function(){BaseTab.prototype.destroy.apply(this,arguments),this.view=null,this.params=null,this.apiClient=null,this.destroyHomeSections(),this.sectionsContainer=null},HomeTab.prototype.destroyHomeSections=function(){var sectionsContainer=this.sectionsContainer;sectionsContainer&&(sectionsContainer.innerHTML="")},HomeTab});