test-pin-diary
code:script.js
var ke=(e,r)=>{let t=0,o=[];for(let n=0;n<r.length;n++){let s=e.findIndex((a,i)=>i>=t&&a.trim()===rn.trim());if(s<0){o.push(rn);continue}o.push(...e.slice(t,s+1)),t=s+1}return o.push(...e.slice(t)),o},Ee=(e,r)=>{let t=-1;for(let o of r){let n=e.findIndex((s,a)=>a>t&&s.trim()===o.trim());if(n<0)return-1;t=n}return t};var ve=(e,r,t)=>{let o=ke(ke(e,r).reverse(),...t.reverse()).reverse(),n=Ee(o,r),s=o.length-1-Ee(...o.reverse(),...t.reverse());return[...o.slice(0,n+1),"",...o.slice(n+1,s).join(` ).trim().split(
),"",...o.slice(s)]};var g=e=>{let{fetch:r=globalThis.fetch,hostName:t="scrapbox.io",...o}=e;return{fetch:r,hostName:t,...o}};var Qt=e=>typeof e=="object"&&e!==null,Vt=e=>Qt(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,nt=e=>{try{let r=typeof e=="string"?JSON.parse(e):e;return Vt(r)?r:!1}catch(r){if(r instanceof SyntaxError)return!1;throw r}};var H=class extends Error{constructor(r){super(${r.status} ${r.statusText} when fetching ${r.url});this.response=r;this.name="UnexpectedResponseError";Error.captureStackTrace&&Error.captureStackTrace(this,H)}},b=async e=>{let r=e.clone(),t=await r.text(),o=nt(t);if(!o)throw new H(r);return{ok:!1,value:o}};var Ie=async e=>{let{sid:r,hostName:t,fetch:o}=g(e??{}),n=new Request(https://${t}/api/users/me,r?{headers:{Cookie:y(r)}}:void 0),s=await o(n);if(!s.ok)throw new H(s);return await s.json()};var y=e=>connect.sid=${e};var F=e=>e.replaceAll(" ","_").toLowerCase();var q=e=>[...e].map((r,t)=>r===" "?"_":!Xt.includes(r)||t===e.length-1&&Zt.includes(r)?encodeURIComponent(r):r).join(""),Xt='@$&+=:;",',Zt=':;",';var st=(e,r,t)=>{let{sid:o,hostName:n,followRename:s,projects:a}=g(t??{}),i=new URLSearchParams;i.append("followRename",${s??!0});for(let p of a??[])i.append("projects",p);let c=https://${n}/api/pages/${e}/${q(r)}?${i.toString()};return new Request(c,o?{headers:{Cookie:y(o)}}:void 0)},it=async e=>{if(!e.ok)return e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:b(e);let r=await e.json();return{ok:!0,value:r}},ae=async(e,r,t)=>{let{fetch:o}=g(t??{}),n=st(e,r,t),s=await o(n);return await it(s)};ae.toRequest=st;ae.fromResponse=it;var at=(e,r)=>{let{sid:t,hostName:o,sort:n,limit:s,skip:a}=g(r??{}),i=new URLSearchParams;n!==void 0&&i.append("sort",n),s!==void 0&&i.append("limit",${s}),a!==void 0&&i.append("skip",${a});let c=https://${o}/api/pages/${e}?${i.toString()};return new Request(c,t?{headers:{Cookie:y(t)}}:void 0)},ct=async e=>{if(!e.ok)return b(e);let r=await e.json();return{ok:!0,value:r}},Z=async(e,r)=>{let{fetch:t}=g(r??{}),o=await t(at(e,r));return await ct(o)};Z.toRequest=at;Z.fromResponse=ct;var dt=(e,r,t,o)=>{let{sid:n,hostName:s}=g(o??{}),a=https://${s}/api/table/${e}/${q(r)}/${encodeURIComponent(t)}.csv;return new Request(a,n?{headers:{Cookie:y(n)}}:void 0)},lt=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:b(e),pt=async(e,r,t,o)=>{let{fetch:n}=g(o??{}),s=dt(e,r,t,o),a=await n(s);return await lt(a)};pt.toRequest=dt;pt.fromResponse=lt;var ut=(e,r)=>{let{sid:t,hostName:o}=g(r??{});return new Request(https://${o}/api/projects/${e},t?{headers:{Cookie:y(t)}}:void 0)},mt=async e=>{if(!e.ok)return b(e);let r=await e.json();return{ok:!0,value:r}},ce=async(e,r)=>{let{fetch:t}=g(r??{}),o=ut(e,r),n=await t(o);return mt(n)};ce.toRequest=ut;ce.fromResponse=mt;var ft=(e,r)=>{let{sid:t,hostName:o}=g(r??{}),n=new URLSearchParams;for(let s of e)n.append("ids",s);return new Request(https://${o}/api/projects?${n.toString()},t?{headers:{Cookie:y(t)}}:void 0)},gt=async e=>{if(!e.ok)return b(e);let r=await e.json();return{ok:!0,value:r}},ht=async(e,r)=>{let{fetch:t}=g(r??{}),o=await t(ft(e,r));return gt(o)};ht.toRequest=ft;ht.fromResponse=gt;var D=async(e,r)=>{let t=await ae(e,r);if(!t.ok)throw new Error(You have no privilege of editing "/${e}/${r}".);let{commitId:o,persistent:n,image:s,links:a,projectLinks:i,lines:c,id:p,pin:l}=t.value;return{commitId:o,pageId:p,persistent:n,image:s,links:a,projectLinks:i,pin:l,lines:c}};var Jt="4.2.0";async function C(){let r=(await er())("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]});return await new Promise((t,o)=>{let n=s=>o(s);r.once("connect",()=>{r.off("disconnect",n),t()}),r.once("disconnect",n)}),r}function er(){let e=https://cdnjs.cloudflare.com/ajax/libs/socket.io/${Jt}/socket.io.min.js;if(document.querySelector(scriptsrc="${e}"))return Promise.resolve(window.io);let r=document.createElement("script");return r.src=e,new Promise((t,o)=>{r.onload=()=>t(window.io),r.onerror=n=>o(n),document.head.append(r)})}function O(e,r=9e4){function t(n,s){let a;return new Promise((i,c)=>{let p=l=>{clearTimeout(a),c(new Error(l))};e.emit(n,s,l=>{clearTimeout(a),e.off("disconnect",p),l.error&&c(new Error(JSON.stringify(l.error))),"data"in l?i(l?.data):i(void 0)}),a=setTimeout(()=>{e.off("disconnect",p),c(new Error(Timeout: exceeded ${r}ms))},r),e.once("disconnect",p)})}async function*o(...n){let s,a=()=>new Promise(c=>s=c),i=c=>{s?.(c)};for(let c of n)e.on(c,i);try{for(;;)yield await a()}finally{for(let c of n)e.off(c,i)}}return{request:t,response:o}}var le,P=async()=>{if(le!==void 0)return le;let e=await Ie();if(e.isGuest)throw new Error("this script can only be executed by Logged in users");return le=e.id,le},xt=new Map,B=async e=>{let r=xt.get(e);if(r!==void 0)return r;let t=await ce(e);if(!t.ok){let{name:n,message:s}=t.value;throw new Error(${n} ${s})}let{id:o}=t.value;return xt.set(e,o),o},yt=e=>e.padStart(8,"0"),Le=e=>{let r=Math.floor(new Date().getTime()/1e3).toString(16),t=Math.floor(16777214*Math.random()).toString(16);return${yt(r).slice(-8)}${e.slice(-6)}0000${yt(t)}};var pe=async(e,r,t)=>r.length===0?{commitId:t.parentId}:await e("socket.io-request",{method:"commit",data:{kind:"page",...t,changes:r,cursor:null,freeze:!0}}),_=async(e,r,{project:t,title:o,retry:n=3,parentId:s,...a})=>{try{s=(await pe(e,r,{parentId:s,...a})).commitId}catch{console.log("Faild to push a commit. Retry after pulling new commits");for(let c=0;c<n;c++){let{commitId:p}=await D(t,o);s=p;try{s=(await pe(e,r,{parentId:s,...a})).commitId,console.log("Success in retrying");break}catch{continue}}throw Error("Faild to retry pushing.")}return s};var bt=(e,r,t,o)=>{let{sid:n,hostName:s}=g(o??{}),a=https://${s}/api/code/${e}/${q(r)}/${q(t)};return new Request(a,n?{headers:{Cookie:y(n)}}:void 0)},wt=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404&&e.headers.get("Content-Type")?.includes?.("text/plain")?{ok:!1,value:{name:"NotFoundError",message:"Code block is not found"}}:b(e),kt=async(e,r,t,o)=>{let{fetch:n}=g(o??{}),s=bt(e,r,t,o),a=await n(s);return await wt(a)};kt.toRequest=bt;kt.fromResponse=wt;var Et=new TextEncoder().encode("0123456789abcdef");function vt(e){let r=new Uint8Array(e.length*2);for(let t=0;t<r.length;t++){let o=e[t];r[t*2]=Et[o>>4],r[t*2+1]=Et[o&15]}return r}var It="md5: data is invalid type",Y=64,Te=class{#e;#t;#r;#o;#n;#i;#s;#a;constructor(){this.#e=1732584193,this.#t=4023233417,this.#r=2562383102,this.#o=271733878,this.#n=new Uint8Array(Y),this.#i=0,this.#s=0,this.#a=0}#d(r){let t=this.#s;t+=r,t>4294967295&&(this.#a+=1),this.#s=t>>>0}#c(r){let t=this.#e,o=this.#t,n=this.#r,s=this.#o,a=$=>r[$]|r[$+1]<<8|r[$+2]<<16|r[$+3]<<24,i=($,ot)=>$<<ot|$>>>32-ot,c=a(0),p=a(4),l=a(8),x=a(12),h=a(16),E=a(20),w=a(24),f=a(28),I=a(32),T=a(36),L=a(40),R=a(44),oe=a(48),ne=a(52),se=a(56),ie=a(60);t=o+i(((n^s)&o^s)+t+c+3614090360,7),s=t+i(((o^n)&t^n)+s+p+3905402710,12),n=s+i(((t^o)&s^o)+n+l+606105819,17),o=n+i(((s^t)&n^t)+o+x+3250441966,22),t=o+i(((n^s)&o^s)+t+h+4118548399,7),s=t+i(((o^n)&t^n)+s+E+1200080426,12),n=s+i(((t^o)&s^o)+n+w+2821735955,17),o=n+i(((s^t)&n^t)+o+f+4249261313,22),t=o+i(((n^s)&o^s)+t+I+1770035416,7),s=t+i(((o^n)&t^n)+s+T+2336552879,12),n=s+i(((t^o)&s^o)+n+L+4294925233,17),o=n+i(((s^t)&n^t)+o+R+2304563134,22),t=o+i(((n^s)&o^s)+t+oe+1804603682,7),s=t+i(((o^n)&t^n)+s+ne+4254626195,12),n=s+i(((t^o)&s^o)+n+se+2792965006,17),o=n+i(((s^t)&n^t)+o+ie+1236535329,22),t=o+i(((o^n)&s^n)+t+p+4129170786,5),s=t+i(((t^o)&n^o)+s+w+3225465664,9),n=s+i(((s^t)&o^t)+n+R+643717713,14),o=n+i(((n^s)&t^s)+o+c+3921069994,20),t=o+i(((o^n)&s^n)+t+E+3593408605,5),s=t+i(((t^o)&n^o)+s+L+38016083,9),n=s+i(((s^t)&o^t)+n+ie+3634488961,14),o=n+i(((n^s)&t^s)+o+h+3889429448,20),t=o+i(((o^n)&s^n)+t+T+568446438,5),s=t+i(((t^o)&n^o)+s+se+3275163606,9),n=s+i(((s^t)&o^t)+n+x+4107603335,14),o=n+i(((n^s)&t^s)+o+I+1163531501,20),t=o+i(((o^n)&s^n)+t+ne+2850285829,5),s=t+i(((t^o)&n^o)+s+l+4243563512,9),n=s+i(((s^t)&o^t)+n+f+1735328473,14),o=n+i(((n^s)&t^s)+o+oe+2368359562,20),t=o+i((o^n^s)+t+E+4294588738,4),s=t+i((t^o^n)+s+I+2272392833,11),n=s+i((s^t^o)+n+R+1839030562,16),o=n+i((n^s^t)+o+se+4259657740,23),t=o+i((o^n^s)+t+p+2763975236,4),s=t+i((t^o^n)+s+h+1272893353,11),n=s+i((s^t^o)+n+f+4139469664,16),o=n+i((n^s^t)+o+L+3200236656,23),t=o+i((o^n^s)+t+ne+681279174,4),s=t+i((t^o^n)+s+c+3936430074,11),n=s+i((s^t^o)+n+x+3572445317,16),o=n+i((n^s^t)+o+w+76029189,23),t=o+i((o^n^s)+t+T+3654602809,4),s=t+i((t^o^n)+s+oe+3873151461,11),n=s+i((s^t^o)+n+ie+530742520,16),o=n+i((n^s^t)+o+l+3299628645,23),t=o+i((n^(o|~s))+t+c+4096336452,6),s=t+i((o^(t|~n))+s+f+1126891415,10),n=s+i((t^(s|~o))+n+se+2878612391,15),o=n+i((s^(n|~t))+o+E+4237533241,21),t=o+i((n^(o|~s))+t+oe+1700485571,6),s=t+i((o^(t|~n))+s+x+2399980690,10),n=s+i((t^(s|~o))+n+L+4293915773,15),o=n+i((s^(n|~t))+o+p+2240044497,21),t=o+i((n^(o|~s))+t+I+1873313359,6),s=t+i((o^(t|~n))+s+ie+4264355552,10),n=s+i((t^(s|~o))+n+w+2734768916,15),o=n+i((s^(n|~t))+o+ne+1309151649,21),t=o+i((n^(o|~s))+t+h+4149444226,6),s=t+i((o^(t|~n))+s+R+3174756917,10),n=s+i((t^(s|~o))+n+l+718787259,15),o=n+i((s^(n|~t))+o+T+3951481745,21),this.#e=this.#e+t>>>0,this.#t=this.#t+o>>>0,this.#r=this.#r+n>>>0,this.#o=this.#o+s>>>0}update(r){let t;if(typeof r=="string")t=new TextEncoder().encode(r);else if(typeof r=="object")if(r instanceof ArrayBuffer||ArrayBuffer.isView(r))t=new Uint8Array(r);else throw new TypeError(It);else throw new TypeError(It);let o=this.#i,n=Y-o;if(t.length<n)this.#n.set(t,o),o+=t.length;else{this.#n.set(t.slice(0,n),o),this.#c(this.#n);let s=n;for(;s+Y<=t.length;)this.#c(t.slice(s,s+Y)),s+=Y;this.#n.fill(0).set(t.slice(s),0),o=t.length-s}return this.#i=o,this.#d(t.length),this}digest(){let r=Y-this.#i;r<9&&(r+=Y);let t=new Uint8Array(r);t[0]=128;let o=this.#s<<3,n=this.#a<<3|this.#s>>>29;t[t.length-8]=o&255,t[t.length-7]=o>>>8&255,t[t.length-6]=o>>>16&255,t[t.length-5]=o>>>24&255,t[t.length-4]=n&255,t[t.length-3]=n>>>8&255,t[t.length-2]=n>>>16&255,t[t.length-1]=n>>>24&255,this.update(t.buffer);let s=new ArrayBuffer(16),a=new DataView(s);return a.setUint32(0,this.#e,!0),a.setUint32(4,this.#t,!0),a.setUint32(8,this.#r,!0),a.setUint32(12,this.#o,!0),s}toString(r="hex"){let t=this.digest();switch(r){case"hex":return new TextDecoder().decode(vt(new Uint8Array(t)));case"base64":{let o=new Uint8Array(t),n="";for(let s=0;s<o.length;++s)n+=String.fromCharCode(o[s]);return btoa(n)}default:throw new Error("md5: invalid format")}}};var Lt=!1;scrapbox.addListener("lines:changed",()=>Lt=!1);scrapbox.addListener("layout:changed",()=>Lt=!1);var Tt=(e,r)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${r}" must be HTMLDivElememt but actual is "${e}")};var Dt=()=>rr(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),rr=(e,r)=>{if(!!e)return Tt(e,r),e};var J=e=>new Promise(r=>setTimeout(()=>r(),e));var Ce=()=>{let e=Dt();if(!e)throw new Error("div.status-bar can't be found");let r=document.createElement("div");return e.append(r),{render:(...t)=>{r.textContent="";let o=Nt(...t);o&&r.append(o)},dispose:()=>r.remove()}},Nt=(...e)=>{let r=e.flatMap(o=>{switch(o.type){case"spinner":return[cr()];case"check-circle":return[dr()];case"exclamation-triangle":return[lr()];case"text":return[ue(o.text)];case"group":{let n=Nt(...o.items);return n?[n]:[]}}});if(r.length===0)return;if(r.length===1)return r[0];let t=document.createElement("span");return t.classList.add("item-group"),t.append(...r),t},ue=e=>{let r=document.createElement("span");return r.classList.add("item"),r.append(e),r},cr=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),ue(e)},dr=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),ue(e)},lr=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),ue(e)};var Ne=()=>C(),W=async e=>{if(e.connected)return;let r=new Promise(t=>e.once("connect",()=>t()));e.connect(),await r},N=async e=>{if(e.disconnected)return;let r=new Promise(t=>{let o=n=>{n==="io client disconnect"&&(t(),e.off("disconnect",o))};e.on("disconnect",o)});e.disconnect(),await r};var Me=(e,r)=>{let t=e.length>r.length,o=t?r:e,n=t?e:r,s=o.length+1,a=o.length+n.length+3,i=new Array(a);i.fill(-1);let c=[];function p(f,I,T){let L=Math.max(I,T),R=L-f;for(;R<o.length&&L<n.length&&o[R]===n[L];)++R,++L;return i[f+s]=c.length,c.push([{x:R,y:L},i[f+(I>T?-1:1)+s]]),L}let l=new Array(a);l.fill(-1);let x=-1,h=n.length-o.length;do{++x;for(let f=-x;f<=h-1;++f)l[f+s]=p(f,l[f-1+s]+1,l[f+1+s]);for(let f=h+x;f>=h+1;--f)l[f+s]=p(f,l[f-1+s]+1,l[f+1+s]);l[h+s]=p(h,l[h-1+s]+1,l[h+1+s])}while(l[h+s]!==n.length);let E=[],w=i[h+s];for(;w!==-1;)E.push(c[w][0]),w=c[w][1];return{from:e,to:r,editDistance:h+x*2,buildSES:function*(){let f=0,I=0;for(let{x:T,y:L}of ur(E))for(;f<T||I<L;)L-T>I-f?(yield{value:n[I],type:t?"deleted":"added"},++I):L-T<I-f?(yield{value:o[f],type:t?"added":"deleted"},++f):(yield{value:o[f],type:"common"},++f,++I)}}};function*Se(e){let r=[],t=[];function*o(){if(r.length>t.length){for(let n=0;n<t.length;n++)yield Mt(r[n],t[n]);for(let n=t.length;n<r.length;n++)yield r[n]}else{for(let n=0;n<r.length;n++)yield Mt(r[n],t[n]);for(let n=r.length;n<t.length;n++)yield t[n]}r=[],t=[]}for(let n of e)switch(n.type){case"added":r.push(n);break;case"deleted":t.push(n);break;case"common":yield*o(),yield n;break}yield*o()}var Mt=(e,r)=>({value:e.value,oldValue:r.value,type:"replaced"});function*ur(e){for(let r=e.length-1;r>=0;r--)yield e[r]}function*Re(e,r,{userId:t}){let{buildSES:o}=Me(e.map(({text:a})=>a),r),n=0,s=e[0].id;for(let a of Se(o())){switch(a.type){case"added":yield{_insert:s,lines:{id:Le(t),text:a.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:a.value}};break}n++,s=e[n]?.id??"_end"}}var mr=e=>({type:"title",text:e.rows[0].text}),fr=e=>{let{rows:[r,...t]}=e,{indent:o=0,text:n=""}=r??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:t.map(a=>a.text.substring(o+1)).join( )}},k=(e,{parseOnNested:r,parseOnQuoted:t,patterns:o})=>(n,s,a)=>{var i,c,p,l,x,h;if(!r&&s.nested)return(i=a?.())!==null&&i!==void 0?i:[];if(!t&&s.quoted)return(c=a?.())!==null&&c!==void 0?c:[];for(let E of o){let w=E.exec(n);if(w===null)continue;let f=n.substring(0,w.index),I=n.substring(w.index+((l=(p=w[0])===null||p===void 0?void 0:p.length)!==null&&l!==void 0?l:0)),T=e((x=w[0])!==null&&x!==void 0?x:"",s);return[...j(f,s),...T,...j(I,s)]}return(h=a?.())!==null&&h!==void 0?h:[]},v=e=>[{type:"plain",raw:e,text:e}],gr=k(v,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),hr=/^>.*$/,xr=(e,r)=>r.context==="table"?v(e,r):[{type:"quote",raw:e,nodes:j(e.substring(1),{...r,quoted:!0})}],yr=k(xr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[hr]}),br=/^\? .+$/,wr=(e,r)=>r.context==="table"?v(e,r):[{type:"helpfeel",raw:e,text:e.substring(2)}],kr=k(wr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[br]}),Er=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,vr=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Ir=(e,r)=>{if(r.context==="table")return v(e,r);let t=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(t);return[{type:"strongImage",raw:e,src:o?${t}/thumb/1000:t}]},Lr=k(Ir,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Er,vr]}),Tr=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function St(e){return(r,t)=>{if(e==="strongIcon"&&t.context==="table")return v(r,t);let o=e==="icon"?r.substring(1,r.length-1):r.substring(2,r.length-2),n=o.lastIndexOf(".icon"),s=o.substring(0,n),a=s.startsWith("/")?"root":"relative",i=o.substring(n+5,o.length),c=i.startsWith("*")?parseInt(i.substring(1),10):1;return new Array(c).fill({}).map(()=>({path:s,pathType:a,type:e,raw:r}))}}var Dr=St("icon"),Cr=k(Dr,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Tr]}),Nr=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Mr=St("strongIcon"),Sr=k(Mr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Nr]}),Rr=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Or=(e,r)=>r.context==="table"?v(e,r):[{type:"strong",raw:e,nodes:j(e.substring(2,e.length-2),{...r,nested:!0})}],Pr=k(Or,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Rr]}),Ar=/\[\$ .+? \]/,Fr=/\[\$ [^\]]+\]/,qr=(e,r)=>r.context==="table"?v(e,r):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Br=k(qr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ar,Fr]}),_r=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,jr=(e,r)=>{if(r.context==="table")return v(e,r);let t=e.indexOf(" "),o=e.substring(1,t),n=e.substring(t+1,e.length-1),s=new Set(o);if(s.has("*")){let a=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:j(n,{...r,nested:!0})}]},Ur=k(jr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[_r]}),$r=/.*?/,Hr=(e,r)=>r.context==="table"?v(e,r):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Yr=k(Hr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$r]}),Wr=/^[$%] .+$/,Gr=(e,r)=>{var t;if(r.context==="table")return v(e,r);let o=(t=e[0])!==null&&t!==void 0?t:"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:o,text:n}]},Kr=k(Gr,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Wr]}),zr=/\[\s+\]/,Qr=(e,r)=>r.context==="table"?v(e,r):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Vr=k(Qr,{parseOnNested:!1,parseOnQuoted:!0,patterns:[zr]}),Xr=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Zr=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Jr=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,eo=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,to=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||ro(e),ro=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),oo=(e,r)=>{if(r.context==="table")return v(e,r);let t=e.search(/\s/),o=t!==-1?e.substring(1,t):e.substring(1,e.length-1),n=t!==-1?e.substring(t,e.length-1).trimLeft():"",[s,a]=to(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:a}]},no=k(oo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Xr,Zr,Jr,eo]}),so=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,io=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,ao=/\[https?:\/\/[^\s\]]+\]/,co=/https?:\/\/[^\s]+/,lo=(e,r)=>{if(r.context==="table")return v(e,r);let t=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(t),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(t);if(n?.[0]===void 0)return[];let s=o?t.substring(n[0].length):t.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},po=k(lo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[so,io,ao,co]}),Rt=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Ot=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,uo=e=>{let[r="",t="",o=""]=e.split(","),n=parseFloat(r.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(t.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(o)?parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:a}},mo=(e,r)=>{var t;if(r.context==="table")return v(e,r);let o=(t=e.match(Rt))!==null&&t!==void 0?t:e.match(Ot);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=n?o:[o[0],o[2],o[1]],{latitude:i,longitude:c,zoom:p}=uo(s),l=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${i},${c},${p}z:https://www.google.com/maps/@${i},${c},${p}z;return[{type:"googleMap",raw:e,latitude:i,longitude:c,zoom:p,place:a,url:l}]},fo=k(mo,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Rt,Ot]}),go=/\[\/?[^[\]]+\]/,ho=e=>{let r=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:r.startsWith("/")?"root":"relative",href:r,content:""}]},xo=k(ho,{parseOnNested:!0,parseOnQuoted:!0,patterns:[go]}),yo=/(?:^|\s)#\S+/,bo=(e,r)=>{if(r.context==="table")return v(e,r);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let t=e.substring(0,1),o=e.substring(1);return[...v(t,r),{type:"hashTag",raw:o,href:o.substring(1)}]},wo=k(bo,{parseOnNested:!0,parseOnQuoted:!0,patterns:[yo]}),ko=/^[0-9]+\. .*$/,Eo=(e,r)=>{if(r.context==="table")return v(e,r);let t=e.indexOf(" "),o=e.substring(0,t-1),n=parseInt(o,10),s=e.substring(t+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:j(s,{...r,nested:!0})}]},vo=k(Eo,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ko]}),Io=(e,r,t)=>{var o;return e===""?[]:(o=t?.())!==null&&o!==void 0?o:[]},Lo=(...e)=>(r,t)=>e.reduceRight((o,n)=>()=>n(r,t,o),()=>gr(r,t))(),j=Lo(Io,yr,kr,Yr,Kr,Br,Vr,Ur,Lr,Sr,Pr,no,po,Cr,fo,xo,wo,vo),To=e=>{let{rows:[r,...t]}=e,{indent:o=0,text:n=""}=r??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:t.map(a=>a.text.substring(o+1)).map(a=>a.split(" ").map(i=>j(i,{nested:!1,quoted:!1,context:"table"})))}},Do=e=>{let{indent:r,text:t}=e.rows[0];return{indent:r,type:"line",nodes:j(t.substring(r),{nested:!1,quoted:!1,context:"line"})}},Pt=e=>{switch(e.type){case"title":return mr(e);case"codeBlock":return fr(e);case"table":return To(e);case"line":return Do(e)}},At=e=>e.split( ).map(r=>{var t,o,n;return{indent:(n=(o=(t=/^\s+/.exec(r))===null||t===void 0?void 0:t[0])===null||o===void 0?void 0:o.length)!==null&&n!==void 0?n:0,text:r}}),Co=(e,r)=>{var t,o;return(e.type==="codeBlock"||e.type==="table")&&r.indent>((o=(t=e.rows[0])===null||t===void 0?void 0:t.indent)!==null&&o!==void 0?o:0)},Ft=(e,r)=>{let t=e[e.length-1];return t!==void 0&&Co(t,r)?(t.rows.push(r),e):(e.push({type:/^\s*code:/.test(r.text)?"codeBlock":/^\s*table:/.test(r.text)?"table":"line",rows:[r]}),e)},qt=(e,r)=>{var t;if(!((t=r.hasTitle)!==null&&t!==void 0)||t){let[o,...n]=e;return o===void 0?[]:[{type:"title",rows:[o]},...n.reduce(Ft,[])]}return e.reduce(Ft,[])};var No=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Mo=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,So=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,Ro=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Oe=e=>{if(No.test(e)){let r=new URL(e).searchParams,t=r.get("v");if(t)return{pathType:"com",videoId:t,params:r}}{let r=e.match(Mo);if(r){let[,t,o]=r;return{videoId:t,params:new URLSearchParams(o),pathType:"dotbe"}}}{let r=e.match(So);if(r){let[,t,o]=r;return{videoId:t,params:new URLSearchParams(o),pathType:"short"}}}{let r=e.match(Ro);if(r){let[,t,o]=r;return{listId:o,params:new URLSearchParams(t),pathType:"list"}}}};function*Bt(e,r,{userId:t,head:o}){let n=r.flatMap(l=>l.split(
));for(let l of Re(e,n,{userId:t}))yield l;(e[0].text!==n[0]||!o.persistent)&&(yield{title:n[0]});let s=e.slice(1,6).map(l=>l.text),a=n.slice(1,6);s.join("")!==a.join("")&&(yield{descriptions:a});let[i,c,p]=Oo(n.join(
));(o.links.length!==i.length||!o.links.every(l=>i.includes(l)))&&(yield{links:i}),(o.projectLinks.length!==c.length||!o.projectLinks.every(l=>c.includes(l)))&&(yield{projectLinks:c}),o.image!==p&&(yield{image:p})}var Oo=e=>{let r=At(e),t=qt(r,{hasTitle:!0}).flatMap(p=>{switch(p.type){case"codeBlock":case"title":return[];case"line":case"table":return[Pt(p)]}}),o=new Map,n=[],s=new Set,a=[],i=null,c=p=>{switch(p.type){case"hashTag":if(o.has(F(p.href)))return;o.set(F(p.href),!1),n.push(p.href);return;case"link":switch(p.pathType){case"relative":{let l=_t(p.href);if(o.get(F(l)))return;o.set(F(l),!0),n.push(l);return}case"root":{let l=_t(p.href);if(/^\/[\w\d-]+\/?$/.test(l)||s.has(F(l)))return;s.add(F(l)),a.push(l);return}case"absolute":{let l=Oe(p.href);if(!l||l.pathType==="list")return;i??=https://i.ytimg.com/vi/${l.videoId}/mqdefault.jpg;return}default:return}case"image":case"strongImage":{i??=p.src.endsWith("/thumb/1000")?p.src.replace(/\/thumb\/1000$/,"/raw"):p.src;return}case"strong":case"quote":case"decoration":{for(let l of p.nodes)c(l);return}default:return}};for(let p of Po(t))c(p);return[n,a,i]};function*Po(e){for(let r of e)switch(r.type){case"codeBlock":case"title":continue;case"line":for(let t of r.nodes)yield t;continue;case"table":{for(let t of r.cells)for(let o of t)for(let n of o)yield n;continue}}}var _t=e=>e.replace(/#[a-f\d]{24,32}$/,"");var Pe=async(e,r,t,o)=>{let[n,s,a]=await Promise.all([D(e,r),B(e),P()]),i=n,c=o?.socket,p=c??await C();await W(p);try{let{request:l}=O(p);for(let x=0;x<3;x++)try{let h=t(i.lines,i),E=h instanceof Promise?await h:h;if(!E)return;E.length===0&&await _(l,[{deleted:!0}],{projectId:s,pageId:i.pageId,parentId:i.commitId,userId:a,project:e,title:r});let w=[...Bt(i.lines,E,{userId:a,head:i})];await pe(l,w,{parentId:i.commitId,projectId:s,pageId:i.pageId,userId:a});break}catch{if(x===2)throw Error("Faild to retry pushing.");console.log("Faild to push a commit. Retry after pulling new commits");try{i=await D(e,r)}catch(E){throw E}}}finally{c||await N(p)}};var Ae=async(e,r,t)=>{let[o,n,s]=await Promise.all([D(e,r),B(e),P()]);if(o.pin>0||!o.persistent&&!(t?.create??!1))return;let a={parentId:o.commitId,projectId:n,pageId:o.pageId,userId:s,project:e,title:r},i=t?.socket,c=i??await C();await W(c);let{request:p}=O(c);if(!o.persistent){let l=await _(p,[{title:r}],a);a.parentId=l}try{await _(p,[{pin:Ao()}],a)}finally{i||await N(c)}},Fe=async(e,r,t)=>{let[o,n,s]=await Promise.all([D(e,r),B(e),P()]);if(o.pin==0||!o.persistent)return;let a={parentId:o.commitId,projectId:n,pageId:o.pageId,userId:s,project:e,title:r},i=t?.socket,c=i??await C();await W(c);let{request:p}=O(c);try{await _(p,[{pin:0}],a)}finally{i||await N(c)}},Ao=()=>Number.MAX_SAFE_INTEGER-Math.floor(Date.now()/1e3);async function*qe(e,r=0){let{count:t,pages:o}=await Bo(e,r);for(let n of o)n.pin!==0&&(yield n);(o.at(-1)?.pin??0)!==0&&(yield*qe(e,r+1e3))}var Bo=async(e,r)=>{let t=await Z(e,{limit:1e3,skip:r});if(!t.ok){let o=new Error;throw o.name=t.value.name,o.message=t.value.message,o}return t.value};var jt=(e,r)=>{let t=r.interval??24*3600*1e3,o=()=>scrapbox.Project.name===e?_o(e,t,r):$t();o(),scrapbox.addListener("project:changed",o)},Ut,_o=async(e,r,t)=>{$t(),await Ht(e,new Date,t),Ut=setInterval(()=>Ht(e,new Date,t),r)},$t=()=>clearInterval(Ut),Ht=async(e,r,{makeDiary:t,isOldDiary:o})=>{let{render:n,dispose:s}=Ce(),a;try{n({type:"spinner"},{type:"text",text:"unpin other diary pages..."}),a=await Ne();for await(let{title:l}of qe(e))!o(l,r)||await Fe(e,l,{socket:a});let{title:i,header:c,footer:p}=t(r);n({type:"spinner"},{type:"text",text:pin "/${e}/${i}"...}),await Ae(e,i,{socket:a,create:!0}),n({type:"spinner"},{type:"text",text:format "/${e}/${i}"...}),await Pe(e,i,l=>[l[0].text,...ve(l.slice(1).map(x=>x.text),c,p)],{socket:a}),n({type:"check-circle"},{type:"text",text:Pinned "/${e}/${i}".})}catch(i){n({type:"exclamation-triangle"},{type:"text",text:i instanceof Error?${i.name} ${i.message}:"Unknown error! (see developper console)"}),console.error(i)}finally{a&&await N(a),await J(1e3),s()}};function d(e,r){if(r.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+r.length+" present")}function u(e){d(1,arguments);let r=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&r==="[object Date]"?new Date(e.getTime()):typeof e=="number"||r==="[object Number]"?new Date(e):((typeof e=="string"||r==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use parseISO to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function Be(e){d(1,arguments);let t=u(e).getFullYear();return t%400==0||t%4==0&&t%100!=0}function me(e){d(1,arguments);let r=u(e);return String(new Date(r))==="Invalid Date"?NaN:Be(r)?366:365}function _e(e){d(1,arguments);let r=u(e),t=new Date(0);return t.setFullYear(r.getFullYear(),0,1),t.setHours(0,0,0,0),t}function z(e){let r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return r.setUTCFullYear(e.getFullYear()),e.getTime()-r.getTime()}function fe(e){d(1,arguments);let r=u(e);return r.setHours(0,0,0,0),r}var jo=864e5;function ee(e,r){d(2,arguments);let t=fe(e),o=fe(r),n=t.getTime()-z(t),s=o.getTime()-z(o);return Math.round((n-s)/jo)}function ge(e){d(1,arguments);let r=u(e);return ee(r,_e(r))+1}function m(e){if(e===null||e===!0||e===!1)return NaN;let r=Number(e);return isNaN(r)?r:r<0?Math.ceil(r):Math.floor(r)}function Q(e,r){d(2,arguments);let t=u(e),o=m(r);return isNaN(o)?new Date(NaN):(o&&t.setDate(t.getDate()+o),t)}function V(e,r){d(2,arguments);let t=m(r);return Q(e,-t)}function U(e,r){d(1,arguments);let t=r||{},o=t.locale,n=o&&o.options&&o.options.weekStartsOn,s=n==null?0:m(n),a=t.weekStartsOn==null?s:m(t.weekStartsOn);if(!(a>=0&&a<=6))throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");let i=u(e),c=i.getDay(),p=(c<a?7:0)+c-a;return i.setDate(i.getDate()-p),i.setHours(0,0,0,0),i}function je(e,r){d(1,arguments);let t=u(e),o=t.getFullYear(),n=r?.locale?.options?.firstWeekContainsDate,s=n==null?1:m(n),a=r?.firstWeekContainsDate==null?s:m(r.firstWeekContainsDate);if(!(a>=1&&a<=7))throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");let i=new Date(0);i.setFullYear(o+1,0,a),i.setHours(0,0,0,0);let c=U(i,r),p=new Date(0);p.setFullYear(o,0,a),p.setHours(0,0,0,0);let l=U(p,r);return t.getTime()>=c.getTime()?o+1:t.getTime()>=l.getTime()?o:o-1}function Ue(e,r){d(1,arguments);var t=r||{},o=t.locale,n=o&&o.options&&o.options.firstWeekContainsDate,s=n==null?1:m(n),a=t.firstWeekContainsDate==null?s:m(t.firstWeekContainsDate),i=je(e,r),c=new Date(0);c.setFullYear(i,0,a),c.setHours(0,0,0,0);var p=U(c,r);return p}var Uo=6048e5;function he(e,r){d(1,arguments);let t=u(e),o=U(t,r).getTime()-Ue(t,r).getTime();return Math.round(o/Uo)+1}function te(e,r){d(2,arguments);let t=u(e),o=m(r);if(isNaN(o))return new Date(NaN);if(!o)return t;let n=t.getDate(),s=new Date(t.getTime());s.setMonth(t.getMonth()+o+1,0);let a=s.getDate();return n>=a?s:(t.setFullYear(s.getFullYear(),s.getMonth(),n),t)}function $e(e,r){d(2,arguments);let t=m(r);return te(e,t*12)}function xe(e,r){d(2,arguments);let t=m(r);return $e(e,-t)}function ye(e){return d(1,arguments),u(e).getDay()}function be(e){return d(1,arguments),u(e).getFullYear()}function M(e,r){for(var t=e<0?"-":"",o=Math.abs(e).toString();o.length<r;)o="0"+o;return t+o}var $o={y(e,r){let t=e.getUTCFullYear(),o=t>0?t:1-t;return M(r==="yy"?o%100:o,r.length)},M(e,r){let t=e.getUTCMonth();return r==="M"?String(t+1):M(t+1,2)},d(e,r){return M(e.getUTCDate(),r.length)},a(e,r){let t=e.getUTCHours()/12>=1?"pm":"am";switch(r){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(e,r){return M(e.getUTCHours()%12||12,r.length)},H(e,r){return M(e.getUTCHours(),r.length)},m(e,r){return M(e.getUTCMinutes(),r.length)},s(e,r){return M(e.getUTCSeconds(),r.length)},S(e,r){let t=r.length,o=e.getUTCMilliseconds(),n=Math.floor(o*Math.pow(10,t-3));return M(n,r.length)}},Yt=$o;function X(e){d(1,arguments);var r=u(e);return!isNaN(r)}function He(e,r){d(2,arguments);let t=u(e).getTime(),o=m(r);return new Date(t+o)}function Ye(e,r){d(2,arguments);let t=m(r);return He(e,-t)}var Ho=/(\w)\1*|''|'(''|[^'])+('|$)|./g,Yo=/^'([^]*?)'?$/,Wo=/''/g,Go=/[a-zA-Z]/;function A(e,r){d(2,arguments);let t=u(e);if(!X(t))throw new RangeError("Invalid time value");let o=z(t),n=Ye(t,o),s=r.match(Ho);return s?s.map(i=>{if(i==="''")return"'";let c=i[0];if(c==="'")return Ko(i);let p=Yt[c];if(p)return p(n,i);if(c.match(Go))throw new RangeError("Format string contains an unescaped latin alphabet character "+c+"");return i}).join(""):""}function Ko(e){let r=e.match(Yo);return r?r[1].replace(Wo,"'"):e}function S(e,r){d(2,arguments);let t=u(e),o=u(r),n=t.getTime()-o.getTime();return n<0?-1:n>0?1:n}function We(e,r){d(2,arguments);let t=u(e),o=u(r);return t.getFullYear()-o.getFullYear()}function Ge(e,r){d(2,arguments);let t=u(e),o=u(r),n=S(t,o),s=Math.abs(We(t,o));t.setFullYear(1584),o.setFullYear(1584);let a=S(t,o)===-n,i=n*(s-Number(a));return i===0?0:i}function Ke(e,r){d(2,arguments);let t=u(e),o=u(r),n=t.getFullYear()-o.getFullYear(),s=t.getMonth()-o.getMonth();return n*12+s}function ze(e){d(1,arguments);let r=u(e);return r.setHours(23,59,59,999),r}function Qe(e){d(1,arguments);let r=u(e),t=r.getMonth();return r.setFullYear(r.getFullYear(),t+1,0),r.setHours(23,59,59,999),r}function Ve(e){d(1,arguments);let r=u(e);return ze(r).getTime()===Qe(r).getTime()}function Xe(e,r){d(2,arguments);let t=u(e),o=u(r),n=S(t,o),s=Math.abs(Ke(t,o)),a;if(s<1)a=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-n*s);let i=S(t,o)===-n;Ve(u(e))&&s===1&&S(e,o)===1&&(i=!1),a=n*(s-Number(i))}return a===0?0:a}function Wt(e,r){let t=e.getFullYear()-r.getFullYear()||e.getMonth()-r.getMonth()||e.getDate()-r.getDate()||e.getHours()-r.getHours()||e.getMinutes()-r.getMinutes()||e.getSeconds()-r.getSeconds()||e.getMilliseconds()-r.getMilliseconds();return t<0?-1:t>0?1:t}function Ze(e,r){d(2,arguments);let t=u(e),o=u(r),n=Wt(t,o),s=Math.abs(ee(t,o));t.setDate(t.getDate()-n*s);let a=Number(Wt(t,o)===-n),i=n*(s-a);return i===0?0:i}function G(e,r){d(2,arguments);let t=u(e),o=u(r);return t.getTime()-o.getTime()}var zo=36e5;function Je(e,r){d(2,arguments);let t=G(e,r)/zo;return t>0?Math.floor(t):Math.ceil(t)}var Qo=6e4;function et(e,r){d(2,arguments);var t=G(e,r)/Qo;return t>0?Math.floor(t):Math.ceil(t)}function tt(e,r){d(2,arguments);let t=G(e,r)/1e3;return t>0?Math.floor(t):Math.ceil(t)}function rt(e,r){d(2,arguments);let t=m(r);return te(e,-t)}function K(e,r){if(d(2,arguments),!r||typeof r!="object")return new Date(NaN);let t="years"in r?m(r.years):0,o="months"in r?m(r.months):0,n="weeks"in r?m(r.weeks):0,s="days"in r?m(r.days):0,a="hours"in r?m(r.hours):0,i="minutes"in r?m(r.minutes):0,c="seconds"in r?m(r.seconds):0,p=rt(u(e),o+t*12),l=V(p,s+n*7),x=i+a*60,E=(c+x*60)*1e3;return new Date(l.getTime()-E)}function we({start:e,end:r}){d(1,arguments);let t=u(e),o=u(r);if(!X(t))throw new RangeError("Start Date is invalid");if(!X(o))throw new RangeError("End Date is invalid");let n={years:0,months:0,days:0,hours:0,minutes:0,seconds:0},s=S(t,o);n.years=Math.abs(Ge(t,o));let a=K(t,{years:s*n.years});n.months=Math.abs(Xe(a,o));let i=K(a,{months:s*n.months});n.days=Math.abs(Ze(i,o));let c=K(i,{days:s*n.days});n.hours=Math.abs(Je(c,o));let p=K(c,{hours:s*n.hours});n.minutes=Math.abs(et(p,o));let l=K(p,{minutes:s*n.minutes});return n.seconds=Math.abs(tt(l,o)),n}var re="yyyy/MM/dd",Gt=e=>{let r=we({start:new Date(2020,9,9),end:e}).years;return{title:zt(e),header:[第${he(e)}週: ${Vo(e)},${be(e)}年 ${(ge(e)*100/me(e)).toFixed(2)}%経過,"","今日のn年前",...[...Array(r).keys()].map(t=> ${A(xe(e,t+1),re)})],footer:[${A(V(e,1),re)}←${A(e,re)}→${A(Q(e,1),re)},${A(e,"yyyy/MM")}.icon]}},Vo=e=>{let r=ye(e);return[..."日月火水木金土"].map((t,o)=>o===r?${t}`:t).join("")},Xo=/^\d{4}\/\d{2}\/\d{2}$/,Kt=(e,r)=>Xo.test(e)?zt(r)!==e:!1,zt=e=>A(e,re);jt("villagepump",{makeDiary:Gt,isOldDiary:Kt});