define(["apphost","connectionManager","listViewStyle","emby-linkbutton","emby-select"],function(appHost,connectionManager){"use strict";function updateUserImage(view,user,apiClient){var fldImage=view.querySelector(".userImage");if(user.PrimaryImageTag){var imageUrl=apiClient.getUserImageUrl(user.Id,{width:200,tag:user.PrimaryImageTag,type:"Primary"});fldImage.innerHTML="<img style='width:7em;border-radius:.2em;' src='"+imageUrl+"' />"}else fldImage.innerHTML='<i class="md-icon defaultCardBackground0" style="font-size:7em;">&#xe7fd;</i>';fldImage.classList.remove("hide")}return function(view,params){view.querySelector(".btnLogout").addEventListener("click",function(){Dashboard.logout()}),view.addEventListener("viewshow",function(){var page=this,apiClient=window.ApiClient,userId=params.userId||(apiClient?apiClient.getCurrentUserId():"");page.querySelector(".lnkDisplayPreferences").setAttribute("href","mypreferencesdisplay.html?userId="+userId),page.querySelector(".lnkLanguagePreferences").setAttribute("href","mypreferenceslanguages.html?userId="+userId),page.querySelector(".lnkSubtitleSettings").setAttribute("href","mypreferencessubtitles.html?userId="+userId),page.querySelector(".lnkHomeScreenPreferences").setAttribute("href","mypreferenceshome.html?userId="+userId),page.querySelector(".lnkMyProfile").setAttribute("href","myprofile.html?userId="+userId),page.querySelector(".lnkSync").setAttribute("href","mysyncsettings.html?userId="+userId),page.querySelector(".lnkCameraUpload").setAttribute("href","camerauploadsettings.html?userId="+userId),appHost.supports("cameraupload")?page.querySelector(".lnkCameraUpload").classList.remove("hide"):page.querySelector(".lnkCameraUpload").classList.add("hide"),appHost.supports("sync")?page.querySelector(".lnkSync").classList.remove("hide"):page.querySelector(".lnkSync").classList.add("hide"),apiClient.getCurrentUser().then(function(user){!user.EnableAutoLogin||connectionManager.isLoggedIntoConnect()?view.querySelector(".loginSection").classList.remove("hide"):view.querySelector(".loginSection").classList.add("hide"),user.Policy.IsAdministrator?page.querySelector(".adminSection").classList.remove("hide"):page.querySelector(".adminSection").classList.add("hide")}),apiClient.getUser(userId).then(function(user){page.querySelector(".headerUser").innerHTML=user.Name,updateUserImage(page,user,apiClient)}),appHost.supports("multiserver")?page.querySelector(".selectServer").classList.remove("hide"):page.querySelector(".selectServer").classList.add("hide")})}});