define(["exports","./../modules/common/playback/playbackmanager.js","./../modules/cardbuilder/cardbuilder.js"],function(_exports,_playbackmanager,_cardbuilder){function scrollOrFocus(instance,focus){var playlistIndex=_playbackmanager.default.getCurrentPlaylistIndex(instance.currentPlayer);instance.itemsContainer.scrollToIndex(playlistIndex=-1===playlistIndex?0:playlistIndex,{},focus)}function OsdPlayQueue(options){options=(this.options=options).parent;!function(parent){parent.innerHTML='<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale tvPlayQueueScroller" data-mousewheel="false" data-focusscroll="true"><div is="emby-itemscontainer" class="scrollSlider focuscontainer-x padded-left padded-right itemsContainer focusable" data-skipplaycommands="true" data-virtualscrolllayout="horizontal-grid"></div></div>'}(options),this.playlistElement=options.querySelector(".osdPlaylist"),this.itemsContainer=options.querySelector(".itemsContainer"),this.itemsContainer.fetchData=function(query){return this.empty||!this.currentPlayer?Promise.resolve({Items:[],TotalRecordCount:0}):_playbackmanager.default.getPlaylist(query||{},this.currentPlayer)}.bind(this),this.itemsContainer.getListOptions=function(items){return{renderer:_cardbuilder.default,options:{action:"setplaylistindex",playAction:"setplaylistindex",shape:"autooverflow",fields:["ParentName","Name","ProductionYear"],lines:2,centerText:!0,cardLayout:!1,cardClass:"tvPlayQueueCard",playQueueIndicator:!0,allowBottomPadding:!1},virtualScrollLayout:"horizontal-grid"}}.bind(this),this.itemsContainer.afterRefresh=function(){var focus=this.itemsContainer.contains(document.activeElement);scrollOrFocus(this,focus)}.bind(this),this.itemsContainer.focus=function(){scrollOrFocus(this,!0)}.bind(this),this.itemsContainer.scrollResizeObserver=!0}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["css!videoosd/tvplayqueue.css"]),OsdPlayQueue.prototype.setPausedState=function(paused){var elem=this.options.parent.querySelector(".activePlaylistCardBox");elem&&(paused?elem.classList.add("paused"):elem.classList.remove("paused"))},OsdPlayQueue.prototype.updatePlaylist=function(player,playlistItemId,playlistIndex,playlistLength){this.currentPlayer=player,this.empty=!playlistLength,this.refreshItems()},OsdPlayQueue.prototype.onPlaybackStopped=function(){this.empty=!0,this.refreshItems()},OsdPlayQueue.prototype.refreshItems=function(){var itemsContainer=this.itemsContainer;itemsContainer&&(itemsContainer.refreshItems?itemsContainer.refreshItems():setTimeout(this.refreshItems.bind(this),100))},OsdPlayQueue.prototype.onPlaylistItemMoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.onPlaylistItemRemoved=function(player,e,info){this.itemsContainer.refreshItems()},OsdPlayQueue.prototype.pause=function(){this.paused=!0,this.itemsContainer.pause&&this.itemsContainer.pause()},OsdPlayQueue.prototype.updateRepeatModeDisplay=function(repeatMode){},OsdPlayQueue.prototype.resume=function(options){return this.paused=!1,this.itemsContainer.resume?this.itemsContainer.resume():(this.itemsContainer.addEventListener("upgraded",function(e){e.target.resume(this)}.bind(options)),Promise.resolve())},OsdPlayQueue.prototype.destroy=function(){var options=this.options;options&&(options=options.parent)&&(options.innerHTML=""),this.options=null,this.currentPlayer=null,this.itemsContainer=null},_exports.default=OsdPlayQueue});