function Channel(n,t){var e=n,a=t,i=null,r=EnumStreamType.FLUENT,s=EnumChannelStatus.CLOSED,l=32,o=150,c=150,u=150,h=150,d=!0,g=null;function f(n,t,e){var a="",i="";let r=!0;ControllerLogin.channelState[n]&&(r=!ControllerLogin.channelState[n].online,a=ControllerLogin.channelState[n].online?"":"CH_disabled",i=ControllerLogin.channelState[n].name),e||(a=""),i=i||"CH "+oneToZeroOne(n+1);var s=$('
');let l=s.find("#ch-btn-edit");ControllerLogin.level&&"admin"!==ControllerLogin.level&&"admin"!==infoHandler.recover2Str(ControllerLogin.userName)||l.after($('')),$("#"+t).append(s),s.on("click",(function(){if($(this).hasClass("CH_disabled"))return;$('[data-toggle="popover"]').popover("hide");const n=parseInt($(this).attr("bc-channel-id"));e?PlayerPreview.changeChannel(n):PlayerPlayback.changeChannel(n)}));var o=s.find(".channel-name-input"),c=s.find(".channel_status_text_center");return l.on("click",(function(n){n.stopPropagation(),s.hasClass("CH_disabled")||s.hasClass("CH_btn-editing")||(o.val(c.text()),s.addClass("CH_btn-editing"),o.trigger("focus"))})),s.find("#ch-btn-setting").on("click",(function(n){if(ControllerLogin.level&&"admin"!==ControllerLogin.level&&"admin"!==infoHandler.recover2Str(ControllerLogin.userName))return;const t=parseInt($(this).parent().attr("bc-channel-id"));ControllerMain.trigger("gotoRemoteConfig",[t])})),o.on("click",(function(n){n.stopPropagation()})),o.on("blur",(function(){s.removeClass("CH_btn-editing");const t=$(this).val();if(""!==t){var e=ControllerLogin.channelState[n]?ControllerLogin.channelState[n].name:i;t!==e&&(validators.deviceName(t)?(c.text(t).attr("title",t),PlayerPreview.waiter.show("Saving OSD settings..."),CGI.sendCommand("SetOsd",{Osd:{channel:n,osdChannel:{name:t}}},(function(){$('[bc-channel-id="'+n+'"]').find(".view-channel-id").text(t),$('.CH_btn-group[bc-channel-id="'+n+'"] .channel_status_text_center').text(t).attr("title",t),ControllerLogin.channelState[n]&&(ControllerLogin.channelState[n].name=t),PlayerPreview.waiter.hide(),bc_alert("alert.OSD_successfully")}),(function(n,t,a){$(this).val(e),c.text(e).attr("title",e),PlayerPreview.waiter.hide(),CGI.autoErrorHandler(n,t,a)}))):bc_alert("Camera name can only consist of alphabet or digital characters.","error"))}else bc_alert("Camera name cannot be blank.","error")})),o.on("keypress",(function(n){13===n.keyCode&&o.trigger("blur")})),s}EventListener.apply(this),this.getViewId=function(){return g},this.getId=function(){return e},this.getMode=function(){return a},this.setAuto=function(n){return d=n,this},this.getAuto=function(){return d},this.setLightValue=function(n){return h=n,this},this.getLightValue=function(){return h},this.setHueValue=function(n){return o=n,this},this.getHueValue=function(){return o},this.setSaturationValue=function(n){return c=n,this},this.getSaturationValue=function(){return c},this.setContrastValue=function(n){return u=n,this},this.getContrastValue=function(){return u},this.setPTZSpeedValue=function(n){return l=n,this},this.getPTZSpeedValue=function(){return l},this.bindView=function(n){return g=n,i.attr("bc-view-id",n),this},this.unbindView=function(n){return g=null,i.removeAttr("bc-view-id"),this},this.setStatus=function(n){switch(n){case EnumChannelStatus.PLAYING:i.find(".channel_status_icon").addClass("channel-status-connected");break;case EnumChannelStatus.CLOSED:i.find(".channel_status_icon").removeClass("channel-status-connected");break;default:return!1}return s=n,!0},this.setCurrentChannel=function(){return $(".channel_status_icon.channel-status-connected").removeClass("channel-status-connected"),i.find(".channel_status_icon").addClass("channel-status-connected"),!0},this.getStatus=function(){return s},this.getStream=function(){return r},this.updateStream=function(n){return r=n,this},this.open=function(n,t){return console.dbg("Channel["+this.getId()+"] Opened with stream",EnumStreamFullNames[n]),ChannelManager.trigger("open",[this,i,void 0===n?r:n,t]),this},this.pause=function(){return ChannelManager.trigger("pause",[this,i]),this},this.setReplayData=function(n,t){this.url=n,this.seekTo=t},this.close=function(){return ChannelManager.trigger("close",[this,i]),this},this.setup=function(){return a==EnumCurState.PREVIEW?i=function(n){return f(n,"channelItems",!0)}(e):(i=function(n){return f(n,"pb_channels_content",!1)}(e),r=EnumStreamType.FLUENT),delete this.setup,this}}