/**
 * Highmaps JS v13.0.0 (2026-06-11)
 * @module highcharts/modules/heatmap
 * @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";import"./coloraxis.js";var e,r={};r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var a=r.n(i);let s=t.default.Color;var o=r.n(s);let l=t.default.SeriesRegistry;var n=r.n(l);let h=t.default.SVGElement;var p=r.n(h);let{column:{prototype:u}}=n().seriesTypes;var d=e||(e={});function c(t){let e=this.series,r=e.chart.renderer;this.moveToTopOnHover&&this.graphic&&(e.stateMarkerGraphic||(e.stateMarkerGraphic=new(p())(r,"use").css({pointerEvents:"none"}).add(this.graphic.parentGroup)),t?.state==="hover"?(this.graphic.attr({id:this.id}),e.stateMarkerGraphic.attr({href:`${r.url}#${this.id}`,visibility:"visible"})):e.stateMarkerGraphic.attr({href:""}))}d.pointMembers={dataLabelOnNull:!0,moveToTopOnHover:!0,isValid:function(){return null!==this.value&&this.value!==1/0&&this.value!==-1/0&&(void 0===this.value||!isNaN(this.value))}},d.seriesMembers={colorKey:"value",axisTypes:["xAxis","yAxis","colorAxis"],parallelArrays:["x","y","value"],pointArrayMap:["value"],trackerGroups:["group","markerGroup","dataLabelsGroup"],colorAttribs:function(t){let e={};return(0,i.defined)(t.color)&&(!t.state||"normal"===t.state)&&(e[this.colorProp||"fill"]=t.color),e},pointAttribs:u.pointAttribs},d.compose=function(t){let e=t.prototype.pointClass;return(0,i.addEvent)(e,"afterSetState",c),t};let m=e,{scatter:{prototype:{pointClass:g}}}=n().seriesTypes;class y extends g{applyOptions(t,e){return(this.isNull||null===this.value)&&delete this.color,super.applyOptions(t,e),this.formatPrefix=this.isNull||null===this.value?"null":"point",this}getCellAttributes(){let t=this.series,e=t.options,r=(e.colsize||1)/2,a=(e.rowsize||1)/2,s=t.xAxis,o=t.yAxis,l=this.options.marker||t.options.marker,n=t.pointPlacementToXValue(),h=(0,i.pick)(this.pointPadding,e.pointPadding,0),p={x1:(0,i.clamp)(Math.round(s.len-s.translate(this.x-r,!1,!0,!1,!0,-n)),-s.len,2*s.len),x2:(0,i.clamp)(Math.round(s.len-s.translate(this.x+r,!1,!0,!1,!0,-n)),-s.len,2*s.len),y1:(0,i.clamp)(Math.round(o.translate(this.y-a,!1,!0,!1,!0)),-o.len,2*o.len),y2:(0,i.clamp)(Math.round(o.translate(this.y+a,!1,!0,!1,!0)),-o.len,2*o.len)};for(let t of[["width","x"],["height","y"]]){let e=t[0],r=t[1],a=r+"1",n=r+"2",u=Math.abs(p[a]-p[n]),d=l&&l.lineWidth||0,c=Math.abs(p[a]+p[n])/2,m=l&&l[e];if((0,i.defined)(m)&&m<u){let t=m/2+d/2;p[a]=c-t,p[n]=c+t}h&&(("x"===r&&s.reversed||"y"===r&&!o.reversed)&&(a=n,n=r+"1"),p[a]+=h,p[n]-=h)}return p}haloPath(t){if(!t)return[];let{x:e=0,y:r=0,width:i=0,height:a=0}=this.shapeArgs||{};return[["M",e-t,r-t],["L",e-t,r+a+t],["L",e+i+t,r+a+t],["L",e+i+t,r-t],["Z"]]}isValid(){return this.value!==1/0&&this.value!==-1/0}}(0,i.extend)(y.prototype,{dataLabelOnNull:!0,moveToTopOnHover:!0,ttBelow:!1});let b=t.default.SVGRenderer;var v=r.n(b);let{doc:x}=a(),{series:f,seriesTypes:{column:M,scatter:k}}=n(),{prototype:{symbols:A}}=v(),{colorFromPoint:C,getContext:w}={colorFromPoint:function(t,e){let r=e.series.colorAxis;if(r){let a=r.toColor(t||0,e).split(")")[0].split("(")[1].split(",").map(t=>(0,i.pick)(parseFloat(t),parseInt(t,10)));return a[3]=255*(0,i.pick)(a[3],1),(0,i.defined)(t)&&e.visible||(a[3]=0),a}return[0,0,0,0]},getContext:function(t){let{canvas:e,context:r}=t;return e&&r?.clearRect?(r.clearRect(0,0,e.width,e.height),r):(t.canvas=x.createElement("canvas"),t.context=t.canvas.getContext("2d",{willReadFrequently:!0})||void 0,t.context)}};class P extends k{constructor(){super(...arguments),this.valueMax=NaN,this.valueMin=NaN,this.isDirtyCanvas=!0}drawPoints(){let t=this,e=t.options,r=e.interpolation,i=e.marker||{};if(r){let{image:e,chart:r,xAxis:i,yAxis:a}=t,{reversed:s=!1,len:o}=i,{reversed:l=!1,len:n}=a,h={width:o,height:n};if(!e||t.isDirtyData||t.isDirtyCanvas){let o=w(t),{canvas:n,options:{colsize:p=1,rowsize:u=1},points:d,points:{length:c}}=t,m=r.colorAxis&&r.colorAxis[0];if(n&&o&&m){let{min:m,max:g}=i.getExtremes(),{min:y,max:b}=a.getExtremes(),v=g-m,x=b-y,f=Math.round(v/p/8*8),M=Math.round(x/u/8*8),[k,A]=[[f,f/v,s,"ceil"],[M,M/x,!l,"floor"]].map(([t,e,r,i])=>r?r=>Math[i](t-e*r):t=>Math[i](e*t)),w=n.width=f+1,P=w*(n.height=M+1),T=(c-1)/P,D=new Uint8ClampedArray(4*P),N=(t,e)=>4*Math.ceil(w*A(e-y)+k(t-m));t.buildKDTree();for(let t=0;t<P;t++){let e=d[Math.ceil(T*t)],{x:r,y:i}=e;D.set(C(e.value,e),N(r,i))}o.putImageData(new ImageData(D,w),0,0),e?e.attr({...h,href:n.toDataURL("image/png",1)}):(t.directTouch=!1,t.image=r.renderer.image(n.toDataURL("image/png",1)).attr(h).add(t.group))}t.isDirtyCanvas=!1}else(e.width!==o||e.height!==n)&&e.attr(h)}else(i.enabled||t._hasPointMarkers)&&(f.prototype.drawPoints.call(t),t.points.forEach(e=>{e.graphic&&(e.graphic[t.chart.styledMode?"css":"animate"](t.colorAttribs(e)),null===e.value&&e.graphic.addClass("highcharts-null-point"))}))}getSymbol(){this.symbol=this.options.marker?.symbol||"rect"}getExtremes(){let{dataMin:t,dataMax:e}=f.prototype.getExtremes.call(this,this.getColumn("value"));return(0,i.isNumber)(t)&&(this.valueMin=t),(0,i.isNumber)(e)&&(this.valueMax=e),f.prototype.getExtremes.call(this)}getValidPoints(t,e){return f.prototype.getValidPoints.call(this,t,e,!0)}hasData(){return!!this.dataTable.rowCount}init(){super.init.apply(this,arguments);let t=this.options;t.pointRange=(0,i.pick)(t.pointRange,t.colsize||1),this.yAxis.axisPointRange=t.rowsize||1,A.ellipse=A.circle,t.marker&&(0,i.isNumber)(t.borderRadius)&&(t.marker.r=t.borderRadius);let e=this.canvas=document.createElement("canvas");e&&(this.context=e?.getContext("webgpu"))}markerAttribs(t,e){let r=t.shapeArgs||{};if(t.hasImage)return{x:t.plotX,y:t.plotY};if(e&&"normal"!==e){let i=t.options.marker||{},a=this.options.marker||{},s=a.states?.[e]||{},o=i.states?.[e]||{},l=(o.width||s.width||r.width||0)+(o.widthPlus||s.widthPlus||0),n=(o.height||s.height||r.height||0)+(o.heightPlus||s.heightPlus||0);return{x:(r.x||0)+((r.width||0)-l)/2,y:(r.y||0)+((r.height||0)-n)/2,width:l,height:n}}return r}pointAttribs(t,e){let r=f.prototype.pointAttribs.call(this,t,e),a=this.options||{},s=this.chart.options.plotOptions||{},l=s.series||{},n=s.heatmap||{},h=t?.options.borderColor||a.borderColor||n.borderColor||l.borderColor,p=t?.options.borderWidth||a.borderWidth||n.borderWidth||l.borderWidth||r["stroke-width"];if(r.stroke=t?.marker?.lineColor||a.marker?.lineColor||h||this.color,r["stroke-width"]=p,e&&"normal"!==e){let s=(0,i.merge)(a.states?.[e],a.marker?.states?.[e],t?.options.marker?.states?.[e]||{});r.fill=s.color||o().parse(r.fill).brighten(s.brightness||0).get(),r.stroke=s.lineColor||r.stroke}return r}translate(){let{borderRadius:t,marker:e}=this.options,r=e?.symbol||"rect",a=A[r]?r:"rect",s=-1!==["circle","square"].indexOf(a);for(let e of(this.generatePoints(),this.points)){let o=e.getCellAttributes(),l=Math.min(o.x1,o.x2),n=Math.min(o.y1,o.y2),h=Math.max(Math.abs(o.x2-o.x1),0),p=Math.max(Math.abs(o.y2-o.y1),0);if(e.hasImage=0===(e.marker?.symbol||r||"").indexOf("url"),s){let t=Math.abs(h-p);l=Math.min(o.x1,o.x2)+(h<p?0:t/2),n=Math.min(o.y1,o.y2)+(h<p?t/2:0),h=p=Math.min(h,p)}e.hasImage&&(e.marker={width:h,height:p}),e.plotX=e.clientX=(o.x1+o.x2)/2,e.plotY=(o.y1+o.y2)/2,e.shapeType="path",e.shapeArgs=(0,i.merge)(!0,{x:l,y:n,width:h,height:p},{d:A[a](l,n,h,p,{r:(0,i.isNumber)(t)?t:0})})}(0,i.fireEvent)(this,"afterTranslate")}}P.defaultOptions=(0,i.merge)(k.defaultOptions,{animation:!1,borderRadius:0,borderWidth:0,interpolation:!1,nullColor:"var(--highcharts-neutral-color-3)",dataLabels:{formatter:function(){let{numberFormatter:t}=this.series.chart,{value:e}=this.point;return(0,i.isNumber)(e)?t(e,-1):""},inside:!0,verticalAlign:"middle",crop:!1,overflow:"allow",padding:0},marker:{radius:0,lineColor:void 0,states:{hover:{lineWidthPlus:0},select:{}}},clip:!0,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{hover:{halo:!1,brightness:.2}},legendSymbol:"rectangle"}),(0,i.addEvent)(P,"afterDataClassLegendClick",function(){this.isDirtyCanvas=!0,this.drawPoints(),this.options.enableMouseTracking&&this.drawTracker()}),(0,i.extend)(P.prototype,{axisTypes:m.seriesMembers.axisTypes,colorKey:m.seriesMembers.colorKey,directTouch:!0,getExtremesFromAll:!0,keysAffectYAxis:["y"],parallelArrays:m.seriesMembers.parallelArrays,pointArrayMap:["y","value"],pointClass:y,specialGroup:"group",trackerGroups:m.seriesMembers.trackerGroups,alignDataLabel:M.prototype.alignDataLabel,colorAttribs:m.seriesMembers.colorAttribs}),m.compose(P),n().registerSeriesType("heatmap",P);let T=a();export{T as default};