define(["tabbedView","registrationServices","require","globalize","userSettings","emby-itemscontainer","emby-tabs","emby-button","emby-scroller","emby-linkbutton"],function(TabbedView,registrationServices,require,globalize,userSettings){"use strict";function hideShowAll(view,className,hide){for(var elems=view.querySelectorAll("."+className),i=0,length=elems.length;i<length;i++)hide?elems[i].classList.add("hide"):elems[i].classList.remove("hide")}function validateUnlock(view,showDialog){return registrationServices.validateFeature("livetv",{showDialog:showDialog,viewOnly:!0}).then(function(){hideShowAll(view,"liveTvContainer",!1),view.querySelector(".unlockContainer").classList.add("hide")},function(){hideShowAll(view,"liveTvContainer",!0),view.querySelector(".unlockContainer").classList.remove("hide"),view.querySelector(".btnUnlock").focus()})}function LiveTVView(view,params){TabbedView.call(this,view,params),view.querySelector(".unlockText").innerHTML=globalize.translate("LiveTvRequiresUnlock"),view.querySelector(".btnUnlockText").innerHTML=globalize.translate("HeaderBecomeProjectSupporter"),validateUnlock(view,!1),view.querySelector(".btnUnlock").addEventListener("click",function(){validateUnlock(view,!0)})}return Object.assign(LiveTVView.prototype,TabbedView.prototype),LiveTVView.prototype.getTabs=function(){return[{name:globalize.translate("Programs")},{name:globalize.translate("Guide")},{name:globalize.translate("Channels")},{name:globalize.translate("Recordings")},{name:globalize.translate("Schedule")},{name:globalize.translate("Series")}]},LiveTVView.prototype.getDefaultTabIndex=function(folderId){switch(userSettings.get("landing-livetv")){case"channels":return 2;case"guide":return 1;default:return 0}},LiveTVView.prototype.getTabController=function(index){if(null==index)throw new Error("index cannot be null");var depends=[];switch(index){case 0:depends.push("./suggestions");break;case 1:depends.push("./guide");break;case 2:depends.push("./channels");break;case 3:depends.push("./recordings");break;case 4:depends.push("./schedule");break;case 5:depends.push("./series")}var instance=this;return function(deps){return new Promise(function(resolve,reject){require(deps,resolve)})}(depends).then(function(controllerFactory){var controller=instance.tabControllers[index];controller||(controller=new controllerFactory(instance.view.querySelector(".tabContent[data-index='"+index+"']"),instance.params),instance.tabControllers[index]=controller);return controller})},LiveTVView.prototype.validateTabLoad=function(index){return validateUnlock(this.view,!1)},LiveTVView.prototype.getTitle=function(){return{Name:globalize.translate("LiveTV"),CollectionType:"livetv",Id:"livetv",ServerId:this.params.serverId}},LiveTVView});