define(["exports","./../modules/tabbedview/basetab.js","./../modules/common/globalize.js","./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/tabbedview/sectionscontroller.js"],function(_exports,_basetab,_globalize,_embyItemscontainer,_embyButton,_embyScroller,_sectionscontroller){function LiveTvSuggestionsTab(view,params){_basetab.default.apply(this,arguments),_sectionscontroller.default.apply(this,arguments),this.view=view,this.params=params}function onAddRecordingClick(e){var instance=this;return Emby.importModule("./modules/recordingcreator/channelrecordingcreator.js").then(function(channelRecordingCreator){return channelRecordingCreator.createRecordingForChannel(null,{serverId:instance.getApiClient().serverId(),positionTo:e.target.closest("button")})})}function getListOptions(options){return Object.assign({preferThumb:"auto",inheritThumb:!1,shape:"auto",centerText:!0,programsAsSeries:!0},options)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(LiveTvSuggestionsTab.prototype,_basetab.default.prototype),Object.assign(LiveTvSuggestionsTab.prototype,_sectionscontroller.default.prototype),LiveTvSuggestionsTab.prototype.fetchSections=function(){var sections=[],serverId=this.serverId(),enableFocusPreview=this.enableFocusPreview(),supportsGrouping=this.getApiClient().isMinServerVersion("4.9.1.32");return sections.push({Id:"Buttons",CollectionType:"livetv",ViewType:"content",Monitor:[],ContentButtons:[{Name:_globalize.default.translate("HeaderAddRecording"),Icon:"add",OnClick:onAddRecordingClick.bind(this)}],CenterContentButtons:!0}),sections.push({Id:"LatestRecordings",Name:_globalize.default.translate("HeaderLatestRecordings"),CollectionType:"livetv",SectionType:"recordings",Monitor:[],RefreshInterval:3e5,ListOptions:getListOptions({fields:enableFocusPreview?[]:["Name","ParentName","ChannelName","AirTime"],preferThumb:"auto",showAirEndTime:!0}),QueryOptions:{GroupItems:!1,SortBy:"DateCreated",SortOrder:"Descending"},CommandOptions:{}}),supportsGrouping&&sections.push({Id:"AllRecordings",Name:_globalize.default.translate("HeaderAllRecordings"),CollectionType:"livetv",SectionType:"recordings",Monitor:[],ListOptions:getListOptions({fields:enableFocusPreview?[]:["ParentName","Name","ProductionYear","ChannelName","AirTime"]}),QueryOptions:{GroupItems:!0,SortBy:"DateLastContentAdded,SortName",SortOrder:"Descending"},Href:"list/list.html?type=Recordings&GroupItems=true&serverId="+serverId}),Promise.resolve(sections)},LiveTvSuggestionsTab.prototype.onTemplateLoaded1=function(){_basetab.default.prototype.onTemplateLoaded.apply(this,arguments);var elem=this.view.querySelector(".listTotalRecordCount"),html=(html=(html=(html="")+'<button is="emby-button" class="itemsViewSettingsContainer-button btnCreateRecording raised raised-mini listTextButton-autohide hide">'+'<i class="md-icon button-icon button-icon-left">&#xe145;</i>')+("<span>"+_globalize.default.translate("HeaderAddRecording")+"</span>")+"</button>")+('<button title="'+_globalize.default.translate("HeaderAddRecording")+'" is="paper-icon-button-light" class="itemsViewSettingsContainer-button btnCreateRecording listIconButton-autohide hide">');elem.insertAdjacentHTML("afterend",html=html+'<i class="md-icon autortl">&#xe145;</i>'+"</button>"),function(instance){for(var btnCreateRecordings=instance.view.querySelectorAll(".btnCreateRecording"),boundOnAddRecordingClick=onAddRecordingClick.bind(instance),i=0,length=btnCreateRecordings.length;i<length;i++)btnCreateRecordings[i].addEventListener("click",boundOnAddRecordingClick)}(this),this.itemsContainer.setAttribute("data-monitor","RecordingStarted,RecordingEnded"),this.getApiClient().getCurrentUser().then(function(user){for(var btnCreateRecordings=elem.parentNode.querySelectorAll(".btnCreateRecording"),i=0,length=btnCreateRecordings.length;i<length;i++)user.Policy.EnableLiveTvManagement?btnCreateRecordings[i].classList.remove("hide"):btnCreateRecordings[i].classList.add("hide")})},LiveTvSuggestionsTab.prototype.onResume=function(options){return _basetab.default.prototype.onResume.apply(this,arguments),_sectionscontroller.default.prototype.onResume.apply(this,arguments)},LiveTvSuggestionsTab.prototype.onPause=function(){_basetab.default.prototype.onPause.apply(this,arguments),_sectionscontroller.default.prototype.onPause.apply(this,arguments)},LiveTvSuggestionsTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),_sectionscontroller.default.prototype.destroy.apply(this,arguments)};_exports.default=LiveTvSuggestionsTab});