/**
 * Highstock JS v12.5.0 (2026-01-12)
 * @module highcharts/modules/drag-panes
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Drag-panes module
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Kacper Madej
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as e from"../highcharts.js";var t={};t.n=e=>{var s=e&&e.__esModule?()=>e.default:()=>e;return t.d(s,{a:s}),s},t.d=(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let s=e.default;var i=t.n(s);let{addEvent:o,clamp:r,isNumber:n,relativeLength:h}=i(),a=class{constructor(e){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,n=r(e.top+e.height+o,t.plotTop,t.plotTop+t.plotHeight),h={};t.styledMode||(h={cursor:s.cursor,stroke:s.lineColor,"stroke-width":s.lineWidth,dashstyle:s.lineDashStyle}),this.lastPos=n-o,this.controlLine||(this.controlLine=t.renderer.path().addClass("highcharts-axis-resizer")),this.controlLine.add(e.axisGroup);let a=t.styledMode?this.controlLine.strokeWidth():s.lineWidth;h.d=t.renderer.crispLine([["M",e.left+i,n],["L",e.left+e.width+i,n]],a),this.controlLine.attr(h)}addMouseEvents(){let e,t,s,i=this,r=i.controlLine.element,n=i.axis.chart.container,h=[];i.mouseMoveHandler=e=e=>i.onMouseMove(e),i.mouseUpHandler=t=e=>i.onMouseUp(e),i.mouseDownHandler=s=()=>i.onMouseDown(),h.push(o(n,"mousemove",e),o(n.ownerDocument,"mouseup",t),o(r,"mousedown",s),o(n,"touchmove",e),o(n.ownerDocument,"touchend",t),o(r,"touchstart",s)),i.eventsToUnbind=h}onMouseMove(e){if(!e.touches||0!==e.touches[0].pageX){let t=this.axis.chart.pointer;this.grabbed&&t&&(this.hasDragged=!0,this.updateAxes(t.normalize(e).chartY-(this.options.y||0)))}}onMouseUp(e){let t=this.axis.chart.pointer;this.hasDragged&&t&&this.updateAxes(t.normalize(e).chartY-(this.options.y||0)),this.grabbed=this.hasDragged=this.axis.chart.activeResizer=void 0}onMouseDown(){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),a=[],l=t.plotTop,d=t.plotHeight,c=l+d,p=e=>100*e/d+"%",u=(e,t,s)=>Math.round(r(e,t,s));e=r(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 o of s){let r,y,v=n(o)?t.yAxis[o]:g?o:t.get(o),m=v&&v.options,z={};if(!m||m.isInternal){g=!1;continue}y=v.top;let M=Math.round(h(m.minLength||NaN,d)),b=Math.round(h(m.maxLength||NaN,d));if(g||s!==i)(r=u(e-y,M,b))===b&&(x=!0),e=y+r,a.push({axis:v,options:{height:p(r)}});else{if(f=e-this.lastPos,r=u(v.len-f,M,b),(y=v.top+f)+r>c){let t=c-r-y;e+=t,y+=t}y<l&&(y=l)+r>c&&(r=d),r===M&&(x=!0),a.push({axis:v,options:{top:p(y-l),height:p(r)}})}g=!1,z.height=r}if(!x){for(let e of a)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}},l={minLength:"10%",maxLength:"100%",resize:{controlledAxis:{next:[],prev:[]},enabled:!1,cursor:"ns-resize",lineColor:"#cccccc",lineDashStyle:"Solid",lineWidth:4,x:0,y:0}},{defaultOptions:d}=i(),{addEvent:c,merge:p,wrap:u}=i();function x(){let e=this.resizer,t=this.options.resize;if(t){let s=!1!==t.enabled;e?s?e.init(this,!0):e.destroy():s&&(this.resizer=new a(this))}}function f(e){!e.keepEvents&&this.resizer&&this.resizer.destroy()}function g(e){this.chart.activeResizer||e.apply(this,[].slice.call(arguments,1))}function y(e){this.chart.activeResizer||e.apply(this,[].slice.call(arguments,1))}let v=i();({compose:function(e,t){e.keepProps.includes("resizer")||(p(!0,d.yAxis,l),e.keepProps.push("resizer"),c(e,"afterRender",x),c(e,"destroy",f),u(t.prototype,"runPointActions",y),u(t.prototype,"drag",g))}}).compose(v.Axis,v.Pointer);let m=i();export{m as default};