/**
 * Highmaps JS v12.6.0 (2026-04-13)
 * @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 o=r.n(i);let a=t.default.Color;var s=r.n(a);let n=t.default.SeriesRegistry;var l=r.n(n);let p=t.default.SVGElement;var h=r.n(p);let{doc:c,win:u}=o();function d(t,e,r,i={}){let a="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(a,"hcEvents")||(a.hcEvents={});let s=a.hcEvents;o().Point&&t instanceof o().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let n=t.addEventListener;n&&n.call(t,e,r,!!o().supportsPassiveEvents&&{passive:void 0===i.passive?-1!==e.indexOf("touch"):i.passive,capture:!1}),s[e]||(s[e]=[]);let l={fn:r,order:"number"==typeof i.order?i.order:1/0};return s[e].push(l),s[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,r){function i(e,r){let i=t.removeEventListener;i&&i.call(t,e,r,!1)}function o(r){let o,a;t.nodeName&&(e?(o={})[e]=!0:o=r,x(o,function(t,e){if(r[e])for(a=r[e].length;a--;)i(e,r[e][a].fn)}))}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}),i(e,r)):(o(t),t[e]=[])}else o(t),delete a.hcEvents}}(t,e,r)}}function f(t,e,r){return t>e?t<r?t:r:e}function y(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function m(t){return g(t)&&"number"==typeof t.nodeType}function v(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function g(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function b(t,...e){let r,i=[t,...e],o={},a=function(t,e){return"object"!=typeof t&&(t={}),x(e,function(r,i){if("__proto__"!==i&&"constructor"!==i){let o;!g(r,!0)||(o=r?.constructor,g(r,!0)&&!m(r)&&o?.name&&"Object"!==o.name)||m(r)?t[i]=e[i]:t[i]=a(t[i]||{},r)}}),t};!0===t&&(o=i[1],i=Array.prototype.slice.call(i,2));let s=i.length;for(r=0;r<s;r++)o=a(o,i[r]);return o}function x(t,e,r){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(r||t[i],t[i],i,t)}function M(){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{column:{prototype:A}}=l().seriesTypes;var k=e||(e={});function E(t){let e=this.series,r=e.chart.renderer;this.moveToTopOnHover&&this.graphic&&(e.stateMarkerGraphic||(e.stateMarkerGraphic=new(h())(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:""}))}k.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))}},k.seriesMembers={colorKey:"value",axisTypes:["xAxis","yAxis","colorAxis"],parallelArrays:["x","y","value"],pointArrayMap:["value"],trackerGroups:["group","markerGroup","dataLabelsGroup"],colorAttribs:function(t){let e={};return null==t.color||t.state&&"normal"!==t.state||(e[this.colorProp||"fill"]=t.color),e},pointAttribs:A.pointAttribs},k.compose=function(t){return d(t.prototype.pointClass,"afterSetState",E),t};let w=e,{scatter:{prototype:{pointClass:P}}}=l().seriesTypes;class C extends P{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,i=(e.rowsize||1)/2,o=t.xAxis,a=t.yAxis,s=this.options.marker||t.options.marker,n=t.pointPlacementToXValue(),l=M(this.pointPadding,e.pointPadding,0),p={x1:f(Math.round(o.len-o.translate(this.x-r,!1,!0,!1,!0,-n)),-o.len,2*o.len),x2:f(Math.round(o.len-o.translate(this.x+r,!1,!0,!1,!0,-n)),-o.len,2*o.len),y1:f(Math.round(a.translate(this.y-i,!1,!0,!1,!0)),-a.len,2*a.len),y2:f(Math.round(a.translate(this.y+i,!1,!0,!1,!0)),-a.len,2*a.len)};for(let t of[["width","x"],["height","y"]]){let e=t[0],r=t[1],i=r+"1",n=r+"2",h=Math.abs(p[i]-p[n]),c=s&&s.lineWidth||0,u=Math.abs(p[i]+p[n])/2,d=s&&s[e];if(null!=d&&d<h){let t=d/2+c/2;p[i]=u-t,p[n]=u+t}l&&(("x"===r&&o.reversed||"y"===r&&!a.reversed)&&(i=n,n=r+"1"),p[i]+=l,p[n]-=l)}return p}haloPath(t){if(!t)return[];let{x:e=0,y:r=0,width:i=0,height:o=0}=this.shapeArgs||{};return[["M",e-t,r-t],["L",e-t,r+o+t],["L",e+i+t,r+o+t],["L",e+i+t,r-t],["Z"]]}isValid(){return this.value!==1/0&&this.value!==-1/0}}y(C.prototype,{dataLabelOnNull:!0,moveToTopOnHover:!0,ttBelow:!1});let O=t.default.SVGRenderer;var T=r.n(O);let{doc:D}=o(),{series:j,seriesTypes:{column:L,scatter:R}}=l(),{prototype:{symbols:G}}=T(),{colorFromPoint:N,getContext:S}={colorFromPoint:function(t,e){let r=e.series.colorAxis;if(r){let i=r.toColor(t||0,e).split(")")[0].split("(")[1].split(",").map(t=>M(parseFloat(t),parseInt(t,10)));return i[3]=255*M(i[3],1),null!=t&&e.visible||(i[3]=0),i}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=D.createElement("canvas"),t.context=t.canvas.getContext("2d",{willReadFrequently:!0})||void 0,t.context)}};class _ extends R{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:o}=t,{reversed:a=!1,len:s}=i,{reversed:n=!1,len:l}=o,p={width:s,height:l};if(!e||t.isDirtyData||t.isDirtyCanvas){let s=S(t),{canvas:l,options:{colsize:h=1,rowsize:c=1},points:u,points:{length:d}}=t,f=r.colorAxis&&r.colorAxis[0];if(l&&s&&f){let{min:f,max:y}=i.getExtremes(),{min:m,max:v}=o.getExtremes(),g=y-f,b=v-m,x=Math.round(g/h/8*8),M=Math.round(b/c/8*8),[A,k]=[[x,x/g,a,"ceil"],[M,M/b,!n,"floor"]].map(([t,e,r,i])=>r?r=>Math[i](t-e*r):t=>Math[i](e*t)),E=l.width=x+1,w=E*(l.height=M+1),P=(d-1)/w,C=new Uint8ClampedArray(4*w),O=(t,e)=>4*Math.ceil(E*k(e-m)+A(t-f));t.buildKDTree();for(let t=0;t<w;t++){let e=u[Math.ceil(P*t)],{x:r,y:i}=e;C.set(N(e.value,e),O(r,i))}s.putImageData(new ImageData(C,E),0,0),e?e.attr({...p,href:l.toDataURL("image/png",1)}):(t.directTouch=!1,t.image=r.renderer.image(l.toDataURL("image/png",1)).attr(p).add(t.group))}t.isDirtyCanvas=!1}else(e.width!==s||e.height!==l)&&e.attr(p)}else(i.enabled||t._hasPointMarkers)&&(j.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"))}))}getExtremes(){let{dataMin:t,dataMax:e}=j.prototype.getExtremes.call(this,this.getColumn("value"));return v(t)&&(this.valueMin=t),v(e)&&(this.valueMax=e),j.prototype.getExtremes.call(this)}getValidPoints(t,e){return j.prototype.getValidPoints.call(this,t,e,!0)}hasData(){return!!this.dataTable.rowCount}init(){super.init.apply(this,arguments);let t=this.options;t.pointRange=M(t.pointRange,t.colsize||1),this.yAxis.axisPointRange=t.rowsize||1,G.ellipse=G.circle,t.marker&&v(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||{},o=this.options.marker||{},a=o.states?.[e]||{},s=i.states?.[e]||{},n=(s.width||a.width||r.width||0)+(s.widthPlus||a.widthPlus||0),l=(s.height||a.height||r.height||0)+(s.heightPlus||a.heightPlus||0);return{x:(r.x||0)+((r.width||0)-n)/2,y:(r.y||0)+((r.height||0)-l)/2,width:n,height:l}}return r}pointAttribs(t,e){let r=j.prototype.pointAttribs.call(this,t,e),i=this.options||{},o=this.chart.options.plotOptions||{},a=o.series||{},n=o.heatmap||{},l=t?.options.borderColor||i.borderColor||n.borderColor||a.borderColor,p=t?.options.borderWidth||i.borderWidth||n.borderWidth||a.borderWidth||r["stroke-width"];if(r.stroke=t?.marker?.lineColor||i.marker?.lineColor||l||this.color,r["stroke-width"]=p,e&&"normal"!==e){let o=b(i.states?.[e],i.marker?.states?.[e],t?.options.marker?.states?.[e]||{});r.fill=o.color||s().parse(r.fill).brighten(o.brightness||0).get(),r.stroke=o.lineColor||r.stroke}return r}translate(){let{borderRadius:t,marker:e}=this.options,r=e?.symbol||"rect",i=G[r]?r:"rect",a=-1!==["circle","square"].indexOf(i);for(let e of(this.generatePoints(),this.points)){let o=e.getCellAttributes(),s=Math.min(o.x1,o.x2),n=Math.min(o.y1,o.y2),l=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"),a){let t=Math.abs(l-p);s=Math.min(o.x1,o.x2)+(l<p?0:t/2),n=Math.min(o.y1,o.y2)+(l<p?t/2:0),l=p=Math.min(l,p)}e.hasImage&&(e.marker={width:l,height:p}),e.plotX=e.clientX=(o.x1+o.x2)/2,e.plotY=(o.y1+o.y2)/2,e.shapeType="path",e.shapeArgs=b(!0,{x:s,y:n,width:l,height:p},{d:G[i](s,n,l,p,{r:v(t)?t:0})})}!function(t,e,r,i){if(r=r||{},c?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==o())){let i=c.createEvent("Events");i.initEvent(e,!0,!0),r=y(i,r),t.dispatchEvent?t.dispatchEvent(r):t.fireEvent(e,r)}else if(t.hcEvents){r.target||y(r,{preventDefault:function(){r.defaultPrevented=!0},target:t,type:e});let i=[],o=t,a=!1;for(;o.hcEvents;)Object.hasOwnProperty.call(o,"hcEvents")&&o.hcEvents[e]&&(i.length&&(a=!0),i.unshift.apply(i,o.hcEvents[e])),o=Object.getPrototypeOf(o);a&&i.sort((t,e)=>t.order-e.order),i.forEach(e=>{!1===e.fn.call(t,r,t)&&r.preventDefault()})}}(this,"afterTranslate")}}_.defaultOptions=b(R.defaultOptions,{animation:!1,borderRadius:0,borderWidth:0,interpolation:!1,nullColor:"#f7f7f7",dataLabels:{formatter:function(){let{numberFormatter:t}=this.series.chart,{value:e}=this.point;return v(e)?t(e,-1):""},inside:!0,verticalAlign:"middle",crop:!1,overflow:"allow",padding:0},marker:{symbol:"rect",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"}),d(_,"afterDataClassLegendClick",function(){this.isDirtyCanvas=!0,this.drawPoints(),this.options.enableMouseTracking&&this.drawTracker()}),y(_.prototype,{axisTypes:w.seriesMembers.axisTypes,colorKey:w.seriesMembers.colorKey,directTouch:!0,getExtremesFromAll:!0,keysAffectYAxis:["y"],parallelArrays:w.seriesMembers.parallelArrays,pointArrayMap:["y","value"],pointClass:C,specialGroup:"group",trackerGroups:w.seriesMembers.trackerGroups,alignDataLabel:L.prototype.alignDataLabel,colorAttribs:w.seriesMembers.colorAttribs,getSymbol:j.prototype.getSymbol}),w.compose(_),l().registerSeriesType("heatmap",_);let I=o();export{I as default};