define(["exports","./../modules/tabbedview/basetab.js","./../modules/loading/loading.js","./../modules/common/globalize.js","./../modules/formhelper.js","./../modules/emby-apiclient/connectionmanager.js","./codeceditor.js","./../modules/emby-elements/emby-input/emby-input.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/emby-elements/emby-checkbox/emby-checkbox.js","./../modules/emby-elements/emby-select/emby-select.js"],function(_exports,_basetab,_loading,_globalize,_formhelper,_connectionmanager,_codeceditor,_embyInput,_embyButton,_embyCheckbox,_embySelect){function loadPage(instance,config,codecs,defaultCodecConfigurations){var view=instance.view,selectHwa=view.querySelector(".selectHwa"),codecConfigs=(selectHwa.value=config.HardwareAccelerationMode||0,1===config.HardwareAccelerationMode?defaultCodecConfigurations:config.CodecConfigurations||[]);!function(context,codecs,codecConfigs){if(null==codecs||0===codecs.length)return;!function(codecs,codecConfigs){for(var i=0,length=codecs.length;i");return html=(html+='
')+codecs.map(renderSingleCodec).join("")+"
"}(group,groupCodecs)}).join("")}function renderSingleCodec(codec,index,codecs){var checkBoxHtml='",""),upDownHtml=(ApiClient.isMinServerVersion("4.8.0.30")&&(codec.SupportsParameters&&(name+=''),codec.Id)&&codec.IsHardwareCodec&&(name+=''),""),index=(0keyboard_arrow_up':1keyboard_arrow_down'),'
');return(index+=checkBoxHtml)+'
'+name+upDownHtml+"
"}function onSubmit(e){var form=this,apiClient=(_loading.default.show(),ApiClient);return apiClient.getNamedConfiguration("encoding").then(function(config){config.DownMixAudioBoost=form.querySelector(".txtDownMixAudioBoost").value,config.TranscodingTempPath=form.querySelector(".txtTranscodingTempPath").value,config.EnableSubtitleExtraction=form.querySelector(".chkEnableSubtitleExtraction").checked,config.EnableThrottling=form.querySelector(".chkEnableThrottle").checked;var selectHwa=form.querySelector(".selectHwa"),codecConfigs=(config.HardwareAccelerationMode=parseInt(selectHwa.value),[]);2===config.HardwareAccelerationMode&&Array.prototype.forEach.call(form.querySelectorAll(".chkEnableCodec"),function(c){var priority=c.checked?100-function(checkBox){var li=checkBox.closest(".sortableOption"),index=0;for(;li=li.previousElementSibling;)index++;return index}(c):0,priority={CodecId:c.getAttribute("data-codec"),Priority:priority,IsEnabled:c.checked};codecConfigs.push(priority)}),config.HardwareAccelerationType=null,config.CodecConfigurations=codecConfigs,apiClient.updateNamedConfiguration("encoding",config).then(function(response){_loading.default.hide(),_formhelper.default.handleConfigurationSavedResponse(response)})}),e.preventDefault(),e.stopPropagation(),!1}function getConfigurationByCodecId(codecConfigs,codecId){if(codecId&&null!=codecConfigs&&0!==codecConfigs.length)for(var i=0;i',""),view.querySelector(".btnSelectTranscodingTempPath").addEventListener("click",function(){require(["directorybrowser"],function(directoryBrowser){var picker=new directoryBrowser;picker.show({callback:function(path){path&&(view.querySelector(".txtTranscodingTempPath").value=path),picker.close()},validateWriteable:!0,header:_globalize.default.translate("HeaderSelectTranscodingPath"),instruction:_globalize.default.translate("HeaderSelectTranscodingPathHelp")})})}),view.querySelector(".encodingSettingsForm").addEventListener("submit",onSubmit),apiClient.getSystemInfo().then(function(systemInfo){for(var hwaPremiereInfo=view.querySelectorAll(".hwaPremiereInfo"),i=0,length=hwaPremiereInfo.length;i',"")})},TranscodingTab.prototype.onResume=function(options){_basetab.default.prototype.onResume.apply(this,arguments),checkMediaEncodingInitialization(this,ApiClient)},TranscodingTab.prototype.destroy=function(){_basetab.default.prototype.destroy.apply(this,arguments),this.codecList=null},_exports.default=TranscodingTab});