"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3511],{40715:(ae,B,a)=>{a.d(B,{o:()=>E});var s=a(96540),e=a(80348),g=a(97007);function E(M){const x=(0,e.useDispatch)(),N=(0,s.useRef)(M);N.current=M,(0,s.useEffect)(()=>()=>{x((0,g.N)({cleanupAction:N.current}))},[x])}},31987:(ae,B,a)=>{a.r(B),a.d(B,{CreateAlertButton:()=>it,default:()=>ga});var s=a(32196),e=a(96540),g=a(24180),E=a(41053),M=a(10940),x=a(76885),N=a(66602),R=a(40845),D=a(55852),b=a(83277),S=a(80348),f=a(25027),U=a(33450),P=a(67061),ve=a(76442),J=a(7521),Q=a(41520);const le=()=>{const{canCreateGrafanaRules:t,canCreateCloudRules:n}=(0,Q.V)(),r=(0,R.of)(de);return t||n?e.createElement("div",null,e.createElement("p",null,"You haven't created any alert rules yet"),e.createElement(P.B,{gap:1},e.createElement("div",{className:r.newRuleCard},e.createElement(J.A,{title:"",buttonIcon:"bell",buttonLink:"alerting/new/alerting",buttonTitle:"New alert rule",proTip:"you can also create alert rules from existing panels and queries.",proTipLink:"https://grafana.com/docs/",proTipLinkTitle:"Learn more",proTipTarget:"_blank",onClick:()=>(0,f.fH)(f.le.alertRuleFromScratch)})),e.createElement("div",{className:r.newRuleCard},e.createElement(J.A,{title:"",buttonIcon:"plus",buttonLink:"alerting/new/recording",buttonTitle:"New recording rule",onClick:()=>(0,f.fH)(f.le.recordingRuleFromScratch)})))):e.createElement(ve.c,{message:"No rules exist yet.",callToActionElement:e.createElement("div",null)})},de=t=>({newRuleCard:(0,s.css)`
    width: calc(50% - ${t.spacing(1)});

    > div {
      height: 100%;
    }
  `});var se=a(11536),ne=a(55127),ge=a.n(ne),Re=a(78685),K=a(42418),ee=a(56034),X=a(61410),I=a(57220),Z=a(56361),z=a(23662);function he(){const[t,n]=(0,e.useState)(!1),[r,c]=(0,Re.A)("grafana.unifiedalerting.hideErrors",!1),l=(0,X.$)(m=>m.dataSources),o=(0,X.$)(m=>m.promRules),u=(0,X.$)(m=>m.rulerRules),i=(0,R.of)(Se),d=(0,e.useMemo)(()=>{const[m,A,W]=[l,o,u].map(y=>(0,I.qi)().reduce((v,$)=>{const k=y[$.name]?.error;return y[$.name]&&k&&!(0,z.$7)(y[$.name])?[...v,{dataSource:$,error:k}]:v},[])),h=o[I.hY]?.error,O=u[I.hY]?.error,C=[];return h&&C.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules state: ",h.message||"Unknown error.")),O&&C.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules config: ",O.message||"Unknown error.")),m.forEach(({dataSource:y,error:v})=>{C.push(e.createElement(e.Fragment,null,"Failed to load the data source configuration for"," ",e.createElement("a",{href:(0,Z.GD)(y.uid),className:i.dsLink},y.name),": ",v.message||"Unknown error."))}),A.forEach(({dataSource:y,error:v})=>C.push(e.createElement(e.Fragment,null,"Failed to load rules state from"," ",e.createElement("a",{href:(0,Z.GD)(y.uid),className:i.dsLink},y.name),": ",v.message||"Unknown error."))),W.forEach(({dataSource:y,error:v})=>C.push(e.createElement(e.Fragment,null,"Failed to load rules config from"," ",e.createElement("a",{href:(0,Z.GD)(y.uid),className:i.dsLink},y.name),": ",v.message||"Unknown error."))),C},[l,o,u,i.dsLink]);return e.createElement(e.Fragment,null,!!d.length&&r&&e.createElement(ue,{count:d.length,onClick:()=>c(m=>!m)}),!!d.length&&!r&&e.createElement(K.F,{"data-testid":"cloud-rulessource-errors",title:"Errors loading rules",severity:"error",onRemove:()=>c(!0)},t&&d.map((m,A)=>e.createElement("div",{key:A},m)),!t&&e.createElement(e.Fragment,null,e.createElement("div",null,d[0]),d.length>=2&&e.createElement(D.$n,{className:i.moreButton,fill:"text",icon:"angle-right",size:"sm",onClick:()=>n(!0)},d.length-1," more ",ge()("error",d.length-1)))))}const ue=({count:t,onClick:n})=>{const r=(0,R.of)(Se);return e.createElement("div",{className:r.floatRight},e.createElement(ee.m,{content:"Show all errors",placement:"bottom"},e.createElement(D.$n,{fill:"text",variant:"destructive",icon:"exclamation-triangle",onClick:n},t>1?e.createElement(e.Fragment,null,t," errors"):e.createElement(e.Fragment,null,"1 error"))))},Se=t=>({moreButton:(0,s.css)`
    padding: 0;
  `,floatRight:(0,s.css)`
    display: flex;
    justify-content: flex-end;
  `,dsLink:(0,s.css)`
    font-weight: ${t.typography.fontWeightBold};
  `});var te=a(19073),He=a(64853),Ce=a(39558),Oe=a(62930),ze=a(19384),je=a(15054),Ye=a(98439),Ve=a(22620),Pe=a(88467),we=a(66864),Ee=a(14578),Te=a(39938),ut=a(96374),mt=a(11167),dt=a(83903),Me=a(23770),Je=a(64047),Qe=a(82437),Ne=a(79938),be=a(16293),Le=a(76648),Fe=a(84029);function gt({folder:t,onClose:n}){const[r,c]=(0,e.useState)("yaml");return e.createElement(Le.m,{title:`Export ${t.title} rules`,activeTab:r,onTabChange:c,onClose:n,formatProviders:Object.values(Fe.sl)},e.createElement(Et,{folder:t,exportFormat:r,onClose:n}))}function Et({folder:t,exportFormat:n,onClose:r}){const{currentData:c="",isFetching:l}=Ne.hK.endpoints.exportRules.useQuery({folderUid:t.uid,format:n});if(l)return e.createElement(Ce._,{text:"Loading...."});const o=`${t.title}-${t.uid}`;return e.createElement(be.J,{format:n,textDefinition:c,downloadFileName:o,onClose:r})}function pt({folderUid:t,groupName:n,onClose:r}){const[c,l]=(0,e.useState)("yaml");return e.createElement(Le.m,{title:`Export ${n} rules`,activeTab:c,onTabChange:l,onClose:r,formatProviders:Object.values(Fe.sl)},e.createElement(ft,{folderUid:t,groupName:n,exportFormat:c,onClose:r}))}function ft({folderUid:t,groupName:n,exportFormat:r,onClose:c}){const{currentData:l="",isFetching:o}=Ne.hK.endpoints.exportRules.useQuery({folderUid:t,group:n,format:r});return o?e.createElement(Ce._,{text:"Loading...."}):e.createElement(be.J,{format:r,textDefinition:l,downloadFileName:n,onClose:c})}var Xe=a(99106),oe=a(72275),vt=a(46479),ht=a(46942),Ze=a.n(ht),ye=a(2543),Be=a(75494),yt=a(37390),Rt=a(99140),Ct=a(18461),xt=a(30423);const Dt=t=>{const{group:n,namespace:r,onClose:c,folderUid:l}=t,[o,u]=(0,e.useState)(!1),[i,d]=(0,e.useState)(n.rules),m=(0,R.of)($e),A=(0,e.useCallback)(h=>{if(!h.destination||h.destination.index===h.source.index)return;const C=Pt(i,h.source.index,h.destination.index);d(C);const y=(0,I.EV)(r.rulesSource),v=(0,ye.compact)(C.map($=>$.rulerRule));u(!0),(0,Rt.JD)((0,Me.DN)({namespaceName:r.name,groupName:n.name,rulesSourceName:y,newRules:v,folderUid:l||r.name})).unwrap().finally(()=>{u(!1)})},[n.name,r.name,r.rulesSource,i,l]),W=i.map(h=>({...h,uid:String((0,Ct.Ns)(h.rulerRule))}));return e.createElement(yt.a,{className:m.modal,isOpen:!0,title:e.createElement(St,{namespace:r,group:n}),onDismiss:c,onClickBackdrop:c},e.createElement(Be.JY,{onDragEnd:A},e.createElement(Be.gL,{droppableId:"alert-list",mode:"standard",renderClone:(h,O,C)=>e.createElement(ke,{provided:h,rule:W[C.source.index],isClone:!0})},h=>e.createElement("div",{ref:h.innerRef,className:Ze()(m.listContainer,o&&m.disabled),...h.droppableProps},W.map((O,C)=>e.createElement(Be.sx,{key:O.uid,draggableId:O.uid,index:C,isDragDisabled:o},y=>e.createElement(ke,{key:O.uid,provided:y,rule:O}))),h.placeholder))))},ke=({provided:t,rule:n,isClone:r=!1,isDragging:c=!1})=>{const l=(0,R.of)($e);return e.createElement("div",{className:Ze()(l.listItem,r&&"isClone",c&&"isDragging"),ref:t.innerRef,...t.draggableProps,...t.dragHandleProps},(0,z.Z8)(n.promRule)&&e.createElement(xt.C,{state:n.promRule.state}),(0,z.KB)(n.promRule)&&e.createElement(Te.E,{text:"Recording",color:"blue"}),e.createElement("div",{className:l.listItemName},n.name),e.createElement(Ee.I,{name:"draggabledots"}))},St=({namespace:t,group:n})=>{const r=(0,R.of)($e);return e.createElement("div",{className:r.header},e.createElement(Ee.I,{name:"folder"}),(0,I.Eb)(t.rulesSource)&&e.createElement(ee.m,{content:t.rulesSource.name,placement:"top"},e.createElement("img",{alt:t.rulesSource.meta.name,className:r.dataSourceIcon,src:t.rulesSource.meta.info.logos.small})),e.createElement("span",null,t.name),e.createElement(Ee.I,{name:"angle-right"}),e.createElement("span",null,n.name))},$e=t=>({modal:(0,s.css)`
    max-width: 640px;
    max-height: 80%;
    overflow: hidden;
  `,listItem:(0,s.css)`
    display: flex;
    flex-direction: row;
    align-items: center;

    gap: ${t.spacing()};

    background: ${t.colors.background.primary};
    color: ${t.colors.text.secondary};

    border-bottom: solid 1px ${t.colors.border.medium};
    padding: ${t.spacing(1)} ${t.spacing(2)};

    &:last-child {
      border-bottom: none;
    }

    &.isClone {
      border: solid 1px ${t.colors.primary.shade};
    }
  `,listContainer:(0,s.css)`
    user-select: none;
    border: solid 1px ${t.colors.border.medium};
  `,disabled:(0,s.css)`
    opacity: 0.5;
    pointer-events: none;
  `,listItemName:(0,s.css)`
    flex: 1;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  `,header:(0,s.css)`
    display: flex;
    align-items: center;

    gap: ${t.spacing(1)};
  `,dataSourceIcon:(0,s.css)`
    width: ${t.spacing(2)};
    height: ${t.spacing(2)};
  `});function Pt(t,n,r){const c=Array.from(t),[l]=c.splice(n,1);return c.splice(r,0,l),c}var qe=a(92467),_e=a(82422);const Ue=e.memo(({group:t,namespace:n,expandAll:r,viewMode:c})=>{const{rulesSource:l}=n,o=(0,S.useDispatch)(),u=(0,R.of)(Mt),[i,d]=(0,e.useState)(!1),[m,A]=(0,e.useState)(!1),[W,h]=(0,e.useState)(!1),[O,C]=(0,e.useState)(void 0),[y,v]=(0,e.useState)(!r),{canEditRules:$}=(0,Q.V)();(0,e.useEffect)(()=>{v(!r)},[r]);const{hasRuler:k,rulerRulesLoaded:L}=(0,dt.y)(),F=t.rules[0]?.rulerRule,G=F&&(0,z.lT)(F)&&F.grafana_alert.namespace_uid||void 0,{folder:T}=(0,mt.a)(G),Y=k(l)&&L(l)&&!t.rules.find(q=>!!q.rulerRule),H=(0,z.YN)(t),ie=t.rules.some(q=>(0,z.lT)(q.rulerRule)&&q.rulerRule.grafana_alert.provenance),re=c==="list",V=c==="grouped",p=()=>{o((0,Me.g6)(n,t)),A(!1)},w=[];if(Y)w.push(e.createElement(we.Gy,{key:"is-deleting"},e.createElement(Oe.y,null),"deleting"));else if(l===I.hY){if(G){const q=(0,Z.NH)(G);T?.canSave&&(V&&!ie&&(w.push(e.createElement(oe.M,{"aria-label":"edit rule group","data-testid":"edit-group",key:"edit",icon:"pen",tooltip:"edit rule group",onClick:()=>d(!0)})),w.push(e.createElement(oe.M,{"aria-label":"re-order rules","data-testid":"reorder-group",key:"reorder",icon:"exchange-alt",tooltip:"reorder rules",className:u.rotate90,onClick:()=>h(!0)}))),re&&(w.push(e.createElement(oe.M,{"aria-label":"go to folder",key:"goto",icon:"folder-open",tooltip:"go to folder",to:q,target:"__blank"})),T?.canAdmin&&w.push(e.createElement(oe.M,{"aria-label":"manage permissions",key:"manage-perms",icon:"lock",tooltip:"manage permissions",to:q+"/permissions",target:"__blank"})))),T&&(re?w.push(e.createElement(oe.M,{"aria-label":"export rule folder","data-testid":"export-folder",key:"export-folder",icon:"download-alt",tooltip:"Export rules folder",onClick:()=>C("folder")})):V&&w.push(e.createElement(oe.M,{"aria-label":"export rule group","data-testid":"export-group",key:"export-group",icon:"download-alt",tooltip:"Export rule group",onClick:()=>C("group")})))}}else $(l.name)&&k(l)&&(H||(w.push(e.createElement(oe.M,{"aria-label":"edit rule group","data-testid":"edit-group",key:"edit",icon:"pen",tooltip:"edit rule group",onClick:()=>d(!0)})),w.push(e.createElement(oe.M,{"aria-label":"re-order rules","data-testid":"reorder-group",key:"reorder",icon:"exchange-alt",tooltip:"re-order rules",className:u.rotate90,onClick:()=>h(!0)}))),w.push(e.createElement(oe.M,{"aria-label":"delete rule group","data-testid":"delete-group",key:"delete-group",icon:"trash-alt",tooltip:"delete rule group",onClick:()=>A(!0)})));const fe=re?e.createElement(Qe.c,{namespace:(0,Xe.EL)(n).name}):e.createElement(Qe.c,{namespace:(0,Xe.EL)(n).name,group:t.name}),me=(q=!1)=>{q||(0,f.fH)(f.le.leavingRuleGroupEdit),d(!1)};return e.createElement("div",{className:u.wrapper,"data-testid":"rule-group"},e.createElement("div",{className:u.header,"data-testid":"rule-group-header"},e.createElement(Je.e,{size:"sm",className:u.collapseToggle,isCollapsed:y,onToggle:v,"data-testid":"group-collapse-toggle"}),e.createElement(Ee.I,{name:y?"folder":"folder-open"}),(0,I.Eb)(l)&&e.createElement(ee.m,{content:l.name,placement:"top"},e.createElement("img",{alt:l.meta.name,className:u.dataSourceIcon,src:l.meta.info.logos.small})),e.createElement("div",{className:u.groupName,onClick:()=>v(!y)},H&&e.createElement(Te.E,{color:"purple",text:"Federated"})," ",fe),e.createElement("div",{className:u.spacer}),e.createElement("div",{className:u.headerStats},e.createElement(qe.j7,{group:t})),ie&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.actionsSeparator},"|"),e.createElement("div",{className:u.actionIcons},e.createElement(Te.E,{color:"purple",text:"Provisioned"}))),!!w.length&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.actionsSeparator},"|"),e.createElement("div",{className:u.actionIcons},e.createElement(P.B,{gap:.5},w)))),!y&&e.createElement(_e.s,{showSummaryColumn:!0,className:u.rulesTable,showGuidelines:!0,showNextEvaluationColumn:!!t.interval,rules:t.rules}),i&&e.createElement(vt.u5,{namespace:n,group:t,onClose:()=>me(),folderUrl:T?.canEdit?(0,Z.qN)(T):void 0,folderUid:G}),W&&e.createElement(Dt,{group:t,folderUid:G,namespace:n,onClose:()=>h(!1)}),e.createElement(ut.u,{isOpen:m,title:"Delete group",body:e.createElement("div",null,e.createElement("p",null,'Deleting "',e.createElement("strong",null,t.name),'" will permanently remove the group and'," ",t.rules.length," alert ",ge()("rule",t.rules.length)," belonging to it."),e.createElement("p",null,"Are you sure you want to delete this group?")),onConfirm:p,onDismiss:()=>A(!1),confirmText:"Delete"}),T&&O==="folder"&&e.createElement(gt,{folder:T,onClose:()=>C(void 0)}),T&&O==="group"&&e.createElement(pt,{folderUid:T.uid,groupName:t.name,onClose:()=>C(void 0)}))});Ue.displayName="RulesGroup";const Mt=t=>({wrapper:(0,s.css)``,header:(0,s.css)`
      display: flex;
      flex-direction: row;
      align-items: center;
      padding: ${t.spacing(1)} ${t.spacing(1)} ${t.spacing(1)} 0;
      flex-wrap: nowrap;
      border-bottom: 1px solid ${t.colors.border.weak};

      &:hover {
        background-color: ${t.components.table.rowHoverBackground};
      }
    `,headerStats:(0,s.css)`
      flex-shrink: 0;

      span {
        vertical-align: middle;
      }

      ${t.breakpoints.down("sm")} {
        order: 2;
        width: 100%;
        padding-left: ${t.spacing(1)};
      }
    `,groupName:(0,s.css)`
      margin-left: ${t.spacing(1)};
      margin-bottom: 0;
      cursor: pointer;

      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    `,spacer:(0,s.css)`
      flex: 1;
    `,collapseToggle:(0,s.css)`
      background: none;
      border: none;
      margin-top: -${t.spacing(1)};
      margin-bottom: -${t.spacing(1)};

      svg {
        margin-bottom: 0;
      }
    `,dataSourceIcon:(0,s.css)`
      width: ${t.spacing(2)};
      height: ${t.spacing(2)};
      margin-left: ${t.spacing(2)};
    `,dataSourceOrigin:(0,s.css)`
      margin-right: 1em;
      color: ${t.colors.text.disabled};
    `,actionsSeparator:(0,s.css)`
      margin: 0 ${t.spacing(2)};
    `,actionIcons:(0,s.css)`
      width: 80px;
      align-items: center;

      flex-shrink: 0;
    `,rulesTable:(0,s.css)`
      margin: ${t.spacing(2,0)};
    `,rotate90:(0,s.css)`
      transform: rotate(90deg);
    `});function et(t){return(0,e.useMemo)(()=>t.flatMap(n=>n.groups.map(r=>({namespace:n,group:r}))),[t])}const It=({namespaces:t,expandAll:n})=>{const r=(0,R.of)(At),c=(0,X.$)(v=>v.dataSources),l=(0,X.$)(v=>v.promRules),o=(0,e.useMemo)(I.qi,[]),u=et(t),i=(0,e.useMemo)(()=>o.filter(v=>(0,Pe.ML)(l[v.name])||(0,Pe.ML)(c[v.name])),[l,c,o]),d=o.some(v=>!!l[v.name]?.result?.length),m=o.length>0,A=i.length>0,W=t.length>0,{numberOfPages:h,onPageChange:O,page:C,pageItems:y}=(0,Ye.W)(u,1,je.FG);return e.createElement("section",{className:r.wrapper},e.createElement("div",{className:r.sectionHeader},e.createElement("div",{className:r.headerRow},e.createElement("h5",null,"Mimir / Cortex / Loki"),i.length?e.createElement(Ce._,{className:r.loader,text:`Loading rules from ${i.length} ${ge()("source",i.length)}`}):e.createElement("div",null),e.createElement(Ot,null))),y.map(({group:v,namespace:$})=>e.createElement(Ue,{group:v,key:`${(0,I.v0)($.rulesSource)}-${$.name}-${v.name}`,namespace:$,expandAll:n,viewMode:"grouped"})),!m&&e.createElement("p",null,"There are no Prometheus or Loki data sources configured."),m&&!A&&!W&&e.createElement("p",null,"No rules found."),!d&&A&&e.createElement(Oe.y,{size:"xl",className:r.spinner}),e.createElement(ze.d,{className:r.pagination,currentPage:C,numberOfPages:h,onNavigate:O,hideWhenSinglePage:!0}))},At=t=>({loader:(0,s.css)`
    margin-bottom: 0;
  `,sectionHeader:(0,s.css)`
    display: flex;
    justify-content: space-between;
  `,wrapper:(0,s.css)`
    margin-bottom: ${t.spacing(4)};
  `,spinner:(0,s.css)`
    text-align: center;
    padding: ${t.spacing(2)};
  `,pagination:(0,Ve.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",marginBottom:t.spacing(1)})});function Ot(){const[t,n]=(0,te.Ej)(te.RY.CreateExternalAlertRule),r=(0,g.zy)();return t&&n?e.createElement(D.z9,{key:"new-recording-rule",href:x.kM.renderUrl("alerting/new/recording",{returnTo:r.pathname+r.search}),icon:"plus",variant:"secondary"},"New recording rule"):null}var Tt=a(42941),xe=a(9518);function Nt({onClose:t}){const[n,r]=(0,e.useState)("yaml");return e.createElement(Le.m,{activeTab:n,onTabChange:r,onClose:t,formatProviders:Object.values(Fe.sl)},e.createElement(bt,{exportFormat:n,onClose:t}))}function bt({exportFormat:t,onClose:n}){const{currentData:r="",isFetching:c}=Ne.hK.endpoints.exportRules.useQuery({format:t}),l=`alert-rules-${new Date().getTime()}`;return c?e.createElement(Ce._,{text:"Loading...."}):e.createElement(be.J,{format:t,textDefinition:r,downloadFileName:l,onClose:n})}const Lt=({namespaces:t,expandAll:n})=>{const r=(0,R.of)(Ft),[c]=(0,b.s)(),{prom:l,ruler:o}=(0,X.$)(G=>({prom:G.promRules[I.hY]||Pe.jA,ruler:G.rulerRules[I.hY]||Pe.jA})),u=l.loading||o.loading,i=!!l.result||!!o.result,d=c.view==="list",m=d?(0,xe.Jr)(t):t,A=et(m),{numberOfPages:W,onPageChange:h,page:O,pageItems:C}=(0,Ye.W)(A,1,je.FG),[y,v]=(0,te.Ej)(te.RY.ExportGrafanaManagedRules),$=y&&v,[k,L]=(0,Tt.A)(!1),F=t.length>0;return e.createElement("section",{className:r.wrapper},e.createElement("div",{className:r.sectionHeader},e.createElement("div",{className:r.headerRow},e.createElement("h5",null,"Grafana"),u?e.createElement(Ce._,{className:r.loader,text:"Loading..."}):e.createElement("div",null),F&&$&&e.createElement(D.$n,{"aria-label":"export all grafana rules","data-testid":"export-all-grafana-rules",icon:"download-alt",tooltip:"Export all Grafana-managed rules",onClick:L,variant:"secondary"},"Export rules"))),C.map(({group:G,namespace:T})=>e.createElement(Ue,{group:G,key:`${T.name}-${G.name}`,namespace:T,expandAll:n,viewMode:d?"list":"grouped"})),i&&m?.length===0&&e.createElement("p",null,"No rules found."),!i&&u&&e.createElement(Oe.y,{size:"xl",className:r.spinner}),e.createElement(ze.d,{className:r.pagination,currentPage:O,numberOfPages:W,onNavigate:h,hideWhenSinglePage:!0}),$&&k&&e.createElement(Nt,{onClose:L}))},Ft=t=>({loader:(0,s.css)`
    margin-bottom: 0;
  `,sectionHeader:(0,s.css)`
    display: flex;
    justify-content: space-between;
    margin-bottom: ${t.spacing(1)};
  `,wrapper:(0,s.css)`
    margin-bottom: ${t.spacing(4)};
  `,spinner:(0,s.css)`
    text-align: center;
    padding: ${t.spacing(2)};
  `,pagination:(0,Ve.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",flexDirection:"row"})}),Bt=({namespaces:t,expandAll:n})=>{const[r,c]=(0,e.useMemo)(()=>{const l=t.map(o=>({...o,groups:o.groups.sort((u,i)=>u.name.localeCompare(i.name))})).sort((o,u)=>o.name.localeCompare(u.name));return[l.filter(o=>(0,I.z2)(o.rulesSource)),l.filter(o=>(0,I.Eb)(o.rulesSource))]},[t]);return(0,e.useEffect)(()=>{(0,f.fH)(f.le.loadedList)},[]),e.createElement(e.Fragment,null,e.createElement(He._,{actions:[te.RY.ViewAlertRule]},e.createElement(Lt,{namespaces:r,expandAll:n})),e.createElement(He._,{actions:[te.RY.ViewExternalAlertRule]},e.createElement(It,{namespaces:c,expandAll:n})))};var j=a(94822);const We=({rules:t,state:n,defaultCollapsed:r=!1})=>{const[c,l]=(0,e.useState)(r),o=(0,R.of)($t);return e.createElement(e.Fragment,null,e.createElement("h4",{className:o.header},e.createElement(Je.e,{className:o.collapseToggle,size:"xxl",isCollapsed:c,onToggle:()=>l(!c)}),(0,z.XI)(n)," (",t.length,")"),!c&&e.createElement(_e.s,{className:o.rulesTable,rules:t,showGroupColumn:!0}))},$t=t=>({collapseToggle:(0,s.css)`
    vertical-align: middle;
  `,header:(0,s.css)`
    margin-top: ${t.spacing(2)};
  `,rulesTable:(0,s.css)`
    margin-top: ${t.spacing(3)};
  `}),Ut=({namespaces:t})=>{const n=(0,Z.Ht)((0,b.s)()[0]),r=(0,e.useMemo)(()=>{const c={[j.cF.Firing]:[],[j.cF.Inactive]:[],[j.cF.Pending]:[]};return t.forEach(l=>l.groups.forEach(o=>o.rules.forEach(u=>{u.promRule&&(0,z.Z8)(u.promRule)&&c[u.promRule.state].push(u)}))),Object.values(c).forEach(l=>l.sort((o,u)=>o.name.localeCompare(u.name))),c},[t]);return e.createElement(e.Fragment,null,(!n.alertState||n.alertState===j.cF.Firing)&&e.createElement(We,{state:j.cF.Firing,rules:r[j.cF.Firing]}),(!n.alertState||n.alertState===j.cF.Pending)&&e.createElement(We,{state:j.cF.Pending,rules:r[j.cF.Pending]}),(!n.alertState||n.alertState===j.cF.Inactive)&&e.createElement(We,{defaultCollapsed:n.alertState!==j.cF.Inactive,state:j.cF.Inactive,rules:r[j.cF.Inactive]}))};var Wt=a(49785),Ke=a(88575),pe=a(60029),Ie=a(94354),Kt=a(10354),Gt=a(59429),Ht=a(53076),zt=a(1932),tt=a(19347),De=a(28475),Ae=a(98164),at=a(55740),jt=a(32642),Yt=a(39964);function nt(){const[t,n]=(0,Yt.l)(),r=t.get("search")??"",c=(0,e.useMemo)(()=>(0,De.XY)(r),[r]),l=(0,e.useMemo)(()=>Object.values(c).some(i=>!(0,ye.isEmpty)(i)),[c]),o=(0,e.useCallback)(i=>{const d=(0,De.kL)(r,i);n({search:d})},[r,n]),u=(0,e.useCallback)(i=>{n({search:i})},[n]);return(0,e.useEffect)(()=>{const i={dataSource:t.get("dataSource")??void 0,alertState:t.get("alertState")??void 0,ruleType:t.get("ruleType")??void 0,labels:(0,Ae.J$)(t.get("queryString")??"").map(Ae.MU)};Object.values(i).some(m=>!(0,ye.isEmpty)(m))&&(n({dataSource:void 0,alertState:void 0,ruleType:void 0,queryString:void 0}),o((0,zt.jM)(c,m=>{if(m.dataSourceNames??=i.dataSource?[i.dataSource]:[],i.alertState&&(0,j.Si)(i.alertState)&&(m.ruleState??=i.alertState),i.ruleType&&(0,z.nf)(i.ruleType)&&(m.ruleType??=i.ruleType),m.labels.length===0&&i.labels.length>0){const A=i.labels.map(({name:W,operator:h,value:O})=>`${W}${h}${O}`);m.labels.push(...A)}})))},[t,o,c,n]),{filterState:c,hasActiveFilters:l,searchQuery:r,setSearchQuery:u,updateFilters:o}}const Vt=(t,n)=>(0,e.useMemo)(()=>{const r=wt(t,n);return r.forEach(c=>{c.groups.forEach(l=>{l.rules.forEach(o=>{(0,z.Z8)(o.promRule)&&(o.instanceTotals=(0,xe.Ug)(o.promRule),o.filteredInstanceTotals=(0,xe.NW)(o.promRule))}),l.totals=(0,xe.Tj)({rules:l.rules.map(o=>o.promRule).filter(o=>!!o)})})}),r},[t,n]),Ge=new Ht.A({intraMode:1,intraIns:1,intraSub:1,intraTrn:1,intraDel:1}),wt=(t,n={dataSourceNames:[],labels:[],freeFormWords:[]})=>{let r=t;const c=n.dataSourceNames;c.length&&(r=r.filter(({rulesSource:o})=>(0,I.Eb)(o)?c.includes(o.name):!0));const l=n.namespace;if(l){const o=r.map(m=>m.name),[u,i,d]=Ge.search(o,l);i&&d?r=d.map(m=>r[i.idx[m]]):u&&(r=u.map(m=>r[m]))}return r.reduce(Jt(n),[])},Jt=t=>(n,r)=>{const c=t.groupName;let l=r.groups;if(c){const o=l.map(m=>m.name),[u,i,d]=Ge.search(o,c);i&&d?l=d.map(m=>l[i.idx[m]]):u&&(l=u.map(m=>l[m]))}return l=l.reduce(Qt(t),[]),l.length&&n.push({...r,groups:l}),n},Qt=t=>{const n=t.ruleName??t.freeFormWords.join(" ");return(r,c)=>{let l=c.rules;if(n){const o=l.map(m=>m.name),[u,i,d]=Ge.search(o,n);i&&d?l=d.map(m=>l[i.idx[m]]):u&&(l=u.map(m=>l[m]))}return l=l.filter(o=>{const u=o.promRule,i=(0,ye.chain)(t).pick(["ruleType","dataSourceNames","ruleHealth","labels","ruleState","dashboardUid"]).omitBy(ye.isEmpty).mapValues(()=>!1).value();if("ruleType"in i&&t.ruleType===u?.type&&(i.ruleType=!0),"dataSourceNames"in i&&((0,z.lT)(o.rulerRule)?Zt(o.rulerRule,t)&&(i.dataSourceNames=!0):i.dataSourceNames=!0),"ruleHealth"in t&&u){const d=(0,z.f6)(u.health);t.ruleHealth===d&&(i.ruleHealth=!0)}if("labels"in i){const d=(0,ye.compact)(t.labels.map(Xt)),m=d.length>0&&(0,Ae.Av)(o.labels,d),A=d.length>0&&u&&u.type===j.JS.Alerting&&u.alerts&&u.alerts.some(W=>(0,Ae.Av)(W.labels,d));(m||A)&&(i.labels=!0)}if("ruleState"in i){const d=o.promRule;d&&(0,z.Z8)(d)&&d.state===t.ruleState&&(i.ruleState=!0)}return"dashboardUid"in i&&o.annotations[at.YH.dashboardUID]===t.dashboardUid&&(i.dashboardUid=!0),Object.values(i).every(d=>d===!0)}),l.length&&r.push({...c,rules:l}),r}};function Xt(t){try{return(0,jt.qR)(t)}catch{return{name:t,value:"",isRegex:!0,isEqual:!0}}}const Zt=(t,n)=>n.dataSourceNames?.length?!!t.grafana_alert.data.find(r=>{if(!r.datasourceUid)return!1;const c=(0,tt.l)().getInstanceSettings(r.datasourceUid);return c?.name&&n?.dataSourceNames?.includes(c.name)}):!0;var kt=a(35108),qt=a(22391),_t=a(51527),rt=a(13544),lt=a(26657),ea=a(88323),ta=a(98624);const aa=t=>{const n=(0,tt.l)(),[r,c]=(0,e.useState)(),l=(L,F)=>{if(F.action==="clear"&&t.onClear){t.onClear();return}const G=L[L.length-1];let T,Y;F.action==="pop-value"||F.action==="remove-value"?(T=F.removedValue?.value,Y="remove"):(T=G.value,Y="add");const H=n.getInstanceSettings(T);H&&(t.onChange(H,Y),c({error:void 0}))},o=()=>{const{current:L,hideTextValue:F,noDefault:G}=t;if(!(!L&&G))return L?.map(T=>{const Y=n.getInstanceSettings(T);if(Y)return{label:Y.name.slice(0,37),value:Y.name,imgUrl:Y.meta.info.logos.small,hideText:F,meta:Y.meta};const H=(0,qt.Iz)(T);return H===lt.dR.uid||H===lt.dR.name?{label:H,value:H,hideText:F}:{label:(H??"no name")+" - not found",value:H??void 0,imgUrl:"",hideText:F}})},u=()=>{const{alerting:L,tracing:F,metrics:G,mixed:T,dashboard:Y,variables:H,annotations:ie,pluginId:re,type:V,filter:p,logs:w}=t,fe=n.getList({alerting:L,tracing:F,metrics:G,logs:w,dashboard:Y,mixed:T,variables:H,annotations:ie,pluginId:re,filter:p,type:V}),me=fe.filter(I.hP).map(_=>({value:_.name,label:`${_.name}${_.isDefault?" (default)":""}`,imgUrl:_.meta.info.logos.small,meta:_.meta})),q=fe.filter(_=>!(0,I.hP)(_)).map(_=>({value:_.name,label:`${_.name}${_.isDefault?" (default)":""}`,imgUrl:_.meta.info.logos.small,meta:_.meta}));return[{label:"Data sources with configured alert rules",options:me,expanded:!0},{label:"Other data sources",options:q,expanded:!0}]},{autoFocus:i,onBlur:d,onClear:m,openMenuOnFocus:A,placeholder:W,width:h,inputId:O,disabled:C=!1,isLoading:y=!1}=t,v=u(),$=o(),k=typeof m=="function";return e.createElement("div",{"data-testid":rt.Tp.components.DataSourcePicker.container},e.createElement(ea.KF,{isLoading:y,disabled:C,"data-testid":rt.Tp.components.DataSourcePicker.inputV2,inputId:O||"data-source-picker",className:"ds-picker select-container",isClearable:k,backspaceRemovesValue:!0,onChange:l,options:v,autoFocus:i,onBlur:d,width:h,openMenuOnFocus:A,maxMenuHeight:500,placeholder:W,noOptionsMessage:"No datasources found",value:$??[],invalid:!!r?.error||!!t.invalid,getOptionLabel:L=>L.meta&&(0,_t.x)(L.meta.signature)&&L!==$?e.createElement(we.Gy,{align:"center",justify:"space-between",height:"auto"},e.createElement("span",null,L.label)," ",e.createElement(ta.B,{status:L.meta.signature})):L.label||""}))},st=[{icon:"folder",label:"Grouped",value:"grouped"},{icon:"list-ul",label:"List",value:"list"},{icon:"heart-rate",label:"State",value:"state"}],na=[{label:"Alert ",value:j.JS.Alerting},{label:"Recording ",value:j.JS.Recording}],ra=[{label:"Ok",value:De.Jc.Ok},{label:"No Data",value:De.Jc.NoData},{label:"Error",value:De.Jc.Error}],la=Object.entries(j.cF).map(([t,n])=>({label:(0,z.XI)(n),value:n})),sa=({onFilterCleared:t=()=>{}})=>{const n=(0,R.of)(oa),[r,c]=(0,b.s)(),{filterState:l,hasActiveFilters:o,searchQuery:u,setSearchQuery:i,updateFilters:d}=nt(),[m,A]=(0,e.useState)(Math.floor(Math.random()*100)),W=`dataSource-${m}`,h=`queryString-${m}`,O=(0,e.useRef)(null),{handleSubmit:C,register:y,setValue:v}=(0,Wt.mN)({defaultValues:{searchQuery:u}}),{ref:$,...k}=y("searchQuery");(0,e.useEffect)(()=>{v("searchQuery",u)},[u,v]);const L=(p,w)=>{const fe=w==="add"?[...l.dataSourceNames].concat([p.name]):l.dataSourceNames.filter(me=>me!==p.name);d({...l,dataSourceNames:fe}),A(me=>me+1)},F=p=>{d({...l,dashboardUid:p})},G=()=>{d({...l,dataSourceNames:[]}),A(p=>p+1)},T=p=>{(0,f.fH)(f.le.clickingAlertStateFilters),d({...l,ruleState:p})},Y=p=>{c({view:p})},H=p=>{d({...l,ruleType:p})},ie=p=>{d({...l,ruleHealth:p})},re=()=>{i(void 0),t(),setTimeout(()=>A(m+1),100)},V=e.createElement(Ee.I,{name:"search"});return e.createElement("div",{className:n.container},e.createElement(P.B,{direction:"column",gap:1},e.createElement(P.B,{direction:"row",gap:1,wrap:"wrap"},e.createElement(Ke.D,{className:n.dsPickerContainer,label:e.createElement(pe.J,{htmlFor:"data-source-picker"},e.createElement(P.B,{gap:.5},e.createElement("span",null,"Search by data sources"),e.createElement(ee.m,{content:e.createElement("div",null,e.createElement("p",null,"Data sources containing configured alert rules are Mimir or Loki data sources where alert rules are stored and evaluated in the data source itself."),e.createElement("p",null,"In these data sources, you can select Manage alerts via Alerting UI to be able to manage these alert rules in the Grafana UI as well as in the data source where they were configured."))},e.createElement(Ee.I,{id:"data-source-picker-inline-help",name:"info-circle",size:"sm"}))))},e.createElement(aa,{key:W,alerting:!0,noDefault:!0,placeholder:"All data sources",current:l.dataSourceNames,onChange:L,onClear:G})),e.createElement(Ke.D,{className:n.dashboardPickerContainer,label:e.createElement(pe.J,{htmlFor:"filters-dashboard-picker"},"Dashboard")},e.createElement(Gt.b,{inputId:"filters-dashboard-picker",key:l.dashboardUid?"dashboard-defined":"dashboard-not-defined",value:l.dashboardUid,onChange:p=>F(p?.uid),isClearable:!0,cacheOptions:!0})),e.createElement("div",null,e.createElement(pe.J,null,"State"),e.createElement(Ie.z,{options:la,value:l.ruleState,onChange:T})),e.createElement("div",null,e.createElement(pe.J,null,"Rule type"),e.createElement(Ie.z,{options:na,value:l.ruleType,onChange:H})),e.createElement("div",null,e.createElement(pe.J,null,"Health"),e.createElement(Ie.z,{options:ra,value:l.ruleHealth,onChange:ie}))),e.createElement(P.B,{direction:"column",gap:1},e.createElement(P.B,{direction:"row",gap:1},e.createElement("form",{className:n.searchInput,onSubmit:C(p=>{i(p.searchQuery),O.current?.blur()})},e.createElement(Ke.D,{label:e.createElement(pe.J,{htmlFor:"rulesSearchInput"},e.createElement(P.B,{gap:.5},e.createElement("span",null,"Search"),e.createElement(kt.j,{content:e.createElement(ca,null)},e.createElement(Ee.I,{name:"info-circle",size:"sm",tabIndex:0}))))},e.createElement(Kt.p,{id:"rulesSearchInput",key:h,prefix:V,ref:p=>{$(p),O.current=p},...k,placeholder:"Search","data-testid":"search-query-input"})),e.createElement("input",{type:"submit",hidden:!0})),e.createElement("div",null,e.createElement(pe.J,null,"View as"),e.createElement(Ie.z,{options:st,value:String(r.view??st[0].value),onChange:Y}))),o&&e.createElement("div",null,e.createElement(D.$n,{fullWidth:!1,icon:"times",variant:"secondary",onClick:re},"Clear filters")))))},oa=t=>({container:(0,s.css)({marginBottom:t.spacing(1)}),dsPickerContainer:(0,s.css)({width:t.spacing(60),flexGrow:0,margin:0}),dashboardPickerContainer:(0,s.css)({minWidth:t.spacing(50)}),searchInput:(0,s.css)({flex:1,margin:0})});function ca(){const t=(0,R.of)(ot);return e.createElement("div",null,e.createElement("div",null,"Search syntax allows to query alert rules by the parameters defined below."),e.createElement("hr",null),e.createElement("div",{className:t.grid},e.createElement("div",null,"Filter type"),e.createElement("div",null,"Expression"),e.createElement(ce,{title:"Datasources",expr:"datasource:mimir datasource:prometheus"}),e.createElement(ce,{title:"Folder/Namespace",expr:"namespace:global"}),e.createElement(ce,{title:"Group",expr:"group:cpu-usage"}),e.createElement(ce,{title:"Rule",expr:'rule:"cpu 80%"'}),e.createElement(ce,{title:"Labels",expr:"label:team=A label:cluster=a1"}),e.createElement(ce,{title:"State",expr:"state:firing|normal|pending"}),e.createElement(ce,{title:"Type",expr:"type:alerting|recording"}),e.createElement(ce,{title:"Health",expr:"health:ok|nodata|error"}),e.createElement(ce,{title:"Dashboard UID",expr:"dashboard:eadde4c7-54e6-4964-85c0-484ab852fd04"})))}function ce({title:t,expr:n}){const r=(0,R.of)(ot);return e.createElement(e.Fragment,null,e.createElement("div",null,t),e.createElement("code",{className:r.code},n))}const ot=t=>({grid:(0,s.css)({display:"grid",gridTemplateColumns:"max-content auto",gap:t.spacing(1),alignItems:"center"}),code:(0,s.css)({display:"block",textAlign:"center"})}),ia=sa,ct={groups:Bt,state:Ut},ua=se.Ys+1,ma=(0,N.Xc)(()=>{const t=(0,S.useDispatch)(),n=(0,R.of)(da),r=(0,e.useMemo)(I.gR,[]),[c,l]=(0,e.useState)(!1),o=(0,e.useCallback)(()=>l(!1),[]),[u]=(0,b.s)(),{filterState:i,hasActiveFilters:d}=nt(),m=ct[u.view]?u.view:"groups",A=ct[m],W=(0,X.$)(V=>V.promRules),h=(0,X.$)(V=>V.rulerRules),O=r.some(V=>W[V]?.loading||h[V]?.loading),C=Object.entries(W),y=Object.entries(h),v=C.every(([V,p])=>p.dispatched&&(p?.result!==void 0||p?.error!==void 0)),$=y.every(([V,p])=>p.dispatched&&(p?.result!==void 0||p?.error!==void 0)),k=C.every(([V,p])=>p.dispatched&&p?.result?.length===0),L=y.every(([V,p])=>Object.entries(p?.result??{}).every(([me,q])=>q?.length===0)&&p.dispatched),F=d?void 0:ua,[G,T]=(0,E.A)(async()=>{O||await t((0,Me.yo)(!1,{limitAlerts:F}))},[O,F,t]);(0,e.useEffect)(()=>{(0,f.Sq)().catch(()=>{})},[]),(0,e.useEffect)(()=>{t((0,Me.yo)(!1,{limitAlerts:F}))},[t,F]),(0,M.A)(T,at.HH);const Y=v&&k&&C.length>0&&L&&$,H=!Y,ie=(0,xe.dy)(),re=Vt(ie,i);return e.createElement(U.d,{navId:"alert-list",isLoading:!1,actions:H&&e.createElement(it,null)},e.createElement(he,null),e.createElement(ia,{onFilterCleared:o}),H&&e.createElement(e.Fragment,null,e.createElement("div",{className:n.break}),e.createElement("div",{className:n.buttonsContainer},e.createElement("div",{className:n.statsContainer},m==="groups"&&d&&e.createElement(D.$n,{className:n.expandAllButton,icon:c?"angle-double-up":"angle-double-down",variant:"secondary",onClick:()=>l(!c)},c?"Collapse all":"Expand all"),e.createElement(qe.M_,{namespaces:re})))),Y&&e.createElement(le,null),H&&e.createElement(A,{expandAll:c,namespaces:re}))},{style:"page"}),da=t=>({break:(0,s.css)`
    width: 100%;
    height: 0;
    margin-bottom: ${t.spacing(2)};
    border-bottom: solid 1px ${t.colors.border.medium};
  `,buttonsContainer:(0,s.css)`
    margin-bottom: ${t.spacing(2)};
    display: flex;
    justify-content: space-between;
  `,statsContainer:(0,s.css)`
    display: flex;
    flex-direction: row;
    align-items: center;
  `,expandAllButton:(0,s.css)`
    margin-right: ${t.spacing(1)};
  `}),ga=ma;function it(){const[t,n]=(0,te.Ej)(te.RY.CreateAlertRule),[r,c]=(0,te.Ej)(te.RY.CreateExternalAlertRule),l=(0,g.zy)();return t&&n||r&&c?e.createElement(D.z9,{href:x.kM.renderUrl("alerting/new/alerting",{returnTo:l.pathname+l.search}),icon:"plus",onClick:()=>(0,f.fH)(f.le.alertRuleFromScratch)},"New alert rule"):null}},64853:(ae,B,a)=>{a.d(B,{_:()=>M});var s=a(2543),e=a.n(s),g=a(96540),E=a(19073);const M=({actions:S,children:f})=>{const U=(0,s.filter)(S,D),P=(0,s.filter)(S,b);return U.length?g.createElement(x,{actions:U},f):P.length?g.createElement(N,{actions:P},f):null},x=({actions:S,children:f})=>{const U=(0,E.iI)();return R(U,S)?g.createElement(g.Fragment,null,f):null},N=({actions:S,children:f})=>{const U=(0,E.e2)();return R(U,S)?g.createElement(g.Fragment,null,f):null};function R(S,f){return(0,s.chain)(S).pick(f).values().value().some(([U,P])=>P===!0)}function D(S){return Object.values(E.QI).includes(S)}function b(S){return Object.values(E.RY).includes(S)}},16293:(ae,B,a)=>{a.d(B,{J:()=>U});var s=a(32196),e=a(4213),g=a.n(e),E=a(96540),M=a(70713),x=a(40845),N=a(32372),R=a(55852),D=a(10534),b=a(72109),S=a(42418),f=a(84029);function U({format:J,textDefinition:Q,downloadFileName:le,onClose:de}){const se=(0,x.of)(P),ne=f.sl[J],ge=(0,E.useCallback)(()=>{const K=new Blob([Q],{type:`application/${J};charset=utf-8`});g()(K,`${le}.${J}`)},[Q,le,J]),Re=(0,E.useMemo)(()=>ne.formatter?ne.formatter(Q):Q,[ne,Q]);return E.createElement("div",{className:se.container},E.createElement(ve,{exportProvider:ne}),E.createElement("div",{className:se.content},E.createElement(M.Ay,{disableWidth:!0},({height:K})=>E.createElement(N.B,{width:"100%",height:K,language:J,value:Re,monacoOptions:{minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:!0}}))),E.createElement("div",{className:se.actions},E.createElement(R.$n,{variant:"secondary",onClick:de},"Cancel"),E.createElement(D.b,{icon:"copy",getText:()=>Q},"Copy code"),E.createElement(R.$n,{icon:"download-alt",onClick:ge},"Download")))}const P=J=>({container:(0,s.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${J.spacing(2)};
  `,content:(0,s.css)`
    flex: 1 1 100%;
  `,actions:(0,s.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${J.spacing(1)};
  `});function ve({exportProvider:J}){const{name:Q,type:le}=J,de={file:{title:"File-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for File Provisioning."," ",E.createElement(b.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/",external:!0},"Read more in the docs."))},api:{title:"API-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for API Provisioning."," ",E.createElement(b.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/http-api-provisioning/",external:!0},"Read more in the docs."))},terraform:{title:"Terraform-provisioning format",component:E.createElement(E.Fragment,null,Q," format is only valid for Terraform Provisioning."," ",E.createElement(b.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/terraform-provisioning/",external:!0},"Read more in the docs."))}},{title:se,component:ne}=de[le];return E.createElement(S.F,{title:se,severity:"info",bottomSpacing:0,topSpacing:0},ne)}},76648:(ae,B,a)=>{a.d(B,{m:()=>E});var s=a(96540),e=a(87978),g=a(73716);function E({activeTab:M,onTabChange:x,children:N,onClose:R,formatProviders:D,title:b="Export"}){const S=Object.values(D).map(f=>({label:f.name,value:f.exportFormat}));return s.createElement(e._,{title:b,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:s.createElement(g.sb,{tabs:S,setActiveTab:x,activeTab:M}),onClose:R,size:"md"},N)}},84029:(ae,B,a)=>{a.d(B,{sl:()=>E});const s={name:"JSON",exportFormat:"json",type:"file",formatter:x=>{try{return JSON.stringify(JSON.parse(x),null,4)}catch{return x}}},e={name:"YAML",exportFormat:"yaml",type:"file"},g={name:"Terraform (HCL)",exportFormat:"hcl",type:"terraform"},E={[s.exportFormat]:s,[e.exportFormat]:e,[g.exportFormat]:g},M=[s,e]},64100:(ae,B,a)=>{a.d(B,{G:()=>R});var s=a(32196),e=a(96540),g=a(40845),E=a(60782),M=a(67061),x=a(14578),N=a(94753);function R({contentText:b,externalLink:S,linkText:f,title:U}){const P=(0,g.of)(D);return e.createElement(E.G,{content:e.createElement("div",{className:P.mutedText},b),title:e.createElement(M.B,{gap:1,direction:"row"},e.createElement(x.I,{name:"question-circle"}),U),footer:S?e.createElement("a",{href:S,target:"_blank",rel:"noreferrer"},e.createElement(M.B,{direction:"row",gap:.5,alignItems:"center"},e.createElement(N.E,{color:"link"},f," ",e.createElement(x.I,{size:"sm",name:"external-link-alt"})))):void 0,closeButton:!0,placement:"bottom-start"},e.createElement("div",{className:P.helpInfo},e.createElement(M.B,{direction:"row",alignItems:"center",gap:.5},e.createElement(x.I,{name:"question-circle",size:"sm"}),e.createElement(N.E,{variant:"bodySmall",color:"primary"},"Need help?"))))}const D=b=>({mutedText:(0,s.css)`
    color: ${b.colors.text.secondary};
    font-size: ${b.typography.size.sm};
  `,helpInfo:(0,s.css)`
    cursor: pointer;
    text-decoration: underline;
  `})},271:(ae,B,a)=>{a.d(B,{P:()=>N});var s=a(32196),e=a(96540),g=a(40845),E=a(84167),M=a(94753),x=a(67061);const N=({title:D,stepNo:b,children:S,fullWidth:f=!1,description:U})=>{const P=(0,g.of)(R);return e.createElement("div",{className:P.parent},e.createElement(E.n,{className:(0,s.cx)(f&&P.fullWidth),label:e.createElement(M.E,{variant:"h3"},b,". ",D)},e.createElement(x.B,{direction:"column"},U&&e.createElement("div",{className:P.description},U),S)))},R=D=>({parent:(0,s.css)`
    display: flex;
    flex-direction: row;
    max-width: ${D.breakpoints.values.xl}px;
    border: solid 1px ${D.colors.border.weak};
    border-radius: ${D.shape.radius.default};
    padding: ${D.spacing(2)} ${D.spacing(3)};
  `,description:(0,s.css)`
    margin-top: -${D.spacing(2)};
  `,fullWidth:(0,s.css)`
    width: 100%;
  `})},73716:(ae,B,a)=>{a.d(B,{G_:()=>Q,sb:()=>le});var s=a(32196),e=a(20382),g=a(96540),E=a(49785),M=a(70713),x=a(40845),N=a(87978),R=a(63021),D=a(40675),b=a(55852),S=a(56034),f=a(14578),U=a(32372),P=a(63066),ve=a(23662);const J=[{label:"Yaml",value:"yaml"}],Q=({onClose:K})=>{const[ee,X]=(0,g.useState)("yaml"),{setValue:I}=(0,E.xW)(),Z=(0,x.of)(Re),z=he=>{for(const ue in he)I(ue,he[ue]);K()};return g.createElement(N._,{title:"Inspect Alert rule",subtitle:g.createElement("div",{className:Z.subtitle},g.createElement(le,{tabs:J,setActiveTab:X,activeTab:ee})),onClose:K},ee==="yaml"&&g.createElement(de,{onSubmit:z}))};function le({tabs:K,activeTab:ee,setActiveTab:X}){return g.createElement(R.U,null,K.map((I,Z)=>g.createElement(D.o,{key:`${I.value}-${Z}`,label:I.label,value:I.value,onChangeTab:()=>X(I.value),active:ee===I.value})))}const de=({onSubmit:K})=>{const ee=(0,x.of)(ge),{getValues:X}=(0,E.xW)(),I=(0,P.l1)(X()),[Z,z]=(0,g.useState)((0,e.Bh)(I)),he=()=>{const ue=(0,e.Hh)(Z),Se=X(),te=ne(ue);K({...Se,...te})};return g.createElement(g.Fragment,null,g.createElement("div",{className:ee.applyButton},g.createElement(b.$n,{type:"button",onClick:he},"Apply"),g.createElement(S.m,{content:g.createElement(se,null),theme:"info",placement:"left-start",interactive:!0},g.createElement(f.I,{name:"exclamation-triangle",size:"xl"}))),g.createElement("div",{className:ee.content},g.createElement(M.Ay,{disableWidth:!0},({height:ue})=>g.createElement(U.B,{width:"100%",height:ue,language:"yaml",value:Z,onBlur:z,monacoOptions:{minimap:{enabled:!1}}}))))};function se(){return g.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",g.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",g.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function ne(K){return(0,ve.$y)(K)?(0,P.Qk)(K):(0,ve.i7)(K)?(0,P.XI)(K):{}}const ge=K=>({content:(0,s.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${K.spacing(2)};
  `,applyButton:(0,s.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${K.spacing(2)};
  `}),Re=()=>({subtitle:(0,s.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},72275:(ae,B,a)=>{a.d(B,{M:()=>E});var s=a(96540),e=a(56034),g=a(55852);const E=({tooltip:M,icon:x,to:N,target:R,onClick:D,className:b,tooltipPlacement:S="top",...f})=>{const U=typeof M=="string"?M:void 0;return s.createElement(e.m,{content:M,placement:S},N?s.createElement(g.z9,{variant:"secondary",fill:"text",icon:x,href:N,size:"sm",target:R,...f,"aria-label":U}):s.createElement(g.$n,{className:b,variant:"secondary",fill:"text",size:"sm",icon:x,type:"button",onClick:D,...f,"aria-label":U}))}},10940:(ae,B,a)=>{a.d(B,{A:()=>g});var s=a(96540),e=function(E,M){var x=(0,s.useRef)(function(){});(0,s.useEffect)(function(){x.current=E}),(0,s.useEffect)(function(){if(M!==null){var N=setInterval(function(){return x.current()},M||0);return function(){return clearInterval(N)}}},[M])};const g=e}}]);

//# sourceMappingURL=AlertRuleListIndex.46e2a523269adb28edf0.js.map