"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6035],{81456:(U,O,n)=>{n.d(O,{q:()=>C});var i=n(86832),e=n.n(i),d=n(39953),h=n(18314);const C=({actions:v,children:c})=>{const r=(0,i.filter)(v,g),t=(0,i.filter)(v,P);return r.length?d.createElement(T,{actions:r},c):t.length?d.createElement(x,{actions:t},c):null},T=({actions:v,children:c})=>{const r=(0,h.Mz)();return u(r,v)?d.createElement(d.Fragment,null,c):null},x=({actions:v,children:c})=>{const r=(0,h.cI)();return u(r,v)?d.createElement(d.Fragment,null,c):null};function u(v,c){return(0,i.chain)(v).pick(c).values().value().some(([r,t])=>t===!0)}function g(v){return Object.values(h.oI).includes(v)}function P(v){return Object.values(h.hB).includes(v)}},18677:(U,O,n)=>{n.d(O,{g:()=>x});var i=n(41407),e=n(39953),d=n(27366),h=n(82803),C=n(98632),T=n(12190);const x=({children:g,icon:P,color:v="secondary",...c})=>{const r=(0,h.wW)(u),t=typeof c.onClick=="function";return e.createElement("div",{className:(0,i.cx)({[r.interactive]:t}),...c},e.createElement(C.x,{variant:"bodySmall",color:v},e.createElement(d.K,{direction:"row",alignItems:"center",gap:.5},P&&e.createElement(T.J,{size:"sm",name:P}),g)))},u=()=>({interactive:(0,i.css)`
    cursor: pointer;
  `})},96440:(U,O,n)=>{n.d(O,{g:()=>g});var i=n(41407),e=n(86832),d=n.n(e),h=n(39953),C=n(27366),T=n(82803),x=n(72899),u=n(44351);const g=({matchers:c})=>{const r=(0,T.wW)(v),t=5,o=(0,e.take)(c,t),m=(0,e.takeRight)(c,c.length-t),l=m.length>0;return h.createElement("span",{"data-testid":"label-matchers"},h.createElement(C.K,{direction:"row",gap:1,alignItems:"center"},o.map(E=>h.createElement(P,{key:(0,e.uniqueId)(),matcher:E})),l&&h.createElement(u.z,{arrow:!0,placement:"top",content:h.createElement(h.Fragment,null,m.map(E=>h.createElement(P,{key:(0,e.uniqueId)(),matcher:E})))},h.createElement("span",null,h.createElement("div",{className:r.metadata},`and ${m.length} more`)))))},P=({matcher:[c,r,t]})=>{const o=(0,T.wW)(v);return h.createElement("div",{className:o.matcher(c).wrapper},h.createElement(C.K,{direction:"row",gap:0,alignItems:"baseline"},c," ",r," ",t))},v=c=>({matcher:r=>{const{color:t,borderColor:o}=(0,x.Bx)(r);return{wrapper:(0,i.css)`
        color: #fff;
        background: ${t};
        padding: ${c.spacing(.33)} ${c.spacing(.66)};
        font-size: ${c.typography.bodySmall.fontSize};

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

    font-size: ${c.typography.bodySmall.fontSize};
    font-weight: ${c.typography.bodySmall.fontWeight};
  `})},46035:(U,O,n)=>{n.r(O),n.d(O,{default:()=>ie});var i=n(41407),e=n(39953),d=n(82803),h=n(33155),C=n(84766),T=n(41393),x=n(65577),u=n(86832),g=n(71757),P=n.n(g),v=n(948),c=n(4919),r=n(72899),t=n(3532),o=n(98934),m=n(18677),l=n(67111),E=n(96440);function y(a){return a.path?.length===0}function R(a){const f=new Map;function M(D,A=[]){f.set(D.id,{...D,path:A}),D.routes?.forEach(p=>M(p,[...A,D.id]))}return M(a,[]),f}function S(a){return a.object_matchers?.length===0}function _({route:a}){const f=(0,d.wW)(H);return y(a)?e.createElement("div",{className:f.defaultPolicy},"Default policy"):S(a)?e.createElement("div",{className:f.textMuted},"No matchers"):e.createElement(E.g,{matchers:a.object_matchers??[]})}const H=a=>({defaultPolicy:(0,i.css)`
    padding: ${a.spacing(.5)};
    background: ${a.colors.background.secondary};
    width: fit-content;
  `,textMuted:(0,i.css)`
    color: ${a.colors.text.secondary};
  `});var k=n(73075),Z=n(12190),s=n(18314),I=n(328),B=n(95712),w=n(76716),L=n(81456);function N({route:a,routesByIdMap:f}){const M=(0,d.wW)(X),D=a.path?.slice(1)??[],A=[...(0,u.compact)(D.map(p=>f.get(p))),a];return e.createElement("div",{className:M.policyPathWrapper},e.createElement("div",{className:M.defaultPolicy},"Default policy"),A.map((p,b)=>e.createElement("div",{key:p.id},e.createElement("div",{className:M.policyInPath(b,b===A.length-1)},S(p)?e.createElement("div",{className:M.textMuted},"No matchers"):e.createElement(E.g,{matchers:p.object_matchers??[]})))))}function j({onClose:a,route:f,receiver:M,routesByIdMap:D,alertManagerSourceName:A}){const p=(0,d.wW)(X),b=y(f);return e.createElement(I.h5,{accessType:"notification",alertmanagerSourceName:B.JY},e.createElement(k.u,{className:p.detailsModal,isOpen:!0,title:"Routing details",onDismiss:a,onClickBackdrop:a},e.createElement(x.K,{gap:0,direction:"column"},e.createElement("div",{className:(0,i.cx)(p.textMuted,p.marginBottom(2))},"Your alert instances are routed as follows."),e.createElement("div",null,"Notification policy path"),b&&e.createElement("div",{className:p.textMuted},"Default policy"),e.createElement("div",{className:p.separator(1)}),!b&&e.createElement(e.Fragment,null,e.createElement(N,{route:f,routesByIdMap:D})),e.createElement("div",{className:p.separator(4)}),e.createElement("div",{className:p.contactPoint},e.createElement(x.K,{gap:1,direction:"row",alignItems:"center"},"Contact point:",e.createElement("span",{className:p.textMuted},M.name)),e.createElement(L.q,{actions:[s.oI.UpdateContactPoint]},e.createElement(x.K,{gap:1,direction:"row",alignItems:"center"},e.createElement("a",{href:(0,w.eQ)(`/alerting/notifications/receivers/${encodeURIComponent(M.name)}/edit`,A),className:p.link,target:"_blank",rel:"noreferrer"},"See details ",e.createElement(Z.J,{name:"external-link-alt"}))))),e.createElement("div",{className:p.button},e.createElement(c.zx,{variant:"primary",type:"button",onClick:a},"Close")))))}const X=a=>({textMuted:(0,i.css)`
    color: ${a.colors.text.secondary};
  `,link:(0,i.css)`
    display: block;
    color: ${a.colors.text.link};
  `,button:(0,i.css)`
    justify-content: flex-end;
    display: flex;
  `,detailsModal:(0,i.css)`
    max-width: 560px;
  `,defaultPolicy:(0,i.css)`
    padding: ${a.spacing(.5)};
    background: ${a.colors.background.secondary};
    width: fit-content;
  `,contactPoint:(0,i.css)`
    display: flex;
    flex-direction: row;
    gap: ${a.spacing(1)};
    align-items: center;
    justify-content: space-between;
    margin-bottom: ${a.spacing(1)};
  `,policyPathWrapper:(0,i.css)`
    display: flex;
    flex-direction: column;
    margin-top: ${a.spacing(1)};
  `,separator:f=>(0,i.css)`
    margin-top: ${a.spacing(f)};
  `,marginBottom:f=>(0,i.css)`
    margin-bottom: ${a.spacing(a.spacing(f))};
  `,policyInPath:(f=0,M=!1)=>(0,i.css)`
    margin-left: ${30+f*30}px;
    padding: ${a.spacing(1)};
    margin-top: ${a.spacing(1)};
    border: solid 1px ${a.colors.border.weak};
    background: ${a.colors.background.secondary};
    width: fit-content;
    position: relative;

    ${M&&(0,i.css)`
        border: solid 1px ${a.colors.info.border};
      `},
    &:before {
      content: '';
      position: absolute;
      height: calc(100% - 10px);
      width: ${a.spacing(1)};
      border-left: solid 1px ${a.colors.border.weak};
      border-bottom: solid 1px ${a.colors.border.weak};
      margin-top: ${a.spacing(-2)};
      margin-left: -17px;
    }
  }  `});function q({route:a,receiver:f,routesByIdMap:M,instancesCount:D,alertManagerSourceName:A,expandRoute:p,onExpandRouteClick:b}){const W=(0,d.wW)(te),[z,Y]=(0,e.useState)(!1),G=()=>{Y(!0)};return e.createElement("div",{className:W.routeHeader},e.createElement(o.U,{isCollapsed:!p,onToggle:F=>b(!F),"aria-label":"Expand policy route"}),e.createElement(x.K,{flexGrow:1,gap:1},e.createElement("div",{onClick:()=>b(!p),className:W.expandable},e.createElement(x.K,{gap:1,direction:"row",alignItems:"center"},"Notification policy",e.createElement(_,{route:a}))),e.createElement(l.L,null),e.createElement(x.K,{gap:2,direction:"row",alignItems:"center"},e.createElement(m.g,{icon:"layers-alt","data-testid":"matching-instances"},D??"-",e.createElement("span",null,P()("instance",D))),e.createElement(x.K,{gap:1,direction:"row",alignItems:"center"},e.createElement("div",null,e.createElement("span",{className:W.textMuted},"@ Delivered to")," ",f.name),e.createElement("div",{className:W.verticalBar}),e.createElement(c.zx,{type:"button",onClick:G,variant:"secondary",fill:"outline",size:"sm"},"See details")))),z&&e.createElement(j,{onClose:()=>Y(!1),route:a,receiver:f,routesByIdMap:M,alertManagerSourceName:A}))}function ee({route:a,instanceMatches:f,receiver:M,routesByIdMap:D,alertManagerSourceName:A}){const p=(0,d.wW)(te),[b,W]=(0,v.Z)(!1),z=9;return e.createElement("div",{"data-testid":"matching-policy-route"},e.createElement(q,{route:a,receiver:M,routesByIdMap:D,instancesCount:f.length,alertManagerSourceName:A,expandRoute:b,onExpandRouteClick:W}),b&&e.createElement(x.K,{gap:1,direction:"column"},e.createElement("div",{className:p.routeInstances,"data-testid":"route-matching-instance"},f.map(Y=>{const G=Array.from(Y.labelsMatch);let F=G.map(([$,V])=>({label:`${$[0]}=${$[1]}`,match:V.match,colorIndex:V.match?(0,r.tu)($[0]):z}));const K=F.filter($=>$.match),Q=F.filter($=>!$.match);return e.createElement("div",{className:p.tagListCard,key:(0,u.uniqueId)()},G.length>0?e.createElement(e.Fragment,null,K.length>0?e.createElement(t.P,{tags:K.map($=>$.label),className:p.labelList,getColorIndex:($,V)=>K[V].colorIndex}):e.createElement("div",{className:(0,i.cx)(p.textMuted,p.textItalic)},"No matching labels"),e.createElement("div",{className:p.labelSeparator}),e.createElement(t.P,{tags:Q.map($=>$.label),className:p.labelList,getColorIndex:($,V)=>Q[V].colorIndex})):e.createElement("div",{className:p.textMuted},"No labels"))}))))}const te=a=>({textMuted:(0,i.css)`
    color: ${a.colors.text.secondary};
  `,textItalic:(0,i.css)`
    font-style: italic;
  `,expandable:(0,i.css)`
    cursor: pointer;
  `,routeHeader:(0,i.css)`
    display: flex;
    flex-direction: row;
    gap: ${a.spacing(1)};
    align-items: center;
    border-bottom: 1px solid ${a.colors.border.weak};
    &:hover {
      background-color: ${a.components.table.rowHoverBackground};
    }
    padding: ${a.spacing(.5,.5,.5,0)};
  `,labelList:(0,i.css)`
    flex: 0 1 auto;
    justify-content: flex-start;
  `,labelSeparator:(0,i.css)`
    width: 1px;
    background-color: ${a.colors.border.weak};
  `,tagListCard:(0,i.css)`
    display: flex;
    flex-direction: row;
    gap: ${a.spacing(2)};

    position: relative;
    background: ${a.colors.background.secondary};
    padding: ${a.spacing(1)};

    border-radius: ${a.shape.borderRadius(2)};
    border: solid 1px ${a.colors.border.weak};
  `,routeInstances:(0,i.css)`
    padding: ${a.spacing(1,0,1,4)};
    position: relative;

    display: flex;
    flex-direction: column;
    gap: ${a.spacing(1)};

    &:before {
      content: '';
      position: absolute;
      left: ${a.spacing(2)};
      height: calc(100% - ${a.spacing(2)});
      width: ${a.spacing(4)};
      border-left: solid 1px ${a.colors.border.weak};
    }
  `,verticalBar:(0,i.css)`
    width: 1px;
    height: 20px;
    background-color: ${a.colors.secondary.main};
    margin-left: ${a.spacing(1)};
    margin-right: ${a.spacing(1)};
  `});var J=n(20653),ne=n(72401),ce=n(47853),ae=n(93139),re=n(62393);const oe=(a,f)=>{const{currentData:M,isLoading:D,error:A}=(0,ne.W)(a),p=M?.alertmanager_config,{matchInstancesToRoute:b}=(0,ce.N)(),{rootRoute:W,receivers:z}=(0,e.useMemo)(()=>p?{rootRoute:p.route?(0,re.w2)((0,ae.br)(p.route)):void 0,receivers:p.receivers??[]}:{receivers:[],rootRoute:void 0},[p]),Y=W?R((0,re.tK)(W)):new Map,G=z.reduce(($,V)=>$.set(V.name,V),new Map)??new Map,{value:F=new Map,loading:K,error:Q}=(0,J.Z)(async()=>{if(W)return await b(W,f)},[W,f]);return{routesByIdMap:Y,receiversByName:G,matchingMap:F,loading:D||K,error:A??Q}};function le({alertManagerSource:a,potentialInstances:f,onlyOneAM:M}){const D=(0,d.wW)(se),{routesByIdMap:A,receiversByName:p,matchingMap:b,loading:W,error:z}=oe(a.name,f);return z?e.createElement(h.b,{title:"Cannot load Alertmanager configuration",severity:"error"},z.message):W?e.createElement(C.u,{text:"Loading routing preview..."}):b.size>0?e.createElement("div",{className:D.alertManagerRow},!M&&e.createElement(x.K,{direction:"row",alignItems:"center"},e.createElement("div",{className:D.firstAlertManagerLine}),e.createElement("div",{className:D.alertManagerName}," ","Alert manager:",e.createElement("img",{src:a.img,alt:"",className:D.img}),a.name),e.createElement("div",{className:D.secondAlertManagerLine})),e.createElement(x.K,{gap:1,direction:"column"},Array.from(b.entries()).map(([G,F])=>{const K=A.get(G),Q=K?.receiver&&p.get(K.receiver);if(!K)return null;if(!Q)throw new Error("Receiver not found");return e.createElement(ee,{instanceMatches:F,route:K,receiver:Q,key:G,routesByIdMap:A,alertManagerSourceName:a.name})}))):null}const ie=(0,T.Pf)(le),se=a=>({alertManagerRow:(0,i.css)`
    display: flex;
    flex-direction: column;
    gap: ${a.spacing(1)};
    width: 100%;
  `,firstAlertManagerLine:(0,i.css)`
    height: 1px;
    width: ${a.spacing(4)};
    background-color: ${a.colors.secondary.main};
  `,alertManagerName:(0,i.css)`
    width: fit-content;
  `,secondAlertManagerLine:(0,i.css)`
    height: 1px;
    width: 100%;
    flex: 1;
    background-color: ${a.colors.secondary.main};
  `,img:(0,i.css)`
    margin-left: ${a.spacing(2)};
    width: ${a.spacing(3)};
    height: ${a.spacing(3)};
    margin-right: ${a.spacing(1)};
  `})},18314:(U,O,n)=>{n.d(O,{Mz:()=>P,RA:()=>v,cI:()=>g,hB:()=>x,o2:()=>c,oI:()=>T,xC:()=>r});var i=n(39953),e=n(97125),d=n(57721),h=n(328),C=n(60703),T=(t=>(t.ViewExternalConfiguration="view-external-configuration",t.UpdateExternalConfiguration="update-external-configuration",t.CreateContactPoint="create-contact-point",t.ViewContactPoint="view-contact-point",t.UpdateContactPoint="edit-contact-points",t.DeleteContactPoint="delete-contact-point",t.ExportContactPoint="export-contact-point",t.CreateNotificationTemplate="create-notification-template",t.ViewNotificationTemplate="view-notification-template",t.UpdateNotificationTemplate="edit-notification-template",t.DeleteNotificationTemplate="delete-notification-template",t.DecryptSecrets="decrypt-secrets",t.CreateNotificationPolicy="create-notification-policy",t.ViewNotificationPolicyTree="view-notification-policy-tree",t.UpdateNotificationPolicyTree="update-notification-policy-tree",t.DeleteNotificationPolicy="delete-notification-policy",t.ExportNotificationPolicies="export-notification-policies",t.CreateSilence="create-silence",t.ViewSilence="view-silence",t.UpdateSilence="update-silence",t.ViewMuteTiming="view-mute-timing",t.CreateMuteTiming="create-mute-timing",t.UpdateMuteTiming="update-mute-timing",t.DeleteMuteTiming="delete-mute-timing",t))(T||{}),x=(t=>(t.CreateAlertRule="create-alert-rule",t.ViewAlertRule="view-alert-rule",t.UpdateAlertRule="update-alert-rule",t.DeleteAlertRule="delete-alert-rule",t.CreateExternalAlertRule="create-external-alert-rule",t.ViewExternalAlertRule="view-external-alert-rule",t.UpdateExternalAlertRule="update-external-alert-rule",t.DeleteExternalAlertRule="delete-external-alert-rule",t))(x||{});const u=!0;function g(){return{["create-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleCreate)],["view-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleRead)],["update-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleUpdate)],["delete-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleDelete)],["create-external-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleExternalWrite)],["view-external-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleExternalRead)],["update-external-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleExternalWrite)],["delete-external-alert-rule"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingRuleExternalWrite)]}}function P(){const{selectedAlertmanager:t,hasConfigurationAPI:o,isGrafanaAlertmanager:m}=(0,h.ZA)(),l=(0,C.Ko)(t),E=(0,C.QX)(t);return{["view-external-configuration"]:[u,e.contextSrv.hasPermission(d.AccessControlAction.AlertingNotificationsExternalRead)],["update-external-configuration"]:[o,e.contextSrv.hasPermission(d.AccessControlAction.AlertingNotificationsExternalWrite)],["create-contact-point"]:[o,e.contextSrv.hasPermission(l.create)],["view-contact-point"]:[u,e.contextSrv.hasPermission(l.read)],["edit-contact-points"]:[o,e.contextSrv.hasPermission(l.update)],["delete-contact-point"]:[o,e.contextSrv.hasPermission(l.delete)],["export-contact-point"]:[m,e.contextSrv.hasPermission(l.provisioning.read)||e.contextSrv.hasPermission(l.provisioning.readSecrets)],["create-notification-template"]:[o,e.contextSrv.hasPermission(l.create)],["view-notification-template"]:[u,e.contextSrv.hasPermission(l.read)],["edit-notification-template"]:[o,e.contextSrv.hasPermission(l.update)],["delete-notification-template"]:[o,e.contextSrv.hasPermission(l.delete)],["create-notification-policy"]:[o,e.contextSrv.hasPermission(l.create)],["view-notification-policy-tree"]:[u,e.contextSrv.hasPermission(l.read)],["update-notification-policy-tree"]:[o,e.contextSrv.hasPermission(l.update)],["delete-notification-policy"]:[o,e.contextSrv.hasPermission(l.delete)],["export-notification-policies"]:[m,e.contextSrv.hasPermission(l.provisioning.read)||e.contextSrv.hasPermission(l.provisioning.readSecrets)],["decrypt-secrets"]:[m,e.contextSrv.hasPermission(l.provisioning.readSecrets)],["create-silence"]:[o,e.contextSrv.hasPermission(E.create)],["view-silence"]:[u,e.contextSrv.hasPermission(E.read)],["update-silence"]:[o,e.contextSrv.hasPermission(E.update)],["create-mute-timing"]:[o,e.contextSrv.hasPermission(l.create)],["view-mute-timing"]:[u,e.contextSrv.hasPermission(l.read)],["update-mute-timing"]:[o,e.contextSrv.hasPermission(l.update)],["delete-mute-timing"]:[o,e.contextSrv.hasPermission(l.delete)]}}function v(t){const o=P();return(0,i.useMemo)(()=>o[t],[o,t])}function c(t){const o=P();return(0,i.useMemo)(()=>t.map(m=>o[m]),[o,t])}function r(t){const o=g();return(0,i.useMemo)(()=>o[t],[o,t])}},72401:(U,O,n)=>{n.d(O,{W:()=>e});var i=n(37546);function e(d,h){const C=i.alertmanagerApi.endpoints.getAlertmanagerConfiguration.useQuery(d??"",{...h,skip:!d});return{...C,error:C.error}}},47853:(U,O,n)=>{n.d(O,{N:()=>c});var i=n(6222),e=n(39953),d=n(5229),h=n(54538),C=n(79517),T=n(84474);const x=()=>new T.q(new URL(n.p+n.u(7530),n.b));var u=n(45050);let g;function P(){let r;if(g===void 0)try{r=x(),g=i.Ud(r)}catch(o){o instanceof Error&&(0,h.H)(o)}return{disposeWorker:()=>{r&&g&&(g[i.Yy](),r.terminate(),g=void 0,r=void 0)}}}function v(r,t){if(!r)throw new Error("Matching routes preview is disabled");if(!g)throw new Error("Route Matcher has not been initialized")}function c(){const r=(0,d.Qb)(u.v.NotificationPoliciesV2MatchingInstances);(0,e.useEffect)(()=>{if(r){const{disposeWorker:m}=P();return m}return()=>null},[r]);const t=(0,e.useCallback)(async(m,l)=>{v(r,g);const E=performance.now(),y=await g.getRouteGroupsMap(m,l),R=performance.now()-E;return(0,C.PN)(`Route Groups Matched in  ${R} ms`,{matchingTime:R.toString(),alertGroupsCount:l.length.toString(),topLevelRoutesCount:m.routes?.length.toString()??"0"}),y},[r]),o=(0,e.useCallback)(async(m,l)=>{v(r,g);const E=performance.now(),y=await g.matchInstancesToRoute(m,l),R=performance.now()-E;return(0,C.PN)(`Instances Matched in  ${R} ms`,{matchingTime:R.toString(),instancesToMatchCount:l.length.toString(),topLevelRoutesCount:m.routes?.length.toString()??"0"}),y},[r]);return{getRouteGroupsMap:t,matchInstancesToRoute:o}}},93139:(U,O,n)=>{n.d(O,{Oy:()=>H,T0:()=>y,Yg:()=>E,ZS:()=>l,bi:()=>_,br:()=>m,dO:()=>t,eP:()=>Z,eh:()=>R,fx:()=>c,mJ:()=>S});var i=n(86832),e=n.n(i),d=n(47858),h=n(14949),C=n(95712),T=n(75404),x=n(75964),u=n(66793);const g=(s,I)=>Object.entries(s??{}).reduce((B,[w,L])=>[...B,{name:w,value:L,operator:I?d._M.regex:d._M.equal}],[]),P=s=>s.value,v=s=>(s??[]).map(P),c={name:"",value:"",operator:d._M.equal},r=["grafana_folder","alertname"],t=[{label:"grafana_folder",value:"grafana_folder"},{label:"alertname",value:"alertname"},{label:"Disable (...)",value:"..."}],o={id:"",overrideGrouping:!1,groupBy:r,object_matchers:[],routes:[],continue:!1,receiver:"",overrideTimings:!1,groupWaitValue:"",groupIntervalValue:"",repeatIntervalValue:"",muteTimeIntervals:[]};function m(s){return{id:(0,i.uniqueId)("route-"),...s,routes:(s.routes??[]).map(m)}}const l=s=>{if(!s)return o;const I="id"in s?s.id:(0,i.uniqueId)("route-");if(Object.keys(s).length===0)return{...o,id:I};const B=[];s.routes?.forEach(N=>{const j=l(N);B.push(j)});const w=s.object_matchers?.map(N=>({name:N[0],operator:N[1],value:N[2]}))??[],L=s.matchers?.map(N=>(0,h.cm)((0,T.tC)(N)))??[];return{id:I,object_matchers:[...L,...w,...g(s.match,!1),...g(s.match_re,!0)],continue:s.continue??!1,receiver:s.receiver??"",overrideGrouping:Array.isArray(s.group_by)&&s.group_by.length>0,groupBy:s.group_by??void 0,overrideTimings:[s.group_wait,s.group_interval,s.repeat_interval].some(Boolean),groupWaitValue:s.group_wait??"",groupIntervalValue:s.group_interval??"",repeatIntervalValue:s.repeat_interval??"",routes:B,muteTimeIntervals:s.mute_time_intervals??[]}},E=(s,I,B)=>{const w=(0,x.Tx)(I.id??"",B),{overrideGrouping:L,groupBy:N,overrideTimings:j,groupWaitValue:X,groupIntervalValue:q,repeatIntervalValue:ee,receiver:te}=I,J=void 0,ne=L?N:J,ae=j&&X?X:J,oe=j&&q?q:J,ie=j&&ee?ee:J,se=I.object_matchers?.filter(M=>M.name&&M.value&&M.operator).map(({name:M,operator:D,value:A})=>[M,D,A]),a=I.routes?.map(M=>E(s,M,B)),f={...w??{},continue:I.continue,group_by:ne,object_matchers:se,match:void 0,match_re:void 0,group_wait:ae,group_interval:oe,repeat_interval:ie,routes:a,mute_time_intervals:I.muteTimeIntervals,receiver:te};return s!==C.GC?(f.matchers=I.object_matchers?.map(({name:M,operator:D,value:A})=>`${M}${D}${A}`),f.object_matchers=void 0):(f.object_matchers=(0,T.QO)(f),f.matchers=void 0),I.receiver&&(f.receiver=I.receiver),f},y=s=>({label:s,value:s}),R=s=>(s??[]).map(y),S=s=>{if(s!==null)return s?P(s)??"":""},_=s=>s?v(s):[];function H(s){return s.length===0?!0:(0,u.wd)(s)||"Invalid duration format. Must be {number}{time_unit}"}const k=s=>s.map(I=>{const[B,w,L]=I;return`${B}${w}${L}`}),Z=(s,I)=>{if(s.length===0)return!0;const B=H(s),w=H(I);if(B!==!0)return B;if(w!==!0)return w;const L=(0,u.Bg)(s),N=(0,u.Bg)(I);return N!==0&&L<N?"Repeat interval should be higher or equal to Group interval":!0}},62393:(U,O,n)=>{n.d(O,{$2:()=>v,tK:()=>c,w2:()=>g});var i=n(86832),e=n.n(i),d=n(47858),h=n(75404);const C={[d._M.equal]:(r,t)=>r===t,[d._M.notEqual]:(r,t)=>r!==t,[d._M.regex]:(r,t)=>!!r.match(new RegExp(t)),[d._M.notRegex]:(r,t)=>!r.match(new RegExp(t))};function T(r,t){const[o,m]=t,[l,E,y]=r;if(o!==l)return!1;const R=C[E];if(!R)throw new Error(`no such operator: ${E}`);return R(m,y)}function x(r,t){const o=new Map,m=new Map(t.map(E=>[E,{match:!1,matchers:[]}]));return{matches:r.every(E=>{const y=t.filter(R=>T(E,R));return y.forEach(R=>{const S=m.get(R);S&&(S.match=!0,S.matchers.push(E))}),y.length===0?!1:(o.set(E,y),y.length>0)}),details:o,labelsMatch:m}}function u(r,t){let o=[];const m=x(r.object_matchers??[],t);if(!m.matches)return[];if(r.routes)for(let l=0;l<r.routes.length;l++){let E=r.routes[l],y=u(E,t);if(o=o.concat(y),y.length&&!E.continue)break}return o.length===0&&o.push({route:r,details:m.details,labelsMatch:m.labelsMatch}),o}function g(r){function t(m){m.object_matchers=(0,h.QO)(m),delete m.matchers,delete m.match,delete m.match_re,m.routes?.forEach(t)}const o=structuredClone(r);return t(o),o}function P(r,t,o){const m=[];return o.reduce((l,E)=>{const y=E.alerts.filter(R=>{const S=Object.entries(R.labels);return u(r,S).some(_=>_.route===t)});return y.length&&l.push({...E,alerts:y}),l},m)}function v(r,t,o){const m=(0,i.merge)({},r,o),l=(0,i.pick)(m,["receiver","group_by","group_wait","group_interval","repeat_interval","mute_time_intervals"]);return(0,i.reduce)(l,(y={},R,S)=>{const _=R!==void 0,H=_&&t[S]===void 0,k=_&&t[S]==="",Z=S==="group_by"&&_&&(0,i.isArray)(t[S])&&t[S]?.length===0;return(H||k||Z)&&(y[S]=R),y},{})}function c(r){return{...r,routes:r.routes?.map(t=>{const o=v(r,t);return c({...t,...o})})}}},75964:(U,O,n)=>{n.d(O,{SF:()=>h,Tx:()=>x,_P:()=>T,wB:()=>C});var i=n(86832),e=n.n(i),d=n(93139);const h=(u,g,P)=>{if(!x(g.id??"",P))throw new Error(`No such route with ID '${g.id}'`);function c(r){let t=r;if(r.id===g.id){const o=(0,d.Yg)(u,g,P);t=(0,i.omit)({...r,...o},"id")}return(0,i.omit)({...t,routes:r.routes?.map(c)},"id")}return c(P)},C=(u,g)=>{if(u.id===g.id)throw new Error("You cant remove the root policy");function P(v){return(0,i.omit)({...v,routes:v.routes?.reduce((c=[],r)=>(r.id===u.id||c.push(P(r)),c),[])},"id")}return P(g)},T=(u,g,P,v)=>{const c=(0,d.Yg)(u,g,v);function r(o){return o.id===P.id?{...o,routes:o.routes?.concat(c)}:{...o,routes:o.routes?.map(r)}}function t(o){return(0,i.omit)({...o,routes:o.routes?.map(t)},"id")}return t(r(v))};function x(u,g){return g.id===u?g:g.routes?.find(P=>x(u,P))}}}]);

//# sourceMappingURL=6035.671639f2cf7fec8076b4.js.map