import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,vt as n}from"./mui-BgU4WrXF.js";import{n as r}from"./MenuItem-BNgF7Xqv.js";import{n as i,t as a}from"./SearchHeader-CjrB_H_O.js";import{t as o}from"./TableHead-DZPVxfXH.js";import{St as s,Y as c,dt as l,pt as u,st as d,vt as f,w as p,wt as m,xt as h,z as g}from"./index-bel1r0Sr.js";import{t as _}from"./CollectionActions-Be6ZPRyC.js";import{t as v}from"./TableShimmer-CBuxG-nx.js";import{n as y,t as b}from"./useSettingsStyles-Bugi6oTj.js";var x=e(t(),1),S=n(),C=()=>{let{classes:e}=b(),t=u(),[n,C]=(0,x.useReducer)(e=>e+1,0),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(!0),A=(0,x.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});E&&n.append(`keyword`,E);let r=await(await p(`/api/notifications?${n.toString()}`,{signal:t})).json();T(t=>e?[...t,...r]:r),k(r.length>=50)},[E]),j=l(()=>A(w.length));d(async({signal:e})=>{T([]),await A(0,e)},[n,A]);let M=(e,n)=>n?n.split(/[, ]+/).filter(Boolean).map(n=>t(c(e,n))).join(`, `):``;return(0,S.jsxs)(r,{menu:(0,S.jsx)(y,{}),breadcrumbs:[`settingsTitle`,`sharedNotifications`],children:[(0,S.jsx)(a,{keyword:E,setKeyword:D}),(0,S.jsxs)(m,{className:e.table,children:[(0,S.jsx)(o,{children:(0,S.jsxs)(f,{children:[(0,S.jsx)(h,{children:t(`sharedDescription`)}),(0,S.jsx)(h,{children:t(`notificationType`)}),(0,S.jsx)(h,{children:t(`notificationAlways`)}),(0,S.jsx)(h,{children:t(`sharedAlarms`)}),(0,S.jsx)(h,{children:t(`notificationNotificators`)}),(0,S.jsx)(h,{className:e.columnAction})]})}),(0,S.jsxs)(s,{children:[w.map(n=>(0,S.jsxs)(f,{children:[(0,S.jsx)(h,{children:n.description}),(0,S.jsx)(h,{children:t(c(`event`,n.type))}),(0,S.jsx)(h,{children:g(n.always,t)}),(0,S.jsx)(h,{children:M(`alarm`,n.attributes.alarms)}),(0,S.jsx)(h,{children:M(`notificator`,n.notificators)}),(0,S.jsx)(h,{className:e.columnAction,padding:`none`,children:(0,S.jsx)(_,{itemId:n.id,editPath:`/settings/notification`,endpoint:`notifications`,onReload:C})})]},n.id)),O&&(0,S.jsx)(v,{ref:w.length>0?j:null,columns:5,endAction:!0})]})]}),(0,S.jsx)(i,{editPath:`/settings/notification`})]})};export{C as default};