define(["exports","./../../common/globalize.js","./../../layoutmanager.js","./../../common/usersettings/usersettings.js","./../../dialoghelper/dialoghelper.js","./../emby-scroller/emby-scroller.js","./../emby-checkbox/emby-checkbox.js","./../emby-select/emby-select.js"],function(_exports,_globalize,_layoutmanager,_usersettings,_dialoghelper,_embyScroller,_embyCheckbox,_embySelect){function load(context){for(var chkIndicators=context.querySelectorAll(".chkIndicator"),i=0,length=chkIndicators.length;i<length;i++){var type=chkIndicators[i].getAttribute("data-type");"true"===chkIndicators[i].getAttribute("data-default")?chkIndicators[i].checked="false"!==_usersettings.default.get("guide-indicator-"+type):chkIndicators[i].checked="true"===_usersettings.default.get("guide-indicator-"+type)}context.querySelector(".chkColorCodedBackgrounds").checked="true"===_usersettings.default.get("guide-colorcodedbackgrounds"),context.querySelector(".chkChannelNumber").checked=_usersettings.default.showChannelNumberInGuide(),context.querySelector(".selectChannelDisplay").value=_usersettings.default.guideChannelStyle(),function(context){for(var value,items=_usersettings.default.getLiveTvChannelSortOrders(_globalize.default),html="",i=0,length=items.length;i<length;i++){var item=items[i];html+='<option value="'+item.value+'">'+item.name+"</option>",item.selected&&(value=item.value)}(context=context.querySelector(".selectChannelSort")).innerHTML=html,context.value=value}(context)}function loadChannelTags(context,apiClient){var selectTags=context.querySelector(".selectTags");selectTags.getItems=function(query){var outerItemIds=query.Ids;return query.Ids=null,this.getLiveTvChannelTags(Object.assign({SortBy:"SortName",SortOrder:"Ascending",EnableImages:!1,EnableUserData:!1,OuterIds:outerItemIds},query))}.bind(apiClient),selectTags.parentContainer=context.querySelector(".fldTags"),function(context){var context=context.querySelector(".selectTags"),channelTagIds=(channelTagIds=_usersettings.default.get("guide-tagids"))?channelTagIds.split(","):[];context.values=channelTagIds}(context)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["formDialogStyle","material-icons"]),_exports.default={show:function(options,apiClient){return new Promise(function(resolve,reject){var settingsChanged=!1,categoryOptions=options.categoryOptions;require(["text!modules/emby-elements/guide/guide-settings.template.html"],function(template){var dialogOptions={removeOnClose:!0,scrollY:!1,offsetTop:2,positionTo:options.positionTo,positionX:options.positionX,positionY:options.positionY},dlg=(_layoutmanager.default.tv&&(dialogOptions.size="fullscreen"),_dialoghelper.default.createDialog(dialogOptions)),dialogOptions=(_layoutmanager.default.tv||dlg.classList.add("dialog-fullscreen-lowres"),dlg.classList.add("formDialog"),""),template=(dialogOptions+=_globalize.default.translateDocument(template,"sharedcomponents"),dlg.innerHTML=dialogOptions,dlg.addEventListener("change",function(){settingsChanged=!0}),dlg.addEventListener("close",function(){!function(context){for(var chkIndicators=context.querySelectorAll(".chkIndicator"),i=0,length=chkIndicators.length;i<length;i++){var type=chkIndicators[i].getAttribute("data-type");_usersettings.default.set("guide-indicator-"+type,chkIndicators[i].checked)}_usersettings.default.showChannelNumberInGuide(context.querySelector(".chkChannelNumber").checked),_usersettings.default.guideChannelStyle(context.querySelector(".selectChannelDisplay").value),_usersettings.default.set("guide-colorcodedbackgrounds",context.querySelector(".chkColorCodedBackgrounds").checked),_usersettings.default.set(_usersettings.default.getLiveTvChannelSortSettingsKey(),context.querySelector(".selectChannelSort").value),_usersettings.default.set("guide-tagids",context.querySelector(".selectTags").getValues().join(","))}(dlg);for(var options=categoryOptions,categories=[],chkCategorys=dlg.querySelectorAll(".chkCategory"),i=0,length=chkCategorys.length;i<length;i++){var type=chkCategorys[i].getAttribute("data-type");chkCategorys[i].checked&&categories.push(type)}4<=categories.length&&categories.push("series"),categories.push("all"),options.categories=categories,(settingsChanged?resolve:reject)()}),dlg.querySelector(".btnCancel"));_layoutmanager.default.tv||template.classList.add("dialogbutton-hidenotfullscreen"),template.addEventListener("click",function(){_dialoghelper.default.close(dlg)}),load(dlg),loadChannelTags(dlg,apiClient),function(context,options){for(var selectedCategories=options.categories||[],chkCategorys=context.querySelectorAll(".chkCategory"),i=0,length=chkCategorys.length;i<length;i++){var type=chkCategorys[i].getAttribute("data-type");chkCategorys[i].checked=!selectedCategories.length||selectedCategories.includes(type)}}(dlg,categoryOptions),_dialoghelper.default.open(dlg)})})}}});