/**
 * Highcharts JS v12.6.0 (2026-04-13)
 * @module highcharts/modules/series-label
 * @requires highcharts
 *
 * (c) 2009-2026 Highsoft AS
 * Author: Torstein Hønsi
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as t from"../highcharts.js";var e={};e.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var o=e.n(r);let n=t.default.Templating;var a=e.n(n);let i={enabled:!0,connectorAllowed:!1,connectorNeighbourDistance:24,format:void 0,formatter:void 0,minFontSize:null,maxFontSize:null,onArea:null,style:{fontSize:"0.8em",fontWeight:"bold"},useHTML:!1,boxesToAvoid:[]};function l(t,e,r,o,n,a){let i=(a-e)*(r-t)-(o-e)*(n-t);return i>0||!(i<0)}function h(t,e,r,o,n,a,i,h){return l(t,e,n,a,i,h)!==l(r,o,n,a,i,h)&&l(t,e,r,o,n,a)!==l(t,e,r,o,i,h)}let{doc:s,win:c}=o();function p(t,e,r,n={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let i=a.hcEvents;o().Point&&t instanceof o().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let l=t.addEventListener;l&&l.call(t,e,r,!!o().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),i[e]||(i[e]=[]);let h={fn:r,order:"number"==typeof n.order?n.order:1/0};return i[e].push(h),i[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,r){function o(e,r){let o=t.removeEventListener;o&&o.call(t,e,r,!1)}function n(r){let n,a;if(t.nodeName){e?(n={})[e]=!0:n=r;var i=n,l=function(t,e){if(r[e])for(a=r[e].length;a--;)o(e,r[e][a].fn)};for(let t in i)Object.hasOwnProperty.call(i,t)&&l.call(i[t],i[t],t,i)}}let a="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(a,"hcEvents")){let t=a.hcEvents;if(e){let a=t[e]||[];r?(t[e]=a.filter(function(t){return r!==t.fn}),o(e,r)):(n(t),t[e]=[])}else n(t),delete a.hcEvents}}(t,e,r)}}function f(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function u(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function d(){let t=arguments,e=t.length;for(let r=0;r<e;r++){let e=t[r];if(null!=e)return e}}Array.prototype.find;let{animObject:x}=o(),{format:b}=a(),{setOptions:g}=o(),{composed:y}=o(),{boxIntersectLine:m,intersectRect:v}={boxIntersectLine:function(t,e,r,o,n,a,i,l){return h(t,e,t+r,e,n,a,i,l)||h(t+r,e,t+r,e+o,n,a,i,l)||h(t,e+o,t+r,e+o,n,a,i,l)||h(t,e,t,e+o,n,a,i,l)},intersectRect:function(t,e){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}};function X(t,e,r,o,n){let a=t.chart,i=t.options.label||{},l=d(i.onArea,!!t.area),h=l||i.connectorAllowed,s=a.boxesToAvoid,c=Number.MAX_VALUE,p=Number.MAX_VALUE,f,u,x,b,g,y,X;for(y=0;s&&y<s.length;y+=1)if(v(s[y],{left:e,right:e+o.width,top:r,bottom:r+o.height}))return!1;for(y=0;y<a.series.length;y+=1){let s=a.series[y],d=s.interpolatedPoints&&[...s.interpolatedPoints];if(s.visible&&d){let y=a.plotHeight/10;for(let t=a.plotTop;t<=a.plotTop+a.plotHeight;t+=y)d.unshift({chartX:a.plotLeft,chartY:t}),d.push({chartX:a.plotLeft+a.plotWidth,chartY:t});for(X=1;X<d.length;X+=1){if(d[X].chartX>=e-16&&d[X-1].chartX<=e+o.width+16){if(m(e,r,o.width,o.height,d[X-1].chartX,d[X-1].chartY,d[X].chartX,d[X].chartY))return!1;t===s&&!x&&n&&(x=m(e-16,r-16,o.width+32,o.height+32,d[X-1].chartX,d[X-1].chartY,d[X].chartX,d[X].chartY))}(h||x)&&(t!==s||l)&&(c=Math.min(c,(b=e+o.width/2-d[X].chartX)*b+(g=r+o.height/2-d[X].chartY)*g))}if(!l&&h&&t===s&&(n&&!x||c<Math.pow(i.connectorNeighbourDistance||1,2))){for(X=1;X<d.length;X+=1)(f=Math.min(Math.pow(e+o.width/2-d[X].chartX,2)+Math.pow(r+o.height/2-d[X].chartY,2),Math.pow(e-d[X].chartX,2)+Math.pow(r-d[X].chartY,2),Math.pow(e+o.width-d[X].chartX,2)+Math.pow(r-d[X].chartY,2),Math.pow(e+o.width-d[X].chartX,2)+Math.pow(r+o.height-d[X].chartY,2),Math.pow(e-d[X].chartX,2)+Math.pow(r+o.height-d[X].chartY,2)))<p&&(p=f,u=d[X]);x=!0}}}return(!n||!!x)&&{x:e,y:r,weight:c-(u?p:0),connectorPoint:u}}function w(t){if(this.renderer){var e,r,n;let a=this,i=x(a.renderer.globalAnimation).duration;a.labelSeries=[],a.labelSeriesMaxSum=0,a.seriesLabelTimer&&null!=(e=a.seriesLabelTimer)&&clearTimeout(e),a.series.forEach(function(e){let r=e.options.label||{},o=e.labelBySeries,n=o&&o.closest,l=e.getColumn("y");r.enabled&&e.visible&&(e.graph||e.area)&&!e.boosted&&a.labelSeries&&(a.labelSeries.push(e),r.minFontSize&&r.maxFontSize&&l.length&&(e.sum=l.reduce((t,e)=>(t||0)+(e||0),0),a.labelSeriesMaxSum=Math.max(a.labelSeriesMaxSum||0,e.sum||0)),"load"===t.type&&(i=Math.max(i,x(e.options.animation).duration)),n&&(void 0!==n[0].plotX?o.animate({x:n[0].plotX+n[1],y:n[0].plotY+n[2]}):o.attr({opacity:0})))}),r=function(){let t,e;a.series&&a.labelSeries&&(a.boxesToAvoid=[],t=a.labelSeries||[],e=a.boxesToAvoid,a.series.forEach(t=>(t.points||[]).forEach(r=>(r.dataLabels||[]).forEach(r=>{let{width:o,height:n}=r.getBBox(),a=(r.translateX||0)+(t.xAxis?t.xAxis.pos:t.chart.plotLeft),i=(r.translateY||0)+(t.yAxis?t.yAxis.pos:t.chart.plotTop);e.push({left:a,top:i,right:a+o,bottom:i+n})}))),t.forEach(function(t){let r=t.options.label||{};t.interpolatedPoints=function(t){let e,r,o,n,a;if(!t.xAxis&&!t.yAxis)return;let i=t.points,l=[],h=t.graph||t.area,s=h&&h.element,c=t.chart.inverted,p=t.xAxis,f=t.yAxis,x=c?f.pos:p.pos,b=c?p.pos:f.pos,g=c?p.len:f.len,y=c?f.len:p.len,m=d((t.options.label||{}).onArea,!!t.area),v=f.getThreshold(t.options.threshold),X={},w=c?"chartCenterX":"chartCenterY";function M(t){let e=Math.round((t.plotX||0)/8)+","+Math.round((t.plotY||0)/8);X[e]||(X[e]=1,l.push(t))}if(t.getPointSpline&&s&&s.getPointAtLength&&!m&&i.length<(t.chart.plotSizeX||0)/16){let t=h.toD&&h.attr("d");for(h.toD&&h.attr({d:h.toD}),o=s.getTotalLength(),e=0;e<o;e+=16){let t=s.getPointAtLength(e),r=c?y-t.y:t.x,o=c?g-t.x:t.y;M({chartX:x+r,chartY:b+o,plotX:r,plotY:o})}t&&h.attr({d:t});let r=i[i.length-1].pos();M({chartX:x+(r?.[0]||0),chartY:b+(r?.[1]||0)})}else{let t;for(e=0,o=i.length;e<o;e+=1){let o=i[e],[l,h]=o.pos()||[],{plotHigh:s}=o;if(u(l)&&u(h)){let e={plotX:l,plotY:h,chartX:x+l,chartY:b+h};if(m&&(s&&(e.plotY=s,e.chartY=b+s),c?e.chartCenterX=x+y-((s||o.plotY||0)+d(o.yBottom,v))/2:e.chartCenterY=b+((s||h)+d(o.yBottom,v))/2),t&&(r=Math.max(Math.abs(e.chartX-t.chartX),Math.abs(e.chartY-t.chartY)))>16&&r<999)for(a=1,n=Math.ceil(r/16);a<n;a+=1)M({chartX:t.chartX+(e.chartX-t.chartX)*(a/n),chartY:t.chartY+(e.chartY-t.chartY)*(a/n),[w]:(t[w]||0)+((e[w]||0)-(t[w]||0))*(a/n),plotX:(t.plotX||0)+(l-(t.plotX||0))*(a/n),plotY:(t.plotY||0)+(h-(t.plotY||0))*(a/n)});M(e),t=e}}}return l}(t),e.push(...r.boxesToAvoid||[])}),a.series.forEach(function(t){let e=t.options.label;if(!e||!t.xAxis&&!t.yAxis)return;let r="highcharts-color-"+d(t.colorIndex,"none"),o=!t.labelBySeries,n=e.minFontSize,i=e.maxFontSize,l=a.inverted,h=l?t.yAxis.pos:t.xAxis.pos,s=l?t.xAxis.pos:t.yAxis.pos,c=a.inverted?t.yAxis.len:t.xAxis.len,p=a.inverted?t.xAxis.len:t.yAxis.len,u=t.interpolatedPoints,g=d(e.onArea,!!t.area),y=[],m=t.getColumn("x"),v,w,M,A,Y,E,S=t.labelBySeries,P,L,T;function O(t,e,r){let o=Math.max(h,d(L,-1/0)),n=Math.min(h+c,d(T,1/0));return t>o&&t<=n-r.width&&e>=s&&e<=s+p-r.height}function B(){S&&(t.labelBySeries=S.destroy())}if(g&&!l&&(P=[t.xAxis.toPixels(m[0]),t.xAxis.toPixels(m[m.length-1])],L=Math.min.apply(Math,P),T=Math.max.apply(Math,P)),t.visible&&!t.boosted&&u){if(!S){var C,z,D;let o=t.name;if("string"==typeof e.format?o=b(e.format,t,a):e.formatter&&(o=e.formatter.call(t,t)),t.labelBySeries=S=a.renderer.label(o,0,0,"connector",0,0,e.useHTML).addClass("highcharts-series-label highcharts-series-label-"+t.index+" "+(t.options.className||"")+" "+r),!a.renderer.styledMode){let r="string"==typeof t.color?t.color:"#666666";S.css(f({color:g?a.renderer.getContrast(r):r},e.style||{})),S.attr({opacity:+!!a.renderer.forExport,stroke:t.color,"stroke-width":1})}n&&i&&S.css({fontSize:(C=t,z=n,D=i,z+(C.sum||0)/(C.chart.labelSeriesMaxSum||0)*(D-z)+"px")}),S.attr({padding:0,zIndex:3}).add()}for((v=S.getBBox()).width=Math.round(v.width),Y=u.length-1;Y>0;Y-=1)g?O(w=(u[Y].chartCenterX??u[Y].chartX)-v.width/2,M=(u[Y].chartCenterY??u[Y].chartY)-v.height/2,v)&&(E=X(t,w,M,v)):(O(w=u[Y].chartX+3,M=u[Y].chartY-v.height-3,v)&&(E=X(t,w,M,v,!0)),E&&y.push(E),O(w=u[Y].chartX+3,M=u[Y].chartY+3,v)&&(E=X(t,w,M,v,!0)),E&&y.push(E),O(w=u[Y].chartX-v.width-3,M=u[Y].chartY+3,v)&&(E=X(t,w,M,v,!0)),E&&y.push(E),O(w=u[Y].chartX-v.width-3,M=u[Y].chartY-v.height-3,v)&&(E=X(t,w,M,v,!0))),E&&y.push(E);if(e.connectorAllowed&&!y.length&&!g)for(w=h+c-v.width;w>=h;w-=16)for(M=s;M<s+p-v.height;M+=16)(A=X(t,w,M,v,!0))&&y.push(A);if(y.length){y.sort((t,e)=>e.weight-t.weight),E=y[0],(a.boxesToAvoid||[]).push({left:E.x,right:E.x+v.width,top:E.y,bottom:E.y+v.height});let e=Math.sqrt(Math.pow(Math.abs(E.x-(S.x||0)),2)+Math.pow(Math.abs(E.y-(S.y||0)),2));if(e&&t.labelBySeries){let r,n={opacity:+!!a.renderer.forExport,x:E.x,y:E.y},i={opacity:1};e<=10&&(i={x:n.x,y:n.y},n={}),o&&(r=x(t.options.animation),r.duration*=.2),t.labelBySeries.attr(f(n,{anchorX:E.connectorPoint&&(E.connectorPoint.plotX||0)+h,anchorY:E.connectorPoint&&(E.connectorPoint.plotY||0)+s})).animate(i,r),t.options.kdNow=!0,t.buildKDTree();let l=t.searchPoint({chartX:E.x,chartY:E.y},!0);l&&(S.closest=[l,E.x-(l.plotX||0),E.y-(l.plotY||0)])}}else B()}else B()}),function(t,e,r,n){if(r=r||{},s?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==o())){let o=s.createEvent("Events");o.initEvent(e,!0,!0),r=f(o,r),t.dispatchEvent?t.dispatchEvent(r):t.fireEvent(e,r)}else if(t.hcEvents){r.target||f(r,{preventDefault:function(){r.defaultPrevented=!0},target:t,type:e});let o=[],n=t,a=!1;for(;n.hcEvents;)Object.hasOwnProperty.call(n,"hcEvents")&&n.hcEvents[e]&&(o.length&&(a=!0),o.unshift.apply(o,n.hcEvents[e])),n=Object.getPrototypeOf(n);a&&o.sort((t,e)=>t.order-e.order),o.forEach(e=>{!1===e.fn.call(t,r,t)&&r.preventDefault()})}}(a,"afterDrawSeriesLabels"))},a.seriesLabelTimer=(n=a.renderer.forExport||!i?0:i)>0?setTimeout(r,n,void 0):(r.call(0,void 0),-1)}}function M(t,e,r,o,n){let a=n&&n.anchorX,i=n&&n.anchorY,l,h,s=r/2;return u(a)&&u(i)&&(l=[["M",a,i]],(h=e-i)<0&&(h=-o-h),h<r&&(s=a<t+r/2?h:r-h),i>e+o?l.push(["L",t+s,e+o]):i<e?l.push(["L",t+s,e]):a<t?l.push(["L",t,e+o/2]):a>t+r&&l.push(["L",t+r,e+o/2])),l||[]}let A=o();({compose:function(t,e){var r;r="SeriesLabel",0>y.indexOf(r)&&y.push(r)&&(p(t,"load",w),p(t,"redraw",w),e.prototype.symbols.connector=M,g({plotOptions:{series:{label:i}}}))}}).compose(A.Chart,A.SVGRenderer);let Y=o();export{Y as default};