ScrapBubble-min
code:app.js
var Pe,h,Pt,Po,be,Nt,St,It,Ne={},Ct=[],No=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i;function K(e,t){for(var r in t)er=tr;return e}function Mt(e){var t=e.parentNode;t&&t.removeChild(e)}function d(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?Pe.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)as===void 0&&(as=e.defaultPropss);return Se(e,a,o,n,null)}function Se(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,__h:null,constructor:void 0,__v:n??++Pt};return n==null&&h.vnode!=null&&h.vnode(s),s}function v(e){return e.children}function Ie(e,t){this.props=e,this.context=t}function te(e,t){if(t==null)return e.__?te(e.__,e.__.__k.indexOf(e)+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"?te(e):null}function Rt(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 Rt(e)}}function tt(e){(!e.__d&&(e.__d=!0)&&be.push(e)&&!Ce.__r++||St!==h.debounceRendering)&&((St=h.debounceRendering)||Nt)(Ce)}function Ce(){for(var e;Ce.__r=be.length;)e=be.sort(function(t,r){return t.__v.__b-r.__v.__b}),be=[],e.some(function(t){var r,o,n,s,a,i;t.__d&&(a=(s=(r=t).__v).__e,(i=r.__P)&&(o=[],(n=K({},s)).__v=s.__v+1,rt(i,s,n,r.__n,i.ownerSVGElement!==void 0,s.__h!=null?a:null,o,a??te(s),s.__h),Ht(o,s),s.__e!=a&&Rt(s)))})}function jt(e,t,r,o,n,s,a,i,c,p){var l,g,u,m,f,x,b,y=o&&o.__k||Ct,L=y.length;for(r.__k=[],l=0;l<t.length;l++)if((m=r.__kl=(m=tl)==null||typeof m=="boolean"?null:typeof m=="string"||typeof m=="number"||typeof m=="bigint"?Se(null,m,null,null,m):Array.isArray(m)?Se(v,{children:m},null,null,null):m.__b>0?Se(m.type,m.props,m.key,null,m.__v):m)!=null){if(m.__=r,m.__b=r.__b+1,(u=yl)===null||u&&m.key==u.key&&m.type===u.type)yl=void 0;else for(g=0;g<L;g++){if((u=yg)&&m.key==u.key&&m.type===u.type){yg=void 0;break}u=null}rt(e,m,u=u||Ne,n,s,a,i,c,p),f=m.__e,(g=m.ref)&&u.ref!=g&&(b||(b=[]),u.ref&&b.push(u.ref,null,m),b.push(g,m.__c||f,m)),f!=null?(x==null&&(x=f),typeof m.type=="function"&&m.__k===u.__k?m.__d=c=Ot(m,c,e):c=Bt(e,m,u,y,f,c),typeof r.type=="function"&&(r.__d=c)):c&&u.__e==c&&c.parentNode!=e&&(c=te(u))}for(r.__e=x,l=L;l--;)yl!=null&&(typeof r.type=="function"&&yl.__e!=null&&yl.__e==r.__d&&(r.__d=te(o,l+1)),At(yl,yl));if(b)for(l=0;l<b.length;l++)Ut(bl,b++l,b++l)}function Ot(e,t,r){for(var o,n=e.__k,s=0;n&&s<n.length;s++)(o=ns)&&(o.__=e,t=typeof o.type=="function"?Ot(o,t,r):Bt(r,o,o,n,o.__e,t));return t}function Bt(e,t,r,o,n,s){var a,i,c;if(t.__d!==void 0)a=t.__d,t.__d=void 0;else if(r==null||n!=s||n.parentNode==null)e:if(s==null||s.parentNode!==e)e.appendChild(n),a=null;else{for(i=s,c=0;(i=i.nextSibling)&&c<o.length;c+=2)if(i==n)break e;e.insertBefore(n,s),a=s}return a!==void 0?a:n.nextSibling}function So(e,t,r,o,n){var s;for(s in r)s==="children"||s==="key"||s in t||Me(e,s,null,rs,o);for(s in t)n&&typeof ts!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||rs===ts||Me(e,s,ts,rs,o)}function Dt(e,t,r){t0==="-"?e.setProperty(t,r):et=r==null?"":typeof r!="number"||No.test(t)?r:r+"px"}function Me(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||Dt(e.style,t,"");if(r)for(t in r)o&&rt===ot||Dt(e.style,t,rt)}else if(t0==="o"&&t1==="n")s=t!==(t=t.replace(/Capture$/,"")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.lt+s=r,r?o||e.addEventListener(t,s?Ft:$t,s):e.removeEventListener(t,s?Ft:$t,s);else if(t!=="dangerouslySetInnerHTML"){if(n)t=t.replace(/xlinkH:h/,"h").replace(/sName$/,"s");else if(t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t in e)try{et=r??"";break e}catch{}typeof r=="function"||(r!=null&&(r!==!1||t0==="a"&&t1==="r")?e.setAttribute(t,r):e.removeAttribute(t))}}function $t(e){this.le.type+!1(h.event?h.event(e):e)}function Ft(e){this.le.type+!0(h.event?h.event(e):e)}function rt(e,t,r,o,n,s,a,i,c){var p,l,g,u,m,f,x,b,y,L,U,R=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(c=r.__h,i=t.__e=r.__e,t.__h=null,s=i),(p=h.__b)&&p(t);try{e:if(typeof R=="function"){if(b=t.props,y=(p=R.contextType)&&op.__c,L=p?y?y.props.value:p.__:o,r.__c?x=(l=t.__c=r.__c).__=l.__E:("prototype"in R&&R.prototype.render?t.__c=l=new R(b,L):(t.__c=l=new Ie(b,L),l.constructor=R,l.render=Co),y&&y.sub(l),l.props=b,l.state||(l.state={}),l.context=L,l.__n=o,g=l.__d=!0,l.__h=[]),l.__s==null&&(l.__s=l.state),R.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=K({},l.__s)),K(l.__s,R.getDerivedStateFromProps(b,l.__s))),u=l.props,m=l.state,g)R.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(R.getDerivedStateFromProps==null&&b!==u&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(b,L),!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(b,l.__s,L)===!1||t.__v===r.__v){l.props=b,l.state=l.__s,t.__v!==r.__v&&(l.__d=!1),l.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(A){A&&(A.__=t)}),l.__h.length&&a.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(b,l.__s,L),l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(u,m,f)})}l.context=L,l.props=b,l.state=l.__s,(p=h.__r)&&p(t),l.__d=!1,l.__v=t,l.__P=e,p=l.render(l.props,l.state,l.context),l.state=l.__s,l.getChildContext!=null&&(o=K(K({},o),l.getChildContext())),g||l.getSnapshotBeforeUpdate==null||(f=l.getSnapshotBeforeUpdate(u,m)),U=p!=null&&p.type===v&&p.key==null?p.props.children:p,jt(e,Array.isArray(U)?U:U,t,r,o,n,s,a,i,c),l.base=t.__e,t.__h=null,l.__h.length&&a.push(l),x&&(l.__E=l.__=null),l.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=Io(r.__e,t,r,o,n,s,a,c);(p=h.diffed)&&p(t)}catch(A){t.__v=null,(c||s!=null)&&(t.__e=i,t.__h=!!c,ss.indexOf(i)=null),h.__e(A,t,r)}}function Ht(e,t){h.__c&&h.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(o){o.call(r)})}catch(o){h.__e(o,r.__v)}})}function Io(e,t,r,o,n,s,a,i){var c,p,l,g=r.props,u=t.props,m=t.type,f=0;if(m==="svg"&&(n=!0),s!=null){for(;f<s.length;f++)if((c=sf)&&"setAttribute"in c==!!m&&(m?c.localName===m:c.nodeType===3)){e=c,sf=null;break}}if(e==null){if(m===null)return document.createTextNode(u);e=n?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,u.is&&u),s=null,i=!1}if(m===null)g===u||i&&e.data===u||(e.data=u);else{if(s=s&&Pe.call(e.childNodes),p=(g=r.props||Ne).dangerouslySetInnerHTML,l=u.dangerouslySetInnerHTML,!i){if(s!=null)for(g={},f=0;f<e.attributes.length;f++)g[e.attributes[f].name]=e.attributes[f].value;(l||p)&&(l&&(p&&l.__html==p.__html||l.__html===e.innerHTML)||(e.innerHTML=l&&l.__html||""))}if(So(e,u,g,n,i),l)t.__k=[];else if(f=t.props.children,jt(e,Array.isArray(f)?f:f,t,r,o,n&&m!=="foreignObject",s,a,s?s0:r.__k&&te(r,0),i),s!=null)for(f=s.length;f--;)sf!=null&&Mt(sf);i||("value"in u&&(f=u.value)!==void 0&&(f!==g.value||f!==e.value||m==="progress"&&!f)&&Me(e,"value",f,g.value,!1),"checked"in u&&(f=u.checked)!==void 0&&f!==e.checked&&Me(e,"checked",f,g.checked,!1))}return e}function Ut(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(o){h.__e(o,r)}}function At(e,t,r){var o,n;if(h.unmount&&h.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||Ut(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){h.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)on&&At(on,t,typeof e.type!="function");r||e.__e==null||Mt(e.__e),e.__e=e.__d=void 0}function Co(e,t,r){return this.constructor(e,r)}function Re(e,t,r){var o,n,s;h.__&&h.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],rt(t,e=(!o&&r||t).__k=d(v,null,e),n||Ne,Ne,t.ownerSVGElement!==void 0,!o&&r?r:n?null:t.firstChild?Pe.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o),Ht(s,e)}function ot(e,t){var r={__c:t="__cC"+It++,__: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.shouldComponentUpdate=function(a){this.props.value!==a.value&&n.some(tt)},this.sub=function(a){n.push(a);var i=a.componentWillUnmount;a.componentWillUnmount=function(){n.splice(n.indexOf(a),1),i&&i.call(a)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}Pe=Ct.slice,h={__e:function(e,t){for(var r,o,n;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(e)),n=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e),n=r.__d),n)return r.__E=r}catch(s){e=s}throw e}},Pt=0,Po=function(e){return e!=null&&e.constructor===void 0},Ie.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=K({},this.state),typeof e=="function"&&(e=e(K({},r),this.props)),e&&K(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),tt(this))},Ie.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),tt(this))},Ie.prototype.render=v,be=[],Nt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ce.__r=0,It=0;var re,j,qt,xe=0,nt=[],zt=h.__b,Kt=h.__r,Gt=h.diffed,Wt=h.__c,Xt=h.unmount;function ye(e,t){h.__h&&h.__h(j,e,xe||t),xe=0;var r=j.__H||(j.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function C(e){return xe=1,Mo(Yt,e)}function Mo(e,t,r){var o=ye(re++,2);return o.t=e,o.__c||(o.__=[r?r(t):Yt(void 0,t),function(n){var s=o.t(o.__0,n);o.__0!==s&&(o.__=[s,o.__1],o.__c.setState({}))}],o.__c=j),o.__}function D(e,t){var r=ye(re++,3);!h.__s&&it(r.__H,t)&&(r.__=e,r.__H=t,j.__H.__h.push(r))}function je(e,t){var r=ye(re++,4);!h.__s&&it(r.__H,t)&&(r.__=e,r.__H=t,j.__h.push(r))}function oe(e){return xe=5,k(function(){return{current:e}},[])}function k(e,t){var r=ye(re++,7);return it(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function B(e,t){return xe=8,k(function(){return e},t)}function G(e){var t=j.contexte.__c,r=ye(re++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(j)),t.props.value):e.__}function Ro(){var e;for(nt.sort(function(t,r){return t.__v.__b-r.__v.__b});e=nt.pop();)if(e.__P)try{e.__H.__h.forEach(Oe),e.__H.__h.forEach(st),e.__H.__h=[]}catch(t){e.__H.__h=[],h.__e(t,e.__v)}}h.__b=function(e){j=null,zt&&zt(e)},h.__r=function(e){Kt&&Kt(e),re=0;var t=(j=e.__c).__H;t&&(t.__h.forEach(Oe),t.__h.forEach(st),t.__h=[])},h.diffed=function(e){Gt&&Gt(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(nt.push(t)!==1&&qt===h.requestAnimationFrame||((qt=h.requestAnimationFrame)||function(r){var o,n=function(){clearTimeout(s),Vt&&cancelAnimationFrame(o),setTimeout(r)},s=setTimeout(n,100);Vt&&(o=requestAnimationFrame(n))})(Ro)),j=null},h.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Oe),r.__h=r.__h.filter(function(o){return!o.__||st(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],h.__e(o,r.__v)}}),Wt&&Wt(e,t)},h.unmount=function(e){Xt&&Xt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Oe(o)}catch(n){t=n}}),t&&h.__e(t,r.__v))};var Vt=typeof requestAnimationFrame=="function";function Oe(e){var t=j,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),j=t}function st(e){var t=j;e.__c=e.__(),j=t}function it(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==eo})}function Yt(e,t){return typeof t=="function"?t(e):t}var Q=(e,t)=>{if(!(e instanceof HTMLDivElement))throw Error(${t??"value"} must be HTMLDivElement)};var w=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Oo=e=>typeof e=="object"&&e!==null,Bo=e=>Oo(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Qt=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return Bo(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var ne=class extends Error{constructor(t){super(${t.status} ${t.statusText} when fetching ${t.url});this.response=t;this.name="UnexpectedResponseError";Error.captureStackTrace&&Error.captureStackTrace(this,ne)}},S=async e=>{let t=e.clone(),r=await t.text(),o=Qt(r);if(!o)throw new ne(t);return{ok:!1,value:o}};var T=e=>connect.sid=${e};var O=e=>e.replaceAll(" ","_").toLowerCase();var M=e=>...e.map((t,r)=>t===" "?"_":!$o.includes(t)||r===e.length-1&&Fo.includes(t)?encodeURIComponent(t):t).join(""),$o='@$&+=:;",',Fo=':;",';var Jt=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:a}=w(r??{}),i=new URLSearchParams;i.append("followRename",${s??!0});for(let p of a??[])i.append("projects",p);let c=https://${n}/api/pages/${e}/${M(t)}?${i.toString()};return new Request(c,o?{headers:{Cookie:T(o)}}:void 0)},Zt=async e=>{if(!e.ok)return e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:S(e);let t=await e.json();return{ok:!0,value:t}},se=async(e,t,r)=>{let{fetch:o}=w(r??{}),n=Jt(e,t,r),s=await o(n);return await Zt(s)};se.toRequest=Jt;se.fromResponse=Zt;var er=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:a}=w(t??{}),i=new URLSearchParams;n!==void 0&&i.append("sort",n),s!==void 0&&i.append("limit",${s}),a!==void 0&&i.append("skip",${a});let c=https://${o}/api/pages/${e}?${i.toString()};return new Request(c,r?{headers:{Cookie:T(r)}}:void 0)},tr=async e=>{if(!e.ok)return S(e);let t=await e.json();return{ok:!0,value:t}},rr=async(e,t)=>{let{fetch:r}=w(t??{}),o=await r(er(e,t));return await tr(o)};rr.toRequest=er;rr.fromResponse=tr;var or=(e,t,r,o)=>{let{sid:n,hostName:s}=w(o??{}),a=https://${s}/api/table/${e}/${M(t)}/${encodeURIComponent(r)}.csv;return new Request(a,n?{headers:{Cookie:T(n)}}:void 0)},nr=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:S(e),sr=async(e,t,r,o)=>{let{fetch:n}=w(o??{}),s=or(e,t,r,o),a=await n(s);return await nr(a)};sr.toRequest=or;sr.fromResponse=nr;var ir=(e,t)=>{let{sid:r,hostName:o}=w(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:T(r)}}:void 0)},ar=async e=>{if(!e.ok)return S(e);let t=await e.json();return{ok:!0,value:t}},ie=async(e,t)=>{let{fetch:r}=w(t??{}),o=ir(e,t),n=await r(o);return ar(n)};ie.toRequest=ir;ie.fromResponse=ar;var cr=(e,t)=>{let{sid:r,hostName:o}=w(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:T(r)}}:void 0)},lr=async e=>{if(!e.ok)return S(e);let t=await e.json();return{ok:!0,value:t}},Be=async(e,t)=>{let{fetch:r}=w(t??{}),o=await r(cr(e,t));return lr(o)};Be.toRequest=cr;Be.fromResponse=lr;var pc=new Map;var pr=new TextEncoder().encode("0123456789abcdef");function dr(e){let t=new Uint8Array(e.length*2);for(let r=0;r<t.length;r++){let o=er;tr*2=pro>>4,tr*2+1=pro&15}return t}var ur="md5: data is invalid type",J=64,at=class{#e;#t;#r;#o;#n;#i;#s;#a;constructor(){this.#e=1732584193,this.#t=4023233417,this.#r=2562383102,this.#o=271733878,this.#n=new Uint8Array(J),this.#i=0,this.#s=0,this.#a=0}#l(t){let r=this.#s;r+=t,r>4294967295&&(this.#a+=1),this.#s=r>>>0}#c(t){let r=this.#e,o=this.#t,n=this.#r,s=this.#o,a=Y=>tY|tY+1<<8|tY+2<<16|tY+3<<24,i=(Y,Tt)=>Y<<Tt|Y>>>32-Tt,c=a(0),p=a(4),l=a(8),g=a(12),u=a(16),m=a(20),f=a(24),x=a(28),b=a(32),y=a(36),L=a(40),U=a(44),R=a(48),A=a(52),Le=a(56),Te=a(60);r=o+i(((n^s)&o^s)+r+c+3614090360,7),s=r+i(((o^n)&r^n)+s+p+3905402710,12),n=s+i(((r^o)&s^o)+n+l+606105819,17),o=n+i(((s^r)&n^r)+o+g+3250441966,22),r=o+i(((n^s)&o^s)+r+u+4118548399,7),s=r+i(((o^n)&r^n)+s+m+1200080426,12),n=s+i(((r^o)&s^o)+n+f+2821735955,17),o=n+i(((s^r)&n^r)+o+x+4249261313,22),r=o+i(((n^s)&o^s)+r+b+1770035416,7),s=r+i(((o^n)&r^n)+s+y+2336552879,12),n=s+i(((r^o)&s^o)+n+L+4294925233,17),o=n+i(((s^r)&n^r)+o+U+2304563134,22),r=o+i(((n^s)&o^s)+r+R+1804603682,7),s=r+i(((o^n)&r^n)+s+A+4254626195,12),n=s+i(((r^o)&s^o)+n+Le+2792965006,17),o=n+i(((s^r)&n^r)+o+Te+1236535329,22),r=o+i(((o^n)&s^n)+r+p+4129170786,5),s=r+i(((r^o)&n^o)+s+f+3225465664,9),n=s+i(((s^r)&o^r)+n+U+643717713,14),o=n+i(((n^s)&r^s)+o+c+3921069994,20),r=o+i(((o^n)&s^n)+r+m+3593408605,5),s=r+i(((r^o)&n^o)+s+L+38016083,9),n=s+i(((s^r)&o^r)+n+Te+3634488961,14),o=n+i(((n^s)&r^s)+o+u+3889429448,20),r=o+i(((o^n)&s^n)+r+y+568446438,5),s=r+i(((r^o)&n^o)+s+Le+3275163606,9),n=s+i(((s^r)&o^r)+n+g+4107603335,14),o=n+i(((n^s)&r^s)+o+b+1163531501,20),r=o+i(((o^n)&s^n)+r+A+2850285829,5),s=r+i(((r^o)&n^o)+s+l+4243563512,9),n=s+i(((s^r)&o^r)+n+x+1735328473,14),o=n+i(((n^s)&r^s)+o+R+2368359562,20),r=o+i((o^n^s)+r+m+4294588738,4),s=r+i((r^o^n)+s+b+2272392833,11),n=s+i((s^r^o)+n+U+1839030562,16),o=n+i((n^s^r)+o+Le+4259657740,23),r=o+i((o^n^s)+r+p+2763975236,4),s=r+i((r^o^n)+s+u+1272893353,11),n=s+i((s^r^o)+n+x+4139469664,16),o=n+i((n^s^r)+o+L+3200236656,23),r=o+i((o^n^s)+r+A+681279174,4),s=r+i((r^o^n)+s+c+3936430074,11),n=s+i((s^r^o)+n+g+3572445317,16),o=n+i((n^s^r)+o+f+76029189,23),r=o+i((o^n^s)+r+y+3654602809,4),s=r+i((r^o^n)+s+R+3873151461,11),n=s+i((s^r^o)+n+Te+530742520,16),o=n+i((n^s^r)+o+l+3299628645,23),r=o+i((n^(o|~s))+r+c+4096336452,6),s=r+i((o^(r|~n))+s+x+1126891415,10),n=s+i((r^(s|~o))+n+Le+2878612391,15),o=n+i((s^(n|~r))+o+m+4237533241,21),r=o+i((n^(o|~s))+r+R+1700485571,6),s=r+i((o^(r|~n))+s+g+2399980690,10),n=s+i((r^(s|~o))+n+L+4293915773,15),o=n+i((s^(n|~r))+o+p+2240044497,21),r=o+i((n^(o|~s))+r+b+1873313359,6),s=r+i((o^(r|~n))+s+Te+4264355552,10),n=s+i((r^(s|~o))+n+f+2734768916,15),o=n+i((s^(n|~r))+o+A+1309151649,21),r=o+i((n^(o|~s))+r+u+4149444226,6),s=r+i((o^(r|~n))+s+U+3174756917,10),n=s+i((r^(s|~o))+n+l+718787259,15),o=n+i((s^(n|~r))+o+y+3951481745,21),this.#e=this.#e+r>>>0,this.#t=this.#t+o>>>0,this.#r=this.#r+n>>>0,this.#o=this.#o+s>>>0}update(t){let r;if(typeof t=="string")r=new TextEncoder().encode(t);else if(typeof t=="object")if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))r=new Uint8Array(t);else throw new TypeError(ur);else throw new TypeError(ur);let o=this.#i,n=J-o;if(r.length<n)this.#n.set(r,o),o+=r.length;else{this.#n.set(r.slice(0,n),o),this.#c(this.#n);let s=n;for(;s+J<=r.length;)this.#c(r.slice(s,s+J)),s+=J;this.#n.fill(0).set(r.slice(s),0),o=r.length-s}return this.#i=o,this.#l(r.length),this}digest(){let t=J-this.#i;t<9&&(t+=J);let r=new Uint8Array(t);r0=128;let o=this.#s<<3,n=this.#a<<3|this.#s>>>29;rr.length-8=o&255,rr.length-7=o>>>8&255,rr.length-6=o>>>16&255,rr.length-5=o>>>24&255,rr.length-4=n&255,rr.length-3=n>>>8&255,rr.length-2=n>>>16&255,rr.length-1=n>>>24&255,this.update(r.buffer);let s=new ArrayBuffer(16),a=new DataView(s);return a.setUint32(0,this.#e,!0),a.setUint32(4,this.#t,!0),a.setUint32(8,this.#r,!0),a.setUint32(12,this.#o,!0),s}toString(t="hex"){let r=this.digest();switch(t){case"hex":return new TextDecoder().decode(dr(new Uint8Array(r)));case"base64":{let o=new Uint8Array(r),n="";for(let s=0;s<o.length;++s)n+=String.fromCharCode(os);return btoa(n)}default:throw new Error("md5: invalid format")}}};var Z=e=>new Promise(t=>setTimeout(()=>t(),e));var Ao=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,qo=/https?:\/\/youtu\.be\/(a-zA-Z\d_-+)(?:\?(^\s{0,100})|)/,zo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/(a-zA-Z\d_-+)(?:\?(^\s+)|)/,Ko=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:^\s+&|)list=(a-zA-Z\d_-+)(?:&^\s+|))/,mr=e=>{if(Ao.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(qo);if(t){let,r,o=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(zo);if(t){let,r,o=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(Ko);if(t){let,r,o=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Go=/https?:\/\/vimeo\.com\/(0-9+)/i,fr=e=>{let t=e.match(Go);if(!!t)return t1};var Wo=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/(a-zA-Z\d_-+)(?:\?^\s{0,100}|)/,gr=e=>{let t=e.match(Wo);if(!t)return;let,r,o=t;return{videoId:o,pathType:r}};var Xo=/https?:\/\/anchor\.fm\/a-zA-Z\d_-+\/episodes\/(a-zA-Z\d_-+(?:\/a-zA-Z\d_-+)?)(?:\?^\s{0,100}|)/,hr=e=>{let t=e.match(Xo);if(!t)return;let,r=t;return r};var br=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let a=mr(n);if(a)return{type:"youtube",href:n,...a,...s};let i=fr(n);if(i)return{type:"vimeo",videoId:i,href:n,...s};let c=gr(n);if(c)return{type:"spotify",href:n,...c,...s};let p=hr(n);if(p)return{type:"anchor-fm",videoId:p,href:n,...s};if(Yo(n))return{type:"video",href:n,...s}}return Vo(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},Vo=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),Yo=e=>/\.(?:mp4|webm)$/.test(e);var xr=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 Be([]);if(!o.ok)return r;let n=o.value.projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var yr=!1;scrapbox.addListener("lines:changed",()=>yr=!1);scrapbox.addListener("layout:changed",()=>yr=!1);var _r=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var ae=()=>Qo(document.getElementById("editor"),"div#editor");var Qo=(e,t)=>{if(!!e)return _r(e,t),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_${O(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var vr=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 wr;(function(e){})(wr||(wr={}));var nn="0.13.3",Er,Lr=async(e=nn)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(document.querySelector(script[src="${t}"]))return window.katex!==void 0?Promise.resolve(window.katex):await new Promise(o=>{let n=setInterval(()=>{window.katex!==void 0&&(clearInterval(n),o(window.katex))},500)});let r=document.createElement("script");return r.src=t,Er??=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>n(s),document.head.append(r)}),Er};var _e=(e,t={})=>{let r=oe(null),o,n=C(e),s,a=C("");return D(()=>{(async()=>{let{render:i}=await Lr();if(!!r.current)try{i(o,r.current,t),a("")}catch(c){if(c instanceof Error&&c.name==="ParseError")a(c.message.slice("KaTeX parse error: ".length));else throw c}})()},o),{ref:r,error:s,setFormula:n}};var ce=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 pt=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&O(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=ce({pathType:r.pathType,href:r.href});return o?!n&&O(s)===e.titleLc:n===e.project&&O(s)===e.titleLc}case"quote":case"strong":case"decoration":return pt(e,r.nodes)}});var E=(e,t)=>/${e}/${O(t)},$e=e=>{let t=e.match("/(^/+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/([^/]+)/(.+)");return{project:t1,titleLc:t2}};var le=(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 Tr=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let a=s0().finally(()=>o(a)).then(i=>s1(i)).catch(i=>s2(i));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 sn="0.6.5",Pr=ScrapBubble-${sn},Nr=await globalThis.caches.open(Pr);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Pr&&(await globalThis.caches.delete(e),console.log([ScrapBubble] deleted old cache :"${e}"))})();var Sr=Tr(3);async function*Fe(e,t){let r=((t?.saveFailedResponse?Nr.match(e):void 0)??vr(e,t)).then(a=>"cache",a);{let a=Z(1e3).then(()=>"timeout"),i=await Promise.race(r,a);if(i!=="timeout"){i1&&(yield["cache",i1]);let c=await Sr(()=>fetch(e));!c.ok&&t?.saveFailedResponse&&await Nr.put(e,c.clone()),yield"network",c}}let o=Sr(()=>fetch(e)).then(a=>"network",a),n,s=await Promise.race(r,o);if(n==="network"){yieldn,s;return}s&&(yieldn,s),yield await o}var Ir=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var He=()=>{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 Cr=Symbol.for("immer-nothing"),Mr=Symbol.for("immer-draftable"),_=Symbol.for("immer-state");function H(e,...t){throw new Error([Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var pe=Object.getPrototypeOf;function de(e){return!!e&&!!e_}function q(e){return e?Rr(e)||Array.isArray(e)||!!eMr||!!e.constructor?.Mr||Ae(e)||qe(e):!1}var an=Object.prototype.constructor.toString();function Rr(e){if(!e||typeof e!="object")return!1;let t=pe(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)===an}function ue(e,t){Ue(e)===0?Object.entries(e).forEach((r,o)=>{t(r,o,e)}):e.forEach((r,o)=>t(o,r,e))}function Ue(e){let t=e_;return t?t.type_:Array.isArray(e)?1:Ae(e)?2:qe(e)?3:0}function dt(e,t){return Ue(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function jr(e,t,r){let o=Ue(e);o===2?e.set(t,r):o===3?e.add(r):et=r}function cn(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function Ae(e){return e instanceof Map}function qe(e){return e instanceof Set}function P(e){return e.copy_||e.base_}function ut(e,t){if(Ae(e))return new Map(e);if(qe(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Rr(e))return pe(e)?{...e}:Object.assign(Object.create(null),e);let r=Object.getOwnPropertyDescriptors(e);delete r_;let o=Reflect.ownKeys(r);for(let n=0;n<o.length;n++){let s=on,a=rs;a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(rs={configurable:!0,writable:!0,enumerable:a.enumerable,value:es})}return Object.create(pe(e),r)}function mt(e,t=!1){return ze(e)||de(e)||!q(e)||(Ue(e)>1&&(e.set=e.add=e.clear=e.delete=ln),Object.freeze(e),t&&ue(e,(r,o)=>mt(o,!0),!0)),e}function ln(){H(2)}function ze(e){return Object.isFrozen(e)}var ft={};function ee(e){let t=fte;return t||H(0,e),t}function pn(e,t){fte||(fte=t)}var ke;function Ke(){return ke}function dn(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Or(e,t){t&&(ee("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function gt(e){ht(e),e.drafts_.forEach(un),e.drafts_=null}function ht(e){e===ke&&(ke=e.parent_)}function Br(e){return ke=dn(ke,e)}function un(e){let t=e_;t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Dr(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_0;return e!==void 0&&e!==r?(r_.modified_&&(gt(t),H(4)),q(e)&&(e=Ge(t,e),t.parent_||We(t,e)),t.patches_&&ee("Patches").generateReplacementPatches_(r_.base_,e,t.patches_,t.inversePatches_)):e=Ge(t,r,[]),gt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Cr?e:void 0}function Ge(e,t,r){if(ze(t))return t;let o=t_;if(!o)return ue(t,(n,s)=>$r(e,o,t,n,s,r),!0),t;if(o.scope_!==e)return t;if(!o.modified_)return We(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),ue(s,(i,c)=>$r(e,o,n,i,c,r,a)),We(e,n,!1),r&&e.patches_&&ee("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function $r(e,t,r,o,n,s,a){if(de(n)){let i=s&&t&&t.type_!==3&&!dt(t.assigned_,o)?s.concat(o):void 0,c=Ge(e,n,i);if(jr(r,o,c),de(c))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(q(n)&&!ze(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ge(e,n),(!t||!t.scope_.parent_)&&We(e,n)}}function We(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&mt(t,r)}function mn(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Ke(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=bt;r&&(n=o,s=ve);let{revoke:a,proxy:i}=Proxy.revocable(n,s);return o.draft_=i,o.revoke_=a,i}var bt={get(e,t){if(t===_)return e;let r=P(e);if(!dt(r,t))return fn(e,r,t);let o=rt;return e.finalized_||!q(o)?o:o===xt(e.base_,t)?(yt(e),e.copy_t=we(o,e)):o},has(e,t){return t in P(e)},ownKeys(e){return Reflect.ownKeys(P(e))},set(e,t,r){let o=Fr(P(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=xt(P(e),t),s=n?._;if(s&&s.base_===r)return e.copy_t=r,e.assigned_t=!1,!0;if(cn(r,n)&&(r!==void 0||dt(e.base_,t)))return!0;yt(e),z(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 xt(e.base_,t)!==void 0||t in e.base_?(e.assigned_t=!1,yt(e),z(e)):delete e.assigned_t,e.copy_&&delete e.copy_t,!0},getOwnPropertyDescriptor(e,t){let r=P(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:rt}},defineProperty(){H(11)},getPrototypeOf(e){return pe(e.base_)},setPrototypeOf(){H(12)}},ve={};ue(bt,(e,t)=>{vee=function(){return arguments0=arguments00,t.apply(this,arguments)}});ve.deleteProperty=function(e,t){return ve.set.call(this,e,t,void 0)};ve.set=function(e,t,r){return bt.set.call(this,e0,t,r,e0)};function xt(e,t){let r=e_;return(r?P(r):e)t}function fn(e,t,r){let o=Fr(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Fr(e,t){if(!(t in e))return;let r=pe(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=pe(r)}}function z(e){e.modified_||(e.modified_=!0,e.parent_&&z(e.parent_))}function yt(e){e.copy_||(e.copy_=ut(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gn=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(i=s,...c){return a.produce(i,p=>r.call(this,p,...c))}}typeof r!="function"&&H(6),o!==void 0&&typeof o!="function"&&H(7);let n;if(q(t)){let s=Br(this),a=we(t,void 0),i=!0;try{n=r(a),i=!1}finally{i?gt(s):ht(s)}return Or(s,o),Dr(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===Cr&&(n=void 0),this.autoFreeze_&&mt(n,!0),o){let s=[],a=[];ee("Patches").generateReplacementPatches_(t,n,s,a),o(s,a)}return n}else H(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,i=>t(i,...a));let o,n;returnthis.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){q(e)||H(8),de(e)&&(e=hn(e));let t=Br(this),r=we(e,void 0);return r_.isManual_=!0,ht(t),r}finishDraft(e,t){let r=e&&e_;(!r||!r.isManual_)&&H(9);let{scope_:o}=r;return Or(o,t),Dr(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=tr;if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let o=ee("Patches").applyPatches_;return de(e)?o(e,t):this.produce(e,n=>o(n,t))}};function we(e,t){let r=Ae(e)?ee("MapSet").proxyMap_(e,t):qe(e)?ee("MapSet").proxySet_(e,t):mn(e,t);return(t?t.scope_:Ke()).drafts_.push(r),r}function hn(e){return de(e)||H(10,e),Hr(e)}function Hr(e){if(!q(e)||ze(e))return e;let t=e_,r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=ut(e,t.scope_.immer_.useStrictShallowCopy_)}else r=ut(e,!0);return ue(r,(o,n)=>{jr(r,o,Hr(n))}),t&&(t.finalized_=!1),r}function Ur(){class e extends Map{constructor(c,p){super(),this_={type_:2,parent_:p,scope_:p?p.scope_:Ke(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:c,draft_:this,isManual_:!1,revoked_:!1}}get size(){return P(this_).size}has(c){return P(this_).has(c)}set(c,p){let l=this_;return a(l),(!P(l).has(c)||P(l).get(c)!==p)&&(r(l),z(l),l.assigned_.set(c,!0),l.copy_.set(c,p),l.assigned_.set(c,!0)),this}delete(c){if(!this.has(c))return!1;let p=this_;return a(p),r(p),z(p),p.base_.has(c)?p.assigned_.set(c,!1):p.assigned_.delete(c),p.copy_.delete(c),!0}clear(){let c=this_;a(c),P(c).size&&(r(c),z(c),c.assigned_=new Map,ue(c.base_,p=>{c.assigned_.set(p,!1)}),c.copy_.clear())}forEach(c,p){let l=this_;P(l).forEach((g,u,m)=>{c.call(p,this.get(u),u,this)})}get(c){let p=this_;a(p);let l=P(p).get(c);if(p.finalized_||!q(l)||l!==p.base_.get(c))return l;let g=we(l,p);return r(p),p.copy_.set(c,g),g}keys(){return P(this_).keys()}values(){let c=this.keys();return{Symbol.iterator:()=>this.values(),next:()=>{let p=c.next();return p.done?p:{done:!1,value:this.get(p.value)}}}}entries(){let c=this.keys();return{Symbol.iterator:()=>this.entries(),next:()=>{let p=c.next();if(p.done)return p;let l=this.get(p.value);return{done:!1,value:p.value,l}}}}Symbol.iterator(){return this.entries()}}function t(i,c){return new e(i,c)}function r(i){i.copy_||(i.assigned_=new Map,i.copy_=new Map(i.base_))}class o extends Set{constructor(c,p){super(),this_={type_:3,parent_:p,scope_:p?p.scope_:Ke(),modified_:!1,finalized_:!1,copy_:void 0,base_:c,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return P(this_).size}has(c){let p=this_;return a(p),p.copy_?!!(p.copy_.has(c)||p.drafts_.has(c)&&p.copy_.has(p.drafts_.get(c))):p.base_.has(c)}add(c){let p=this_;return a(p),this.has(c)||(s(p),z(p),p.copy_.add(c)),this}delete(c){if(!this.has(c))return!1;let p=this_;return a(p),s(p),z(p),p.copy_.delete(c)||(p.drafts_.has(c)?p.copy_.delete(p.drafts_.get(c)):!1)}clear(){let c=this_;a(c),P(c).size&&(s(c),z(c),c.copy_.clear())}values(){let c=this_;return a(c),s(c),c.copy_.values()}entries(){let c=this_;return a(c),s(c),c.copy_.entries()}keys(){return this.values()}Symbol.iterator(){return this.values()}forEach(c,p){let l=this.values(),g=l.next();for(;!g.done;)c.call(p,g.value,g.value,this),g=l.next()}}function n(i,c){return new o(i,c)}function s(i){i.copy_||(i.copy_=new Set,i.base_.forEach(c=>{if(q(c)){let p=we(c,i);i.drafts_.set(c,p),i.copy_.add(p)}else i.copy_.add(c)}))}function a(i){i.revoked_&&H(3,JSON.stringify(P(i)))}pn("MapSet",{proxyMap_:t,proxySet_:n})}var $=new gn,Xe=$.produce,Dd=$.produceWithPatches.bind($),$d=$.setAutoFreeze.bind($),Fd=$.setUseStrictShallowCopy.bind($),Hd=$.applyPatches.bind($),Ud=$.createDraft.bind($),Ad=$.finishDraft.bind($);Ur();var Ar=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},qr=(e,t)=>Xe(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...a}=t;Object.assign(r,a),_t(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}_t(r)&&!_t(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)}),_t=e=>e.lines0.id==="dummy";var zr=(e,t)=>{let r=new Map,o=O(t.title);for(let c of t.links){let p=bn(e,c);p.linked=o,r.set(E(e,c),p)}let n=E(e,o),s=t.projectLinks.map(c=>{let p=$e(c);return E(p.project,p.titleLc)}),a={...Ve(e,t),linked:[],projectLinked:[]};r.set(n,a);let i=t.links.map(c=>O(c));for(let c of t.relatedPages.links1hop){c.linksLc.includes(o)&&a.linked.push(c.titleLc);for(let u of c.linksLc.filter(m=>i.includes(m))){let m=E(e,u),f=r.get(m);if(!f)throw Error(storage already must have "${m}");if(!f.linked){f.linked=c.titleLc;continue}f.linked.push(c.titleLc)}let p=E(e,c.titleLc),l=Ve(e,c),g=r.get(p)?.linked;g&&(l.linked=g),r.set(p,l)}for(let c of t.relatedPages.projectLinks1hop){let p=E(c.projectName,c.titleLc);s.includes(p)||a.projectLinked.push(p);let l=Ve(c.projectName,c),g=r.get(p)?.projectLinked;g&&(l.projectLinked=g),r.set(p,l)}a.isLinkedCorrect=!0;for(let c of t.relatedPages.links2hop){for(let u of c.linksLc){let m=E(e,u),f=r.get(m);if(!f)throw Error(storage already must have "${m}");if(!f.linked){f.linked=c.titleLc;continue}f.linked.push(c.titleLc)}let p=E(e,c.titleLc),l=Ve(e,c),g=r.get(p)?.linked;g&&(l.linked=g),r.set(p,l)}return r},Ve=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:O(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}),bn=(e,t)=>({project:e,titleLc:O(t),exists:!1,descriptions:[],image:null,lines:{text:t,id:"dummy",userId:"dummy",updated:0,created:0},updated:0,isLinkedCorrect:!1});var F=!1,Kr=e=>{F=typeof e=="boolean"?e:new Set(e)},W=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,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)=>{F!==!0&&(!F||!F.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{F!==!0&&(!F||!F.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{F!==!0&&(!F||!F.has(e))||r(${e} ${o})}];default:returnt,(...o)=>{if(!(F!==!0&&(!F||!F.has(e))))return r(...o)}}}));var Ye=W("ScrapBubble:bubble.ts"),kt=new Map,Qe=new Set,vt=He();function*Gr(e){for(let t of e)yield kt.get(t)}var Wr=(e,t)=>vt.on(e,t),Xr=(e,t)=>vt.off(e,t),Vr=async(e,t,r,o)=>{let n=[];for(let s of...t.reverse()){let a=E(s,e);Qe.has(a)||n.push(xn(s,e,r,o))}await Promise.all(n)},Yr=0,xn=async(e,t,r,o)=>{let n=E(e,t);if(Qe.has(n))return;Qe.add(n);let s=Yr++,a=[${s}] Check update ${n};Ye.time(a);try{let i=se.toRequest(e,t,{followRename:!0,projects:...r});for await(letc,pof Fe(i,{ignoreSearch:!0,saveFailedResponse:!0})){Ye.debug([${s}]${c} ${n});let l=await se.fromResponse(p);if(l.ok){let g=zr(e,l.value);for(letu,mof g){let f=kt.get(u),x=qr(f,m);!x||f!==x&&(kt.set(u,x),vt.dispatch(u,m))}}if(o?.ignoreFetch===!0||c==="cache"&&!Ir(p,o?.maxAge??60))break}}catch(i){Ye.error(i)}finally{Qe.delete(n),Ye.timeEnd(a),Yr--}};var Qr=W("ScrapBubble:useBubbleData.ts"),me=e=>{lett,r=C([]);return je(()=>{let o=()=>{r(()=>{let a=...Gr(e).flatMap(i=>i?i:[]);return Qr.debug(Required: ${e.length} pages, ${a.length} found,a),a})};o();let n,s=()=>{clearTimeout(n),n=setTimeout(()=>{Qr.debug(Update ${e.length} pages),o()},10)};return e.forEach(a=>Wr(a,s)),()=>e.forEach(a=>Xr(a,s))},e),t};var fe=e=>{let t=ae();Q(t,"#editor");let{top:r,right:o,left:n,bottom:s}=e.getBoundingClientRect(),a=t.getBoundingClientRect(),i=(n-a.left)/a.width>.5;return{top:Math.round(s-a.top),bottom:Math.round(a.bottom-r),...i?{right:Math.round(a.right-o)}:{left:Math.round(n-a.left)},maxWidth:i?o-10:document.documentElement.clientWidth-n-10}};var yn=e=>({type:"title",text:e.rows0.text}),_n=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(` )}},N=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,a)=>{var i,c,p,l,g,u;if(!t&&s.nested)return(i=a?.())!==null&&i!==void 0?i:[];if(!r&&s.quoted)return(c=a?.())!==null&&c!==void 0?c:[];for(let m of o){let f=m.exec(n);if(f===null)continue;let x=n.substring(0,f.index),b=n.substring(f.index+((l=(p=f[0])===null||p===void 0?void 0:p.length)!==null&&l!==void 0?l:0)),y=e((g=f[0])!==null&&g!==void 0?g:"",s);return[...X(x,s),...y,...X(b,s)]}return(u=a?.())!==null&&u!==void 0?u:[]},I=e=>[{type:"plain",raw:e,text:e}],kn=N(I,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),vn=/^>.*$/,wn=(e,t)=>t.context==="table"?I(e,t):[{type:"quote",raw:e,nodes:X(e.substring(1),{...t,quoted:!0})}],En=N(wn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[vn]}),Ln=/^\? .+$/,Tn=(e,t)=>t.context==="table"?I(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],Pn=N(Tn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Ln]}),Nn=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,Sn=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,In=(e,t)=>{if(t.context==="table")return I(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}]},Cn=N(In,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Nn,Sn]}),Mn=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function Jr(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return I(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",i=o.substring(n+5,o.length),c=i.startsWith("*")?parseInt(i.substring(1),10):1;return new Array(c).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Rn=Jr("icon"),jn=N(Rn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Mn]}),On=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Bn=Jr("strongIcon"),Dn=N(Bn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[On]}),$n=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Fn=(e,t)=>t.context==="table"?I(e,t):[{type:"strong",raw:e,nodes:X(e.substring(2,e.length-2),{...t,nested:!0})}],Hn=N(Fn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$n]}),Un=/\[\$ .+? \]/,An=/\[\$ [^\]]+\]/,qn=(e,t)=>t.context==="table"?I(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],zn=N(qn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Un,An]}),Kn=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Gn=(e,t)=>{if(t.context==="table")return I(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:X(n,{...t,nested:!0})}]},Wn=N(Gn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Kn]}),Xn=/.*?/,Vn=(e,t)=>t.context==="table"?I(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Yn=N(Vn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Xn]}),Qn=/^[$%] .+$/,Jn=(e,t)=>{var r;if(t.context==="table")return I(e,t);let o=(r=e[0])!==null&&r!==void 0?r:"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:o,text:n}]},Zn=N(Jn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Qn]}),es=/\[\s+\]/,ts=(e,t)=>t.context==="table"?I(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],rs=N(ts,{parseOnNested:!1,parseOnQuoted:!0,patterns:[es]}),os=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,ns=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,ss=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,is=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,as=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||cs(e),cs=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),ls=(e,t)=>{if(t.context==="table")return I(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]=as(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}]},ps=N(ls,{parseOnNested:!0,parseOnQuoted:!0,patterns:[os,ns,ss,is]}),ds=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,us=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,ms=/\[https?:\/\/[^\s\]]+\]/,fs=/https?:\/\/[^\s]+/,gs=(e,t)=>{if(t.context==="table")return I(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()}]},hs=N(gs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ds,us,ms,fs]}),Zr=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,eo=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,bs=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}},xs=(e,t)=>{var r;if(t.context==="table")return I(e,t);let o=(r=e.match(Zr))!==null&&r!==void 0?r:e.match(eo);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=n?o:[o[0],o[2],o[1]],{latitude:i,longitude:c,zoom:p}=bs(s),l=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${i},${c},${p}z:https://www.google.com/maps/@${i},${c},${p}z;return[{type:"googleMap",raw:e,latitude:i,longitude:c,zoom:p,place:a,url:l}]},ys=N(xs,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Zr,eo]}),_s=/\[\/?[^[\]]+\]/,ks=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},vs=N(ks,{parseOnNested:!0,parseOnQuoted:!0,patterns:[_s]}),ws=/(?:^|\s)#\S+/,Es=(e,t)=>{if(t.context==="table")return I(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[...I(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},Ls=N(Es,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ws]}),Ts=/^[0-9]+\. .*$/,Ps=(e,t)=>{if(t.context==="table")return I(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:X(s,{...t,nested:!0})}]},Ns=N(Ps,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Ts]}),Ss=(e,t,r)=>{var o;return e===""?[]:(o=r?.())!==null&&o!==void 0?o:[]},Is=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>kn(t,r))(),X=Is(Ss,En,Pn,Yn,Zn,zn,rs,Wn,Cn,Dn,Hn,ps,hs,jn,ys,vs,Ls,Ns),Cs=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(i=>X(i,{nested:!1,quoted:!1,context:"table"})))}},Ms=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"})}},Rs=e=>{switch(e.type){case"title":return yn(e);case"codeBlock":return _n(e);case"table":return Cs(e);case"line":return Ms(e)}},js=e=>e.split( ).map(t=>{var r,o,n;return{indent:(n=(o=(r=/^\s+/.exec(t))===null||r===void 0?void 0:r[0])===null||o===void 0?void 0:o.length)!==null&&n!==void 0?n:0,text:t}}),Os=(e,t)=>{var r,o;return(e.type==="codeBlock"||e.type==="table")&&t.indent>((o=(r=e.rows[0])===null||r===void 0?void 0:r.indent)!==null&&o!==void 0?o:0)},to=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Os(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)},Bs=(e,t)=>{var r;if(!((r=t.hasTitle)!==null&&r!==void 0)||r){let[o,...n]=e;return o===void 0?[]:[{type:"title",rows:[o]},...n.reduce(to,[])]}return e.reduce(to,[])},Ee=(e,t)=>{var r;let o=js(e);return Bs(o,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(Rs)};var V=ot({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),ro=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:a,...i})=>{let c=k(()=>e.flatMap(u=>typeof u=="string"?[]:[u.id]),[e]),p=k(()=>{let u=0;return Ee(e.map(m=>typeof m=="string"?m:m.text).join(
),{hasTitle:!0}).map(m=>{switch(m.type){case"title":case"line":return{...m,id:c[u++]};case"codeBlock":{let f=u;return u+=m.content.split(
).length+1,{...m,ids:c.slice(f,u)}}case"table":{let f=u;return u+=m.cells.length+1,{...m,ids:c.slice(f,u)}}}})},[e,c]),l=k(()=>{if(s&&c.includes(s))return s;if(!!a)return p.find(u=>u.type!=="line"?!1:pt(a,u.nodes))?.id},[p,c,s,a?.project,a?.titleLc]),g=oe(null);return D(()=>{if(!l)return;let u=g.current?.querySelector(data-id="${l}"),m=window.scrollY;u?.scrollIntoView?.({block:"center"}),window.scroll(0,m)},[l]),d("div",{className:"lines",ref:g},d(V.Provider,{value:{project:t,title:r,whiteList:o,...i}},p.map(u=>{switch(u.type){case"title":return d(v,null,d(ge,{key:u.id,index:u.id,indent:0,noIndent:n,permalink:u.id===l},u.text),d("hr",null));case"codeBlock":return d(Ds,{key:u.ids[0],block:u,noIndent:n,ids:u.ids,scrollId:l});case"table":return d($s,{key:u.ids[0],block:u,noIndent:n,ids:u.ids,scrollId:l});case"line":return d(ge,{key:u.id,index:u.id,indent:u.indent,noIndent:n,permalink:u.id===l},u.nodes.length>0?u.nodes.map(m=>d(he,{node:m})):d("br",null))}})))},ge=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>d("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em}},o),Ds=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=G(V),[i,c]=C(""),p=B(async l=>{l.preventDefault(),l.stopPropagation();try{await navigator.clipboard.writeText(t),c("Copied"),await Z(1e3),c("")}catch(g){alert(Failed to copy the code block Error:${g.message})}},[t]);return d(v,null,d(ge,{index:o[0],indent:r,permalink:o[0]===n},d("span",{className:"code-block"},d("span",{className:"code-block-start"},d("a",{href:/api/code/${s}/${M(a)}/${e},target:"_blank"},e)),d("span",{className:"copy",title:"Copy",onClick:p},i))),d(v,null,t.split(
).map((l,g)=>d(ge,{index:o[g+1],indent:r,permalink:o[g+1]===n},d("code",{className:"code-block"},l)))))},$s=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=G(V);return d(v,null,d(ge,{index:o[0],indent:r,permalink:o[0]===n},d("span",{className:"table-block"},d("span",{className:"table-block-start"},d("a",{href:/api/table/${s}/${M(a)}/${e}.csv,target:"_blank"},e)))),d(v,null,t.map((i,c)=>d(ge,{index:o[c+1],indent:r,permalink:o[c+1]===n},d("span",{className:"table-block table-block-row"},i.map((p,l)=>d("span",{className:cell col-${l}},p.map(g=>d(he,{node:g})))))))))},he=({node:e})=>{switch(e.type){case"code":return d("code",{className:"code"},e.text);case"formula":return d(Fs,{node:e});case"commandLine":return d(Us,{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(he,{node:t})));case"strong":return d("strong",null,e.nodes.map(t=>d(he,{node:t})));case"decoration":return d(Hs,{node:e});case"plain":case"blank":return d(v,null,e.text);case"hashTag":return d(zs,{node:e});case"link":return d(Ks,{node:e});case"googleMap":return d(As,{node:e});case"icon":return d(oo,{node:e});case"strongIcon":return d(oo,{node:e,strong:!0});case"image":return d(qs,{node:e});case"strongImage":return d("img",{className:"image strong-image",src:e.src});case"numberList":return d(v,null,${e.number}. ,e.nodes.map(t=>d(he,{node:t})))}},Fs=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=_e("");return o(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},Hs=({node:{decos:e,nodes:t}})=>d("span",{className:e.map(r=>deco-${r}).join(" ")},t.map(r=>d(he,{node:r}))),Us=({node:e})=>{let[t,r]=C(""),o=B(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await Z(1e3),r("")}catch(s){alert(Failed to copy the code block
Error:${s.message})}},[e.text]);return d(v,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:o},t)))},As=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>d("span",{className:"pointing-device-map"},d("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${window._csrf}}))),oo=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=G(V),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],a=M(s);return d("a",{href:/${n}/${a},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank"},d("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${a}/icon},s))},qs=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-"/thumb/1000".length):t);return d("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},d("img",{className:"image",src:t}))},zs=({node:{href:e}})=>{let{project:t}=G(V),r=no(t,e),o=so(t,e,"hashtag");return d("a",{href:/${t}/${M(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},"#",e)},Ks=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return d(Gs,{pathType:e,href:t.href});case"absolute":{let r=br({pathType:e,...t});switch(r.type){case"youtube":return d(Ws,{...r});case"vimeo":return d(Xs,{...r});case"spotify":return d(Vs,{...r});case"anchor-fm":return d(Ys,{...r});case"audio":return d(Qs,{...r});case"video":return d(Zs,{...r});case"absoluteLink":return d("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},Gs=({pathType:e,href:t})=>{let{project:r}=G(V),{project:o=r,title:n,hash:s=""}=ce({pathType:e,href:t}),a=so(o,n,"link",s),i=no(o,n??"");return d("a",{className:page-link${n!==void 0&&i?" empty-page-link":""},type:"link",href:/${o}${n===void 0?"":/${M(n)}${s===""?"":#${s}}},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:a},t)},Ws=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"}))},Xs=({videoId:e})=>d("div",{className:"iframe-video-player"},d("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0,type:"text/html"})),Vs=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"})),Ys=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"})),Qs=e=>e.content===""?d("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):d(Js,{...e}),Js=({href:e,content:t})=>{let r=oe(null),o=B(()=>{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:o},"♬"),d("audio",{preload:"none",src:e,ref:r}))},Zs=({href:e})=>d("div",{className:"video-player"},d("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})),no=(e,t)=>{let{whiteList:r}=G(V),o=k(()=>(r.has(e)?[...r]:[e,...r]).map(s=>E(s,t)),[r,e]),n=me(o);return k(()=>Ar(n),n)},so=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:a}=G(V);return B(async({currentTarget:i})=>{!t||(a(e,t),!!await le(i,n)&&s({project:e,title:t,hash:o,type:r,position:fe(i)}))},[e,t,o,r,n,a,s])};var wt=He(),Je=new Map,ei=W("ScrapBubble:useProject.ts"),io=e=>{let[t,r]=C();return D(()=>{wt.on(e,r);let o=Je.get(e);return o?r(o.loading?void 0:o.value):(Je.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=ie.toRequest(e);for await(let[,s]of Fe(n)){let a=await ie.fromResponse(s);Je.set(e,{loading:!1,value:a}),wt.dispatch(e,a);break}}catch(n){ei.error(n),Je.delete(e)}})()),()=>wt.off(e,r)},[e]),t};var ti=["default-light","default-dark","default-minimal"],ri=["paper-light","paper-dark-dark","paper-dark"],ao=["blue","purple","green","orange","red"],oi=["hacker1","hacker2"],co=["winter","spring","summer","automn"],lo=["tropical"],po=["kyoto","newyork","paris"],uo=["mred","lgreen"],Zu=["default-light","default-minimal","paper-light",...ao,...co,...lo,...po,...uo];var ni=[...ti,...ri,...ao,...oi,...co,...lo,...po,...uo];function mo(e){return ni.includes(e)}var fo="default-light",Ze=e=>{let t=io(e);return k(()=>{if(!t||!t.ok)return fo;let r=t.value.theme;return mo(r)?r:fo},[t])};var go=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:a,prefetch:i})=>{let c=k(()=>o?[]:Ee(r.join( ),{hasTitle:!1}),[o,r]),p=Ze(e),l=B(async({currentTarget:u})=>{i(e,t),!!await le(u,a)&&s({project:e,title:t,linkTo:n,type:"link",position:fe(u)})},[e,t,a,n?.project,n?.titleLc]),g=k(()=>n?()=>{lt({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return d("a",{className:"related-page-card page-link",type:"link","data-theme":p,href:/${e}/${M(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:l,onClick:g},d("div",{class:"hover"}),d("div",{class:"content"},d("div",{class:"header"},d("div",{class:"title"},t)),o?d("div",{class:"thumbnail"},d("img",{src:o})):d("div",{class:"description"},c.flatMap((u,m)=>u.type==="line"?[d("p",{key:m},u.nodes.map(f=>d(ho,{node:f,project:e})))]:[]))))},ho=({node:e,project:t})=>{switch(e.type){case"code":return d("code",null,e.text);case"formula":return d(si,{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(v,null,e.nodes.map(r=>d(ho,{node:r,project:t})));case"icon":case"strongIcon":return d(ii,{node:e,project:t});case"hashTag":return d(ai,{node:e});case"link":return d(ci,{node:e});case"plain":case"blank":return d(v,null,e.text);default:return d(v,null)}},si=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=_e("");return o(e),d("span",{className:formula ${r?" error":""}},r?d("code",null,e):d("span",{className:"katex-display",ref:t}))},ii=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return d("img",{class:"icon",src:/api/pages/${o}/${M(n)}/icon})},ai=({node:{href:e}})=>d("span",{class:"page-link"},"#",e),ci=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?d("span",{class:"page-link"},t):d("span",{class:"link"},r||t);var bo=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=k(()=>[...t.keys(),...r.keys()],[t,r]),a=me(s),i=k(()=>[...o],[o]),c=k(()=>{let l=(g,u)=>{let m=i.indexOf(g.project),f=i.indexOf(u.project);return m===f?u.updated-g.updated:m<0?1:f<0?-1:m-f};return[...a].sort(l)},[a,i]),p=k(()=>({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:p,onClick:n.onClick},c.map(({project:l,titleLc:g,lines:[{text:u}],descriptions:m,image:f})=>{let x=E(l,g),b=t.get(x)??r.get(x);return d("li",{key:x},d(go,{project:l,title:u,linkTo:b,descriptions:m,thumbnail:f??"",...n}))}))};var xo=W("ScrapBubble:Bubble.tsx"),yo=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=k(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,a,i]=li(e,n,r,t),c=B(()=>o.hide(),[o.hide]),p=Ze(i[0]?.project??e.project),l=k(()=>({top:${e.position.top}px,maxWidth:${e.position.maxWidth}px,..."left"in e.position?{left:${e.position.left}px}:{right:${e.position.right}px}}),[e.position]);return d(v,null,i.length>0&&d("div",{className:"text-bubble",style:l,"data-theme":p,onClick:c},d(pi,null,i[0].project!==scrapbox.Project.name&&d(di,{project:i[0].project,title:i[0].lines[0].text})),d(ro,{lines:i[0].lines,project:i[0].project,title:i[0].lines[0].text,hash:e.hash,linkTo:e.linkTo,whiteList:r,...o})),d(bo,{linked:s,externalLinked:a,onClick:c,source:e,projectsForSort:n,...o}))},li=(e,t,r,o)=>{let[[n,s,a],i]=C([new Map,new Map,[]]),c=k(()=>{let g=[...t].map(u=>E(u,e.title));return xo.debug("projects",g),g},[t,e.title]),p=me(c),l=k(()=>o.map(g=>O(g)),[o]);return je(()=>{let g=new Map,u=new Map,m=[];for(let f of p){let x={project:f.project,titleLc:f.titleLc};for(let y of f.projectLinked??[]){let{project:L,titleLc:U}=$e(y);l.includes(U)&&r.has(L)||u.has(y)||u.set(y,x)}if(!r.has(f.project))continue;let b={titleLc:f.titleLc};for(let y of f.linked??[]){if(l.includes(y))continue;let L=E(f.project,y);g.has(L)||g.set(L,b)}l.includes(f.titleLc)||!f.exists||m.push(f)}i(Xe(f=>{xo.debug(depth: ${l.length}, bubbled from ${E(e.project,e.title)}, bubbles,,p,"before",f[0],"internal cards,",g,"external cards",u);for(let x of f[0].keys())g.has(x)||f[0].delete(x);for(let[x,b]of g)f[0].set(x,b);for(let x of f[1].keys())u.has(x)||f[1].delete(x);for(let[x,b]of u)f[1].set(x,b);f[2]=m}))},[p,r,l]),[n,s,a]},pi=({children:e})=>d("div",{className:"status-bar top-right"},e),di=({project:e,title:t})=>d("a",{href:/${e}/${M(t)},target:"_blank",rel:"noopener noreferrer"},e);var _o=(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 ko=e=>{let t=k(()=>_o(e.style,import.meta.url),[e.style]);return d(v,null,t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",null,t)))};var vo=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(2n+1){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{padding:5px 0 5px 5px;font-size:11px;line-height:1.42857;user-select:text;position:absolute;max-height:80vh;overflow-y:auto;background-color:var(--page-bg, #fefefe);color:var(--page-text-color, #4a4a4a);border-radius:4px;--text-bubble-border-color: hsl(221, 15%, 25%);border:1px solid var(--text-bubble-border-color, #f2f2f3);--status-bar-border-color: var(--text-bubble-border-color, #f2f2f3);box-shadow:0 6px 12px #0000002d;z-index:9000}.text-bubble.no-scroll{overflow-y:hidden}.text-bubbledata-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}.text-bubbledata-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}.text-bubbledata-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}.text-bubbledata-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}.text-bubbledata-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}.text-bubbledata-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}.text-bubbledata-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}.text-bubbledata-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}.text-bubbledata-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}.text-bubbledata-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}.text-bubbledata-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}.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 wo=()=>{let[e,t]=C([]),r=B((s,a)=>t(i=>a?[...i.slice(0,s),a]:[...i.slice(0,s)]),[]),[o,n]=C([{bubble:s=>r(0,s),hide:()=>r(0)}]);return D(()=>{n(([s,...a])=>[s,...e.map((i,c)=>i===a.at(c)?.source?a.at(c):{source:i,parentTitles:[scrapbox.Page.title??"",...e.slice(0,c).map(p=>p.title)],bubble:p=>r(c+1,p),hide:()=>r(c+1)})])},[e]),o};var Et=(e,t,r,o,n)=>{D(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var Eo=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),et=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var Lt="scrap-bubble",Lo=ae();Q(Lo,"#editor");var To=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...a]=wo(),i=B((c,p)=>Vr(p,t.has(c)?t:new Set([c]),r),[t,r]);return Et(Lo,"pointerenter",async c=>{Q(c.currentTarget,"event.currentTarget");let p=c.target;if(!et(p)&&!Eo(p))return;let{project:l=scrapbox.Project.name,title:g,hash:u=""}=et(p)?ce({pathType:"root",href:${new URL(p.href).pathname}${new URL(p.href).hash}`}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(l==="")return;let m=decodeURIComponent(g??"");i(l,m),!!await le(p,e)&&n({project:l,title:m,hash:u,position:fe(p),type:ui(p)})},{capture:!0},e,t,r),Et(document,"click",c=>{c.target.dataset.userscriptName!==Lt&&s()},{capture:!0},s),D(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),s),d(v,null,d("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),d("style",null,vo),d(ko,{style:o}),a.map(c=>d(yo,{key:E(c.source.project,c.source.title),...c,whiteList:t,delay:e,prefetch:i})))},ui=e=>et(e)?e.type==="link"?"link":"hashtag":"title";var mf=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await xr()).slice(0,100),style:n="",debug:s=!1}=e??{};Kr(s);let a=document.createElement("div");a.dataset.userscriptName=Lt;let i=ae();Q(i,"#editor"),i.append(a);let c=a.attachShadow({mode:"open"});Re(d(To,{delay:t,whiteList:new Set(scrapbox.Project.name,...r),watchList:new Set(o),style:n}),c)};export{mf as mount};