import{i as d}from"./chunk-I6BQZFSU.js";d();(function(m){var c={crosshair:{mode:null,color:"rgba(170, 0, 0, 0.80)",lineWidth:1}};function g(i){var r={x:-1,y:-1,locked:!1};i.setCrosshair=function(e){if(!e)r.x=-1;else{var s=i.p2c(e);r.x=Math.max(0,Math.min(s.left,i.width())),r.y=Math.max(0,Math.min(s.top,i.height()))}i.triggerRedrawOverlay()},i.clearCrosshair=i.setCrosshair,i.lockCrosshair=function(e){e&&i.setCrosshair(e),r.locked=!0},i.unlockCrosshair=function(){r.locked=!1};function n(){r.locked||r.x!==-1&&(r.x=-1,i.triggerRedrawOverlay())}function a(o){if(!r.locked){if(i.getSelection&&i.getSelection()){r.x=-1;return}var e=i.offset();r.x=Math.max(0,Math.min(o.pageX-e.left,i.width())),r.y=Math.max(0,Math.min(o.pageY-e.top,i.height())),i.triggerRedrawOverlay()}}i.hooks.bindEvents.push(function(o,e){o.getOptions().crosshair.mode&&(e.mouseout(n),e.mousemove(a))}),i.hooks.drawOverlay.push(function(o,e){var s=o.getOptions().crosshair;if(s.mode){var t=o.getPlotOffset();if(e.save(),e.translate(t.left,t.top),r.x!==-1){var h=o.getOptions().crosshair.lineWidth%2?.5:0;if(e.strokeStyle=s.color,e.lineWidth=s.lineWidth,e.lineJoin="round",e.beginPath(),s.mode.indexOf("x")!==-1){var f=Math.floor(r.x)+h;e.moveTo(f,0),e.lineTo(f,o.height())}if(s.mode.indexOf("y")!==-1){var u=Math.floor(r.y)+h;e.moveTo(0,u),e.lineTo(o.width(),u)}e.stroke()}e.restore()}}),i.hooks.shutdown.push(function(o,e){e.unbind("mouseout",n),e.unbind("mousemove",a)})}m.plot.plugins.push({init:g,options:c,name:"crosshair",version:"1.0"})})(jQuery);
