"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[642],{89439:(S,I,t)=>{t.d(I,{q:()=>h});var c=t(27702),E=t(91368);const h=({actions:o,children:f,fallback:T=!0})=>o.some(O=>E.contextSrv.hasAccess(O,T))?c.createElement(c.Fragment,null,f):null},218:(S,I,t)=>{t.d(I,{g:()=>O});var c=t(42844),E=t(27702),h=t(23852),o=t(66310),f=t(73453),T=t(21323);const O=({children:i,icon:_,color:P="secondary",...a})=>{const e=(0,o.wW)(g),s=typeof a.onClick=="function";return E.createElement("div",{className:(0,c.cx)({[e.interactive]:s}),...a},E.createElement(T.x,{color:P},E.createElement(h.K,{direction:"row",alignItems:"center",gap:.5},_&&E.createElement(f.J,{name:_}),i)))},g=()=>({interactive:(0,c.css)`
    cursor: pointer;
  `})},9908:(S,I,t)=>{t.d(I,{B0:()=>u,Iw:()=>m,tK:()=>M});var c=t(42844),E=t(89949),h=t.n(E),o=t(27702),f=t(23852),T=t(66310),O=t(22209),g=t(79978),i=t(80011),_=t(73453),P=t(1128),a=t(28580),e=t(66670),s=t(79003),r=t(76658),l=t(95984);const u=({receivers:p,onChangeReceiver:A,onChangeMatchers:W})=>{const[n,d]=(0,s.j)(),R=(0,o.useRef)(null),{queryString:D,contactPoint:y}=B(n),C=(0,T.wW)($),L=(0,o.useCallback)(()=>(0,E.debounce)(W,500),[W]);(0,o.useEffect)(()=>{A(y)},[y,A]),(0,o.useEffect)(()=>{const K=(0,r.Zh)(D??"").map(r.xz);L()(K)},[L,D]);const F=(0,o.useCallback)(()=>{R.current&&(R.current.value=""),d({contactPoint:void 0,queryString:void 0})},[d]),G=p.map(v),V=G.find(K=>K.value===y)??null,j=D||y,x=D&&D.length>3?(0,r.Zh)(D).length===0:!1;return o.createElement(f.K,{direction:"row",alignItems:"flex-start",gap:.5},o.createElement(O.g,{className:C.noBottom,label:o.createElement(g._,null,o.createElement(f.K,{gap:.5},o.createElement("span",null,"Search by matchers"),o.createElement(i.u,{content:o.createElement("div",null,"Filter silences by matchers using a comma separated list of matchers, ie:",o.createElement("pre",null,"severity=critical, instance=~cluster-us-.+"))},o.createElement(_.J,{name:"info-circle",size:"sm"})))),invalid:x,error:x?"Query must use valid matcher syntax":null},o.createElement(P.I,{ref:R,"data-testid":"search-query-input",placeholder:"Search",width:46,prefix:o.createElement(_.J,{name:"search"}),onChange:K=>{d({queryString:K.currentTarget.value})},defaultValue:D})),o.createElement(O.g,{label:"Search by contact point",style:{marginBottom:0}},o.createElement(a.Ph,{id:"receiver","aria-label":"Search by contact point",value:V,options:G,onChange:K=>{d({contactPoint:K?.value})},width:28,isClearable:!0})),j&&o.createElement(e.zx,{variant:"secondary",icon:"times",onClick:F,style:{marginTop:19}},"Clear filters"))};function m(p,A){const W=[];function n(d){A(d)&&W.push(d),d.routes?.forEach(n)}return n(p),W}function M(p){return{...p,routes:p.routes?.map(A=>{const W=(0,l.$2)(p,A);return M({...A,...W})})}}const v=p=>({label:p.name,value:p.name}),B=p=>({queryString:p.get("queryString")??void 0,contactPoint:p.get("contactPoint")??void 0}),$=()=>({noBottom:(0,c.css)`
    margin-bottom: 0;
  `})},54915:(S,I,t)=>{t.d(I,{g:()=>i});var c=t(42844),E=t(89949),h=t.n(E),o=t(27702),f=t(23852),T=t(66310),O=t(64714),g=t(51453);const i=({matchers:a})=>{const e=(0,T.wW)(P),s=5,r=(0,E.take)(a,s),l=(0,E.takeRight)(a,a.length-s),u=l.length>0;return o.createElement("span",{"data-testid":"label-matchers"},o.createElement(f.K,{direction:"row",gap:1,alignItems:"center"},r.map(m=>o.createElement(_,{key:(0,E.uniqueId)(),matcher:m})),u&&o.createElement(g.z,{arrow:!0,placement:"top",content:o.createElement(o.Fragment,null,l.map(m=>o.createElement(_,{key:(0,E.uniqueId)(),matcher:m})))},o.createElement("span",null,o.createElement("div",{className:e.metadata},`and ${l.length} more`)))))},_=({matcher:[a,e,s]})=>{const r=(0,T.wW)(P);return o.createElement("div",{className:r.matcher(a).wrapper},o.createElement(f.K,{direction:"row",gap:0,alignItems:"baseline"},a," ",e," ",s))},P=a=>({matcher:e=>{const{color:s,borderColor:r}=(0,O.Bx)(e);return{wrapper:(0,c.css)`
        color: #fff;
        background: ${s};
        padding: ${a.spacing(.33)} ${a.spacing(.66)};
        font-size: ${a.typography.bodySmall.fontSize};

        border: solid 1px ${r};
        border-radius: ${a.shape.borderRadius(2)};
      `}},metadata:(0,c.css)`
    color: ${a.colors.text.secondary};

    font-size: ${a.typography.bodySmall.fontSize};
    font-weight: ${a.typography.bodySmall.fontWeight};
  `})},97529:(S,I,t)=>{t.d(I,{W:()=>E});var c=t(52646);function E(h,o){const f=c.alertmanagerApi.endpoints.getAlertmanagerConfiguration.useQuery(h??"",{...o,skip:!h});return{...f,error:f.error}}},36546:(S,I,t)=>{t.d(I,{N:()=>a});var c=t(85907),E=t(27702),h=t(91078),o=t(91106),f=t(28722),T=t(42575);const O=()=>new T.q(new URL(t.p+t.u(9438),t.b));var g=t(30888);let i;function _(){let e;if(i===void 0)try{e=O(),i=c.Ud(e)}catch(r){r instanceof Error&&(0,o.H)(r)}return{disposeWorker:()=>{e&&i&&(i[c.Yy](),e.terminate(),i=void 0,e=void 0)}}}function P(e,s){if(!e)throw new Error("Matching routes preview is disabled");if(!i)throw new Error("Route Matcher has not been initialized")}function a(){const e=(0,h.Qb)(g.v.NotificationPoliciesV2MatchingInstances);(0,E.useEffect)(()=>{if(e){const{disposeWorker:l}=_();return l}return()=>null},[e]);const s=(0,E.useCallback)(async(l,u)=>{P(e,i);const m=performance.now(),M=await i.getRouteGroupsMap(l,u),v=performance.now()-m;return(0,f.PN)(`Route Groups Matched in  ${v} ms`,{matchingTime:v.toString(),alertGroupsCount:u.length.toString(),topLevelRoutesCount:l.routes?.length.toString()??"0"}),M},[e]),r=(0,E.useCallback)(async(l,u)=>{P(e,i);const m=performance.now(),M=await i.matchInstancesToRoute(l,u),v=performance.now()-m;return(0,f.PN)(`Instances Matched in  ${v} ms`,{matchingTime:v.toString(),instancesToMatchCount:u.length.toString(),topLevelRoutesCount:l.routes?.length.toString()??"0"}),M},[e]);return{getRouteGroupsMap:s,matchInstancesToRoute:r}}},26630:(S,I,t)=>{t.d(I,{Oy:()=>p,T0:()=>M,Yg:()=>m,ZS:()=>u,bi:()=>$,br:()=>l,dO:()=>s,eP:()=>W,eh:()=>v,fx:()=>a,mJ:()=>B});var c=t(89949),E=t.n(c),h=t(62862),o=t(76658),f=t(22513),T=t(32925),O=t(68228),g=t(447);const i=(n,d)=>Object.entries(n??{}).reduce((R,[D,y])=>[...R,{name:D,value:y,operator:d?h._M.regex:h._M.equal}],[]),_=n=>n.value,P=n=>(n??[]).map(_),a={name:"",value:"",operator:h._M.equal},e=["grafana_folder","alertname"],s=[{label:"grafana_folder",value:"grafana_folder"},{label:"alertname",value:"alertname"},{label:"Disable (...)",value:"..."}],r={id:"",overrideGrouping:!1,groupBy:e,object_matchers:[],routes:[],continue:!1,receiver:"",overrideTimings:!1,groupWaitValue:"",groupIntervalValue:"",repeatIntervalValue:"",muteTimeIntervals:[]};function l(n){return{id:(0,c.uniqueId)("route-"),...n,routes:(n.routes??[]).map(l)}}const u=n=>{if(!n)return r;const d="id"in n?n.id:(0,c.uniqueId)("route-");if(Object.keys(n).length===0)return{...r,id:d};const R=[];n.routes?.forEach(C=>{const L=u(C);R.push(L)});const D=n.object_matchers?.map(C=>({name:C[0],operator:C[1],value:C[2]}))??[],y=n.matchers?.map(C=>(0,o.cm)((0,T.tC)(C)))??[];return{id:d,object_matchers:[...y,...D,...i(n.match,!1),...i(n.match_re,!0)],continue:n.continue??!1,receiver:n.receiver??"",overrideGrouping:Array.isArray(n.group_by)&&n.group_by.length>0,groupBy:n.group_by??void 0,overrideTimings:[n.group_wait,n.group_interval,n.repeat_interval].some(Boolean),groupWaitValue:n.group_wait??"",groupIntervalValue:n.group_interval??"",repeatIntervalValue:n.repeat_interval??"",routes:R,muteTimeIntervals:n.mute_time_intervals??[]}},m=(n,d,R)=>{const D=(0,O.Tx)(d.id??"",R),{overrideGrouping:y,groupBy:C,overrideTimings:L,groupWaitValue:F,groupIntervalValue:G,repeatIntervalValue:V,receiver:j}=d,x=void 0,K=y?C:x,w=L&&F?F:x,H=L&&G?G:x,Q=L&&V?V:x,Y=d.object_matchers?.filter(U=>U.name&&U.value&&U.operator).map(({name:U,operator:z,value:N})=>[U,z,N]),J=d.routes?.map(U=>m(n,U,R)),b={...D??{},continue:d.continue,group_by:K,object_matchers:Y,match:void 0,match_re:void 0,group_wait:w,group_interval:H,repeat_interval:Q,routes:J,mute_time_intervals:d.muteTimeIntervals,receiver:j};return n!==f.GC?(b.matchers=d.object_matchers?.map(({name:U,operator:z,value:N})=>`${U}${z}${N}`),b.object_matchers=void 0):(b.object_matchers=(0,T.QO)(b),b.matchers=void 0),d.receiver&&(b.receiver=d.receiver),b},M=n=>({label:n,value:n}),v=n=>(n??[]).map(M),B=n=>{if(n!==null)return n?_(n)??"":""},$=n=>n?P(n):[];function p(n){return n.length===0?!0:(0,g.wd)(n)||"Invalid duration format. Must be {number}{time_unit}"}const A=n=>n.map(d=>{const[R,D,y]=d;return`${R}${D}${y}`}),W=(n,d)=>{if(n.length===0)return!0;const R=p(n),D=p(d);if(R!==!0)return R;if(D!==!0)return D;const y=(0,g.Bg)(n),C=(0,g.Bg)(d);return C!==0&&y<C?"Repeat interval should be higher or equal to Group interval":!0}},95984:(S,I,t)=>{t.d(I,{$2:()=>P,w2:()=>i});var c=t(89949),E=t.n(c),h=t(62862),o=t(32925);const f={[h._M.equal]:(a,e)=>a===e,[h._M.notEqual]:(a,e)=>a!==e,[h._M.regex]:(a,e)=>!!a.match(new RegExp(e)),[h._M.notRegex]:(a,e)=>!a.match(new RegExp(e))};function T(a,e){const[s,r]=e,[l,u,m]=a;if(s!==l)return!1;const M=f[u];if(!M)throw new Error(`no such operator: ${u}`);return M(r,m)}function O(a,e){const s=new Map,r=new Map(e.map(u=>[u,{match:!1,matchers:[]}]));return{matches:a.every(u=>{const m=e.filter(M=>T(u,M));return m.forEach(M=>{const v=r.get(M);v&&(v.match=!0,v.matchers.push(u))}),m.length===0?!1:(s.set(u,m),m.length>0)}),details:s,labelsMatch:r}}function g(a,e){let s=[];const r=O(a.object_matchers??[],e);if(!r.matches)return[];if(a.routes)for(let l=0;l<a.routes.length;l++){let u=a.routes[l],m=g(u,e);if(s=s.concat(m),m.length&&!u.continue)break}return s.length===0&&s.push({route:a,details:r.details,labelsMatch:r.labelsMatch}),s}function i(a){function e(r){r.object_matchers=(0,o.QO)(r),delete r.matchers,delete r.match,delete r.match_re,r.routes?.forEach(e)}const s=structuredClone(a);return e(s),s}function _(a,e,s){const r=[];return s.reduce((l,u)=>{const m=u.alerts.filter(M=>{const v=Object.entries(M.labels);return g(a,v).some(B=>B.route===e)});return m.length&&l.push({...u,alerts:m}),l},r)}function P(a,e,s){const r=(0,c.merge)({},a,s),l=(0,c.pick)(r,["receiver","group_by","group_wait","group_interval","repeat_interval","mute_time_intervals"]);return(0,c.reduce)(l,(m={},M,v)=>{const B=M!==void 0,$=B&&e[v]===void 0,p=B&&e[v]==="",A=v==="group_by"&&B&&(0,c.isArray)(e[v])&&e[v]?.length===0;return($||p||A)&&(m[v]=M),m},{})}},68228:(S,I,t)=>{t.d(I,{SF:()=>o,Tx:()=>O,_P:()=>T,wB:()=>f});var c=t(89949),E=t.n(c),h=t(26630);const o=(g,i,_)=>{if(!O(i.id??"",_))throw new Error(`No such route with ID '${i.id}'`);function a(e){let s=e;if(e.id===i.id){const r=(0,h.Yg)(g,i,_);s=(0,c.omit)({...e,...r},"id")}return(0,c.omit)({...s,routes:e.routes?.map(a)},"id")}return a(_)},f=(g,i)=>{if(g.id===i.id)throw new Error("You cant remove the root policy");function _(P){return(0,c.omit)({...P,routes:P.routes?.reduce((a=[],e)=>(e.id===g.id||a.push(_(e)),a),[])},"id")}return _(i)},T=(g,i,_,P)=>{const a=(0,h.Yg)(g,i,P);function e(r){return r.id===_.id?{...r,routes:r.routes?.concat(a)}:{...r,routes:r.routes?.map(e)}}function s(r){return(0,c.omit)({...r,routes:r.routes?.map(s)},"id")}return s(e(P))};function O(g,i){return i.id===g?i:i.routes?.find(_=>O(g,_))}}}]);

//# sourceMappingURL=642.38b1cf05e91e995e058f.js.map