SharedUserScripts-min
全プロジェクトで使うUserScript
sharedUserScriptsをこのURLでbundleしたもの
code:script.js
var $o=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var jo=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Ln=()=>eu(document.getElementsByClassName("lines").item(0),"div.lines");var Pt=()=>{let e=document.getElementById("text-input");if(e)return jo(e,"textarea#text-input"),e};var eu=(e,t)=>{if(e)return $o(e,t),e};var Cn=()=>{let e=Ln();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 Sn(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,i)=>{let a=()=>{clearTimeout(l),i(r?.reason)},l=setTimeout(()=>{r?.removeEventListener("abort",a),o()},e);if(r?.addEventListener("abort",a,{once:!0}),n===!1)try{Deno.unrefTimer(l)}catch(c){if(!(c instanceof ReferenceError))throw c;console.error("persistent option is only available in Deno")}})}var Ho=async e=>{let t=Pt();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 Sn(1)};var xr=e=>...e.map((t,r)=>t===" "?"_":!au.includes(t)||r===e.length-1&&lu.includes(t)?encodeURIComponent(t):t).join(""),au='@$&+=:;",',lu=':;",';var yr=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let i=await(await caches.open(n)).match(e,t);if(i)return i}},br=async(e,t)=>{let r=t.clone();return await(await caches.open(cu(new Date))).put(e,r)},cu=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var pu=e=>typeof e=="object"&&e!==null,fu=e=>pu(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,zo=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return fu(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var Wo=!1;scrapbox.addListener("lines:changed",()=>Wo=!1);scrapbox.addListener("layout:changed",()=>Wo=!1);var Vo=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Go=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Mt=()=>{let e=document.getElementById("text-input");if(e)return Go(e,"textarea#text-input"),e};var qo=()=>mu(document.getElementsByClassName("status-bar")?.0,"div.status-bar"),mu=(e,t)=>{if(e)return Vo(e,t),e};var Jo=()=>{let e=qo();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=Yo(...r);n&&t.append(n)},dispose:()=>t.remove()}},Yo=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnwu();case"check-circle":returnRu();case"exclamation-triangle":returnku();case"text":returnEr(n.text);case"group":{let o=Yo(...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},Er=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},wu=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Er(e)},Ru=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Er(e)},ku=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Er(e)};var it=e=>...e.map((t,r)=>t===" "?"_":!vu.includes(t)||r===e.length-1&&Tu.includes(t)?encodeURIComponent(t):t).join(""),vu='@$&+=:;",',Tu=':;",';var Qo=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 Cu=new Map;scrapbox.on("layout:changed",()=>{let e=Mt();if(e)for(lett,rof Cu)for(letn,oof r)for(let i of o)e.addEventListener(t,n,Qo(i))});var Ke=e=>typeof e=="string";var On=(e,...t)=>{let r=e;for(let n of t){let o=r instanceof Promise?r.then(i=>Ke(i)?i:n(i)):n(r);if(Ke(o))return o;r=o instanceof URL?new URL(o):o.then(i=>Ke(i)?i:new URL(i))}return r instanceof Promise?r.then(n=>${n}):${e}};var _t=e=>e.ok?void 0:{name:"HTTPError",message:${e.status} ${e.statusText},response:e};var Xo=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=_t(r);return n?{ok:!1,value:n}:{ok:!0,value:await r.json()}})()};var wr=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}},Zo=e=>typeof e=="object"&&e!==null;var er=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 Rr=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(!Zo(r)||typeof r.message!="string")throw new er({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 er({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)})}}catch(r){throw r instanceof SyntaxError?new er({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)}):r}};var ei=async(e,t)=>{let{title:r,description:n,metadataIsPublic:o,collectionId:i,refererURL:a,accessToken:s,created:l,app:c,fetch:u}=wr(t),p=new FormData;p.append("imagedata",e),p.append("access_token",s),a&&p.append("referer_url",a.toString()),c!==void 0&&p.append("app",c),r!==void 0&&p.append("title",r),n!=null&&p.append("desc",n),i&&p.append("collection_id",i),o&&p.append("metadata_is_public","true"),l!==void 0&&p.append("created_at",${l});let m=await u("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:p}),f=await Rr(m);return f.ok?{ok:!0,value:JSON.parse(f.value)}:f};var X=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Je=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"},ce=async e=>{let t=e.clone(),r=await t.text(),n=zo(r);if(!n)throw new Je(t);return{ok:!1,value:n}};var ti=async e=>{let{sid:t,hostName:r,fetch:n}=X(e??{}),o=new Request(https://${r}/api/users/me,t?{headers:{Cookie:ie(t)}}:void 0),i=await n(o);if(!i.ok)throw new Je(i);return await i.json()};var ie=e=>connect.sid=${e},Ye=async e=>globalThis._csrf?globalThis._csrf:(await ti(e)).csrfToken;var ri=(e,t,r)=>{let{sid:n,hostName:o,followRename:i,projects:a}=X(r??{}),s=new URLSearchParams;s.append("followRename",${i??!0});for(let c of a??[])s.append("projects",c);let l=https://${o}/api/pages/${e}/${it(t)}?${s.toString()};return new Request(l,n?{headers:{Cookie:ie(n)}}:void 0)},ni=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."}}:ce(e),An=async(e,t,r)=>{let{fetch:n}=X(r??{}),o=ri(e,t,r),i=await n(o);return await ni(i)};An.toRequest=ri;An.fromResponse=ni;var oi=(e,t)=>{let{sid:r,hostName:n,sort:o,limit:i,skip:a}=X(t??{}),s=new URLSearchParams;o!==void 0&&s.append("sort",o),i!==void 0&&s.append("limit",${i}),a!==void 0&&s.append("skip",${a});let l=https://${n}/api/pages/${e}?${s.toString()};return new Request(l,r?{headers:{Cookie:ie(r)}}:void 0)},ii=async e=>e.ok?{ok:!0,value:await e.json()}:ce(e),si=async(e,t)=>{let{fetch:r}=X(t??{}),n=await r(oi(e,t));return await ii(n)};si.toRequest=oi;si.fromResponse=ii;var ai=(e,t,r,n)=>{let{sid:o,hostName:i}=X(n??{}),a=https://${i}/api/table/${e}/${it(t)}/${encodeURIComponent(r)}.csv;return new Request(a,o?{headers:{Cookie:ie(o)}}:void 0)},li=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:ce(e),ci=async(e,t,r,n)=>{let{fetch:o}=X(n??{}),i=ai(e,t,r,n),a=await o(i);return await li(a)};ci.toRequest=ai;ci.fromResponse=li;var ui=(e,t)=>{let{sid:r,hostName:n}=X(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:ie(r)}}:void 0)},pi=async e=>e.ok?{ok:!0,value:await e.json()}:ce(e),kr=async(e,t)=>{let{fetch:r}=X(t??{}),n=ui(e,t),o=await r(n);return pi(o)};kr.toRequest=ui;kr.fromResponse=pi;var fi=(e,t)=>{let{sid:r,hostName:n}=X(t??{}),o=new URLSearchParams;for(let i of e)o.append("ids",i);return new Request(https://${n}/api/projects?${o.toString()},r?{headers:{Cookie:ie(r)}}:void 0)},mi=async e=>e.ok?{ok:!0,value:await e.json()}:ce(e),di=async(e,t)=>{let{fetch:r}=X(t??{}),n=await r(fi(e,t));return mi(n)};di.toRequest=fi;di.fromResponse=mi;var gi=async(e,t)=>{let{sid:r,hostName:n,fetch:o,csrf:i}=X(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":i??await Ye(t),...r?{Cookie:ie(r)}:{}},body:JSON.stringify({timeout:3e3})}),s=await o(a);if(!s.ok)return s.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await s.json()).message}}:ce(s);let{title:l}=await s.json();return{ok:!0,value:l}};var hi=async(e,t)=>{let{sid:r,hostName:n,fetch:o,csrf:i}=X(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":i??await Ye(t),...r?{Cookie:ie(r)}:{}},body:JSON.stringify({timeout:3e3})}),s=await o(a);return s.ok?{ok:!0,value:await s.json()}:s.status===422?{ok:!1,value:{name:"InvalidURLError",message:(await s.json()).message}}:ce(s)};var xi=async e=>{let{sid:t,hostName:r,gyazoTeamsName:n}=X(e??{}),o=new Request(https://${r}/api/login/gyazo/oauth-upload/token${n??gyazoTeamsName=${n}:""},t?{headers:{Cookie:ie(t)}}:void 0),i=await fetch(o);if(!i.ok)return ce(i);let{token:a}=await i.json();return{ok:!0,value:a}};var yi=(e,t,r,n)=>{let{sid:o,hostName:i}=X(n??{}),a=https://${i}/api/code/${e}/${it(t)}/${it(r)};return new Request(a,o?{headers:{Cookie:ie(o)}}:void 0)},bi=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"}}:ce(e),Ei=async(e,t,r,n)=>{let{fetch:o}=X(n??{}),i=yi(e,t,r,n),a=await o(i);return await bi(a)};Ei.toRequest=yi;Ei.fromResponse=bi;var wi=new TextEncoder().encode("0123456789abcdef");function Ri(e){let t=new Uint8Array(e.length*2);for(let r=0;r<t.length;r++){let n=er;tr*2=win>>4,tr*2+1=win&15}return t}var ki="md5: data is invalid type",bt=64,tr=class{#i;#r;#t;#e;#o;#a;#n;#c;constructor(){this.#i=1732584193,this.#r=4023233417,this.#t=2562383102,this.#e=271733878,this.#o=new Uint8Array(bt),this.#a=0,this.#n=0,this.#c=0}#u(t){let r=this.#n;r+=t,r>4294967295&&(this.#c+=1),this.#n=r>>>0}#f(t){let r=this.#i,n=this.#r,o=this.#t,i=this.#e,a=O=>tO|tO+1<<8|tO+2<<16|tO+3<<24,s=(O,_)=>O<<_|O>>>32-_,l=a(0),c=a(4),u=a(8),p=a(12),m=a(16),f=a(20),b=a(24),A=a(28),N=a(32),C=a(36),H=a(40),E=a(44),R=a(48),w=a(52),h=a(56),S=a(60);r=n+s(((o^i)&n^i)+r+l+3614090360,7),i=r+s(((n^o)&r^o)+i+c+3905402710,12),o=i+s(((r^n)&i^n)+o+u+606105819,17),n=o+s(((i^r)&o^r)+n+p+3250441966,22),r=n+s(((o^i)&n^i)+r+m+4118548399,7),i=r+s(((n^o)&r^o)+i+f+1200080426,12),o=i+s(((r^n)&i^n)+o+b+2821735955,17),n=o+s(((i^r)&o^r)+n+A+4249261313,22),r=n+s(((o^i)&n^i)+r+N+1770035416,7),i=r+s(((n^o)&r^o)+i+C+2336552879,12),o=i+s(((r^n)&i^n)+o+H+4294925233,17),n=o+s(((i^r)&o^r)+n+E+2304563134,22),r=n+s(((o^i)&n^i)+r+R+1804603682,7),i=r+s(((n^o)&r^o)+i+w+4254626195,12),o=i+s(((r^n)&i^n)+o+h+2792965006,17),n=o+s(((i^r)&o^r)+n+S+1236535329,22),r=n+s(((n^o)&i^o)+r+c+4129170786,5),i=r+s(((r^n)&o^n)+i+b+3225465664,9),o=i+s(((i^r)&n^r)+o+E+643717713,14),n=o+s(((o^i)&r^i)+n+l+3921069994,20),r=n+s(((n^o)&i^o)+r+f+3593408605,5),i=r+s(((r^n)&o^n)+i+H+38016083,9),o=i+s(((i^r)&n^r)+o+S+3634488961,14),n=o+s(((o^i)&r^i)+n+m+3889429448,20),r=n+s(((n^o)&i^o)+r+C+568446438,5),i=r+s(((r^n)&o^n)+i+h+3275163606,9),o=i+s(((i^r)&n^r)+o+p+4107603335,14),n=o+s(((o^i)&r^i)+n+N+1163531501,20),r=n+s(((n^o)&i^o)+r+w+2850285829,5),i=r+s(((r^n)&o^n)+i+u+4243563512,9),o=i+s(((i^r)&n^r)+o+A+1735328473,14),n=o+s(((o^i)&r^i)+n+R+2368359562,20),r=n+s((n^o^i)+r+f+4294588738,4),i=r+s((r^n^o)+i+N+2272392833,11),o=i+s((i^r^n)+o+E+1839030562,16),n=o+s((o^i^r)+n+h+4259657740,23),r=n+s((n^o^i)+r+c+2763975236,4),i=r+s((r^n^o)+i+m+1272893353,11),o=i+s((i^r^n)+o+A+4139469664,16),n=o+s((o^i^r)+n+H+3200236656,23),r=n+s((n^o^i)+r+w+681279174,4),i=r+s((r^n^o)+i+l+3936430074,11),o=i+s((i^r^n)+o+p+3572445317,16),n=o+s((o^i^r)+n+b+76029189,23),r=n+s((n^o^i)+r+C+3654602809,4),i=r+s((r^n^o)+i+R+3873151461,11),o=i+s((i^r^n)+o+S+530742520,16),n=o+s((o^i^r)+n+u+3299628645,23),r=n+s((o^(n|~i))+r+l+4096336452,6),i=r+s((n^(r|~o))+i+A+1126891415,10),o=i+s((r^(i|~n))+o+h+2878612391,15),n=o+s((i^(o|~r))+n+f+4237533241,21),r=n+s((o^(n|~i))+r+R+1700485571,6),i=r+s((n^(r|~o))+i+p+2399980690,10),o=i+s((r^(i|~n))+o+H+4293915773,15),n=o+s((i^(o|~r))+n+c+2240044497,21),r=n+s((o^(n|~i))+r+N+1873313359,6),i=r+s((n^(r|~o))+i+S+4264355552,10),o=i+s((r^(i|~n))+o+b+2734768916,15),n=o+s((i^(o|~r))+n+w+1309151649,21),r=n+s((o^(n|~i))+r+m+4149444226,6),i=r+s((n^(r|~o))+i+E+3174756917,10),o=i+s((r^(i|~n))+o+u+718787259,15),n=o+s((i^(o|~r))+n+C+3951481745,21),this.#i=this.#i+r>>>0,this.#r=this.#r+n>>>0,this.#t=this.#t+o>>>0,this.#e=this.#e+i>>>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(ki);else throw new TypeError(ki);let n=this.#a,o=bt-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 i=o;for(;i+bt<=r.length;)this.#f(r.slice(i,i+bt)),i+=bt;this.#o.fill(0).set(r.slice(i),0),n=r.length-i}return this.#a=n,this.#u(r.length),this}digest(){let t=bt-this.#a;t<9&&(t+=bt);let r=new Uint8Array(t);r0=128;let n=this.#n<<3,o=this.#c<<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 i=new ArrayBuffer(16),a=new DataView(i);return a.setUint32(0,this.#i,!0),a.setUint32(4,this.#r,!0),a.setUint32(8,this.#t,!0),a.setUint32(12,this.#e,!0),i}toString(t="hex"){let r=this.digest();switch(t){case"hex":return new TextDecoder().decode(Ri(new Uint8Array(r)));case"base64":{let n=new Uint8Array(r),o="";for(let i=0;i<n.length;++i)o+=String.fromCharCode(ni);return btoa(o)}default:throw new Error("md5: invalid format")}}};var vi=async(e,t,r)=>{let n=new tr().update(await e.arrayBuffer()).toString(),o=await Ou(e,t,n,r);if(!o.ok)return o;if("embedUrl"in o.value)return{ok:!0,value:o.value};let i=await Au(o.value.signedUrl,e,r);return i.ok?Nu(t,o.value.fileId,n,r):i},Ou=async(e,t,r,n)=>{let{sid:o,hostName:i,fetch:a,csrf:s}=X(n??{}),l={md5:r,size:e.size,contentType:e.type,name:e.name},c=s??await Ye(),u=new Request(https://${i}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":c,...o?{Cookie:ie(o)}:{}}}),p=await a(u);return p.ok?{ok:!0,value:await p.json()}:ce(p)},Au=async(e,t,r)=>{let{sid:n,fetch:o}=X(r??{}),i=await o(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...n?{Cookie:ie(n)}:{}}});if(!i.ok){if(i.headers.get("Content-Type")?.includes?.("/xml"))return{ok:!1,value:{name:"GCSError",message:await i.text()}};throw new Je(i)}return{ok:!0,value:void 0}},Nu=async(e,t,r,n)=>{let{sid:o,hostName:i,fetch:a,csrf:s}=X(n??{}),l=s??await Ye(),c=new Request(https://${i}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":l,...o?{Cookie:ie(o)}:{}}}),u=await a(c);if(!u.ok){try{if(u.status===404)return{ok:!1,value:{name:"NotFoundError",message:(await u.json()).message}}}catch{throw new Je(u)}throw new Je(u)}return{ok:!0,value:await u.json()}};var Ti=(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 vr="",Li=!1,Tr=new Map,Ci=async(e,t,r,n)=>{let o=Tr.get(e.href);if(o)return o;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let l=await GM_fetch(e);if(!l.ok)return;let c=l.headers.get("content-type")?.split?.(";")?.0??${e}.endsWith(".mp4")?"video/mp4":"video/webm",u=new File(await l.blob(),n||${t},{type:c});if(c==="video/mp4"){let f=await Ti(u);if(f.ok){let b=new URL(await f.text());return Tr.set(e.href,b),b}}let p=await vi(u,r);if(!p.ok)throw Error(p.value.name);let m=new URL(p.value.embedUrl);return Tr.set(e.href,m),m}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Li){if(!vr)return}else{let l=await xi();if(Li=!0,!l.ok){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(vr=l.value||"",!vr){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let i=await GM_fetch(e);if(!i.ok)return;let a=await ei(await i.blob(),{accessToken:vr,refererURL:t,description:n});if(!a.ok)throw Error(a.value.name);let s=new URL(a.value.permalink_url);return Tr.set(e.href,s),s};var Pu={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&#x27;":"'","&#x60;":""},Nn=e=>e.replace(/&(lt|gt|amp|quot|#x27|#x60);/g,t=>Pu[t]);var Ft=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 s={type:"url",indices:a.indices,url:new URL(a.expanded_url)};if(e.card&&e.card?.url===a.url){let{description:l,title:c}=e.card.binding_values,u="STRING";l?.type===u&&(s.description=l.string_value),c?.type===u&&(s.title=c.string_value)}return s}),...e.entities.media?.map?.(a=>({type:"media",indices:a.indices,media:e.mediaDetails?.flatMap?.(s=>s.url===a.url?[{type:s.type,url:new URL(s.video_info?.variants?.sort?.((l,c)=>(c.bitrate??0)-(l.bitrate??0))?.[0].url??s.media_url_https)}]:[])??[]}))??[]].sort((a,s)=>a.indices[0]-s.indices[0]),o=[];{let a=0,s=e.text;for(let{indices:l,...c}of n){let u=[...s].slice(0,l[0]-a).join("");o.push({type:"plain",text:Nn(u)}),o.push(c),s=[...s].slice(l[1]-a).join(""),a=l[1]}s&&o.push({type:"plain",text:Nn(s)})}let i={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&&(i.rootId=e.self_thread.id_str),e.in_reply_to_status_id_str&&(i.replyId=e.in_reply_to_status_id_str),e.parent&&(i.replyTo=Ft(e.parent)),e.quoted_tweet&&(i.quote=Ft(e.quoted_tweet)),i};var Mu=["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"],Lr=(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||Mu.includes(n)?r:o?n===e?${decodeURIComponent(o)}:/${n}/${decodeURIComponent(o)}:/${n}};var Si=(e=_u)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:(?:www\.|mobile\.|m\.)?twitter|x)\.com\/[\w\d_]+\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let n=await(Xo(r)??hi(t.href));if(!n.ok)throw n.value;return e("images"in n.value?{...n.value,id:r}:n.value,t)})():t},_u=async e=>{if("images"in e)return Qe(e);let{quote:t,replyTo:r,...n}=Ft(e);return[...r?[...(await Qe(r)).split(
).map(o=> > ${o}),...r.quote?(await Qe(r.quote)).split(
).map(o=> > ${o}):[]]:[],...(await Qe(n)).split(
).map(o=>> ${o}),...t?(await Qe(t)).split(
).map(o=>> > ${o}):[]].join(
)},Qe=async e=>{let t=new URL(https://twitter.com/${"author"in e?e.author.screenName:e.screenName}/status/${e.id});if("images"in e)return[> @${Mn(e.screenName)} ${t.origin}${t.pathname},...e.description?.split?.(
)?.map?.(o=>> ${Mn(o)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(o=>[${o}])}]:[]].join(
);let r=e.content,n=e.author.screenName;return[@${Mn(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 i=[],a=1;for(;a<o.media.length;a+=2)i.push([${await Pn(o.mediaa-1,t)}] [${await Pn(o.mediaa,t)}]);return a===o.media.length&&i.push([${await Pn(o.mediaa-1,t)}]),
${i.join(`
`)}
}case"url":return${Lr()(o.url)} }}))).join("").split(
)].join(
)},Cr="",Fu=async()=>{if(Cr)return Cr;let e=await kr(scrapbox.Project.name);if(!e.ok)throw new Error(e.value.name);return Cr=e.value.id,Cr},Pn=async(e,t)=>await Ci(e.url,t,await Fu(),"")??e.url,Mn=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Oi=e=>{if(!window.GM_fetch)return;let t=window.GM_fetch;return(async()=>{let r=await t(https://t.co/${e}),n=_t(r);return n?{ok:!1,value:n}:{ok:!0,value:new DOMParser().parseFromString(await r.text(),"text/html").title}})()};var Ai=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=Oi(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 Ni=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 Pi=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 _n=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var Mi=/charset=(^;+)/,_i=e=>{if(!window.GM_fetch)return;let t=window.GM_fetch;return(async()=>{let r=await t(${e}),n=_t(r);if(n)return{ok:!1,value:n};let o=r.headers.get("content-type")?.match?.(Mi)?.1??await Iu(r.clone());return{ok:!0,value:new TextDecoder(o).decode(await r.arrayBuffer())}})()},Iu=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?.(Mi)?.1??"utf-8"};var Fi=(e=Uu)=>async t=>e(await Du(t),t),Uu=(e,t)=>{let r=(Ke(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},Du=async e=>{let t=_i(e);if(!t){let n=await gi(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 Ii=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 Ui=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 Di=(e,...t)=>{if(e instanceof URL)return On(new URL(e),...t);let r=0,n=0,o=0,i=!1,a=e.split(/(https?:\/\/\S+)/g).map(u=>{if(!/^https?:\/\/\S+$/.test(u))return u;r++;try{let p=On(new URL(u),...t);return Ke(p)?(n++,p):(i=!0,p,u)}catch(p){return console.error(p),o++,u}});if(!i)return a.join("");let{render:s,dispose:l}=Jo(),c=()=>s({type:"spinner"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed});return c(),Promise.all(a.map(async u=>{if(Ke(u))return u;try{let p=await u0;return n++,p}catch(p){return console.error(p),o++,u1}finally{c()}})).then(u=>(s({type:"check-circle"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed}),u.join(""))).finally(()=>{setTimeout(l,1e3)})};var $i=async e=>{if("images"in e)return Qe(e);let{quote:t,...r}=Ft(e);return[...t?(await Qe(t)).split(`
).map(n=>> ${n}):[],...(await Qe(r)).split(
).map(n=>> ${n})].join(
)};var $u=[_n,Ai,_n,Pi,Ii,Lr(),Ui,Si($i),Ni,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,i]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${o&&i?L${o}-${i}/:o?L${o}/:""}https://raw.githubusercontent.com/${t}/${r}/${n}#.svg ${e}]},Fi()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=Di(e,...$u);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return Ho(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 ju(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=i=>i.toLowerCase().split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ");return e.replace(t,",").split(",").map(i=>i.replace(r,"").trim()).filter(i=>i.length>1).map(i=>${n(i)}).join(", ")}scrapbox.PopupMenu.addButton({title:"link authors",onClick:ju});var ji=document.createElement("i");function It(e){let t="&"+e+";";ji.innerHTML=t;let r=ji.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}var Bu={};function Hi(e,t){let r=t||Bu,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,o=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return zi(e,n,o)}function zi(e,t,r){if(Hu(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Bi(e.children,t,r)}return Array.isArray(e)?Bi(e,t,r):""}function Bi(e,t,r){let n=[],o=-1;for(;++o<e.length;)n[o]=zi(e[o],t,r);return n.join("")}function Hu(e){return!!(e&&typeof e=="object")}function Sr(e,t){let r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCharCode(r)}var zu=/\\([!-/:-@[-{-~])|&(#(?:\d{1,7}|x\da-f{1,6})|\da-z{1,31});/gi;function Or(e){return e.replace(zu,Wu)}function Wu(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){let n=r.charCodeAt(1),o=n===120||n===88;return Sr(r.slice(o?2:1),o?16:10)}return It(r)||e}function ve(e){return e.replace(/\t\n\r +/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Vu=/[!-\/:-@\[-\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,Ee=st(/[A-Za-z]/),he=st(/[\dA-Za-z]/),Wi=st(/[#-'*+\--9=?A-Z^-~]/);function Et(e){return e!==null&&(e<32||e===127)}var rr=st(/\d/),Vi=st(/[\dA-Fa-f]/),Gi=st(/[!-/:-@[-{-~]/);function I(e){return e!==null&&e<-2}function J(e){return e!==null&&(e<0||e===32)}function V(e){return e===-2||e===-1||e===32}var wt=st(Vu),Be=st(/\s/);function st(e){return t;function t(r){return r!==null&&e.test(String.fromCharCode(r))}}function Ar(e,t,r,n,o,i,a,s,l){let c=l||Number.POSITIVE_INFINITY,u=0;return p;function p(C){return C===60?(e.enter(n),e.enter(o),e.enter(i),e.consume(C),e.exit(i),m):C===null||C===32||C===41||Et(C)?r(C):(e.enter(n),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),A(C))}function m(C){return C===62?(e.enter(i),e.consume(C),e.exit(i),e.exit(o),e.exit(n),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===62?(e.exit("chunkString"),e.exit(s),m(C)):C===null||C===60||I(C)?r(C):(e.consume(C),C===92?b:f)}function b(C){return C===60||C===62||C===92?(e.consume(C),f):f(C)}function A(C){return!u&&(C===null||C===41||J(C))?(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(n),t(C)):u<c&&C===40?(e.consume(C),u++,A):C===41?(e.consume(C),u--,A):C===null||C===32||C===40||Et(C)?r(C):(e.consume(C),C===92?N:A)}function N(C){return C===40||C===41||C===92?(e.consume(C),A):A(C)}}function Nr(e,t,r,n,o,i){let a=this,s=0,l;return c;function c(f){return e.enter(n),e.enter(o),e.consume(f),e.exit(o),e.enter(i),u}function u(f){return s>999||f===null||f===91||f===93&&!l||f===94&&!s&&"_hiddenFootnoteSupport"in a.parser.constructs?r(f):f===93?(e.exit(i),e.enter(o),e.consume(f),e.exit(o),e.exit(n),t):I(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),p(f))}function p(f){return f===null||f===91||f===93||I(f)||s++>999?(e.exit("chunkString"),u(f)):(e.consume(f),l||(l=!V(f)),f===92?m:p)}function m(f){return f===91||f===92||f===93?(e.consume(f),s++,p):p(f)}}function z(e,t,r,n){let o=n?n-1:Number.POSITIVE_INFINITY,i=0;return a;function a(l){return V(l)?(e.enter(r),s(l)):t(l)}function s(l){return V(l)&&i++<o?(e.consume(l),s):(e.exit(r),t(l))}}function Pr(e,t,r,n,o,i){let a;return s;function s(m){return m===34||m===39||m===40?(e.enter(n),e.enter(o),e.consume(m),e.exit(o),a=m===40?41:m,l):r(m)}function l(m){return m===a?(e.enter(o),e.consume(m),e.exit(o),e.exit(n),t):(e.enter(i),c(m))}function c(m){return m===a?(e.exit(i),l(a)):m===null?r(m):I(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),z(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(m))}function u(m){return m===a||m===null||I(m)?(e.exit("chunkString"),c(m)):(e.consume(m),m===92?p:u)}function p(m){return m===a||m===92?(e.consume(m),u):u(m)}}function Rt(e,t){let r;return n;function n(o){return I(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),r=!0,n):V(o)?z(e,n,r?"linePrefix":"lineSuffix")(o):t(o)}}function de(e,t,r,n){let o=e.length,i=0,a;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,r=r>0?r:0,n.length<1e4)a=Array.from(n),a.unshift(t,r),e.splice(...a);else for(r&&e.splice(t,r);i<n.length;)a=n.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function Ce(e,t){return e.length>0?(de(e,e.length,0,t),e):t}function Ut(e){if(e===null||J(e)||Be(e))return 1;if(wt(e))return 2}var qi="address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul",Fn="pre","script","style","textarea";function at(e,t,r){let n=[],o=-1;for(;++o<e.length;){let i=eo.resolveAll;i&&!n.includes(i)&&(t=i(t,r),n.push(i))}return t}function Mr(e){let t={},r=-1,n,o,i,a,s,l,c;for(;++r<e.length;){for(;r in t;)r=tr;if(n=er,r&&n1.type==="chunkFlow"&&er-11.type==="listItemPrefix"&&(l=n1._tokenizer.events,i=0,i<l.length&&li1.type==="lineEndingBlank"&&(i+=2),i<l.length&&li1.type==="content"))for(;++i<l.length&&li1.type!=="content";)li1.type==="chunkText"&&(li1._isInFirstContentOfListItem=!0,i++);if(n0==="enter")n1.contentType&&(Object.assign(t,Gu(e,r)),r=tr,c=!0);else if(n1._container){for(i=r,o=void 0;i--&&(a=ei,a1.type==="lineEnding"||a1.type==="lineEndingBlank");)a0==="enter"&&(o&&(eo1.type="lineEndingBlank"),a1.type="lineEnding",o=i);o&&(n1.end=Object.assign({},eo1.start),s=e.slice(o,r),s.unshift(n),de(e,o,r-o+1,s))}}return!c}function Gu(e,t){let r=et1,n=et2,o=t-1,i=[],a=r._tokenizer||n.parserr.contentType(r.start),s=a.events,l=[],c={},u,p,m=-1,f=r,b=0,A=0,N=A;for(;f;){for(;e++o1!==f;);i.push(o),f._tokenizer||(u=n.sliceStream(f),f.next||u.push(null),p&&a.defineSkip(f.start),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),f._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=f,f=f.next}for(f=r;++m<s.length;)sm0==="exit"&&sm-10==="enter"&&sm1.type===sm-11.type&&sm1.start.line!==sm1.end.line&&(A=m+1,N.push(A),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(a.events=[],f?(f._tokenizer=void 0,f.previous=void 0):N.pop(),m=N.length;m--;){let C=s.slice(Nm,Nm+1),H=i.pop();l.unshift(H,H+C.length-1),de(e,H,2,C)}for(m=-1;++m<l.length;)c[b+lm0]=b+lm1,b+=lm1-lm0-1;return c}var _r={name:"attention",tokenize:Ku,resolveAll:qu};function qu(e,t){let r=-1,n,o,i,a,s,l,c,u;for(;++r<e.length;)if(er0==="enter"&&er1.type==="attentionSequence"&&er1._close){for(n=r;n--;)if(en0==="exit"&&en1.type==="attentionSequence"&&en1._open&&t.sliceSerialize(en1).charCodeAt(0)===t.sliceSerialize(er1).charCodeAt(0)){if((en1._close||er1._open)&&(er1.end.offset-er1.start.offset)%3&&!((en1.end.offset-en1.start.offset+er1.end.offset-er1.start.offset)%3))continue;l=en1.end.offset-en1.start.offset>1&&er1.end.offset-er1.start.offset>1?2:1;let p=Object.assign({},en1.end),m=Object.assign({},er1.start);Ki(p,-l),Ki(m,l),a={type:l>1?"strongSequence":"emphasisSequence",start:p,end:Object.assign({},en1.end)},s={type:l>1?"strongSequence":"emphasisSequence",start:Object.assign({},er1.start),end:m},i={type:l>1?"strongText":"emphasisText",start:Object.assign({},en1.end),end:Object.assign({},er1.start)},o={type:l>1?"strong":"emphasis",start:Object.assign({},a.start),end:Object.assign({},s.end)},en1.end=Object.assign({},a.start),er1.start=Object.assign({},s.end),c=[],en1.end.offset-en1.start.offset&&(c=Ce(c,"enter",en1,t],["exit",en1,t)),c=Ce(c,"enter",o,t],"enter",a,t,"exit",a,t,["enter",i,t),c=Ce(c,at(t.parser.constructs.insideSpan.null,e.slice(n+1,r),t)),c=Ce(c,"exit",i,t],"enter",s,t,"exit",s,t,["exit",o,t),er1.end.offset-er1.start.offset?(u=2,c=Ce(c,"enter",er1,t],["exit",er1,t)):u=0,de(e,n-1,r-n+3,c),r=n+c.length-u-2;break}}for(r=-1;++r<e.length;)er1.type==="attentionSequence"&&(er1.type="data");return e}function Ku(e,t){let r=this.parser.constructs.attentionMarkers.null,n=this.previous,o=Ut(n),i;return a;function a(l){return i=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===i)return e.consume(l),s;let c=e.exit("attentionSequence"),u=Ut(l),p=!u||u===2&&o||r.includes(l),m=!o||o===2&&u||r.includes(n);return c._open=!!(i===42?p:p&&(o||!m)),c._close=!!(i===42?m:m&&(u||!p)),t(l)}}function Ki(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Yi={name:"autolink",tokenize:Ju};function Ju(e,t,r){let n=0;return o;function o(f){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(f){return Ee(f)?(e.consume(f),a):c(f)}function a(f){return f===43||f===45||f===46||he(f)?(n=1,s(f)):c(f)}function s(f){return f===58?(e.consume(f),n=0,l):(f===43||f===45||f===46||he(f))&&n++<32?(e.consume(f),s):(n=0,c(f))}function l(f){return f===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):f===null||f===32||f===60||Et(f)?r(f):(e.consume(f),l)}function c(f){return f===64?(e.consume(f),u):Wi(f)?(e.consume(f),c):r(f)}function u(f){return he(f)?p(f):r(f)}function p(f){return f===46?(e.consume(f),n=0,u):f===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(f),e.exit("autolinkMarker"),e.exit("autolink"),t):m(f)}function m(f){if((f===45||he(f))&&n++<63){let b=f===45?m:p;return e.consume(f),b}return r(f)}}var kt={tokenize:Yu,partial:!0};function Yu(e,t,r){return n;function n(i){return V(i)?z(e,o,"linePrefix")(i):o(i)}function o(i){return i===null||I(i)?t(i):r(i)}}var In={name:"blockQuote",tokenize:Qu,continuation:{tokenize:Xu},exit:Zu};function Qu(e,t,r){let n=this;return o;function o(a){if(a===62){let s=n.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),i}return r(a)}function i(a){return V(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Xu(e,t,r){let n=this;return o;function o(a){return V(a)?z(e,i,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(In,t,r)(a)}}function Zu(e){e.exit("blockQuote")}var Un={name:"characterEscape",tokenize:ep};function ep(e,t,r){return n;function n(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),o}function o(i){return Gi(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(i)}}var Dn={name:"characterReference",tokenize:tp};function tp(e,t,r){let n=this,o=0,i,a;return s;function s(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),l}function l(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),i=31,a=he,u(p))}function c(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=Vi,u):(e.enter("characterReferenceValue"),i=7,a=rr,u(p))}function u(p){if(p===59&&o){let m=e.exit("characterReferenceValue");return a===he&&!It(n.sliceSerialize(m))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&o++<i?(e.consume(p),u):r(p)}}var Ji={tokenize:np,partial:!0},$n={name:"codeFenced",tokenize:rp,concrete:!0};function rp(e,t,r){let n=this,o={tokenize:w,partial:!0},i=0,a=0,s;return l;function l(h){return c(h)}function c(h){let S=n.eventsn.events.length-1;return i=S&&S1.type==="linePrefix"?S2.sliceSerialize(S1,!0).length:0,s=h,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(h)}function u(h){return h===s?(a++,e.consume(h),u):a<3?r(h):(e.exit("codeFencedFenceSequence"),V(h)?z(e,p,"whitespace")(h):p(h))}function p(h){return h===null||I(h)?(e.exit("codeFencedFence"),n.interrupt?t(h):e.check(Ji,A,R)(h)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(h))}function m(h){return h===null||I(h)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(h)):V(h)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),z(e,f,"whitespace")(h)):h===96&&h===s?r(h):(e.consume(h),m)}function f(h){return h===null||I(h)?p(h):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),b(h))}function b(h){return h===null||I(h)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(h)):h===96&&h===s?r(h):(e.consume(h),b)}function A(h){return e.attempt(o,R,N)(h)}function N(h){return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),C}function C(h){return i>0&&V(h)?z(e,H,"linePrefix",i+1)(h):H(h)}function H(h){return h===null||I(h)?e.check(Ji,A,R)(h):(e.enter("codeFlowValue"),E(h))}function E(h){return h===null||I(h)?(e.exit("codeFlowValue"),H(h)):(e.consume(h),E)}function R(h){return e.exit("codeFenced"),t(h)}function w(h,S,O){let _=0;return x;function x(F){return h.enter("lineEnding"),h.consume(F),h.exit("lineEnding"),v}function v(F){return h.enter("codeFencedFence"),V(F)?z(h,T,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):T(F)}function T(F){return F===s?(h.enter("codeFencedFenceSequence"),L(F)):O(F)}function L(F){return F===s?(_++,h.consume(F),L):_>=a?(h.exit("codeFencedFenceSequence"),V(F)?z(h,P,"whitespace")(F):P(F)):O(F)}function P(F){return F===null||I(F)?(h.exit("codeFencedFence"),S(F)):O(F)}}}function np(e,t,r){let n=this;return o;function o(a){return a===null?r(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i)}function i(a){return n.parser.lazyn.now().line?r(a):t(a)}}var Fr={name:"codeIndented",tokenize:ip},op={tokenize:sp,partial:!0};function ip(e,t,r){let n=this;return o;function o(c){return e.enter("codeIndented"),z(e,i,"linePrefix",5)(c)}function i(c){let u=n.eventsn.events.length-1;return u&&u1.type==="linePrefix"&&u2.sliceSerialize(u1,!0).length>=4?a(c):r(c)}function a(c){return c===null?l(c):I(c)?e.attempt(op,a,l)(c):(e.enter("codeFlowValue"),s(c))}function s(c){return c===null||I(c)?(e.exit("codeFlowValue"),a(c)):(e.consume(c),s)}function l(c){return e.exit("codeIndented"),t(c)}}function sp(e,t,r){let n=this;return o;function o(a){return n.parser.lazyn.now().line?r(a):I(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):z(e,i,"linePrefix",5)(a)}function i(a){let s=n.eventsn.events.length-1;return s&&s1.type==="linePrefix"&&s2.sliceSerialize(s1,!0).length>=4?t(a):I(a)?o(a):r(a)}}var Qi={name:"codeText",tokenize:cp,resolve:ap,previous:lp};function ap(e){let t=e.length-4,r=3,n,o;if((er1.type==="lineEnding"||er1.type==="space")&&(et1.type==="lineEnding"||et1.type==="space")){for(n=r;++n<t;)if(en1.type==="codeTextData"){er1.type="codeTextPadding",et1.type="codeTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)o===void 0?n!==t&&en1.type!=="lineEnding"&&(o=n):(n===t||en1.type==="lineEnding")&&(eo1.type="codeTextData",n!==o+2&&(eo1.end=en-11.end,e.splice(o+2,n-o-2),t-=n-o-2,n=o+2),o=void 0);return e}function lp(e){return e!==96||this.eventsthis.events.length-11.type==="characterEscape"}function cp(e,t,r){let n=this,o=0,i,a;return s;function s(m){return e.enter("codeText"),e.enter("codeTextSequence"),l(m)}function l(m){return m===96?(e.consume(m),o++,l):(e.exit("codeTextSequence"),c(m))}function c(m){return m===null?r(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),c):m===96?(a=e.enter("codeTextSequence"),i=0,p(m)):I(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(m))}function u(m){return m===null||m===32||m===96||I(m)?(e.exit("codeTextData"),c(m)):(e.consume(m),u)}function p(m){return m===96?(e.consume(m),i++,p):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(a.type="codeTextData",u(m))}}var Xi={tokenize:fp,resolve:pp},up={tokenize:mp,partial:!0};function pp(e){return Mr(e),e}function fp(e,t){let r;return n;function n(s){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),o(s)}function o(s){return s===null?i(s):I(s)?e.check(up,a,i)(s):(e.consume(s),o)}function i(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function a(s){return e.consume(s),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,o}}function mp(e,t,r){let n=this;return o;function o(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),z(e,i,"linePrefix")}function i(a){if(a===null||I(a))return r(a);let s=n.eventsn.events.length-1;return!n.parser.constructs.disable.null.includes("codeIndented")&&s&&s1.type==="linePrefix"&&s2.sliceSerialize(s1,!0).length>=4?t(a):e.interrupt(n.parser.constructs.flow,r,t)(a)}}var Zi={name:"definition",tokenize:gp},dp={tokenize:hp,partial:!0};function gp(e,t,r){let n=this,o;return i;function i(f){return e.enter("definition"),a(f)}function a(f){return Nr.call(n,e,s,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function s(f){return o=ve(n.sliceSerialize(n.eventsn.events.length-11).slice(1,-1)),f===58?(e.enter("definitionMarker"),e.consume(f),e.exit("definitionMarker"),l):r(f)}function l(f){return J(f)?Rt(e,c)(f):c(f)}function c(f){return Ar(e,u,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function u(f){return e.attempt(dp,p,p)(f)}function p(f){return V(f)?z(e,m,"whitespace")(f):m(f)}function m(f){return f===null||I(f)?(e.exit("definition"),n.parser.defined.push(o),t(f)):r(f)}}function hp(e,t,r){return n;function n(s){return J(s)?Rt(e,o)(s):r(s)}function o(s){return Pr(e,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return V(s)?z(e,a,"whitespace")(s):a(s)}function a(s){return s===null||I(s)?t(s):r(s)}}var es={name:"hardBreakEscape",tokenize:xp};function xp(e,t,r){return n;function n(i){return e.enter("hardBreakEscape"),e.consume(i),o}function o(i){return I(i)?(e.exit("hardBreakEscape"),t(i)):r(i)}}var ts={name:"headingAtx",tokenize:bp,resolve:yp};function yp(e,t){let r=e.length-2,n=3,o,i;return en1.type==="whitespace"&&(n+=2),r-2>n&&er1.type==="whitespace"&&(r-=2),er1.type==="atxHeadingSequence"&&(n===r-1||r-4>n&&er-21.type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(o={type:"atxHeadingText",start:en1.start,end:er1.end},i={type:"chunkText",start:en1.start,end:er1.end,contentType:"text"},de(e,n,r-n+1,"enter",o,t],"enter",i,t,"exit",i,t,["exit",o,t)),e}function bp(e,t,r){let n=0;return o;function o(u){return e.enter("atxHeading"),i(u)}function i(u){return e.enter("atxHeadingSequence"),a(u)}function a(u){return u===35&&n++<6?(e.consume(u),a):u===null||J(u)?(e.exit("atxHeadingSequence"),s(u)):r(u)}function s(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||I(u)?(e.exit("atxHeading"),t(u)):V(u)?z(e,s,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),s(u))}function c(u){return u===null||u===35||J(u)?(e.exit("atxHeadingText"),s(u)):(e.consume(u),c)}}var rs={name:"htmlFlow",tokenize:kp,resolveTo:Rp,concrete:!0},Ep={tokenize:Tp,partial:!0},wp={tokenize:vp,partial:!0};function Rp(e){let t=e.length;for(;t--&&!(et0==="enter"&&et1.type==="htmlFlow"););return t>1&&et-21.type==="linePrefix"&&(et1.start=et-21.start,et+11.start=et-21.start,e.splice(t-2,2)),e}function kp(e,t,r){let n=this,o,i,a,s,l;return c;function c(g){return u(g)}function u(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),p}function p(g){return g===33?(e.consume(g),m):g===47?(e.consume(g),i=!0,A):g===63?(e.consume(g),o=3,n.interrupt?t:d):Ee(g)?(e.consume(g),a=String.fromCharCode(g),N):r(g)}function m(g){return g===45?(e.consume(g),o=2,f):g===91?(e.consume(g),o=5,s=0,b):Ee(g)?(e.consume(g),o=4,n.interrupt?t:d):r(g)}function f(g){return g===45?(e.consume(g),n.interrupt?t:d):r(g)}function b(g){let se="CDATA[";return g===se.charCodeAt(s++)?(e.consume(g),s===se.length?n.interrupt?t:T:b):r(g)}function A(g){return Ee(g)?(e.consume(g),a=String.fromCharCode(g),N):r(g)}function N(g){if(g===null||g===47||g===62||J(g)){let se=g===47,re=a.toLowerCase();return!se&&!i&&Fn.includes(re)?(o=1,n.interrupt?t(g):T(g)):qi.includes(a.toLowerCase())?(o=6,se?(e.consume(g),C):n.interrupt?t(g):T(g)):(o=7,n.interrupt&&!n.parser.lazyn.now().line?r(g):i?H(g):E(g))}return g===45||he(g)?(e.consume(g),a+=String.fromCharCode(g),N):r(g)}function C(g){return g===62?(e.consume(g),n.interrupt?t:T):r(g)}function H(g){return V(g)?(e.consume(g),H):x(g)}function E(g){return g===47?(e.consume(g),x):g===58||g===95||Ee(g)?(e.consume(g),R):V(g)?(e.consume(g),E):x(g)}function R(g){return g===45||g===46||g===58||g===95||he(g)?(e.consume(g),R):w(g)}function w(g){return g===61?(e.consume(g),h):V(g)?(e.consume(g),w):E(g)}function h(g){return g===null||g===60||g===61||g===62||g===96?r(g):g===34||g===39?(e.consume(g),l=g,S):V(g)?(e.consume(g),h):O(g)}function S(g){return g===l?(e.consume(g),l=null,_):g===null||I(g)?r(g):(e.consume(g),S)}function O(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||J(g)?w(g):(e.consume(g),O)}function _(g){return g===47||g===62||V(g)?E(g):r(g)}function x(g){return g===62?(e.consume(g),v):r(g)}function v(g){return g===null||I(g)?T(g):V(g)?(e.consume(g),v):r(g)}function T(g){return g===45&&o===2?(e.consume(g),D):g===60&&o===1?(e.consume(g),$):g===62&&o===4?(e.consume(g),G):g===63&&o===3?(e.consume(g),d):g===93&&o===5?(e.consume(g),j):I(g)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(Ep,K,L)(g)):g===null||I(g)?(e.exit("htmlFlowData"),L(g)):(e.consume(g),T)}function L(g){return e.check(wp,P,K)(g)}function P(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),F}function F(g){return g===null||I(g)?L(g):(e.enter("htmlFlowData"),T(g))}function D(g){return g===45?(e.consume(g),d):T(g)}function $(g){return g===47?(e.consume(g),a="",W):T(g)}function W(g){if(g===62){let se=a.toLowerCase();return Fn.includes(se)?(e.consume(g),G):T(g)}return Ee(g)&&a.length<8?(e.consume(g),a+=String.fromCharCode(g),W):T(g)}function j(g){return g===93?(e.consume(g),d):T(g)}function d(g){return g===62?(e.consume(g),G):g===45&&o===2?(e.consume(g),d):T(g)}function G(g){return g===null||I(g)?(e.exit("htmlFlowData"),K(g)):(e.consume(g),G)}function K(g){return e.exit("htmlFlow"),t(g)}}function vp(e,t,r){let n=this;return o;function o(a){return I(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):r(a)}function i(a){return n.parser.lazyn.now().line?r(a):t(a)}}function Tp(e,t,r){return n;function n(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(kt,t,r)}}var ns={name:"htmlText",tokenize:Lp};function Lp(e,t,r){let n=this,o,i,a;return s;function s(d){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(d),l}function l(d){return d===33?(e.consume(d),c):d===47?(e.consume(d),w):d===63?(e.consume(d),E):Ee(d)?(e.consume(d),O):r(d)}function c(d){return d===45?(e.consume(d),u):d===91?(e.consume(d),i=0,b):Ee(d)?(e.consume(d),H):r(d)}function u(d){return d===45?(e.consume(d),f):r(d)}function p(d){return d===null?r(d):d===45?(e.consume(d),m):I(d)?(a=p,$(d)):(e.consume(d),p)}function m(d){return d===45?(e.consume(d),f):p(d)}function f(d){return d===62?D(d):d===45?m(d):p(d)}function b(d){let G="CDATA[";return d===G.charCodeAt(i++)?(e.consume(d),i===G.length?A:b):r(d)}function A(d){return d===null?r(d):d===93?(e.consume(d),N):I(d)?(a=A,$(d)):(e.consume(d),A)}function N(d){return d===93?(e.consume(d),C):A(d)}function C(d){return d===62?D(d):d===93?(e.consume(d),C):A(d)}function H(d){return d===null||d===62?D(d):I(d)?(a=H,$(d)):(e.consume(d),H)}function E(d){return d===null?r(d):d===63?(e.consume(d),R):I(d)?(a=E,$(d)):(e.consume(d),E)}function R(d){return d===62?D(d):E(d)}function w(d){return Ee(d)?(e.consume(d),h):r(d)}function h(d){return d===45||he(d)?(e.consume(d),h):S(d)}function S(d){return I(d)?(a=S,$(d)):V(d)?(e.consume(d),S):D(d)}function O(d){return d===45||he(d)?(e.consume(d),O):d===47||d===62||J(d)?_(d):r(d)}function _(d){return d===47?(e.consume(d),D):d===58||d===95||Ee(d)?(e.consume(d),x):I(d)?(a=_,$(d)):V(d)?(e.consume(d),_):D(d)}function x(d){return d===45||d===46||d===58||d===95||he(d)?(e.consume(d),x):v(d)}function v(d){return d===61?(e.consume(d),T):I(d)?(a=v,$(d)):V(d)?(e.consume(d),v):_(d)}function T(d){return d===null||d===60||d===61||d===62||d===96?r(d):d===34||d===39?(e.consume(d),o=d,L):I(d)?(a=T,$(d)):V(d)?(e.consume(d),T):(e.consume(d),P)}function L(d){return d===o?(e.consume(d),o=void 0,F):d===null?r(d):I(d)?(a=L,$(d)):(e.consume(d),L)}function P(d){return d===null||d===34||d===39||d===60||d===61||d===96?r(d):d===47||d===62||J(d)?_(d):(e.consume(d),P)}function F(d){return d===47||d===62||J(d)?_(d):r(d)}function D(d){return d===62?(e.consume(d),e.exit("htmlTextData"),e.exit("htmlText"),t):r(d)}function $(d){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),W}function W(d){return V(d)?z(e,j,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):j(d)}function j(d){return e.enter("htmlTextData"),a(d)}}var Ir={name:"labelEnd",tokenize:Pp,resolveTo:Np,resolveAll:Ap},Cp={tokenize:Mp},Sp={tokenize:_p},Op={tokenize:Fp};function Ap(e){let t=-1;for(;++t<e.length;){let r=et1;(r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd")&&(e.splice(t+1,r.type==="labelImage"?4:2),r.type="data",t++)}return e}function Np(e,t){let r=e.length,n=0,o,i,a,s;for(;r--;)if(o=er1,i){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;er0==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(a){if(er0==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(i=r,o.type!=="labelLink")){n=2;break}}else o.type==="labelEnd"&&(a=r);let l={type:ei1.type==="labelLink"?"link":"image",start:Object.assign({},ei1.start),end:Object.assign({},ee.length-11.end)},c={type:"label",start:Object.assign({},ei1.start),end:Object.assign({},ea1.end)},u={type:"labelText",start:Object.assign({},ei+n+21.end),end:Object.assign({},ea-21.start)};return s="enter",l,t],["enter",c,t,s=Ce(s,e.slice(i+1,i+n+3)),s=Ce(s,"enter",u,t),s=Ce(s,at(t.parser.constructs.insideSpan.null,e.slice(i+n+4,a-3),t)),s=Ce(s,"exit",u,t],ea-2,ea-1,["exit",c,t),s=Ce(s,e.slice(a+1)),s=Ce(s,"exit",l,t),de(e,i,e.length,s),e}function Pp(e,t,r){let n=this,o=n.events.length,i,a;for(;o--;)if((n.eventso1.type==="labelImage"||n.eventso1.type==="labelLink")&&!n.eventso1._balanced){i=n.eventso1;break}return s;function s(m){return i?i._inactive?p(m):(a=n.parser.defined.includes(ve(n.sliceSerialize({start:i.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),l):r(m)}function l(m){return m===40?e.attempt(Cp,u,a?u:p)(m):m===91?e.attempt(Sp,u,a?c:p)(m):a?u(m):p(m)}function c(m){return e.attempt(Op,u,p)(m)}function u(m){return t(m)}function p(m){return i._balanced=!0,r(m)}}function Mp(e,t,r){return n;function n(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),o}function o(p){return J(p)?Rt(e,i)(p):i(p)}function i(p){return p===41?u(p):Ar(e,a,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return J(p)?Rt(e,l)(p):u(p)}function s(p){return r(p)}function l(p){return p===34||p===39||p===40?Pr(e,c,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):u(p)}function c(p){return J(p)?Rt(e,u)(p):u(p)}function u(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):r(p)}}function _p(e,t,r){let n=this;return o;function o(s){return Nr.call(n,e,i,a,"reference","referenceMarker","referenceString")(s)}function i(s){return n.parser.defined.includes(ve(n.sliceSerialize(n.eventsn.events.length-11).slice(1,-1)))?t(s):r(s)}function a(s){return r(s)}}function Fp(e,t,r){return n;function n(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),o}function o(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):r(i)}}var os={name:"labelStartImage",tokenize:Ip,resolveAll:Ir.resolveAll};function Ip(e,t,r){let n=this;return o;function o(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),i}function i(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),a):r(s)}function a(s){return s===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(s):t(s)}}var is={name:"labelStartLink",tokenize:Up,resolveAll:Ir.resolveAll};function Up(e,t,r){let n=this;return o;function o(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):t(a)}}var Ur={name:"lineEnding",tokenize:Dp};function Dp(e,t){return r;function r(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),z(e,t,"linePrefix")}}var nr={name:"thematicBreak",tokenize:$p};function $p(e,t,r){let n=0,o;return i;function i(c){return e.enter("thematicBreak"),a(c)}function a(c){return o=c,s(c)}function s(c){return c===o?(e.enter("thematicBreakSequence"),l(c)):n>=3&&(c===null||I(c))?(e.exit("thematicBreak"),t(c)):r(c)}function l(c){return c===o?(e.consume(c),n++,l):(e.exit("thematicBreakSequence"),V(c)?z(e,s,"whitespace")(c):s(c))}}var Se={name:"list",tokenize:Hp,continuation:{tokenize:zp},exit:Vp},jp={tokenize:Gp,partial:!0},Bp={tokenize:Wp,partial:!0};function Hp(e,t,r){let n=this,o=n.eventsn.events.length-1,i=o&&o1.type==="linePrefix"?o2.sliceSerialize(o1,!0).length:0,a=0;return s;function s(f){let b=n.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(b==="listUnordered"?!n.containerState.marker||f===n.containerState.marker:rr(f)){if(n.containerState.type||(n.containerState.type=b,e.enter(b,{_container:!0})),b==="listUnordered")return e.enter("listItemPrefix"),f===42||f===45?e.check(nr,r,c)(f):c(f);if(!n.interrupt||f===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(f)}return r(f)}function l(f){return rr(f)&&++a<10?(e.consume(f),l):(!n.interrupt||a<2)&&(n.containerState.marker?f===n.containerState.marker:f===41||f===46)?(e.exit("listItemValue"),c(f)):r(f)}function c(f){return e.enter("listItemMarker"),e.consume(f),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||f,e.check(kt,n.interrupt?r:u,e.attempt(jp,m,p))}function u(f){return n.containerState.initialBlankLine=!0,i++,m(f)}function p(f){return V(f)?(e.enter("listItemPrefixWhitespace"),e.consume(f),e.exit("listItemPrefixWhitespace"),m):r(f)}function m(f){return n.containerState.size=i+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(f)}}function zp(e,t,r){let n=this;return n.containerState._closeFlow=void 0,e.check(kt,o,i);function o(s){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,z(e,t,"listItemIndent",n.containerState.size+1)(s)}function i(s){return n.containerState.furtherBlankLines||!V(s)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,a(s)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(Bp,t,a)(s))}function a(s){return n.containerState._closeFlow=!0,n.interrupt=void 0,z(e,e.attempt(Se,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Wp(e,t,r){let n=this;return z(e,o,"listItemIndent",n.containerState.size+1);function o(i){let a=n.eventsn.events.length-1;return a&&a1.type==="listItemIndent"&&a2.sliceSerialize(a1,!0).length===n.containerState.size?t(i):r(i)}}function Vp(e){e.exit(this.containerState.type)}function Gp(e,t,r){let n=this;return z(e,o,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(i){let a=n.eventsn.events.length-1;return!V(i)&&a&&a1.type==="listItemPrefixWhitespace"?t(i):r(i)}}var jn={name:"setextUnderline",tokenize:Kp,resolveTo:qp};function qp(e,t){let r=e.length,n,o,i;for(;r--;)if(er0==="enter"){if(er1.type==="content"){n=r;break}er1.type==="paragraph"&&(o=r)}else er1.type==="content"&&e.splice(r,1),!i&&er1.type==="definition"&&(i=r);let a={type:"setextHeading",start:Object.assign({},eo1.start),end:Object.assign({},ee.length-11.end)};return eo1.type="setextHeadingText",i?(e.splice(o,0,"enter",a,t),e.splice(i+1,0,["exit",en1,t]),en1.end=Object.assign({},ei1.end)):en1=a,e.push("exit",a,t),e}function Kp(e,t,r){let n=this,o;return i;function i(c){let u=n.events.length,p;for(;u--;)if(n.eventsu1.type!=="lineEnding"&&n.eventsu1.type!=="linePrefix"&&n.eventsu1.type!=="content"){p=n.eventsu1.type==="paragraph";break}return!n.parser.lazyn.now().line&&(n.interrupt||p)?(e.enter("setextHeadingLine"),o=c,a(c)):r(c)}function a(c){return e.enter("setextHeadingLineSequence"),s(c)}function s(c){return c===o?(e.consume(c),s):(e.exit("setextHeadingLineSequence"),V(c)?z(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||I(c)?(e.exit("setextHeadingLine"),t(c)):r(c)}}var ss={}.hasOwnProperty;function Dr(e){let t={},r=-1;for(;++r<e.length;)Jp(t,er);return t}function Jp(e,t){let r;for(r in t){let n=(ss.call(e,r)?er:void 0)||(er={}),o=tr,i;if(o)for(i in o){ss.call(n,i)||(ni=[]);let a=oi;Yp(ni,Array.isArray(a)?a:a?a:[])}}}function Yp(e,t){let r=-1,n=[];for(;++r<t.length;)(tr.add==="after"?e:n).push(tr);de(e,0,0,n)}var Qp=Object.defineProperty,Xp=(e,t)=>{for(var r in t)Qp(e,r,{get:tr,enumerable:!0})},Zp={tokenize:ef};function ef(e){let t=e.attempt(this.parser.constructs.contentInitial,n,o),r;return t;function n(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),z(e,t,"linePrefix")}function o(s){return e.enter("paragraph"),i(s)}function i(s){let l=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,a(s)}function a(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return I(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),a)}}var tf={tokenize:rf},as={tokenize:nf};function rf(e){let t=this,r=[],n=0,o,i,a;return s;function s(E){if(n<r.length){let R=rn;return t.containerState=R1,e.attempt(R0.continuation,l,c)(E)}return c(E)}function l(E){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&H();let R=t.events.length,w=R,h;for(;w--;)if(t.eventsw0==="exit"&&t.eventsw1.type==="chunkFlow"){h=t.eventsw1.end;break}C(n);let S=R;for(;S<t.events.length;)t.eventsS1.end=Object.assign({},h),S++;return de(t.events,w+1,0,t.events.slice(R)),t.events.length=S,c(E)}return s(E)}function c(E){if(n===r.length){if(!o)return m(E);if(o.currentConstruct&&o.currentConstruct.concrete)return b(E);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(as,u,p)(E)}function u(E){return o&&H(),C(n),m(E)}function p(E){return t.parser.lazyt.now().line=n!==r.length,a=t.now().offset,b(E)}function m(E){return t.containerState={},e.attempt(as,f,b)(E)}function f(E){return n++,r.push(t.currentConstruct,t.containerState),m(E)}function b(E){if(E===null){o&&H(),C(0),e.consume(E);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{contentType:"flow",previous:i,_tokenizer:o}),A(E)}function A(E){if(E===null){N(e.exit("chunkFlow"),!0),C(0),e.consume(E);return}return I(E)?(e.consume(E),N(e.exit("chunkFlow")),n=0,t.interrupt=void 0,s):(e.consume(E),A)}function N(E,R){let w=t.sliceStream(E);if(R&&w.push(null),E.previous=i,i&&(i.next=E),i=E,o.defineSkip(E.start),o.write(w),t.parser.lazyE.start.line){let h=o.events.length;for(;h--;)if(o.eventsh1.start.offset<a&&(!o.eventsh1.end||o.eventsh1.end.offset>a))return;let S=t.events.length,O=S,_,x;for(;O--;)if(t.eventsO0==="exit"&&t.eventsO1.type==="chunkFlow"){if(_){x=t.eventsO1.end;break}_=!0}for(C(n),h=S;h<t.events.length;)t.eventsh1.end=Object.assign({},x),h++;de(t.events,O+1,0,t.events.slice(S)),t.events.length=h}}function C(E){let R=r.length;for(;R-- >E;){let w=rR;t.containerState=w1,w0.exit.call(t,e)}r.length=E}function H(){o.write(null),i=void 0,o=void 0,t.containerState._closeFlow=void 0}}function nf(e,t,r){return z(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var of={tokenize:sf};function sf(e){let t=this,r=e.attempt(kt,n,e.attempt(this.parser.constructs.flowInitial,o,z(e,e.attempt(this.parser.constructs.flow,o,e.attempt(Xi,o)),"linePrefix")));return r;function n(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function o(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var af={resolveAll:cs()},lf=ls("string"),cf=ls("text");function ls(e){return{tokenize:t,resolveAll:cs(e==="text"?uf:void 0)};function t(r){let n=this,o=this.parser.constructse,i=r.attempt(o,a,s);return a;function a(u){return c(u)?i(u):s(u)}function s(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),l}function l(u){return c(u)?(r.exit("data"),i(u)):(r.consume(u),l)}function c(u){if(u===null)return!0;let p=ou,m=-1;if(p)for(;++m<p.length;){let f=pm;if(!f.previous||f.previous.call(n,n.previous))return!0}return!1}}}function cs(e){return t;function t(r,n){let o=-1,i;for(;++o<=r.length;)i===void 0?ro&&ro1.type==="data"&&(i=o,o++):(!ro||ro1.type!=="data")&&(o!==i+2&&(ri1.end=ro-11.end,r.splice(i+2,o-i-2),o=i+2),i=void 0);return e?e(r,n):r}}function uf(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||er1.type==="lineEnding")&&er-11.type==="data"){let n=er-11,o=t.sliceStream(n),i=o.length,a=-1,s=0,l;for(;i--;){let c=oi;if(typeof c=="string"){for(a=c.length;c.charCodeAt(a-1)===32;)s++,a--;if(a)break;a=-1}else if(c===-2)l=!0,s++;else if(c!==-1){i++;break}}if(s){let c={type:r===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{line:n.end.line,column:n.end.column-s,offset:n.end.offset-s,_index:n.start._index+i,_bufferIndex:i?a:n.start._bufferIndex+a},end:Object.assign({},n.end)};n.end=Object.assign({},c.start),n.start.offset===n.end.offset?Object.assign(n,c):(e.splice(r,0,"enter",c,t,"exit",c,t),r+=2)}r++}return e}function pf(e,t,r){let n=Object.assign(r?Object.assign({},r):{line:1,column:1,offset:0},{_index:0,_bufferIndex:-1}),o={},i=[],a=[],s=[],l=!0,c={consume:R,enter:w,exit:h,attempt:_(S),check:_(O),interrupt:_(O,{interrupt:!0})},u={previous:null,code:null,containerState:{},events:[],parser:e,sliceStream:A,sliceSerialize:b,now:N,defineSkip:C,write:f},p=t.tokenize.call(u,c),m;return t.resolveAll&&i.push(t),u;function f(L){return a=Ce(a,L),H(),aa.length-1!==null?[]:(x(t,0),u.events=at(i,u.events,u),u.events)}function b(L,P){return mf(A(L),P)}function A(L){return ff(a,L)}function N(){let{line:L,column:P,offset:F,_index:D,_bufferIndex:$}=n;return{line:L,column:P,offset:F,_index:D,_bufferIndex:$}}function C(L){oL.line=L.column,T()}function H(){let L;for(;n._index<a.length;){let P=an._index;if(typeof P=="string")for(L=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===L&&n._bufferIndex<P.length;)E(P.charCodeAt(n._bufferIndex));else E(P)}}function E(L){l=void 0,m=L,p=p(L)}function R(L){I(L)?(n.line++,n.column=1,n.offset+=L===-3?2:1,T()):L!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===an._index.length&&(n._bufferIndex=-1,n._index++)),u.previous=L,l=!0}function w(L,P){let F=P||{};return F.type=L,F.start=N(),u.events.push("enter",F,u),s.push(F),F}function h(L){let P=s.pop();return P.end=N(),u.events.push("exit",P,u),P}function S(L,P){x(L,P.from)}function O(L,P){P.restore()}function _(L,P){return F;function F(D,$,W){let j,d,G,K;return Array.isArray(D)?se(D):"tokenize"in D?se(D):g(D);function g(te){return Le;function Le(be){let ke=be!==null&&tebe,$e=be!==null&&te.null,Qt=[...Array.isArray(ke)?ke:ke?ke:[],...Array.isArray($e)?$e:$e?$e:[]];return se(Qt)(be)}}function se(te){return j=te,d=0,te.length===0?W:re(ted)}function re(te){return Le;function Le(be){return K=v(),G=te,te.partial||(u.currentConstruct=te),te.name&&u.parser.constructs.disable.null.includes(te.name)?ee(be):te.tokenize.call(P?Object.assign(Object.create(u),P):u,c,U,ee)(be)}}function U(te){return l=!0,L(G,K),$}function ee(te){return l=!0,K.restore(),++d<j.length?re(jd):W}}}function x(L,P){L.resolveAll&&!i.includes(L)&&i.push(L),L.resolve&&de(u.events,P,u.events.length-P,L.resolve(u.events.slice(P),u)),L.resolveTo&&(u.events=L.resolveTo(u.events,u))}function v(){let L=N(),P=u.previous,F=u.currentConstruct,D=u.events.length,$=Array.from(s);return{restore:W,from:D};function W(){n=L,u.previous=P,u.currentConstruct=F,u.events.length=D,s=$,T()}}function T(){n.line in o&&n.column<2&&(n.column=on.line,n.offset+=on.line-1)}}function ff(e,t){let r=t.start._index,n=t.start._bufferIndex,o=t.end._index,i=t.end._bufferIndex,a;if(r===o)a=[er.slice(n,i)];else{if(a=e.slice(r,o),n>-1){let s=a0;typeof s=="string"?a0=s.slice(n):a.shift()}i>0&&a.push(eo.slice(0,i))}return a}function mf(e,t){let r=-1,n=[],o;for(;++r<e.length;){let i=er,a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
;break}case-3:{a=\r
;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&o)continue;a=" ";break}default:a=String.fromCharCode(i)}o=i===-2,n.push(a)}return n.join("")}var us={};Xp(us,{attentionMarkers:()=>wf,contentInitial:()=>gf,disable:()=>Rf,document:()=>df,flow:()=>xf,flowInitial:()=>hf,insideSpan:()=>Ef,string:()=>yf,text:()=>bf});var df={42:Se,43:Se,45:Se,48:Se,49:Se,50:Se,51:Se,52:Se,53:Se,54:Se,55:Se,56:Se,57:Se,62:In},gf={91:Zi},hf={[-2]:Fr,[-1]:Fr,32:Fr},xf={35:ts,42:nr,45:[jn,nr],60:rs,61:jn,95:nr,96:$n,126:$n},yf={38:Dn,92:Un},bf={[-5]:Ur,[-4]:Ur,[-3]:Ur,33:os,38:Dn,42:_r,60:[Yi,ns],91:is,92:[es,Un],93:Ir,95:_r,96:Qi},Ef={null:[_r,af]},wf={null:[42,95]},Rf={null:[]};function ps(e){let t=Dr([us,...(e||{}).extensions||[]]),r={defined:[],lazy:{},constructs:t,content:n(Zp),document:n(tf),flow:n(of),string:n(lf),text:n(cf)};return r;function n(o){return i;function i(a){return pf(r,o,a)}}}function fs(e){for(;!Mr(e););return e}var ms=/[\0\t\n\r]/g;function ds(){let e=1,t="",r=!0,n;return o;function o(i,a,s){let l=[],c,u,p,m,f;for(i=t+i.toString(a),p=0,t="",r&&(i.charCodeAt(0)===65279&&p++,r=void 0);p<i.length;){if(ms.lastIndex=p,c=ms.exec(i),m=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(m),!c){t=i.slice(p);break}if(f===10&&p===m&&n)l.push(-3),n=void 0;else switch(n&&(l.push(-5),n=void 0),p<m&&(l.push(i.slice(p,m)),e+=m-p),f){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:n=!0,e=1}p=m+1}return s&&(n&&l.push(-5),t&&l.push(t),l.push(null)),l}}function or(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?gs(e.position):"start"in e||"end"in e?gs(e):"line"in e||"column"in e?Bn(e):""}function Bn(e){return hs(e&&e.line)+":"+hs(e&&e.column)}function gs(e){return Bn(e&&e.start)+"-"+Bn(e&&e.end)}function hs(e){return e&&typeof e=="number"?e:1}var ys={}.hasOwnProperty,bs=function(e,t,r){return typeof t!="string"&&(r=t,t=void 0),kf(r)(fs(ps(r).document().write(ds()(e,t,!0))))};function kf(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Uo),autolinkProtocol:v,autolinkEmail:v,atxHeading:s(_o),blockQuote:s(ke),characterEscape:v,characterReference:v,codeFenced:s($e),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:s($e,l),codeText:s(Qt,l),codeTextData:v,data:v,codeFlowValue:v,definition:s(kn),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:s(vn),hardBreakEscape:s(Fo),hardBreakTrailing:s(Fo),htmlFlow:s(Io,l),htmlFlowData:v,htmlText:s(Io,l),htmlTextData:v,image:s(Kc),label:l,link:s(Uo),listItem:s(Jc),listItemValue:b,listOrdered:s(Do,f),listUnordered:s(Do),paragraph:s(Yc),reference:re,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:s(_o),strong:s(Qc),thematicBreak:s(Zc)},exit:{atxHeading:u(),atxHeadingSequence:S,autolink:u(),autolinkEmail:be,autolinkProtocol:Le,blockQuote:u(),characterEscapeValue:T,characterReferenceMarkerHexadecimal:ee,characterReferenceMarkerNumeric:ee,characterReferenceValue:te,codeFenced:u(H),codeFencedFence:C,codeFencedFenceInfo:A,codeFencedFenceMeta:N,codeFlowValue:T,codeIndented:u(E),codeText:u($),codeTextData:T,data:T,definition:u(),definitionDestinationString:h,definitionLabelString:R,definitionTitleString:w,emphasis:u(),hardBreakEscape:u(P),hardBreakTrailing:u(P),htmlFlow:u(F),htmlFlowData:T,htmlText:u(D),htmlTextData:T,image:u(j),label:G,labelText:d,lineEnding:L,link:u(W),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:U,resourceDestinationString:K,resourceTitleString:g,resource:se,setextHeading:u(x),setextHeadingLineSequence:_,setextHeadingText:O,strong:u(),thematicBreak:u()}};Es(t,(e||{}).mdastExtensions||[]);let r={};return n;function n(k){let M={type:"root",children:[]},q={stack:[M],tokenStack:[],config:t,enter:c,exit:p,buffer:l,resume:m,setData:i,getData:a},oe=[],ae=-1;for(;++ae<k.length;)if(k[ae][1].type==="listOrdered"||k[ae][1].type==="listUnordered")if(k[ae][0]==="enter")oe.push(ae);else{let je=oe.pop();ae=o(k,je,ae)}for(ae=-1;++ae<k.length;){let je=t[k[ae][0]];ys.call(je,k[ae][1].type)&&je[k[ae][1].type].call(Object.assign({sliceSerialize:k[ae][2].sliceSerialize},q),k[ae][1])}if(q.tokenStack.length>0){let je=q.tokenStack[q.tokenStack.length-1];(je[1]||xs).call(q,void 0,je[0])}for(M.position={start:lt(k.length>0?k[0][1].start:{line:1,column:1,offset:0}),end:lt(k.length>0?k[k.length-2][1].end:{line:1,column:1,offset:0})},ae=-1;++ae<t.transforms.length;)M=t.transforms[ae](M)||M;return M}function o(k,M,q){let oe=M-1,ae=-1,je=!1,yt,Ge,Xt,Zt;for(;++oe<=q;){let me=k[oe];if(me[1].type==="listUnordered"||me[1].type==="listOrdered"||me[1].type==="blockQuote"?(me[0]==="enter"?ae++:ae--,Zt=void 0):me[1].type==="lineEndingBlank"?me[0]==="enter"&&(yt&&!Zt&&!ae&&!Xt&&(Xt=oe),Zt=void 0):me[1].type==="linePrefix"||me[1].type==="listItemValue"||me[1].type==="listItemMarker"||me[1].type==="listItemPrefix"||me[1].type==="listItemPrefixWhitespace"||(Zt=void 0),!ae&&me[0]==="enter"&&me[1].type==="listItemPrefix"||ae===-1&&me[0]==="exit"&&(me[1].type==="listUnordered"||me[1].type==="listOrdered")){if(yt){let Tn=oe;for(Ge=void 0;Tn--;){let qe=k[Tn];if(qe[1].type==="lineEnding"||qe[1].type==="lineEndingBlank"){if(qe[0]==="exit")continue;Ge&&(k[Ge][1].type="lineEndingBlank",je=!0),qe[1].type="lineEnding",Ge=Tn}else if(!(qe[1].type==="linePrefix"||qe[1].type==="blockQuotePrefix"||qe[1].type==="blockQuotePrefixWhitespace"||qe[1].type==="blockQuoteMarker"||qe[1].type==="listItemIndent"))break}Xt&&(!Ge||Xt<Ge)&&(yt._spread=!0),yt.end=Object.assign({},Ge?k[Ge][1].start:me[1].end),k.splice(Ge||oe,0,["exit",yt,me[2]]),oe++,q++}me[1].type==="listItemPrefix"&&(yt={type:"listItem",_spread:!1,start:Object.assign({},me[1].start),end:void 0},k.splice(oe,0,["enter",yt,me[2]]),oe++,q++,Xt=void 0,Zt=!0)}}return k[M][1]._spread=je,q}function i(k,M){r[k]=M}function a(k){return r[k]}function s(k,M){return q;function q(oe){c.call(this,k(oe),oe),M&&M.call(this,oe)}}function l(){this.stack.push({type:"fragment",children:[]})}function c(k,M,q){return this.stack[this.stack.length-1].children.push(k),this.stack.push(k),this.tokenStack.push([M,q]),k.position={start:lt(M.start)},k}function u(k){return M;function M(q){k&&k.call(this,q),p.call(this,q)}}function p(k,M){let q=this.stack.pop(),oe=this.tokenStack.pop();if(oe)oe[0].type!==k.type&&(M?M.call(this,k,oe[0]):(oe[1]||xs).call(this,k,oe[0]));else throw new Error("Cannot close "+k.type+" ("+or({start:k.start,end:k.end})+"): it’s not open");return q.position.end=lt(k.end),q}function m(){return Hi(this.stack.pop())}function f(){i("expectingFirstListItemValue",!0)}function b(k){if(a("expectingFirstListItemValue")){let M=this.stack[this.stack.length-2];M.start=Number.parseInt(this.sliceSerialize(k),10),i("expectingFirstListItemValue")}}function A(){let k=this.resume(),M=this.stack[this.stack.length-1];M.lang=k}function N(){let k=this.resume(),M=this.stack[this.stack.length-1];M.meta=k}function C(){a("flowCodeInside")||(this.buffer(),i("flowCodeInside",!0))}function H(){let k=this.resume(),M=this.stack[this.stack.length-1];M.value=k.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),i("flowCodeInside")}function E(){let k=this.resume(),M=this.stack[this.stack.length-1];M.value=k.replace(/(\r?\n|\r)$/g,"")}function R(k){let M=this.resume(),q=this.stack[this.stack.length-1];q.label=M,q.identifier=ve(this.sliceSerialize(k)).toLowerCase()}function w(){let k=this.resume(),M=this.stack[this.stack.length-1];M.title=k}function h(){let k=this.resume(),M=this.stack[this.stack.length-1];M.url=k}function S(k){let M=this.stack[this.stack.length-1];if(!M.depth){let q=this.sliceSerialize(k).length;M.depth=q}}function O(){i("setextHeadingSlurpLineEnding",!0)}function _(k){let M=this.stack[this.stack.length-1];M.depth=this.sliceSerialize(k).charCodeAt(0)===61?1:2}function x(){i("setextHeadingSlurpLineEnding")}function v(k){let M=this.stack[this.stack.length-1],q=M.children[M.children.length-1];(!q||q.type!=="text")&&(q=Xc(),q.position={start:lt(k.start)},M.children.push(q)),this.stack.push(q)}function T(k){let M=this.stack.pop();M.value+=this.sliceSerialize(k),M.position.end=lt(k.end)}function L(k){let M=this.stack[this.stack.length-1];if(a("atHardBreak")){let q=M.children[M.children.length-1];q.position.end=lt(k.end),i("atHardBreak");return}!a("setextHeadingSlurpLineEnding")&&t.canContainEols.includes(M.type)&&(v.call(this,k),T.call(this,k))}function P(){i("atHardBreak",!0)}function F(){let k=this.resume(),M=this.stack[this.stack.length-1];M.value=k}function D(){let k=this.resume(),M=this.stack[this.stack.length-1];M.value=k}function $(){let k=this.resume(),M=this.stack[this.stack.length-1];M.value=k}function W(){let k=this.stack[this.stack.length-1];if(a("inReference")){let M=a("referenceType")||"shortcut";k.type+="Reference",k.referenceType=M,delete k.url,delete k.title}else delete k.identifier,delete k.label;i("referenceType")}function j(){let k=this.stack[this.stack.length-1];if(a("inReference")){let M=a("referenceType")||"shortcut";k.type+="Reference",k.referenceType=M,delete k.url,delete k.title}else delete k.identifier,delete k.label;i("referenceType")}function d(k){let M=this.sliceSerialize(k),q=this.stack[this.stack.length-2];q.label=Or(M),q.identifier=ve(M).toLowerCase()}function G(){let k=this.stack[this.stack.length-1],M=this.resume(),q=this.stack[this.stack.length-1];if(i("inReference",!0),q.type==="link"){let oe=k.children;q.children=oe}else q.alt=M}function K(){let k=this.resume(),M=this.stack[this.stack.length-1];M.url=k}function g(){let k=this.resume(),M=this.stack[this.stack.length-1];M.title=k}function se(){i("inReference")}function re(){i("referenceType","collapsed")}function U(k){let M=this.resume(),q=this.stack[this.stack.length-1];q.label=M,q.identifier=ve(this.sliceSerialize(k)).toLowerCase(),i("referenceType","full")}function ee(k){i("characterReferenceType",k.type)}function te(k){let M=this.sliceSerialize(k),q=a("characterReferenceType"),oe;q?(oe=Sr(M,q==="characterReferenceMarkerNumeric"?10:16),i("characterReferenceType")):oe=It(M);let ae=this.stack.pop();ae.value+=oe,ae.position.end=lt(k.end)}function Le(k){T.call(this,k);let M=this.stack[this.stack.length-1];M.url=this.sliceSerialize(k)}function be(k){T.call(this,k);let M=this.stack[this.stack.length-1];M.url="mailto:"+this.sliceSerialize(k)}function ke(){return{type:"blockquote",children:[]}}function $e(){return{type:"code",lang:null,meta:null,value:""}}function Qt(){return{type:"inlineCode",value:""}}function kn(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function vn(){return{type:"emphasis",children:[]}}function _o(){return{type:"heading",depth:void 0,children:[]}}function Fo(){return{type:"break"}}function Io(){return{type:"html",value:""}}function Kc(){return{type:"image",title:null,url:"",alt:null}}function Uo(){return{type:"link",title:null,url:"",children:[]}}function Do(k){return{type:"list",ordered:k.type==="listOrdered",start:null,spread:k._spread,children:[]}}function Jc(k){return{type:"listItem",spread:k._spread,checked:null,children:[]}}function Yc(){return{type:"paragraph",children:[]}}function Qc(){return{type:"strong",children:[]}}function Xc(){return{type:"text",value:""}}function Zc(){return{type:"thematicBreak"}}}function lt(e){return{line:e.line,column:e.column,offset:e.offset}}function Es(e,t){let r=-1;for(;++r<t.length;){let n=t[r];Array.isArray(n)?Es(e,n):vf(e,n)}}function vf(e,t){let r;for(r in t)if(ys.call(t,r)){if(r==="canContainEols"){let n=t[r];n&&e[r].push(...n)}else if(r==="transforms"){let n=t[r];n&&e[r].push(...n)}else if(r==="enter"||r==="exit"){let n=t[r];n&&Object.assign(e[r],n)}}}function xs(e,t){throw e?new Error("Cannot close "+e.type+" ("+or({start:e.start,end:e.end})+"): a different token ("+t.type+", "+or({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token ("+t.type+", "+or({start:t.start,end:t.end})+") is still open")}function Hn(e,t){let r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,o=r.indexOf(t);for(;o!==-1;)n++,o=r.indexOf(t,o+t.length);return n}function zn(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ir=function(e){if(e==null)return Sf;if(typeof e=="string")return Cf(e);if(typeof e=="object")return Array.isArray(e)?Tf(e):Lf(e);if(typeof e=="function")return $r(e);throw new Error("Expected function, string, or object as test")};function Tf(e){let t=[],r=-1;for(;++r<e.length;)t[r]=ir(e[r]);return $r(n);function n(...o){let i=-1;for(;++i<t.length;)if(t[i].call(this,...o))return!0;return!1}}function Lf(e){return $r(t);function t(r){let n;for(n in e)if(r[n]!==e[n])return!1;return!0}}function Cf(e){return $r(t);function t(r){return r&&r.type===e}}function $r(e){return t;function t(r,...n){return!!(r&&typeof r=="object"&&"type"in r&&e.call(this,r,...n))}}function Sf(){return!0}var Of=!0,ws=!1,Af="skip",Rs=function(e,t,r,n){typeof t=="function"&&typeof r!="function"&&(n=r,r=t,t=null);let o=ir(t),i=n?-1:1;a(e,void 0,[])();function a(s,l,c){let u=s&&typeof s=="object"?s:{};if(typeof u.type=="string"){let m=typeof u.tagName=="string"?u.tagName:typeof u.name=="string"?u.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(s.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=[],f,b,A;if((!t||o(s,l,c[c.length-1]||null))&&(m=Nf(r(s,c)),m[0]===ws))return m;if(s.children&&m[0]!==Af)for(b=(n?s.children.length:-1)+i,A=c.concat(s);b>-1&&b<s.children.length;){if(f=a(s.children[b],b,A)(),f[0]===ws)return f;b=typeof f[1]=="number"?f[1]:b+i}return m}}};function Nf(e){return Array.isArray(e)?e:typeof e=="number"?[Of,e]:[e]}var Pf={}.hasOwnProperty,Ts=function(e,t,r,n){let o,i;typeof t=="string"||t instanceof RegExp?(i=[[t,r]],o=n):(i=t,o=r),o||(o={});let a=ir(o.ignore||[]),s=Mf(i),l=-1;for(;++l<s.length;)Rs(e,"text",c);return e;function c(p,m){let f=-1,b;for(;++f<m.length;){let A=m[f];if(a(A,b?b.children.indexOf(A):void 0,b))return;b=A}if(b)return u(p,m)}function u(p,m){let f=m[m.length-1],b=s[l][0],A=s[l][1],N=0,C=f.children.indexOf(p),H=!1,E=[];b.lastIndex=0;let R=b.exec(p.value);for(;R;){let w=R.index,h={index:R.index,input:R.input,stack:[...m,p]},S=A(...R,h);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S!==!1&&(N!==w&&E.push({type:"text",value:p.value.slice(N,w)}),Array.isArray(S)?E.push(...S):S&&E.push(S),N=w+R[0].length,H=!0),!b.global)break;R=b.exec(p.value)}return H?(N<p.value.length&&E.push({type:"text",value:p.value.slice(N)}),f.children.splice(C,1,...E)):E=[p],C+E.length}};function Mf(e){let t=[];if(typeof e!="object")throw new TypeError("Expected array or object as schema");if(Array.isArray(e)){let r=-1;for(;++r<e.length;)t.push([ks(e[r][0]),vs(e[r][1])])}else{let r;for(r in e)Pf.call(e,r)&&t.push([ks(r),vs(e[r])])}return t}function ks(e){return typeof e=="string"?new RegExp(zn(e),"g"):e}function vs(e){return typeof e=="function"?e:()=>e}var Ls={transforms:[$f],enter:{literalAutolink:_f,literalAutolinkEmail:Wn,literalAutolinkHttp:Wn,literalAutolinkWww:Wn},exit:{literalAutolink:Df,literalAutolinkEmail:Uf,literalAutolinkHttp:Ff,literalAutolinkWww:If}};function _f(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Wn(e){this.config.enter.autolinkProtocol.call(this,e)}function Ff(e){this.config.exit.autolinkProtocol.call(this,e)}function If(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.url="http://"+this.sliceSerialize(e)}function Uf(e){this.config.exit.autolinkEmail.call(this,e)}function Df(e){this.exit(e)}function $f(e){Ts(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,jf],[/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/g,Bf]],{ignore:["link","linkReference"]})}function jf(e,t,r,n,o){let i="";if(!Cs(o)||(/^w/i.test(t)&&(r=t+r,t="",i="http://"),!Hf(r)))return!1;let a=zf(r+n);if(!a[0])return!1;let s={type:"link",title:null,url:i+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[s,{type:"text",value:a[1]}]:s}function Bf(e,t,r,n){return!Cs(n,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}function Hf(e){let t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function zf(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],n=r.indexOf(")"),o=Hn(e,"("),i=Hn(e,")");for(;n!==-1&&o>i;)e+=r.slice(0,n+1),r=r.slice(n+1),n=r.indexOf(")"),i++;return[e,r]}function Cs(e,t){let r=e.input.charCodeAt(e.index-1);return(e.index===0||Be(r)||wt(r))&&(!t||r!==47)}function Ss(e){return e.label||!e.identifier?e.label||"":Or(e.identifier)}function Wf(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function Vf(e,t){return Os(e,t.inConstruct,!0)&&!Os(e,t.notInConstruct,!1)}function Os(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let n=-1;for(;++n<t.length;)if(e.includes(t[n]))return!0;return!1}function Ns(e,t,r){let n=(r.before||"")+(t||"")+(r.after||""),o=[],i=[],a={},s=-1;for(;++s<e.unsafe.length;){let u=e.unsafe[s];if(!Vf(e.stack,u))continue;let p=Wf(u),m;for(;m=p.exec(n);){let f="before"in u||!!u.atBreak,b="after"in u,A=m.index+(f?m[1].length:0);o.includes(A)?(a[A].before&&!f&&(a[A].before=!1),a[A].after&&!b&&(a[A].after=!1)):(o.push(A),a[A]={before:f,after:b})}}o.sort(Gf);let l=r.before?r.before.length:0,c=n.length-(r.after?r.after.length:0);for(s=-1;++s<o.length;){let u=o[s];u<l||u>=c||u+1<c&&o[s+1]===u+1&&a[u].after&&!a[u+1].before&&!a[u+1].after||o[s-1]===u-1&&a[u].before&&!a[u-1].before&&!a[u-1].after||(l!==u&&i.push(As(n.slice(l,u),"\\")),l=u,/[!-/:-@[-{-~]/.test(n.charAt(u))&&(!r.encode||!r.encode.includes(n.charAt(u)))?i.push("\\"):(i.push("&#x"+n.charCodeAt(u).toString(16).toUpperCase()+";"),l++))}return i.push(As(n.slice(l,c),r.after)),i.join("")}function Gf(e,t){return e-t}function As(e,t){let r=/\\(?=[!-/:-@[-{-~])/g,n=[],o=[],i=e+t,a=-1,s=0,l;for(;l=r.exec(i);)n.push(l.index);for(;++a<n.length;)s!==n[a]&&o.push(e.slice(s,n[a])),o.push("\\"),s=n[a];return o.push(e.slice(s)),o.join("")}function sr(e){let t=e||{},r=t.now||{},n=t.lineShift||0,o=r.line||1,i=r.column||1;return{move:l,current:a,shift:s};function a(){return{now:{line:o,column:i},lineShift:n}}function s(c){n+=c}function l(c){let u=c||"",p=u.split(/\r?\n|\r/g),m=p[p.length-1];return o+=p.length-1,i=p.length===1?i+m.length:1+m.length+n,u}}tm.peek=rm;function Ps(){return{enter:{gfmFootnoteDefinition:qf,gfmFootnoteDefinitionLabelString:Kf,gfmFootnoteCall:Qf,gfmFootnoteCallString:Xf},exit:{gfmFootnoteDefinition:Yf,gfmFootnoteDefinitionLabelString:Jf,gfmFootnoteCall:em,gfmFootnoteCallString:Zf}}}function qf(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Kf(){this.buffer()}function Jf(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=ve(this.sliceSerialize(e)).toLowerCase()}function Yf(e){this.exit(e)}function Qf(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Xf(){this.buffer()}function Zf(e){let t=this.resume(),r=this.stack[this.stack.length-1];r.label=t,r.identifier=ve(this.sliceSerialize(e)).toLowerCase()}function em(e){this.exit(e)}function tm(e,t,r,n){let o=sr(n),i=o.move("[^"),a=r.enter("footnoteReference"),s=r.enter("reference");return i+=o.move(Ns(r,Ss(e),{...o.current(),before:i,after:"]"})),s(),a(),i+=o.move("]"),i}function rm(){return"["}function Vn(e,t,r){let n=t.indexStack,o=e.children||[],i=[],a=-1,s=r.before;n.push(-1);let l=t.createTracker(r);for(;++a<o.length;){let c=o[a],u;if(n[n.length-1]=a,a+1<o.length){let p=t.handle.handlers[o[a+1].type];p&&p.peek&&(p=p.peek),u=p?p(o[a+1],e,t,{before:"",after:"",...l.current()}).charAt(0):""}else u=r.after;i.length>0&&(s==="\r"||s===
)&&c.type==="html"&&(i[i.length-1]=i[i.length-1].replace(/(\r?\n|\r)$/," "),s=" ",l=t.createTracker(r),l.move(i.join(""))),i.push(l.move(t.handle(c,e,t,{...l.current(),before:s,after:u}))),s=i[i.length-1].slice(-1)}return n.pop(),i.join("")}im.peek=sm;var Ms={canContainEols:["delete"],enter:{strikethrough:nm},exit:{strikethrough:om}};function nm(e){this.enter({type:"delete",children:[]},e)}function om(e){this.exit(e)}function im(e,t,r,n){let o=sr(n),i=r.enter("strikethrough"),a=o.move("~~");return a+=Vn(e,r,{...o.current(),before:a,after:"~"}),a+=o.move("~~"),i(),a}function sm(){return"~"}function am(e){if(!e._compiled){let t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}_s.peek=lm;function _s(e,t,r){let n=e.value||"",o="",i=-1;for(;new RegExp("(^|[^])"+o+"([^]|$)").test(n);)o+="";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^|$/.test(n))&&(n=" "+n+" ");++i<r.unsafe.length;){let a=r.unsafe[i],s=am(a),l;if(a.atBreak)for(;l=s.exec(n);){let c=l.index;n.charCodeAt(c)===10&&n.charCodeAt(c-1)===13&&c--,n=n.slice(0,c)+" "+n.slice(l.index+1)}}return o+n+o}function lm(){return""}var Is={enter:{table:cm,tableData:Fs,tableHeader:Fs,tableRow:pm},exit:{codeText:fm,table:um,tableData:Gn,tableHeader:Gn,tableRow:Gn}};function cm(e){let t=e._align;this.enter({type:"table",align:t.map(r=>r==="none"?null:r),children:[]},e),this.setData("inTable",!0)}function um(e){this.exit(e),this.setData("inTable")}function pm(e){this.enter({type:"tableRow",children:[]},e)}function Gn(e){this.exit(e)}function Fs(e){this.enter({type:"tableCell",children:[]},e)}function fm(e){let t=this.resume();this.getData("inTable")&&(t=t.replace(/\\(\\|)/g,mm));let r=this.stackthis.stack.length-1;r.value=t,this.exit(e)}function mm(e,t){return t==="|"?t:e}var Ds={exit:{taskListCheckValueChecked:Us,taskListCheckValueUnchecked:Us,paragraph:dm}};function Us(e){let t=this.stackthis.stack.length-2;t.checked=e.type==="taskListCheckValueChecked"}function dm(e){let t=this.stackthis.stack.length-2;if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){let r=this.stackthis.stack.length-1,n=r.children0;if(n&&n.type==="text"){let o=t.children,i=-1,a;for(;++i<o.length;){let s=oi;if(s.type==="paragraph"){a=s;break}}a===r&&(n.value=n.value.slice(1),n.value.length===0?r.children.shift():r.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,r.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function $s(){returnLs,Ps(),Ms,Is,Ds}var hm={tokenize:wm,partial:!0},js={tokenize:Rm,partial:!0},Bs={tokenize:km,partial:!0},Hs={tokenize:vm,partial:!0},xm={tokenize:Tm,partial:!0},zs={tokenize:bm,previous:Gs},Ws={tokenize:Em,previous:qs},Xe={tokenize:ym,previous:Ks},He={},Vs={text:He},vt=48;for(;vt<123;)Hevt=Xe,vt++,vt===58?vt=65:vt===91&&(vt=97);He43=Xe;He45=Xe;He46=Xe;He95=Xe;He72=Xe,Ws;He104=Xe,Ws;He87=Xe,zs;He119=Xe,zs;function ym(e,t,r){let n=this,o,i;return a;function a(p){return!qn(p)||!Ks.call(n,n.previous)||Kn(n.events)?r(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(p))}function s(p){return qn(p)?(e.consume(p),s):p===64?(e.consume(p),l):r(p)}function l(p){return p===46?e.check(xm,u,c)(p):p===45||p===95||he(p)?(i=!0,e.consume(p),l):u(p)}function c(p){return e.consume(p),o=!0,l}function u(p){return i&&o&&Ee(n.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):r(p)}}function bm(e,t,r){let n=this;return o;function o(a){return a!==87&&a!==119||!Gs.call(n,n.previous)||Kn(n.events)?r(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(hm,e.attempt(js,e.attempt(Bs,i),r),r)(a))}function i(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function Em(e,t,r){let n=this,o="",i=!1;return a;function a(p){return(p===72||p===104)&&qs.call(n,n.previous)&&!Kn(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),e.consume(p),s):r(p)}function s(p){if(Ee(p)&&o.length<5)return o+=String.fromCodePoint(p),e.consume(p),s;if(p===58){let m=o.toLowerCase();if(m==="http"||m==="https")return e.consume(p),l}return r(p)}function l(p){return p===47?(e.consume(p),i?c:(i=!0,l)):r(p)}function c(p){return p===null||Et(p)||J(p)||Be(p)||wt(p)?r(p):e.attempt(js,e.attempt(Bs,u),r)(p)}function u(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function wm(e,t,r){let n=0;return o;function o(a){return(a===87||a===119)&&n<3?(n++,e.consume(a),o):a===46&&n===3?(e.consume(a),i):r(a)}function i(a){return a===null?r(a):t(a)}}function Rm(e,t,r){let n,o,i;return a;function a(c){return c===46||c===95?e.check(Hs,l,s)(c):c===null||J(c)||Be(c)||c!==45&&wt(c)?l(c):(i=!0,e.consume(c),a)}function s(c){return c===95?n=!0:(o=n,n=void 0),e.consume(c),a}function l(c){return o||n||!i?r(c):t(c)}}function km(e,t){let r=0,n=0;return o;function o(a){return a===40?(r++,e.consume(a),o):a===41&&n<r?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Hs,t,i)(a):a===null||J(a)||Be(a)?t(a):(e.consume(a),o)}function i(a){return a===41&&n++,e.consume(a),o}}function vm(e,t,r){return n;function n(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),n):s===38?(e.consume(s),i):s===93?(e.consume(s),o):s===60||s===null||J(s)||Be(s)?t(s):r(s)}function o(s){return s===null||s===40||s===91||J(s)||Be(s)?t(s):n(s)}function i(s){return Ee(s)?a(s):r(s)}function a(s){return s===59?(e.consume(s),n):Ee(s)?(e.consume(s),a):r(s)}}function Tm(e,t,r){return n;function n(i){return e.consume(i),o}function o(i){return he(i)?r(i):t(i)}}function Gs(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function qs(e){return!Ee(e)}function Ks(e){return!(e===47||qn(e))}function qn(e){return e===43||e===45||e===46||e===95||he(e)}function Kn(e){let t=e.length,r=!1;for(;t--;){let n=et1;if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){r=!0;break}if(n._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(ee.length-11._gfmAutolinkLiteralWalkedInto=!0),r}var Lm={tokenize:Mm,partial:!0};function Js(){return{document:{91:{tokenize:Am,continuation:{tokenize:Nm},exit:Pm}},text:{91:{tokenize:Om},93:{add:"after",tokenize:Cm,resolveTo:Sm}}}}function Cm(e,t,r){let n=this,o=n.events.length,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),a;for(;o--;){let l=n.eventso1;if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!a||!a._balanced)return r(l);let c=ve(n.sliceSerialize({start:a.end,end:n.now()}));return c.codePointAt(0)!==94||!i.includes(c.slice(1))?r(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Sm(e,t){let r=e.length,n;for(;r--;)if(er1.type==="labelImage"&&er0==="enter"){n=er1;break}er+11.type="data",er+31.type="gfmFootnoteCallLabelMarker";let o={type:"gfmFootnoteCall",start:Object.assign({},er+31.start),end:Object.assign({},ee.length-11.end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},er+31.end),end:Object.assign({},er+31.end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},ee.length-11.start)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[er+1,er+2,"enter",o,t,er+3,er+4,"enter",i,t,"exit",i,t,"enter",a,t,"enter",s,t,"exit",s,t,"exit",a,t,ee.length-2,ee.length-1,"exit",o,t];return e.splice(r,e.length-r+1,...l),e}function Om(e,t,r){let n=this,o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),i=0,a;return s;function s(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),l}function l(p){return p!==94?r(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(p){if(i>999||p===93&&!a||p===null||p===91||J(p))return r(p);if(p===93){e.exit("chunkString");let m=e.exit("gfmFootnoteCallString");return o.includes(ve(n.sliceSerialize(m)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(p)}return J(p)||(a=!0),i++,e.consume(p),p===92?u:c}function u(p){return p===91||p===92||p===93?(e.consume(p),i++,c):c(p)}}function Am(e,t,r){let n=this,o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]),i,a=0,s;return l;function l(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):r(b)}function u(b){if(a>999||b===93&&!s||b===null||b===91||J(b))return r(b);if(b===93){e.exit("chunkString");let A=e.exit("gfmFootnoteDefinitionLabelString");return i=ve(n.sliceSerialize(A)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),m}return J(b)||(s=!0),a++,e.consume(b),b===92?p:u}function p(b){return b===91||b===92||b===93?(e.consume(b),a++,u):u(b)}function m(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),o.includes(i)||o.push(i),z(e,f,"gfmFootnoteDefinitionWhitespace")):r(b)}function f(b){return t(b)}}function Nm(e,t,r){return e.check(kt,t,e.attempt(Lm,t,r))}function Pm(e){e.exit("gfmFootnoteDefinition")}function Mm(e,t,r){let n=this;return z(e,o,"gfmFootnoteDefinitionIndent",5);function o(i){let a=n.eventsn.events.length-1;return a&&a1.type==="gfmFootnoteDefinitionIndent"&&a2.sliceSerialize(a1,!0).length===4?t(i):r(i)}}var wA={}.hasOwnProperty;function Ys(e){let t=(e||{}).singleTilde,r={tokenize:o,resolveAll:n};return t==null&&(t=!0),{text:{126:r},insideSpan:{null:r},attentionMarkers:{null:126}};function n(i,a){let s=-1;for(;++s<i.length;)if(is0==="enter"&&is1.type==="strikethroughSequenceTemporary"&&is1._close){let l=s;for(;l--;)if(il0==="exit"&&il1.type==="strikethroughSequenceTemporary"&&il1._open&&is1.end.offset-is1.start.offset===il1.end.offset-il1.start.offset){is1.type="strikethroughSequence",il1.type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},il1.start),end:Object.assign({},is1.end)},u={type:"strikethroughText",start:Object.assign({},il1.end),end:Object.assign({},is1.start)},p="enter",c,a],["enter",il1,a],["exit",il1,a],["enter",u,a,m=a.parser.constructs.insideSpan.null;m&&de(p,p.length,0,at(m,i.slice(l+1,s),a)),de(p,p.length,0,"exit",u,a],["enter",is1,a],["exit",is1,a],["exit",c,a),de(i,l-1,s-l+3,p),s=l+p.length-2;break}}for(s=-1;++s<i.length;)is1.type==="strikethroughSequenceTemporary"&&(is1.type="data");return i}function o(i,a,s){let l=this.previous,c=this.events,u=0;return p;function p(f){return l===126&&cc.length-11.type!=="characterEscape"?s(f):(i.enter("strikethroughSequenceTemporary"),m(f))}function m(f){let b=Ut(l);if(f===126)return u>1?s(f):(i.consume(f),u++,m);if(u<2&&!t)return s(f);let A=i.exit("strikethroughSequenceTemporary"),N=Ut(f);return A._open=!N||N===2&&!!b,A._close=!b||b===2&&!!N,a(f)}}}var _m=class{constructor(){this.map=[]}add(e,t,r){Fm(this,e,t,r)}consume(e){if(this.map.sort((o,i)=>o0-i0),this.map.length===0)return;let t=this.map.length,r=[];for(;t>0;)t-=1,r.push(e.slice(this.mapt0+this.mapt1)),r.push(this.mapt2),e.length=this.mapt0;r.push(...e),e.length=0;let n=r.pop();for(;n;)e.push(...n),n=r.pop();this.map.length=0}};function Fm(e,t,r,n){let o=0;if(!(r===0&&n.length===0)){for(;o<e.map.length;){if(e.mapo0===t){e.mapo1+=r,e.mapo2.push(...n);return}o+=1}e.map.push(t,r,n)}}function Im(e,t){let r=!1,n=[];for(;t<e.length;){let o=et;if(r){if(o0==="enter")o1.type==="tableContent"&&n.push(et+11.type==="tableDelimiterMarker"?"left":"none");else if(o1.type==="tableContent"){if(et-11.type==="tableDelimiterMarker"){let i=n.length-1;ni=ni==="left"?"center":"right"}}else if(o1.type==="tableDelimiterRow")break}else o0==="enter"&&o1.type==="tableDelimiterRow"&&(r=!0);t+=1}return n}var Xs={flow:{null:{tokenize:Um,resolveAll:Dm}}};function Um(e,t,r){let n=this,o=0,i=0,a;return s;function s(x){let v=n.events.length-1;for(;v>-1;){let P=n.eventsv1.type;if(P==="lineEnding"||P==="linePrefix")v--;else break}let T=v>-1?n.eventsv1.type:null,L=T==="tableHead"||T==="tableRow"?h:l;return L===h&&n.parser.lazyn.now().line?r(x):L(x)}function l(x){return e.enter("tableHead"),e.enter("tableRow"),c(x)}function c(x){return x===124||(a=!0,i+=1),u(x)}function u(x){return x===null?r(x):I(x)?i>1?(i=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),f):r(x):V(x)?z(e,u,"whitespace")(x):(i+=1,a&&(a=!1,o+=1),x===124?(e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),a=!0,u):(e.enter("data"),p(x)))}function p(x){return x===null||x===124||J(x)?(e.exit("data"),u(x)):(e.consume(x),x===92?m:p)}function m(x){return x===92||x===124?(e.consume(x),p):p(x)}function f(x){return n.interrupt=!1,n.parser.lazyn.now().line?r(x):(e.enter("tableDelimiterRow"),a=!1,V(x)?z(e,b,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):b(x))}function b(x){return x===45||x===58?N(x):x===124?(a=!0,e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),A):w(x)}function A(x){return V(x)?z(e,N,"whitespace")(x):N(x)}function N(x){return x===58?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(x),e.exit("tableDelimiterMarker"),C):x===45?(i+=1,C(x)):x===null||I(x)?R(x):w(x)}function C(x){return x===45?(e.enter("tableDelimiterFiller"),H(x)):w(x)}function H(x){return x===45?(e.consume(x),H):x===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(x),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(x))}function E(x){return V(x)?z(e,R,"whitespace")(x):R(x)}function R(x){return x===124?b(x):x===null||I(x)?!a||o!==i?w(x):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(x)):w(x)}function w(x){return r(x)}function h(x){return e.enter("tableRow"),S(x)}function S(x){return x===124?(e.enter("tableCellDivider"),e.consume(x),e.exit("tableCellDivider"),S):x===null||I(x)?(e.exit("tableRow"),t(x)):V(x)?z(e,S,"whitespace")(x):(e.enter("data"),O(x))}function O(x){return x===null||x===124||J(x)?(e.exit("data"),S(x)):(e.consume(x),x===92?_:O)}function _(x){return x===92||x===124?(e.consume(x),O):O(x)}}function Dm(e,t){let r=-1,n=!0,o=0,i=0,0,0,0,a=0,0,0,0,s=!1,l=0,c,u,p,m=new _m;for(;++r<e.length;){let f=er,b=f1;f0==="enter"?b.type==="tableHead"?(s=!1,l!==0&&(Qs(m,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(r,0,"enter",c,t)):b.type==="tableRow"||b.type==="tableDelimiterRow"?(n=!0,p=void 0,i=0,0,0,0,a=0,r+1,0,0,s&&(s=!1,u={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},m.add(r,0,"enter",u,t)),o=b.type==="tableDelimiterRow"?2:u?3:1):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(n=!1,a2===0&&(i1!==0&&(a0=a1,p=jr(m,t,i,o,void 0,p),i=0,0,0,0),a2=r)):b.type==="tableCellDivider"&&(n?n=!1:(i1!==0&&(a0=a1,p=jr(m,t,i,o,void 0,p)),i=a,a=[i1,r,0,0])):b.type==="tableHead"?(s=!0,l=r):b.type==="tableRow"||b.type==="tableDelimiterRow"?(l=r,i1!==0?(a0=a1,p=jr(m,t,i,o,r,p)):a1!==0&&(p=jr(m,t,a,o,r,p)),o=0):o&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(a3=r)}for(l!==0&&Qs(m,t,l,c,u),m.consume(t.events),r=-1;++r<t.events.length;){let f=t.eventsr;f0==="enter"&&f1.type==="table"&&(f1._align=Im(t.events,r))}return e}function jr(e,t,r,n,o,i){let a=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",s="tableContent";r0!==0&&(i.end=Object.assign({},Dt(t.events,r0)),e.add(r0,0,"exit",i,t));let l=Dt(t.events,r1);if(i={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(r1,0,"enter",i,t),r2!==0){let c=Dt(t.events,r2),u=Dt(t.events,r3),p={type:s,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(r2,0,"enter",p,t),n!==2){let m=t.events[r2],f=t.events[r3];if(m1.end=Object.assign({},f1.end),m1.type="chunkText",m1.contentType="text",r3>r2+1){let b=r2+1,A=r3-r2-1;e.add(b,A,[])}}e.add(r3+1,0,"exit",p,t)}return o!==void 0&&(i.end=Object.assign({},Dt(t.events,o)),e.add(o,0,"exit",i,t),i=void 0),i}function Qs(e,t,r,n,o){let i=[],a=Dt(t.events,r);o&&(o.end=Object.assign({},a),i.push("exit",o,t)),n.end=Object.assign({},a),i.push("exit",n,t),e.add(r+1,0,i)}function Dt(e,t){let r=et,n=r0==="enter"?"start":"end";return r1n}var $m=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|title|textarea|xmp)(?=\t\n\f\r />)/gi,qA=new RegExp("^"+$m.source,"i");var jm={tokenize:Bm},Zs={text:{91:jm}};function Bm(e,t,r){let n=this;return o;function o(l){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?r(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),i)}function i(l){return J(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):r(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):r(l)}function s(l){return I(l)?t(l):V(l)?e.check({tokenize:Hm},t,r)(l):r(l)}}function Hm(e,t,r){return z(e,n,"whitespace");function n(o){return o===null?r(o):t(o)}}function ea(e){return Dr(Vs,Js(),Ys(e),Xs,Zs)}var na=e=>bs(e,{extensions:ea(),mdastExtensions:$s()}).children.map(t=>jt(t)).join(`
),Jn=(e,t="txt")=>[code:${t},...e.split(
).map(r=> ${r})].join(
),jt=e=>{switch(e.type){case"paragraph":return e.children.map(t=>$t(t)).join("");case"heading":return zm(e);case"code":return Jn(e.value,e.lang??"txt");case"yaml":return Jn(e.value,"yaml");case"thematicBreak":return"[/icons/hr.icon]";case"table":return["table:table",...e.children.map(t=> ${ra(t)})].join(
);case"tableRow":return ra(e);case"tableCell":return oa(e);case"footnoteDefinition":return${e.label}: ${e.children.map(t=>jt(t)).join("").replaceAll(`
," ")};case"definition":return[${e.label}]: ${e.url};case"list":return e.children.map((t,r)=>{let n=e.ordered?${(e.start??1)+r}. :"";return ta(t,n)}).join(`
);case"listItem":return ta(e);case"blockquote":return e.children.map(t=>jt(t).split(
).map(n=>> ${n}).join(
)).join(
);default:return $t(e)}},zm=e=>e.children.map(t=>${jt(t)}).join(""),ta=(e,t="")=>{if(e.children.length===0)return"";let r=jt(e.children[0]),n=${t}${r},o=e.children.slice(1).map(i=>jt(i).split(
).map(s=> ${s}).join(
)).join(
);return o?${n}
${o}:n},$t=e=>{let t=n=>{if(n.title)return${n.title} ${n.url};let o=n.children.map(i=>$t(i)).join("");return o!==n.url?${o} ${n.url}:${n.url}},r=n=>${n};switch(e.type){case"link":return t(e);case"inlineCode":return\${e.value}\`;case"html":return Jn(e.value,"html");case"text":return e.value;case"break":return`
;case"image":return e.url.endsWith(".png")?${e.url}:${e.url}#.png;case"footnoteReference":return r(e.label||"");case"linkReference":return${e.children.map(o=>$t(o)).join("")} (${e.label});case"imageReference":return${e.label};default:{let n=e.children.map(o=>$t(o)).join("").replaceAll(
," ");switch(e.type){case"footnote":return${n};case"emphasis":return${n};case"strong":return${n};case"delete":return${n};default:return n}}}},ra=e=> ${e.children.map(t=>oa(t)).join(" ")},oa=e=>e.children.map(t=>$t(t)).join("").replaceAll(
," ").replace(/\s+/g," ").trimEnd();cosense.PopupMenu.addButton({title:"From Markdown",onClick:na});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 ia=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 Wm=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),sa=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Wm(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)},aa=(e,t)=>{if(t.hasTitle??!0){let[r,...n]=e;return r===void 0?[]:[{type:"title",rows:[r]},...n.reduce(sa,[])]}return e.reduce(sa,[])};var la=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var ca=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},i=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:i,content:r.map(a=>a.text.substring(n+1)).join(
)}};var Y=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,i,a)=>{if(!t&&i.nested)return a?.()??[];if(!r&&i.quoted)return a?.()??[];for(let s of n){let l=s.exec(o);if(l===null)continue;let c=o.substring(0,l.index),u=o.substring(l.index+(l[0]?.length??0)),p=e(l[0]??"",i);return[...Oe(c,i),...p,...Oe(u,i)]}return a?.()??[]};var Z=e=>[{type:"plain",raw:e,text:e}],ua=Y(Z,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var Vm=/\[\s+\]/,Gm=(e,t)=>t.context==="table"?Z(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],pa=Y(Gm,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Vm]});var qm=/.*?/,Km=(e,t)=>t.context==="table"?Z(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],fa=Y(Km,{parseOnNested:!1,parseOnQuoted:!0,patterns:[qm]});var Jm=/^[$%] .+$/,Ym=(e,t)=>{if(t.context==="table")return Z(e,t);let r=e[0]??"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:n}]},ma=Y(Ym,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Jm]});var Qm=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Xm=(e,t)=>{if(t.context==="table")return Z(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),i=new Set(n);if(i.has("*")){let a=n.split("*").length-1;i.delete("*"),i.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(i),nodes:Oe(o,{...t,nested:!0})}]},da=Y(Xm,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Qm]});var Zm=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,ed=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,td=/\[https?:\/\/[^\s\]]+\]/,rd=/https?:\/\/[^\s]+/,nd=(e,t)=>{if(t.context==="table")return Z(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 i=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:i.trim()}]},ga=Y(nd,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Zm,ed,td,rd]});var od=/\[\$ .+? \]/,id=/\[\$ [^\]]+\]/,sd=(e,t)=>t.context==="table"?Z(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],ha=Y(sd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[od,id]});var xa=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,ya=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,ad=e=>{let[t="",r="",n=""]=e.split(","),o=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),i=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(n)?Number.parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:i,zoom:a}},ld=(e,t)=>{if(t.context==="table")return Z(e,t);let r=e.match(xa)??e.match(ya);if(r===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,o="",i=""]=n?r:[r[0],r[2],r[1]],{latitude:a,longitude:s,zoom:l}=ad(o),c=i!==""?https://www.google.com/maps/place/${encodeURIComponent(i)}/@${a},${s},${l}z:https://www.google.com/maps/@${a},${s},${l}z;return[{type:"googleMap",raw:e,latitude:a,longitude:s,zoom:l,place:i,url:c}]},ba=Y(ld,{parseOnNested:!1,parseOnQuoted:!0,patterns:[xa,ya]});var cd=/(?:^|\s)#\S+/,ud=(e,t)=>{if(t.context==="table")return Z(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[...Z(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},Ea=Y(ud,{parseOnNested:!0,parseOnQuoted:!0,patterns:[cd]});var pd=/^\? .+$/,fd=(e,t)=>t.context==="table"?Z(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],wa=Y(fd,{parseOnNested:!1,parseOnQuoted:!1,patterns:[pd]});var md=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,dd=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),n=t.substring(0,r),o=n.startsWith("/")?"root":"relative",i=t.substring(r+5,t.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:n,pathType:o,type:"icon",raw:e}))},Ra=Y(dd,{parseOnNested:!0,parseOnQuoted:!0,patterns:[md]});var gd=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,hd=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,xd=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,yd=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,bd=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Ed(e),Ed=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),wd=(e,t)=>{if(t.context==="table")return Z(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+/,""):"",[i,a]=bd(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(i)?${i}/thumb/1000:i,link:a}]},ka=Y(wd,{parseOnNested:!0,parseOnQuoted:!0,patterns:[gd,hd,xd,yd]});var Rd=/\[\/?[^[\]]+\]/,kd=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},va=Y(kd,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Rd]});var vd=/^[0-9]+\. .*$/,Td=(e,t)=>{if(t.context==="table")return Z(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=Number.parseInt(n,10),i=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:Oe(i,{...t,nested:!1})}]},Ta=Y(Td,{parseOnNested:!1,parseOnQuoted:!1,patterns:[vd]});var Ld=/^>.*$/,Cd=(e,t)=>t.context==="table"?Z(e,t):[{type:"quote",raw:e,nodes:Oe(e.substring(1),{...t,quoted:!0})}],La=Y(Cd,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Ld]});var Sd=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Od=(e,t)=>{if(t.context==="table")return Z(e,t);let r=e.substring(2,e.length-2),n=r.lastIndexOf(".icon"),o=r.substring(0,n),i=o.startsWith("/")?"root":"relative",a=r.substring(n+5,r.length),s=a.startsWith("*")?Number.parseInt(a.substring(1),10):1;return new Array(s).fill({}).map(()=>({path:o,pathType:i,type:"strongIcon",raw:e}))},Ca=Y(Od,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Sd]});var Ad=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,Nd=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Pd=(e,t)=>{if(t.context==="table")return Z(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}]},Sa=Y(Pd,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ad,Nd]});var Md=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,_d=(e,t)=>t.context==="table"?Z(e,t):[{type:"strong",raw:e,nodes:Oe(e.substring(2,e.length-2),{...t,nested:!0})}],Oa=Y(_d,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Md]});var Fd=(e,t,r)=>e===""?[]:r?.()??[],Id=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>ua(t,r))(),Oe=Id(Fd,La,wa,Ta,fa,ma,ha,pa,da,Sa,Ca,Oa,ka,ga,Ra,ba,va,Ea);var Aa=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:Oe(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Na=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},i=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:i,cells:r.map(a=>a.text.substring(n+1)).map(a=>a.split(" ").map(s=>Oe(s,{nested:!1,quoted:!1,context:"table"})))}};var Pa=e=>({type:"title",text:e.rows[0].text});var Ma=e=>{switch(e.type){case"title":return Pa(e);case"codeBlock":return ca(e);case"table":return Na(e);case"line":return Aa(e)}};var Yn=(e,t)=>{let r=la(e);return aa(r,{hasTitle:t?.hasTitle??!0}).map(Ma)};var _a=(e,t,r)=>{if(r.length===0)return[];let n=r.map(s=>s.text).join(
),o=Yn(n,{hasTitle:!0}),i=new Map,a=0;for(let s of o)switch(s.type){case"title":case"line":{a++;break}case"table":a+=s.cells.length+1;break;case"codeBlock":{let{fileName:l,lang:c}=ia(s.fileName),u=i.get(l);i.set(l,{path:u?.path??https://scrapbox.io/api/code/${e}/${xr(t)}/${xr(l)},lang:u?.lang??c,startIds:[...u?.startIds??[],r[a].id]}),a+=s.content.split(
).length+1;break}}return i.values()};function Xn(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(Ue(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 i of o)r.write(Ue(i)),t(n[i])}},r=new Br;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Qn(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Fa(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return Bt(r.read());case 4:return r.read();case 5:{let a=r.read32(),s=[];for(let l=0;l<a;l++)s.push(t());return s}case 6:{let a=r.read32(),s={};for(let l=0;l<a;l++)s[Bt(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new Br(e),n=r.read32(),o=(n&1)===0;n>>>=1;let i=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:i}}var Br=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);Qn(this.buf,t,r)}write(t){let r=this._write(4+t.length);Qn(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 Zn(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}},Ue,Bt,Ia;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;Ue=r=>e.encode(r),Bt=r=>t.decode(r),Ia='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(Ue("")instanceof Uint8Array))throw new Error(Invariant violation: "${Ia} 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 Zn(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Qn(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var ar="0.23.0";var xe=JSON.stringify,Ua="warning",Da="silent";function $a(e){if(Re(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var Wr=()=>null,ue=e=>typeof e=="boolean"?null:"a boolean",B=e=>typeof e=="string"?null:"a string",Vr=e=>e instanceof RegExp?null:"a RegExp object",Lt=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ha=e=>typeof e=="function"?null:"a function",pe=e=>Array.isArray(e)?null:"an array",Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Dd=e=>typeof e=="object"&&e!==null?null:"an array or an object",$d=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",ja=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",za=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",jd=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Bd=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Wa=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",Hd=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function y(e,t,r,n){let o=e[r];if(t[r+""]=!0,o===void 0)return;let i=n(o);if(i!==null)throw new Error(${xe(r)} must be ${i});return o}function ye(e,t,r){for(let n in e)if(!(n in t))throw new Error(Invalid option ${r}: ${xe(n)})}function Va(e){let t=Object.create(null),r=y(e,t,"wasmModule",$d),n=y(e,t,"workerURL",Hd);return ye(e,t,"in initialize() call"),{wasmModule:r,workerURL:n}}function Ga(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 ${xe(r)} in mangle cache to map to either a string or false)}}return t}function Gr(e,t,r,n,o){let i=y(t,r,"color",ue),a=y(t,r,"logLevel",B),s=y(t,r,"logLimit",Lt);i!==void 0?e.push(--color=${i}):n&&e.push("--color=true"),e.push(--log-level=${a||o}),e.push(--log-limit=${s||0})}function Re(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+xe(r):""} to be a string, got ${typeof e} instead);return e}function qa(e,t,r){let n=y(t,r,"legalComments",B),o=y(t,r,"sourceRoot",B),i=y(t,r,"sourcesContent",ue),a=y(t,r,"target",Bd),s=y(t,r,"format",B),l=y(t,r,"globalName",B),c=y(t,r,"mangleProps",Vr),u=y(t,r,"reserveProps",Vr),p=y(t,r,"mangleQuoted",ue),m=y(t,r,"minify",ue),f=y(t,r,"minifySyntax",ue),b=y(t,r,"minifyWhitespace",ue),A=y(t,r,"minifyIdentifiers",ue),N=y(t,r,"lineLimit",Lt),C=y(t,r,"drop",pe),H=y(t,r,"dropLabels",pe),E=y(t,r,"charset",B),R=y(t,r,"treeShaking",ue),w=y(t,r,"ignoreAnnotations",ue),h=y(t,r,"jsx",B),S=y(t,r,"jsxFactory",B),O=y(t,r,"jsxFragment",B),_=y(t,r,"jsxImportSource",B),x=y(t,r,"jsxDev",ue),v=y(t,r,"jsxSideEffects",ue),T=y(t,r,"define",Me),L=y(t,r,"logOverride",Me),P=y(t,r,"supported",Me),F=y(t,r,"pure",pe),D=y(t,r,"keepNames",ue),$=y(t,r,"platform",B),W=y(t,r,"tsconfigRaw",jd);if(n&&e.push(--legal-comments=${n}),o!==void 0&&e.push(--source-root=${o}),i!==void 0&&e.push(--sources-content=${i}),a&&(Array.isArray(a)?e.push(--target=${Array.from(a).map($a).join(",")}):e.push(--target=${$a(a)})),s&&e.push(--format=${s}),l&&e.push(--global-name=${l}),$&&e.push(--platform=${$}),W&&e.push(--tsconfig-raw=${typeof W=="string"?W:JSON.stringify(W)}),m&&e.push("--minify"),f&&e.push("--minify-syntax"),b&&e.push("--minify-whitespace"),A&&e.push("--minify-identifiers"),N&&e.push(--line-limit=${N}),E&&e.push(--charset=${E}),R!==void 0&&e.push(--tree-shaking=${R}),w&&e.push("--ignore-annotations"),C)for(let j of C)e.push(--drop:${Re(j,"drop")});if(H&&e.push(--drop-labels=${Array.from(H).map(j=>Re(j,"dropLabels")).join(",")}),c&&e.push(--mangle-props=${c.source}),u&&e.push(--reserve-props=${u.source}),p!==void 0&&e.push(--mangle-quoted=${p}),h&&e.push(--jsx=${h}),S&&e.push(--jsx-factory=${S}),O&&e.push(--jsx-fragment=${O}),_&&e.push(--jsx-import-source=${_}),x&&e.push("--jsx-dev"),v&&e.push("--jsx-side-effects"),T)for(let j in T){if(j.indexOf("=")>=0)throw new Error(Invalid define: ${j});e.push(--define:${j}=${Re(Tj,"define",j)})}if(L)for(let j in L){if(j.indexOf("=")>=0)throw new Error(Invalid log override: ${j});e.push(--log-override:${j}=${Re(Lj,"log override",j)})}if(P)for(let j in P){if(j.indexOf("=")>=0)throw new Error(Invalid supported: ${j});let d=P[j];if(typeof d!="boolean")throw new Error(Expected value for supported ${xe(j)} to be a boolean, got ${typeof d} instead);e.push(--supported:${j}=${d})}if(F)for(let j of F)e.push(--pure:${Re(j,"pure")});D&&e.push("--keep-names")}function zd(e,t,r,n,o){let i=[],a=[],s=Object.create(null),l=null,c=null;Gr(i,t,s,r,n),qa(i,t,s);let u=y(t,s,"sourcemap",za),p=y(t,s,"bundle",ue),m=y(t,s,"splitting",ue),f=y(t,s,"preserveSymlinks",ue),b=y(t,s,"metafile",ue),A=y(t,s,"outfile",B),N=y(t,s,"outdir",B),C=y(t,s,"outbase",B),H=y(t,s,"tsconfig",B),E=y(t,s,"resolveExtensions",pe),R=y(t,s,"nodePaths",pe),w=y(t,s,"mainFields",pe),h=y(t,s,"conditions",pe),S=y(t,s,"external",pe),O=y(t,s,"packages",B),_=y(t,s,"alias",Me),x=y(t,s,"loader",Me),v=y(t,s,"outExtension",Me),T=y(t,s,"publicPath",B),L=y(t,s,"entryNames",B),P=y(t,s,"chunkNames",B),F=y(t,s,"assetNames",B),D=y(t,s,"inject",pe),$=y(t,s,"banner",Me),W=y(t,s,"footer",Me),j=y(t,s,"entryPoints",Dd),d=y(t,s,"absWorkingDir",B),G=y(t,s,"stdin",Me),K=y(t,s,"write",ue)??o,g=y(t,s,"allowOverwrite",ue),se=y(t,s,"mangleCache",Me);if(s.plugins=!0,ye(t,s,in ${e}() call),u&&i.push(--sourcemap${u===!0?"":=${u}}),p&&i.push("--bundle"),g&&i.push("--allow-overwrite"),m&&i.push("--splitting"),f&&i.push("--preserve-symlinks"),b&&i.push("--metafile"),A&&i.push(--outfile=${A}),N&&i.push(--outdir=${N}),C&&i.push(--outbase=${C}),H&&i.push(--tsconfig=${H}),O&&i.push(--packages=${O}),E){let U=[];for(let ee of E){if(Re(ee,"resolve extension"),ee.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${ee});U.push(ee)}i.push(--resolve-extensions=${U.join(",")})}if(T&&i.push(--public-path=${T}),L&&i.push(--entry-names=${L}),P&&i.push(--chunk-names=${P}),F&&i.push(--asset-names=${F}),w){let U=[];for(let ee of w){if(Re(ee,"main field"),ee.indexOf(",")>=0)throw new Error(Invalid main field: ${ee});U.push(ee)}i.push(--main-fields=${U.join(",")})}if(h){let U=[];for(let ee of h){if(Re(ee,"condition"),ee.indexOf(",")>=0)throw new Error(Invalid condition: ${ee});U.push(ee)}i.push(--conditions=${U.join(",")})}if(S)for(let U of S)i.push(--external:${Re(U,"external")});if(_)for(let U in _){if(U.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${U});i.push(--alias:${U}=${Re(_U,"alias",U)})}if($)for(let U in $){if(U.indexOf("=")>=0)throw new Error(Invalid banner file type: ${U});i.push(--banner:${U}=${Re($U,"banner",U)})}if(W)for(let U in W){if(U.indexOf("=")>=0)throw new Error(Invalid footer file type: ${U});i.push(--footer:${U}=${Re(WU,"footer",U)})}if(D)for(let U of D)i.push(--inject:${Re(U,"inject")});if(x)for(let U in x){if(U.indexOf("=")>=0)throw new Error(Invalid loader extension: ${U});i.push(--loader:${U}=${Re(xU,"loader",U)})}if(v)for(let U in v){if(U.indexOf("=")>=0)throw new Error(Invalid out extension: ${U});i.push(--out-extension:${U}=${Re(vU,"out extension",U)})}if(j)if(Array.isArray(j))for(let U=0,ee=j.length;U<ee;U++){let te=j[U];if(typeof te=="object"&&te!==null){let Le=Object.create(null),be=y(te,Le,"in",B),ke=y(te,Le,"out",B);if(ye(te,Le,"in entry point at index "+U),be===void 0)throw new Error('Missing property "in" for entry point at index '+U);if(ke===void 0)throw new Error('Missing property "out" for entry point at index '+U);a.push([ke,be])}else a.push(["",Re(te,"entry point at index "+U)])}else for(let U in j)a.push([U,Re(j[U],"entry point",U)]);if(G){let U=Object.create(null),ee=y(G,U,"contents",Wa),te=y(G,U,"resolveDir",B),Le=y(G,U,"sourcefile",B),be=y(G,U,"loader",B);ye(G,U,'in "stdin" object'),Le&&i.push(--sourcefile=${Le}),be&&i.push(--loader=${be}),te&&(c=te),typeof ee=="string"?l=Ue(ee):ee instanceof Uint8Array&&(l=ee)}let re=[];if(R)for(let U of R)U+="",re.push(U);return{entries:a,flags:i,write:K,stdinContents:l,stdinResolveDir:c,absWorkingDir:d,nodePaths:re,mangleCache:Ga(se)}}function Wd(e,t,r,n){let o=[],i=Object.create(null);Gr(o,t,i,r,n),qa(o,t,i);let a=y(t,i,"sourcemap",za),s=y(t,i,"sourcefile",B),l=y(t,i,"loader",B),c=y(t,i,"banner",B),u=y(t,i,"footer",B),p=y(t,i,"mangleCache",Me);return ye(t,i,in ${e}() call),a&&o.push(--sourcemap=${a===!0?"external":a}),s&&o.push(--sourcefile=${s}),l&&o.push(--loader=${l}),c&&o.push(--banner=${c}),u&&o.push(--footer=${u}),{flags:o,mangleCache:Ga(p)}}function Ka(e){let t={},r={didClose:!1,reason:""},n={},o=0,i=0,a=new Uint8Array(16*1024),s=0,l=E=>{let R=s+E.length;if(R>a.length){let h=new Uint8Array(R*2);h.set(a),a=h}a.set(E,s),s+=E.length;let w=0;for(;w+4<=s;){let h=Zn(a,w);if(w+4+h>s)break;w+=4,b(a.subarray(w,w+h)),w+=h}w>0&&(a.copyWithin(0,w,s),s-=w)},c=E=>{r.didClose=!0,E&&(r.reason=": "+(E.message||E));let R="The service was stopped"+r.reason;for(let w in n)n[w](R,null);n={}},u=(E,R,w)=>{if(r.didClose)return w("The service is no longer running"+r.reason,null);let h=o++;n[h]=(S,O)=>{try{w(S,O)}finally{E&&E.unref()}},E&&E.ref(),e.writeToStdin(Xn({id:h,isRequest:!0,value:R}))},p=(E,R)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(Xn({id:E,isRequest:!1,value:R}))},m=async(E,R)=>{try{if(R.command==="ping"){p(E,{});return}if(typeof R.key=="number"){let w=t[R.key];if(!w)return;let h=w[R.command];if(h){await h(E,R);return}}throw new Error("Invalid command: "+R.command)}catch(w){let h=[Tt(w,e,null,void 0,"")];try{p(E,{errors:h})}catch{}}},f=!0,b=E=>{if(f){f=!1;let w=String.fromCharCode(...E);if(w!==ar)throw new Error(Cannot start service: Host version "${ar}" does not match binary version ${xe(w)});return}let R=Fa(E);if(R.isRequest)m(R.id,R.value);else{let w=n[R.id];delete n[R.id],R.value.error?w(R.value.error,{}):w(null,R.value)}};return{readFromStdout:l,afterClose:c,service:{buildOrContext:({callName:E,refs:R,options:w,isTTY:h,defaultWD:S,callback:O})=>{let _=0,x=i++,v={},T={ref(){++_===1&&R&&R.ref()},unref(){--_===0&&(delete t[x],R&&R.unref())}};t[x]=v,T.ref(),Vd(E,x,u,p,T,e,v,w,h,S,(L,P)=>{try{O(L,P)}finally{T.unref()}})},transform:({callName:E,refs:R,input:w,options:h,isTTY:S,fs:O,callback:_})=>{let x=Ja(),v=T=>{try{if(typeof w!="string"&&!(w instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:L,mangleCache:P}=Wd(E,h,S,Da),F={command:"transform",flags:L,inputFS:T!==null,input:T!==null?Ue(T):typeof w=="string"?Ue(w):w};P&&(F.mangleCache=P),u(R,F,(D,$)=>{if(D)return _(new Error(D),null);let W=Ht($.errors,x),j=Ht($.warnings,x),d=1,G=()=>{if(--d===0){let K={warnings:j,code:$.code,map:$.map,mangleCache:void 0,legalComments:void 0};"legalComments"in $&&(K.legalComments=$?.legalComments),$.mangleCache&&(K.mangleCache=$?.mangleCache),_(null,K)}};if(W.length>0)return _(lr("Transform failed",W,j),null);$.codeFS&&(d++,O.readFile($.code,(K,g)=>{K!==null?_(K,null):($.code=g,G())})),$.mapFS&&(d++,O.readFile($.map,(K,g)=>{K!==null?_(K,null):($.map=g,G())})),G()})}catch(L){let P=[];try{Gr(P,h,{},S,Da)}catch{}let F=Tt(L,e,x,void 0,"");u(R,{command:"error",flags:P,error:F},()=>{F.detail=x.load(F.detail),_(lr("Transform failed",[F],[]),null)})}};if((typeof w=="string"||w instanceof Uint8Array)&&w.length>1024*1024){let T=v;v=()=>O.writeFile(w,T)}v(null)},formatMessages:({callName:E,refs:R,messages:w,options:h,callback:S})=>{if(!h)throw new Error(Missing second argument in ${E}() call);let O={},_=y(h,O,"kind",B),x=y(h,O,"color",ue),v=y(h,O,"terminalWidth",Lt);if(ye(h,O,in ${E}() call),_===void 0)throw new Error(Missing "kind" in ${E}() call);if(_!=="error"&&_!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${E}() call);let T={command:"format-msgs",messages:Ze(w,"messages",null,"",v),isWarning:_==="warning"};x!==void 0&&(T.color=x),v!==void 0&&(T.terminalWidth=v),u(R,T,(L,P)=>{if(L)return S(new Error(L),null);S(null,P.messages)})},analyzeMetafile:({callName:E,refs:R,metafile:w,options:h,callback:S})=>{h===void 0&&(h={});let O={},_=y(h,O,"color",ue),x=y(h,O,"verbose",ue);ye(h,O,in ${E}() call);let v={command:"analyze-metafile",metafile:w};_!==void 0&&(v.color=_),x!==void 0&&(v.verbose=x),u(R,v,(T,L)=>{if(T)return S(new Error(T),null);S(null,L.result)})}}}}function Vd(e,t,r,n,o,i,a,s,l,c,u){let p=Ja(),m=e==="context",f=(N,C)=>{let H=[];try{Gr(H,s,{},l,Ua)}catch{}let E=Tt(N,i,p,void 0,C);r(o,{command:"error",flags:H,error:E},()=>{E.detail=p.load(E.detail),u(lr(m?"Context failed":"Build failed",[E],[]),null)})},b;if(typeof s=="object"){let N=s.plugins;if(N!==void 0){if(!Array.isArray(N))return f(new Error('"plugins" must be an array'),"");b=N}}if(b&&b.length>0){if(i.isSync)return f(new Error("Cannot use plugins in synchronous API calls"),"");Gd(t,r,n,o,i,a,s,b,p).then(N=>{if(!N.ok)return f(N.error,N.pluginName);try{A(N.requestPlugins,N.runOnEndCallbacks,N.scheduleOnDisposeCallbacks)}catch(C){f(C,"")}},N=>f(N,""));return}try{A(null,(N,C)=>C([],[]),()=>{})}catch(N){f(N,"")}function A(N,C,H){let E=i.hasFS,{entries:R,flags:w,write:h,stdinContents:S,stdinResolveDir:O,absWorkingDir:_,nodePaths:x,mangleCache:v}=zd(e,s,l,Ua,E);if(h&&!i.hasFS)throw new Error('The "write" option is unavailable in this environment');let T={command:"build",key:t,entries:R,flags:w,write:h,stdinContents:S,stdinResolveDir:O,absWorkingDir:_||c,nodePaths:x,context:m};N&&(T.plugins=N),v&&(T.mangleCache=v);let L=(D,$)=>{let W={errors:Ht(D.errors,p),warnings:Ht(D.warnings,p),outputFiles:void 0,metafile:void 0,mangleCache:void 0},j=W.errors.slice(),d=W.warnings.slice();D.outputFiles&&(W.outputFiles=D.outputFiles.map(Kd)),D.metafile&&(W.metafile=JSON.parse(D.metafile)),D.mangleCache&&(W.mangleCache=D.mangleCache),D.writeToStdout!==void 0&&console.log(Bt(D.writeToStdout).replace(/\n$/,"")),C(W,(G,K)=>{if(j.length>0||G.length>0){let g=lr("Build failed",j.concat(G),d.concat(K));return $(g,null,G,K)}$(null,W,G,K)})},P,F;m&&(a["on-end"]=(D,$)=>new Promise(W=>{L($,(j,d,G,K)=>{let g={errors:G,warnings:K};F&&F(j,d),P=void 0,F=void 0,n(D,g),W()})})),r(o,T,(D,$)=>{if(D)return u(new Error(D),null);if(!m)return L($,(d,G)=>(H(),u(d,G)));if($.errors.length>0)return u(lr("Context failed",$.errors,$.warnings),null);let W=!1,j={rebuild:()=>(P||(P=new Promise((d,G)=>{let K;F=(se,re)=>{K||(K=()=>se?G(se):d(re))};let g=()=>{r(o,{command:"rebuild",key:t},(re,U)=>{re?G(new Error(re)):K?K():g()})};g()})),P),watch:(d={})=>new Promise((G,K)=>{if(!i.hasFS)throw new Error('Cannot use the "watch" API in this environment');ye(d,{},"in watch() call"),r(o,{command:"watch",key:t},re=>{re?K(new Error(re)):G(void 0)})}),serve:(d={})=>new Promise((G,K)=>{if(!i.hasFS)throw new Error('Cannot use the "serve" API in this environment');let g={},se=y(d,g,"port",Lt),re=y(d,g,"host",B),U=y(d,g,"servedir",B),ee=y(d,g,"keyfile",B),te=y(d,g,"certfile",B),Le=y(d,g,"fallback",B),be=y(d,g,"onRequest",Ha);ye(d,g,"in serve() call");let ke={command:"serve",key:t,onRequest:!!be};se!==void 0&&(ke.port=se),re!==void 0&&(ke.host=re),U!==void 0&&(ke.servedir=U),ee!==void 0&&(ke.keyfile=ee),te!==void 0&&(ke.certfile=te),Le!==void 0&&(ke.fallback=Le),r(o,ke,($e,Qt)=>{if($e)return K(new Error($e));be&&(a["serve-request"]=(kn,vn)=>{be(vn.args),n(kn,{})}),G(Qt)})}),cancel:()=>new Promise(d=>{if(W)return d();r(o,{command:"cancel",key:t},()=>{d()})}),dispose:()=>new Promise(d=>{if(W)return d();W=!0,r(o,{command:"dispose",key:t},()=>{d(),H(),o.unref()})})};o.ref(),u(null,j)})}}var Gd=async(e,t,r,n,o,i,a,s,l)=>{let c=[],u=[],p={},m={},f=[],b=0,A=0,N=[],C=!1;s=[...s];for(let R of s){let w={};if(typeof R!="object")throw new Error(Plugin at index ${A} must be an object);let h=y(R,w,"name",B);if(typeof h!="string"||h==="")throw new Error(Plugin at index ${A} is missing a name);try{let S=y(R,w,"setup",Ha);if(typeof S!="function")throw new Error("Plugin is missing a setup function");ye(R,w,on plugin ${xe(h)});let O={name:h,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};A++;let x=S({initialOptions:a,resolve:(v,T={})=>{if(!C)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof v!="string")throw new Error("The path to resolve must be a string");let L=Object.create(null),P=y(T,L,"pluginName",B),F=y(T,L,"importer",B),D=y(T,L,"namespace",B),$=y(T,L,"resolveDir",B),W=y(T,L,"kind",B),j=y(T,L,"pluginData",Wr),d=y(T,L,"with",Me);return ye(T,L,"in resolve() call"),new Promise((G,K)=>{let g={command:"resolve",path:v,key:e,pluginName:h};if(P!=null&&(g.pluginName=P),F!=null&&(g.importer=F),D!=null&&(g.namespace=D),$!=null&&(g.resolveDir=$),W!=null)g.kind=W;else throw new Error('Must specify "kind" when calling "resolve"');j!=null&&(g.pluginData=l.store(j)),d!=null&&(g.with=qd(d,"with")),t(n,g,(se,re)=>{se!==null?K(new Error(se)):G({errors:Ht(re.errors,l),warnings:Ht(re.warnings,l),path:re.path,external:re.external,sideEffects:re.sideEffects,namespace:re.namespace,suffix:re.suffix,pluginData:l.load(re.pluginData)})})})},onStart(v){let T='This error came from the "onStart" callback registered here:',L=Hr(new Error(T),o,"onStart");c.push({name:h,callback:v,note:L}),O.onStart=!0},onEnd(v){let T='This error came from the "onEnd" callback registered here:',L=Hr(new Error(T),o,"onEnd");u.push({name:h,callback:v,note:L}),O.onEnd=!0},onResolve(v,T){let L='This error came from the "onResolve" callback registered here:',P=Hr(new Error(L),o,"onResolve"),F={},D=y(v,F,"filter",Vr),$=y(v,F,"namespace",B);if(ye(v,F,in onResolve() call for plugin ${xe(h)}),D==null)throw new Error("onResolve() call is missing a filter");let W=b++;p[W]={name:h,callback:T,note:P},O.onResolve.push({id:W,filter:D.source,namespace:$||""})},onLoad(v,T){let L='This error came from the "onLoad" callback registered here:',P=Hr(new Error(L),o,"onLoad"),F={},D=y(v,F,"filter",Vr),$=y(v,F,"namespace",B);if(ye(v,F,in onLoad() call for plugin ${xe(h)}),D==null)throw new Error("onLoad() call is missing a filter");let W=b++;m[W]={name:h,callback:T,note:P},O.onLoad.push({id:W,filter:D.source,namespace:$||""})},onDispose(v){f.push(v)},esbuild:o.esbuild});x&&await x,N.push(O)}catch(S){return{ok:!1,error:S,pluginName:h}}}i["on-start"]=async(R,w)=>{let h={errors:[],warnings:[]};await Promise.all(c.map(async({name:S,callback:O,note:_})=>{try{let x=await O();if(x!=null){if(typeof x!="object")throw new Error(Expected onStart() callback in plugin ${xe(S)} to return an object);let v={},T=y(x,v,"errors",pe),L=y(x,v,"warnings",pe);ye(x,v,from onStart() callback in plugin ${xe(S)}),T!=null&&h.errors.push(...Ze(T,"errors",l,S,void 0)),L!=null&&h.warnings.push(...Ze(L,"warnings",l,S,void 0))}}catch(x){h.errors.push(Tt(x,o,l,_&&_(),S))}})),r(R,h)},i["on-resolve"]=async(R,w)=>{let h={},S="",O,_;for(let x of w.ids)try{({name:S,callback:O,note:_}=p[x]);let v=await O({path:w.path,importer:w.importer,namespace:w.namespace,resolveDir:w.resolveDir,kind:w.kind,pluginData:l.load(w.pluginData),with:w.with});if(v!=null){if(typeof v!="object")throw new Error(Expected onResolve() callback in plugin ${xe(S)} to return an object);let T={},L=y(v,T,"pluginName",B),P=y(v,T,"path",B),F=y(v,T,"namespace",B),D=y(v,T,"suffix",B),$=y(v,T,"external",ue),W=y(v,T,"sideEffects",ue),j=y(v,T,"pluginData",Wr),d=y(v,T,"errors",pe),G=y(v,T,"warnings",pe),K=y(v,T,"watchFiles",pe),g=y(v,T,"watchDirs",pe);ye(v,T,from onResolve() callback in plugin ${xe(S)}),h.id=x,L!=null&&(h.pluginName=L),P!=null&&(h.path=P),F!=null&&(h.namespace=F),D!=null&&(h.suffix=D),$!=null&&(h.external=$),W!=null&&(h.sideEffects=W),j!=null&&(h.pluginData=l.store(j)),d!=null&&(h.errors=Ze(d,"errors",l,S,void 0)),G!=null&&(h.warnings=Ze(G,"warnings",l,S,void 0)),K!=null&&(h.watchFiles=zr(K,"watchFiles")),g!=null&&(h.watchDirs=zr(g,"watchDirs"));break}}catch(v){h={id:x,errors:[Tt(v,o,l,_&&_(),S)]};break}r(R,h)},i["on-load"]=async(R,w)=>{let h={},S="",O,_;for(let x of w.ids)try{({name:S,callback:O,note:_}=m[x]);let v=await O({path:w.path,namespace:w.namespace,suffix:w.suffix,pluginData:l.load(w.pluginData),with:w.with});if(v!=null){if(typeof v!="object")throw new Error(Expected onLoad() callback in plugin ${xe(S)} to return an object);let T={},L=y(v,T,"pluginName",B),P=y(v,T,"contents",Wa),F=y(v,T,"resolveDir",B),D=y(v,T,"pluginData",Wr),$=y(v,T,"loader",B),W=y(v,T,"errors",pe),j=y(v,T,"warnings",pe),d=y(v,T,"watchFiles",pe),G=y(v,T,"watchDirs",pe);ye(v,T,from onLoad() callback in plugin ${xe(S)}),h.id=x,L!=null&&(h.pluginName=L),P instanceof Uint8Array?h.contents=P:P!=null&&(h.contents=Ue(P)),F!=null&&(h.resolveDir=F),D!=null&&(h.pluginData=l.store(D)),$!=null&&(h.loader=$),W!=null&&(h.errors=Ze(W,"errors",l,S,void 0)),j!=null&&(h.warnings=Ze(j,"warnings",l,S,void 0)),d!=null&&(h.watchFiles=zr(d,"watchFiles")),G!=null&&(h.watchDirs=zr(G,"watchDirs"));break}}catch(v){h={id:x,errors:[Tt(v,o,l,_&&_(),S)]};break}r(R,h)};let H=(R,w)=>w([],[]);u.length>0&&(H=(R,w)=>{(async()=>{let h=[],S=[];for(let{name:O,callback:_,note:x}of u){let v,T;try{let L=await _(R);if(L!=null){if(typeof L!="object")throw new Error(Expected onEnd() callback in plugin ${xe(O)} to return an object);let P={},F=y(L,P,"errors",pe),D=y(L,P,"warnings",pe);ye(L,P,from onEnd() callback in plugin ${xe(O)}),F!=null&&(v=Ze(F,"errors",l,O,void 0)),D!=null&&(T=Ze(D,"warnings",l,O,void 0))}}catch(L){v=[Tt(L,o,l,x&&x(),O)]}if(v){h.push(...v);try{R.errors.push(...v)}catch{}}if(T){S.push(...T);try{R.warnings.push(...T)}catch{}}}w(h,S)})()});let E=()=>{for(let R of f)setTimeout(()=>R(),0)};return C=!0,{ok:!0,requestPlugins:N,runOnEndCallbacks:H,scheduleOnDisposeCallbacks:E}};function Ja(){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 Hr(e,t,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let i=(e.stack+"").split(
);i.splice(1,1);let a=Ya(t,i,r);if(a)return n={text:e.message,location:a},n}catch{}}}function Tt(e,t,r,n,o){let i="Internal error",a=null;try{i=(e&&e.message||e)+""}catch{}try{a=Ya(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:o,text:i,location:a,notes:n?[n]:[],detail:r?r.store(e):-1}}function Ya(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 i=t[o];if(i.startsWith(n))for(i=i.slice(n.length);;){let a=/^(?:new |async )?\S+ \((.*)\)$/.exec(i);if(a){i=a[1];continue}if(a=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(i),a){i=a[1];continue}if(a=/^(\S+):(\d+):(\d+)$/.exec(i),a){let s;try{s=e.readFileSync(a[1],"utf8")}catch{break}let l=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+a[2]-1]||"",c=+a[3]-1,u=l.slice(c,c+r.length)===r?r.length:0;return{file:a[1],namespace:"file",line:+a[2],column:Ue(l.slice(0,c)).length,length:Ue(l.slice(c,c+u)).length,lineText:l+
+t.slice(1).join(
),suggestion:""}}break}}return null}function lr(e,t,r){let n=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,n+1).map((i,a)=>{if(a===n)return
...;if(!i.location)return
error: ${i.text};let{file:s,line:l,column:c}=i.location,u=i.pluginName?plugin: ${i.pluginName} :"";return
${s}:${l}:${c}: ERROR: ${u}${i.text}}).join("");let o=new Error(e);for(let[i,a]of[["errors",t],["warnings",r]])Object.defineProperty(o,i,{configurable:!0,enumerable:!0,get:()=>a,set:s=>Object.defineProperty(o,i,{configurable:!0,enumerable:!0,value:s})});return o}function Ht(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Ba(e,t,r){if(e==null)return null;let n={},o=y(e,n,"file",B),i=y(e,n,"namespace",B),a=y(e,n,"line",Lt),s=y(e,n,"column",Lt),l=y(e,n,"length",Lt),c=y(e,n,"lineText",B),u=y(e,n,"suggestion",B);if(ye(e,n,t),c){let p=c.slice(0,(s&&s>0?s:0)+(l&&l>0?l:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(p)&&!/\n/.test(c)&&(c=p)}return{file:o||"",namespace:i||"",line:a||0,column:s||0,length:l||0,lineText:c||"",suggestion:u||""}}function Ze(e,t,r,n,o){let i=[],a=0;for(let s of e){let l={},c=y(s,l,"id",B),u=y(s,l,"pluginName",B),p=y(s,l,"text",B),m=y(s,l,"location",ja),f=y(s,l,"notes",pe),b=y(s,l,"detail",Wr),A=in element ${a} of "${t}";ye(s,l,A);let N=[];if(f)for(let C of f){let H={},E=y(C,H,"text",B),R=y(C,H,"location",ja);ye(C,H,A),N.push({text:E||"",location:Ba(R,A,o)})}i.push({id:c||"",pluginName:u||n,text:p||"",location:Ba(m,A,o),notes:N,detail:r?r.store(b):-1}),a++}return i}function zr(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(${xe(t)} must be an array of strings);r.push(n)}return r}function qd(e,t){let r=Object.create(null);for(let n in e){let o=e[n];if(typeof o!="string")throw new Error(key ${xe(n)} in object ${xe(t)} must be a string);r[n]=o}return r}function Kd({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=Bt(o)),n}}}var Xa=ar,Kr=e=>Jr().build(e),Za=(e,t)=>Jr().transform(e,t),el=(e,t)=>Jr().formatMessages(e,t),tl=(e,t)=>Jr().analyzeMetafile(e,t);var Ct,Qa,qr,Jr=()=>{if(qr)return qr;throw Ct?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')},Yr=e=>{e=Va(e||{});let t=e.wasmModule,r=e.workerURL;if(!t)throw new Error('Must provide the "wasmModule" option');if(Ct)throw new Error('Cannot call "initialize" more than once');return Ct=Yd(t,r),Ct.catch(()=>{Ct=void 0}),Ct},Yd=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),n,o,i=new Promise((l,c)=>{n=l,o=c});r.onmessage=({data:l})=>{r.onmessage=({data:c})=>a(c),l?o(l):n()},r.postMessage(e);let{readFromStdout:a,service:s}=Ka({writeToStdin(l){r.postMessage(l)},isSync:!1,hasFS:!1,esbuild:{build:Kr,transform:Za,formatMessages:el,analyzeMetafile:tl,version:Xa,initialize:Yr}});await i,Qa=()=>{r.terminate(),Ct=void 0,Qa=void 0,qr=void 0},qr={build:l=>new Promise((c,u)=>s.buildOrContext({callName:"build",refs:null,options:l,isTTY:!1,defaultWD:"/",callback:(p,m)=>p?u(p):c(m)})),transform:(l,c)=>new Promise((u,p)=>s.transform({callName:"transform",refs:null,input:l,options:c||{},isTTY:!1,fs:{readFile(m,f){f(new Error("Internal error"),null)},writeFile(m,f){f(null)}},callback:(m,f)=>m?p(m):u(f)})),formatMessages:(l,c)=>new Promise((u,p)=>s.formatMessages({callName:"formatMessages",refs:null,messages:l,options:c,callback:(m,f)=>m?p(m):u(f)})),analyzeMetafile:(l,c)=>new Promise((u,p)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof l=="string"?l:JSON.stringify(l),options:c,callback:(m,f)=>m?p(m):u(f)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function Te(e){if(typeof e!="string")throw new TypeError(Path must be a string. Received ${JSON.stringify(e)})}function ze(e){return e===47||e===92}function et(e){return e>=97&&e<=122||e>=65&&e<=90}function Zr(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError("Must be a file URL.");return e}function rl(e){e=Zr(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 to(e){Te(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return ze(r)?!0:!!(et(r)&&t>2&&e.charCodeAt(1)===58&&ze(e.charCodeAt(2)))}var en=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function tn(e,t=""){if(!e)throw new en(t)}var cg={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function rn(e){return e.replaceAll(/[\s]/g,t=>cg[t]??t)}function il(e){if(!to(e))throw new TypeError("Must be an absolute path.");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=rn(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError("Invalid hostname.");return n}function tt(e){return e===47}function al(e){return e=Zr(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function no(e){return Te(e),e.length>0&&tt(e.charCodeAt(0))}function cl(e){if(!no(e))throw new TypeError("Must be an absolute path.");let t=new URL("file:///");return t.pathname=rn(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}var wg=(()=>{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"})(),ge=wg==="windows";var zt=ge?"\\":"/";function nn(e){return ge?rl(e):al(e)}function ur(e){return ge?il(e):cl(e)}function on(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function sn(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 ul(e){return on(e)&&(e.imports!==void 0?oo(e.imports):!0)&&(e.scopes!==void 0?io(e.scopes):!0)}function oo(e){return on(e)}function io(e){return on(e)&&Object.values(e).every(t=>so(t))}function so(e){return on(e)}function an(e){try{return new URL(e),!0}catch{return!1}}function fl(e,t){let r={};for(let[n,o]of Object.entries(e)){let i=kg(n,t);if(i===null)continue;if(typeof o!="string"){console.warn("addresses need to be strings."),r[i]=null;continue}let a=ao(o,t);if(a===null){console.warn("the address was invalid."),r[i]=null;continue}if(n.endsWith("/")&&!We(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[i]=null;continue}r[i]=We(a)}return sn(r)}function We(e){return e.href}function Rg(e,t){let r={};for(let[o,i]of Object.entries(e)){if(!so(i))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 s=We(a);r[s]=fl(i,t)}let n={};for(let o of Object.keys(r))n[o]=sn(r[o]);return sn(n)}function kg(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=ao(e,t);return r!==null?We(r):e}function ao(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 vg=["ftp","file","http","https","ws","wss"];function Tg(e){return vg.some(t=>We(e).startsWith(t))}function pl(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(!an(o))throw new TypeError("resolutionResult must be an URL.");return o}else if(n.endsWith("/")&&e.startsWith(n)&&(t===null||Tg(t))){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!an(o))throw new TypeError("resolutionResult must be an URL.");let i=e.slice(n.length);if(!o.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let a=new URL(i,o);if(!an(a))throw new TypeError("url must be an URL.");if(!We(a).startsWith(o))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return We(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 lo(e,t){let r={};if(!ul(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(!oo(n))throw new TypeError('"imports" top-level key needs to be an object.');r=fl(n,t)}let i={};if(o!==void 0){if(!io(o))throw new TypeError('"scopes" top-level key needs to be an object.');i=Rg(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:i}}function ml(e,{imports:t={},scopes:r={}},n){let o=We(n),i=ao(e,n),a=i!==null?We(i):e;for(let[l,c]of Object.entries(r))if(l===o||l.endsWith("/")&&o.startsWith(l)){let u=pl(a,i,c);if(u!==null)return u}let s=pl(a,i,t);if(s!==null)return s;if(i!==null)return We(i);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}function gl(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new co(e,{allowTrailingComma:t}).parse()}var dl=globalThis.JSON.parse,co=class{#i=new Set( \r
);#r=new Set([..."[]{}:,/",...this.#i]);#t;#e;#o;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#o=this.#c(),this.#a=r}parse(){let t=this.#n(),r=this.#u(t),{done:n,value:o}=this.#o.next();if(!n)throw new SyntaxError(ut(o));return r}#n(){let{done:t,value:r}=this.#o.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#c(){for(let t=0;t<this.#e;t++)if(!this.#i.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}}}}}#u(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#s();case"NullOrTrueOrFalseOrNumber":return this.#h(t);case"String":return this.#g(t);default:throw new SyntaxError(ut(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(ut(n));let o=this.#g(n),i=this.#n();if(i.type!=="NameSeparator")throw new SyntaxError(ut(i));let a=this.#n();Object.defineProperty(t,o,{value:this.#u(a),writable:!0,enumerable:!0,configurable:!0});let s=this.#n();if(s.type==="EndObject")return t;if(s.type!=="ValueSeparator")throw new SyntaxError(ut(s))}}#s(){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.#u(n));let o=this.#n();if(o.type==="EndArray")return t;if(o.type!=="ValueSeparator")throw new SyntaxError(ut(o))}}#g(t){let r;try{r=dl(t.sourceText)}catch{throw new SyntaxError(ut(t))}return tn(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=dl(t.sourceText)}catch{throw new SyntaxError(ut(t))}return tn(typeof r=="number"),r}};function ut({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 cn(e){if(e.protocol==="file:")return{path:nn(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function uo(e){let t=await Deno.readTextFile(e),r=gl(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 hl(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+"/",i=n.slice(0,4)+"/"+n.slice(n[4]==="/"?5:4)+"/";t.push([o,i])}e.imports=Object.fromEntries(t)}}var Cg=${zt}node_modules${zt},Sg=${zt}node_modules;function ln(e){return e.includes(Cg)||e.endsWith(Sg)}function po(e){return(e.namespace===""||e.namespace==="file")&&(ln(e.resolveDir)||ln(e.path)||ln(e.importer))}function fo(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 i;if(e.importMapURL===void 0&&e.configPath!==void 0){let a=await uo(e.configPath);if(a.imports!==void 0||a.scopes!==void 0){let s={imports:a.imports,scopes:a.scopes};hl(s),r=lo(s,ur(e.configPath))}else a.importMap!==void 0&&(i=new URL(a.importMap,ur(e.configPath)).href)}else e.importMapURL!==void 0&&(i=e.importMapURL);if(i){let a=await fetch(i),s=await a.json();r=lo(s,new URL(a.url))}}),t.onResolve({filter:/.*/},async function(i){if(po(i))return;let a;if(i.importer!==""){if(i.namespace==="")throw new Error("[assert] namespace is empty");a=new URL(${i.namespace}:${i.importer})}else if(i.resolveDir!=="")a=new URL(${ur(i.resolveDir).href}/);else return;let s;if(r!==null){let p=ml(i.path,r,new URL(a));s=new URL(p)}else s=new URL(i.path,a);for(let p of n)if(p.test(s.href))return{path:s.href,external:!0};let{path:l,namespace:c}=cn(s);return await t.resolve(l,{namespace:c,kind:i.kind})})}}}var J$=new TextEncoder;var Og=[],Ag=[],mo="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=mo.length;e<t;++e)Og[e]=mo[e],Ag[mo.charCodeAt(e)]=e;var hj=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var Dg=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var xl=fo;function Ae(e){return e.val}var yl=" must not return ",$g="transformer",jg="recoverer",Bg="defaultValue",Wt=$g+yl,rt="called with ",Vt=Bg+" must not be ",Gt=jg+yl;var Hg="Ok",bl="Err",El=rt+bl,wl=rt+Hg,zg="Carrying E in "+bl+" instead of throwing it directly. See .cause",go="an instance of Error of the current realm.",Dj="The thrown value is not "+go,$j="The contained E should be "+go,Wg="This .cause is not "+go;function we(e){return e.ok}function ne(e){return{ok:!0,val:e,err:null}}function fe(e){return!e.ok}function Q(e){return{ok:!1,val:null,err:e}}function Ne(e){return Rl(e,El)}function pt(e){return kl(e,wl)}function Rl(e,t){if(fe(e))throw new TypeError(t);return e.val}function kl(e,t){if(we(e))throw new TypeError(t);return e.err}async function St(e,t){if(fe(e))return e;let r=Ae(e),n=await t(r);return ne(n)}var un="null",V2=Wt+un,qg=rt+un,G2=Vt+un,q2=Gt+un;var pn="undefined",X2=Wt+pn,Kg=rt+pn,Z2=Vt+pn,eB=Gt+pn;var fn="null or undefined",qt=Wt+fn,Yg=rt+fn,ho=Vt+fn,mn=Gt+fn;function De(e){return e!=null}function xo(e,t){if(De(e))return ne(e);let r=t();return Q(r)}var Tl=e=>!!(Qg.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),Qg=["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 mt(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function Ot(e){return e===47}function Ll(e){mt(e);let t=-1,r=0,n=-1,o=!0,i=0;for(let a=e.length-1;a>=0;--a){let s=e.charCodeAt(a);if(Ot(s)){if(!o){r=a+1;break}continue}n===-1&&(o=!1,n=a+1),s===46?t===-1?t=a:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||n===-1||i===0||i===1&&t===n-1&&t===r+1?"":e.slice(t,n)}function Cl(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 Sl(e,t,r=0){let n=!1,o=e.length;for(let i=e.length-1;i>=r;--i)if(t(e.charCodeAt(i))){if(n){r=i+1;break}}else n||(n=!0,o=i+1);return e.slice(r,o)}function Ol(e,t){if(mt(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function Al(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 Nl(e,t=""){Ol(e,t);let r=Sl(e,Ot),n=Al(r,Ot);return t?Cl(n,t):n}var dn=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function gn(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 Pl(e){return e=gn(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Ml(e){e=gn(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 _l(e){return dn?Ml(e):Pl(e)}var Zg={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function hn(e){return e.replaceAll(/[\s]/g,t=>Zg[t]??t)}function Fl(e){return mt(e),e.length>0&&Ot(e.charCodeAt(0))}function Il(e){if(!Fl(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=hn(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function bo(e){return e===47||e===92}function Ul(e){return e>=97&&e<=122||e>=65&&e<=90}function Dl(e){mt(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return bo(r)?!0:!!(Ul(r)&&t>2&&e.charCodeAt(1)===58&&bo(e.charCodeAt(2)))}function $l(e){if(!Dl(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=hn(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError(Invalid hostname: "${n.hostname}");return n}function jl(e){return dn?$l(e):Il(e)}var Bl=e=>{if(e.protocol==="file:")return{path:_l(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},Eo=e=>e.namespace==="file"?jl(e.path):new URL(${e.namespace}:${e.path});var Hl=(e,t)=>{let r=xo(sh(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(fe(r))return r;let{url:n,start:o,end:i}=Ne(r);return URL.canParse(n,t)?ne({url:new URL(n,t),start:o,end:i}):Q({name:"InvalidURLError",message:Invalid URL: ${n}})},sh=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 ah=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],zl=e=>ah.includes(e),Wl=e=>/^js|^ts|css$/.test(e),Vl=e=>{let t=e.url,r=Nl(t);if(zl(r))return r;if(r==="mjs")return"js";let n=new URL(t);n.search="",n.hash="";let o=Ll(n.href).slice(1);if(zl(o))return o;if(o==="mjs")return"js";let a=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return lh(a)},lh=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 xn(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function Kl(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Ro(e=[],t=[]){let r=Math.max(e.length,t.length);for(let n=0;n<r;n++){let o=e[n],i=t[n];if(o===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(o===void 0)return-1;if(typeof o=="string"&&typeof i=="number")return 1;if(typeof o=="number"&&typeof i=="string"||o<i)return-1;if(o>i)return 1}return 0}var Kt="0|[1-9]\\d*",ch="\\d*[a-zA-Z-][a-zA-Z0-9-]*",uh=(?<major>${Kt})\\.(?<minor>${Kt})\\.(?<patch>${Kt}),Gl=(?:${Kt}|${ch}),Jl=(?:-(?<prerelease>${Gl}(?:\\.${Gl})*)),ql="[0-9A-Za-z-]+",Yl=(?:\\+(?<buildmetadata>${ql}(?:\\.${ql})*)),Ql=v?${uh}${Jl}?${Yl}?,Xl=new RegExp(^${Ql}$),Zl="(?:<|>)?=?",ph="x|X|\\*",wo=${Kt}|${ph},yn=v=\\s*(?<major>${wo})(?:\\.(?<minor>${wo})(?:\\.(?<patch>${wo})${Jl}?${Yl}?)?)?,ec=new RegExp(^(?<operator>~>?|\\^|${Zl})\\s*${yn}$),tc=new RegExp(^(?<operator>${Zl})\\s*(${Ql})$|^$);function ko(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var vo=256;var fh=new RegExp(^${Kt}$);function Pe(e){return e.split(".").filter(Boolean).map(t=>{if(fh.test(t)){let r=Number(t);if(ko(r))return r}return t})}function Ve(e){return e.split(".").filter(Boolean)}function dt(e,t){let r=Number(e);if(!ko(r))throw new TypeError(t);return r}function At(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 Fe(e,t){return e===t?0:xn(e.major,t.major)||xn(e.minor,t.minor)||xn(e.patch,t.patch)||Kl(e.prerelease,t.prerelease)||Ro(e.prerelease,t.prerelease)}function To(e){return e.toFixed(0)}function Nt(e){let t=To(e.major),r=To(e.minor),n=To(e.patch),o=e.prerelease?.join(".")??"",i=e.build?.join(".")??"";return[[${t}.${r}.${n},o].filter(l=>l).join("-"),i].filter(l=>l).join("+")}function mh(e,t){if(At(t))return!0;let r=Fe(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 bn(e,t){for(let r of t)if(!mh(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(At(r))continue;let{major:n,minor:o,patch:i,prerelease:a}=r;if(a&&a.length>0&&e.major===n&&e.minor===o&&e.patch===i)return!0}return!1}return!0}function En(e,t){return t.some(r=>bn(e,r))}var wn={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},Jt={operator:void 0,...wn};function rc(e,t){return Fe(e,t)>0}function pr(e,t){let r;for(let n of e)En(n,t)&&(r=r&&rc(r,n)?r:n);return r}function dh(e){let r=e.match(tc)?.groups;if(!r)return null;let{operator:n,prerelease:o,buildmetadata:i}=r,a=r.major?{major:dt(r.major,Cannot parse comparator ${e}: invalid major version),minor:dt(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:dt(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:o?Pe(o):[],build:i?Ve(i):[]}:wn;return{operator:n||void 0,...a}}function le(e){return!e||e.toLowerCase()==="x"||e==="*"}function gh(e){if(!le(e.major))return le(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:le(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?Pe(e.prerelease):[],build:[]}}function hh(e){if(!le(e.major))return le(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:le(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:Pe(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:[],build:[]}}function xh(e){let t=e.match(new RegExp(^${yn})),r=t?.groups;if(!r)return null;let n=t[0].length,o=e.slice(n).match(/^\s+-\s+/);if(!o)return null;let i=o[0].length,s=e.slice(n+i).match(new RegExp(^${yn}\\s*$))?.groups;if(!s)return null;let l=gh(r),c=hh(s);return[l,c].filter(Boolean)}function yh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+e.minor,a=+e.patch;if(t)return[Jt];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:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}]:[{operator:">=",major:o,minor:i,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];let s=Pe(e.prerelease??"");return o===0?i===0?[{operator:">=",major:o,minor:i,patch:a,prerelease:s},{operator:"<",major:o,minor:i,patch:a+1}]:[{operator:">=",major:o,minor:i,patch:a,prerelease:s},{operator:"<",major:o,minor:i+1,patch:0}]:[{operator:">=",major:o,minor:i,patch:a,prerelease:s},{operator:"<",major:o+1,minor:0,patch:0}]}function bh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+e.minor,a=+e.patch;if(t)return[Jt];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:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}];let s=Pe(e.prerelease??"");return[{operator:">=",major:o,minor:i,patch:a,prerelease:s},{operator:"<",major:o,minor:i+1,patch:0}]}function Eh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+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:0,patch:0}];if(n)return[{operator:"<",major:o,minor:i,patch:0}];let s=Pe(e.prerelease??""),l=Ve(e.build??"");return[{operator:"<",major:o,minor:i,patch:a,prerelease:s,build:l}]}function wh(e){let t=le(e.minor),r=le(e.patch),n=+e.major,o=+e.minor,i=+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=Pe(e.prerelease??""),s=Ve(e.build??"");return[{operator:"<=",major:n,minor:o,patch:i,prerelease:a,build:s}]}function Rh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+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:i+1,patch:0}];let s=Pe(e.prerelease??""),l=Ve(e.build??"");return[{operator:">",major:o,minor:i,patch:a,prerelease:s,build:l}]}function kh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+e.minor,a=+e.patch;if(t)return[Jt];if(r)return n?[{operator:">=",major:o,minor:0,patch:0}]:[{operator:">=",major:o,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:i,patch:0}];let s=Pe(e.prerelease??""),l=Ve(e.build??"");return[{operator:">=",major:o,minor:i,patch:a,prerelease:s,build:l}]}function vh(e){let t=le(e.major),r=le(e.minor),n=le(e.patch),o=+e.major,i=+e.minor,a=+e.patch;if(t)return[Jt];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:i,patch:0},{operator:"<",major:o,minor:i+1,patch:0}];let s=Pe(e.prerelease??""),l=Ve(e.build??"");return[{operator:void 0,major:o,minor:i,patch:a,prerelease:s,build:l}]}function Th(e){let t=e.match(ec)?.groups;if(!t)return dh(e);switch(t.operator){case"^":return yh(t);case"~":case"~>":return bh(t);case"<":return Eh(t);case"<=":return wh(t);case">":return Rh(t);case">=":return kh(t);case"=":case"":return vh(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function Lh(e){return e.split(/\s+/).flatMap(Th)}function nc(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>xh(r)||Lh(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Lo(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>vo)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${vo});e=e.trim();let t=e.match(Xl)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=dt(t.major,Cannot parse version ${e}: invalid major version),n=dt(t.minor,Cannot parse version ${e}: invalid minor version),o=dt(t.patch,Cannot parse version ${e}: invalid patch version),i=t.prerelease?Pe(t.prerelease):[],a=t.buildmetadata?Ve(t.buildmetadata):[];return{major:r,minor:n,patch:o,prerelease:i,build:a}}function Co(e){try{return nc(e)}catch{return}}function So(e){try{return Lo(e)}catch{return}}var fr={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var gt=async e=>{try{let t=await fetch(e);return t.ok?ne([t,!1]):Q({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return Q({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return Q({name:"AbortError",message:t.message,request:e});throw t}};var Oo="https://jsr.io",oc=async(e,t)=>{let r=await(t?.fetch??gt)(new Request(${t?.endpoint??Oo}/${e}/meta.json),t?.cacheFirst);return St(r,([n])=>n.json())};var ic=async(e,t,r)=>{let n=await(r?.fetch??gt)(new Request(${r?.endpoint??Oo}/${e}/${t}_meta.json),r?.cacheFirst);return St(n,([o])=>o.json())};var sc=async(e,t)=>{let r=await(t?.fetch??gt)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return St(r,([n])=>n.json())};var cc=(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}),Rn=(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}),uc=async(e,t)=>{if(t?.resolvedVersions){let l=new Map(t.resolvedVersions.get(e.name)??[]),c=pr([...l.keys()],e.range);if(c){let u=l.get(c)??mr,p=u[e.entryPoint];return typeof p!="string"&&console.log(p),p?ne(ac(e.name,Nt(c),p)):Q(Rn(e,Object.keys(u)))}}let r=await sc(e.name,t);if(fe(r))return r;let n=Ne(r),o=new Map(Object.entries(n.versions).flatMap(([l,{exports:c}])=>{let u=So(l);return u?[[u,c??mr]]:[]})),i=pr([...o.keys()],e.range);if(!i)return Q(cc(e,Object.keys(n.versions)));let a={...mr};for(let l of Object.keys(o.get(i)??mr))a[l]=l;let s=a[e.entryPoint];return s?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[i,a]]),ne(ac(e.name,Nt(i),s))):Q(Rn(e,Object.keys(a)))},ac=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),pc=async(e,t)=>{if(t?.resolvedVersions){let s=new Map(t.resolvedVersions.get(e.name)??[]),l=pr([...s.keys()],e.range);if(l){let c=s.get(l)??mr,u=c[e.entryPoint];return u?ne(lc(e.name,Nt(l),u)):Q(Rn(e,Object.keys(c)))}}let r=await Ch(e,t);if(fe(r))return r;let n=Ne(r),o=await ic(e.name,Nt(n),t);if(fe(o))return o;let i=Ne(o).exports,a=i[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[n,i]]),ne(lc(e.name,Nt(n),a))):Q(Rn(e,Object.keys(Ne(o).exports)))},lc=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),Ch=async(e,t)=>{let r=await oc(e.name,t);if(fe(r))return r;let n=Ne(r),o=Object.keys(n.versions).flatMap(a=>{let s=So(a);return s?[s]:[]}),i=pr(o,e.range);return i?ne(i):Q(cc(e,Object.keys(n.versions)))},mr={".":"./"};var Sh=e=>({name:"OnlyScopeProvidedError",specifier:e}),fc=e=>({name:"PackageNotFoundError",specifier:e}),mc=e=>{if(e.protocol!=="npm:")return Q({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,n,o;if(t[r]==="@"){let p=t.indexOf("/",r);if(p===-1)return Q(Sh(e));n=t.indexOf("/",p+1),o=t.indexOf("@",p+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 Q(fc(e));let i=t.slice(r,o),a=decodeURIComponent(t.slice(o+1,n)),s=a?Co(a)??[[fr]]:[[fr]],l=t.slice(n+1),c=l?./${l}:".",u={name:i,range:s,entryPoint:c};return a&&(u.tag=a),ne(u)},dc=e=>{if(e.protocol!=="jsr:")return Q({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return Q({name:"ScopeNotFoundError",specifier:e});let n=t.indexOf("/",r);if(n===-1)return Q(fc(e));let o=t.indexOf("/",n+1),i=t.indexOf("@",n+1);o===-1&&(o=t.length),i===-1&&(i=t.length),i=Math.min(i,o);let a=t.slice(r,i),s=decodeURIComponent(t.slice(i+1,o)),l=s?Co(s)??[[fr]]:[[fr]],c=t.slice(o+1),u=c?./${c}:".",p={name:a,range:l,entryPoint:u};return s&&(p.tag=s),ne(p)};var gc=e=>new Promise((t,r)=>{let n=new FileReader;n.addEventListener("load",()=>{let o=n.result,i=o.indexOf(";");o.startsWith("; charset=utf-8",i)?t(${o.slice(0,i)}${o.slice(i+15)}):t(o)}),n.addEventListener("error",()=>r(n.error)),n.readAsDataURL(e)});var yc=e=>{let t=new Map,r=async n=>{let o=n.namespace==="npm",i=(o?mc:dc)(Eo(n));if(fe(i)){let s=pt(i);return{errors:[{text:s.name,detail:s}]}}let a=await(o?uc:pc)(Ne(i),{resolvedVersions:t,...e});if(fe(a)){let s=pt(a);return{errors:[{text:${s.name} ${s.message},detail:s}]}}return Bl(Ne(a))};return{name:"remote-loader",setup({onLoad:n,onResolve:o,initialOptions:i}){for(let a of[...hc,...xc])o({filter:/.*/,namespace:a.slice(0,-1)},Oh);o({filter:/.*/,namespace:"npm"},r),o({filter:/.*/,namespace:"jsr"},r);for(let a of hc)n({filter:/.*/,namespace:a.slice(0,-1)},s=>Ah(Eo(s),{...e,sourcemap:i.sourcemap!==!1&&i.sourcemap!==void 0}));for(let a of xc)n({filter:/.*/,namespace:a.slice(0,-1)},()=>{throw new Error(${a} import is not supported yet.)})}}},Oh=e=>({path:e.path,namespace:e.namespace}),hc=["http:","https:","data:"],xc=["node:"],Ah=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(c=>c.test(e)):!0,n=t.fetch??gt,o=await n(new Request(e),r);if(fe(o))return{errors:[{text:${pt(o).message} Failed to fetch ${e},detail:pt(o)}]};let[i,a]=Ne(o),s=Vl(i);t.onProgress?.({path:e,done:i.clone().blob().then(c=>({size:c.size,loader:s,isCache:a}))});let l=await i.blob();if(t.sourcemap&&Wl(s)){let c=await l.text(),u=Hl(c,e);if(we(u)){let{url:p,start:m,end:f}=Ne(u);if(p.protocol!=="data:"){let b=await n(new Request(p),r);if(fe(b))return{contents:c,loader:s,warnings:[{text:${pt(b).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${p}},{text:Original URL: ${e}}],detail:pt(b)}]};let A=await Ne(b)[0].blob().then(gc);return{contents:c.slice(0,m)+A+c.slice(f),loader:s}}}}return{contents:new Uint8Array(await l.arrayBuffer()),loader:s}};var hr=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,n,o,i){this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=o,this.modifier=i}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Nh=/[$_\p{ID_Start}]/u,Ph=/[$_\u200C\u200D\p{ID_Continue}]/u,No=".*";function Mh(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function wc(e,t=!1){let r=[],n=0;for(;n<e.length;){let o=e[n],i=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="",s=n+1;for(;s<e.length;){let l=e.substr(s,1);if(s===n+1&&Nh.test(l)||s!==n+1&&Ph.test(l)){a+=e[s++];continue}break}if(!a){i(Missing parameter name at ${n});continue}r.push({type:"NAME",index:n,value:a}),n=s;continue}if(o==="("){let a=1,s="",l=n+1,c=!1;if(e[l]==="?"){i(Pattern cannot start with "?" at ${l});continue}for(;l<e.length;){if(!Mh(e[l],!1)){i(Invalid character '${el}' at ${l}.),c=!0;break}if(e[l]==="\\"){s+=e[l++]+e[l++];continue}if(e[l]===")"){if(a--,a===0){l++;break}}else if(e[l]==="("&&(a++,e[l+1]!=="?")){i(Capturing groups are not allowed at ${l}),c=!0;break}s+=e[l++]}if(c)continue;if(a){i(Unbalanced pattern at ${n});continue}if(!s){i(Missing pattern at ${n});continue}r.push({type:"REGEX",index:n,value:s}),n=l;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function Rc(e,t={}){let r=wc(e);t.delimiter??="/#?",t.prefixes??="./";let n=^${Ie(t.delimiter)}+?,o=[],i=0,a=0,s="",l=new Set,c=E=>{if(a<r.length&&r[a].type===E)return r[a++].value},u=()=>c("OTHER_MODIFIER")??c("ASTERISK"),p=E=>{let R=c(E);if(R!==void 0)return R;let{type:w,index:h}=r[a];throw new TypeError(Unexpected ${w} at ${h}, expected ${E})},m=()=>{let E="",R;for(;R=c("CHAR")??c("ESCAPED_CHAR");)E+=R;return E},f=E=>E,b=t.encodePart||f,A="",N=E=>{A+=E},C=()=>{A.length&&(o.push(new hr(3,"","",b(A),"",3)),A="")},H=(E,R,w,h,S)=>{let O=3;switch(S){case"?":O=1;break;case"*":O=0;break;case"+":O=2;break}if(!R&&!w&&O===3){N(E);return}if(C(),!R&&!w){if(!E)return;o.push(new hr(3,"","",b(E),"",O));return}let _;w?w==="*"?_=No:_=w:_=n;let x=2;_===n?(x=1,_=""):_===No&&(x=0,_="");let v;if(R?v=R:w&&(v=i++),l.has(v))throw new TypeError(Duplicate name '${v}'.);l.add(v),o.push(new hr(x,v,b(E),_,b(h),O))};for(;a<r.length;){let E=c("CHAR"),R=c("NAME"),w=c("REGEX");if(!R&&!w&&(w=c("ASTERISK")),R||w){let S=E??"";t.prefixes.indexOf(S)===-1&&(N(S),S=""),C();let O=u();H(S,R,w,"",O);continue}let h=E??c("ESCAPED_CHAR");if(h){N(h);continue}if(c("OPEN")){let S=m(),O=c("NAME"),_=c("REGEX");!O&&!_&&(_=c("ASTERISK"));let x=m();p("CLOSE");let v=u();H(S,O,_,x,v);continue}C(),p("END")}return o}function Ie(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function bc(e){return e&&e.ignoreCase?"ui":"u"}function _h(e,t,r){return kc(Rc(e,r),t,r)}function Yt(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function kc(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 s of e){if(s.type===3){s.modifier===3?n+=Ie(s.value):n+=(?:${Ie(s.value)})${Yt(s.modifier)};continue}t&&t.push(s.name);let l=^${Ie(r.delimiter)}+?,c=s.value;if(s.type===1?c=l:s.type===0&&(c=No),!s.prefix.length&&!s.suffix.length){s.modifier===3||s.modifier===1?n+=(${c})${Yt(s.modifier)}:n+=((?:${c})${Yt(s.modifier)});continue}if(s.modifier===3||s.modifier===1){n+=(?:${Ie(s.prefix)}(${c})${Ie(s.suffix)}),n+=Yt(s.modifier);continue}n+=(?:${Ie(s.prefix)},n+=((?:${c})(?:,n+=Ie(s.suffix),n+=Ie(s.prefix),n+=(?:${c}))*)${Ie(s.suffix)}),s.modifier===0&&(n+="?")}let o=${Ie(r.endsWith)}|$,i=${Ie(r.delimiter)};if(r.end)return r.strict||(n+=${i}?),r.endsWith.length?n+=(?=${o}):n+="$",new RegExp(n,bc(r));r.strict||(n+=(?:${i}(?=${o}))?);let a=!1;if(e.length){let s=e[e.length-1];s.type===3&&s.modifier===3&&(a=r.delimiter.indexOf(s)>-1)}return a||(n+=(?=${i}|${o})),new RegExp(n,bc(r))}var xt={delimiter:"",prefixes:"",sensitive:!0,strict:!0},Fh={delimiter:".",prefixes:"",sensitive:!0,strict:!0},Ih={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Uh(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function vc(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function Dh(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function Tc(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var Lc=["ftp","file","http","https","ws","wss"];function Cc(e){if(!e)return!0;for(let t of Lc)if(e.test(t))return!0;return!1}function $h(e,t){if(e=vc(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 jh(e,t){if(e=vc(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 Bh(e,t){return t||e===""?e:Tc(e)?Ac(e):Oc(e)}function Hh(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function zh(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function Wh(e,t,r){if(r||e==="")return e;if(t&&!Lc.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 Vh(e,t,r){return Sc(t)===e&&(e=""),r||e===""?e:Nc(e)}function Gh(e,t){return e=Dh(e,":"),t||e===""?e:Po(e)}function Sc(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function Po(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function qh(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function Kh(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function Oc(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 Ac(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function Nc(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function Jh(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 Yh(e){return e===""?e:new URL(data:${e}).pathname}function Qh(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function Xh(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var Zh=class{#i;#r=[];#t={};#e=0;#o=1;#a=0;#n=0;#c=0;#u=0;#f=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#r=wc(this.#i,!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.#s(9,1):this.#d()?this.#s(8,1):this.#s(7,0);continue}else if(this.#n===2){this.#x(5);continue}this.#s(10,0);break}if(this.#c>0)if(this.#L())this.#c-=1;else continue;if(this.#T()){this.#c+=1;continue}switch(this.#n){case 0:this.#w()&&this.#x(1);break;case 1:if(this.#w()){this.#O();let e=7,t=1;this.#R()?(e=2,t=3):this.#f&&(e=2),this.#s(e,t)}break;case 2:this.#b()?this.#x(3):(this.#E()||this.#d()||this.#m())&&this.#x(5);break;case 3:this.#k()?this.#s(4,1):this.#b()&&this.#s(5,1);break;case 4:this.#b()&&this.#s(5,1);break;case 5:this.#C()?this.#u+=1:this.#S()&&(this.#u-=1),this.#v()&&!this.#u?this.#s(6,1):this.#E()?this.#s(7,0):this.#d()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 6:this.#E()?this.#s(7,0):this.#d()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 7:this.#d()?this.#s(8,1):this.#m()&&this.#s(9,1);break;case 8:this.#m()&&this.#s(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#s(e,t){switch(this.#n){case 0:break;case 1:this.#t.protocol=this.#p();break;case 2:break;case 3:this.#t.username=this.#p();break;case 4:this.#t.password=this.#p();break;case 5:this.#t.hostname=this.#p();break;case 6:this.#t.port=this.#p();break;case 7:this.#t.pathname=this.#p();break;case 8:this.#t.search=this.#p();break;case 9:this.#t.hash=this.#p();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]}#l(e,t){let r=this.#y(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#w(){return this.#l(this.#e,":")}#R(){return this.#l(this.#e+1,"/")&&this.#l(this.#e+2,"/")}#b(){return this.#l(this.#e,"@")}#k(){return this.#l(this.#e,":")}#v(){return this.#l(this.#e,":")}#E(){return this.#l(this.#e,"/")}#d(){if(this.#l(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.#l(this.#e,"#")}#T(){return this.#r[this.#e].type=="OPEN"}#L(){return this.#r[this.#e].type=="CLOSE"}#C(){return this.#l(this.#e,"[")}#S(){return this.#l(this.#e,"]")}#p(){let e=this.#r[this.#e],t=this.#y(this.#a).index;return this.#i.substring(t,e.index)}#O(){let e={};Object.assign(e,xt),e.encodePart=Po;let t=_h(this.#p(),void 0,e);this.#f=Cc(t)}},Ao=["protocol","username","password","hostname","port","pathname","search","hash"],ht="*";function Ec(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 ot(e,t){return t?gr(e):e}function dr(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=ot(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=ot(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=ot(n.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=ot(n.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=ot(n.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=ot(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=ot(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=ot(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=Gh(t.protocol,r)),typeof t.username=="string"&&(e.username=zh(t.username,r)),typeof t.password=="string"&&(e.password=Hh(t.password,r)),typeof t.hostname=="string"&&(e.hostname=Bh(t.hostname,r)),typeof t.port=="string"&&(e.port=Vh(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!Uh(e.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(e.pathname=ot(n.pathname.substring(0,o+1),r)+e.pathname)}e.pathname=Wh(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=jh(t.search,r)),typeof t.hash=="string"&&(e.hash=$h(t.hash,r)),e}function gr(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function ex(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function tx(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",n=^${ex(t.delimiter)}+?,o=/[$_\u200C\u200D\p{ID_Continue}]/u,i="";for(let a=0;a<e.length;++a){let s=e[a];if(s.type===3){if(s.modifier===3){i+=gr(s.value);continue}i+={${gr(s.value)}}${Yt(s.modifier)};continue}let l=s.hasCustomName(),c=!!s.suffix.length||!!s.prefix.length&&(s.prefix.length!==1||!t.prefixes.includes(s.prefix)),u=a>0?e[a-1]:null,p=a<e.length-1?e[a+1]:null;if(!c&&l&&s.type===1&&s.modifier===3&&p&&!p.prefix.length&&!p.suffix.length)if(p.type===3){let m=p.value.length>0?p.value[0]:"";c=o.test(m)}else c=!p.hasCustomName();if(!c&&!s.prefix.length&&u&&u.type===3){let m=u.value[u.value.length-1];c=t.prefixes.includes(m)}c&&(i+="{"),i+=gr(s.prefix),l&&(i+=:${s.name}),s.type===2?i+=(${s.value}):s.type===1?l||(i+=(${n})):s.type===0&&(!l&&(!u||u.type===3||u.modifier!==3||c||s.prefix!=="")?i+="*":i+=(${r})),s.type===1&&l&&s.suffix.length&&o.test(s.suffix[0])&&(i+="\\"),i+=gr(s.suffix),c&&(i+="}"),s.modifier!==3&&(i+=Yt(s.modifier))}return i}var Pc=class{#i;#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 s=new Zh(e);if(s.parse(),e=s.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},i={pathname:ht,protocol:ht,username:ht,password:ht,hostname:ht,port:ht,search:ht,hash:ht};this.#i=dr(i,e,!0),Sc(this.#i.protocol)===this.#i.port&&(this.#i.port="");let a;for(a of Ao){if(!(a in this.#i))continue;let s={},l=this.#i[a];switch(this.#t[a]=[],a){case"protocol":Object.assign(s,xt),s.encodePart=Po;break;case"username":Object.assign(s,xt),s.encodePart=qh;break;case"password":Object.assign(s,xt),s.encodePart=Kh;break;case"hostname":Object.assign(s,Fh),Tc(l)?s.encodePart=Ac:s.encodePart=Oc;break;case"port":Object.assign(s,xt),s.encodePart=Nc;break;case"pathname":Cc(this.#r.protocol)?(Object.assign(s,Ih,o),s.encodePart=Jh):(Object.assign(s,xt,o),s.encodePart=Yh);break;case"search":Object.assign(s,xt,o),s.encodePart=Qh;break;case"hash":Object.assign(s,xt,o),s.encodePart=Xh;break}try{this.#o[a]=Rc(l,s),this.#r[a]=kc(this.#o[a],this.#t[a],s),this.#e[a]=tx(this.#o[a],s),this.#a=this.#a||this.#o[a].some(c=>c.type===2)}catch{throw new TypeError(invalid ${a} pattern '${this.#ia}'.)}}}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=dr(r,e,!1):r=dr(r,Ec(e,t),!1)}catch{return!1}let n;for(n of Ao)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=dr(r,e,!1):r=dr(r,Ec(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let o;for(o of Ao){let i=this.#r[o].exec(r[o]);if(!i)return null;let a={};for(let[s,l]of this.#t[o].entries())if(typeof l=="string"||typeof l=="number"){let c=i[s+1];a[l]=c}n[o]={input:r[o]??"",groups:a}}return n}static compareComponent(e,t,r){let n=(s,l)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(s[c]<l[c])return-1;if(s[c]!==l[c])return 1}return 0},o=new hr(3,"","","","",3),i=new hr(0,"","","","",3),a=(s,l)=>{let c=0;for(;c<Math.min(s.length,l.length);++c){let u=n(s[c],l[c]);if(u)return u}return s.length===l.length?0:n(s[c]??o,l[c]??o)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?a(t.#o[e],[i]):!t.#e[e]&&r.#e[e]?a([i],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=Pc);var Mc,_c=async(e,t)=>(Mc??=Yr({wasmModule:e,workerURL:t}),await Mc,async r=>{let{outputFiles:n}=await Kr({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[xl(),yc({fetch:rx,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:n[0].text}}),rx=async(e,t)=>{let r=Tl(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let n=await Mo(e);if(n)return n}try{let n=await r(e);return n.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await br(e,n),ne([n,!1])):await Mo(e)??Q({name:"HTTPError",message:${n.status} ${n.statusText},response:n})}catch(n){let o=await Mo(e);if(o)return o;if(n instanceof TypeError)return Q({name:"NetworkError",message:n.message,request:e});if(n instanceof DOMException)return Q({name:"AbortError",message:n.message,request:e});throw n}},Mo=async e=>{if(e.url.startsWith("data:"))return;let t=await yr(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),ne([t,!0])};var Fc=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var Ic=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},Uc=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},Dc=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},$c=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var jc=()=>{let e;return{show:(n,{x:o,y:i})=>{e=nx(),e.append(ox(n)),e.style.visibility="hidden",document.body.append(e);let{height:a}=e.getBoundingClientRect();e.style.top=${i-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?.()}}},nx=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},ox=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 Bc=()=>{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}=jc();return{component:e,setStatus:async(i,a)=>{switch(e.textContent="",await n(),i){case"loading":e.append(Dc());break;case"pass":e.append(Ic());break;case"fail":e.append(Uc());break;case"none":break}a!==void 0&&i!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await n();else{let{top:s,left:l}=e.getBoundingClientRect();r(a,{y:s+globalThis.scrollY,x:l})}t=!t}):e.style.pointerEvents="none"}}};var Hc=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append($c()),t.addEventListener("click",e),t};var zc=e=>{let{component:t,setStatus:r}=Bc(),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(Hc(e),t),{menu:n,setStatus:r}};function Wc(e){return new Promise(t=>setTimeout(t,e))}function Vc(e,t){let{trailing:r=!1,interval:n=0}=t??{},o,i=!1,a=c=>{o?.resolve?.({executed:!1}),o=c},s=()=>{let{...c}=o;return o=void 0,c},l=async()=>{if(i||!o)return;i=!0,n>0&&await Wc(n);let{parameters:c,resolve:u,reject:p}=s();try{let m=await e(...c);i=!1,u({result:m,executed:!0})}catch(m){i=!1,p(m)}finally{r?await l():(a(),await Promise.resolve())}};return(...c)=>new Promise((u,p)=>{a({parameters:c,resolve:u,reject:p}),l()})}var Gc,qc=async(e,t)=>{let r=[],o=Vc(async()=>{r.forEach(({menu:a,setStatus:s})=>{s("none"),a.remove()});let i=_a(scrapbox.Project.name,scrapbox.Page.title??"",Cn());for(let a of i){let s=a.lang.toLowerCase();if(Fc(s))for(let l of a.startIds){let c=document.getElementById(L${l}),{menu:u,setStatus:p}=zc(async()=>{await p("loading");try{Gc??=await _c(e,t);let{contents:m}=await Gc(a.path);console.debug("execute:",m),await Function(return (async()=>{${m}})())(),await p("pass")}catch(m){console.error(m),await p("fail",${m}`)}});r.push({menu:u,setStatus:p}),c?.insertBefore?.(u,c?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await o(),scrapbox.addListener("lines:changed",o),()=>{scrapbox.removeListener("lines:changed",o),r.forEach(({menu:i,setStatus:a})=>{a("none"),i.remove()})}};var ix="https://scrapbox.io/files/6730bb5886d646fa1d630a2a.wasm",sx="https://scrapbox.io/api/code/yosider-scripts/esbuild-wasm-no-blob-min/worker.js";(async()=>{let e=new Request(ix),t=await yr(e)||await ax(e);await qc(await WebAssembly.compileStreaming(t),sx)})();async function ax(e){let t=await fetch(e);return await br(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),Ft={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:">"},zt=e=>{let t=e.toLowerCase();return Ce(Ft,t)?Ftt:e},Ut={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(Ut,e)?Ut[e][t?1:0]:e},Kt={"<":"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=zt(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(Kt,r)&&(r=Kt[r]),n||r.length>1?<${n}${r}>:r},qt={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:zt(n)};for(let s of r.split("-").slice(0,-1)){let a=s.toLowerCase();if(!Ce(qt,a))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let l=qt[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}},Gt=e=>{let t=vo(e);return t.ok?{ok:!0,value:ut(t.value)}:t},Wt=e=>e.match(/<[^<>\s]+>|[\s\S]|^$/g);var A=!1;var Xt=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=Xt("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=Yt(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=Yt(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"},Yt=e=>{let t=Wt(e);if(!t)return{ok:!1,value:[Eo]};let r="",n=[];for(let o of t){let s=Gt(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 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,mt=()=>{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))}),mt=void 0},Re=(e,t,r)=>{mt?.();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 gt(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)},gt=(e,t,r)=>{mt?.();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 ht()});async function ht(){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),ht()}};var{render:Io}=rr(),bt,Ro=e=>{bt!==void 0&&cancelAnimationFrame(bt),bt=requestAnimationFrame(()=>Io({type:"text",text:e}))},cr=new Ne({addEventListener:Re,removeEventListener:gt},{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 xt(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,yt(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}yt(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 yt(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=[],yt(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 vt(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(xt)},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),xt(this))},$e.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),xt(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,Et=[],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&&kt(r.__H,t)&&(r.__=e,r.__H=t,R.__H.__h.push(r))}function ze(e,t){var r=ye(ne++,4);!h.__s&&kt(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 kt(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(Et.sort(function(t,r){return t.__v.__b-r.__v.__b});e=Et.pop();)if(e.__P)try{e.__H.__h.forEach(qe),e.__H.__h.forEach(wt),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(wt),t.__h=[])},h.diffed=function(e){Pr&&Pr(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(Et.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.__||wt(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 wt(e){var t=R;e.__c=e.__(),R=t}function kt(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 Lt=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 _t=Ye(),Ve=new Map,Ii=Y("ScrapBubble:useProject.ts"),yn=e=>{let[t,r]=M();return D(()=>{_t.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}),_t.dispatch(e,a);break}}catch(o){Ii.error(o),Ve.delete(e)}})()),()=>_t.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?()=>{Lt({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 Pt(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 Ct(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 Rt(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])=>Rt(n,!0))),e}function Ki(){F(2)}function ot(e){return Object.isFrozen(e)}var Nt={};function ee(e){let t=Nt[e];return t||F(0,e),t}function qi(e,t){Nt[e]||(Nt[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 St(e){It(e),e.drafts_.forEach(Gi),e.drafts_=null}function It(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_&&(St(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,[]),St(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&&!Pt(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_&&Rt(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=Bt;r&&(o=[n],s=Te);let{revoke:a,proxy:l}=Proxy.revocable(o,s);return n.draft_=l,n.revoke_=a,l}var Bt={get(e,t){if(t===y)return e;let r=N(e);if(!Pt(r,t))return Xi(e,r,t);let n=r[t];return e.finalized_||!z(n)?n:n===Tt(e.base_,t)?(Mt(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=Tt(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||Pt(e.base_,t)))return!0;Mt(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 Tt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mt(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(Bt,(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 Bt.set.call(this,e[0],t,r,e[0])};function Tt(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 Mt(e){e.copy_||(e.copy_=Ct(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?St(s):It(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_&&Rt(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,It(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=Ct(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Ct(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),Ht(t)||(r.lines=n),o&&(r.linked??=o),s&&(r.projectLinked??=s);return}Ht(r)&&!Ht(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)}),Ht=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"),Ot=new Map,ct=new Set,Dt=Ye();function*qn(e){for(let t of e)yield Ot.get(t)}var zn=(e,t)=>Dt.on(e,t),Gn=(e,t)=>Dt.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=Ot.get(g),b=Fn(f,p);b&&f!==b&&(Ot.set(g,b),Dt.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 $t=(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 $t(e,r.nodes)}});var V=vt({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:$t(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 jt=(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 At="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 jt(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]),jt(document,"click",i=>{i.target.dataset.userscriptName!==At&&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=At,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