define(["require","globalize","loading","connectionManager","homeSections","dom","events","listViewStyle","emby-select","emby-checkbox"],function(require,globalize,loading,connectionManager,homeSections,dom,events){"use strict";function renderLatestItems(context,user,result){var folderHtml="";folderHtml+='
';var excludeViewTypes=["playlists","livetv","boxsets","channels"],excludeItemTypes=["Channel"];folderHtml+=result.Items.map(function(i){if(excludeViewTypes.indexOf(i.CollectionType||[])!==-1)return"";if(excludeItemTypes.indexOf(i.Type)!==-1)return"";var currentHtml="",id="chkIncludeInLatest"+i.Id,isChecked=user.Configuration.LatestItemsExcludes.indexOf(i.Id)===-1,checkedHtml=isChecked?' checked="checked"':"";return currentHtml+=""}).join(""),folderHtml+="
",context.querySelector(".latestItemsList").innerHTML=folderHtml}function renderViews(page,user,result){var folderHtml="";folderHtml+='
',folderHtml+=result.map(function(i){var currentHtml="",id="chkGroupFolder"+i.Id,isChecked=user.Configuration.GroupedFolders.indexOf(i.Id)!==-1,checkedHtml=isChecked?' checked="checked"':"";return currentHtml+=""}).join(""),folderHtml+="
",page.querySelector(".folderGroupList").innerHTML=folderHtml}function getLandingScreenOptions(type){var list=[];return"movies"===type?(list.push({name:globalize.translate("sharedcomponents#Movies"),value:"movies",isDefault:!0}),list.push({name:globalize.translate("sharedcomponents#Suggestions"),value:"suggestions"}),list.push({name:globalize.translate("sharedcomponents#Favorites"),value:"favorites"}),list.push({name:globalize.translate("sharedcomponents#Collections"),value:"collections"})):"tvshows"===type&&(list.push({name:globalize.translate("sharedcomponents#Suggestions"),value:"suggestions",isDefault:!0}),list.push({name:globalize.translate("sharedcomponents#Latest"),value:"latest"}),list.push({name:globalize.translate("sharedcomponents#Shows"),value:"shows"}),list.push({name:globalize.translate("sharedcomponents#Favorites"),value:"favorites"})),list.push({name:globalize.translate("sharedcomponents#Genres"),value:"genres"}),list}function getLandingScreenOptionsHtml(type,userValue){return getLandingScreenOptions(type).map(function(o){var selected=userValue===o.value||o.isDefault&&!userValue,selectedHtml=selected?" selected":"",optionValue=o.isDefault?"":o.value;return'"}).join("")}function renderLandingScreens(context,user,userSettings,result){for(var html="",i=0,length=result.Items.length;i',html+='",html+=""}}context.querySelector(".landingScreens").innerHTML=html,html?context.querySelector(".landingScreensSection").classList.remove("hide"):context.querySelector(".landingScreensSection").classList.add("hide")}function renderViewOrder(context,user,result){var html="",index=0;html+=result.Items.map(function(view){var currentHtml="";return currentHtml+='
',currentHtml+='',currentHtml+='
',currentHtml+="
",currentHtml+=view.Name,currentHtml+="
",currentHtml+="
",currentHtml+='',currentHtml+='',currentHtml+="
",index++,currentHtml}).join(""),context.querySelector(".viewOrderList").innerHTML=html}function updateHomeSectionValues(context,userSettings){for(var i=1;i<=7;i++){var select=context.querySelector("#selectHomeSection"+i),defaultValue=homeSections.getDefaultSection(i-1),option=select.querySelector("option[value="+defaultValue+"]")||select.querySelector('option[value=""]'),userValue=userSettings.get("homesection"+(i-1));option.value="",userValue!==defaultValue&&userValue?select.value=userValue:select.value=""}}function loadForm(context,user,userSettings,apiClient){context.querySelector(".chkHidePlayedFromLatest").checked=user.Configuration.HidePlayedInLatest||!1,updateHomeSectionValues(context,userSettings);var promise1=apiClient.getUserViews({},user.Id),promise2=apiClient.getJSON(apiClient.getUrl("Users/"+user.Id+"/GroupingOptions"));Promise.all([promise1,promise2]).then(function(responses){renderViews(context,user,responses[1]),renderLatestItems(context,user,responses[0]),renderViewOrder(context,user,responses[0]),renderLandingScreens(context,user,userSettings,responses[0]),loading.hide()})}function onSectionOrderListClick(e){var target=dom.parentWithClass(e.target,"btnViewItemMove");if(target){var viewItem=dom.parentWithClass(target,"viewItem");if(viewItem){dom.parentWithClass(viewItem,"paperList");if(target.classList.contains("btnViewItemDown")){var next=viewItem.nextSibling;next&&(viewItem.parentNode.removeChild(viewItem),next.parentNode.insertBefore(viewItem,next.nextSibling))}else{var prev=viewItem.previousSibling;prev&&(viewItem.parentNode.removeChild(viewItem),prev.parentNode.insertBefore(viewItem,prev))}}}}function getCheckboxItems(selector,context,isChecked){for(var inputs=context.querySelectorAll(selector),list=[],i=0,length=inputs.length;i