"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6987],{91866:(e,t,l)=>{l.d(t,{q:()=>r});var a=l(77813),n=l(76687),i=l(27668),o=l(52010);const r=e=>{let{colorPalette:t,min:l,max:a,display:r,hoverValue:u,useStopsPercentage:c}=e;const[m,h]=(0,n.useState)([]),[p,v]=(0,n.useState)({isShown:!1,value:0}),[f,g]=(0,n.useState)(null),x=(0,i.l4)(),y=d(x,m);(0,n.useEffect)((()=>{h(s({colorArray:t,stops:10,useStopsPercentage:c}))}),[t,c]);return(0,n.useEffect)((()=>{g(null==u?null:function(e){if(e>1)return 100;if(e<0)return 0;return 100*e}((u-l)/(a-l)))}),[u,l,a]),(0,o.jsxs)("div",{className:y.scaleWrapper,onMouseMove:e=>{const t=e.nativeEvent.offsetX,n=e.target.offsetWidth,i=Math.floor(100*t/n+1),o=Math.floor((a-l)*i/100+l);v({isShown:!0,value:o}),g(i)},onMouseLeave:()=>{v({isShown:!1,value:0})},children:[(0,o.jsx)("div",{className:y.scaleGradient,children:r&&(p.isShown||void 0!==u)&&(0,o.jsx)("div",{className:y.followerContainer,children:(0,o.jsx)("div",{className:y.follower,style:{left:`${f}%`}})})}),r&&(0,o.jsxs)("div",{className:y.followerContainer,children:[(0,o.jsxs)("div",{className:y.legendValues,children:[(0,o.jsx)("span",{children:r(l)}),(0,o.jsx)("span",{children:r(a)})]}),null!=f&&(p.isShown||void 0!==u)&&(0,o.jsx)("span",{className:y.hoverValue,style:{left:`${f}%`},children:r(null!=u?u:p.value)})]})]})},s=e=>{let{colorArray:t,stops:l,useStopsPercentage:a=!0}=e;const n=t.length;if(a&&n<=20){const e=1/n*100;let l=0;const a=[];for(const n of t)l>0?a.push(`${n} ${l}%`):a.push(n),l+=e,a.push(`${n} ${l}%`);return a}const i=t[n-1],o=Math.ceil(n/l),r=new Set;for(let e=0;e<n;e+=o)r.add(t[e]);return r.add(i),[...r]};const d=(e,t)=>({scaleWrapper:a.css`
    width: 100%;
    font-size: 11px;
    opacity: 1;
  `,scaleGradient:a.css`
    background: linear-gradient(90deg, ${t.join()});
    height: 10px;
    pointer-events: none;
  `,legendValues:a.css`
    display: flex;
    justify-content: space-between;
    pointer-events: none;
  `,hoverValue:a.css`
    position: absolute;
    margin-top: -14px;
    padding: 3px 15px;
    background: ${e.colors.background.primary};
    transform: translateX(-50%);
  `,followerContainer:a.css`
    position: relative;
    pointer-events: none;
    white-space: nowrap;
  `,follower:a.css`
    position: absolute;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    transform: translateX(-50%) translateY(-50%);
    border: 2px solid ${e.colors.text.primary};
    margin-top: 5px;
  `})},4873:(e,t,l)=>{l.r(t),l.d(t,{plugin:()=>he});var a=l(76687),n=l(92394),i=l(78755),o=l(72671),r=l(37330),s=l(67273),d=l(98277),u=l(7286),c=l(7705),m=l(91866),h=l(61097),p=l(67641),v=l(72218),f=l(77813),g=l(39652),x=l(12740),y=l(27668),w=l(98189),b=l(8250),k=l(25241),S=l(31504),B=l(70468),M=l(64341),V=l(63469),C=l(20202),D=l(7053),L=l(55312),A=l(50137),j=l(54643),O=l(52010);const P=e=>2===e.hover.seriesIdx?(0,O.jsx)(j.H,{data:e.data.exemplars,rowIndex:e.hover.dataIdx}):(0,O.jsx)(R,Object.assign({},e)),R=e=>{var t,l,n,i,r,s;let{data:d,hover:u,showHistogram:c}=e;const m=u.dataIdx,h=null===(t=d.heatmap)||void 0===t?void 0:t.fields[0],f=null===(l=d.heatmap)||void 0===l?void 0:l.fields[1],x=null===(n=d.heatmap)||void 0===n?void 0:n.fields[2],y=e=>{if(null!=h&&h.display)return(0,V.zc)(h.display(e));if((null==h?void 0:h.type)===o.fS.time){const t="YYYY-MM-DD HH:mm:ss",l=(0,A.h4)().getCurrent();return null==l?void 0:l.formatDate(e,t)}return`${e}`},w=null==h?void 0:h.values.toArray(),b=null==f?void 0:f.values.toArray(),k=null==x?void 0:x.values.toArray(),S=null!==(i=(0,p.d8)(d.heatmap).yOrdinalDisplay)&&void 0!==i?i:b,B=null!=f&&f.display?e=>(0,V.zc)(f.display(e)):e=>`${e}`,M=null!==(r=m%d.yBucketCount)&&void 0!==r?r:0,P=d.yLayout===v.D.le?M-1:M,R=d.yLayout===v.D.le?M:M+1,I=null==S?void 0:S[P],H=null==S?void 0:S[R];let E,N;d.xLayout===v.D.le?(N=null==w?void 0:w[m],E=N-d.xBucketSize):(E=null==w?void 0:w[m],N=E+d.xBucketSize);const z=null==k?void 0:k[m],G=null===(s=d.heatmap)||void 0===s?void 0:s.fields.filter((e=>{var t,l;return!Boolean(null===(t=e.config.custom)||void 0===t||null===(l=t.hideFrom)||void 0===l?void 0:l.tooltip)})),Y=[],F=new Set;for(const e of null!=G?G:[])if(e.getLinks){const t=e.values.get(m),l=e.display?e.display(t):{text:`${t}`,numeric:+t};e.getLinks({calculatedValue:l,valueRowIndex:m}).forEach((e=>{const t=`${e.title}/${e.href}`;F.has(t)||(Y.push(e),F.add(t))}))}let T=(0,a.useRef)(null),$=Math.round(150*devicePixelRatio),_=Math.round(50*devicePixelRatio);(0,a.useEffect)((()=>{if(c){var e;let t=null===(e=T.current)||void 0===e?void 0:e.getContext("2d");if(t&&w&&b&&k){let e=m;for(;w[e--]===w[m];);e++;let l=e+d.yBucketCount,a=0,n=e;for(;n<l;){let e=k[n];a=Math.max(a,e),n++}let i=new Path2D,o=new Path2D;n=e;let r=0;for(;n<l;){let e=k[n];if(e>0){let t=e/a,l=r/(d.yBucketCount+1);(n===m?i:o).rect(Math.round($*l),Math.round(_*(1-t)),Math.round($/d.yBucketCount),Math.round(_*t))}n++,r++}t.clearRect(0,0,$,_),t.fillStyle="#ffffff80",t.fill(o),t.fillStyle="#ff000080",t.fill(i)}}}),[m]);const[W]=(0,a.useState)((()=>{var e,t;return(null===(e=d.heatmap)||void 0===e||null===(t=e.meta)||void 0===t?void 0:t.type)===g.P.HeatmapCells&&!(0,p.qJ)(d.heatmap)}));if(W)return(0,O.jsx)("div",{children:(0,O.jsx)(j.H,{data:d.heatmap,rowIndex:m})});return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("div",{children:[(0,O.jsx)("div",{children:y(E)}),(0,O.jsx)("div",{children:y(N)})]}),c&&(0,O.jsx)("canvas",{width:$,height:_,ref:T,style:{width:$+"px",height:_+"px"}}),(0,O.jsxs)("div",{children:[d.yLayout===v.D.unknown?(0,O.jsx)("div",{children:B(I)}):(0,O.jsxs)("div",{children:["Bucket: ",B(I)," - ",B(H)]}),(0,O.jsxs)("div",{children:[(0,C.C)(x,d.heatmap),": ",d.display(z)]})]}),Y.length>0&&(0,O.jsx)(D.wc,{children:Y.map(((e,t)=>(0,O.jsx)(L.Qj,{icon:"external-link-alt",target:e.target,href:e.href,onClick:e.onClick,fill:"text",style:{width:"100%"},children:e.title},t)))})]})};var I=l(52103),H=l(64239),E=l(53693),N=l(82302),z=l(19291),G=l(92350),Y=l(71133),F=l(28640);function T(e){const{disp:t,each:l,gap:a=1,hideLE:n=-1/0,hideGE:i=1/0,xAlign:o=1,yAlign:r=1,ySizeDivisor:s=1}=e,d=devicePixelRatio,u=a>=4?Math.round:e=>e,c=Math.round(a*d);return(e,a)=>(E.Z.orient(e,a,((d,m,h,p,v,f,g,x,y,w,b,k,S,B,M)=>{var V;let C=e.data[a];const D=C[0],L=C[1],A=C[2],j=D.length;let O,P,R=t.fill.values(e,a),I=null!==(V=t.fill.index)&&void 0!==V?V:[...new Set(R)],H=I.map((e=>new Path2D)),E=j-L.lastIndexOf(L[0]),N=j/E,z=L[1]-L[0]||v.max-v.min,G=D[E]-D[0];O=3===p.distr?Math.abs(f(D[0]*p.log,p,w,x)-f(D[0],p,w,x)):Math.abs(f(G,p,w,x)-f(0,p,w,x)),P=3===v.distr?Math.abs(g(L[0]*v.log,v,b,y)-g(L[0],v,b,y))/s:Math.abs(g(z,v,b,y)-g(0,v,b,y))/s,O=Math.max(1,u(O-c)),P=Math.max(1,u(P-c));let Y=-1===o?-O:0===o?-O/2:0,F=1===r?-P:0===r?-P/2:0,T=L.slice(0,E).map((e=>u(g(e,v,b,y)+F))),$=Array.from({length:N},((e,t)=>u(f(D[t*E],p,w,x)+Y)));for(let t=0;t<j;t++)if(A[t]>n&&A[t]<i){let a=$[~~(t/E)],n=T[t%E];B(H[R[t]],a,n,O,P),l(e,1,t,a,n,O,P)}return e.ctx.save(),e.ctx.rect(e.bbox.left,e.bbox.top,e.bbox.width,e.bbox.height),e.ctx.clip(),H.forEach(((t,l)=>{e.ctx.fillStyle=I[l],e.ctx.fill(t)})),e.ctx.restore(),null})),null)}function $(e,t){return(l,a)=>(E.Z.orient(l,a,((n,i,o,r,s,d,u,c,m,h,p,v,f,g,x)=>{[i,o]=o;let y=new Path2D,w=[y],b=[null!=t?t:"rgba(255,0,255,0.7)"];for(let t=0;t<i.length;t++){let n=o[t];n-=.5,n+=.5*(2*Math.round(Math.random())-1)*Math.random();let v=d(i[t],r,h,c),f=u(n,s,p,m),x=8,w=8;g(y,v-x/2,f-w/2,x,w),e.each(l,a,t,v-x/2,f-w/2,x,w)}l.ctx.save(),l.ctx.rect(l.bbox.left,l.bbox.top,l.bbox.width,l.bbox.height),l.ctx.clip(),w.forEach(((e,t)=>{l.ctx.fillStyle=b[t],l.ctx.fill(e)})),l.ctx.restore()})),null)}function _(e){const{disp:t,each:l,gap:a=1,hideLE:n=-1/0,hideGE:i=1/0}=e,o=devicePixelRatio,r=a>=4?Math.round:e=>e,s=Math.round(a*o);return(e,a)=>(E.Z.orient(e,a,((o,d,u,c,m,h,p,v,f,g,x,y,w,b,k)=>{var S;let B=e.data[a];const M=B[0],V=B[1],C=B[2],D=B[3],L=M.length;let A=t.fill.values(e,a),j=null!==(S=t.fill.index)&&void 0!==S?S:[...new Set(A)],O=j.map((e=>new Path2D)),P=new Map,R=new Map;for(let e=0;e<M.length;e++){let t=M[e],l=V[e],a=C[e];P.has(t)||P.set(t,r(h(t,c,g,v))),R.has(l)||R.set(l,r(p(l,m,x,f))),R.has(a)||R.set(a,r(p(a,m,x,f)))}let I=P.get(M.find((e=>e!==M[0])))-P.get(M[0]);for(let t=0;t<L;t++){if(D[t]<=n||D[t]>=i)continue;let a=M[t],o=V[t],r=C[t],d=P.get(a),u=R.get(o),c=I,m=u-R.get(r);c=Math.max(1,c-s),m=Math.max(1,m-s);let h=d,p=u;b(O[A[t]],h,p,c,m),l(e,1,t,h,p,c,m)}e.ctx.save(),e.ctx.rect(e.bbox.left,e.bbox.top,e.bbox.width,e.bbox.height),e.ctx.clip(),O.forEach(((t,l)=>{e.ctx.fillStyle=j[l],e.ctx.fill(t)})),e.ctx.restore()})),null)}const W=function(e,t,l){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1/0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0;if(null==t){t=1/0;for(let l=0;l<e.length;l++)e[l]>a&&e[l]<n&&(t=Math.min(t,e[l]))}if(null==l){l=-1/0;for(let t=0;t<e.length;t++)e[t]>a&&e[t]<n&&(l=Math.max(l,e[t]))}return[t,l]},q=(e,t,l,a)=>{let n=Math.max(a-l,1),i=t.length,o=Array(e.length);for(let t=0;t<e.length;t++)o[t]=e[t]<l?0:e[t]>a?i-1:Math.min(i-1,Math.floor(i*(e[t]-l)/n));return o};function U(e,t,l){var a,n,i,o;let r=e.series;if(null==r||!r.length)return{};const s=null===(a=e.annotations)||void 0===a?void 0:a.find((e=>"exemplar"===e.name));var d;if(t.calculate)return J((0,p.xf)(r,null!==(d=t.calculation)&&void 0!==d?d:{}),s,t,l);let u;for(const e of r)switch(null===(n=e.meta)||void 0===n?void 0:n.type){case g.P.HeatmapCells:return(0,p.qJ)(e)?J(e,s,t,l):Z(e,s,t,l);case g.P.HeatmapRows:u=e}return u||(u=r.length>1?(0,I._9)({frames:r}):r[0]),J((0,p.Cj)(Object.assign({unit:null===(i=t.yAxis)||void 0===i?void 0:i.unit,decimals:null===(o=t.yAxis)||void 0===o?void 0:o.decimals},t.rowsFrame,{frame:u})),s,t,l)}const Z=(e,t,l,a)=>{var n,i,o;if((null===(n=e.meta)||void 0===n?void 0:n.type)!==g.P.HeatmapCells||(0,p.qJ)(e))return{warning:"Expected sparse heatmap format",heatmap:e};K(e.fields[1],l.yAxis,a);const r=K(e.fields[3],l.cellValues,a);let[s,d]=W(e.fields[3].values.toArray(),l.color.min,l.color.max,null===(i=l.filterValues)||void 0===i?void 0:i.le,null===(o=l.filterValues)||void 0===o?void 0:o.ge);return{heatmap:e,minValue:s,maxValue:d,exemplars:t,display:e=>(0,V.zc)(r(e))}},J=(e,t,l,a)=>{var n,i,r;if((null===(n=e.meta)||void 0===n?void 0:n.type)!==g.P.HeatmapCells)return{warning:"Expected heatmap scanlines format",heatmap:e};if(e.fields.length<2||e.length<2)return{heatmap:e};const s=(0,p.d8)(e);let d,u,c;for(const t of e.fields)switch(t.name){case"y":u=t.name;case"yMin":case"yMax":u||(u=t.name),null==s.yOrdinalDisplay&&K(t,l.yAxis,a);break;case"x":case"xMin":case"xMax":d=t.name;break;default:t.type!==o.fS.number||c||(c=t)}if(!u)return{warning:"Missing Y field",heatmap:e};if(!u)return{warning:"Missing X field",heatmap:e};if(!c)return{warning:"Missing value field",heatmap:e};const m=K(c,l.cellValues,a),h=e.fields[0].values.toArray(),f=e.fields[1].values.toArray(),x=h.length;let y=x-f.lastIndexOf(f[0]),w=x/y,b=f[1]-f[0],k=h[y]-h[0],[S,B]=W(c.values.toArray(),l.color.min,l.color.max,null===(i=l.filterValues)||void 0===i?void 0:i.le,null===(r=l.filterValues)||void 0===r?void 0:r.ge);return{heatmap:e,exemplars:null!=t&&t.length?t:void 0,xBucketSize:k,yBucketSize:b,xBucketCount:w,yBucketCount:y,minValue:S,maxValue:B,xLayout:"xMax"===d?v.D.le:"xMin"===d?v.D.ge:v.D.unknown,yLayout:"yMax"===u?v.D.le:"yMin"===u?v.D.ge:v.D.unknown,display:e=>(0,V.zc)(m(e))}};function K(e,t,l){var a;if(null!=t&&null!==(a=t.unit)&&void 0!==a&&a.length||null!=(null==t?void 0:t.decimals)){const{unit:l,decimals:a}=t;e.display=void 0,e.config=Object.assign({},e.config),null!=l&&l.length&&(e.config.unit=l),null!=a&&(e.config.decimals=a)}return e.display||(e.display=(0,H.U)({field:e,theme:l})),e.display}var X=l(81810),Q=l(42843),ee=l(32172),te=l.n(ee);Object.freeze([1,0]);let le,ae;!function(e){e.Opacity="opacity",e.Scheme="scheme"}(le||(le={})),function(e){e.Linear="linear",e.Exponential="exponential"}(ae||(ae={}));const ne={calculate:!1,color:{mode:le.Scheme,scheme:"Oranges",fill:"dark-orange",scale:ae.Exponential,reverse:!1,exponent:.5,steps:64},rowsFrame:{layout:v.D.auto},yAxis:{axisPlacement:d.LB.Left},cellValues:{},showValue:d.Jp.Auto,tooltip:{show:!0,yHistogram:!1},legend:{show:!0},exemplars:{color:"rgba(255,0,255,0.7)"},filterValues:{le:1e-9},cellGap:1},ie=[{name:"BrBG",invert:"always"},{name:"PiYG",invert:"always"},{name:"PRGn",invert:"always"},{name:"PuOr",invert:"always"},{name:"RdBu",invert:"always"},{name:"RdGy",invert:"always"},{name:"RdYlBu",invert:"always"},{name:"RdYlGn",invert:"always"},{name:"Spectral",invert:"always"},{name:"Blues",invert:"dark"},{name:"Greens",invert:"dark"},{name:"Greys",invert:"dark"},{name:"Oranges",invert:"dark"},{name:"Purples",invert:"dark"},{name:"Reds",invert:"dark"},{name:"Turbo",invert:"light"},{name:"Cividis",invert:"light"},{name:"Viridis",invert:"light"},{name:"Magma",invert:"light"},{name:"Inferno",invert:"light"},{name:"Plasma",invert:"light"},{name:"Warm",invert:"light"},{name:"Cool",invert:"light"},{name:"Cubehelix",invert:"light",name2:"CubehelixDefault"},{name:"BuGn",invert:"dark"},{name:"BuPu",invert:"dark"},{name:"GnBu",invert:"dark"},{name:"OrRd",invert:"dark"},{name:"PuBuGn",invert:"dark"},{name:"PuBu",invert:"dark"},{name:"PuRd",invert:"dark"},{name:"RdPu",invert:"dark"},{name:"YlGnBu",invert:"dark"},{name:"YlGn",invert:"dark"},{name:"YlOrBr",invert:"dark"},{name:"YlOrRd",invert:"dark"},{name:"Rainbow",invert:"always"},{name:"Sinebow",invert:"always"}],oe=ie.find((e=>"Spectral"===e.name));function re(e,t){var l;const a=Object.assign({},ne.color,e),n=[],i=(null!==(l=a.steps)&&void 0!==l?l:128)-1;if(e.mode===le.Opacity){const l=te()(t.visualization.getColorByName(e.fill)).toPercentageRgb(),o=a.scale===ae.Exponential?X.scalePow().exponent(a.exponent).domain([0,1]).range([0,1]):X.scaleLinear().domain([0,1]).range([0,1]);for(let e=0;e<=i;e++)l.a=o(e/i),n.push(te()(l).toString("hex8"))}else{var o,r;const l=null!==(o=ie.find((e=>e.name===a.scheme)))&&void 0!==o?o:oe;let s="interpolate"+(null!==(r=l.name2)&&void 0!==r?r:l.name);const d=Q[s];for(let e=0;e<=i;e++){let t=d(e/i),l=0===t.indexOf("rgb")?"#"+[...t.matchAll(/\d+/g)].map((e=>(+e[0]).toString(16).padStart(2,"0"))).join(""):t;n.push(l)}("always"===l.invert||"dark"===l.invert&&t.isDark||"light"===l.invert&&t.isLight)&&n.reverse(),e.reverse&&n.reverse()}return n}const se=e=>({colorScaleWrapper:f.css`
    margin-left: 25px;
    padding: 10px 0;
    max-width: 300px;
  `}),de=["bucketFrame"];const ue=(e,t,l,a)=>{if("heatmap"===t&&l.angular){const{fieldConfig:t,options:n}=function(e){var t,l,a,n,i,o;const r={defaults:{},overrides:[]},s="tsbuckets"!==e.dataFormat,u=Object.assign({},ne.calculation),c=Object.assign({logBase:1},e.yAxis);s&&(e.xBucketSize?u.xBuckets={mode:v.k.Size,value:`${e.xBucketSize}`}:e.xBucketNumber&&(u.xBuckets={mode:v.k.Count,value:`${e.xBucketNumber}`}),e.yBucketSize?u.yBuckets={mode:v.k.Size,value:`${e.yBucketSize}`}:e.xBucketNumber&&(u.yBuckets={mode:v.k.Count,value:`${e.yBucketNumber}`}),c.logBase>1&&(u.yBuckets={mode:v.k.Count,value:+c.splitFactor>0?`${c.splitFactor}`:void 0,scale:{type:d.wf.Log,log:c.logBase}}));const m=me(null===(t=e.cards)||void 0===t?void 0:t.cardPadding,2),h={calculate:s,calculation:u,color:Object.assign({},ne.color,{steps:128}),cellGap:m||1,cellRadius:me(null===(l=e.cards)||void 0===l?void 0:l.cardRound),yAxis:{axisPlacement:!1===c.show?d.LB.Hidden:d.LB.Left,reverse:Boolean(e.reverseYBuckets),axisWidth:me(c.width),min:c.min,max:c.max,unit:c.format,decimals:c.decimals},cellValues:{decimals:me(e.tooltipDecimals)},rowsFrame:{layout:ce(e.yBucketBound)},legend:{show:Boolean(null===(a=e.legend)||void 0===a?void 0:a.show)},showValue:d.Jp.Never,tooltip:{show:Boolean(null===(n=e.tooltip)||void 0===n?void 0:n.show),yHistogram:Boolean(null===(i=e.tooltip)||void 0===i?void 0:i.showHistogram)},exemplars:Object.assign({},ne.exemplars)};e.hideZeroBuckets&&(h.filterValues=Object.assign({},ne.filterValues));const p=null!==(o=e.color)&&void 0!==o?o:{};switch(null==p?void 0:p.mode){case"spectrum":{h.color.mode=le.Scheme;const e=p.colorScheme;let t=ie.find((t=>t.name===e));t||(t=ie.find((t=>e.indexOf(t.name)>=0))),h.color.scheme=t?t.name:ne.color.scheme;break}case"opacity":h.color.mode=le.Opacity,h.color.scale=p.scale}h.color.fill=p.cardColor,h.color.min=p.min,h.color.max=p.max,"number"==typeof p.min&&"number"==typeof p.max&&p.min>p.max&&(h.color.min=p.max,h.color.max=p.min,h.color.reverse=!0);return{fieldConfig:r,options:h}}(Object.assign({},l.angular,{fieldConfig:a}));return e.fieldConfig=t,n}if("heatmap-new"===t){const t=e.options,{bucketFrame:l}=t,a=function(e,t){if(null==e)return{};var l,a,n={},i=Object.keys(e);for(a=0;a<i.length;a++)l=i[a],t.indexOf(l)>=0||(n[l]=e[l]);return n}(t,de);return l?Object.assign({},a,{rowsFrame:l}):e.options}return{}};function ce(e){switch(e){case"upper":return v.D.ge;case"lower":return v.D.le;case"middle":return v.D.unknown}return v.D.auto}function me(e,t){if(null==e||""===e)return t;const l=+e;return isNaN(l)?t:l}const he=new n.c((e=>{let{data:t,id:l,timeRange:n,timeZone:i,width:o,height:r,options:s,fieldConfig:u,eventBus:c,onChangeTimeRange:h,replaceVariables:f}=e;const C=(0,y.l4)(),D=(0,y.wW)(se),{sync:L}=(0,w.R9)();let A=(0,a.useRef)(n);A.current=n;const j=(0,a.useMemo)((()=>{try{return U(t,s,C)}catch(e){return{warning:`${e}`}}}),[t,s,C]),R=(0,a.useMemo)((()=>{var e,t;let l=[],a=[];const n=(0,p.d8)(j.heatmap);if(null!==(e=j.exemplars)&&void 0!==e&&e.length&&n.yMatchWithLabel){var i;l=null===(i=j.exemplars)||void 0===i?void 0:i.fields[0].values.toArray();if(null!=n.yOrdinalDisplay){var o;a=(null===(o=j.exemplars)||void 0===o?void 0:o.fields.find((e=>e.name===n.yMatchWithLabel)).values.toArray()).map((e=>{var t;return null===(t=n.yOrdinalLabel)||void 0===t?void 0:t.indexOf(e)}))}else{var r;a=null===(r=j.exemplars)||void 0===r?void 0:r.fields[1].values.toArray()}}return[null,null===(t=j.heatmap)||void 0===t?void 0:t.fields.map((e=>e.values.toArray())),[l,a]]}),[j.heatmap,j.exemplars]),I=(0,a.useMemo)((()=>re(s.color,C)),[s.color,C]),[H,W]=(0,a.useState)(void 0),[Z,J]=(0,a.useState)(!1),K=(0,a.useRef)(!1),X=()=>{K.current=!K.current,J(K.current)},Q=(0,a.useCallback)((e=>{W(null!=e?e:void 0)}),[s,t.structureRev]),ee=(0,a.useRef)(j);ee.current=j;const te=(0,a.useMemo)((()=>{var e,t,l,a,n,o,r,u,m,f;const x=null===(e=ee.current)||void 0===e||null===(t=e.heatmap)||void 0===t||null===(l=t.fields[1].config)||void 0===l||null===(a=l.custom)||void 0===a?void 0:a.scaleDistribution;return function(e){var t,l,a,n,i,o,r,s,u,c,m,h,f,x,y,w;const{dataRef:b,theme:k,eventBus:S,onhover:B,onclick:M,onzoom:C,isToolTipOpen:D,timeZone:L,getTimeRange:A,palette:j,cellGap:O,hideLE:P,hideGE:R,yAxisConfig:I,ySizeDivisor:H,sync:W}=e,U="x",Z="time",J=devicePixelRatio;let K=null===(t=b.current)||void 0===t||null===(l=t.heatmap)||void 0===l||null===(a=l.meta)||void 0===a?void 0:a.type;const X=k.visualization.getColorByName(e.exemplarColor);let Q,ee,te,le=new Y.U(L);le.addHook("init",(e=>{e.root.querySelectorAll(".u-cursor-pt").forEach((e=>{Object.assign(e.style,{borderRadius:"0",border:"1px solid white",background:"transparent"})})),M&&e.over.addEventListener("mouseup",(t=>{e.cursor.drag._x||e.cursor.drag._y||M(t)}),!0)})),C&&le.addHook("setSelect",(e=>{C({xMin:e.posToVal(e.select.left,U),xMax:e.posToVal(e.select.left+e.select.width,U)}),e.setSelect({left:0,top:0,width:0,height:0},!1)})),le.addHook("setData",(e=>{let{min:t,max:l}=e.scales.x,a=A().from.valueOf(),n=A().to.valueOf();t===a&&l===n||queueMicrotask((()=>{e.setScale(U,{min:a,max:n})}))})),le.addHook("syncRect",((e,t)=>{te=t}));const ae={point:{[Z]:null},data:null===(n=b.current)||void 0===n?void 0:n.heatmap},ne=new N.es(ae);let ie;B&&le.addHook("setLegend",(e=>{if(null!=e.cursor.idxs)for(let t=0;t<e.cursor.idxs.length;t++){const l=e.cursor.idxs[t];if(null!=l){const{left:a,top:n}=e.cursor;return ae.rowIndex=l,ae.point.time=e.posToVal(a,U),S.publish(ne),void(D.current||(ie&&(clearTimeout(ie),ie=0),B({seriesIdx:t,dataIdx:l,pageX:te.left+a,pageY:te.top+n})))}}D.current||ie||(ie=setTimeout((()=>{B(null),ae.rowIndex=void 0,ae.point.time=null,S.publish(ne)}),100))})),le.addHook("drawClear",(e=>{Q=Q||new F.lW(0,0,e.bbox.width,e.bbox.height),Q.clear(),e.series.forEach(((e,t)=>{t>0&&(e._paths=null)}))})),le.setMode(2),le.addScale({scaleKey:U,isTime:!0,orientation:d.wN.Horizontal,direction:d.bQ.Right,range:()=>[A().from.valueOf(),A().to.valueOf()]}),le.addAxis({scaleKey:U,placement:d.LB.Bottom,isTime:!0,theme:k,timeZone:L});const oe=null===(i=b.current)||void 0===i||null===(o=i.heatmap)||void 0===o?void 0:o.fields[1];if(!oe)return le;const re=null===(r=oe.config)||void 0===r?void 0:r.custom,se=null!==(s=null==re?void 0:re.scaleDistribution)&&void 0!==s?s:{type:d.wf.Linear},de=Boolean(I.reverse),ue=K===g.P.HeatmapCells&&!(0,p.qJ)(null===(u=b.current)||void 0===u?void 0:u.heatmap),ce=se.type!==d.wf.Linear||ue,me=null!=(0,p.d8)(null===(c=b.current)||void 0===c?void 0:c.heatmap).yOrdinalDisplay,he="y_"+(Math.random()+1).toString(36).substring(7);le.addScale({scaleKey:he,isTime:!1,orientation:d.wN.Vertical,direction:de?d.bQ.Down:d.bQ.Up,distribution:ce?d.wf.Log:d.wf.Linear,log:null!==(m=se.log)&&void 0!==m?m:2,range:ue?(e,t,l)=>{var a;let n,i;if([n,i]=ce?E.Z.rangeLog(t,l,null!==(a=se.log)&&void 0!==a?a:2,!0):[t,l],ce&&!me){let t=e.scales[he].log,l=2===t?Math.log2:Math.log10,{min:a,max:o}=I;if(null!=a&&a>0){let e=l(a);n=t**(0,z.mB)(e,1)}if(null!=o&&o>0){let e=l(o);i=t**(0,z.UO)(e,1)}}return[n,i]}:(e,t,l)=>{let a=t,n=l,{min:i,max:o}=I;if(ce){var r,s;let d=e.scales[he].log,u=!1,c=!1,m=2===d?Math.log2:Math.log10;if(1!==H){let e=m(t),i=m(l);Number.isInteger(e)||(a=d**(0,z.mB)(e,1),u=!0),Number.isInteger(i)||(n=d**(0,z.UO)(i,1),c=!0)}if((null===(r=b.current)||void 0===r?void 0:r.yLayout)===v.D.le?u||(a/=d):(null===(s=b.current)||void 0===s?void 0:s.yLayout)===v.D.ge?c||(n*=d):(a/=d/2,n*=d/2),!me){if(null!=i&&i>0){let e=m(i);a=d**(0,z.mB)(e,1)}if(null!=o&&o>0){let e=m(o);n=d**(0,z.UO)(e,1)}}}else{var d;let e=null===(d=b.current)||void 0===d?void 0:d.yBucketSize;var u,c;0===e&&(e=1),e&&((null===(u=b.current)||void 0===u?void 0:u.yLayout)===v.D.le?a-=e:(null===(c=b.current)||void 0===c?void 0:c.yLayout)===v.D.ge?n+=e:(a-=e/2,n+=e/2)),me||(a=null!=i?i:a,n=null!=o?o:n)}return[a,n]}});const pe=null!==(h=oe.display)&&void 0!==h?h:(0,V.Cf)("short");le.addAxis({scaleKey:he,show:I.axisPlacement!==d.LB.Hidden,placement:I.axisPlacement||d.LB.Left,size:I.axisWidth||null,label:I.axisLabel,theme:k,formatValue:(e,t)=>{var l;return(0,V.zc)(pe(e,null!==(l=oe.config.decimals)&&void 0!==l?l:t))},splits:me?e=>{var t,l;const a=(0,p.d8)(null===(t=b.current)||void 0===t?void 0:t.heatmap);if(!a.yOrdinalDisplay)return[0,1];let n=a.yOrdinalDisplay.map(((e,t)=>t));switch(null===(l=b.current)||void 0===l?void 0:l.yLayout){case v.D.le:n.unshift(-1);break;case v.D.ge:n.push(n.length)}if(e.height<60)n=[n[0],n[n.length-1]];else for(;n.length>3&&(e.height-15)/n.length<10;)n=n.filter(((e,t)=>t%2==0));return n}:void 0,values:me?(e,t)=>{var l;const a=(0,p.d8)(null===(l=b.current)||void 0===l?void 0:l.heatmap);return a.yOrdinalDisplay?t.map((e=>{var t,l;return e<0?null!==(t=a.yMinDisplay)&&void 0!==t?t:"":null!==(l=a.yOrdinalDisplay[e])&&void 0!==l?l:""})):t}:void 0});const ve=ue?_:T;le.addSeries({facets:[{scale:U,auto:!0,sorted:1},{scale:he,auto:!0}],pathBuilder:ve({each:(e,t,l,a,n,i,o)=>{Q.add({x:a-e.bbox.left,y:n-e.bbox.top,w:i,h:o,sidx:t,didx:l})},gap:O,hideLE:P,hideGE:R,xAlign:(null===(f=b.current)||void 0===f?void 0:f.xLayout)===v.D.le?-1:(null===(x=b.current)||void 0===x?void 0:x.xLayout)===v.D.ge?1:0,yAlign:((null===(y=b.current)||void 0===y?void 0:y.yLayout)===v.D.le?-1:(null===(w=b.current)||void 0===w?void 0:w.yLayout)===v.D.ge?1:0)*(de?-1:1),ySizeDivisor:H,disp:{fill:{values:(e,t)=>{var l,a;let n=ue?3:2;return q(e.data[t][n],j,null===(l=b.current)||void 0===l?void 0:l.minValue,null===(a=b.current)||void 0===a?void 0:a.maxValue)},index:j}}}),theme:k,scaleKey:""}),le.addSeries({facets:[{scale:U,auto:!0,sorted:1},{scale:he,auto:!0}],pathBuilder:$({each:(e,t,l,a,n,i,o)=>{Q.add({x:a-e.bbox.left,y:n-e.bbox.top,w:i,h:o,sidx:t,didx:l})}},X),theme:k,scaleKey:""});const fe={drag:{x:!0,y:!1,setScale:!1},dataIdx:(e,t)=>{if(1===t){ee=null;let t=e.cursor.left*J,l=e.cursor.top*J;Q.get(t,l,1,1,(e=>{(0,F.Pn)(t,l,e.x,e.y,e.x+e.w,e.y+e.h)&&(ee=e)}))}return ee&&t===ee.sidx?ee.didx:null},points:{fill:"rgba(255,255,255, 0.3)",bbox:(e,t)=>{let l=ee&&t===ee.sidx;return{left:l?ee.x/J:-10,top:l?ee.y/J:-10,width:l?ee.w/J:0,height:l?ee.h/J:0}}}};return W&&W()!==G.m.Off&&(fe.sync={key:"__global_",scales:[U,he],filters:{pub:(e,t,l,a,n,i,o)=>(l<0?(ae.point.time=null,S.publish(new N.xH)):(ae.point.time=t.posToVal(l,U),S.publish(ne)),!0)}},le.setSync()),le.setCursor(fe),le}({dataRef:ee,theme:C,eventBus:c,onhover:Q,onclick:s.tooltip.show?X:null,onzoom:e=>{e.xMax-e.xMin>1&&h({from:e.xMin,to:e.xMax})},isToolTipOpen:K,timeZone:i,getTimeRange:()=>A.current,sync:L,palette:I,cellGap:s.cellGap,hideLE:null===(n=s.filterValues)||void 0===n?void 0:n.le,hideGE:null===(o=s.filterValues)||void 0===o?void 0:o.ge,exemplarColor:null!==(r=null===(u=s.exemplars)||void 0===u?void 0:u.color)&&void 0!==r?r:"rgba(255,0,255,0.7)",yAxisConfig:s.yAxis,ySizeDivisor:(null==x?void 0:x.type)===d.wf.Log?+((null===(m=s.calculation)||void 0===m||null===(f=m.yBuckets)||void 0===f?void 0:f.value)||1):1})}),[s,i,t.structureRev]);return j.warning||!j.heatmap?(0,O.jsx)(x.Z,{panelId:l,fieldConfig:u,data:t,needsNumberField:!0,message:j.warning}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(b.AY,{width:o,height:r,legend:(()=>{var e,t,l,a;if(!j.heatmap||!s.legend.show)return null;let n=(null===(e=ee.current)||void 0===e||null===(t=e.heatmap)||void 0===t||null===(l=t.meta)||void 0===l?void 0:l.type)===g.P.HeatmapCells&&!(0,p.qJ)(null===(a=ee.current)||void 0===a?void 0:a.heatmap)?3:2;const i=j.heatmap.fields[n];let o;return H&&j.heatmap.fields&&1===H.seriesIdx&&(o=i.values.get(H.dataIdx)),(0,O.jsx)(b.AY.Legend,{placement:"bottom",maxHeight:"20%",children:(0,O.jsx)("div",{className:D.colorScaleWrapper,children:(0,O.jsx)(m.q,{hoverValue:o,colorPalette:I,min:ee.current.minValue,max:ee.current.maxValue,display:j.display})})})})(),children:(e,t)=>(0,O.jsx)(k.N,{config:te,data:R,width:e,height:t,timeRange:n})}),(0,O.jsx)(S.h_,{children:H&&s.tooltip.show&&(0,O.jsxs)(B.S,{position:{x:H.pageX,y:H.pageY},offset:{x:10,y:10},allowPointerEvents:K.current,children:[Z&&(0,O.jsx)("div",{style:{width:"100%",display:"flex",justifyContent:"flex-end"},children:(0,O.jsx)(M.P,{onClick:()=>{K.current=!1,J(!1),Q(null)},style:{position:"relative",top:"auto",right:"auto",marginRight:0}})}),(0,O.jsx)(P,{data:j,hover:H,showHistogram:s.tooltip.yHistogram})]})})]})})).useFieldConfig({disableStandardOptions:Object.values(i.qb).filter((e=>e!==i.qb.Links)),useCustomConfig:e=>{e.addCustomEditor({id:"scaleDistribution",path:"scaleDistribution",name:"Y axis scale",category:["Heatmap"],editor:u.Y,override:u.Y,defaultValue:{type:d.wf.Linear},shouldApply:e=>e.type===o.fS.number,process:r.kG,hideFromDefaults:!0}),(0,c.B)(e)}}).setPanelChangeHandler(ue).setMigrationHandler((e=>0===Object.keys(e.options).length?ue(e,"heatmap",{angular:e},e.fieldConfig):e.options)).setPanelOptions(((e,t)=>{var l,a,n,i;const o=null!==(l=t.options)&&void 0!==l?l:ne;let r=!1;try{const e=U({series:t.data},o,s.v.theme2);r=null!=(0,p.d8)(e.heatmap).yOrdinalDisplay}catch{}let u=["Heatmap"];var c,f,g;(e.addRadio({path:"calculate",name:"Calculate from data",defaultValue:ne.calculate,category:u,settings:{options:[{label:"Yes",value:!0},{label:"No",value:!1}]}}),o.calculate&&(0,h.J)("calculation.",e,o.calculation,u),u=["Y Axis"],e.addRadio({path:"yAxis.axisPlacement",name:"Placement",defaultValue:null!==(a=ne.yAxis.axisPlacement)&&void 0!==a?a:d.LB.Left,category:u,settings:{options:[{label:"Left",value:d.LB.Left},{label:"Right",value:d.LB.Right},{label:"Hidden",value:d.LB.Hidden}]}}).addUnitPicker({category:u,path:"yAxis.unit",name:"Unit",defaultValue:void 0,settings:{isClearable:!0}}).addNumberInput({category:u,path:"yAxis.decimals",name:"Decimals",settings:{placeholder:"Auto"}}),r||e.addNumberInput({path:"yAxis.min",name:"Min value",settings:{placeholder:"Auto"},category:u}).addTextInput({path:"yAxis.max",name:"Max value",settings:{placeholder:"Auto"},category:u}),e.addNumberInput({path:"yAxis.axisWidth",name:"Axis width",defaultValue:ne.yAxis.axisWidth,settings:{placeholder:"Auto",min:5},category:u}).addTextInput({path:"yAxis.axisLabel",name:"Axis label",defaultValue:ne.yAxis.axisLabel,settings:{placeholder:"Auto"},category:u}),o.calculate)||e.addRadio({path:"rowsFrame.layout",name:"Tick alignment",defaultValue:null!==(c=null===(f=ne.rowsFrame)||void 0===f?void 0:f.layout)&&void 0!==c?c:v.D.auto,category:u,settings:{options:[{label:"Auto",value:v.D.auto},{label:"Top (LE)",value:v.D.le},{label:"Middle",value:v.D.unknown},{label:"Bottom (GE)",value:v.D.ge}]}});(e.addBooleanSwitch({path:"yAxis.reverse",name:"Reverse",defaultValue:!0===ne.yAxis.reverse,category:u}),u=["Colors"],e.addRadio({path:"color.mode",name:"Mode",defaultValue:ne.color.mode,category:u,settings:{options:[{label:"Scheme",value:le.Scheme},{label:"Opacity",value:le.Opacity}]}}),e.addColorPicker({path:"color.fill",name:"Color",defaultValue:ne.color.fill,category:u,showIf:e=>e.color.mode===le.Opacity}),e.addRadio({path:"color.scale",name:"Scale",defaultValue:ne.color.scale,category:u,settings:{options:[{label:"Exponential",value:ae.Exponential},{label:"Linear",value:ae.Linear}]},showIf:e=>e.color.mode===le.Opacity}),e.addSliderInput({path:"color.exponent",name:"Exponent",defaultValue:ne.color.exponent,category:u,settings:{min:.1,max:2,step:.1},showIf:e=>e.color.mode===le.Opacity&&e.color.scale===ae.Exponential}),e.addSelect({path:"color.scheme",name:"Scheme",description:"",defaultValue:ne.color.scheme,category:u,settings:{options:ie.map((e=>({value:e.name,label:e.name})))},showIf:e=>e.color.mode!==le.Opacity}),e.addSliderInput({path:"color.steps",name:"Steps",defaultValue:ne.color.steps,category:u,settings:{min:2,max:128,step:1}}).addBooleanSwitch({path:"color.reverse",name:"Reverse",defaultValue:ne.color.reverse,category:u}).addCustomEditor({id:"__scale__",path:"__scale__",name:"",category:u,editor:()=>{const e=re(o.color,s.v.theme2);return(0,O.jsx)("div",{children:(0,O.jsx)(m.q,{colorPalette:e,min:1,max:100})})}}),e.addNumberInput({path:"color.min",name:"Start color scale from value",defaultValue:ne.color.min,settings:{placeholder:"Auto (min)"},category:u}).addNumberInput({path:"color.max",name:"End color scale at value",defaultValue:ne.color.max,settings:{placeholder:"Auto (max)"},category:u}),u=["Cell display"],o.calculate)||e.addTextInput({path:"rowsFrame.value",name:"Value name",defaultValue:null===(g=ne.rowsFrame)||void 0===g?void 0:g.value,settings:{placeholder:"Value"},category:u});e.addUnitPicker({category:u,path:"cellValues.unit",name:"Unit",defaultValue:void 0,settings:{isClearable:!0}}).addNumberInput({category:u,path:"cellValues.decimals",name:"Decimals",settings:{placeholder:"Auto"}}),e.addSliderInput({name:"Cell gap",path:"cellGap",defaultValue:ne.cellGap,category:u,settings:{min:0,max:25}}).addNumberInput({path:"filterValues.le",name:"Hide cells with values <=",defaultValue:null===(n=ne.filterValues)||void 0===n?void 0:n.le,settings:{placeholder:"None"},category:u}).addNumberInput({path:"filterValues.ge",name:"Hide cells with values >=",defaultValue:null===(i=ne.filterValues)||void 0===i?void 0:i.ge,settings:{placeholder:"None"},category:u}),u=["Tooltip"],e.addBooleanSwitch({path:"tooltip.show",name:"Show tooltip",defaultValue:ne.tooltip.show,category:u}),e.addBooleanSwitch({path:"tooltip.yHistogram",name:"Show histogram (Y axis)",defaultValue:ne.tooltip.yHistogram,category:u,showIf:e=>e.tooltip.show}),u=["Legend"],e.addBooleanSwitch({path:"legend.show",name:"Show legend",defaultValue:ne.legend.show,category:u}),u=["Exemplars"],e.addColorPicker({path:"exemplars.color",name:"Color",defaultValue:ne.exemplars.color,category:u})})).setSuggestionsSupplier(new class{getSuggestionsForData(e){var t;const{dataSummary:l}=e;if(null===(t=e.data)||void 0===t||!t.series||!l.hasData||l.timeFieldCount<1||l.numberFieldCount<2||l.numberFieldCount>10)return;const a=U(e.data,ne,s.v.theme2);a&&!a.warning&&e.getListAppender({name:"",pluginId:"heatmap",options:{},fieldConfig:{defaults:{custom:{}},overrides:[]}})}})}}]);
//# sourceMappingURL=heatmapPanel.56a5ebbca30c1a89a8c6.js.map