import{r as s}from"./index-ukWRVZhT.js";const l=s.createContext(new Map);l.Provider;function m(u,{event:o="message",init:t}={}){let r=s.useContext(l),[d,a]=s.useState(null);return s.useEffect(()=>{let n=[u.toString(),o,t==null?void 0:t.withCredentials].join("::"),e=r.get(n)??{count:0,source:new EventSource(u,t)};++e.count,r.set(n,e),e.source.addEventListener(o,c),a(null);function c(E){a(E.data||"UNKNOWN_EVENT_DATA")}return()=>{e.source.removeEventListener(o,c),--e.count,e.count<=0&&(e.source.close(),r.delete(n))}},[u,o,t,r]),d}export{m as u};
//# sourceMappingURL=use-event-source-LFD5QCNy.js.map
