define(["shell","dialogHelper","loading","layoutManager","connectionManager","embyRouter","globalize","emby-input","emby-checkbox","paper-icon-button-light","emby-select","material-icons","css!./../formdialog","emby-button"],function(shell,dialogHelper,loading,layoutManager,connectionManager,embyRouter,globalize){"use strict";function parentWithClass(elem,className){for(;!elem.classList||!elem.classList.contains(className);)if(elem=elem.parentNode,!elem)return null;return elem}function getEditorHtml(){var html="";return html+='
',html+='
',html+='
',html+='
',html+='",html+="
",html+='",html+='
',html+=globalize.translate("sharedcomponents#RefreshDialogHelp"),html+="
",html+='',html+="
",html+='
',html+='",html+="
",html+="
",html+="
",html+="
"}function centerFocus(elem,horiz,on){require(["scrollHelper"],function(scrollHelper){var fn=on?"on":"off";scrollHelper.centerFocus[fn](elem,horiz)})}function onSubmit(e){loading.show();var instance=this,dlg=parentWithClass(e.target,"dialog"),options=instance.options,apiClient=connectionManager.getApiClient(options.serverId),replaceAllImages=dlg.querySelector(".chkReplaceImages").checked,replaceAllMetadata="all"===dlg.querySelector("#selectMetadataRefreshMode").value;return options.itemIds.forEach(function(itemId){apiClient.refreshItem(itemId,{Recursive:!0,ImageRefreshMode:"FullRefresh",MetadataRefreshMode:"FullRefresh",ReplaceAllImages:replaceAllImages,ReplaceAllMetadata:replaceAllMetadata})}),dialogHelper.close(dlg),require(["toast"],function(toast){toast(globalize.translate("sharedcomponents#RefreshQueued"))}),loading.hide(),e.preventDefault(),!1}function RefreshDialog(options){this.options=options}return RefreshDialog.prototype.show=function(){var dialogOptions={removeOnClose:!0,scrollY:!1};layoutManager.tv?dialogOptions.size="fullscreen":dialogOptions.size="small";var dlg=dialogHelper.createDialog(dialogOptions);dlg.classList.add("formDialog");var html="",title=globalize.translate("sharedcomponents#RefreshMetadata");return html+='
',html+='',html+='

',html+=title,html+="

",html+="
",html+=getEditorHtml(),dlg.innerHTML=html,dlg.querySelector("form").addEventListener("submit",onSubmit.bind(this)),dlg.querySelector(".btnCancel").addEventListener("click",function(){dialogHelper.close(dlg)}),layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!0),new Promise(function(resolve,reject){layoutManager.tv&¢erFocus(dlg.querySelector(".formDialogContent"),!1,!1),dlg.addEventListener("close",resolve),dialogHelper.open(dlg)})},RefreshDialog});