define(["exports","./../dialoghelper/dialoghelper.js","./../layoutmanager.js","./../common/globalize.js","./../loading/loading.js","./../emby-apiclient/connectionmanager.js","./../emby-elements/emby-toggle/emby-toggle.js","./../emby-elements/emby-select/emby-select.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-button/paper-icon-button-light.js","./../emby-elements/emby-scroller/emby-scroller.js","./../emby-elements/emby-dialogclosebutton/emby-dialogclosebutton.js"],function(_exports,_dialoghelper,_layoutmanager,_globalize,_loading,_connectionmanager,_embyToggle,_embySelect,_embyButton,_paperIconButtonLight,_embyScroller,_embyDialogclosebutton){function onSubmit(e){_loading.default.show();var dlg=e.target.closest(".dialog"),options=this.options,replaceAllMetadata="all"===dlg.querySelector(".selectMetadataRefreshMode").value,mode="FullRefresh",replaceAllImages=dlg.querySelector(".chkReplaceImages").checked,options=options.items;return _connectionmanager.default.getApiClient(options[0]).refreshItems(options,{Recursive:!0,ImageRefreshMode:mode,MetadataRefreshMode:mode,ReplaceAllImages:replaceAllImages,ReplaceAllMetadata:replaceAllMetadata}),_dialoghelper.default.close(dlg),function(options){Emby.importModule("./modules/toast/toast.js").then(function(toast){return toast(options)})}(_globalize.default.translate("RefreshingMetadataDots")),_loading.default.hide(),e.preventDefault(),!1}function RefreshDialog(options){this.options=options}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons","formDialogStyle","flexStyles"]),RefreshDialog.prototype.show=function(){var dialogOptions={removeOnClose:!0,scrollY:!1},dlg=(_layoutmanager.default.tv?dialogOptions.size="fullscreen":dialogOptions.size="small",_dialoghelper.default.createDialog(dialogOptions));dlg.classList.add("formDialog");dialogOptions=(dialogOptions=(dialogOptions='<div class="formDialogHeader"><button type="button" is="emby-dialogclosebutton"></button>')+'<h3 class="formDialogHeaderTitle">'+_globalize.default.translate("HeaderRefreshMetadata")+"</h3></div>")+function(){var html="";return html+'<div is="emby-scroller" data-horizontal="false" data-focusscroll="true" class="formDialogContent">'+'<div class="scrollSlider">'+'<form class="dialogContentInner dialog-content-centered padded-left padded-right">'+'<div class="fldSelectPlaylist selectContainer">'+('<select is="emby-select" class="selectMetadataRefreshMode" label="'+_globalize.default.translate("LabelRefreshMode")+'">')+('<option value="missing">'+_globalize.default.translate("SearchForMissingMetadata")+"</option>")+('<option value="all" selected>'+_globalize.default.translate("ReplaceAllMetadata")+"</option>")+"</select>"+'<div class="fieldDescription">'+_globalize.default.translate("RefreshDialogHelp")+"</div>"+"</div>"+'<div class="toggleContainer hide fldReplaceExistingImages">'+"<label>"+'<input type="checkbox" is="emby-toggle" class="chkReplaceImages" />'+("<span>"+_globalize.default.translate("ReplaceExistingImages")+"</span>")+"</label>"+'<div class="toggleFieldDescription fieldDescription">'+_globalize.default.translate("ReplaceExistingImagesHelp")+"</div>"+"</div>"+"<br />"+'<div class="formDialogFooter">'+('<button is="emby-button" type="submit" class="raised btnSubmit block formDialogFooterItem button-submit">'+_globalize.default.translate("Refresh")+"</button>")+"</div>"+"</form>"+"</div>"+"</div>"}();return dlg.innerHTML=dialogOptions,dlg.querySelector("form").addEventListener("submit",onSubmit.bind(this)),dlg.querySelector(".selectMetadataRefreshMode").addEventListener("change",function(){dlg.querySelector(".fldReplaceExistingImages").classList.remove("hide")}),this.options.mode&&(dlg.querySelector(".selectMetadataRefreshMode").value=this.options.mode),dlg.querySelector(".selectMetadataRefreshMode").dispatchEvent(new CustomEvent("change")),new Promise(function(resolve,reject){dlg.addEventListener("close",resolve),_dialoghelper.default.open(dlg)})};_exports.default=RefreshDialog});