scrapbubble-min
code:script.js
var He,w,rr,On,oe,Zt,or,pt,gt,ut,dt,nr,_e={},sr=[],Bn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,ht=Array.isArray;function J(e,t){for(var r in t)er=tr;return e}function ir(e){var t=e.parentNode;t&&t.removeChild(e)}function ar(e,t,r){var o,n,s,a={};for(s in t)s=="key"?o=ts:s=="ref"?n=ts:as=ts;if(arguments.length>2&&(a.children=arguments.length>3?He.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)as===void 0&&(as=e.defaultPropss);return Oe(e,a,o,n,null)}function Oe(e,t,r,o,n){var s={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++rr,__i:-1,__u:0};return n==null&&w.vnode!=null&&w.vnode(s),s}function P(e){return e.children}function Be(e,t){this.props=e,this.context=t}function ne(e,t){if(t==null)return e.__?ne(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__kt)!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?ne(e):null}function cr(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.__kt)!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return cr(e)}}function mt(e){(!e.__d&&(e.__d=!0)&&oe.push(e)&&!je.__r++||Zt!==w.debounceRendering)&&((Zt=w.debounceRendering)||or)(je)}function je(){var e,t,r,o,n,s,a,c;for(oe.sort(pt);e=oe.shift();)e.__d&&(t=oe.length,o=void 0,s=(n=(r=e).__v).__e,a=[],c=[],r.__P&&((o=J({},n)).__v=n.__v+1,w.vnode&&w.vnode(o),bt(r.__P,o,n,r.__n,r.__P.namespaceURI,32&n.__u?s:null,a,s??ne(n),!!(32&n.__u),c),o.__v=n.__v,o.__.__ko.__i=o,ur(a,o,c),o.__e!=s&&cr(o)),oe.length>t&&oe.sort(pt));je.__r=0}function lr(e,t,r,o,n,s,a,c,i,l,m){var p,g,d,f,b,L=o&&o.__k||sr,y=t.length;for(r.__d=i,jn(r,t,L),i=r.__d,p=0;p<y;p++)(d=r.__kp)!=null&&typeof d!="boolean"&&typeof d!="function"&&(g=d.__i===-1?_e:Ld.__i||_e,d.__i=p,bt(e,d,g,n,s,a,c,i,l,m),f=d.__e,d.ref&&g.ref!=d.ref&&(g.ref&&yt(g.ref,null,d),m.push(d.ref,d.__c||f,d)),b==null&&f!=null&&(b=f),65536&d.__u||g.__k===d.__k?i=pr(d,i,e):typeof d.type=="function"&&d.__d!==void 0?i=d.__d:f&&(i=f.nextSibling),d.__d=void 0,d.__u&=-196609);r.__d=i,r.__e=b}function jn(e,t,r){var o,n,s,a,c,i=t.length,l=r.length,m=l,p=0;for(e.__k=[],o=0;o<i;o++)a=o+p,(n=e.__ko=(n=to)==null||typeof n=="boolean"||typeof n=="function"?null:typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?Oe(null,n,null,null,null):ht(n)?Oe(P,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?Oe(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)!=null?(n.__=e,n.__b=e.__b+1,c=Hn(n,r,a,m),n.__i=c,s=null,c!==-1&&(m--,(s=rc)&&(s.__u|=131072)),s==null||s.__v===null?(c==-1&&p--,typeof n.type!="function"&&(n.__u|=65536)):c!==a&&(c==a-1?p=c-a:c==a+1?p++:c>a?m>i-a?p+=c-a:p--:c<a&&p++,c!==o+p&&(n.__u|=65536))):(s=ra)&&s.key==null&&s.__e&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=ne(s)),ft(s,s,!1),ra=null,m--);if(m)for(o=0;o<l;o++)(s=ro)!=null&&!(131072&s.__u)&&(s.__e==e.__d&&(e.__d=ne(s)),ft(s,s))}function pr(e,t,r){var o,n;if(typeof e.type=="function"){for(o=e.__k,n=0;o&&n<o.length;n++)on&&(on.__=e,t=pr(on,t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=ne(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function Hn(e,t,r,o){var n=e.key,s=e.type,a=r-1,c=r+1,i=tr;if(i===null||i&&n==i.key&&s===i.type&&!(131072&i.__u))return r;if(o>(i!=null&&!(131072&i.__u)?1:0))for(;a>=0||c<t.length;){if(a>=0){if((i=ta)&&!(131072&i.__u)&&n==i.key&&s===i.type)return a;a--}if(c<t.length){if((i=tc)&&!(131072&i.__u)&&n==i.key&&s===i.type)return c;c++}}return-1}function er(e,t,r){t0==="-"?e.setProperty(t,r??""):et=r==null?"":typeof r!="number"||Bn.test(t)?r:r+"px"}function Fe(e,t,r,o,n){var s;e:if(t==="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)r&&t in r||er(e.style,t,"");if(r)for(t in r)o&&rt===ot||er(e.style,t,rt)}else if(t0==="o"&&t1==="n")s=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.lt+s=r,r?o?r.u=o.u:(r.u=gt,e.addEventListener(t,s?dt:ut,s)):e.removeEventListener(t,s?dt:ut,s);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{et=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t4!=="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function tr(e){return function(t){if(this.l){var r=this.lt.type+e;if(t.t==null)t.t=gt++;else if(t.t<r.u)return;return r(w.event?w.event(t):t)}}}function bt(e,t,r,o,n,s,a,c,i,l){var m,p,g,d,f,b,L,y,T,re,Y,Se,Ee,Jt,Ie,lt,G=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(i=!!(32&r.__u),s=c=t.__e=r.__e),(m=w.__b)&&m(t);e:if(typeof G=="function")try{if(y=t.props,T="prototype"in G&&G.prototype.render,re=(m=G.contextType)&&om.__c,Y=m?re?re.props.value:m.__:o,r.__c?L=(p=t.__c=r.__c).__=p.__E:(T?t.__c=p=new G(y,Y):(t.__c=p=new Be(y,Y),p.constructor=G,p.render=$n),re&&re.sub(p),p.props=y,p.state||(p.state={}),p.context=Y,p.__n=o,g=p.__d=!0,p.__h=[],p._sb=[]),T&&p.__s==null&&(p.__s=p.state),T&&G.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=J({},p.__s)),J(p.__s,G.getDerivedStateFromProps(y,p.__s))),d=p.props,f=p.state,p.__v=t,g)T&&G.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),T&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(T&&G.getDerivedStateFromProps==null&&y!==d&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(y,Y),!p.__e&&(p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(y,p.__s,Y)===!1||t.__v===r.__v)){for(t.__v!==r.__v&&(p.props=y,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(Me){Me&&(Me.__=t)}),Se=0;Se<p._sb.length;Se++)p.__h.push(p._sbSe);p._sb=[],p.__h.length&&a.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(y,p.__s,Y),T&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(d,f,b)})}if(p.context=Y,p.props=y,p.__P=e,p.__e=!1,Ee=w.__r,Jt=0,T){for(p.state=p.__s,p.__d=!1,Ee&&Ee(t),m=p.render(p.props,p.state,p.context),Ie=0;Ie<p._sb.length;Ie++)p.__h.push(p._sbIe);p._sb=[]}else do p.__d=!1,Ee&&Ee(t),m=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++Jt<25);p.state=p.__s,p.getChildContext!=null&&(o=J(J({},o),p.getChildContext())),T&&!g&&p.getSnapshotBeforeUpdate!=null&&(b=p.getSnapshotBeforeUpdate(d,f)),lr(e,ht(lt=m!=null&&m.type===P&&m.key==null?m.props.children:m)?lt:lt,t,r,o,n,s,a,c,i,l),p.base=t.__e,t.__u&=-161,p.__h.length&&a.push(p),L&&(p.__E=p.__=null)}catch(Me){if(t.__v=null,i||s!=null){for(t.__u|=i?160:32;c&&c.nodeType===8&&c.nextSibling;)c=c.nextSibling;ss.indexOf(c)=null,t.__e=c}else t.__e=r.__e,t.__k=r.__k;w.__e(Me,t,r)}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=An(r.__e,t,r,o,n,s,a,i,l);(m=w.diffed)&&m(t)}function ur(e,t,r){t.__d=void 0;for(var o=0;o<r.length;o++)yt(ro,r++o,r++o);w.__c&&w.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(s){s.call(n)})}catch(s){w.__e(s,n.__v)}})}function An(e,t,r,o,n,s,a,c,i){var l,m,p,g,d,f,b,L=r.props,y=t.props,T=t.type;if(T==="svg"?n="http://www.w3.org/2000/svg":T==="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((d=s[l])&&"setAttribute"in d==!!T&&(T?d.localName===T:d.nodeType===3)){e=d,sl=null;break}}if(e==null){if(T===null)return document.createTextNode(y);e=document.createElementNS(n,T,y.is&&y),s=null,c=!1}if(T===null)L===y||c&&e.data===y||(e.data=y);else{if(s=s&&He.call(e.childNodes),L=r.props||_e,!c&&s!=null)for(L={},l=0;l<e.attributes.length;l++)L[(d=e.attributesl).name]=d.value;for(l in L)if(d=Ll,l!="children"){if(l=="dangerouslySetInnerHTML")p=d;else if(l!=="key"&&!(l in y)){if(l=="value"&&"defaultValue"in y||l=="checked"&&"defaultChecked"in y)continue;Fe(e,l,null,d,n)}}for(l in y)d=yl,l=="children"?g=d:l=="dangerouslySetInnerHTML"?m=d:l=="value"?f=d:l=="checked"?b=d:l==="key"||c&&typeof d!="function"||Ll===d||Fe(e,l,d,Ll,n);if(m)c||p&&(m.__html===p.__html||m.__html===e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(p&&(e.innerHTML=""),lr(e,ht(g)?g:g,t,r,o,T==="foreignObject"?"http://www.w3.org/1999/xhtml":n,s,a,s?s[0]:r.__k&&ne(r,0),c,i),s!=null)for(l=s.length;l--;)s[l]!=null&&ir(s[l]);c||(l="value",f!==void 0&&(f!==el||T==="progress"&&!f||T==="option"&&f!==Ll)&&Fe(e,l,f,Ll,n),l="checked",b!==void 0&&b!==el&&Fe(e,l,b,Ll,n))}return e}function yt(e,t,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(n){w.__e(n,r)}}function ft(e,t,r){var o,n;if(w.unmount&&w.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||yt(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){w.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)on&&ft(on,t,r||typeof e.type!="function");r||e.__e==null||ir(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function $n(e,t,r){return this.constructor(e,r)}function xt(e,t,r){var o,n,s,a;w.__&&w.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],a=[],bt(t,e=(!o&&r||t).__k=ar(P,null,e),n||_e,_e,t.namespaceURI,!o&&r?r:n?null:t.firstChild?He.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o,a),ur(s,e,a)}function Et(e,t){var r={__c:t="__cC"+nr++,__:e,Consumer:function(o,n){return o.children(n)},Provider:function(o){var n,s;return this.getChildContext||(n=[],(s={})t=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(a){this.props.value!==a.value&&n.some(function(c){c.__e=!0,mt(c)})},this.sub=function(a){n.push(a);var c=a.componentWillUnmount;a.componentWillUnmount=function(){n&&n.splice(n.indexOf(a),1),c&&c.call(a)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}He=sr.slice,w={__e:function(e,t,r,o){for(var n,s,a;t=t.__;)if((n=t.__c)&&!n.__)try{if((s=n.constructor)&&s.getDerivedStateFromError!=null&&(n.setState(s.getDerivedStateFromError(e)),a=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,o||{}),a=n.__d),a)return n.__E=n}catch(c){e=c}throw e}},rr=0,On=function(e){return e!=null&&e.constructor==null},Be.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=J({},this.state),typeof e=="function"&&(e=e(J({},r),this.props)),e&&J(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),mt(this))},Be.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),mt(this))},Be.prototype.render=P,oe=[],or=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,pt=function(e,t){return e.__v.__b-t.__v.__b},je.__r=0,gt=0,ut=tr(!1),dt=tr(!0),nr=0;var se,C,_t,dr,ke=0,Er=[],F=w,mr=F.__b,fr=F.__r,gr=F.diffed,hr=F.__c,br=F.unmount,yr=F.__;function Te(e,t){F.__h&&F.__h(C,e,ke||t),ke=0;var r=C.__H||(C.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function A(e){return ke=1,Dn(kr,e)}function Dn(e,t,r){var o=Te(se++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):kr(void 0,t),function(c){var i=o.__N?o.__N0:o.__0,l=o.t(i,c);i!==l&&(o.__N=[l,o.__1],o.__c.setState({}))}],o.__c=C,!C.u)){var n=function(c,i,l){if(!o.__c.__H)return!0;var m=o.__c.__H.__.filter(function(g){return!!g.__c});if(m.every(function(g){return!g.__N}))return!s||s.call(this,c,i,l);var p=!1;return m.forEach(function(g){if(g.__N){var d=g.__0;g.__=g.__N,g.__N=void 0,d!==g.__0&&(p=!0)}}),!(!p&&o.__c.props===c)&&(!s||s.call(this,c,i,l))};C.u=!0;var s=C.shouldComponentUpdate,a=C.componentWillUpdate;C.componentWillUpdate=function(c,i,l){if(this.__e){var m=s;s=void 0,n(c,i,l),s=m}a&&a.call(this,c,i,l)},C.shouldComponentUpdate=n}return o.__N||o.__}function W(e,t){var r=Te(se++,3);!F.__s&&wt(r.__H,t)&&(r.__=e,r.i=t,C.__H.__h.push(r))}function _r(e,t){var r=Te(se++,4);!F.__s&&wt(r.__H,t)&&(r.__=e,r.i=t,C.__h.push(r))}function Tt(e){return ke=5,N(function(){return{current:e}},[])}function N(e,t){var r=Te(se++,7);return wt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function $(e,t){return ke=8,N(function(){return e},t)}function Z(e){var t=C.contexte.__c,r=Te(se++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(C)),t.props.value):e.__}function Un(){for(var e;e=Er.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ae),e.__H.__h.forEach(kt),e.__H.__h=[]}catch(t){e.__H.__h=[],F.__e(t,e.__v)}}F.__b=function(e){C=null,mr&&mr(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),yr&&yr(e,t)},F.__r=function(e){fr&&fr(e),se=0;var t=(C=e.__c).__H;t&&(_t===C?(t.__h=[],C.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Ae),t.__h.forEach(kt),t.__h=[],se=0)),_t=C},F.diffed=function(e){gr&&gr(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Er.push(t)!==1&&dr===F.requestAnimationFrame||((dr=F.requestAnimationFrame)||qn)(Un)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),_t=C=null},F.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Ae),r.__h=r.__h.filter(function(o){return!o.__||kt(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],F.__e(o,r.__v)}}),hr&&hr(e,t)},F.unmount=function(e){br&&br(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Ae(o)}catch(n){t=n}}),r.__H=void 0,t&&F.__e(t,r.__v))};var xr=typeof requestAnimationFrame=="function";function qn(e){var t,r=function(){clearTimeout(o),xr&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,100);xr&&(t=requestAnimationFrame(r))}function Ae(e){var t=C,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),C=t}function kt(e){var t=C;e.__c=e.__(),C=t}function wt(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==eo})}function kr(e,t){return typeof t=="function"?t(e):t}var Tr=" must not return ",zn="transformer",Kn="recoverer",Gn="defaultValue",Pa=zn+Tr,wr="called with ",Na=Gn+" must not be ",La=Kn+Tr,Wn="Ok",vr="Err",Qn=wr+vr,Ra=wr+Wn,Ca="Carrying E in "+vr+" instead of throwing it directly. See .cause",vt="an instance of Error of the current realm.",Sa="The thrown value is not "+vt,Ia="The contained E should be "+vt,Ma="This .cause is not "+vt;function Pt(e){return e.ok}function Q(e){return{ok:!0,val:e,err:null}}function R(e){return!e.ok}function pe(e){return{ok:!1,val:null,err:e}}function v(e){return Vn(e,Qn)}function Vn(e,t){if(!e.ok)throw new TypeError(t);return e.val}async function Nt(e,t){if(R(e))return e;let r=v(e);return await t(r)}async function S(e,t){if(R(e))return e;let r=v(e),o=await t(r);return Q(o)}async function O(e,t){if(Pt(e))return e;let r=await t(e.err);return pe(r)}var I=e=>e.ok?Q(e):pe({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Pr=async(e,t)=>{let r=new Request(e,t);try{return Q(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return pe({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return pe({name:"NetworkError",message:o.message,request:r});throw o}};var E=e=>{let{fetch:t=Pr,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Nr=e=>{let{sid:t,hostName:r}=E(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:M(t)}}:void 0)},Lr=e=>S(I(e),async t=>await t.json()),Lt=async e=>{let{fetch:t,...r}=E(e??{}),o=await t(Nr(r));return R(o)?o:Lr(v(o))};Lt.toRequest=Nr;Lt.fromResponse=Lr;var M=e=>connect.sid=${e};function $e(e,t={}){if(e===null)return"null";if(Array.isArray(e))return Yn(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:Jn(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function Yn(e,t){let{threshold:r=20}=t,o=e.map(a=>$e(a,t)),n=o.join(", ");if(n.length<=r)return[${n}];let s=o.join(`, );return[
${Rr(2,s)}
]}function Jn(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(a=>${a.toString()}: ${$e(ea,t)}),n=o.join(", ");if(n.length<=r)return{${n}};let s=o.join(, );return{
${Rr(2,s)}
}}function Rr(e,t){let r=" ".repeat(e);return t.split(
).map(o=>${r}${o}).join(
)}function De(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${t}(${r.map(n=>$e(n)).join(", ")}),o)}})}function Ue(e){return Array.isArray(e)}function Cr(e){return De(t=>Ue(t)&&t.every(e),"isArrayOf",e)}function Rt(e){let t=new Set(e);return De(r=>t.has(r),"isLiteralOneOf",e)}function Ct(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function ie(e){return typeof e=="string"}var B=async(e,t)=>{let r=e.response.clone(),o=Rt(t);try{let n=await r.json();if(!Ct(n))return;if(r.status===422){if(!ie(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!ie(n.message)?void 0:n.name==="NotLoggedInError"?!Ct(n.detals)||!ie(n.detals.project)||!Cr(Zn)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},Zn=Rt(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var D=e=>e.replaceAll(" ","_").toLowerCase();var j=e=>[...e].map((t,r)=>t===" "?"_":!es.includes(t)||r===e.length-1&&ts.includes(t)?encodeURIComponent(t):t).join(""),es='@$&+=:;",',ts=':;",';var Sr=" must not return ",rs="transformer",os="recoverer",ns="defaultValue",ss=rs+Sr,is="called with ",as=ns+" must not be ",cs=os+Sr,qe="null or undefined",fc=ss+qe,gc=is+qe,ls=as+qe,hc=cs+qe;function Ir(e){return e!=null}function ps(e,t){if(Ir(e))return e;throw new TypeError(t)}function St(e,t){return Ir(e)?e:ps(t,ls)}var Mr=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:a}=E(r??{}),c=new URLSearchParams;c.append("followRename",${s??!0});for(let i of a??[])c.append("projects",i);return new Request(https://${n}/api/pages/${e}/${j(t)}?${c},o?{headers:{Cookie:M(o)}}:void 0)},Fr=async e=>O(await S(I(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:St(await B(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),we=async(e,t,r)=>Nt(await E(r??{}).fetch(Mr(e,t,r)),o=>Fr(o));we.toRequest=Mr;we.fromResponse=Fr;var Or=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:a}=E(t??{}),c=new URLSearchParams;return n!==void 0&&c.append("sort",n),s!==void 0&&c.append("limit",${s}),a!==void 0&&c.append("skip",${a}),new Request(https://${o}/api/pages/${e}?${c},r?{headers:{Cookie:M(r)}}:void 0)},Br=async e=>O(await S(I(e),t=>t.json()),async t=>St(await B(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),jr=async(e,t)=>Nt(await E(t??{})?.fetch(Or(e,t)),Br);jr.toRequest=Or;jr.fromResponse=Br;var Hr=(e,t,r,o)=>{let{sid:n,hostName:s}=E(o??{}),a=https://${s}/api/table/${e}/${j(t)}/${encodeURIComponent(r)}.csv;return new Request(a,n?{headers:{Cookie:M(n)}}:void 0)},Ar=async e=>S(await O(I(e),async t=>t.response.status===404?{name:"NotFoundError",message:"Table not found."}:await B(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),$r=async(e,t,r,o)=>{let{fetch:n}=E(o??{}),s=Hr(e,t,r,o),a=await n(s);return R(a)?a:await Ar(v(a))};$r.toRequest=Hr;$r.fromResponse=Ar;var Dr=(e,t)=>{let{sid:r,hostName:o}=E(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:M(r)}}:void 0)},Ur=async e=>S(await O(I(e),async t=>await B(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),ve=async(e,t)=>{let{fetch:r}=E(t??{}),o=Dr(e,t),n=await r(o);return R(n)?n:Ur(v(n))};ve.toRequest=Dr;ve.fromResponse=Ur;var qr=(e,t)=>{let{sid:r,hostName:o}=E(t??{}),n=new URLSearchParams;for(let s of e)n.append("ids",s);return new Request(https://${o}/api/projects?${n.toString()},r?{headers:{Cookie:M(r)}}:void 0)},zr=async e=>S(await O(I(e),async t=>await B(t,["NotLoggedInError"])??t),t=>t.json()),ze=async(e,t)=>{let{fetch:r}=E(t??{}),o=await r(qr(e,t));return R(o)?o:zr(v(o))};ze.toRequest=qr;ze.fromResponse=zr;var Kr=(e,t)=>{let{sid:r,hostName:o,followingId:n}=E(t??{});return new Request(https://${o}/api/pages/${e}/search/titles${n??followingId=${n}:""},r?{headers:{Cookie:M(r)}}:void 0)},Gr=async e=>S(await O(I(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await B(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),Wr=async(e,t)=>{let r=await E(t??{}).fetch(Kr(e,t));return R(r)?r:Gr(v(r))};Wr.toRequest=Kr;Wr.fromResponse=Gr;var Qr=(e,t,r,o)=>{let{sid:n,hostName:s}=E(o??{});return new Request(https://${s}/api/code/${e}/${j(t)}/${j(r)},n?{headers:{Cookie:M(n)}}:void 0)},Vr=async e=>S(await O(I(e),async t=>t.response.status===404&&t.response.headers.get("Content-Type")?.includes?.("text/plain")?{name:"NotFoundError",message:"Code block is not found"}:await B(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),Xr=async(e,t,r,o)=>{let n=Qr(e,t,r,o),s=await E(o??{}).fetch(n);return R(s)?s:Vr(v(s))};Xr.toRequest=Qr;Xr.fromResponse=Vr;var Wl=new TextEncoder;var Yl=new TextEncoder().encode("0123456789abcdef"),Jl=new TextEncoder,Zl=new TextDecoder;var us=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,ds=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,ms=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,fs=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Yr=e=>{if(us.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(ds);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(ms);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(fs);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var gs=/https?:\/\/vimeo\.com\/([0-9]+)/i,Jr=e=>{let t=e.match(gs);if(t)return t[1]};var hs=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Zr=e=>{let t=e.match(hs);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var bs=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,eo=e=>{let t=e.match(bs);if(!t)return;let[,r]=t;return r};var to=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let a=Yr(n);if(a)return{type:"youtube",href:n,...a,...s};let c=Jr(n);if(c)return{type:"vimeo",videoId:c,href:n,...s};let i=Zr(n);if(i)return{type:"spotify",href:n,...i,...s};let l=eo(n);if(l)return{type:"anchor-fm",videoId:l,href:n,...s};if(xs(n))return{type:"video",href:n,...s}}return ys(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},ys=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),xs=e=>/\.(?:mp4|webm)$/.test(e);var ro=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),o=await ze([]);if(R(o))return r;let n=v(o).projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var Es;(e=>{})(Es||={});var _s="0.13.3",oo,It,no=async(e=_s)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(It)throw It;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,await new Promise((o,n)=>{r.onload=()=>o(),r.onerror=s=>{It=s,n(s)},document.head.append(r)})}return new Promise(r=>{let o=setInterval(()=>{oo&&(clearInterval(o),r(oo))},500)})};var Ge=(e,t)=>{let[r,o]=A("");return{ref:$(s=>{if(!s){o("");return}no().then(a=>{try{a.render(e,s,t),o("")}catch(c){if(c instanceof Error&&c.name==="ParseError")o(c.message.slice(19));else throw c}})},[e,...Object.values(t??{})]),error:r}};var so=!1;scrapbox.addListener("lines:changed",()=>so=!1);scrapbox.addListener("layout:changed",()=>so=!1);var io=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var ue=()=>{let e=document.getElementById("text-input");if(e)return io(e,"textarea#text-input"),e};function ae(e,t={}){let{signal:r,persistent:o=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((n,s)=>{let a=()=>{clearTimeout(i),s(r?.reason)},i=setTimeout(()=>{r?.removeEventListener("abort",a),n()},e);if(r?.addEventListener("abort",a,{once:!0}),o===!1)try{Deno.unrefTimer(i)}catch(l){if(!(l instanceof ReferenceError))throw l;console.error("persistent option is only available in Deno")}})}var Mt=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_${D(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var ao=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}};var co=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 Rs=new Map;scrapbox.on("layout:changed",()=>{let e=ue();if(e)for(let[t,r]of Rs)for(let[o,n]of r)for(let s of n)e.addEventListener(t,o,co(s))});var lo=e=>({type:"title",text:e.rows[0].text});var po=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(a=>a.text.substring(o+1)).join( )}};var h=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,a)=>{if(!t&&s.nested)return a?.()??[];if(!r&&s.quoted)return a?.()??[];for(let c of o){let i=c.exec(n);if(i===null)continue;let l=n.substring(0,i.index),m=n.substring(i.index+(i[0]?.length??0)),p=e(i[0]??"",s);return[...U(l,s),...p,...U(m,s)]}return a?.()??[]};var x=e=>[{type:"plain",raw:e,text:e}],uo=h(x,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var Cs=/^>.*$/,Ss=(e,t)=>t.context==="table"?x(e,t):[{type:"quote",raw:e,nodes:U(e.substring(1),{...t,quoted:!0})}],mo=h(Ss,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Cs]});var Is=/^\? .+$/,Ms=(e,t)=>t.context==="table"?x(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],fo=h(Ms,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Is]});var Fs=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,Os=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Bs=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?${r}/thumb/1000:r}]},go=h(Bs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Fs,Os]});var js=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function Ft(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return x(t,r);let o=e==="icon"?t.substring(1,t.length-1):t.substring(2,t.length-2),n=o.lastIndexOf(".icon"),s=o.substring(0,n),a=s.startsWith("/")?"root":"relative",c=o.substring(n+5,o.length),i=c.startsWith("*")?parseInt(c.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Hs=Ft("icon"),ho=h(Hs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[js]});var As=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,$s=Ft("strongIcon"),bo=h($s,{parseOnNested:!1,parseOnQuoted:!0,patterns:[As]});var Ds=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Us=(e,t)=>t.context==="table"?x(e,t):[{type:"strong",raw:e,nodes:U(e.substring(2,e.length-2),{...t,nested:!0})}],yo=h(Us,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Ds]});var qs=/\[\$ .+? \]/,zs=/\[\$ [^\]]+\]/,Ks=(e,t)=>t.context==="table"?x(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],xo=h(Ks,{parseOnNested:!1,parseOnQuoted:!0,patterns:[qs,zs]});var Gs=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Ws=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let a=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(a,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:U(n,{...t,nested:!0})}]},Eo=h(Ws,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Gs]});var Qs=/.*?/,Vs=(e,t)=>t.context==="table"?x(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],_o=h(Vs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Qs]});var Xs=/^[$%] .+$/,Ys=(e,t)=>{if(t.context==="table")return x(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},ko=h(Ys,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Xs]});var Js=/\[\s+\]/,Zs=(e,t)=>t.context==="table"?x(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],To=h(Zs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Js]});var ei=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,ti=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,ri=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,oi=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,ni=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||si(e),si=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),ii=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).trimLeft():"",[s,a]=ni(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:a}]},wo=h(ii,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ei,ti,ri,oi]});var ai=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,ci=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,li=/\[https?:\/\/[^\s\]]+\]/,pi=/https?:\/\/[^\s]+/,ui=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},vo=h(ui,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ai,ci,li,pi]});var Po=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,No=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,di=e=>{let[t="",r="",o=""]=e.split(","),n=parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),a=/^Z\d+$/.test(o)?parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:a}},mi=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.match(Po)??e.match(No);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,n="",s=""]=o?r:[r[0],r[2],r[1]],{latitude:a,longitude:c,zoom:i}=di(n),l=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${a},${c},${i}z:https://www.google.com/maps/@${a},${c},${i}z;return[{type:"googleMap",raw:e,latitude:a,longitude:c,zoom:i,place:s,url:l}]},Lo=h(mi,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Po,No]});var fi=/\[\/?[^[\]]+\]/,gi=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},Ro=h(gi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[fi]});var hi=/(?:^|\s)#\S+/,bi=(e,t)=>{if(t.context==="table")return x(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...x(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},Co=h(bi,{parseOnNested:!0,parseOnQuoted:!0,patterns:[hi]});var yi=/^[0-9]+\. .*$/,xi=(e,t)=>{if(t.context==="table")return x(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:U(s,{...t,nested:!0})}]},So=h(xi,{parseOnNested:!1,parseOnQuoted:!1,patterns:[yi]});var Ei=(e,t,r)=>e===""?[]:r?.()??[],_i=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>uo(t,r))(),U=_i(Ei,mo,fo,_o,ko,xo,To,Eo,go,bo,yo,wo,vo,ho,Lo,Ro,Co,So);var Io=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(a=>a.text.substring(o+1)).map(a=>a.split(" ").map(c=>U(c,{nested:!1,quoted:!1,context:"table"})))}};var Mo=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:U(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Fo=e=>{switch(e.type){case"title":return lo(e);case"codeBlock":return po(e);case"table":return Io(e);case"line":return Mo(e)}};var Oo=e=>e.split( ).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var ki=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),Bo=(e,t)=>{let r=e[e.length-1];return r!==void 0&&ki(r,t)?(r.rows.push(t),e):(e.push({type:/^\s*code:/.test(t.text)?"codeBlock":/^\s*table:/.test(t.text)?"table":"line",rows:[t]}),e)},jo=(e,t)=>{if(t.hasTitle??!0){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(Bo,[])]}return e.reduce(Bo,[])};var Pe=(e,t)=>{let r=Oo(e);return jo(r,{hasTitle:t?.hasTitle??!0}).map(Fo)};var Ho=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let a=s[0]().finally(()=>o(a)).then(c=>s[1](c)).catch(c=>s[2](c));r.add(a)};return n=>{if(r.size<e){let s=n().finally(()=>o(s));return r.add(s),s}return new Promise((s,a)=>{t.push([n,s,a])})}};var Ti="0.6.5",Do=ScrapBubble-${Ti},Ao=await globalThis.caches.open(Do);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Do&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var $o=Ho(3);async function*We(e,t){let r=((t?.saveFailedResponse?Ao.match(e):void 0)??ao(e,t)).then(a=>["cache",a]);{let a=ae(1e3).then(()=>"timeout"),c=await Promise.race([r,a]);if(c!=="timeout"){c[1]&&(yield["cache",c[1]]);let i=await $o(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await Ao.put(e,i.clone()),yield["network",i]}}let o=$o(()=>fetch(e)).then(a=>["network",a]),[n,s]=await Promise.race([r,o]);if(n==="network"){yield[n,s];return}s&&(yield[n,s]),yield await o}var Uo=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Qe=()=>{let e=new Map;return{dispatch:(t,r)=>{let o=e.get(t);if(o)for(let n of o)n(r)},on:(t,r)=>{let o=e.get(t)??new Set;o.add(r),e.set(t,o)},off:(t,r)=>{let o=e.get(t);o&&o.delete(r)}}};var q=!1,qo=e=>{q=typeof e=="boolean"?e:new Set(e)},ee=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{q!==!0&&(!q||!q.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{q!==!0&&(!q||!q.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{q!==!0&&(!q||!q.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(q!==!0&&(!q||!q.has(e))))return r(...o)}]}}));var Ot=Qe(),Ve=new Map,wi=ee("ScrapBubble:useProject.ts"),zo=e=>{let[t,r]=A();return W(()=>{Ot.on(e,r);let o=Ve.get(e);return o?r(o.loading?void 0:o.value):(Ve.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=ve.toRequest(e);for await(let[,s]of We(n)){let a=await ve.fromResponse(s);Ve.set(e,{loading:!1,value:a}),Ot.dispatch(e,a);break}}catch(n){wi.error(n),Ve.delete(e)}})()),()=>Ot.off(e,r)},[e]),t};var vi=["default-light","default-dark","default-minimal"],Pi=["paper-light","paper-dark-dark","paper-dark"],Ko=["blue","purple","green","orange","red"],Ni=["hacker1","hacker2"],Go=["winter","spring","summer","automn"],Wo=["tropical"],Qo=["kyoto","newyork","paris"],Vo=["mred","lgreen"],dg=["default-light","default-minimal","paper-light",...Ko,...Go,...Wo,...Qo,...Vo];var Li=[...vi,...Pi,...Ko,...Ni,...Go,...Wo,...Qo,...Vo];function Xo(e){return Li.includes(e)}var Yo="default-light",ce=e=>{let t=zo(e);return N(()=>{if(!t||R(t))return Yo;let r=v(t).theme;return Xo(r)?r:Yo},[t])};var de=(e,t)=>new Promise(r=>{let o=!1,n=()=>{o=!0,r(!1)};e.addEventListener("click",n),e.addEventListener("pointerleave",n),setTimeout(()=>{o||r(!0),e.removeEventListener("click",n),e.removeEventListener("pointerleave",n),r(!1)},t)});var me=e=>{let{top:t,right:r,left:o,bottom:n}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),a=(o-s.left)/s.width>.5;return{top:Math.round(n-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...a?{right:Math.round(s.right-r)}:{left:Math.round(o-s.left)},maxWidth:a?r-10:document.documentElement.clientWidth-o-10}};var Ri=0,wg=Array.isArray;function u(e,t,r,o,n,s){t||(t={});var a,c,i=t;if("ref"in i)for(c in i={},t)c=="ref"?a=t[c]:i[c]=t[c];var l={type:e,props:i,key:r,ref:a,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--Ri,__i:-1,__u:0,__source:n,__self:s};if(typeof e=="function"&&(a=e.defaultProps))for(c in a)i[c]===void 0&&(i[c]=a[c]);return w.vnode&&w.vnode(l),l}var Jo=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:a,prefetch:c})=>{let i=N(()=>o?[]:Pe(r.join( ),{hasTitle:!1}),[o,r]),l=ce(e),m=$(async({currentTarget:g})=>{c(e,t),await de(g,a)&&s({project:e,title:t,linkTo:n,type:"link",position:me(g)})},[e,t,a,n?.project,n?.titleLc]),p=N(()=>n?()=>{Mt({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return u("a",{className:"related-page-card page-link",type:"link","data-theme":l,href:/${e}/${j(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:m,onClick:p,children:[u("div",{class:"hover"}),u("div",{class:"content",children:[u("div",{class:"header",children:u("div",{class:"title",children:t})}),o?u("div",{class:"thumbnail",children:u("img",{src:o})}):u("div",{class:"description",children:i.flatMap((g,d)=>g.type==="line"?[u("p",{children:g.nodes.map(f=>u(Zo,{node:f,project:e}))},d)]:[])})]})]})},Zo=({node:e,project:t})=>{switch(e.type){case"code":return u("code",{children:e.text});case"formula":return u(Ci,{node:e});case"commandLine":return u("code",{children:[e.symbol," $",e.text]});case"helpfeel":return u("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return u(P,{children:e.nodes.map(r=>u(Zo,{node:r,project:t}))});case"icon":case"strongIcon":return u(Si,{node:e,project:t});case"hashTag":return u(Ii,{node:e});case"link":return u(Mi,{node:e});case"plain":case"blank":return u(P,{children:e.text});default:return u(P,{})}},Ci=({node:{formula:e}})=>{let{ref:t,error:r}=Ge(e);return u("span",{className:formula ${r?" error":""},children:r?u("code",{children:e}):u("span",{className:"katex-display",ref:t})})},Si=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return u("img",{class:"icon",src:/api/pages/${o}/${j(n)}/icon})},Ii=({node:{href:e}})=>u("span",{class:"page-link",children:["#",e]}),Mi=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?u("span",{class:"page-link",children:t}):u("span",{class:"link",children:r||t});var k=(e,t)=>/${e.toLowerCase()}/${D(t)},Xe=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var sn=Symbol.for("immer-nothing"),en=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function K(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var fe=Object.getPrototypeOf;function ge(e){return!!e&&!!e[_]}function X(e){return e?an(e)||Array.isArray(e)||!!e[en]||!!e.constructor?.[en]||tt(e)||rt(e):!1}var Fi=Object.prototype.constructor.toString();function an(e){if(!e||typeof e!="object")return!1;let t=fe(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 Ne(e,t){et(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,o)=>t(o,r,e))}function et(e){let t=e[_];return t?t.type_:Array.isArray(e)?1:tt(e)?2:rt(e)?3:0}function Ht(e,t){return et(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function cn(e,t,r){let o=et(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function Oi(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function tt(e){return e instanceof Map}function rt(e){return e instanceof Set}function H(e){return e.copy_||e.base_}function At(e,t){if(tt(e))return new Map(e);if(rt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=an(e);if(t===!0||t==="class_only"&&!r){let o=Object.getOwnPropertyDescriptors(e);delete o[_];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){let a=n[s],c=o[a];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(o[a]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[a]})}return Object.create(fe(e),o)}else{let o=fe(e);if(o!==null&&r)return{...e};let n=Object.create(o);return Object.assign(n,e)}}function qt(e,t=!1){return ot(e)||ge(e)||!X(e)||(et(e)>1&&(e.set=e.add=e.clear=e.delete=Bi),Object.freeze(e),t&&Object.entries(e).forEach(([r,o])=>qt(o,!0))),e}function Bi(){K(2)}function ot(e){return Object.isFrozen(e)}var $t={};function le(e){let t=$t[e];return t||K(0,e),t}function ji(e,t){$t[e]||($t[e]=t)}var Le;function Ye(){return Le}function Hi(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function tn(e,t){t&&(le("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Dt(e){Ut(e),e.drafts_.forEach(Ai),e.drafts_=null}function Ut(e){e===Le&&(Le=e.parent_)}function rn(e){return Le=Hi(Le,e)}function Ai(e){let t=e[_];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function on(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[_].modified_&&(Dt(t),K(4)),X(e)&&(e=Je(t,e),t.parent_||Ze(t,e)),t.patches_&&le("Patches").generateReplacementPatches_(r[_].base_,e,t.patches_,t.inversePatches_)):e=Je(t,r,[]),Dt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==sn?e:void 0}function Je(e,t,r){if(ot(t))return t;let o=t[_];if(!o)return Ne(t,(n,s)=>nn(e,o,t,n,s,r)),t;if(o.scope_!==e)return t;if(!o.modified_)return Ze(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let n=o.copy_,s=n,a=!1;o.type_===3&&(s=new Set(n),n.clear(),a=!0),Ne(s,(c,i)=>nn(e,o,n,c,i,r,a)),Ze(e,n,!1),r&&e.patches_&&le("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function nn(e,t,r,o,n,s,a){if(ge(n)){let c=s&&t&&t.type_!==3&&!Ht(t.assigned_,o)?s.concat(o):void 0,i=Je(e,n,c);if(cn(r,o,i),ge(i))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(X(n)&&!ot(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Je(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,o)&&Ze(e,n)}}function Ze(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&qt(t,r)}function $i(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Ye(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=zt;r&&(n=[o],s=Re);let{revoke:a,proxy:c}=Proxy.revocable(n,s);return o.draft_=c,o.revoke_=a,c}var zt={get(e,t){if(t===_)return e;let r=H(e);if(!Ht(r,t))return Di(e,r,t);let o=r[t];return e.finalized_||!X(o)?o:o===Bt(e.base_,t)?(jt(e),e.copy_[t]=Ce(o,e)):o},has(e,t){return t in H(e)},ownKeys(e){return Reflect.ownKeys(H(e))},set(e,t,r){let o=ln(H(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=Bt(H(e),t),s=n?.[_];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(Oi(r,n)&&(r!==void 0||Ht(e.base_,t)))return!0;jt(e),V(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 Bt(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,jt(e),V(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=H(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){K(11)},getPrototypeOf(e){return fe(e.base_)},setPrototypeOf(){K(12)}},Re={};Ne(zt,(e,t)=>{Re[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Re.deleteProperty=function(e,t){return Re.set.call(this,e,t,void 0)};Re.set=function(e,t,r){return zt.set.call(this,e[0],t,r,e[0])};function Bt(e,t){let r=e[_];return(r?H(r):e)[t]}function Di(e,t,r){let o=ln(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function ln(e,t){if(!(t in e))return;let r=fe(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=fe(r)}}function V(e){e.modified_||(e.modified_=!0,e.parent_&&V(e.parent_))}function jt(e){e.copy_||(e.copy_=At(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ui=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,o)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let a=this;return function(c=s,...i){return a.produce(c,l=>r.call(this,l,...i))}}typeof r!="function"&&K(6),o!==void 0&&typeof o!="function"&&K(7);let n;if(X(t)){let s=rn(this),a=Ce(t,void 0),c=!0;try{n=r(a),c=!1}finally{c?Dt(s):Ut(s)}return tn(s,o),on(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===sn&&(n=void 0),this.autoFreeze_&&qt(n,!0),o){let s=[],a=[];le("Patches").generateReplacementPatches_(t,n,s,a),o(s,a)}return n}else K(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,c=>t(c,...a));let o,n;return[this.produce(t,r,(s,a)=>{o=s,n=a}),o,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){X(e)||K(8),ge(e)&&(e=qi(e));let t=rn(this),r=Ce(e,void 0);return r[_].isManual_=!0,Ut(t),r}finishDraft(e,t){let r=e&&e[_];(!r||!r.isManual_)&&K(9);let{scope_:o}=r;return tn(o,t),on(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let o=le("Patches").applyPatches_;return ge(e)?o(e,t):this.produce(e,n=>o(n,t))}};function Ce(e,t){let r=tt(e)?le("MapSet").proxyMap_(e,t):rt(e)?le("MapSet").proxySet_(e,t):$i(e,t);return(t?t.scope_:Ye()).drafts_.push(r),r}function qi(e){return ge(e)||K(10,e),pn(e)}function pn(e){if(!X(e)||ot(e))return e;let t=e[_],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=At(e,t.scope_.immer_.useStrictShallowCopy_)}else r=At(e,!0);return Ne(r,(o,n)=>{cn(r,o,pn(n))}),t&&(t.finalized_=!1),r}function un(){class e extends Map{constructor(i,l){super(),this[_]={type_:2,parent_:l,scope_:l?l.scope_:Ye(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return H(this[_]).size}has(i){return H(this[_]).has(i)}set(i,l){let m=this[_];return a(m),(!H(m).has(i)||H(m).get(i)!==l)&&(r(m),V(m),m.assigned_.set(i,!0),m.copy_.set(i,l),m.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let l=this[_];return a(l),r(l),V(l),l.base_.has(i)?l.assigned_.set(i,!1):l.assigned_.delete(i),l.copy_.delete(i),!0}clear(){let i=this[_];a(i),H(i).size&&(r(i),V(i),i.assigned_=new Map,Ne(i.base_,l=>{i.assigned_.set(l,!1)}),i.copy_.clear())}forEach(i,l){let m=this[_];H(m).forEach((p,g,d)=>{i.call(l,this.get(g),g,this)})}get(i){let l=this[_];a(l);let m=H(l).get(i);if(l.finalized_||!X(m)||m!==l.base_.get(i))return m;let p=Ce(m,l);return r(l),l.copy_.set(i,p),p}keys(){return H(this[_]).keys()}values(){let i=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let l=i.next();return l.done?l:{done:!1,value:this.get(l.value)}}}}entries(){let i=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let l=i.next();if(l.done)return l;let m=this.get(l.value);return{done:!1,value:[l.value,m]}}}}[Symbol.iterator](){return this.entries()}}function t(c,i){return new e(c,i)}function r(c){c.copy_||(c.assigned_=new Map,c.copy_=new Map(c.base_))}class o extends Set{constructor(i,l){super(),this[_]={type_:3,parent_:l,scope_:l?l.scope_:Ye(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return H(this[_]).size}has(i){let l=this[_];return a(l),l.copy_?!!(l.copy_.has(i)||l.drafts_.has(i)&&l.copy_.has(l.drafts_.get(i))):l.base_.has(i)}add(i){let l=this[_];return a(l),this.has(i)||(s(l),V(l),l.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let l=this[_];return a(l),s(l),V(l),l.copy_.delete(i)||(l.drafts_.has(i)?l.copy_.delete(l.drafts_.get(i)):!1)}clear(){let i=this[_];a(i),H(i).size&&(s(i),V(i),i.copy_.clear())}values(){let i=this[_];return a(i),s(i),i.copy_.values()}entries(){let i=this[_];return a(i),s(i),i.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(i,l){let m=this.values(),p=m.next();for(;!p.done;)i.call(l,p.value,p.value,this),p=m.next()}}function n(c,i){return new o(c,i)}function s(c){c.copy_||(c.copy_=new Set,c.base_.forEach(i=>{if(X(i)){let l=Ce(i,c);c.drafts_.set(i,l),c.copy_.add(l)}else c.copy_.add(i)}))}function a(c){c.revoked_&&K(3,JSON.stringify(H(c)))}ji("MapSet",{proxyMap_:t,proxySet_:n})}var z=new Ui,nt=z.produce,Ug=z.produceWithPatches.bind(z),qg=z.setAutoFreeze.bind(z),zg=z.setUseStrictShallowCopy.bind(z),Kg=z.applyPatches.bind(z),Gg=z.createDraft.bind(z),Wg=z.finishDraft.bind(z);un();var dn=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},mn=(e,t)=>nt(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...a}=t;Object.assign(r,a),Kt(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}Kt(r)&&!Kt(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)}),Kt=e=>e.lines[0].id==="dummy";var fn=(e,t)=>{let r=new Map,o=D(t.title);for(let i of t.links){let l=zi(e,i);l.linked=[o],r.set(k(e,i),l)}let n=k(e,o),s=t.projectLinks.map(i=>{let l=Xe(i);return k(l.project,l.titleLc)}),a={...st(e,t),linked:[],projectLinked:[]};r.set(n,a);let c=t.links.map(i=>D(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(o)&&a.linked.push(i.titleLc);for(let g of i.linksLc.filter(d=>c.includes(d))){let d=k(e,g),f=r.get(d);if(!f)throw Error(storage already must have "${d}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let l=k(e,i.titleLc),m=st(e,i),p=r.get(l)?.linked;p&&(m.linked=p),r.set(l,m)}for(let i of t.relatedPages.projectLinks1hop){let l=k(i.projectName,i.titleLc);s.includes(l)||a.projectLinked.push(l);let m=st(i.projectName,i),p=r.get(l)?.projectLinked;p&&(m.projectLinked=p),r.set(l,m)}a.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let g of i.linksLc){let d=k(e,g),f=r.get(d);if(!f)throw Error(storage already must have "${d}");if(!f.linked){f.linked=[i.titleLc];continue}f.linked.push(i.titleLc)}let l=k(e,i.titleLc),m=st(e,i),p=r.get(l)?.linked;p&&(m.linked=p),r.set(l,m)}return r},st=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:D(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}),zi=(e,t)=>({project:e,titleLc:D(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var it=ee("ScrapBubble:bubble.ts"),Gt=new Map,at=new Set,Wt=Qe();function*hn(e){for(let t of e)yield Gt.get(t)}var bn=(e,t)=>Wt.on(e,t),yn=(e,t)=>Wt.off(e,t),xn=async(e,t,r,o)=>{let n=[];for(let s of[...t].reverse()){let a=k(s,e);at.has(a)||n.push(Ki(s,e,r,o))}await Promise.all(n)},gn=0,Ki=async(e,t,r,o)=>{let n=k(e,t);if(at.has(n))return;at.add(n);let s=gn++,a=${s} Check update ${n};it.time(a);try{let c=we.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[i,l]of We(c,{ignoreSearch:!0,saveFailedResponse:!0})){it.debug(${s}${i} ${n});let m=await we.fromResponse(l);if(Pt(m)){let p=fn(e,v(m));for(let[g,d]of p){let f=Gt.get(g),b=mn(f,d);b&&f!==b&&(Gt.set(g,b),Wt.dispatch(g,d))}}if(o?.ignoreFetch===!0||i==="cache"&&!Uo(l,o?.maxAge??60))break}}catch(c){it.error(c)}finally{at.delete(n),it.timeEnd(a),gn--}};var En=ee("ScrapBubble:useBubbleData.ts"),he=e=>{let[t,r]=A(Qt(e));return W(()=>{r(Qt(e));let o,n=()=>{clearTimeout(o),o=setTimeout(()=>{En.debug(Update ${e.length} pages),r(Qt(e))},10)};return e.forEach(s=>bn(s,n)),()=>e.forEach(s=>yn(s,n))},e),t},Qt=e=>{let t=[...hn(e)].flatMap(r=>r?[r]:[]);return En.debug(Required: ${e.length} pages, ${t.length} found,t),t};var _n=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=N(()=>[...t.keys(),...r.keys()],[t,r]),a=he(s),c=N(()=>[...o],[o]),i=N(()=>{let m=(p,g)=>{let d=c.indexOf(p.project),f=c.indexOf(g.project);return d===f?g.updated-p.updated:d<0?1:f<0?-1:d-f};return[...a].sort(m)},[a,c]),l=N(()=>({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 u("ul",{className:"card-bubble",style:l,onClick:n.onClick,children:i.map(({project:m,titleLc:p,lines:[{text:g}],descriptions:d,image:f})=>{let b=k(m,p),L=t.get(b)??r.get(b);return u("li",{children:u(Jo,{project:m,title:g,linkTo:L,descriptions:d,thumbnail:f??"",...n})},b)})})};var be=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[,o]=r?.match?.(/#([a-f\d]{24,32})$/)??["",""];return r===""?{project:t}:o===""?{project:t,title:r}:{project:t,title:r.slice(0,-1-o.length),hash:o}}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 Vt=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&D(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=be({pathType:r.pathType,href:r.href});return o?!n&&D(s)===e.titleLc:n===e.project&&D(s)===e.titleLc}case"quote":case"strong":case"decoration":return Vt(e,r.nodes)}});var te=Et({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Tn=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:a,...c})=>{let i=N(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),l=N(()=>{let d=0;return Pe(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[d++]};case"codeBlock":{let b=d;return d+=f.content.split(
).length+1,{...f,ids:i.slice(b,d)}}case"table":{let b=d;return d+=f.cells.length+1,{...f,ids:i.slice(b,d)}}}})},[e,i]),m=N(()=>{if(s&&i.includes(s))return s;if(a)return l.find(d=>d.type!=="line"?!1:Vt(a,d.nodes))?.id},[l,i,s,a?.project,a?.titleLc]),p=Tt(null);W(()=>{if(!m)return;let d=p.current?.querySelector(data-id="${m}"),f=globalThis.scrollY;d?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,f)},[m]);let g=ce(t);return u("div",{className:"lines","data-theme":g,ref:p,children:u(te.Provider,{value:{project:t,title:r,whiteList:o,...c},children:l.map(d=>{switch(d.type){case"title":return u(P,{children:[u(xe,{index:d.id,indent:0,noIndent:n,permalink:d.id===m,children:u("a",{className:"page-link",type:"link",href:/${t}/${j(d.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:d.text})},d.id),u("hr",{})]});case"codeBlock":return u(Gi,{block:d,noIndent:n,ids:d.ids,scrollId:m},d.ids[0]);case"table":return u(Wi,{block:d,noIndent:n,ids:d.ids,scrollId:m},d.ids[0]);case"line":return u(xe,{index:d.id,indent:d.indent,noIndent:n,permalink:d.id===m,children:d.nodes.length>0?d.nodes.map(f=>u(ye,{node:f})):u("br",{})},d.id)}})})})},xe=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>u("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:o}),Gi=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=Z(te),[c,i]=A(""),l=$(async m=>{m.preventDefault(),m.stopPropagation();try{await navigator.clipboard.writeText(t),i("Copied"),await ae(1e3),i("")}catch(p){alert(Failed to copy the code block Error:${p.message})}},[t]);return u(P,{children:[u(xe,{index:o[0],indent:r,permalink:o[0]===n,children:u("span",{className:"code-block",children:[u("span",{className:"code-block-start",children:u("a",{href:/api/code/${s}/${j(a)}/${e},target:"_blank",children:e})}),u("span",{className:"copy",title:"Copy",onClick:l,children:c})]})}),u(P,{children:t.split(
).map((m,p)=>u(xe,{index:o[p+1],indent:r,permalink:o[p+1]===n,children:u("code",{className:"code-block",children:m})}))})]})},Wi=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=Z(te);return u(P,{children:[u(xe,{index:o[0],indent:r,permalink:o[0]===n,children:u("span",{className:"table-block",children:u("span",{className:"table-block-start",children:u("a",{href:/api/table/${s}/${j(a)}/${e}.csv,target:"_blank",children:e})})})}),u(P,{children:t.map((c,i)=>u(xe,{index:o[i+1],indent:r,permalink:o[i+1]===n,children:u("span",{className:"table-block table-block-row",children:c.map((l,m)=>u("span",{className:cell col-${m},children:l.map(p=>u(ye,{node:p}))}))})}))})]})},ye=({node:e})=>{switch(e.type){case"code":return u("code",{className:"code",children:e.text});case"formula":return u(Qi,{node:e});case"commandLine":return u(Xi,{node:e});case"helpfeel":return u("code",{className:"helpfeel",children:[u("span",{className:"prefix",children:"?"})," ",u("span",{className:"entry",children:e.text})]});case"quote":return u("blockquote",{className:"quote",children:e.nodes.map(t=>u(ye,{node:t}))});case"strong":return u("strong",{children:e.nodes.map(t=>u(ye,{node:t}))});case"decoration":return u(Vi,{node:e});case"plain":case"blank":return u(P,{children:e.text});case"hashTag":return u(Zi,{node:e});case"link":return u(ea,{node:e});case"googleMap":return u(Yi,{node:e});case"icon":return u(kn,{node:e});case"strongIcon":return u(kn,{node:e,strong:!0});case"image":return u(Ji,{node:e});case"strongImage":return u("img",{className:"image strong-image",src:e.src});case"numberList":return u(P,{children:[${e.number}. ,e.nodes.map(t=>u(ye,{node:t}))]})}},Qi=({node:{formula:e}})=>{let{ref:t,error:r}=Ge(e);return u("span",{className:formula ${r?" error":""},children:r?u("code",{children:e}):u("span",{className:"katex-display",ref:t})})},Vi=({node:{decos:e,nodes:t}})=>u("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>u(ye,{node:r}))}),Xi=({node:e})=>{let[t,r]=A(""),o=$(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await ae(1e3),r("")}catch(s){alert(Failed to copy the code block
Error:${s.message})}},[e.text]);return u(P,{children:[u("code",{className:"cli",children:[u("span",{className:"prefix",children:e.symbol})," ",u("span",{className:"command",children:e.text})]}),u("span",{className:"tool-buttons",children:u("span",{title:"Copy",className:"copy",onClick:o,children:t})})]})},Yi=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>u("span",{className:"pointing-device-map",children:u("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank",children:u("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${globalThis._csrf}})})}),kn=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=Z(te),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],a=j(s);return u("a",{href:/${n}/${a},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",children:u("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${a}/icon,children:s})})},Ji=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return u("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank",children:u("img",{className:"image",src:t})})},Zi=({node:{href:e}})=>{let{project:t}=Z(te),r=wn(t,e),o=vn(t,e,"hashtag");return u("a",{href:/${t}/${j(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:o,children:["#",e]})},ea=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return u(ta,{pathType:e,href:t.href});case"absolute":{let r=to({pathType:e,...t});switch(r.type){case"youtube":return u(ra,{...r});case"vimeo":return u(oa,{...r});case"spotify":return u(na,{...r});case"anchor-fm":return u(sa,{...r});case"audio":return u(ia,{...r});case"video":return u(ca,{...r});case"absoluteLink":return u("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},ta=({pathType:e,href:t})=>{let{project:r}=Z(te),{project:o=r,title:n,hash:s=""}=be({pathType:e,href:t}),a=vn(o,n,"link",s),c=wn(o,n??"");return u("a",{className:page-link${n!==void 0&&c?" empty-page-link":""},type:"link",href:/${o}${n===void 0?"":/${j(n)}${s===""?"":#${s}}},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:a,children:t})},ra=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 u("div",{className:"iframe-video-player",children:u("iframe",{src:t,allowFullScreen:!0,type:"text/html"})})},oa=({videoId:e})=>u("div",{className:"iframe-video-player",children:u("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0,type:"text/html"})}),na=e=>u("div",{className:"iframe-video-player",children:u("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0,type:"text/html",scrolling:"no"})}),sa=e=>u("div",{className:"iframe-video-player",children:u("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0,type:"text/html",scrolling:"no"})}),ia=e=>e.content===""?u("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):u(aa,{...e}),aa=({href:e,content:t})=>{let r=Tt(null),o=$(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return u("span",{className:"audio-link",children:[u("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),u("span",{className:"play",onClick:o,children:"♬"}),u("audio",{preload:"none",src:e,ref:r})]})},ca=({href:e})=>u("div",{className:"video-player",children:u("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),wn=(e,t)=>{let{whiteList:r}=Z(te),o=N(()=>(r.has(e)?[...r]:[e,...r]).map(s=>k(s,t)),[r,e]),n=he(o);return N(()=>dn(n),n)},vn=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:a}=Z(te);return $(async({currentTarget:c})=>{t&&(a(e,t),await de(c,n)&&s({project:e,title:t,hash:o,type:r,position:me(c)}))},[e,t,o,r,n,a,s])};var Pn=({pages:e,onClick:t,source:r,whiteList:o,...n})=>{let[s,a]=A(k(e[0].project,e[0].titleLc)),c=N(()=>({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 u("div",{className:"text-bubble",style:c,onClick:t,children:[e.length>1&&u("div",{role:"tablist",children:e.map(i=>u(la,{project:i.project,titleLc:i.titleLc,selected:s===k(i.project,i.titleLc),tabSelector:a},k(i.project,i.titleLc)))}),e.map(i=>u(pa,{selected:s===k(i.project,i.titleLc),...i,title:i.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:o,...n},k(i.project,i.titleLc)))]})},la=({project:e,titleLc:t,tabSelector:r,selected:o})=>{let n=$(()=>r(k(e,t)),[e,t]),s=ce(e);return u("button",{role:"tab","aria-selected":o,"data-theme":s,tabIndex:-1,onClick:n,children:e})},pa=({selected:e,...t})=>{let r=ce(t.project);return u("div",{role:"tabpanel","data-theme":r,hidden:!e,children:u(Tn,{...t})})};var Nn=ee("ScrapBubble:Bubble.tsx"),Ln=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=N(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,a,c]=da(e,n,r,t);return u(P,{children:[ua(c)&&u(Pn,{pages:c,source:e,whiteList:r,onClick:o.hide,...o}),u(_n,{linked:s,externalLinked:a,onClick:o.hide,source:e,projectsForSort:n,...o})]})},ua=e=>e.length>0,da=(e,t,r,o)=>{let[[n,s,a],c]=A([new Map,new Map,[]]),i=N(()=>{let p=[...t].map(g=>k(g,e.title));return Nn.debug("projects",p),p},[t,e.title]),l=he(i),m=N(()=>o.map(p=>D(p)),[o]);return _r(()=>{let p=new Map,g=new Map,d=[];for(let f of l){let b={project:f.project,titleLc:f.titleLc};for(let y of f.projectLinked??[]){let{project:T,titleLc:re}=Xe(y);m.includes(re)&&r.has(T)||g.has(y)||g.set(y,b)}if(!r.has(f.project))continue;let L={titleLc:f.titleLc};for(let y of f.linked??[]){if(m.includes(y))continue;let T=k(f.project,y);p.has(T)||p.set(T,L)}m.includes(f.titleLc)||f.exists&&d.push(f)}c(nt(f=>{Nn.debug(depth: ${m.length}, bubbled from ${k(e.project,e.title)}, bubbles,,l,"before",f[0],"internal cards,",p,"external cards",g);for(let b of f[0].keys())p.has(b)||f[0].delete(b);for(let[b,L]of p)f[0].set(b,L);for(let b of f[1].keys())g.has(b)||f[1].delete(b);for(let[b,L]of g)f[1].set(b,L);f[2]=d}))},[l,r,m]),[n,s,a]};var Rn=(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(o){if(!(o instanceof TypeError))throw o;return e}}};var Cn=e=>{let t=N(()=>Rn(e.style,import.meta.url),[e.style]);return u(P,{children:t!==""&&(t instanceof URL?u("link",{rel:"stylesheet",href:t.href}):u("style",{children:t}))})};var Sn=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 In=()=>{let[e,t]=A([{bubble:o=>r(0,o),hide:()=>r(0)}]),r=$((o,n)=>{t(([s,...a])=>[s,...n?[...a.slice(0,o),n===a.at(o)?.source?a.at(o):{source:n,parentTitles:[scrapbox.Page.title??"",...a.slice(0,o).map(c=>c.source.title)],bubble:c=>r(o+1,c),hide:()=>r(o+1)}]:[...a.slice(0,o)]])},[]);return e};var Xt=(e,t,r,o,n)=>{W(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var Mn=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),ct=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var Yt="scrap-bubble",Fn=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...a]=In(),c=$((i,l)=>xn(l,t.has(i)?t:new Set([i]),r),[t,r]);return Xt(document,"pointerenter",async i=>{let l=i.target;if(!ct(l)&&!Mn(l))return;let{project:m=scrapbox.Project.name,title:p,hash:g=""}=ct(l)?be({pathType:"root",href:${new URL(l.href).pathname}${new URL(l.href).hash}`}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(m==="")return;let d=decodeURIComponent(p??"");c(m,d),await de(l,e)&&n({project:m,title:d,hash:g,position:me(l),type:ma(l)})},{capture:!0},e,t,r),Xt(document,"click",i=>{i.target.dataset.userscriptName!==Yt&&s()},{capture:!0},s),W(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),s),u(P,{children:[u("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),u("style",{children:Sn}),u(Cn,{style:o}),a.map(i=>u(Ln,{...i,whiteList:t,delay:e,prefetch:c},k(i.source.project,i.source.title)))]})},ma=e=>ct(e)?e.type==="link"?"link":"hashtag":"title";var oy=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await ro()).slice(0,100),style:n="",debug:s=!1}=e??{};qo(s);let a=document.createElement("div");a.dataset.userscriptName=Yt,document.body.append(a);let c=a.attachShadow({mode:"open"});xt(u(Fn,{delay:t,whiteList:new Set(scrapbox.Project.name,...r),watchList:new Set(o),style:n}),c)};export{oy as mount};