define(["loading","mainTabsManager","globalize","formHelper","emby-select","emby-checkbox","emby-input","emby-button","paper-icon-button-light","material-icons"],function(loading,mainTabsManager,globalize,formHelper){"use strict";var useLegacyUploadProperty=!1;function onSubmit(e){loading.show();var form=this;return ApiClient.getNamedConfiguration("sync").then(function(config){config.TemporaryPath=form.querySelector("#txtSyncTempPath").value;var uploadLimit=parseInt(1e6*parseFloat(form.querySelector("#txtUploadSpeedLimit").value||"0"));config.TranscodingCpuCoreLimit=parseInt(form.querySelector("#selectThreadCount").value),config.EnableFullSpeedTranscoding=form.querySelector("#chkEnableFullSpeedConversion").checked,useLegacyUploadProperty?config.UploadSpeedLimitBytes=uploadLimit:config.UploadSpeedLimitBitsPerSecond=uploadLimit,ApiClient.updateNamedConfiguration("sync",config).then(formHelper.handleConfigurationSavedResponse)}),e.preventDefault(),e.stopPropagation(),!1}function getConvertTabs(){return[{href:"conversions?mode=convert",name:globalize.translate("Conversions")},{href:"serverdownloadsettings?mode=convert",name:globalize.translate("Settings")}]}function getDownloadTabs(){return[{href:"serverdownloads",name:globalize.translate("Downloads")},{href:"serverdownloadsettings",name:globalize.translate("Settings")}]}return function(view,params){view.querySelector("#btnSelectSyncTempPath").addEventListener("click",function(){require(["directorybrowser"],function(directoryBrowser){var picker=new directoryBrowser;picker.show({callback:function(path){path&&(view.querySelector("#txtSyncTempPath").value=path),picker.close()},validateWriteable:!0})})}),view.querySelector("form").addEventListener("submit",onSubmit),view.addEventListener("viewshow",function(){loading.show(),mainTabsManager.setTabs(this,1,"convert"===params.mode?getConvertTabs:getDownloadTabs);var page=this;ApiClient.getNamedConfiguration("sync").then(function(config){!function(page,config){var uploadLimit=config.UploadSpeedLimitBitsPerSecond||0===config.UploadSpeedLimitBitsPerSecond?(useLegacyUploadProperty=!1,config.UploadSpeedLimitBitsPerSecond/1e6||""):(useLegacyUploadProperty=!0,config.UploadSpeedLimitBytes/1e6||"");page.querySelector("#txtSyncTempPath").value=config.TemporaryPath||"",page.querySelector("#txtUploadSpeedLimit").value=uploadLimit,page.querySelector("#selectThreadCount").value=config.TranscodingCpuCoreLimit,page.querySelector("#chkEnableFullSpeedConversion").checked=config.EnableFullSpeedTranscoding,loading.hide()}(page,config)})})}});