import-dev
code:script.js
await import("../../takker-dist/import-devにbackgroundでテストコードを貼り付けるUserScript/script.js");
await import("./mod.js");
code:mod.js
var Xr=Object.defineProperty;var Zr=(e,t)=>{for(var r in t)Xr(e,r,{get:tr,enumerable:!0})};function ye(e){return typeof e=="number"}function Q(e){return typeof e=="string"}function ae(e){return typeof e>"u"}var Lt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Qe=()=>Ft(document.getElementsByClassName("lines").item(0),"div.lines");var It=()=>Ft(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),Ft=(e,t)=>{if(e)return Lt(e,t),e};var pe=()=>{let e=Qe();if(!e)throw Error("div.lines is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.lines must has the property whose name starts with "__reactFiber"');return et.return.stateNode.props.lines};var Ct=e=>{if(ae(e))return;if(ye(e))return to(e)?.id;if(Q(e))return e.startsWith("L")?e.slice(1):e;if(e.classList.contains("line"))return e.id.slice(1);let t=e.closest(".line");if(t)return t.id.slice(1)};var to=e=>{if(ae(e))return;if(ye(e))return pe()e;let t=Ct(e);return t?pe().find(r=>r.id===t):void 0},Je=e=>{if(ro(e))return e;let t=Ct(e);if(ae(t))return t;let r=document.getElementById(L${t});if(!ae(r))return r},ro=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var xe=()=>{let e=It();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=Mt(...r);o&&t.append(o)},dispose:()=>t.remove(),Symbol.dispose:()=>t.remove()}},Mt=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":returnio();case"check-circle":returnao();case"exclamation-triangle":returnpo();case"text":returnRe(o.text);case"group":{let n=Mt(...o.items);return n?n:[]}}});if(t.length===0)return;if(t.length===1)return t0;let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},Re=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},io=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Re(e)},ao=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Re(e)},po=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Re(e)};var V=e=>...e.map((t,r)=>t===" "?"_":!co.includes(t)||r===e.length-1&&uo.includes(t)?encodeURIComponent(t):t).join(""),co='@$&+=:;",',uo=':;",';var Ut=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}};var ce=e=>{let{fetch:t=(n,s)=>globalThis.fetch(n,s),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var Dt=" must not return ",fo="transformer",ho="recoverer",go="defaultValue",Z=fo+Dt,j="called with ",ee=go+" must not be ",te=ho+Dt;var yo="Ok",Bt="Err",Eo=j+Bt,xo=j+yo,Ro="Carrying E in "+Bt+" instead of throwing it directly. See .cause",Xe="an instance of Error of the current realm.",hp="The thrown value is not "+Xe,gp="The contained E should be "+Xe,To="This .cause is not "+Xe;var Te="null",Pc=Z+Te,_o=j+Te,Lc=ee+Te,Ic=te+Te;var be="undefined",vc=Z+be,ko=j+be,Mc=ee+be,Uc=te+be;var g=e=>connect.sid=${e};var So=(e,t,r)=>{let{sid:o,baseURL:n,followRename:s,projects:i}=ce(r??{}),u=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(a=>"projects",a)??[]]);return new Request(${n}api/pages/${e}/${V(t)}?${u},o?{headers:{Cookie:g(o)}}:void 0)},et=(e,t,r)=>ce(r??{}).fetch(So(e,t,r));var Co=Math.pow(10,8)*24*60*60*1e3,Nm=-Co;var tt=6e4;var vo=3600;var jt=vo*24,_m=jt*7,Mo=jt*365.2425,Uo=Mo/12,km=Uo*3,rt=Symbol.for("constructDateFrom");function y(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&rt in e?ert(t):e instanceof Date?new e.constructor(t):new Date(t)}function l(e,t){return y(t||e,e)}function ue(e,t,r){let o=l(e,r?.in);return isNaN(t)?y(r?.in||e,NaN):(t&&o.setDate(o.getDate()+t),o)}function Ne(e){return t=>{let r=(e?Mathe:Math.trunc)(t);return r===0?0:r}}function _e(e,t){return+l(e)-+l(t)}function ke(e,t,r){let o=_e(e,t)/tt;return Ne(r?.roundingMethod)(o)}function ot(e,t,r){return ue(e,-t,r)}function we(e,t){let r=l(e,t?.in);return r.setHours(0,0,0,0),r}function Oe(e,t){return+l(e)>+l(t)}function qt(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="object Date"}function it(e){return!(!qt(e)&&typeof e!="number"||isNaN(+l(e)))}function $(e,t){let r=e<0?"-":"",o=Math.abs(e).toString().padStart(t,"0");return r+o}var Wt={y(e,t){let r=e.getFullYear(),o=r>0?r:1-r;return $(t==="yy"?o%100:o,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):$(r+1,2)},d(e,t){return $(e.getDate(),t.length)},a(e,t){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r0;case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return $(e.getHours()%12||12,t.length)},H(e,t){return $(e.getHours(),t.length)},m(e,t){return $(e.getMinutes(),t.length)},s(e,t){return $(e.getSeconds(),t.length)},S(e,t){let r=t.length,o=e.getMilliseconds(),n=Math.trunc(o*Math.pow(10,r-3));return $(n,t.length)}};var jo=/(\w)\1*|''|'(''|^')+('|$)|./g,$o=/^'(^*?)'?$/,qo=/''/g,Wo=/a-zA-Z/;function at(e,t){let r=l(e);if(!it(r))throw new RangeError("Invalid time value");let o=t.match(jo);return o?o.map(n=>{if(n==="''")return"'";let s=n0;if(s==="'")return Go(n);let i=Wts;if(i)return i(r,n);if(s.match(Wo))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return n}).join(""):""}function Go(e){let t=e.match($o);return t?t1.replace(qo,"'"):e}var Pe="null or undefined",re=Z+Pe,Ko=j+Pe,pt=ee+Pe,Le=te+Pe;var Jo=new TextEncoder().encode("0123456789abcdef"),Gt=new Uint8Array(128).fill(16);Jo.forEach((e,t)=>Gte=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Gte=t+10);var Xo=new TextEncoder().encode("0123456789abcdef"),Vt=new Uint8Array(128).fill(16);Xo.forEach((e,t)=>Vte=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Vte=t+10);var G=e=>{let t=e.match(/^(\d{4})-(\d{2})-(\d{2}) (?: {5}|(\d{2}):(\d{2})) (?: {4}|(\d{4})) (?: {8}|(\d{2}):(\d{2}):(\d{2})) (?: {8}|(\d{2}):(\d{2}):(\d{2}))(^\n*)$/);if(!t)return;let,r,o,n,s,i,u,a,R,E,U,zr,Qr,Jr=t,D={title:Jr,base:new Date(parseInt(r),parseInt(o)-1,parseInt(n)),plan:{},record:{}};if(s){let T=new Date(D.base);T.setHours(parseInt(s)),T.setMinutes(parseInt(i)),D.plan.start=T}if(u&&(D.plan.duration=parseInt(u)*60),a){let T=new Date(D.base);T.setHours(parseInt(a)),T.setMinutes(parseInt(R)),T.setSeconds(parseInt(E)),D.record.start=T}if(U){let T=new Date(D.base);T.setHours(parseInt(U)),T.setMinutes(parseInt(zr)),T.setSeconds(parseInt(Qr)),D.record.start&&Oe(D.record.start,T)&&T.setDate(T.getDate()+1),D.record.end=T}return D};var qN=5*60;var an="日刊記録sheet";var Fe=e=>at(e,'${an}' yyyy-MM-dd);function f(e){if(e)return pn(e)}function pn(e){for(var t in f.prototype)et=f.prototypet;return e}f.prototype.on=f.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};f.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.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=rn,o===t||o.fn===t){r.splice(n,1);break}return r.length===0&&delete this._callbacks"$"+e,this};f.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++)to-1=argumentso;if(r){r=r.slice(0);for(var o=0,n=r.length;o<n;++o)ro.apply(this,t)}return this};f.prototype.emitReserved=f.prototype.emit;f.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};f.prototype.hasListeners=function(e){return!!this.listeners(e).length};var H=Object.create(null);H.open="0";H.close="1";H.ping="2";H.pong="3";H.message="4";H.upgrade="5";H.noop="6";var Ce=Object.create(null);Object.keys(H).forEach(e=>{Ce[He]=e});var mt={type:"error",data:"parser error"},Zt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",er=typeof ArrayBuffer=="function",tr=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ve=({type:e,data:t},r,o)=>Zt&&t instanceof Blob?r?o(t):Qt(t,o):er&&(t instanceof ArrayBuffer||tr(t))?r?o(t):Qt(new Blob(t),o):o(He+(t||"")),Qt=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")1;t("b"+(o||""))},r.readAsDataURL(e)};function Jt(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ut;function cn(e,t){if(Zt&&e.data instanceof Blob)return e.data.arrayBuffer().then(Jt).then(t);if(er&&(e.data instanceof ArrayBuffer||tr(e.data)))return t(Jt(e.data));ve(e,!1,r=>{ut||(ut=new TextEncoder),t(ut.encode(r))})}var Xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",le=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Xt.length;e++)leXt.charCodeAt(e)=e;var un=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,u,a;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let R=new ArrayBuffer(t),E=new Uint8Array(R);for(o=0;o<r;o+=4)s=lee.charCodeAt(o),i=lee.charCodeAt(o+1),u=lee.charCodeAt(o+2),a=lee.charCodeAt(o+3),En++=s<<2|i>>4,En++=(i&15)<<4|u>>2,En++=(u&3)<<6|a&63;return R},ln=typeof ArrayBuffer=="function",Me=(e,t)=>{if(typeof e!="string")return{type:"message",data:rr(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:mn(e.substring(1),t)}:Cer?e.length>1?{type:Cer,data:e.substring(1)}:{type:Cer}:mt},mn=(e,t)=>{if(ln){let r=un(e);return rr(r,t)}else return{base64:!0,data:e}},rr=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},or="",nr=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{ve(s,!1,u=>{oi=u,++n===r&&t(o.join(or))})})},sr=(e,t)=>{let r=e.split(or),o=[];for(let n=0;n<r.length;n++){let s=Me(rn,t);if(o.push(s),s.type==="error")break}return o};function ir(){return new TransformStream({transform(e,t){cn(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"&&(n0|=128),t.enqueue(n),t.enqueue(r)})}})}var lt;function Ae(e){return e.reduce((t,r)=>t+r.length,0)}function Se(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),o=0;for(let n=0;n<t;n++)rn=e0o++,o===e0.length&&(e.shift(),o=0);return e.length&&o<e0.length&&(e0=e0.slice(o)),r}function ar(e,t){lt||(lt=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,u){for(r.push(i);;){if(o===0){if(Ae(r)<1)break;let a=Se(r,1);s=(a0&128)===128,n=a0&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(Ae(r)<2)break;let a=Se(r,2);n=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),o=3}else if(o===2){if(Ae(r)<8)break;let a=Se(r,8),R=new DataView(a.buffer,a.byteOffset,a.length),E=R.getUint32(0);if(E>Math.pow(2,21)-1){u.enqueue(mt);break}n=E*Math.pow(2,32)+R.getUint32(4),o=3}else{if(Ae(r)<n)break;let a=Se(r,n);u.enqueue(Me(s?a:lt.decode(a),t)),o=0}if(n===0||n>e){u.enqueue(mt);break}}}})}var ft=4;var me=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),S=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),fn="arraybuffer";function cr(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(ro=eo),r),{})}var dn=S.setTimeout,hn=S.clearTimeout;function fe(e,t){t.useNativeTimers?(e.setTimeoutFn=dn.bind(S),e.clearTimeoutFn=hn.bind(S)):(e.setTimeoutFn=S.setTimeout.bind(S),e.clearTimeoutFn=S.clearTimeout.bind(S))}var gn=1.33;function yn(e){return typeof e=="string"?En(e):Math.ceil((e.byteLength||e.size)*gn)}function En(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 ur(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function xn(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function Rn(e){let t={},r=e.split("&");for(let o=0,n=r.length;o<n;o++){let s=ro.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var Tn=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},gt=class extends f{constructor(e){super(),this.writable=!1,fe(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 Tn(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=xn(e);return t.length?"?"+t:""}},bn=class extends gt{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)};sr(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,nr(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&&(tthis.opts.timestampParam=ur()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},lr=!1;try{lr=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Nn=lr;function _n(){}var kn=class extends bn{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}},oe=class Ue extends f{constructor(t,r,o){super(),this.createRequest=t,fe(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=cr(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.extraHeadersn)}}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=Ue.requestsCount++,Ue.requeststhis._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=_n,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ue.requeststhis._index,this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};oe.requestsCount=0;oe.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",pr);else if(typeof addEventListener=="function"){let e="onpagehide"in S?"pagehide":"unload";addEventListener(e,pr,!1)}}function pr(){for(let e in oe.requests)oe.requests.hasOwnProperty(e)&&oe.requestse.abort()}var wn=function(){let e=mr({xdomain:!1});return e&&e.responseType!==null}(),yt=class extends kn{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=wn&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new oe(mr,this.uri(),e)}};function mr(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Nn))return new XMLHttpRequest}catch{}if(!t)try{return new S["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var fr=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",On=class extends gt{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=fr?{}:cr(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=et,o=t===e.length-1;ve(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}o&&me(()=>{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&&(tthis.opts.timestampParam=ur()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},dt=S.WebSocket||S.MozWebSocket,Et=class extends On{createSocket(e,t,r){return fr?new dt(e,t,r):t?new dt(e,t):new dt(e)}doWrite(e,t){this.ws.send(t)}},dr=class extends gt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptionsthis.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=ar(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),o=ir();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();let n=()=>{r.read().then(({done:i,value:u})=>{i||(this.onPacket(u),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=et,o=t===e.length-1;this._writer.write(r).then(()=>{o&&me(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},Pn={websocket:Et,webtransport:dr,polling:yt},Ln=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,In="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function je(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=Ln.exec(e||""),s={},i=14;for(;i--;)s[Ini]=ni||"";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=Fn(s,s.path),s.queryKey=An(s,s.query),s}function Fn(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 An(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(o,n,s){n&&(rn=s)}),r}var ht=typeof addEventListener=="function"&&typeof removeEventListener=="function",De=[];ht&&addEventListener("offline",()=>{De.forEach(e=>e())},!1);var Be=class He extends f{constructor(t,r){if(super(),this.binaryType=fn,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=je(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=je(r.host).host);fe(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._transportsByNamen=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=Rn(this.opts.query)),ht&&(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"})},De.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=ft,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.transportOptionst);return new this._transportsByNamet(o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&He.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports0;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",He.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.writeBufferr.data;if(o&&(t+=yn(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,me(()=>{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(He.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(),ht&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=De.indexOf(this._offlineEventListener);o!==-1&&De.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};Be.protocol=ft;var Sn=class extends Be{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._upgradese)}_probe(e){let t=this.createTransport(e),r=!1;Be.priorWebsocketSuccess=!1;let o=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",E=>{if(!r)if(E.type==="pong"&&E.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Be.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(R(),this.setTransport(t),t.send({type:"upgrade"}),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let U=new Error("probe error");U.transport=t.name,this.emitReserved("upgradeError",U)}}))};function n(){r||(r=!0,R(),t.close(),t=null)}let s=E=>{let U=new Error("probe error: "+E);U.transport=t.name,n(),this.emitReserved("upgradeError",U)};function i(){s("transport closed")}function u(){s("socket closed")}function a(E){t&&E.name!==t.name&&n()}let R=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",i),this.off("close",u),this.off("upgrading",a)};t.once("open",o),t.once("error",s),t.once("close",i),this.once("close",u),this.once("upgrading",a),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(er)&&t.push(er);return t}},xt=class extends Sn{constructor(e,t={}){let r=typeof e=="object"?e:t;(!r.transports||r.transports&&typeof r.transports0=="string")&&(r.transports=(r.transports||"polling","websocket","webtransport").map(o=>Pno).filter(o=>!!o)),super(e,r)}};var Z_=xt.protocol;var Nt={};Zr(Nt,{Decoder:()=>$n,Encoder:()=>jn,PacketType:()=>p,protocol:()=>yr});var Cn=typeof ArrayBuffer=="function",vn=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,gr=Object.prototype.toString,Mn=typeof Blob=="function"||typeof Blob<"u"&&gr.call(Blob)==="object BlobConstructor",Un=typeof File=="function"||typeof File<"u"&&gr.call(File)==="object FileConstructor";function bt(e){return Cn&&(e instanceof ArrayBuffer||vn(e))||Mn&&e instanceof Blob||Un&&e instanceof File}function $e(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if($e(er))return!0;return!1}if(bt(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return $e(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&$e(er))return!0;return!1}function Dn(e){let t=[],r=e.data,o=e;return o.data=Rt(r,t),o.attachments=t.length,{packet:o,buffers:t}}function Rt(e,t){if(!e)return e;if(bt(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++)ro=Rt(eo,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(ro=Rt(eo,t));return r}return e}function Bn(e,t){return e.data=Tt(e.data,t),delete e.attachments,e}function Tt(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return te.num;throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)er=Tt(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=Tt(er,t));return e}var Hn="connect","connect_error","disconnect","disconnecting","newListener","removeListener",yr=5,p;(function(e){ee.CONNECT=0="CONNECT",ee.DISCONNECT=1="DISCONNECT",ee.EVENT=2="EVENT",ee.ACK=3="ACK",ee.CONNECT_ERROR=4="CONNECT_ERROR",ee.BINARY_EVENT=5="BINARY_EVENT",ee.BINARY_ACK=6="BINARY_ACK"})(p||(p={}));var jn=class{constructor(e){this.replacer=e}encode(e){return(e.type===p.EVENT||e.type===p.ACK)&&$e(e)?this.encodeAsBinary({type:e.type===p.EVENT?p.BINARY_EVENT:p.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===p.BINARY_EVENT||e.type===p.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=Dn(e),r=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(r),o}};function hr(e){return Object.prototype.toString.call(e)==="object Object"}var $n=class Er extends f{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===p.BINARY_EVENT;o||r.type===p.BINARY_ACK?(r.type=o?p.EVENT:p.ACK,this.reconstructor=new qn(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(bt(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(po.type===void 0)throw new Error("unknown packet type "+o.type);if(o.type===p.BINARY_EVENT||o.type===p.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(Er.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 p.CONNECT:return hr(r);case p.DISCONNECT:return r===void 0;case p.CONNECT_ERROR:return typeof r=="string"||hr(r);case p.EVENT:case p.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&Hn.indexOf(r0)===-1);case p.ACK:case p.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},qn=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=Bn(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Wn(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=je(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 M(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var Gn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),xr=class extends f{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=M(e,"open",this.onopen.bind(this)),M(e,"packet",this.onpacket.bind(this)),M(e,"error",this.onerror.bind(this)),M(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(Gn.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:p.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof tt.length-1=="function"){let a=this.ids++,R=t.pop();this._registerAckCallback(a,R),s.id=a}let i=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,u=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!i||(u?(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.ackse=t;return}let n=this.io.setTimeoutFn(()=>{delete this.ackse;for(let i=0;i<this.sendBuffer.length;i++)this.sendBufferi.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.ackse=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 ee.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._queue0?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._queue0;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:p.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.ackse;delete this.ackse,t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case p.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 p.EVENT:case p.BINARY_EVENT:this.onevent(e);break;case p.ACK:case p.BINARY_ACK:this.onack(e);break;case p.DISCONNECT:this.ondisconnect();break;case p.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 ee.length-1=="string"&&(this._lastOffset=ee.length-1)}ack(e){let t=this,r=!1;return function(...o){r||(r=!0,t.packet({type:p.ACK,id:e,data:o}))}}onack(e){let t=this.ackse.id;typeof t=="function"&&(delete this.ackse.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:p.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===tr)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===tr)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 ne(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}ne.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};ne.prototype.reset=function(){this.attempts=0};ne.prototype.setMin=function(e){this.ms=e};ne.prototype.setMax=function(e){this.max=e};ne.prototype.setJitter=function(e){this.jitter=e};var _t=class extends f{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,fe(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 ne({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||Nt;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 xt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=M(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=M(t,"error",n);if(this._timeout!==!1){let i=this._timeout,u=this.setTimeoutFn(()=>{o(),n(new Error("timeout")),t.close()},i);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}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(M(e,"ping",this.onping.bind(this)),M(e,"data",this.ondata.bind(this)),M(e,"error",this.onerror.bind(this)),M(e,"close",this.onclose.bind(this)),M(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){me(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nspse;return r?this._autoConnect&&!r.active&&r.connect():(r=new xr(this,e,t),this.nspse=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nspsr.active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(tr,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)}},de={};function he(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=Wn(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=den&&s in den.nsps,u=t.forceNew||t"force new connection"||t.multiplex===!1||i,a;return u?a=new _t(o,t):(den||(den=new _t(o,t)),a=den),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}Object.assign(he,{Manager:_t,Socket:xr,io:he,connect:he});var c=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let u of o){let a=u.exec(n);if(a===null)continue;let R=n.substring(0,a.index),E=n.substring(a.index+(a0?.length??0)),U=e(a0??"",s);return...F(R,s),...U,...F(E,s)}return i?.()??[]};var m=e=>{type:"plain",raw:e,text:e},br=c(m,{parseOnNested:!0,parseOnQuoted:!0,patterns:/^()(.*)()$/});var Qn=/\\s+\/,Jn=(e,t)=>t.context==="table"?m(e,t):{type:"blank",raw:e,text:e.substring(1,e.length-1)},Nr=c(Jn,{parseOnNested:!1,parseOnQuoted:!0,patterns:Qn});var Xn=/.*?/,Zn=(e,t)=>t.context==="table"?m(e,t):{type:"code",raw:e,text:e.substring(1,e.length-1)},_r=c(Zn,{parseOnNested:!1,parseOnQuoted:!0,patterns:Xn});var es=/^$% .+$/,ts=(e,t)=>{if(t.context==="table")return m(e,t);let r=e0??"",o=e.substring(2);return{type:"commandLine",raw:e,symbol:r,text:o}},kr=c(ts,{parseOnNested:!1,parseOnQuoted:!1,patterns:es});var rs=/\!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\+\]|^\])+\]/,os=(e,t)=>{if(t.context==="table")return m(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:F(n,{...t,nested:!0})}},wr=c(os,{parseOnNested:!1,parseOnQuoted:!0,patterns:rs});var ns=/\[https?:\/\/^\s\]+\s+^\]*^\s\]/,ss=/\^[\*^\s\s+https?:\/\/^\s\]+\]/,is=/\[https?:\/\/^\s\]+\]/,as=/https?:\/\/^\s+/,ps=(e,t)=>{if(t.context==="table")return m(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(n0.length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n0,content:s.trim()}]},Or=c(ps,{parseOnNested:!0,parseOnQuoted:!0,patterns:ns,ss,is,as});var cs=/\\$ .+? \/,us=/\[\$ ^\]+\]/,ls=(e,t)=>t.context==="table"?m(e,t):{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ")?2:1))}],Pr=c(ls,{parseOnNested:!1,parseOnQuoted:!0,patterns:cs,us});var Lr=/\[(^\]*^\s)\s+(NS\d+(?:\.\d+)?,EW\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Ir=/\[(NS\d+(?:\.\d+)?,EW\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+(^\]*^\s))?\]/,ms=e=>{lett="",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}},fs=(e,t)=>{if(t.context==="table")return m(e,t);let r=e.match(Lr)??e.match(Ir);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),,n="",s=""=o?r:[r0,r2,r1],{latitude:i,longitude:u,zoom:a}=ms(n),R=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${i},${u},${a}z:https://www.google.com/maps/@${i},${u},${a}z;return{type:"googleMap",raw:e,latitude:i,longitude:u,zoom:a,place:s,url:R}},Fr=c(fs,{parseOnNested:!1,parseOnQuoted:!0,patterns:Lr,Ir});var ds=/(?:^|\s)#\S+/,hs=(e,t)=>{if(t.context==="table")return m(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...m(r,t),{type:"hashTag",raw:o,href:o.substring(1)}},Ar=c(hs,{parseOnNested:!0,parseOnQuoted:!0,patterns:ds});var gs=/^\? .+$/,ys=(e,t)=>t.context==="table"?m(e,t):{type:"helpfeel",raw:e,text:e.substring(2)},Sr=c(ys,{parseOnNested:!1,parseOnQuoted:!1,patterns:gs});var Es=/\^[\*\.icon(?:\*1-9\d*)?\]/,xs=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}))},Cr=c(xs,{parseOnNested:!0,parseOnQuoted:!0,patterns:Es});var Rs=/\[https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)(?:\?^\\s]+)?(?:\s+https?:\/\/^\s\]+)?\]/i,Ts=/\[https?:\/\/^\s\]+\s+https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)(?:\?^\\s]+)?\]/i,bs=/\[https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}(?:\/raw)?(?:\s+https?:\/\/^\s\]+)?\]/,Ns=/\[https?:\/\/^\s\]+\s+https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}(?:\/raw)?\]/,_s=e=>/^https?:\/\/^\s\]+\.(png|jpe?g|gif|svg|webp)(\?^\\s]+)?$/i.test(e)||ks(e),ks=e=>/^https?:\/\/(0-9a-z-\.)?gyazo\.com\/0-9a-f{32}(\/raw)?$/.test(e),ws=(e,t)=>{if(t.context==="table")return m(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=_s(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}]},vr=c(ws,{parseOnNested:!0,parseOnQuoted:!0,patterns:Rs,Ts,bs,Ns});var Os=/\[\/?[^\]+\]/,Ps=e=>{let t=e.substring(1,e.length-1);return{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}},Mr=c(Ps,{parseOnNested:!0,parseOnQuoted:!0,patterns:Os});var Ls=/^0-9+\. .*$/,Is=(e,t)=>{if(t.context==="table")return m(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:F(s,{...t,nested:!1})}},Ur=c(Is,{parseOnNested:!1,parseOnQuoted:!1,patterns:Ls});var Fs=/^>.*$/,As=(e,t)=>t.context==="table"?m(e,t):{type:"quote",raw:e,nodes:F(e.substring(1),{...t,quoted:!0})},Dr=c(As,{parseOnNested:!1,parseOnQuoted:!1,patterns:Fs});var Ss=/\[\^[\*\.icon(?:\*\d+)?\]\]/,Cs=(e,t)=>{if(t.context==="table")return m(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),u=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(u).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},Br=c(Cs,{parseOnNested:!1,parseOnQuoted:!0,patterns:Ss});var vs=/\[\[https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,Ms=/\[\[https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}\]\]/,Us=(e,t)=>{if(t.context==="table")return m(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}]},Hr=c(Us,{parseOnNested:!1,parseOnQuoted:!0,patterns:vs,Ms});var Ds=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Bs=(e,t)=>t.context==="table"?m(e,t):{type:"strong",raw:e,nodes:F(e.substring(2,e.length-2),{...t,nested:!0})},jr=c(Bs,{parseOnNested:!1,parseOnQuoted:!0,patterns:Ds});var Hs=(e,t,r)=>e===""?[]:r?.()??[],js=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>br(t,r))(),F=js(Hs,Dr,Sr,Ur,_r,kr,Pr,Nr,wr,Hr,Br,jr,vr,Or,Cr,Fr,Mr,Ar);var $r=" must not return ",Vs="transformer",Ks="recoverer",Ys="defaultValue",We=Vs+$r,z="called with ",Ge=Ys+" must not be ",Ve=Ks+$r;var zs="Ok",qr="Err",Qs=z+qr,Js=z+zs,Xs="Carrying E in "+qr+" instead of throwing it directly. See .cause",wt="an instance of Error of the current realm.",AP="The thrown value is not "+wt,SP="The contained E should be "+wt,Zs="This .cause is not "+wt;var Ke="null",BL=We+Ke,ri=z+Ke,HL=Ge+Ke,jL=Ve+Ke;var Ye="undefined",VL=We+Ye,oi=z+Ye,KL=Ge+Ye,YL=Ve+Ye;function Gr(e,t,r){let o=_e(e,t)/1e3;return Ne(r?.roundingMethod)(o)}function Vr(e,t){let r,o=t?.in;return e.forEach(n=>{!o&&typeof n=="object"&&(o=y.bind(null,n));let s=l(n,o);(!r||r<s||isNaN(+s))&&(r=s)}),y(o,r||NaN)}var Ot=e=>{let t=Math.round(e/5),r=Math.floor(t/6),o=Math.floor((t-r*6)/3),n=t-r*6-o*3;return${r>20?🍅x${(e/30).toFixed(1)}:"🍅".repeat(r)}${"🍊".repeat(o)}${"🍓".repeat(n)}};var pi=()=>{let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.textAlign="right",e},ie=new Map,ze,Pt=()=>{for(let t of ie.values())t.remove();ie.clear();let e=()=>ci(pe());if(scrapbox.Layout!=="page"){if(scrapbox.removeListener("lines:changed",e),!ze)return;clearInterval(ze),ze=void 0;return}e(),scrapbox.addListener("lines:changed",e),ze=setInterval(e,60*1e3)},ci=e=>{for(let t of e){let r=G(t.text);if(!r?.record?.start){ie.get(t.id)?.remove?.(),ie.delete(t.id);continue}let o=ie.get(t.id)??pi();Je(t.id)?.append?.(o),ie.set(t.id,o),o.textContent=Ot(ke(r.record.end??new Date,r.record.start))}};scrapbox.Project.name==="takker-memex"&&(Pt(),scrapbox.addListener("page:changed",Pt),scrapbox.addListener("lines:changed",Pt));var ui=e=>{lett,r=e.reduce((o,{text:n})=>{let s=G(n);return s?.record?.start?s.record.end?(o1.push(s.record.end),o):(s.record.start&&o0.push(s.record.start),o):o},],[);if(t.length===0&&t.push(...r),t.length!==0)return Vr(t)},li=async(e,t)=>{letr,o=await Promise.all(et(e,Fe(t),{fetch:Kr}),et(e,Fe(ot(t,1)),{fetch:Kr})),n=r.ok?(await r.json()).lines:[];return o.ok&&n.push(...(await o.json()).lines),n},Kr=async(e,t)=>{let r=await Ut(new Request(e,t));return!r||Gr(new Date,new Date(${r.headers.get("Date")}))>=60?globalThis.fetch(e,t):r},{render:mi}=xe(),Yr=async()=>{let e=ui(await li("takker-memex",new Date))??we(new Date);mi({type:"text",text:Ot(ke(new Date,e))})};Yr();setInterval(Yr,60*1e3);