"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4282],{"./public/app/features/alerting/unified/components/alert-groups/MatcherFilter.tsx":(e,t,a)=>{a.d(t,{F:()=>l});a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js");var n,s,r=a("./packages/grafana-ui/src/index.ts"),i=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"),o=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const l=e=>{let{className:t,onFilterChange:a,defaultQueryString:i,queryString:l}=e;const u=(0,r.useStyles2)(c),d=n||(n=(0,o.jsx)(r.Icon,{name:"search"}));return(0,o.jsxs)("div",{className:t,children:[(0,o.jsxs)(r.Label,{children:[(0,o.jsx)(r.Tooltip,{content:s||(s=(0,o.jsxs)("div",{children:["Filter alerts using label querying, ex:",(0,o.jsx)("pre",{children:'{severity="critical", instance=~"cluster-us-.+"}'})]})),children:(0,o.jsx)(r.Icon,{className:u.icon,name:"info-circle",size:"xs"})}),"Search by label"]}),(0,o.jsx)(r.Input,{placeholder:"Search",defaultValue:i,value:l,onChange:e=>{const t=e.target;a(t.value)},"data-testid":"search-query-input",prefix:d,className:u.inputWidth})]})},c=e=>({icon:i.css`
    margin-right: ${e.spacing(.5)};
  `,inputWidth:i.css`
    width: 340px;
    flex-grow: 0;
  `})},"./public/app/features/alerting/unified/components/rules/RuleDetailsActionButtons.tsx":(e,t,a)=>{a.d(t,{f:()=>I});var n=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),s=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"),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"),i=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"),o=a("./packages/grafana-data/src/index.ts"),l=a("./packages/grafana-runtime/src/index.ts"),c=a("./packages/grafana-ui/src/index.ts"),u=a("./public/app/core/services/context_srv.ts"),d=a("./public/app/core/core.ts"),p=a("./public/app/features/alerting/unified/hooks/useIsRuleEditable.ts"),m=a("./public/app/features/alerting/unified/utils/constants.ts"),f=a("./public/app/features/alerting/unified/utils/datasource.ts"),g=a("./public/app/features/alerting/unified/utils/misc.ts"),h=a("./public/app/features/alerting/unified/utils/rule-id.ts"),x=a("./public/app/features/alerting/unified/state/actions.ts"),b=a("./public/app/features/alerting/unified/utils/alertmanager.ts"),y=a("../../opt/drone/yarncache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip/node_modules/lodash/lodash.js"),j=a("./public/app/features/alerting/unified/components/DynamicTable.tsx"),v=a("./public/app/features/alerting/unified/components/rules/AlertStateTag.tsx"),_=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts");var S,w=a("./public/app/features/alerting/unified/components/AlertLabel.tsx"),z=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const k=e=>{let{alertId:t}=e;const{loading:a,error:r,result:i=[]}=function(e){const t=(0,s.useDispatch)(),a=(0,_._)((e=>e.managedAlertStateHistory));return(0,n.useEffect)((()=>{t((0,x.Ms)(e))}),[t,e]),a}(t);if(a&&!r)return S||(S=(0,z.jsx)(c.LoadingPlaceholder,{text:"Loading history..."}));if(r&&!a)return(0,z.jsx)(c.Alert,{title:"Failed to fetch alert state history",children:r.message});const o=[{id:"state",label:"State",size:"max-content",renderCell:C},{id:"value",label:"",size:"auto",renderCell:R},{id:"timestamp",label:"Time",size:"max-content",renderCell:q}],l=i.reduce(((e,t,a)=>(e.push({id:String(t.id),state:t.newState,text:t.text,data:t.data,timestamp:t.updated}),function(e,t){const a=t[e],n=t[e+1];if(!n)return!1;return n.newState===a.prevState}(a,i)||e.push({id:(0,y.uniqueId)(),state:t.prevState}),e)),[]).map((e=>({id:e.id,data:e})));return(0,z.jsx)(j.t,{cols:o,items:l})};function R(e){var t,a;const n=null!==(t=null===(a=e.data.data)||void 0===a?void 0:a.evalMatches)&&void 0!==t?t:[];return(0,z.jsxs)(z.Fragment,{children:[e.data.text,(0,z.jsx)(E,{children:n.map((e=>(0,z.jsx)(w.i,{labelKey:e.metric,value:String(e.value)},e.metric)))})]})}function C(e){return(0,z.jsx)(v.l,{state:e.data.state})}function q(e){return(0,z.jsx)("div",{className:N,children:e.data.timestamp&&(0,z.jsx)("span",{children:(0,o.dateTimeFormat)(e.data.timestamp)})})}const E=e=>{let{children:t}=e;const{wrapper:a}=(0,c.useStyles)($);return(0,z.jsx)("div",{className:a,children:t})},N=i.css`
  display: flex;
  align-items: flex-end;
  flex-direction: column;
`,$=e=>({wrapper:i.css`
    & > * {
      margin-right: ${e.spacing.xs};
    }
  `});var D,F,M=a("./public/app/features/alerting/unified/utils/rules.ts");const I=e=>{var t,a;let{rule:i,rulesSource:y}=e;const j=(0,s.useDispatch)(),v=(0,r.TH)(),_=(0,c.useStyles2)(U),{namespace:S,group:w,rulerRule:R}=i,[C,q]=(0,n.useState)(),E=function(e){if(!e)return!1;return null!=e.grafana_alert}(i.rulerRule)&&null!==(t=i.rulerRule.grafana_alert.id)&&void 0!==t?t:"",{StateHistoryModal:N,showStateHistoryModal:$}=function(e){var t;const[a,s]=(0,n.useState)(!1);return{StateHistoryModal:(0,n.useMemo)((()=>(0,z.jsx)(c.Modal,{isOpen:a,onDismiss:()=>s(!1),closeOnBackdropClick:!0,closeOnEscape:!0,title:"State history",children:t||(t=(0,z.jsx)(k,{alertId:e}))})),[e,a]),showStateHistoryModal:()=>s(!0),hideStateHistoryModal:()=>s(!1)}}(E),I=(0,f.HY)(y)?y:null===(a=(0,b.Xy)(y.jsonData.alertmanagerUid))||void 0===a?void 0:a.name,A=[],L=[],H=(0,M.Jq)(w),{isEditable:B}=(0,p.M)((0,f.EG)(y),R),T=v.pathname+v.search,G=v.pathname.endsWith("/view");const O=()=>{if(C&&C.rulerRule){const e=h.Zk((0,f.EG)(C.namespace.rulesSource),C.namespace.name,C.group.name,C.rulerRule);j((0,x.hS)(e,{navigateTo:G?"/alerting/list":void 0})),q(void 0)}},V=()=>{if((0,f.jq)(y)){const{appUrl:e,appSubUrl:t}=l.config;return`${""!==t?`${e}${t}/`:l.config.appUrl}alerting/${`${encodeURIComponent(y.name)}/${encodeURIComponent(i.name)}`}/find`}return window.location.href.split("?")[0]};if((0,f.jq)(y)&&u.Vt.isEditor&&!H&&A.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"primary",icon:"chart-line",target:"__blank",href:(0,g.mH)(y.name,i.query),children:"See graph"},"explore")),i.annotations[m.q6.runbookURL]&&A.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"primary",icon:"book",target:"__blank",href:i.annotations[m.q6.runbookURL],children:"View runbook"},"runbook")),i.annotations[m.q6.dashboardUID]){const e=i.annotations[m.q6.dashboardUID];if(e){A.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"primary",icon:"apps",target:"__blank",href:`d/${encodeURIComponent(e)}`,children:"Go to dashboard"},"dashboard"));const t=i.annotations[m.q6.panelID];t&&A.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"primary",icon:"apps",target:"__blank",href:`d/${encodeURIComponent(e)}?viewPanel=${encodeURIComponent(t)}`,children:"Go to panel"},"panel"))}}if(I&&A.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",icon:"bell-slash",target:"__blank",href:(0,g.Vv)(I,i),children:"Silence"},"silence")),E&&A.push((0,z.jsxs)(n.Fragment,{children:[(0,z.jsx)(c.Button,{className:_.button,size:"xs",icon:"history",onClick:()=>$(),children:"Show state history"}),N]},"history")),G||L.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"secondary",icon:"eye",href:(0,g.V2)(y,i,T),children:"View"},"view")),B&&R&&!H){const e=(0,f.EG)(y),t=h.Zk(e,S.name,w.name,R),a=o.urlUtil.renderUrl(`${l.config.appSubUrl}/alerting/${encodeURIComponent(h.$V(t))}/edit`,{returnTo:T});G&&L.push((0,z.jsx)(c.ClipboardButton,{onClipboardCopy:()=>{d.h$.emit(o.AppEvents.alertSuccess,["URL copied!"])},onClipboardError:e=>{d.h$.emit(o.AppEvents.alertError,["Error while copying URL",e.text])},className:_.button,size:"sm",getText:V,children:"Copy link to rule"},"copy")),L.push((0,z.jsx)(c.LinkButton,{className:_.button,size:"xs",variant:"secondary",icon:"pen",href:a,children:"Edit"},"edit"),(0,z.jsx)(c.Button,{className:_.button,size:"xs",type:"button",variant:"secondary",icon:"trash-alt",onClick:()=>q(i),children:"Delete"},"delete"))}return A.length||L.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)("div",{className:_.wrapper,children:[(0,z.jsx)(c.HorizontalGroup,{width:"auto",children:A.length?A:D||(D=(0,z.jsx)("div",{}))}),(0,z.jsx)(c.HorizontalGroup,{width:"auto",children:L.length?L:F||(F=(0,z.jsx)("div",{}))})]}),!!C&&(0,z.jsx)(c.ConfirmModal,{isOpen:!0,title:"Delete rule",body:"Deleting this rule will permanently remove it from your alert rule list. Are you sure you want to delete this rule?",confirmText:"Yes, delete",icon:"exclamation-triangle",onConfirm:O,onDismiss:()=>q(void 0)})]}):null};const U=e=>({wrapper:i.css`
    padding: ${e.spacing(2)} 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: wrap;
    border-bottom: solid 1px ${e.colors.border.medium};
  `,button:i.css`
    height: 24px;
    margin-top: ${e.spacing(1)};
    font-size: ${e.typography.size.sm};
  `})},"./public/app/features/alerting/unified/components/rules/RuleDetailsAnnotations.tsx":(e,t,a)=>{a.d(t,{J:()=>o});a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js");var 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"),s=a("./packages/grafana-ui/src/index.ts"),r=a("./public/app/features/alerting/unified/components/AnnotationDetailsField.tsx"),i=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");function o(e){const{annotations:t}=e,a=(0,s.useStyles2)(l);return 0===t.length?null:(0,i.jsx)("div",{className:a.annotations,children:t.map((e=>{let[t,a]=e;return(0,i.jsx)(r.a,{annotationKey:t,value:a},t)}))})}const l=()=>({annotations:n.css`
    margin-top: 46px;
  `})},"./public/app/features/alerting/unified/components/rules/RuleDetailsDataSources.tsx":(e,t,a)=>{a.d(t,{C:()=>p});var 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"),s=a("./packages/grafana-runtime/src/index.ts"),r=a("./packages/grafana-ui/src/index.ts"),i=a("./public/app/features/expressions/ExpressionDatasource.ts"),o=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),l=a("./public/app/features/alerting/unified/utils/datasource.ts"),c=a("./public/app/features/alerting/unified/utils/rules.ts"),u=a("./public/app/features/alerting/unified/components/DetailsField.tsx"),d=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");function p(e){const{rulesSource:t,rule:a}=e,n=(0,r.useStyles2)(m),p=(0,o.useMemo)((()=>{if((0,l.jq)(t))return[{name:t.name,icon:t.meta.info.logos.small}];if((0,c.Pc)(a.rulerRule)){const{data:e}=a.rulerRule.grafana_alert,t=e.reduce(((e,t)=>{const a=(0,s.getDataSourceSrv)().getInstanceSettings(t.datasourceUid);return a&&a.uid!==i.Yq?(e[a.name]={name:a.name,icon:a.meta.info.logos.small},e):e}),{});return Object.values(t)}return[]}),[a,t]);return 0===p.length?null:(0,d.jsx)(u.C,{label:"Data source",children:p.map(((e,t)=>{let{name:a,icon:s}=e;return(0,d.jsxs)("div",{children:[s&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("img",{alt:`${a} datasource logo`,className:n.dataSourceIcon,src:s})," "]}),a]},a)}))})}function m(e){const t=e.spacing(2);return{dataSourceIcon:n.css`
      width: ${t};
      height: ${t};
    `}}},"./public/app/features/alerting/unified/components/rules/RuleDetailsExpression.tsx":(e,t,a)=>{a.d(t,{C:()=>x});var n=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),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"),r=a("./public/app/features/alerting/unified/utils/datasource.ts"),i=a("./public/app/features/alerting/unified/components/DetailsField.tsx"),o=a("./.yarn/__virtual__/@grafana-slate-react-virtual-047372596b/3/opt/drone/yarncache/@grafana-slate-react-npm-0.22.10-grafana-510bc0576d-3417c53d9d.zip/node_modules/@grafana/slate-react/lib/slate-react.es.js"),l=a("./public/app/plugins/datasource/prometheus/promql.ts"),c=a("./public/app/plugins/datasource/loki/syntax.ts"),u=a("../../opt/drone/yarncache/prismjs-npm-1.26.0-15be1ab06b-6de058930c.zip/node_modules/prismjs/prism.js"),d=a("./packages/grafana-ui/src/index.ts"),p=a("./public/app/features/alerting/unified/components/Well.tsx"),m=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const f=e=>{let{language:t,expr:a}=e;const s=(0,n.useMemo)((()=>[(0,d.SlatePrism)({onlyIn:e=>"code_block"===e.type,getSyntax:()=>t},Object.assign({},u.languages,{[t]:"logql"===t?c.ZP:l.ZP}))]),[t]),r=(0,n.useMemo)((()=>(0,d.makeValue)(a)),[a]);return(0,m.jsx)(o.ML,{plugins:s,value:r,readOnly:!0})},g=e=>{let{expression:t,rulesSource:a}=e;const n=(0,d.useStyles)(h);return(0,m.jsx)(p.t,{className:(0,s.cx)(n.well,"slate-query-field"),children:(0,r.jq)(a)?(0,m.jsx)(f,{expr:t,language:a.type===r.ye.Loki?"logql":"promql"}):t})},h=e=>({well:s.css`
    font-family: ${e.typography.fontFamily.monospace};
  `});function x(e){const{annotations:t,rulesSource:a,rule:n}=e,o=b();return(0,r.jq)(a)?(0,m.jsx)(i.C,{label:"Expression",horizontal:!0,className:(0,s.cx)({[o.exprRow]:!!t.length}),children:(0,m.jsx)(g,{expression:n.query,rulesSource:a})}):null}const b=()=>({exprRow:s.css`
    margin-bottom: 46px;
  `})},"./public/app/features/alerting/unified/components/rules/RuleDetailsMatchingInstances.tsx":(e,t,a)=>{a.d(t,{M:()=>x});var n,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/rules.ts"),i=a("./public/app/features/alerting/unified/components/DetailsField.tsx"),o=a("./public/app/features/alerting/unified/components/rules/AlertInstancesTable.tsx"),l=a("./public/app/plugins/panel/alertlist/types.ts"),c=a("./packages/grafana-ui/src/index.ts"),u=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"),d=a("./public/app/features/alerting/unified/utils/alertmanager.ts"),p=a("./public/app/features/alerting/unified/utils/misc.ts"),m=a("./public/app/features/alerting/unified/components/alert-groups/MatcherFilter.tsx"),f=a("./public/app/types/unified-alerting-dto.ts"),g=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js");const h=e=>{let{className:t,onStateFilterChange:a,stateFilter:s}=e;const r=Object.values(f.bj).map((e=>({label:e,value:e})));return(0,g.jsxs)("div",{className:t,children:[n||(n=(0,g.jsx)(c.Label,{children:"State"})),(0,g.jsx)(c.RadioButtonGroup,{options:r,value:s,onChange:a,onClick:e=>{e===s&&a(void 0)}})]})};function x(e){const{promRule:t}=e,[a,n]=(0,s.useState)(),[f,x]=(0,s.useState)(),[y]=(0,s.useState)(Math.floor(100*Math.random())),j=`queryString-${y}`,v=(0,c.useStyles)(b),_=(0,s.useMemo)((()=>{var e;return(0,r.x_)(t)&&null!==(e=t.alerts)&&void 0!==e&&e.length?function(e,t,a){let n=[...a];if(e){const t=(0,d.Zh)(e||"");n=n.filter((e=>{let{labels:a}=e;return(0,d.eD)(a,t)}))}t&&(n=n.filter((e=>e.state===t)));return n}(a,f,(0,p.Zl)(l.As.Importance,t.alerts)):[]}),[t,f,a]);return(0,r.x_)(t)?(0,g.jsxs)(i.C,{label:"Matching instances",horizontal:!0,children:[(0,g.jsx)("div",{className:(0,u.cx)(v.flexRow,v.spaceBetween),children:(0,g.jsxs)("div",{className:v.flexRow,children:[(0,g.jsx)(m.F,{className:v.rowChild,defaultQueryString:a,onFilterChange:e=>n(e)},j),(0,g.jsx)(h,{className:v.rowChild,stateFilter:f,onStateFilterChange:x})]})}),(0,g.jsx)(o.o,{instances:_})]}):null}const b=e=>({flexRow:u.css`
      display: flex;
      flex-direction: row;
      align-items: flex-end;
      width: 100%;
      flex-wrap: wrap;
      margin-bottom: ${e.spacing.sm};
    `,spaceBetween:u.css`
      justify-content: space-between;
    `,rowChild:u.css`
      margin-right: ${e.spacing.sm};
    `})},"./public/app/features/alerting/unified/components/rules/RuleHealth.tsx":(e,t,a)=>{a.d(t,{V:()=>l});var n,s,r=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-ui/src/index.ts"),o=(a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/jsx-runtime.js"));const l=e=>{let{rule:t}=e;const a=(0,i.useStyles2)(c);return"err"===t.health||"error"===t.health?(0,o.jsx)(i.Tooltip,{theme:"error",content:t.lastError||"No error message provided.",children:(0,o.jsxs)("div",{className:a.warn,children:[n||(n=(0,o.jsx)(i.Icon,{name:"exclamation-triangle"})),s||(s=(0,o.jsx)("span",{children:"error"}))]})}):(0,o.jsx)(o.Fragment,{children:t.health})},c=e=>({warn:r.css`
    display: inline-flex;
    flex-direction: row;
    color: ${e.colors.warning.text};
    & > * + * {
      margin-left: ${e.spacing(1)};
    }
  `})},"./public/app/features/alerting/unified/components/rules/RuleState.tsx":(e,t,a)=>{a.d(t,{p:()=>m});var n,s,r=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"),o=a("./packages/grafana-ui/src/index.ts"),l=a("./public/app/types/unified-alerting-dto.ts"),c=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),u=a("./public/app/features/alerting/unified/utils/rules.ts"),d=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:r}=e;const m=(0,o.useStyles2)(f),{promRule:g}=t,h=(0,c.useMemo)((()=>{var e;if(g&&(0,u.x_)(g)&&null!==(e=g.alerts)&&void 0!==e&&e.length&&g.state!==l.x_.Inactive){const e=(0,u.ub)(g);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}),[g,m]);return a?n||(n=(0,p.jsxs)(o.HorizontalGroup,{align:"flex-start",children:[(0,p.jsx)(o.Spinner,{}),"deleting"]})):r?s||(s=(0,p.jsxs)(o.HorizontalGroup,{align:"flex-start",children:[" ",(0,p.jsx)(o.Spinner,{}),"creating"]})):g&&(0,u.x_)(g)?(0,p.jsxs)(o.HorizontalGroup,{align:"flex-start",children:[(0,p.jsx)(d.l,{state:g.state}),h]}):g&&(0,u.OP)(g)?(0,p.jsx)(p.Fragment,{children:"Recording rule"}):(0,p.jsx)(p.Fragment,{children:"n/a"})},f=e=>({for:r.css`
    font-size: ${e.typography.bodySmall.fontSize};
    color: ${e.colors.text.secondary};
    white-space: nowrap;
    padding-top: 2px;
  `})},"./public/app/features/alerting/unified/hooks/useCombinedRuleNamespaces.ts":(e,t,a)=>{a.d(t,{Z:()=>o});var n=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),s=a("./public/app/features/alerting/unified/utils/datasource.ts"),r=a("./public/app/features/alerting/unified/utils/rules.ts"),i=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts");function o(e){const t=(0,i._)((e=>e.promRules)),a=(0,i._)((e=>e.rulerRules)),o=(0,n.useRef)({}),c=(0,n.useMemo)((()=>{if(e){const t=(0,s.o_)(e);if(!t)throw new Error(`Unknown rules source: ${e}`);return[t]}return(0,s.h_)()}),[e]);return(0,n.useMemo)((()=>c.map((e=>{var n,i;const c=(0,s.jq)(e)?e.name:e,u=null===(n=t[c])||void 0===n?void 0:n.result,d=null===(i=a[c])||void 0===i?void 0:i.result,p=o.current[c];if(p&&p.promRules===u&&p.rulerRules===d)return p.result;const m={};Object.entries(d||{}).forEach((t=>{let[a,n]=t;const s={rulesSource:e,name:a,groups:[]};m[a]=s,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,r.cG)(e)?{name:e.alert,query:e.expr,labels:e.labels||{},annotations:e.annotations||{},rulerRule:e,namespace:t,group:a}:(0,r.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}))}(s,n)})),null==u||u.forEach((t=>{let{name:a,groups:n}=t;!function(e,t){t.forEach((t=>{var a;let n=e.groups.find((e=>e.name===t.name));n||(n={name:t.name,rules:[]},e.groups.push(n)),(null!==(a=t.rules)&&void 0!==a?a:[]).forEach((t=>{const a=function(e,t,a){var n;if((0,s.HY)(a))return t.rules.find((t=>t.name===e.name));return null!==(n=t.rules.find((t=>!t.promRule&&l(t,e,!0))))&&void 0!==n?n:t.rules.find((t=>!t.promRule&&l(t,e,!1)))}(t,n,e.rulesSource);a?a.promRule=t:n.rules.push(function(e,t,a){return{name:e.name,query:e.query,labels:e.labels||{},annotations:(0,r.x_)(e)&&e.annotations||{},promRule:e,namespace:t,group:a}}(t,e,n))}))}))}(m[a]=m[a]||{rulesSource:e,name:a,groups:[]},n)}));const f=Object.values(m);return(0,s.HY)(e)&&f.forEach((e=>{e.groups=[{name:"default",rules:e.groups.flatMap((e=>e.rules)).sort(((e,t)=>e.name.localeCompare(t.name)))}]})),o.current[c]={promRules:u,rulerRules:d,result:f},f})).flat()),[t,a,c])}function l(e,t){let a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.name===t.name&&JSON.stringify([a?c(e.query):"",e.labels,e.annotations])===JSON.stringify([a?c(t.query):"",t.labels||{},(0,r.x_)(t)&&t.annotations||{}])}function c(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/useFolder.ts":(e,t,a)=>{a.d(t,{W:()=>l});var 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"),s=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts"),r=a("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),i=a("./public/app/features/alerting/unified/state/actions.ts"),o=a("./public/app/features/alerting/unified/utils/redux.ts");function l(e){const t=(0,n.useDispatch)(),a=(0,s._)((e=>e.folders));if((0,r.useEffect)((()=>{e&&t((0,i.sw)(e))}),[t,e]),e){const t=a[e]||o.oq;return{folder:t.result,loading:t.loading}}return{loading:!1}}},"./public/app/features/alerting/unified/hooks/useIsRuleEditable.ts":(e,t,a)=>{a.d(t,{M:()=>d});var n=a("./public/app/core/services/context_srv.ts"),s=a("./public/app/features/alerting/unified/utils/rules.ts"),r=a("./public/app/features/alerting/unified/hooks/useFolder.ts"),i=a("./public/app/features/alerting/unified/hooks/useUnifiedAlertingSelector.ts"),o=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("../../opt/drone/yarncache/react-npm-17.0.2-99ba37d931-b254cc17ce.zip/node_modules/react/index.js"),c=a("./public/app/features/alerting/unified/state/actions.ts"),u=a("./public/app/features/alerting/unified/utils/datasource.ts");function d(e,t){var a,d;const p=(0,i._)((e=>e.lotexSupportsRuleEditing)),m=(0,o.useDispatch)(),f=t&&(0,s.Pc)(t)?t.grafana_alert.namespace_uid:void 0,{folder:g,loading:h}=(0,r.W)(f);if((0,l.useEffect)((()=>{void 0===p[e]&&e!==u.GC&&m((0,c.Yb)(e))}),[e,p,m]),!t)return{isEditable:!1,loading:!1};if((0,s.Pc)(t)){if(!f)throw new Error(`Rule ${t.grafana_alert.title} does not have a folder uid, cannot determine if it is editable.`);return{isEditable:null==g?void 0:g.canSave,loading:h}}return{isEditable:n.Vt.isEditor&&!(null===(a=p[e])||void 0===a||!a.result),loading:!(null===(d=p[e])||void 0===d||!d.loading)}}}}]);
//# sourceMappingURL=4282.cd4ada1146b53ad3284f.js.map