/**
 * Highstock JS v12.5.0 (2026-01-12)
 * @module highcharts/indicators/supertrend
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Wojciech Chmiel
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as o from"../highcharts.js";var e={};e.n=o=>{var l=o&&o.__esModule?()=>o.default:()=>o;return e.d(l,{a:l}),l},e.d=(o,l)=>{for(var t in l)e.o(l,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:l[t]})},e.o=(o,e)=>Object.prototype.hasOwnProperty.call(o,e);let l=o.default;var t=e.n(l);let r=o.default.SeriesRegistry;var n=e.n(r);let{atr:i,sma:s}=n().seriesTypes,{addEvent:p,correctFloat:a,isArray:d,isNumber:c,extend:h,merge:u,objectEach:g}=t();function x(o,e){return{index:e,close:o.getColumn("close")[e],x:o.getColumn("x")[e]}}class y extends s{init(){let o=this;super.init.apply(o,arguments);let e=p(this.chart.constructor,"afterLinkSeries",()=>{if(o.options){let e=o.options;e.cropThreshold=o.linkedParent.options.cropThreshold-(e.params.period-1)}e()},{order:1})}drawGraph(){let o=this,e=o.options,l=o.linkedParent,t=l.getColumn("x"),r=l?l.points:[],n=o.points,i=o.graph,p=r.length-n.length,a=p>0?p:0,d={options:{gapSize:e.gapSize}},h={top:[],bottom:[],intersect:[]},y={top:{styles:{lineWidth:e.lineWidth,lineColor:e.fallingTrendColor||e.color,dashStyle:e.dashStyle}},bottom:{styles:{lineWidth:e.lineWidth,lineColor:e.risingTrendColor||e.color,dashStyle:e.dashStyle}},intersect:e.changeTrendLine},f,m,C,T,S,b,v,D,L,N=n.length;for(;N--;)f=n[N],m=n[N-1],C=r[N-1+a],T=r[N-2+a],S=r[N+a],b=r[N+a+1],v=f.options.color,D={x:f.x,plotX:f.plotX,plotY:f.plotY,isNull:!1},!T&&C&&c(t[C.index-1])&&(T=x(l,C.index-1)),!b&&S&&c(t[S.index+1])&&(b=x(l,S.index+1)),!C&&T&&c(t[T.index+1])?C=x(l,T.index+1):!C&&S&&c(t[S.index-1])&&(C=x(l,S.index-1)),f&&C&&S&&T&&f.x!==C.x&&(f.x===S.x?(T=C,C=S):f.x===T.x?(C=T,T={close:l.getColumn("close")[C.index-1],x:t[C.index-1]}):b&&f.x===b.x&&(C=b,T=S)),m&&T&&C?(L={x:m.x,plotX:m.plotX,plotY:m.plotY,isNull:!1},f.y>=C.close&&m.y>=T.close?(f.color=v||e.fallingTrendColor||e.color,h.top.push(D)):f.y<C.close&&m.y<T.close?(f.color=v||e.risingTrendColor||e.color,h.bottom.push(D)):(h.intersect.push(D),h.intersect.push(L),h.intersect.push(u(L,{isNull:!0})),f.y>=C.close&&m.y<T.close?(f.color=v||e.fallingTrendColor||e.color,m.color=v||e.risingTrendColor||e.color,h.top.push(D),h.top.push(u(L,{isNull:!0}))):f.y<C.close&&m.y>=T.close&&(f.color=v||e.risingTrendColor||e.color,m.color=v||e.fallingTrendColor||e.color,h.bottom.push(D),h.bottom.push(u(L,{isNull:!0}))))):C&&(f.y>=C.close?(f.color=v||e.fallingTrendColor||e.color,h.top.push(D)):(f.color=v||e.risingTrendColor||e.color,h.bottom.push(D)));g(h,function(e,l){o.points=e,o.options=u(y[l].styles,d),o.graph=o["graph"+l+"Line"],s.prototype.drawGraph.call(o),o["graph"+l+"Line"]=o.graph}),o.points=n,o.options=e,o.graph=i}getValues(o,e){let l=e.period,t=e.multiplier,r=o.xData,n=o.yData,s=[],p=[],c=[],h=0===l?0:l-1,u=[],g=[],x=[],y,f,m,C,T,S,b,v,D;if(!(r.length<=l)&&d(n[0])&&4===n[0].length&&!(l<0)){for(D=0,x=i.prototype.getValues.call(this,o,{period:l}).yData;D<x.length;D++)v=n[h+D],b=n[h+D-1]||[],C=u[D-1],T=g[D-1],S=c[D-1],0===D&&(C=T=S=0),y=a((v[1]+v[2])/2+t*x[D]),f=a((v[1]+v[2])/2-t*x[D]),y<C||b[3]>C?u[D]=y:u[D]=C,f>T||b[3]<T?g[D]=f:g[D]=T,S===C&&v[3]<u[D]||S===T&&v[3]<g[D]?m=u[D]:(S===C&&v[3]>u[D]||S===T&&v[3]>g[D])&&(m=g[D]),s.push([r[h+D],m]),p.push(r[h+D]),c.push(m);return{values:s,xData:p,yData:c}}}}y.defaultOptions=u(s.defaultOptions,{params:{index:void 0,multiplier:3,period:10},risingTrendColor:"#06b535",fallingTrendColor:"#f21313",changeTrendLine:{styles:{lineWidth:1,lineColor:"#333333",dashStyle:"LongDash"}}}),h(y.prototype,{nameBase:"Supertrend",nameComponents:["multiplier","period"]}),n().registerSeriesType("supertrend",y);let f=t();export{f as default};