"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3511],{40715:(ae,b,a)=>{a.d(b,{o:()=>E});var s=a(96540),e=a(31678),g=a(97007);function E(D){const x=(0,e.useDispatch)(),T=(0,s.useRef)(D);T.current=D,(0,s.useEffect)(()=>()=>{x((0,g.N)({cleanupAction:T.current}))},[x])}},31987:(ae,b,a)=>{a.r(b),a.d(b,{CreateAlertButton:()=>mt,default:()=>fa});var s=a(32196),e=a(96540),g=a(58476),E=a(41053),D=a(10940),x=a(76885),T=a(66602),R=a(40845),P=a(55852),N=a(83277),M=a(31678),f=a(25027),U=a(37959),I=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(I.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(15300),ne=a(55127),ge=a.n(ne),Re=a(78685),K=a(42418),ee=a(56034),X=a(61410),O=a(57220),Z=a(56361),H=a(23662);function he(){const[t,n]=(0,e.useState)(!1),[r,o]=(0,Re.A)("grafana.unifiedalerting.hideErrors",!1),l=(0,X.$)(d=>d.dataSources),c=(0,X.$)(d=>d.promRules),u=(0,X.$)(d=>d.rulerRules),i=(0,R.of)(De),m=(0,e.useMemo)(()=>{const[d,p,W]=[l,c,u].map(C=>(0,O.qi)().reduce((h,$)=>{const k=C[$.name]?.error;return C[$.name]&&k&&!(0,H.$7)(C[$.name])?[...h,{dataSource:$,error:k}]:h},[])),y=c[O.hY]?.error,A=u[O.hY]?.error,S=[];return y&&S.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules state: ",y.message||"Unknown error.")),A&&S.push(e.createElement(e.Fragment,null,"Failed to load Grafana rules config: ",A.message||"Unknown error.")),d.forEach(({dataSource:C,error:h})=>{S.push(e.createElement(e.Fragment,null,"Failed to load the data source configuration for"," ",e.createElement("a",{href:(0,Z.GD)(C.uid),className:i.dsLink},C.name),": ",h.message||"Unknown error."))}),p.forEach(({dataSource:C,error:h})=>S.push(e.createElement(e.Fragment,null,"Failed to load rules state from"," ",e.createElement("a",{href:(0,Z.GD)(C.uid),className:i.dsLink},C.name),": ",h.message||"Unknown error."))),W.forEach(({dataSource:C,error:h})=>S.push(e.createElement(e.Fragment,null,"Failed to load rules config from"," ",e.createElement("a",{href:(0,Z.GD)(C.uid),className:i.dsLink},C.name),": ",h.message||"Unknown error."))),S},[l,c,u,i.dsLink]);return e.createElement(e.Fragment,null,!!m.length&&r&&e.createElement(ue,{count:m.length,onClick:()=>o(d=>!d)}),!!m.length&&!r&&e.createElement(K.F,{"data-testid":"cloud-rulessource-errors",title:"Errors loading rules",severity:"error",onRemove:()=>o(!0)},t&&m.map((d,p)=>e.createElement("div",{key:p},d)),!t&&e.createElement(e.Fragment,null,e.createElement("div",null,m[0]),m.length>=2&&e.createElement(P.$n,{className:i.moreButton,fill:"text",icon:"angle-right",size:"sm",onClick:()=>n(!0)},m.length-1," more ",ge()("error",m.length-1)))))}const ue=({count:t,onClick:n})=>{const r=(0,R.of)(De);return e.createElement("div",{className:r.floatRight},e.createElement(ee.m,{content:"Show all errors",placement:"bottom"},e.createElement(P.$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"))))},De=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),Ye=a(64853),Ce=a(39558),Te=a(62930),Ve=a(19384),we=a(15054),Je=a(98439),Qe=a(22620),Pe=a(88467),Ne=a(13544),Xe=a(66864),Ee=a(14578),Le=a(39938),dt=a(96374),gt=a(11167),Et=a(83903),Me=a(23770),Ze=a(64047),ke=a(82437),be=a(79938),Fe=a(16293),Be=a(76648),$e=a(84029);function pt({folder:t,onClose:n}){const[r,o]=(0,e.useState)("yaml");return e.createElement(Be.m,{title:`Export ${t.title} rules`,activeTab:r,onTabChange:o,onClose:n,formatProviders:Object.values($e.sl)},e.createElement(ft,{folder:t,exportFormat:r,onClose:n}))}function ft({folder:t,exportFormat:n,onClose:r}){const{currentData:o="",isFetching:l}=be.hK.endpoints.exportRules.useQuery({folderUid:t.uid,format:n});if(l)return e.createElement(Ce._,{text:"Loading...."});const c=`${t.title}-${t.uid}`;return e.createElement(Fe.J,{format:n,textDefinition:o,downloadFileName:c,onClose:r})}function vt({folderUid:t,groupName:n,onClose:r}){const[o,l]=(0,e.useState)("yaml");return e.createElement(Be.m,{title:`Export ${n} rules`,activeTab:o,onTabChange:l,onClose:r,formatProviders:Object.values($e.sl)},e.createElement(ht,{folderUid:t,groupName:n,exportFormat:o,onClose:r}))}function ht({folderUid:t,groupName:n,exportFormat:r,onClose:o}){const{currentData:l="",isFetching:c}=be.hK.endpoints.exportRules.useQuery({folderUid:t,group:n,format:r});return c?e.createElement(Ce._,{text:"Loading...."}):e.createElement(Fe.J,{format:r,textDefinition:l,downloadFileName:n,onClose:o})}var qe=a(99106),oe=a(72275),yt=a(46479),Rt=a(46942),_e=a.n(Rt),ye=a(2543),Ue=a(55244),Ct=a(37390),xt=a(99140),St=a(18461),Dt=a(30423);const Pt=t=>{const{group:n,namespace:r,onClose:o,folderUid:l}=t,[c,u]=(0,e.useState)(!1),[i,m]=(0,e.useState)(n.rules),d=(0,R.of)(We),p=(0,e.useCallback)(y=>{if(!y.destination||y.destination.index===y.source.index)return;const S=It(i,y.source.index,y.destination.index);m(S);const C=(0,O.EV)(r.rulesSource),h=(0,ye.compact)(S.map($=>$.rulerRule));u(!0),(0,xt.JD)((0,Me.DN)({namespaceName:r.name,groupName:n.name,rulesSourceName:C,newRules:h,folderUid:l||r.name})).unwrap().finally(()=>{u(!1)})},[n.name,r.name,r.rulesSource,i,l]),W=i.map(y=>({...y,uid:String((0,St.Ns)(y.rulerRule))}));return e.createElement(Ct.a,{className:d.modal,isOpen:!0,title:e.createElement(Mt,{namespace:r,group:n}),onDismiss:o,onClickBackdrop:o},e.createElement(Ue.JY,{onDragEnd:p},e.createElement(Ue.gL,{droppableId:"alert-list",mode:"standard",renderClone:(y,A,S)=>e.createElement(et,{provided:y,rule:W[S.source.index],isClone:!0})},y=>e.createElement("div",{ref:y.innerRef,className:_e()(d.listContainer,c&&d.disabled),...y.droppableProps},W.map((A,S)=>e.createElement(Ue.sx,{key:A.uid,draggableId:A.uid,index:S,isDragDisabled:c},C=>e.createElement(et,{key:A.uid,provided:C,rule:A}))),y.placeholder))))},et=({provided:t,rule:n,isClone:r=!1,isDragging:o=!1})=>{const l=(0,R.of)(We);return e.createElement("div",{className:_e()(l.listItem,r&&"isClone",o&&"isDragging"),ref:t.innerRef,...t.draggableProps,...t.dragHandleProps},(0,H.Z8)(n.promRule)&&e.createElement(Dt.C,{state:n.promRule.state}),(0,H.KB)(n.promRule)&&e.createElement(Le.E,{text:"Recording",color:"blue"}),e.createElement("div",{className:l.listItemName},n.name),e.createElement(Ee.I,{name:"draggabledots"}))},Mt=({namespace:t,group:n})=>{const r=(0,R.of)(We);return e.createElement("div",{className:r.header},e.createElement(Ee.I,{name:"folder"}),(0,O.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))},We=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 It(t,n,r){const o=Array.from(t),[l]=o.splice(n,1);return o.splice(r,0,l),o}var tt=a(92467),at=a(14618);const Ke=e.memo(({group:t,namespace:n,expandAll:r,viewMode:o})=>{const{rulesSource:l}=n,c=(0,M.useDispatch)(),u=(0,R.of)(Ot),[i,m]=(0,e.useState)(!1),[d,p]=(0,e.useState)(!1),[W,y]=(0,e.useState)(!1),[A,S]=(0,e.useState)(void 0),[C,h]=(0,e.useState)(!r),{canEditRules:$}=(0,Q.V)();(0,e.useEffect)(()=>{h(!r)},[r]);const{hasRuler:k,rulerRulesLoaded:F}=(0,Et.y)(),B=t.rules[0]?.rulerRule,G=B&&(0,H.lT)(B)&&B.grafana_alert.namespace_uid||void 0,{folder:L}=(0,gt.a)(G),Y=k(l)&&F(l)&&!t.rules.find(q=>!!q.rulerRule),z=(0,H.YN)(t),ie=t.rules.some(q=>(0,H.lT)(q.rulerRule)&&q.rulerRule.grafana_alert.provenance),re=o==="list",V=o==="grouped",v=()=>{c((0,Me.g6)(n,t)),p(!1)},w=[];if(Y)w.push(e.createElement(Xe.Gy,{key:"is-deleting"},e.createElement(Te.y,null),"deleting"));else if(l===O.hY){if(G){const q=(0,Z.NH)(G);L?.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:()=>m(!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:()=>y(!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"})),L?.canAdmin&&w.push(e.createElement(oe.M,{"aria-label":"manage permissions",key:"manage-perms",icon:"lock",tooltip:"manage permissions",to:q+"/permissions",target:"__blank"})))),L&&(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:()=>S("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:()=>S("group")})))}}else $(l.name)&&k(l)&&(z||(w.push(e.createElement(oe.M,{"aria-label":"edit rule group","data-testid":"edit-group",key:"edit",icon:"pen",tooltip:"edit rule group",onClick:()=>m(!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:()=>y(!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:()=>p(!0)})));const fe=re?e.createElement(ke.c,{namespace:(0,qe.EL)(n).name}):e.createElement(ke.c,{namespace:(0,qe.EL)(n).name,group:t.name}),me=(q=!1)=>{q||(0,f.fH)(f.le.leavingRuleGroupEdit),m(!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(Ze.e,{size:"sm",className:u.collapseToggle,isCollapsed:C,onToggle:h,"data-testid":Ne.Tp.components.AlertRules.groupToggle}),e.createElement(Ee.I,{name:C?"folder":"folder-open"}),(0,O.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:()=>h(!C)},z&&e.createElement(Le.E,{color:"purple",text:"Federated"})," ",fe),e.createElement("div",{className:u.spacer}),e.createElement("div",{className:u.headerStats},e.createElement(tt.j7,{group:t})),ie&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.actionsSeparator},"|"),e.createElement("div",{className:u.actionIcons},e.createElement(Le.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(I.B,{gap:.5},w)))),!C&&e.createElement(at.s,{showSummaryColumn:!0,className:u.rulesTable,showGuidelines:!0,showNextEvaluationColumn:!!t.interval,rules:t.rules}),i&&e.createElement(yt.u5,{namespace:n,group:t,onClose:()=>me(),folderUrl:L?.canEdit?(0,Z.qN)(L.uid):void 0,folderUid:G}),W&&e.createElement(Pt,{group:t,folderUid:G,namespace:n,onClose:()=>y(!1)}),e.createElement(dt.u,{isOpen:d,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:v,onDismiss:()=>p(!1),confirmText:"Delete"}),L&&A==="folder"&&e.createElement(pt,{folder:L,onClose:()=>S(void 0)}),L&&A==="group"&&e.createElement(vt,{folderUid:L.uid,groupName:t.name,onClose:()=>S(void 0)}))});Ke.displayName="RulesGroup";const Ot=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 nt(t){return(0,e.useMemo)(()=>t.flatMap(n=>n.groups.map(r=>({namespace:n,group:r}))),[t])}const At=({namespaces:t,expandAll:n})=>{const r=(0,R.of)(Tt),o=(0,X.$)(h=>h.dataSources),l=(0,X.$)(h=>h.promRules),c=(0,e.useMemo)(O.qi,[]),u=nt(t),i=(0,e.useMemo)(()=>c.filter(h=>(0,Pe.ML)(l[h.name])||(0,Pe.ML)(o[h.name])),[l,o,c]),m=c.some(h=>!!l[h.name]?.result?.length),d=c.length>0,p=i.length>0,W=t.length>0,{numberOfPages:y,onPageChange:A,page:S,pageItems:C}=(0,Je.W)(u,1,we.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(Nt,null))),C.map(({group:h,namespace:$})=>e.createElement(Ke,{group:h,key:`${(0,O.v0)($.rulesSource)}-${$.name}-${h.name}`,namespace:$,expandAll:n,viewMode:"grouped"})),!d&&e.createElement("p",null,"There are no Prometheus or Loki data sources configured."),d&&!p&&!W&&e.createElement("p",null,"No rules found."),!m&&p&&e.createElement(Te.y,{size:"xl",className:r.spinner}),e.createElement(Ve.d,{className:r.pagination,currentPage:S,numberOfPages:y,onNavigate:A,hideWhenSinglePage:!0}))},Tt=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,Qe.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",marginBottom:t.spacing(1)})});function Nt(){const[t,n]=(0,te.Ej)(te.RY.CreateExternalAlertRule),r=(0,g.zy)();return t&&n?e.createElement(P.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 Lt=a(42941),xe=a(9518);function bt({onClose:t}){const[n,r]=(0,e.useState)("yaml");return e.createElement(Be.m,{activeTab:n,onTabChange:r,onClose:t,formatProviders:Object.values($e.sl)},e.createElement(Ft,{exportFormat:n,onClose:t}))}function Ft({exportFormat:t,onClose:n}){const{currentData:r="",isFetching:o}=be.hK.endpoints.exportRules.useQuery({format:t}),l=`alert-rules-${new Date().getTime()}`;return o?e.createElement(Ce._,{text:"Loading...."}):e.createElement(Fe.J,{format:t,textDefinition:r,downloadFileName:l,onClose:n})}const Bt=({namespaces:t,expandAll:n})=>{const r=(0,R.of)($t),[o]=(0,N.s)(),{prom:l,ruler:c}=(0,X.$)(G=>({prom:G.promRules[O.hY]||Pe.jA,ruler:G.rulerRules[O.hY]||Pe.jA})),u=l.loading||c.loading,i=!!l.result||!!c.result,m=o.view==="list",d=m?(0,xe.Jr)(t):t,p=nt(d),{numberOfPages:W,onPageChange:y,page:A,pageItems:S}=(0,Je.W)(p,1,we.FG),[C,h]=(0,te.Ej)(te.RY.ExportGrafanaManagedRules),$=C&&h,[k,F]=(0,Lt.A)(!1),B=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),B&&$&&e.createElement(P.$n,{"aria-label":"export all grafana rules","data-testid":"export-all-grafana-rules",icon:"download-alt",tooltip:"Export all Grafana-managed rules",onClick:F,variant:"secondary"},"Export rules"))),S.map(({group:G,namespace:L})=>e.createElement(Ke,{group:G,key:`${L.name}-${G.name}`,namespace:L,expandAll:n,viewMode:m?"list":"grouped"})),i&&d?.length===0&&e.createElement("p",null,"No rules found."),!i&&u&&e.createElement(Te.y,{size:"xl",className:r.spinner}),e.createElement(Ve.d,{className:r.pagination,currentPage:A,numberOfPages:W,onNavigate:y,hideWhenSinglePage:!0}),$&&k&&e.createElement(bt,{onClose:F}))},$t=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,Qe.H)(t),headerRow:(0,s.css)({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",flexDirection:"row"})}),Ut=({namespaces:t,expandAll:n})=>{const[r,o]=(0,e.useMemo)(()=>{const l=t.map(c=>({...c,groups:c.groups.sort((u,i)=>u.name.localeCompare(i.name))})).sort((c,u)=>c.name.localeCompare(u.name));return[l.filter(c=>(0,O.z2)(c.rulesSource)),l.filter(c=>(0,O.Eb)(c.rulesSource))]},[t]);return(0,e.useEffect)(()=>{(0,f.fH)(f.le.loadedList)},[]),e.createElement(e.Fragment,null,e.createElement(Ye._,{actions:[te.RY.ViewAlertRule]},e.createElement(Bt,{namespaces:r,expandAll:n})),e.createElement(Ye._,{actions:[te.RY.ViewExternalAlertRule]},e.createElement(At,{namespaces:o,expandAll:n})))};var j=a(94822);const Ge=({rules:t,state:n,defaultCollapsed:r=!1})=>{const[o,l]=(0,e.useState)(r),c=(0,R.of)(Wt);return e.createElement(e.Fragment,null,e.createElement("h4",{className:c.header},e.createElement(Ze.e,{className:c.collapseToggle,size:"xxl",isCollapsed:o,onToggle:()=>l(!o)}),(0,H.XI)(n)," (",t.length,")"),!o&&e.createElement(at.s,{className:c.rulesTable,rules:t,showGroupColumn:!0}))},Wt=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)};
  `}),Kt=({namespaces:t})=>{const n=(0,Z.Ht)((0,N.s)()[0]),r=(0,e.useMemo)(()=>{const o={[j.cF.Firing]:[],[j.cF.Inactive]:[],[j.cF.Pending]:[]};return t.forEach(l=>l.groups.forEach(c=>c.rules.forEach(u=>{u.promRule&&(0,H.Z8)(u.promRule)&&o[u.promRule.state].push(u)}))),Object.values(o).forEach(l=>l.sort((c,u)=>c.name.localeCompare(u.name))),o},[t]);return e.createElement(e.Fragment,null,(!n.alertState||n.alertState===j.cF.Firing)&&e.createElement(Ge,{state:j.cF.Firing,rules:r[j.cF.Firing]}),(!n.alertState||n.alertState===j.cF.Pending)&&e.createElement(Ge,{state:j.cF.Pending,rules:r[j.cF.Pending]}),(!n.alertState||n.alertState===j.cF.Inactive)&&e.createElement(Ge,{defaultCollapsed:n.alertState!==j.cF.Inactive,state:j.cF.Inactive,rules:r[j.cF.Inactive]}))};var Gt=a(49785),ze=a(88575),pe=a(60029),Ie=a(94354),zt=a(10354),Ht=a(59429),jt=a(53076),Yt=a(1932),rt=a(19347),Se=a(28475),Oe=a(98164),lt=a(55740),Vt=a(32642),wt=a(39964);const Jt=25,He=1/0;function st(){const[t,n]=(0,wt.l)(),r=t.get("search")??"",o=(0,e.useMemo)(()=>(0,Se.XY)(r),[r]),l=(0,e.useMemo)(()=>Object.values(o).some(i=>!(0,ye.isEmpty)(i)),[o]),c=(0,e.useCallback)(i=>{const m=(0,Se.kL)(r,i);n({search:m})},[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,Oe.J$)(t.get("queryString")??"").map(Oe.MU)};Object.values(i).some(d=>!(0,ye.isEmpty)(d))&&(n({dataSource:void 0,alertState:void 0,ruleType:void 0,queryString:void 0}),c((0,Yt.jM)(o,d=>{if(d.dataSourceNames??=i.dataSource?[i.dataSource]:[],i.alertState&&(0,j.Si)(i.alertState)&&(d.ruleState??=i.alertState),i.ruleType&&(0,H.nf)(i.ruleType)&&(d.ruleType??=i.ruleType),d.labels.length===0&&i.labels.length>0){const p=i.labels.map(({name:W,operator:y,value:A})=>`${W}${y}${A}`);d.labels.push(...p)}})))},[t,c,o,n]),{filterState:o,hasActiveFilters:l,searchQuery:r,setSearchQuery:u,updateFilters:c}}const Qt=(t,n)=>(0,e.useMemo)(()=>{const r=Xt(t,n);return r.forEach(o=>{o.groups.forEach(l=>{l.rules.forEach(c=>{(0,H.Z8)(c.promRule)&&(c.instanceTotals=(0,xe.Ug)(c.promRule),c.filteredInstanceTotals=(0,xe.NW)(c.promRule))}),l.totals=(0,xe.Tj)({rules:l.rules.map(c=>c.promRule).filter(c=>!!c)})})}),r},[t,n]),Xt=(t,n={dataSourceNames:[],labels:[],freeFormWords:[]})=>{let r=t;const o=n.dataSourceNames;o.length&&(r=r.filter(({rulesSource:c})=>(0,O.Eb)(c)?o.includes(c.name):!0));const l=n.namespace;if(l){const c=r.map(p=>p.name),u=Ae(l),[i,m,d]=u.search(c,l,je(l),He);m&&d?r=d.map(p=>r[m.idx[p]]):i&&(r=i.map(p=>r[p]))}return r.reduce(Zt(n),[])},Zt=t=>(n,r)=>{const o=t.groupName;let l=r.groups;if(o){const c=l.map(p=>p.name),u=Ae(o),[i,m,d]=u.search(c,o,je(o),He);m&&d?l=d.map(p=>l[m.idx[p]]):i&&(l=i.map(p=>l[p]))}return l=l.reduce(kt(t),[]),l.length&&n.push({...r,groups:l}),n},kt=t=>{const n=t.ruleName??t.freeFormWords.join(" ");return(r,o)=>{let l=o.rules;if(n){const c=l.map(p=>p.name),u=Ae(n),[i,m,d]=u.search(c,n,je(n),He);m&&d?l=d.map(p=>l[m.idx[p]]):i&&(l=i.map(p=>l[p]))}return l=l.filter(c=>{const u=c.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,H.lT)(c.rulerRule)?_t(c.rulerRule,t)&&(i.dataSourceNames=!0):i.dataSourceNames=!0),"ruleHealth"in t&&u){const m=(0,H.f6)(u.health);t.ruleHealth===m&&(i.ruleHealth=!0)}if("labels"in i){const m=(0,ye.compact)(t.labels.map(qt)),d=m.length>0&&(0,Oe.Av)(c.labels,m),p=m.length>0&&u&&u.type===j.JS.Alerting&&u.alerts&&u.alerts.some(W=>(0,Oe.Av)(W.labels,m));(d||p)&&(i.labels=!0)}if("ruleState"in i){const m=c.promRule;m&&(0,H.Z8)(m)&&m.state===t.ruleState&&(i.ruleState=!0)}return"dashboardUid"in i&&c.annotations[lt.YH.dashboardUID]===t.dashboardUid&&(i.dashboardUid=!0),Object.values(i).every(m=>m===!0)}),l.length&&r.push({...o,rules:l}),r}};function je(t){return Ae(t).split(t).length<5?4:0}function qt(t){try{return(0,Vt.qR)(t)}catch{return{name:t,value:"",isRegex:!0,isEqual:!0}}}function Ae(t){const n=t.length>Jt;return new jt.A({intraMode:n?0:1,interSplit:"\\s+"})}const _t=(t,n)=>n.dataSourceNames?.length?!!t.grafana_alert.data.find(r=>{if(!r.datasourceUid)return!1;const o=(0,rt.l)().getInstanceSettings(r.datasourceUid);return o?.name&&n?.dataSourceNames?.includes(o.name)}):!0;var ea=a(35108),ta=a(22391),aa=a(51527),ot=a(26657),na=a(88323),ra=a(98624);const la=t=>{const n=(0,rt.l)(),[r,o]=(0,e.useState)(),l=(F,B)=>{if(B.action==="clear"&&t.onClear){t.onClear();return}const G=F[F.length-1];let L,Y;B.action==="pop-value"||B.action==="remove-value"?(L=B.removedValue?.value,Y="remove"):(L=G.value,Y="add");const z=n.getInstanceSettings(L);z&&(t.onChange(z,Y),o({error:void 0}))},c=()=>{const{current:F,hideTextValue:B,noDefault:G}=t;if(!(!F&&G))return F?.map(L=>{const Y=n.getInstanceSettings(L);if(Y)return{label:Y.name.slice(0,37),value:Y.name,imgUrl:Y.meta.info.logos.small,hideText:B,meta:Y.meta};const z=(0,ta.Iz)(L);return z===ot.dR.uid||z===ot.dR.name?{label:z,value:z,hideText:B}:{label:(z??"no name")+" - not found",value:z??void 0,imgUrl:"",hideText:B}})},u=()=>{const{alerting:F,tracing:B,metrics:G,mixed:L,dashboard:Y,variables:z,annotations:ie,pluginId:re,type:V,filter:v,logs:w}=t,fe=n.getList({alerting:F,tracing:B,metrics:G,logs:w,dashboard:Y,mixed:L,variables:z,annotations:ie,pluginId:re,filter:v,type:V}),me=fe.filter(O.hP).map(_=>({value:_.name,label:`${_.name}${_.isDefault?" (default)":""}`,imgUrl:_.meta.info.logos.small,meta:_.meta})),q=fe.filter(_=>!(0,O.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:m,onClear:d,openMenuOnFocus:p,placeholder:W,width:y,inputId:A,disabled:S=!1,isLoading:C=!1}=t,h=u(),$=c(),k=typeof d=="function";return e.createElement("div",{"data-testid":Ne.Tp.components.DataSourcePicker.container},e.createElement(na.KF,{isLoading:C,disabled:S,"data-testid":Ne.Tp.components.DataSourcePicker.inputV2,inputId:A||"data-source-picker",className:"ds-picker select-container",isClearable:k,backspaceRemovesValue:!0,onChange:l,options:h,autoFocus:i,onBlur:m,width:y,openMenuOnFocus:p,maxMenuHeight:500,placeholder:W,noOptionsMessage:"No datasources found",value:$??[],invalid:!!r?.error||!!t.invalid,getOptionLabel:F=>F.meta&&(0,aa.x)(F.meta.signature)&&F!==$?e.createElement(Xe.Gy,{align:"center",justify:"space-between",height:"auto"},e.createElement("span",null,F.label)," ",e.createElement(ra.B,{status:F.meta.signature})):F.label||""}))},ct=[{icon:"folder",label:"Grouped",value:"grouped"},{icon:"list-ul",label:"List",value:"list"},{icon:"heart-rate",label:"State",value:"state"}],sa=[{label:"Alert ",value:j.JS.Alerting},{label:"Recording ",value:j.JS.Recording}],oa=[{label:"Ok",value:Se.Jc.Ok},{label:"No Data",value:Se.Jc.NoData},{label:"Error",value:Se.Jc.Error}],ca=Object.entries(j.cF).map(([t,n])=>({label:(0,H.XI)(n),value:n})),ia=({onFilterCleared:t=()=>{}})=>{const n=(0,R.of)(ua),[r,o]=(0,N.s)(),{filterState:l,hasActiveFilters:c,searchQuery:u,setSearchQuery:i,updateFilters:m}=st(),[d,p]=(0,e.useState)(Math.floor(Math.random()*100)),W=`dataSource-${d}`,y=`queryString-${d}`,A=(0,e.useRef)(null),{handleSubmit:S,register:C,setValue:h}=(0,Gt.mN)({defaultValues:{searchQuery:u}}),{ref:$,...k}=C("searchQuery");(0,e.useEffect)(()=>{h("searchQuery",u)},[u,h]);const F=(v,w)=>{const fe=w==="add"?[...l.dataSourceNames].concat([v.name]):l.dataSourceNames.filter(me=>me!==v.name);m({...l,dataSourceNames:fe}),p(me=>me+1),(0,f.Sn)("dataSourceNames")},B=v=>{m({...l,dashboardUid:v}),(0,f.Sn)("dashboardUid")},G=()=>{m({...l,dataSourceNames:[]}),p(v=>v+1)},L=v=>{(0,f.fH)(f.le.clickingAlertStateFilters),m({...l,ruleState:v}),(0,f.Sn)("ruleState")},Y=v=>{m({...l,ruleType:v}),(0,f.Sn)("ruleType")},z=v=>{m({...l,ruleHealth:v}),(0,f.Sn)("ruleHealth")},ie=()=>{i(void 0),t(),setTimeout(()=>p(d+1),100)},re=v=>{o({view:v}),(0,f.aL)({view:v})},V=e.createElement(Ee.I,{name:"search"});return e.createElement("div",{className:n.container},e.createElement(I.B,{direction:"column",gap:1},e.createElement(I.B,{direction:"row",gap:1,wrap:"wrap"},e.createElement(ze.D,{className:n.dsPickerContainer,label:e.createElement(pe.J,{htmlFor:"data-source-picker"},e.createElement(I.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(la,{key:W,alerting:!0,noDefault:!0,placeholder:"All data sources",current:l.dataSourceNames,onChange:F,onClear:G})),e.createElement(ze.D,{className:n.dashboardPickerContainer,label:e.createElement(pe.J,{htmlFor:"filters-dashboard-picker"},"Dashboard")},e.createElement(Ht.b,{inputId:"filters-dashboard-picker",key:l.dashboardUid?"dashboard-defined":"dashboard-not-defined",value:l.dashboardUid,onChange:v=>B(v?.uid),isClearable:!0,cacheOptions:!0})),e.createElement("div",null,e.createElement(pe.J,null,"State"),e.createElement(Ie.z,{options:ca,value:l.ruleState,onChange:L})),e.createElement("div",null,e.createElement(pe.J,null,"Rule type"),e.createElement(Ie.z,{options:sa,value:l.ruleType,onChange:Y})),e.createElement("div",null,e.createElement(pe.J,null,"Health"),e.createElement(Ie.z,{options:oa,value:l.ruleHealth,onChange:z}))),e.createElement(I.B,{direction:"column",gap:1},e.createElement(I.B,{direction:"row",gap:1},e.createElement("form",{className:n.searchInput,onSubmit:S(v=>{i(v.searchQuery),A.current?.blur(),(0,f.zs)({oldQuery:u,newQuery:v.searchQuery})})},e.createElement(ze.D,{label:e.createElement(pe.J,{htmlFor:"rulesSearchInput"},e.createElement(I.B,{gap:.5},e.createElement("span",null,"Search"),e.createElement(ea.j,{content:e.createElement(ma,null)},e.createElement(Ee.I,{name:"info-circle",size:"sm",tabIndex:0}))))},e.createElement(zt.p,{id:"rulesSearchInput",key:y,prefix:V,ref:v=>{$(v),A.current=v},...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:ct,value:String(r.view??ct[0].value),onChange:re}))),c&&e.createElement("div",null,e.createElement(P.$n,{fullWidth:!1,icon:"times",variant:"secondary",onClick:ie},"Clear filters")))))},ua=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 ma(){const t=(0,R.of)(it);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)(it);return e.createElement(e.Fragment,null,e.createElement("div",null,t),e.createElement("code",{className:r.code},n))}const it=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"})}),da=ia,ut={groups:Ut,state:Kt},ga=se.Ys+1,Ea=(0,T.Xc)(()=>{const t=(0,M.useDispatch)(),n=(0,R.of)(pa),r=(0,e.useMemo)(O.gR,[]),[o,l]=(0,e.useState)(!1),c=(0,e.useCallback)(()=>l(!1),[]),[u]=(0,N.s)(),{filterState:i,hasActiveFilters:m}=st(),d=ut[u.view]?u.view:"groups",p=ut[d],W=(0,X.$)(V=>V.promRules),y=(0,X.$)(V=>V.rulerRules),A=r.some(V=>W[V]?.loading||y[V]?.loading),S=Object.entries(W),C=Object.entries(y),h=S.every(([V,v])=>v.dispatched&&(v?.result!==void 0||v?.error!==void 0)),$=C.every(([V,v])=>v.dispatched&&(v?.result!==void 0||v?.error!==void 0)),k=S.every(([V,v])=>v.dispatched&&v?.result?.length===0),F=C.every(([V,v])=>Object.entries(v?.result??{}).every(([me,q])=>q?.length===0)&&v.dispatched),B=m?void 0:ga,[G,L]=(0,E.A)(async()=>{A||await t((0,Me.yo)(!1,{limitAlerts:B}))},[A,B,t]);(0,e.useEffect)(()=>{(0,f.Sq)().catch(()=>{})},[]),(0,e.useEffect)(()=>{t((0,Me.yo)(!1,{limitAlerts:B}))},[t,B]),(0,D.A)(L,lt.HH);const Y=h&&k&&S.length>0&&F&&$,z=!Y,ie=(0,xe.dy)(),re=Qt(ie,i);return e.createElement(U.d,{navId:"alert-list",isLoading:!1,actions:z&&e.createElement(mt,null)},e.createElement(he,null),e.createElement(da,{onFilterCleared:c}),z&&e.createElement(e.Fragment,null,e.createElement("div",{className:n.break}),e.createElement("div",{className:n.buttonsContainer},e.createElement("div",{className:n.statsContainer},d==="groups"&&m&&e.createElement(P.$n,{className:n.expandAllButton,icon:o?"angle-double-up":"angle-double-down",variant:"secondary",onClick:()=>l(!o)},o?"Collapse all":"Expand all"),e.createElement(tt.M_,{namespaces:re})))),Y&&e.createElement(le,null),z&&e.createElement(p,{expandAll:o,namespaces:re}))},{style:"page"}),pa=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)};
  `}),fa=Ea;function mt(){const[t,n]=(0,te.Ej)(te.RY.CreateAlertRule),[r,o]=(0,te.Ej)(te.RY.CreateExternalAlertRule),l=(0,g.zy)();return t&&n||r&&o?e.createElement(P.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,{_:()=>D});var s=a(2543),e=a.n(s),g=a(96540),E=a(19073);const D=({actions:M,children:f})=>{const U=(0,s.filter)(M,P),I=(0,s.filter)(M,N);return U.length?g.createElement(x,{actions:U},f):I.length?g.createElement(T,{actions:I},f):null},x=({actions:M,children:f})=>{const U=(0,E.iI)();return R(U,M)?g.createElement(g.Fragment,null,f):null},T=({actions:M,children:f})=>{const U=(0,E.e2)();return R(U,M)?g.createElement(g.Fragment,null,f):null};function R(M,f){return(0,s.chain)(M).pick(f).values().value().some(([U,I])=>I===!0)}function P(M){return Object.values(E.QI).includes(M)}function N(M){return Object.values(E.RY).includes(M)}},64047:(ae,b,a)=>{a.d(b,{e:()=>g});var s=a(96540),e=a(55852);const g=({isCollapsed:E,onToggle:D,idControlled:x,className:T,text:R,size:P="xl",...N})=>s.createElement(e.$n,{type:"button",fill:"text",variant:"secondary","aria-expanded":!E,"aria-controls":x,className:T,icon:E?"angle-right":"angle-down",onClick:()=>D(!E),...N},R)},16293:(ae,b,a)=>{a.d(b,{J:()=>U});var s=a(32196),e=a(4213),g=a.n(e),E=a(96540),D=a(70713),x=a(40845),T=a(32372),R=a(55852),P=a(10534),N=a(72109),M=a(42418),f=a(84029);function U({format:J,textDefinition:Q,downloadFileName:le,onClose:de}){const se=(0,x.of)(I),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(D.Ay,{disableWidth:!0},({height:K})=>E.createElement(T.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(P.b,{icon:"copy",getText:()=>Q},"Copy code"),E.createElement(R.$n,{icon:"download-alt",onClick:ge},"Download")))}const I=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(N.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(N.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(N.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(M.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:D,onTabChange:x,children:T,onClose:R,formatProviders:P,title:N="Export"}){const M=Object.values(P).map(f=>({label:f.name,value:f.exportFormat}));return s.createElement(e._,{title:N,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:s.createElement(g.sb,{tabs:M,setActiveTab:x,activeTab:D}),onClose:R,size:"md"},T)}},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},D=[s,e]},64100:(ae,b,a)=>{a.d(b,{G:()=>R});var s=a(32196),e=a(96540),g=a(40845),E=a(60782),D=a(67061),x=a(14578),T=a(94753);function R({contentText:N,externalLink:M,linkText:f,title:U}){const I=(0,g.of)(P);return e.createElement(E.G,{content:e.createElement("div",{className:I.mutedText},N),title:e.createElement(D.B,{gap:1,direction:"row"},e.createElement(x.I,{name:"question-circle"}),U),footer:M?e.createElement("a",{href:M,target:"_blank",rel:"noreferrer"},e.createElement(D.B,{direction:"row",gap:.5,alignItems:"center"},e.createElement(T.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:I.helpInfo},e.createElement(D.B,{direction:"row",alignItems:"center",gap:.5},e.createElement(x.I,{name:"question-circle",size:"sm"}),e.createElement(T.E,{variant:"bodySmall",color:"primary"},"Need help?"))))}const P=N=>({mutedText:(0,s.css)`
    color: ${N.colors.text.secondary};
    font-size: ${N.typography.size.sm};
  `,helpInfo:(0,s.css)`
    cursor: pointer;
    text-decoration: underline;
  `})},271:(ae,b,a)=>{a.d(b,{P:()=>T});var s=a(32196),e=a(96540),g=a(40845),E=a(84167),D=a(94753),x=a(67061);const T=({title:P,stepNo:N,children:M,fullWidth:f=!1,description:U})=>{const I=(0,g.of)(R);return e.createElement("div",{className:I.parent},e.createElement(E.n,{className:(0,s.cx)(f&&I.fullWidth),label:e.createElement(D.E,{variant:"h3"},N,". ",P)},e.createElement(x.B,{direction:"column"},U&&e.createElement("div",{className:I.description},U),M)))},R=P=>({parent:(0,s.css)`
    display: flex;
    flex-direction: row;
    max-width: ${P.breakpoints.values.xl}px;
    border: solid 1px ${P.colors.border.weak};
    border-radius: ${P.shape.radius.default};
    padding: ${P.spacing(2)} ${P.spacing(3)};
  `,description:(0,s.css)`
    margin-top: -${P.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),D=a(70713),x=a(40845),T=a(87978),R=a(63021),P=a(40675),N=a(55852),M=a(56034),f=a(14578),U=a(32372),I=a(63066),ve=a(23662);const J=[{label:"Yaml",value:"yaml"}],Q=({onClose:K})=>{const[ee,X]=(0,g.useState)("yaml"),{setValue:O}=(0,E.xW)(),Z=(0,x.of)(Re),H=he=>{for(const ue in he)O(ue,he[ue]);K()};return g.createElement(T._,{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:H}))};function le({tabs:K,activeTab:ee,setActiveTab:X}){return g.createElement(R.U,null,K.map((O,Z)=>g.createElement(P.o,{key:`${O.value}-${Z}`,label:O.label,value:O.value,onChangeTab:()=>X(O.value),active:ee===O.value})))}const de=({onSubmit:K})=>{const ee=(0,x.of)(ge),{getValues:X}=(0,E.xW)(),O=(0,I.l1)(X()),[Z,H]=(0,g.useState)((0,e.Bh)(O)),he=()=>{const ue=(0,e.Hh)(Z),De=X(),te=ne(ue);K({...De,...te})};return g.createElement(g.Fragment,null,g.createElement("div",{className:ee.applyButton},g.createElement(N.$n,{type:"button",onClick:he},"Apply"),g.createElement(M.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(D.Ay,{disableWidth:!0},({height:ue})=>g.createElement(U.B,{width:"100%",height:ue,language:"yaml",value:Z,onBlur:H,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,I.Qk)(K):(0,ve.i7)(K)?(0,I.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:D,icon:x,to:T,target:R,onClick:P,className:N,tooltipPlacement:M="top",...f})=>{const U=typeof D=="string"?D:void 0;return s.createElement(e.m,{content:D,placement:M},T?s.createElement(g.z9,{variant:"secondary",fill:"text",icon:x,href:T,size:"sm",target:R,...f,"aria-label":U}):s.createElement(g.$n,{className:N,variant:"secondary",fill:"text",size:"sm",icon:x,type:"button",onClick:P,...f,"aria-label":U}))}},10940:(ae,b,a)=>{a.d(b,{A:()=>g});var s=a(96540),e=function(E,D){var x=(0,s.useRef)(function(){});(0,s.useEffect)(function(){x.current=E}),(0,s.useEffect)(function(){if(D!==null){var T=setInterval(function(){return x.current()},D||0);return function(){return clearInterval(T)}}},[D])};const g=e}}]);

//# sourceMappingURL=AlertRuleListIndex.e8e11c9626757d2af290.js.map