"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4140],{78015:(w,I,s)=>{s.r(I),s.d(I,{NotificationsPage:()=>A,default:()=>Q});var i=s(74848),T=s(21780),u=s(32196),M=s(96540),Y=s(94701),X=s(40845),z=s(69529),F=s(42418),C=s(10880),Z=s(55852),E=s(30284),P=s(25733),g=s(2940),W=s(81929),$=s(43924),N=s(2642),H=s(96519),G=s(82695),O=s(40215);function K(e,c,l){const m=(0,G.q)(),a=l?.locale??m.locale??H.c,y=2520,r=(0,P.z)(e,c);if(isNaN(r))throw new RangeError("Invalid time value");const n=Object.assign({},l,{addSuffix:l?.addSuffix,comparison:r});let f,d;r>0?(f=(0,N.a)(c),d=(0,N.a)(e)):(f=(0,N.a)(e),d=(0,N.a)(c));const t=(0,$.O)(d,f),x=((0,O.G)(d)-(0,O.G)(f))/1e3,o=Math.round((t-x)/60);let p;if(o<2)return l?.includeSeconds?t<5?a.formatDistance("lessThanXSeconds",5,n):t<10?a.formatDistance("lessThanXSeconds",10,n):t<20?a.formatDistance("lessThanXSeconds",20,n):t<40?a.formatDistance("halfAMinute",0,n):t<60?a.formatDistance("lessThanXMinutes",1,n):a.formatDistance("xMinutes",1,n):o===0?a.formatDistance("lessThanXMinutes",1,n):a.formatDistance("xMinutes",o,n);if(o<45)return a.formatDistance("xMinutes",o,n);if(o<90)return a.formatDistance("aboutXHours",1,n);if(o<g.F6){const h=Math.round(o/60);return a.formatDistance("aboutXHours",h,n)}else{if(o<y)return a.formatDistance("xDays",1,n);if(o<g.Nw){const h=Math.round(o/g.F6);return a.formatDistance("xDays",h,n)}else if(o<g.Nw*2)return p=Math.round(o/g.Nw),a.formatDistance("aboutXMonths",p,n)}if(p=(0,W.W)(d,f),p<12){const h=Math.round(o/g.Nw);return a.formatDistance("xMonths",h,n)}else{const h=p%12,j=Math.trunc(p/12);return h<3?a.formatDistance("aboutXYears",j,n):h<9?a.formatDistance("overXYears",j,n):a.formatDistance("almostXYears",j+1,n)}}const b=null;function B(e,c){return K(e,(0,E.A)(e),c)}const k=null;var v=s(10860);const L=({children:e,className:c,isSelected:l,onClick:m,severity:a="error",title:y,traceId:r,timestamp:n})=>{const f=(0,X.$j)(),d=U(f);return(0,i.jsxs)(v.Z,{className:c,onClick:m,children:[(0,i.jsx)(v.Z.Heading,{children:y}),(0,i.jsx)(v.Z.Description,{children:e}),(0,i.jsx)(v.Z.Figure,{children:(0,i.jsx)(C.S,{onChange:m,tabIndex:-1,value:l})}),(0,i.jsxs)(v.Z.Tags,{className:d.trace,children:[r&&(0,i.jsx)("span",{children:`Trace ID: ${r}`}),n&&B(n,{addSuffix:!0})]})]})},U=e=>({trace:(0,u.css)({alignItems:"flex-end",alignSelf:"flex-end",color:e.colors.text.secondary,display:"flex",flexDirection:"column",fontSize:e.typography.pxToRem(10),justifySelf:"flex-end"})});var R=s(8484),D=s(16001),S=s(31678);function V(){const e=(0,S.useDispatch)(),c=(0,S.useSelector)(t=>(0,D.qN)(t.appNotifications)),[l,m]=(0,M.useState)([]),a=c.every(t=>l.includes(t.id)),y=(0,M.useRef)((0,S.useSelector)(t=>(0,D.$K)(t.appNotifications))),r=(0,X.of)(J);(0,Y.A)(()=>{e((0,D.oF)(Date.now()))});const n=()=>{a?e((0,D.XC)()):l.forEach(t=>{e((0,D.XR)(t))}),m([])},f=t=>{m(t?c.map(x=>x.id):[])},d=t=>{m(x=>x.includes(t)?x.filter(o=>o!==t):[...x,t])};return c.length===0?(0,i.jsx)(z.p,{variant:"completed",message:(0,R.t)("notifications.empty-state.title","You're all caught up!"),children:(0,i.jsx)(R.x6,{i18nKey:"notifications.empty-state.description",children:"Notifications you have received will appear here"})}):(0,i.jsxs)("div",{className:r.wrapper,children:[(0,i.jsx)(F.F,{severity:"info",title:"This page displays past errors and warnings. Once dismissed, they cannot be retrieved."}),(0,i.jsxs)("div",{className:r.topRow,children:[(0,i.jsx)(C.S,{value:a,onChange:t=>f(t.target.checked)}),(0,i.jsx)(Z.$n,{disabled:l.length===0,onClick:n,children:"Dismiss notifications"})]}),(0,i.jsx)("ul",{className:r.list,children:c.map(t=>(0,i.jsx)("li",{className:r.listItem,children:(0,i.jsx)(L,{className:(0,u.cx)({[r.newItem]:t.timestamp>y.current}),isSelected:l.includes(t.id),onClick:()=>d(t.id),severity:t.severity,title:t.title,timestamp:t.timestamp,traceId:t.traceId,children:(0,i.jsx)("span",{children:t.text})})},t.id))})]})}function J(e){return{topRow:(0,u.css)({alignItems:"center",display:"flex",gap:e.spacing(2)}),list:(0,u.css)({display:"flex",flexDirection:"column"}),listItem:(0,u.css)({alignItems:"center",display:"flex",gap:e.spacing(2),listStyle:"none",position:"relative"}),newItem:(0,u.css)({"&::before":{content:'""',height:"100%",position:"absolute",left:"-7px",top:0,background:e.colors.gradients.brandVertical,width:e.spacing(.5),borderRadius:e.shape.radius.default}}),noNotifsWrapper:(0,u.css)({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1)}),wrapper:(0,u.css)({display:"flex",flexDirection:"column",gap:e.spacing(2)})}}const A=()=>(0,i.jsx)(T.YW,{navId:"profile/notifications",children:(0,i.jsx)(T.YW.Contents,{children:(0,i.jsx)(V,{})})}),Q=A}}]);

//# sourceMappingURL=NotificationsPage.03c1e47574b39674c2fc.js.map