pin-diary-script
なんとなく使いたくなったので更新するwogikaze.icon
/villagepump/takker99/pin-diary
templateが開発されるみたいだけど、そんなに今すぐ必要ではないので待たない
yanked versionだw
スゴクフクザツなtemplateを作っている
table:week(日付は例)
mon tue wed thu fri sat sun 月曜始まりさ 妥協案 誘惑される鼓動に
1 2 3 4 5 6 7 [2025-02@1-7] [2025-02@w1]
29 30 31 1 2 3 4 [2025-03@29-4] [2025-03@w4]
もしかしなくても妥協案のほうが難しいな、妥協案は辞めようwogikaze.icon
https://gyazo.com/2cf15ecfb06e3d3b1b90a65c0131266b
無限にwogikaze-studyのページについてアクセスするDoSみたいなやつになってしまった
/villagepump/takker99/pin-diary#6705ead81280f00000065456これか、0.1.0なら治っているだろうという慢心
yankedなんだから文句言うな👈
pin-diary-beforebundle-script
code:title
@yyyy-MM-dd@
code:header
今日のn年前
@from_2025-02-19@
code:footer
@yyyy-MM-dd-1@←@yyyy-MM@→@yyyy-MM-dd+1@
@yyyy-MM@.icon
code:footer_dakyou
@yyyy-MM-dd-1@←@yyyy-MM@ww@→@yyyy-MM-dd+1@
code:script.js
var os=Object.defineProperty;var ns=(e,t)=>{for(var r in t)os(e,r,{get:tr,enumerable:!0})};function Ge(e){return Array.isArray(e)}function X(e){return typeof e=="string"}var gr=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Er=()=>ss(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),ss=(e,t)=>{if(e)return gr(e,t),e};function de(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(u){if(!(u instanceof ReferenceError))throw u;console.error("persistent option is only available in Deno")}})}var xr=()=>{let e=Er();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=Rr(...r);o&&t.append(o)},dispose:()=>t.remove()}},Rr=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":returnms();case"check-circle":returnfs();case"exclamation-triangle":returnds();case"text":returnKe(o.text);case"group":{let n=Rr(...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},Ke=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},ms=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Ke(e)},fs=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Ke(e)},ds=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Ke(e)};var te=e=>e.replaceAll(" ","_").toLowerCase();var he=e=>...e.map((t,r)=>t===" "?"_":!hs.includes(t)||r===e.length-1&&ys.includes(t)?encodeURIComponent(t):t).join(""),hs='@$&+=:;",',ys=':;",';function _(e){if(e)return Es(e)}function Es(e){for(var t in _.prototype)et=_.prototypet;return e}_.prototype.on=_.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};_.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};_.prototype.off=_.prototype.removeListener=_.prototype.removeAllListeners=_.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};_.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};_.prototype.emitReserved=_.prototype.emit;_.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};_.prototype.hasListeners=function(e){return!!this.listeners(e).length};var re=Object.create(null);re.open="0";re.close="1";re.ping="2";re.pong="3";re.message="4";re.upgrade="5";re.noop="6";var Qe=Object.create(null);Object.keys(re).forEach(e=>{Qe[ree]=e});var It={type:"error",data:"parser error"},_r=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",br=typeof ArrayBuffer=="function",wr=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Je=({type:e,data:t},r,o)=>_r&&t instanceof Blob?r?o(t):Tr(t,o):br&&(t instanceof ArrayBuffer||wr(t))?r?o(t):Tr(new Blob(t),o):o(ree+(t||"")),Tr=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")1;t("b"+(o||""))},r.readAsDataURL(e)};function Nr(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var At;function xs(e,t){if(_r&&e.data instanceof Blob)return e.data.arrayBuffer().then(Nr).then(t);if(br&&(e.data instanceof ArrayBuffer||wr(e.data)))return t(Nr(e.data));Je(e,!1,r=>{At||(At=new TextEncoder),t(At.encode(r))})}var kr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ve=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<kr.length;e++)vekr.charCodeAt(e)=e;var Rs=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,a,c;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let u=new ArrayBuffer(t),p=new Uint8Array(u);for(o=0;o<r;o+=4)s=vee.charCodeAt(o),i=vee.charCodeAt(o+1),a=vee.charCodeAt(o+2),c=vee.charCodeAt(o+3),pn++=s<<2|i>>4,pn++=(i&15)<<4|a>>2,pn++=(a&3)<<6|c&63;return u},Ts=typeof ArrayBuffer=="function",Xe=(e,t)=>{if(typeof e!="string")return{type:"message",data:Or(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:Ns(e.substring(1),t)}:Qer?e.length>1?{type:Qer,data:e.substring(1)}:{type:Qer}:It},Ns=(e,t)=>{if(Ts){let r=Rs(e);return Or(r,t)}else return{base64:!0,data:e}},Or=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Pr="",Ar=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{Je(s,!1,a=>{oi=a,++n===r&&t(o.join(Pr))})})},Lr=(e,t)=>{let r=e.split(Pr),o=[];for(let n=0;n<r.length;n++){let s=Xe(rn,t);if(o.push(s),s.type==="error")break}return o};function Ir(){return new TransformStream({transform(e,t){xs(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 Ye(e){return e.reduce((t,r)=>t+r.length,0)}function ze(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 Fr(e,t){Lt||(Lt=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(o===0){if(Ye(r)<1)break;let c=ze(r,1);s=(c0&128)===128,n=c0&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(Ye(r)<2)break;let c=ze(r,2);n=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),o=3}else if(o===2){if(Ye(r)<8)break;let c=ze(r,8),u=new DataView(c.buffer,c.byteOffset,c.length),p=u.getUint32(0);if(p>Math.pow(2,21)-1){a.enqueue(It);break}n=p*Math.pow(2,32)+u.getUint32(4),o=3}else{if(Ye(r)<n)break;let c=ze(r,n);a.enqueue(Xe(s?c:Lt.decode(c),t)),o=0}if(n===0||n>e){a.enqueue(It);break}}}})}var Ft=4;var Me=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),K=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),ks="arraybuffer";function Sr(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(ro=eo),r),{})}var _s=K.setTimeout,bs=K.clearTimeout;function Ue(e,t){t.useNativeTimers?(e.setTimeoutFn=_s.bind(K),e.clearTimeoutFn=bs.bind(K)):(e.setTimeoutFn=K.setTimeout.bind(K),e.clearTimeoutFn=K.clearTimeout.bind(K))}var ws=1.33;function Os(e){return typeof e=="string"?Ps(e):Math.ceil((e.byteLength||e.size)*ws)}function Ps(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 vr(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function As(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function Ls(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 Is=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},vt=class extends _{constructor(e){super(),this.writable=!1,Ue(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 Is(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=Xe(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=As(e);return t.length?"?"+t:""}},Fs=class extends vt{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)};Lr(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,Ar(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=vr()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Mr=!1;try{Mr=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Cs=Mr;function Ss(){}var vs=class extends Fs{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}},Ne=class Ze extends _{constructor(t,r,o){super(),this.createRequest=t,Ue(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=Sr(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=Ze.requestsCount++,Ze.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=Ss,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Ze.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()}};Ne.requestsCount=0;Ne.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Cr);else if(typeof addEventListener=="function"){let e="onpagehide"in K?"pagehide":"unload";addEventListener(e,Cr,!1)}}function Cr(){for(let e in Ne.requests)Ne.requests.hasOwnProperty(e)&&Ne.requestse.abort()}var Ms=function(){let e=Ur({xdomain:!1});return e&&e.responseType!==null}(),Mt=class extends vs{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ms&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ne(Ur,this.uri(),e)}};function Ur(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Cs))return new XMLHttpRequest}catch{}if(!t)try{return new K["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Br=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Us=class extends vt{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=Br?{}:Sr(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;Je(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=vr()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Ct=K.WebSocket||K.MozWebSocket,Ut=class extends Us{createSocket(e,t,r){return Br?new Ct(e,t,r):t?new Ct(e,t):new Ct(e)}doWrite(e,t){this.ws.send(t)}},Dr=class extends vt{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=Fr(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: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=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()}},Bs={websocket:Ut,webtransport:Dr,polling:Mt},Ds=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,Hs="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function ot(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=Ds.exec(e||""),s={},i=14;for(;i--;)s[Hsi]=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=js(s,s.path),s.queryKey=$s(s,s.query),s}function js(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 $s(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(o,n,s){n&&(rn=s)}),r}var St=typeof addEventListener=="function"&&typeof removeEventListener=="function",et=[];St&&addEventListener("offline",()=>{et.forEach(e=>e())},!1);var tt=class rt extends _{constructor(t,r){if(super(),this.binaryType=ks,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=ot(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=ot(r.host).host);Ue(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=Ls(this.opts.query)),St&&(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"})},et.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&&rt.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",rt.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+=Os(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(rt.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(),St&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=et.indexOf(this._offlineEventListener);o!==-1&&et.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};tt.protocol=Ft;var Ws=class extends tt{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;tt.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;tt.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(u(),this.setTransport(t),t.send({type:"upgrade"}),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let h=new Error("probe error");h.transport=t.name,this.emitReserved("upgradeError",h)}}))};function n(){r||(r=!0,u(),t.close(),t=null)}let s=p=>{let h=new Error("probe error: "+p);h.transport=t.name,n(),this.emitReserved("upgradeError",h)};function i(){s("transport closed")}function a(){s("socket closed")}function c(p){t&&p.name!==t.name&&n()}let u=()=>{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(er)&&t.push(er);return t}},Bt=class extends Ws{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=>Bso).filter(o=>!!o)),super(e,r)}};var bu=Bt.protocol;var $t={};ns($t,{Decoder:()=>Xs,Encoder:()=>Js,PacketType:()=>x,protocol:()=>$r});var qs=typeof ArrayBuffer=="function",Gs=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,jr=Object.prototype.toString,Vs=typeof Blob=="function"||typeof Blob<"u"&&jr.call(Blob)==="object BlobConstructor",Ks=typeof File=="function"||typeof File<"u"&&jr.call(File)==="object FileConstructor";function jt(e){return qs&&(e instanceof ArrayBuffer||Gs(e))||Vs&&e instanceof Blob||Ks&&e instanceof File}function nt(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if(nt(er))return!0;return!1}if(jt(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return nt(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&nt(er))return!0;return!1}function Ys(e){let t=[],r=e.data,o=e;return o.data=Dt(r,t),o.attachments=t.length,{packet:o,buffers:t}}function Dt(e,t){if(!e)return e;if(jt(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=Dt(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=Dt(eo,t));return r}return e}function zs(e,t){return e.data=Ht(e.data,t),delete e.attachments,e}function Ht(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=Ht(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=Ht(er,t));return e}var Qs="connect","connect_error","disconnect","disconnecting","newListener","removeListener",$r=5,x;(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"})(x||(x={}));var Js=class{constructor(e){this.replacer=e}encode(e){return(e.type===x.EVENT||e.type===x.ACK)&&nt(e)?this.encodeAsBinary({type:e.type===x.EVENT?x.BINARY_EVENT:x.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===x.BINARY_EVENT||e.type===x.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=Ys(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 Xs=class Wr extends _{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===x.BINARY_EVENT;o||r.type===x.BINARY_ACK?(r.type=o?x.EVENT:x.ACK,this.reconstructor=new Zs(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(jt(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(xo.type===void 0)throw new Error("unknown packet type "+o.type);if(o.type===x.BINARY_EVENT||o.type===x.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(Wr.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 x.CONNECT:return Hr(r);case x.DISCONNECT:return r===void 0;case x.CONNECT_ERROR:return typeof r=="string"||Hr(r);case x.EVENT:case x.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&Qs.indexOf(r0)===-1);case x.ACK:case x.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},Zs=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=zs(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ei(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=ot(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 Z(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var ti=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),qr=class extends _{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=Z(e,"open",this.onopen.bind(this)),Z(e,"packet",this.onpacket.bind(this)),Z(e,"error",this.onerror.bind(this)),Z(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(ti.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:x.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof tt.length-1=="function"){let c=this.ids++,u=t.pop();this._registerAckCallback(c,u),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.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:x.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 x.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 x.EVENT:case x.BINARY_EVENT:this.onevent(e);break;case x.ACK:case x.BINARY_ACK:this.onack(e);break;case x.DISCONNECT:this.ondisconnect();break;case x.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:x.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:x.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 _e(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}_e.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};_e.prototype.reset=function(){this.attempts=0};_e.prototype.setMin=function(e){this.ms=e};_e.prototype.setMax=function(e){this.max=e};_e.prototype.setJitter=function(e){this.jitter=e};var Wt=class extends _{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,Ue(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 _e({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||$t;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 Bt(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=Z(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=Z(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(Z(e,"ping",this.onping.bind(this)),Z(e,"data",this.ondata.bind(this)),Z(e,"error",this.onerror.bind(this)),Z(e,"close",this.onclose.bind(this)),Z(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 qr(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)}},Be={};function ke(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=ei(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=Ben&&s in Ben.nsps,a=t.forceNew||t"force new connection"||t.multiplex===!1||i,c;return a?c=new Wt(o,t):(Ben||(Ben=new Wt(o,t)),c=Ben),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(ke,{Manager:Wt,Socket:qr,io:ke,connect:ke});function S(e){return e.val}function H(e){return e.err}var Gr=" must not return ",ri="transformer",oi="recoverer",ni="defaultValue",be=ri+Gr,se="called with ",we=ni+" must not be ",Oe=oi+Gr;var si="Ok",Vr="Err",Kr=se+Vr,Yr=se+si,ii="Carrying E in "+Vr+" instead of throwing it directly. See .cause",qt="an instance of Error of the current realm.",fl="The thrown value is not "+qt,dl="The contained E should be "+qt,ai="This .cause is not "+qt;function w(e){return e.ok}function E(e){return{ok:!0,val:e,err:null}}function g(e){return!e.ok}function k(e){return{ok:!1,val:null,err:e}}function T(e){return zr(e,Kr)}function ye(e){return Qr(e,Yr)}function zr(e,t){if(g(e))throw new TypeError(t);return e.val}function Qr(e,t){if(w(e))throw new TypeError(t);return e.err}async function Pe(e,t){if(g(e))return e;let r=S(e);return await t(r)}function De(e,t){if(g(e))return e;let r=S(e),o=t(r);return E(o)}async function I(e,t){if(g(e))return e;let r=S(e),o=await t(r);return E(o)}async function v(e,t){if(w(e))return e;let r=H(e),o=await t(r);return k(o)}var st="null",wm=be+st,ui=se+st,Om=we+st,Pm=Oe+st;var it="undefined",Cm=be+it,li=se+it,Sm=we+it,vm=Oe+it;var C=e=>e.ok?E(e):k({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Xr=async(e,t)=>{let r=new Request(e,t);try{return E(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return k({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return k({name:"NetworkError",message:o.message,request:r});throw o}};var O=e=>{let{fetch:t=Xr,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Zr=e=>{let{sid:t,hostName:r}=O(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:L(t)}}:void 0)},eo=e=>I(C(e),async t=>await t.json()),Gt=(()=>{let e=async t=>{let{fetch:r,...o}=O(t??{}),n=await r(Zr(o));return g(n)?n:eo(T(n))};return e.toRequest=Zr,e.fromResponse=eo,e})();var L=e=>connect.sid=${e};var at=(e,t)=>{if(e?.connected)return Promise.resolve(E(e));e??=ke("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"],...t?{rejectUnauthorized:!1,extraHeaders:{Cookie:L(t),Host:"scrapbox.io",Referer:"https://scrapbox.io/"}}:{}});let r=new Promise(o=>{let n=s=>o(k(s));e.once("connect",()=>{e.off("disconnect",n),o(E(e))}),e.once("disconnect",n)});return e.connect(),r},He=e=>{if(e.disconnected)return Promise.resolve(E(void 0));let t=new Promise(r=>{let o=n=>{if(n!=="io client disconnect"){r(k(n));return}r(E(void 0)),e.off("disconnect",o)};e.on("disconnect",o)});return e.disconnect(),t};var to=e=>di.includes(e.name),di="SocketIOError","DuplicateTitleError","NotFastForwardError";var ro=(e,t,r,o)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(E(void 0));let{resolve:n,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(p)},c=y=>{if(y==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(y==="io server disconnect"){a(),n(k({name:"SocketIOError"}));return}};e.on("disconnect",c);let u=o?.timeout??9e4,p=setTimeout(()=>{a(),n(k({name:"TimeoutError",message:exceeded ${u} (ms)}))},u),h=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",h,y=>{if(a(),"error"in y){n(k(to(y.error)?y.error:{name:"UnexpectedRequestError",...y}));return}n(E(y.data))}),s};function ct(e,t={}){if(e===null)return"null";if(Array.isArray(e))return hi(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:yi(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function hi(e,t){let{threshold:r=20}=t,o=e.map(i=>ct(i,t)),n=o.join(", ");if(n.length<=r)return[${n}];let s=o.join(`,
);return[
${oo(2,s)}
]}function yi(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${ct(ei,t)}),n=o.join(", ");if(n.length<=r)return{${n}};let s=o.join(,
);return{
${oo(2,s)}
}}function oo(e,t){let r=" ".repeat(e);return t.split(
).map(o=>${r}${o}).join(
)}function pt(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${t}(${r.map(n=>ct(n)).join(", ")}),o)}})}function no(e){return pt(t=>Ge(t)&&t.every(r=>e(r)),"isArrayOf",e)}function Vt(e){let t=new Set(e);return pt(r=>t.has(r),"isLiteralOneOf",e)}function Kt(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}var U=async(e,t)=>{let r=e.response.clone(),o=Vt(t);try{let n=await r.json();if(!Kt(n))return;if(r.status===422){if(!X(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!X(n.message)?void 0:n.name==="NotLoggedInError"?!Kt(n.detals)||!X(n.detals.project)||!no(gi)(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}},gi=Vt(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var ut="null or undefined",Ae=be+ut,Ei=se+ut,lt=we+ut,mt=Oe+ut;function Y(e){return e!=null}function ee(e,t){if(Y(e))return e;throw new TypeError(t)}function ft(e,t){return Y(e)?e:ee(t,lt)}var so=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:i}=O(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(https://${n}/api/pages/${e}/${he(t)}?${a},o?{headers:{Cookie:L(o)}}:void 0)},io=async e=>v(await I(C(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:ft(await U(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),po=(()=>{let e=async(t,r,o)=>Pe(await O(o??{}).fetch(so(t,r,o)),n=>io(n));return e.toRequest=so,e.fromResponse=io,e})(),ao=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:i}=O(t??{}),a=new URLSearchParams;return n!==void 0&&a.append("sort",n),s!==void 0&&a.append("limit",${s}),i!==void 0&&a.append("skip",${i}),new Request(https://${o}/api/pages/${e}?${a},r?{headers:{Cookie:L(r)}}:void 0)},co=async e=>v(await I(C(e),t=>t.json()),async t=>ft(await U(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),uo=(()=>{let e=async(t,r)=>Pe(await O(r??{})?.fetch(ao(t,r)),co);return e.toRequest=ao,e.fromResponse=co,e})();var lo=(e,t)=>{let{sid:r,hostName:o}=O(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:L(r)}}:void 0)},mo=async e=>I(await v(C(e),async t=>await U(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),fo=(()=>{let e=async(t,r)=>{let{fetch:o}=O(r??{}),n=lo(t,r),s=await o(n);return g(s)?s:mo(T(s))};return e.toRequest=lo,e.fromResponse=mo,e})();var zt=async(e,t,r)=>{let[o,n,s]=await Promise.all([po(e,t,r),Ri(r),Ti(e,r)]);return g(o)?o:g(n)?n:g(s)?s:E({...T(o),projectId:T(s),userId:T(n)})},Yt,Ri=async e=>{if(Yt)return E(Yt);let t=await Gt(e);if(g(t))return t;let r=T(t);return"id"in r?(Yt=r.id,E(r.id)):k({name:"NotLoggedInError",message:"This script cannot be used without login"})},ho=new Map,Ti=async(e,t)=>{let r=ho.get(e);return r?E(r):De(await fo(e,t),({id:o})=>(ho.set(e,o),o))};var ue=async(e,t,r,o)=>{let n=await at(o?.socket,o?.sid);if(g(n))return k({name:"UnexpectedRequestError",error:ye(n)});let s=T(n),i=await zt(e,t,o);if(g(i))return i;let a=T(i);try{let c=0,u=[],p;for(;o?.maxAttempts===void 0||c<o.maxAttempts;){let h=r(a,c,u,p);if(u=h instanceof Promise?await h:h,c++,u.length===0)return E(a.commitId);let y={kind:"page",projectId:a.projectId,pageId:a.id,parentId:a.commitId,userId:a.userId,changes:u,cursor:null,freeze:!0};for(;;){let b=await ro(s,"commit",y);if(w(b))return a.commitId=T(b).commitId,E(a.commitId);let A=ye(b),f=A.name;if(f==="SocketIOServerDisconnectError"||f==="UnexpectedRequestError")return k(A);if(f==="TimeoutError"||f==="SocketIOError"){await de(3e3);continue}if(f==="NotFastForwardError"){await de(1e3);let F=await zt(e,t,o);if(g(F))return F;a=T(F)}p=f;break}}return k({name:"RetryError",attempts:c,message:Retrying exceeded the maxAttempts (${c}).})}finally{o?.socket||await He(s)}};var Qt=(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 u(f,F,l){let d=Math.max(F,l),J=d-f;for(;J<o.length&&d<n.length&&o[J]===n[d];)++J,++d;return a[f+s]=c.length,c.push([{x:J,y:d},a[f+(F>l?-1:1)+s]]),d}let p=new Array(i);p.fill(-1);let h=-1,y=n.length-o.length;do{++h;for(let f=-h;f<=y-1;++f)p[f+s]=u(f,p[f-1+s]+1,p[f+1+s]);for(let f=y+h;f>=y+1;--f)p[f+s]=u(f,p[f-1+s]+1,p[f+1+s]);p[y+s]=u(y,p[y-1+s]+1,p[y+1+s])}while(p[y+s]!==n.length);let b=[],A=a[y+s];for(;A!==-1;)b.push(c[A][0]),A=c[A][1];return{from:e,to:t,editDistance:y+h*2,buildSES:function*(){let f=0,F=0;for(let{x:l,y:d}of Ni(b))for(;f<l||F<d;)d-l>F-f?(yield{value:n[F],type:r?"deleted":"added"},++F):d-l<F-f?(yield{value:o[f],type:r?"added":"deleted"},++f):(yield{value:o[f],type:"common"},++f,++F)}}};function*Jt(e){let t=[],r=[];function*o(){if(t.length>r.length){for(let n=0;n<r.length;n++)yield yo(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 yo(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 yo=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*Ni(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var go=e=>e.padStart(8,"0"),Xt=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${go(t).slice(-8)}${e.slice(-6)}0000${go(r)}};function*Zt(e,t,{userId:r}){let{buildSES:o}=Qt(e.map(({text:i})=>i),t),n=0,s=e[0].id;for(let i of Jt(o())){switch(i.type){case"added":yield{_insert:s,lines:{id:Xt(r),text:i.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:i.value}};break}n++,s=e[n]?.id??"_end"}}var ki=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),Eo=(e,t)=>{let r=e[e.length-1];return r!==void 0&&ki(r,t)?(r.rows.push(t),e):(e.push({type:/^\s*code:/.test(t.text)?"codeBlock":/^\s*table:/.test(t.text)?"table":"line",rows:[t]}),e)},xo=(e,t)=>{if(t.hasTitle??!0){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(Eo,[])]}return e.reduce(Eo,[])};var Ro=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var To=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(i=>i.text.substring(o+1)).join(
)}};var R=(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 u=n.substring(0,c.index),p=n.substring(c.index+(c[0]?.length??0)),h=e(c[0]??"",s);return[...j(u,s),...h,...j(p,s)]}return i?.()??[]};var N=e=>[{type:"plain",raw:e,text:e}],No=R(N,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var _i=/\[\s+\]/,bi=(e,t)=>t.context==="table"?N(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],ko=R(bi,{parseOnNested:!1,parseOnQuoted:!0,patterns:[_i]});var wi=/.*?/,Oi=(e,t)=>t.context==="table"?N(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],_o=R(Oi,{parseOnNested:!1,parseOnQuoted:!0,patterns:[wi]});var Pi=/^[$%] .+$/,Ai=(e,t)=>{if(t.context==="table")return N(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},bo=R(Ai,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Pi]});var Li=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Ii=(e,t)=>{if(t.context==="table")return N(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:j(n,{...t,nested:!0})}]},wo=R(Ii,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Li]});var Fi=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,Ci=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,Si=/\[https?:\/\/[^\s\]]+\]/,vi=/https?:\/\/[^\s]+/,Mi=(e,t)=>{if(t.context==="table")return N(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()}]},Oo=R(Mi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Fi,Ci,Si,vi]});var Ui=/\[\$ .+? \]/,Bi=/\[\$ [^\]]+\]/,Di=(e,t)=>t.context==="table"?N(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Po=R(Di,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ui,Bi]});var Ao=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Lo=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Hi=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}},ji=(e,t)=>{if(t.context==="table")return N(e,t);let r=e.match(Ao)??e.match(Lo);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}=Hi(n),u=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:u}]},Io=R(ji,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ao,Lo]});var $i=/(?:^|\s)#\S+/,Wi=(e,t)=>{if(t.context==="table")return N(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[...N(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},Fo=R(Wi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[$i]});var qi=/^\? .+$/,Gi=(e,t)=>t.context==="table"?N(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],Co=R(Gi,{parseOnNested:!1,parseOnQuoted:!1,patterns:[qi]});var Vi=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,Ki=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}))},So=R(Ki,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Vi]});var Yi=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,zi=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,Qi=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,Ji=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,Xi=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Zi(e),Zi=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),ea=(e,t)=>{if(t.context==="table")return N(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]=Xi(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}]},vo=R(ea,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Yi,zi,Qi,Ji]});var ta=/\[\/?[^[\]]+\]/,ra=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},Mo=R(ra,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ta]});var oa=/^[0-9]+\. .*$/,na=(e,t)=>{if(t.context==="table")return N(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:j(s,{...t,nested:!1})}]},Uo=R(na,{parseOnNested:!1,parseOnQuoted:!1,patterns:[oa]});var sa=/^>.*$/,ia=(e,t)=>t.context==="table"?N(e,t):[{type:"quote",raw:e,nodes:j(e.substring(1),{...t,quoted:!0})}],Bo=R(ia,{parseOnNested:!1,parseOnQuoted:!1,patterns:[sa]});var aa=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,ca=(e,t)=>{if(t.context==="table")return N(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}))},Do=R(ca,{parseOnNested:!1,parseOnQuoted:!0,patterns:[aa]});var pa=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,ua=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,la=(e,t)=>{if(t.context==="table")return N(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}]},Ho=R(la,{parseOnNested:!1,parseOnQuoted:!0,patterns:[pa,ua]});var ma=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,fa=(e,t)=>t.context==="table"?N(e,t):[{type:"strong",raw:e,nodes:j(e.substring(2,e.length-2),{...t,nested:!0})}],jo=R(fa,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ma]});var da=(e,t,r)=>e===""?[]:r?.()??[],ha=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>No(t,r))(),j=ha(da,Bo,Co,Uo,_o,bo,Po,ko,wo,Ho,Do,jo,vo,Oo,So,Io,Mo,Fo);var $o=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:j(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Wo=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(i=>i.text.substring(o+1)).map(i=>i.split(" ").map(a=>j(a,{nested:!1,quoted:!1,context:"table"})))}};var qo=e=>({type:"title",text:e.rows[0].text});var Go=e=>{switch(e.type){case"title":return qo(e);case"codeBlock":return To(e);case"table":return Wo(e);case"line":return $o(e)}};var er=(e,t)=>{let r=Ro(e);return xo(r,{hasTitle:t?.hasTitle??!0}).map(Go)};var ya=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,ga=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,Ea=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,xa=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Vo=e=>{if(ya.test(e)){let t=new URL(e).searchParams,r=t.get("v");if(r)return{pathType:"com",videoId:r,params:t}}{let t=e.match(ga);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(Ea);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(xa);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var zo=e=>{let t=er(e,{hasTitle:!0}),r="",o=new Map,n=[],s=new Set,i=[],a=new Set,c=[],u=null,p=[],h=new Set,y=new Set,b=new RegExp(${globalThis.location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),A=l=>{switch(l.type){case"hashTag":if(o.has(te(l.href)))return;o.set(te(l.href),!1),n.push(l.href);return;case"link":switch(l.pathType){case"relative":{let d=Yo(l.href);if(o.get(te(d)))return;o.set(te(d),!0),n.push(d);return}case"root":{let d=Yo(l.href);if(/^\/[\w\d-]+\/?$/.test(d)||s.has(te(d)))return;s.add(te(d)),i.push(d);return}case"absolute":{if(l.content)return;let d=Vo(l.href);if(d&&d.pathType!=="list"){u??=https://i.ytimg.com/vi/${d.videoId}/mqdefault.jpg;return}let J=l.href.match(b)?.[1];J&&h.add(J);return}default:return}case"icon":case"strongIcon":{if(l.pathType==="root"||a.has(te(l.path)))return;a.add(te(l.path)),c.push(l.path);return}case"image":case"strongImage":{u??=l.src.endsWith("/thumb/1000")?l.src.replace(/\/thumb\/1000$/,"/raw"):l.src;{let d=l.src.match(b)?.[1];d&&h.add(d)}if(l.type==="image"){let d=l.link.match(b)?.[1];d&&h.add(d)}return}case"helpfeel":y.add(l.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let d of l.nodes)A(d);return}default:return}},f=[];for(let l of t)switch(l.type){case"title":{r=l.text;continue}case"line":p.length<5&&l.nodes.length>0&&p.push(l.nodes[0].type==="helpfeel"||l.nodes[0].type==="commandLine"?Ko(l.nodes[0].raw):l.nodes.map(d=>d.raw).join("").trim().slice(0,200));for(let d of l.nodes)A(d);continue;case"codeBlock":p.length<5&&p.push(Ko(l.content));continue;case"table":{for(let d of l.cells)for(let J of d)for(let Pt of J)A(Pt);if(!["infobox","cosense"].includes(l.fileName))continue;f.push(...l.cells.map(d=>d.map(J=>J.map(Pt=>Pt.raw).join("")).join(" ").trim()));continue}}let F=e.split(
);return[r,n,i,c,u,p,[...h],[...y],f,F.length,F.reduce((l,d)=>l+[...d].length,0)]},Ko=e=>\${e.trim().replaceAll("","\\").slice(0,198)}\`,Yo=e=>e.replace(/#a-f\d{24,32}$/,""),Qo=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?t.trimStart().slice(2):[]);var le=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));function*Jo(e,t,r){let o=t.flatMap(f=>(X(f)?f:f.text).split(`
));for(let f of Zt(e.lines,o,{userId:r}))yield f;let[n,s,i,a,c,u,p,h,y,b,A]=zo(o.join(
));(e.title!==n||!e.persistent)&&(yield{title:n}),le(e.links,s)||(yield{links:s}),le(e.projectLinks,i)||(yield{projectLinks:i}),le(e.icons,a)||(yield{icons:a}),e.image!==c&&(yield{image:c}),le(e.descriptions,u)||(yield{descriptions:u}),le(e.files,p)||(yield{files:p}),le(Qo(e.lines),h)||(yield{helpfeels:h}),le(e.infoboxDefinition,y)||(yield{infoboxDefinition:y}),yield{linesCount:b},yield{charsCount:A}}var Xo=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,o=t?.[2]?parseInt(t[2])+1:2;return${r}_${o}};var Zo=(e,t,r)=>ue(e,t,o=>{if(o.pin>0||!o.persistent&&!(r?.create??!1))return[];let n=[{pin:tr()}];return o.persistent||n.unshift({title:t}),n},r),en=(e,t,r)=>ue(e,t,o=>o.pin==0||!o.persistent?[]:[{pin:0}],r),tr=()=>Number.MAX_SAFE_INTEGER-Math.floor(Date.now()/1e3);var tn=(e,t,r,o)=>ue(e,t,async(n,s,i,a)=>{if(a==="DuplicateTitleError"){let b=Xo(t);return i.map(A=>("title"in A&&(A.title=b),A))}let c=r(n.lines,{...n,attempts:s}),u=c instanceof Promise?await c:c;if(u===void 0)return[];let[p,h]=Array.isArray(u)?[u,void 0]:[u.lines,u.pin];if(p.length===0)return[{deleted:!0}];let y=n.lines===p?[]:[...Jo(n,p,n.userId)];return h!==void 0&&(h&&n.pin===0||!h&&n.pin>0)&&y.push({pin:h?tr():0}),y},o);var Na=Math.pow(10,8)*24*60*60*1e3,lT=-Na,rn=6048e5,on=864e5,nn=6e4,sn=36e5;var ka=3600;var an=ka*24,mT=an*7,_a=an*365.2425,ba=_a/12,fT=ba*3,rr=Symbol.for("constructDateFrom");function B(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&rr in e?e[rr](t):e instanceof Date?new e.constructor(t):new Date(t)}function m(e,t){return B(t||e,e)}function or(e,t){return m(e,t?.in).getFullYear()}var wa={};function Le(){return wa}function ie(e,t){let r=Le(),o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,n=m(e,t?.in),s=n.getDay(),i=(s<o?7:0)+s-o;return n.setDate(n.getDate()-i),n.setHours(0,0,0,0),n}function cn(e,t){let r=m(e,t?.in),o=r.getFullYear(),n=Le(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=B(t?.in||e,0);i.setFullYear(o+1,0,s),i.setHours(0,0,0,0);let a=ie(i,t),c=B(t?.in||e,0);c.setFullYear(o,0,s),c.setHours(0,0,0,0);let u=ie(c,t);return+r>=+a?o+1:+r>=+u?o:o-1}function pn(e,t){let r=Le(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,n=cn(e,t),s=B(t?.in||e,0);return s.setFullYear(n,0,o),s.setHours(0,0,0,0),ie(s,t)}function je(e,t){let r=m(e,t?.in),o=+ie(r,t)-+pn(r,t);return Math.round(o/rn)+1}function un(e,t){return m(e,t?.in).getDate()}function ln(e,t){return m(e,t?.in).getMonth()}var nr=(e,t)=>{let r=0,o=[];for(let n=0;n<t.length;n++){let s=e.findIndex((i,a)=>a>=r&&i.trim()===t[n].trim());if(s<0){o.push(t[n]);continue}o.push(...e.slice(r,s+1)),r=s+1}return o.push(...e.slice(r)),o},sr=(e,t)=>{let r=-1;for(let o of t){let n=e.findIndex((s,i)=>i>r&&s.trim()===o.trim());if(n<0)return-1;r=n}return r},ae=e=>${e}.padStart(2,"0"),ir=e=>${or(e)},ar=(e,t)=>${ir(e)}${t}${ae(ln(e)+1)},mn=(e,t)=>${or(e)}${t}w${ae(je(e))},dt=(e,t)=>${ar(e,t)}${t}${ae(un(e))};var cr=(e,t,r)=>{let o=nr(nr(e,t).reverse(),[...r].reverse()).reverse(),n=sr(o,t),s=o.length-1-sr([...o].reverse(),[...r].reverse());return[...o.slice(0,n+1),"",...o.slice(n+1,s).join(
).trim().split(
),"",...o.slice(s)]};var fn=(e,t,r,o)=>{let{sid:n,hostName:s}=O(o??{});return new Request(https://${s}/api/code/${e}/${he(t)}/${he(r)},n?{headers:{Cookie:L(n)}}:void 0)},dn=async e=>I(await v(C(e),async t=>t.response.status===404&&t.response.headers.get("Content-Type")?.includes?.("text/plain")?{name:"NotFoundError",message:"Code block is not found"}:await U(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),yt=(()=>{let e=async(t,r,o,n)=>{let s=fn(t,r,o,n),i=await O(n??{}).fetch(s);return g(i)?i:dn(T(i))};return e.toRequest=fn,e.fromResponse=dn,e})();var Ak=new TextEncoder;var Ck=new TextEncoder().encode("0123456789abcdef"),Sk=new TextEncoder,vk=new TextDecoder;async function*hn(e,t){let r=0,o=t?.limit??100;for(;;){let n=await uo(e,{...t,limit:o,sort:"updated",skip:r});if(g(n))return;let s=T(n).pages;for(let a of s)a.pin!==0&&(yield a);let i=s.at(-1);if(T(n).count<o||(i?.pin??0)===0)return;r+=o}}var yn=" must not return ",Oa="transformer",Pa="recoverer",Aa="defaultValue",gt=Oa+yn,ge="called with ",Et=Aa+" must not be ",xt=Pa+yn;var La="Ok",gn="Err",En=ge+gn,Ia=ge+La,Fa="Carrying E in "+gn+" instead of throwing it directly. See .cause",pr="an instance of Error of the current realm.",E_="The thrown value is not "+pr,x_="The contained E should be "+pr,Ca="This .cause is not "+pr;function ce(e){return{ok:!0,val:e,err:null}}function W(e){return!e.ok}function $e(e){return xn(e,En)}function xn(e,t){if(W(e))throw new TypeError(t);return e.val}var Rt="null",bb=gt+Rt,Ma=ge+Rt,wb=Et+Rt,Ob=xt+Rt;var Tt="undefined",Fb=gt+Tt,Ua=ge+Tt,Cb=Et+Tt,Sb=xt+Tt;var me=e=>e.ok,qe=e=>!e.ok,ur=(e,t,r,o)=>({ok:!0,location:e,value:t,furthest:r,expected:o}),Nt=(e,t)=>({ok:!1,furthest:e,expected:t});var lr=e=>({index:e[0],line:e[1],column:e[2]}),Q=(e,t,r)=>ur(Tn(e,t),r,[-1,-1,-1],[]),Ee=(e,t,r)=>Nt(Tn(e,t),r),fe=(e,t)=>{let r=t.furthest[0]-e.furthest[0];if(r>0)return t;let o=r<0?e.expected:[...new Set([...e.expected,...t.expected])];return me(t)?ur(t.location,t.value,e.furthest,o):Nt(e.furthest,o)},Tn=(e,t,r)=>{let[o,n]=e,[s,i,a]=n;if(t==s)return n;let c=t;if(typeof o=="string"){r??=[
];let u=o.slice(s,c);for(let p of u)r.includes(p)?(i++,a=1):a++}else for(let u=s;u<c;u++){let p=o[u];r?.includes?.(p)?(i++,a=1):a++}return[t,i,a]};var xe=(e,t)=>r=>{let o=e(r);if(qe(o))return o;let n=t(o.value);return fe(o,n([r[0],o.location]))};var M=e=>t=>Q(t,t[1][0],e);var G=(e,t)=>xe(e,r=>M(t(r)));var kt=(...e)=>e.reduce((t,r)=>xe(t,o=>G(r,n=>[...o,n])),M([]));var oe=(e,t)=>r=>{let o=e(r);if(qe(o))return o;r=[r[0],o.location];let n=fe(o,t(r));if(me(n)){let s=[o.value,n.value];return fe(n,Q(r,n.location[0],s))}return n};var V=(e,t)=>r=>{let o=e(r);return me(o)?o:fe(o,t(r))};var mr=(...e)=>e.reduce((t,r)=>V(t,r));var Nn="<EOF>",kn=e=>{let[t,[r]]=e;return r<t.length?Ee(e,r,[Nn]):Q(e,r,Nn)};var _t=e=>{for(let r of e.flags)switch(r){case"i":case"s":case"m":case"u":continue;default:throw new Error("only the regexp flags 'imsu' are supported")}let t=new RegExp(e.source,e.flags+"y");return r=>{let[o,[n]]=r;t.lastIndex=n;let s=o.match(t);if(s){let i=n+s[0].length,a=o.slice(n,i);return Q(r,i,a)}return Ee(r,n,[${e}])}};var ne=(e,t)=>G(oe(e,t),([,r])=>r);var fr=(e,t)=>G(oe(e,t),([r])=>r);var _n=(e,t)=>{let r=fr(e,kn)([t,[0,1,1]]);return r.ok?{ok:!0,value:r.value}:{ok:!1,location:lr(r.furthest),expected:r.expected}};var P=e=>t=>{let[r,[o]]=t,n=o+e.length;return r.slice(o,n)==e?Q(t,n,e):Ee(t,o,[e])};var bn=e=>{switch(e){case"Sun":return 0;case"Mon":return 1;case"Tue":return 2;case"Wed":return 3;case"Thu":return 4;case"Fri":return 5;default:return 6}};function wn(e,t){return m(e,t?.in).getHours()}function On(e,t){return m(e,t?.in).getMinutes()}function Pn(e){return m(e).getSeconds()}function Re(e,t,r){let o=m(e,r?.in);return isNaN(t)?B(r?.in||e,NaN):(t&&o.setDate(o.getDate()+t),o)}function Ie(e,t,r){let o=m(e,r?.in);if(isNaN(t))return B(r?.in||e,NaN);if(!t)return o;let n=o.getDate(),s=B(r?.in||e,o.getTime());s.setMonth(o.getMonth()+t+1,0);let i=s.getDate();return n>=i?s:(o.setFullYear(s.getFullYear(),s.getMonth(),n),o)}function An(e,t,r){return Re(e,t*7,r)}function bt(e,t,r){return Ie(e,t*12,r)}var In=e=>${ae(wn(e))},Fn=e=>${In(e)}:${ae(On(e))},Ha=e=>${Fn(e)}:${ae(Pn(e))},ja=P("yyyy"),$a=P("MM"),Wa=P("dd"),qa=P("ww"),Ga=P("HH"),Va=P("mm"),Ka=P("ss"),Ya=_t(/\s/),za=_t(/[^Mw]?/),Ln=P(":"),Qa=ne(Ga,V(ne(oe(Ln,Va),V(ne(oe(Ln,Ka),M(Ha)),M(Fn))),M(In))),Ja=G(_t(/[-+]\d+/),e=>parseInt(e)),Xa=mr(P("y"),P("m"),P("d"),P("w"),P("")),Za=oe(Ja,Xa),ec=P("("),tc=P(")"),rc=G(kt(ec,mr(P("Sun"),P("Mon"),P("Tue"),P("Wed"),P("Thu"),P("Fri"),P("Sat")),tc),([,e])=>bn(e)),oc=ne(ja,V(xe(za,e=>{let t=P(e);return V(ne($a,V(ne(oe(t,Wa),M(r=>dt(r,e))),M(r=>ar(r,e)))),ne(qa,M(r=>mn(r,e))))}),M(ir))),Cn=e=>_n(G(kt(oc,G(V(Za,M([0,"d"])),([t,r])=>o=>nc(o,t,r)),V(rc,M(void 0)),V(oe(Ya,Qa),M(["",()=>""]))),([t,r,o,[n,s]])=>i=>{let a=r(i),c=o!==void 0?Re(ie(a),o):a;return${t(c)}${n}${s(c)}}),e.slice(1,-1)),nc=(e,t,r)=>{switch(r){case"y":return bt(e,t);case"m":return Ie(e,t);case"w":return An(e,t);case"d":case"":return Re(e,t)}};function dr(e){let t=m(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function D(e,...t){let r=B.bind(null,e||t.find(o=>typeof o=="object"));return t.map(r)}function hr(e,t){let r=m(e,t?.in);return r.setHours(0,0,0,0),r}function wt(e,t,r){let[o,n]=D(r?.in,e,t),s=hr(o),i=hr(n),a=+s-dr(s),c=+i-dr(i);return Math.round((a-c)/on)}function Sn(e,t){let r=m(e,t?.in);return r.setFullYear(r.getFullYear(),0,1),r.setHours(0,0,0,0),r}function vn(e,t){let r=m(e,t?.in);return wt(r,Sn(r))+1}function Mn(e,t){let r=m(e,t?.in).getFullYear();return r%400===0||r%4===0&&r%100!==0}function Un(e,t){let r=m(e,t?.in);return Number.isNaN(+r)?NaN:Mn(r)?366:365}function Bn(e,t){let[r,o]=D(e,t.start,t.end);return{start:r,end:o}}function Fe(e,t,r){let{years:o=0,months:n=0,weeks:s=0,days:i=0,hours:a=0,minutes:c=0,seconds:u=0}=t,p=m(e,r?.in),h=n||o?Ie(p,n+o*12):p,y=i||s?Re(h,i+s*7):h,b=c+a*60,A=(u+b*60)*1e3;return B(r?.in||e,+y+A)}function Hn(e,t,r){let[o,n]=D(r?.in,e,t),s=Dn(o,n),i=Math.abs(wt(o,n));o.setDate(o.getDate()-s*i);let a=+(Dn(o,n)===-s),c=s*(i-a);return c===0?0:c}function Dn(e,t){let r=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return r<0?-1:r>0?1:r}function Ce(e){return t=>{let r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function jn(e,t,r){let[o,n]=D(r?.in,e,t),s=(+o-+n)/sn;return Ce(r?.roundingMethod)(s)}function Ot(e,t){return+m(e)-+m(t)}function $n(e,t,r){let o=Ot(e,t)/nn;return Ce(r?.roundingMethod)(o)}function Te(e,t){let r=+m(e)-+m(t);return r<0?-1:r>0?1:r}function Wn(e,t,r){let[o,n]=D(r?.in,e,t),s=o.getFullYear()-n.getFullYear(),i=o.getMonth()-n.getMonth();return s*12+i}function qn(e,t){let r=m(e,t?.in);return r.setHours(23,59,59,999),r}function Gn(e,t){let r=m(e,t?.in),o=r.getMonth();return r.setFullYear(r.getFullYear(),o+1,0),r.setHours(23,59,59,999),r}function Vn(e,t){let r=m(e,t?.in);return+qn(r,t)==+Gn(r,t)}function Kn(e,t,r){let[o,n,s]=D(r?.in,e,e,t),i=Te(n,s),a=Math.abs(Wn(n,s));if(a<1)return 0;n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*a);let c=Te(n,s)===-i;Vn(o)&&a===1&&Te(o,s)===1&&(c=!1);let u=i*(a-+c);return u===0?0:u}function Yn(e,t,r){let o=Ot(e,t)/1e3;return Ce(r?.roundingMethod)(o)}function zn(e,t,r){let[o,n]=D(r?.in,e,t);return o.getFullYear()-n.getFullYear()}function Qn(e,t,r){let[o,n]=D(r?.in,e,t),s=Te(o,n),i=Math.abs(zn(o,n));o.setFullYear(1584),n.setFullYear(1584);let a=Te(o,n)===-s,c=s*(i-+a);return c===0?0:c}function Jn(e,t){let{start:r,end:o}=Bn(t?.in,e),n={},s=Qn(o,r);s&&(n.years=s);let i=Fe(r,{years:n.years}),a=Kn(o,i);a&&(n.months=a);let c=Fe(i,{months:n.months}),u=Hn(o,c);u&&(n.days=u);let p=Fe(c,{days:n.days}),h=jn(o,p);h&&(n.hours=h);let y=Fe(p,{hours:n.hours}),b=$n(o,y);b&&(n.minutes=b);let A=Fe(y,{minutes:n.minutes}),f=Yn(o,A);return f&&(n.seconds=f),n}function Xn(e,t,r){return bt(e,-t,r)}function Zn(e,t){return m(e,t?.in).getDay()}var Se=(e,t)=>t.split(
).flatMap(r=>r.replaceAll("@w@",${je(e)}).replaceAll("@ww@",${ae(je(e))}).replaceAll("@day_indicator@",${sc(e)}).replaceAll("@progress@",${(vn(e)*100/Un(e)).toFixed(2)}).replace(/^(\s*)@\[from_(\d{4})(\D?)(\d{2})(\D?)(\d{2})\]@\s*/,(o,n,s,i,a,c,u)=>{let p=new Date(parseInt(s),parseInt(a)-1,parseInt(u)),h=Jn({start:p,end:e}).years??0;return[...Array(h).keys()].map(y=>${n}${dt(Xn(e,y+1),i??c??"")}).join(
)}).replace(/@[^@]+@/g,o=>{let n=Cn(o);return n.ok?n.value(e):o}).split(
)),sc=e=>{let t=Zn(e);return[..."日月火水木金土"].map((r,o)=>o===t?${r}:r).join("")};var es=async(e,t)=>{let r=await yt(e,t,"title");if(W(r))return r;let o=await yt(e,t,"header");if(W(o))return o;let n=await yt(e,t,"footer");return W(n)?n:ce({title:$e(r),header:$e(o),footer:$e(n)})},yr=e=>({makeDiary:t=>({title:Se(t,e.title)[0],header:Se(t,e.header),footer:Se(t,e.footer)}),isOldDiary:(t,r)=>Se(r,t)[0]!==t});var rs=(e,t)=>{let r=t.interval??864e5,o,n=async()=>{s(),await ts(e,new Date,t),o=setInterval(()=>ts(e,new Date,t),r)},s=()=>clearInterval(o),i=()=>scrapbox.Project.name===e?n():s();return i(),scrapbox.addListener("project:changed",i),()=>{s(),scrapbox.removeListener("project:changed",i)}},ts=async(e,t,r)=>{let{render:o,dispose:n}=xr(),s;try{let i;if("title"in r)if("header"in r)i=yr(r);else{let h=await es(r.project??e,r.title);if(w(h))i=yr(T(h));else{let y=ye(h),b=Failed to load template from /${r.project??e}/${r.title}.
Please make sure this page includes the following 3 code blocks: "title", "header", and "footer".;o({type:"exclamation-triangle"},{type:"text",text:b}),console.error(b,y);return}}else i=r;let{makeDiary:a,isOldDiary:c}=i,u=await Pe(await at(),async h=>{s=h,o({type:"spinner"},{type:"text",text:"unpin other diary pages..."});for await(let{title:l}of hn(e)){if(!c(l,t))continue;let d=await en(e,l,{socket:s});if(g(d))return d}let{title:y,header:b,footer:A}=a(t);o({type:"spinner"},{type:"text",text:pin "/${e}/${y}"...});let f=await Zo(e,y,{socket:s,create:!0});if(g(f))return f;o({type:"spinner"},{type:"text",text:format "/${e}/${y}"...});let F=await tn(e,y,l=>[l[0].text,...cr(l.slice(1).map(d=>d.text),b,A)],{socket:s});return g(F)?F:(o({type:"check-circle"},{type:"text",text:Pinned "/${e}/${y}".}),await He(s),E(void 0))});if(w(u))return;let p=ye(u);o({type:"exclamation-triangle"},{type:"text",text:X(p)?SocketIO error: ${p}:${p.name}${"message"in p&&: ${p.message}}}),console.error(p)}catch(i){o({type:"exclamation-triangle"},{type:"text",text:i instanceof Error?${i.name} ${i.message}`:"Unknown error! (see developper console)"}),console.error(i)}finally{s&&await He(s),await de(1e3),n()}};rs("wogikaze-study",{project:"yuyasurarin",title:"pin-diary-script"});
以下は古いやつ
pin-diary-6-script