import-dev
code:script.js
await import("../../takker-dist/import-devにbackgroundでテストコードを貼り付けるUserScript/script.js");
await import("./mod.js");
code:mod.js
var Re,_,Ct,An,X,vt,It,Ue,Mt,Ke,$e,qe,Dn,me={},Nt=[],Bn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,Te=Array.isArray;function V(e,t){for(var r in t)er=tr;return e}function Ge(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function re(e,t,r){var n,o,s,i={};for(s in t)s=="key"?n=ts:s=="ref"?o=ts:is=ts;if(arguments.length>2&&(i.children=arguments.length>3?Re.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)is===void 0&&(is=e.defaultPropss);return ke(e,i,n,o,null)}function ke(e,t,r,n,o){var s={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++Ct,__i:-1,__u:0};return o==null&&_.vnode!=null&&_.vnode(s),s}function S(e){return e.children}function K(e,t){this.props=e,this.context=t}function te(e,t){if(t==null)return e.__?te(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__kt)!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?te(e):null}function Ft(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 Ft(e)}}function Lt(e){(!e.__d&&(e.__d=!0)&&X.push(e)&&!we.__r++||vt!==_.debounceRendering)&&((vt=_.debounceRendering)||It)(we)}function we(){var e,t,r,n,o,s,i,a;for(X.sort(Ue);e=X.shift();)e.__d&&(t=X.length,n=void 0,s=(o=(r=e).__v).__e,i=[],a=[],r.__P&&((n=V({},o)).__v=o.__v+1,_.vnode&&_.vnode(n),We(r.__P,n,o,r.__n,r.__P.namespaceURI,32&o.__u?s:null,i,s??te(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__kn.__i=n,At(i,n,a),n.__e!=s&&Ft(n)),X.length>t&&X.sort(Ue));we.__r=0}function Ot(e,t,r,n,o,s,i,a,u,l,d){var c,p,f,m,b,x,g=n&&n.__k||Nt,h=t.length;for(u=Hn(r,t,g,u,h),c=0;c<h;c++)(f=r.__kc)!=null&&(p=f.__i===-1?me:gf.__i||me,f.__i=c,x=We(e,f,p,o,s,i,a,u,l,d),m=f.__e,f.ref&&p.ref!=f.ref&&(p.ref&&Ve(p.ref,null,f),d.push(f.ref,f.__c||m,f)),b==null&&m!=null&&(b=m),4&f.__u||p.__k===f.__k?u=jt(f,u,e):typeof f.type=="function"&&x!==void 0?u=x:m&&(u=m.nextSibling),f.__u&=-7);return r.__e=b,u}function Hn(e,t,r,n,o){var s,i,a,u,l,d=r.length,c=d,p=0;for(e.__k=new Array(o),s=0;s<o;s++)(i=ts)!=null&&typeof i!="boolean"&&typeof i!="function"?(u=s+p,(i=e.__ks=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?ke(null,i,null,null,null):Te(i)?ke(S,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?ke(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,a=null,(l=i.__i=Un(i,r,u,c))!==-1&&(c--,(a=rl)&&(a.__u|=2)),a==null||a.__v===null?(l==-1&&p--,typeof i.type!="function"&&(i.__u|=4)):l!=u&&(l==u-1?p--:l==u+1?p++:(l>u?p--:p++,i.__u|=4))):e.__ks=null;if(c)for(s=0;s<d;s++)(a=rs)!=null&&!(2&a.__u)&&(a.__e==n&&(n=te(a)),Dt(a,a));return n}function jt(e,t,r){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)no&&(no.__=e,t=jt(no,t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=te(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ne(e,t){return t=t||[],e==null||typeof e=="boolean"||(Te(e)?e.some(function(r){ne(r,t)}):t.push(e)),t}function Un(e,t,r,n){var o,s,i=e.key,a=e.type,u=tr;if(u===null||u&&i==u.key&&a===u.type&&!(2&u.__u))return r;if(n>(u!=null&&!(2&u.__u)?1:0))for(o=r-1,s=r+1;o>=0||s<t.length;){if(o>=0){if((u=to)&&!(2&u.__u)&&i==u.key&&a===u.type)return o;o--}if(s<t.length){if((u=ts)&&!(2&u.__u)&&i==u.key&&a===u.type)return s;s++}}return-1}function Pt(e,t,r){t0=="-"?e.setProperty(t,r??""):et=r==null?"":typeof r!="number"||Bn.test(t)?r:r+"px"}function be(e,t,r,n,o){var s;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||Pt(e.style,t,"");if(r)for(t in r)n&&rt===nt||Pt(e.style,t,rt)}else if(t0=="o"&&t1=="n")s=t!=(t=t.replace(Mt,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.lt+s=r,r?n?r.u=n.u:(r.u=Ke,e.addEventListener(t,s?qe:$e,s)):e.removeEventListener(t,s?qe:$e,s);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{et=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t4!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function St(e){return function(t){if(this.l){var r=this.lt.type+e;if(t.t==null)t.t=Ke++;else if(t.t<r.u)return;return r(_.event?_.event(t):t)}}}function We(e,t,r,n,o,s,i,a,u,l){var d,c,p,f,m,b,x,g,h,v,N,J,W,de,ee,fe,k,w=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(u=!!(32&r.__u),s=a=t.__e=r.__e),(d=_.__b)&&d(t);e:if(typeof w=="function")try{if(g=t.props,h="prototype"in w&&w.prototype.render,v=(d=w.contextType)&&nd.__c,N=d?v?v.props.value:d.__:n,r.__c?x=(c=t.__c=r.__c).__=c.__E:(h?t.__c=c=new w(g,N):(t.__c=c=new K(g,N),c.constructor=w,c.render=qn),v&&v.sub(c),c.props=g,c.state||(c.state={}),c.context=N,c.__n=n,p=c.__d=!0,c.__h=[],c._sb=[]),h&&c.__s==null&&(c.__s=c.state),h&&w.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=V({},c.__s)),V(c.__s,w.getDerivedStateFromProps(g,c.__s))),f=c.props,m=c.state,c.__v=t,p)h&&w.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),h&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(h&&w.getDerivedStateFromProps==null&&g!==f&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(g,N),!c.__e&&(c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(g,c.__s,N)===!1||t.__v==r.__v)){for(t.__v!=r.__v&&(c.props=g,c.state=c.__s,c.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(C){C&&(C.__=t)}),J=0;J<c._sb.length;J++)c.__h.push(c._sbJ);c._sb=[],c.__h.length&&i.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(g,c.__s,N),h&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(f,m,b)})}if(c.context=N,c.props=g,c.__P=e,c.__e=!1,W=_.__r,de=0,h){for(c.state=c.__s,c.__d=!1,W&&W(t),d=c.render(c.props,c.state,c.context),ee=0;ee<c._sb.length;ee++)c.__h.push(c._sbee);c._sb=[]}else do c.__d=!1,W&&W(t),d=c.render(c.props,c.state,c.context),c.state=c.__s;while(c.__d&&++de<25);c.state=c.__s,c.getChildContext!=null&&(n=V(V({},n),c.getChildContext())),h&&!p&&c.getSnapshotBeforeUpdate!=null&&(b=c.getSnapshotBeforeUpdate(f,m)),a=Ot(e,Te(fe=d!=null&&d.type===S&&d.key==null?d.props.children:d)?fe:fe,t,r,n,o,s,i,a,u,l),c.base=t.__e,t.__u&=-161,c.__h.length&&i.push(c),x&&(c.__E=c.__=null)}catch(C){if(t.__v=null,u||s!=null)if(C.then){for(t.__u|=u?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;ss.indexOf(a)=null,t.__e=a}else for(k=s.length;k--;)Ge(sk);else t.__e=r.__e,t.__k=r.__k;_.__e(C,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=$n(r.__e,t,r,n,o,s,i,u,l);return(d=_.diffed)&&d(t),128&t.__u?void 0:a}function At(e,t,r){for(var n=0;n<r.length;n++)Ve(rn,r++n,r++n);_.__c&&_.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(s){s.call(o)})}catch(s){_.__e(s,o.__v)}})}function $n(e,t,r,n,o,s,i,a,u){var l,d,c,p,f,m,b,x=r.props,g=t.props,h=t.type;if(h=="svg"?o="http://www.w3.org/2000/svg":h=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((f=s[l])&&"setAttribute"in f==!!h&&(h?f.localName==h:f.nodeType==3)){e=f,sl=null;break}}if(e==null){if(h==null)return document.createTextNode(g);e=document.createElementNS(o,h,g.is&&g),a&&(_.__m&&_.__m(t,s),a=!1),s=null}if(h===null)x===g||a&&e.data===g||(e.data=g);else{if(s=s&&Re.call(e.childNodes),x=r.props||me,!a&&s!=null)for(x={},l=0;l<e.attributes.length;l++)x[(f=e.attributesl).name]=f.value;for(l in x)if(f=xl,l!="children"){if(l=="dangerouslySetInnerHTML")c=f;else if(!(l in g)){if(l=="value"&&"defaultValue"in g||l=="checked"&&"defaultChecked"in g)continue;be(e,l,null,f,o)}}for(l in g)f=gl,l=="children"?p=f:l=="dangerouslySetInnerHTML"?d=f:l=="value"?m=f:l=="checked"?b=f:a&&typeof f!="function"||xl===f||be(e,l,f,xl,o);if(d)a||c&&(d.__html===c.__html||d.__html===e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(c&&(e.innerHTML=""),Ot(e,Te(p)?p:p,t,r,n,h=="foreignObject"?"http://www.w3.org/1999/xhtml":o,s,i,s?s[0]:r.__k&&te(r,0),a,u),s!=null)for(l=s.length;l--;)Ge(s[l]);a||(l="value",h=="progress"&&m==null?e.removeAttribute("value"):m!==void 0&&(m!==el||h=="progress"&&!m||h=="option"&&m!==xl)&&be(e,l,m,xl,o),l="checked",b!==void 0&&b!==el&&be(e,l,b,xl,o))}return e}function Ve(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(o){_.__e(o,r)}}function Dt(e,t,r){var n,o;if(_.unmount&&_.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||Ve(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){_.__e(s,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)no&&Dt(no,t,r||typeof e.type!="function");r||Ge(e.__e),e.__c=e.__=e.__e=void 0}function qn(e,t,r){return this.constructor(e,r)}function ve(e,t,r){var n,o,s,i;t==document&&(t=document.documentElement),_.__&&_.__(e,t),o=(n=typeof r=="function")?null:r&&r.__k||t.__k,s=[],i=[],We(t,e=(!n&&r||t).__k=re(S,null,e),o||me,me,t.namespaceURI,!n&&r?r:o?null:t.firstChild?Re.call(t.childNodes):null,s,!n&&r?r:o?o.__e:t.firstChild,n,i),At(s,e,i)}Re=Nt.slice,_={__e:function(e,t,r,n){for(var o,s,i;t=t.__;)if((o=t.__c)&&!o.__)try{if((s=o.constructor)&&s.getDerivedStateFromError!=null&&(o.setState(s.getDerivedStateFromError(e)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),i=o.__d),i)return o.__E=o}catch(a){e=a}throw e}},Ct=0,An=function(e){return e!=null&&e.constructor==null},K.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=V({},this.state),typeof e=="function"&&(e=e(V({},r),this.props)),e&&V(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),Lt(this))},K.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Lt(this))},K.prototype.render=S,X=[],It=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ue=function(e,t){return e.__v.__b-t.__v.__b},we.__r=0,Mt=/(PointerCapture)$|Capture$/i,Ke=0,$e=St(!1),qe=St(!0),Dn=0;var oe,R,ze,Bt,ge=0,Vt=[],L=_,Ht=L.__b,Ut=L.__r,$t=L.diffed,qt=L.__c,Kt=L.unmount,Gt=L.__;function Pe(e,t){L.__h&&L.__h(R,e,ge||t),ge=0;var r=R.__H||(R.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__e}function U(e){return ge=1,se(Yt,e)}function se(e,t,r){var n=Pe(oe++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):Yt(void 0,t),function(a){var u=n.__N?n.__N0:n.__0,l=n.t(u,a);u!==l&&(n.__N=[l,n.__1],n.__c.setState({}))}],n.__c=R,!R.u)){var o=function(a,u,l){if(!n.__c.__H)return!0;var d=n.__c.__H.__.filter(function(p){return!!p.__c});if(d.every(function(p){return!p.__N}))return!s||s.call(this,a,u,l);var c=n.__c.props!==a;return d.forEach(function(p){if(p.__N){var f=p.__0;p.__=p.__N,p.__N=void 0,f!==p.__0&&(c=!0)}}),s&&s.call(this,a,u,l)||c};R.u=!0;var s=R.shouldComponentUpdate,i=R.componentWillUpdate;R.componentWillUpdate=function(a,u,l){if(this.__e){var d=s;s=void 0,o(a,u,l),s=d}i&&i.call(this,a,u,l)},R.shouldComponentUpdate=o}return n.__N||n.__}function j(e,t){var r=Pe(oe++,3);!L.__s&&Je(r.__H,t)&&(r.__=e,r.i=t,R.__H.__h.push(r))}function zt(e,t){var r=Pe(oe++,4);!L.__s&&Je(r.__H,t)&&(r.__=e,r.i=t,R.__h.push(r))}function ie(e){return ge=5,T(function(){return{current:e}},[])}function T(e,t){var r=Pe(oe++,7);return Je(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function E(e,t){return ge=8,T(function(){return e},t)}function Kn(){for(var e;e=Vt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Le),e.__H.__h.forEach(Ye),e.__H.__h=[]}catch(t){e.__H.__h=[],L.__e(t,e.__v)}}L.__b=function(e){R=null,Ht&&Ht(e)},L.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Gt&&Gt(e,t)},L.__r=function(e){Ut&&Ut(e),oe=0;var t=(R=e.__c).__H;t&&(ze===R?(t.__h=[],R.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Le),t.__h.forEach(Ye),t.__h=[],oe=0)),ze=R},L.diffed=function(e){$t&&$t(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Vt.push(t)!==1&&Bt===L.requestAnimationFrame||((Bt=L.requestAnimationFrame)||Gn)(Kn)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),ze=R=null},L.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Le),r.__h=r.__h.filter(function(n){return!n.__||Ye(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],L.__e(n,r.__v)}}),qt&&qt(e,t)},L.unmount=function(e){Kt&&Kt(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Le(n)}catch(o){t=o}}),r.__H=void 0,t&&L.__e(t,r.__v))};var Wt=typeof requestAnimationFrame=="function";function Gn(e){var t,r=function(){clearTimeout(n),Wt&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,100);Wt&&(t=requestAnimationFrame(r))}function Le(e){var t=R,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),R=t}function Ye(e){var t=R;e.__c=e.__(),R=t}function Je(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==en})}function Yt(e,t){return typeof t=="function"?t(e):t}function Jt(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var n in t)if(n!=="__source"&&en!==tn)return!0;return!1}function Ze(e,t){var r=t(),n=U({t:{__:r,u:t}}),o=n0.t,s=n1;return zt(function(){o.__=r,o.u=t,Xe(o)&&s({t:o})},e,r,t),j(function(){return Xe(o)&&s({t:o}),e(function(){Xe(o)&&s({t:o})})},e),r}function Xe(e){var t,r,n=e.u,o=e.__;try{var s=n();return!((t=o)===(r=s)&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}}function Xt(e,t){this.props=e,this.context=t}(Xt.prototype=new K).isPureReactComponent=!0,Xt.prototype.shouldComponentUpdate=function(e,t){return Jt(this.props,e)||Jt(this.state,t)};var Qt=_.__b;_.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Qt&&Qt(e)};var ys=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var zn=_.__e;_.__e=function(e,t,r,n){if(e.then){for(var o,s=t;s=s.__;)if((o=s.__c)&&o.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),o.__c(e,t)}zn(e,t,r,n)};var Zt=_.unmount;function sr(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),e.__c.__H=null),(e=function(n,o){for(var s in o)ns=os;return n}({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map(function(n){return sr(n,t,r)})),e}function ir(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(n){return ir(n,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function Qe(){this.__u=0,this.o=null,this.__b=null}function ar(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function Se(){this.i=null,this.l=null}_.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Zt&&Zt(e)},(Qe.prototype=new K).__c=function(e,t){var r=t.__c,n=this;n.o==null&&(n.o=[]),n.o.push(r);var o=ar(n.__v),s=!1,i=function(){s||(s=!0,r.__R=null,o?o(a):a())};r.__R=i;var a=function(){if(!--n.__u){if(n.state.__a){var u=n.state.__a;n.__v.__k0=ir(u,u.__c.__P,u.__c.__O)}var l;for(n.setState({__a:n.__b=null});l=n.o.pop();)l.forceUpdate()}};n.__u++||32&t.__u||n.setState({__a:n.__b=n.__v.__k0}),e.then(i,i)},Qe.prototype.componentWillUnmount=function(){this.o=[]},Qe.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),n=this.__v.__k0.__c;this.__v.__k0=sr(this.__b,r,n.__O=n.__P)}this.__b=null}var o=t.__a&&re(S,null,e.fallback);return o&&(o.__u&=-33),re(S,null,t.__a?null:e.children),o};var er=function(e,t,r){if(++r1===r0&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder0!=="t"||!e.l.size))for(r=e.i;r;){for(;r.length>3;)r.pop()();if(r1<r0)break;e.i=r=r2}};(Se.prototype=new K).__a=function(e){var t=this,r=ar(t.__v),n=t.l.get(e);return n0++,function(o){var s=function(){t.props.revealOrder?(n.push(o),er(t,e,n)):o()};r?r(s):s()}},Se.prototype.render=function(e){this.i=null,this.l=new Map;var t=ne(e.children);e.revealOrder&&e.revealOrder0==="b"&&t.reverse();for(var r=t.length;r--;)this.l.set(tr,this.i=1,0,this.i);return e.children},Se.prototype.componentDidUpdate=Se.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){er(e,r,t)})};var Yn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Jn=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))A-Z/,Xn=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Qn=/A-Z0-9/g,Zn=typeof document<"u",eo=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};K.prototype.isReactComponent={},"componentWillMount","componentWillReceiveProps","componentWillUpdate".forEach(function(e){Object.defineProperty(K.prototype,e,{configurable:!0,get:function(){return this"UNSAFE_"+e},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var tr=_.event;function to(){}function ro(){return this.cancelBubble}function no(){return this.defaultPrevented}_.event=function(e){return tr&&(e=tr(e)),e.persist=to,e.isPropagationStopped=ro,e.isDefaultPrevented=no,e.nativeEvent=e};var cr,oo={enumerable:!1,configurable:!0,get:function(){return this.class}},rr=_.vnode;_.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,n=t.type,o={},s=n.indexOf("-")===-1;for(var i in r){var a=ri;if(!(i==="value"&&"defaultValue"in r&&a==null||Zn&&i==="children"&&n==="noscript"||i==="class"||i==="className")){var u=i.toLowerCase();i==="defaultValue"&&"value"in r&&r.value==null?i="value":i==="download"&&a===!0?a="":u==="translate"&&a==="no"?a=!1:u0==="o"&&u1==="n"?u==="ondoubleclick"?i="ondblclick":u!=="onchange"||n!=="input"&&n!=="textarea"||eo(r.type)?u==="onfocus"?i="onfocusin":u==="onblur"?i="onfocusout":Xn.test(i)&&(i=u):u=i="oninput":s&&Jn.test(i)?i=i.replace(Qn,"-$&").toLowerCase():a===null&&(a=void 0),u==="oninput"&&oi=u&&(i="oninputCapture"),oi=a}}n=="select"&&o.multiple&&Array.isArray(o.value)&&(o.value=ne(r.children).forEach(function(l){l.props.selected=o.value.indexOf(l.props.value)!=-1})),n=="select"&&o.defaultValue!=null&&(o.value=ne(r.children).forEach(function(l){l.props.selected=o.multiple?o.defaultValue.indexOf(l.props.value)!=-1:o.defaultValue==l.props.value})),r.class&&!r.className?(o.class=r.class,Object.defineProperty(o,"className",oo)):(r.className&&!r.class||r.class&&r.className)&&(o.class=o.className=r.className),t.props=o}(e),e.$$typeof=Yn,rr&&rr(e)};var nr=_.__r;_.__r=function(e){nr&&nr(e),cr=e.__c};var or=_.diffed;_.diffed=function(e){or&&or(e);var t=e.props,r=e.__e;r!=null&&e.type==="textarea"&&"value"in t&&t.value!==r.value&&(r.value=t.value==null?"":t.value),cr=null};function Ce(e){return Array.isArray(e)}function Ie(e){return typeof e=="number"}function z(e){return typeof e=="string"}function he(e){return typeof e>"u"}var ur=!1;scrapbox.addListener("lines:changed",()=>ur=!1);scrapbox.addListener("layout:changed",()=>ur=!1);var lr=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var pr=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var et=()=>so(document.getElementsByClassName("lines").item(0),"div.lines");var A=()=>{let e=document.getElementById("text-input");if(e)return pr(e,"textarea#text-input"),e};var so=(e,t)=>{if(e)return lr(e,t),e};var tt=()=>{let e=et();if(!e)throw Error("div.lines is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.lines must has the property whose name starts with "__reactFiber"');return et.return.stateNode.props.lines};var dr=e=>{if(he(e))return;if(Ie(e))return ao(e)?.id;if(z(e))return e.startsWith("L")?e.slice(1):e;if(e.classList.contains("line"))return e.id.slice(1);let t=e.closest(".line");if(t)return t.id.slice(1)};var ao=e=>{if(he(e))return;if(Ie(e))return tt()e;let t=dr(e);return t?tt().find(r=>r.id===t):void 0},fr=e=>{if(co(e))return e;let t=dr(e);if(he(t))return t;let r=document.getElementById(L${t});if(!he(r))return r},co=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var uo=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index");var rt=(e,t)=>{let r=fr(e)?.getElementsByClassName?.(c-${t})?.0;return uo(r)?r:void 0};function nt(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,s)=>{let i=()=>{clearTimeout(u),s(r?.reason)},u=setTimeout(()=>{r?.removeEventListener("abort",i),o()},e);if(r?.addEventListener("abort",i,{once:!0}),n===!1)try{Deno.unrefTimer(u)}catch(l){if(!(l instanceof ReferenceError))throw l;console.error("persistent option is only available in Deno")}})}var mr=async e=>{let t=A();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await nt(1)};var ae=e=>e.replaceAll(" ","_").toLowerCase(),gr=e=>e.replaceAll("_"," "),_e=e=>...e.map((t,r)=>t===" "?"_":!mo.includes(t)||r===e.length-1&&go.includes(t)?encodeURIComponent(t):t).join(""),mo='@$&+=:;",',go=':;",';var Q=()=>{let e=A();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(s=>s.startsWith("__reactFiber"));if(!t)throw Error('#text-input must has the property whose name starts with "__reactFiber"');let r=et.return.return.stateNode._stores,n=r.find(s=>s.constructor.name==="Cursor");if(!n)throw Error('#text-input must has a "Cursor" store.');let o=r.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:n,selection:o}};var hr=()=>Q().cursor;var _r=()=>Q().selection;var ye=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),yr=e=>{if(e===0)return;let t={};return e&1&&(t.capture=!0),e&2&&(t.once=!0),e&4&&(t.passive=!0),t};var Me=new Map,ot=new Map,xr=(e,t,r)=>{let n=Me.get(e)??new Map,o=n.get(t)??new Set;if(o.has(ye(r)))return;if(o.add(ye(r)),n.set(t,o),Me.set(e,n),typeof r=="object"&&r?.once){let i=ot.get(t)??new Map,a=ye(r),u=function(d){return ho(e,t,r),i.delete(a),t.call(this,d)};i.set(a,u),ot.set(t,i);let l=A();if(!l)return;l.addEventListener(e,u,r)}let s=A();s&&s.addEventListener(e,t,r)};scrapbox.on("layout:changed",()=>{let e=A();if(e)for(lett,rof Me)for(letn,oof r)for(let s of o)e.addEventListener(t,n,yr(s))});var ho=(e,t,r)=>{let n=Me.get(e);if(!n)return;let o=n.get(t);if(!o)return;let s=ye(r);if(o.delete(s),typeof r=="object"&&r?.once){let a=ot.get(t);if(!a)return;let u=a.get(s);if(!u)return;let l=A();if(!l)return;l.removeEventListener(e,u,r),a.delete(s);return}let i=A();i&&i.removeEventListener(e,t,r)};var _o=0,Pa=Array.isArray;function y(e,t,r,n,o,s){t||(t={});var i,a,u=t;"ref"in t&&(i=t.ref,delete t.ref);var l={type:e,props:u,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--_o,__i:-1,__u:0,__source:o,__self:s};if(typeof e=="function"&&(i=e.defaultProps))for(a in i)ua===void 0&&(ua=ia);return _.vnode&&_.vnode(l),l}var Er=({title:e,projects:t,selected:r,confirm:n})=>y("div",{className:candidate${r?" selected":""},children:y(yo,{title:e,confirm:n}),t.map(o=>y(xo,{project:o.name,title:e,mark:o.mark,confirm:o.confirm}))}),yo=({title:e,confirm:t})=>y("a",{className:"button",tabIndex:0,role:"menuitem",href:./${_e(e)},onClick:br(t),children:e}),xo=({project:e,title:t,mark:r,confirm:n})=>r===""?y(S,{}):y("a",{className:"mark",tabIndex:0,href:../${e}/${_e(t)},onClick:br(n),title:/${e}/${_e(t)},children:r instanceof URL?y("img",{src:r.href}):[${r}]}),br=e=>E(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},e);var kr=(e,t)=>{letr,n=U(null),o=E(u=>n(l=>{if(e.length===0)return null;if(l===null)return t(e0);let d=e.findIndex(c=>t(c)===l);return t(u?.cyclic?e(d+1)%e.length:e.at(d+1)??e0)}),e,t),s=E(u=>n(l=>{if(e.length===0)return null;if(l===null)return t(ee.length-1);let d=e.findIndex(c=>t(c)===l);return d<0?t(ee.length-1):t(u?.cyclic?e(d-1+e.length)%e.length:e.at(d-1)??ee.length-1)}),e,t),i=E(()=>n(e.length===0?null:t(e0)),e,t),a=E(()=>n(e.length===0?null:t(ee.length-1)),e,t);return{selectedId:r,next:o,prev:s,selectFirst:i,selectLast:a}};var wr=e=>{lett,r=U(null),n=T(()=>{let o=t?.getBoundingClientRect?.(),i=rt(e.line,e.char)?.getBoundingClientRect?.();return!i||!o?{}:{top:${i.bottom-o.top}px,left:${i?.left??0-o.left}px,right:${o.right-(i?.left??0)}px}},t,e.line,e.char);return{updateStandardElement:r,...n}};var it="enableProjectsOnSuggestion",Rr=(e,t)=>{letr,n=U(Ne(...e,t)),o=E((s,i)=>{Eo(s,i,e,t),n(Ne(...e,t))},e,t.enableSelfProjectOnStart);return j(()=>{let s=i=>{i.key===it&&n(Ne(...e,t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},e,t.enableSelfProjectOnStart),{projects:r,set:o}},st=!0,Ne=(e,t)=>{try{let r=localStorage.getItem(it);if(r===null)return Fe(e),e;let n=JSON.parse(r);return Array.isArray(n)&&n.every(o=>typeof o=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?n:n.includes(scrapbox.Project.name)?st?n:n.filter(o=>o!==scrapbox.Project.name):st?...n,scrapbox.Project.name:n:(Fe(e),e)}catch(r){if(!(r instanceof TypeError))throw r;return Fe(e),e}},Eo=(e,t,r,n)=>{let o=Ne(...r,n);n.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(st=t),Fe(t?...o,e:o.filter(s=>s!==e))},Fe=e=>localStorage.setItem(it,JSON.stringify(e));var Tr=()=>T(()=>document.documentElement.dataset.os??"",[]);var xe=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var vr=({progress:e})=>y("div",{className:"progress",style:background: linear-gradient(to right, var(--select-suggest-border-color, #eee) ${(e*100).toPrecision(3)}%, transparent ${(e*100).toPrecision(3)}%)});var Pr=({position:e,start:t,enableSelfProjectOnStart:r,projects:n,...o})=>{let{projects:s,set:i}=Rr(n,{enableSelfProjectOnStart:r}),{updateStandardElement:a,top:u,left:l,right:d}=wr({line:e.line,char:t}),c=Tr();return y(S,{children:y(ko,{itemCount:o.items.length,enableProjects:s,projects:n,top:u,right:d,set:i,os:c,...o}),y(bo,{updateStandardElement:a,start:t,enableProjects:s,projects:n,top:u,left:l,os:c,...o})})},bo=({start:e,updateStandardElement:t,confirmAfter:r,cancel:n,query:o,enableProjects:s,projects:i,items:a,top:u,left:l,progress:d,callback:c,limit:p,mark:f,os:m})=>{let b=E((k,w,C)=>{let Ee=[${w?/${w}/${k}:k}${C?.icon?".icon":""}];r((Tt,{line:jn})=>[${[...Tt].slice(0,e).join("")}${Ee}${[...Tt].slice(e+[...o].length).join("")},{line:jn,char:e+...Ee.length}])},e,o),x=T(()=>i.size>1||!i.has(scrapbox.Project.name),i),g=T(()=>{let k=[];for(let w of a){if(k.length===p)break;w.projects.some(C=>s.includes(C))&&k.push({title:w.title,projects:w.projects.flatMap(C=>s.includes(C)?[{name:C,mark:x?xe(fC??"",import.meta.url)||C0:"",confirm:Ee=>b(w.title,C,Ee)}]:[]),confirm:C=>b(w.title,void 0,C)})}return k},s,x,a,p,f,b),{selectedId:h,next:v,prev:N,selectLast:J,selectFirst:W}=kr(g,Lr),de=E(k=>h===null?!1:(g.find(w=>Lr(w)===h)?.confirm?.(k),!0),h,g);j(()=>c(g.length===0?void 0:{selectNext:k=>(v(k),!0),selectPrev:k=>(N(k),!0),selectFirst:()=>(W(),!0),selectLast:()=>(J(),!0),confirm:de,cancel:()=>(n(),!0)}),c,g.length,v,N,W,J,de);let ee=T(()=>g.length>0&&u!=null&&l!=null?{top:u,left:l}:{display:"none"},g.length,u,l),fe=E(k=>{if(!k){t(k);return}let w=k.parentNode;if(!(w instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(w.host.parentElement)},t);return y("div",{ref:fe,className:"container candidates","data-os":m,style:ee,children:[g.map(k=>y(Er,{...k,selected:h===k.title},k.title)),a.length>p&&y("div",{className:"counter",children:${a.length-p} more links}),y(vr,{progress:d})]})},ko=({enableProjects:e,projects:t,projectScore:r,mark:n,itemCount:o,top:s,right:i,set:a,os:u,freezeUntil:l})=>{let d=T(()=>...t.sort((p,f)=>(r.get(f)??0)-(r.get(p)??0)).flatMap(p=>r.has(p)?[{name:p,enable:e.includes(p),mark:xe(np??"",import.meta.url)||p0,score:r.get(p),onClick:()=>l(()=>{a(p,!e.includes(p)),A().focus()})}]:[]),t,r,e,n),c=T(()=>o>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},s,i,o,t.size);return y("div",{className:"container projects","data-os":u,style:c,children:d.map(p=>y(wo,{...p},p.name))})},wo=e=>y("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name,children:e.mark instanceof URL?y("img",{src:e.mark.href}):[${e.mark}]}),Lr=e=>e.title;var D=!1,Sr=e=>{D=typeof e=="boolean"?e:new Set(e)},$=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,r;switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},at,...n)];case"log":case"info":case"debug":return[t,(...n)=>{D!==!0&&(!D||!D.has(e))||r(%c${e},at,...n)}];case"assert":return[t,(n,...o)=>{D!==!0&&(!D||!D.has(e))||r(n,%c${e},at,...o)}];case"time":case"timeEnd":return[t,n=>{D!==!0&&(!D||!D.has(e))||r(${e} ${n})}];default:returnt,(...n)=>{if(!(D!==!0&&(!D||!D.has(e))))return r(...n)}}})),at="color: gray";var Cr=" must not return ",Ro="transformer",To="recoverer",vo="defaultValue",uc=Ro+Cr,ct="called with ",lc=vo+" must not be ",pc=To+Cr;var Lo="Ok",Ir="Err",Mr=ct+Ir,Nr=ct+Lo,mc="Carrying E in "+Ir+" instead of throwing it directly. See .cause",ut="an instance of Error of the current realm.",gc="The thrown value is not "+ut,hc="The contained E should be "+ut,_c="This .cause is not "+ut;function ce(e){return e.ok}function q(e){return{ok:!0,val:e,err:null}}function F(e){return!e.ok}function G(e){return{ok:!1,val:null,err:e}}function B(e){return Fr(e,Mr)}function ue(e){return Or(e,Nr)}function Fr(e,t){if(F(e))throw new TypeError(t);return e.val}function Or(e,t){if(ce(e))throw new TypeError(t);return e.err}function jr(e){return e.val}function Ar(e){return e.err}async function le(e,t){if(F(e))return e;let r=jr(e),n=await t(r);return q(n)}async function pe(e,t){if(ce(e))return e;let r=Ar(e),n=await t(r);return G(n)}var I=e=>e.ok?q(e):G({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Dr=async(e,t)=>{let r=new Request(e,t);try{return q(await globalThis.fetch(r))}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return G({name:"AbortError",message:n.message,request:r});if(n instanceof TypeError)return G({name:"NetworkError",message:n.message,request:r});throw n}};var P=e=>{let{fetch:t=Dr,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var M=e=>connect.sid=${e};function Oe(e,t={}){if(e===null)return"null";if(Array.isArray(e))return Po(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:So(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function Po(e,t){let{threshold:r=20}=t,n=e.map(i=>Oe(i,t)),o=n.join(", ");if(o.length<=r)return[${o}];let s=n.join(`, );return[
${Br(2,s)}
]}function So(e,t){let{threshold:r=20}=t,n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${Oe(ei,t)}),o=n.join(", ");if(o.length<=r)return{${o}};let s=n.join(, );return{
${Br(2,s)}
}}function Br(e,t){let r=" ".repeat(e);return t.split(
).map(n=>${r}${n}).join(
)}function je(e,t,...r){let n;return Object.defineProperties(e,{name:{get:()=>n||(n=${t}(${r.map(o=>Oe(o)).join(", ")}),n)}})}function Hr(e){return je(t=>Ce(t)&&t.every(r=>e(r)),"isArrayOf",e)}function lt(e){let t=new Set(e);return je(r=>t.has(r),"isLiteralOneOf",e)}function pt(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}var O=async(e,t)=>{let r=e.response.clone(),n=lt(t);try{let o=await r.json();if(!pt(o))return;if(r.status===422){if(!z(o.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:o.message}}return!n(o.name)||!z(o.message)?void 0:o.name==="NotLoggedInError"?!pt(o.detals)||!z(o.detals.project)||!Hr(Co)(o.detals.loginStrategies)?void 0:{name:o.name,message:o.message,details:{project:o.detals.project,loginStrategies:o.detals.loginStrategies}}:{name:o.name,message:o.message}}catch(o){if(o instanceof SyntaxError)return;throw o}},Co=lt(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var $r=(e,t)=>{let{sid:r,hostName:n}=P(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:M(r)}}:void 0)},qr=async e=>le(await pe(I(e),async t=>await O(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),Wr=(()=>{let e=async(t,r)=>{let{fetch:n}=P(r??{}),o=$r(t,r),s=await n(o);return F(s)?s:qr(B(s))};return e.toRequest=$r,e.fromResponse=qr,e})(),Kr=(e,t)=>{let{sid:r,hostName:n}=P(t??{}),o=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${n}/api/projects?${o},r?{headers:{Cookie:M(r)}}:void 0)},Gr=async e=>le(await pe(I(e),async t=>await O(t,["NotLoggedInError"])??t),t=>t.json()),Vr=(()=>{let e=async(t,r)=>{let{fetch:n}=P(r??{}),o=await n(Kr(t,r));return F(o)?o:Gr(B(o))};return e.toRequest=Kr,e.fromResponse=Gr,e})();var zr=(e,t)=>{let{sid:r,hostName:n,followingId:o}=P(t??{});return new Request(https://${n}/api/pages/${e}/search/titles${o??followingId=${o}:""},r?{headers:{Cookie:M(r)}}:void 0)},Yr=async e=>le(await pe(I(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await O(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),Io=(()=>{let e=async(t,r)=>{let n=await P(r??{}).fetch(zr(t,r));return F(n)?n:Yr(B(n))};return e.toRequest=zr,e.fromResponse=Yr,e})();async function*Jr(e,t){let r;do{let n=await Io(e,{followingId:r,...t});if(F(n)){yield n;return}let o=B(n);yield q(o.pages),r=o.followingId}while(r)}var kl=new TextEncoder;var vl=new TextEncoder().encode("0123456789abcdef"),Ll=new TextEncoder,Pl=new TextDecoder;async function*Xr(e){let t=[],r=[],n=new Map,o=[];for(let s of e)s.isValid&&(s.id?s.isMember||t.push(s.id):r.push(s.name),o.push(s.name),n.set(s.name,s.checked));for(let s=0;s<t.length;s+=50){let i=t.slice(s,s+50);if(i.length===0)break;i.length===1&&i.push(i[0]);let a=await Vr(i);if(F(a)){r=o;break}for(let u of B(a).projects)n.has(u.name)&&(yield q({...u,checked:n.get(u.name)??0}))}for(let s of r){let i=await Wr(s);yield ce(i)?q({...B(i),checked:n.get(s)??0}):G({...ue(i),project:s})}}var mt=(e,t)=>t.some(r=>e instanceof r),Qr,Zr;function Mo(){return Qr||(Qr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function No(){return Zr||(Zr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var gt=new WeakMap,dt=new WeakMap,De=new WeakMap;function Fo(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(Y(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return De.set(t,e),t}function Oo(e){if(gt.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});gt.set(e,t)}var ht={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return gt.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Y(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function nn(e){ht=e(ht)}function jo(e){return No().includes(e)?function(...t){return e.apply(_t(this),t),Y(this.request)}:function(...t){return Y(e.apply(_t(this),t))}}function Ao(e){return typeof e=="function"?jo(e):(e instanceof IDBTransaction&&Oo(e),mt(e,Mo())?new Proxy(e,ht):e)}function Y(e){if(e instanceof IDBRequest)return Fo(e);if(dt.has(e))return dt.get(e);let t=Ao(e);return t!==e&&(dt.set(e,t),De.set(t,e)),t}var _t=e=>De.get(e);function on(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),a=Y(i);return n&&i.addEventListener("upgradeneeded",u=>{n(Y(i.result),u.oldVersion,u.newVersion,Y(i.transaction),u)}),r&&i.addEventListener("blocked",u=>r(u.oldVersion,u.newVersion,u)),a.then(u=>{s&&u.addEventListener("close",()=>s()),o&&u.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function sn(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),Y(r).then(()=>{})}var Do=["get","getKey","getAll","getAllKeys","count"],Bo=["put","add","delete","clear"],ft=new Map;function en(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(ft.get(t))return ft.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=Bo.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||Do.includes(r)))return;let s=async function(i,...a){let u=this.transaction(i,o?"readwrite":"readonly"),l=u.store;return n&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),o&&u.done]))[0]};return ft.set(t,s),s}nn(e=>({...e,get:(t,r,n)=>en(t,r)||e.get(t,r,n),has:(t,r)=>!!en(t,r)||e.has(t,r)}));var Ho=["continue","continuePrimaryKey","advance"],tn={},yt=new WeakMap,an=new WeakMap,Uo={get(e,t){if(!Ho.includes(t))return e[t];let r=tn[t];return r||(r=tn[t]=function(...n){yt.set(this,an.get(this)[t](...n))}),r}};async function*$o(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let r=new Proxy(t,Uo);for(an.set(r,t),De.set(r,_t(t));t;)yield r,t=await(yt.get(r)||t.continue()),yt.delete(r)}function rn(e,t){return t===Symbol.asyncIterator&&mt(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&mt(e,[IDBIndex,IDBObjectStore])}nn(e=>({...e,get(t,r,n){return rn(t,r)?$o:e.get(t,r,n)},has(t,r){return rn(t,r)||e.has(t,r)}}));var Be=$("scrapbox-storage:db.ts"),cn,xt=async()=>(cn??=await on("scrapbox-storage",4,{upgrade(e){Be.time("update DB");for(let n of e.objectStoreNames)e.deleteObjectStore(n);e.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let r=e.createObjectStore("projects",{keyPath:"id"});r.createIndex("checked","checked"),r.createIndex("name","name"),Be.timeEnd("update DB")},blocked(e,t){let r=The database "@takker/cosense-storage"(v${t}) is blocked because the older one (v${e}) is opened in other tabs. Please close the other tabs and reload this page.;Be.error(r),alert(r)},blocking(e,t){let r=The database "@takker/cosense-storage"(v${e}) is blocking the newer one (v${t}) opened.
Please close this page.;Be.error(r),alert(r)}}),cn);var un=(e,t)=>(Et||(Et=new BroadcastChannel(pn),Et.addEventListener("message",r=>ln(r.data))),He.set(t,new Set(e).union(He.get(t)??new Set)),()=>He.delete(t)),bt=(e,t)=>{if((t.added?.size??0)+(t.updated?.size??0)+(t.deleted?.size??0)===0)return;let r={type:"links:changed",project:e,diff:t};ln(r);let n=new BroadcastChannel(pn);n.postMessage(r),n.close()},ln=e=>{for(let[t,r]of He)r.has(e.project)&&t(e)},pn="scrapbox-storage-notify",Et,He=new Map;var qo=Math.pow(10,8)*24*60*60*1e3,pp=-qo;var Ko=3600;var dn=Ko*24,dp=dn*7,Go=dn*365.2425,Wo=Go/12,fp=Wo*3,kt=Symbol.for("constructDateFrom");function fn(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&kt in e?e[kt](t):e instanceof Date?new e.constructor(t):new Date(t)}function mn(e,t){return fn(t||e,e)}function wt(e){return Math.trunc(+mn(e)/1e3)}var H=$("scrapbox-storage:mod.ts"),gn=async(e,t)=>{let r=await xt(),n=new Map;try{{H.debug("check updates of links...");let s=new Set,i=r.transaction("projects","readwrite"),a=wt(new Date),u=a-600;for await(let c of i.store.index("checked").iterate(IDBKeyRange.lowerBound(u,!0))){let p=c.value;if(p.isValid===!1){s.add(p.id);continue}s.add(p.name);let f=p.checked;if(f+t>a||p?.updating&&f>u)continue;let m=structuredClone(p);m.updating=!0,n.set(p.id,m),c.update(m)}let l=[],d=i.store.index("name");for(let c of e)s.has(c)||l.push(d.get(c).then(p=>{n.set(c,p??Vo(c))}));if(await Promise.all(l),await i.done,n.size===0){H.debug("checked. No project needs upgrade.");return}H.debug(checked. ${n.size} projects maybe need upgrade.)}let o=wt(new Date);for await(let s of Xr(n.values())){if(F(s)){let{project:m,name:b}=ue(s);switch(b){default:continue;case"NotFoundError":H.warn("${m}" is not found.);break;case"NotMemberError":H.warn(You are not a member of "${m}".);break;case"NotLoggedInError":H.warn(You are not a member of "${m}" or You are not logged in yet.);break}n.set(m,{id:m,name:m,checked:o,updating:!1,isValid:!1,reason:b});continue}let{checked:i,...a}=B(s);if(a.updated<i){H.debug(no updates in "${a.name}"),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1});continue}let u=download and store links of "${a.name}";H.time(u);let l=new Set(await r.getAllKeysFromIndex("titles","project",a.name)),d=0,c=0;for await(let m of Jr(a.name)){if(F(m)){let{name:h,message:v}=ue(m);H.error(Failed to get links of "${a.name}" with ${h}: ${v});break}let b=B(m),x={},g=r.transaction("titles","readwrite");await Promise.all(b.map(async h=>{let v={...h,project:a.name};if(!l.has(h.id))return x.added?.set?.(h.id,v)??(x.added=new Map([[h.id,v]])),g.store.add(v);l.delete(h.id);let N=await g.store.get(h.id);if(!N)return x.added?.set?.(h.id,v)??(x.added=new Map([[h.id,v]])),g.store.add(v);if(!(N.updated>=v.updated))return x.updated?.set?.(h.id,[N,v])??(x.updated=new Map([[h.id,[N,v]]])),g.store.put(v)})),await g.done,d+=x.added?.size??0,c+=x.updated?.size??0,H.debug(Updating "/${a.name}": +${d} pages, ~${c} pages),bt(a.name,x)}let p=r.transaction("titles","readwrite"),f=new Map((await Promise.all([...l].map(async m=>{let b=await p.store.get(m);if(!b)return[];let x=[[m,b]];return await p.store.delete(m),x}))).flat());await p.done,H.timeEnd(u),H.debug(Update "/${a.name}": +${d} pages, ~${c} pages, -${f.size} pages),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1}),bt(a.name,{deleted:f})}}finally{let o=r.transaction("projects","readwrite");await Promise.all([...n].map(([,s])=>(s.updating=!1,o.store.put({...s})))),await o.done}},hn=async e=>{let t=[...new Set(e)];if(t.length===0)return[];let r=Date.now(),o=(await xt()).transaction("titles","readonly"),s=o.store.index("project"),i=(await Promise.all(t.map(a=>s.getAll(a)))).flat();return await o.done,H.debug(Read ${i.length} links from ${t.length} projects in ${Date.now()-r}ms),i},Vo=e=>({name:e,displayName:e,id:"",isValid:!0,publicVisible:!0,isMember:!0,loginStrategies:[],theme:"default",gyazoTeamsName:null,translation:!0,infobox:!0,checked:0,updated:0,created:0,updating:!0});sn("userscript-links").catch(e=>console.error(e));var zo=$("scrapbox-select-suggestion:useSource.ts"),yn=e=>Ze(...T(()=>{let t=[];return[o=>{let s=hn(e).then(i=>{let a=Yo(i);return t=[...a.values()],o(),a});return gn(e,600),un(e,({diff:i})=>s=s.then(a=>(zo.debug(Update: +${i.added?.size??0} pages, ~${i.updated?.size??0} pages, -${i.deleted?.size??0} pages),a=Jo(a,i),t=[...a.values()],o(),a)))},()=>t]},[e])),Yo=e=>{let t=new Map;for(let r of e)Rt(t,r);return t},Jo=(e,t)=>{let r=new Map(e);if(t.added)for(let[,n]of t.added)Rt(r,n);if(t.updated)for(let[,[n,o]]of t.updated)_n(r,n),Rt(r,o);if(t.deleted)for(let[,n]of t.deleted)_n(r,n);return r},Rt=(e,t)=>{let r=ae(t.title),n=e.get(r);if((n?.updated??0)>t.updated)return;let o=n?.metadata??new Map;o.set(t.project,{image:t.image}),e.set(r,{title:t.title,titleLc:r,updated:t.updated,linked:n?.linked??0,metadata:o});for(let s of t.links){let i=ae(s),a=e.get(i),u=a?.metadata??new Map;u.set(t.project,u.get(t.project)??{image:t.image}),e.set(i,{title:a?.title??s,titleLc:i,updated:a?.updated??0,linked:(a?.linked??0)+1,metadata:u})}},_n=(e,t)=>{let r=ae(t.title),n=e.get(r);if(!n||(n.updated??0)>t.updated)return;let o=n.metadata;o.delete(t.project),o.size<=0?e.delete(r):e.set(r,{title:n.title,titleLc:r,updated:t.updated,linked:n.linked,metadata:o});for(let s of t.links){let i=ae(s),a=e.get(i);if(!a)continue;let u=a.metadata;u.delete(t.project),u.size<=0?e.delete(i):e.set(i,{title:a.title,titleLc:i,updated:t.updated,linked:a.linked-1,metadata:u})}};var xn=e=>{let t=T(()=>xe(e.style,import.meta.url),[e.style]);return y(S,{children:t!==""&&(t instanceof URL?y("link",{rel:"stylesheet",href:t.href}):y("style",{children:t}))})};var En=()=>y("style",{children:.container {
position: absolute;
margin-top: 14px;
max-height: 80vh;
z-index: 301;
background-color: var(--select-suggest-bg, #111); font-family: var(--select-suggest-font-family, "Open Sans", Helvetica, Arial, "Hiragino Sans", sans-serif);
font-size: 14px;
color: var(--select-suggest-text-color, #eee); border-radius: 4px;
}
.candidates {
max-width: 80vw;
}
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
padding: 6px;
}
.candidates > :not(:first-child) {
border-top: 1px solid var(--select-suggest-border-color, #eee); }
.candidates > *{
line-height: 1.2em;
padding: 0.5em 10px;
}
.candidate {
display: flex;
}
a {
display: block;
text-decoration: none;
color: inherit;
}
a:not(.mark) {
width: 100%;
}
.selected a {
background-color: var(--select-suggest-selected-bg, #222); text-decoration: underline
}
img {
height: 1.3em;
width: 1.3em;
position: relative;
object-fit: cover;
object-position: 0% 0%;
}
.disabled {
filter: grayscale(1.0) opacity(0.5);
}
.counter {
color: var(--select-suggest-information-text-color, #aaa); font-size: 80%;
font-style: italic;
}
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
}});function*bn(e){if(!("nodes"in e))return;let t=0;function*r(n){for(let o of Array.isArray(n)?n:[n]){if(typeof o=="string"){t+=[...o].length;continue}switch(o.type){case"link":yield{whole:o.unit.whole,start:t},t+=[...o.unit.whole].length;break;case"indent":case"quote":t+=[...o.unit.tag].length,yield*r(o.children);break;case"deco":t+=[...o.unit.deco].length+2,yield*r(o.children),t++;break;case"strong":t+=2,yield*r(o.children),t+=2;break;default:t+=[...o.unit.whole].length;break}}}yield*r(e.nodes)}var kn=(e,t)=>{if(t.type==="unlock"){if(!e.lock)return e;let{lock:i,...a}=e;return{...a}}if(e.lock)return e;switch(t.type){case"lock":{let{lock:i,...a}=e;return{lock:!0,...a}}case"enable":return e.type==="disabled"&&e.isManuallyDisabled?{type:"ready"}:e;case"disable":return e.type==="disabled"&&e.isManuallyDisabled?e:{type:"disabled",isManuallyDisabled:!0}}if(e.type==="disabled")return e.isManuallyDisabled||!t.lines?e:{type:"ready"};if(t.type==="cancel")return e.type==="completion"?{type:"cancelled",context:e.context}:e;if(!t.lines)return{type:"disabled"};let r=Math.min(t.range.start.char,t.range.end.char),n=Math.max(t.range.start.char,t.range.end.char),o=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(r,n).join(""):"";if(Qo(t.lines[t.position.line],o)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:o,start:r,position:t.position};if(o!=="")return e.type==="completion"?{type:"ready"}:e;let s=Xo(t.lines[t.position.line],t.position.char);return s?e.type==="cancelled"&&e.context==="input"?e:e.type==="completion"||t.type==="lines:changed"?{type:"completion",context:"input",query:s.whole,start:s.start,position:t.position}:e.type==="ready"?e:{type:"ready"}:e.type==="ready"?e:{type:"ready"}},Xo=(e,t)=>{for(let{whole:r,start:n}of bn(e))if(!(t<=n||n+[...r].length<=t))return{whole:r,start:n}},Qo=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var wn=()=>{let e=ie(scrapbox.Page.lines),t=ie(!1);return j(()=>{let r=()=>{t.current=!0};return scrapbox.addListener("lines:changed",r),scrapbox.addListener("layout:changed",r),()=>{scrapbox.removeListener("lines:changed",r),scrapbox.removeListener("layout:changed",r)}},[]),E(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var Zo=$("scrapbox-select-suggestion:useLifecycle.ts"),Rn=()=>{let[e,t]=se(kn,{type:"ready"}),r=wn(),n=T(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:u,selection:l}=Q();t({type:a,lines:r(),range:l.getRange({normalizeOrder:!0}),position:u.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);j(()=>{let i=()=>{n("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{n("selection:changed")},u=_r();return u.addChangeListener(a),()=>{scrapbox.removeListener("lines:changed",i),scrapbox.removeListener("layout:changed",i),u.removeChangeListener(a)}},[]),j(()=>{if(e.context!=="input")return;let i=()=>{n("cursor:changed")},a=hr();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[o,s]=U(e);return o!==e&&(s(e),Zo.debug("Detect changes",e)),{state:e,setEnable:E(i=>t({type:i?"enable":"disable"}),[]),cancel:E(()=>t({type:"cancel"}),[]),freezeUntil:E(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:E(async i=>{let a=r();if(!a)return;t({type:"lock"});let{cursor:u,selection:l}=Q(),d=u.getPosition().line,c=a[d].text,[p,f]=i(c,u.getPosition());l.setRange({start:{line:d,char:0},end:{line:d,char:[...c].length}}),await mr(p),u.setPosition(f),u.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var Tn=(e,t)=>{let r=e.dist-t.dist;if(r!==0)return r;let n=e.matches.map(([i])=>i).sort(),o=t.matches.map(([i])=>i).sort();for(let i=0;i<n.length;i++){let a=n[i]-(o[i]??o.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var vn=e=>{let t=new Map,r=[...e].reverse();{let i=1;for(let a of r){t.set(a,(t.get(a)??0)|i);let u=a.toLowerCase();t.set(u,(t.get(u)??0)|i);let l=a.toUpperCase();t.set(l,(t.get(l)??0)|i),i<<=1}}let n=r.length,o=~(-1<<n),s=1<<n-1;return i=>{let a=0,u=o,l=[...i].reverse(),d=[],c=l.length;d[c]=n;for(let p of l){let f=t.get(p)??0,m=f|a,b=(f&u)+u^u|f,x=a|~(b|u),g=u&b;d[c-1]=d[c]+(x&s?1:g&s?-1:0),u=g<<1|~(m|x<<1),a=x<<1&m,c--}return d}};var es=[0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],Ln=e=>{let t=gr(e.trim()).split(/\s+/).sort((r,n)=>n.length-r.length);if(!(t.length===0||t.every(r=>r==="")))return r=>{let n=[...r];for(let o of t)n=ts(o,n);return n}},ts=(e,t)=>{let r=[...e].length,n=es[r],o=vn(e);return t.flatMap(({title:s,dist:i,matches:a,...u})=>{a??=[],i??=0;let l=o(s).flatMap((c,p)=>c<=n&&a.every(([f,m])=>p+r<=f||m<p)?[[p,c]]:[]);if(l.length===0)return[];let d=l.reduce((c,[p,f])=>(c.dist<=f||(c.dist=f,c.start=p),c),{dist:r,start:0});return a.push([d.start,d.start+r-1]),[{title:s,dist:d.dist+i,matches:a,...u}]})};var rs=$("scrapbox-select-suggestion:cancelableSearch.ts");async function*Pn(e,t,r){let n=Ln(e);if(!n)return;let o=r?.chunk??1e3,s=Math.floor(t.length/o)+1,i=0,a=new Date;try{for(;i<s;i++)await new Promise(u=>requestAnimationFrame(u)),yield[n(t.slice(i*o,(i+1)*o)),(i+1)/s]}finally{let l=new Date().getTime()-a.getTime();rs.debug(search ${(i/s*100).toPrecision(3)}% of the source for "${e}" in ${l}ms)}}var Sn=(e,t)=>{let r=t?.interval??0,n=t?.maxQueued??1/0,o,s=[],i=(...a)=>{if(!o)return o=(async()=>{do{await new Promise(p=>setTimeout(p,r));let c=s.pop();if(!c)break;c("delayed")}while(s.length>0);o=void 0})(),new Promise(c=>c(e.call(i,...a,"immediate")));for(;s.length>Math.max(n,0);)s.shift()("discarded");let{promise:u,resolve:l,reject:d}=Promise.withResolvers();return s.push(c=>{try{l(e.call(i,...a,c))}catch(p){d(p)}}),u};return Object.defineProperty(i,"ready",{get:()=>o}),i};var Z=e=>"query"in e,Cn=e=>(t,r)=>{if("query"in r){let i=Z(t)?t.query:"";if(r.query===i)return t;let a=Z(t)?t.job:void 0;if(!r.query)return a?.abort?.(),{source:t.source};let{run:u,abort:l}=e(r.query,t.source,!1),d=a?.abort?.()?.then?.(u)??u();return{query:r.query,source:t.source,job:{done:d,abort:()=>(l(),d)},progress:0,candidates:!i||!Z(t)?[]:t.candidates}}if("source"in r){if(!Z(t))return r.source===t.source?t:r;let{source:i,job:a,...u}=t;if(r.source===i)return t;let{run:l,abort:d}=e(u.query,r.source,!0),c=a.done.then(l);return{source:r.source,job:{done:c,abort:()=>a.abort().then(()=>(d(),c))},...u}}if(!Z(t))return t;if(!r.candidates){let{progress:i,...a}=t;return i===r.progress?t:{progress:r.progress,...a}}let{candidates:n,progress:o,...s}=t;return n===r.candidates&&o===r.progress?t:{candidates:r.candidates??n,progress:r.progress,...s}};var ns=$("scrapbox-select-suggestion:useSearch.ts"),In=e=>{let t=E((o,s,i)=>{let a=!1,u=Pn(o,s,{chunk:5e3});return{run:async()=>{if(i){let c=[];for await(let[p]of u){if(a)return;c.push(...p)}n({progress:1,candidates:c});return}let l=Sn((c,p)=>{p!=="discarded"&&(a||n(c))},{interval:500,maxQueued:0}),d=[];for await(let[c,p]of u){if(a)return;d=[...d,...c],n({progress:p}),c.length!==0&&l({progress:p,candidates:d})}l({progress:1,candidates:d})},abort:()=>a=!0}},[]),[r,n]=se(T(()=>Cn(t),[t]),{source:e});return[T(()=>{if(!Z(r))return;let[o,s]=os(r.candidates);return ns.debug("Detect changes",{progress:r.progress,items:s}),{progress:r.progress,projectScore:o,items:s}},[r]),{search:E(o=>n({query:o}),[]),update:E(o=>n({source:o}),[])}]},os=e=>{let t=new Map,r=[];for(let n of e.sort(Tn)){let o=[...n.metadata.keys()];for(let s of o)t.set(s,(t.get(s)??0)+.5**n.dist);r.push({title:n.title,dist:n.dist,projects:o})}return[t,r]};var Mn=(e,t)=>{let r=ie({...t});j(()=>(Object.assign(r.current,t),()=>{for(let n of Object.keys(t))delete r.current[n]}),[...Object.keys(t)].sort().map(n=>t[n])),j(()=>{e(r.current)},[e])};var ss={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},Nn=e=>{let t=yn(e.projects),[r,{update:n,search:o}]=In(t),{state:s,setEnable:i,...a}=Rn();n(t),o(s.type==="completion"?s.context==="input"?s.query.slice(1,-1):s.query:"");let[u,l]=U(),{callback:d,style:c,...p}=e;return Mn(d,{enable:E(()=>i(!0),[]),disable:E(()=>i(!1),[]),...s.type!=="completion"||!u?ss:u}),y(S,{children:[y(En,{}),y(xn,{style:c}),s.type==="completion"&&r&&y(Pr,{callback:l,...r,...s,...a,...p})]})};var Fn=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let r=t.attachShadow({mode:"open"});document.body.append(t);let{limit:n=5,debug:o=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0}=e??{},u=new Set([...a?[scrapbox.Project.name]:[],...e?.projects??[scrapbox.Project.name]]);return Sr(o),new Promise(l=>ve(y(Nn,{limit:n,projects:u,mark:s,style:i,callback:l,enableSelfProjectOnStart:a}),r))};var On=async e=>{let t=await Fn(e);xr("keydown",r=>{if(!(r.metaKey||r.altKey)){switch(r.key){case"Tab":{if(r.ctrlKey||r.altKey||!(r.shiftKey?t.selectPrev?.({cyclic:!0}):t.selectNext?.({cyclic:!0})))return;break}case"Enter":{if(r.shiftKey||r.ctrlKey||r.altKey||!t.confirm?.())return;break}case"i":{if(r.shiftKey||!r.ctrlKey||r.altKey||!t.confirm?.({icon:!0}))return;break}case"Escape":{if(r.shiftKey||r.ctrlKey||r.altKey||!t.cancel?.())return;break}default:return}r.preventDefault(),r.stopPropagation()}})};var is=[scrapbox.Project.name,"takker","takker-memex","takker-books","takker-private","villagepump","hub","arpla","unnamedcamp","unnamed-project","nishio","enchi","rashitamemo","motoso","shokai","masui","rakusai","yuiseki","akiroom","c4j","miyamonz","mrsekut-p","masuilab","kidaaam-92022284","nwtgck","juneboku","marshmallow-rm","sushitecture","sno2wman","inteltank","issac-37765679","blu3mo","yosider","Mijinko","Mijinko-other","scrapbox-drinkup","nota-techconf","customize","scrapboxlab","scrasobox","programming-notes","tus-alpine","tus-alpine-private","guiland"];await On({projects:is,mark:{...Object.fromEntries([["takker","takker"],["takker-memex","takker"],["takker-books","takker-books"],["takker-private","takker-private"],["nishio","nishio"],["rashitamemo","rashita"],["enchi","\u96D1\u8AC7_2022-04-12~"],["rakusai","rakusai"],["masui","\u6982\u8981"],["shokai","shokai"],["yuiseki","yuiseki"],["akiroom","\u306F\u3058\u3081\u306B"],["inteltank","sawachin"],["motoso","\u3082\u3068\u305D\u306E\u3082\u3068"],["villagepump","\u4E95\u6238\u7AEF"],["hub","scrapbox.io%2Fhub_\u306B\u3064\u3044\u3066"],["masuilab","\u5897\u4E95\u7814\u306B\u5165\u3063\u305F\u3089\u307E\u305A\u3084\u308B\u3053\u3068"],["marshmallow-rm","\u8AAD\u66F8\u733F\u30DE\u30B7\u30E5\u30DE\u30ED\u5168\u8CEA\u554F\u56DE\u7B54"],["miyamonz","miyamonz"],["mrsekut-p","mrsekut"],["kidaaam-92022284","kidooom"],["c4j","Code_for_Japan"],["suto3","suto3"],["blu3mo","blu3mo"],["nwtgck","nwtgck"],["juneboku","juneboku"],["jigsaw","jgs"],["sno2wman","SnO2WMaN"],["sushitecture","hashrock"],["unnamedcamp","\u77E5\u3092\u55B6\u3080"],["unnamed-project","unnamed-project"],["issac-37765679","cFQ2f7LRuLYP"],["blu3mo","blu3mo"],["yosider","yosider"],["Mijinko","Mijinko_SD"],["Mijinko-other","Mijinko_SD"],["customize","\u307F\u3093\u306A\u306E\u30AB\u30B9\u30BF\u30DE\u30A4\u30BA"],["scrapboxlab","\u5165\u4F1A\u624B\u7D9A\u304D"],["scrasobox","Scrapbox\u3068\u3042\u305D\u3076"],["programming-notes","\u53C2\u52A0\u3059\u308B"],["guiland","\u6982\u8981\u3068\u53C2\u52A0\u65B9\u6CD5"]].map(([e,t])=>[e,https://scrapbox.io/api/pages/${e}/${t}/icon`])),"NDLSH-SB":"\u{1F4DA}","scrapbox-drinkup":"https://scrapbox.io/assets/img/page-icon/scrapbox_beaver.png","nota-techconf":"https://i.gyazo.com/727f42bbd9e2534d99d70e6ea90705b3.jpg","plurality-japanese":"\u2FFB"},enableSelfProjectOnStart:!0});