define(["layoutManager","events","viewManager","libraryBrowser","embyRouter","apphost","playbackManager","browser","appfooter-shared","dockedtabs","paper-icon-button-light","material-icons","scrollStyles","flexStyles"],function(layoutManager,events,viewManager,libraryBrowser,embyRouter,appHost,playbackManager,browser,appFooter,DockedTabs){"use strict";function renderHeader(){var html="";html+='
",html+='",skinHeader.innerHTML=html,browser.chrome||skinHeader.classList.add("skinHeader-blurred"),lazyLoadViewMenuBarImages(),bindMenuEvents()}function lazyLoadViewMenuBarImages(){require(["imageLoader"],function(imageLoader){imageLoader.lazyChildren(skinHeader)})}function onBackClick(){embyRouter.back()}function updateUserInHeader(user){var hasImage,headerUserButton=skinHeader.querySelector(".headerUserButton");if(user&&user.name&&user.imageUrl){var userButtonHeight=26,url=user.imageUrl;user.supportsImageParams&&(url+="&height="+Math.round(userButtonHeight*Math.max(window.devicePixelRatio||1,2))),headerUserButton&&(updateHeaderUserButton(headerUserButton,url),hasImage=!0)}headerUserButton&&!hasImage&&updateHeaderUserButton(headerUserButton,null),user&&updateLocalUser(user.localUser),requiresUserRefresh=!1}function updateHeaderUserButton(headerUserButton,src){src?(headerUserButton.classList.add("headerUserButtonRound"),headerUserButton.classList.remove("autoSize"),headerUserButton.innerHTML=''):(headerUserButton.classList.remove("headerUserButtonRound"),headerUserButton.classList.add("autoSize"),headerUserButton.innerHTML='person')}function updateLocalUser(user){var headerSearchButton=skinHeader.querySelector(".headerSearchButton"),btnCast=skinHeader.querySelector(".btnCast"),dashboardEntryHeaderButton=skinHeader.querySelector(".dashboardEntryHeaderButton");user?(btnCast.classList.remove("hide"),headerSearchButton&&headerSearchButton.classList.remove("hide"),dashboardEntryHeaderButton&&(user.Policy.IsAdministrator?dashboardEntryHeaderButton.classList.remove("hide"):dashboardEntryHeaderButton.classList.add("hide"))):(btnCast.classList.add("hide"),headerSearchButton&&headerSearchButton.classList.add("hide"),dashboardEntryHeaderButton&&dashboardEntryHeaderButton.classList.add("hide"))}function showSearch(){Dashboard.navigate("search.html")}function onHeaderUserButtonClick(e){Dashboard.showUserFlyout(e.target)}function onHeaderAppsButtonClick(){Dashboard.navigate("home.html")}function bindMenuEvents(){mainDrawerButton=document.querySelector(".mainDrawerButton"),mainDrawerButton&&mainDrawerButton.addEventListener("click",toggleMainDrawer);var headerBackButton=document.querySelector(".headerBackButton");headerBackButton&&headerBackButton.addEventListener("click",onBackClick);var headerSearchButton=document.querySelector(".headerSearchButton");headerSearchButton&&headerSearchButton.addEventListener("click",showSearch);var headerUserButton=document.querySelector(".headerUserButton");headerUserButton&&headerUserButton.addEventListener("click",onHeaderUserButtonClick);var headerAppsButton=document.querySelector(".headerAppsButton");headerAppsButton&&headerAppsButton.addEventListener("click",onHeaderAppsButtonClick),initHeadRoom(skinHeader),skinHeader.querySelector(".btnNotifications").addEventListener("click",function(){Dashboard.navigate("notificationlist.html")});var btnCast=document.querySelector(".headerButton-btnCast");btnCast&&btnCast.addEventListener("click",onCastButtonClicked)}function onCastButtonClicked(){var btn=this;require(["playerSelectionMenu"],function(playerSelectionMenu){playerSelectionMenu.show(btn)})}function getItemHref(item,context){return embyRouter.getRouteUrl(item,{context:context})}function toggleMainDrawer(){navDrawerInstance.isVisible?closeMainDrawer():openMainDrawer()}function openMainDrawer(){navDrawerInstance.open(),lastOpenTime=(new Date).getTime()}function onMainDrawerOpened(){layoutManager.mobile&&document.body.classList.add("bodyWithPopupOpen")}function closeMainDrawer(){navDrawerInstance.close()}function onMainDrawerSelect(e){navDrawerInstance.isVisible?onMainDrawerOpened():document.body.classList.remove("bodyWithPopupOpen")}function refreshLibraryInfoInDrawer(user,drawer){var html="";html+='';var homeHref=window.ApiClient?"home.html":"selectserver.html?showuser=1";html+='",html+='",html+='',html+='";var localUser=user.localUser;localUser&&localUser.Policy.IsAdministrator&&(html+='"),html+='",navDrawerScrollContainer.innerHTML=html;var lnkManageServer=navDrawerScrollContainer.querySelector(".lnkManageServer");lnkManageServer&&lnkManageServer.addEventListener("click",onManageServerClicked)}function refreshDashboardInfoInDrawer(page,user){loadNavDrawer(),navDrawerScrollContainer.querySelector(".adminDrawerLogo")?updateDashboardMenuSelectedItem():createDashboardMenu(page)}function updateDashboardMenuSelectedItem(){for(var links=navDrawerScrollContainer.querySelectorAll(".sidebarLink"),i=0,length=links.length;i',html+='',html+="",html+=Dashboard.getToolsMenuHtml(),html=html.split("href=").join('onclick="return LibraryMenu.onLinkClicked(event, this);" href='),navDrawerScrollContainer.innerHTML=html,updateDashboardMenuSelectedItem()}function onSidebarLinkClick(){var section=this.getElementsByClassName("sectionName")[0],text=section?section.innerHTML:this.innerHTML;LibraryMenu.setTitle(text)}function getUserViews(apiClient,userId){return apiClient.getUserViews({},userId).then(function(result){for(var items=result.Items,list=[],i=0,length=items.length;i