/**
 * Highstock JS v12.5.0 (2026-01-12)
 * @module highcharts/indicators/stochastic
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Paweł Fus
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as e from"../highcharts.js";var t,a={};a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let i=e.default;var o=a.n(i);let s=function(e,t,a){return e.reduce((e,i)=>[Math.min(e[0],i[t]),Math.max(e[1],i[a])],[Number.MAX_VALUE,-Number.MAX_VALUE])},r=e.default.SeriesRegistry;var n=a.n(r);let{sma:{prototype:l}}=n().seriesTypes,{defined:p,error:h,merge:u}=o();!function(e){let t=["bottomLine"],a=["top","bottom"],i=["top"];function o(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function s(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(o(e))}),a}function r(){let e=this,t=e.pointValKey,a=e.linesApiNames,i=e.areaLinesNames,r=e.points,n=e.options,c=e.graph,d={options:{gapSize:n.gapSize}},y=[],f=s(e,t),m=r.length,g;if(f.forEach((e,t)=>{for(y[t]=[];m--;)g=r[m],y[t].push({x:g.x,plotX:g.plotX,plotY:g[e],isNull:!p(g[e])});m=r.length}),e.userOptions.fillColor&&i.length){let t=y[f.indexOf(o(i[0]))],a=1===i.length?r:y[f.indexOf(o(i[1]))],s=e.color;e.points=a,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=u(r,d),e.graph=e.area,e.fillGraph=!0,l.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=s}a.forEach((t,a)=>{y[a]?(e.points=y[a],n[t]?e.options=u(n[t].styles,d):h('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],l.drawGraph.call(e),e["graph"+t]=e.graph):h('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=r,e.options=n,e.graph=c,l.drawGraph.call(e)}function n(e){let t,a=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=l.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=l.getGraphPath.call(this,e),i=t.slice(0,a.length);for(let e=i.length-1;e>=0;e--)a.push(i[e])}}else a=l.getGraphPath.apply(this,arguments);return a}function c(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function d(){let e=this.pointArrayMap,t=[],a;t=s(this),l.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,o)=>{a=i[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(i[t[o]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let o=e.prototype;return o.linesApiNames=o.linesApiNames||t.slice(),o.pointArrayMap=o.pointArrayMap||a.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||i.slice(),o.drawGraph=r,o.getGraphPath=n,o.toYData=c,o.translate=d,e}}(t||(t={}));let c=t,{sma:d}=n().seriesTypes,{extend:y,isArray:f,merge:m}=o();class g extends d{init(){super.init.apply(this,arguments),this.options=m({smoothedLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let a=t.periods[0],i=t.periods[1],o=e.xData,r=e.yData,n=r?r.length:0,l=[],p=[],h=[],u,c,d=null,y,m;if(n<a||!f(r[0])||4!==r[0].length)return;let g=!0,A=0;for(m=a-1;m<n;m++){if(u=(y=s(r.slice(m-a+1,m+1),2,1))[0],isNaN(c=(r[m][3]-u)/(y[1]-u)*100)&&g){A++;continue}g&&!isNaN(c)&&(g=!1);let e=p.push(o[m]);isNaN(c)?h.push([h[e-2]&&"number"==typeof h[e-2][0]?h[e-2][0]:null,null]):h.push([c,null]),m>=A+(a-1)+(i-1)&&(d=super.getValues({xData:p.slice(-i),yData:h.slice(-i)},{period:i}).yData[0]),l.push([o[m],c,d]),h[e-1][1]=d}return{values:l,xData:p,yData:h}}}g.defaultOptions=m(d.defaultOptions,{params:{index:void 0,period:void 0,periods:[14,3]},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">●</span><b> {series.name}</b><br/>%K: {point.y}<br/>%D: {point.smoothed}<br/>'},smoothedLine:{styles:{lineWidth:1,lineColor:void 0}},dataGrouping:{approximation:"averages"}}),y(g.prototype,{areaLinesNames:[],nameComponents:["periods"],nameBase:"Stochastic",pointArrayMap:["y","smoothed"],parallelArrays:["x","y","smoothed"],pointValKey:"y",linesApiNames:["smoothedLine"]}),c.compose(g),n().registerSeriesType("stochastic",g);let A=o();export{A as default};