D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
build
/
Filename :
5917.7b45d994b2e1a6df1a6d.js
back
Copy
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5917],{18629:(ne,W,e)=>{e.d(W,{C0:()=>A,Uv:()=>I,Xq:()=>C});var u=e(27702),y=e(63439),t=e(25357),I=(E=>(E.ContactPoint="contact point",E.Template="template",E.MuteTiming="mute timing",E.AlertRule="alert rule",E.RootNotificationPolicy="root notification policy",E))(I||{});const C=({resource:E})=>u.createElement(y.b,{title:`This ${E} cannot be edited through the UI`,severity:"info"},"This ",E," has been provisioned, that means it was created by config. Please contact your server admin to update this ",E,"."),A=()=>u.createElement(t.C,{text:"Provisioned",color:"purple"})},51145:(ne,W,e)=>{e.d(W,{_:()=>A});var u=e(42844),y=e(27702),t=e(66310),I=e(25357),C=e(66670);const A=({enabled:v=!1,error:$,warning:j,onSetCondition:R})=>{const D=(0,t.wW)(E);return v&&$?y.createElement(I.C,{color:"red",icon:"exclamation-circle",text:"Alert condition",tooltip:$.message}):v&&j?y.createElement(I.C,{color:"orange",icon:"exclamation-triangle",text:"Alert condition",tooltip:j.message}):v&&!$&&!j?y.createElement(I.C,{color:"green",icon:"check",text:"Alert condition"}):v?null:y.createElement("button",{type:"button",className:D.actionLink,onClick:()=>R&&R()},"Set as alert condition")},E=v=>{const $=(0,C.gN)(v);return{actionLink:(0,u.css)` ${$}; color: ${v.colors.text.link}; cursor: pointer; &:hover { text-decoration: underline; } `}}},68525:(ne,W,e)=>{e.d(W,{A2:()=>_,bw:()=>s});var u=e(42844),y=e(89949),t=e(27702),I=e(53933),C=e(59425),A=e(60956),E=e(23852),v=e(66310),$=e(66670),j=e(31465),R=e(67437),D=e(19239),X=e(10124),k=e(74667),H=e(32291),P=e(33305),h=e(65946),g=e(18447),x=e(92367),S=e(51453),T=e(67045),M=e(68614),N=e(51145),B=e(27107);const Y=n=>{const d=n.fields[0];return d?.config?.displayNameFromDS??n.name??d?.labels?.__name__},Z=n=>{const d=n.fields[0]?.values[0];return Number.isFinite(d)?(0,B.O)(d,5):d},G=n=>n.fields[0]?.labels??{},w=n=>Object.entries(n).map(([d,i])=>d+"="+i).join(", "),J=n=>n.every(i=>i.fields.every(f=>f.values.every(p=>p==null))),_=({queries:n=[],query:d,data:i,error:f,warning:p,isAlertCondition:K,onSetCondition:z,onUpdateRefId:F,onRemoveExpression:O,onUpdateExpressionType:V,onChangeQuery:b})=>{const U=(0,v.wW)(a),Q=d?.type,ee=i&&Object.values(i).some(L=>!!L&&L.state===I.Gu.Loading),se=Array.isArray(i?.series)&&!ee,te=i?.series??[],ie=te.length,re=K??!1,le={[g.x_.Firing]:te.filter(L=>Z(L)!==0),[g.x_.Inactive]:te.filter(L=>Z(L)===0)},ce=(0,t.useCallback)(L=>{const oe=n.filter(q=>L.refId!==q.refId).map(q=>({value:q.refId,label:q.refId}));switch(L.type){case h.Us.math:return t.createElement(X.Z,{onChange:b,query:L,labelWidth:"auto",onRunQuery:()=>{}});case h.Us.reduce:return t.createElement(k.v,{onChange:b,refIds:oe,labelWidth:"auto",query:L});case h.Us.resample:return t.createElement(H.p,{onChange:b,query:L,labelWidth:"auto",refIds:oe});case h.Us.classic:return t.createElement(D.I,{onChange:b,query:L,refIds:oe});case h.Us.threshold:return t.createElement(P.M,{onChange:b,query:L,labelWidth:"auto",refIds:oe});default:return t.createElement(t.Fragment,null,"Expression not supported: ",L.type)}},[b,n]),ue=h.EJ.find(L=>L.value===Q)?.description??"";return t.createElement("div",{className:(0,u.cx)(U.expression.wrapper,re&&U.expression.alertCondition,Q===h.Us.classic&&U.expression.classic,Q!==h.Us.classic&&U.expression.nonClassic)},t.createElement("div",{className:U.expression.stack},t.createElement(l,{refId:d.refId,queryType:Q,onRemoveExpression:()=>O(d.refId),onUpdateRefId:L=>F(d.refId,L),onUpdateExpressionType:L=>V(d.refId,L),onSetCondition:z,warning:p,error:f,query:d,alertCondition:re}),t.createElement("div",{className:U.expression.body},t.createElement("div",{className:U.expression.description},ue),ce(d)),se&&t.createElement(t.Fragment,null,t.createElement(s,{series:te,isAlertCondition:K}),t.createElement("div",{className:U.footer},t.createElement(E.K,{direction:"row",alignItems:"center"},t.createElement(T.L,null),t.createElement(c,{isCondition:!!K,firing:le[g.x_.Firing].length,normal:le[g.x_.Inactive].length,seriesCount:ie}))))))},m=20,s=({series:n,isAlertCondition:d})=>{const{pageItems:i,previousPage:f,nextPage:p,numberOfPages:K,pageStart:z,pageEnd:F}=(0,x.h)(n,1,m),O=(0,v.wW)(a),V=J(n),b=!V&&(0,C.xI)(n),U=K>1;return t.createElement("div",{className:O.expression.results},!V&&b&&t.createElement("div",null,i.map((Q,ee)=>t.createElement(r,{key:(0,y.uniqueId)(),frame:Q,index:z+ee,isAlertCondition:d}))),!V&&!b&&i.map((Q,ee)=>t.createElement(o,{key:(0,y.uniqueId)(),frame:Q,index:z+ee,isAlertCondition:d})),V&&t.createElement("div",{className:(0,u.cx)(O.expression.noData,O.mutedText)},"No data"),U&&t.createElement("div",{className:O.pagination.wrapper,"data-testid":"paginate-expression"},t.createElement(E.K,null,t.createElement($.zx,{variant:"secondary",fill:"outline",onClick:f,icon:"angle-left",size:"sm","aria-label":"previous-page"}),t.createElement(T.L,null),t.createElement("span",{className:O.mutedText},z," - ",F," of ",n.length),t.createElement(T.L,null),t.createElement($.zx,{variant:"secondary",fill:"outline",onClick:p,icon:"angle-right",size:"sm","aria-label":"next-page"}))))},c=({firing:n,normal:d,isCondition:i,seriesCount:f})=>{const{mutedText:p}=(0,v.wW)(a);return f===0?t.createElement("span",{className:p},"No series"):i?t.createElement("span",{className:p},`${f} series: ${n} firing, ${d} normal`):t.createElement("span",{className:p},`${f} series`)},l=({refId:n,queryType:d,onUpdateRefId:i,onRemoveExpression:f,warning:p,onSetCondition:K,alertCondition:z,query:F,error:O})=>{const V=(0,v.wW)(a),b=(0,v.wW)($.gN),[U,Q]=(0,t.useState)(!1),se=U!==!1&&U==="refId";return t.createElement("header",{className:V.header.wrapper},t.createElement(E.K,{direction:"row",gap:.5,alignItems:"center"},t.createElement(E.K,{direction:"row",gap:1,alignItems:"center",wrap:!1},!se&&t.createElement("button",{type:"button",className:(0,u.cx)(b,V.editable),onClick:()=>Q("refId")},t.createElement("div",{className:V.expression.refId},n)),se&&t.createElement(j.H,{autoFocus:!0,defaultValue:n,minWidth:5,onChange:te=>{i(te.currentTarget.value),Q(!1)},onFocus:te=>te.target.select(),onBlur:te=>{i(te.currentTarget.value),Q(!1)}}),t.createElement("div",null,(0,h.hF)(d))),t.createElement(T.L,null),t.createElement(N._,{onSetCondition:()=>K(F.refId),enabled:z,error:O,warning:p}),t.createElement(R.h,{name:"trash-alt",variant:"secondary",className:V.mutedIcon,onClick:f,tooltip:"Remove expression"})))},o=({frame:n,index:d,isAlertCondition:i})=>{const f=(0,v.wW)(a),p=Y(n)||"Series "+d,K=Z(n),z=G(n),F=Object.entries(z),O=F.length>0,V=i&&K!==0,b=i&&K===0,U=`${O?"":p}${O?`{${w(z)}}`:""}`;return t.createElement("div",{className:f.expression.resultsRow},t.createElement(E.K,{direction:"row",gap:1,alignItems:"center"},t.createElement("div",{className:f.expression.resultLabel,title:U},t.createElement("span",null,O?"":p),O&&t.createElement(t.Fragment,null,t.createElement("span",null,"{"),F.map(([Q,ee],se)=>t.createElement("span",{key:(0,y.uniqueId)()},t.createElement("span",{className:f.expression.labelKey},Q),t.createElement("span",null,"="),t.createElement("span",null,'"'),t.createElement("span",{className:f.expression.labelValue},ee),t.createElement("span",null,'"'),se<F.length-1&&t.createElement("span",null,", "))),t.createElement("span",null,"}"))),t.createElement("div",{className:f.expression.resultValue},K),V&&t.createElement(M.l,{state:g.x_.Firing,size:"sm"}),b&&t.createElement(M.l,{state:g.x_.Inactive,size:"sm"})))},r=({frame:n,index:d})=>{const i=(0,v.wW)(a),f=n.fields[1],p=f.labels,z=f.config?.displayNameFromDS??(p?w(f.labels??{}):"Series "+d),F=n.fields[0].values,O=b=>n.fields[0].values[b],V=b=>n.fields[1].values[b];return t.createElement("div",{className:i.expression.resultsRow},t.createElement(E.K,{direction:"row",alignItems:"center"},t.createElement("span",{className:(0,u.cx)(i.mutedText,i.expression.resultLabel),title:z},z),t.createElement("div",{className:i.expression.resultValue},t.createElement(S.z,{placement:"right",wrapperClassName:i.timeseriesTableWrapper,content:t.createElement("table",{className:i.timeseriesTable},t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",null,"Timestamp"),t.createElement("th",null,"Value"))),t.createElement("tbody",null,F.map((b,U)=>t.createElement("tr",{key:U},t.createElement("td",{className:i.mutedText},(0,A.dq)(O(U))),t.createElement("td",{className:i.expression.resultValue},V(U))))))},t.createElement("span",null,"Time series data")))))},a=n=>({expression:{wrapper:(0,u.css)` display: flex; border: solid 1px ${n.colors.border.medium}; flex: 1; flex-basis: 400px; border-radius: ${n.shape.borderRadius()}; `,stack:(0,u.css)` display: flex; flex-direction: column; flex-wrap: nowrap; gap: 0; width: 100%; min-width: 0; // this one is important to prevent text overflow `,classic:(0,u.css)` max-width: 100%; `,nonClassic:(0,u.css)` max-width: 640px; `,alertCondition:(0,u.css)``,body:(0,u.css)` padding: ${n.spacing(1)}; flex: 1; `,description:(0,u.css)` margin-bottom: ${n.spacing(1)}; font-size: ${n.typography.size.xs}; color: ${n.colors.text.secondary}; `,refId:(0,u.css)` font-weight: ${n.typography.fontWeightBold}; color: ${n.colors.primary.text}; `,results:(0,u.css)` display: flex; flex-direction: column; flex-wrap: nowrap; border-top: solid 1px ${n.colors.border.medium}; `,noResults:(0,u.css)` display: flex; align-items: center; justify-content: center; `,resultsRow:(0,u.css)` padding: ${n.spacing(.75)} ${n.spacing(1)}; &:nth-child(odd) { background-color: ${n.colors.background.secondary}; } &:hover { background-color: ${n.colors.background.canvas}; } `,labelKey:(0,u.css)` color: ${n.isDark?"#73bf69":"#56a64b"}; `,labelValue:(0,u.css)` color: ${n.isDark?"#ce9178":"#a31515"}; `,resultValue:(0,u.css)` text-align: right; `,resultLabel:(0,u.css)` flex: 1; overflow-x: auto; display: inline-block; white-space: nowrap; `,noData:(0,u.css)` display: flex; align-items: center; justify-content: center; padding: ${n.spacing()}; `},mutedText:(0,u.css)` color: ${n.colors.text.secondary}; font-size: 0.9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `,header:{wrapper:(0,u.css)` background: ${n.colors.background.secondary}; padding: ${n.spacing(.5)} ${n.spacing(1)}; border-bottom: solid 1px ${n.colors.border.weak}; `},footer:(0,u.css)` background: ${n.colors.background.secondary}; padding: ${n.spacing(1)}; border-top: solid 1px ${n.colors.border.weak}; `,draggableIcon:(0,u.css)` cursor: grab; `,mutedIcon:(0,u.css)` color: ${n.colors.text.secondary}; `,editable:(0,u.css)` padding: ${n.spacing(.5)} ${n.spacing(1)}; border: solid 1px ${n.colors.border.weak}; border-radius: ${n.shape.borderRadius()}; display: flex; flex-direction: row; align-items: center; gap: ${n.spacing(1)}; cursor: pointer; `,timeseriesTableWrapper:(0,u.css)` max-height: 500px; overflow-y: scroll; `,timeseriesTable:(0,u.css)` table-layout: auto; width: 100%; height: 100%; td, th { padding: ${n.spacing(1)}; } td { background: ${n.colors.background.primary}; } th { background: ${n.colors.background.secondary}; } tr { border-bottom: 1px solid ${n.colors.border.medium}; &:last-of-type { border-bottom: none; } } `,pagination:{wrapper:(0,u.css)` border-top: 1px solid ${n.colors.border.medium}; padding: ${n.spacing()}; `}})},98445:(ne,W,e)=>{e.d(W,{l:()=>j});var u=e(42844),y=e(27702),t=e(55925),I=e(59425),C=e(66310),A=e(5933),E=e(98742),v=e(68525),$=e(95017);const j=({data:D,thresholds:X,thresholdsType:k})=>{const H=(0,C.wW)(R),P=(0,I.xI)(D.series),h=(0,$._4)(D),g=k?{mode:k}:void 0,x={from:D.timeRange.from.valueOf(),to:D.timeRange.to.valueOf()};return y.createElement("div",{className:H.wrapper},y.createElement(t.Z,{disableHeight:!0},({width:S})=>y.createElement("div",{style:{width:S}},P?y.createElement(E.F,{statusMessage:h,data:D.series,eventBus:A.Z,height:300,width:S,absoluteRange:x,timeZone:"browser",onChangeTime:()=>{},splitOpenFn:()=>{},loadingState:D.state,thresholdsConfig:X,thresholdsStyle:g}):y.createElement("div",{className:H.instantVectorResultWrapper},y.createElement("header",{className:H.title},"Table"),y.createElement(v.bw,{series:D.series})))))},R=D=>({wrapper:(0,u.css)` width: 100%; position: relative; `,instantVectorResultWrapper:(0,u.css)` border: solid 1px ${D.colors.border.medium}; border-radius: ${D.shape.borderRadius()}; padding: 0; display: flex; flex-direction: column; flex-wrap: nowrap; `,title:(0,u.css)({label:"panel-title",padding:D.spacing(),textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",fontSize:D.typography.h6.fontSize,fontWeight:D.typography.h6.fontWeight})})},95017:(ne,W,e)=>{e.d(W,{p0:()=>N,Vp:()=>B,eW:()=>_,_4:()=>w,Fu:()=>Z,Ry:()=>S,Dr:()=>M,KP:()=>J,Yq:()=>Y});var u=e(89949),y=e(59425),t=e(5168),I=e(64167),C=e(66805),A=e(12308),E=e(43609),v=e(55692),$=e(65946),j=e(72821),R=e(82152),D=e(2567);const X=(0,R.Z)(k,(m,s)=>x(m[0])===x(s[0]));function k(m){const s=new D.kJ,c=m.map(l=>l.refId);return s.createNodes(c),m.forEach(l=>{const o=l.refId;((0,v.j)(l.model)&&l.model.type==="math"?H(l.model.expression??""):[l.model.expression]).forEach(n=>{o&&n&&!(o===n)&&s.link(n,o)})}),s}function H(m){const s=new RegExp(/\$\{(?<var>[a-zA-Z0-9_ ]+?)\}/gm),c=new RegExp(/\$(?<var>[a-zA-Z0-9_]+)/gm),l=Array.from(m.matchAll(s)).map(r=>r.groups?.var),o=Array.from(m.matchAll(c)).map(r=>r.groups?.var);return(0,u.compact)((0,u.uniq)([...l,...o]))}const P=(0,u.memoize)(h,(m,s)=>m+g(s));function h(m,s){const c=s.getNode(m);let l=[];function o(r){const a=r.inputEdges;a.length>0?a.forEach(n=>{n.inputNode&&o(n.inputNode)}):l?.push(r)}return o(c),l.map(r=>r.name)}function g(m){return Object.keys(m.nodes).map(s=>{const c=m.nodes[s];let l=c.outputEdges.map(r=>r.outputNode?.name).join(", "),o=c.inputEdges.map(r=>r.inputNode?.name).join(", ");return`${c.name}:${l}:${o}`}).join(" ")}function x(m){return m.map(s=>{const c=(0,v.j)(s.model)?s.model.type:s.queryType;return s.refId+(s.model.expression??"")+c}).join()}function S(m,s,c){return m.map(l=>{if(s===c||!(0,v.j)(l.model))return l;const o=l.model.type==="math",r=l.model.type==="reduce",a=l.model.type==="resample",n=l.model.type==="classic_conditions",d=l.model.type==="threshold";if(o)return{...l,model:{...l.model,expression:T(l.model.expression??"",s,c)}};if(a||r||d){const i=l.model.expression===s;return{...l,model:{...l.model,expression:i?c:l.model.expression}}}if(n){const i=l.model.conditions?.map(f=>({...f,query:{...f.query,params:f.query.params.map(p=>p===s?c:p)}}));return{...l,model:{...l.model,conditions:i}}}return l})}function T(m,s,c){const l=new RegExp("(\\$"+s+"\\b)|(\\${"+s+"})","gm"),o="${"+c+"}";return m.replace(l,o)}function M(m,s){return m.find(c=>c.refId===s)!==void 0}function N(m){return m.includes("/")||m.includes("\\")?'Cannot contain "/" or "\\" characters':!0}function B(m){if(m.length===0)return;const s=(0,y.xI)(m);let c;return s&&(c=new Error("You cannot use time series data as an alert condition, consider adding a reduce expression.")),c}function Y(m){const c=(m[0]?.meta?.notices??[]).find(l=>l.severity==="warning")?.text;return c?new Error(c):void 0}function Z(m){const s={},c=[$.Us.threshold,$.Us.classic];for(const r of m){if(!(0,v.j)(r.model)||!c.includes(r.model.type)||!Array.isArray(r.model.conditions))continue;const a=r.model.conditions.some(G);r.model.conditions.forEach(n=>{const d=n.evaluator.params,i=n.query?.params[0]??r.model.expression;if(!i)return;const f=G(n);try{const p=X(m),K=P(i,p);m.filter(F=>K.includes(F.refId)).forEach(F=>{const O=F.refId,b=!!(!(0,v.j)(F?.model)&&O);O&&!s[O]&&(s[O]={config:{mode:t.H.Absolute,steps:[]},mode:I.i3.Line}),O&&b&&!f&&!a?l(O,d[0]):O&&b&&f&&(o(O,d,n.evaluator.type),s[O].mode=I.i3.LineAndArea)})}catch(p){console.error("Failed to parse thresholds",p);return}})}function l(r,a){s[r].config.steps.push({value:-1/0,color:"transparent"},{value:a,color:A.config.theme2.colors.error.main})}function o(r,a,n){n===E.$.IsWithinRange&&s[r].config.steps.push({value:-1/0,color:"transparent"},{value:a[0],color:A.config.theme2.colors.error.main},{value:a[1],color:A.config.theme2.colors.error.main},{value:a[1],color:"transparent"}),n===E.$.IsOutsideRange&&s[r].config.steps.push({value:-1/0,color:A.config.theme2.colors.error.main},{value:a[0],color:A.config.theme2.colors.error.main},{value:a[0],color:"transparent"},{value:a[1],color:A.config.theme2.colors.error.main}),s[r].config.steps.sort((d,i)=>d.value-i.value),s[r].config.steps=s[r].config.steps.filter(d=>d.value!==void 0)}return s}function G(m){return m.evaluator.type===E.$.IsWithinRange||m.evaluator.type===E.$.IsOutsideRange}function w(m){const s="Failed to fetch data";if(m.state!==C.Gu.Error)return;const c=m.errors;return c?.length?c.map(l=>l.message??s).join(", "):m.error?.message??s}function J(m=""){return m==="recording"?j.$.cloudRecording:j.$.grafana}function _(m,s){const c=s.filter(a=>!(0,v.j)(a.model)).map(a=>a.refId),l=m.filter(a=>!(0,v.j)(a.model)).map(a=>a.refId),[o,r]=(0,u.xor)(l,c);return[o,r]}},2701:(ne,W,e)=>{e.d(W,{S:()=>I});var u=e(27702),y=e(10864),t=e(42751);function I(C){return{allDataSourcesAvailable:(0,u.useMemo)(()=>C.filter(E=>!(0,t.Pr)(E.datasourceUid)).every(E=>!!(0,y.F)().getInstanceSettings(E.datasourceUid)),[C])}}},73475:(ne,W,e)=>{e.d(W,{v:()=>w});var u=e(89949),y=e(37497),t=e(45383),I=e(56469),C=e(32900),A=e(39343),E=e(66117),v=e(53933),$=e(32053),j=e(35412),R=e(76305),D=e(8508),X=e(66784),k=e(10864),H=e(40545),P=e(45937),h=e(55692),g=e(45329),x=e(3359),S=e(65946);const T={from:21600,to:0},M=(o,r)=>{const a=N(o,r);if(!a)return T;const{from:n,to:d}=Y(a,r);return!n.length&&!d.length?T:{from:Math.max(...n),to:Math.min(...d)}},N=(o,r)=>{switch(o.type){case S.Us.classic:return B(o);case S.Us.math:return Z(o,r);case S.Us.resample:case S.Us.reduce:case S.Us.threshold:return G(o)}},B=o=>o.conditions?.map(r=>r.query.params[0]),Y=(o,r)=>{let a=[],n=[T.to];for(const d of o){const i=r.find(f=>f.refId===d);!i||!i.relativeTimeRange||(a.push(i.relativeTimeRange.from),n.push(i.relativeTimeRange.to))}return{from:a,to:n}},Z=(o,r)=>r.filter(a=>a.queryType==="query"&&o.expression?.includes(a.refId)).map(a=>a.refId),G=o=>o.expression?[o.expression]:void 0;class w{constructor(r=(0,P.i)(),a=(0,k.F)()){this.backendSrv=r,this.dataSourceSrv=a,this.subject=new y.t(1),this.lastResult={}}get(){return this.subject.asObservable()}async run(r){const a=_(r,v.Gu.Done),n=[];for(const i of r){const f=i.model.refId;if((0,h.j)(i.model))continue;const p=await this.dataSourceSrv.get(i.datasourceUid);p.filterQuery&&!p.filterQuery(i.model)&&n.push(f)}const d=(0,u.reject)(r,i=>n.includes(i.model.refId));if(d.length===0)return this.subject.next(a);this.subscription=J(this.backendSrv,d).subscribe({next:i=>{const f=l(i,(p,K)=>{const z=this.lastResult[p],F=(0,$.zR)(K,z);return(0,x.C)(F,z)});this.lastResult=f,this.subject.next(this.lastResult)},error:i=>{this.lastResult=c(this.lastResult,i),this.subject.next(this.lastResult)}})}cancel(){if(!this.subscription)return;this.subscription.unsubscribe();let r=!1;const a=l(this.lastResult,(n,d)=>(d.state===v.Gu.Loading&&(r=!0),{...d,state:v.Gu.Done}));r&&this.subject.next(a)}destroy(){this.subject&&this.subject.complete(),this.cancel()}}const J=(o,r)=>{const a=_(r,v.Gu.Loading),n={data:{data:r},url:"/api/v1/eval",method:"POST",requestId:(0,E.Z)()};return(0,j.x)({whileLoading:a,source:o.fetch(n).pipe(s(a),(0,I.K)(d=>(0,t.of)(c(a,d))),(0,g.V)(o,n.requestId),(0,C.B)())})},_=(o,r)=>o.reduce((a,n)=>(a[n.refId]={state:r,series:[],timeRange:m(n,o)},a),{}),m=(o,r)=>{if((0,h.j)(o.model)){const a=M(o.model,r);return R.relativeToTimeRange(a)}return o.relativeTimeRange?R.relativeToTimeRange(o.relativeTimeRange):(console.warn(`Query with refId: ${o.refId} did not have any relative time range, using default.`),(0,D.JK)())},s=o=>(0,A.U)(r=>{const{data:a}=r,n={};for(const[d,i]of Object.entries(a.results))n[d]={timeRange:o[d].timeRange,state:v.Gu.Done,series:i.frames.map(X.vP)};return n}),c=(o,r)=>{const a=(0,H.P)(r);return l(o,(n,d)=>({...d,state:v.Gu.Error,error:a}))},l=(o,r)=>{const a={};for(const[n,d]of Object.entries(o))a[n]=r(n,d);return a}},48549:(ne,W,e)=>{e.d(W,{N:()=>j});var u=e(25587),y=e(1141),t=e(19221),I=e(29241),C=e(75578),A=e(76178),E=e(76761);const v="hideSeriesFrom",$=(0,u.Y4)(v);function j(h,g,x,S){const{overrides:T}=x,M=h,N=T.findIndex($);if(N<0){if(g===E.R.ToggleSelection){const J=R([M,...P(T,S)]);return{...x,overrides:[...x.overrides,J]}}const G=H(S,M),w=R(G);return{...x,overrides:[...x.overrides,w]}}const B=Array.from(T),[Y]=B.splice(N,1);if(g===E.R.ToggleSelection){let G=X(Y);const w=P(B,S);if(w.length>0&&(G=G.filter(_=>w.indexOf(_)<0)),G[0]===M&&G.length===1)return{...x,overrides:B};const J=R([M,...w]);return{...x,overrides:[...B,J]}}const Z=D(Y,M);return k(Z,S)?{...x,overrides:B}:{...x,overrides:[...B,Z]}}function R(h,g=y.Ys.exclude,x){return x=x??{id:"custom.hideFrom",value:{viz:!0,legend:!1,tooltip:!1}},{__systemRef:v,matcher:{id:t.mi.byNames,options:{mode:g,names:h,prefix:g===y.Ys.exclude?"All except:":void 0,readOnly:!0}},properties:[{...x,value:{viz:!0,legend:!1,tooltip:!1}}]}}const D=(h,g,x=y.Ys.exclude)=>{const S=h.properties.find(N=>N.id==="custom.hideFrom"),T=X(h),M=T.findIndex(N=>N===g);return M<0?T.push(g):T.splice(M,1),R(T,x,S)},X=h=>{const g=h.matcher.options?.names;return Array.isArray(g)?[...g]:[]},k=(h,g)=>X(h).length===H(g).length,H=(h,g)=>{const x=new Set;for(const S of h)for(const T of S.fields){if(T.type!==I.fS.number)continue;const M=(0,C.CZ)(T,S,h);M!==g&&x.add(M)}return Array.from(x)},P=(h,g)=>{let x=[];for(const S of h){const T=S.properties.find(M=>M.id==="custom.hideFrom");if(T!==void 0&&T.value?.legend===!0){const N=A.Ls.get(S.matcher.id).get(S.matcher.options);for(const B of g)for(const Y of B.fields){if(Y.type!==I.fS.number)continue;const Z=(0,C.CZ)(Y,B,g);N(Y,B,g)&&x.push(Z)}}}return x}},21512:(ne,W,e)=>{e.d(W,{y:()=>_});var u=e(42844),y=e(89949),t=e(27702),I=e(99633),C=e(26946),A=e(93666),E=e(21708),v=e(75578),$=e(79248),j=e(22323),R=e(64167),D=e(66310),X=e(70823),k=e(73453),H=e(66670),P=e(2643),h=e(48549),g=e(11109);function x(s,c,l){return(0,g.Uy)(s,o=>{o.defaults.custom===void 0&&(o.defaults.custom={}),o.defaults.max=l;const{custom:r}=o.defaults;switch(r.stacking===void 0&&(r.stacking={group:"A"}),c){case"lines":r.drawStyle=R.l8.Line,r.stacking.mode=R.o0.None,r.fillOpacity=0;break;case"bars":r.drawStyle=R.l8.Bars,r.stacking.mode=R.o0.None,r.fillOpacity=100;break;case"points":r.drawStyle=R.l8.Points,r.stacking.mode=R.o0.None,r.fillOpacity=0;break;case"stacked_lines":r.drawStyle=R.l8.Line,r.stacking.mode=R.o0.Normal,r.fillOpacity=100;break;case"stacked_bars":r.drawStyle=R.l8.Bars,r.stacking.mode=R.o0.Normal,r.fillOpacity=100;break;default:{const a=c;throw new Error(`Invalid graph-style: ${a}`)}}})}function S(s,c,l){return(0,g.Uy)(s,o=>{o.defaults.thresholds=l,o.defaults.custom=o.defaults.custom??{},o.defaults.custom.thresholdsStyle=c})}var T=function(s){return(s+1)%1e6};function M(){var s=(0,t.useReducer)(T,0),c=s[1];return c}function N(s,c){return typeof s=="function"?s.length?s(c):s():s}function B(s){var c=(0,t.useRef)(N(s)),l=M();return(0,t.useMemo)(function(){return[function(){return c.current},function(o){c.current=N(o,c.current),l()}]},[])}function Y(s,c,l){s===void 0&&(s=0),c===void 0&&(c=null),l===void 0&&(l=null);var o=N(s);typeof o!="number"&&console.error("initialValue has to be a number, got "+typeof s),typeof l=="number"?o=Math.max(o,l):l!==null&&console.error("min has to be a number, got "+typeof l),typeof c=="number"?o=Math.min(o,c):c!==null&&console.error("max has to be a number, got "+typeof c);var r=B(o),a=r[0],n=r[1];return[a(),(0,t.useMemo)(function(){var d=function(i){var f=a(),p=N(i,f);f!==p&&(typeof l=="number"&&(p=Math.max(p,l)),typeof c=="number"&&(p=Math.min(p,c)),f!==p&&n(p))};return{get:a,set:d,inc:function(i){i===void 0&&(i=1);var f=N(i,a());typeof f!="number"&&console.error("delta has to be a number or function returning a number, got "+typeof f),d(function(p){return p+f})},dec:function(i){i===void 0&&(i=1);var f=N(i,a());typeof f!="number"&&console.error("delta has to be a number or function returning a number, got "+typeof f),d(function(p){return p-f})},reset:function(i){i===void 0&&(i=o);var f=N(i,a());typeof f!="number"&&console.error("value has to be a number or function returning a number, got "+typeof f),o=f,d(f)}}},[o,l,c])]}var Z=e(24077),G=e(64987);function w(s){const[c,{inc:l}]=Y(0),o=(0,Z.Z)(s);return(0,t.useMemo)(()=>{o&&!(0,G.nl)(s,o,G.Ch)&&l()},[s,o,l]),c}const J=20;function _({data:s,height:c,width:l,timeZone:o,absoluteRange:r,onChangeTime:a,loadingState:n,annotations:d,onHiddenSeriesChanged:i,splitOpenFn:f,graphStyle:p,tooltipDisplayMode:K=R.f3.Single,anchorToZero:z=!1,yAxisMaximum:F,thresholdsConfig:O,thresholdsStyle:V,eventBus:b}){const U=(0,D.l4)(),Q=(0,D.wW)(m),[ee,se]=(0,t.useState)(!1),te={from:(0,I.CQ)(r.from),to:(0,I.CQ)(r.to),raw:{from:(0,I.CQ)(r.from),to:(0,I.CQ)(r.to)}},ie=(0,t.useMemo)(()=>(0,C.j)((0,P.F)(P.r),"Explore"),[]),[re,le]=(0,t.useState)({defaults:{min:z?0:void 0,max:F||void 0,color:{mode:A.S.PaletteClassic},custom:{drawStyle:R.l8.Line,fillOpacity:0,pointSize:5}},overrides:[]}),ce=(0,t.useMemo)(()=>{const q=x(re,p,F);return S(q,V,O)},[re,p,F,O,V]),ae=(0,t.useMemo)(()=>(0,E.SM)({fieldConfig:ce,data:ee?s:s.slice(0,J),timeZone:o,replaceVariables:q=>q,theme:U,fieldConfigRegistry:ie}),[ie,s,o,U,ce,ee]),ue=w(ae);(0,t.useEffect)(()=>{if(i){const q=[];ae.forEach(de=>{de.fields.map(me=>me.config?.custom?.hideFrom?.viz).every(y.identity)&&q.push((0,v.nf)(de))}),i(q)}},[ae,i]);const L={eventsScope:"explore",eventBus:b,sync:()=>$.m.Crosshair,onSplitOpen:f,onToggleSeriesVisibility(q,de){le((0,h.N)(q,de,re,s))}},oe=(0,t.useMemo)(()=>({tooltip:{mode:K,sort:R.As.None},legend:{displayMode:R.jK.List,showLegend:!0,placement:"bottom",calcs:[]}}),[K]);return t.createElement(X._w,{value:L},s.length>J&&!ee&&t.createElement("div",{className:Q.timeSeriesDisclaimer},t.createElement(k.J,{className:Q.disclaimerIcon,name:"exclamation-triangle"}),"Showing only ",J," time series.",t.createElement(H.zx,{variant:"primary",fill:"text",onClick:()=>se(!0),className:Q.showAllButton},"Show all ",s.length)),t.createElement(j.$,{data:{series:ae,timeRange:te,state:n,annotations:d,structureRev:ue},pluginId:"timeseries",title:"",width:l,height:c,onChangeTimeRange:a,timeZone:o,options:oe}))}const m=s=>({timeSeriesDisclaimer:(0,u.css)` label: time-series-disclaimer; margin: ${s.spacing(1)} auto; padding: 10px 0; text-align: center; `,disclaimerIcon:(0,u.css)` label: disclaimer-icon; color: ${s.colors.warning.main}; margin-right: ${s.spacing(.5)}; `,showAllButton:(0,u.css)` margin-left: ${s.spacing(.5)}; `})},98742:(ne,W,e)=>{e.d(W,{F:()=>H});var u=e(27702),y=e(92056),t=e(96866),I=e(21512),C=e(40705),A=e(18771);const E=A.EXPLORE_GRAPH_STYLES.map(P=>({value:P,label:P[0].toUpperCase()+P.slice(1).replace(/_/," ")}));function v(P){const{graphStyle:h,onChangeGraphStyle:g}=P;return u.createElement(C.S,{size:"sm",options:E,value:h,onChange:g})}var $=e(56812);const j="grafana.explore.style.graph",R=P=>{store.set(j,P)},D=()=>k($.Z.get(j)),X="lines",k=P=>A.EXPLORE_GRAPH_STYLES.find(g=>g===P)??X,H=({data:P,eventBus:h,height:g,width:x,absoluteRange:S,timeZone:T,annotations:M,onChangeTime:N,splitOpenFn:B,thresholdsConfig:Y,thresholdsStyle:Z,loadingState:G,statusMessage:w})=>{const[J,_]=(0,u.useState)(D),m=(0,u.useCallback)(s=>{(0,t.FG)(s),_(s)},[]);return u.createElement(y.fm,{title:"Graph",width:x,height:g,loadingState:G,statusMessage:w,actions:u.createElement(v,{graphStyle:J,onChangeGraphStyle:m})},(s,c)=>u.createElement(I.y,{graphStyle:J,data:P,height:c,width:s,absoluteRange:S,onChangeTime:N,timeZone:T,annotations:M,splitOpenFn:B,loadingState:G,thresholdsConfig:Y,thresholdsStyle:Z,eventBus:h}))}},55692:(ne,W,e)=>{e.d(W,{j:()=>t});var u=e(42751),y=e(65946);const t=I=>{if(!I)return!1;if((0,u.Pr)(I.datasource))return!0;const C=I;return typeof C.type!="string"?!1:Object.values(y.Us).includes(C.type)}}}]); //# sourceMappingURL=5917.7b45d994b2e1a6df1a6d.js.map