/**
 * Highstock JS v11.2.0 (2023-10-30)
 *
 * Drag-panes module
 *
 * (c) 2010-2021 Highsoft AS
 * Author: Kacper Madej
 *
 * License: www.highcharts.com/license
 */!function(e){"object"==typeof module&&module.exports?(e.default=e,module.exports=e):"function"==typeof define&&define.amd?define("highcharts/modules/drag-panes",["highcharts","highcharts/modules/stock"],function(t){return e(t),e.Highcharts=t,e}):e("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(e){"use strict";var t=e?e._modules:{};function s(e,t,s,i){e.hasOwnProperty(t)||(e[t]=i.apply(null,s),"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:t,module:e[t]}})))}s(t,"Extensions/DragPanes/AxisResizerDefaults.js",[],function(){return{minLength:"10%",maxLength:"100%",resize:{controlledAxis:{next:[],prev:[]},enabled:!1,cursor:"ns-resize",lineColor:"#cccccc",lineDashStyle:"Solid",lineWidth:4,x:0,y:0}}}),s(t,"Extensions/DragPanes/AxisResizer.js",[t["Extensions/DragPanes/AxisResizerDefaults.js"],t["Core/Globals.js"],t["Core/Utilities.js"]],function(e,t,s){let{hasTouch:i}=t,{addEvent:o,clamp:n,isNumber:r,relativeLength:a}=s;class h{constructor(e){this.axis=void 0,this.controlLine=void 0,this.lastPos=void 0,this.options=void 0,this.init(e)}init(e,t){this.axis=e,this.options=e.options.resize||{},this.render(),t||this.addMouseEvents()}render(){let e=this.axis,t=e.chart,s=this.options,i=s.x||0,o=s.y,r=n(e.top+e.height+o,t.plotTop,t.plotTop+t.plotHeight),a={};t.styledMode||(a={cursor:s.cursor,stroke:s.lineColor,"stroke-width":s.lineWidth,dashstyle:s.lineDashStyle}),this.lastPos=r-o,this.controlLine||(this.controlLine=t.renderer.path().addClass("highcharts-axis-resizer")),this.controlLine.add(e.axisGroup);let h=t.styledMode?this.controlLine.strokeWidth():s.lineWidth;a.d=t.renderer.crispLine([["M",e.left+i,r],["L",e.left+e.width+i,r]],h),this.controlLine.attr(a)}addMouseEvents(){let e,t,s;let n=this,r=n.controlLine.element,a=n.axis.chart.container,h=[];n.mouseMoveHandler=e=e=>n.onMouseMove(e),n.mouseUpHandler=t=e=>n.onMouseUp(e),n.mouseDownHandler=s=e=>n.onMouseDown(e),h.push(o(a,"mousemove",e),o(a.ownerDocument,"mouseup",t),o(r,"mousedown",s)),i&&h.push(o(a,"touchmove",e),o(a.ownerDocument,"touchend",t),o(r,"touchstart",s)),n.eventsToUnbind=h}onMouseMove(e){(!e.touches||0!==e.touches[0].pageX)&&this.grabbed&&(this.hasDragged=!0,this.updateAxes(this.axis.chart.pointer.normalize(e).chartY-this.options.y))}onMouseUp(e){this.hasDragged&&this.updateAxes(this.axis.chart.pointer.normalize(e).chartY-this.options.y),this.grabbed=this.hasDragged=this.axis.chart.activeResizer=void 0}onMouseDown(e){this.axis.chart.pointer.reset(!1,0),this.grabbed=this.axis.chart.activeResizer=!0}updateAxes(e){let t=this.axis.chart,s=this.options.controlledAxis,i=0===s.next.length?[t.yAxis.indexOf(this.axis)+1]:s.next,o=[this.axis].concat(s.prev),h=[],l=t.plotTop,d=t.plotHeight,c=l+d,u=e=>100*e/d+"%",p=(e,t,s)=>Math.round(n(e,t,s));e=n(e,l,c);let x=!1,f=e-this.lastPos;if(f*f<1)return;let g=!0;for(let s of[o,i])for(let i of s){let s,o;let n=r(i)?t.yAxis[i]:g?i:t.get(i),m=n&&n.options,v={};if(!m||"navigator-y-axis"===m.id){g=!1;continue}o=n.top;let y=Math.round(a(m.minLength||NaN,d)),z=Math.round(a(m.maxLength||NaN,d));if(g)(s=p(e-o,y,z))===z&&(x=!0),e=o+s,h.push({axis:n,options:{height:u(s)}});else{if(f=e-this.lastPos,s=p(n.len-f,y,z),(o=n.top+f)+s>c){let t=c-s-o;e+=t,o+=t}o<l&&(o=l)+s>c&&(s=d),s===y&&(x=!0),h.push({axis:n,options:{top:u(o-l),height:u(s)}})}g=!1,v.height=s}if(!x){for(let e of h)e.axis.update(e.options,!1);t.redraw(!1)}}destroy(){let e=this.axis;for(let t of(delete e.resizer,this.eventsToUnbind&&this.eventsToUnbind.forEach(e=>e()),this.controlLine.destroy(),Object.keys(this)))this[t]=null}}return h.resizerOptions=e,h}),s(t,"Extensions/DragPanes/DragPanes.js",[t["Extensions/DragPanes/AxisResizer.js"],t["Core/Utilities.js"]],function(e,t){let{addEvent:s,merge:i,wrap:o}=t,n=[];function r(){let t=this.resizer,s=this.options.resize;if(s){let i=!1!==s.enabled;t?i?t.init(this,!0):t.destroy():i&&(this.resizer=new e(this))}}function a(e){!e.keepEvents&&this.resizer&&this.resizer.destroy()}function h(e){this.chart.activeResizer||e.apply(this,[].slice.call(arguments,1))}function l(e){this.chart.activeResizer||e.apply(this,[].slice.call(arguments,1))}return{compose:function(d,c){t.pushUnique(n,d)&&(i(!0,d.defaultOptions,e.resizerOptions),d.keepProps.push("resizer"),s(d,"afterRender",r),s(d,"destroy",a)),t.pushUnique(n,c)&&(o(c.prototype,"runPointActions",l),o(c.prototype,"drag",h))}}}),s(t,"masters/modules/drag-panes.src.js",[t["Core/Globals.js"],t["Extensions/DragPanes/AxisResizer.js"],t["Extensions/DragPanes/DragPanes.js"]],function(e,t,s){e.AxisResizer=t,s.compose(e.Axis,e.Pointer)})});//# sourceMappingURL=drag-panes.js.map