mod.jsvar m="4.2.0",f=`https://cdnjs.cloudflare.com/ajax/libs/socket.io/${m}/socket.io.min.js`,u;async function v(){let o=(await l())("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]});return await new Promise((n,s)=>{let r=i=>s(i);o.once("connect",()=>{o.off("disconnect",r),n()}),o.once("disconnect",r)}),o}async function l(){if(!document.querySelector(`script[src="${f}"]`)){let e=document.createElement("script");e.src=f,await new Promise((o,n)=>{e.onload=()=>o(),e.onerror=s=>{u=s,n(s)},document.head.append(e)})}return new Promise((e,o)=>{let n=setInterval(()=>{window.io&&(clearInterval(n),e(window.io))},500)})}function w(e,o=9e4){function n(r,i){let c;return new Promise((d,t)=>{let p=a=>{clearTimeout(c),t(new Error(a))};e.emit(r,i,a=>{clearTimeout(c),e.off("disconnect",p),a.error&&t(new Error(JSON.stringify(a.error))),"data"in a?d(a?.data):d(void 0)}),c=setTimeout(()=>{e.off("disconnect",p),t(new Error(`Timeout: exceeded ${o}ms`))},o),e.once("disconnect",p)})}async function*s(...r){let i,c=()=>new Promise(t=>i=t),d=t=>{i?.(t)};for(let t of r)e.on(t,d);try{for(;;)yield await c()}finally{for(let t of r)e.off(t,d)}}return{request:n,response:s}}export{v as socketIO,w as wrap};