import{ap as u,aq as l,ar as d,r as f,as as m,am as p}from"./index-DlNZgIG9.js";import{p as I}from"./notificationSound-XZEPjESV.js";const y=()=>{var i;const c=u(),n=l(e=>{var r,t;return(t=(r=e==null?void 0:e.user)==null?void 0:r.data)==null?void 0:t.userId}),{data:a}=d({}),s=((i=a==null?void 0:a.userProfileDTO)==null?void 0:i.userReferenceId)??n;f.useEffect(()=>{if(!s)return;const e=`${m}/erp-crm/v1/notifications/stream?userId=${s}`;let r=null;try{r=new EventSource(e)}catch{return}return r.onmessage=t=>{try{const o=JSON.parse(t.data);if((o==null?void 0:o.type)==="PING")return}catch{}c(p.util.invalidateTags(["Notification","SalesTask"])),I()},r.onerror=()=>{},()=>{r==null||r.close()}},[s,c])};export{y as u};
