"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4140],{748:(w,j,s)=>{s.r(j),s.d(j,{NotificationsPage:()=>R,default:()=>Q});var i=s(74848),I=s(54122),f=s(22803),T=s(96540),A=s(94701),M=s(29675),Y=s(59830),z=s(37e3),X=s(81942),F=s(54594),Z=s(52365),E=s(75156),P=s(92516),C=s(1108),$=s(5305),H=s(96054),g=s(61501),G=s(75930),K=s(91349);function W(e,c,r){const d=(0,P.q)(),a=r?.locale??d.locale??E.c,y=2520,l=(0,H.z)(e,c);if(isNaN(l))throw new RangeError("Invalid time value");const n=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:l}),[m,h]=(0,$.x)(r?.in,...l>0?[c,e]:[e,c]),t=(0,K.O)(h,m),x=((0,C.G)(h)-(0,C.G)(m))/1e3,o=Math.round((t-x)/60);let p;if(o<2)return r?.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 u=Math.round(o/60);return a.formatDistance("aboutXHours",u,n)}else{if(o<y)return a.formatDistance("xDays",1,n);if(o<g.Nw){const u=Math.round(o/g.F6);return a.formatDistance("xDays",u,n)}else if(o<g.Nw*2)return p=Math.round(o/g.Nw),a.formatDistance("aboutXMonths",p,n)}if(p=(0,G.W)(h,m),p<12){const u=Math.round(o/g.Nw);return a.formatDistance("xMonths",u,n)}else{const u=p%12,S=Math.trunc(p/12);return u<3?a.formatDistance("aboutXYears",S,n):u<9?a.formatDistance("overXYears",S,n):a.formatDistance("almostXYears",S+1,n)}}const b=null;function B(e,c){return W(e,(0,Z.A)(e),c)}const k=null;var v=s(6210);const U=({children:e,className:c,isSelected:r,onClick:d,severity:a="error",title:y,traceId:l,timestamp:n})=>{const m=(0,M.$j)(),h=V(m);return(0,i.jsxs)(v.Z,{className:c,onClick:d,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)(X.S,{onChange:d,tabIndex:-1,value:r})}),(0,i.jsxs)(v.Z.Tags,{className:h.trace,children:[l&&(0,i.jsx)("span",{children:`Trace ID: ${l}`}),n&&B(n,{addSuffix:!0})]})]})},V=e=>({trace:(0,f.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 O=s(11817),D=s(80847),N=s(61491);function J(){const e=(0,N.useDispatch)(),c=(0,N.useSelector)(t=>(0,D.qN)(t.appNotifications)),[r,d]=(0,T.useState)([]),a=c.every(t=>r.includes(t.id)),y=(0,T.useRef)((0,N.useSelector)(t=>(0,D.$K)(t.appNotifications))),l=(0,M.of)(L);(0,A.A)(()=>{e((0,D.oF)(Date.now()))});const n=()=>{a?e((0,D.XC)()):r.forEach(t=>{e((0,D.XR)(t))}),d([])},m=t=>{d(t?c.map(x=>x.id):[])},h=t=>{d(x=>x.includes(t)?x.filter(o=>o!==t):[...x,t])};return c.length===0?(0,i.jsx)(Y.p,{variant:"completed",message:(0,O.t)("notifications.empty-state.title","You're all caught up!"),children:(0,i.jsx)(O.x6,{i18nKey:"notifications.empty-state.description",children:"Notifications you have received will appear here"})}):(0,i.jsxs)("div",{className:l.wrapper,children:[(0,i.jsx)(z.F,{severity:"info",title:"This page displays past errors and warnings. Once dismissed, they cannot be retrieved."}),(0,i.jsxs)("div",{className:l.topRow,children:[(0,i.jsx)(X.S,{value:a,onChange:t=>m(t.target.checked)}),(0,i.jsx)(F.$n,{disabled:r.length===0,onClick:n,children:"Dismiss notifications"})]}),(0,i.jsx)("ul",{className:l.list,children:c.map(t=>(0,i.jsx)("li",{className:l.listItem,children:(0,i.jsx)(U,{className:(0,f.cx)({[l.newItem]:t.timestamp>y.current}),isSelected:r.includes(t.id),onClick:()=>h(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 L(e){return{topRow:(0,f.css)({alignItems:"center",display:"flex",gap:e.spacing(2)}),list:(0,f.css)({display:"flex",flexDirection:"column"}),listItem:(0,f.css)({alignItems:"center",display:"flex",gap:e.spacing(2),listStyle:"none",position:"relative"}),newItem:(0,f.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,f.css)({display:"flex",flexDirection:"column",alignItems:"center",gap:e.spacing(1)}),wrapper:(0,f.css)({display:"flex",flexDirection:"column",gap:e.spacing(2)})}}const R=()=>(0,i.jsx)(I.Y,{navId:"profile/notifications",children:(0,i.jsx)(I.Y.Contents,{children:(0,i.jsx)(J,{})})}),Q=R}}]);

//# sourceMappingURL=NotificationsPage.4a5a0fe2562e8ae70146.js.map