function ViewStitch(){throw{msg:"Don't NEW a singleton."}}EventListener.apply(ViewStitch),ViewStitch.btnMouseDownTimer=null,ViewStitch.loopChangeCurrentValue=null,ViewStitch.isBtnMouseDown=!1,ViewStitch.oldValue=0,ViewStitch.initUI=function(){$(["distance","stitchXMove","stitchYMove"]).each((function(){$("#amount_stitch_"+this).val(0)})),$("#stitch_control_container .stitch_cmd").each((function(){$(this).on("mouseup",(function(t){0===t.button&&ViewStitch.onStitchBtnRelease(t)})).on("mouseleave",(function(t){ViewStitch.onStitchBtnRelease(t)})).on("mousedown",(function(t){if(0===t.button){var e=ControllerFlash.getSelectedChannel();if(e){var i=g_device.channels[e.getId()];if(i.data.stitch){var a=$(t.target),n=a.attr("stitch-attr");if(!a.hasClass("disabled")){ViewStitch.isBtnMouseDown=!0;var s=1;"distance"===n&&(s=.1);var c=i.limits.stitch[n].max,h=i.limits.stitch[n].min,o=parseFloat($("#amount_stitch_"+n).val());ViewStitch.oldValue=o,o=parseFloat(Math.min(c,Math.max(h,"inc"===a.attr("value-direct")?o+s:o-s)).toFixed(1)),$("#amount_stitch_"+n).val(o),i.data.stitch[n]=o,ViewStitch.refreshCtrlBtnStatus(n),ViewStitch.btnMouseDownTimer=setTimeout((function(){ViewStitch.loopChangeCurrentValue=createLoopExecutor((function(){var t=parseFloat($("#amount_stitch_"+n).val());t=parseFloat(Math.min(c,Math.max(h,"inc"===a.attr("value-direct")?t+s:t-s)).toFixed(1)),$("#amount_stitch_"+n).val(t),i.data.stitch[n]=t,ViewStitch.refreshCtrlBtnStatus(n)}),.1),ViewStitch.loopChangeCurrentValue(!0)}),100)}}}}}))})),$("#pre_stitch_default_btn").on("click",(function(){var t=ControllerFlash.getSelectedChannel();if(t){var e=g_device.channels[t.getId()];if(e.data.stitch){var i={};$(["distance","stitchXMove","stitchYMove"]).each((function(){i[this]=$("#amount_stitch_"+this).val(),$("#amount_stitch_"+this).val(e.initials.stitch[this]),e.data.stitch[this]=e.initials.stitch[this],ViewStitch.refreshCtrlBtnStatus(this)})),$("#pre_stitch_default_btn").attr("disabled",!0),CGI.sendCommand("SetStitch",{stitch:{...e.data.stitch,channel:t.getId()}},(function(){$("#pre_stitch_default_btn").removeAttr("disabled")}),(function(t,a,n){CGI.autoErrorHandler(t,a,n),$(["distance","stitchXMove","stitchYMove"]).each((function(){$("#amount_stitch_"+this).val(i[this]),e.data.stitch[this]=i[this],ViewStitch.refreshCtrlBtnStatus(this)})),$("#pre_stitch_default_btn").removeAttr("disabled")}))}}})),delete this.initUI},ViewStitch.refreshView=function(){var t=ControllerFlash.getSelectedChannel();if(t){var e=g_device.channels[t.getId()];e.data.stitch&&$(["distance","stitchXMove","stitchYMove"]).each((function(){var t=parseFloat(e.data.stitch[this].toFixed(1));$("#amount_stitch_"+this).val(t),ViewStitch.refreshCtrlBtnStatus(this)}))}},ViewStitch.onStitchBtnRelease=function(t){if(ViewStitch.isBtnMouseDown){ViewStitch.loopChangeCurrentValue&&(ViewStitch.loopChangeCurrentValue(!1),ViewStitch.loopChangeCurrentValue=null),ViewStitch.btnMouseDownTimer&&(clearTimeout(ViewStitch.btnMouseDownTimer),ViewStitch.btnMouseDownTimer=null),ViewStitch.isBtnMouseDown=!1;var e=ControllerFlash.getSelectedChannel();if(e){var i=g_device.channels[e.getId()];if(i.data.stitch){var a=$(t.target).attr("stitch-attr");CGI.sendCommand("SetStitch",{stitch:{...i.data.stitch,channel:e.getId()}},(function(){}),(function(t,e,n){$("#amount_stitch_"+a).val(ViewStitch.oldValue),i.data.stitch[a]=ViewStitch.oldValue,ViewStitch.refreshCtrlBtnStatus(a),CGI.autoErrorHandler(t,e,n)}))}}}},ViewStitch.refreshCtrlBtnStatus=function(t){if(["distance","stitchXMove","stitchYMove"].includes(t+="")){var e=ControllerFlash.getSelectedChannel();if(e){var i=g_device.channels[e.getId()];if(i.limits.stitch){var a=i.limits.stitch[t].max,n=i.limits.stitch[t].min;a===parseFloat($("#amount_stitch_"+t).val())?$("#stitch_"+t+"_container .pre_control_increase").addClass("disabled"):$("#stitch_"+t+"_container .pre_control_increase").removeClass("disabled"),n===parseFloat($("#amount_stitch_"+t).val())?$("#stitch_"+t+"_container .pre_control_decrease").addClass("disabled"):$("#stitch_"+t+"_container .pre_control_decrease").removeClass("disabled")}}}};