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