icon-suggestion-beta
mizdra.icondone.iconインターネットの神様.icon
ソースコード
code:script.js
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==object||typeof i==function)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=cl,!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>ie).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,default,{value:n,enumerable:!0}):a,n)),l,u,d,f,p,m,h,g,_,v,y,b,x={},S=[],C=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|inech|zoo|^ord|itera/i,w=Array.isArray;function T(e,t){for(var n in t)en=tn;return e}function E(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function D(e,t,n){var r,i,a,o={};for(a in t)a==key?r=ta:a==ref?i=ta:oa=ta;if(arguments.length>2&&(o.children=arguments.length>3?l.call(arguments,2):n),typeof e==function&&e.defaultProps!=null)for(a in e.defaultProps)oa===void 0&&(oa=e.defaultPropsa);return O(e,o,r,i,null)}function O(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++d,__i:-1,__u:0};return i==null&&u.vnode!=null&&u.vnode(a),a}function k(e){return e.children}function A(e,t){this.props=e,this.context=t}function j(e,t){if(t==null)return e.__?j(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__kt)!=null&&n.__e!=null)return n.__e;return typeof e.type==function?j(e):null}function M(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=T({},t);a.__v=t.__v+1,u.vnode&&u.vnode(a),I(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?n:null,r,n??j(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__ka.__i=a,se(r,a,i),t.__e=t.__=null,a.__e!=n&&ee(a)}}function ee(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ee(e)}function N(e){(!e.__d&&(e.__d=!0)&&f.push(e)&&!P.__r++||p!=u.debounceRendering)&&((p=u.debounceRendering)||m)(P)}function P(){for(var e,t=1;f.length;)f.length>t&&f.sort(h),e=f.shift(),t=f.length,M(e);P.__r=0}function te(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||S,y=t.length;for(c=ne(n,t,v,c,y),d=0;d<y;d++)(p=n.__kd)!=null&&(f=p.__i!=-1&&vp.__i||x,p.__i=d,g=I(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&R(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?c=re(p,c,e,_):typeof p.type==function&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function ne(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=ta)!=null&&typeof o!=boolean&&typeof o!=function?(typeof o==string||typeof o==number||typeof o==bigint||o.constructor==String?o=e.__ka=O(null,o,null,null,null):w(o)?o=e.__ka=O(k,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__ka=O(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__ka=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=ie(o,n,c,d))!=-1&&(d--,(s=nl)&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=function&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__ka=null;if(d)for(a=0;a<u;a++)(s=na)!=null&&!(2&s.__u)&&(s.__e==r&&(r=j(s)),ue(s,s));return r}function re(e,t,n,r){var i,a;if(typeof e.type==function){for(i=e.__k,a=0;i&&a<i.length;a++)ia&&(ia.__=e,t=re(ia,t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=j(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function ie(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=tn,u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>(u?1:0)){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=to=i>=0?i--:a++)!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ae(e,t,n){t0==-?e.setProperty(t,n??):et=n==null?:typeof n!=number||C.test(t)?n:n+px}function F(e,t,n,r,i){var a,o;n:if(t==style)if(typeof n==string)e.style.cssText=n;else{if(typeof r==string&&(e.style.cssText=r=),r)for(t in r)n&&t in n||ae(e.style,t,);if(n)for(t in n)r&&nt==rt||ae(e.style,t,nt)}else if(t0==o&&t1==n)a=t!=(t=t.replace(g,$1)),o=t.toLowerCase(),t=o in e||t==onFocusOut||t==onFocusIn?o.slice(2):t.slice(2),e.l||={},e.lt+a=n,n?r?n.u=r.u:(n.u=_,e.addEventListener(t,a?y:v,a)):e.removeEventListener(t,a?y:v,a);else{if(i==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=n??;break n}catch{}typeof n==function||(n==null||!1===n&&t4!=-?e.removeAttribute(t):e.setAttribute(t,t==popover&&n==1?:n))}}function oe(e){return function(t){if(this.l){var n=this.lt.type+e;if(t.t==null)t.t=_++;else if(t.t<n.u)return;return n(u.event?u.event(t):t)}}}function I(e,t,n,r,i,a,o,s,c,l){var d,f,p,m,h,g,_,v,y,b,x,C,D,O,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=s=t.__e=n.__e),(d=u.__b)&&d(t);n:if(typeof M==function)try{if(v=t.props,y=prototypein M&&M.prototype.render,b=(d=M.contextType)&&rd.__c,x=d?b?b.props.value:d.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new M(v,x):(t.__c=f=new A(v,x),f.constructor=M,f.render=de),b&&b.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=T({},f.__s)),T(f.__s,M.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&M.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__e=!1,C=u.__r,D=0,y)f.state=f.__s,f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),S.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++D<25);f.state=f.__s,f.getChildContext!=null&&(r=T(T({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),O=d!=null&&d.type===k&&d.key==null?ce(d.props.children):d,s=te(e,w(O)?O:O,t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;aa.indexOf(s)=null,t.__e=s}else{for(j=a.length;j--;)E(aj);L(t)}else t.__e=n.__e,t.__k=n.__k,e.then||L(t);u.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=le(n.__e,t,n,r,i,a,o,c,l);return(d=u.diffed)&&d(t),128&t.__u?void 0:s}function L(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(L))}function se(e,t,n){for(var r=0;r<n.length;r++)R(nr,n++r,n++r);u.__c&&u.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){u.__e(e,t.__v)}})}function ce(e){return typeof e!=object||!e||e.__b>0?e:w(e)?e.map(ce):T({},e)}function le(e,t,n,r,i,a,o,s,c){var d,f,p,m,h,g,_,v=n.props||x,y=t.props,b=t.type;if(b==svg?i=http://www.w3.org/2000/svg:b==math?i=http://www.w3.org/1998/Math/MathML:i||=http://www.w3.org/1999/xhtml,a!=null){for(d=0;d<a.length;d++)if((h=ad)&&setAttributein h==!!b&&(b?h.localName==b:h.nodeType==3)){e=h,ad=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&=(u.__m&&u.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=l.call(e.childNodes),!s&&a!=null)for(v={},d=0;d<e.attributes.length;d++)v[(h=e.attributesd).name]=h.value;for(d in v)h=vd,d==dangerouslySetInnerHTML?p=h:d==children||d in y||d==value&&defaultValuein y||d==checked&&defaultCheckedin y||F(e,d,null,h,i);for(d in y)h=yd,d==children?m=h:d==dangerouslySetInnerHTML?f=h:d==value?g=h:d==checked?_=h:s&&typeof h!=function||vd===h||F(e,d,h,vd,i);if(f)s||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=),te(t.type==template?e.content:e,w(m)?m:m,t,n,r,b==foreignObject?http://www.w3.org/1999/xhtml:i,a,o,a?a0:n.__k&&j(n,0),s,c),a!=null)for(d=a.length;d--;)E(ad);s||(d=value,b==progress&&g==null?e.removeAttribute(value):g!=null&&(g!==ed||b==progress&&!g||b==option&&g!=vd)&&F(e,d,g,vd,i),d=checked,_!=null&&_!=ed&&F(e,d,_,vd,i))}return e}function R(e,t,n){try{if(typeof e==function){var r=typeof e.__u==function;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){u.__e(e,n)}}function ue(e,t,n){var r,i;if(u.unmount&&u.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||R(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){u.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)ri&&ue(ri,t,n||typeof e.type!=function);n||E(e.__e),e.__c=e.__=e.__e=void 0}function de(e,t,n){return this.constructor(e,n)}function fe(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),u.__&&u.__(e,t),i=(r=typeof n==function)?null:n&&n.__k||t.__k,a=[],o=[],I(t,e=(!r&&n||t).__k=D(k,null,e),i||x,x,t.namespaceURI,!r&&n?n:i?null:t.firstChild?l.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),se(a,e,o)}function pe(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})t.__c=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,N(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=__cC+ b++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}l=S.slice,u={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},d=0,A.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=T({},this.state);typeof e==function&&(e=e(T({},n),this.props)),e&&T(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),N(this))},A.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),N(this))},A.prototype.render=k,f=[],m=typeof Promise==function?Promise.prototype.then.bind(Promise.resolve()):setTimeout,h=function(e,t){return e.__v.__b-t.__v.__b},P.__r=0,g=/(PointerCapture)$|Capture$/i,_=0,v=oe(!1),y=oe(!0),b=0;var z,B,V,me,H=0,he=[],U=u,ge=U.__b,_e=U.__r,ve=U.diffed,ye=U.__c,be=U.unmount,xe=U.__;function W(e,t){U.__h&&U.__h(B,e,H||t),H=0;var n=B.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__e}function G(e){return H=1,Se(Ae,e)}function Se(e,t,n){var r=W(z++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ae(void 0,t),function(e){var t=r.__N?r.__N0:r.__0,n=r.t(t,e);t!==n&&(r.__N=[n,r.__1],r.__c.setState({}))}],r.__c=B,!B.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__0;e.__=e.__N,e.__N=void 0,t!==e.__0&&(o=!0)}}),a&&a.call(this,e,t,n)||o};B.__f=!0;var a=B.shouldComponentUpdate,o=B.componentWillUpdate;B.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},B.shouldComponentUpdate=i}return r.__N||r.__}function K(e,t){var n=W(z++,3);!U.__s&&ke(n.__H,t)&&(n.__=e,n.u=t,B.__H.__h.push(n))}function Ce(e){return H=5,q(function(){return{current:e}},[])}function q(e,t){var n=W(z++,7);return ke(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function J(e,t){return H=8,q(function(){return e},t)}function we(e){var t=B.contexte.__c,n=W(z++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(B)),t.props.value):e.__}function Te(){for(var e;e=he.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Y),t.__h.some(Oe),t.__h=[]}catch(n){t.__h=[],U.__e(n,e.__v)}}}U.__b=function(e){B=null,ge&&ge(e)},U.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xe&&xe(e,t)},U.__r=function(e){_e&&_e(e),z=0;var t=(B=e.__c).__H;t&&(V===B?(t.__h=[],B.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Y),t.__h.some(Oe),t.__h=[],z=0)),V=B},U.diffed=function(e){ve&&ve(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(he.push(t)!==1&&me===U.requestAnimationFrame||((me=U.requestAnimationFrame)||De)(Te)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),V=B=null},U.__c=function(e,t){t.some(function(e){try{e.__h.some(Y),e.__h=e.__h.filter(function(e){return!e.__||Oe(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],U.__e(n,e.__v)}}),ye&&ye(e,t)},U.unmount=function(e){be&&be(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Y(e)}catch(e){t=e}}),n.__H=void 0,t&&U.__e(t,n.__v))};var Ee=typeof requestAnimationFrame==function;function De(e){var t,n=function(){clearTimeout(r),Ee&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ee&&(t=requestAnimationFrame(n))}function Y(e){var t=B,n=e.__c;typeof n==function&&(e.__c=void 0,n()),B=t}function Oe(e){var t=B;e.__c=e.__(),B=t}function ke(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==en})}function Ae(e,t){return typeof t==function?t(e):t}function je(e,t){let n=Ce(t);K(()=>{n.current=t},t),K(()=>{let t=e=>n.current.call(document,e);return document.addEventListener(e,t,{capture:!0}),()=>document.removeEventListener(e,t,{capture:!0})},e)}var X=class{projectName;pageTitle;constructor(e,t){this.projectName=e,this.pageTitle=t}getShortPagePath(e){return this.projectName===e?this.pageTitle:/${this.projectName}/${this.pageTitle}}get fullPagePath(){return/${this.projectName}/${this.pageTitle}}get imgAlt(){return this.pageTitle}get imgTitle(){return this.pageTitle}get imgSrc(){return/api/pages/${this.projectName}/${encodeURIComponent(this.pageTitle)}/icon}getNotation(e){return[${this.getShortPagePath(e)}.icon]}equals(e){return this.fullPagePath===e.fullPagePath}};function Me(e,t){let n=t.querySelector(img.icon);if(!n)throw Error(.icon.link の子要素 img.icon がありません。iconLinkElement.innnerHTML: ${t.innerHTML});return new X(t.pathname.startsWith(/${e}/)?e:t.pathname.slice(1,t.pathname.indexOf(/,1)),n.alt)}function Ne(e,t){for(let n of t)if(!n.equals(e)&&n.pageTitle===e.pageTitle)return!0;return!1}function Pe(e){let t=e.querySelector(.line.cursor-line);if(!t)return;let n=t.id.slice(1);return{element:t,index:scrapbox.Page.lines.findIndex(e=>e.id===n)}}function Fe(e,t){return Array.from(t.querySelectorAll(a.link.icon)).map(t=>Me(e,t))}function Ie(e){return{styleTop:+e.style.top.slice(0,-2),styleLeft:+e.style.left.slice(0,-2)}}function Le(e,t){e.focus(),e.value=t;let n=document.createEvent(UIEvent);n.initEvent(input,!0,!1),e.dispatchEvent(n)}function Re(){let e=document.querySelector(.editor);if(e)return e;throw Error(.editor が存在しません)}const ze=pe({scrapbox:window.scrapbox,editor:Re()});function Be(){let{scrapbox:e,editor:t}=we(ze),n,r=G(e.Layout),i,a=G(e.Project.name);return K(()=>{let t=()=>r(e.Layout),n=()=>a(e.Project.name);return e.addListener(layout:changed,t),e.addListener(project:changed,n),()=>{e.removeListener(layout:changed,t),e.removeListener(project:changed,n)}},e),{layout:n,projectName:i,editor:t,cursor:q(()=>{let e=t.querySelector(.cursor);if(!e)throw Error(.cursor が存在しません);return e},t),textInput:q(()=>{let e=t.querySelector(#text-input);if(!e)throw Error(#text-input が存在しません);return e},t)}}function Ve(e,t){let n=[],r=new Set;for(let i of e){let e=t(i);r.has(e)||(r.add(e),n.push(i))}return n}function Z(e){return Ve(e,e=>e.fullPagePath)}function He(e){return e.isComposing||e.key===Enter&&e.which===229}function Ue(e){lett,n=G({width:void 0,height:void 0});return K(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=e0;t&&n({width:t.contentRect.width,height:t.contentRect.height})});return r.observe(t),()=>r.disconnect()},e),t}function We(e){return{top:e.styleTop}}function Ge(e,t){return{left:e.styleLeft,...t?{borderTopColor:#555}:{}}}function Ke(e,t,n,r){let i=n.styleLeft/e*100,a=20/t*100,o=100-a;return{left:n.styleLeft,transform:translateX(-${Math.max(a,Math.min(i,o))}%),...r?{color:#eee,fontSize:11px,display:inline-block,padding:0 5px,cursor:not-allowed,backgroundColor:#555}:{}}}var qe=0;Array.isArray;function Q(e,t,n,r,i,a){t||={};var o,s,c=t;if(refin c)for(s in c={},t)s==ref?o=ts:cs=ts;var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--qe,__i:-1,__u:0,__source:i,__self:a};if(typeof e==function&&(o=e.defaultProps))for(s in o)cs===void 0&&(cs=os);return u.vnode&&u.vnode(l),l}function Je({cursorPosition:e,icons:t,onSelect:n}){let{editor:r}=Be(),i=Ce(null),{width:a=0}=Ue(i),o=t.length===0,s,c=G(t.length===0?null:0),l,u=G(t),{width:d=0}=Ue(Ce(r));l!==t&&(u(t),c(o?null:0)),je(keydown,e=>{if(!open||He(e)||o||s===null)return;let r=e.key===Tab&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,i=e.key===Tab&&!e.ctrlKey&&e.shiftKey&&!e.altKey,a=e.key===Enter&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;(r||i||a)&&(e.preventDefault(),e.stopPropagation()),r&&c(e=>e===null?0:(e+1)%t.length),i&&c(e=>e===null?0:(e-1+t.length)%t.length),a&&n?.(ts,s)});let f=We(e),p=Ge(e,o),m=Ke(d,a,e,o),h=t.map((e,n)=>{let r=Ne(e,t)?${e.pageTitle} (${e.projectName}):e.pageTitle;return Q(Ye,{selected:s===n,children:Q(span,{children:[Q(img,{alt:e.imgAlt,title:e.imgTitle,style:width: 1.3em; height: 1.3em; object-fit: contain;,src:e.imgSrc}), ,Q(span,{"data-testid":suggested-icon-label,children:r})]})},e.fullPagePath)});return Q(div,{className:popup-menu icon-suggestion-popup-menu,style:f,"data-testid":popup-menu,children:[Q(div,{ref:i,className:button-container,style:m,"data-testid":button-container,children:t.length===0?キーワードにマッチするアイコンがありません:h}),Q(div,{className:triangle,style:p})]})}function Ye({children:e,selected:t}){return Q(div,{className:t?button selected:button,children:e})}function Xe({query:e,cursorPosition:t,matcher:n,onSelect:r,onBlur:i}){let a=q(()=>n(e),n,e);return Q(div,{children:Q(Je,{icons:a,cursorPosition:t,onSelect:J((e,t)=>{r?.(at)},a,r)})})}const Ze=({isExitIconSuggestionKey:e,isLaunchIconSuggestionKey:t,matcher:n,presetIcons:r})=>{let{textInput:i,cursor:a,editor:o,layout:s,projectName:c}=Be(),l,u=G(!1),d,f=G([]),p,m=G({styleTop:0,styleLeft:0}),h,g=G(null),_,v=G(null);console.log({open:l,cursorLine:_,query:h}),K(()=>{let e=()=>{if(!l||!_||!h)return;let e=_.element.querySelectorAll(.char-index),t=Array.from(e).find(e=>{let t=+e.dataset.charIndex,n=e.dataset.char;return t>=h.start&&n===]});if(t){let e=+t.dataset.charIndex;g({start:h.start,end:e,text:scrapbox.Page.lines_.index.text.slice(h.start,e)})}else u(!1)};return scrapbox.addListener(lines:changed,e),()=>{scrapbox.removeListener(lines:changed,e)}},l,h,_);let y=J(e=>{if(console.log(open || layout !== 'page',l||s!==page),l||s!==page)return;let t=Pe(o);if(console.log(!cursorLine,!t),!t)return;e.preventDefault(),e.stopPropagation(),v(t);let n=t.element.querySelectorAll(.char-index),r=a.getBoundingClientRect();console.log({cursorRectLeft:r.left});let d=Array.from(n).find(e=>{let t=e.getBoundingClientRect();return console.log({charIndexRectLeft:t.left}),r.left<=t.left}),p=d?+d.dataset.charIndex+1:n.length+1;g({start:p,end:p,text:}),Le(i,[),m(Ie(a)),f(Fe(c,o)),u(!0)},a,o,l,s,c,i);je(keydown,J(e=>{He(e)||t(e)&&y(e)},t,y));let b=J(()=>{u(!1),i.focus()},i),x=J(e=>{h&&(u(!1),scrapbox.Page.updateLine($e(scrapbox.Page.lines_.index.text,h.start,h.end,e.getNotation(c).slice(1,-1)),_.index),i.focus())},c,i,_,h);return!l||s!==page?null:Q(k,{children:[Q(style,{children:.suggest-popup-menu { display: none !important; }}),Q(Qe,{isExitIconSuggestionKey:e,presetIcons:r,matcher:n,embeddedIcons:d,cursorPosition:p,query:h?.text??,onClose:b,onSelect:x})]})};function Qe({query:e,isExitIconSuggestionKey:t,presetIcons:n,matcher:r,embeddedIcons:i,cursorPosition:a,onClose:o,onSelect:s}){let c=J(e=>r({query:e,composedIcons:Z(...i,...n),presetIcons:n,embeddedIcons:i}),i,r,n),l=J(e=>{e.preventDefault(),e.stopPropagation(),o()},o);return je(keydown,J(e=>{He(e)||t(e)&&l(e)},t,l)),Q(Xe,{query:e,cursorPosition:a,matcher:c,onSelect:s,onBlur:o})}function $e(e,t,n,r){return e.slice(0,t)+r+e.slice(n)}var et=c(o(((e,t)=>{let n=2147483648,r=n,0,0,0,i=e=>e>=65&&e<=90,a=e=>e>=97&&e<=122,o=e=>i(e)?e+32:e,s=e=>a(e)?e-32:e;t.exports=function(e){let t=[],i=0,a=0,c=n;for(let e=0;e<65536;e++)te=0;for(let n of u(e))n===32?i|=c:(tn|=c,ts(n)|=c,to(n)|=c,c>>>=1);a=c;function l(e=r,n=){let a=e0,o=e1,s=e2,l=e3;for(let e of u(n))c=te,l=l&i|(l&c)>>>1|s>>>1|s,s=s&i|(s&c)>>>1|o>>>1|o,o=o&i|(o&c)>>>1|a>>>1|a,a=a&i|(a&c)>>>1,o|=a>>>1,s|=o>>>1,l|=s>>>1;returna,o,s,l}function u(e){let t=[];for(let n of e.split()){let e=n.charCodeAt(0);t.push(e)}return t}function d(e,t=0){let n=l(r,e);return t>=r.length&&(t=r.length-1),(nt&a)!==0}return d.source=e,d}}))(),1);function tt({query:e,composedIcons:t}){let n=Math.min(Math.floor(e.length/3),3),r=(0,et.default)( ${e} ),i=[];for(let e=0;e<=n;e++)for(let n of t)r(n.pageTitle,e)&&i.push(n);return Z(i)}function nt({query:e,composedIcons:t}){return t.filter(t=>t.pageTitle.toLowerCase().startsWith(e.toLowerCase()))}function rt({query:e,composedIcons:t}){return t.filter(t=>t.pageTitle.toLowerCase().includes(e.toLowerCase()))}function it(e){return Z(...nt(e),...rt(e),...tt(e))}const at=e=>e.key===l&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey,ot=e=>e.key===Escape&&!e.ctrlKey&&!e.shiftKey&&!e.altKey;async function $(e){if(e instanceof X)returne;if(Array.isArray(e)){let t=e.map($);return(await Promise.all(t)).flat()}if(e instanceof Promise)return $(await e);let t=(await e()).map($);return(await Promise.all(t)).flat()}async function st(e){return(await Promise.all(e.map($))).flat()}async function ct(e){return{isLaunchIconSuggestionKey:e?.isLaunchIconSuggestionKey??at,isExitIconSuggestionKey:e?.isExitIconSuggestionKey??ot,presetIcons:await st(e?.presetIcons??[]),matcher:e?.matcher??it}}async function lt(e){let t=document.createElement(div);Re().appendChild(t),fe(Q(Ze,{...await ct(e)}),t)}async function ut(e){let{origin:t}=window.location,n,r=await Promise.all([fetch(${t}/api/projects/${e}).then(async e=>e.json()),fetch(${t}/api/pages/${e}/member).then(async e=>e.json())]),i=r.relatedPages;if(!n.users||!i)throw Error(You are not a member of \`${e}\` project.);return n.users.map(e=>e.name).filter(e=>{let t=i.links1hop.find(t=>t.title===e);return t&&t.image!==null}).map(t=>new X(e,t))}async function dt(e,t){let{origin:n}=window.location,r=await fetch(${n}/api/pages/${e}/${encodeURIComponent(t)}).then(async e=>e.json());if(!r.relatedPages)throw Error(You are not a member of \`${e}\` project.);return r.relatedPages.links1hop.filter(e=>e.image!==null).map(t=>new X(e,t.title))}export{X as Icon,ut as fetchMemberPageIcons,dt as fetchRelatedPageIconsByHashTag,nt as forwardMatcher,it as forwardPartialFuzzyMatcher,tt as fuzzyMatcher,rt as partialMatcher,lt as registerIconSuggestion,Z as uniqueIcons};