script.jsvar kr=Object.defineProperty;var Or=(e,t)=>{for(var r in t)kr(e,r,{get:t[r],enumerable:!0})};function se(e){return Array.isArray(e)}function B(e){return typeof e=="string"}var nt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError(`"${t}" must be HTMLDivElememt but actual is "${e}"`)};var st=()=>wr(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),wr=(e,t)=>{if(e)return nt(e,t),e};function X(e,t={}){let{signal:r,persistent:o=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((n,s)=>{let i=()=>{clearTimeout(c),s(r?.reason)},c=setTimeout(()=>{r?.removeEventListener("abort",i),n()},e);if(r?.addEventListener("abort",i,{once:!0}),o===!1)try{Deno.unrefTimer(c)}catch(d){if(!(d instanceof ReferenceError))throw d;console.error("`persistent` option is only available in Deno")}})}var it=()=>{let e=st();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=at(...r);o&&t.append(o)},dispose:()=>t.remove()}},at=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":return[Sr()];case"check-circle":return[Ir()];case"exclamation-triangle":return[Fr()];case"text":return[ae(o.text)];case"group":{let n=at(...o.items);return n?[n]:[]}}});if(t.length===0)return;if(t.length===1)return t[0];let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},ae=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Sr=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),ae(e)},Ir=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),ae(e)},Fr=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),ae(e)};var ve=e=>[...e].map((t,r)=>t===" "?"_":!Ur.includes(t)||r===e.length-1&&Br.includes(t)?encodeURIComponent(t):t).join(""),Ur='@$&+=:;",',Br=':;",';function E(e){if(e)return jr(e)}function jr(e){for(var t in E.prototype)e[t]=E.prototype[t];return e}E.prototype.on=E.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};E.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};E.prototype.off=E.prototype.removeListener=E.prototype.removeAllListeners=E.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var o,n=0;n<r.length;n++)if(o=r[n],o===t||o.fn===t){r.splice(n,1);break}return r.length===0&&delete this._callbacks["$"+e],this};E.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],o=1;o<arguments.length;o++)t[o-1]=arguments[o];if(r){r=r.slice(0);for(var o=0,n=r.length;o<n;++o)r[o].apply(this,t)}return this};E.prototype.emitReserved=E.prototype.emit;E.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};E.prototype.hasListeners=function(e){return!!this.listeners(e).length};var I=Object.create(null);I.open="0";I.close="1";I.ping="2";I.pong="3";I.message="4";I.upgrade="5";I.noop="6";var le=Object.create(null);Object.keys(I).forEach(e=>{le[I[e]]=e});var Me={type:"error",data:"parser error"},ut=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",mt=typeof ArrayBuffer=="function",dt=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ue=({type:e,data:t},r,o)=>ut&&t instanceof Blob?r?o(t):ct(t,o):mt&&(t instanceof ArrayBuffer||dt(t))?r?o(t):ct(new Blob([t]),o):o(I[e]+(t||"")),ct=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")[1];t("b"+(o||""))},r.readAsDataURL(e)};function pt(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Ce;function qr(e,t){if(ut&&e.data instanceof Blob)return e.data.arrayBuffer().then(pt).then(t);if(mt&&(e.data instanceof ArrayBuffer||dt(e.data)))return t(pt(e.data));ue(e,!1,r=>{Ce||(Ce=new TextEncoder),t(Ce.encode(r))})}var lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<lt.length;e++)J[lt.charCodeAt(e)]=e;var $r=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,a,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);let d=new ArrayBuffer(t),p=new Uint8Array(d);for(o=0;o<r;o+=4)s=J[e.charCodeAt(o)],i=J[e.charCodeAt(o+1)],a=J[e.charCodeAt(o+2)],c=J[e.charCodeAt(o+3)],p[n++]=s<<2|i>>4,p[n++]=(i&15)<<4|a>>2,p[n++]=(a&3)<<6|c&63;return d},Vr=typeof ArrayBuffer=="function",me=(e,t)=>{if(typeof e!="string")return{type:"message",data:ft(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:Wr(e.substring(1),t)}:le[r]?e.length>1?{type:le[r],data:e.substring(1)}:{type:le[r]}:Me},Wr=(e,t)=>{if(Vr){let r=$r(e);return ft(r,t)}else return{base64:!0,data:e}},ft=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},ht="",gt=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{ue(s,!1,a=>{o[i]=a,++n===r&&t(o.join(ht))})})},yt=(e,t)=>{let r=e.split(ht),o=[];for(let n=0;n<r.length;n++){let s=me(r[n],t);if(o.push(s),s.type==="error")break}return o};function Et(){return new TransformStream({transform(e,t){qr(e,r=>{let o=r.length,n;if(o<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,o);else if(o<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,o)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(o))}e.data&&typeof e.data!="string"&&(n[0]|=128),t.enqueue(n),t.enqueue(r)})}})}var Ae;function ce(e){return e.reduce((t,r)=>t+r.length,0)}function pe(e,t){if(e[0].length===t)return e.shift();let r=new Uint8Array(t),o=0;for(let n=0;n<t;n++)r[n]=e[0][o++],o===e[0].length&&(e.shift(),o=0);return e.length&&o<e[0].length&&(e[0]=e[0].slice(o)),r}function xt(e,t){Ae||(Ae=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(o===0){if(ce(r)<1)break;let c=pe(r,1);s=(c[0]&128)===128,n=c[0]&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(ce(r)<2)break;let c=pe(r,2);n=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),o=3}else if(o===2){if(ce(r)<8)break;let c=pe(r,8),d=new DataView(c.buffer,c.byteOffset,c.length),p=d.getUint32(0);if(p>Math.pow(2,21)-1){a.enqueue(Me);break}n=p*Math.pow(2,32)+d.getUint32(4),o=3}else{if(ce(r)<n)break;let c=pe(r,n);a.enqueue(me(s?c:Ae.decode(c),t)),o=0}if(n===0||n>e){a.enqueue(Me);break}}}})}var Se=4;var Z=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),L=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Gr="arraybuffer";function Rt(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(r[o]=e[o]),r),{})}var Kr=L.setTimeout,Yr=L.clearTimeout;function ee(e,t){t.useNativeTimers?(e.setTimeoutFn=Kr.bind(L),e.clearTimeoutFn=Yr.bind(L)):(e.setTimeoutFn=L.setTimeout.bind(L),e.clearTimeoutFn=L.clearTimeout.bind(L))}var zr=1.33;function Qr(e){return typeof e=="string"?Xr(e):Math.ceil((e.byteLength||e.size)*zr)}function Xr(e){let t=0,r=0;for(let o=0,n=e.length;o<n;o++)t=e.charCodeAt(o),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(o++,r+=4);return r}function Nt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Jr(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}function Zr(e){let t={},r=e.split("&");for(let o=0,n=r.length;o<n;o++){let s=r[o].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}var eo=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Ue=class extends E{constructor(e){super(),this.writable=!1,ee(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,r){return super.emitReserved("error",new eo(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=me(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=Jr(e);return t.length?"?"+t:""}},to=class extends Ue{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};yt(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,gt(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=Nt()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Tt=!1;try{Tt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var ro=Tt;function oo(){}var no=class extends to{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",r=location.port;r||(r=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(o,n)=>{this.onError("xhr post error",o,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},q=class de extends E{constructor(t,r,o){super(),this.createRequest=t,ee(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var t;let r=Rt(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&o.setRequestHeader(n,this._opts.extraHeaders[n])}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var n;o.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=de.requestsCount++,de.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=oo,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete de.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};q.requestsCount=0;q.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",bt);else if(typeof addEventListener=="function"){let e="onpagehide"in L?"pagehide":"unload";addEventListener(e,bt,!1)}}function bt(){for(let e in q.requests)q.requests.hasOwnProperty(e)&&q.requests[e].abort()}var so=function(){let e=_t({xdomain:!1});return e&&e.responseType!==null}(),Be=class extends no{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=so&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new q(_t,this.uri(),e)}};function _t(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||ro))return new XMLHttpRequest}catch{}if(!t)try{return new L[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var kt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",io=class extends Ue{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=kt?{}:Rt(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],o=t===e.length-1;ue(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}o&&Z(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Nt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Ie=L.WebSocket||L.MozWebSocket,De=class extends io{createSocket(e,t,r){return kt?new Ie(e,t,r):t?new Ie(e,t):new Ie(e)}doWrite(e,t){this.ws.send(t)}},Ot=class extends Ue{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=xt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),o=Et();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();let n=()=>{r.read().then(({done:i,value:a})=>{i||(this.onPacket(a),n())}).catch(i=>{})};n();let s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=e[t],o=t===e.length-1;this._writer.write(r).then(()=>{o&&Z(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},ao={websocket:De,webtransport:Ot,polling:Be},co=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,po=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ye(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf("["),o=e.indexOf("]");r!=-1&&o!=-1&&(e=e.substring(0,r)+e.substring(r,o).replace(/:/g,";")+e.substring(o,e.length));let n=co.exec(e||""),s={},i=14;for(;i--;)s[po[i]]=n[i]||"";return r!=-1&&o!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=lo(s,s.path),s.queryKey=uo(s,s.query),s}function lo(e,t){let r=/\/{2,9}/g,o=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&o.splice(0,1),t.slice(-1)=="/"&&o.splice(o.length-1,1),o}function uo(e,t){let r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(o,n,s){n&&(r[n]=s)}),r}var Fe=typeof addEventListener=="function"&&typeof removeEventListener=="function",fe=[];Fe&&addEventListener("offline",()=>{fe.forEach(e=>e())},!1);var he=class ge extends E{constructor(t,r){if(super(),this.binaryType=Gr,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){let o=ye(t);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=ye(r.host).host);ee(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{let n=o.prototype.name;this.transports.push(n),this._transportsByName[n]=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Zr(this.opts.query)),Fe&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},fe.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=Se,r.transport=t,this.id&&(r.sid=this.id);let o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&ge.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let r=this.createTransport(t);r.open(),this.setTransport(r)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",ge.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let r=new Error("server error");r.code=t.data,this._onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let o=this.writeBuffer[r].data;if(o&&(t+=Qr(o)),r>0&&t>this._maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Z(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,o){return this._sendPacket("message",t,r,o),this}send(t,r,o){return this._sendPacket("message",t,r,o),this}_sendPacket(t,r,o,n){if(typeof r=="function"&&(n=r,r=void 0),typeof o=="function"&&(n=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;let s={type:t,data:r,options:o};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():t()}):this.upgrading?o():t()),this}_onError(t){if(ge.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Fe&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=fe.indexOf(this._offlineEventListener);o!==-1&&fe.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};he.protocol=Se;var mo=class extends he{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),r=!1;he.priorWebsocketSuccess=!1;let o=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;he.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let b=new Error("probe error");b.transport=t.name,this.emitReserved("upgradeError",b)}}))};function n(){r||(r=!0,d(),t.close(),t=null)}let s=p=>{let b=new Error("probe error: "+p);b.transport=t.name,n(),this.emitReserved("upgradeError",b)};function i(){s("transport closed")}function a(){s("socket closed")}function c(p){t&&p.name!==t.name&&n()}let d=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",o),t.once("error",s),t.once("close",i),this.once("close",a),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}},He=class extends mo{constructor(e,t={}){let r=typeof e=="object"?e:t;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(o=>ao[o]).filter(o=>!!o)),super(e,r)}};var da=He.protocol;var Ve={};Or(Ve,{Decoder:()=>No,Encoder:()=>Ro,PacketType:()=>l,protocol:()=>Lt});var fo=typeof ArrayBuffer=="function",ho=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Pt=Object.prototype.toString,go=typeof Blob=="function"||typeof Blob<"u"&&Pt.call(Blob)==="[object BlobConstructor]",yo=typeof File=="function"||typeof File<"u"&&Pt.call(File)==="[object FileConstructor]";function $e(e){return fo&&(e instanceof ArrayBuffer||ho(e))||go&&e instanceof Blob||yo&&e instanceof File}function Ee(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if(Ee(e[r]))return!0;return!1}if($e(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Ee(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&Ee(e[r]))return!0;return!1}function Eo(e){let t=[],r=e.data,o=e;return o.data=je(r,t),o.attachments=t.length,{packet:o,buffers:t}}function je(e,t){if(!e)return e;if($e(e)){let r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=je(e[o],t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=je(e[o],t));return r}return e}function xo(e,t){return e.data=qe(e.data,t),delete e.attachments,e}function qe(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=qe(e[r],t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=qe(e[r],t));return e}var
bo=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Lt=5,l;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(l||(l={}));var Ro=class{constructor(e){this.replacer=e}encode(e){return(e.type===l.EVENT||e.type===l.ACK)&&Ee(e)?this.encodeAsBinary({type:e.type===l.EVENT?l.BINARY_EVENT:l.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===l.BINARY_EVENT||e.type===l.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Eo(e),r=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(r),o}};function wt(e){return Object.prototype.toString.call(e)==="[object Object]"}var No=class vt extends E{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);let o=r.type===l.BINARY_EVENT;o||r.type===l.BINARY_ACK?(r.type=o?l.EVENT:l.ACK,this.reconstructor=new To(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if($e(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0,o={type:Number(t.charAt(0))};if(l[o.type]===void 0)throw new Error("unknown packet type "+o.type);if(o.type===l.BINARY_EVENT||o.type===l.BINARY_ACK){let s=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);let i=t.substring(s,r);if(i!=Number(i)||t.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););o.nsp=t.substring(s,r)}else o.nsp="/";let n=t.charAt(r+1);if(n!==""&&Number(n)==n){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}o.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(vt.isPayloadValid(o.type,s))o.data=s;else throw new Error("invalid payload")}return o}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case l.CONNECT:return wt(r);case l.DISCONNECT:return r===void 0;case l.CONNECT_ERROR:return typeof r=="string"||wt(r);case l.EVENT:case l.BINARY_EVENT:return Array.isArray(r)&&(typeof r[0]=="number"||typeof r[0]=="string"&&bo.indexOf(r[0])===-1);case l.ACK:case l.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},To=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=xo(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function _o(e,t="",r){let o=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),o=ye(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";let n=o.host.indexOf(":")!==-1?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+n+":"+o.port+t,o.href=o.protocol+"://"+n+(r&&r.port===o.port?"":":"+o.port),o}function A(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var ko=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Ct=class extends E{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[A(e,"open",this.onopen.bind(this)),A(e,"packet",this.onpacket.bind(this)),A(e,"error",this.onerror.bind(this)),A(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var r,o,n;if(ko.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let s={type:l.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let c=this.ids++,d=t.pop();this._registerAckCallback(c,d),s.id=c}let i=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!i||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var r;let o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.acks[e]=t;return}let n=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let i=0;i<this.sendBuffer.length;i++)this.sendBuffer[i].id===e&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},o),s=(...i)=>{this.io.clearTimeoutFn(n),t.apply(this,i)};s.withError=!0,this.acks[e]=s}emitWithAck(e,...t){return new Promise((r,o)=>{let n=(s,i)=>s?o(s):r(i);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...n)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:l.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case l.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case l.EVENT:case l.BINARY_EVENT:this.onevent(e);break;case l.ACK:case l.BINARY_ACK:this.onack(e);break;case l.DISCONNECT:this.ondisconnect();break;case l.CONNECT_ERROR:this.destroy();let t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,r=!1;return function(...o){r||(r=!0,t.packet({type:l.ACK,id:e,data:o}))}}onack(e){let t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:l.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function V(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}V.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};V.prototype.reset=function(){this.attempts=0};V.prototype.setMin=function(e){this.ms=e};V.prototype.setMax=function(e){this.max=e};V.prototype.setJitter=function(e){this.jitter=e};var We=class extends E{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,ee(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new V({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let o=t.parser||Ve;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new He(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=A(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=A(t,"error",n);if(this._timeout!==!1){let i=this._timeout,a=this.setTimeoutFn(()=>{o(),n(new Error("timeout")),t.close()},i);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(o),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(A(e,"ping",this.onping.bind(this)),A(e,"data",this.ondata.bind(this)),A(e,"error",this.onerror.bind(this)),A(e,"close",this.onclose.bind(this)),A(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Z(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ct(this,e,t),this.nsps[e]=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nsps[r].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}},te={};function $(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=_o(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=te[n]&&s in te[n].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||i,c;return a?c=new We(o,t):(te[n]||(te[n]=new We(o,t)),c=te[n]),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign($,{Manager:We,Socket:Ct,io:$,connect:$});function T(e){return e.val}function k(e){return e.err}var At=" must not return ",Oo="`transformer`",wo="`recoverer`",Po="`defaultValue`",W=Oo+At,F="called with ",G=Po+" must not be ",K=wo+At;var Lo="`Ok`",Mt="`Err`",St=F+Mt,It=F+Lo,vo="Carrying `E` in "+Mt+" instead of throwing it directly. See `.cause`",Ge="an instance of `Error` of the current realm.",tc="The thrown value is not "+Ge,rc="The contained E should be "+Ge,Co="This `.cause` is not "+Ge;function N(e){return e.ok}function h(e){return{ok:!0,val:e,err:null}}function x(e){return!e.ok}function y(e){return{ok:!1,val:null,err:e}}function _(e){return Ft(e,St)}function xe(e){return Ut(e,It)}function Ft(e,t){if(x(e))throw new TypeError(t);return e.val}function Ut(e,t){if(N(e))throw new TypeError(t);return e.err}async function Ke(e,t){if(x(e))return e;let r=T(e);return await t(r)}function be(e,t){if(x(e))return e;let r=T(e),o=t(r);return h(o)}async function j(e,t){if(x(e))return e;let r=T(e),o=await t(r);return h(o)}async function re(e,t){if(N(e))return e;let r=k(e),o=await t(r);return y(o)}var Re="`null`",cp=W+Re,So=F+Re,pp=G+Re,lp=K+Re;var Ne="`undefined`",hp=W+Ne,Io=F+Ne,gp=G+Ne,yp=K+Ne;var Y=e=>e.ok?h(e):y({name:"HTTPError",message:`${e.status} ${e.statusText}`,response:e});var Dt=async(e,t)=>{let r=new Request(e,t);try{return h(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return y({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return y({name:"NetworkError",message:o.message,request:r});throw o}};var U=e=>{let{fetch:t=Dt,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Ht=e=>{let{sid:t,hostName:r}=U(e??{});return new Request(`https://${r}/api/users/me`,t?{headers:{Cookie:D(t)}}:void 0)},jt=e=>j(Y(e),async t=>await t.json()),Ye=(()=>{let e=async t=>{let{fetch:r,...o}=U(t??{}),n=await r(Ht(o));return x(n)?n:jt(_(n))};return e.toRequest=Ht,e.fromResponse=jt,e})();var D=e=>`connect.sid=${e}`;var qt=(e,t)=>{if(e?.connected)return Promise.resolve(h(e));e??=$("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"],...t?{rejectUnauthorized:!1,extraHeaders:{Cookie:D(t),Host:"scrapbox.io",Referer:"https://scrapbox.io/"}}:{}});let r=new Promise(o=>{let n=s=>o(y(s));e.once("connect",()=>{e.off("disconnect",n),o(h(e))}),e.once("disconnect",n)});return e.connect(),r},$t=e=>{if(e.disconnected)return Promise.resolve(h(void 0));let t=new Promise(r=>{let o=n=>{if(n!=="io client disconnect"){r(y(n));return}r(h(void 0)),e.off("disconnect",o)};e.on("disconnect",o)});return e.disconnect(),t};var Vt=e=>Uo.includes(e.name),Uo=["SocketIOError","DuplicateTitleError","NotFastForwardError"];var Wt=(e,t,r,o)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(h(void 0));let{resolve:n,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(p)},c=f=>{if(f==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(f==="io server disconnect"){a(),n(y({name:"SocketIOError"}));return}};e.on("disconnect",c);let d=o?.timeout??9e4,p=setTimeout(()=>{a(),n(y({name:"TimeoutError",message:`exceeded ${d} (ms)`}))},d),b=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",b,f=>{if(a(),"error"in f){n(y(Vt(f.error)?f.error:{name:"UnexpectedRequestError",...f}));return}n(h(f.data))}),s};function Te(e,t={}){if(e===null)return"null";if(Array.isArray(e))return Bo(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return`${e}n`;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:Do(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function Bo(e,t){let{threshold:r=20}=t,o=e.map(i=>Te(i,t)),n=o.join(", ");if(n.length<=r)return`[${n}]`;let s=o.join(`,
`);return`[
${Gt(2,s)}
]`}function Do(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>`${i.toString()}: ${Te(e[i],t)}`),n=o.join(", ");if(n.length<=r)return`{${n}}`;let s=o.join(`,
`);return`{
${Gt(2,s)}
}`}function Gt(e,t){let r=" ".repeat(e);return t.split(`
`).map(o=>`${r}${o}`).join(`
`)}function _e(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=`${t}(${r.map(n=>Te(n)).join(", ")})`,o)}})}function Kt(e){return _e(t=>se(t)&&t.every(r=>e(r)),"isArrayOf",e)}function ze(e){let t=new Set(e);return _e(r=>t.has(r),"isLiteralOneOf",e)}function Qe(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}var ke=async(e,t)=>{let r=e.response.clone(),o=ze(t);try{let n=await r.json();if(!Qe(n))return;if(r.status===422){if(!B(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!B(n.message)?void 0:n.name==="NotLoggedInError"?!Qe(n.detals)||!B(n.detals.project)||!Kt(Ho)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},Ho=ze(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var Oe="`null` or `undefined`",z=W+Oe,jo=F+Oe,we=G+Oe,Pe=K+Oe;function v(e){return e!=null}function M(e,t){if(v(e))return e;throw new TypeError(t)}function Xe(e,t){return v(e)?e:M(t,we)}var Yt=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:i}=U(r??{}),a=new URLSearchParams([["followRename",`${s??!0}`],...i?.map?.(c=>["projects",c])??[]]);return new Request(`https://${n}/api/pages/${e}/${ve(t)}?${a}`,o?{headers:{Cookie:D(o)}}:void 0)},zt=async e=>re(await j(Y(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:Xe(await ke(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),Qt=(()=>{let e=async(t,r,o)=>Ke(await U(o??{}).fetch(Yt(t,r,o)),n=>zt(n));return e.toRequest=Yt,e.fromResponse=zt,e})();var Xt=(e,t)=>{let{sid:r,hostName:o}=U(t??{});return new Request(`https://${o}/api/projects/${e}`,r?{headers:{Cookie:D(r)}}:void 0)},Jt=async e=>j(await re(Y(e),async t=>await ke(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),Zt=(()=>{let e=async(t,r)=>{let{fetch:o}=U(r??{}),n=Xt(t,r),s=await o(n);return x(s)?s:Jt(_(s))};return e.toRequest=Xt,e.fromResponse=Jt,e})();var Ze=async(e,t,r)=>{let[o,n,s]=await Promise.all([Qt(e,t,r),qo(r),$o(e,r)]);return x(o)?o:x(n)?n:x(s)?s:h({..._(o),projectId:_(s),userId:_(n)})},Je,qo=async e=>{if(Je)return h(Je);let t=await Ye(e);if(x(t))return t;let r=_(t);return"id"in r?(Je=r.id,h(r.id)):y({name:"NotLoggedInError",message:"This script cannot be used without login"})},er=new Map,$o=async(e,t)=>{let r=er.get(e);return r?h(r):be(await Zt(e,t),({id:o})=>(er.set(e,o),o))};var Q=async(e,t,r,o)=>{let n=await qt(o?.socket,o?.sid);if(x(n))return y({name:"UnexpectedRequestError",error:xe(n)});let s=_(n),i=await Ze(e,t,o);if(x(i))return i;let a=_(i);try{let c=0,d=[],p;for(;o?.maxAttempts===void 0||c<o.maxAttempts;){let b=r(a,c,d,p);if(d=b instanceof Promise?await b:b,c++,d.length===0)return h(a.commitId);let f={kind:"page",projectId:a.projectId,pageId:a.id,parentId:a.commitId,userId:a.userId,changes:d,cursor:null,freeze:!0};for(;;){let O=await Wt(s,"commit",f);if(N(O))return a.commitId=_(O).commitId,h(a.commitId);let P=xe(O),m=P.name;if(m==="SocketIOServerDisconnectError"||m==="UnexpectedRequestError")return y(P);if(m==="TimeoutError"||m==="SocketIOError"){await X(3e3);continue}if(m==="NotFastForwardError"){await X(1e3);let R=await Ze(e,t,o);if(x(R))return R;a=_(R)}p=m;break}}return y({name:"RetryError",attempts:c,message:`Retrying exceeded the maxAttempts (${c}).`})}finally{o?.socket||await $t(s)}};var et=(e,t)=>{let r=e.length>t.length,o=r?t:e,n=r?e:t,s=o.length+1,i=o.length+n.length+3,a=new Array(i);a.fill(-1);let c=[];function d(m,R,C){let S=Math.max(R,C),ne=S-m;for(;ne<o.length&&S<n.length&&o[ne]===n[S];)++ne,++S;return a[m+s]=c.length,c.push([{x:ne,y:S},a[m+(R>C?-1:1)+s]]),S}let p=new Array(i);p.fill(-1);let b=-1,f=n.length-o.length;do{++b;for(let m=-b;m<=f-1;++m)p[m+s]=d(m,p[m-1+s]+1,p[m+1+s]);for(let m=f+b;m>=f+1;--m)p[m+s]=d(m,p[m-1+s]+1,p[m+1+s]);p[f+s]=d(f,p[f-1+s]+1,p[f+1+s])}while(p[f+s]!==n.length);let O=[],P=a[f+s];for(;P!==-1;)O.push(c[P][0]),P=c[P][1];return{from:e,to:t,editDistance:f+b*2,buildSES:function*(){let m=0,R=0;for(let{x:C,y:S}of Vo(O))for(;m<C||R<S;)S-C>R-m?(yield{value:n[R],type:r?"deleted":"added"},++R):S-C<R-m?(yield{value:o[m],type:r?"added":"deleted"},++m):(yield{value:o[m],type:"common"},++m,++R)}}};function*tt(e){let t=[],r=[];function*o(){if(t.length>r.length){for(let n=0;n<r.length;n++)yield tr(t[n],r[n]);for(let n=r.length;n<t.length;n++)yield t[n]}else{for(let n=0;n<t.length;n++)yield tr(t[n],r[n]);for(let n=t.length;n<r.length;n++)yield r[n]}t=[],r=[]}for(let n of e)switch(n.type){case"added":t.push(n);break;case"deleted":r.push(n);break;case"common":yield*o(),yield n;break}yield*o()}var tr=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*Vo(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var rr=e=>e.padStart(8,"0"),oe=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return`${rr(t).slice(-8)}${e.slice(-6)}0000${rr(r)}`};var u=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let a of o){let c=a.exec(n);if(c===null)continue;let d=n.substring(0,c.index),p=n.substring(c.index+(c[0]?.length??0)),b=e(c[0]??"",s);return[...w(d,s),...b,...w(p,s)]}return i?.()??[]};var g=e=>[{type:"plain",raw:e,text:e}],or=u(g,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var Wo=/\[\s+\]/,Go=(e,t)=>t.context==="table"?g(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],nr=u(Go,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Wo]});var Ko=/`.*?`/,Yo=(e,t)=>t.context==="table"?g(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],sr=u(Yo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ko]});var zo=/^[$%] .+$/,Qo=(e,t)=>{if(t.context==="table")return g(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},ir=u(Qo,{parseOnNested:!1,parseOnQuoted:!1,patterns:[zo]});var Xo=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Jo=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let i=o.split("*").length-1;s.delete("*"),s.add(`*-${Math.min(i,10)}`)}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:w(n,{...t,nested:!0})}]},ar=u(Jo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Xo]});var Zo=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,en=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,tn=/\[https?:\/\/[^\s\]]+\]/,rn=/https?:\/\/[^\s]+/,on=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},cr=u(on,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Zo,en,tn,rn]});var nn=/\[\$ .+? \]/,sn=/\[\$ [^\]]+\]/,an=(e,t)=>t.context==="table"?g(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],pr=u(an,{parseOnNested:!1,parseOnQuoted:!0,patterns:[nn,sn]});var lr=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,ur=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,cn=e=>{let[t="",r="",o=""]=e.split(","),n=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(o)?Number.parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:i}},pn=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.match(lr)??e.match(ur);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,n="",s=""]=o?r:[r[0],r[2],r[1]],{latitude:i,longitude:a,zoom:c}=cn(n),d=s!==""?`https://www.google.com/maps/place/${encodeURIComponent(s)}/@${i},${a},${c}z`:`https://www.google.com/maps/@${i},${a},${c}z`;return[{type:"googleMap",raw:e,latitude:i,longitude:a,zoom:c,place:s,url:d}]},mr=u(pn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[lr,ur]});var ln=/(?:^|\s)#\S+/,un=(e,t)=>{if(t.context==="table")return g(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...g(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},dr=u(un,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ln]});var mn=/^\? .+$/,dn=(e,t)=>t.context==="table"?g(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],fr=u(dn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[mn]});var fn=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,hn=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),o=t.substring(0,r),n=o.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),i=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:o,pathType:n,type:"icon",raw:e}))},hr=u(hn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[fn]});var gn=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,yn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,En=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,xn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,bn=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Rn(e),Rn=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),Nn=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,i]=bn(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?`${s}/thumb/1000`:s,link:i}]},gr=u(Nn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[gn,yn,En,xn]});var Tn=/\[\/?[^[\]]+\]/,_n=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},yr=u(_n,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Tn]});var kn=/^[0-9]+\. .*$/,On=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=Number.parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:w(s,{...t,nested:!1})}]},Er=u(On,{parseOnNested:!1,parseOnQuoted:!1,patterns:[kn]});var wn=/^>.*$/,Pn=(e,t)=>t.context==="table"?g(e,t):[{type:"quote",raw:e,nodes:w(e.substring(1),{...t,quoted:!0})}],xr=u(Pn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[wn]});var Ln=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,vn=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.substring(2,e.length-2),o=r.lastIndexOf(".icon"),n=r.substring(0,o),s=n.startsWith("/")?"root":"relative",i=r.substring(o+5,r.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},br=u(vn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ln]});var Cn=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,An=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Mn=(e,t)=>{if(t.context==="table")return g(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?`${r}/thumb/1000`:r}]},Rr=u(Mn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Cn,An]});var Sn=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,In=(e,t)=>t.context==="table"?g(e,t):[{type:"strong",raw:e,nodes:w(e.substring(2,e.length-2),{...t,nested:!0})}],Nr=u(In,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Sn]});var Fn=(e,t,r)=>e===""?[]:r?.()??[],Un=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>or(t,r))(),w=Un(Fn,xr,fr,Er,sr,ir,pr,nr,ar,Rr,br,Nr,gr,cr,hr,mr,yr,dr);var rt=e=>{let t=e.match(/^(\s*)code:(.+?)(\(.+\)){0,1}\s*$/);if(t===null)return null;let r=t[2].trim(),o="";if(t[3]===void 0){let n=r.match(/.+\.(.*)$/);if(n===null)o=r;else{if(n[1]==="")return null;o=n[1].trim()}}else o=t[3].slice(1,-1);return{filename:r,lang:o,indent:t[1].length}};function Le(e){return e.titleLine.text.length-e.titleLine.text.trimStart().length+1}var Tr=(e,t)=>{let r=[],o={isCodeBlock:!1,filename:"",lang:"",indent:0};for(let n of e.lines)if(o.isCodeBlock){if(jn(n.text,o.indent)===null){r[r.length-1].nextLine=n,o.isCodeBlock=!1;continue}r[r.length-1].bodyLines.push(n)}else{let s=rt(n.text);if(s===null){o.isCodeBlock=!1;continue}o={isCodeBlock:!0,...s},r.push({filename:o.filename,lang:o.lang,titleLine:n,bodyLines:[],nextLine:null,pageInfo:{projectName:e.project,pageTitle:e.title}})}return r.filter(n=>Hn(n,t))},Hn=(e,t)=>ot(t?.filename,e.filename)&&ot(t?.lang,e.lang)&&ot(t?.titleLineId,e.titleLine.id),ot=(e,t)=>!e||e===t,jn=(e,t)=>{let r=e.replaceAll("\r","").match(/^(\s*)(.*)$/);if(r===null||r.length<2)return null;let o=r[1],n=r[2];return o.length<=t?null:o.slice(o.length-t)+n};var _r=(e,t,r,o)=>{let n={insertPositionIfNotExist:"notInsert",isInsertEmptyLineInTail:!0,debug:!1},s=o?{...n,...o}:n;return Q(t,r,i=>{let a=i.lines,c=Tr({project:t,title:r,lines:a},{filename:e.filename}),d=[...$n(c,e,a,{...s,userId:i.userId})];if(s.debug){console.log("%cvvv original code Blocks vvv","color: limegreen;"),console.log(c),console.log("%cvvv new codes vvv","color: limegreen;");let p=Array.isArray(e.content)?e.content:e.content.split(`
`);console.log(p),console.log("%cvvv commits vvv","color: limegreen;"),console.log(d)}return d},o)},qn=e=>e.map(t=>{let r=Le(t);return t.bodyLines.map(o=>({...o,text:o.text.slice(r)}))}).flat();function*$n(e,t,r,{userId:o,insertPositionIfNotExist:n,isInsertEmptyLineInTail:s}){function i(f){return" ".repeat(Le(f))}let a=[...e],c=qn(e);if(a.length<=0){if(n==="notInsert")return;let f=n==="top"&&r.length>1?r[1]:null,O={_insert:f?.id??"_end",lines:{id:oe(o),text:Vn(t)}};yield O,a.push({titleLine:{...O.lines,userId:o,created:-1,updated:-1},bodyLines:[],nextLine:f})}let{buildSES:d}=et(c.map(f=>f.text),Array.isArray(t.content)?t.content:t.content.split(`
`)),p=0,b=!1;for(let f of tt(d())){let{lineId:O,codeIndex:P}=(()=>{if(p>=c.length){let R=a.length-1;return{lineId:a[R].nextLine?.id??"_end",codeIndex:R}}return{lineId:c[p].id,codeIndex:a.findIndex(R=>R.bodyLines.some(C=>C.id==c[p].id))}})(),m=a[P];if(f.type=="added"){let R=O==m.bodyLines[0]?.id&&P>=1?a[P-1]:a[P],C=R?.nextLine?.id??"_end";yield{_insert:C,lines:{id:oe(o),text:i(R)+f.value}},C=="_end"&&(b=!0);continue}else f.type=="deleted"?yield{_delete:O,lines:-1}:f.type=="replaced"&&(yield{_update:O,lines:{text:i(m)+f.value}});p++}b&&s&&(yield{_insert:"_end",lines:{id:oe(o),text:""}})}var Vn=e=>`code:${e.filename+(e.lang?`(${e.lang})`:"")}`;scrapbox.PageMenu.addMenu({title:"Update dev UserScript",image:"https://i.gyazo.com/95e1d28e25db16bf7c4fdeeb16452179.png",onClick:async()=>{let e=await navigator.clipboard.readText();if(!e?.trim?.())return;let t=it();t.render({type:"group",items:[{type:"spinner"},{type:"text",text:"Update import-dev/mod.js..."}]});try{await _r({filename:"mod.js",content:e},"takker","import-dev"),t.render({type:"group",items:[{type:"check-circle"},{type:"text",text:"Updated"}]})}catch(r){if(console.error(r),!(r instanceof Error))throw r;t.render({type:"group",items:[{type:"exclamation-triangle"},{type:"text",text:`${r.name} ${r.message}`}]})}finally{setTimeout(()=>t.dispose(),2e3)}}});