"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1783],{"./public/app/core/hooks/useCleanup.ts":(e,t,a)=>{a.d(t,{x:()=>i});var s=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),r=a("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),n=a("./public/app/core/actions/cleanUp.ts");function i(e){const t=(0,r.useDispatch)(),a=(0,s.useRef)(e);a.current=e,(0,s.useEffect)((()=>()=>{t((0,n.e)({stateSelector:a.current}))}),[t])}},"./public/app/features/alerting/unified/Silences.tsx":(e,t,a)=>{a.r(t),a.d(t,{default:()=>Te});var s,r=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),n=a("./packages/grafana-ui/src/index.ts"),i=a("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),l=a("./.yarn/__virtual__/react-router-virtual-31642fe47a/3/opt/drone/yarncache/react-router-npm-5.2.1-ea754d7473-7daae084bf.zip/node_modules/react-router/esm/react-router.js"),c=a("./public/app/features/alerting/unified/components/AlertingPageWrapper.tsx"),o=a("./packages/grafana-data/src/index.ts"),d=a("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js"),u=a("./public/app/plugins/datasource/alertmanager/types.ts"),p=a("./public/app/core/components/EmptyListCTA/EmptyListCTA.tsx"),m=a("./public/app/core/services/context_srv.ts"),g=a("./public/app/features/alerting/unified/utils/misc.ts"),h=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const f=e=>{let{alertManagerSourceName:t}=e;return m.Vt.isEditor?(0,h.jsx)(p.Z,{title:"You haven't created any silences yet",buttonIcon:"bell-slash",buttonLink:(0,g.eQ)("alerting/silence/new",t),buttonTitle:"New silence"}):s||(s=(0,h.jsx)(n.CallToActionCard,{callToActionElement:(0,h.jsx)("div",{}),message:"No silences found."}))};var x,b,v,j=a("./public/app/core/hooks/useQueryParams.ts"),y=a("./public/app/features/alerting/unified/utils/alertmanager.ts"),S=a("../../opt/drone/yarncache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip/node_modules/lodash/lodash.js");const _=Object.entries(u.As).map((e=>{let[t,a]=e;return{label:t,value:a}})),A=()=>(0,S.uniqueId)("query-string-"),w=()=>{const[e,t]=(0,r.useState)(A()),[a,s]=(0,j.K)(),{queryString:i,silenceState:l}=(0,g.pF)(a),c=(0,n.useStyles2)(N),o=(0,S.debounce)((e=>{const t=e.target;s({queryString:t.value||null})}),400),d=!!(i&&i.length>3)&&0===(0,y.Zh)(i).length;return(0,h.jsxs)("div",{className:c.flexRow,children:[(0,h.jsx)(n.Field,{className:c.rowChild,label:(0,h.jsxs)("span",{className:c.fieldLabel,children:[x||(x=(0,h.jsx)(n.Tooltip,{content:(0,h.jsxs)("div",{children:["Filter silences by matchers using a comma separated list of matchers, ie:",(0,h.jsx)("pre",{children:"severity=critical, instance=~cluster-us-.+"})]}),children:(0,h.jsx)(n.Icon,{name:"info-circle"})}))," ","Search by matchers"]}),invalid:d,error:d?"Query must use valid matcher syntax":null,children:(0,h.jsx)(n.Input,{className:c.searchInput,prefix:b||(b=(0,h.jsx)(n.Icon,{name:"search"})),onChange:o,defaultValue:null!=i?i:"",placeholder:"Search","data-testid":"search-query-input"},e)}),(0,h.jsxs)("div",{className:c.rowChild,children:[v||(v=(0,h.jsx)(n.Label,{children:"State"})),(0,h.jsx)(n.RadioButtonGroup,{options:_,value:l,onChange:e=>{s({silenceState:e})}})]}),(i||l)&&(0,h.jsx)("div",{className:c.rowChild,children:(0,h.jsx)(n.Button,{variant:"secondary",icon:"times",onClick:()=>{s({queryString:null,silenceState:null}),setTimeout((()=>t(A())))},children:"Clear filters"})})]})},N=e=>({searchInput:d.css`
    width: 360px;
  `,flexRow:d.css`
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    padding-bottom: ${e.spacing(2)};
    border-bottom: 1px solid ${e.colors.border.strong};
  `,rowChild:d.css`
    margin-right: ${e.spacing(1)};
    margin-bottom: 0;
    max-height: 52px;
  `,fieldLabel:d.css`
    font-size: 12px;
    font-weight: 500;
  `});var k=a("./public/app/features/alerting/unified/components/DynamicTable.tsx"),C=a("./public/app/features/alerting/unified/components/StateTag.tsx");const R={[u.As.Active]:"good",[u.As.Expired]:"neutral",[u.As.Pending]:"neutral"},$=e=>{let{state:t}=e;return(0,h.jsx)(C.i,{state:R[t],children:t})};var D=a("./public/app/features/alerting/unified/components/silences/Matchers.tsx"),M=a("./packages/grafana-ui/src/components/Button/index.ts");const z=["className"];const T=e=>{let{className:t}=e,a=function(e,t){if(null==e)return{};var a,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)a=n[s],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,z);return(0,h.jsx)(M.zx,Object.assign({variant:"secondary",size:"xs",className:(0,d.cx)((0,n.useStyles)(O),t)},a))},O=e=>d.css`
  height: 24px;
  font-size: ${e.typography.size.sm};
`;var q,I=a("./public/app/features/alerting/unified/components/rules/ActionIcon.tsx"),E=a("./public/app/features/alerting/unified/state/actions.ts"),B=a("./public/app/features/alerting/unified/styles/table.ts"),Z=a("./public/app/features/alerting/unified/components/CollapseToggle.tsx"),F=a("./public/app/features/alerting/unified/components/AlertLabels.tsx"),L=a("./public/app/features/alerting/unified/components/silences/AmAlertStateTag.tsx");const P=e=>{let{alert:t,className:a}=e;const[s,n]=(0,r.useState)(!0),i=(0,o.intervalToAbbreviatedDurationString)({start:new Date(t.startsAt),end:new Date(t.endsAt)}),l=Object.entries(t.labels).reduce(((e,t)=>{let[a,s]=t;return"alertname"!==a&&"__alert_rule_title__"!==a||(e=s),e}),"");return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("tr",{className:a,children:[(0,h.jsx)("td",{children:(0,h.jsx)(Z.U,{isCollapsed:s,onToggle:e=>n(e)})}),(0,h.jsx)("td",{children:(0,h.jsx)(L.G,{state:t.status.state})}),(0,h.jsxs)("td",{children:["for ",i," seconds"]}),(0,h.jsx)("td",{children:l})]}),!s&&(0,h.jsxs)("tr",{className:a,children:[q||(q=(0,h.jsx)("td",{})),(0,h.jsx)("td",{colSpan:5,children:(0,h.jsx)(F.s,{labels:t.labels})})]})]})};var V,Y;const G=e=>({tableMargin:d.css`
    margin-bottom: ${e.spacing(1)};
  `,colState:d.css`
    width: 110px;
  `,colName:d.css`
    width: 65%;
  `}),H=e=>{let{silencedAlerts:t}=e;const a=(0,n.useStyles2)(B.D),s=(0,n.useStyles2)(G);return t.length?(0,h.jsxs)("table",{className:(0,d.cx)(a.table,s.tableMargin),children:[(0,h.jsxs)("colgroup",{children:[(0,h.jsx)("col",{className:a.colExpand}),(0,h.jsx)("col",{className:s.colState}),V||(V=(0,h.jsx)("col",{})),(0,h.jsx)("col",{className:s.colName})]}),Y||(Y=(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{}),(0,h.jsx)("th",{children:"State"}),(0,h.jsx)("th",{}),(0,h.jsx)("th",{children:"Alert name"})]})})),(0,h.jsx)("tbody",{children:t.map(((e,t)=>(0,h.jsx)(P,{alert:e,className:t%2==0?a.evenRow:""},e.fingerprint)))})]}):null},U=e=>{let{silence:t}=e;const{startsAt:a,endsAt:s,comment:r,createdBy:i,silencedAlerts:l}=t,c=(0,n.useStyles2)(Q),d="YYYY-MM-DD HH:mm",u=o.dateMath.parse(a),p=o.dateMath.parse(s),m=(0,o.intervalToAbbreviatedDurationString)({start:new Date(a),end:new Date(s)});return(0,h.jsxs)("div",{className:c.container,children:[(0,h.jsx)("div",{className:c.title,children:"Comment"}),(0,h.jsx)("div",{children:r}),(0,h.jsx)("div",{className:c.title,children:"Schedule"}),(0,h.jsx)("div",{children:`${null==u?void 0:u.format(d)} - ${null==p?void 0:p.format(d)}`}),(0,h.jsx)("div",{className:c.title,children:"Duration"}),(0,h.jsxs)("div",{children:[" ",m]}),(0,h.jsx)("div",{className:c.title,children:"Created by"}),(0,h.jsxs)("div",{children:[" ",i]}),(0,h.jsx)("div",{className:c.title,children:"Affected alerts"}),(0,h.jsx)(H,{silencedAlerts:l})]})},Q=e=>({container:d.css`
    display: grid;
    grid-template-columns: 1fr 9fr;
    grid-row-gap: 1rem;
  `,title:d.css`
    color: ${e.colors.text.primary};
  `,row:d.css`
    margin: ${e.spacing(1,0)};
  `});var W,J,K,X;const ee=e=>{const[t]=(0,j.K)();return(0,r.useMemo)((()=>{const{queryString:a,silenceState:s}=(0,g.pF)(t),r=null==t?void 0:t.silenceIds;return e.filter((e=>{if("string"==typeof r){if(!r.split(",").includes(e.id))return!1}if(a){if(!(0,y.Zh)(a).every((t=>{var a;return null===(a=e.matchers)||void 0===a?void 0:a.some((e=>{let{name:a,value:s,isEqual:r,isRegex:n}=e;return t.name===a&&t.value===s&&t.isEqual===r&&t.isRegex===n}))})))return!1}if(s){if(!(e.status.state===s))return!1}return!0}))}),[t,e])},te=e=>({topButtonContainer:d.css`
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
  `,addNewSilence:d.css`
    margin: ${e.spacing(2,0)};
  `,callout:d.css`
    background-color: ${e.colors.background.secondary};
    border-top: 3px solid ${e.colors.info.border};
    border-radius: 2px;
    height: 62px;
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-top: ${e.spacing(2)};

    & > * {
      margin-left: ${e.spacing(1)};
    }
  `,calloutIcon:d.css`
    color: ${e.colors.info.text};
  `,editButton:d.css`
    margin-left: ${e.spacing(.5)};
  `});const ae=e=>{let{silences:t,alertManagerAlerts:a,alertManagerSourceName:s}=e;const l=(0,n.useStyles2)(te),[c]=(0,j.K)(),d=ee(t),{silenceState:p}=(0,g.pF)(c),x=!!d.length&&(void 0===p||p===u.As.Expired),b=function(e){const t=(0,i.useDispatch)(),a=(0,n.useStyles2)(te);return(0,r.useMemo)((()=>{const s=a=>{t((0,E.yO)(e,a))},r=[{id:"state",label:"State",renderCell:function(e){let{data:{status:t}}=e;return(0,h.jsx)($,{state:t.state})},size:"88px"},{id:"matchers",label:"Matching labels",renderCell:function(e){let{data:{matchers:t}}=e;return(0,h.jsx)(D.g,{matchers:t||[]})},size:9},{id:"alerts",label:"Alerts",renderCell:function(e){let{data:{silencedAlerts:t}}=e;return(0,h.jsx)("span",{"data-testid":"alerts",children:t.length})},size:1},{id:"schedule",label:"Schedule",renderCell:function(e){let{data:{startsAt:t,endsAt:a}}=e;const s=o.dateMath.parse(t),r=o.dateMath.parse(a),n="YYYY-MM-DD HH:mm";return(0,h.jsxs)(h.Fragment,{children:[" ",null==s?void 0:s.format(n)," ","-",K||(K=(0,h.jsx)("br",{})),null==r?void 0:r.format(n)]})},size:"150px"}];return m.Vt.isEditor&&r.push({id:"actions",label:"Actions",renderCell:function(t){let{data:r}=t;return(0,h.jsxs)(h.Fragment,{children:["expired"===r.status.state?(0,h.jsx)(n.Link,{href:(0,g.eQ)(`/alerting/silence/${r.id}/edit`,e),children:X||(X=(0,h.jsx)(T,{icon:"sync",children:"Recreate"}))}):(0,h.jsx)(T,{icon:"bell",onClick:()=>s(r.id),children:"Unsilence"}),"expired"!==r.status.state&&(0,h.jsx)(I.A,{className:a.editButton,to:(0,g.eQ)(`/alerting/silence/${r.id}/edit`,e),icon:"pen",tooltip:"edit"})]})},size:"140px"}),r}),[e,t,a])}(s),v=(0,r.useMemo)((()=>d.map((e=>{const t=(s=e.id,a.filter((e=>e.status.silencedBy.includes(s))));var s;return{id:e.id,data:Object.assign({},e,{silencedAlerts:t})}}))),[d,a]);return(0,h.jsxs)("div",{"data-testid":"silences-table",children:[!!t.length&&(0,h.jsxs)(h.Fragment,{children:[W||(W=(0,h.jsx)(w,{})),m.Vt.isEditor&&(0,h.jsx)("div",{className:l.topButtonContainer,children:(0,h.jsx)(n.Link,{href:(0,g.eQ)("/alerting/silence/new",s),children:(0,h.jsx)(n.Button,{className:l.addNewSilence,icon:"plus",children:"New Silence"})})}),v.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(k.t,{items:v,cols:b,isExpandable:!0,renderExpandedContent:e=>{let{data:t}=e;return(0,h.jsx)(U,{silence:t})}}),x&&(0,h.jsxs)("div",{className:l.callout,children:[(0,h.jsx)(n.Icon,{className:l.calloutIcon,name:"info-circle"}),J||(J=(0,h.jsx)("span",{children:"Expired silences are automatically deleted after 5 days."}))]})]}):"No matching silences found"]}),!t.length&&(0,h.jsx)(f,{alertManagerSourceName:s})]})};var se=a("./public/app/features/alerting/unified/hooks/useAlertManagerSourceName.ts"),re=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts"),ne=a("./public/app/features/alerting/unified/utils/constants.ts"),ie=a("./public/app/features/alerting/unified/utils/redux.ts"),le=a("./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useDebounce.js"),ce=a("./packages/grafana-runtime/src/index.ts"),oe=a("./.yarn/__virtual__/react-hook-form-virtual-92b6119fd4/3/opt/drone/yarncache/react-hook-form-npm-7.5.3-f9cc466c62-fbfaa3b664.zip/node_modules/react-hook-form/dist/index.esm.js");const de=["onChange","ref"];const ue=e=>({wrapper:d.css`
      margin-top: ${e.spacing(2)};
    `,row:d.css`
      display: flex;
      align-items: flex-start;
      flex-direction: row;
      background-color: ${e.colors.background.secondary};
      padding: ${e.spacing(1)} ${e.spacing(1)} 0 ${e.spacing(1)};
      & > * + * {
        margin-left: ${e.spacing(2)};
      }
    `,removeButton:d.css`
      margin-left: ${e.spacing(1)};
      margin-top: ${e.spacing(2.5)};
    `,matcherOptions:d.css`
      min-width: 140px;
    `,matchers:d.css`
      max-width: ${e.breakpoints.values.sm}px;
      margin: ${e.spacing(1)} 0;
      padding-top: ${e.spacing(.5)};
    `}),pe=e=>{let{className:t}=e;const a=(0,n.useStyles2)(ue),s=(0,oe.Gc)(),{control:r,register:i,formState:{errors:l}}=s,{fields:c=[],append:o,remove:p}=(0,oe.Dq)({name:"matchers"});return(0,h.jsx)("div",{className:(0,d.cx)(t,a.wrapper),children:(0,h.jsx)(n.Field,{label:"Matching labels",required:!0,children:(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:a.matchers,children:c.map(((e,t)=>{var s,o,d,u,m,g,f,x,b,v;return(0,h.jsxs)("div",{className:a.row,"data-testid":"matcher",children:[(0,h.jsx)(n.Field,{label:"Label",invalid:!(null==l||null===(s=l.matchers)||void 0===s||null===(o=s[t])||void 0===o||!o.name),error:null==l||null===(d=l.matchers)||void 0===d||null===(u=d[t])||void 0===u||null===(m=u.name)||void 0===m?void 0:m.message,children:(0,h.jsx)(n.Input,Object.assign({},i(`matchers.${t}.name`,{required:{value:!0,message:"Required."}}),{defaultValue:e.name,placeholder:"label"}))}),(0,h.jsx)(n.Field,{label:"Operator",children:(0,h.jsx)(n.InputControl,{control:r,render:e=>{let{field:{onChange:t}}=e,s=function(e,t){if(null==e)return{};var a,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)a=n[s],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e.field,de);return(0,h.jsx)(n.Select,Object.assign({},s,{menuShouldPortal:!0,onChange:e=>t(e.value),className:a.matcherOptions,options:y.tA,"aria-label":"operator"}))},defaultValue:e.operator||y.tA[0].value,name:`matchers.${t}.operator`,rules:{required:{value:!0,message:"Required."}}})}),(0,h.jsx)(n.Field,{label:"Value",invalid:!(null==l||null===(g=l.matchers)||void 0===g||null===(f=g[t])||void 0===f||!f.value),error:null==l||null===(x=l.matchers)||void 0===x||null===(b=x[t])||void 0===b||null===(v=b.value)||void 0===v?void 0:v.message,children:(0,h.jsx)(n.Input,Object.assign({},i(`matchers.${t}.value`,{required:{value:!0,message:"Required."}}),{defaultValue:e.value,placeholder:"value"}))}),c.length>1&&(0,h.jsx)(n.IconButton,{className:a.removeButton,tooltip:"Remove matcher",name:"trash-alt",onClick:()=>p(t),children:"Remove"})]},`${e.id}`)}))}),(0,h.jsx)(n.Button,{type:"button",icon:"plus",variant:"secondary",onClick:()=>{const e={name:"",value:"",operator:u._M.equal};o(e)},children:"Add matcher"})]})})})};var me,ge=a("./public/app/features/alerting/unified/components/rules/RuleState.tsx"),he=a("./public/app/features/alerting/unified/hooks/useCombinedRuleNamespaces.ts"),fe=a("./public/app/features/alerting/unified/utils/matchers.ts");const xe=()=>{var e;const[t,a]=(0,r.useState)([]),s=(0,oe.Gc)(),l=(0,i.useDispatch)(),{watch:c}=s,o=c("matchers"),d=(0,n.useStyles2)(be),u=[{id:"state",label:"State",renderCell:function(e){let{data:{matchedRule:t}}=e;return(0,h.jsx)(ge.p,{rule:t,isCreating:!1,isDeleting:!1})},size:"160px"},{id:"name",label:"Name",renderCell:function(e){let{data:{matchedRule:t}}=e;return t.name},size:"250px"},{id:"summary",label:"Summary",renderCell:function(e){var t;let{data:{matchedRule:a}}=e;return null!==(t=a.annotations[ne.q6.summary])&&void 0!==t?t:""},size:"400px"}];(0,r.useEffect)((()=>{l((0,E.ei)())}),[l]);const p=(0,he.Z)();return(0,le.Z)((()=>{const e=p.flatMap((e=>e.groups.flatMap((e=>(0,fe.jM)(e.rules,o)))));a(e)}),500,[p,o]),(0,h.jsxs)("div",{children:[(0,h.jsxs)("h4",{className:d.title,children:["Affected alerts",t.length>0?(0,h.jsx)(n.Badge,{className:d.badge,color:"blue",text:t.length}):null]}),(0,h.jsx)("div",{className:d.table,children:o.every((e=>!e.value&&!e.name))?me||(me=(0,h.jsx)("span",{children:"Add a valid matcher to see affected alerts"})):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(k.t,{items:null!==(e=t.slice(0,5))&&void 0!==e?e:[],isExpandable:!1,cols:u}),t.length>5&&(0,h.jsxs)("div",{className:d.moreMatches,children:["and ",t.length-5," more"]})]})})]})};const be=e=>({table:d.css`
    max-width: ${e.breakpoints.values.lg}px;
  `,moreMatches:d.css`
    margin-top: ${e.spacing(1)};
  `,title:d.css`
    display: flex;
    align-items: center;
  `,badge:d.css`
    margin-left: ${e.spacing(1)};
  `}),ve=()=>{const{control:e,getValues:t}=(0,oe.Gc)(),a=(0,n.useStyles)(je),{field:{onChange:s,value:r},fieldState:{invalid:i}}=(0,oe.bc)({name:"startsAt",control:e,rules:{validate:e=>t().endsAt>e}}),{field:{onChange:l,value:c},fieldState:{invalid:d}}=(0,oe.bc)({name:"endsAt",control:e,rules:{validate:e=>t().startsAt<e}}),{field:{onChange:u,value:p}}=(0,oe.bc)({name:"timeZone",control:e}),m=i||d,g=(0,o.dateTime)(r),f=(0,o.dateTime)(c);return(0,h.jsx)(n.Field,{className:a.timeRange,label:"Silence start and end",error:m?"To is before or the same as from":"",invalid:m,children:(0,h.jsx)(n.TimeRangeInput,{value:{from:g,to:f,raw:{from:g,to:f}},timeZone:p,onChange:e=>{s((0,o.dateTime)(e.from)),l((0,o.dateTime)(e.to))},onChangeTimeZone:e=>u(e),hideTimeZone:!1,hideQuickRanges:!0,placeholder:"Select time range"})})},je=e=>({timeRange:d.css`
    width: 400px;
  `});var ye,Se,_e,Ae,we,Ne=a("./public/app/core/hooks/useCleanup.ts"),ke=a("./public/app/features/alerting/unified/hooks/useURLSearchParams.ts");const Ce=(e,t)=>{const a=new Date;if(t){var s;const e=Date.parse(t.endsAt)<Date.now()?{start:a,end:(0,o.addDurationToDate)(a,{hours:2})}:{start:new Date(t.startsAt),end:new Date(t.endsAt)};return{id:t.id,startsAt:e.start.toISOString(),endsAt:e.end.toISOString(),comment:t.comment,createdBy:t.createdBy,duration:(0,o.intervalToAbbreviatedDurationString)(e),isRegex:!1,matchers:(null===(s=t.matchers)||void 0===s?void 0:s.map(y.cm))||[],matcherName:"",matcherValue:"",timeZone:o.DefaultTimeZone}}{const t=(0,o.addDurationToDate)(a,{hours:2});return Object.assign({id:"",startsAt:a.toISOString(),endsAt:t.toISOString(),comment:`created ${(0,o.dateTime)().format("YYYY-MM-DD HH:mm")}`,createdBy:ce.config.bootData.user.name,duration:"2h",isRegex:!1,matchers:[{name:"",value:"",operator:u._M.equal}],matcherName:"",matcherValue:"",timeZone:o.DefaultTimeZone},(e=>{const t={},a=e.get("comment"),s=e.getAll("matcher"),r=(0,fe.RT)(s);return r.length&&(t.matchers=r.map(y.cm)),a&&(t.comment=a),t})(e))}},Re=e=>({field:d.css`
    margin: ${e.spacing(1,0)};
  `,textArea:d.css`
    max-width: ${e.breakpoints.values.sm}px;
  `,createdBy:d.css`
    width: 200px;
  `,flexRow:d.css`
    display: flex;
    flex-direction: row;
    justify-content: flex-start;

    & > * {
      margin-right: ${e.spacing(1)};
    }
  `,silencePeriod:d.css`
    max-width: ${e.breakpoints.values.sm}px;
  `}),$e=e=>{var t;let{silence:a,alertManagerSourceName:s}=e;const[l]=(0,ke.j)(),c=(0,r.useMemo)((()=>Ce(l,a)),[a,l]),u=(0,oe.cI)({defaultValues:c}),p=(0,i.useDispatch)(),m=(0,n.useStyles2)(Re),{loading:f}=(0,re._)((e=>e.updateSilence));(0,Ne.x)((e=>e.unifiedAlerting.updateSilence));const{register:x,handleSubmit:b,formState:v,watch:j,setValue:_,clearErrors:A}=u,w=j("duration"),N=j("startsAt"),k=j("endsAt"),[C,R]=(0,r.useState)(w);return(0,le.Z)((()=>{if((0,o.isValidDate)(N)&&(0,o.isValidDate)(k))if(w!==C)_("endsAt",(0,o.dateTime)((0,o.addDurationToDate)(new Date(N),(0,o.parseDuration)(w))).toISOString()),R(w);else{const e=new Date(N).valueOf();if(new Date(k).valueOf()>e){const e=(0,o.intervalToAbbreviatedDurationString)({start:new Date(N),end:new Date(k)});_("duration",e),R(e)}}}),700,[A,w,k,C,_,N]),(0,h.jsx)(oe.RV,Object.assign({},u,{children:(0,h.jsxs)("form",{onSubmit:b((e=>{const{id:t,startsAt:a,endsAt:r,comment:n,createdBy:i,matchers:l}=e,c=l.map(y._J),o=(0,S.pickBy)({id:t,startsAt:a,endsAt:r,comment:n,createdBy:i,matchers:c},(e=>!!e));p((0,E.QY)({alertManagerSourceName:s,payload:o,exitOnSave:!0,successMessage:"Silence "+(o.id?"updated":"created")}))})),children:[(0,h.jsxs)(n.FieldSet,{label:""+(a?"Recreate silence":"Create silence"),children:[(0,h.jsxs)("div",{className:(0,d.cx)(m.flexRow,m.silencePeriod),children:[ye||(ye=(0,h.jsx)(ve,{})),(0,h.jsx)(n.Field,{label:"Duration",invalid:!!v.errors.duration,error:v.errors.duration&&("required"===v.errors.duration.type?"Required field":v.errors.duration.message),children:(0,h.jsx)(n.Input,Object.assign({className:m.createdBy},x("duration",{validate:e=>0===Object.keys((0,o.parseDuration)(e)).length?"Invalid duration. Valid example: 1d 4h (Available units: y, M, w, d, h, m, s)":void 0}),{id:"duration"}))})]}),Se||(Se=(0,h.jsx)(pe,{})),(0,h.jsx)(n.Field,{className:(0,d.cx)(m.field,m.textArea),label:"Comment",required:!0,error:null===(t=v.errors.comment)||void 0===t?void 0:t.message,invalid:!!v.errors.comment,children:(0,h.jsx)(n.TextArea,Object.assign({},x("comment",{required:{value:!0,message:"Required."}}),{rows:5,placeholder:"Details about the silence"}))}),_e||(_e=(0,h.jsx)(xe,{}))]}),(0,h.jsxs)("div",{className:m.flexRow,children:[f&&(Ae||(Ae=(0,h.jsx)(n.Button,{disabled:!0,icon:"fa fa-spinner",variant:"primary",children:"Saving..."}))),!f&&(we||(we=(0,h.jsx)(n.Button,{type:"submit",children:"Submit"}))),(0,h.jsx)(n.LinkButton,{href:(0,g.eQ)("alerting/silences",s),variant:"secondary",fill:"outline",children:"Cancel"})]})]})}))};var De,Me,ze=a("./public/app/features/alerting/unified/components/AlertManagerPicker.tsx");const Te=(0,n.withErrorBoundary)((()=>{var e,t;const[a,s]=(0,se.k)(),o=(0,i.useDispatch)(),d=(0,re._)((e=>e.silences)),u=(0,re._)((e=>e.amAlerts)),p=a?u[a]||ie.oq:void 0,m=(0,l.TH)().pathname.endsWith("/alerting/silences");(0,r.useEffect)((()=>{function e(){a&&(o((0,E.je)(a)),o((0,E.dB)(a)))}e();const t=setInterval((()=>e),ne.cm);return()=>{clearInterval(t)}}),[a,o]);const{result:g,loading:f,error:x}=a&&d[a]||ie.oq,b=(0,r.useCallback)((e=>g&&g.find((t=>t.id===e))),[g]);return a?(0,h.jsxs)(c.J,{pageId:"silences",children:[(0,h.jsx)(ze.P,{disabled:!m,current:a,onChange:s}),x&&!f&&(0,h.jsx)(n.Alert,{severity:"error",title:"Error loading silences",children:x.message||"Unknown error."}),(null==p?void 0:p.error)&&!(null!=p&&p.loading)&&(0,h.jsx)(n.Alert,{severity:"error",title:"Error loading Alertmanager alerts",children:(null===(e=p.error)||void 0===e?void 0:e.message)||"Unknown error."}),f&&(Me||(Me=(0,h.jsx)(n.LoadingPlaceholder,{text:"loading silences..."}))),g&&!x&&(0,h.jsxs)(l.rs,{children:[(0,h.jsx)(l.AW,{exact:!0,path:"/alerting/silences",children:(0,h.jsx)(ae,{silences:g,alertManagerAlerts:null!==(t=null==p?void 0:p.result)&&void 0!==t?t:[],alertManagerSourceName:a})}),(0,h.jsx)(l.AW,{exact:!0,path:"/alerting/silence/new",children:(0,h.jsx)($e,{alertManagerSourceName:a})}),(0,h.jsx)(l.AW,{exact:!0,path:"/alerting/silence/:id/edit",children:e=>{let{match:t}=e;return(null==t?void 0:t.params.id)&&(0,h.jsx)($e,{silence:b(t.params.id),alertManagerSourceName:a})}})]})]}):De||(De=(0,h.jsx)(l.l_,{to:"/alerting/silences"}))}),{style:"page"})},"./public/app/features/alerting/unified/components/AlertingPageWrapper.tsx":(e,t,a)=>{a.d(t,{J:()=>l});a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js");var s=a("./public/app/core/components/Page/Page.tsx"),r=a("./public/app/core/selectors/navModel.ts"),n=a("./.yarn/__virtual__/react-redux-virtual-7ad20a440e/3/opt/drone/yarncache/react-redux-npm-7.2.6-134f5ed64d-0bf142ce0d.zip/node_modules/react-redux/es/index.js"),i=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const l=e=>{let{children:t,pageId:a,isLoading:l}=e;const c=(0,r.h)((0,n.useSelector)((e=>e.navIndex)),a);return(0,i.jsx)(s.Z,{navModel:c,children:(0,i.jsx)(s.Z.Contents,{isLoading:l,children:t})})}},"./public/app/features/alerting/unified/components/rules/ActionIcon.tsx":(e,t,a)=>{a.d(t,{A:()=>c});var s=a("./packages/grafana-ui/src/index.ts"),r=(a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),a("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js")),n=a("./.yarn/__virtual__/react-router-dom-virtual-e45eb1b58b/3/opt/drone/yarncache/react-router-dom-npm-5.3.0-aa9adb5bec-47584fd629.zip/node_modules/react-router-dom/esm/react-router-dom.js"),i=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const l=["tooltip","icon","to","target","onClick","className","tooltipPlacement"];const c=e=>{let{tooltip:t,icon:a,to:n,target:c,onClick:u,className:p,tooltipPlacement:m="top"}=e,g=function(e,t){if(null==e)return{};var a,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)a=n[s],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,l);const h="string"==typeof t?t:void 0,f=(0,i.jsx)(s.Icon,Object.assign({role:"button",className:(0,r.cx)((0,s.useStyles)(d),p),onClick:u,name:a},g,{"aria-label":h}));return(0,i.jsx)(s.Tooltip,{content:t,placement:m,children:n?(0,i.jsx)(o,{url:n,label:h,target:c,children:f}):f})},o=e=>{let{url:t,label:a,target:s,children:r}=e;return(null==t?void 0:t.startsWith("http"))?(0,i.jsx)("a",{"aria-label":a,href:t,target:s,children:r}):(0,i.jsx)(n.Link,{"aria-label":a,to:t,target:s,children:r})},d=()=>r.css`
  cursor: pointer;
`},"./public/app/features/alerting/unified/components/rules/RuleState.tsx":(e,t,a)=>{a.d(t,{p:()=>m});var s,r,n=a("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js"),i=a("./packages/grafana-data/src/index.ts"),l=a("./packages/grafana-ui/src/index.ts"),c=a("./public/app/types/unified-alerting-dto.ts"),o=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),d=a("./public/app/features/alerting/unified/utils/rules.ts"),u=a("./public/app/features/alerting/unified/components/rules/AlertStateTag.tsx"),p=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const m=e=>{let{rule:t,isDeleting:a,isCreating:n}=e;const m=(0,l.useStyles2)(g),{promRule:h}=t,f=(0,o.useMemo)((()=>{var e;if(h&&(0,d.x_)(h)&&null!==(e=h.alerts)&&void 0!==e&&e.length&&h.state!==c.x_.Inactive){const e=(0,d.ub)(h);if(e)return(0,p.jsxs)("span",{title:String(e),className:m.for,children:["for"," ",(0,i.intervalToAbbreviatedDurationString)({start:e,end:new Date},!1)]})}return null}),[h,m]);return a?s||(s=(0,p.jsxs)(l.HorizontalGroup,{align:"flex-start",children:[(0,p.jsx)(l.Spinner,{}),"deleting"]})):n?r||(r=(0,p.jsxs)(l.HorizontalGroup,{align:"flex-start",children:[" ",(0,p.jsx)(l.Spinner,{}),"creating"]})):h&&(0,d.x_)(h)?(0,p.jsxs)(l.HorizontalGroup,{align:"flex-start",children:[(0,p.jsx)(u.l,{state:h.state}),f]}):h&&(0,d.OP)(h)?(0,p.jsx)(p.Fragment,{children:"Recording rule"}):(0,p.jsx)(p.Fragment,{children:"n/a"})},g=e=>({for:n.css`
    font-size: ${e.typography.bodySmall.fontSize};
    color: ${e.colors.text.secondary};
    white-space: nowrap;
    padding-top: 2px;
  `})},"./public/app/features/alerting/unified/components/silences/AmAlertStateTag.tsx":(e,t,a)=>{a.d(t,{G:()=>l});var s=a("./public/app/plugins/datasource/alertmanager/types.ts"),r=(a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),a("./public/app/features/alerting/unified/components/StateTag.tsx")),n=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const i={[s.Z9.Active]:"bad",[s.Z9.Unprocessed]:"neutral",[s.Z9.Suppressed]:"info"},l=e=>{let{state:t}=e;return(0,n.jsx)(r.i,{state:i[t],children:t})}},"./public/app/features/alerting/unified/components/silences/Matchers.tsx":(e,t,a)=>{a.d(t,{g:()=>o});var s=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),r=a("./packages/grafana-ui/src/index.ts"),n=a("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js"),i=a("./public/app/features/alerting/unified/components/AlertLabel.tsx"),l=a("./public/app/features/alerting/unified/utils/alertmanager.ts"),c=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const o=e=>{let{matchers:t,onRemoveLabel:a}=e;const n=(0,r.useStyles)(d),o=(0,s.useCallback)((e=>{a&&a(e)}),[a]);return(0,c.jsx)("div",{className:n.wrapper,children:t.map(((e,t)=>{const{name:s,value:r}=e;return(0,c.jsx)(i.i,{labelKey:s,value:r,operator:(0,l.zy)(e),onRemoveLabel:a?()=>o(t):void 0},`${s}-${r}-${t}`)}))})},d=e=>({wrapper:n.css`
    & > * {
      margin-top: ${e.spacing.xs};
      margin-right: ${e.spacing.xs};
    }
    padding-bottom: ${e.spacing.xs};
  `})},"./public/app/features/alerting/unified/hooks/useAlertManagerSourceName.ts":(e,t,a)=>{a.d(t,{k:()=>o});var s=a("./public/app/core/hooks/useQueryParams.ts"),r=a("./public/app/core/store.ts"),n=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),i=a("./public/app/features/alerting/unified/utils/constants.ts"),l=a("./public/app/features/alerting/unified/utils/datasource.ts");function c(e){return e===l.GC||!!(0,l.aM)().find((t=>t.name===e))}function o(){const[e,t]=(0,s.K)(),a=(0,n.useCallback)((e=>{c(e)&&(e===l.GC?(r.Z.delete(i.de),t({[i.c4]:null})):(r.Z.set(i.de,e),t({[i.c4]:e})))}),[t]),o=e[i.c4];if(o&&"string"==typeof o)return c(o)?[o,a]:[void 0,a];const d=r.Z.get(i.de);return d&&"string"==typeof d&&c(d)?(a(d),[d,a]):[l.GC,a]}},"./public/app/features/alerting/unified/hooks/useCombinedRuleNamespaces.ts":(e,t,a)=>{a.d(t,{Z:()=>l});var s=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),r=a("./public/app/features/alerting/unified/utils/datasource.ts"),n=a("./public/app/features/alerting/unified/utils/rules.ts"),i=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts");function l(e){const t=(0,i._)((e=>e.promRules)),a=(0,i._)((e=>e.rulerRules)),l=(0,s.useRef)({}),o=(0,s.useMemo)((()=>{if(e){const t=(0,r.o_)(e);if(!t)throw new Error(`Unknown rules source: ${e}`);return[t]}return(0,r.h_)()}),[e]);return(0,s.useMemo)((()=>o.map((e=>{var s,i;const o=(0,r.jq)(e)?e.name:e,d=null===(s=t[o])||void 0===s?void 0:s.result,u=null===(i=a[o])||void 0===i?void 0:i.result,p=l.current[o];if(p&&p.promRules===d&&p.rulerRules===u)return p.result;const m={};Object.entries(u||{}).forEach((t=>{let[a,s]=t;const r={rulesSource:e,name:a,groups:[]};m[a]=r,function(e,t){e.groups=t.map((t=>{const a={name:t.name,interval:t.interval,source_tenants:t.source_tenants,rules:[]};return a.rules=t.rules.map((t=>function(e,t,a){return(0,n.cG)(e)?{name:e.alert,query:e.expr,labels:e.labels||{},annotations:e.annotations||{},rulerRule:e,namespace:t,group:a}:(0,n.yF)(e)?{name:e.record,query:e.expr,labels:e.labels||{},annotations:{},rulerRule:e,namespace:t,group:a}:{name:e.grafana_alert.title,query:"",labels:e.labels||{},annotations:e.annotations||{},rulerRule:e,namespace:t,group:a}}(t,e,a))),a}))}(r,s)})),null==d||d.forEach((t=>{let{name:a,groups:s}=t;!function(e,t){t.forEach((t=>{var a;let s=e.groups.find((e=>e.name===t.name));s||(s={name:t.name,rules:[]},e.groups.push(s)),(null!==(a=t.rules)&&void 0!==a?a:[]).forEach((t=>{const a=function(e,t,a){var s;if((0,r.HY)(a))return t.rules.find((t=>t.name===e.name));return null!==(s=t.rules.find((t=>!t.promRule&&c(t,e,!0))))&&void 0!==s?s:t.rules.find((t=>!t.promRule&&c(t,e,!1)))}(t,s,e.rulesSource);a?a.promRule=t:s.rules.push(function(e,t,a){return{name:e.name,query:e.query,labels:e.labels||{},annotations:(0,n.x_)(e)&&e.annotations||{},promRule:e,namespace:t,group:a}}(t,e,s))}))}))}(m[a]=m[a]||{rulesSource:e,name:a,groups:[]},s)}));const g=Object.values(m);return(0,r.HY)(e)&&g.forEach((e=>{e.groups=[{name:"default",rules:e.groups.flatMap((e=>e.rules)).sort(((e,t)=>e.name.localeCompare(t.name)))}]})),l.current[o]={promRules:d,rulerRules:u,result:g},g})).flat()),[t,a,o])}function c(e,t){let a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.name===t.name&&JSON.stringify([a?o(e.query):"",e.labels,e.annotations])===JSON.stringify([a?o(t.query):"",t.labels||{},(0,n.x_)(t)&&t.annotations||{}])}function o(e){return e.length>1&&"("===e[0]&&")"===e[e.length-1]&&(e=e.substr(1,e.length-2)),(e=e.replace(/\s|\n/g,"")).split("").sort().join("")}},"./public/app/features/alerting/unified/hooks/useURLSearchParams.ts":(e,t,a)=>{a.d(t,{j:()=>i});var s=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),r=a("./.yarn/__virtual__/react-router-virtual-31642fe47a/3/opt/drone/yarncache/react-router-npm-5.2.1-ea754d7473-7daae084bf.zip/node_modules/react-router/esm/react-router.js"),n=a("./packages/grafana-runtime/src/index.ts");function i(){const{search:e}=(0,r.TH)();return[(0,s.useMemo)((()=>new URLSearchParams(e)),[e]),(0,s.useCallback)(((e,t)=>{n.locationService.partial(e,t)}),[])]}},"./public/app/features/alerting/unified/styles/table.ts":(e,t,a)=>{a.d(t,{D:()=>r});var s=a("./.yarn/__virtual__/@emotion-css-virtual-72c314ddb1/3/opt/drone/yarncache/@emotion-css-npm-11.7.1-25ff8755a7-ac1f56656f.zip/node_modules/@emotion/css/dist/emotion-css.esm.js");const r=e=>({table:s.css`
    width: 100%;
    border-radius: ${e.shape.borderRadius()};
    border: solid 1px ${e.colors.border.weak};
    background-color: ${e.colors.background.secondary};

    th {
      padding: ${e.spacing(1)};
    }

    td {
      padding: 0 ${e.spacing(1)};
    }

    tr {
      height: 38px;
    }
  `,evenRow:s.css`
    background-color: ${e.colors.background.primary};
  `,colExpand:s.css`
    width: 36px;
  `,actionsCell:s.css`
    text-align: right;
    width: 1%;
    white-space: nowrap;

    & > * + * {
      margin-left: ${e.spacing(1)};
    }
  `})}}]);
//# sourceMappingURL=AlertSilences.cd4ada1146b53ad3284f.js.map