const e=e=>null==e,n=e=>void 0===e,t=((n=e)=>(e,t,s)=>n(e)?s?.():t(e))(n),s=(e,n,t)=>e.slice(n,t),o=(e,n)=>e?.delete(n),c=Object.freeze,r=e=>new Map(e),a=(e,n)=>e?.get(n),d=(e,n,t)=>void 0===t?(o(e,n),e):e?.set(n,t),l=/\/([^?]*)/,i=e=>{const i=r();return e.on("connection",(e,c)=>{return t((u=c.url,v=l,u?.match(v)),([,l])=>t(c.headers["sec-websocket-key"],async t=>{const c=(f=r,g=u=i,h=v=l,g?.has(h)||d(u,v,f()),a(u,v));var u,v,f,g,h;d(c,t,e),e.on("message",e=>(e=>{const n=e.indexOf("\n");-1!==n&&((e,n)=>{const s=((e,n)=>e+"\n"+n)(t,n);""===e?(e=>{((e,n)=>{e?.forEach(n)})(e,(e,n)=>{return o=e,n!==t?o.send(s):0;var o})})(c):a(c,e)?.send(s)})(s(e,0,n),s(e,n+1))})(e.toString("utf8"))),e.on("close",()=>{o(c,t),(e=>n(e)||0==(e=>e?.size??0)(e))(c)&&o(i,l)})}));var u,v}),c({getWebSocketServer:()=>e,destroy:async()=>{i.clear(),e.close()}})};export{i as createWsServerSimple};
