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