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

//# sourceMappingURL=NotificationsPage.d26b90d7348139106351.js.map