"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[0],{46913:(I,g,e)=>{e.d(g,{A:()=>t});var o=e(96540);function E({children:n,shouldWrap:c,wrap:f},v){return c?o.cloneElement(f(n)):n}const t=(0,o.forwardRef)(E)},26423:(I,g,e)=>{e.d(g,{Pc:()=>c,WG:()=>v,uz:()=>p});var o=e(17172),E=e(37534),t=e(99494),n=e(49962);const c="grafana_alerting_v2",f=l=>`/api/plugin-proxy/${t.W.OnCall}${l}`,v=n.H.injectEndpoints({endpoints:l=>({grafanaOnCallIntegrations:l.query({query:()=>({url:f("/api/internal/v1/alert_receive_channels/"),params:{filters:!0,integration:[E.FI,"legacy_grafana_alerting"],skip_pagination:!0},showErrorAlert:!1}),transformResponse:u=>A(u)?u.results:u,providesTags:["OnCallIntegrations"]}),validateIntegrationName:l.query({query:u=>({url:f("/api/internal/v1/alert_receive_channels/validate_name/"),params:{verbal_name:u},showErrorAlert:!1})}),createIntegration:l.mutation({query:u=>({url:f("/api/internal/v1/alert_receive_channels/"),data:u,method:"POST",showErrorAlert:!0}),invalidatesTags:["OnCallIntegrations"]}),features:l.query({query:()=>({url:f("/api/internal/v1/features/"),showErrorAlert:!1})})})});function A(l){return"results"in l&&Array.isArray(l.results)}const{useGrafanaOnCallIntegrationsQuery:D}=v;function p(l){return(0,o.NF)(l)&&"detail"in l.data}},64853:(I,g,e)=>{e.d(g,{_:()=>c});var o=e(2543),E=e.n(o),t=e(96540),n=e(19073);const c=({actions:l,children:u})=>{const h=(0,o.filter)(l,D),P=(0,o.filter)(l,p);return h.length?t.createElement(f,{actions:h},u):P.length?t.createElement(v,{actions:P},u):null},f=({actions:l,children:u})=>{const h=(0,n.iI)();return A(h,l)?t.createElement(t.Fragment,null,u):null},v=({actions:l,children:u})=>{const h=(0,n.e2)();return A(h,l)?t.createElement(t.Fragment,null,u):null};function A(l,u){return(0,o.chain)(l).pick(u).values().value().some(([h,P])=>P===!0)}function D(l){return Object.values(n.QI).includes(l)}function p(l){return Object.values(n.RY).includes(l)}},57895:(I,g,e)=>{e.d(g,{M:()=>A});var o=e(32196),E=e(96540),t=e(40845),n=e(42418),c=e(60021),f=e(82843),v=e(57220);function A({currentAlertmanager:p}){const l=(0,t.of)(D),u=p===v.hY,{currentData:h}=f.m.endpoints.getAlertmanagerChoiceStatus.useQuery(void 0,{skip:!u});if(!(h?.alertmanagersChoice&&[c.nA.External,c.nA.All].includes(h?.alertmanagersChoice))||!u)return null;const T=h.numExternalAlertmanagers>0;return h.alertmanagersChoice===c.nA.External?E.createElement(n.F,{title:"Grafana alerts are not delivered to Grafana Alertmanager"},"Grafana is configured to send alerts to external Alertmanagers only. Changing Grafana Alertmanager configuration will not affect delivery of your alerts.",E.createElement("div",{className:l.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):h.alertmanagersChoice===c.nA.All&&T?E.createElement(n.F,{title:"You have additional Alertmanagers to configure",severity:"warning"},"Ensure you make configuration changes in the correct Alertmanagers; both internal and external. Changing one will not affect the others.",E.createElement("div",{className:l.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):null}const D=p=>({adminHint:(0,o.css)`
    font-size: ${p.typography.bodySmall.fontSize};
    font-weight: ${p.typography.bodySmall.fontWeight};
  `})},94855:(I,g,e)=>{e.d(g,{O:()=>t});var o=e(96540),E=e(40845);const t=({children:n})=>{const c=(0,E.$j)();return o.createElement("strong",{style:{color:c.colors.text.primary}},n)}},16293:(I,g,e)=>{e.d(g,{J:()=>h});var o=e(32196),E=e(4213),t=e.n(E),n=e(96540),c=e(70713),f=e(40845),v=e(32372),A=e(55852),D=e(10534),p=e(72109),l=e(42418),u=e(84029);function h({format:y,textDefinition:a,downloadFileName:r,onClose:i}){const s=(0,f.of)(P),m=u.sl[y],d=(0,n.useCallback)(()=>{const _=new Blob([a],{type:`application/${y};charset=utf-8`});t()(_,`${r}.${y}`)},[a,r,y]),O=(0,n.useMemo)(()=>m.formatter?m.formatter(a):a,[m,a]);return n.createElement("div",{className:s.container},n.createElement(T,{exportProvider:m}),n.createElement("div",{className:s.content},n.createElement(c.Ay,{disableWidth:!0},({height:_})=>n.createElement(v.B,{width:"100%",height:_,language:y,value:O,monacoOptions:{minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:!0}}))),n.createElement("div",{className:s.actions},n.createElement(A.$n,{variant:"secondary",onClick:i},"Cancel"),n.createElement(D.b,{icon:"copy",getText:()=>a},"Copy code"),n.createElement(A.$n,{icon:"download-alt",onClick:d},"Download")))}const P=y=>({container:(0,o.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${y.spacing(2)};
  `,content:(0,o.css)`
    flex: 1 1 100%;
  `,actions:(0,o.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${y.spacing(1)};
  `});function T({exportProvider:y}){const{name:a,type:r}=y,i={file:{title:"File-provisioning format",component:n.createElement(n.Fragment,null,a," format is only valid for File Provisioning."," ",n.createElement(p.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:n.createElement(n.Fragment,null,a," format is only valid for API Provisioning."," ",n.createElement(p.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:n.createElement(n.Fragment,null,a," format is only valid for Terraform Provisioning."," ",n.createElement(p.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/terraform-provisioning/",external:!0},"Read more in the docs."))}},{title:s,component:m}=i[r];return n.createElement(l.F,{title:s,severity:"info",bottomSpacing:0,topSpacing:0},m)}},76648:(I,g,e)=>{e.d(g,{m:()=>n});var o=e(96540),E=e(87978),t=e(73716);function n({activeTab:c,onTabChange:f,children:v,onClose:A,formatProviders:D,title:p="Export"}){const l=Object.values(D).map(u=>({label:u.name,value:u.exportFormat}));return o.createElement(E._,{title:p,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:o.createElement(t.sb,{tabs:l,setActiveTab:f,activeTab:c}),onClose:A,size:"md"},v)}},84029:(I,g,e)=>{e.d(g,{sl:()=>n});const o={name:"JSON",exportFormat:"json",type:"file",formatter:f=>{try{return JSON.stringify(JSON.parse(f),null,4)}catch{return f}}},E={name:"YAML",exportFormat:"yaml",type:"file"},t={name:"Terraform (HCL)",exportFormat:"hcl",type:"terraform"},n={[o.exportFormat]:o,[E.exportFormat]:E,[t.exportFormat]:t},c=[o,E]},37534:(I,g,e)=>{e.d(g,{FI:()=>o,J4:()=>E,p8:()=>n});const o="grafana_alerting";var E=(c=>(c.OnCall="oncall",c))(E||{});const t=(c,f)=>f.includes(c),n=(c,f)=>{if(!c.grafana_managed_receiver_configs)return!1;const v=c.grafana_managed_receiver_configs.length===1,A=t(c.grafana_managed_receiver_configs[0]?.settings?.url??"",f.map(D=>D.integration_url));return v&&A}},73716:(I,g,e)=>{e.d(g,{G_:()=>a,sb:()=>r});var o=e(32196),E=e(20382),t=e(96540),n=e(49785),c=e(70713),f=e(40845),v=e(87978),A=e(63021),D=e(40675),p=e(55852),l=e(56034),u=e(14578),h=e(32372),P=e(63066),T=e(23662);const y=[{label:"Yaml",value:"yaml"}],a=({onClose:_})=>{const[M,C]=(0,t.useState)("yaml"),{setValue:R}=(0,n.xW)(),L=(0,f.of)(O),K=B=>{for(const W in B)R(W,B[W]);_()};return t.createElement(v._,{title:"Inspect Alert rule",subtitle:t.createElement("div",{className:L.subtitle},t.createElement(r,{tabs:y,setActiveTab:C,activeTab:M})),onClose:_},M==="yaml"&&t.createElement(i,{onSubmit:K}))};function r({tabs:_,activeTab:M,setActiveTab:C}){return t.createElement(A.U,null,_.map((R,L)=>t.createElement(D.o,{key:`${R.value}-${L}`,label:R.label,value:R.value,onChangeTab:()=>C(R.value),active:M===R.value})))}const i=({onSubmit:_})=>{const M=(0,f.of)(d),{getValues:C}=(0,n.xW)(),R=(0,P.l1)(C()),[L,K]=(0,t.useState)((0,E.Bh)(R)),B=()=>{const W=(0,E.Hh)(L),U=C(),x=m(W);_({...U,...x})};return t.createElement(t.Fragment,null,t.createElement("div",{className:M.applyButton},t.createElement(p.$n,{type:"button",onClick:B},"Apply"),t.createElement(l.m,{content:t.createElement(s,null),theme:"info",placement:"left-start",interactive:!0},t.createElement(u.I,{name:"exclamation-triangle",size:"xl"}))),t.createElement("div",{className:M.content},t.createElement(c.Ay,{disableWidth:!0},({height:W})=>t.createElement(h.B,{width:"100%",height:W,language:"yaml",value:L,onBlur:K,monacoOptions:{minimap:{enabled:!1}}}))))};function s(){return t.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",t.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",t.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function m(_){return(0,T.$y)(_)?(0,P.Qk)(_):(0,T.i7)(_)?(0,P.XI)(_):{}}const d=_=>({content:(0,o.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${_.spacing(2)};
  `,applyButton:(0,o.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${_.spacing(2)};
  `}),O=()=>({subtitle:(0,o.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},19645:(I,g,e)=>{e.d(g,{M:()=>o});const o={discord:"discord",email:"envelope",googlechat:"google-hangouts-alt",hipchat:"hipchat",line:"line",pagerduty:"pagerduty",slack:"slack",teams:"microsoft",telegram:"telegram-alt",webhook:"link",sns:"amazon"}},79581:(I,g,e)=>{e.d(g,{W$:()=>u,_I:()=>h,rJ:()=>D});var o=e(2543),E=e.n(o),t=e(60021),n=e(32642);const c=["receiver","group_by","group_wait","group_interval","repeat_interval"];function f(a,r){const i=v(a,r),s=new Map(r.map(m=>[m,{match:!1,matcher:null}]));return a.forEach(m=>{const d=r.find(O=>y(m,O));d&&s.set(d,{match:!0,matcher:m})}),{matches:i,labelsMatch:s}}function v(a,r){for(const i of a)if(!T(i,r))return!1;return!0}function A(a,r){let i=[];const s=f(a.object_matchers??[],r);if(!s.matches)return[];if(a.routes)for(const m of a.routes){let d=A(m,r);if(i=i.concat(d),d.length&&!m.continue)break}return i.length===0&&i.push({route:a,labelsMatch:s.labelsMatch}),i}function D(a){function r(s){s.object_matchers=(0,n.J$)(s),delete s.matchers,delete s.match,delete s.match_re,s.routes?.forEach(r)}const i=structuredClone(a);return r(i),i}function p(a){function r(s){s.object_matchers=s.object_matchers?.map(([m,d,O])=>[m,d,unquoteWithUnescape(O)]),s.routes?.forEach(r)}const i=structuredClone(a);return r(i),i}function l(a,r,i){const s=[];return i.reduce((m,d)=>{const O=d.alerts.filter(_=>{const M=Object.entries(_.labels);return A(a,M).some(C=>C.route===r)});return O.length&&m.push({...d,alerts:O}),m},s)}function u(a,r,i){const m={...(0,o.pick)(a,c),...i};return(0,o.reduce)(m,(O,_,M)=>{const C=_!=null,K=[void 0,"",null].some(U=>r[M]===U)&&C,B=M==="group_by"&&C&&(0,o.isArray)(r[M])&&r[M]?.length===0;return(K||B)&&(O[M]=_),O},{})}function h(a){return{...a,routes:a.routes?.map(r=>{const i=u(a,r);return h({...r,...i})})}}const P={[t.ho.equal]:(a,r)=>a===r,[t.ho.notEqual]:(a,r)=>a!==r,[t.ho.regex]:(a,r)=>new RegExp(r).test(a),[t.ho.notRegex]:(a,r)=>!new RegExp(r).test(a)};function T(a,r){const[i,s,m]=a;let d="";const O=Object.fromEntries(r)[i];O&&(d=O);const _=P[s];if(!_)throw new Error(`no such operator: ${s}`);return _(d,m)}function y(a,r){let[i,s]=r;const[m,d,O]=a;if(i!==m)return!1;const _=P[d];if(!_)throw new Error(`no such operator: ${d}`);return _(s,O)}}}]);

//# sourceMappingURL=0.c88fc16b6533c8976681.js.map