SharedUserScripts-min
全プロジェクトで使うUserScript
code:script.js
var Xr=!1;scrapbox.addListener("lines:changed",()=>Xr=!1);scrapbox.addListener("layout:changed",()=>Xr=!1);var Yr=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Qr=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var or=()=>qi(document.getElementsByClassName("lines").item(0),"div.lines");var je=()=>{let e=document.getElementById("text-input");if(e)return Qr(e,"textarea#text-input"),e};var qi=(e,t)=>{if(e)return Yr(e,t),e};var sr=()=>{let e=or();if(!e)throw Error("div.lines is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.lines must has the property whose name starts with "__reactFiber"');return et.return.stateNode.props.lines};function ir(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,s)=>{let a=()=>{clearTimeout(c),s(r?.reason)},c=setTimeout(()=>{r?.removeEventListener("abort",a),o()},e);if(r?.addEventListener("abort",a,{once:!0}),n===!1)try{Deno.unrefTimer(c)}catch(l){if(!(l instanceof ReferenceError))throw l;console.error("persistent option is only available in Deno")}})}var en=async e=>{let t=je();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await ir(1)};var gt=e=>...e.map((t,r)=>t===" "?"_":!Qi.includes(t)||r===e.length-1&&Zi.includes(t)?encodeURIComponent(t):t).join(""),Qi='@$&+=:;",',Zi=':;",';var ht=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(e,t);if(s)return s}},xt=async(e,t)=>{let r=t.clone();return await(await caches.open(ea(new Date))).put(e,r)},ea=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var tn=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var ra=new Map;scrapbox.on("layout:changed",()=>{let e=je();if(e)for(lett,rof ra)for(letn,oof r)for(let s of o)e.addEventListener(t,n,tn(s))});var na=e=>typeof e=="object"&&e!==null,oa=e=>na(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,rn=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return oa(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var nn=!1;scrapbox.addListener("lines:changed",()=>nn=!1);scrapbox.addListener("layout:changed",()=>nn=!1);var on=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var sn=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var ze=()=>{let e=document.getElementById("text-input");if(e)return sn(e,"textarea#text-input"),e};var an=()=>sa(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),sa=(e,t)=>{if(e)return on(e,t),e};var ln=()=>{let e=an();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 n=pn(...r);n&&t.append(n)},dispose:()=>t.remove()}},pn=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnma();case"check-circle":returnda();case"exclamation-triangle":returnga();case"text":returnyt(n.text);case"group":{let o=pn(...n.items);return o?o:[]}}});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},yt=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},ma=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),yt(e)},da=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),yt(e)},ga=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),yt(e)};var Se=e=>...e.map((t,r)=>t===" "?"_":!ha.includes(t)||r===e.length-1&&xa.includes(t)?encodeURIComponent(t):t).join(""),ha='@$&+=:;",',xa=':;",';var un=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var ba=new Map;scrapbox.on("layout:changed",()=>{let e=ze();if(e)for(lett,rof ba)for(letn,oof r)for(let s of o)e.addEventListener(t,n,un(s))});var Re=e=>typeof e=="string";var ar=(e,...t)=>{let r=e;for(let n of t){let o=r instanceof Promise?r.then(s=>Re(s)?s:n(s)):n(r);if(Re(o))return o;r=o instanceof URL?new URL(o):o.then(s=>Re(s)?s:new URL(s))}return r instanceof Promise?r.then(n=>${n}):${e}};var Ve=e=>e.ok?void 0:{name:"HTTPError",message:${e.status} ${e.statusText},response:e};var fn=e=>{if(!window.GM_fetch)return;let t=window.GM_fetch;return(async()=>{let r=await t(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x),n=Ve(r);return n?{ok:!1,value:n}:{ok:!0,value:await r.json()}})()};var bt=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}},mn=e=>typeof e=="object"&&e!==null;var nt=class e extends Error{name="UnexpectedResponseError";status;statusText;body;path;constructor(t){super(${t.status} ${t.statusText} when fetching ${t.path.toString()}),this.status=t.status,this.statusText=t.statusText,this.body=t.body,this.path=t.path,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};var wt=async e=>{let t=await e.text();if(e.ok)return{ok:!0,value:t};if(e.status===400)return{ok:!1,value:{name:"BadRequestError",message:t}};try{let r=JSON.parse(t);if(!mn(r)||typeof r.message!="string")throw new nt({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)});switch(e.status){case 401:return{ok:!1,value:{name:"UnauthorizedError",message:r.message}};case 403:return{ok:!1,value:{name:"NotPrivilegeError",message:r.message}};case 404:return{ok:!1,value:{name:"NotFoundError",message:r.message}};case 422:return{ok:!1,value:{name:"InvalidParameterError",message:r.message}};case 429:return{ok:!1,value:{name:"RateLimitError",message:r.message}};default:throw new nt({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)})}}catch(r){throw r instanceof SyntaxError?new nt({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)}):r}};var dn=async(e,t)=>{let{title:r,description:n,metadataIsPublic:o,collectionId:s,refererURL:a,accessToken:i,created:c,app:l,fetch:u}=bt(t),f=new FormData;f.append("imagedata",e),f.append("access_token",i),a&&f.append("referer_url",a.toString()),l!==void 0&&f.append("app",l),r!==void 0&&f.append("title",r),n!=null&&f.append("desc",n),s&&f.append("collection_id",s),o&&f.append("metadata_is_public","true"),c!==void 0&&f.append("created_at",${c});let v=await u("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:f}),C=await wt(v);return C.ok?{ok:!0,value:JSON.parse(C.value)}:C};var F=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var ve=class e extends Error{constructor(r){super(${r.status} ${r.statusText} when fetching ${r.url});this.response=r;Error.captureStackTrace&&Error.captureStackTrace(this,e)}name="UnexpectedResponseError"},X=async e=>{let t=e.clone(),r=await t.text(),n=rn(r);if(!n)throw new ve(t);return{ok:!1,value:n}};var gn=async e=>{let{sid:t,hostName:r,fetch:n}=F(e??{}),o=new Request(https://${r}/api/users/me,t?{headers:{Cookie:K(t)}}:void 0),s=await n(o);if(!s.ok)throw new ve(s);return await s.json()};var K=e=>connect.sid=${e},Te=async e=>globalThis._csrf?globalThis._csrf:(await gn(e)).csrfToken;var hn=(e,t,r)=>{let{sid:n,hostName:o,followRename:s,projects:a}=F(r??{}),i=new URLSearchParams;i.append("followRename",${s??!0});for(let l of a??[])i.append("projects",l);let c=https://${o}/api/pages/${e}/${Se(t)}?${i.toString()};return new Request(c,n?{headers:{Cookie:K(n)}}:void 0)},xn=async e=>e.ok?{ok:!0,value:await e.json()}:e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:X(e),cr=async(e,t,r)=>{let{fetch:n}=F(r??{}),o=hn(e,t,r),s=await n(o);return await xn(s)};cr.toRequest=hn;cr.fromResponse=xn;var yn=(e,t)=>{let{sid:r,hostName:n,sort:o,limit:s,skip:a}=F(t??{}),i=new URLSearchParams;o!==void 0&&i.append("sort",o),s!==void 0&&i.append("limit",${s}),a!==void 0&&i.append("skip",${a});let c=https://${n}/api/pages/${e}?${i.toString()};return new Request(c,r?{headers:{Cookie:K(r)}}:void 0)},bn=async e=>e.ok?{ok:!0,value:await e.json()}:X(e),wn=async(e,t)=>{let{fetch:r}=F(t??{}),n=await r(yn(e,t));return await bn(n)};wn.toRequest=yn;wn.fromResponse=bn;var En=(e,t,r,n)=>{let{sid:o,hostName:s}=F(n??{}),a=https://${s}/api/table/${e}/${Se(t)}/${encodeURIComponent(r)}.csv;return new Request(a,o?{headers:{Cookie:K(o)}}:void 0)},Rn=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:X(e),vn=async(e,t,r,n)=>{let{fetch:o}=F(n??{}),s=En(e,t,r,n),a=await o(s);return await Rn(a)};vn.toRequest=En;vn.fromResponse=Rn;var Tn=(e,t)=>{let{sid:r,hostName:n}=F(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:K(r)}}:void 0)},Ln=async e=>e.ok?{ok:!0,value:await e.json()}:X(e),Et=async(e,t)=>{let{fetch:r}=F(t??{}),n=Tn(e,t),o=await r(n);return Ln(o)};Et.toRequest=Tn;Et.fromResponse=Ln;var kn=(e,t)=>{let{sid:r,hostName:n}=F(t??{}),o=new URLSearchParams;for(let s of e)o.append("ids",s);return new Request(https://${n}/api/projects?${o.toString()},r?{headers:{Cookie:K(r)}}:void 0)},Pn=async e=>e.ok?{ok:!0,value:await e.json()}:X(e),Cn=async(e,t)=>{let{fetch:r}=F(t??{}),n=await r(kn(e,t));return Pn(n)};Cn.toRequest=kn;Cn.fromResponse=Pn;var Nn=async(e,t)=>{let{sid:r,hostName:n,fetch:o,csrf:s}=F(t??{}),a=new Request(https://${n}/api/embed-text/url?url=${encodeURIComponent(e.toString())},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":s??await Te(t),...r?{Cookie:K(r)}:{}},body:JSON.stringify({timeout:3e3})}),i=await o(a);if(!i.ok)return i.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await i.json()).message}}:X(i);let{title:c}=await i.json();return{ok:!0,value:c}};var Sn=async(e,t)=>{let{sid:r,hostName:n,fetch:o,csrf:s}=F(t??{}),a=new Request(https://${n}/api/embed-text/twitter?url=${encodeURIComponent(e.toString())},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":s??await Te(t),...r?{Cookie:K(r)}:{}},body:JSON.stringify({timeout:3e3})}),i=await o(a);return i.ok?{ok:!0,value:await i.json()}:i.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await i.json()).message}}:X(i)};var On=async e=>{let{sid:t,hostName:r,gyazoTeamsName:n}=F(e??{}),o=new Request(https://${r}/api/login/gyazo/oauth-upload/token${n??gyazoTeamsName=${n}:""},t?{headers:{Cookie:K(t)}}:void 0),s=await fetch(o);if(!s.ok)return X(s);let{token:a}=await s.json();return{ok:!0,value:a}};var An=(e,t,r,n)=>{let{sid:o,hostName:s}=F(n??{}),a=https://${s}/api/code/${e}/${Se(t)}/${Se(r)};return new Request(a,o?{headers:{Cookie:K(o)}}:void 0)},Mn=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"}}:X(e),In=async(e,t,r,n)=>{let{fetch:o}=F(n??{}),s=An(e,t,r,n),a=await o(s);return await Mn(a)};In.toRequest=An;In.fromResponse=Mn;var $n=new TextEncoder().encode("0123456789abcdef");function Un(e){let t=new Uint8Array(e.length*2);for(let r=0;r<t.length;r++){let n=er;tr*2=$nn>>4,tr*2+1=$nn&15}return t}var _n="md5: data is invalid type",De=64,ot=class{#s;#r;#t;#e;#o;#a;#n;#l;constructor(){this.#s=1732584193,this.#r=4023233417,this.#t=2562383102,this.#e=271733878,this.#o=new Uint8Array(De),this.#a=0,this.#n=0,this.#l=0}#p(t){let r=this.#n;r+=t,r>4294967295&&(this.#l+=1),this.#n=r>>>0}#f(t){let r=this.#s,n=this.#r,o=this.#t,s=this.#e,a=w=>tw|tw+1<<8|tw+2<<16|tw+3<<24,i=(w,T)=>w<<T|w>>>32-T,c=a(0),l=a(4),u=a(8),f=a(12),v=a(16),C=a(20),D=a(24),G=a(28),S=a(32),W=a(36),q=a(40),y=a(44),h=a(48),d=a(52),m=a(56),E=a(60);r=n+i(((o^s)&n^s)+r+c+3614090360,7),s=r+i(((n^o)&r^o)+s+l+3905402710,12),o=s+i(((r^n)&s^n)+o+u+606105819,17),n=o+i(((s^r)&o^r)+n+f+3250441966,22),r=n+i(((o^s)&n^s)+r+v+4118548399,7),s=r+i(((n^o)&r^o)+s+C+1200080426,12),o=s+i(((r^n)&s^n)+o+D+2821735955,17),n=o+i(((s^r)&o^r)+n+G+4249261313,22),r=n+i(((o^s)&n^s)+r+S+1770035416,7),s=r+i(((n^o)&r^o)+s+W+2336552879,12),o=s+i(((r^n)&s^n)+o+q+4294925233,17),n=o+i(((s^r)&o^r)+n+y+2304563134,22),r=n+i(((o^s)&n^s)+r+h+1804603682,7),s=r+i(((n^o)&r^o)+s+d+4254626195,12),o=s+i(((r^n)&s^n)+o+m+2792965006,17),n=o+i(((s^r)&o^r)+n+E+1236535329,22),r=n+i(((n^o)&s^o)+r+l+4129170786,5),s=r+i(((r^n)&o^n)+s+D+3225465664,9),o=s+i(((s^r)&n^r)+o+y+643717713,14),n=o+i(((o^s)&r^s)+n+c+3921069994,20),r=n+i(((n^o)&s^o)+r+C+3593408605,5),s=r+i(((r^n)&o^n)+s+q+38016083,9),o=s+i(((s^r)&n^r)+o+E+3634488961,14),n=o+i(((o^s)&r^s)+n+v+3889429448,20),r=n+i(((n^o)&s^o)+r+W+568446438,5),s=r+i(((r^n)&o^n)+s+m+3275163606,9),o=s+i(((s^r)&n^r)+o+f+4107603335,14),n=o+i(((o^s)&r^s)+n+S+1163531501,20),r=n+i(((n^o)&s^o)+r+d+2850285829,5),s=r+i(((r^n)&o^n)+s+u+4243563512,9),o=s+i(((s^r)&n^r)+o+G+1735328473,14),n=o+i(((o^s)&r^s)+n+h+2368359562,20),r=n+i((n^o^s)+r+C+4294588738,4),s=r+i((r^n^o)+s+S+2272392833,11),o=s+i((s^r^n)+o+y+1839030562,16),n=o+i((o^s^r)+n+m+4259657740,23),r=n+i((n^o^s)+r+l+2763975236,4),s=r+i((r^n^o)+s+v+1272893353,11),o=s+i((s^r^n)+o+G+4139469664,16),n=o+i((o^s^r)+n+q+3200236656,23),r=n+i((n^o^s)+r+d+681279174,4),s=r+i((r^n^o)+s+c+3936430074,11),o=s+i((s^r^n)+o+f+3572445317,16),n=o+i((o^s^r)+n+D+76029189,23),r=n+i((n^o^s)+r+W+3654602809,4),s=r+i((r^n^o)+s+h+3873151461,11),o=s+i((s^r^n)+o+E+530742520,16),n=o+i((o^s^r)+n+u+3299628645,23),r=n+i((o^(n|~s))+r+c+4096336452,6),s=r+i((n^(r|~o))+s+G+1126891415,10),o=s+i((r^(s|~n))+o+m+2878612391,15),n=o+i((s^(o|~r))+n+C+4237533241,21),r=n+i((o^(n|~s))+r+h+1700485571,6),s=r+i((n^(r|~o))+s+f+2399980690,10),o=s+i((r^(s|~n))+o+q+4293915773,15),n=o+i((s^(o|~r))+n+l+2240044497,21),r=n+i((o^(n|~s))+r+S+1873313359,6),s=r+i((n^(r|~o))+s+E+4264355552,10),o=s+i((r^(s|~n))+o+D+2734768916,15),n=o+i((s^(o|~r))+n+d+1309151649,21),r=n+i((o^(n|~s))+r+v+4149444226,6),s=r+i((n^(r|~o))+s+y+3174756917,10),o=s+i((r^(s|~n))+o+u+718787259,15),n=o+i((s^(o|~r))+n+W+3951481745,21),this.#s=this.#s+r>>>0,this.#r=this.#r+n>>>0,this.#t=this.#t+o>>>0,this.#e=this.#e+s>>>0}update(t){let r;if(typeof t=="string")r=new TextEncoder().encode(t);else if(typeof t=="object")if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new Uint8Array(t);else throw new TypeError(_n);else throw new TypeError(_n);let n=this.#a,o=De-n;if(r.length<o)this.#o.set(r,n),n+=r.length;else{this.#o.set(r.slice(0,o),n),this.#f(this.#o);let s=o;for(;s+De<=r.length;)this.#f(r.slice(s,s+De)),s+=De;this.#o.fill(0).set(r.slice(s),0),n=r.length-s}return this.#a=n,this.#p(r.length),this}digest(){let t=De-this.#a;t<9&&(t+=De);let r=new Uint8Array(t);r0=128;let n=this.#n<<3,o=this.#l<<3|this.#n>>>29;rr.length-8=n&255,rr.length-7=n>>>8&255,rr.length-6=n>>>16&255,rr.length-5=n>>>24&255,rr.length-4=o&255,rr.length-3=o>>>8&255,rr.length-2=o>>>16&255,rr.length-1=o>>>24&255,this.update(r.buffer);let s=new ArrayBuffer(16),a=new DataView(s);return a.setUint32(0,this.#s,!0),a.setUint32(4,this.#r,!0),a.setUint32(8,this.#t,!0),a.setUint32(12,this.#e,!0),s}toString(t="hex"){let r=this.digest();switch(t){case"hex":return new TextDecoder().decode(Un(new Uint8Array(r)));case"base64":{let n=new Uint8Array(r),o="";for(let s=0;s<n.length;++s)o+=String.fromCharCode(ns);return btoa(o)}default:throw new Error("md5: invalid format")}}};var jn=async(e,t,r)=>{let n=new ot().update(await e.arrayBuffer()).toString(),o=await Ea(e,t,n,r);if(!o.ok)return o;if("embedUrl"in o.value)return{ok:!0,value:o.value};let s=await Ra(o.value.signedUrl,e,r);return s.ok?va(t,o.value.fileId,n,r):s},Ea=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:a,csrf:i}=F(n??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},l=i??await Te(),u=new Request(https://${s}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":l,...o?{Cookie:K(o)}:{}}}),f=await a(u);return f.ok?{ok:!0,value:await f.json()}:X(f)},Ra=async(e,t,r)=>{let{sid:n,fetch:o}=F(r??{}),s=await o(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...n?{Cookie:K(n)}:{}}});if(!s.ok){if(s.headers.get("Content-Type")?.includes?.("/xml"))return{ok:!1,value:{name:"GCSError",message:await s.text()}};throw new ve(s)}return{ok:!0,value:void 0}},va=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:a,csrf:i}=F(n??{}),c=i??await Te(),l=new Request(https://${s}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":c,...o?{Cookie:K(o)}:{}}}),u=await a(l);if(!u.ok){try{if(u.status===404)return{ok:!1,value:{name:"NotFoundError",message:(await u.json()).message}}}catch{throw new ve(u)}throw new ve(u)}return{ok:!0,value:await u.json()}};var Dn=(e,t)=>{let r=new FormData;return r.append("data",e),r.append("metadata",JSON.stringify({app:"Gyazo",title:e.name})),GM_fetch(https://gif.gyazo.com/${t?.teams?"teams":"gif"}/upload,{method:"POST",body:r,credentials:"include",headers:{Origin:"https://gyazo.com","sec-fetch-site":"same-site"},referrer:"https://gyazo.com/"})};var Rt="",Fn=!1,vt=new Map,Hn=async(e,t,r,n)=>{let o=vt.get(e.href);if(o)return o;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let c=await GM_fetch(e);if(!c.ok)return;let l=c.headers.get("content-type")?.split?.(";")?.0??${e}.endsWith(".mp4")?"video/mp4":"video/webm",u=new File(await c.blob(),n||${t},{type:l});if(l==="video/mp4"){let C=await Dn(u);if(C.ok){let D=new URL(await C.text());return vt.set(e.href,D),D}}let f=await jn(u,r);if(!f.ok)throw Error(f.value.name);let v=new URL(f.value.embedUrl);return vt.set(e.href,v),v}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Fn){if(!Rt)return}else{let c=await On();if(Fn=!0,!c.ok){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(Rt=c.value||"",!Rt){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let s=await GM_fetch(e);if(!s.ok)return;let a=await dn(await s.blob(),{accessToken:Rt,refererURL:t,description:n});if(!a.ok)throw Error(a.value.name);let i=new URL(a.value.permalink_url);return vt.set(e.href,i),i};var Ta={"<":"<",">":">","&":"&",""":'"',"'":"'","`":""},lr=e=>e.replace(/&(lt|gt|amp|quot|#x27|#x60);/g,t=>Ta[t]);var Je=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),n=[...e.entities.hashtags.map(a=>({type:"hashtag",...a})),...e.entities.symbols.map(a=>({type:"symbol",...a})),...e.entities.user_mentions.map(a=>({type:"mention",name:a.name,screenName:a.screen_name,indices:a.indices})),...e.entities.urls.map(a=>{let i={type:"url",indices:a.indices,url:new URL(a.expanded_url)};if(e.card&&e.card?.url===a.url){let{description:c,title:l}=e.card.binding_values,u="STRING";c?.type===u&&(i.description=c.string_value),l?.type===u&&(i.title=l.string_value)}return i}),...e.entities.media?.map?.(a=>({type:"media",indices:a.indices,media:e.mediaDetails?.flatMap?.(i=>i.url===a.url?[{type:i.type,url:new URL(i.video_info?.variants?.sort?.((c,l)=>(l.bitrate??0)-(c.bitrate??0))?.[0].url??i.media_url_https)}]:[])??[]}))??[]].sort((a,i)=>a.indices[0]-i.indices[0]),o=[];{let a=0,i=e.text;for(let{indices:c,...l}of n){let u=[...i].slice(0,c[0]-a).join("");o.push({type:"plain",text:lr(u)}),o.push(l),i=[...i].slice(c[1]-a).join(""),a=c[1]}i&&o.push({type:"plain",text:lr(i)})}let s={id:e.id_str,content:o,author:t,posted:r,replyCount:"reply_count"in e?e.reply_count:e.conversation_count};return e.self_thread&&(s.rootId=e.self_thread.id_str),e.in_reply_to_status_id_str&&(s.replyId=e.in_reply_to_status_id_str),e.parent&&(s.replyTo=Je(e.parent)),e.quoted_tweet&&(s.quote=Je(e.quoted_tweet)),s};var La=["landing","product","enterprise","pricing","try-enterprise","contact","terms","privacy","jp-commercial-act","support","case","features","business","auth","login","logout","oauth2","_","api","app.html","assets","file","files","billing","billings","config","feed","index","io","new","opensearch","project","projects","search","setting","settings","setup-profile","slide","socket.io","stream","user","users"],Tt=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,n,o]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!n||La.includes(n)?r:o?n===e?${decodeURIComponent(o)}:/${n}/${decodeURIComponent(o)}:/${n}};var Bn=(e=ka)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:(?:www\.|mobile\.|m\.)?twitter|x)\.com\/[\w\d_]+\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let n=await(fn(r)??Sn(t.href));if(!n.ok)throw n.value;return e("images"in n.value?{...n.value,id:r}:n.value,t)})():t},ka=async e=>{if("images"in e)return Le(e);let{quote:t,replyTo:r,...n}=Je(e);return[...r?[...(await Le(r)).split( ).map(o=> > ${o}),...r.quote?(await Le(r.quote)).split(
).map(o=> > ${o}):[]]:[],...(await Le(n)).split(
).map(o=>> ${o}),...t?(await Le(t)).split(
).map(o=>> > ${o}):[]].join(
)?.map?.(o=>> ${ur(o)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(o=>[${o}])}]:[]].join(
);let r=e.content,n=e.author.screenName;return[@${ur(n)} ${t},...(await Promise.all(r.map(async o=>{switch(o.type){case"plain":return o.text;case"hashtag":return #${o.text} ;case"symbol":return #$${o.text} ;case"mention":return@${o.screenName};case"media":{let s=[],a=1;for(;a<o.media.length;a+=2)s.push([${await pr(o.mediaa-1,t)}] [${await pr(o.mediaa,t)}]);return a===o.media.length&&s.push([${await pr(o.mediaa-1,t)}]), ${s.join(`
`)}
}case"url":return${Tt()(o.url)} }}))).join("").split(
)].join(
)},Lt="",Pa=async()=>{if(Lt)return Lt;let e=await Et(scrapbox.Project.name);if(!e.ok)throw new Error(e.value.name);return Lt=e.value.id,Lt},pr=async(e,t)=>await Hn(e.url,t,await Pa(),"")??e.url,ur=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Wn=e=>{if(!window.GM_fetch)return;let t=window.GM_fetch;return(async()=>{let r=await t(https://t.co/${e}),n=Ve(r);return n?{ok:!1,value:n}:{ok:!0,value:new DOMParser().parseFromString(await r.text(),"text/html").title}})()};var Gn=e=>{if("bit.ly","amzn.to","amzn.asia","goo.gl","s.nikkei.com","apple.co","nico.ms","w.wiki".includes(e.hostname)&&window.GM_fetch)return window.GM_fetch(e).then(r=>r.ok?new URL(r.url):e);if(e.hostname!=="t.co")return e;let t=Wn(e.pathname.slice(1));return t?(async()=>{let r=await t;if(!r.ok)throw r.value;try{return new URL(r.value)}catch(n){if(n instanceof TypeError)return e;throw n}})():e};var qn=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,o=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!o)return e;e.hostname=${o}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",n=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${n}#${r}]:[${t} - Wikipedia ${n}]};var Kn=e=>{if(e.hostname!=="www.wikiwand.com")return e;let,t,r=e.pathname.match(/^\/(^\/+)\/(^\/+)/)??[];return!t||!r||(e.hostname=${t}.wikipedia.org,e.pathname=/wiki/${r},e.hash=e.hash.startsWith("#/")?#${e.hash.slice(2)}:e.hash),e};var fr=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var zn=/charset=(^;+)/,Vn=e=>{if(!window.GM_fetch)return;let t=window.GM_fetch;return(async()=>{let r=await t(${e}),n=Ve(r);if(n)return{ok:!1,value:n};let o=r.headers.get("content-type")?.match?.(zn)?.1??await Ca(r.clone());return{ok:!0,value:new TextDecoder(o).decode(await r.arrayBuffer())}})()},Ca=async e=>{let t=new DOMParser().parseFromString(await e.text(),"text/html");return t.querySelector("metacharset")?.getAttribute?.("charset")??t.querySelector('metahttp-equiv="content-type"')?.getAttribute?.("content")?.match?.(zn)?.1??"utf-8"};var Jn=(e=Na)=>async t=>e(await Sa(t),t),Na=(e,t)=>{let r=(Re(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},Sa=async e=>{let t=Vn(e);if(!t){let n=await Nn(e);if(!n.ok)throw n.value;return n.value}let r=await t;if(!r.ok)throw r.value;return new DOMParser().parseFromString(r.value,"text/html")};var Xn=e=>{if(!/^(?:www\.)?amazon(?:\.co|com)?\.(?:au|br|ca|fr|de|in|it|jp|mx|nl|sg|es|tr|ae|uk|cn)$/.test(e.hostname))return e;let,t=e.pathname.match(/\/dp\/(\w\d+)/)??e.pathname.match(/\/gp\/product\/(\w\d+)/)??e.pathname.match(/\/exec\/obidos\/asin\/(\w\d+)/)??e.pathname.match(/\/o\/ASIN\/(\w\d+)/)??[];return t&&(e.hash="",e.search="",e.pathname=/dp/${t}),e};var Yn=e=>{if(!/(?:0-9a-z-\.)?gyazo\.com/.test(e.hostname))return e;let,t=e.pathname.match(/^\/(0-9a-f{32})(?:\/raw)?$/)??[];return t?[https://gyazo.com/${t}]:e};var Qn=(e,...t)=>{if(e instanceof URL)return ar(new URL(e),...t);let r=0,n=0,o=0,s=!1,a=e.split(/(https?:\/\/\S+)/g).map(u=>{if(!/^https?:\/\/\S+$/.test(u))return u;r++;try{let f=ar(new URL(u),...t);return Re(f)?(n++,f):(s=!0,f,u)}catch(f){return console.error(f),o++,u}});if(!s)return a.join("");let{render:i,dispose:c}=ln(),l=()=>i({type:"spinner"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed});return l(),Promise.all(a.map(async u=>{if(Re(u))return u;try{let f=await u0;return n++,f}catch(f){return console.error(f),o++,u1}finally{l()}})).then(u=>(i({type:"check-circle"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed}),u.join(""))).finally(()=>{setTimeout(c,1e3)})};var Zn=async e=>{if("images"in e)return Le(e);let{quote:t,...r}=Je(e);return[...t?(await Le(t)).split(` ).map(n=>> ${n}):[],...(await Le(r)).split(
).map(n=>> ${n})].join(
)};var Oa=[fr,Gn,fr,Kn,Xn,Tt(),Yn,Bn(Zn),qn,e=>{if(e.hostname==="raw.githubusercontent.com")return${e};if(e.hostname!=="github.com")return e;let[t,r,n]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!n)return e;let[,o,s]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${o&&s?L${o}-${s}/:o?L${o}/:""}https://raw.githubusercontent.com/${t}/${r}/${n}#.svg ${e}]},Jn()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=Qn(e,...Oa);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return en(r)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[([^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~][^\[\]]*)\]/g,"$1")).join( );if(e!=t)return t}});scrapbox.PopupMenu.addButton({title:"[]",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[([^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~][^\[\]]*)\]/g,"$1")).join( );if(e!=t)return t}});scrapbox.PopupMenu.addButton({title:"$",onClick:e=>$ ${e}});scrapbox.PopupMenu.addButton({title:"LaTeX→Scb",onClick:e=>e.replace(/\$(.+?)\$/g,"[$ $1 ]").replace(/\\\((.+?)\\\)/g,"[$ $1 ]").replace(/\$\$(.+?)\$\$/gs,(t,r)=>"[$ "+r.replace(/\n/g," ").replace(/\s*>/g,"")+" ]").replace(/\\\[(.+?)\\\]/gs,(t,r)=>"[$ "+r.replace(/\n/g," ").replace(/\s*>/g,"")+" ]")});function Aa(e){let t=/[,&;]|and|\n/gi,r=new RegExp("[\\d†\\*]|(\\s[a-z])+(\\s*$)|ORCID|View ORCID Profile|Author links open overlay panel|https?:\\/\\/\\S+","gi"),n=s=>s.toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");return e.replace(t,",").split(",").map(s=>s.replace(r,"").trim()).filter(s=>s.length>1).map(s=>${n(s)}).join(", ")}scrapbox.PopupMenu.addButton({title:"link authors",onClick:Aa});scrapbox.PopupMenu.addButton({title:"md→cs",onClick:e=>(e=e.split(/\n/).map(t=>t.replace(/^[\*\-\+] /g," ")).join( ),e=e.split(/\n/).map(t=>t.replace(/[\*\-\+] /g,"")).join(
),e=e.split(/\n/).map(t=>t.replace(/ {4}/g," ")).join(
),e=e.split(/\n/).map(t=>t.replace(/^([0-9]+\. )/g," $1")).join(
),e=e.split(/\n/).map(t=>t.replace(/\*{2}([^*]+)\*{2}/g,"[* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\_{2}([^_]+)\_{2}/g,"[* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\~\~(\~+|[^~]+)\~\~/g,"[- $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^# (.*)/g,"[******* $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{2} (.*)/g,"[****** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{3} (.*)/g,"[***** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{4} (.*)/g,"[**** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{5} (.*)/g,"[*** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^#{6} (.*)/g,"[** $1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/!?\[\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/!\[([^\]]+)\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1 $2]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\[([^\]]+)\]\((https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)\)/g,"[$1 $2]")).join(
),e=e.split(/\n/).map(t=>t.replace(/<(https?:\/\/[\w/:%#\$&\?\(\)~\.=\+\-]+)>/g,"[$1]")).join(
),e=e.split(/\n/).map(t=>t.replace(/^([\*|\-|\_]){3,}/g,"[/icons/hr.icon]")).join(
),e=e.split(/\n/).map(t=>t.replace(/\\([\\||\*|_|\{|\}|\|\|\(|\)|#|\+|\-|\.|\!])/g,"$1")).join(` ),e)});scrapbox.TimeStamp.removeAllFormats();scrapbox.TimeStamp.addFormat("YYYY/M/D");scrapbox.TimeStamp.addFormat("[[]YYYY/M/D[]]");scrapbox.TimeStamp.addFormat("YYYY/M/D HH:mm:ss");var eo=e=>{{let r=e.match(/^([^(]+)\(([^)]+)\)$/);if(r)return{fileName:r[1],lang:r[2]}}let t=e.split(".").pop();return t===void 0?{fileName:e,lang:e}:{fileName:e,lang:t}};var Ma=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),to=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Ma(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)},ro=(e,t)=>{if(t.hasTitle??!0){let[r,...n]=e;return r===void 0?[]:[{type:"title",rows:[r]},...n.reduce(to,[])]}return e.reduce(to,[])};var no=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var oo=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(n+1)).join(
)}};var _=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,s,a)=>{if(!t&&s.nested)return a?.()??[];if(!r&&s.quoted)return a?.()??[];for(let i of n){let c=i.exec(o);if(c===null)continue;let l=o.substring(0,c.index),u=o.substring(c.index+(c[0]?.length??0)),f=e(c[0]??"",s);return[...ie(l,s),...f,...ie(u,s)]}return a?.()??[]};var H=e=>[{type:"plain",raw:e,text:e}],so=_(H,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var Ia=/\[\s+\]/,$a=(e,t)=>t.context==="table"?H(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],io=_($a,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ia]});var Ua=/.*?/,_a=(e,t)=>t.context==="table"?H(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],ao=_(_a,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ua]});var ja=/^[$%] .+$/,Da=(e,t)=>{if(t.context==="table")return H(e,t);let r=e[0]??"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:n}]},co=_(Da,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ja]});var Fa=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Ha=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),s=new Set(n);if(s.has("*")){let a=n.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(s),nodes:ie(o,{...t,nested:!0})}]},lo=_(Ha,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Fa]});var Ba=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,Wa=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,Ga=/\[https?:\/\/[^\s\]]+\]/,qa=/https?:\/\/[^\s]+/,Ka=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let s=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},po=_(Ka,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Ba,Wa,Ga,qa]});var za=/\[\$ .+? \]/,Va=/\[\$ [^\]]+\]/,Ja=(e,t)=>t.context==="table"?H(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],uo=_(Ja,{parseOnNested:!1,parseOnQuoted:!0,patterns:[za,Va]});var fo=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,mo=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Xa=e=>{let[t="",r="",n=""]=e.split(","),o=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(n)?Number.parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:a}},Ya=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.match(fo)??e.match(mo);if(r===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,o="",s=""]=n?r:[r[0],r[2],r[1]],{latitude:a,longitude:i,zoom:c}=Xa(o),l=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${a},${i},${c}z:https://www.google.com/maps/@${a},${i},${c}z;return[{type:"googleMap",raw:e,latitude:a,longitude:i,zoom:c,place:s,url:l}]},go=_(Ya,{parseOnNested:!1,parseOnQuoted:!0,patterns:[fo,mo]});var Qa=/(?:^|\s)#\S+/,Za=(e,t)=>{if(t.context==="table")return H(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...H(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},ho=_(Za,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Qa]});var ec=/^\? .+$/,tc=(e,t)=>t.context==="table"?H(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],xo=_(tc,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ec]});var rc=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,nc=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),n=t.substring(0,r),o=n.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),a=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:n,pathType:o,type:"icon",raw:e}))},yo=_(nc,{parseOnNested:!0,parseOnQuoted:!0,patterns:[rc]});var oc=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,sc=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,ic=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,ac=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,cc=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||lc(e),lc=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),pc=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,a]=cc(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},bo=_(pc,{parseOnNested:!0,parseOnQuoted:!0,patterns:[oc,sc,ic,ac]});var uc=/\[\/?[^[\]]+\]/,fc=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},wo=_(fc,{parseOnNested:!0,parseOnQuoted:!0,patterns:[uc]});var mc=/^[0-9]+\. .*$/,dc=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=Number.parseInt(n,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:ie(s,{...t,nested:!1})}]},Eo=_(dc,{parseOnNested:!1,parseOnQuoted:!1,patterns:[mc]});var gc=/^>.*$/,hc=(e,t)=>t.context==="table"?H(e,t):[{type:"quote",raw:e,nodes:ie(e.substring(1),{...t,quoted:!0})}],Ro=_(hc,{parseOnNested:!1,parseOnQuoted:!1,patterns:[gc]});var xc=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,yc=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.substring(2,e.length-2),n=r.lastIndexOf(".icon"),o=r.substring(0,n),s=o.startsWith("/")?"root":"relative",a=r.substring(n+5,r.length),i=a.startsWith("*")?Number.parseInt(a.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:o,pathType:s,type:"strongIcon",raw:e}))},vo=_(yc,{parseOnNested:!1,parseOnQuoted:!0,patterns:[xc]});var bc=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,wc=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Ec=(e,t)=>{if(t.context==="table")return H(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},To=_(Ec,{parseOnNested:!1,parseOnQuoted:!0,patterns:[bc,wc]});var Rc=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,vc=(e,t)=>t.context==="table"?H(e,t):[{type:"strong",raw:e,nodes:ie(e.substring(2,e.length-2),{...t,nested:!0})}],Lo=_(vc,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Rc]});var Tc=(e,t,r)=>e===""?[]:r?.()??[],Lc=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>so(t,r))(),ie=Lc(Tc,Ro,xo,Eo,ao,co,uo,io,lo,To,vo,Lo,bo,po,yo,go,wo,ho);var ko=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:ie(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Po=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:s,cells:r.map(a=>a.text.substring(n+1)).map(a=>a.split(" ").map(i=>ie(i,{nested:!1,quoted:!1,context:"table"})))}};var Co=e=>({type:"title",text:e.rows[0].text});var No=e=>{switch(e.type){case"title":return Co(e);case"codeBlock":return oo(e);case"table":return Po(e);case"line":return ko(e)}};var mr=(e,t)=>{let r=no(e);return ro(r,{hasTitle:t?.hasTitle??!0}).map(No)};var So=(e,t,r)=>{if(r.length===0)return[];let n=r.map(i=>i.text).join( ),o=mr(n,{hasTitle:!0}),s=new Map,a=0;for(let i of o)switch(i.type){case"title":case"line":{a++;break}case"table":a+=i.cells.length+1;break;case"codeBlock":{let{fileName:c,lang:l}=eo(i.fileName),u=s.get(c);s.set(c,{path:u?.path??https://scrapbox.io/api/code/${e}/${gt(t)}/${gt(c)},lang:u?.lang??l,startIds:[...u?.startIds??[],r[a].id]}),a+=i.content.split( ).length+1;break}}return s.values()};function gr(e){let t=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(ge(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let o of n)t(o)}else{let o=Object.keys(n);r.write8(6),r.write32(o.length);for(let s of o)r.write(ge(s)),t(n[s])}},r=new kt;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),dr(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Oo(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return Xe(r.read());case 4:return r.read();case 5:{let a=r.read32(),i=[];for(let c=0;c<a;c++)i.push(t());return i}case 6:{let a=r.read32(),i={};for(let c=0;c<a;c++)i[Xe(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new kt(e),n=r.read32(),o=(n&1)===0;n>>>=1;let s=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:s}}var kt=class{constructor(t=new Uint8Array(1024)){this.buf=t}len=0;ptr=0;_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);dr(this.buf,t,r)}write(t){let r=this._write(4+t.length);dr(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return hr(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),n=this._read(r.length);return r.set(this.buf.subarray(n,n+t)),r}},ge,Xe,Ao;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;ge=r=>e.encode(r),Xe=r=>t.decode(r),Ao='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(ge("")instanceof Uint8Array))throw new Error(Invariant violation: "${Ao} instanceof Uint8Array" is incorrectly false
This indicates that your JavaScript environment is broken. You cannot use
esbuild in this environment because esbuild relies on this invariant. This
is not a problem with esbuild. You need to fix your environment instead.
);function hr(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function dr(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var st="0.23.0";var te=JSON.stringify,Mo="warning",Io="silent";function $o(e){if(ne(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var Nt=()=>null,Y=e=>typeof e=="boolean"?null:"a boolean",R=e=>typeof e=="string"?null:"a string",St=e=>e instanceof RegExp?null:"a RegExp object",He=e=>typeof e=="number"&&e===(e|0)?null:"an integer",jo=e=>typeof e=="function"?null:"a function",Z=e=>Array.isArray(e)?null:"an array",fe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Pc=e=>typeof e=="object"&&e!==null?null:"an array or an object",Cc=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Uo=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Do=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",Nc=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Sc=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Fo=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Oc=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function p(e,t,r,n){let o=e[r];if(t[r+""]=!0,o===void 0)return;let s=n(o);if(s!==null)throw new Error(${te(r)} must be ${s});return o}function re(e,t,r){for(let n in e)if(!(n in t))throw new Error(Invalid option ${r}: ${te(n)})}function Ho(e){let t=Object.create(null),r=p(e,t,"wasmModule",Cc),n=p(e,t,"workerURL",Oc);return re(e,t,"in initialize() call"),{wasmModule:r,workerURL:n}}function Bo(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let n=e[r];if(typeof n=="string"||n===!1)t[r]=n;else throw new Error(Expected ${te(r)} in mangle cache to map to either a string or false)}}return t}function Ot(e,t,r,n,o){let s=p(t,r,"color",Y),a=p(t,r,"logLevel",R),i=p(t,r,"logLimit",He);s!==void 0?e.push(--color=${s}):n&&e.push("--color=true"),e.push(--log-level=${a||o}),e.push(--log-limit=${i||0})}function ne(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+te(r):""} to be a string, got ${typeof e} instead);return e}function Wo(e,t,r){let n=p(t,r,"legalComments",R),o=p(t,r,"sourceRoot",R),s=p(t,r,"sourcesContent",Y),a=p(t,r,"target",Sc),i=p(t,r,"format",R),c=p(t,r,"globalName",R),l=p(t,r,"mangleProps",St),u=p(t,r,"reserveProps",St),f=p(t,r,"mangleQuoted",Y),v=p(t,r,"minify",Y),C=p(t,r,"minifySyntax",Y),D=p(t,r,"minifyWhitespace",Y),G=p(t,r,"minifyIdentifiers",Y),S=p(t,r,"lineLimit",He),W=p(t,r,"drop",Z),q=p(t,r,"dropLabels",Z),y=p(t,r,"charset",R),h=p(t,r,"treeShaking",Y),d=p(t,r,"ignoreAnnotations",Y),m=p(t,r,"jsx",R),E=p(t,r,"jsxFactory",R),w=p(t,r,"jsxFragment",R),T=p(t,r,"jsxImportSource",R),k=p(t,r,"jsxDev",Y),g=p(t,r,"jsxSideEffects",Y),x=p(t,r,"define",fe),L=p(t,r,"logOverride",fe),M=p(t,r,"supported",fe),$=p(t,r,"pure",Z),A=p(t,r,"keepNames",Y),N=p(t,r,"platform",R),I=p(t,r,"tsconfigRaw",Nc);if(n&&e.push(--legal-comments=${n}),o!==void 0&&e.push(--source-root=${o}),s!==void 0&&e.push(--sources-content=${s}),a&&(Array.isArray(a)?e.push(--target=${Array.from(a).map($o).join(",")}):e.push(--target=${$o(a)})),i&&e.push(--format=${i}),c&&e.push(--global-name=${c}),N&&e.push(--platform=${N}),I&&e.push(--tsconfig-raw=${typeof I=="string"?I:JSON.stringify(I)}),v&&e.push("--minify"),C&&e.push("--minify-syntax"),D&&e.push("--minify-whitespace"),G&&e.push("--minify-identifiers"),S&&e.push(--line-limit=${S}),y&&e.push(--charset=${y}),h!==void 0&&e.push(--tree-shaking=${h}),d&&e.push("--ignore-annotations"),W)for(let P of W)e.push(--drop:${ne(P,"drop")});if(q&&e.push(--drop-labels=${Array.from(q).map(P=>ne(P,"dropLabels")).join(",")}),l&&e.push(--mangle-props=${l.source}),u&&e.push(--reserve-props=${u.source}),f!==void 0&&e.push(--mangle-quoted=${f}),m&&e.push(--jsx=${m}),E&&e.push(--jsx-factory=${E}),w&&e.push(--jsx-fragment=${w}),T&&e.push(--jsx-import-source=${T}),k&&e.push("--jsx-dev"),g&&e.push("--jsx-side-effects"),x)for(let P in x){if(P.indexOf("=")>=0)throw new Error(Invalid define: ${P});e.push(--define:${P}=${ne(xP,"define",P)})}if(L)for(let P in L){if(P.indexOf("=")>=0)throw new Error(Invalid log override: ${P});e.push(--log-override:${P}=${ne(LP,"log override",P)})}if(M)for(let P in M){if(P.indexOf("=")>=0)throw new Error(Invalid supported: ${P});let O=M[P];if(typeof O!="boolean")throw new Error(Expected value for supported ${te(P)} to be a boolean, got ${typeof O} instead);e.push(--supported:${P}=${O})}if($)for(let P of $)e.push(--pure:${ne(P,"pure")});A&&e.push("--keep-names")}function Ac(e,t,r,n,o){let s=[],a=[],i=Object.create(null),c=null,l=null;Ot(s,t,i,r,n),Wo(s,t,i);let u=p(t,i,"sourcemap",Do),f=p(t,i,"bundle",Y),v=p(t,i,"splitting",Y),C=p(t,i,"preserveSymlinks",Y),D=p(t,i,"metafile",Y),G=p(t,i,"outfile",R),S=p(t,i,"outdir",R),W=p(t,i,"outbase",R),q=p(t,i,"tsconfig",R),y=p(t,i,"resolveExtensions",Z),h=p(t,i,"nodePaths",Z),d=p(t,i,"mainFields",Z),m=p(t,i,"conditions",Z),E=p(t,i,"external",Z),w=p(t,i,"packages",R),T=p(t,i,"alias",fe),k=p(t,i,"loader",fe),g=p(t,i,"outExtension",fe),x=p(t,i,"publicPath",R),L=p(t,i,"entryNames",R),M=p(t,i,"chunkNames",R),$=p(t,i,"assetNames",R),A=p(t,i,"inject",Z),N=p(t,i,"banner",fe),I=p(t,i,"footer",fe),P=p(t,i,"entryPoints",Pc),O=p(t,i,"absWorkingDir",R),U=p(t,i,"stdin",fe),B=p(t,i,"write",Y)??o,j=p(t,i,"allowOverwrite",Y),pe=p(t,i,"mangleCache",fe);if(i.plugins=!0,re(t,i,in ${e}() call),u&&s.push(--sourcemap${u===!0?"":=${u}}),f&&s.push("--bundle"),j&&s.push("--allow-overwrite"),v&&s.push("--splitting"),C&&s.push("--preserve-symlinks"),D&&s.push("--metafile"),G&&s.push(--outfile=${G}),S&&s.push(--outdir=${S}),W&&s.push(--outbase=${W}),q&&s.push(--tsconfig=${q}),w&&s.push(--packages=${w}),y){let b=[];for(let V of y){if(ne(V,"resolve extension"),V.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${V});b.push(V)}s.push(--resolve-extensions=${b.join(",")})}if(x&&s.push(--public-path=${x}),L&&s.push(--entry-names=${L}),M&&s.push(--chunk-names=${M}),$&&s.push(--asset-names=${$}),d){let b=[];for(let V of d){if(ne(V,"main field"),V.indexOf(",")>=0)throw new Error(Invalid main field: ${V});b.push(V)}s.push(--main-fields=${b.join(",")})}if(m){let b=[];for(let V of m){if(ne(V,"condition"),V.indexOf(",")>=0)throw new Error(Invalid condition: ${V});b.push(V)}s.push(--conditions=${b.join(",")})}if(E)for(let b of E)s.push(--external:${ne(b,"external")});if(T)for(let b in T){if(b.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${b});s.push(--alias:${b}=${ne(Tb,"alias",b)})}if(N)for(let b in N){if(b.indexOf("=")>=0)throw new Error(Invalid banner file type: ${b});s.push(--banner:${b}=${ne(Nb,"banner",b)})}if(I)for(let b in I){if(b.indexOf("=")>=0)throw new Error(Invalid footer file type: ${b});s.push(--footer:${b}=${ne(Ib,"footer",b)})}if(A)for(let b of A)s.push(--inject:${ne(b,"inject")});if(k)for(let b in k){if(b.indexOf("=")>=0)throw new Error(Invalid loader extension: ${b});s.push(--loader:${b}=${ne(kb,"loader",b)})}if(g)for(let b in g){if(b.indexOf("=")>=0)throw new Error(Invalid out extension: ${b});s.push(--out-extension:${b}=${ne(gb,"out extension",b)})}if(P)if(Array.isArray(P))for(let b=0,V=P.length;b<V;b++){let ue=P[b];if(typeof ue=="object"&&ue!==null){let we=Object.create(null),Ee=p(ue,we,"in",R),he=p(ue,we,"out",R);if(re(ue,we,"in entry point at index "+b),Ee===void 0)throw new Error('Missing property "in" for entry point at index '+b);if(he===void 0)throw new Error('Missing property "out" for entry point at index '+b);a.push([he,Ee])}else a.push(["",ne(ue,"entry point at index "+b)])}else for(let b in P)a.push([b,ne(P[b],"entry point",b)]);if(U){let b=Object.create(null),V=p(U,b,"contents",Fo),ue=p(U,b,"resolveDir",R),we=p(U,b,"sourcefile",R),Ee=p(U,b,"loader",R);re(U,b,'in "stdin" object'),we&&s.push(--sourcefile=${we}),Ee&&s.push(--loader=${Ee}),ue&&(l=ue),typeof V=="string"?c=ge(V):V instanceof Uint8Array&&(c=V)}let Q=[];if(h)for(let b of h)b+="",Q.push(b);return{entries:a,flags:s,write:B,stdinContents:c,stdinResolveDir:l,absWorkingDir:O,nodePaths:Q,mangleCache:Bo(pe)}}function Mc(e,t,r,n){let o=[],s=Object.create(null);Ot(o,t,s,r,n),Wo(o,t,s);let a=p(t,s,"sourcemap",Do),i=p(t,s,"sourcefile",R),c=p(t,s,"loader",R),l=p(t,s,"banner",R),u=p(t,s,"footer",R),f=p(t,s,"mangleCache",fe);return re(t,s,in ${e}() call),a&&o.push(--sourcemap=${a===!0?"external":a}),i&&o.push(--sourcefile=${i}),c&&o.push(--loader=${c}),l&&o.push(--banner=${l}),u&&o.push(--footer=${u}),{flags:o,mangleCache:Bo(f)}}function Go(e){let t={},r={didClose:!1,reason:""},n={},o=0,s=0,a=new Uint8Array(16*1024),i=0,c=y=>{let h=i+y.length;if(h>a.length){let m=new Uint8Array(h*2);m.set(a),a=m}a.set(y,i),i+=y.length;let d=0;for(;d+4<=i;){let m=hr(a,d);if(d+4+m>i)break;d+=4,D(a.subarray(d,d+m)),d+=m}d>0&&(a.copyWithin(0,d,i),i-=d)},l=y=>{r.didClose=!0,y&&(r.reason=": "+(y.message||y));let h="The service was stopped"+r.reason;for(let d in n)n[d](h,null);n={}},u=(y,h,d)=>{if(r.didClose)return d("The service is no longer running"+r.reason,null);let m=o++;n[m]=(E,w)=>{try{d(E,w)}finally{y&&y.unref()}},y&&y.ref(),e.writeToStdin(gr({id:m,isRequest:!0,value:h}))},f=(y,h)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(gr({id:y,isRequest:!1,value:h}))},v=async(y,h)=>{try{if(h.command==="ping"){f(y,{});return}if(typeof h.key=="number"){let d=t[h.key];if(!d)return;let m=d[h.command];if(m){await m(y,h);return}}throw new Error("Invalid command: "+h.command)}catch(d){let m=[Fe(d,e,null,void 0,"")];try{f(y,{errors:m})}catch{}}},C=!0,D=y=>{if(C){C=!1;let d=String.fromCharCode(...y);if(d!==st)throw new Error(Cannot start service: Host version "${st}" does not match binary version ${te(d)});return}let h=Oo(y);if(h.isRequest)v(h.id,h.value);else{let d=n[h.id];delete n[h.id],h.value.error?d(h.value.error,{}):d(null,h.value)}};return{readFromStdout:c,afterClose:l,service:{buildOrContext:({callName:y,refs:h,options:d,isTTY:m,defaultWD:E,callback:w})=>{let T=0,k=s++,g={},x={ref(){++T===1&&h&&h.ref()},unref(){--T===0&&(delete t[k],h&&h.unref())}};t[k]=g,x.ref(),Ic(y,k,u,f,x,e,g,d,m,E,(L,M)=>{try{w(L,M)}finally{x.unref()}})},transform:({callName:y,refs:h,input:d,options:m,isTTY:E,fs:w,callback:T})=>{let k=qo(),g=x=>{try{if(typeof d!="string"&&!(d instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:L,mangleCache:M}=Mc(y,m,E,Io),$={command:"transform",flags:L,inputFS:x!==null,input:x!==null?ge(x):typeof d=="string"?ge(d):d};M&&($.mangleCache=M),u(h,$,(A,N)=>{if(A)return T(new Error(A),null);let I=Ye(N.errors,k),P=Ye(N.warnings,k),O=1,U=()=>{if(--O===0){let B={warnings:P,code:N.code,map:N.map,mangleCache:void 0,legalComments:void 0};"legalComments"in N&&(B.legalComments=N?.legalComments),N.mangleCache&&(B.mangleCache=N?.mangleCache),T(null,B)}};if(I.length>0)return T(it("Transform failed",I,P),null);N.codeFS&&(O++,w.readFile(N.code,(B,j)=>{B!==null?T(B,null):(N.code=j,U())})),N.mapFS&&(O++,w.readFile(N.map,(B,j)=>{B!==null?T(B,null):(N.map=j,U())})),U()})}catch(L){let M=[];try{Ot(M,m,{},E,Io)}catch{}let $=Fe(L,e,k,void 0,"");u(h,{command:"error",flags:M,error:$},()=>{$.detail=k.load($.detail),T(it("Transform failed",[$],[]),null)})}};if((typeof d=="string"||d instanceof Uint8Array)&&d.length>1024*1024){let x=g;g=()=>w.writeFile(d,x)}g(null)},formatMessages:({callName:y,refs:h,messages:d,options:m,callback:E})=>{if(!m)throw new Error(Missing second argument in ${y}() call);let w={},T=p(m,w,"kind",R),k=p(m,w,"color",Y),g=p(m,w,"terminalWidth",He);if(re(m,w,in ${y}() call),T===void 0)throw new Error(Missing "kind" in ${y}() call);if(T!=="error"&&T!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${y}() call);let x={command:"format-msgs",messages:ke(d,"messages",null,"",g),isWarning:T==="warning"};k!==void 0&&(x.color=k),g!==void 0&&(x.terminalWidth=g),u(h,x,(L,M)=>{if(L)return E(new Error(L),null);E(null,M.messages)})},analyzeMetafile:({callName:y,refs:h,metafile:d,options:m,callback:E})=>{m===void 0&&(m={});let w={},T=p(m,w,"color",Y),k=p(m,w,"verbose",Y);re(m,w,in ${y}() call);let g={command:"analyze-metafile",metafile:d};T!==void 0&&(g.color=T),k!==void 0&&(g.verbose=k),u(h,g,(x,L)=>{if(x)return E(new Error(x),null);E(null,L.result)})}}}}function Ic(e,t,r,n,o,s,a,i,c,l,u){let f=qo(),v=e==="context",C=(S,W)=>{let q=[];try{Ot(q,i,{},c,Mo)}catch{}let y=Fe(S,s,f,void 0,W);r(o,{command:"error",flags:q,error:y},()=>{y.detail=f.load(y.detail),u(it(v?"Context failed":"Build failed",[y],[]),null)})},D;if(typeof i=="object"){let S=i.plugins;if(S!==void 0){if(!Array.isArray(S))return C(new Error('"plugins" must be an array'),"");D=S}}if(D&&D.length>0){if(s.isSync)return C(new Error("Cannot use plugins in synchronous API calls"),"");$c(t,r,n,o,s,a,i,D,f).then(S=>{if(!S.ok)return C(S.error,S.pluginName);try{G(S.requestPlugins,S.runOnEndCallbacks,S.scheduleOnDisposeCallbacks)}catch(W){C(W,"")}},S=>C(S,""));return}try{G(null,(S,W)=>W([],[]),()=>{})}catch(S){C(S,"")}function G(S,W,q){let y=s.hasFS,{entries:h,flags:d,write:m,stdinContents:E,stdinResolveDir:w,absWorkingDir:T,nodePaths:k,mangleCache:g}=Ac(e,i,c,Mo,y);if(m&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let x={command:"build",key:t,entries:h,flags:d,write:m,stdinContents:E,stdinResolveDir:w,absWorkingDir:T||l,nodePaths:k,context:v};S&&(x.plugins=S),g&&(x.mangleCache=g);let L=(A,N)=>{let I={errors:Ye(A.errors,f),warnings:Ye(A.warnings,f),outputFiles:void 0,metafile:void 0,mangleCache:void 0},P=I.errors.slice(),O=I.warnings.slice();A.outputFiles&&(I.outputFiles=A.outputFiles.map(_c)),A.metafile&&(I.metafile=JSON.parse(A.metafile)),A.mangleCache&&(I.mangleCache=A.mangleCache),A.writeToStdout!==void 0&&console.log(Xe(A.writeToStdout).replace(/\n$/,"")),W(I,(U,B)=>{if(P.length>0||U.length>0){let j=it("Build failed",P.concat(U),O.concat(B));return N(j,null,U,B)}N(null,I,U,B)})},M,$;v&&(a["on-end"]=(A,N)=>new Promise(I=>{L(N,(P,O,U,B)=>{let j={errors:U,warnings:B};$&&$(P,O),M=void 0,$=void 0,n(A,j),I()})})),r(o,x,(A,N)=>{if(A)return u(new Error(A),null);if(!v)return L(N,(O,U)=>(q(),u(O,U)));if(N.errors.length>0)return u(it("Context failed",N.errors,N.warnings),null);let I=!1,P={rebuild:()=>(M||(M=new Promise((O,U)=>{let B;$=(pe,Q)=>{B||(B=()=>pe?U(pe):O(Q))};let j=()=>{r(o,{command:"rebuild",key:t},(Q,b)=>{Q?U(new Error(Q)):B?B():j()})};j()})),M),watch:(O={})=>new Promise((U,B)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');re(O,{},"in watch() call"),r(o,{command:"watch",key:t},Q=>{Q?B(new Error(Q)):U(void 0)})}),serve:(O={})=>new Promise((U,B)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let j={},pe=p(O,j,"port",He),Q=p(O,j,"host",R),b=p(O,j,"servedir",R),V=p(O,j,"keyfile",R),ue=p(O,j,"certfile",R),we=p(O,j,"fallback",R),Ee=p(O,j,"onRequest",jo);re(O,j,"in serve() call");let he={command:"serve",key:t,onRequest:!!Ee};pe!==void 0&&(he.port=pe),Q!==void 0&&(he.host=Q),b!==void 0&&(he.servedir=b),V!==void 0&&(he.keyfile=V),ue!==void 0&&(he.certfile=ue),we!==void 0&&(he.fallback=we),r(o,he,(Jr,Bi)=>{if(Jr)return B(new Error(Jr));Ee&&(a["serve-request"]=(Wi,Gi)=>{Ee(Gi.args),n(Wi,{})}),U(Bi)})}),cancel:()=>new Promise(O=>{if(I)return O();r(o,{command:"cancel",key:t},()=>{O()})}),dispose:()=>new Promise(O=>{if(I)return O();I=!0,r(o,{command:"dispose",key:t},()=>{O(),q(),o.unref()})})};o.ref(),u(null,P)})}}var $c=async(e,t,r,n,o,s,a,i,c)=>{let l=[],u=[],f={},v={},C=[],D=0,G=0,S=[],W=!1;i=[...i];for(let h of i){let d={};if(typeof h!="object")throw new Error(Plugin at index ${G} must be an object);let m=p(h,d,"name",R);if(typeof m!="string"||m==="")throw new Error(Plugin at index ${G} is missing a name);try{let E=p(h,d,"setup",jo);if(typeof E!="function")throw new Error("Plugin is missing a setup function");re(h,d,on plugin ${te(m)});let w={name:m,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};G++;let k=E({initialOptions:a,resolve:(g,x={})=>{if(!W)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof g!="string")throw new Error("The path to resolve must be a string");let L=Object.create(null),M=p(x,L,"pluginName",R),$=p(x,L,"importer",R),A=p(x,L,"namespace",R),N=p(x,L,"resolveDir",R),I=p(x,L,"kind",R),P=p(x,L,"pluginData",Nt),O=p(x,L,"with",fe);return re(x,L,"in resolve() call"),new Promise((U,B)=>{let j={command:"resolve",path:g,key:e,pluginName:m};if(M!=null&&(j.pluginName=M),$!=null&&(j.importer=$),A!=null&&(j.namespace=A),N!=null&&(j.resolveDir=N),I!=null)j.kind=I;else throw new Error('Must specify "kind" when calling "resolve"');P!=null&&(j.pluginData=c.store(P)),O!=null&&(j.with=Uc(O,"with")),t(n,j,(pe,Q)=>{pe!==null?B(new Error(pe)):U({errors:Ye(Q.errors,c),warnings:Ye(Q.warnings,c),path:Q.path,external:Q.external,sideEffects:Q.sideEffects,namespace:Q.namespace,suffix:Q.suffix,pluginData:c.load(Q.pluginData)})})})},onStart(g){let x='This error came from the "onStart" callback registered here:',L=Pt(new Error(x),o,"onStart");l.push({name:m,callback:g,note:L}),w.onStart=!0},onEnd(g){let x='This error came from the "onEnd" callback registered here:',L=Pt(new Error(x),o,"onEnd");u.push({name:m,callback:g,note:L}),w.onEnd=!0},onResolve(g,x){let L='This error came from the "onResolve" callback registered here:',M=Pt(new Error(L),o,"onResolve"),$={},A=p(g,$,"filter",St),N=p(g,$,"namespace",R);if(re(g,$,in onResolve() call for plugin ${te(m)}),A==null)throw new Error("onResolve() call is missing a filter");let I=D++;f[I]={name:m,callback:x,note:M},w.onResolve.push({id:I,filter:A.source,namespace:N||""})},onLoad(g,x){let L='This error came from the "onLoad" callback registered here:',M=Pt(new Error(L),o,"onLoad"),$={},A=p(g,$,"filter",St),N=p(g,$,"namespace",R);if(re(g,$,in onLoad() call for plugin ${te(m)}),A==null)throw new Error("onLoad() call is missing a filter");let I=D++;v[I]={name:m,callback:x,note:M},w.onLoad.push({id:I,filter:A.source,namespace:N||""})},onDispose(g){C.push(g)},esbuild:o.esbuild});k&&await k,S.push(w)}catch(E){return{ok:!1,error:E,pluginName:m}}}s["on-start"]=async(h,d)=>{let m={errors:[],warnings:[]};await Promise.all(l.map(async({name:E,callback:w,note:T})=>{try{let k=await w();if(k!=null){if(typeof k!="object")throw new Error(Expected onStart() callback in plugin ${te(E)} to return an object);let g={},x=p(k,g,"errors",Z),L=p(k,g,"warnings",Z);re(k,g,from onStart() callback in plugin ${te(E)}),x!=null&&m.errors.push(...ke(x,"errors",c,E,void 0)),L!=null&&m.warnings.push(...ke(L,"warnings",c,E,void 0))}}catch(k){m.errors.push(Fe(k,o,c,T&&T(),E))}})),r(h,m)},s["on-resolve"]=async(h,d)=>{let m={},E="",w,T;for(let k of d.ids)try{({name:E,callback:w,note:T}=f[k]);let g=await w({path:d.path,importer:d.importer,namespace:d.namespace,resolveDir:d.resolveDir,kind:d.kind,pluginData:c.load(d.pluginData),with:d.with});if(g!=null){if(typeof g!="object")throw new Error(Expected onResolve() callback in plugin ${te(E)} to return an object);let x={},L=p(g,x,"pluginName",R),M=p(g,x,"path",R),$=p(g,x,"namespace",R),A=p(g,x,"suffix",R),N=p(g,x,"external",Y),I=p(g,x,"sideEffects",Y),P=p(g,x,"pluginData",Nt),O=p(g,x,"errors",Z),U=p(g,x,"warnings",Z),B=p(g,x,"watchFiles",Z),j=p(g,x,"watchDirs",Z);re(g,x,from onResolve() callback in plugin ${te(E)}),m.id=k,L!=null&&(m.pluginName=L),M!=null&&(m.path=M),$!=null&&(m.namespace=$),A!=null&&(m.suffix=A),N!=null&&(m.external=N),I!=null&&(m.sideEffects=I),P!=null&&(m.pluginData=c.store(P)),O!=null&&(m.errors=ke(O,"errors",c,E,void 0)),U!=null&&(m.warnings=ke(U,"warnings",c,E,void 0)),B!=null&&(m.watchFiles=Ct(B,"watchFiles")),j!=null&&(m.watchDirs=Ct(j,"watchDirs"));break}}catch(g){m={id:k,errors:[Fe(g,o,c,T&&T(),E)]};break}r(h,m)},s["on-load"]=async(h,d)=>{let m={},E="",w,T;for(let k of d.ids)try{({name:E,callback:w,note:T}=v[k]);let g=await w({path:d.path,namespace:d.namespace,suffix:d.suffix,pluginData:c.load(d.pluginData),with:d.with});if(g!=null){if(typeof g!="object")throw new Error(Expected onLoad() callback in plugin ${te(E)} to return an object);let x={},L=p(g,x,"pluginName",R),M=p(g,x,"contents",Fo),$=p(g,x,"resolveDir",R),A=p(g,x,"pluginData",Nt),N=p(g,x,"loader",R),I=p(g,x,"errors",Z),P=p(g,x,"warnings",Z),O=p(g,x,"watchFiles",Z),U=p(g,x,"watchDirs",Z);re(g,x,from onLoad() callback in plugin ${te(E)}),m.id=k,L!=null&&(m.pluginName=L),M instanceof Uint8Array?m.contents=M:M!=null&&(m.contents=ge(M)),$!=null&&(m.resolveDir=$),A!=null&&(m.pluginData=c.store(A)),N!=null&&(m.loader=N),I!=null&&(m.errors=ke(I,"errors",c,E,void 0)),P!=null&&(m.warnings=ke(P,"warnings",c,E,void 0)),O!=null&&(m.watchFiles=Ct(O,"watchFiles")),U!=null&&(m.watchDirs=Ct(U,"watchDirs"));break}}catch(g){m={id:k,errors:[Fe(g,o,c,T&&T(),E)]};break}r(h,m)};let q=(h,d)=>d([],[]);u.length>0&&(q=(h,d)=>{(async()=>{let m=[],E=[];for(let{name:w,callback:T,note:k}of u){let g,x;try{let L=await T(h);if(L!=null){if(typeof L!="object")throw new Error(Expected onEnd() callback in plugin ${te(w)} to return an object);let M={},$=p(L,M,"errors",Z),A=p(L,M,"warnings",Z);re(L,M,from onEnd() callback in plugin ${te(w)}),$!=null&&(g=ke($,"errors",c,w,void 0)),A!=null&&(x=ke(A,"warnings",c,w,void 0))}}catch(L){g=[Fe(L,o,c,k&&k(),w)]}if(g){m.push(...g);try{h.errors.push(...g)}catch{}}if(x){E.push(...x);try{h.warnings.push(...x)}catch{}}}d(m,E)})()});let y=()=>{for(let h of C)setTimeout(()=>h(),0)};return W=!0,{ok:!0,requestPlugins:S,runOnEndCallbacks:q,scheduleOnDisposeCallbacks:y}};function qo(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let n=t++;return e.set(n,r),n}}}function Pt(e,t,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let s=(e.stack+"").split( );s.splice(1,1);let a=Ko(t,s,r);if(a)return n={text:e.message,location:a},n}catch{}}}function Fe(e,t,r,n,o){let s="Internal error",a=null;try{s=(e&&e.message||e)+""}catch{}try{a=Ko(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:o,text:s,location:a,notes:n?[n]:[],detail:r?r.store(e):-1}}function Ko(e,t,r){let n=" at ";if(e.readFileSync&&!t[0].startsWith(n)&&t[1].startsWith(n))for(let o=1;o<t.length;o++){let s=t[o];if(s.startsWith(n))for(s=s.slice(n.length);;){let a=/^(?:new |async )?\S+ \((.*)\)$/.exec(s);if(a){s=a[1];continue}if(a=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(s),a){s=a[1];continue}if(a=/^(\S+):(\d+):(\d+)$/.exec(s),a){let i;try{i=e.readFileSync(a[1],"utf8")}catch{break}let c=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+a[2]-1]||"",l=+a[3]-1,u=c.slice(l,l+r.length)===r?r.length:0;return{file:a[1],namespace:"file",line:+a[2],column:ge(c.slice(0,l)).length,length:ge(c.slice(l,l+u)).length,lineText:c+
+t.slice(1).join(
),suggestion:""}}break}}return null}function it(e,t,r){let n=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,n+1).map((s,a)=>{if(a===n)return
...;if(!s.location)return
${i}:${c}:${l}: ERROR: ${u}${s.text}}).join("");let o=new Error(e);for(let[s,a]of[["errors",t],["warnings",r]])Object.defineProperty(o,s,{configurable:!0,enumerable:!0,get:()=>a,set:i=>Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:i})});return o}function Ye(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function _o(e,t,r){if(e==null)return null;let n={},o=p(e,n,"file",R),s=p(e,n,"namespace",R),a=p(e,n,"line",He),i=p(e,n,"column",He),c=p(e,n,"length",He),l=p(e,n,"lineText",R),u=p(e,n,"suggestion",R);if(re(e,n,t),l){let f=l.slice(0,(i&&i>0?i:0)+(c&&c>0?c:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(f)&&!/\n/.test(l)&&(l=f)}return{file:o||"",namespace:s||"",line:a||0,column:i||0,length:c||0,lineText:l||"",suggestion:u||""}}function ke(e,t,r,n,o){let s=[],a=0;for(let i of e){let c={},l=p(i,c,"id",R),u=p(i,c,"pluginName",R),f=p(i,c,"text",R),v=p(i,c,"location",Uo),C=p(i,c,"notes",Z),D=p(i,c,"detail",Nt),G=in element ${a} of "${t}";re(i,c,G);let S=[];if(C)for(let W of C){let q={},y=p(W,q,"text",R),h=p(W,q,"location",Uo);re(W,q,G),S.push({text:y||"",location:_o(h,G,o)})}s.push({id:l||"",pluginName:u||n,text:f||"",location:_o(v,G,o),notes:S,detail:r?r.store(D):-1}),a++}return s}function Ct(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(${te(t)} must be an array of strings);r.push(n)}return r}function Uc(e,t){let r=Object.create(null);for(let n in e){let o=e[n];if(typeof o!="string")throw new Error(key ${te(n)} in object ${te(t)} must be a string);r[n]=o}return r}function _c({path:e,contents:t,hash:r}){let n=null;return{path:e,contents:t,hash:r,get text(){let o=this.contents;return(n===null||o!==t)&&(t=o,n=Xe(o)),n}}}var Vo=st,Mt=e=>It().build(e),Jo=(e,t)=>It().transform(e,t),Xo=(e,t)=>It().formatMessages(e,t),Yo=(e,t)=>It().analyzeMetafile(e,t);var Be,zo,At,It=()=>{if(At)return At;throw Be?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},$t=e=>{e=Ho(e||{});let t=e.wasmModule,r=e.workerURL;if(!t)throw new Error('Must provide the "wasmModule" option');if(Be)throw new Error('Cannot call "initialize" more than once');return Be=Dc(t,r),Be.catch(()=>{Be=void 0}),Be},Dc=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),n,o,s=new Promise((c,l)=>{n=c,o=l});r.onmessage=({data:c})=>{r.onmessage=({data:l})=>a(l),c?o(c):n()},r.postMessage(e);let{readFromStdout:a,service:i}=Go({writeToStdin(c){r.postMessage(c)},isSync:!1,hasFS:!1,esbuild:{build:Mt,transform:Jo,formatMessages:Xo,analyzeMetafile:Yo,version:Vo,initialize:$t}});await s,zo=()=>{r.terminate(),Be=void 0,zo=void 0,At=void 0},At={build:c=>new Promise((l,u)=>i.buildOrContext({callName:"build",refs:null,options:c,isTTY:!1,defaultWD:"/",callback:(f,v)=>f?u(f):l(v)})),transform:(c,l)=>new Promise((u,f)=>i.transform({callName:"transform",refs:null,input:c,options:l||{},isTTY:!1,fs:{readFile(v,C){C(new Error("Internal error"),null)},writeFile(v,C){C(null)}},callback:(v,C)=>v?f(v):u(C)})),formatMessages:(c,l)=>new Promise((u,f)=>i.formatMessages({callName:"formatMessages",refs:null,messages:c,options:l,callback:(v,C)=>v?f(v):u(C)})),analyzeMetafile:(c,l)=>new Promise((u,f)=>i.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof c=="string"?c:JSON.stringify(c),options:l,callback:(v,C)=>v?f(v):u(C)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function se(e){if(typeof e!="string")throw new TypeError(Path must be a string. Received ${JSON.stringify(e)})}function xe(e){return e===47||e===92}function Pe(e){return e>=97&&e<=122||e>=65&&e<=90}function jt(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError("Must be a file URL.");return e}function Qo(e){e=jt(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}function yr(e){se(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return xe(r)?!0:!!(Pe(r)&&t>2&&e.charCodeAt(1)===58&&xe(e.charCodeAt(2)))}var Dt=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function Ft(e,t=""){if(!e)throw new Dt(t)}var Qc={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Ht(e){return e.replaceAll(/[\s]/g,t=>Qc[t]??t)}function ts(e){if(!yr(e))throw new TypeError("Must be an absolute path.");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Ht(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError("Invalid hostname.");return n}function Ce(e){return e===47}function ns(e){return e=jt(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function wr(e){return se(e),e.length>0&&Ce(e.charCodeAt(0))}function ss(e){if(!wr(e))throw new TypeError("Must be an absolute path.");let t=new URL("file:///");return t.pathname=Ht(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}var pl=(()=>{let{Deno:e}=globalThis;if(typeof e?.build?.os=="string")return e.build.os;let{navigator:t}=globalThis;return t?.appVersion?.includes?.("Win")?"windows":"linux"})(),ee=pl==="windows";var Qe=ee?"\\":"/";function Bt(e){return ee?Qo(e):ns(e)}function ct(e){return ee?ts(e):ss(e)}function Wt(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Gt(e){let t={},r=Object.keys(e).sort((n,o)=>o.length-n.length);for(let n of r)t[n]=e[n];return t}function is(e){return Wt(e)&&(e.imports!==void 0?Er(e.imports):!0)&&(e.scopes!==void 0?Rr(e.scopes):!0)}function Er(e){return Wt(e)}function Rr(e){return Wt(e)&&Object.values(e).every(t=>vr(t))}function vr(e){return Wt(e)}function qt(e){try{return new URL(e),!0}catch{return!1}}function cs(e,t){let r={};for(let[n,o]of Object.entries(e)){let s=fl(n,t);if(s===null)continue;if(typeof o!="string"){console.warn("addresses need to be strings."),r[s]=null;continue}let a=Tr(o,t);if(a===null){console.warn("the address was invalid."),r[s]=null;continue}if(n.endsWith("/")&&!ye(a).endsWith("/")){console.warn("an invalid address was given for the specifier key specifierKey; since specifierKey ended in a slash, the address needs to as well."),r[s]=null;continue}r[s]=ye(a)}return Gt(r)}function ye(e){return e.href}function ul(e,t){let r={};for(let[o,s]of Object.entries(e)){if(!vr(s))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let a;try{a=new URL(o,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let i=ye(a);r[i]=cs(s,t)}let n={};for(let o of Object.keys(r))n[o]=Gt(r[o]);return Gt(n)}function fl(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=Tr(e,t);return r!==null?ye(r):e}function Tr(e,t){if(t&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")))try{return new URL(e,t)}catch{return null}try{return new URL(e)}catch{return null}}var ml=["ftp","file","http","https","ws","wss"];function dl(e){return ml.some(t=>ye(e).startsWith(t))}function as(e,t,r){for(let[n,o]of Object.entries(r))if(n===e){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!qt(o))throw new TypeError("resolutionResult must be an URL.");return o}else if(n.endsWith("/")&&e.startsWith(n)&&(t===null||dl(t))){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!qt(o))throw new TypeError("resolutionResult must be an URL.");let s=e.slice(n.length);if(!o.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let a=new URL(s,o);if(!qt(a))throw new TypeError("url must be an URL.");if(!ye(a).startsWith(o))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return ye(a)}catch{throw new TypeError("resolution of normalizedSpecifier was blocked since the afterPrefix portion could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.")}}return null}function Lr(e,t){let r={};if(!is(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:n,scopes:o}=e;if(n!==void 0){if(!Er(n))throw new TypeError('"imports" top-level key needs to be an object.');r=cs(n,t)}let s={};if(o!==void 0){if(!Rr(o))throw new TypeError('"scopes" top-level key needs to be an object.');s=ul(o,t)}return Object.keys(e).find(a=>a!=="imports"&&a!=="scopes")&&console.warn("an invalid top-level key was present in the import map."),{imports:r,scopes:s}}function ls(e,{imports:t={},scopes:r={}},n){let o=ye(n),s=Tr(e,n),a=s!==null?ye(s):e;for(let[c,l]of Object.entries(r))if(c===o||c.endsWith("/")&&o.startsWith(c)){let u=as(a,s,l);if(u!==null)return u}let i=as(a,s,t);if(i!==null)return i;if(s!==null)return ye(s);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}function us(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new kr(e,{allowTrailingComma:t}).parse()}var ps=globalThis.JSON.parse,kr=class{#s=new Set( \r
);#r=new Set([..."[]{}:,/",...this.#s]);#t;#e;#o;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#o=this.#l(),this.#a=r}parse(){let t=this.#n(),r=this.#p(t),{done:n,value:o}=this.#o.next();if(!n)throw new SyntaxError(Ae(o));return r}#n(){let{done:t,value:r}=this.#o.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#l(){for(let t=0;t<this.#e;t++)if(!this.#s.has(this.#t[t])){if(this.#t[t]==="/"&&this.#t[t+1]==="*"){t+=2;let r=!1;for(;t<this.#e;t++)if(this.#t[t]==="*"&&this.#t[t+1]==="/"){r=!0;break}if(!r)throw new SyntaxError("Unexpected end of JSONC input");t++;continue}if(this.#t[t]==="/"&&this.#t[t+1]==="/"){for(t+=2;t<this.#e&&!(this.#t[t]===
||this.#t[t]==="\r");t++);continue}switch(this.#t[t]){case"{":yield{type:"BeginObject",position:t};break;case"}":yield{type:"EndObject",position:t};break;case"[":yield{type:"BeginArray",position:t};break;case"]":yield{type:"EndArray",position:t};break;case":":yield{type:"NameSeparator",position:t};break;case",":yield{type:"ValueSeparator",position:t};break;case'"':{let r=t,n=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!n);t++)n=this.#t[t]==="\\"&&!n;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#r.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#p(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#i();case"NullOrTrueOrFalseOrNumber":return this.#h(t);case"String":return this.#g(t);default:throw new SyntaxError(Ae(t))}}#f(){let t={};for(let r=!0;;r=!1){let n=this.#n();if((r||this.#a.allowTrailingComma)&&n.type==="EndObject")return t;if(n.type!=="String")throw new SyntaxError(Ae(n));let o=this.#g(n),s=this.#n();if(s.type!=="NameSeparator")throw new SyntaxError(Ae(s));let a=this.#n();Object.defineProperty(t,o,{value:this.#p(a),writable:!0,enumerable:!0,configurable:!0});let i=this.#n();if(i.type==="EndObject")return t;if(i.type!=="ValueSeparator")throw new SyntaxError(Ae(i))}}#i(){let t=[];for(let r=!0;;r=!1){let n=this.#n();if((r||this.#a.allowTrailingComma)&&n.type==="EndArray")return t;t.push(this.#p(n));let o=this.#n();if(o.type==="EndArray")return t;if(o.type!=="ValueSeparator")throw new SyntaxError(Ae(o))}}#g(t){let r;try{r=ps(t.sourceText)}catch{throw new SyntaxError(Ae(t))}return Ft(typeof r=="string"),r}#h(t){if(t.sourceText==="null")return null;if(t.sourceText==="true")return!0;if(t.sourceText==="false")return!1;let r;try{r=ps(t.sourceText)}catch{throw new SyntaxError(Ae(t))}return Ft(typeof r=="number"),r}};function Ae({type:e,sourceText:t,position:r}){let n="";switch(e){case"BeginObject":n="{";break;case"EndObject":n="}";break;case"BeginArray":n="[";break;case"EndArray":n="]";break;case"NameSeparator":n=":";break;case"ValueSeparator":n=",";break;case"NullOrTrueOrFalseOrNumber":case"String":n=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${n} in JSONC at position ${r}}function zt(e){if(e.protocol==="file:")return{path:Bt(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function Pr(e){let t=await Deno.readTextFile(e),r=us(t);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(Deno config at ${e} must be an object);if("imports"in r&&(typeof r.imports!="object"||r.imports===null||Array.isArray(r.imports)))throw new Error(Deno config at ${e} has invalid "imports" key);if("scopes"in r&&(typeof r.scopes!="object"||r.scopes===null||Array.isArray(r.scopes)))throw new Error(Deno config at ${e} has invalid "scopes" key);if("lock"in r&&typeof r.lock!="boolean"&&typeof r.lock!="string")throw new Error(Deno config at ${e} has invalid "lock" key);if("importMap"in r&&typeof r.importMap!="string")throw new Error(Deno config at ${e} has invalid "importMap" key);return r}function fs(e){if(e.imports!==void 0){let t=[];for(let[r,n]of Object.entries(e.imports))if(t.push([r,n]),!r.endsWith("/")&&n&&(n.startsWith("jsr:")||n.startsWith("npm:"))&&!e.imports[r+"/"]){let o=r+"/",s=n.slice(0,4)+"/"+n.slice(n[4]==="/"?5:4)+"/";t.push([o,s])}e.imports=Object.fromEntries(t)}}var hl=${Qe}node_modules${Qe},xl=${Qe}node_modules;function Kt(e){return e.includes(hl)||e.endsWith(xl)}function Cr(e){return(e.namespace===""||e.namespace==="file")&&(Kt(e.resolveDir)||Kt(e.path)||Kt(e.importer))}function Nr(e={}){return{name:"deno-resolver",setup(t){let r=null,n=(t.initialOptions.external??[]).map(o=>new RegExp("^"+o.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let s;if(e.importMapURL===void 0&&e.configPath!==void 0){let a=await Pr(e.configPath);if(a.imports!==void 0||a.scopes!==void 0){let i={imports:a.imports,scopes:a.scopes};fs(i),r=Lr(i,ct(e.configPath))}else a.importMap!==void 0&&(s=new URL(a.importMap,ct(e.configPath)).href)}else e.importMapURL!==void 0&&(s=e.importMapURL);if(s){let a=await fetch(s),i=await a.json();r=Lr(i,new URL(a.url))}}),t.onResolve({filter:/.*/},async function(s){if(Cr(s))return;let a;if(s.importer!==""){if(s.namespace==="")throw new Error("[assert] namespace is empty");a=new URL(${s.namespace}:${s.importer})}else if(s.resolveDir!=="")a=new URL(${ct(s.resolveDir).href}/);else return;let i;if(r!==null){let f=ls(s.path,r,new URL(a));i=new URL(f)}else i=new URL(s.path,a);for(let f of n)if(f.test(i.href))return{path:i.href,external:!0};let{path:c,namespace:l}=zt(i);return await t.resolve(c,{namespace:l,kind:s.kind})})}}}var t0=new TextEncoder;var yl=[],bl=[],Sr="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=Sr.length;e<t;++e)yl[e]=Sr[e],bl[Sr.charCodeAt(e)]=e;var R0=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var Pl=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var ms=Nr;var ds=" must not return ",Cl="transformer",Nl="recoverer",Sl="defaultValue",H0=Cl+ds,gs="called with ",B0=Sl+" must not be ",W0=Nl+ds,Ol="Ok",hs="Err",Al=gs+hs,Ml=gs+Ol,G0="Carrying E in "+hs+" instead of throwing it directly. See .cause",Or="an instance of Error of the current realm.",q0="The thrown value is not "+Or,K0="The contained E should be "+Or,z0="This .cause is not "+Or;function Ar(e){return e.ok}function oe(e){return{ok:!0,val:e,err:null}}function ae(e){return!e.ok}function J(e){return{ok:!1,val:null,err:e}}function ce(e){return Il(e,Al)}function We(e){return $l(e,Ml)}function Il(e,t){if(ae(e))throw new TypeError(t);return e.val}function $l(e,t){if(Ar(e))throw new TypeError(t);return e.err}function Ul(e){return e.val}async function Ze(e,t){if(ae(e))return e;let r=Ul(e),n=await t(r);return oe(n)}var xs=" must not return ",_l="transformer",jl="recoverer",Dl="defaultValue",Fl=_l+xs,Hl="called with ",Bl=Dl+" must not be ",Wl=jl+xs,Vt="null or undefined",Y0=Fl+Vt,Q0=Hl+Vt,Z0=Bl+Vt,eC=Wl+Vt;function Gl(e){return e!=null}function ql(e){return{ok:!0,val:e,err:null}}function Kl(e){return{ok:!1,val:null,err:e}}function ys(e,t){if(Gl(e))return ql(e);let r=t();return Kl(r)}var bs=e=>!!(zl.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),zl=["i.gyazo.com","t.gyazo.com","scrapbox.io","api.openai.com","*.openai.azure.com","maps.googleapis.com","upload.gyazo.com","storage.googleapis.com","sentry.io"];function Me(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function Ge(e){return e===47}function ws(e){Me(e);let t=-1,r=0,n=-1,o=!0,s=0;for(let a=e.length-1;a>=0;--a){let i=e.charCodeAt(a);if(Ge(i)){if(!o){r=a+1;break}continue}n===-1&&(o=!1,n=a+1),i===46?t===-1?t=a:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||n===-1||s===0||s===1&&t===n-1&&t===r+1?"":e.slice(t,n)}function Es(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let n=t.length-1;n>=0;--n)if(e.charCodeAt(r+n)!==t.charCodeAt(n))return e;return e.slice(0,-t.length)}function Rs(e,t,r=0){let n=!1,o=e.length;for(let s=e.length-1;s>=r;--s)if(t(e.charCodeAt(s))){if(n){r=s+1;break}}else n||(n=!0,o=s+1);return e.slice(r,o)}function vs(e,t){if(Me(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function Ts(e,t){if(e.length<=1)return e;let r=e.length;for(let n=e.length-1;n>0&&t(e.charCodeAt(n));n--)r=n;return e.slice(0,r)}function Ls(e,t=""){vs(e,t);let r=Rs(e,Ge),n=Ts(r,Ge);return t?Es(n,t):n}var Jt=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function Xt(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError(URL must be a file URL: received "${e.protocol}");return e}function ks(e){return e=Xt(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Ps(e){e=Xt(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}function Cs(e){return Jt?Ps(e):ks(e)}var Jl={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Yt(e){return e.replaceAll(/[\s]/g,t=>Jl[t]??t)}function Ns(e){return Me(e),e.length>0&&Ge(e.charCodeAt(0))}function Ss(e){if(!Ns(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=Yt(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function Ir(e){return e===47||e===92}function Os(e){return e>=97&&e<=122||e>=65&&e<=90}function As(e){Me(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return Ir(r)?!0:!!(Os(r)&&t>2&&e.charCodeAt(1)===58&&Ir(e.charCodeAt(2)))}function Ms(e){if(!As(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Yt(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError(Invalid hostname: "${n.hostname}");return n}function Is(e){return Jt?Ms(e):Ss(e)}var $s=e=>{if(e.protocol==="file:")return{path:Cs(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},$r=e=>e.namespace==="file"?Is(e.path):new URL(${e.namespace}:${e.path});var Us=(e,t)=>{let r=ys(rp(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(ae(r))return r;let{url:n,start:o,end:s}=ce(r);return URL.canParse(n,t)?oe({url:new URL(n,t),start:o,end:s}):J({name:"InvalidURLError",message:Invalid URL: ${n}})},rp=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,n=e.length,o=r;for(;o<n&&e.charCodeAt(o)>32;)o++;if(o!==r&&(t[1]==="/"||e.indexOf("*/",o)>0))return{url:e.slice(r,o),start:r,end:o}}};var np=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],_s=e=>np.includes(e),js=e=>/^js|^ts|css$/.test(e),Ds=e=>{let t=e.url,r=Ls(t);if(_s(r))return r;if(r==="mjs")return"js";let n=new URL(t);n.search="",n.hash="";let o=ws(n.href).slice(1);if(_s(o))return o;if(o==="mjs")return"js";let a=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return op(a)},op=e=>{let t=e.split("/")[1]??"plain";if(/(?:^plain$|^xml|^svg|^x?html)/.test(t))return"text";if(t.startsWith("json"))return"json";switch(t){case"javascript":return"js";case"typescript":return"ts";case"css":return"css";default:return"text"}};function Qt(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function Bs(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function _r(e=[],t=[]){let r=Math.max(e.length,t.length);for(let n=0;n<r;n++){let o=e[n],s=t[n];if(o===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(o===void 0)return-1;if(typeof o=="string"&&typeof s=="number")return 1;if(typeof o=="number"&&typeof s=="string"||o<s)return-1;if(o>s)return 1}return 0}var et="0|[1-9]\\d*",sp="\\d*[a-zA-Z-][a-zA-Z0-9-]*",ip=(?<major>${et})\\.(?<minor>${et})\\.(?<patch>${et}),Fs=(?:${et}|${sp}),Ws=(?:-(?<prerelease>${Fs}(?:\\.${Fs})*)),Hs="[0-9A-Za-z-]+",Gs=(?:\\+(?<buildmetadata>${Hs}(?:\\.${Hs})*)),qs=v?${ip}${Ws}?${Gs}?,Ks=new RegExp(^${qs}$),zs="(?:<|>)?=?",ap="x|X|\\*",Ur=${et}|${ap},Zt=v=\\s*(?<major>${Ur})(?:\\.(?<minor>${Ur})(?:\\.(?<patch>${Ur})${Ws}?${Gs}?)?)?,Vs=new RegExp(^(?<operator>~>?|\\^|${zs})\\s*${Zt}$),Js=new RegExp(^(?<operator>${zs})\\s*(${qs})$|^$);function jr(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var Dr=256;var cp=new RegExp(^${et}$);function le(e){return e.split(".").filter(Boolean).map(t=>{if(cp.test(t)){let r=Number(t);if(jr(r))return r}return t})}function be(e){return e.split(".").filter(Boolean)}function Ie(e,t){let r=Number(e);if(!jr(r))throw new TypeError(t);return r}function qe(e){return Number.isNaN(e.major)&&Number.isNaN(e.minor)&&Number.isNaN(e.patch)&&(e.prerelease===void 0||e.prerelease.length===0)&&(e.build===void 0||e.build.length===0)}function me(e,t){return e===t?0:Qt(e.major,t.major)||Qt(e.minor,t.minor)||Qt(e.patch,t.patch)||Bs(e.prerelease,t.prerelease)||_r(e.prerelease,t.prerelease)}function Fr(e){return e.toFixed(0)}function Ke(e){let t=Fr(e.major),r=Fr(e.minor),n=Fr(e.patch),o=e.prerelease?.join(".")??"",s=e.build?.join(".")??"";return[[${t}.${r}.${n},o].filter(c=>c).join("-"),s].filter(c=>c).join("+")}function lp(e,t){if(qe(t))return!0;let r=me(e,t);switch(t.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function er(e,t){for(let r of t)if(!lp(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(qe(r))continue;let{major:n,minor:o,patch:s,prerelease:a}=r;if(a&&a.length>0&&e.major===n&&e.minor===o&&e.patch===s)return!0}return!1}return!0}function tr(e,t){return t.some(r=>er(e,r))}var rr={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},tt={operator:void 0,...rr};function Xs(e,t){return me(e,t)>0}function lt(e,t){let r;for(let n of e)tr(n,t)&&(r=r&&Xs(r,n)?r:n);return r}function pp(e){let r=e.match(Js)?.groups;if(!r)return null;let{operator:n,prerelease:o,buildmetadata:s}=r,a=r.major?{major:Ie(r.major,Cannot parse comparator ${e}: invalid major version),minor:Ie(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:Ie(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:o?le(o):[],build:s?be(s):[]}:rr;return{operator:n||void 0,...a}}function z(e){return!e||e.toLowerCase()==="x"||e==="*"}function up(e){if(!z(e.major))return z(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:z(e.patch)?{operator:">=",major:+e.major,minor:+e.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?le(e.prerelease):[],build:[]}}function fp(e){if(!z(e.major))return z(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:z(e.patch)?{operator:"<",major:+e.major,minor:+e.minor+1,patch:0,prerelease:[],build:[]}:e.prerelease?{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:le(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?le(e.prerelease):[],build:[]}}function mp(e){let t=e.match(new RegExp(^${Zt})),r=t?.groups;if(!r)return;let n=t[0].length,o=e.slice(n).match(/^\s+-\s+/);if(!o)return;let s=o[0].length,i=e.slice(n+s).match(new RegExp(^${Zt}\\s*$))?.groups;if(!i)return;let c=up(r),l=fp(i);return[c,l].filter(Boolean)}function dp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[tt];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return o===0?[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];let i=le(e.prerelease??"");return o===0?s===0?[{operator:">=",major:o,minor:s,patch:a,prerelease:i},{operator:"<",major:o,minor:s,patch:a+1}]:[{operator:">=",major:o,minor:s,patch:a,prerelease:i},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:a,prerelease:i},{operator:"<",major:o+1,minor:0,patch:0}]}function gp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[tt];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let i=le(e.prerelease??"");return[{operator:">=",major:o,minor:s,patch:a,prerelease:i},{operator:"<",major:o,minor:s+1,patch:0}]}function hp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:o,minor:0,patch:0}]:[{operator:"<",major:o,minor:s,patch:0}];if(n)return[{operator:"<",major:o,minor:s,patch:0}];let i=le(e.prerelease??""),c=be(e.build??"");return[{operator:"<",major:o,minor:s,patch:a,prerelease:i,build:c}]}function xp(e){let t=z(e.minor),r=z(e.patch),n=+e.major,o=+e.minor,s=+e.patch;if(t)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:o+1,patch:0}];if(r)return[{operator:"<",major:n,minor:o+1,patch:0}];let a=le(e.prerelease??""),i=be(e.build??"");return[{operator:"<=",major:n,minor:o,patch:s,prerelease:a,build:i}]}function yp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s+1,patch:0}];let i=le(e.prerelease??""),c=be(e.build??"");return[{operator:">",major:o,minor:s,patch:a,prerelease:i,build:c}]}function bp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[tt];if(r)return n?[{operator:">=",major:o,minor:0,patch:0}]:[{operator:">=",major:o,minor:s,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0}];let i=le(e.prerelease??""),c=be(e.build??"");return[{operator:">=",major:o,minor:s,patch:a,prerelease:i,build:c}]}function wp(e){let t=z(e.major),r=z(e.minor),n=z(e.patch),o=+e.major,s=+e.minor,a=+e.patch;if(t)return[tt];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let i=le(e.prerelease??""),c=be(e.build??"");return[{operator:void 0,major:o,minor:s,patch:a,prerelease:i,build:c}]}function Ep(e){let t=e.match(Vs)?.groups;if(!t)return pp(e);switch(t.operator){case"^":return dp(t);case"~":case"~>":return gp(t);case"<":return hp(t);case"<=":return xp(t);case">":return yp(t);case">=":return bp(t);case"=":case"":return wp(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function Rp(e){return e.split(/\s+/).flatMap(Ep)}function Ys(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>mp(r)||Rp(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Hr(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>Dr)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${Dr});e=e.trim();let t=e.match(Ks)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=Ie(t.major,Cannot parse version ${e}: invalid major version),n=Ie(t.minor,Cannot parse version ${e}: invalid minor version),o=Ie(t.patch,Cannot parse version ${e}: invalid patch version),s=t.prerelease?le(t.prerelease):[],a=t.buildmetadata?be(t.buildmetadata):[];return{major:r,minor:n,patch:o,prerelease:s,build:a}}function Br(e){try{return Ys(e)}catch{return}}function Wr(e){try{return Hr(e)}catch{return}}var pt={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var $e=async e=>{try{let t=await fetch(e);return t.ok?oe([t,!1]):J({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return J({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return J({name:"AbortError",message:t.message,request:e});throw t}};var Gr="https://jsr.io",Qs=async(e,t)=>{let r=await(t?.fetch??$e)(new Request(${t?.endpoint??Gr}/${e}/meta.json),t?.cacheFirst);return Ze(r,([n])=>n.json())};var Zs=async(e,t,r)=>{let n=await(r?.fetch??$e)(new Request(${r?.endpoint??Gr}/${e}/${t}_meta.json),r?.cacheFirst);return Ze(n,([o])=>o.json())};var ei=async(e,t)=>{let r=await(t?.fetch??$e)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return Ze(r,([n])=>n.json())};var ni=(e,t)=>({name:"InvalidPackageVersionError",message:No version of ${e.name} satisfies "${e.tag??"*"}" (available: ${t.slice(0,10).join(", ")}${t.length>10?, ... (${t.length-10} more versions):""}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableVersions:t}),nr=(e,t)=>({name:"InvalidEntryPointError",message:${e.entryPoint} is not a valid entry point for ${e.name}@${e.tag??"*"} (available: ${t.join(", ")}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableEntryPoints:t}),oi=async(e,t)=>{if(t?.resolvedVersions){let c=new Map(t.resolvedVersions.get(e.name)??[]),l=lt([...c.keys()],e.range);if(l){let u=c.get(l)??ut,f=u[e.entryPoint];return typeof f!="string"&&console.log(f),f?oe(ti(e.name,Ke(l),f)):J(nr(e,Object.keys(u)))}}let r=await ei(e.name,t);if(ae(r))return r;let n=ce(r),o=new Map(Object.entries(n.versions).flatMap(([c,{exports:l}])=>{let u=Wr(c);return u?[[u,l??ut]]:[]})),s=lt([...o.keys()],e.range);if(!s)return J(ni(e,Object.keys(n.versions)));let a={...ut};for(let c of Object.keys(o.get(s)??ut))a[c]=c;let i=a[e.entryPoint];return i?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[s,a]]),oe(ti(e.name,Ke(s),i))):J(nr(e,Object.keys(a)))},ti=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),si=async(e,t)=>{if(t?.resolvedVersions){let i=new Map(t.resolvedVersions.get(e.name)??[]),c=lt([...i.keys()],e.range);if(c){let l=i.get(c)??ut,u=l[e.entryPoint];return u?oe(ri(e.name,Ke(c),u)):J(nr(e,Object.keys(l)))}}let r=await vp(e,t);if(ae(r))return r;let n=ce(r),o=await Zs(e.name,Ke(n),t);if(ae(o))return o;let s=ce(o).exports,a=s[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[n,s]]),oe(ri(e.name,Ke(n),a))):J(nr(e,Object.keys(ce(o).exports)))},ri=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),vp=async(e,t)=>{let r=await Qs(e.name,t);if(ae(r))return r;let n=ce(r),o=Object.keys(n.versions).flatMap(a=>{let i=Wr(a);return i?[i]:[]}),s=lt(o,e.range);return s?oe(s):J(ni(e,Object.keys(n.versions)))},ut={".":"./"};var Tp=e=>({name:"OnlyScopeProvidedError",specifier:e}),ii=e=>({name:"PackageNotFoundError",specifier:e}),ai=e=>{if(e.protocol!=="npm:")return J({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,n,o;if(t[r]==="@"){let f=t.indexOf("/",r);if(f===-1)return J(Tp(e));n=t.indexOf("/",f+1),o=t.indexOf("@",f+1)}else n=t.indexOf("/",r),o=t.indexOf("@",r);if(n===-1&&(n=t.length),o===-1&&(o=t.length),o=Math.min(o,n),r===o)return J(ii(e));let s=t.slice(r,o),a=decodeURIComponent(t.slice(o+1,n)),i=a?Br(a)??[[pt]]:[[pt]],c=t.slice(n+1),l=c?./${c}:".",u={name:s,range:i,entryPoint:l};return a&&(u.tag=a),oe(u)},ci=e=>{if(e.protocol!=="jsr:")return J({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return J({name:"ScopeNotFoundError",specifier:e});let n=t.indexOf("/",r);if(n===-1)return J(ii(e));let o=t.indexOf("/",n+1),s=t.indexOf("@",n+1);o===-1&&(o=t.length),s===-1&&(s=t.length),s=Math.min(s,o);let a=t.slice(r,s),i=decodeURIComponent(t.slice(s+1,o)),c=i?Br(i)??[[pt]]:[[pt]],l=t.slice(o+1),u=l?./${l}:".",f={name:a,range:c,entryPoint:u};return i&&(f.tag=i),oe(f)};var li=e=>new Promise((t,r)=>{let n=new FileReader;n.addEventListener("load",()=>{let o=n.result,s=o.indexOf(";");o.startsWith("; charset=utf-8",s)?t(${o.slice(0,s)}${o.slice(s+15)}):t(o)}),n.addEventListener("error",()=>r(n.error)),n.readAsDataURL(e)});var fi=e=>{let t=new Map,r=async n=>{let o=n.namespace==="npm",s=(o?ai:ci)($r(n));if(ae(s)){let i=We(s);return{errors:[{text:i.name,detail:i}]}}let a=await(o?oi:si)(ce(s),{resolvedVersions:t,...e});if(ae(a)){let i=We(a);return{errors:[{text:${i.name} ${i.message},detail:i}]}}return $s(ce(a))};return{name:"remote-loader",setup({onLoad:n,onResolve:o,initialOptions:s}){for(let a of[...pi,...ui])o({filter:/.*/,namespace:a.slice(0,-1)},Lp);o({filter:/.*/,namespace:"npm"},r),o({filter:/.*/,namespace:"jsr"},r);for(let a of pi)n({filter:/.*/,namespace:a.slice(0,-1)},i=>kp($r(i),{...e,sourcemap:s.sourcemap!==!1&&s.sourcemap!==void 0}));for(let a of ui)n({filter:/.*/,namespace:a.slice(0,-1)},()=>{throw new Error(${a} import is not supported yet.)})}}},Lp=e=>({path:e.path,namespace:e.namespace}),pi=["http:","https:","data:"],ui=["node:"],kp=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(l=>l.test(e)):!0,n=t.fetch??$e,o=await n(new Request(e),r);if(ae(o))return{errors:[{text:${We(o).message} Failed to fetch ${e},detail:We(o)}]};let[s,a]=ce(o),i=Ds(s);t.onProgress?.({path:e,done:s.clone().blob().then(l=>({size:l.size,loader:i,isCache:a}))});let c=await s.blob();if(t.sourcemap&&js(i)){let l=await c.text(),u=Us(l,e);if(Ar(u)){let{url:f,start:v,end:C}=ce(u);if(f.protocol!=="data:"){let D=await n(new Request(f),r);if(ae(D))return{contents:l,loader:i,warnings:[{text:${We(D).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${f}},{text:Original URL: ${e}}],detail:We(D)}]};let G=await ce(D)[0].blob().then(li);return{contents:l.slice(0,v)+G+l.slice(C),loader:i}}}}return{contents:new Uint8Array(await c.arrayBuffer()),loader:i}};var dt=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,n,o,s){this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=o,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Pp=/[$_\p{ID_Start}]/u,Cp=/[$_\u200C\u200D\p{ID_Continue}]/u,Kr=".*";function Np(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function gi(e,t=!1){let r=[],n=0;for(;n<e.length;){let o=e[n],s=function(a){if(!t)throw new TypeError(a);r.push({type:"INVALID_CHAR",index:n,value:e[n++]})};if(o==="*"){r.push({type:"ASTERISK",index:n,value:e[n++]});continue}if(o==="+"||o==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:e[n++]});continue}if(o==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});continue}if(o==="{"){r.push({type:"OPEN",index:n,value:e[n++]});continue}if(o==="}"){r.push({type:"CLOSE",index:n,value:e[n++]});continue}if(o===":"){let a="",i=n+1;for(;i<e.length;){let c=e.substr(i,1);if(i===n+1&&Pp.test(c)||i!==n+1&&Cp.test(c)){a+=e[i++];continue}break}if(!a){s(Missing parameter name at ${n});continue}r.push({type:"NAME",index:n,value:a}),n=i;continue}if(o==="("){let a=1,i="",c=n+1,l=!1;if(e[c]==="?"){s(Pattern cannot start with "?" at ${c});continue}for(;c<e.length;){if(!Np(e[c],!1)){s(Invalid character '${ec}' at ${c}.),l=!0;break}if(e[c]==="\\"){i+=e[c++]+e[c++];continue}if(e[c]===")"){if(a--,a===0){c++;break}}else if(e[c]==="("&&(a++,e[c+1]!=="?")){s(Capturing groups are not allowed at ${c}),l=!0;break}i+=e[c++]}if(l)continue;if(a){s(Unbalanced pattern at ${n});continue}if(!i){s(Missing pattern at ${n});continue}r.push({type:"REGEX",index:n,value:i}),n=c;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function hi(e,t={}){let r=gi(e);t.delimiter??="/#?",t.prefixes??="./";let n=^${de(t.delimiter)}+?,o=[],s=0,a=0,i="",c=new Set,l=y=>{if(a<r.length&&r[a].type===y)return r[a++].value},u=()=>l("OTHER_MODIFIER")??l("ASTERISK"),f=y=>{let h=l(y);if(h!==void 0)return h;let{type:d,index:m}=r[a];throw new TypeError(Unexpected ${d} at ${m}, expected ${y})},v=()=>{let y="",h;for(;h=l("CHAR")??l("ESCAPED_CHAR");)y+=h;return y},C=y=>y,D=t.encodePart||C,G="",S=y=>{G+=y},W=()=>{G.length&&(o.push(new dt(3,"","",D(G),"",3)),G="")},q=(y,h,d,m,E)=>{let w=3;switch(E){case"?":w=1;break;case"*":w=0;break;case"+":w=2;break}if(!h&&!d&&w===3){S(y);return}if(W(),!h&&!d){if(!y)return;o.push(new dt(3,"","",D(y),"",w));return}let T;d?d==="*"?T=Kr:T=d:T=n;let k=2;T===n?(k=1,T=""):T===Kr&&(k=0,T="");let g;if(h?g=h:d&&(g=s++),c.has(g))throw new TypeError(Duplicate name '${g}'.);c.add(g),o.push(new dt(k,g,D(y),T,D(m),w))};for(;a<r.length;){let y=l("CHAR"),h=l("NAME"),d=l("REGEX");if(!h&&!d&&(d=l("ASTERISK")),h||d){let E=y??"";t.prefixes.indexOf(E)===-1&&(S(E),E=""),W();let w=u();q(E,h,d,"",w);continue}let m=y??l("ESCAPED_CHAR");if(m){S(m);continue}if(l("OPEN")){let E=v(),w=l("NAME"),T=l("REGEX");!w&&!T&&(T=l("ASTERISK"));let k=v();f("CLOSE");let g=u();q(E,w,T,k,g);continue}W(),f("END")}return o}function de(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function mi(e){return e&&e.ignoreCase?"ui":"u"}function Sp(e,t,r){return xi(hi(e,r),t,r)}function rt(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function xi(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let i of e){if(i.type===3){i.modifier===3?n+=de(i.value):n+=(?:${de(i.value)})${rt(i.modifier)};continue}t&&t.push(i.name);let c=^${de(r.delimiter)}+?,l=i.value;if(i.type===1?l=c:i.type===0&&(l=Kr),!i.prefix.length&&!i.suffix.length){i.modifier===3||i.modifier===1?n+=(${l})${rt(i.modifier)}:n+=((?:${l})${rt(i.modifier)});continue}if(i.modifier===3||i.modifier===1){n+=(?:${de(i.prefix)}(${l})${de(i.suffix)}),n+=rt(i.modifier);continue}n+=(?:${de(i.prefix)},n+=((?:${l})(?:,n+=de(i.suffix),n+=de(i.prefix),n+=(?:${l}))*)${de(i.suffix)}),i.modifier===0&&(n+="?")}let o=${de(r.endsWith)}|$,s=${de(r.delimiter)};if(r.end)return r.strict||(n+=${s}?),r.endsWith.length?n+=(?=${o}):n+="$",new RegExp(n,mi(r));r.strict||(n+=(?:${s}(?=${o}))?);let a=!1;if(e.length){let i=e[e.length-1];i.type===3&&i.modifier===3&&(a=r.delimiter.indexOf(i)>-1)}return a||(n+=(?=${s}|${o})),new RegExp(n,mi(r))}var _e={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Op={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Ap={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Mp(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function yi(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function Ip(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function bi(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var wi=["ftp","file","http","https","ws","wss"];function Ei(e){if(!e)return!0;for(let t of wi)if(e.test(t))return!0;return!1}function $p(e,t){if(e=yi(e,"#"),t||e==="")return e;let r=new URL("https://example.com");return r.hash=e,r.hash?r.hash.substring(1,r.hash.length):""}function Up(e,t){if(e=yi(e,"?"),t||e==="")return e;let r=new URL("https://example.com");return r.search=e,r.search?r.search.substring(1,r.search.length):""}function _p(e,t){return t||e===""?e:bi(e)?Ti(e):vi(e)}function jp(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function Dp(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function Fp(e,t,r){if(r||e==="")return e;if(t&&!wi.includes(t))return new URL(${t}:${e}).pathname;let n=e[0]=="/";return e=new URL(n?e:"/-"+e,"https://example.com").pathname,n||(e=e.substring(2,e.length)),e}function Hp(e,t,r){return Ri(t)===e&&(e=""),r||e===""?e:Li(e)}function Bp(e,t){return e=Ip(e,":"),t||e===""?e:zr(e)}function Ri(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function zr(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function Wp(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function Gp(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function vi(e){if(e==="")return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw new TypeError(Invalid hostname '${e}');let t=new URL("https://example.com");return t.hostname=e,t.hostname}function Ti(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function Li(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function qp(e){if(e==="")return e;let t=new URL("https://example.com");return t.pathname=e[0]!=="/"?"/-"+e:e,e[0]!=="/"?t.pathname.substring(2,t.pathname.length):t.pathname}function Kp(e){return e===""?e:new URL(data:${e}).pathname}function zp(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function Vp(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var Jp=class{#s;#r=[];#t={};#e=0;#o=1;#a=0;#n=0;#l=0;#p=0;#f=!1;constructor(e){this.#s=e}get result(){return this.#t}parse(){for(this.#r=gi(this.#s,!0);this.#e<this.#r.length;this.#e+=this.#o){if(this.#o=1,this.#r[this.#e].type==="END"){if(this.#n===0){this.#h(),this.#m()?this.#i(9,1):this.#d()?this.#i(8,1):this.#i(7,0);continue}else if(this.#n===2){this.#x(5);continue}this.#i(10,0);break}if(this.#l>0)if(this.#k())this.#l-=1;else continue;if(this.#L()){this.#l+=1;continue}switch(this.#n){case 0:this.#E()&&this.#x(1);break;case 1:if(this.#E()){this.#N();let e=7,t=1;this.#R()?(e=2,t=3):this.#f&&(e=2),this.#i(e,t)}break;case 2:this.#b()?this.#x(3):(this.#w()||this.#d()||this.#m())&&this.#x(5);break;case 3:this.#v()?this.#i(4,1):this.#b()&&this.#i(5,1);break;case 4:this.#b()&&this.#i(5,1);break;case 5:this.#P()?this.#p+=1:this.#C()&&(this.#p-=1),this.#T()&&!this.#p?this.#i(6,1):this.#w()?this.#i(7,0):this.#d()?this.#i(8,1):this.#m()&&this.#i(9,1);break;case 6:this.#w()?this.#i(7,0):this.#d()?this.#i(8,1):this.#m()&&this.#i(9,1);break;case 7:this.#d()?this.#i(8,1):this.#m()&&this.#i(9,1);break;case 8:this.#m()&&this.#i(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#i(e,t){switch(this.#n){case 0:break;case 1:this.#t.protocol=this.#u();break;case 2:break;case 3:this.#t.username=this.#u();break;case 4:this.#t.password=this.#u();break;case 5:this.#t.hostname=this.#u();break;case 6:this.#t.port=this.#u();break;case 7:this.#t.pathname=this.#u();break;case 8:this.#t.search=this.#u();break;case 9:this.#t.hash=this.#u();break;case 10:break}this.#n!==0&&e!==10&&([1,2,3,4].includes(this.#n)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#n)&&[8,9].includes(e)&&(this.#t.pathname??=this.#f?"/":""),[1,2,3,4,5,6,7].includes(this.#n)&&e===9&&(this.#t.search??="")),this.#g(e,t)}#g(e,t){this.#n=e,this.#a=this.#e+t,this.#e+=t,this.#o=0}#h(){this.#e=this.#a,this.#o=0}#x(e){this.#h(),this.#n=e}#y(e){return e<0&&(e=this.#r.length-e),e<this.#r.length?this.#r[e]:this.#r[this.#r.length-1]}#c(e,t){let r=this.#y(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#E(){return this.#c(this.#e,":")}#R(){return this.#c(this.#e+1,"/")&&this.#c(this.#e+2,"/")}#b(){return this.#c(this.#e,"@")}#v(){return this.#c(this.#e,":")}#T(){return this.#c(this.#e,":")}#w(){return this.#c(this.#e,"/")}#d(){if(this.#c(this.#e,"?"))return!0;if(this.#r[this.#e].value!=="?")return!1;let e=this.#y(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#m(){return this.#c(this.#e,"#")}#L(){return this.#r[this.#e].type=="OPEN"}#k(){return this.#r[this.#e].type=="CLOSE"}#P(){return this.#c(this.#e,"[")}#C(){return this.#c(this.#e,"]")}#u(){let e=this.#r[this.#e],t=this.#y(this.#a).index;return this.#s.substring(t,e.index)}#N(){let e={};Object.assign(e,_e),e.encodePart=zr;let t=Sp(this.#u(),void 0,e);this.#f=Ei(t)}},qr=["protocol","username","password","hostname","port","pathname","search","hash"],Ue="*";function di(e,t){if(typeof e!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(e,t);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function Ne(e,t){return t?mt(e):e}function ft(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=Ne(n.protocol.substring(0,n.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=Ne(n.username,r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=Ne(n.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=Ne(n.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=Ne(n.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=Ne(n.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=Ne(n.search.substring(1,n.search.length),r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=Ne(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=Bp(t.protocol,r)),typeof t.username=="string"&&(e.username=Dp(t.username,r)),typeof t.password=="string"&&(e.password=jp(t.password,r)),typeof t.hostname=="string"&&(e.hostname=_p(t.hostname,r)),typeof t.port=="string"&&(e.port=Hp(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!Mp(e.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(e.pathname=Ne(n.pathname.substring(0,o+1),r)+e.pathname)}e.pathname=Fp(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=Up(t.search,r)),typeof t.hash=="string"&&(e.hash=$p(t.hash,r)),e}function mt(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function Xp(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function Yp(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",n=^${Xp(t.delimiter)}+?,o=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let a=0;a<e.length;++a){let i=e[a];if(i.type===3){if(i.modifier===3){s+=mt(i.value);continue}s+={${mt(i.value)}}${rt(i.modifier)};continue}let c=i.hasCustomName(),l=!!i.suffix.length||!!i.prefix.length&&(i.prefix.length!==1||!t.prefixes.includes(i.prefix)),u=a>0?e[a-1]:null,f=a<e.length-1?e[a+1]:null;if(!l&&c&&i.type===1&&i.modifier===3&&f&&!f.prefix.length&&!f.suffix.length)if(f.type===3){let v=f.value.length>0?f.value[0]:"";l=o.test(v)}else l=!f.hasCustomName();if(!l&&!i.prefix.length&&u&&u.type===3){let v=u.value[u.value.length-1];l=t.prefixes.includes(v)}l&&(s+="{"),s+=mt(i.prefix),c&&(s+=:${i.name}),i.type===2?s+=(${i.value}):i.type===1?c||(s+=(${n})):i.type===0&&(!c&&(!u||u.type===3||u.modifier!==3||l||i.prefix!=="")?s+="*":s+=(${r})),i.type===1&&c&&i.suffix.length&&o.test(i.suffix[0])&&(s+="\\"),s+=mt(i.suffix),l&&(s+="}"),i.modifier!==3&&(s+=rt(i.modifier))}return s}var ki=class{#s;#r={};#t={};#e={};#o={};#a=!1;constructor(e={},t,r){try{let n;if(typeof t=="string"?n=t:r=t,typeof e=="string"){let i=new Jp(e);if(i.parse(),e=i.result,n===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=n}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let o={ignoreCase:r.ignoreCase===!0},s={pathname:Ue,protocol:Ue,username:Ue,password:Ue,hostname:Ue,port:Ue,search:Ue,hash:Ue};this.#s=ft(s,e,!0),Ri(this.#s.protocol)===this.#s.port&&(this.#s.port="");let a;for(a of qr){if(!(a in this.#s))continue;let i={},c=this.#s[a];switch(this.#t[a]=[],a){case"protocol":Object.assign(i,_e),i.encodePart=zr;break;case"username":Object.assign(i,_e),i.encodePart=Wp;break;case"password":Object.assign(i,_e),i.encodePart=Gp;break;case"hostname":Object.assign(i,Op),bi(c)?i.encodePart=Ti:i.encodePart=vi;break;case"port":Object.assign(i,_e),i.encodePart=Li;break;case"pathname":Ei(this.#r.protocol)?(Object.assign(i,Ap,o),i.encodePart=qp):(Object.assign(i,_e,o),i.encodePart=Kp);break;case"search":Object.assign(i,_e,o),i.encodePart=zp;break;case"hash":Object.assign(i,_e,o),i.encodePart=Vp;break}try{this.#o[a]=hi(c,i),this.#r[a]=xi(this.#o[a],this.#t[a],i),this.#e[a]=Yp(this.#o[a],i),this.#a=this.#a||this.#o[a].some(l=>l.type===2)}catch{throw new TypeError(invalid ${a} pattern '${this.#sa}'.)}}}catch(n){throw new TypeError(Failed to construct 'URLPattern': ${n.message})}}test(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return!1;try{typeof e=="object"?r=ft(r,e,!1):r=ft(r,di(e,t),!1)}catch{return!1}let n;for(n of qr)if(!this.#r[n].exec(r[n]))return!1;return!0}exec(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return;try{typeof e=="object"?r=ft(r,e,!1):r=ft(r,di(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let o;for(o of qr){let s=this.#r[o].exec(r[o]);if(!s)return null;let a={};for(let[i,c]of this.#t[o].entries())if(typeof c=="string"||typeof c=="number"){let l=s[i+1];a[c]=l}n[o]={input:r[o]??"",groups:a}}return n}static compareComponent(e,t,r){let n=(i,c)=>{for(let l of["type","modifier","prefix","value","suffix"]){if(i[l]<c[l])return-1;if(i[l]!==c[l])return 1}return 0},o=new dt(3,"","","","",3),s=new dt(0,"","","","",3),a=(i,c)=>{let l=0;for(;l<Math.min(i.length,c.length);++l){let u=n(i[l],c[l]);if(u)return u}return i.length===c.length?0:n(i[l]??o,c[l]??o)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?a(t.#o[e],[s]):!t.#e[e]&&r.#e[e]?a([s],r.#o[e]):a(t.#o[e],r.#o[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#a}};globalThis.URLPattern||(globalThis.URLPattern=ki);var Pi,Ci=async(e,t)=>(Pi??=$t({wasmModule:e,workerURL:t}),await Pi,async r=>{let{outputFiles:n}=await Mt({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[ms(),fi({fetch:Qp,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:n[0].text}}),Qp=async(e,t)=>{let r=bs(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let n=await Vr(e);if(n)return n}try{let n=await r(e);return n.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await xt(e,n),oe([n,!1])):await Vr(e)??J({name:"HTTPError",message:${n.status} ${n.statusText},response:n})}catch(n){let o=await Vr(e);if(o)return o;if(n instanceof TypeError)return J({name:"NetworkError",message:n.message,request:e});if(n instanceof DOMException)return J({name:"AbortError",message:n.message,request:e});throw n}},Vr=async e=>{if(e.url.startsWith("data:"))return;let t=await ht(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),oe([t,!0])};var Ni=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var Si=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},Oi=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},Ai=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},Mi=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var Ii=()=>{let e;return{show:(n,{x:o,y:s})=>{e=Zp(),e.append(eu(n)),e.style.visibility="hidden",document.body.append(e);let{height:a}=e.getBoundingClientRect();e.style.top=${s-a}px,e.style.left=${o}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(n=>setTimeout(n,150)),e?.remove?.()}}},Zp=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},eu=e=>{let t=document.createElement("pre");return t.classList.add("tooltip-inner"),t.style.textAlign="unset",t.style.maxWidth="70vw",t.style.margin="unset",t.innerText=e,t};var $i=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:n}=Ii();return{component:e,setStatus:async(s,a)=>{switch(e.textContent="",await n(),s){case"loading":e.append(Ai());break;case"pass":e.append(Si());break;case"fail":e.append(Oi());break;case"none":break}a!==void 0&&s!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await n();else{let{top:i,left:c}=e.getBoundingClientRect();r(a,{y:i+globalThis.scrollY,x:c})}t=!t}):e.style.pointerEvents="none"}}};var Ui=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(Mi()),t.addEventListener("click",e),t};var _i=e=>{let{component:t,setStatus:r}=$i(),n=document.createElement("div");return n.style.position="absolute",n.style.left="-2em",n.style.zIndex="1",n.style.display="flex",n.style.flexFlow="column",n.append(Ui(e),t),{menu:n,setStatus:r}};function ji(e){return new Promise(t=>setTimeout(t,e))}function Di(e,t){let{trailing:r=!1,interval:n=0}=t??{},o,s=!1,a=l=>{o?.resolve?.({executed:!1}),o=l},i=()=>{let{...l}=o;return o=void 0,l},c=async()=>{if(s||!o)return;s=!0,n>0&&await ji(n);let{parameters:l,resolve:u,reject:f}=i();try{let v=await e(...l);s=!1,u({result:v,executed:!0})}catch(v){s=!1,f(v)}finally{r?await c():(a(),await Promise.resolve())}};return(...l)=>new Promise((u,f)=>{a({parameters:l,resolve:u,reject:f}),c()})}var Fi,Hi=async(e,t)=>{let r=[],o=Di(async()=>{r.forEach(({menu:a,setStatus:i})=>{i("none"),a.remove()});let s=So(scrapbox.Project.name,scrapbox.Page.title??"",sr());for(let a of s){let i=a.lang.toLowerCase();if(Ni(i))for(let c of a.startIds){let l=document.getElementById(L${c}),{menu:u,setStatus:f}=_i(async()=>{await f("loading");try{Fi??=await Ci(e,t);let{contents:v}=await Fi(a.path);console.debug("execute:",v),await Function(return (async()=>{${v}})())(),await f("pass")}catch(v){console.error(v),await f("fail",${v}`)}});r.push({menu:u,setStatus:f}),l?.insertBefore?.(u,l?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await o(),scrapbox.addListener("lines:changed",o),()=>{scrapbox.removeListener("lines:changed",o),r.forEach(({menu:s,setStatus:a})=>{a("none"),s.remove()})}};var tu="https://scrapbox.io/files/6730bb5886d646fa1d630a2a.wasm",ru="https://scrapbox.io/api/code/yosider-scripts/esbuild-wasm-no-blob-min/worker.js";(async()=>{let e=new Request(tu),t=await ht(e)||await nu(e);await Hi(await WebAssembly.compileStreaming(t),ru)})();async function nu(e){let t=await fetch(e);return await xt(e,t),t} /** @license
* esbuild-wasm@v0.21.5
*
* MIT License
*
* Copyright (c) 2020 Evan Wallace
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
code:script-pc.js
var go=Object.defineProperty;var ho=(e,t)=>()=>(e&&(t=e(e=0)),t);var bo=(e,t)=>{for(var r in t)go(e,r,{get:tr,enumerable:!0})};var fo={};bo(fo,{execute:()=>Ea});async function Ea(e=[]){let t=[...new Set(...e)].filter(r=>r!==scrapbox.Project.name);scrapbox.PageMenu.addMenu({title:po,image:"https://gyazo.com/54226f0588bb63aa3ff505fad0af824a/raw",onClick:async()=>{let r=scrapbox.PageMenu(po);r.removeAllItems(),r.emitChange(),!(await Promise.all(t.map(o=>wa(o,r)))).some(o=>o)&&r.addItem({title:"No page found.",onClick:()=>{}})}})}async function wa(e,t){let r=await fetch(/api/pages/${e}/${scrapbox.Page.title});if(!r.ok)return!1;let{lines:n}=await r.json();return n.length<3&&!n1?.text?!1:(t.addItem({title:/${e}/${scrapbox.Page.title},onClick:()=>window.open(https://scrapbox.io/${e}/${scrapbox.Page.title})}),!0)}var po,mo=ho(()=>{po="OtherProjects"});var Ce=(e,t)=>Object.hasOwn(e,t),At={left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",bs:"Backspace",menu:"ContextMenu",apps:"ContextMenu",del:"Delete",return:"Enter",cr:"Enter",esc:"Escape",pgup:"PageUp",pgdn:"PageDown",lt:"<",less:"<",lesser:"<",gt:">",greater:">"},qt=e=>{let t=e.toLowerCase();return Ce(At,t)?Att:e},Ft={Backquote:["","~"],Digit1:["1","!"],Digit2:["2","@"],Digit3:["3","#"],Digit4:["4","$"],Digit5:["5","%"],Digit6:["6","^"],Digit7:["7","&"],Digit8:["8","*"],Digit9:["9","("],Digit0:["0",")"],Minus:["-","_"],Equal:["=","+"],Backslash:["\\","|"],BracketLeft:["[","{"],BracketRight:["]","}"],Semicolon:[";",":"],Quote:["'",'"'],Comma:[",","<"],Period:[".",">"],Slash:["/","?"]},xo=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return Ce(Ft,e)?Ft[e][t?1:0]:e},Ut={"<":"lt",">":"gt"},yo=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,ut=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=xo(e.code||"",t):(r=qt(r),r===" "&&(r="Space")),yo.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let n="";return e.altKey&&(n+="a-"),e.ctrlKey&&(n+="c-"),e.metaKey&&(n+="m-"),t&&(n+="s-"),Ce(Ut,r)&&(r=Ut[r]),n||r.length>1?<${n}${r}>:r},Kt={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},vo=e=>{if(e.length===1)return/\s/.test(e)?{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}}:{ok:!0,value:{key:e}};let t=e.match(/^<((?:[a-z]-)*)([a-z\d]+|[^<>\s])>$/i);if(!t)return{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}};let[,r,n]=t,o={key:qt(n)};for(let s of r.split("-").slice(0,-1)){let a=s.toLowerCase();if(!Ce(Kt,a))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let l=Kt[a];if(o[l]!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(o[l]=!0,o.key.length===1&&o.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:o}},zt=e=>{let t=vo(e);return t.ok?{ok:!0,value:ut(t.value)}:t},Gt=e=>e.match(/<[^<>\s]+>|[\s\S]|^$/g);var A=!1;var Wt=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{A!==!0&&(!A||!A.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{A!==!0&&(!A||!A.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{A!==!0&&(!A||!A.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(A!==!0&&(!A||!A.has(e))))return r(...n)}]}}));var Q=Wt("ScrapBindings:mod.ts"),Ne=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let n=new Map,o=[];for(let[s,a]of t instanceof Map?t.entries():typeof t=="string"?[[t,r]]:Object.entries(t)){let l=Xt(s);if(!l.ok){for(let u of l.value)Q.error(${s}: ${u.message});n.set(s,l.value);continue}let i=l.value;this.bindings.set(i,a),i.startsWith(this.currentSequence)&&this.filtered.add(i),o.push(i)}return Q.debug("Binded the following commands:",o),this.emitChange(),n}unbind(...t){for(let r of t){let n=Xt(r);if(!n.ok)continue;let o=n.value;this.bindings.delete(o),this.filtered.delete(o)}this.emitChange()}reset(){this.bindings.clear(),this.emitChange()}bindings=new Map;onSequenceUpdate;flushInterval;_sequence="";set currentSequence(t){let r=this._sequence!==t;this._sequence=t,r&&this.onSequenceUpdate?.(t)}get currentSequence(){return this._sequence}prevBestMatchCommand;filtered=new Set;timer;backToInitial=()=>{clearTimeout(this.timer),this.currentSequence="",this.prevBestMatchCommand=void 0,this.filtered=new Set(this.bindings.keys()),Q.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=ut(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,Q.debug("sequence",this.currentSequence);let n;for(let s of this.filtered){if(s.startsWith(this.currentSequence)||this.filtered.delete(s),this.currentSequence!==s)continue;let a=this.bindings.get(s);if(!a){this.filtered.delete(s);continue}n=()=>{Q.debug(run ${s});try{a(t)}catch(l){Q.error(l)}finally{this.backToInitial()}}}let o=this.filtered.size;if(Q.debug(${o} candidates: ${...this.filtered.keys().join(", ")}),o>0&&(this.prevBestMatchCommand=n),this.prevBestMatchCommand&&o<2){if(this.prevBestMatchCommand(),o===0){this.handleKeydown(t);return}return}if(o===0){this.backToInitial();return}t.preventDefault(),t.stopPropagation(),this.timer=setTimeout(this.prevBestMatchCommand??this.backToInitial,this.flushInterval)};emitChange=()=>{if(this.bindings.size===0){this.backToInitial(),this.target.removeEventListener("keydown",this.handleKeydown);return}this.target.addEventListener("keydown",this.handleKeydown)}},Eo={name:"InvalidSequenceError",message:"cannot parse the sequence"},Xt=e=>{let t=Gt(e);if(!t)return{ok:!1,value:[Eo]};let r="",n=[];for(let o of t){let s=zt(o);if(!s.ok){n.push(s.value);continue}r+=s.value}return n.length>0?{ok:!1,value:n}:{ok:!0,value:r}};var Yt=!1;scrapbox.addListener("lines:changed",()=>Yt=!1);scrapbox.addListener("layout:changed",()=>Yt=!1);var Vt=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Qt=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var O=()=>{let e=document.getElementById("text-input");if(e)return Qt(e,"textarea#text-input"),e};var Jt=()=>er(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Zt=()=>er(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),er=(e,t)=>{if(e)return Vt(e,t),e};var K=(e,t)=>{let{noModifiedKeys:r=!1,...n}=t??{},o={bubbles:!0,cancelable:!0,keyCode:To[e],...r?{}:{...n}},s=O();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",o)),s.dispatchEvent(new KeyboardEvent("keyup",o))},To={Backspace:8,Tab:9,Enter:13,Delete:46,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,a:65,A:65,b:66,B:66,c:67,C:67,d:68,D:68,e:69,E:69,f:70,F:70,g:71,G:71,h:72,H:72,i:73,I:73,j:74,J:74,k:75,K:75,l:76,L:76,m:77,M:77,n:78,N:78,o:79,O:79,p:80,P:80,q:81,Q:81,r:82,R:82,s:83,S:83,t:84,T:84,u:85,U:85,v:86,V:86,w:87,W:87,x:88,X:88,y:89,Y:89,z:90,Z:90,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,F1:113,F2:114,F3:115,F4:116,F5:117,F6:118,F7:119,F8:120,F9:121,F10:122,F11:123,F12:124,":":186,"*":186,";":187,"+":187,"-":189,"=":189,".":190,">":190,"/":191,"?":191,"@":192,"":192,"":219,"{":219,"\\":220,"|":220,"":221,"}":221,"^":222,"~":222,_:226};function dt(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,s)=>{let a=()=>{clearTimeout(i),s(r?.reason)},i=setTimeout(()=>{r?.removeEventListener("abort",a),o()},e);if(r?.addEventListener("abort",a,{once:!0}),n===!1)try{Deno.unrefTimer(i)}catch(u){if(!(u instanceof ReferenceError))throw u;console.error("persistent option is only available in Deno")}})}var ge=async e=>{let t=O();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await dt(1)};var rr=()=>{let e=Zt();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 n=nr(...r);n&&t.append(n)},dispose:()=>t.remove()}},nr=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnCo();case"check-circle":returnNo();case"exclamation-triangle":returnSo();case"text":returnSe(n.text);case"group":{let o=nr(...n.items);return o?o:[]}}});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},Se=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Co=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Se(e)},No=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Se(e)},So=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Se(e)};var pt=()=>{let e=O();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(s=>s.startsWith("__reactFiber"));if(!t)throw Error('#text-input must has the property whose name starts with "__reactFiber"');let r=et.return.return.stateNode._stores,n=r.find(s=>s.constructor.name==="Cursor");if(!n)throw Error('#text-input must has a "Cursor" store.');let o=r.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:n,selection:o}};var or=()=>pt().cursor;var he=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),sr=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var Ie=new Map,ft=new Map,Re=(e,t,r)=>{let n=Ie.get(e)??new Map,o=n.get(t)??new Set;if(o.has(he(r)))return;if(o.add(he(r)),n.set(t,o),Ie.set(e,n),typeof r=="object"&&r?.once){let a=ft.get(t)??new Map,l=he(r),i=function(c){return mt(e,t,r),a.delete(l),t.call(this,c)};a.set(l,i),ft.set(t,a);let u=O();if(!u)return;u.addEventListener(e,i,r)}let s=O();s&&s.addEventListener(e,t,r)};scrapbox.on("layout:changed",()=>{let e=O();if(e)for(lett,rof Ie)for(letn,oof r)for(let s of o)e.addEventListener(t,n,sr(s))});var mt=(e,t,r)=>{let n=Ie.get(e);if(!n)return;let o=n.get(t);if(!o)return;let s=he(r);if(o.delete(s),typeof r=="object"&&r?.once){let l=ft.get(t);if(!l)return;let i=l.get(s);if(!i)return;let u=O();if(!u)return;u.removeEventListener(e,i,r),l.delete(s);return}let a=O();a&&a.removeEventListener(e,t,r)};Re("keydown",async e=>{e.key!=="Enter"||e.metaKey||e.altKey||!e.ctrlKey||e.shiftKey||await gt()});async function gt(){if(scrapbox.Layout!=="page")return;let e=or(),t=e.getPosition().line,r=scrapbox.Page.linest;!("codeBlock"in r)||r.codeBlock.start||r.codeBlock.end||(K("End"),K("Enter"),e.setPosition({line:e.getPosition().line,char:r.codeBlock.indent-1}),K("End",{shiftKey:!0}),await ge(code:${r.codeBlock.filename??""}),K("Home"),K("Enter"),K("ArrowUp"))}var He=e=>e.preventDefault(),Oe=e=>e.stopPropagation(),Be=(e,t)=>{let r=Jt()?.getElementsByClassName?.("button");if(!r)return;let n=...r.find(o=>t instanceof RegExp?t.test(o.textContent??""):o.textContent===t);n instanceof HTMLDivElement&&e.target===document.activeElement&&(He(e),Oe(e),n.click())},ir={u:e=>Be(e,"URL"),う:e=>Be(e,"URL"),4:e=>Be(e,"$"),l:e=>Be(e,"link authors"),"<A-q>":e=>{He(e),Oe(e),ge("todo.icon")},"<A-w>":e=>{He(e),Oe(e),ge("done.icon")},"<C-Enter>":e=>{He(e),Oe(e),gt()}};var{render:Io}=rr(),ht,Ro=e=>{ht!==void 0&&cancelAnimationFrame(ht),ht=requestAnimationFrame(()=>Io({type:"text",text:e}))},cr=new Ne({addEventListener:Re,removeEventListener:mt},{onSequenceUpdate:Ro}),ar=cr.bind(ir);ar.size>0&&alert(...ar.entries().map((e,t)=>`${e}: ${t.map(r=>- ${r}).join(`
)}).join(`
));var Ue,h,fr,Bo,be,mr,lr,gr,je={},hr=[],Ho=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function G(e,t){for(var r in t)e[r]=t[r];return e}function br(e){var t=e.parentNode;t&&t.removeChild(e)}function d(e,t,r){var n,o,s,a={};for(s in t)s=="key"?n=t[s]:s=="ref"?o=t[s]:a[s]=t[s];if(arguments.length>2&&(a.children=arguments.length>3?Ue.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)a[s]===void 0&&(a[s]=e.defaultProps[s]);return De(e,a,n,o,null)}function De(e,t,r,n,o){var s={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:o??++fr};return o==null&&h.vnode!=null&&h.vnode(s),s}function L(e){return e.children}function $e(e,t){this.props=e,this.context=t}function re(e,t){if(t==null)return e.__?re(e.__,e.__.__k.indexOf(e)+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?re(e):null}function xr(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return xr(e)}}function bt(e){(!e.__d&&(e.__d=!0)&&be.push(e)&&!Ae.__r++||lr!==h.debounceRendering)&&((lr=h.debounceRendering)||mr)(Ae)}function Ae(){for(var e;Ae.__r=be.length;)e=be.sort(function(t,r){return t.__v.__b-r.__v.__b}),be=[],e.some(function(t){var r,n,o,s,a,l;t.__d&&(a=(s=(r=t).__v).__e,(l=r.__P)&&(n=[],(o=G({},s)).__v=s.__v+1,xt(l,s,o,r.__n,l.ownerSVGElement!==void 0,s.__h!=null?[a]:null,n,a??re(s),s.__h),wr(n,s),s.__e!=a&&xr(s)))})}function yr(e,t,r,n,o,s,a,l,i,u){var c,m,g,p,f,b,x,w=n&&n.__k||hr,I=w.length;for(r.__k=[],c=0;c<t.length;c++)if((p=r.__k[c]=(p=t[c])==null||typeof p=="boolean"?null:typeof p=="string"||typeof p=="number"||typeof p=="bigint"?De(null,p,null,null,p):Array.isArray(p)?De(L,{children:p},null,null,null):p.__b>0?De(p.type,p.props,p.key,null,p.__v):p)!=null){if(p.__=r,p.__b=r.__b+1,(g=w[c])===null||g&&p.key==g.key&&p.type===g.type)w[c]=void 0;else for(m=0;m<I;m++){if((g=w[m])&&p.key==g.key&&p.type===g.type){w[m]=void 0;break}g=null}xt(e,p,g=g||je,o,s,a,l,i,u),f=p.__e,(m=p.ref)&&g.ref!=m&&(x||(x=[]),g.ref&&x.push(g.ref,null,p),x.push(m,p.__c||f,p)),f!=null?(b==null&&(b=f),typeof p.type=="function"&&p.__k===g.__k?p.__d=i=vr(p,i,e):i=Er(e,p,g,w,f,i),typeof r.type=="function"&&(r.__d=i)):i&&g.__e==i&&i.parentNode!=e&&(i=re(g))}for(r.__e=b,c=I;c--;)w[c]!=null&&(typeof r.type=="function"&&w[c].__e!=null&&w[c].__e==r.__d&&(r.__d=re(n,c+1)),Lr(w[c],w[c]));if(x)for(c=0;c<x.length;c++)kr(x[c],x[++c],x[++c])}function vr(e,t,r){for(var n,o=e.__k,s=0;o&&s<o.length;s++)(n=o[s])&&(n.__=e,t=typeof n.type=="function"?vr(n,t,r):Er(r,n,n,o,n.__e,t));return t}function Er(e,t,r,n,o,s){var a,l,i;if(t.__d!==void 0)a=t.__d,t.__d=void 0;else if(r==null||o!=s||o.parentNode==null)e:if(s==null||s.parentNode!==e)e.appendChild(o),a=null;else{for(l=s,i=0;(l=l.nextSibling)&&i<n.length;i+=2)if(l==o)break e;e.insertBefore(o,s),a=s}return a!==void 0?a:o.nextSibling}function Oo(e,t,r,n,o){var s;for(s in r)s==="children"||s==="key"||s in t||Fe(e,s,null,r[s],n);for(s in t)o&&typeof t[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||r[s]===t[s]||Fe(e,s,t[s],r[s],n)}function ur(e,t,r){t[0]==="-"?e.setProperty(t,r):e[t]=r==null?"":typeof r!="number"||Ho.test(t)?r:r+"px"}function Fe(e,t,r,n,o){var s;e:if(t==="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||ur(e.style,t,"");if(r)for(t in r)n&&r[t]===n[t]||ur(e.style,t,r[t])}else if(t[0]==="o"&&t[1]==="n")s=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?n||e.addEventListener(t,s?pr:dr,s):e.removeEventListener(t,s?pr:dr,s);else if(t!=="dangerouslySetInnerHTML"){if(o)t=t.replace(/xlink[H:h]/,"h").replace(/sName$/,"s");else if(t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r!=null&&(r!==!1||t[0]==="a"&&t[1]==="r")?e.setAttribute(t,r):e.removeAttribute(t))}}function dr(e){this.l[e.type+!1](h.event?h.event(e):e)}function pr(e){this.l[e.type+!0](h.event?h.event(e):e)}function xt(e,t,r,n,o,s,a,l,i){var u,c,m,g,p,f,b,x,w,I,te,U=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(i=r.__h,l=t.__e=r.__e,t.__h=null,s=[l]),(u=h.__b)&&u(t);try{e:if(typeof U=="function"){if(x=t.props,w=(u=U.contextType)&&n[u.__c],I=u?w?w.props.value:u.__:n,r.__c?b=(c=t.__c=r.__c).__=c.__E:("prototype"in U&&U.prototype.render?t.__c=c=new U(x,I):(t.__c=c=new $e(x,I),c.constructor=U,c.render=$o),w&&w.sub(c),c.props=x,c.state||(c.state={}),c.context=I,c.__n=n,m=c.__d=!0,c.__h=[]),c.__s==null&&(c.__s=c.state),U.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=G({},c.__s)),G(c.__s,U.getDerivedStateFromProps(x,c.__s))),g=c.props,p=c.state,m)U.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(U.getDerivedStateFromProps==null&&x!==g&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(x,I),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(x,c.__s,I)===!1||t.__v===r.__v){c.props=x,c.state=c.__s,t.__v!==r.__v&&(c.__d=!1),c.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(Pe){Pe&&(Pe.__=t)}),c.__h.length&&a.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(x,c.__s,I),c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(g,p,f)})}c.context=I,c.props=x,c.state=c.__s,(u=h.__r)&&u(t),c.__d=!1,c.__v=t,c.__P=e,u=c.render(c.props,c.state,c.context),c.state=c.__s,c.getChildContext!=null&&(n=G(G({},n),c.getChildContext())),m||c.getSnapshotBeforeUpdate==null||(f=c.getSnapshotBeforeUpdate(g,p)),te=u!=null&&u.type===L&&u.key==null?u.props.children:u,yr(e,Array.isArray(te)?te:[te],t,r,n,o,s,a,l,i),c.base=t.__e,t.__h=null,c.__h.length&&a.push(c),b&&(c.__E=c.__=null),c.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=Do(r.__e,t,r,n,o,s,a,i);(u=h.diffed)&&u(t)}catch(Pe){t.__v=null,(i||s!=null)&&(t.__e=l,t.__h=!!i,s[s.indexOf(l)]=null),h.__e(Pe,t,r)}}function wr(e,t){h.__c&&h.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(n){n.call(r)})}catch(n){h.__e(n,r.__v)}})}function Do(e,t,r,n,o,s,a,l){var i,u,c,m=r.props,g=t.props,p=t.type,f=0;if(p==="svg"&&(o=!0),s!=null){for(;f<s.length;f++)if((i=s[f])&&"setAttribute"in i==!!p&&(p?i.localName===p:i.nodeType===3)){e=i,s[f]=null;break}}if(e==null){if(p===null)return document.createTextNode(g);e=o?document.createElementNS("http://www.w3.org/2000/svg",p):document.createElement(p,g.is&&g),s=null,l=!1}if(p===null)m===g||l&&e.data===g||(e.data=g);else{if(s=s&&Ue.call(e.childNodes),u=(m=r.props||je).dangerouslySetInnerHTML,c=g.dangerouslySetInnerHTML,!l){if(s!=null)for(m={},f=0;f<e.attributes.length;f++)m[e.attributes[f].name]=e.attributes[f].value;(c||u)&&(c&&(u&&c.__html==u.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}if(Oo(e,g,m,o,l),c)t.__k=[];else if(f=t.props.children,yr(e,Array.isArray(f)?f:[f],t,r,n,o&&p!=="foreignObject",s,a,s?s[0]:r.__k&&re(r,0),l),s!=null)for(f=s.length;f--;)s[f]!=null&&br(s[f]);l||("value"in g&&(f=g.value)!==void 0&&(f!==m.value||f!==e.value||p==="progress"&&!f)&&Fe(e,"value",f,m.value,!1),"checked"in g&&(f=g.checked)!==void 0&&f!==e.checked&&Fe(e,"checked",f,m.checked,!1))}return e}function kr(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(n){h.__e(n,r)}}function Lr(e,t,r){var n,o;if(h.unmount&&h.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||kr(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){h.__e(s,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&Lr(n[o],t,typeof e.type!="function");r||e.__e==null||br(e.__e),e.__e=e.__d=void 0}function $o(e,t,r){return this.constructor(e,r)}function Ke(e,t,r){var n,o,s;h.__&&h.__(e,t),o=(n=typeof r=="function")?null:r&&r.__k||t.__k,s=[],xt(t,e=(!n&&r||t).__k=d(L,null,[e]),o||je,je,t.ownerSVGElement!==void 0,!n&&r?[r]:o?null:t.firstChild?Ue.call(t.childNodes):null,s,!n&&r?r:o?o.__e:t.firstChild,n),wr(s,e)}function yt(e,t){var r={__c:t="__cC"+gr++,__:e,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,s;return this.getChildContext||(o=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&o.some(bt)},this.sub=function(a){o.push(a);var l=a.componentWillUnmount;a.componentWillUnmount=function(){o.splice(o.indexOf(a),1),l&&l.call(a)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}Ue=hr.slice,h={__e:function(e,t){for(var r,n,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&n.getDerivedStateFromError!=null&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e),o=r.__d),o)return r.__E=r}catch(s){e=s}throw e}},fr=0,Bo=function(e){return e!=null&&e.constructor===void 0},$e.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=G({},this.state),typeof e=="function"&&(e=e(G({},r),this.props)),e&&G(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),bt(this))},$e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),bt(this))},$e.prototype.render=L,be=[],mr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ae.__r=0,gr=0;var ne,R,_r,xe=0,vt=[],Tr=h.__b,Mr=h.__r,Pr=h.diffed,Cr=h.__c,Nr=h.unmount;function ye(e,t){h.__h&&h.__h(R,e,xe||t),xe=0;var r=R.__H||(R.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function M(e){return xe=1,jo(Ir,e)}function jo(e,t,r){var n=ye(ne++,2);return n.t=e,n.__c||(n.__=[r?r(t):Ir(void 0,t),function(o){var s=n.t(n.__[0],o);n.__[0]!==s&&(n.__=[s,n.__[1]],n.__c.setState({}))}],n.__c=R),n.__}function D(e,t){var r=ye(ne++,3);!h.__s&&wt(r.__H,t)&&(r.__=e,r.__H=t,R.__H.__h.push(r))}function ze(e,t){var r=ye(ne++,4);!h.__s&&wt(r.__H,t)&&(r.__=e,r.__H=t,R.__h.push(r))}function oe(e){return xe=5,E(function(){return{current:e}},[])}function E(e,t){var r=ye(ne++,7);return wt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function H(e,t){return xe=8,E(function(){return e},t)}function W(e){var t=R.context[e.__c],r=ye(ne++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(R)),t.props.value):e.__}function Ao(){var e;for(vt.sort(function(t,r){return t.__v.__b-r.__v.__b});e=vt.pop();)if(e.__P)try{e.__H.__h.forEach(qe),e.__H.__h.forEach(Et),e.__H.__h=[]}catch(t){e.__H.__h=[],h.__e(t,e.__v)}}h.__b=function(e){R=null,Tr&&Tr(e)},h.__r=function(e){Mr&&Mr(e),ne=0;var t=(R=e.__c).__H;t&&(t.__h.forEach(qe),t.__h.forEach(Et),t.__h=[])},h.diffed=function(e){Pr&&Pr(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(vt.push(t)!==1&&_r===h.requestAnimationFrame||((_r=h.requestAnimationFrame)||function(r){var n,o=function(){clearTimeout(s),Sr&&cancelAnimationFrame(n),setTimeout(r)},s=setTimeout(o,100);Sr&&(n=requestAnimationFrame(o))})(Ao)),R=null},h.__c=function(e,t){t.some(function(r){try{r.__h.forEach(qe),r.__h=r.__h.filter(function(n){return!n.__||Et(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],h.__e(n,r.__v)}}),Cr&&Cr(e,t)},h.unmount=function(e){Nr&&Nr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{qe(n)}catch(o){t=o}}),t&&h.__e(t,r.__v))};var Sr=typeof requestAnimationFrame=="function";function qe(e){var t=R,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),R=t}function Et(e){var t=R;e.__c=e.__(),R=t}function wt(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Ir(e,t){return typeof t=="function"?t(e):t}var k=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Uo=e=>typeof e=="object"&&e!==null,Ko=e=>Uo(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Rr=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Ko(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var ve=class e extends Error{constructor(r){super(${r.status} ${r.statusText} when fetching ${r.url});this.response=r;Error.captureStackTrace&&Error.captureStackTrace(this,e)}name="UnexpectedResponseError"},T=async e=>{let t=e.clone(),r=await t.text(),n=Rr(r);if(!n)throw new ve(t);return{ok:!1,value:n}};var _=e=>connect.sid=${e};var B=e=>e.replaceAll(" ","_").toLowerCase();var P=e=>[...e].map((t,r)=>t===" "?"_":!qo.includes(t)||r===e.length-1&&zo.includes(t)?encodeURIComponent(t):t).join(""),qo='@$&+=:;",',zo=':;",';var Br=(e,t,r)=>{let{sid:n,hostName:o,followRename:s,projects:a}=k(r??{}),l=new URLSearchParams;l.append("followRename",${s??!0});for(let u of a??[])l.append("projects",u);let i=https://${o}/api/pages/${e}/${P(t)}?${l.toString()};return new Request(i,n?{headers:{Cookie:_(n)}}:void 0)},Hr=async e=>e.ok?{ok:!0,value:await e.json()}:e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:T(e),se=async(e,t,r)=>{let{fetch:n}=k(r??{}),o=Br(e,t,r),s=await n(o);return await Hr(s)};se.toRequest=Br;se.fromResponse=Hr;var Or=(e,t)=>{let{sid:r,hostName:n,sort:o,limit:s,skip:a}=k(t??{}),l=new URLSearchParams;o!==void 0&&l.append("sort",o),s!==void 0&&l.append("limit",${s}),a!==void 0&&l.append("skip",${a});let i=https://${n}/api/pages/${e}?${l.toString()};return new Request(i,r?{headers:{Cookie:_(r)}}:void 0)},Dr=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),$r=async(e,t)=>{let{fetch:r}=k(t??{}),n=await r(Or(e,t));return await Dr(n)};$r.toRequest=Or;$r.fromResponse=Dr;var jr=(e,t,r,n)=>{let{sid:o,hostName:s}=k(n??{}),a=https://${s}/api/table/${e}/${P(t)}/${encodeURIComponent(r)}.csv;return new Request(a,o?{headers:{Cookie:_(o)}}:void 0)},Ar=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:T(e),Fr=async(e,t,r,n)=>{let{fetch:o}=k(n??{}),s=jr(e,t,r,n),a=await o(s);return await Ar(a)};Fr.toRequest=jr;Fr.fromResponse=Ar;var Ur=(e,t)=>{let{sid:r,hostName:n}=k(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:_(r)}}:void 0)},Kr=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),Ee=async(e,t)=>{let{fetch:r}=k(t??{}),n=Ur(e,t),o=await r(n);return Kr(o)};Ee.toRequest=Ur;Ee.fromResponse=Kr;var qr=(e,t)=>{let{sid:r,hostName:n}=k(t??{}),o=new URLSearchParams;for(let s of e)o.append("ids",s);return new Request(https://${n}/api/projects?${o.toString()},r?{headers:{Cookie:_(r)}}:void 0)},zr=async e=>e.ok?{ok:!0,value:await e.json()}:T(e),Ge=async(e,t)=>{let{fetch:r}=k(t??{}),n=await r(qr(e,t));return zr(n)};Ge.toRequest=qr;Ge.fromResponse=zr;var Gr=(e,t,r,n)=>{let{sid:o,hostName:s}=k(n??{}),a=https://${s}/api/code/${e}/${P(t)}/${P(r)};return new Request(a,o?{headers:{Cookie:_(o)}}:void 0)},Wr=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"}}:T(e),Xr=async(e,t,r,n)=>{let{fetch:o}=k(n??{}),s=Gr(e,t,r,n),a=await o(s);return await Wr(a)};Xr.toRequest=Gr;Xr.fromResponse=Wr;var op=new TextEncoder().encode("0123456789abcdef");var J=e=>new Promise(t=>setTimeout(()=>t(),e));var Xo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Yo=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,Vo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,Qo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Yr=e=>{if(Xo.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(Yo);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"dotbe"}}}{let t=e.match(Vo);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"short"}}}{let t=e.match(Qo);if(t){let[,r,n]=t;return{listId:n,params:new URLSearchParams(r),pathType:"list"}}}};var Jo=/https?:\/\/vimeo\.com\/([0-9]+)/i,Vr=e=>{let t=e.match(Jo);if(t)return t[1]};var Zo=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Qr=e=>{let t=e.match(Zo);if(!t)return;let[,r,n]=t;return{videoId:n,pathType:r}};var es=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Jr=e=>{let t=e.match(es);if(!t)return;let[,r]=t;return r};var Zr=e=>{let{type:t,pathType:r,content:n,href:o,...s}=e;if(n===""){let a=Yr(o);if(a)return{type:"youtube",href:o,...a,...s};let l=Vr(o);if(l)return{type:"vimeo",videoId:l,href:o,...s};let i=Qr(o);if(i)return{type:"spotify",href:o,...i,...s};let u=Jr(o);if(u)return{type:"anchor-fm",videoId:u,href:o,...s};if(rs(o))return{type:"video",href:o,...s}}return ts(o)?{type:"audio",content:n,href:o,...s}:{type:"absoluteLink",content:n,href:o,...s}},ts=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),rs=e=>/\.(?:mp4|webm)$/.test(e);var en=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,a])=>a-s).map(([s])=>s),n=await Ge([]);if(!n.ok)return r;let o=n.value.projects.map(s=>s.id);return r.filter(s=>!o.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var ns;(e=>{})(ns||={});var os="0.13.3",tn,rn=async(e=os)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(document.querySelector(scriptsrc="${t}"))return window.katex!==void 0?Promise.resolve(window.katex):await new Promise(n=>{let o=setInterval(()=>{window.katex!==void 0&&(clearInterval(o),n(window.katex))},500)});let r=document.createElement("script");return r.src=t,tn??=new Promise((n,o)=>{r.onload=()=>n(window.katex),r.onerror=s=>o(s),document.head.append(r)}),tn};var we=(e,t={})=>{let r=oe(null),[n,o]=M(e),[s,a]=M("");return D(()=>{(async()=>{let{render:l}=await rn();if(r.current)try{l(n,r.current,t),a("")}catch(i){if(i instanceof Error&&i.name==="ParseError")a(i.message.slice(19));else throw i}})()},[n]),{ref:r,error:s,setFormula:o}};var nn=!1;scrapbox.addListener("lines:changed",()=>nn=!1);scrapbox.addListener("layout:changed",()=>nn=!1);var on=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var ie=()=>{let e=document.getElementById("text-input");if(e)return on(e,"textarea#text-input"),e};var kt=e=>{let t=JSON.parse(localStorage.getItem("pageTransitionContext")??""),r=e.type==="page"?e.from.project===e.to.project?e.from.title===e.to.title?{titleHint:e.to.title}:{linkFrom:e.from.title}:{linkFrom:/${e.from.project}/${e.from.title}}:{searchQuery:e.query};t[page_${B(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var an=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(e,t);if(s)return s}};var cn=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var ps=new Map;scrapbox.on("layout:changed",()=>{let e=ie();if(e)for(let[t,r]of ps)for(let[n,o]of r)for(let s of o)e.addEventListener(t,n,cn(s))});var fs=e=>({type:"title",text:e.rows[0].text}),ms=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(n+1)).join( )}},C=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,s,a)=>{var l,i,u,c,m,g;if(!t&&s.nested)return(l=a?.())!==null&&l!==void 0?l:[];if(!r&&s.quoted)return(i=a?.())!==null&&i!==void 0?i:[];for(let p of n){let f=p.exec(o);if(f===null)continue;let b=o.substring(0,f.index),x=o.substring(f.index+((c=(u=f[0])===null||u===void 0?void 0:u.length)!==null&&c!==void 0?c:0)),w=e((m=f[0])!==null&&m!==void 0?m:"",s);return[...X(b,s),...w,...X(x,s)]}return(g=a?.())!==null&&g!==void 0?g:[]},S=e=>[{type:"plain",raw:e,text:e}],gs=C(S,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),hs=/^>.*$/,bs=(e,t)=>t.context==="table"?S(e,t):[{type:"quote",raw:e,nodes:X(e.substring(1),{...t,quoted:!0})}],xs=C(bs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[hs]}),ys=/^\? .+$/,vs=(e,t)=>t.context==="table"?S(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],Es=C(vs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[ys]}),ws=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,ks=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Ls=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},_s=C(Ls,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ws,ks]}),Ts=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function un(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return S(t,r);let n=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),o=n.lastIndexOf(".icon"),s=n.substring(0,o),a=s.startsWith("/")?"root":"relative",l=n.substring(o+5,n.length),i=l.startsWith("*")?parseInt(l.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Ms=un("icon"),Ps=C(Ms,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Ts]}),Cs=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Ns=un("strongIcon"),Ss=C(Ns,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Cs]}),Is=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Rs=(e,t)=>t.context==="table"?S(e,t):[{type:"strong",raw:e,nodes:X(e.substring(2,e.length-2),{...t,nested:!0})}],Bs=C(Rs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Is]}),Hs=/\[\$ .+? \]/,Os=/\[\$ [^\]]+\]/,Ds=(e,t)=>t.context==="table"?S(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],$s=C(Ds,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Hs,Os]}),js=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,As=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),s=new Set(n);if(s.has("*")){let a=n.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(s),nodes:X(o,{...t,nested:!0})}]},Fs=C(As,{parseOnNested:!1,parseOnQuoted:!0,patterns:[js]}),Us=/.*?/,Ks=(e,t)=>t.context==="table"?S(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],qs=C(Ks,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Us]}),zs=/^[$%] .+$/,Gs=(e,t)=>{var r;if(t.context==="table")return S(e,t);let n=(r=e[0])!==null&&r!==void 0?r:"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:n,text:o}]},Ws=C(Gs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[zs]}),Xs=/\[\s+\]/,Ys=(e,t)=>t.context==="table"?S(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Vs=C(Ys,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Xs]}),Qs=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Js=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Zs=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,ei=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,ti=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||ri(e),ri=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),ni=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).trimLeft():"",[s,a]=ti(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},oi=C(ni,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Qs,Js,Zs,ei]}),si=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,ii=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,ai=/\[https?:\/\/[^\s\]]+\]/,ci=/https?:\/\/[^\s]+/,li=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let s=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},ui=C(li,{parseOnNested:!0,parseOnQuoted:!0,patterns:[si,ii,ai,ci]}),dn=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,pn=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,di=e=>{let[t="",r="",n=""]=e.split(","),o=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(n)?parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:a}},pi=(e,t)=>{var r;if(t.context==="table")return S(e,t);let n=(r=e.match(dn))!==null&&r!==void 0?r:e.match(pn);if(n===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=o?n:[n[0],n[2],n[1]],{latitude:l,longitude:i,zoom:u}=di(s),c=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${l},${i},${u}z:https://www.google.com/maps/@${l},${i},${u}z;return[{type:"googleMap",raw:e,latitude:l,longitude:i,zoom:u,place:a,url:c}]},fi=C(pi,{parseOnNested:!1,parseOnQuoted:!0,patterns:[dn,pn]}),mi=/\[\/?[^[\]]+\]/,gi=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},hi=C(gi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[mi]}),bi=/(?:^|\s)#\S+/,xi=(e,t)=>{if(t.context==="table")return S(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...S(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},yi=C(xi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[bi]}),vi=/^[0-9]+\. .*$/,Ei=(e,t)=>{if(t.context==="table")return S(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=parseInt(n,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:X(s,{...t,nested:!0})}]},wi=C(Ei,{parseOnNested:!1,parseOnQuoted:!1,patterns:[vi]}),ki=(e,t,r)=>{var n;return e===""?[]:(n=r?.())!==null&&n!==void 0?n:[]},Li=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>gs(t,r))(),X=Li(ki,xs,Es,qs,Ws,$s,Vs,Fs,_s,Ss,Bs,oi,ui,Ps,fi,hi,yi,wi),_i=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:s,cells:r.map(a=>a.text.substring(n+1)).map(a=>a.split(" ").map(l=>X(l,{nested:!1,quoted:!1,context:"table"})))}},Ti=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:X(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},Mi=e=>{switch(e.type){case"title":return fs(e);case"codeBlock":return ms(e);case"table":return _i(e);case"line":return Ti(e)}},Pi=e=>e.split( ).map(t=>{var r,n,o;return{indent:(o=(n=(r=/^\s+/.exec(t))===null||r===void 0?void 0:r[0])===null||n===void 0?void 0:n.length)!==null&&o!==void 0?o:0,text:t}}),Ci=(e,t)=>{var r,n;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((n=(r=e.rows[0])===null||r===void 0?void 0:r.indent)!==null&&n!==void 0?n:0)},ln=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Ci(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)},Ni=(e,t)=>{var r;if(!((r=t.hasTitle)!==null&&r!==void 0)||r){let[n,...o]=e;return n===void 0?[]:[{type:"title",rows:[n]},...o.reduce(ln,[])]}return e.reduce(ln,[])},ke=(e,t)=>{var r;let n=Pi(e);return Ni(n,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(Mi)};var fn=e=>{let t=[],r=new Set,n=o=>{r.delete(o);let s=t.pop();if(!s)return;let a=s[0]().finally(()=>n(a)).then(l=>s[1](l)).catch(l=>s[2](l));r.add(a)};return o=>{if(r.size<e){let s=o().finally(()=>n(s));return r.add(s),s}return new Promise((s,a)=>{t.push([o,s,a])})}};var Si="0.6.5",hn=ScrapBubble-${Si},mn=await globalThis.caches.open(hn);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==hn&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var gn=fn(3);async function*Xe(e,t){let r=((t?.saveFailedResponse?mn.match(e):void 0)??an(e,t)).then(a=>["cache",a]);{let a=J(1e3).then(()=>"timeout"),l=await Promise.race([r,a]);if(l!=="timeout"){l[1]&&(yield["cache",l[1]]);let i=await gn(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await mn.put(e,i.clone()),yield["network",i]}}let n=gn(()=>fetch(e)).then(a=>["network",a]),[o,s]=await Promise.race([r,n]);if(o==="network"){yield[o,s];return}s&&(yield[o,s]),yield await n}var bn=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Ye=()=>{let e=new Map;return{dispatch:(t,r)=>{let n=e.get(t);if(n)for(let o of n)o(r)},on:(t,r)=>{let n=e.get(t)??new Set;n.add(r),e.set(t,n)},off:(t,r)=>{let n=e.get(t);n&&n.delete(r)}}};var $=!1,xn=e=>{$=typeof e=="boolean"?e:new Set(e)},Y=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{$!==!0&&(!$||!$.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{$!==!0&&(!$||!$.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{$!==!0&&(!$||!$.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!($!==!0&&(!$||!$.has(e))))return r(...n)}]}}));var Lt=Ye(),Ve=new Map,Ii=Y("ScrapBubble:useProject.ts"),yn=e=>{let[t,r]=M();return D(()=>{Lt.on(e,r);let n=Ve.get(e);return n?r(n.loading?void 0:n.value):(Ve.set(e,{loading:!0}),r(void 0),(async()=>{try{let o=Ee.toRequest(e);for await(let[,s]of Xe(o)){let a=await Ee.fromResponse(s);Ve.set(e,{loading:!1,value:a}),Lt.dispatch(e,a);break}}catch(o){Ii.error(o),Ve.delete(e)}})()),()=>Lt.off(e,r)},[e]),t};var Ri=["default-light","default-dark","default-minimal"],Bi=["paper-light","paper-dark-dark","paper-dark"],vn=["blue","purple","green","orange","red"],Hi=["hacker1","hacker2"],En=["winter","spring","summer","automn"],wn=["tropical"],kn=["kyoto","newyork","paris"],Ln=["mred","lgreen"],Mg=["default-light","default-minimal","paper-light",...vn,...En,...wn,...kn,...Ln];var Oi=[...Ri,...Bi,...vn,...Hi,...En,...wn,...kn,...Ln];function _n(e){return Oi.includes(e)}var Tn="default-light",Z=e=>{let t=yn(e);return E(()=>{if(!t||!t.ok)return Tn;let r=t.value.theme;return _n(r)?r:Tn},[t])};var ae=(e,t)=>new Promise(r=>{let n=!1,o=()=>{n=!0,r(!1)};e.addEventListener("click",o),e.addEventListener("pointerleave",o),setTimeout(()=>{n||r(!0),e.removeEventListener("click",o),e.removeEventListener("pointerleave",o),r(!1)},t)});var ce=e=>{let{top:t,right:r,left:n,bottom:o}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),a=(n-s.left)/s.width>.5;return{top:Math.round(o-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...a?{right:Math.round(s.right-r)}:{left:Math.round(n-s.left)},maxWidth:a?r-10:document.documentElement.clientWidth-n-10}};var Mn=({project:e,title:t,descriptions:r,thumbnail:n,linkTo:o,bubble:s,delay:a,prefetch:l})=>{let i=E(()=>n?[]:ke(r.join( ),{hasTitle:!1}),[n,r]),u=Z(e),c=H(async({currentTarget:g})=>{l(e,t),await ae(g,a)&&s({project:e,title:t,linkTo:o,type:"link",position:ce(g)})},[e,t,a,o?.project,o?.titleLc]),m=E(()=>o?()=>{kt({type:"page",from:{project:o.project??e,title:o.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,o?.project,o?.titleLc]);return d("a",{className:"related-page-card page-link",type:"link","data-theme":u,href:/${e}/${P(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:c,onClick:m},d("div",{class:"hover"}),d("div",{class:"content"},d("div",{class:"header"},d("div",{class:"title"},t)),n?d("div",{class:"thumbnail"},d("img",{src:n})):d("div",{class:"description"},i.flatMap((g,p)=>g.type==="line"?[d("p",{key:p},g.nodes.map(f=>d(Pn,{node:f,project:e})))]:[]))))},Pn=({node:e,project:t})=>{switch(e.type){case"code":return d("code",null,e.text);case"formula":return d(Di,{node:e});case"commandLine":return d("code",null,e.symbol," $",e.text);case"helpfeel":return d("code",null,"? ",e.text);case"quote":case"strong":case"decoration":return d(L,null,e.nodes.map(r=>d(Pn,{node:r,project:t})));case"icon":case"strongIcon":return d($i,{node:e,project:t});case"hashTag":return d(ji,{node:e});case"link":return d(Ai,{node:e});case"plain":case"blank":return d(L,null,e.text);default:return d(L,null)}},Di=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:n}=we("");return n(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},$i=({node:{pathType:e,path:t},project:r})=>{let[n,o]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return d("img",{class:"icon",src:/api/pages/${n}/${P(o)}/icon})},ji=({node:{href:e}})=>d("span",{class:"page-link"},"#",e),Ai=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?d("span",{class:"page-link"},t):d("span",{class:"link"},r||t);var v=(e,t)=>/${e}/${B(t)},Qe=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var Bn=Symbol.for("immer-nothing"),Cn=Symbol.for("immer-draftable"),y=Symbol.for("immer-state");function F(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var le=Object.getPrototypeOf;function ue(e){return!!e&&!!e[y]}function z(e){return e?Hn(e)||Array.isArray(e)||!!e[Cn]||!!e.constructor?.[Cn]||rt(e)||nt(e):!1}var Fi=Object.prototype.constructor.toString();function Hn(e){if(!e||typeof e!="object")return!1;let t=le(e);if(t===null)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return r===Object?!0:typeof r=="function"&&Function.toString.call(r)===Fi}function Le(e,t){tt(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function tt(e){let t=e[y];return t?t.type_:Array.isArray(e)?1:rt(e)?2:nt(e)?3:0}function Mt(e,t){return tt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function On(e,t,r){let n=tt(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function Ui(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function rt(e){return e instanceof Map}function nt(e){return e instanceof Set}function N(e){return e.copy_||e.base_}function Pt(e,t){if(rt(e))return new Map(e);if(nt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Hn(e);if(t===!0||t==="class_only"&&!r){let n=Object.getOwnPropertyDescriptors(e);delete n[y];let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++){let a=o[s],l=n[a];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(n[a]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[a]})}return Object.create(le(e),n)}else{let n=le(e);if(n!==null&&r)return{...e};let o=Object.create(n);return Object.assign(o,e)}}function It(e,t=!1){return ot(e)||ue(e)||!z(e)||(tt(e)>1&&(e.set=e.add=e.clear=e.delete=Ki),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>It(n,!0))),e}function Ki(){F(2)}function ot(e){return Object.isFrozen(e)}var Ct={};function ee(e){let t=Ct[e];return t||F(0,e),t}function qi(e,t){Ct[e]||(Ct[e]=t)}var _e;function Je(){return _e}function zi(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Nn(e,t){t&&(ee("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Nt(e){St(e),e.drafts_.forEach(Gi),e.drafts_=null}function St(e){e===_e&&(_e=e.parent_)}function Sn(e){return _e=zi(_e,e)}function Gi(e){let t=e[y];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function In(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[y].modified_&&(Nt(t),F(4)),z(e)&&(e=Ze(t,e),t.parent_||et(t,e)),t.patches_&&ee("Patches").generateReplacementPatches_(r[y].base_,e,t.patches_,t.inversePatches_)):e=Ze(t,r,[]),Nt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Bn?e:void 0}function Ze(e,t,r){if(ot(t))return t;let n=t[y];if(!n)return Le(t,(o,s)=>Rn(e,n,t,o,s,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return et(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,a=!1;n.type_===3&&(s=new Set(o),o.clear(),a=!0),Le(s,(l,i)=>Rn(e,n,o,l,i,r,a)),et(e,o,!1),r&&e.patches_&&ee("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Rn(e,t,r,n,o,s,a){if(ue(o)){let l=s&&t&&t.type_!==3&&!Mt(t.assigned_,n)?s.concat(n):void 0,i=Ze(e,o,l);if(On(r,n,i),ue(i))e.canAutoFreeze_=!1;else return}else a&&r.add(o);if(z(o)&&!ot(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ze(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&et(e,o)}}function et(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&It(t,r)}function Wi(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:Je(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=Rt;r&&(o=[n],s=Te);let{revoke:a,proxy:l}=Proxy.revocable(o,s);return n.draft_=l,n.revoke_=a,l}var Rt={get(e,t){if(t===y)return e;let r=N(e);if(!Mt(r,t))return Xi(e,r,t);let n=r[t];return e.finalized_||!z(n)?n:n===_t(e.base_,t)?(Tt(e),e.copy_[t]=Me(n,e)):n},has(e,t){return t in N(e)},ownKeys(e){return Reflect.ownKeys(N(e))},set(e,t,r){let n=Dn(N(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=_t(N(e),t),s=o?.[y];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Ui(r,o)&&(r!==void 0||Mt(e.base_,t)))return!0;Tt(e),q(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return _t(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Tt(e),q(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=N(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){F(11)},getPrototypeOf(e){return le(e.base_)},setPrototypeOf(){F(12)}},Te={};Le(Rt,(e,t)=>{Te[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Te.deleteProperty=function(e,t){return Te.set.call(this,e,t,void 0)};Te.set=function(e,t,r){return Rt.set.call(this,e[0],t,r,e[0])};function _t(e,t){let r=e[y];return(r?N(r):e)[t]}function Xi(e,t,r){let n=Dn(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function Dn(e,t){if(!(t in e))return;let r=le(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=le(r)}}function q(e){e.modified_||(e.modified_=!0,e.parent_&&q(e.parent_))}function Tt(e){e.copy_||(e.copy_=Pt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Yi=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let a=this;return function(l=s,...i){return a.produce(l,u=>r.call(this,u,...i))}}typeof r!="function"&&F(6),n!==void 0&&typeof n!="function"&&F(7);let o;if(z(t)){let s=Sn(this),a=Me(t,void 0),l=!0;try{o=r(a),l=!1}finally{l?Nt(s):St(s)}return Nn(s,n),In(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===Bn&&(o=void 0),this.autoFreeze_&&It(o,!0),n){let s=[],a=[];ee("Patches").generateReplacementPatches_(t,o,s,a),n(s,a)}return o}else F(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let n,o;return[this.produce(t,r,(s,a)=>{n=s,o=a}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){z(e)||F(8),ue(e)&&(e=Vi(e));let t=Sn(this),r=Me(e,void 0);return r[y].isManual_=!0,St(t),r}finishDraft(e,t){let r=e&&e[y];(!r||!r.isManual_)&&F(9);let{scope_:n}=r;return Nn(n,t),In(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=ee("Patches").applyPatches_;return ue(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Me(e,t){let r=rt(e)?ee("MapSet").proxyMap_(e,t):nt(e)?ee("MapSet").proxySet_(e,t):Wi(e,t);return(t?t.scope_:Je()).drafts_.push(r),r}function Vi(e){return ue(e)||F(10,e),$n(e)}function $n(e){if(!z(e)||ot(e))return e;let t=e[y],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Pt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Pt(e,!0);return Le(r,(n,o)=>{On(r,n,$n(o))}),t&&(t.finalized_=!1),r}function jn(){class e extends Map{constructor(i,u){super(),this[y]={type_:2,parent_:u,scope_:u?u.scope_:Je(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return N(this[y]).size}has(i){return N(this[y]).has(i)}set(i,u){let c=this[y];return a(c),(!N(c).has(i)||N(c).get(i)!==u)&&(r(c),q(c),c.assigned_.set(i,!0),c.copy_.set(i,u),c.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let u=this[y];return a(u),r(u),q(u),u.base_.has(i)?u.assigned_.set(i,!1):u.assigned_.delete(i),u.copy_.delete(i),!0}clear(){let i=this[y];a(i),N(i).size&&(r(i),q(i),i.assigned_=new Map,Le(i.base_,u=>{i.assigned_.set(u,!1)}),i.copy_.clear())}forEach(i,u){let c=this[y];N(c).forEach((m,g,p)=>{i.call(u,this.get(g),g,this)})}get(i){let u=this[y];a(u);let c=N(u).get(i);if(u.finalized_||!z(c)||c!==u.base_.get(i))return c;let m=Me(c,u);return r(u),u.copy_.set(i,m),m}keys(){return N(this[y]).keys()}values(){let i=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let u=i.next();return u.done?u:{done:!1,value:this.get(u.value)}}}}entries(){let i=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let u=i.next();if(u.done)return u;let c=this.get(u.value);return{done:!1,value:[u.value,c]}}}}[Symbol.iterator](){return this.entries()}}function t(l,i){return new e(l,i)}function r(l){l.copy_||(l.assigned_=new Map,l.copy_=new Map(l.base_))}class n extends Set{constructor(i,u){super(),this[y]={type_:3,parent_:u,scope_:u?u.scope_:Je(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return N(this[y]).size}has(i){let u=this[y];return a(u),u.copy_?!!(u.copy_.has(i)||u.drafts_.has(i)&&u.copy_.has(u.drafts_.get(i))):u.base_.has(i)}add(i){let u=this[y];return a(u),this.has(i)||(s(u),q(u),u.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let u=this[y];return a(u),s(u),q(u),u.copy_.delete(i)||(u.drafts_.has(i)?u.copy_.delete(u.drafts_.get(i)):!1)}clear(){let i=this[y];a(i),N(i).size&&(s(i),q(i),i.copy_.clear())}values(){let i=this[y];return a(i),s(i),i.copy_.values()}entries(){let i=this[y];return a(i),s(i),i.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(i,u){let c=this.values(),m=c.next();for(;!m.done;)i.call(u,m.value,m.value,this),m=c.next()}}function o(l,i){return new n(l,i)}function s(l){l.copy_||(l.copy_=new Set,l.base_.forEach(i=>{if(z(i)){let u=Me(i,l);l.drafts_.set(i,u),l.copy_.add(u)}else l.copy_.add(i)}))}function a(l){l.revoked_&&F(3,JSON.stringify(N(l)))}qi("MapSet",{proxyMap_:t,proxySet_:o})}var j=new Yi,st=j.produce,Wg=j.produceWithPatches.bind(j),Xg=j.setAutoFreeze.bind(j),Yg=j.setUseStrictShallowCopy.bind(j),Vg=j.applyPatches.bind(j),Qg=j.createDraft.bind(j),Jg=j.finishDraft.bind(j);jn();var An=e=>{let t=0;for(let r of e)if(r&&(r.exists||(t+=(r.linked?.length??0)+(r.projectLinked?.length??0),t>1)))return!1;return t<2},Fn=(e,t)=>st(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:n,linked:o,projectLinked:s,...a}=t;Object.assign(r,a),Bt(t)||(r.lines=n),o&&(r.linked??=o),s&&(r.projectLinked??=s);return}Bt(r)&&!Bt(t)&&(r.lines=t.lines),t.linked&&(t.isLinkedCorrect||!r.isLinkedCorrect&&(r.linked?.length??0)<=t.linked.length)&&(r.linked=t.linked),t.projectLinked&&(r.projectLinked=t.projectLinked)}),Bt=e=>e.lines[0].id==="dummy";var Un=(e,t)=>{let r=new Map,n=B(t.title);for(let i of t.links){let u=Qi(e,i);u.linked=[n],r.set(v(e,i),u)}let o=v(e,n),s=t.projectLinks.map(i=>{let u=Qe(i);return v(u.project,u.titleLc)}),a={...it(e,t),linked:[],projectLinked:[]};r.set(o,a);let l=t.links.map(i=>B(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(n)&&a.linked.push(i.titleLc);for(let g of i.linksLc.filter(p=>l.includes(p))){let p=v(e,g),f=r.get(p);if(!f)throw Error(storage already must have "${p}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let u=v(e,i.titleLc),c=it(e,i),m=r.get(u)?.linked;m&&(c.linked=m),r.set(u,c)}for(let i of t.relatedPages.projectLinks1hop){let u=v(i.projectName,i.titleLc);s.includes(u)||a.projectLinked.push(u);let c=it(i.projectName,i),m=r.get(u)?.projectLinked;m&&(c.projectLinked=m),r.set(u,c)}a.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let g of i.linksLc){let p=v(e,g),f=r.get(p);if(!f)throw Error(storage already must have "${p}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let u=v(e,i.titleLc),c=it(e,i),m=r.get(u)?.linked;m&&(c.linked=m),r.set(u,c)}return r},it=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:B(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:t.descriptions,image:t.image,lines:"lines"in t?t.lines:[t.title,...t.descriptions].map(r=>({text:r,id:"dummy",userId:"dummy",updated:t.updated,created:t.updated})),updated:t.updated,isLinkedCorrect:!1}),Qi=(e,t)=>({project:e,titleLc:B(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var at=Y("ScrapBubble:bubble.ts"),Ht=new Map,ct=new Set,Ot=Ye();function*qn(e){for(let t of e)yield Ht.get(t)}var zn=(e,t)=>Ot.on(e,t),Gn=(e,t)=>Ot.off(e,t),Wn=async(e,t,r,n)=>{let o=[];for(let s of[...t].reverse()){let a=v(s,e);ct.has(a)||o.push(Ji(s,e,r,n))}await Promise.all(o)},Kn=0,Ji=async(e,t,r,n)=>{let o=v(e,t);if(ct.has(o))return;ct.add(o);let s=Kn++,a=${s} Check update ${o};at.time(a);try{let l=se.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[i,u]of Xe(l,{ignoreSearch:!0,saveFailedResponse:!0})){at.debug(${s}${i} ${o});let c=await se.fromResponse(u);if(c.ok){let m=Un(e,c.value);for(let[g,p]of m){let f=Ht.get(g),b=Fn(f,p);b&&f!==b&&(Ht.set(g,b),Ot.dispatch(g,p))}}if(n?.ignoreFetch===!0||i==="cache"&&!bn(u,n?.maxAge??60))break}}catch(l){at.error(l)}finally{ct.delete(o),at.timeEnd(a),Kn--}};var Xn=Y("ScrapBubble:useBubbleData.ts"),de=e=>{let[t,r]=M([]);return ze(()=>{let n=()=>{r(()=>{let a=[...qn(e)].flatMap(l=>l?[l]:[]);return Xn.debug(Required: ${e.length} pages, ${a.length} found,a),a})};n();let o,s=()=>{clearTimeout(o),o=setTimeout(()=>{Xn.debug(Update ${e.length} pages),n()},10)};return e.forEach(a=>zn(a,s)),()=>e.forEach(a=>Gn(a,s))},e),t};var Yn=({source:e,linked:t,externalLinked:r,projectsForSort:n,...o})=>{let s=E(()=>[...t.keys(),...r.keys()],[t,r]),a=de(s),l=E(()=>[...n],[n]),i=E(()=>{let c=(m,g)=>{let p=l.indexOf(m.project),f=l.indexOf(g.project);return p===f?g.updated-m.updated:p<0?1:f<0?-1:p-f};return[...a].sort(c)},[a,l]),u=E(()=>({bottom:${e.position.bottom}px,maxWidth:${e.position.maxWidth}px,..."left"in e.position?{left:${e.position.left}px}:{right:${e.position.right}px}}),[e.position]);return d("ul",{className:"card-bubble",style:u,onClick:o.onClick},i.map(({project:c,titleLc:m,lines:[{text:g}],descriptions:p,image:f})=>{let b=v(c,m),x=t.get(b)??r.get(b);return d("li",{key:b},d(Mn,{project:c,title:g,linkTo:x,descriptions:p,thumbnail:f??"",...o}))}))};var pe=e=>{if(e.pathType==="root"){let[,t="",r=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(t==="")throw SyntaxError(Failed to get a project name from "${e.href}");let[,n]=r?.match?.(/#([a-f\d]{24,32})$/)??["",""];return r===""?{project:t}:n===""?{project:t,title:r}:{project:t,title:r.slice(0,-1-n.length),hash:n}}else{let[,t]=e.href.match(/#([a-f\d]{24,32})$/)??["",""];return t===""?{title:e.href}:{title:e.href.slice(0,-1-t.length),hash:t}}};var Dt=(e,t)=>t.some(r=>{let n=!e.project;switch(r.type){case"hashTag":return n&&B(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==n)return!1;let{project:o,title:s=""}=pe({pathType:r.pathType,href:r.href});return n?!o&&B(s)===e.titleLc:o===e.project&&B(s)===e.titleLc}case"quote":case"strong":case"decoration":return Dt(e,r.nodes)}});var V=yt({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Qn=({lines:e,project:t,title:r,whiteList:n,noIndent:o,hash:s,linkTo:a,...l})=>{let i=E(()=>e.flatMap(p=>typeof p=="string"?[]:[p.id]),[e]),u=E(()=>{let p=0;return ke(e.map(f=>typeof f=="string"?f:f.text).join( ),{hasTitle:!0}).map(f=>{switch(f.type){case"title":case"line":return{...f,id:i[p++]};case"codeBlock":{let b=p;return p+=f.content.split(
).length+1,{...f,ids:i.slice(b,p)}}case"table":{let b=p;return p+=f.cells.length+1,{...f,ids:i.slice(b,p)}}}})},[e,i]),c=E(()=>{if(s&&i.includes(s))return s;if(a)return u.find(p=>p.type!=="line"?!1:Dt(a,p.nodes))?.id},[u,i,s,a?.project,a?.titleLc]),m=oe(null);D(()=>{if(!c)return;let p=m.current?.querySelector(data-id="${c}"),f=globalThis.scrollY;p?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,f)},[c]);let g=Z(t);return d("div",{className:"lines","data-theme":g,ref:m},d(V.Provider,{value:{project:t,title:r,whiteList:n,...l}},u.map(p=>{switch(p.type){case"title":return d(L,null,d(me,{key:p.id,index:p.id,indent:0,noIndent:o,permalink:p.id===c},d("a",{className:"page-link",type:"link",href:/${t}/${P(p.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank"},p.text)),d("hr",null));case"codeBlock":return d(Zi,{key:p.ids[0],block:p,noIndent:o,ids:p.ids,scrollId:c});case"table":return d(ea,{key:p.ids[0],block:p,noIndent:o,ids:p.ids,scrollId:c});case"line":return d(me,{key:p.id,index:p.id,indent:p.indent,noIndent:o,permalink:p.id===c},p.nodes.length>0?p.nodes.map(f=>d(fe,{node:f})):d("br",null))}})))},me=({index:e,indent:t,noIndent:r,children:n,permalink:o})=>d("div",{className:line${o?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em}},n),Zi=({block:{fileName:e,content:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:a}=W(V),[l,i]=M(""),u=H(async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(t),i("Copied"),await J(1e3),i("")}catch(m){alert(Failed to copy the code block Error:${m.message})}},[t]);return d(L,null,d(me,{index:n[0],indent:r,permalink:n[0]===o},d("span",{className:"code-block"},d("span",{className:"code-block-start"},d("a",{href:/api/code/${s}/${P(a)}/${e},target:"_blank"},e)),d("span",{className:"copy",title:"Copy",onClick:u},l))),d(L,null,t.split(
).map((c,m)=>d(me,{index:n[m+1],indent:r,permalink:n[m+1]===o},d("code",{className:"code-block"},c)))))},ea=({block:{fileName:e,cells:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:a}=W(V);return d(L,null,d(me,{index:n[0],indent:r,permalink:n[0]===o},d("span",{className:"table-block"},d("span",{className:"table-block-start"},d("a",{href:/api/table/${s}/${P(a)}/${e}.csv,target:"_blank"},e)))),d(L,null,t.map((l,i)=>d(me,{index:n[i+1],indent:r,permalink:n[i+1]===o},d("span",{className:"table-block table-block-row"},l.map((u,c)=>d("span",{className:cell col-${c}},u.map(m=>d(fe,{node:m})))))))))},fe=({node:e})=>{switch(e.type){case"code":return d("code",{className:"code"},e.text);case"formula":return d(ta,{node:e});case"commandLine":return d(na,{node:e});case"helpfeel":return d("code",{className:"helpfeel"},d("span",{className:"prefix"},"?")," ",d("span",{className:"entry"},e.text));case"quote":return d("blockquote",{className:"quote"},e.nodes.map(t=>d(fe,{node:t})));case"strong":return d("strong",null,e.nodes.map(t=>d(fe,{node:t})));case"decoration":return d(ra,{node:e});case"plain":case"blank":return d(L,null,e.text);case"hashTag":return d(ia,{node:e});case"link":return d(aa,{node:e});case"googleMap":return d(oa,{node:e});case"icon":return d(Vn,{node:e});case"strongIcon":return d(Vn,{node:e,strong:!0});case"image":return d(sa,{node:e});case"strongImage":return d("img",{className:"image strong-image",src:e.src});case"numberList":return d(L,null,${e.number}. ,e.nodes.map(t=>d(fe,{node:t})))}},ta=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:n}=we("");return n(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},ra=({node:{decos:e,nodes:t}})=>d("span",{className:e.map(r=>deco-${r}).join(" ")},t.map(r=>d(fe,{node:r}))),na=({node:e})=>{let[t,r]=M(""),n=H(async o=>{o.preventDefault(),o.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await J(1e3),r("")}catch(s){alert(Failed to copy the code block
Error:${s.message})}},[e.text]);return d(L,null,d("code",{className:"cli"},d("span",{className:"prefix"},e.symbol)," ",d("span",{className:"command"},e.text)),d("span",{className:"tool-buttons"},d("span",{title:"Copy",className:"copy",onClick:n},t)))},oa=({node:{place:e,latitude:t,longitude:r,zoom:n}})=>d("span",{className:"pointing-device-map"},d("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${n}z,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${n}&_csrf=${globalThis._csrf}}))),Vn=({node:{pathType:e,path:t},strong:r})=>{let{project:n}=W(V),[o,s]=e==="relative"?[n,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[n,t],a=P(s);return d("a",{href:/${o}/${a},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank"},d("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${o}/${a}/icon},s))},sa=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return d("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"image",src:t}))},ia=({node:{href:e}})=>{let{project:t}=W(V),r=Jn(t,e),n=Zn(t,e,"hashtag");return d("a",{href:/${t}/${P(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:n},"#",e)},aa=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return d(ca,{pathType:e,href:t.href});case"absolute":{let r=Zr({pathType:e,...t});switch(r.type){case"youtube":return d(la,{...r});case"vimeo":return d(ua,{...r});case"spotify":return d(da,{...r});case"anchor-fm":return d(pa,{...r});case"audio":return d(fa,{...r});case"video":return d(ga,{...r});case"absoluteLink":return d("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},ca=({pathType:e,href:t})=>{let{project:r}=W(V),{project:n=r,title:o,hash:s=""}=pe({pathType:e,href:t}),a=Zn(n,o,"link",s),l=Jn(n,o??"");return d("a",{className:page-link${o!==void 0&&l?" empty-page-link":""},type:"link",href:/${n}${o===void 0?"":/${P(o)}${s===""?"":#${s}}},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",onPointerEnter:a},t)},la=e=>{e.params.append("autoplay","0");let t=e.pathType==="list"?https://www.youtube.com/embed/?${e.params.toString()}&list=${e.listId}:https://www.youtube.com/embed/${e.videoId}?${e.params.toString()};return d("div",{className:"iframe-video-player"},d("iframe",{src:t,allowFullScreen:!0,type:"text/html"}))},ua=({videoId:e})=>d("div",{className:"iframe-video-player"},d("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0,type:"text/html"})),da=e=>d("div",{className:"iframe-video-player"},d("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0,type:"text/html",scrolling:"no"})),pa=e=>d("div",{className:"iframe-video-player"},d("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})),fa=e=>e.content===""?d("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):d(ma,{...e}),ma=({href:e,content:t})=>{let r=oe(null),n=H(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return d("span",{className:"audio-link"},d("a",{href:e,rel:"noopener noreferrer",target:"_blank"},t),d("span",{className:"play",onClick:n},"♬"),d("audio",{preload:"none",src:e,ref:r}))},ga=({href:e})=>d("div",{className:"video-player"},d("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})),Jn=(e,t)=>{let{whiteList:r}=W(V),n=E(()=>(r.has(e)?[...r]:[e,...r]).map(s=>v(s,t)),[r,e]),o=de(n);return E(()=>An(o),o)},Zn=(e,t,r,n)=>{let{delay:o,bubble:s,prefetch:a}=W(V);return H(async({currentTarget:l})=>{t&&(a(e,t),await ae(l,o)&&s({project:e,title:t,hash:n,type:r,position:ce(l)}))},[e,t,n,r,o,a,s])};var eo=({pages:e,onClick:t,source:r,whiteList:n,...o})=>{let[s,a]=M(v(e[0].project,e[0].titleLc)),l=E(()=>({top:${r.position.top}px,maxWidth:${r.position.maxWidth}px,..."left"in r.position?{left:${r.position.left}px}:{right:${r.position.right}px}}),[r.position]);return d("div",{className:"text-bubble",style:l,onClick:t},e.length>1&&d("div",{role:"tablist"},e.map(i=>d(ha,{key:v(i.project,i.titleLc),project:i.project,titleLc:i.titleLc,selected:s===v(i.project,i.titleLc),tabSelector:a}))),e.map(i=>d(ba,{key:v(i.project,i.titleLc),selected:s===v(i.project,i.titleLc),...i,title:i.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:n,...o})))},ha=({project:e,titleLc:t,tabSelector:r,selected:n})=>{let o=H(()=>r(v(e,t)),[e,t]),s=Z(e);return d("button",{role:"tab","aria-selected":n,"data-theme":s,tabIndex:-1,onClick:o},e)},ba=({selected:e,...t})=>{let r=Z(t.project);return d("div",{role:"tabpanel","data-theme":r,hidden:!e},d(Qn,{...t}))};var to=Y("ScrapBubble:Bubble.tsx"),ro=({source:e,parentTitles:t,whiteList:r,...n})=>{let o=E(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,a,l]=ya(e,o,r,t);return d(L,null,xa(l)&&d(eo,{pages:l,source:e,whiteList:r,onClick:n.hide,...n}),d(Yn,{linked:s,externalLinked:a,onClick:n.hide,source:e,projectsForSort:o,...n}))},xa=e=>e.length>0,ya=(e,t,r,n)=>{let[[o,s,a],l]=M([new Map,new Map,[]]),i=E(()=>{let m=[...t].map(g=>v(g,e.title));return to.debug("projects",m),m},[t,e.title]),u=de(i),c=E(()=>n.map(m=>B(m)),[n]);return ze(()=>{let m=new Map,g=new Map,p=[];for(let f of u){let b={project:f.project,titleLc:f.titleLc};for(let w of f.projectLinked??[]){let{project:I,titleLc:te}=Qe(w);c.includes(te)&&r.has(I)||g.has(w)||g.set(w,b)}if(!r.has(f.project))continue;let x={titleLc:f.titleLc};for(let w of f.linked??[]){if(c.includes(w))continue;let I=v(f.project,w);m.has(I)||m.set(I,x)}c.includes(f.titleLc)||f.exists&&p.push(f)}l(st(f=>{to.debug(depth: ${c.length}, bubbled from ${v(e.project,e.title)}, bubbles,,u,"before",f[0],"internal cards,",m,"external cards",g);for(let b of f[0].keys())m.has(b)||f[0].delete(b);for(let[b,x]of m)f[0].set(b,x);for(let b of f[1].keys())g.has(b)||f[1].delete(b);for(let[b,x]of g)f[1].set(b,x);f[2]=p}))},[u,r,c]),[o,s,a]};var no=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var oo=e=>{let t=E(()=>no(e.style,import.meta.url),[e.style]);return d(L,null,t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",null,t)))};var so=String.raw*{box-sizing:border-box}a{background-color:transparent;text-decoration:none;cursor:pointer}img{display:inline-block;max-width:100%;max-height:100px}code{font-family:var(--code-text-font, Menlo, Monaco, Consolas, "Courier New", monospace);font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}blockquote{background-color:var(--quote-bg-color, rgba(0,0,0,.05));display:block;border-left:solid 4px #a0a0a0;padding-left:4px;margin:0}strong{font-weight:700}iframe{display:inline-block;margin:3px 0;vertical-align:middle;max-width:100%;width:640px;height:360px;border:0}audio{display:inline-block;vertical-align:middle;white-space:initial;max-width:100%}.formula{margin:auto 6px}.formula.error code{color:#fd7373}.katex-display{display:inline-block!important;margin:0!important;text-align:inherit!important}.error .katex-display{display:none}.cli{border-radius:4px}.cli .prefix{color:#9c6248}.helpfeel{background-color:#fbebdd;border-radius:4px;padding:3px!important}.helpfeel .prefix{color:#f17c00}.helpfeel .entry{color:#cc5020}.code-block{display:block;line-height:1.7em;background-color:var(--code-bg, rgba(0,0,0,.04))}.code-block-start{font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#342d9c;background-color:#ffcfc6;font-size:.9em;padding:1px 2px}.code-block-start a{color:#342d9c;text-decoration:underline}code.code-block,.table-block.table-block-row{padding-left:1em}.copy{font-family:"Font Awesome 5 Free";cursor:pointer}.table-block{white-space:nowrap}.table-block-start{padding:1px 2px;font-size:.9em;background-color:#ffcfc6}.table-block-start a{color:#342d9c;text-decoration:underline}.cell{margin:0;padding:0 2px 0 8px;box-sizing:content-box;display:inline-block;white-space:pre}.cell:nth-child(odd){background-color:#0000000a}.cell:nth-child(2n){background-color:#0000000f}.strong-image{max-height:100%}.icon{height:11px;vertical-align:middle}.strong-icon{height:13.2px}.tool-button{margin-left:1em;cursor:pointer;font-size:.9em}.deco-\/{font-style:italic}.deco-\*-1{font-weight:700}.deco-\*-2{font-weight:700;font-size:1.2em}.deco-\*-3{font-weight:700;font-size:1.44em}.deco-\*-4{font-weight:700;font-size:1.73em}.deco-\*-5{font-weight:700;font-size:2.07em}.deco-\*-6{font-weight:700;font-size:2.49em}.deco-\*-7{font-weight:700;font-size:3em}.deco-\*-8{font-weight:700;font-size:3.58em}.deco-\*-9{font-weight:700;font-size:4.3em}.deco-\*-10{font-weight:700;font-size:5.16em}.deco--{text-decoration:line-through}.deco-_{text-decoration:underline}.page-link{color:var(--page-link-color, #5e8af7)}a.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}a.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}a.link:hover{color:var(--page-link-color-hover-color, #2d67f5)}.link img{padding-bottom:3px;border-style:none none solid;border-width:1.5px;border-color:#8fadf9}.permalink{background-color:var(--line-permalink-color, rgba(234,218,74,.75))}.status-bar{display:inline-block;position:absolute;background-color:var(--page-bg, #fefefe);cursor:default}.status-bar>*{border:1px solid var(--status-bar-border-color, #a9aaaf)}.status-bar.top-left{top:0;left:0}.status-bar.top-left>*{border-top:none;border-left:none}.status-bar.top-left :last-of-type{border-bottom-right-radius:3px}.status-bar.top-right{top:0;right:0}.status-bar.top-right>*{border-top:none;border-right:none}.status-bar.top-right :last-of-type{border-bottom-left-radius:3px}.status-bar.bottom-right{bottom:0;right:0}.status-bar.bottom-right>*{border-bottom:none;border-right:none}.status-bar.bottom-right :last-of-type{border-top-left-radius:3px}.status-bar.bottom-left{bottom:0;left:0}.status-bar.bottom-left>*{border-bottom:none;border-left:none}.status-bar.bottom-left :last-of-type{border-top-right-radius:3px}.text-bubble{font-size:11px;line-height:1.42857;user-select:text;position:absolute;color:var(--page-text-color, #4a4a4a);box-shadow:0 6px 12px #0000002d;display:flex;flex-direction:column;z-index:9000;&.no-scroll{overflow-y:hidden}data-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}data-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}data-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}data-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}data-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}data-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}data-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}data-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}data-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}data-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}data-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}data-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}role=tabpanel{padding:5px 0 5px 5px;border-radius:4px;background-color:var(--page-bg, #fefefe);max-height:80vh;overflow-y:auto}role=tabpanel,button{border:1px solid var(--text-bubble-border-color, hsl(221, 15%, 25%))}button{cursor:default;color:inherit;font-size:inherit;line-height:inherit;background-color:var(--page-bg, #fefefe);border-radius:4px 4px 0 0}buttonaria-selected=true{background-color:var(--text-bubble-border-color, hsl(221, 15%, 25%))}}.project-badge{text-decoration:none;color:var(--tool-text-color, #363c49)}.related-page-carddata-theme=default-dark{--card-title-bg: hsl(0, 0%, 39%)}.related-page-carddata-theme=default-minimal{--card-title-bg: hsl(0, 0%, 89%)}.related-page-carddata-theme=paper-light{--card-title-bg: hsl(53, 8%, 58%)}.related-page-carddata-theme=paper-dark-dark{--card-title-bg: hsl(203, 42%, 17%)}.related-page-carddata-theme=blue{--card-title-bg: hsl(227, 68%, 62%)}.related-page-carddata-theme=purple{--card-title-bg: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--card-title-bg: hsl(136, 29%, 50%)}.related-page-carddata-theme=orange{--card-title-bg: hsl(43, 71%, 51%)}.related-page-carddata-theme=red{--card-title-bg: hsl(4, 58%, 56%)}.related-page-carddata-theme=spring{--card-title-bg: hsl(72, 64%, 57%)}.related-page-carddata-theme=kyoto{--card-title-bg: hsl(331, 21%, 26%)}.related-page-carddata-theme=newyork{--card-title-bg: hsl(176, 29%, 67%)}.related-page-card{display:block;position:relative;height:inherit;width:inherit;overflow:hidden;text-overflow:ellipsis;font-family:Roboto,Helvetica,Arial,Hiragino Sans,sans-serif;background-color:var(--card-bg, #fff);color:var(--card-title-color, #555);word-break:break-word;text-decoration:none}.related-page-card:hover{box-shadow:var(--card-box-hover-shadow, 0 2px 0 rgba(0,0,0,.23))}.related-page-card:focus{outline:0;box-shadow:0 0 0 3px #66afe999;border-color:#66afe9;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.related-page-card.hover{opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;background-color:var(--card-hover-bg, rgba(0,0,0,.05));mix-blend-mode:multiply;z-index:1;transition:background-color .1s}.related-page-card:hover .hover{opacity:1}.related-page-card:active .hover{opacity:1;background-color:var(--card-active-bg, rgba(0,0,0,.1))}.related-page-card .content{height:calc(100% - 5px);width:inherit;display:flex;flex-direction:column;overflow:hidden}.related-page-card .content .header{width:100%;color:#396bdd;text-overflow:ellipsis;border-top:var(--card-title-bg, #f2f2f3) solid 10px;padding:8px 10px}.related-page-card .content .header .title{font-size:11px;line-height:16px;font-weight:700;max-height:48px;color:var(--card-title-color, #363c49);margin:0;overflow:hidden;display:block;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-overflow:ellipsis}.related-page-card .content .description{line-height:16px;padding:8px 10px 0;font-size:10px;white-space:pre-line;column-count:1;column-gap:2em;column-width:10em;height:inherit;color:var(--card-description-color, gray);flex-shrink:16;overflow:hidden}.related-page-card .content .thumbnail{display:block;width:100%;margin:0 auto;padding:0 5px}.related-page-card .content .description p{margin:0;display:block}.related-page-card .content .description code{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}.related-page-card .content .description .icon{height:9px;vertical-align:middle}.related-page-card .content .description .page-link{background-color:transparent;text-decoration:none;cursor:pointer;color:var(--page-link-color, #5e8af7)}.card-bubble{background-color:var(--page-bg, #FFF);box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;position:absolute;max-width:80vw;box-sizing:content-box;z-index:9000;font-size:11px;line-height:1.42857;display:flex;padding:0;margin:0;list-style:none;overflow-x:auto;overflow-y:visible}.card-bubble li{display:block;position:relative;float:none;margin:5px;box-sizing:border-box;box-shadow:var(--card-box-shadow, 0 2px 0 rgba(0,0,0,.12));border-radius:2px;width:120px;height:120px} ;var io=()=>{let[e,t]=M([]),r=H((s,a)=>t(l=>a?[...l.slice(0,s),a]:[...l.slice(0,s)]),[]),[n,o]=M([{bubble:s=>r(0,s),hide:()=>r(0)}]);return D(()=>{o(([s,...a])=>[s,...e.map((l,i)=>l===a.at(i)?.source?a.at(i):{source:l,parentTitles:[scrapbox.Page.title??"",...e.slice(0,i).map(u=>u.title)],bubble:u=>r(i+1,u),hide:()=>r(i+1)})])},[e]),n};var $t=(e,t,r,n,o)=>{D(()=>(e.addEventListener(t,r,n),()=>e.removeEventListener(t,r,n)),[e,t,n,...o??[]])};var ao=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),lt=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var jt="scrap-bubble",co=({delay:e,whiteList:t,watchList:r,style:n})=>{let[{bubble:o,hide:s},...a]=io(),l=H((i,u)=>Wn(u,t.has(i)?t:new Set([i]),r),[t,r]);return $t(document,"pointerenter",async i=>{let u=i.target;if(!lt(u)&&!ao(u))return;let{project:c=scrapbox.Project.name,title:m,hash:g=""}=lt(u)?pe({pathType:"root",href:${new URL(u.href).pathname}${new URL(u.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(c==="")return;let p=decodeURIComponent(m??"");l(c,p),await ae(u,e)&&o({project:c,title:p,hash:g,position:ce(u),type:va(u)})},{capture:!0},[e,t,r]),$t(document,"click",i=>{i.target.dataset.userscriptName!==jt&&s()},{capture:!0},[s]),D(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),d(L,null,d("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),d("style",null,so),d(oo,{style:n}),a.map(i=>d(ro,{key:v(i.source.project,i.source.title),...i,whiteList:t,delay:e,prefetch:l})))},va=e=>lt(e)?e.type==="link"?"link":"hashtag":"title";var lo=async e=>{let{delay:t=500,whiteList:r=[],watchList:n=(await en()).slice(0,100),style:o="",debug:s=!1}=e??{};xn(s);let a=document.createElement("div");a.dataset.userscriptName=jt,document.body.append(a);let l=a.attachShadow({mode:"open"});Ke(d(co,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(n),style:o}),l)};lo({whiteList:["yosider-private","villagepump","shokai","arpla","nishio","motoso","takker","sta"]});var uo="Jump to an unread page";scrapbox.PageMenu.addMenu({title:uo,image:"https://gyazo.com/f74d4fc373248fb2abac31ff1f69b482/raw",onClick:async()=>{let e=scrapbox.Project.name,t=scrapbox.Project.pages.filter(s=>s.exists&&s.title!==scrapbox.Page.title),r=async()=>{let s=t[Math.floor(Math.random()*t.length)].title;return await(await fetch(/api/pages/${e}/${encodeURIComponent(s)})).json()},n=scrapbox.PageMenu(uo);n.removeAllItems(),n.emitChange();let o=0;for(;;){let s=await r(),a=${++o}: /${e}/${s.title};n.addItem({title:a,onClick:()=>{}}),console.log(a);let l=s.lines.find(i=>s.lastAccessed<i.updated);if(l){let i=document.createElement("a");i.href=./${encodeURIComponent(s.title)}#${l.id}`,i.rel="route",document.body.appendChild(i),i.click(),i.remove();return}}}});(async()=>{let{execute:e}=await Promise.resolve().then(()=>(mo(),fo));e("yosider-private","AGI","villagepump","programming-notes","yosider-scripts")})();export{cr as scrapBindings}; code:script-mobile.js