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