define(["exports","./../../modules/common/globalize.js","./../../modules/dialoghelper/dialoghelper.js","./../../modules/emby-elements/emby-checkbox/emby-checkbox.js","./../../modules/emby-elements/emby-button/emby-button.js","./../../modules/emby-elements/emby-button/paper-icon-button-light.js","./../../modules/emby-elements/emby-select/emby-select.js","./../../modules/emby-elements/emby-input/emby-input.js"],function(_exports,_globalize,_dialoghelper,_embyCheckbox,_embyButton,_paperIconButtonLight,_embySelect,_embyInput){function findImageOptions(imageOptions,type){return imageOptions.filter(function(i){return i.Type===type})[0]}function getImageConfig(options,availableOptions,imageType){return findImageOptions(options.ImageOptions||[],imageType)||findImageOptions(availableOptions.DefaultImageOptions||[],imageType)||{Type:imageType,MinWidth:0,Limit:"Primary"===imageType?1:0}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_exports.default=function(){this.show=function(itemType,options,availableOptions){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest;xhr.open("GET","components/imageoptionseditor/imageoptionseditor.template.html",!0),xhr.onload=function(e){var template=this.response,dlg=_dialoghelper.default.createDialog({size:"medium-tall",removeOnClose:!0,scrollY:!1});dlg.classList.add("formDialog"),dlg.innerHTML=_globalize.default.translateDocument(template),dlg.addEventListener("close",function(){!function(context,options){options.ImageOptions=Array.prototype.map.call(context.querySelectorAll(".imageType:not(.hide)"),function(c){return{Type:c.getAttribute("data-imagetype"),Limit:c.checked?1:0,MinWidth:0}}),options.ImageOptions.push({Type:"Backdrop",Limit:context.querySelector("#txtMaxBackdrops").value,MinWidth:context.querySelector("#txtMinBackdropDownloadWidth").value})}(dlg,options)}),function(context,options,availableOptions){var supportedImageTypes=availableOptions.SupportedImageTypes||[],elem=(elem=context.querySelector(".backdropFields"),-1!==supportedImageTypes.indexOf("Backdrop")?(elem.classList.remove("hide"),elem.querySelector("input").setAttribute("required","required")):(elem.classList.add("hide"),elem.querySelector("input").setAttribute("required",""),elem.querySelector("input").removeAttribute("required")),Array.prototype.forEach.call(context.querySelectorAll(".imageType"),function(i){var imageType=i.getAttribute("data-imagetype"),container=i.closest("LABEL");-1===supportedImageTypes.indexOf(imageType)?container.classList.add("hide"):container.classList.remove("hide"),getImageConfig(options,availableOptions,imageType).Limit?i.checked=!0:i.checked=!1}),getImageConfig(options,availableOptions,"Backdrop"));context.querySelector("#txtMaxBackdrops").value=elem.Limit,context.querySelector("#txtMinBackdropDownloadWidth").value=elem.MinWidth}(dlg,options,availableOptions),_dialoghelper.default.open(dlg).then(resolve,resolve),dlg.querySelector(".btnCancel").addEventListener("click",function(){_dialoghelper.default.close(dlg)})},xhr.send()})}}});