define(["loading","mainTabsManager","globalize","emby-select"],function(loading,mainTabsManager,globalize){"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(Dashboard.processServerConfigurationUpdateResult)}),e.preventDefault(),e.stopPropagation(),!1}function getConvertTabs(){return[{href:"syncactivity.html?mode=convert",name:globalize.translate("Conversions")},{href:"syncsettings.html?mode=convert",name:globalize.translate("Settings")}]}function getDownloadTabs(){return[{href:"syncactivity.html",name:globalize.translate("Downloads")},{href:"syncsettings.html",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;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)})})}});