"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6987],{8747:(_e,Le,x)=>{x.d(Le,{q:()=>De});var m=x(42844),X=x(27702),Ce=x(66310);const me=10,De=({colorPalette:q,min:ae,max:fe,display:F,hoverValue:se,useStopsPercentage:ye})=>{const[ne,ce]=(0,X.useState)([]),[oe,ue]=(0,X.useState)({isShown:!1,value:0}),[re,be]=(0,X.useState)(null),Fe=(0,Ce.l4)(),de=Ee(Fe,ne);(0,X.useEffect)(()=>{ce(xe({colorArray:q,stops:me,useStopsPercentage:ye}))},[q,ye]);const ze=ke=>{const Te=ke.nativeEvent.offsetX,Ge=ke.currentTarget.offsetWidth,Pe=Math.floor(Te*100/Ge+1),Ve=Math.floor((fe-ae)*Pe/100+ae);ue({isShown:!0,value:Ve}),be(Pe)},he=()=>{ue({isShown:!1,value:0})};return(0,X.useEffect)(()=>{be(se==null?null:i((se-ae)/(fe-ae)))},[se,ae,fe]),X.createElement("div",{className:de.scaleWrapper,onMouseMove:ze,onMouseLeave:he},X.createElement("div",{className:de.scaleGradient},F&&(oe.isShown||se!==void 0)&&X.createElement("div",{className:de.followerContainer},X.createElement("div",{className:de.follower,style:{left:`${re}%`}}))),F&&X.createElement("div",{className:de.followerContainer},X.createElement("div",{className:de.legendValues},X.createElement("span",null,F(ae)),X.createElement("span",null,F(fe))),re!=null&&(oe.isShown||se!==void 0)&&X.createElement("span",{className:de.hoverValue,style:{left:`${re}%`}},F(se??oe.value))))},xe=({colorArray:q,stops:ae,useStopsPercentage:fe=!0})=>{const F=q.length;if(fe&&F<=20){const ce=1/F*100;let oe=0;const ue=[];for(const re of q)oe>0?ue.push(`${re} ${oe}%`):ue.push(re),oe+=ce,ue.push(`${re} ${oe}%`);return ue}const se=q[F-1],ye=Math.ceil(F/ae),ne=new Set;for(let ce=0;ce<F;ce+=ye)ne.add(q[ce]);return ne.add(se),[...ne]};function i(q){return q>1?100:q<0?0:q*100}const Ee=(q,ae)=>({scaleWrapper:(0,m.css)`
    width: 100%;
    font-size: 11px;
    opacity: 1;
  `,scaleGradient:(0,m.css)`
    background: linear-gradient(90deg, ${ae.join()});
    height: 10px;
    pointer-events: none;
  `,legendValues:(0,m.css)`
    display: flex;
    justify-content: space-between;
    pointer-events: none;
  `,hoverValue:(0,m.css)`
    position: absolute;
    margin-top: -14px;
    padding: 3px 15px;
    background: ${q.colors.background.primary};
    transform: translateX(-50%);
  `,followerContainer:(0,m.css)`
    position: relative;
    pointer-events: none;
    white-space: nowrap;
  `,follower:(0,m.css)`
    position: absolute;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    transform: translateX(-50%) translateY(-50%);
    border: 2px solid ${q.colors.text.primary};
    margin-top: 5px;
  `})},50738:(_e,Le,x)=>{x.r(Le),x.d(Le,{plugin:()=>vt});var m=x(27702),X=x(97585),Ce=x(25587),me=x(29241),De=x(27001),xe=x(34667),i=x(64167),Ee=x(53387),q=x(56617),ae=x(8747),fe=x(73941),F=x(28635),se=x(42844),ye=x(21708),ne=x(43987),ce=x(72566),oe=x(66310),ue=x(70823),re=x(34072),be=x(81144),Fe=x(52995),de=x(97695),ze=x(8379),he=x(21609),ke=x(75578),Te=x(64022),Ge=x(66670),Pe=x(75261),Ve=x(16546);const et=e=>e.hover.seriesIdx===2?m.createElement(Ve.H,{data:e.data.exemplars,rowIndex:e.hover.dataIdx,header:"Exemplar"}):m.createElement(tt,{...e}),tt=({data:e,hover:n,showHistogram:t,scopedVars:u,replaceVars:l})=>{const a=n.dataIdx,o=e.heatmap?.fields[0],c=e.heatmap?.fields[1],h=e.heatmap?.fields[2],f=s=>{if(o?.display)return(0,he.zc)(o.display(s));if(o?.type===me.fS.time){const B="YYYY-MM-DD HH:mm:ss";return(0,Pe.h4)().getCurrent()?.formatDate(s,B)}return`${s}`},w=o?.values,E=c?.values,k=h?.values,I=(0,F.d8)(e.heatmap),_=c?.display?s=>(0,he.zc)(c.display(s)):s=>`${s}`,j=a%e.yBucketCount;let Z,S,y;if(I.yOrdinalDisplay){const s=e.yLayout===i.kv.le?j-1:j,B=e.yLayout===i.kv.le?j:j+1;Z=s<0?I.yMinDisplay:`${I.yOrdinalDisplay[s]}`,S=`${I.yOrdinalDisplay[B]}`,(!I.yOrdinalLabel||Number.isNaN(+I.yOrdinalLabel[0]))&&(y=e.yLayout===i.kv.le?S:Z)}else{const s=E?.[j];if(e.yLayout===i.kv.le)if(S=`${s}`,e.yLog){let D=(e.yLog===2?Math.log2:Math.log10)(s)-1/e.yLogSplit;Z=`${e.yLog**D}`}else Z=`${s-e.yBucketSize}`;else if(Z=`${s}`,e.yLog){let D=(e.yLog===2?Math.log2:Math.log10)(s)+1/e.yLogSplit;S=`${e.yLog**D}`}else S=`${s+e.yBucketSize}`}let O,M;e.xLayout===i.kv.le?(M=w?.[a],O=M-e.xBucketSize):(O=w?.[a],M=O+e.xBucketSize);const J=k?.[a],H=e.heatmap?.fields.filter(s=>!s.config.custom?.hideFrom?.tooltip),z=[],b=new Set;for(const s of H??[]){if(s.config.links&&s.config.links.length>0&&e.heatmap){const D=u.find(G=>G&&G.__dataContext&&G.__dataContext.value.field.name===y);s.getLinks=(0,ye.oB)(e.heatmap,s,D||{},l)}if(s.getLinks){const D=s.values[a],G=s.display?s.display(D):{text:`${D}`,numeric:+D};s.getLinks({calculatedValue:G,valueRowIndex:a}).forEach(V=>{const U=`${V.title}/${V.href}`;b.has(U)||(z.push(V),b.add(U))})}}let R=(0,m.useRef)(null),ee=150,A=50,T=Math.round(ee*devicePixelRatio),Y=Math.round(A*devicePixelRatio);(0,m.useEffect)(()=>{if(t){let s=R.current?.getContext("2d");if(s&&w&&E&&k){let B=a;for(;w[B--]===w[a];);B++;let D=B+e.yBucketCount,G=0,V=B;for(;V<D;){let le=k[V];G=Math.max(G,le),V++}let U=new Path2D,L=new Path2D;V=B;let te=0;for(;V<D;){let le=k[V];if(le>0){let K=le/G,r=te/(e.yBucketCount+1);(V===a?U:L).rect(Math.round(T*r),Math.round(Y*(1-K)),Math.round(T/e.yBucketCount),Math.round(Y*K))}V++,te++}s.clearRect(0,0,T,Y),s.fillStyle="#ffffff80",s.fill(L),s.fillStyle="#ff000080",s.fill(U)}}},[a]);const[Q]=(0,m.useState)(()=>e.heatmap?.meta?.type===ne.P.HeatmapCells&&!(0,F.qJ)(e.heatmap));if(Q)return m.createElement("div",null,m.createElement(Ve.H,{data:e.heatmap,rowIndex:a}));const P=()=>{if(y)return m.createElement("div",null,"Name: ",y);switch(e.yLayout){case i.kv.unknown:return m.createElement("div",null,_(Z))}return m.createElement("div",null,"Bucket: ",_(Z)," - ",_(S))};return m.createElement(m.Fragment,null,m.createElement("div",null,m.createElement("div",null,f(O)),e.xLayout!==i.kv.unknown&&m.createElement("div",null,f(M))),t&&m.createElement("canvas",{width:T,height:Y,ref:R,style:{width:T+"px",height:Y+"px"}}),m.createElement("div",null,P(),m.createElement("div",null,(0,ke.CZ)(h,e.heatmap),": ",e.display(J))),z.length>0&&m.createElement(Te.wc,null,z.map((s,B)=>m.createElement(Ge.Qj,{key:B,icon:"external-link-alt",target:s.target,href:s.href,onClick:s.onClick,fill:"text",style:{width:"100%"}},s.title))))};var lt=x(48962),at=x(61965),Me=x(48789),Ne=x(26712),Ye=x(84714),ge=x(35596),nt=x(79248),ot=x(19345),Ue=x(94876);function it(e){const{dataRef:n,theme:t,eventBus:u,onhover:l,onclick:a,onzoom:o,isToolTipOpen:c,timeZone:h,getTimeRange:f,cellGap:w,hideLE:E,hideGE:k,yAxisConfig:I,ySizeDivisor:_,sync:j,eventsScope:Z="__global_"}=e,S="x";let y="time",O=!0;n.current?.heatmap?.fields[0].type!==me.fS.time&&(y=n.current?.heatmap?.fields[0].config?.unit??"x",O=!1);const M=devicePixelRatio;let J=n.current?.heatmap?.meta?.type;const H=t.visualization.getColorByName(e.exemplarColor);let z,b,R=new ot.U(h),ee;R.addHook("init",r=>{r.root.querySelectorAll(".u-cursor-pt").forEach(p=>{Object.assign(p.style,{borderRadius:"0",border:"1px solid white",background:"transparent"})}),a&&r.over.addEventListener("mouseup",p=>{r.cursor.drag._x||r.cursor.drag._y||a(p)},!0)}),o&&R.addHook("setSelect",r=>{o({xMin:r.posToVal(r.select.left,S),xMax:r.posToVal(r.select.left+r.select.width,S)}),r.setSelect({left:0,top:0,width:0,height:0},!1)}),O&&R.addHook("setData",r=>{let{min:p,max:d}=r.scales.x,g=f().from.valueOf(),v=f().to.valueOf();(p!==g||d!==v)&&queueMicrotask(()=>{r.setScale(S,{min:g,max:v})})}),R.addHook("syncRect",(r,p)=>{ee=p});const A={point:{[y]:null},data:n.current?.heatmap},T=new Ye.es(A);let Y;l&&R.addHook("setLegend",r=>{if(r.cursor.idxs!=null)for(let p=0;p<r.cursor.idxs.length;p++){const d=r.cursor.idxs[p];if(d!=null){const{left:g,top:v}=r.cursor;A.rowIndex=d,A.point[y]=r.posToVal(g,S),u.publish(T),c.current||(Y&&(clearTimeout(Y),Y=0),l({seriesIdx:p,dataIdx:d,pageX:ee.left+g,pageY:ee.top+v}));return}}c.current||Y||(Y=setTimeout(()=>{l(null),A.rowIndex=void 0,A.point[y]=null,u.publish(T)},100))}),R.addHook("drawClear",r=>{z=z||new Ue.lW(0,0,r.bbox.width,r.bbox.height),z.clear(),r.series.forEach((p,d)=>{d>0&&(p._paths=null)})}),R.setMode(2),R.addScale({scaleKey:S,isTime:O,orientation:i.wN.Horizontal,direction:i.bQ.Right,range:(r,p,d)=>{if(O)return[f().from.valueOf(),f().to.valueOf()];if(n.current?.xLayout===i.kv.le)return[p-n.current?.xBucketSize,d];if(n.current?.xLayout===i.kv.ge)return[p,d+n.current?.xBucketSize];{let g=n.current?.xBucketSize/2;return[p-g,d+g]}}});let Q;if(!O){Q=[];for(let r=0;r<10;r++)Q.push(r*n.current?.xBucketSize)}R.addAxis({scaleKey:S,placement:i.LB.Bottom,incrs:Q,isTime:O,theme:t,timeZone:h});const P=n.current?.heatmap?.fields[1];if(!P)return R;const B=P.config?.custom?.scaleDistribution??{type:i.wf.Linear},D=!!I.reverse,G=J===ne.P.HeatmapCells&&!(0,F.qJ)(n.current?.heatmap),V=B.type!==i.wf.Linear||G,U=(0,F.d8)(n.current?.heatmap).yOrdinalDisplay!=null,L="y_"+(Math.random()+1).toString(36).substring(7);R.addScale({scaleKey:L,isTime:!1,orientation:i.wN.Vertical,direction:D?i.bQ.Down:i.bQ.Up,distribution:V?i.wf.Log:i.wf.Linear,log:B.log??2,range:G?(r,p,d)=>{let g,v;if([g,v]=V?Ne.Z.rangeLog(p,d,B.log??2,!0):[p,d],V&&!U){let N=r.scales[L].log,W=N===2?Math.log2:Math.log10,{min:$,max:pe}=I;if($!=null&&$>0){let Se=W($);g=N**(0,ge.mB)(Se,1)}if(pe!=null&&pe>0){let Se=W(pe);v=N**(0,ge.UO)(Se,1)}}return[g,v]}:(r,p,d)=>{let g=p,v=d,{min:N,max:W}=I;if(V){let $=r.scales[L].log,pe=!1,Se=!1,Ae=$===2?Math.log2:Math.log10;if(_!==1){let we=Ae(p),qe=Ae(d);Number.isInteger(we)||(g=$**(0,ge.mB)(we,1),pe=!0),Number.isInteger(qe)||(v=$**(0,ge.UO)(qe,1),Se=!0)}if(n.current?.yLayout===i.kv.le?pe||(g/=$):n.current?.yLayout===i.kv.ge?Se||(v*=$):(g/=$/2,v*=$/2),!U){if(N!=null&&N>0){let we=Ae(N);g=$**(0,ge.mB)(we,1)}if(W!=null&&W>0){let we=Ae(W);v=$**(0,ge.UO)(we,1)}}}else{let $=n.current?.yBucketSize;$===0&&($=1),$&&(n.current?.yLayout===i.kv.le?g-=$:n.current?.yLayout===i.kv.ge?v+=$:(g-=$/2,v+=$/2)),U||(g=N??g,v=W??v)}return[g,v]}});const te=P.display??(0,he.Cf)("short");R.addAxis({scaleKey:L,show:I.axisPlacement!==i.LB.Hidden,placement:I.axisPlacement||i.LB.Left,size:I.axisWidth||null,label:I.axisLabel,theme:t,formatValue:(r,p)=>(0,he.zc)(te(r,p)),splits:U?r=>{const p=(0,F.d8)(n.current?.heatmap);if(!p.yOrdinalDisplay)return[0,1];let d=p.yOrdinalDisplay.map((g,v)=>v);switch(n.current?.yLayout){case i.kv.le:d.unshift(-1);break;case i.kv.ge:d.push(d.length);break}if(r.height<60)d=[d[0],d[d.length-1]];else for(;d.length>3&&(r.height-15)/d.length<10;)d=d.filter((g,v)=>v%2===0);return d}:void 0,values:U?(r,p)=>{const d=(0,F.d8)(n.current?.heatmap);return d.yOrdinalDisplay?p.map(g=>g<0?d.yMinDisplay??"":d.yOrdinalDisplay[g]??""):p}:void 0});const le=G?ct:st;R.addSeries({facets:[{scale:S,auto:!0,sorted:1},{scale:L,auto:!0}],pathBuilder:le({each:(r,p,d,g,v,N,W)=>{z.add({x:g-r.bbox.left,y:v-r.bbox.top,w:N,h:W,sidx:p,didx:d})},gap:w,hideLE:E,hideGE:k,xAlign:n.current?.xLayout===i.kv.le?-1:n.current?.xLayout===i.kv.ge?1:0,yAlign:(n.current?.yLayout===i.kv.le?-1:n.current?.yLayout===i.kv.ge?1:0)*(D?-1:1),ySizeDivisor:_,disp:{fill:{values:(r,p)=>n.current?.heatmapColors?.values,index:n.current?.heatmapColors?.palette}}}),theme:t,scaleKey:""}),R.addSeries({facets:[{scale:S,auto:!0,sorted:1},{scale:L,auto:!0}],pathBuilder:rt({each:(r,p,d,g,v,N,W)=>{z.add({x:g-r.bbox.left,y:v-r.bbox.top,w:N,h:W,sidx:p,didx:d})}},H),theme:t,scaleKey:""});const K={drag:{x:!0,y:!1,setScale:!1},dataIdx:(r,p)=>{if(p===1){b=null;let d=r.cursor.left*M,g=r.cursor.top*M;z.get(d,g,1,1,v=>{(0,Ue.Pn)(d,g,v.x,v.y,v.x+v.w,v.y+v.h)&&(b=v)})}return b&&p===b.sidx?b.didx:null},points:{fill:"rgba(255,255,255, 0.3)",bbox:(r,p)=>{let d=b&&p===b.sidx;return{left:d?b.x/M:-10,top:d?b.y/M:-10,width:d?b.w/M:0,height:d?b.h/M:0}}}};return j&&j()!==nt.m.Off&&(K.sync={key:Z,scales:[S,L],filters:{pub:(r,p,d,g,v,N,W)=>(d<0?(A.point[y]=null,u.publish(new Ye.xH)):(A.point[y]=p.posToVal(d,S),u.publish(T)),!0)}},R.setSync()),R.setCursor(K),R}const Ke=4;function st(e){const{disp:n,each:t,gap:u=1,hideLE:l=-1/0,hideGE:a=1/0,xAlign:o=1,yAlign:c=1,ySizeDivisor:h=1}=e,f=devicePixelRatio,w=u>=Ke?Math.round:k=>k,E=Math.round(u*f);return(k,I)=>(Ne.Z.orient(k,I,(_,j,Z,S,y,O,M,J,H,z,b,R,ee,A,T)=>{let Y=k.data[I];const Q=Y[0],P=Y[1],s=Y[2],B=Q.length;let D=n.fill.values(k,I),G=n.fill.index??[...new Set(D)],V=G.map(N=>new Path2D),U=B-P.lastIndexOf(P[0]),L=B/U,te=P[1]-P[0]||y.max-y.min,le=Q[U]-Q[0],K,r;S.distr===3?K=Math.abs(O(Q[0]*S.log,S,z,J)-O(Q[0],S,z,J)):K=Math.abs(O(le,S,z,J)-O(0,S,z,J)),y.distr===3?r=Math.abs(M(P[0]*y.log,y,b,H)-M(P[0],y,b,H))/h:r=Math.abs(M(te,y,b,H)-M(0,y,b,H))/h,K=Math.max(1,w(K-E)),r=Math.max(1,w(r-E));let p=o===-1?-K:o===0?-K/2:0,d=c===1?-r:c===0?-r/2:0,g=P.slice(0,U).map(N=>w(M(N,y,b,H)+d)),v=Array.from({length:L},(N,W)=>w(O(Q[W*U],S,z,J)+p));for(let N=0;N<B;N++)if(s[N]>l&&s[N]<a){let W=v[~~(N/U)],$=g[N%U],pe=V[D[N]];A(pe,W,$,K,r),t(k,1,N,W,$,K,r)}return k.ctx.save(),k.ctx.rect(k.bbox.left,k.bbox.top,k.bbox.width,k.bbox.height),k.ctx.clip(),V.forEach((N,W)=>{k.ctx.fillStyle=G[W],k.ctx.fill(N)}),k.ctx.restore(),null}),null)}function rt(e,n){return(t,u)=>(Ne.Z.orient(t,u,(l,a,o,c,h,f,w,E,k,I,_,j,Z,S,y)=>{let O=new Path2D,M=[O],J=[n??"rgba(255,0,255,0.7)"];for(let H=0;H<a.length;H++){let z=o[H];z-=.5;let b=Math.round(Math.random())*2-1;z+=b*.5*Math.random();let R=f(a[H],c,I,E),ee=w(z,h,_,k),A=8,T=8;S(O,R-A/2,ee-T/2,A,T),e.each(t,u,H,R-A/2,ee-T/2,A,T)}t.ctx.save(),t.ctx.rect(t.bbox.left,t.bbox.top,t.bbox.width,t.bbox.height),t.ctx.clip(),M.forEach((H,z)=>{t.ctx.fillStyle=J[z],t.ctx.fill(H)}),t.ctx.restore()}),null)}function ct(e){const{disp:n,each:t,gap:u=1,hideLE:l=-1/0,hideGE:a=1/0}=e,o=devicePixelRatio,c=u>=Ke?Math.round:f=>f,h=Math.round(u*o);return(f,w)=>(Ne.Z.orient(f,w,(E,k,I,_,j,Z,S,y,O,M,J,H,z,b,R)=>{let ee=f.data[w];const A=ee[0],T=ee[1],Y=ee[2],Q=ee[3],P=A.length;let s=n.fill.values(f,w),B=n.fill.index??[...new Set(s)],D=B.map(L=>new Path2D),G=new Map,V=new Map;for(let L=0;L<A.length;L++){let te=A[L],le=T[L],K=Y[L];G.has(te)||G.set(te,c(Z(te,_,M,y))),V.has(le)||V.set(le,c(S(le,j,J,O))),V.has(K)||V.set(K,c(S(K,j,J,O)))}let U=G.get(A.find(L=>L!==A[0]))-G.get(A[0]);for(let L=0;L<P;L++){if(Q[L]<=l||Q[L]>=a)continue;let te=A[L],le=T[L],K=Y[L],r=G.get(te),p=V.get(le),d=V.get(K),g=U,v=p-d;g=Math.max(1,g-h),v=Math.max(1,v-h);let N=r,W=p,$=D[s[L]];b($,N,W,g,v),t(f,1,L,N,W,g,v)}f.ctx.save(),f.ctx.rect(f.bbox.left,f.bbox.top,f.bbox.width,f.bbox.height),f.ctx.clip(),D.forEach((L,te)=>{f.ctx.fillStyle=B[te],f.ctx.fill(L)}),f.ctx.restore()}),null)}const je=(e,n,t,u=-1/0,l=1/0)=>{if(n==null){n=1/0;for(let a=0;a<e.length;a++)e[a]>u&&e[a]<l&&(n=Math.min(n,e[a]))}if(t==null){t=-1/0;for(let a=0;a<e.length;a++)e[a]>u&&e[a]<l&&(t=Math.max(t,e[a]))}return[n,t]},Ze=(e,n,t,u)=>{let l=u-t||1,a=n.length,o=Array(e.length);for(let c=0;c<e.length;c++)o[c]=e[c]<t?0:e[c]>u?a-1:Math.min(a-1,Math.floor(a*(e[c]-t)/l));return o};function $e(e,n,t,u,l,a){if(!e?.length)return{};(0,ke.UY)(e);const o=n?.find(h=>h.name==="exemplar");if(a&&o?.fields.forEach((h,f)=>{o.fields[f].getLinks=a(o,h)}),t.calculate)return We((0,F.xf)(e,t.calculation??{}),o,t,u,l);let c;for(const h of e)switch(h.meta?.type){case ne.P.HeatmapCells:return(0,F.qJ)(h)?We(h,o,t,u,l):ut(h,o,t,u,l);case ne.P.HeatmapRows:c=h}if(!c)if(e.length>1)e.every(f=>!Number.isNaN((0,Me.Ky)(f.fields[1].state?.displayName)))&&e.sort(Me.nf),c=[(0,lt._9)({frames:e})][0];else{let h=e[0],f=h.fields.filter(E=>E.type===me.fS.number);f.every(E=>!Number.isNaN((0,Me.Ky)(E.state?.displayName)))?(f.sort((E,k)=>(0,Me.Ky)(E.state?.displayName)-(0,Me.Ky)(k.state?.displayName)),c={...h,fields:[h.fields.find(E=>E.type===me.fS.time),...f]}):c=h}return We((0,F.Cj)({unit:t.yAxis?.unit,decimals:t.yAxis?.decimals,...t.rowsFrame,frame:c}),o,t,u,l)}const ut=(e,n,t,u,l)=>{if(e.meta?.type!==ne.P.HeatmapCells||(0,F.qJ)(e))return{warning:"Expected sparse heatmap format",heatmap:e};He(e.fields[1],t.yAxis,l);const a=e.fields[3],o=He(a,t.cellValues,l);let[c,h]=je(a.values,t.color.min,t.color.max,t.filterValues?.le,t.filterValues?.ge);return{heatmap:e,heatmapColors:{palette:u,values:Ze(a.values,u,c,h),minValue:c,maxValue:h},exemplars:n,display:f=>(0,he.zc)(o(f))}},We=(e,n,t,u,l)=>{if(e.meta?.type!==ne.P.HeatmapCells)return{warning:"Expected heatmap scanlines format",heatmap:e};if(e.fields.length<2||e.length<2)return{heatmap:e};const a=(0,F.d8)(e);let o,c,h;for(const H of e.fields)switch(H.name){case"y":c=H.name;case"yMin":case"yMax":{c||(c=H.name),a.yOrdinalDisplay==null&&He(H,t.yAxis,l);break}case"x":case"xMin":case"xMax":o=H.name;break;default:H.type===me.fS.number&&!h&&(h=H)}if(!c)return{warning:"Missing Y field",heatmap:e};if(!c)return{warning:"Missing X field",heatmap:e};if(!h)return{warning:"Missing value field",heatmap:e};const f=He(h,t.cellValues,l),w=e.fields[0].values,E=e.fields[1].values,k=w.length;let I=k-E.lastIndexOf(E[0]),_=k/I,j=E[1]-E[0],Z=w[I]-w[0],[S,y]=je(h.values,t.color.min,t.color.max,t.filterValues?.le,t.filterValues?.ge),O=t.calculation?.xBuckets,M=t.calculation?.yBuckets;return{heatmap:e,heatmapColors:{palette:u,values:Ze(h.values,u,S,y),minValue:S,maxValue:y},exemplars:n?.length?n:void 0,xBucketSize:Z,yBucketSize:j,xBucketCount:_,yBucketCount:I,yLog:M?.scale?.log??0,xLog:O?.scale?.log??0,xLogSplit:O?.scale?.log?+(O?.value??"1"):1,yLogSplit:M?.scale?.log?+(M?.value??"1"):1,xLayout:o==="xMax"?i.kv.le:o==="xMin"?i.kv.ge:i.kv.unknown,yLayout:c==="yMax"?i.kv.le:c==="yMin"?i.kv.ge:i.kv.unknown,display:H=>(0,he.zc)(f(H))}};function He(e,n,t){if(n?.unit?.length||n?.decimals!=null){const{unit:u,decimals:l}=n;e.display=void 0,e.config={...e.config},u?.length&&(e.config.unit=u),l!=null&&(e.config.decimals=l)}return e.display||(e.display=(0,at.U)({field:e,theme:t})),e.display}var Je=x(45306),dt=x(58862),Qe=x(71685),ie=(e=>(e.Opacity="opacity",e.Scheme="scheme",e))(ie||{}),ve=(e=>(e.Exponential="exponential",e.Linear="linear",e))(ve||{});const Oe={calculate:!1,cellGap:1,cellValues:{},color:{scheme:"Oranges",fill:"dark-orange",reverse:!1,exponent:.5,steps:64},exemplars:{color:"rgba(255,0,255,0.7)"},filterValues:{le:1e-9},legend:{show:!0},showValue:i.Jp.Auto,tooltip:{show:!0,yHistogram:!1}},C={...Oe,color:{...Oe.color,mode:ie.Scheme,scale:ve.Exponential},yAxis:{...Oe.yAxis,axisPlacement:i.LB.Left},rowsFrame:{...Oe.rowsFrame,layout:i.kv.auto}},Be=[{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"}],mt=Be.find(e=>e.name==="Spectral");function Ie(e,n){const t={...C.color,...e},u=[],l=(t.steps??128)-1;if(e.mode===ie.Opacity){const a=(0,Qe.Z)(n.visualization.getColorByName(e.fill)).toPercentageRgb(),o=t.scale===ve.Exponential?Je.scalePow().exponent(t.exponent).domain([0,1]).range([0,1]):Je.scaleLinear().domain([0,1]).range([0,1]);for(let c=0;c<=l;c++)a.a=o(c/l),u.push((0,Qe.Z)(a).toString("hex8"))}else{const a=Be.find(h=>h.name===t.scheme)??mt;let o="interpolate"+(a.name2??a.name);const c=dt[o];for(let h=0;h<=l;h++){let f=c(h/l),w=f.indexOf("rgb")===0?"#"+[...f.matchAll(/\d+/g)].map(E=>(+E[0]).toString(16).padStart(2,"0")).join(""):f;u.push(w)}(a.invert==="always"||a.invert==="dark"&&n.isDark||a.invert==="light"&&n.isLight)&&u.reverse(),e.reverse&&u.reverse()}return u}const ft=({data:e,id:n,timeRange:t,timeZone:u,width:l,height:a,options:o,fieldConfig:c,eventBus:h,onChangeTimeRange:f,replaceVariables:w})=>{const E=(0,oe.l4)(),k=(0,oe.wW)(ht),{sync:I}=(0,ue.R9)();let _=[];for(const P of e.series)for(const s of P.fields)s.state?.scopedVars&&_.push(s.state.scopedVars);let j=(0,m.useRef)(t);j.current=t;const Z=(0,m.useCallback)((P,s)=>(0,ye.oB)(P,s,s.state?.scopedVars??{},w),[w]),S=(0,m.useMemo)(()=>Ie(o.color,E),[o.color,E]),y=(0,m.useMemo)(()=>{try{return $e(e.series,e.annotations,o,S,E,Z)}catch(P){return{warning:`${P}`}}},[e.series,e.annotations,o,S,E,Z]),O=(0,m.useMemo)(()=>{let P=[],s=[];const B=(0,F.d8)(y.heatmap);return y.exemplars?.length&&B.yMatchWithLabel&&(P=y.exemplars?.fields[0].values,B.yOrdinalDisplay!=null?s=(y.exemplars?.fields.find(V=>V.name===B.yMatchWithLabel).values).map(V=>B.yOrdinalLabel?.indexOf(V)):s=y.exemplars?.fields[1].values),[null,y.heatmap?.fields.map(D=>D.values),[P,s]]},[y.heatmap,y.exemplars]),[M,J]=(0,m.useState)(void 0),[H,z]=(0,m.useState)(!1),b=(0,m.useRef)(!1),R=()=>{b.current=!1,z(!1),A(null)},ee=()=>{b.current=!b.current,z(b.current)},A=(0,m.useCallback)(P=>{J(P??void 0)},[o,e.structureRev]),T=(0,m.useRef)(y);T.current=y;const Y=(0,m.useMemo)(()=>{const P=T.current?.heatmap?.fields[1].config?.custom?.scaleDistribution;return it({dataRef:T,theme:E,eventBus:h,onhover:A,onclick:o.tooltip.show?ee:null,onzoom:s=>{s.xMax-s.xMin>1&&f({from:s.xMin,to:s.xMax})},isToolTipOpen:b,timeZone:u,getTimeRange:()=>j.current,sync:I,cellGap:o.cellGap,hideLE:o.filterValues?.le,hideGE:o.filterValues?.ge,exemplarColor:o.exemplars?.color??"rgba(255,0,255,0.7)",yAxisConfig:o.yAxis,ySizeDivisor:P?.type===i.wf.Log?+(o.calculation?.yBuckets?.value||1):1})},[o,u,e.structureRev]),Q=()=>{if(!y.heatmap||!o.legend.show)return null;let B=T.current?.heatmap?.meta?.type===ne.P.HeatmapCells&&!(0,F.qJ)(T.current?.heatmap)?3:2;const D=y.heatmap.fields[B];let G;return M&&y.heatmap.fields&&M.seriesIdx===1&&(G=D.values[M.dataIdx]),m.createElement(re.AY.Legend,{placement:"bottom",maxHeight:"20%"},m.createElement("div",{className:k.colorScaleWrapper},m.createElement(ae.q,{hoverValue:G,colorPalette:S,min:T.current.heatmapColors?.minValue,max:T.current.heatmapColors?.maxValue,display:y.display})))};return y.warning||!y.heatmap?m.createElement(ce.Z,{panelId:n,fieldConfig:c,data:e,needsNumberField:!0,message:y.warning}):m.createElement(m.Fragment,null,m.createElement(re.AY,{width:l,height:a,legend:Q()},(P,s)=>m.createElement(be.N,{config:Y,data:O,width:P,height:s})),m.createElement(Fe.h_,null,M&&o.tooltip.show&&m.createElement(de.S,{position:{x:M.pageX,y:M.pageY},offset:{x:10,y:10},allowPointerEvents:b.current},H&&m.createElement(ze.o,{onClick:R}),m.createElement(et,{timeRange:t,data:y,hover:M,showHistogram:o.tooltip.yHistogram,replaceVars:w,scopedVars:_}))))},ht=e=>({colorScaleWrapper:(0,se.css)`
    margin-left: 25px;
    padding: 10px 0;
    max-width: 300px;
  `}),pt=e=>Object.keys(e.options).length===0?Xe(e,"heatmap",{angular:e},e.fieldConfig):e.options,Xe=(e,n,t,u)=>{if(n==="heatmap"&&t.angular){const{fieldConfig:l,options:a}=xt({...t.angular,fieldConfig:u});return e.fieldConfig=l,a}if(n==="heatmap-new"){const{bucketFrame:l,...a}=e.options;return l?{...a,rowsFrame:l}:e.options}return{}};function xt(e){const n={defaults:{},overrides:[]},t=e.dataFormat!=="tsbuckets",u={...C.calculation},l={logBase:1,...e.yAxis};t&&(e.xBucketSize?u.xBuckets={mode:i.kW.Size,value:`${e.xBucketSize}`}:e.xBucketNumber&&(u.xBuckets={mode:i.kW.Count,value:`${e.xBucketNumber}`}),e.yBucketSize?u.yBuckets={mode:i.kW.Size,value:`${e.yBucketSize}`}:e.xBucketNumber&&(u.yBuckets={mode:i.kW.Count,value:`${e.yBucketNumber}`}),l.logBase>1&&(u.yBuckets={mode:i.kW.Count,value:+l.splitFactor>0?`${l.splitFactor}`:void 0,scale:{type:i.wf.Log,log:l.logBase}}));const a=Re(e.cards?.cardPadding,2),o={calculate:t,calculation:u,color:{...C.color,steps:128},cellGap:a||1,cellRadius:Re(e.cards?.cardRound),yAxis:{axisPlacement:l.show===!1?i.LB.Hidden:i.LB.Left,reverse:!!e.reverseYBuckets,axisWidth:Re(l.width),min:l.min,max:l.max,unit:l.format,decimals:l.decimals},cellValues:{decimals:Re(e.tooltipDecimals)},rowsFrame:{layout:yt(e.yBucketBound)},legend:{show:!!e.legend?.show},showValue:i.Jp.Never,tooltip:{show:!!e.tooltip?.show,yHistogram:!!e.tooltip?.showHistogram},exemplars:{...C.exemplars}};e.hideZeroBuckets&&(o.filterValues={...C.filterValues});const c=e.color??{};switch(c?.mode){case"spectrum":{o.color.mode=ie.Scheme;const h=c.colorScheme;let f=Be.find(w=>w.name===h);f||(f=Be.find(w=>h.indexOf(w.name)>=0)),o.color.scheme=f?f.name:C.color.scheme;break}case"opacity":{o.color.mode=ie.Opacity,o.color.scale=c.scale;break}}return o.color.fill=c.cardColor,o.color.min=c.min,o.color.max=c.max,typeof c.min=="number"&&typeof c.max=="number"&&c.min>c.max&&(o.color.min=c.max,o.color.max=c.min,o.color.reverse=!0),{fieldConfig:n,options:o}}function yt(e){switch(e){case"upper":return i.kv.ge;case"lower":return i.kv.le;case"middle":return i.kv.unknown}return i.kv.auto}function Re(e,n){if(e==null||e==="")return n;const t=+e;return isNaN(t)?n:t}class gt{getSuggestionsForData(n){const{dataSummary:t}=n;if(!n.data?.series||!t.hasData||t.timeFieldCount<1||t.numberFieldCount<2||t.numberFieldCount>10)return;const u=Ie(C.color,xe.config.theme2),l=$e(n.data.series,void 0,C,u,xe.config.theme2);!l||l.warning||n.getListAppender({name:"",pluginId:"heatmap",options:{},fieldConfig:{defaults:{custom:{}},overrides:[]}})}}const vt=new X.c(ft).useFieldConfig({disableStandardOptions:Object.values(Ce.qb).filter(e=>e!==Ce.qb.Links),useCustomConfig:e=>{e.addCustomEditor({id:"scaleDistribution",path:"scaleDistribution",name:"Y axis scale",category:["Heatmap"],editor:Ee.Y,override:Ee.Y,defaultValue:{type:i.wf.Linear},shouldApply:n=>n.type===me.fS.number,process:De.kG,hideFromDefaults:!0}),(0,q.B)(e)}}).setPanelChangeHandler(Xe).setMigrationHandler(pt).setPanelOptions((e,n)=>{const t=n.options??C;let u=!1;if(n.data.length>0)try{const a=Ie(t.color,xe.config.theme2),o=$e(n.data,void 0,t,a,xe.config.theme2);u=(0,F.d8)(o.heatmap).yOrdinalDisplay!=null}catch{}let l=["Heatmap"];e.addRadio({path:"calculate",name:"Calculate from data",defaultValue:C.calculate,category:l,settings:{options:[{label:"Yes",value:!0},{label:"No",value:!1}]}}),t.calculate&&(0,fe.J)("calculation.",e,t.calculation,l),l=["Y Axis"],e.addRadio({path:"yAxis.axisPlacement",name:"Placement",defaultValue:C.yAxis.axisPlacement??i.LB.Left,category:l,settings:{options:[{label:"Left",value:i.LB.Left},{label:"Right",value:i.LB.Right},{label:"Hidden",value:i.LB.Hidden}]}}).addUnitPicker({category:l,path:"yAxis.unit",name:"Unit",defaultValue:void 0,settings:{isClearable:!0}}).addNumberInput({category:l,path:"yAxis.decimals",name:"Decimals",settings:{placeholder:"Auto"}}),u||e.addNumberInput({path:"yAxis.min",name:"Min value",settings:{placeholder:"Auto"},category:l}).addTextInput({path:"yAxis.max",name:"Max value",settings:{placeholder:"Auto"},category:l}),e.addNumberInput({path:"yAxis.axisWidth",name:"Axis width",defaultValue:C.yAxis.axisWidth,settings:{placeholder:"Auto",min:5},category:l}).addTextInput({path:"yAxis.axisLabel",name:"Axis label",defaultValue:C.yAxis.axisLabel,settings:{placeholder:"Auto"},category:l}),t.calculate||e.addRadio({path:"rowsFrame.layout",name:"Tick alignment",defaultValue:C.rowsFrame?.layout??i.kv.auto,category:l,settings:{options:[{label:"Auto",value:i.kv.auto},{label:"Top (LE)",value:i.kv.le},{label:"Middle",value:i.kv.unknown},{label:"Bottom (GE)",value:i.kv.ge}]}}),e.addBooleanSwitch({path:"yAxis.reverse",name:"Reverse",defaultValue:C.yAxis.reverse===!0,category:l}),l=["Colors"],e.addRadio({path:"color.mode",name:"Mode",defaultValue:C.color.mode,category:l,settings:{options:[{label:"Scheme",value:ie.Scheme},{label:"Opacity",value:ie.Opacity}]}}),e.addColorPicker({path:"color.fill",name:"Color",defaultValue:C.color.fill,category:l,showIf:a=>a.color.mode===ie.Opacity}),e.addRadio({path:"color.scale",name:"Scale",defaultValue:C.color.scale,category:l,settings:{options:[{label:"Exponential",value:ve.Exponential},{label:"Linear",value:ve.Linear}]},showIf:a=>a.color.mode===ie.Opacity}),e.addSliderInput({path:"color.exponent",name:"Exponent",defaultValue:C.color.exponent,category:l,settings:{min:.1,max:2,step:.1},showIf:a=>a.color.mode===ie.Opacity&&a.color.scale===ve.Exponential}),e.addSelect({path:"color.scheme",name:"Scheme",description:"",defaultValue:C.color.scheme,category:l,settings:{options:Be.map(a=>({value:a.name,label:a.name}))},showIf:a=>a.color.mode!==ie.Opacity}),e.addSliderInput({path:"color.steps",name:"Steps",defaultValue:C.color.steps,category:l,settings:{min:2,max:128,step:1}}).addBooleanSwitch({path:"color.reverse",name:"Reverse",defaultValue:C.color.reverse,category:l}).addCustomEditor({id:"__scale__",path:"__scale__",name:"",category:l,editor:()=>{const a=Ie(t.color,xe.config.theme2);return m.createElement("div",null,m.createElement(ae.q,{colorPalette:a,min:1,max:100}))}}),e.addNumberInput({path:"color.min",name:"Start color scale from value",defaultValue:C.color.min,settings:{placeholder:"Auto (min)"},category:l}).addNumberInput({path:"color.max",name:"End color scale at value",defaultValue:C.color.max,settings:{placeholder:"Auto (max)"},category:l}),l=["Cell display"],t.calculate||e.addTextInput({path:"rowsFrame.value",name:"Value name",defaultValue:C.rowsFrame?.value,settings:{placeholder:"Value"},category:l}),e.addUnitPicker({category:l,path:"cellValues.unit",name:"Unit",defaultValue:void 0,settings:{isClearable:!0}}).addNumberInput({category:l,path:"cellValues.decimals",name:"Decimals",settings:{placeholder:"Auto"}}),e.addSliderInput({name:"Cell gap",path:"cellGap",defaultValue:C.cellGap,category:l,settings:{min:0,max:25}}).addNumberInput({path:"filterValues.le",name:"Hide cells with values <=",defaultValue:C.filterValues?.le,settings:{placeholder:"None"},category:l}).addNumberInput({path:"filterValues.ge",name:"Hide cells with values >=",defaultValue:C.filterValues?.ge,settings:{placeholder:"None"},category:l}),l=["Tooltip"],e.addBooleanSwitch({path:"tooltip.show",name:"Show tooltip",defaultValue:C.tooltip.show,category:l}),e.addBooleanSwitch({path:"tooltip.yHistogram",name:"Show histogram (Y axis)",defaultValue:C.tooltip.yHistogram,category:l,showIf:a=>a.tooltip.show}),l=["Legend"],e.addBooleanSwitch({path:"legend.show",name:"Show legend",defaultValue:C.legend.show,category:l}),l=["Exemplars"],e.addColorPicker({path:"exemplars.color",name:"Color",defaultValue:C.exemplars.color,category:l})}).setSuggestionsSupplier(new gt)}}]);

//# sourceMappingURL=heatmapPanel.e220babf9c85f497534c.js.map