ScrapBubble
code:js
var Ne,h,Tt,bo,fe,Pt,wt,Nt,Le={},St=[],xo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i;function q(e,t){for(var r in t)er=tr;return e}function It(e){var t=e.parentNode;t&&t.removeChild(e)}function p(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?Ne.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)as===void 0&&(as=e.defaultPropss);return ke(e,a,o,n,null)}function ke(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??++Tt};return n==null&&h.vnode!=null&&h.vnode(s),s}function w(e){return e.children}function Ee(e,t){this.props=e,this.context=t}function J(e,t){if(t==null)return e.__?J(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"?J(e):null}function Ct(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 Ct(e)}}function Qe(e){(!e.__d&&(e.__d=!0)&&fe.push(e)&&!Te.__r++||wt!==h.debounceRendering)&&((wt=h.debounceRendering)||Pt)(Te)}function Te(){for(var e;Te.__r=fe.length;)e=fe.sort(function(t,r){return t.__v.__b-r.__v.__b}),fe=[],e.some(function(t){var r,o,n,s,a,u;t.__d&&(a=(s=(r=t).__v).__e,(u=r.__P)&&(o=[],(n=q({},s)).__v=s.__v+1,Je(u,s,n,r.__n,u.ownerSVGElement!==void 0,s.__h!=null?a:null,o,a??J(s),s.__h),Ot(o,s),s.__e!=a&&Ct(s)))})}function Mt(e,t,r,o,n,s,a,u,i,l){var c,g,d,f,m,y,b,_=o&&o.__k||St,I=_.length;for(r.__k=[],c=0;c<t.length;c++)if((f=r.__kc=(f=tc)==null||typeof f=="boolean"?null:typeof f=="string"||typeof f=="number"||typeof f=="bigint"?ke(null,f,null,null,f):Array.isArray(f)?ke(w,{children:f},null,null,null):f.__b>0?ke(f.type,f.props,f.key,null,f.__v):f)!=null){if(f.__=r,f.__b=r.__b+1,(d=_c)===null||d&&f.key==d.key&&f.type===d.type)_c=void 0;else for(g=0;g<I;g++){if((d=_g)&&f.key==d.key&&f.type===d.type){_g=void 0;break}d=null}Je(e,f,d=d||Le,n,s,a,u,i,l),m=f.__e,(g=f.ref)&&d.ref!=g&&(b||(b=[]),d.ref&&b.push(d.ref,null,f),b.push(g,f.__c||m,f)),m!=null?(y==null&&(y=m),typeof f.type=="function"&&f.__k===d.__k?f.__d=i=Rt(f,i,e):i=jt(e,f,d,_,m,i),typeof r.type=="function"&&(r.__d=i)):i&&d.__e==i&&i.parentNode!=e&&(i=J(d))}for(r.__e=y,c=I;c--;)_c!=null&&(typeof r.type=="function"&&_c.__e!=null&&_c.__e==r.__d&&(r.__d=J(o,c+1)),$t(_c,_c));if(b)for(c=0;c<b.length;c++)Bt(bc,b++c,b++c)}function Rt(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"?Rt(o,t,r):jt(r,o,o,n,o.__e,t));return t}function jt(e,t,r,o,n,s){var a,u,i;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(u=s,i=0;(u=u.nextSibling)&&i<o.length;i+=2)if(u==n)break e;e.insertBefore(n,s),a=s}return a!==void 0?a:n.nextSibling}function yo(e,t,r,o,n){var s;for(s in r)s==="children"||s==="key"||s in t||Pe(e,s,null,rs,o);for(s in t)n&&typeof ts!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||rs===ts||Pe(e,s,ts,rs,o)}function kt(e,t,r){t0==="-"?e.setProperty(t,r):et=r==null?"":typeof r!="number"||xo.test(t)?r:r+"px"}function Pe(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||kt(e.style,t,"");if(r)for(t in r)o&&rt===ot||kt(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?Lt:Et,s):e.removeEventListener(t,s?Lt:Et,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 Et(e){this.le.type+!1(h.event?h.event(e):e)}function Lt(e){this.le.type+!0(h.event?h.event(e):e)}function Je(e,t,r,o,n,s,a,u,i){var l,c,g,d,f,m,y,b,_,I,Q,H=t.type;if(t.constructor!==void 0)return null;r.__h!=null&&(i=r.__h,u=t.__e=r.__e,t.__h=null,s=u),(l=h.__b)&&l(t);try{e:if(typeof H=="function"){if(b=t.props,_=(l=H.contextType)&&ol.__c,I=l?_?_.props.value:l.__:o,r.__c?y=(c=t.__c=r.__c).__=c.__E:("prototype"in H&&H.prototype.render?t.__c=c=new H(b,I):(t.__c=c=new Ee(b,I),c.constructor=H,c.render=vo),_&&_.sub(c),c.props=b,c.state||(c.state={}),c.context=I,c.__n=o,g=c.__d=!0,c.__h=[]),c.__s==null&&(c.__s=c.state),H.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=q({},c.__s)),q(c.__s,H.getDerivedStateFromProps(b,c.__s))),d=c.props,f=c.state,g)H.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(H.getDerivedStateFromProps==null&&b!==d&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(b,I),!c.__e&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(b,c.__s,I)===!1||t.__v===r.__v){c.props=b,c.state=c.__s,t.__v!==r.__v&&(c.__d=!1),c.__v=t,t.__e=r.__e,t.__k=r.__k,t.__k.forEach(function(we){we&&(we.__=t)}),c.__h.length&&a.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(b,c.__s,I),c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(d,f,m)})}c.context=I,c.props=b,c.state=c.__s,(l=h.__r)&&l(t),c.__d=!1,c.__v=t,c.__P=e,l=c.render(c.props,c.state,c.context),c.state=c.__s,c.getChildContext!=null&&(o=q(q({},o),c.getChildContext())),g||c.getSnapshotBeforeUpdate==null||(m=c.getSnapshotBeforeUpdate(d,f)),Q=l!=null&&l.type===w&&l.key==null?l.props.children:l,Mt(e,Array.isArray(Q)?Q:Q,t,r,o,n,s,a,u,i),c.base=t.__e,t.__h=null,c.__h.length&&a.push(c),y&&(c.__E=c.__=null),c.__e=!1}else s==null&&t.__v===r.__v?(t.__k=r.__k,t.__e=r.__e):t.__e=_o(r.__e,t,r,o,n,s,a,i);(l=h.diffed)&&l(t)}catch(we){t.__v=null,(i||s!=null)&&(t.__e=u,t.__h=!!i,ss.indexOf(u)=null),h.__e(we,t,r)}}function Ot(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 _o(e,t,r,o,n,s,a,u){var i,l,c,g=r.props,d=t.props,f=t.type,m=0;if(f==="svg"&&(n=!0),s!=null){for(;m<s.length;m++)if((i=sm)&&"setAttribute"in i==!!f&&(f?i.localName===f:i.nodeType===3)){e=i,sm=null;break}}if(e==null){if(f===null)return document.createTextNode(d);e=n?document.createElementNS("http://www.w3.org/2000/svg",f):document.createElement(f,d.is&&d),s=null,u=!1}if(f===null)g===d||u&&e.data===d||(e.data=d);else{if(s=s&&Ne.call(e.childNodes),l=(g=r.props||Le).dangerouslySetInnerHTML,c=d.dangerouslySetInnerHTML,!u){if(s!=null)for(g={},m=0;m<e.attributes.length;m++)g[e.attributes[m].name]=e.attributes[m].value;(c||l)&&(c&&(l&&c.__html==l.__html||c.__html===e.innerHTML)||(e.innerHTML=c&&c.__html||""))}if(yo(e,d,g,n,u),c)t.__k=[];else if(m=t.props.children,Mt(e,Array.isArray(m)?m:m,t,r,o,n&&f!=="foreignObject",s,a,s?s0:r.__k&&J(r,0),u),s!=null)for(m=s.length;m--;)sm!=null&&It(sm);u||("value"in d&&(m=d.value)!==void 0&&(m!==g.value||m!==e.value||f==="progress"&&!m)&&Pe(e,"value",m,g.value,!1),"checked"in d&&(m=d.checked)!==void 0&&m!==e.checked&&Pe(e,"checked",m,g.checked,!1))}return e}function Bt(e,t,r){try{typeof e=="function"?e(t):e.current=t}catch(o){h.__e(o,r)}}function $t(e,t,r){var o,n;if(h.unmount&&h.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||Bt(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&&$t(on,t,typeof e.type!="function");r||e.__e==null||It(e.__e),e.__e=e.__d=void 0}function vo(e,t,r){return this.constructor(e,r)}function Se(e,t,r){var o,n,s;h.__&&h.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],Je(t,e=(!o&&r||t).__k=p(w,null,e),n||Le,Le,t.ownerSVGElement!==void 0,!o&&r?r:n?null:t.firstChild?Ne.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o),Ot(s,e)}function Ze(e,t){var r={__c:t="__cC"+Nt++,__: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(Qe)},this.sub=function(a){n.push(a);var u=a.componentWillUnmount;a.componentWillUnmount=function(){n.splice(n.indexOf(a),1),u&&u.call(a)}}),o.children}};return r.Provider.__=r.Consumer.contextType=r}Ne=St.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}},Tt=0,bo=function(e){return e!=null&&e.constructor===void 0},Ee.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=q({},this.state),typeof e=="function"&&(e=e(q({},r),this.props)),e&&q(r,e),e!=null&&this.__v&&(t&&this.__h.push(t),Qe(this))},Ee.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Qe(this))},Ee.prototype.render=w,fe=[],Pt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Te.__r=0,Nt=0;var Z,R,Ft,me=0,et=[],Dt=h.__b,Ht=h.__r,At=h.diffed,Ut=h.__c,qt=h.unmount;function ge(e,t){h.__h&&h.__h(R,e,me||t),me=0;var r=R.__H||(R.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function C(e){return me=1,wo(Kt,e)}function wo(e,t,r){var o=ge(Z++,2);return o.t=e,o.__c||(o.__=[r?r(t):Kt(void 0,t),function(n){var s=o.t(o.__0,n);o.__0!==s&&(o.__=[s,o.__1],o.__c.setState({}))}],o.__c=R),o.__}function B(e,t){var r=ge(Z++,3);!h.__s&&rt(r.__H,t)&&(r.__=e,r.__H=t,R.__H.__h.push(r))}function Ce(e,t){var r=ge(Z++,4);!h.__s&&rt(r.__H,t)&&(r.__=e,r.__H=t,R.__h.push(r))}function ee(e){return me=5,v(function(){return{current:e}},[])}function v(e,t){var r=ge(Z++,7);return rt(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function O(e,t){return me=8,v(function(){return e},t)}function z(e){var t=R.contexte.__c,r=ge(Z++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(R)),t.props.value):e.__}function ko(){var e;for(et.sort(function(t,r){return t.__v.__b-r.__v.__b});e=et.pop();)if(e.__P)try{e.__H.__h.forEach(Ie),e.__H.__h.forEach(tt),e.__H.__h=[]}catch(t){e.__H.__h=[],h.__e(t,e.__v)}}h.__b=function(e){R=null,Dt&&Dt(e)},h.__r=function(e){Ht&&Ht(e),Z=0;var t=(R=e.__c).__H;t&&(t.__h.forEach(Ie),t.__h.forEach(tt),t.__h=[])},h.diffed=function(e){At&&At(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(et.push(t)!==1&&Ft===h.requestAnimationFrame||((Ft=h.requestAnimationFrame)||function(r){var o,n=function(){clearTimeout(s),zt&&cancelAnimationFrame(o),setTimeout(r)},s=setTimeout(n,100);zt&&(o=requestAnimationFrame(n))})(ko)),R=null},h.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Ie),r.__h=r.__h.filter(function(o){return!o.__||tt(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],h.__e(o,r.__v)}}),Ut&&Ut(e,t)},h.unmount=function(e){qt&&qt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Ie(o)}catch(n){t=n}}),t&&h.__e(t,r.__v))};var zt=typeof requestAnimationFrame=="function";function Ie(e){var t=R,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),R=t}function tt(e){var t=R;e.__c=e.__(),R=t}function rt(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==eo})}function Kt(e,t){return typeof t=="function"?t(e):t}var X=(e,t)=>{if(!(e instanceof HTMLDivElement))throw Error(${t??"value"} must be HTMLDivElement)};var k=e=>{let{fetch:t=globalThis.fetch,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Lo=e=>typeof e=="object"&&e!==null,To=e=>Lo(e)?(e.name===void 0||typeof e.name=="string")&&typeof e.message=="string":!1,Gt=e=>{try{let t=typeof e=="string"?JSON.parse(e):e;return To(t)?t:!1}catch(t){if(t instanceof SyntaxError)return!1;throw t}};var he=class e extends Error{constructor(r){super(${r.status} ${r.statusText} when fetching ${r.url});this.response=r;Error.captureStackTrace&&Error.captureStackTrace(this,e)}name="UnexpectedResponseError"},N=async e=>{let t=e.clone(),r=await t.text(),o=Gt(r);if(!o)throw new he(t);return{ok:!1,value:o}};var L=e=>connect.sid=${e};var j=e=>e.replaceAll(" ","_").toLowerCase();var M=e=>...e.map((t,r)=>t===" "?"_":!No.includes(t)||r===e.length-1&&So.includes(t)?encodeURIComponent(t):t).join(""),No='@$&+=:;",',So=':;",';var Wt=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:a}=k(r??{}),u=new URLSearchParams;u.append("followRename",${s??!0});for(let l of a??[])u.append("projects",l);let i=https://${n}/api/pages/${e}/${M(t)}?${u.toString()};return new Request(i,o?{headers:{Cookie:L(o)}}:void 0)},Xt=async e=>e.ok?{ok:!0,value:await e.json()}:e.status===414?{ok:!1,value:{name:"TooLongURIError",message:"project ids may be too much."}}:N(e),te=async(e,t,r)=>{let{fetch:o}=k(r??{}),n=Wt(e,t,r),s=await o(n);return await Xt(s)};te.toRequest=Wt;te.fromResponse=Xt;var Vt=(e,t)=>{let{sid:r,hostName:o,sort:n,limit:s,skip:a}=k(t??{}),u=new URLSearchParams;n!==void 0&&u.append("sort",n),s!==void 0&&u.append("limit",${s}),a!==void 0&&u.append("skip",${a});let i=https://${o}/api/pages/${e}?${u.toString()};return new Request(i,r?{headers:{Cookie:L(r)}}:void 0)},Yt=async e=>e.ok?{ok:!0,value:await e.json()}:N(e),Qt=async(e,t)=>{let{fetch:r}=k(t??{}),o=await r(Vt(e,t));return await Yt(o)};Qt.toRequest=Vt;Qt.fromResponse=Yt;var Jt=(e,t,r,o)=>{let{sid:n,hostName:s}=k(o??{}),a=https://${s}/api/table/${e}/${M(t)}/${encodeURIComponent(r)}.csv;return new Request(a,n?{headers:{Cookie:L(n)}}:void 0)},Zt=async e=>e.ok?{ok:!0,value:await e.text()}:e.status===404?{ok:!1,value:{name:"NotFoundError",message:"Table not found."}}:N(e),er=async(e,t,r,o)=>{let{fetch:n}=k(o??{}),s=Jt(e,t,r,o),a=await n(s);return await Zt(a)};er.toRequest=Jt;er.fromResponse=Zt;var tr=(e,t)=>{let{sid:r,hostName:o}=k(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:L(r)}}:void 0)},rr=async e=>e.ok?{ok:!0,value:await e.json()}:N(e),re=async(e,t)=>{let{fetch:r}=k(t??{}),o=tr(e,t),n=await r(o);return rr(n)};re.toRequest=tr;re.fromResponse=rr;var or=(e,t)=>{let{sid:r,hostName:o}=k(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:L(r)}}:void 0)},nr=async e=>e.ok?{ok:!0,value:await e.json()}:N(e),Me=async(e,t)=>{let{fetch:r}=k(t??{}),o=await r(or(e,t));return nr(o)};Me.toRequest=or;Me.fromResponse=nr;var _c=new TextEncoder().encode("0123456789abcdef");var V=e=>new Promise(t=>setTimeout(()=>t(),e));var jo=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,Oo=/https?:\/\/youtu\.be\/(a-zA-Z\d_-+)(?:\?(^\s{0,100})|)/,Bo=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/(a-zA-Z\d_-+)(?:\?(^\s+)|)/,$o=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:^\s+&|)list=(a-zA-Z\d_-+)(?:&^\s+|))/,sr=e=>{if(jo.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(Oo);if(t){let,r,o=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(Bo);if(t){let,r,o=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match($o);if(t){let,r,o=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Fo=/https?:\/\/vimeo\.com\/(0-9+)/i,ir=e=>{let t=e.match(Fo);if(t)return t1};var Do=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/(a-zA-Z\d_-+)(?:\?^\s{0,100}|)/,ar=e=>{let t=e.match(Do);if(!t)return;let,r,o=t;return{videoId:o,pathType:r}};var Ho=/https?:\/\/anchor\.fm\/a-zA-Z\d_-+\/episodes\/(a-zA-Z\d_-+(?:\/a-zA-Z\d_-+)?)(?:\?^\s{0,100}|)/,cr=e=>{let t=e.match(Ho);if(!t)return;let,r=t;return r};var lr=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let a=sr(n);if(a)return{type:"youtube",href:n,...a,...s};let u=ir(n);if(u)return{type:"vimeo",videoId:u,href:n,...s};let i=ar(n);if(i)return{type:"spotify",href:n,...i,...s};let l=cr(n);if(l)return{type:"anchor-fm",videoId:l,href:n,...s};if(Uo(n))return{type:"video",href:n,...s}}return Ao(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},Ao=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),Uo=e=>/\.(?:mp4|webm)$/.test(e);var pr=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 Me([]);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 ur=!1;scrapbox.addListener("lines:changed",()=>ur=!1);scrapbox.addListener("layout:changed",()=>ur=!1);var dr=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var oe=()=>qo(document.getElementById("editor"),"div#editor");var qo=(e,t)=>{if(e)return dr(e,t),e};var nt=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_${j(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var mr=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 Qo;(e=>{})(Qo||={});var Jo="0.13.3",gr,hr=async(e=Jo)=>{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,gr??=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>n(s),document.head.append(r)}),gr};var be=(e,t={})=>{let r=ee(null),o,n=C(e),s,a=C("");return B(()=>{(async()=>{let{render:u}=await hr();if(r.current)try{u(o,r.current,t),a("")}catch(i){if(i instanceof Error&&i.name==="ParseError")a(i.message.slice(19));else throw i}})()},o),{ref:r,error:s,setFormula:n}};var ne=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 st=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&j(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=ne({pathType:r.pathType,href:r.href});return o?!n&&j(s)===e.titleLc:n===e.project&&j(s)===e.titleLc}case"quote":case"strong":case"decoration":return st(e,r.nodes)}});var E=(e,t)=>/${e}/${j(t)},je=e=>{let t=e.match("/(^/+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/([^/]+)/(.+)");return{project:t1,titleLc:t2}};var se=(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 br=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(u=>s1(u)).catch(u=>s2(u));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 Zo="0.6.5",yr=ScrapBubble-${Zo},it;(async()=>it=await globalThis.caches.open(yr))();(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==yr&&(await globalThis.caches.delete(e),console.log([ScrapBubble] deleted old cache :"${e}"))})();var xr=br(3);async function*Oe(e,t){let r=((t?.saveFailedResponse?it.match(e):void 0)??mr(e,t)).then(a=>"cache",a);{let a=V(1e3).then(()=>"timeout"),u=await Promise.race(r,a);if(u!=="timeout"){u1&&(yield["cache",u1]);let i=await xr(()=>fetch(e));!i.ok&&t?.saveFailedResponse&&await it.put(e,i.clone()),yield"network",i}}let o=xr(()=>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 _r=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Be=()=>{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 Tr=Symbol.for("immer-nothing"),vr=Symbol.for("immer-draftable"),x=Symbol.for("immer-state");function D(e,...t){throw new Error([Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var ie=Object.getPrototypeOf;function ae(e){return!!e&&!!ex}function U(e){return e?Pr(e)||Array.isArray(e)||!!evr||!!e.constructor?.vr||Ae(e)||Ue(e):!1}var en=Object.prototype.constructor.toString();function Pr(e){if(!e||typeof e!="object")return!1;let t=ie(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)===en}function ce(e,t){He(e)===0?Object.entries(e).forEach((r,o)=>{t(r,o,e)}):e.forEach((r,o)=>t(o,r,e))}function He(e){let t=ex;return t?t.type_:Array.isArray(e)?1:Ae(e)?2:Ue(e)?3:0}function lt(e,t){return He(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Nr(e,t,r){let o=He(e);o===2?e.set(t,r):o===3?e.add(r):et=r}function tn(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ae(e){return e instanceof Map}function Ue(e){return e instanceof Set}function T(e){return e.copy_||e.base_}function pt(e,t){if(Ae(e))return new Map(e);if(Ue(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&Pr(e))return ie(e)?{...e}:Object.assign(Object.create(null),e);let r=Object.getOwnPropertyDescriptors(e);delete rx;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(ie(e),r)}function mt(e,t=!1){return qe(e)||ae(e)||!U(e)||(He(e)>1&&(e.set=e.add=e.clear=e.delete=rn),Object.freeze(e),t&&ce(e,(r,o)=>mt(o,!0),!0)),e}function rn(){D(2)}function qe(e){return Object.isFrozen(e)}var ut={};function Y(e){let t=ute;return t||D(0,e),t}function on(e,t){ute||(ute=t)}var xe;function $e(){return xe}function nn(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wr(e,t){t&&(Y("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function dt(e){ft(e),e.drafts_.forEach(sn),e.drafts_=null}function ft(e){e===xe&&(xe=e.parent_)}function kr(e){return xe=nn(xe,e)}function sn(e){let t=ex;t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Er(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_0;return e!==void 0&&e!==r?(rx.modified_&&(dt(t),D(4)),U(e)&&(e=Fe(t,e),t.parent_||De(t,e)),t.patches_&&Y("Patches").generateReplacementPatches_(rx.base_,e,t.patches_,t.inversePatches_)):e=Fe(t,r,[]),dt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Tr?e:void 0}function Fe(e,t,r){if(qe(t))return t;let o=tx;if(!o)return ce(t,(n,s)=>Lr(e,o,t,n,s,r),!0),t;if(o.scope_!==e)return t;if(!o.modified_)return De(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),ce(s,(u,i)=>Lr(e,o,n,u,i,r,a)),De(e,n,!1),r&&e.patches_&&Y("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function Lr(e,t,r,o,n,s,a){if(ae(n)){let u=s&&t&&t.type_!==3&&!lt(t.assigned_,o)?s.concat(o):void 0,i=Fe(e,n,u);if(Nr(r,o,i),ae(i))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(U(n)&&!qe(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Fe(e,n),(!t||!t.scope_.parent_)&&De(e,n)}}function De(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&mt(t,r)}function an(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:$e(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=gt;r&&(n=o,s=ye);let{revoke:a,proxy:u}=Proxy.revocable(n,s);return o.draft_=u,o.revoke_=a,u}var gt={get(e,t){if(t===x)return e;let r=T(e);if(!lt(r,t))return cn(e,r,t);let o=rt;return e.finalized_||!U(o)?o:o===at(e.base_,t)?(ct(e),e.copy_t=_e(o,e)):o},has(e,t){return t in T(e)},ownKeys(e){return Reflect.ownKeys(T(e))},set(e,t,r){let o=Sr(T(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=at(T(e),t),s=n?.x;if(s&&s.base_===r)return e.copy_t=r,e.assigned_t=!1,!0;if(tn(r,n)&&(r!==void 0||lt(e.base_,t)))return!0;ct(e),A(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 at(e.base_,t)!==void 0||t in e.base_?(e.assigned_t=!1,ct(e),A(e)):delete e.assigned_t,e.copy_&&delete e.copy_t,!0},getOwnPropertyDescriptor(e,t){let r=T(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:rt}},defineProperty(){D(11)},getPrototypeOf(e){return ie(e.base_)},setPrototypeOf(){D(12)}},ye={};ce(gt,(e,t)=>{yee=function(){return arguments0=arguments00,t.apply(this,arguments)}});ye.deleteProperty=function(e,t){return ye.set.call(this,e,t,void 0)};ye.set=function(e,t,r){return gt.set.call(this,e0,t,r,e0)};function at(e,t){let r=ex;return(r?T(r):e)t}function cn(e,t,r){let o=Sr(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Sr(e,t){if(!(t in e))return;let r=ie(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=ie(r)}}function A(e){e.modified_||(e.modified_=!0,e.parent_&&A(e.parent_))}function ct(e){e.copy_||(e.copy_=pt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ln=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(u=s,...i){return a.produce(u,l=>r.call(this,l,...i))}}typeof r!="function"&&D(6),o!==void 0&&typeof o!="function"&&D(7);let n;if(U(t)){let s=kr(this),a=_e(t,void 0),u=!0;try{n=r(a),u=!1}finally{u?dt(s):ft(s)}return wr(s,o),Er(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===Tr&&(n=void 0),this.autoFreeze_&&mt(n,!0),o){let s=[],a=[];Y("Patches").generateReplacementPatches_(t,n,s,a),o(s,a)}return n}else D(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,u=>t(u,...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){U(e)||D(8),ae(e)&&(e=pn(e));let t=kr(this),r=_e(e,void 0);return rx.isManual_=!0,ft(t),r}finishDraft(e,t){let r=e&&ex;(!r||!r.isManual_)&&D(9);let{scope_:o}=r;return wr(o,t),Er(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=Y("Patches").applyPatches_;return ae(e)?o(e,t):this.produce(e,n=>o(n,t))}};function _e(e,t){let r=Ae(e)?Y("MapSet").proxyMap_(e,t):Ue(e)?Y("MapSet").proxySet_(e,t):an(e,t);return(t?t.scope_:$e()).drafts_.push(r),r}function pn(e){return ae(e)||D(10,e),Ir(e)}function Ir(e){if(!U(e)||qe(e))return e;let t=ex,r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=pt(e,t.scope_.immer_.useStrictShallowCopy_)}else r=pt(e,!0);return ce(r,(o,n)=>{Nr(r,o,Ir(n))}),t&&(t.finalized_=!1),r}function Cr(){class e extends Map{constructor(i,l){super(),thisx={type_:2,parent_:l,scope_:l?l.scope_:$e(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:i,draft_:this,isManual_:!1,revoked_:!1}}get size(){return T(thisx).size}has(i){return T(thisx).has(i)}set(i,l){let c=thisx;return a(c),(!T(c).has(i)||T(c).get(i)!==l)&&(r(c),A(c),c.assigned_.set(i,!0),c.copy_.set(i,l),c.assigned_.set(i,!0)),this}delete(i){if(!this.has(i))return!1;let l=thisx;return a(l),r(l),A(l),l.base_.has(i)?l.assigned_.set(i,!1):l.assigned_.delete(i),l.copy_.delete(i),!0}clear(){let i=thisx;a(i),T(i).size&&(r(i),A(i),i.assigned_=new Map,ce(i.base_,l=>{i.assigned_.set(l,!1)}),i.copy_.clear())}forEach(i,l){let c=thisx;T(c).forEach((g,d,f)=>{i.call(l,this.get(d),d,this)})}get(i){let l=thisx;a(l);let c=T(l).get(i);if(l.finalized_||!U(c)||c!==l.base_.get(i))return c;let g=_e(c,l);return r(l),l.copy_.set(i,g),g}keys(){return T(thisx).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 c=this.get(l.value);return{done:!1,value:l.value,c}}}}Symbol.iterator(){return this.entries()}}function t(u,i){return new e(u,i)}function r(u){u.copy_||(u.assigned_=new Map,u.copy_=new Map(u.base_))}class o extends Set{constructor(i,l){super(),thisx={type_:3,parent_:l,scope_:l?l.scope_:$e(),modified_:!1,finalized_:!1,copy_:void 0,base_:i,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return T(thisx).size}has(i){let l=thisx;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=thisx;return a(l),this.has(i)||(s(l),A(l),l.copy_.add(i)),this}delete(i){if(!this.has(i))return!1;let l=thisx;return a(l),s(l),A(l),l.copy_.delete(i)||(l.drafts_.has(i)?l.copy_.delete(l.drafts_.get(i)):!1)}clear(){let i=thisx;a(i),T(i).size&&(s(i),A(i),i.copy_.clear())}values(){let i=thisx;return a(i),s(i),i.copy_.values()}entries(){let i=thisx;return a(i),s(i),i.copy_.entries()}keys(){return this.values()}Symbol.iterator(){return this.values()}forEach(i,l){let c=this.values(),g=c.next();for(;!g.done;)i.call(l,g.value,g.value,this),g=c.next()}}function n(u,i){return new o(u,i)}function s(u){u.copy_||(u.copy_=new Set,u.base_.forEach(i=>{if(U(i)){let l=_e(i,u);u.drafts_.set(i,l),u.copy_.add(l)}else u.copy_.add(i)}))}function a(u){u.revoked_&&D(3,JSON.stringify(T(u)))}on("MapSet",{proxyMap_:t,proxySet_:n})}var $=new ln,ze=$.produce,Pu=$.produceWithPatches.bind($),Nu=$.setAutoFreeze.bind($),Su=$.setUseStrictShallowCopy.bind($),Iu=$.applyPatches.bind($),Cu=$.createDraft.bind($),Mu=$.finishDraft.bind($);Cr();var Mr=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},Rr=(e,t)=>ze(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...a}=t;Object.assign(r,a),ht(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}ht(r)&&!ht(t)&&(r.lines=t.lines),t.linked&&(t.isLinkedCorrect||!r.isLinkedCorrect&&(r.linked?.length??0)<=t.linked.length)&&(r.linked=t.linked),t.projectLinked&&(r.projectLinked=t.projectLinked)}),ht=e=>e.lines0.id==="dummy";var jr=(e,t)=>{let r=new Map,o=j(t.title);for(let i of t.links){let l=un(e,i);l.linked=o,r.set(E(e,i),l)}let n=E(e,o),s=t.projectLinks.map(i=>{let l=je(i);return E(l.project,l.titleLc)}),a={...Ke(e,t),linked:[],projectLinked:[]};r.set(n,a);let u=t.links.map(i=>j(i));for(let i of t.relatedPages.links1hop){i.linksLc.includes(o)&&a.linked.push(i.titleLc);for(let d of i.linksLc.filter(f=>u.includes(f))){let f=E(e,d),m=r.get(f);if(!m)throw Error(storage already must have "${f}");if(!m.linked){m.linked=i.titleLc;continue}m.linked.push(i.titleLc)}let l=E(e,i.titleLc),c=Ke(e,i),g=r.get(l)?.linked;g&&(c.linked=g),r.set(l,c)}for(let i of t.relatedPages.projectLinks1hop){let l=E(i.projectName,i.titleLc);s.includes(l)||a.projectLinked.push(l);let c=Ke(i.projectName,i),g=r.get(l)?.projectLinked;g&&(c.projectLinked=g),r.set(l,c)}a.isLinkedCorrect=!0;for(let i of t.relatedPages.links2hop){for(let d of i.linksLc){let f=E(e,d),m=r.get(f);if(!m)throw Error(storage already must have "${f}");if(!m.linked){m.linked=i.titleLc;continue}m.linked.push(i.titleLc)}let l=E(e,i.titleLc),c=Ke(e,i),g=r.get(l)?.linked;g&&(c.linked=g),r.set(l,c)}return r},Ke=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:j(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}),un=(e,t)=>({project:e,titleLc:j(t),exists:!1,descriptions:[],image:null,lines:{text:t,id:"dummy",userId:"dummy",updated:0,created:0},updated:0,isLinkedCorrect:!1});var F=!1,Or=e=>{F=typeof e=="boolean"?e:new Set(e)},K=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 Ge=K("ScrapBubble:bubble.ts"),bt=new Map,We=new Set,xt=Be();function*$r(e){for(let t of e)yield bt.get(t)}var Fr=(e,t)=>xt.on(e,t),Dr=(e,t)=>xt.off(e,t),Hr=async(e,t,r,o)=>{let n=[];for(let s of...t.reverse()){let a=E(s,e);We.has(a)||n.push(dn(s,e,r,o))}await Promise.all(n)},Br=0,dn=async(e,t,r,o)=>{let n=E(e,t);if(We.has(n))return;We.add(n);let s=Br++,a=[${s}] Check update ${n};Ge.time(a);try{let u=te.toRequest(e,t,{followRename:!0,projects:...r});for await(leti,lof Oe(u,{ignoreSearch:!0,saveFailedResponse:!0})){Ge.debug([${s}]${i} ${n});let c=await te.fromResponse(l);if(c.ok){let g=jr(e,c.value);for(letd,fof g){let m=bt.get(d),y=Rr(m,f);y&&m!==y&&(bt.set(d,y),xt.dispatch(d,f))}}if(o?.ignoreFetch===!0||i==="cache"&&!_r(l,o?.maxAge??60))break}}catch(u){Ge.error(u)}finally{We.delete(n),Ge.timeEnd(a),Br--}};var Ar=K("ScrapBubble:useBubbleData.ts"),le=e=>{lett,r=C([]);return Ce(()=>{let o=()=>{r(()=>{let a=...$r(e).flatMap(u=>u?u:[]);return Ar.debug(Required: ${e.length} pages, ${a.length} found,a),a})};o();let n,s=()=>{clearTimeout(n),n=setTimeout(()=>{Ar.debug(Update ${e.length} pages),o()},10)};return e.forEach(a=>Fr(a,s)),()=>e.forEach(a=>Dr(a,s))},e),t};var pe=e=>{let t=oe();X(t,"#editor");let{top:r,right:o,left:n,bottom:s}=e.getBoundingClientRect(),a=t.getBoundingClientRect(),u=(n-a.left)/a.width>.5;return{top:Math.round(s-a.top),bottom:Math.round(a.bottom-r),...u?{right:Math.round(a.right-o)}:{left:Math.round(n-a.left)},maxWidth:u?o-10:document.documentElement.clientWidth-n-10}};var fn=e=>({type:"title",text:e.rows0.text}),mn=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(` )}},P=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,a)=>{var u,i,l,c,g,d;if(!t&&s.nested)return(u=a?.())!==null&&u!==void 0?u:[];if(!r&&s.quoted)return(i=a?.())!==null&&i!==void 0?i:[];for(let f of o){let m=f.exec(n);if(m===null)continue;let y=n.substring(0,m.index),b=n.substring(m.index+((c=(l=m[0])===null||l===void 0?void 0:l.length)!==null&&c!==void 0?c:0)),_=e((g=m[0])!==null&&g!==void 0?g:"",s);return[...G(y,s),..._,...G(b,s)]}return(d=a?.())!==null&&d!==void 0?d:[]},S=e=>[{type:"plain",raw:e,text:e}],gn=P(S,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]}),hn=/^>.*$/,bn=(e,t)=>t.context==="table"?S(e,t):[{type:"quote",raw:e,nodes:G(e.substring(1),{...t,quoted:!0})}],xn=P(bn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[hn]}),yn=/^\? .+$/,_n=(e,t)=>t.context==="table"?S(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],vn=P(_n,{parseOnNested:!1,parseOnQuoted:!1,patterns:[yn]}),wn=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)\]\]/i,kn=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,En=(e,t)=>{if(t.context==="table")return S(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}]},Ln=P(En,{parseOnNested:!1,parseOnQuoted:!0,patterns:[wn,kn]}),Tn=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/;function qr(e){return(t,r)=>{if(e==="strongIcon"&&r.context==="table")return S(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",u=o.substring(n+5,o.length),i=u.startsWith("*")?parseInt(u.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:s,pathType:a,type:e,raw:t}))}}var Pn=qr("icon"),Nn=P(Pn,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Tn]}),Sn=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,In=qr("strongIcon"),Cn=P(In,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Sn]}),Mn=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,Rn=(e,t)=>t.context==="table"?S(e,t):[{type:"strong",raw:e,nodes:G(e.substring(2,e.length-2),{...t,nested:!0})}],jn=P(Rn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Mn]}),On=/\[\$ .+? \]/,Bn=/\[\$ [^\]]+\]/,$n=(e,t)=>t.context==="table"?S(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],Fn=P($n,{parseOnNested:!1,parseOnQuoted:!0,patterns:[On,Bn]}),Dn=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,Hn=(e,t)=>{if(t.context==="table")return S(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:G(n,{...t,nested:!0})}]},An=P(Hn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Dn]}),Un=/.*?/,qn=(e,t)=>t.context==="table"?S(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],zn=P(qn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Un]}),Kn=/^[$%] .+$/,Gn=(e,t)=>{var r;if(t.context==="table")return S(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}]},Wn=P(Gn,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Kn]}),Xn=/\[\s+\]/,Vn=(e,t)=>t.context==="table"?S(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Yn=P(Vn,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Xn]}),Qn=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Jn=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg)(?:\?[^\]\s]+)?\]/i,Zn=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,es=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,ts=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg)(\?[^\]\s]+)?$/i.test(e)||rs(e),rs=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),os=(e,t)=>{if(t.context==="table")return S(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]=ts(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}]},ns=P(os,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Qn,Jn,Zn,es]}),ss=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,is=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,as=/\[https?:\/\/[^\s\]]+\]/,cs=/https?:\/\/[^\s]+/,ls=(e,t)=>{if(t.context==="table")return S(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()}]},ps=P(ls,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ss,is,as,cs]}),zr=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,Kr=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,us=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}},ds=(e,t)=>{var r;if(t.context==="table")return S(e,t);let o=(r=e.match(zr))!==null&&r!==void 0?r:e.match(Kr);if(o===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,s="",a=""]=n?o:[o[0],o[2],o[1]],{latitude:u,longitude:i,zoom:l}=us(s),c=a!==""?https://www.google.com/maps/place/${encodeURIComponent(a)}/@${u},${i},${l}z:https://www.google.com/maps/@${u},${i},${l}z;return[{type:"googleMap",raw:e,latitude:u,longitude:i,zoom:l,place:a,url:c}]},fs=P(ds,{parseOnNested:!1,parseOnQuoted:!0,patterns:[zr,Kr]}),ms=/\[\/?[^[\]]+\]/,gs=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},hs=P(gs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[ms]}),bs=/(?:^|\s)#\S+/,xs=(e,t)=>{if(t.context==="table")return S(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...S(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},ys=P(xs,{parseOnNested:!0,parseOnQuoted:!0,patterns:[bs]}),_s=/^[0-9]+\. .*$/,vs=(e,t)=>{if(t.context==="table")return S(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:G(s,{...t,nested:!0})}]},ws=P(vs,{parseOnNested:!1,parseOnQuoted:!1,patterns:[_s]}),ks=(e,t,r)=>{var o;return e===""?[]:(o=r?.())!==null&&o!==void 0?o:[]},Es=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>gn(t,r))(),G=Es(ks,xn,vn,zn,Wn,Fn,Yn,An,Ln,Cn,jn,ns,ps,Nn,fs,hs,ys,ws),Ls=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(u=>G(u,{nested:!1,quoted:!1,context:"table"})))}},Ts=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:G(r.substring(t),{nested:!1,quoted:!1,context:"line"})}},Ps=e=>{switch(e.type){case"title":return fn(e);case"codeBlock":return mn(e);case"table":return Ls(e);case"line":return Ts(e)}},Ns=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}}),Ss=(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)},Ur=(e,t)=>{let r=e[e.length-1];return r!==void 0&&Ss(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)},Is=(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(Ur,[])]}return e.reduce(Ur,[])},ve=(e,t)=>{var r;let o=Ns(e);return Is(o,{hasTitle:(r=t?.hasTitle)!==null&&r!==void 0?r:!0}).map(Ps)};var W=Ze({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Wr=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:a,...u})=>{let i=v(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),l=v(()=>{let d=0;return ve(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 m=d;return d+=f.content.split(
).length+1,{...f,ids:i.slice(m,d)}}case"table":{let m=d;return d+=f.cells.length+1,{...f,ids:i.slice(m,d)}}}})},[e,i]),c=v(()=>{if(s&&i.includes(s))return s;if(a)return l.find(d=>d.type!=="line"?!1:st(a,d.nodes))?.id},[l,i,s,a?.project,a?.titleLc]),g=ee(null);return B(()=>{if(!c)return;let d=g.current?.querySelector(data-id="${c}"),f=window.scrollY;d?.scrollIntoView?.({block:"center"}),window.scroll(0,f)},[c]),p("div",{className:"lines",ref:g},p(W.Provider,{value:{project:t,title:r,whiteList:o,...u}},l.map(d=>{switch(d.type){case"title":return p(w,null,p(de,{key:d.id,index:d.id,indent:0,noIndent:n,permalink:d.id===c},d.text),p("hr",null));case"codeBlock":return p(Cs,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:c});case"table":return p(Ms,{key:d.ids[0],block:d,noIndent:n,ids:d.ids,scrollId:c});case"line":return p(de,{key:d.id,index:d.id,indent:d.indent,noIndent:n,permalink:d.id===c},d.nodes.length>0?d.nodes.map(f=>p(ue,{node:f})):p("br",null))}})))},de=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>p("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em}},o),Cs=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=z(W),[u,i]=C("\uF0C5"),l=O(async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(t),i("Copied"),await V(1e3),i("\uF0C5")}catch(g){alert(Failed to copy the code block Error:${g.message})}},[t]);return p(w,null,p(de,{index:o[0],indent:r,permalink:o[0]===n},p("span",{className:"code-block"},p("span",{className:"code-block-start"},p("a",{href:/api/code/${s}/${M(a)}/${e},target:"_blank"},e)),p("span",{className:"copy",title:"Copy",onClick:l},u))),p(w,null,t.split(
).map((c,g)=>p(de,{index:o[g+1],indent:r,permalink:o[g+1]===n},p("code",{className:"code-block"},c)))))},Ms=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:a}=z(W);return p(w,null,p(de,{index:o[0],indent:r,permalink:o[0]===n},p("span",{className:"table-block"},p("span",{className:"table-block-start"},p("a",{href:/api/table/${s}/${M(a)}/${e}.csv,target:"_blank"},e)))),p(w,null,t.map((u,i)=>p(de,{index:o[i+1],indent:r,permalink:o[i+1]===n},p("span",{className:"table-block table-block-row"},u.map((l,c)=>p("span",{className:cell col-${c}},l.map(g=>p(ue,{node:g})))))))))},ue=({node:e})=>{switch(e.type){case"code":return p("code",{className:"code"},e.text);case"formula":return p(Rs,{node:e});case"commandLine":return p(Os,{node:e});case"helpfeel":return p("code",{className:"helpfeel"},p("span",{className:"prefix"},"?")," ",p("span",{className:"entry"},e.text));case"quote":return p("blockquote",{className:"quote"},e.nodes.map(t=>p(ue,{node:t})));case"strong":return p("strong",null,e.nodes.map(t=>p(ue,{node:t})));case"decoration":return p(js,{node:e});case"plain":case"blank":return p(w,null,e.text);case"hashTag":return p(Fs,{node:e});case"link":return p(Ds,{node:e});case"googleMap":return p(Bs,{node:e});case"icon":return p(Gr,{node:e});case"strongIcon":return p(Gr,{node:e,strong:!0});case"image":return p($s,{node:e});case"strongImage":return p("img",{className:"image strong-image",src:e.src});case"numberList":return p(w,null,${e.number}. ,e.nodes.map(t=>p(ue,{node:t})))}},Rs=({node:{formula:e}})=>{let{ref:t,error:r,setFormula:o}=be("");return o(e),p("span",{className:formula ${r?" error":""}},r?p("code",null,e):p("span",{className:"katex-display",ref:t}))},js=({node:{decos:e,nodes:t}})=>p("span",{className:e.map(r=>deco-${r}).join(" ")},t.map(r=>p(ue,{node:r}))),Os=({node:e})=>{let[t,r]=C("\uF0C5"),o=O(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await V(1e3),r("\uF0C5")}catch(s){alert(Failed to copy the code block
Error:${s.message})}},[e.text]);return p(w,null,p("code",{className:"cli"},p("span",{className:"prefix"},e.symbol)," ",p("span",{className:"command"},e.text)),p("span",{className:"tool-buttons"},p("span",{title:"Copy",className:"copy",onClick:o},t)))},Bs=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>p("span",{className:"pointing-device-map"},p("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank"},p("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${window._csrf}}))),Gr=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=z(W),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],a=M(s);return p("a",{href:/${n}/${a},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank"},p("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${a}/icon},s))},$s=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return p("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank"},p("img",{className:"image",src:t}))},Fs=({node:{href:e}})=>{let{project:t}=z(W),r=Xr(t,e),o=Vr(t,e,"hashtag");return p("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)},Ds=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return p(Hs,{pathType:e,href:t.href});case"absolute":{let r=lr({pathType:e,...t});switch(r.type){case"youtube":return p(As,{...r});case"vimeo":return p(Us,{...r});case"spotify":return p(qs,{...r});case"anchor-fm":return p(zs,{...r});case"audio":return p(Ks,{...r});case"video":return p(Ws,{...r});case"absoluteLink":return p("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank"},r.content||r.href)}}}},Hs=({pathType:e,hr