/**
 * Highstock JS v12.6.0 (2026-04-13)
 * @module highcharts/indicators/ichimoku-kinko-hyo
 * @requires highcharts
 * @requires highcharts/modules/stock
 *
 * Indicator series type for Highcharts Stock
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Sebastian Bochan
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as o from"../highcharts.js";import*as t from"../modules/datagrouping.js";var e={};e.n=o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return e.d(t,{a:t}),t},e.d=(o,t)=>{for(var n in t)e.o(t,n)&&!e.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:t[n]})},e.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);let n=o.default;var i=e.n(n);let l=t.default.dataGrouping.approximations;var p=e.n(l);let r=o.default.Color;var s=e.n(r);let a=o.default.SeriesRegistry;var h=e.n(a);let{doc:u,win:c}=i();function f(o){return k(o)&&"number"==typeof o.nodeType}function g(o){let t=Object.prototype.toString.call(o);return"[object Array]"===t||"[object Array Iterator]"===t}function k(o,t){return!!o&&"object"==typeof o&&(!t||!g(o))}function d(o,...t){let e,n=[o,...t],i={},l=function(o,t){return"object"!=typeof o&&(o={}),y(t,function(e,n){if("__proto__"!==n&&"constructor"!==n){let i;!k(e,!0)||(i=e?.constructor,k(e,!0)&&!f(e)&&i?.name&&"Object"!==i.name)||f(e)?o[n]=t[n]:o[n]=l(o[n]||{},e)}}),o};!0===o&&(i=n[1],n=Array.prototype.slice.call(n,2));let p=n.length;for(e=0;e<p;e++)i=l(i,n[e]);return i}function y(o,t,e){for(let n in o)Object.hasOwnProperty.call(o,n)&&t.call(e||o[n],o[n],n,o)}Array.prototype.find;let{parse:S}=s(),{sma:m}=h().seriesTypes;function v(o){return{high:o.reduce(function(o,t){return Math.max(o,t[1])},-1/0),low:o.reduce(function(o,t){return Math.min(o,t[2])},1/0)}}function A(o){let t=o.indicator;t.points=o.points,t.nextPoints=o.nextPoints,t.color=o.color,t.options=d(o.options.senkouSpan.styles,o.gap),t.graph=o.graph,t.fillGraph=!0,h().seriesTypes.sma.prototype.drawGraph.call(t)}class b extends m{constructor(){super(...arguments),this.data=[],this.options={},this.points=[],this.graphCollection=[]}init(){super.init.apply(this,arguments),this.options=d({tenkanLine:{styles:{lineColor:this.color}},kijunLine:{styles:{lineColor:this.color}},chikouLine:{styles:{lineColor:this.color}},senkouSpanA:{styles:{lineColor:this.color,fill:S(this.color).setOpacity(.5).get()}},senkouSpanB:{styles:{lineColor:this.color,fill:S(this.color).setOpacity(.5).get()}},senkouSpan:{styles:{fill:S(this.color).setOpacity(.2).get()}}},this.options)}toYData(o){return[o.tenkanSen,o.kijunSen,o.chikouSpan,o.senkouSpanA,o.senkouSpanB]}translate(){for(let o of(h().seriesTypes.sma.prototype.translate.apply(this),this.points))for(let t of this.pointArrayMap){let e=o[t];"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0&&(o["plot"+t]=this.yAxis.toPixels(e,!0),o.plotY=o["plot"+t],o.tooltipPos=[o.plotX,o["plot"+t]],o.isNull=!1)}}drawGraph(){let o=this,t=o.points,e=o.options,n=o.graph,i=o.color,l={options:{gapSize:e.gapSize}},p=o.pointArrayMap.length,r=[[],[],[],[],[],[]],s={tenkanLine:r[0],kijunLine:r[1],chikouLine:r[2],senkouSpanA:r[3],senkouSpanB:r[4],senkouSpan:r[5]},a=[],u=o.options.senkouSpan,c=u.color||u.styles.fill,f=u.negativeColor,g=[[],[]],k=[[],[]],S=t.length,m=0,v,b,C,Y,x,P,j,B,N,O,G,T,X;for(o.ikhMap=s;S--;){for(C=0,b=t[S];C<p;C++)null!=b[v=o.pointArrayMap[C]]&&r[C].push({plotX:b.plotX,plotY:b["plot"+v],isNull:!1});if(f&&S!==t.length-1){let o=s.senkouSpanB.length-1,t=function(o,t,e,n){if(o&&t&&e&&n){let i=t.plotX-o.plotX,l=t.plotY-o.plotY,p=n.plotX-e.plotX,r=n.plotY-e.plotY,s=o.plotX-e.plotX,a=o.plotY-e.plotY,h=(-l*s+i*a)/(-p*l+i*r),u=(p*a-r*s)/(-p*l+i*r);if(h>=0&&h<=1&&u>=0&&u<=1)return{plotX:o.plotX+u*i,plotY:o.plotY+u*l}}}(s.senkouSpanA[o-1],s.senkouSpanA[o],s.senkouSpanB[o-1],s.senkouSpanB[o]);if(t){let e={plotX:t.plotX,plotY:t.plotY,isNull:!1,intersectPoint:!0};s.senkouSpanA.splice(o,0,e),s.senkouSpanB.splice(o,0,e),a.push(o)}}}if(y(s,(t,n)=>{e[n]&&"senkouSpan"!==n&&(o.points=r[m],o.options=d(e[n].styles,l),o.graph=o["graph"+n],o.fillGraph=!1,o.color=i,h().seriesTypes.sma.prototype.drawGraph.call(o),o["graph"+n]=o.graph),m++}),o.graphCollection)for(let t of o.graphCollection)o[t].destroy(),delete o[t];if(o.graphCollection=[],f&&s.senkouSpanA[0]&&s.senkouSpanB[0]){for(a.unshift(0),a.push(s.senkouSpanA.length-1),T=0;T<a.length-1;T++)if(Y=a[T],x=a[T+1],P=s.senkouSpanB.slice(Y,x+1),j=s.senkouSpanA.slice(Y,x+1),Math.floor(P.length/2)>=1){let o=Math.floor(P.length/2);if(P[o].plotY===j[o].plotY){for(X=0,B=0,N=0;X<P.length;X++)B+=P[X].plotY,N+=j[X].plotY;g[G=B>N?0:1]=g[G].concat(P),k[G]=k[G].concat(j)}else g[G=P[o].plotY>j[o].plotY?0:1]=g[G].concat(P),k[G]=k[G].concat(j)}else g[G=P[0].plotY>j[0].plotY?0:1]=g[G].concat(P),k[G]=k[G].concat(j);["graphsenkouSpanColor","graphsenkouSpanNegativeColor"].forEach(function(t,n){g[n].length&&k[n].length&&(O=0===n?c:f,A({indicator:o,points:g[n],nextPoints:k[n],color:O,options:e,gap:l,graph:o[t]}),o[t]=o.graph,o.graphCollection.push(t))})}else A({indicator:o,points:s.senkouSpanB,nextPoints:s.senkouSpanA,color:c,options:e,gap:l,graph:o.graphsenkouSpan}),o.graphsenkouSpan=o.graph;delete o.nextPoints,delete o.fillGraph,o.points=t,o.options=e,o.graph=n,o.color=i}getGraphPath(o){let t=[],e,n=[];if(o=o||this.points,this.fillGraph&&this.nextPoints){if((e=h().seriesTypes.sma.prototype.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",t=h().seriesTypes.sma.prototype.getGraphPath.call(this,o),n=e.slice(0,t.length);for(let o=n.length-1;o>=0;o--)t.push(n[o])}}else t=h().seriesTypes.sma.prototype.getGraphPath.apply(this,arguments);return t}getValues(o,t){var e,n;let i,l,p,r,s,a,h,u,c,f,k,d,y,S,m,A=t.period,b=t.periodTenkan,C=t.periodSenkouSpanB,Y=o.xData,x=o.yData,P=o.xAxis,j=x&&x.length||0,B=(e=P.series.map(o=>o.getColumn("x")),m=!n,e.forEach(o=>{if(o.length>1)for(S=d=o.length-1;S>0;S--)(y=o[S]-o[S-1])<0&&!m?(n?.(),n=void 0):y&&(void 0===k||y<k)&&(k=y)}),k),N=[],O=[];if(Y.length<=A||!g(x[0])||4!==x[0].length)return;let G=Y[0]-A*B;for(s=0;s<A;s++)O.push(G+s*B);for(s=0;s<j;s++)s>=b&&(a=((l=v(x.slice(s-b,s))).high+l.low)/2),s>=A&&(c=(a+(h=((p=v(x.slice(s-A,s))).high+p.low)/2))/2),s>=C&&(f=((r=v(x.slice(s-C,s))).high+r.low)/2),u=x[s][3],i=Y[s],void 0===N[s]&&(N[s]=[]),void 0===N[s+A-1]&&(N[s+A-1]=[]),N[s+A-1][0]=a,N[s+A-1][1]=h,N[s+A-1][2]=void 0,void 0===N[s+1]&&(N[s+1]=[]),N[s+1][2]=u,s<=A&&(N[s+A-1][3]=void 0,N[s+A-1][4]=void 0),void 0===N[s+2*A-2]&&(N[s+2*A-2]=[]),N[s+2*A-2][3]=c,N[s+2*A-2][4]=f,O.push(i);for(s=1;s<=A;s++)O.push(i+s*B);return{values:N,xData:O,yData:N}}}b.defaultOptions=d(m.defaultOptions,{params:{index:void 0,period:26,periodTenkan:9,periodSenkouSpanB:52},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b> {series.name}</b><br/>TENKAN SEN: {point.tenkanSen:.3f}<br/>KIJUN SEN: {point.kijunSen:.3f}<br/>CHIKOU SPAN: {point.chikouSpan:.3f}<br/>SENKOU SPAN A: {point.senkouSpanA:.3f}<br/>SENKOU SPAN B: {point.senkouSpanB:.3f}<br/>'},tenkanLine:{styles:{lineWidth:1,lineColor:void 0}},kijunLine:{styles:{lineWidth:1,lineColor:void 0}},chikouLine:{styles:{lineWidth:1,lineColor:void 0}},senkouSpanA:{styles:{lineWidth:1,lineColor:void 0}},senkouSpanB:{styles:{lineWidth:1,lineColor:void 0}},senkouSpan:{styles:{fill:"rgba(255, 0, 0, 0.5)"}},dataGrouping:{approximation:"ichimoku-averages"}}),function(o,t){let e;for(e in o||(o={}),t)o[e]=t[e]}(b.prototype,{pointArrayMap:["tenkanSen","kijunSen","chikouSpan","senkouSpanA","senkouSpanB"],pointValKey:"tenkanSen",nameComponents:["periodSenkouSpanB","period","periodTenkan"]}),p()["ichimoku-averages"]=function(){let o,t=[];return[].forEach.call(arguments,function(e,n){t.push(p().average(e)),o=!o&&void 0===t[n]}),o?void 0:t},h().registerSeriesType("ikh",b);let C=i();export{C as default};