function ViewISP(){throw{msg:"Don't NEW a singleton."}}EventListener.apply(ViewISP),function(){var e=!1;ViewISP.restoreDefault=function(e){var a,i,t=ControllerFlash.getSelectedChannelInfo();if(t){this.restoring=!0,a=t.limits.isp,i=t.initials.isp,$("#pv-adv-channel").val(i.channel),$("#pv-gain-begin").val(i.gain.min),$("#pv-gain-end").val(i.gain.max),$("#pv-shutter-begin").val(i.shutter.min),$("#pv-shutter-end").val(i.shutter.max),$("#pv-red-gain").slider({min:a.redGain.min,max:a.redGain.max,value:i.redGain}),$("#pv-blue-gain").slider({min:a.blueGain.min,max:a.blueGain.max,value:i.blueGain}),$("#pv-gain-begin").attr({max:a.gain.max,min:a.gain.min,title:a.gain.min+"~"+a.gain.max}).val(i.gain.min),$("#pv-gain-end").attr({max:a.gain.max,min:a.gain.min,title:a.gain.min+"~"+a.gain.max}).val(i.gain.max),$("#pv-shutter-begin").attr({max:a.shutter.max,min:a.shutter.min,title:a.shutter.min+"~"+a.shutter.max}).val(i.shutter.min),$("#pv-shutter-end").attr({max:a.shutter.max,min:a.shutter.min,title:a.shutter.min+"~"+a.shutter.max}).val(i.shutter.max),$("#pv-blc").slider({min:a.blc.min,max:a.blc.max,value:i.blc}),$("#pv-drc").slider({min:a.drc.min,max:a.drc.max,value:i.drc}),$("#pv-3d-nr").is(":checked")!=i.nr3d&&$("#pv-3d-nr").trigger("click"),$("#pv-anti-flicker").html(""),$(a.antiFlicker).each((function(){$("#pv-anti-flicker").append('")})),$("#pv-anti-flicker").val(i.antiFlicker),$("#pv-exposure").html(""),$(a.exposure).each((function(){$("#pv-exposure").append('")})),$("#pv-exposure").val(i.exposure).trigger("change"),$("#pv-exposure").html(""),$(a.exposure).each((function(){$("#pv-exposure").append('")})),$("#pv-exposure").val(i.exposure).trigger("change"),$("#pv-white-balance").html(""),$(a.whiteBalance).each((function(){$("#pv-white-balance").append('")})),$("#pv-white-balance").val(i.whiteBalance).trigger("change"),$("#pv-backlight").html("");var n={DynamicRangeControl:"Dynamic Range",BackLightControl:"Back-Light",Off:"Off"};$(a.backLight).each((function(){$("#pv-backlight").append('")})),$("#pv-backlight").val(i.backLight).trigger("change"),$("#pv-daynight").html(""),$(a.dayNight).each((function(){$("#pv-daynight").append('")})),$("#pv-daynight").val(i.dayNight),PCE.getFeatureVersion("powerLed",i.channel)>0&&($("#pv-power-light").html(""),$(t.limits.powerControl.state).each((function(){$("#pv-power-light").append('")})),$("#pv-power-light").val(t.initials.powerControl.state)),0===PCE.getFeatureVersion("white_balance",e)?$("#pv-white-balance").parents("tr").hide():$("#pv-white-balance").parents("tr").show(),$("#pv-adv-commit").trigger("click")}},ViewISP.refreshView=function(a){a=void 0===a?ControllerFlash.getSelectedChannel().getId():a;var i,t,n=ControllerFlash.getSelectedChannelInfo();if(ControllerMain.disableAbility("isp"),n){if(ControllerMain.enableAbility("isp"),i=n.limits.isp,t=n.data.isp,$("#pv-adv-channel").val(t.channel),$("#pv-gain-begin").val(t.gain.min),$("#pv-gain-end").val(t.gain.max),$("#pv-shutter-begin").val(t.shutter.min),$("#pv-shutter-end").val(t.shutter.max),$("#pv-red-gain").slider({min:i.redGain.min,max:i.redGain.max,value:t.redGain}),$("#pv-blue-gain").slider({min:i.blueGain.min,max:i.blueGain.max,value:t.blueGain}),$("#pv-gain-begin").attr({max:i.gain.max,min:i.gain.min,title:i.gain.min+"~"+i.gain.max}).val(t.gain.min),$("#pv-gain-end").attr({max:i.gain.max,min:i.gain.min,title:i.gain.min+"~"+i.gain.max}).val(t.gain.max),$("#pv-shutter-begin").attr({max:i.shutter.max,min:i.shutter.min,title:i.shutter.min+"~"+i.shutter.max}).val(t.shutter.min),$("#pv-shutter-end").attr({max:i.shutter.max,min:i.shutter.min,title:i.shutter.min+"~"+i.shutter.max}).val(t.shutter.max),$("#pv-blc").slider({min:i.blc.min,max:i.blc.max,value:t.blc}),$("#pv-drc").slider({min:i.drc.min,max:i.drc.max,value:t.drc}),e=!0,ControllerMain.deviceInfo.channelNum>1){$("#advanced-channal-select").parents("tr").show();const e=ViewManager.getViewObject(0).getChannelId();$("#advanced-channal-select").html('"),$("#advanced-channal-select").attr("disabled",!0)}else $("#advanced-channal-select").parents("tr").hide();$("#pv-rotation").is(":checked")!=t.rotation&&$("#pv-rotation").trigger("click"),$("#pv-mirroring").is(":checked")!=t.mirroring&&$("#pv-mirroring").trigger("click"),e=!1,$("#pv-3d-nr").is(":checked")!=t.nr3d&&$("#pv-3d-nr").trigger("click"),PCE.isReadable("ledControl")&&($("#pv-led-light").html(""),$(n.limits.ledControl.state).each((function(){$("#pv-led-light").append('")})),$("#pv-led-light").val(n.data.ledControl.state)),PCE.getFeatureVersion("powerLed",t.channel)>0&&($("#pv-power-light").html(""),$(n.limits.powerControl.state).each((function(){$("#pv-power-light").append('")})),$("#pv-power-light").val(n.data.powerControl.state)),$("#pv-anti-flicker").html(""),$(i.antiFlicker).each((function(){$("#pv-anti-flicker").append('")})),$("#pv-anti-flicker").val(t.antiFlicker),$("#pv-exposure").html(""),$(i.exposure).each((function(){$("#pv-exposure").append('")})),$("#pv-exposure").val(t.exposure).trigger("change"),$("#pv-exposure").html(""),$(i.exposure).each((function(){$("#pv-exposure").append('")})),$("#pv-exposure").val(t.exposure).trigger("change"),$("#pv-white-balance").html(""),$(i.whiteBalance).each((function(){$("#pv-white-balance").append('")})),$("#pv-white-balance").val(t.whiteBalance).trigger("change"),$("#pv-backlight").html("");var r={DynamicRangeControl:"Dynamic Range",BackLightControl:"Back-Light",Off:"Off"};$(i.backLight).each((function(){$("#pv-backlight").append('")})),$("#pv-backlight").val(t.backLight).trigger("change"),$("#pv-daynight").html(""),$(i.dayNight).each((function(){$("#pv-daynight").append('")})),$("#pv-daynight").val(t.dayNight),ControllerLogin.chkPermission("isp","write",n.index)||ControllerMain.disableAbility("isp"),0===PCE.getFeatureVersion("white_balance",a)?$("#pv-white-balance").parents("tr").hide():$("#pv-white-balance").parents("tr").show()}},ViewISP.initUI=function(){$("#pv-blc").slider({range:"min",value:50,min:0,max:100}),$("#pv-drc").slider({range:"min",value:50,min:0,max:100}),$("#pv-blue-gain").slider({range:"min",value:50,min:0,max:100}),$("#pv-red-gain").slider({range:"min",value:50,min:0,max:100}),$("#pv-adv-default").on("click",(function(){ViewISP.restoreDefault(parseInt($("#pv-adv-channel").val()))})),$("#pv-gain-begin").on("change",(function(){var e=parseInt($(this).val());e>parseInt($("#pv-gain-end").val())&&$("#pv-gain-end").val(e)})),$("#pv-gain-end").on("change",(function(){var e=parseInt($("#pv-gain-begin").val()),a=parseInt($(this).val());e>a&&$("#pv-gain-begin").val(a)})),$("#pv-shutter-begin").on("change",(function(){var e=parseInt($(this).val());e>parseInt($("#pv-shutter-end").val())&&$("#pv-shutter-end").val(e)})),$("#pv-shutter-end").on("change",(function(){var e=parseInt($("#pv-shutter-begin").val()),a=parseInt($(this).val());e>a&&$("#pv-shutter-begin").val(a)})),$("#pv-adv-commit").on("click",(function(){$(this).attr("disabled",!0);var e=parseInt($("#pv-adv-channel").val());if(e<0)return bc_alert("alert.select_view","error");ViewISP.restoring?PlayerPreview.waiter.show("Restoring advanced settings..."):PlayerPreview.waiter.show("Saving advanced settings...");var a=[];a.push(new Promise((function(a,i){CGI.sendCommand("SetIsp",{Isp:{channel:e,antiFlicker:$("#pv-anti-flicker").val(),exposure:$("#pv-exposure").val(),gain:{min:parseInt($("#pv-gain-begin").val()),max:parseInt($("#pv-gain-end").val())},shutter:{min:parseInt($("#pv-shutter-begin").val()),max:parseInt($("#pv-shutter-end").val())},blueGain:parseInt($("#pv-blue-gain").slider("value")),redGain:parseInt($("#pv-red-gain").slider("value")),whiteBalance:$("#pv-white-balance").val(),dayNight:$("#pv-daynight").val(),backLight:$("#pv-backlight").val(),blc:parseInt($("#pv-blc").slider("value")),drc:parseInt($("#pv-drc").slider("value")),rotation:$("#pv-rotation").is(":checked")?1:0,mirroring:$("#pv-mirroring").is(":checked")?1:0,nr3d:$("#pv-3d-nr").is(":checked")?1:0}},(function(){new Promise((function(a,i){if(!PCE.isReadable("ledControl")||!PCE.isExecutable("ledControl"))return a();CGI.sendCommand("SetIrLights",{IrLights:{state:$("#pv-led-light").val(),channel:e}},a,(function(e,a,t){i({cmd:e,errno:a,msg:t})}))})).then((function(){a()})).catch((function(e){i(e)}))}),(function(e,a,t){i({cmd:e,errno:a,msg:t})}))}))),a.push(new Promise((function(a,i){if(PCE.getFeatureVersion("powerLed",e)<=0||!PCE.isExecutable("powerLed",e))return a();CGI.sendCommand("SetPowerLed",{PowerLed:{state:$("#pv-power-light").val(),channel:e}},a,(function(e,a,t){i({cmd:e,errno:a,msg:t})}))}))),Promise.all(a).then((function(){PlayerPreview.waiter.hide(),bc_alert(),$("#pv-adv-commit").removeAttr("disabled")}),(function(e){PlayerPreview.waiter.hide(),CGI.autoErrorHandler(e.cmd,e.errno,e.msg),$("#pv-adv-commit").removeAttr("disabled")}))})),$("#pv-mirroring").on("click",(function(){if(!e){var a=parseInt($("#pv-adv-channel").val());$(this).attr("disabled",!0),$("#pv-adv-commit").attr("disabled",!0),g_device.channels[a].data.isp.mirroring=$("#pv-mirroring").is(":checked")?1:0,CGI.sendCommand("SetIsp",{Isp:g_device.channels[a].data.isp},(function(){$("#pv-mirroring").hasClass("image-isp-reset")||bc_alert(),$("#pv-mirroring").removeClass("image-isp-reset"),$("#pv-mirroring").removeAttr("disabled"),$("#pv-adv-commit").removeAttr("disabled")}),(function(e,a,i){CGI.autoErrorHandler(e,a,i),$("#pv-mirroring").removeAttr("disabled"),$("#pv-adv-commit").removeAttr("disabled")}))}})),$("#pv-rotation").on("click",(function(){if(!e){var a=parseInt($("#pv-adv-channel").val());$(this).attr("disabled",!0),$("#pv-adv-commit").attr("disabled",!0),g_device.channels[a].data.isp.rotation=$("#pv-rotation").is(":checked")?1:0,CGI.sendCommand("SetIsp",{Isp:g_device.channels[a].data.isp},(function(){$("#pv-rotation").hasClass("image-isp-reset")||bc_alert(),$("#pv-rotation").removeClass("image-isp-reset"),$("#pv-rotation").removeAttr("disabled"),$("#pv-adv-commit").removeAttr("disabled")}),(function(e,a,i){CGI.autoErrorHandler(e,a,i),$("#pv-rotation").removeAttr("disabled"),$("#pv-adv-commit").removeAttr("disabled")}))}})),$("#pv-exposure").on("change",(function(){switch($(".pv-exposure").hide(),$(this).val()){case"Auto":break;case"LowNoise":$("#pv-gain").show();break;case"Anti-Smearing":$("#pv-shutter").show();break;case"Manual":$("#pv-gain").show(),$("#pv-shutter").show()}})),$("#pv-white-balance").on("change",(function(){switch($(".pv-white-balance").hide(),$(this).val()){case"Auto":break;case"Manual":0!==PCE.getFeatureVersion("white_balance",parseInt($("#pv-adv-channel").val()))&&$(".pv-white-balance").show()}})),$("#pv-backlight").on("change",(function(){switch($(".pv-backlight").hide(),$(this).val()){case"Auto":break;case"BackLightControl":$(".pv-blc").show();break;case"DynamicRangeControl":$(".pv-drc").show()}}))}}();