var VIEW_DOM_ID_PREFIX="view-block-",VIEW_DOM_CLASS="view-block";function View(e,t){var i,n=t,r=e,o=null,l=null;function a(e,t){return VIEW_DOM_ID_PREFIX+t+"-"+r}if(EventListener.apply(this),this.isRecording=function(){return 1==o.find(".view-record.onwork").length},this.bindChannel=function(e){var t=ControllerLogin.channelState[e]?ControllerLogin.channelState[e].name:"";if(t=t||oneToZeroOne(e+1),o.attr("bc-channel-id",e).find(".view-channel-id").text(t),o.removeClass("no-channel"),l=e,ControllerLogin.chkLowestVersion("supportFLswitch",0,e)){o.find(".view-floodlight").show();const t=ControllerLogin.chkVersion("lightType",1,e);o.find(".view-floodlight").attr("title",t?"floodlight":"spotlight")}else o.find(".view-floodlight").hide();return this},this.unbindChannel=function(){return this.isEmpty()||(o.addClass("no-channel"),o.removeAttr("bc-channel-id").find(".view-channel-id").text("00"),l=null),this},this.isAvailable=function(){return null!==o},this.getClientArea=function(){var e={top:2+parseFloat(o.css("top"))+o.find(".view-toolbar").outerHeight(),left:2+parseFloat(o.css("left"))};return e.height=o.height()-o.find(".view-toolbar").outerHeight(),e.width=o.width(),e},this.isEmpty=function(){return null===l},this.getChannelId=function(){return l},this.getMode=function(){return n},this.getId=function(){return r},this.setSelected=function(){return $("."+VIEW_DOM_CLASS+'.selected[bc-view-mode="'+n+'"]').removeClass("selected"),o.addClass("selected"),ViewManager.trigger("selected",[this]),this},this.isSelected=function(){return o.hasClass("selected")},this.show=function(){return o.show(),this.trigger("show"),this},this.hide=function(){return o.hide(),this.trigger("hide"),this},this.updateStatus=function(e,t){const n=ViewManager.getSelectedView().getChannelId();var r=o.find(".view-channel-status");switch(o.removeClass("playing"),e){case EnumViewStatus.BUFFERING:r.text("Buffering");break;case EnumViewStatus.ERROR:r.text("Error Occured");break;case EnumViewStatus.PAUSED:r.text("Paused");break;case EnumViewStatus.PLAYING:o.addClass("playing");let e=["Fluent","Balanced","Clear","Auto","Clip","TrackFluent","TrackClear"][t];if(void 0!==e){if("TrackFluent"===e||"TrackClear"===e){e=(ControllerMain.isNvr?3===ControllerLogin.abilities.abilityChn[n].channelType.ver:"SD7"===ControllerMain.deviceInfo.type)?e:e.replace("Track","Telephoto")}r.text(e)}else r.text("Error");break;case EnumViewStatus.CLOSED:}i=e;let l=!1;l=ControllerMain.isNvr?[6,4].includes(ControllerLogin.abilities.abilityChn[n].channelType.ver)||ControllerLogin.chkVersion("supportBinoStitch",1,n):"FISHEYE"===ControllerMain.deviceInfo.exactType||"BELL"===ControllerMain.deviceInfo.type||ControllerLogin.chkVersion("supportBinoStitch",1,0);const a=o.find(".view-fill");l?(a.removeClass("exfit"),a.attr("title","Stretch")):(a.addClass("exfit"),a.attr("title","Center"))},this.getStatus=function(){return i},$("#"+a(0,n)).length>0)throw{msg:"This view block was already created."};this.setup=function(){var e=a(0,n),t=ControllerLogin.channelState[r]?ControllerLogin.channelState[r].name:"";t=t||oneToZeroOne(r+1);var i=$('
'),l=flashCheck()?$("#preview_plugin_container"):$(".h5_player_wrapper");return o=$(''),l.append(o),o.append(i),function(e,t,i,n){var r;if(r=$(''),n.append(r),r.on("click",(function(){return ViewManager.trigger("fillmode",[e,i]),!1})),e.getMode()==EnumCurState.PLAYBACK)ControllerMain.isNvr||(r=$(''),n.append(r),r.on("click",(function(){return ControllerLogin.chkPermission("recDownload","read",0)?ViewManager.trigger("download",[e,i]):bc_alert("alert.permission_download_video","error"),!1})));else{r=$(''),n.prepend(r),r=$(''),n.append(r),r.on("click",(function(){return ControllerLogin.chkPermission("snap","read",0)?ViewManager.trigger("snap",[e,i]):bc_alert("alert.permission_download_video","error"),!1}));let o=$('');o.hide(),n.append(o),o.on("click",(function(){return ViewManager.trigger("lightup",[e,i]),!1}))}r=$(''),n.append(r),r.on("click",(function(){return ViewManager.trigger("close",[e,i]),$(this).addClass("no-channel"),!1})),i.droppable({drop:function(t,n){ViewManager.trigger("drop",[e,i,n.draggable])}}),i.on("click",(function(t){e.setSelected(),ViewManager.trigger("click",[e,i])})),i.on("dblclick",(function(){ViewManager.trigger("dblclick",[e,i])}))}(this,e,o,i),delete this.setup,this},this.resize=function(e,t){$("#preview_main_ocx").width($(window).innerWidth()-240);var i,n=(flashCheck()?$("#preview_plugin_container"):$(".h5_player_wrapper")).height()/e,r=($(window).innerWidth()-240)/e;1==e?(o.height(n-4),o.width(r-4)):(o.height(n),o.width(r)),i=t%e,o.css({left:i*r}),i=Math.floor(t/e),o.css({top:i*n})}}