pi-weave 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,12 +18,12 @@
18
18
  * sigma@3.0.3 — MIT
19
19
  */
20
20
 
21
- "use strict";(()=>{var ep=Object.create;var ts=Object.defineProperty;var tp=Object.getOwnPropertyDescriptor;var np=Object.getOwnPropertyNames;var rp=Object.getPrototypeOf,ip=Object.prototype.hasOwnProperty;var ns=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var op=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of np(e))!ip.call(t,i)&&i!==n&&ts(t,i,{get:()=>e[i],enumerable:!(r=tp(e,i))||r.enumerable});return t};var dn=(t,e,n)=>(n=t!=null?ep(rp(t)):{},op(e||!t||!t.__esModule?ts(n,"default",{value:t,enumerable:!0}):n,t));var Sr=ns((dk,mo)=>{"use strict";var Vt=typeof Reflect=="object"?Reflect:null,au=Vt&&typeof Vt.apply=="function"?Vt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},kr;Vt&&typeof Vt.ownKeys=="function"?kr=Vt.ownKeys:Object.getOwnPropertySymbols?kr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:kr=function(e){return Object.getOwnPropertyNames(e)};function Rg(t){console&&console.warn&&console.warn(t)}var lu=Number.isNaN||function(e){return e!==e};function K(){K.init.call(this)}mo.exports=K;mo.exports.once=Dg;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var su=10;function Er(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return su},set:function(t){if(typeof t!="number"||t<0||lu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");su=t}});K.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};K.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||lu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function uu(t){return t._maxListeners===void 0?K.defaultMaxListeners:t._maxListeners}K.prototype.getMaxListeners=function(){return uu(this)};K.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")au(l,this,n);else for(var u=l.length,c=pu(l,u),r=0;r<u;++r)au(c[r],this,n);return!0};function cu(t,e,n,r){var i,o,a;if(Er(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=uu(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,Rg(s)}return t}K.prototype.addListener=function(e,n){return cu(this,e,n,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(e,n){return cu(this,e,n,!0)};function Cg(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function du(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=Cg.bind(r);return i.listener=n,r.wrapFn=i,i}K.prototype.once=function(e,n){return Er(n),this.on(e,du(this,e,n)),this};K.prototype.prependOnceListener=function(e,n){return Er(n),this.prependListener(e,du(this,e,n)),this};K.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Er(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():Lg(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};K.prototype.off=K.prototype.removeListener;K.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function hu(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Ng(i):pu(i,i.length)}K.prototype.listeners=function(e){return hu(this,e,!0)};K.prototype.rawListeners=function(e){return hu(this,e,!1)};K.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):fu.call(t,e)};K.prototype.listenerCount=fu;function fu(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}K.prototype.eventNames=function(){return this._eventsCount>0?kr(this._events):[]};function pu(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function Lg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Ng(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Dg(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}gu(t,e,o,{once:!0}),e!=="error"&&Pg(t,i,{once:!0})})}function Pg(t,e,n){typeof t.on=="function"&&gu(t,"error",e,n)}function gu(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var vo=ns((pk,vu)=>{"use strict";vu.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var ar,W,ss,ap,dt,rs,ls,us,Ti,er,hn,cs,Ci,Ai,Ri,sp,rr={},ir=[],lp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,sr=Array.isArray;function Je(t,e){for(var n in e)t[n]=e[n];return t}function Li(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function up(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?ar.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return tr(t,a,r,i,null)}function tr(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ss,__i:-1,__u:0};return i==null&&W.vnode!=null&&W.vnode(o),o}function Oe(t){return t.children}function nr(t,e){this.props=t,this.context=e}function wt(t,e){if(e==null)return t.__?wt(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?wt(t):null}function cp(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=Je({},e);o.__v=e.__v+1,W.vnode&&W.vnode(o),Ni(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??wt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,gs(r,o,i),e.__e=e.__=null,o.__e!=n&&ds(o)}}function ds(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),ds(t)}function is(t){(!t.__d&&(t.__d=!0)&&dt.push(t)&&!or.__r++||rs!=W.debounceRendering)&&((rs=W.debounceRendering)||ls)(or)}function or(){try{for(var t,e=1;dt.length;)dt.length>e&&dt.sort(us),t=dt.shift(),e=dt.length,cp(t)}finally{dt.length=or.__r=0}}function hs(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,p,m,v,w=r&&r.__k||ir,y=e.length;for(l=dp(n,e,w,l,y),h=0;h<y;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&w[f.__i]||rr,f.__i=h,v=Ni(t,f,d,i,o,a,s,l,u,c),p=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Di(d.ref,null,f),c.push(f.ref,f.__c||p,f)),m==null&&p!=null&&(m=p),4&f.__u?(l=fs(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:p&&(l=p.nextSibling),f.__u&=-7);return n.__e=m,l}function dp(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=tr(null,a,null,null,null):sr(a)?a=t.__k[o]=tr(Oe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=tr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=hp(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=wt(s)),vs(s,s));return r}function fs(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=fs(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=wt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function hp(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function os(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||lp.test(e)?n:n+"px"}function Jn(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||os(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||os(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(cs,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[hn]=r[hn]:(n[hn]=Ci,t.addEventListener(e,o?Ri:Ai,o)):t.removeEventListener(e,o?Ri:Ai,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function as(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[er]==null)e[er]=Ci++;else if(e[er]<n[hn])return;return n(W.event?W.event(e):e)}}}function Ni(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,p,m,v,w,y,_,k,N,R,P,z,O,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=W.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(y=e.props,_=G.prototype&&G.prototype.render,k=(c=G.contextType)&&r[c.__c],N=c?k?k.props.value:c.__:r,n.__c?w=(d=e.__c=n.__c).__=d.__E:(_?e.__c=d=new G(y,N):(e.__c=d=new nr(y,N),d.constructor=G,d.render=pp),k&&k.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),_&&d.__s==null&&(d.__s=d.state),_&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Je({},d.__s)),Je(d.__s,G.getDerivedStateFromProps(y,d.__s))),p=d.props,m=d.state,d.__v=e,f)_&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),_&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(_&&G.getDerivedStateFromProps==null&&y!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(y,N),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(y,d.__s,N)===!1){e.__v!=n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),ir.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=wt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(y,d.__s,N),_&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,v)})}if(d.context=N,d.props=y,d.__P=t,d.__e=!1,R=W.__r,P=0,_)d.state=d.__s,d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),ir.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++P<25);d.state=d.__s,d.getChildContext!=null&&(r=Je(Je({},r),d.getChildContext())),_&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(p,m)),z=c!=null&&c.type===Oe&&c.key==null?ms(c.props.children):c,s=hs(t,sr(z)?z:[z],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(O=o.length;O--;)Li(o[O])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||ps(e),W.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=fp(n.__e,e,n,r,i,o,a,l,u);return(c=W.diffed)&&c(e),128&e.__u?void 0:s}function ps(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(ps))}function gs(t,e,n){for(var r=0;r<n.length;r++)Di(n[r],n[++r],n[++r]);W.__c&&W.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){W.__e(o,i.__v)}})}function ms(t){return typeof t!="object"||t==null||t.__b>0?t:sr(t)?t.map(ms):t.constructor!==void 0?null:Je({},t)}function fp(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,p,m,v=n.props||rr,w=e.props,y=e.type;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!y&&(y?f.localName==y:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(y==null)return document.createTextNode(w);t=document.createElementNS(i,y,w.is&&w),s&&(W.__m&&W.__m(e,o),s=!1),o=null}if(y==null)v===w||s&&t.data==w||(t.data=w);else{if(o=y=="textarea"&&w.defaultValue!=null?null:o&&ar.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in w||u=="value"&&"defaultValue"in w||u=="checked"&&"defaultChecked"in w||Jn(t,u,null,f,i);for(u in w)f=w[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?p=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||Jn(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),hs(e.type=="template"?t.content:t,sr(d)?d:[d],e,n,r,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&wt(n,0),s,l),o!=null)for(u=o.length;u--;)Li(o[u]);s&&y!="textarea"||(u="value",y=="progress"&&p==null?t.removeAttribute("value"):p!=null&&(p!==t[u]||y=="progress"&&!p||y=="option"&&p!=v[u])&&Jn(t,u,p,v[u],i),u="checked",m!=null&&m!=t[u]&&Jn(t,u,m,v[u],i))}return t}function Di(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){W.__e(i,n)}}function vs(t,e,n){var r,i;if(W.unmount&&W.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Di(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){W.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&vs(r[i],e,n||typeof t.type!="function");n||Li(t.__e),t.__c=t.__=t.__e=void 0}function pp(t,e,n){return this.constructor(t,n)}function ys(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),W.__&&W.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],Ni(e,t=(!r&&n||e).__k=up(Oe,null,[t]),i||rr,rr,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?ar.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),gs(o,t,a),t.props.children=null}ar=ir.slice,W={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},ss=0,ap=function(t){return t!=null&&t.constructor===void 0},nr.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Je({},this.state),typeof t=="function"&&(t=t(Je({},n),this.props)),t&&Je(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),is(this))},nr.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),is(this))},nr.prototype.render=Oe,dt=[],ls=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,us=function(t,e){return t.__v.__b-e.__v.__b},or.__r=0,Ti=Math.random().toString(8),er="__d"+Ti,hn="__a"+Ti,cs=/(PointerCapture)$|Capture$/i,Ci=0,Ai=as(!1),Ri=as(!0),sp=0;var ws="weave-bootstrap";var Pi={cwd:""};function gp(t){return typeof t!="object"||t===null?!1:typeof t.cwd=="string"}function bs(t){if(t===null||t.trim()==="")return Pi;let e;try{e=JSON.parse(t)}catch{return Pi}return gp(e)?e:Pi}function xs(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return _s(this.cover(e,n),e,n,t)}function _s(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,p,m,v,w,y;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[w=v<<1|m]))return i[w]=a,t;if(f=+t._x.call(null,o.data),p=+t._y.call(null,o.data),e===f&&n===p)return a.next=o,i?i[w]=a:t._root=a,t;do i=i?i[w]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((w=v<<1|m)===(y=(p>=d)<<1|f>=h));return i[y]=o,i[w]=a,t}function ks(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)_s(this,a[n],s[n],t[n]);return this}function Es(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function Ss(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Ts(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function fe(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function As(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,p,m;for(f&&d.push(new fe(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);p=d.pop();)if(!(!(f=p.node)||(a=p.x0)>c||(s=p.y0)>h||(l=p.x1)<i||(u=p.y1)<o))if(f.length){var v=(a+l)/2,w=(s+u)/2;d.push(new fe(f[3],v,w,l,u),new fe(f[2],a,w,v,u),new fe(f[1],v,s,l,w),new fe(f[0],a,s,v,w)),(m=(e>=w)<<1|t>=v)&&(p=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=p)}else{var y=t-+this._x.call(null,f.data),_=e-+this._y.call(null,f.data),k=y*y+_*_;if(k<n){var N=Math.sqrt(n=k);i=t-N,o=e-N,c=t+N,h=e+N,r=f.data}}return r}function Rs(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,p,m,v,w;if(!n)return this;if(n.length)for(;;){if((p=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|p]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,w=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[w]=n:this._root=n),this):(this._root=o,this)}function Cs(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Ls(){return this._root}function Ns(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Ds(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new fe(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,c,s,l)),(i=r[2])&&e.push(new fe(i,o,c,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,c)),(i=r[0])&&e.push(new fe(i,o,a,u,c))}return this}function Ps(t){var e=[],n=[],r;for(this._root&&e.push(new fe(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,c,h)),(o=i[1])&&e.push(new fe(o,c,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,c,u)),(o=i[3])&&e.push(new fe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Is(t){return t[0]}function Gs(t){return arguments.length?(this._x=t,this):this._x}function Ms(t){return t[1]}function Fs(t){return arguments.length?(this._y=t,this):this._y}function bt(t,e,n){var r=new Ii(e??Is,n??Ms,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Ii(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Os(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var xe=bt.prototype=Ii.prototype;xe.copy=function(){var t=new Ii(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Os(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=Os(r));return t};xe.add=xs;xe.addAll=ks;xe.cover=Es;xe.data=Ss;xe.extent=Ts;xe.find=As;xe.remove=Rs;xe.removeAll=Cs;xe.root=Ls;xe.size=Ns;xe.visit=Ds;xe.visitAfter=Ps;xe.x=Gs;xe.y=Fs;function ae(t){return function(){return t}}function ze(t){return(t()-.5)*1e-6}function mp(t){return t.x+t.vx}function vp(t){return t.y+t.vy}function Gi(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ae(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,p,m,v,w=0;w<o;++w)for(h=bt(e,mp,vp).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,p=d.y+d.vy,h.visit(y);function y(_,k,N,R,P){var z=_.data,O=_.r,G=m+O;if(z){if(z.index>d.index){var U=f-z.x-z.vx,q=p-z.y-z.vy,ee=U*U+q*q;ee<G*G&&(U===0&&(U=ze(r),ee+=U*U),q===0&&(q=ze(r),ee+=q*q),ee=(G-(ee=Math.sqrt(ee)))/ee*i,d.vx+=(U*=ee)*(G=(O*=O)/(v+O)),d.vy+=(q*=ee)*G,z.vx-=U*(G=1-G),z.vy-=q*G)}return}return k>f+G||R<f-G||N>p+G||P<p-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:ae(+u),l(),a):t},a}function yp(t){return t.index}function zs(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Mi(t){var e=yp,n=h,r,i=ae(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var w=0,y=t.length;w<c;++w)for(var _=0,k,N,R,P,z,O,G;_<y;++_)k=t[_],N=k.source,R=k.target,P=R.x+R.vx-N.x-N.vx||ze(u),z=R.y+R.vy-N.y-N.vy||ze(u),O=Math.sqrt(P*P+z*z),O=(O-o[_])/O*v*r[_],P*=O,z*=O,R.vx-=P*(G=l[_]),R.vy-=z*G,N.vx+=P*(G=1-G),N.vy+=z*G}function f(){if(a){var v,w=a.length,y=t.length,_=new Map(a.map((N,R)=>[e(N,R,a),N])),k;for(v=0,s=new Array(w);v<y;++v)k=t[v],k.index=v,typeof k.source!="object"&&(k.source=zs(_,k.source)),typeof k.target!="object"&&(k.target=zs(_,k.target)),s[k.source.index]=(s[k.source.index]||0)+1,s[k.target.index]=(s[k.target.index]||0)+1;for(v=0,l=new Array(y);v<y;++v)k=t[v],l[v]=s[k.source.index]/(s[k.source.index]+s[k.target.index]);r=new Array(y),p(),o=new Array(y),m()}}function p(){if(a)for(var v=0,w=t.length;v<w;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,w=t.length;v<w;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,w){a=v,u=w,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ae(+v),p(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ae(+v),m(),d):i},d}var wp={value:()=>{}};function Us(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new lr(n)}function lr(t){this._=t}function bp(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}lr.prototype=Us.prototype={constructor:lr,on:function(t,e){var n=this._,r=bp(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=xp(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=$s(n[i],t.name,e);else if(e==null)for(i in n)n[i]=$s(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new lr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function xp(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function $s(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=wp,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Fi=Us;var Ut=0,pn=0,fn=0,Ws=1e3,ur,gn,cr=0,xt=0,dr=0,mn=typeof performance=="object"&&performance.now?performance:Date,Bs=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function $i(){return xt||(Bs(_p),xt=mn.now()+dr)}function _p(){xt=0}function Oi(){this._call=this._time=this._next=null}Oi.prototype=hr.prototype={constructor:Oi,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?$i():+n)+(e==null?0:+e),!this._next&&gn!==this&&(gn?gn._next=this:ur=this,gn=this),this._call=t,this._time=n,zi()},stop:function(){this._call&&(this._call=null,this._time=1/0,zi())}};function hr(t,e,n){var r=new Oi;return r.restart(t,e,n),r}function Ks(){$i(),++Ut;for(var t=ur,e;t;)(e=xt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ut}function Hs(){xt=(cr=mn.now())+dr,Ut=pn=0;try{Ks()}finally{Ut=0,Ep(),xt=0}}function kp(){var t=mn.now(),e=t-cr;e>Ws&&(dr-=e,cr=t)}function Ep(){for(var t,e=ur,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:ur=n);gn=t,zi(r)}function zi(t){if(!Ut){pn&&(pn=clearTimeout(pn));var e=t-xt;e>24?(t<1/0&&(pn=setTimeout(Hs,t-mn.now()-dr)),fn&&(fn=clearInterval(fn))):(fn||(cr=mn.now(),fn=setInterval(kp,Ws)),Ut=1,Bs(Hs))}}function Vs(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function js(t){return t.x}function qs(t){return t.y}var Sp=10,Tp=Math.PI*(3-Math.sqrt(5));function Ui(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=hr(h),u=Fi("tick","end"),c=Vs();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,w=t.length,y;m===void 0&&(m=1);for(var _=0;_<m;++_)for(n+=(o-n)*i,s.forEach(function(k){k(n)}),v=0;v<w;++v)y=t[v],y.fx==null?y.x+=y.vx*=a:(y.x=y.fx,y.vx=0),y.fy==null?y.y+=y.vy*=a:(y.y=y.fy,y.vy=0);return e}function f(){for(var m=0,v=t.length,w;m<v;++m){if(w=t[m],w.index=m,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var y=Sp*Math.sqrt(.5+m),_=m*Tp;w.x=y*Math.cos(_),w.y=y*Math.sin(_)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function p(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(p),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(p),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,p(v)),e):s.get(m)},find:function(m,v,w){var y=0,_=t.length,k,N,R,P,z;for(w==null?w=1/0:w*=w,y=0;y<_;++y)P=t[y],k=m-P.x,N=v-P.y,R=k*k+N*N,R<w&&(z=P,w=R);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function Hi(){var t,e,n,r,i=ae(-30),o,a=1,s=1/0,l=.81;function u(f){var p,m=t.length,v=bt(t,js,qs).visitAfter(h);for(r=f,p=0;p<m;++p)e=t[p],v.visit(d)}function c(){if(t){var f,p=t.length,m;for(o=new Array(p),f=0;f<p;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var p=0,m,v,w=0,y,_,k;if(f.length){for(y=_=k=0;k<4;++k)(m=f[k])&&(v=Math.abs(m.value))&&(p+=m.value,w+=v,y+=v*m.x,_+=v*m.y);f.x=y/w,f.y=_/w}else{m=f,m.x=m.data.x,m.y=m.data.y;do p+=o[m.data.index];while(m=m.next)}f.value=p}function d(f,p,m,v){if(!f.value)return!0;var w=f.x-e.x,y=f.y-e.y,_=v-p,k=w*w+y*y;if(_*_/l<k)return k<s&&(w===0&&(w=ze(n),k+=w*w),y===0&&(y=ze(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)),e.vx+=w*f.value*r/k,e.vy+=y*f.value*r/k),!0;if(f.length||k>=s)return;(f.data!==e||f.next)&&(w===0&&(w=ze(n),k+=w*w),y===0&&(y=ze(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)));do f.data!==e&&(_=o[f.data.index]*r/k,e.vx+=w*_,e.vy+=y*_);while(f=f.next)}return u.initialize=function(f,p){t=f,n=p,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ae(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function Wi(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}function Bi(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}var Ap=9,fr=6,pr=18,Rp=32,Zs=9,gr=Ap+Zs;function Ki(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Rp));return fr+(pr-fr)*n}function Vi(t){return t+Zs}var Cp=300,Qs=1,Ys=.001,ve={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},vn={...ve};function ji(t){Object.assign(ve,t)}function Xs(t){return t==="contains"||t==="anchored-at"}function Lp(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Np(t){let e=[],n=new Set;for(let o of t.nodes)n.has(o.id)||(n.add(o.id),e.push(o.id));let r=[],i=new Set;for(let o of t.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:e,edges:r}}function qi(t){let e=Mi(t.links).id(n=>n.id).distance(n=>Xs(n.kind)?ve.containsRest:ve.relationDistance).strength(n=>Xs(n.kind)?ve.containsStrength:ve.relationStrength).iterations(2);return Ui(t.nodes).randomSource(Lp(t.seed??Qs)).force("charge",Hi().strength(ve.charge).distanceMax(ve.chargeMax)).force("link",e).force("collide",Gi(n=>n.r??gr).strength(1)).force("x",Wi(0).strength(ve.center)).force("y",Bi(0).strength(ve.center)).stop()}function Dp(t,e,n){let r=qi({nodes:t,links:e.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(Ys).alphaDecay(n.ticks>0?1-Math.pow(Ys,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function Js(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Cp)),{ids:r,edges:i}=Np(t),o=r.map(l=>{let u=e.initial?.get(l),c={id:l,vx:0,vy:0};return u!==void 0&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(c.x=u.x,c.y=u.y,e.pinWarm===!0&&(c.fx=u.x,c.fy=u.y)),c}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=Vi(Ki(a.get(l.id)??0));o.length>1&&Dp(o,i,{ticks:n,seed:e.seed??Qs,warm:e.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}var Pp="sliders";function el(t){for(let e of t.replace(/^\?/,"").split("&")){let n=e.indexOf("=");if((n===-1?e:e.slice(0,n))!==Pp)continue;let i=n===-1?"":e.slice(n+1).toLowerCase();return i!=="0"&&i!=="false"}return!1}var mr=[{key:"containsStrength",label:"contains strength",hint:"how hard a parent holds its children — group cohesion",min:0,max:1,step:.01},{key:"containsRest",label:"contains rest",hint:"how far children sit from their parent — rosette radius",min:10,max:300,step:5},{key:"relationStrength",label:"relation strength",hint:"pull of links-to / mentions across groups",min:0,max:1,step:.01},{key:"relationDistance",label:"relation distance",hint:"how long those cross-group springs are",min:20,max:600,step:10},{key:"charge",label:"charge",hint:"node-to-node repulsion — more negative pushes harder",min:-1200,max:0,step:10},{key:"chargeMax",label:"charge range",hint:"distance past which repulsion stops — caps overall spread",min:100,max:4e3,step:50},{key:"center",label:"centre gravity",hint:"pull toward the origin — too much makes one blob",min:0,max:.3,step:.005}],tl={containsRest:90,containsStrength:.02,relationDistance:170,relationStrength:.05,charge:-50,chargeMax:1/0,center:.09};function nl(t,e){let n=t[e.key];return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):e.max}function rl(t,e){let n=Number.parseFloat(e);return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):vn[t.key]}function il(t){return Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Yi(t){let e=n=>` ${n}: ${Number.isFinite(t[n])?t[n]:"Infinity"},`;return["export const FORCES: ForceConstants = {",...mr.map(n=>e(n.key)),"};"].join(`
22
- `)}function ol(t){return mr.every(e=>Object.is(t[e.key],vn[e.key]))}var al="pi-weave.graph.groupColors.v1";function sl(t){try{return t.getItem(al)!=="off"}catch{return!0}}function ll(t,e){try{t.setItem(al,e?"on":"off")}catch{}}var Ht,ne,Xi,ul,yn=0,vl=[],ie=W,cl=ie.__b,dl=ie.__r,hl=ie.diffed,fl=ie.__c,pl=ie.unmount,gl=ie.__;function yr(t,e){ie.__h&&ie.__h(ne,t,yn||e),yn=0;var n=ne.__H||(ne.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function B(t){return yn=1,Ip(wl,t)}function Ip(t,e,n){var r=yr(Ht++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):wl(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=ne,!ne.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};ne.__f=!0;var o=ne.shouldComponentUpdate,a=ne.componentWillUpdate;ne.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},ne.shouldComponentUpdate=i}return r.__N||r.__}function oe(t,e){var n=yr(Ht++,3);!ie.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,ne.__H.__h.push(n))}function _t(t,e){var n=yr(Ht++,4);!ie.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,ne.__h.push(n))}function Z(t){return yn=5,Ze(function(){return{current:t}},[])}function Ze(t,e){var n=yr(Ht++,7);return Qi(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function yl(t,e){return yn=8,Ze(function(){return t},e)}function Gp(){for(var t;t=vl.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(vr),e.__h.some(Zi),e.__h=[]}catch(n){e.__h=[],ie.__e(n,t.__v)}}}ie.__b=function(t){ne=null,cl&&cl(t)},ie.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),gl&&gl(t,e)},ie.__r=function(t){dl&&dl(t),Ht=0;var e=(ne=t.__c).__H;e&&(Xi===ne?(e.__h=[],ne.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(vr),e.__h.some(Zi),e.__h=[],Ht=0)),Xi=ne},ie.diffed=function(t){hl&&hl(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(vl.push(e)!==1&&ul===ie.requestAnimationFrame||((ul=ie.requestAnimationFrame)||Mp)(Gp)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Xi=ne=null},ie.__c=function(t,e){e.some(function(n){try{n.__h.some(vr),n.__h=n.__h.filter(function(r){return!r.__||Zi(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],ie.__e(r,n.__v)}}),fl&&fl(t,e)},ie.unmount=function(t){pl&&pl(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{vr(r)}catch(i){e=i}}),n.__H=void 0,e&&ie.__e(e,n.__v))};var ml=typeof requestAnimationFrame=="function";function Mp(t){var e,n=function(){clearTimeout(r),ml&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);ml&&(e=requestAnimationFrame(n))}function vr(t){var e=ne,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ne=e}function Zi(t){var e=ne;t.__c=t.__(),ne=e}function Qi(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function wl(t,e){return typeof e=="function"?e(t):e}var $e=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},...e?.signal===void 0?{}:{signal:e.signal},credentials:"same-origin"});function Ji(t,e=!1){return{ok:!0,data:t,cached:e}}function et(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function bl(t){return t===403?"auth":t===404?"missing":"server"}function xl(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function wr(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return et("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return et(bl(i.status),i.status,xl(i.status));let o;try{o=await i.json()}catch{return et("malformed",i.status,"response was not valid JSON")}return n(o)?Ji(o):et("malformed",i.status,"response did not match the expected shape")}function tt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Fp(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Op(t){if(!tt(t)||typeof t.stamp!="string")return!1;let e=t.model;return!tt(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:tt(t.tags)&&tt(t.dangling)}function zp(t){if(!tt(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return Fp(t.tags)}function $p(t){return tt(t)&&zp(t.note)}function Up(t){return tt(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function Hp(t){return tt(t)&&typeof t.opened=="boolean"}function Wp(t){return tt(t)&&t.ok===!0&&(t.id===void 0||typeof t.id=="string")}async function _l(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return et("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?et("malformed",304,"server sent 304 for an unconditional request"):Ji(e,!0);if(!r.ok)return et(bl(r.status),r.status,xl(r.status));let i;try{i=await r.json()}catch{return et("malformed",r.status,"response was not valid JSON")}return Op(i)?Ji(i):et("malformed",r.status,"response did not match the expected shape")}function kl(t,e){return wr(t,`/api/note/${encodeURIComponent(e)}`,$p)}function El(t,e,n){return wr(t,`/api/search?q=${encodeURIComponent(e)}`,Up,n===void 0?void 0:{signal:n})}function Sl(t,e){return wr(t,"/api/open",Hp,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function Wt(t,e,n,r){return wr(t,e,Wp,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var eo=(t,e="")=>`/api/note/${encodeURIComponent(t)}${e}`,to=(t,e="")=>`/api/folder/${t.split("/").map(encodeURIComponent).join("/")}${e}`,Tl=(t,e,n)=>Wt(t,eo(e,"/rename"),"POST",{name:n}),Al=(t,e,n)=>Wt(t,eo(e,"/move"),"POST",{folder:n}),Rl=(t,e)=>Wt(t,eo(e),"DELETE"),Cl=(t,e)=>Wt(t,to(e),"POST"),Ll=(t,e,n)=>Wt(t,to(e,"/rename"),"POST",{name:n}),Nl=(t,e)=>Wt(t,to(e),"DELETE");var Dl="(prefers-color-scheme: light)";function br(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(Dl).matches?"light":"dark"}function Pl(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(Dl);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function Bp(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Et(t){var e=Bp(t,"string");return typeof e=="symbol"?e:e+""}function le(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Il(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Et(r.key),r)}}function ue(t,e,n){return e&&Il(t.prototype,e),n&&Il(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function kt(t){return kt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kt(t)}function Gl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Gl=function(){return!!t})()}function Kp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Vp(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kp(t)}function _e(t,e,n){return e=kt(e),Vp(t,Gl()?Reflect.construct(e,n||[],kt(t).constructor):e.apply(t,n))}function no(t,e){return no=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},no(t,e)}function ke(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&no(t,e)}function jp(t){if(Array.isArray(t))return t}function qp(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function xr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ao(t,e){if(t){if(typeof t=="string")return xr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xr(t,e):void 0}}function Yp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
23
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ht(t,e){return jp(t)||qp(t,e)||ao(t,e)||Yp()}var ro={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"};var Ml=new Int8Array(4),io=new Int32Array(Ml.buffer,0,1),Xp=new Float32Array(Ml.buffer,0,1),Zp=/^\s*rgba?\s*\(/,Qp=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jp(t){var e=0,n=0,r=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),n=parseInt(t.charAt(2)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(4),16),r=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(Zp.test(t)){var o=t.match(Qp);o&&(e=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:e,g:n,b:r,a:i}}var Bt={};for(wn in ro)Bt[wn]=Kt(ro[wn]),Bt[ro[wn]]=Bt[wn];var wn;function Fl(t,e,n,r,i){return io[0]=r<<24|n<<16|e<<8|t,i&&(io[0]=io[0]&4278190079),Xp[0]}function Kt(t){if(t=t.toLowerCase(),typeof Bt[t]<"u")return Bt[t];var e=Jp(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=Fl(n,r,i,o,!0);return Bt[t]=a,a}var oo={};function so(t){if(typeof oo[t]<"u")return oo[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=Fl(e,n,r,i,!0);return oo[t]=o,o}function lo(t,e,n,r){return n+(e<<8)+(t<<16)}function uo(t,e,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(t.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(a,s,1,1,t.RGBA,t.UNSIGNED_BYTE,l);var u=ht(l,4),c=u[0],h=u[1],d=u[2],f=u[3];return[c,h,d,f]}function S(t,e,n){return(e=Et(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ol(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ol(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ol(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eg(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=kt(t))!==null;);return t}function fo(){return fo=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=eg(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},fo.apply(null,arguments)}function Kl(t,e,n,r){var i=fo(kt(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function tg(t){return t.normalized?1:t.size}function co(t){var e=0;return t.forEach(function(n){return e+=tg(n)}),e}function Vl(t,e,n){var r=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,n),e.compileShader(i);var o=e.getShaderParameter(i,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
21
+ "use strict";(()=>{var op=Object.create;var rs=Object.defineProperty;var ap=Object.getOwnPropertyDescriptor;var sp=Object.getOwnPropertyNames;var lp=Object.getPrototypeOf,up=Object.prototype.hasOwnProperty;var is=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var cp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of sp(e))!up.call(t,i)&&i!==n&&rs(t,i,{get:()=>e[i],enumerable:!(r=ap(e,i))||r.enumerable});return t};var dn=(t,e,n)=>(n=t!=null?op(lp(t)):{},cp(e||!t||!t.__esModule?rs(n,"default",{value:t,enumerable:!0}):n,t));var Tr=is((bk,yo)=>{"use strict";var Vt=typeof Reflect=="object"?Reflect:null,lu=Vt&&typeof Vt.apply=="function"?Vt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},Er;Vt&&typeof Vt.ownKeys=="function"?Er=Vt.ownKeys:Object.getOwnPropertySymbols?Er=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Er=function(e){return Object.getOwnPropertyNames(e)};function Pg(t){console&&console.warn&&console.warn(t)}var cu=Number.isNaN||function(e){return e!==e};function K(){K.init.call(this)}yo.exports=K;yo.exports.once=Fg;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var uu=10;function Sr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return uu},set:function(t){if(typeof t!="number"||t<0||cu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");uu=t}});K.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};K.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||cu(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function du(t){return t._maxListeners===void 0?K.defaultMaxListeners:t._maxListeners}K.prototype.getMaxListeners=function(){return du(this)};K.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")lu(l,this,n);else for(var u=l.length,c=mu(l,u),r=0;r<u;++r)lu(c[r],this,n);return!0};function hu(t,e,n,r){var i,o,a;if(Sr(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=du(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,Pg(s)}return t}K.prototype.addListener=function(e,n){return hu(this,e,n,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(e,n){return hu(this,e,n,!0)};function Ig(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function fu(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=Ig.bind(r);return i.listener=n,r.wrapFn=i,i}K.prototype.once=function(e,n){return Sr(n),this.on(e,fu(this,e,n)),this};K.prototype.prependOnceListener=function(e,n){return Sr(n),this.prependListener(e,fu(this,e,n)),this};K.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Sr(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():Gg(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};K.prototype.off=K.prototype.removeListener;K.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function pu(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Mg(i):mu(i,i.length)}K.prototype.listeners=function(e){return pu(this,e,!0)};K.prototype.rawListeners=function(e){return pu(this,e,!1)};K.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):gu.call(t,e)};K.prototype.listenerCount=gu;function gu(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}K.prototype.eventNames=function(){return this._eventsCount>0?Er(this._events):[]};function mu(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function Gg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Mg(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Fg(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}vu(t,e,o,{once:!0}),e!=="error"&&Og(t,i,{once:!0})})}function Og(t,e,n){typeof t.on=="function"&&vu(t,"error",e,n)}function vu(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var wo=is((kk,wu)=>{"use strict";wu.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var sr,B,us,dp,dt,os,cs,ds,Ri,tr,hn,hs,Ni,Ci,Li,hp,ir={},or=[],fp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,lr=Array.isArray;function Je(t,e){for(var n in e)t[n]=e[n];return t}function Di(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function pp(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?sr.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return nr(t,a,r,i,null)}function nr(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++us,__i:-1,__u:0};return i==null&&B.vnode!=null&&B.vnode(o),o}function Oe(t){return t.children}function rr(t,e){this.props=t,this.context=e}function bt(t,e){if(e==null)return t.__?bt(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?bt(t):null}function gp(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=Je({},e);o.__v=e.__v+1,B.vnode&&B.vnode(o),Pi(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??bt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,vs(r,o,i),e.__e=e.__=null,o.__e!=n&&fs(o)}}function fs(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),fs(t)}function as(t){(!t.__d&&(t.__d=!0)&&dt.push(t)&&!ar.__r++||os!=B.debounceRendering)&&((os=B.debounceRendering)||cs)(ar)}function ar(){try{for(var t,e=1;dt.length;)dt.length>e&&dt.sort(ds),t=dt.shift(),e=dt.length,gp(t)}finally{dt.length=ar.__r=0}}function ps(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,w=r&&r.__k||or,y=e.length;for(l=mp(n,e,w,l,y),h=0;h<y;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&w[f.__i]||ir,f.__i=h,v=Pi(t,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Ii(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=gs(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=m,l}function mp(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=nr(null,a,null,null,null):lr(a)?a=t.__k[o]=nr(Oe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=nr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=vp(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=bt(s)),ws(s,s));return r}function gs(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=gs(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=bt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function vp(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function ss(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||fp.test(e)?n:n+"px"}function er(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||ss(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||ss(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(hs,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[hn]=r[hn]:(n[hn]=Ni,t.addEventListener(e,o?Li:Ci,o)):t.removeEventListener(e,o?Li:Ci,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function ls(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[tr]==null)e[tr]=Ni++;else if(e[tr]<n[hn])return;return n(B.event?B.event(e):e)}}}function Pi(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,w,y,_,k,A,S,L,z,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=B.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(y=e.props,_=G.prototype&&G.prototype.render,k=(c=G.contextType)&&r[c.__c],A=c?k?k.props.value:c.__:r,n.__c?w=(d=e.__c=n.__c).__=d.__E:(_?e.__c=d=new G(y,A):(e.__c=d=new rr(y,A),d.constructor=G,d.render=wp),k&&k.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),_&&d.__s==null&&(d.__s=d.state),_&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Je({},d.__s)),Je(d.__s,G.getDerivedStateFromProps(y,d.__s))),g=d.props,m=d.state,d.__v=e,f)_&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),_&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(_&&G.getDerivedStateFromProps==null&&y!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(y,A),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(y,d.__s,A)===!1){e.__v!=n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),or.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=bt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(y,d.__s,A),_&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=A,d.props=y,d.__P=t,d.__e=!1,S=B.__r,L=0,_)d.state=d.__s,d.__d=!1,S&&S(e),c=d.render(d.props,d.state,d.context),or.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,S&&S(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++L<25);d.state=d.__s,d.getChildContext!=null&&(r=Je(Je({},r),d.getChildContext())),_&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),z=c!=null&&c.type===Oe&&c.key==null?ys(c.props.children):c,s=ps(t,lr(z)?z:[z],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(F=o.length;F--;)Di(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||ms(e),B.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=yp(n.__e,e,n,r,i,o,a,l,u);return(c=B.diffed)&&c(e),128&e.__u?void 0:s}function ms(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(ms))}function vs(t,e,n){for(var r=0;r<n.length;r++)Ii(n[r],n[++r],n[++r]);B.__c&&B.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){B.__e(o,i.__v)}})}function ys(t){return typeof t!="object"||t==null||t.__b>0?t:lr(t)?t.map(ys):t.constructor!==void 0?null:Je({},t)}function yp(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||ir,w=e.props,y=e.type;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!y&&(y?f.localName==y:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(y==null)return document.createTextNode(w);t=document.createElementNS(i,y,w.is&&w),s&&(B.__m&&B.__m(e,o),s=!1),o=null}if(y==null)v===w||s&&t.data==w||(t.data=w);else{if(o=y=="textarea"&&w.defaultValue!=null?null:o&&sr.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in w||u=="value"&&"defaultValue"in w||u=="checked"&&"defaultChecked"in w||er(t,u,null,f,i);for(u in w)f=w[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||er(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),ps(e.type=="template"?t.content:t,lr(d)?d:[d],e,n,r,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&bt(n,0),s,l),o!=null)for(u=o.length;u--;)Di(o[u]);s&&y!="textarea"||(u="value",y=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||y=="progress"&&!g||y=="option"&&g!=v[u])&&er(t,u,g,v[u],i),u="checked",m!=null&&m!=t[u]&&er(t,u,m,v[u],i))}return t}function Ii(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){B.__e(i,n)}}function ws(t,e,n){var r,i;if(B.unmount&&B.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Ii(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){B.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&ws(r[i],e,n||typeof t.type!="function");n||Di(t.__e),t.__c=t.__=t.__e=void 0}function wp(t,e,n){return this.constructor(t,n)}function bs(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),B.__&&B.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],Pi(e,t=(!r&&n||e).__k=pp(Oe,null,[t]),i||ir,ir,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?sr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),vs(o,t,a),t.props.children=null}sr=or.slice,B={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},us=0,dp=function(t){return t!=null&&t.constructor===void 0},rr.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Je({},this.state),typeof t=="function"&&(t=t(Je({},n),this.props)),t&&Je(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),as(this))},rr.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),as(this))},rr.prototype.render=Oe,dt=[],cs=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ds=function(t,e){return t.__v.__b-e.__v.__b},ar.__r=0,Ri=Math.random().toString(8),tr="__d"+Ri,hn="__a"+Ri,hs=/(PointerCapture)$|Capture$/i,Ni=0,Ci=ls(!1),Li=ls(!0),hp=0;var xs="weave-bootstrap";var Gi={cwd:""};function bp(t){return typeof t!="object"||t===null?!1:typeof t.cwd=="string"}function _s(t){if(t===null||t.trim()==="")return Gi;let e;try{e=JSON.parse(t)}catch{return Gi}return bp(e)?e:Gi}function ks(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return Es(this.cover(e,n),e,n,t)}function Es(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,g,m,v,w,y;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[w=v<<1|m]))return i[w]=a,t;if(f=+t._x.call(null,o.data),g=+t._y.call(null,o.data),e===f&&n===g)return a.next=o,i?i[w]=a:t._root=a,t;do i=i?i[w]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((w=v<<1|m)===(y=(g>=d)<<1|f>=h));return i[y]=o,i[w]=a,t}function Ss(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)Es(this,a[n],s[n],t[n]);return this}function Ts(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function As(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Rs(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function fe(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Cs(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,g,m;for(f&&d.push(new fe(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);g=d.pop();)if(!(!(f=g.node)||(a=g.x0)>c||(s=g.y0)>h||(l=g.x1)<i||(u=g.y1)<o))if(f.length){var v=(a+l)/2,w=(s+u)/2;d.push(new fe(f[3],v,w,l,u),new fe(f[2],a,w,v,u),new fe(f[1],v,s,l,w),new fe(f[0],a,s,v,w)),(m=(e>=w)<<1|t>=v)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=g)}else{var y=t-+this._x.call(null,f.data),_=e-+this._y.call(null,f.data),k=y*y+_*_;if(k<n){var A=Math.sqrt(n=k);i=t-A,o=e-A,c=t+A,h=e+A,r=f.data}}return r}function Ls(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,g,m,v,w;if(!n)return this;if(n.length)for(;;){if((g=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|g]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,w=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[w]=n:this._root=n),this):(this._root=o,this)}function Ns(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Ds(){return this._root}function Ps(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Is(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new fe(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,c,s,l)),(i=r[2])&&e.push(new fe(i,o,c,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,c)),(i=r[0])&&e.push(new fe(i,o,a,u,c))}return this}function Gs(t){var e=[],n=[],r;for(this._root&&e.push(new fe(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,c,h)),(o=i[1])&&e.push(new fe(o,c,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,c,u)),(o=i[3])&&e.push(new fe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Ms(t){return t[0]}function Fs(t){return arguments.length?(this._x=t,this):this._x}function Os(t){return t[1]}function zs(t){return arguments.length?(this._y=t,this):this._y}function xt(t,e,n){var r=new Mi(e??Ms,n??Os,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Mi(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function $s(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var xe=xt.prototype=Mi.prototype;xe.copy=function(){var t=new Mi(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=$s(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=$s(r));return t};xe.add=ks;xe.addAll=Ss;xe.cover=Ts;xe.data=As;xe.extent=Rs;xe.find=Cs;xe.remove=Ls;xe.removeAll=Ns;xe.root=Ds;xe.size=Ps;xe.visit=Is;xe.visitAfter=Gs;xe.x=Fs;xe.y=zs;function ae(t){return function(){return t}}function ze(t){return(t()-.5)*1e-6}function xp(t){return t.x+t.vx}function _p(t){return t.y+t.vy}function Fi(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ae(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,m,v,w=0;w<o;++w)for(h=xt(e,xp,_p).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,g=d.y+d.vy,h.visit(y);function y(_,k,A,S,L){var z=_.data,F=_.r,G=m+F;if(z){if(z.index>d.index){var U=f-z.x-z.vx,q=g-z.y-z.vy,ee=U*U+q*q;ee<G*G&&(U===0&&(U=ze(r),ee+=U*U),q===0&&(q=ze(r),ee+=q*q),ee=(G-(ee=Math.sqrt(ee)))/ee*i,d.vx+=(U*=ee)*(G=(F*=F)/(v+F)),d.vy+=(q*=ee)*G,z.vx-=U*(G=1-G),z.vy-=q*G)}return}return k>f+G||S<f-G||A>g+G||L<g-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:ae(+u),l(),a):t},a}function kp(t){return t.index}function Us(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Oi(t){var e=kp,n=h,r,i=ae(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var w=0,y=t.length;w<c;++w)for(var _=0,k,A,S,L,z,F,G;_<y;++_)k=t[_],A=k.source,S=k.target,L=S.x+S.vx-A.x-A.vx||ze(u),z=S.y+S.vy-A.y-A.vy||ze(u),F=Math.sqrt(L*L+z*z),F=(F-o[_])/F*v*r[_],L*=F,z*=F,S.vx-=L*(G=l[_]),S.vy-=z*G,A.vx+=L*(G=1-G),A.vy+=z*G}function f(){if(a){var v,w=a.length,y=t.length,_=new Map(a.map((A,S)=>[e(A,S,a),A])),k;for(v=0,s=new Array(w);v<y;++v)k=t[v],k.index=v,typeof k.source!="object"&&(k.source=Us(_,k.source)),typeof k.target!="object"&&(k.target=Us(_,k.target)),s[k.source.index]=(s[k.source.index]||0)+1,s[k.target.index]=(s[k.target.index]||0)+1;for(v=0,l=new Array(y);v<y;++v)k=t[v],l[v]=s[k.source.index]/(s[k.source.index]+s[k.target.index]);r=new Array(y),g(),o=new Array(y),m()}}function g(){if(a)for(var v=0,w=t.length;v<w;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,w=t.length;v<w;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,w){a=v,u=w,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ae(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ae(+v),m(),d):i},d}var Ep={value:()=>{}};function Bs(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ur(n)}function ur(t){this._=t}function Sp(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ur.prototype=Bs.prototype={constructor:ur,on:function(t,e){var n=this._,r=Sp(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=Tp(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=Hs(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Hs(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ur(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function Tp(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Hs(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Ep,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var zi=Bs;var Ut=0,pn=0,fn=0,Ks=1e3,cr,gn,dr=0,_t=0,hr=0,mn=typeof performance=="object"&&performance.now?performance:Date,Vs=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Hi(){return _t||(Vs(Ap),_t=mn.now()+hr)}function Ap(){_t=0}function $i(){this._call=this._time=this._next=null}$i.prototype=fr.prototype={constructor:$i,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Hi():+n)+(e==null?0:+e),!this._next&&gn!==this&&(gn?gn._next=this:cr=this,gn=this),this._call=t,this._time=n,Ui()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ui())}};function fr(t,e,n){var r=new $i;return r.restart(t,e,n),r}function js(){Hi(),++Ut;for(var t=cr,e;t;)(e=_t-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ut}function Ws(){_t=(dr=mn.now())+hr,Ut=pn=0;try{js()}finally{Ut=0,Cp(),_t=0}}function Rp(){var t=mn.now(),e=t-dr;e>Ks&&(hr-=e,dr=t)}function Cp(){for(var t,e=cr,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:cr=n);gn=t,Ui(r)}function Ui(t){if(!Ut){pn&&(pn=clearTimeout(pn));var e=t-_t;e>24?(t<1/0&&(pn=setTimeout(Ws,t-mn.now()-hr)),fn&&(fn=clearInterval(fn))):(fn||(dr=mn.now(),fn=setInterval(Rp,Ks)),Ut=1,Vs(Ws))}}function qs(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Ys(t){return t.x}function Xs(t){return t.y}var Lp=10,Np=Math.PI*(3-Math.sqrt(5));function Bi(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=fr(h),u=zi("tick","end"),c=qs();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,w=t.length,y;m===void 0&&(m=1);for(var _=0;_<m;++_)for(n+=(o-n)*i,s.forEach(function(k){k(n)}),v=0;v<w;++v)y=t[v],y.fx==null?y.x+=y.vx*=a:(y.x=y.fx,y.vx=0),y.fy==null?y.y+=y.vy*=a:(y.y=y.fy,y.vy=0);return e}function f(){for(var m=0,v=t.length,w;m<v;++m){if(w=t[m],w.index=m,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var y=Lp*Math.sqrt(.5+m),_=m*Np;w.x=y*Math.cos(_),w.y=y*Math.sin(_)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function g(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(g),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(g),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,g(v)),e):s.get(m)},find:function(m,v,w){var y=0,_=t.length,k,A,S,L,z;for(w==null?w=1/0:w*=w,y=0;y<_;++y)L=t[y],k=m-L.x,A=v-L.y,S=k*k+A*A,S<w&&(z=L,w=S);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function Wi(){var t,e,n,r,i=ae(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=t.length,v=xt(t,Ys,Xs).visitAfter(h);for(r=f,g=0;g<m;++g)e=t[g],v.visit(d)}function c(){if(t){var f,g=t.length,m;for(o=new Array(g),f=0;f<g;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var g=0,m,v,w=0,y,_,k;if(f.length){for(y=_=k=0;k<4;++k)(m=f[k])&&(v=Math.abs(m.value))&&(g+=m.value,w+=v,y+=v*m.x,_+=v*m.y);f.x=y/w,f.y=_/w}else{m=f,m.x=m.data.x,m.y=m.data.y;do g+=o[m.data.index];while(m=m.next)}f.value=g}function d(f,g,m,v){if(!f.value)return!0;var w=f.x-e.x,y=f.y-e.y,_=v-g,k=w*w+y*y;if(_*_/l<k)return k<s&&(w===0&&(w=ze(n),k+=w*w),y===0&&(y=ze(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)),e.vx+=w*f.value*r/k,e.vy+=y*f.value*r/k),!0;if(f.length||k>=s)return;(f.data!==e||f.next)&&(w===0&&(w=ze(n),k+=w*w),y===0&&(y=ze(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)));do f.data!==e&&(_=o[f.data.index]*r/k,e.vx+=w*_,e.vy+=y*_);while(f=f.next)}return u.initialize=function(f,g){t=f,n=g,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ae(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function Ki(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}function Vi(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}var Dp=9,pr=6,gr=18,Pp=32,Js=9,mr=Dp+Js;function ji(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Pp));return pr+(gr-pr)*n}function qi(t){return t+Js}var Ip=300,el=1,Zs=.001,ve={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},vn={...ve};function Yi(t){Object.assign(ve,t)}function Qs(t){return t==="contains"||t==="anchored-at"}function Gp(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Mp(t){let e=[],n=new Set;for(let o of t.nodes)n.has(o.id)||(n.add(o.id),e.push(o.id));let r=[],i=new Set;for(let o of t.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:e,edges:r}}function Xi(t){let e=Oi(t.links).id(n=>n.id).distance(n=>Qs(n.kind)?ve.containsRest:ve.relationDistance).strength(n=>Qs(n.kind)?ve.containsStrength:ve.relationStrength).iterations(2);return Bi(t.nodes).randomSource(Gp(t.seed??el)).force("charge",Wi().strength(ve.charge).distanceMax(ve.chargeMax)).force("link",e).force("collide",Fi(n=>n.r??mr).strength(1)).force("x",Ki(0).strength(ve.center)).force("y",Vi(0).strength(ve.center)).stop()}function Fp(t,e,n){let r=Xi({nodes:t,links:e.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(Zs).alphaDecay(n.ticks>0?1-Math.pow(Zs,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function tl(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Ip)),{ids:r,edges:i}=Mp(t),o=r.map(l=>{let u=e.initial?.get(l),c={id:l,vx:0,vy:0};return u!==void 0&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(c.x=u.x,c.y=u.y,e.pinWarm===!0&&(c.fx=u.x,c.fy=u.y)),c}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=qi(ji(a.get(l.id)??0));o.length>1&&Fp(o,i,{ticks:n,seed:e.seed??el,warm:e.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}var Op="sliders";function nl(t){for(let e of t.replace(/^\?/,"").split("&")){let n=e.indexOf("=");if((n===-1?e:e.slice(0,n))!==Op)continue;let i=n===-1?"":e.slice(n+1).toLowerCase();return i!=="0"&&i!=="false"}return!1}var vr=[{key:"containsStrength",label:"contains strength",hint:"how hard a parent holds its children — group cohesion",min:0,max:1,step:.01},{key:"containsRest",label:"contains rest",hint:"how far children sit from their parent — rosette radius",min:10,max:300,step:5},{key:"relationStrength",label:"relation strength",hint:"pull of links-to / mentions across groups",min:0,max:1,step:.01},{key:"relationDistance",label:"relation distance",hint:"how long those cross-group springs are",min:20,max:600,step:10},{key:"charge",label:"charge",hint:"node-to-node repulsion — more negative pushes harder",min:-1200,max:0,step:10},{key:"chargeMax",label:"charge range",hint:"distance past which repulsion stops — caps overall spread",min:100,max:4e3,step:50},{key:"center",label:"centre gravity",hint:"pull toward the origin — too much makes one blob",min:0,max:.3,step:.005}],rl={containsRest:90,containsStrength:.02,relationDistance:170,relationStrength:.05,charge:-50,chargeMax:1/0,center:.09};function il(t,e){let n=t[e.key];return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):e.max}function ol(t,e){let n=Number.parseFloat(e);return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):vn[t.key]}function al(t){return Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Zi(t){let e=n=>` ${n}: ${Number.isFinite(t[n])?t[n]:"Infinity"},`;return["export const FORCES: ForceConstants = {",...vr.map(n=>e(n.key)),"};"].join(`
22
+ `)}function sl(t){return vr.every(e=>Object.is(t[e.key],vn[e.key]))}var ll="pi-weave.graph.groupColors.v1";function ul(t){try{return t.getItem(ll)!=="off"}catch{return!0}}function cl(t,e){try{t.setItem(ll,e?"on":"off")}catch{}}var Ht,ne,Qi,dl,yn=0,wl=[],ie=B,hl=ie.__b,fl=ie.__r,pl=ie.diffed,gl=ie.__c,ml=ie.unmount,vl=ie.__;function wr(t,e){ie.__h&&ie.__h(ne,t,yn||e),yn=0;var n=ne.__H||(ne.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function W(t){return yn=1,zp(xl,t)}function zp(t,e,n){var r=wr(Ht++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):xl(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=ne,!ne.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};ne.__f=!0;var o=ne.shouldComponentUpdate,a=ne.componentWillUpdate;ne.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},ne.shouldComponentUpdate=i}return r.__N||r.__}function oe(t,e){var n=wr(Ht++,3);!ie.__s&&eo(n.__H,e)&&(n.__=t,n.u=e,ne.__H.__h.push(n))}function kt(t,e){var n=wr(Ht++,4);!ie.__s&&eo(n.__H,e)&&(n.__=t,n.u=e,ne.__h.push(n))}function Z(t){return yn=5,Ze(function(){return{current:t}},[])}function Ze(t,e){var n=wr(Ht++,7);return eo(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function bl(t,e){return yn=8,Ze(function(){return t},e)}function $p(){for(var t;t=wl.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(yr),e.__h.some(Ji),e.__h=[]}catch(n){e.__h=[],ie.__e(n,t.__v)}}}ie.__b=function(t){ne=null,hl&&hl(t)},ie.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),vl&&vl(t,e)},ie.__r=function(t){fl&&fl(t),Ht=0;var e=(ne=t.__c).__H;e&&(Qi===ne?(e.__h=[],ne.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(yr),e.__h.some(Ji),e.__h=[],Ht=0)),Qi=ne},ie.diffed=function(t){pl&&pl(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(wl.push(e)!==1&&dl===ie.requestAnimationFrame||((dl=ie.requestAnimationFrame)||Up)($p)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Qi=ne=null},ie.__c=function(t,e){e.some(function(n){try{n.__h.some(yr),n.__h=n.__h.filter(function(r){return!r.__||Ji(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],ie.__e(r,n.__v)}}),gl&&gl(t,e)},ie.unmount=function(t){ml&&ml(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{yr(r)}catch(i){e=i}}),n.__H=void 0,e&&ie.__e(e,n.__v))};var yl=typeof requestAnimationFrame=="function";function Up(t){var e,n=function(){clearTimeout(r),yl&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);yl&&(e=requestAnimationFrame(n))}function yr(t){var e=ne,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ne=e}function Ji(t){var e=ne;t.__c=t.__(),ne=e}function eo(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function xl(t,e){return typeof e=="function"?e(t):e}var $e=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},...e?.signal===void 0?{}:{signal:e.signal},credentials:"same-origin"});function to(t,e=!1){return{ok:!0,data:t,cached:e}}function et(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function _l(t){return t===403?"auth":t===404?"missing":"server"}function kl(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function br(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return et("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return et(_l(i.status),i.status,kl(i.status));let o;try{o=await i.json()}catch{return et("malformed",i.status,"response was not valid JSON")}return n(o)?to(o):et("malformed",i.status,"response did not match the expected shape")}function tt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Hp(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Bp(t){if(!tt(t)||typeof t.stamp!="string")return!1;let e=t.model;return!tt(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:tt(t.tags)&&tt(t.dangling)}function Wp(t){if(!tt(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return Hp(t.tags)}function Kp(t){return tt(t)&&Wp(t.note)}function Vp(t){return tt(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function jp(t){return tt(t)&&typeof t.opened=="boolean"}function qp(t){return tt(t)&&t.ok===!0&&(t.id===void 0||typeof t.id=="string")}async function El(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return et("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?et("malformed",304,"server sent 304 for an unconditional request"):to(e,!0);if(!r.ok)return et(_l(r.status),r.status,kl(r.status));let i;try{i=await r.json()}catch{return et("malformed",r.status,"response was not valid JSON")}return Bp(i)?to(i):et("malformed",r.status,"response did not match the expected shape")}function Sl(t,e){return br(t,`/api/note/${encodeURIComponent(e)}`,Kp)}function Tl(t,e,n){return br(t,`/api/search?q=${encodeURIComponent(e)}`,Vp,n===void 0?void 0:{signal:n})}function Al(t,e){return br(t,"/api/open",jp,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function Bt(t,e,n,r){return br(t,e,qp,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var no=(t,e="")=>`/api/note/${encodeURIComponent(t)}${e}`,ro=(t,e="")=>`/api/folder/${t.split("/").map(encodeURIComponent).join("/")}${e}`,Rl=(t,e,n)=>Bt(t,no(e,"/rename"),"POST",{name:n}),Cl=(t,e,n)=>Bt(t,no(e,"/move"),"POST",{folder:n}),Ll=(t,e)=>Bt(t,no(e),"DELETE"),Nl=(t,e)=>Bt(t,ro(e),"POST"),Dl=(t,e,n)=>Bt(t,ro(e,"/rename"),"POST",{name:n}),Pl=(t,e)=>Bt(t,ro(e),"DELETE");var Il="(prefers-color-scheme: light)";function xr(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(Il).matches?"light":"dark"}function Gl(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(Il);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function Yp(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function St(t){var e=Yp(t,"string");return typeof e=="symbol"?e:e+""}function le(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ml(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,St(r.key),r)}}function ue(t,e,n){return e&&Ml(t.prototype,e),n&&Ml(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Et(t){return Et=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Et(t)}function Fl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fl=function(){return!!t})()}function Xp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Zp(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xp(t)}function _e(t,e,n){return e=Et(e),Zp(t,Fl()?Reflect.construct(e,n||[],Et(t).constructor):e.apply(t,n))}function io(t,e){return io=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},io(t,e)}function ke(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&io(t,e)}function Qp(t){if(Array.isArray(t))return t}function Jp(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function _r(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function lo(t,e){if(t){if(typeof t=="string")return _r(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_r(t,e):void 0}}function eg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
23
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ht(t,e){return Qp(t)||Jp(t,e)||lo(t,e)||eg()}var oo={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"};var Ol=new Int8Array(4),ao=new Int32Array(Ol.buffer,0,1),tg=new Float32Array(Ol.buffer,0,1),ng=/^\s*rgba?\s*\(/,rg=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function ig(t){var e=0,n=0,r=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),n=parseInt(t.charAt(2)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(4),16),r=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(ng.test(t)){var o=t.match(rg);o&&(e=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:e,g:n,b:r,a:i}}var Wt={};for(wn in oo)Wt[wn]=Kt(oo[wn]),Wt[oo[wn]]=Wt[wn];var wn;function zl(t,e,n,r,i){return ao[0]=r<<24|n<<16|e<<8|t,i&&(ao[0]=ao[0]&4278190079),tg[0]}function Kt(t){if(t=t.toLowerCase(),typeof Wt[t]<"u")return Wt[t];var e=ig(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=zl(n,r,i,o,!0);return Wt[t]=a,a}var so={};function uo(t){if(typeof so[t]<"u")return so[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=zl(e,n,r,i,!0);return so[t]=o,o}function co(t,e,n,r){return n+(e<<8)+(t<<16)}function ho(t,e,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(t.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(a,s,1,1,t.RGBA,t.UNSIGNED_BYTE,l);var u=ht(l,4),c=u[0],h=u[1],d=u[2],f=u[3];return[c,h,d,f]}function T(t,e,n){return(e=St(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$l(Object(n),!0).forEach(function(r){T(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$l(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function og(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=Et(t))!==null;);return t}function go(){return go=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=og(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},go.apply(null,arguments)}function jl(t,e,n,r){var i=go(Et(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function ag(t){return t.normalized?1:t.size}function fo(t){var e=0;return t.forEach(function(n){return e+=ag(n)}),e}function ql(t,e,n){var r=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,n),e.compileShader(i);var o=e.getShaderParameter(i,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
24
24
  `.concat(a,`
25
- `).concat(n))}return i}function ng(t,e){return Vl("VERTEX",t,e)}function rg(t,e){return Vl("FRAGMENT",t,e)}function ig(t,e){var n=t.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=e.length;r<i;r++)t.attachShader(n,e[r]);t.linkProgram(n);var o=t.getProgramParameter(n,t.LINK_STATUS);if(!o){var a=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function zl(t){var e=t.gl,n=t.buffer,r=t.program,i=t.vertexShader,o=t.fragmentShader;e.deleteShader(i),e.deleteShader(o),e.deleteProgram(r),e.deleteBuffer(n)}var $l=`#define PICKING_MODE
26
- `,og=S(S(S(S(S(S(S(S({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4);var jl=(function(){function t(e,n,r){le(this,t),S(this,"array",new Float32Array),S(this,"constantArray",new Float32Array),S(this,"capacity",0),S(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=co(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",e,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",e,$l+i.VERTEX_SHADER_SOURCE,$l+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=co(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var l=0;l<s.length;l++)this.constantArray[a*o+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ue(t,[{key:"kill",value:function(){zl(this.normalProgram),this.pickProgram&&(zl(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,a){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=ng(r,i),c=rg(r,o),h=ig(r,[u,c]),d={};s.UNIFORMS.forEach(function(m){var v=r.getUniformLocation(h,m);v&&(d[m]=v)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)});var p;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)}),p=r.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:p||{},uniformLocations:d,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var a=og[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=r.attributeLocations[n.name],l=r.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:co(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],a=r.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(D(D({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var ag=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"kill",value:function(){Kl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(so(r),a,o)}}])})(jl);var po=(function(t){function e(){var n;le(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=_e(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return ke(e,t),ue(e,[{key:"kill",value:function(){Kl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(so(r),l,o,a,s)}}])})(jl);function sg(t,e){return(function(){function n(r,i,o){le(this,n),S(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return ue(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function ql(t,e,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?e[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=e.label;if(u){t.fillStyle=l,t.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,f=n.y,p=r.x,m=r.y,v=(d+p)/2,w=(f+m)/2,y=p-d,_=m-f,k=Math.sqrt(y*y+_*_);if(!(k<c+h)){d+=y*c/k,f+=_*c/k,p-=y*h/k,m-=_*h/k,v=(d+p)/2,w=(f+m)/2,y=p-d,_=m-f,k=Math.sqrt(y*y+_*_);var N=t.measureText(u).width;if(N>k){var R="…";for(u=u+R,N=t.measureText(u).width;N>k&&u.length>1;)u=u.slice(0,-2)+R,N=t.measureText(u).width;if(u.length<4)return}var P;y>0?_>0?P=Math.acos(y/k):P=Math.asin(_/k):_>0?P=Math.acos(y/k)+Math.PI:P=Math.asin(y/k)+Math.PI/2,t.save(),t.translate(v,w),t.rotate(P),t.fillText(u,-N/2,e.size/2+o),t.restore()}}}function go(t,e,n){if(e.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?e[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;t.fillStyle=a,t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillText(e.label,e.x+e.size+3,e.y+r/3)}}function Yl(t,e,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000";var a=2;if(typeof e.label=="string"){var s=t.measureText(e.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(e.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+u/2),t.lineTo(e.x+c+l,e.y+u/2),t.lineTo(e.x+c+l,e.y-u/2),t.lineTo(e.x+d,e.y-u/2),t.arc(e.x,e.y,c,h,-h),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+a,0,Math.PI*2),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,go(t,e,n)}var lg=`
25
+ `).concat(n))}return i}function sg(t,e){return ql("VERTEX",t,e)}function lg(t,e){return ql("FRAGMENT",t,e)}function ug(t,e){var n=t.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=e.length;r<i;r++)t.attachShader(n,e[r]);t.linkProgram(n);var o=t.getProgramParameter(n,t.LINK_STATUS);if(!o){var a=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function Ul(t){var e=t.gl,n=t.buffer,r=t.program,i=t.vertexShader,o=t.fragmentShader;e.deleteShader(i),e.deleteShader(o),e.deleteProgram(r),e.deleteBuffer(n)}var Hl=`#define PICKING_MODE
26
+ `,cg=T(T(T(T(T(T(T(T({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4);var Yl=(function(){function t(e,n,r){le(this,t),T(this,"array",new Float32Array),T(this,"constantArray",new Float32Array),T(this,"capacity",0),T(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=fo(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",e,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",e,Hl+i.VERTEX_SHADER_SOURCE,Hl+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=fo(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var l=0;l<s.length;l++)this.constantArray[a*o+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ue(t,[{key:"kill",value:function(){Ul(this.normalProgram),this.pickProgram&&(Ul(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,a){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=sg(r,i),c=lg(r,o),h=ug(r,[u,c]),d={};s.UNIFORMS.forEach(function(m){var v=r.getUniformLocation(h,m);v&&(d[m]=v)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:g||{},uniformLocations:d,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var a=cg[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=r.attributeLocations[n.name],l=r.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:fo(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],a=r.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(P(P({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var dg=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"kill",value:function(){jl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(uo(r),a,o)}}])})(Yl);var mo=(function(t){function e(){var n;le(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=_e(this,e,[].concat(i)),T(n,"drawLabel",void 0),n}return ke(e,t),ue(e,[{key:"kill",value:function(){jl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(uo(r),l,o,a,s)}}])})(Yl);function hg(t,e){return(function(){function n(r,i,o){le(this,n),T(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return ue(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function Xl(t,e,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?e[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=e.label;if(u){t.fillStyle=l,t.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,f=n.y,g=r.x,m=r.y,v=(d+g)/2,w=(f+m)/2,y=g-d,_=m-f,k=Math.sqrt(y*y+_*_);if(!(k<c+h)){d+=y*c/k,f+=_*c/k,g-=y*h/k,m-=_*h/k,v=(d+g)/2,w=(f+m)/2,y=g-d,_=m-f,k=Math.sqrt(y*y+_*_);var A=t.measureText(u).width;if(A>k){var S="…";for(u=u+S,A=t.measureText(u).width;A>k&&u.length>1;)u=u.slice(0,-2)+S,A=t.measureText(u).width;if(u.length<4)return}var L;y>0?_>0?L=Math.acos(y/k):L=Math.asin(_/k):_>0?L=Math.acos(y/k)+Math.PI:L=Math.asin(y/k)+Math.PI/2,t.save(),t.translate(v,w),t.rotate(L),t.fillText(u,-A/2,e.size/2+o),t.restore()}}}function vo(t,e,n){if(e.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?e[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;t.fillStyle=a,t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillText(e.label,e.x+e.size+3,e.y+r/3)}}function Zl(t,e,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000";var a=2;if(typeof e.label=="string"){var s=t.measureText(e.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(e.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+u/2),t.lineTo(e.x+c+l,e.y+u/2),t.lineTo(e.x+c+l,e.y-u/2),t.lineTo(e.x+d,e.y-u/2),t.arc(e.x,e.y,c,h,-h),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+a,0,Math.PI*2),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,vo(t,e,n)}var fg=`
27
27
  precision highp float;
28
28
 
29
29
  varying vec4 v_color;
@@ -55,7 +55,7 @@ void main(void) {
55
55
  gl_FragColor = mix(v_color, transparent, t);
56
56
  #endif
57
57
  }
58
- `,ug=lg,cg=`
58
+ `,pg=fg,gg=`
59
59
  attribute vec4 a_id;
60
60
  attribute vec4 a_color;
61
61
  attribute vec2 a_position;
@@ -96,7 +96,7 @@ void main() {
96
96
 
97
97
  v_color.a *= bias;
98
98
  }
99
- `,dg=cg,Xl=WebGLRenderingContext,Ul=Xl.UNSIGNED_BYTE,ho=Xl.FLOAT,hg=["u_sizeRatio","u_correctionRatio","u_matrix"],xn=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:dg,FRAGMENT_SHADER_SOURCE:ug,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:hg,ATTRIBUTES:[{name:"a_position",size:2,type:ho},{name:"a_size",size:1,type:ho},{name:"a_color",size:4,type:Ul,normalized:!0},{name:"a_id",size:4,type:Ul,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:ho}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Kt(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(u,!1,r.matrix)}}])})(ag);S(xn,"ANGLE_1",0);S(xn,"ANGLE_2",2*Math.PI/3);S(xn,"ANGLE_3",4*Math.PI/3);var fg=`
99
+ `,mg=gg,Ql=WebGLRenderingContext,Bl=Ql.UNSIGNED_BYTE,po=Ql.FLOAT,vg=["u_sizeRatio","u_correctionRatio","u_matrix"],xn=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:mg,FRAGMENT_SHADER_SOURCE:pg,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vg,ATTRIBUTES:[{name:"a_position",size:2,type:po},{name:"a_size",size:1,type:po},{name:"a_color",size:4,type:Bl,normalized:!0},{name:"a_id",size:4,type:Bl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:po}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Kt(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(u,!1,r.matrix)}}])})(dg);T(xn,"ANGLE_1",0);T(xn,"ANGLE_2",2*Math.PI/3);T(xn,"ANGLE_3",4*Math.PI/3);var yg=`
100
100
  precision mediump float;
101
101
 
102
102
  varying vec4 v_color;
@@ -104,7 +104,7 @@ varying vec4 v_color;
104
104
  void main(void) {
105
105
  gl_FragColor = v_color;
106
106
  }
107
- `,pg=fg,gg=`
107
+ `,wg=yg,bg=`
108
108
  attribute vec2 a_position;
109
109
  attribute vec2 a_normal;
110
110
  attribute float a_radius;
@@ -170,7 +170,7 @@ void main() {
170
170
 
171
171
  v_color.a *= bias;
172
172
  }
173
- `,mg=gg,Zl=WebGLRenderingContext,Hl=Zl.UNSIGNED_BYTE,_r=Zl.FLOAT,vg=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Ql={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Jl(t){var e=D(D({},Ql),t||{});return(function(n){function r(){return le(this,r),_e(this,r,arguments)}return ke(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:mg,FRAGMENT_SHADER_SOURCE:pg,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vg,ATTRIBUTES:[{name:"a_position",size:2,type:_r},{name:"a_normal",size:2,type:_r},{name:"a_radius",size:1,type:_r},{name:"a_color",size:4,type:Hl,normalized:!0},{name:"a_id",size:4,type:Hl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:_r}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(e.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,f=s.x,p=s.y,m=l.x,v=l.y,w=Kt(u.color),y=m-f,_=v-p,k=y*y+_*_,N=0,R=0;k&&(k=1/Math.sqrt(k),N=-_*k*h,R=y*k*h);var P=this.array;P[a++]=m,P[a++]=v,P[a++]=-N,P[a++]=-R,P[a++]=d,P[a++]=w,P[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,p=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(p,e.widenessToThicknessRatio)}}])})(po)}var lk=Jl();var yg=`
173
+ `,xg=bg,Jl=WebGLRenderingContext,Wl=Jl.UNSIGNED_BYTE,kr=Jl.FLOAT,_g=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],eu={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function tu(t){var e=P(P({},eu),t||{});return(function(n){function r(){return le(this,r),_e(this,r,arguments)}return ke(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:xg,FRAGMENT_SHADER_SOURCE:wg,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:_g,ATTRIBUTES:[{name:"a_position",size:2,type:kr},{name:"a_normal",size:2,type:kr},{name:"a_radius",size:1,type:kr},{name:"a_color",size:4,type:Wl,normalized:!0},{name:"a_id",size:4,type:Wl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:kr}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(e.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,f=s.x,g=s.y,m=l.x,v=l.y,w=Kt(u.color),y=m-f,_=v-g,k=y*y+_*_,A=0,S=0;k&&(k=1/Math.sqrt(k),A=-_*k*h,S=y*k*h);var L=this.array;L[a++]=m,L[a++]=v,L[a++]=-A,L[a++]=-S,L[a++]=d,L[a++]=w,L[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(g,e.widenessToThicknessRatio)}}])})(mo)}var vk=tu();var kg=`
174
174
  precision mediump float;
175
175
 
176
176
  varying vec4 v_color;
@@ -196,7 +196,7 @@ void main(void) {
196
196
  gl_FragColor = mix(v_color, transparent, t);
197
197
  #endif
198
198
  }
199
- `,eu=yg,wg=`
199
+ `,nu=kg,Eg=`
200
200
  attribute vec4 a_id;
201
201
  attribute vec4 a_color;
202
202
  attribute vec2 a_normal;
@@ -264,7 +264,7 @@ void main() {
264
264
 
265
265
  v_color.a *= bias;
266
266
  }
267
- `,bg=wg,tu=WebGLRenderingContext,Wl=tu.UNSIGNED_BYTE,St=tu.FLOAT,xg=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],_g={lengthToThicknessRatio:Ql.lengthToThicknessRatio};function nu(t){var e=D(D({},_g),t||{});return(function(n){function r(){return le(this,r),_e(this,r,arguments)}return ke(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:bg,FRAGMENT_SHADER_SOURCE:eu,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:xg,ATTRIBUTES:[{name:"a_positionStart",size:2,type:St},{name:"a_positionEnd",size:2,type:St},{name:"a_normal",size:2,type:St},{name:"a_color",size:4,type:Wl,normalized:!0},{name:"a_id",size:4,type:Wl,normalized:!0},{name:"a_radius",size:1,type:St}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:St},{name:"a_normalCoef",size:1,type:St},{name:"a_radiusCoef",size:1,type:St}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,d=s.y,f=l.x,p=l.y,m=Kt(u.color),v=f-h,w=p-d,y=l.size||1,_=v*v+w*w,k=0,N=0;_&&(_=1/Math.sqrt(_),k=-w*_*c,N=v*_*c);var R=this.array;R[a++]=h,R[a++]=d,R[a++]=f,R[a++]=p,R[a++]=k,R[a++]=N,R[a++]=m,R[a++]=o,R[a++]=y}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,f=l.u_correctionRatio,p=l.u_sizeRatio,m=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(p,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(v,e.lengthToThicknessRatio)}}])})(po)}var uk=nu();function kg(t){return sg([nu(t),Jl(t)])}var Eg=kg(),ru=Eg,Sg=`
267
+ `,Sg=Eg,ru=WebGLRenderingContext,Kl=ru.UNSIGNED_BYTE,Tt=ru.FLOAT,Tg=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Ag={lengthToThicknessRatio:eu.lengthToThicknessRatio};function iu(t){var e=P(P({},Ag),t||{});return(function(n){function r(){return le(this,r),_e(this,r,arguments)}return ke(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Sg,FRAGMENT_SHADER_SOURCE:nu,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Tg,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Tt},{name:"a_positionEnd",size:2,type:Tt},{name:"a_normal",size:2,type:Tt},{name:"a_color",size:4,type:Kl,normalized:!0},{name:"a_id",size:4,type:Kl,normalized:!0},{name:"a_radius",size:1,type:Tt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Tt},{name:"a_normalCoef",size:1,type:Tt},{name:"a_radiusCoef",size:1,type:Tt}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,d=s.y,f=l.x,g=l.y,m=Kt(u.color),v=f-h,w=g-d,y=l.size||1,_=v*v+w*w,k=0,A=0;_&&(_=1/Math.sqrt(_),k=-w*_*c,A=v*_*c);var S=this.array;S[a++]=h,S[a++]=d,S[a++]=f,S[a++]=g,S[a++]=k,S[a++]=A,S[a++]=m,S[a++]=o,S[a++]=y}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,f=l.u_correctionRatio,g=l.u_sizeRatio,m=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(g,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(v,e.lengthToThicknessRatio)}}])})(mo)}var yk=iu();function Rg(t){return hg([iu(t),tu(t)])}var Cg=Rg(),ou=Cg,Lg=`
268
268
  attribute vec4 a_id;
269
269
  attribute vec4 a_color;
270
270
  attribute vec2 a_normal;
@@ -329,41 +329,41 @@ void main() {
329
329
 
330
330
  v_color.a *= bias;
331
331
  }
332
- `,Tg=Sg,iu=WebGLRenderingContext,Bl=iu.UNSIGNED_BYTE,bn=iu.FLOAT,Ag=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],ou=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Tg,FRAGMENT_SHADER_SOURCE:eu,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ag,ATTRIBUTES:[{name:"a_positionStart",size:2,type:bn},{name:"a_positionEnd",size:2,type:bn},{name:"a_normal",size:2,type:bn},{name:"a_color",size:4,type:Bl,normalized:!0},{name:"a_id",size:4,type:Bl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:bn},{name:"a_normalCoef",size:1,type:bn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=Kt(s.color),p=h-u,m=d-c,v=p*p+m*m,w=0,y=0;v&&(v=1/Math.sqrt(v),w=-m*v*l,y=p*v*l);var _=this.array;_[i++]=u,_[i++]=c,_[i++]=h,_[i++]=d,_[i++]=w,_[i++]=y,_[i++]=f,_[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(po);var mu=dn(Sr()),Tr=(function(t){function e(){var n;return le(this,e),n=_e(this,e),n.rawEmitter=n,n}return ke(e,t),ue(e)})(mu.EventEmitter);var bu=dn(vo());var Ig=function(e){return e},Gg=function(e){return e*e},Mg=function(e){return e*(2-e)},Fg=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},Og=function(e){return e*e*e},zg=function(e){return--e*e*e+1},$g=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},xu={linear:Ig,quadraticIn:Gg,quadraticOut:Mg,quadraticInOut:Fg,cubicIn:Og,cubicOut:zg,cubicInOut:$g},_u={easing:"quadraticInOut",duration:150};function De(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ar(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function yu(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function wu(t,e,n){return t[6]=e,t[7]=n,t}function ft(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],p=e[3],m=e[4],v=e[5],w=e[6],y=e[7],_=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=p*n+m*o+v*l,t[4]=p*r+m*a+v*u,t[5]=p*i+m*s+v*c,t[6]=w*n+y*o+_*l,t[7]=w*r+y*a+_*u,t[8]=w*i+y*s+_*c,t}function Rr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Ug(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function jt(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=De(),d=Math.min(u,c)-2*r,f=Ug(e,n);return i?(ft(h,wu(De(),s,l)),ft(h,Ar(De(),a)),ft(h,yu(De(),o)),ft(h,Ar(De(),u/d/2/f,c/d/2/f))):(ft(h,Ar(De(),2*(d/u)*f,2*(d/c)*f)),ft(h,yu(De(),-o)),ft(h,Ar(De(),1/a)),ft(h,wu(De(),-s,-l))),h}function ku(t,e,n){var r=Rr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Eu(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function Su(t){if(!(0,bu.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Tu(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function yo(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function wo(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function bo(t){var e=ht(t.x,2),n=e[0],r=e[1],i=ht(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function Cr(t){"@babel/helpers - typeof";return Cr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cr(t)}function xo(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function Lr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var Nr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:ql,defaultDrawNodeLabel:go,defaultDrawNodeHover:Yl,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Hg={circle:xn},Wg={arrow:ru,line:ou};function Dr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Au(t){var e=Lr({},Nr,t);return e.nodeProgramClasses=Lr({},Hg,e.nodeProgramClasses),e.edgeProgramClasses=Lr({},Wg,e.edgeProgramClasses),e}var Rk=dn(Sr()),Ck=dn(vo()),Pr=1.5,Ru=(function(t){function e(){var n;return le(this,e),n=_e(this,e),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return ke(e,t),ue(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(D(D({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=D(D({},_u),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:xu[s.easing],c=Date.now(),h=this.getState(),d=function(){var p=(Date.now()-c)/s.duration;if(p>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(p),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Pr)},r):this.animate({ratio:this.ratio/Pr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Pr)},r):this.animate({ratio:this.ratio*Pr})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(Tr);function Ue(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function nt(t,e){var n=D(D({},Ue(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function _n(t){var e="x"in t?t:D(D({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function Bg(t,e){return D(D({},nt(t,e)),{},{delta:Iu(t)})}var Kg=2;function Ir(t){for(var e=[],n=0,r=Math.min(t.length,Kg);n<r;n++)e.push(t[n]);return e}function kn(t,e,n){var r={touches:Ir(t.touches).map(function(i){return Ue(i,n)}),previousTouches:e.map(function(i){return Ue(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Iu(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Gu=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e),i.container=n,i.renderer=r,i}return ke(e,t),ue(e)})(Tr),Vg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],jg=Vg.reduce(function(t,e){return D(D({},t),{},S({},e,Nr[e]))},{}),qg=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",jg),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return ke(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",nt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",nt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=nt(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Ue(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Ue(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",nt(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=Ue(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",nt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=nt(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=Ue(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,p=a.getState(),m=p.x+d,v=p.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",nt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",nt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Iu(r);if(a){var s=Bg(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Ue(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Gu),Yg=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Xg=Yg.reduce(function(t,e){return D(D({},t),{},S({},e,Nr[e]))},{}),Zg=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",Xg),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return ke(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=Ir(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Ue(f,i.container)}),this.touchMode===2){var a=ht(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",kn(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",kn(r,this.lastTouches,this.container)),!r.touches.length){var s=Ue(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=kn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=kn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Ir(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Ir(r.touches),a=o.map(function(je){return Ue(je,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=kn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(je,an){var Ne=i.startTouchesPositions[an];return Ne&&(je.x!==Ne.x||je.y!==Ne.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,p=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,w=m.y;u.setState({x:c.x+f-v,y:c.y+p-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},_=a[0],k=_.x,N=_.y,R=a[1],P=R.x,z=R.y,O=Math.atan2(z-N,P-k)-this.startTouchesAngle,G=Math.hypot(z-N,P-k)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);y.ratio=U,y.angle=c.angle+O;var q=this.getDimensions(),ee=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(q.width,q.height)-2*h,he=ge/q.width,Ve=ge/q.height,It=U/ge,Ge=k-ge/2/he,Me=N-ge/2/Ve,Fe=[Ge*Math.cos(-y.angle)-Me*Math.sin(-y.angle),Me*Math.cos(-y.angle)+Ge*Math.sin(-y.angle)];Ge=Fe[0],Me=Fe[1],y.x=ee.x-Ge*It,y.y=ee.y+Me*It,u.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Gu);function Qg(t){if(Array.isArray(t))return xr(t)}function Jg(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function em(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
333
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cu(t){return Qg(t)||Jg(t)||ao(t)||em()}function tm(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function _o(t,e){if(t==null)return{};var n,r,i=tm(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var Lu=(function(){function t(e,n){le(this,t),this.key=e,this.size=n}return ue(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Nu=(function(){function t(){le(this,t),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return ue(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Lu(n,r),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Lu.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function nm(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var Du=150,Pu=50,rt=Object.prototype.hasOwnProperty;function rm(t,e,n){if(!rt.call(n,"x")||!rt.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),rt.call(n,"hidden")||(n.hidden=!1),rt.call(n,"highlighted")||(n.highlighted=!1),rt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function im(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),rt.call(n,"hidden")||(n.hidden=!1),rt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var om=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(le(this,e),i=_e(this,e),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new Nu),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",De()),S(i,"invMatrix",De()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",bo({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",yo()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=Au(o),Dr(i.settings),Su(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new Ru,i.bindCameraHandlers(),i.mouseCaptor=new qg(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Zg(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return ke(e,t),ue(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=_o(i,[r].map(Et));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=_o(s,[r].map(Et));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=_o(i,[r].map(Et));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=uo(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=lo.apply(void 0,Cu(a)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",D(D({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",D(D({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",D(D({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",D(D({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",D(D({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=_n(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",D(D({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",D(D({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",D({},s))},this.activeListeners.handleEnter=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",D({},s))};var i=function(a){return function(s){var l=_n(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),D(D({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),D(D({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=uo(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=lo.apply(void 0,Cu(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=Eu(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=bo(this.customBBox||this.nodeExtent);var d=new Ru,f=jt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var p={},m={},v={},w={},y=1,_=i.nodes(),k=0,N=_.length;k<N;k++){var R=_[k],P=this.nodeDataCache[R],z=i.getNodeAttributes(R);P.x=z.x,P.y=z.y,this.normalizationFunction.applyTo(P),typeof P.label=="string"&&!P.hidden&&this.labelGrid.add(R,P.size,this.framedGraphToViewport(P,{matrix:f})),p[P.type]=(p[P.type]||0)+1}this.labelGrid.organize();for(var O in this.nodePrograms){if(!rt.call(this.nodePrograms,O))throw new Error('Sigma: could not find a suitable program for node type "'.concat(O,'"!'));this.nodePrograms[O].reallocate(p[O]||0),p[O]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=wo(this.nodeZExtent,function(sn){return r.nodeDataCache[sn].zIndex},_));for(var G=0,U=_.length;G<U;G++){var q=_[G];m[q]=y,w[m[q]]={type:"node",id:q},y++;var ee=this.nodeDataCache[q];this.addNodeToProgram(q,m[q],p[ee.type]++)}for(var ge={},he=i.edges(),Ve=0,It=he.length;Ve<It;Ve++){var Ge=he[Ve],Me=this.edgeDataCache[Ge];ge[Me.type]=(ge[Me.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=wo(this.edgeZExtent,function(sn){return r.edgeDataCache[sn].zIndex},he));for(var Fe in this.edgePrograms){if(!rt.call(this.edgePrograms,Fe))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Fe,'"!'));this.edgePrograms[Fe].reallocate(ge[Fe]||0),ge[Fe]=0}for(var je=0,an=he.length;je<an;je++){var Ne=he[je];v[Ne]=y,w[v[Ne]]={type:"edge",id:Ne},y++;var Y=this.edgeDataCache[Ne];this.addEdgeToProgram(Ne,v[Ne],ge[Y.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&Cr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=D({},r),u=s||this.nodeExtent,c=ht(u.x,2),h=c[0],d=c[1],f=ht(u.y,2),p=f[0],m=f[1],v=[this.graphToViewport({x:h,y:p},{cameraState:r}),this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],w=1/0,y=-1/0,_=1/0,k=-1/0;v.forEach(function(ge){var he=ge.x,Ve=ge.y;w=Math.min(w,he),y=Math.max(y,he),_=Math.min(_,Ve),k=Math.max(k,Ve)});var N=y-w,R=k-_,P=this.getDimensions(),z=P.width,O=P.height,G=0,U=0;if(N>=z?y<z-a?G=y-(z-a):w>a&&(G=w-a):y>z+a?G=y-(z+a):w<-a&&(G=w+a),R>=O?k<O-a?U=k-(O-a):_>a&&(U=_-a):k>O+a?U=k-(O+a):_<-a&&(U=_+a),G||U){var q=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),ee=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=ee.x-q.x,U=ee.y-q.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);xo(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-Du||h>this.width+Du||d<-Pu||d>this.height+Pu)){this.displayedNodeLabels.add(l);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||p;v(o,D(D({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=nm({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});xo(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[d.type],m=p?.drawLabel||f;m(r,D(D({key:l},d),{},{size:this.scaleSize(d.size)}),D(D(D({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),D(D(D({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var p=r.nodeDataCache[f],m=r.framedGraphToViewport(p),v=m.x,w=m.y,y=r.scaleSize(p.size),_=r.settings.defaultDrawNodeHover,k=r.nodePrograms[p.type],N=k?.drawHover||_;N(i,D(D({key:f},p),{},{size:y,x:v,y:w}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=jt(s,l,u,c),this.invMatrix=jt(s,l,u,c,!0),this.correctionRatio=ku(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=rm(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=im(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Nu,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=Tu(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=D({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return D({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=D({},this.settings);return this.settings[r]=i,Dr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=D({},this.settings);return this.settings=D(D({},this.settings),r),Dr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=yo(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(k){return i.addNode(k)}),this.graph.forEachEdge(function(k){return i.addEdge(k)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var p=this.nodeProgramIndex[f];if(p===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],p)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,w=m.length;v<w;v++){var y=m[v];if(this.updateEdge(y),o){var _=this.edgeProgramIndex[y];if(_===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],_)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(D(D({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(p);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?jt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Rr(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?jt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Rr(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(Tr),Mu=om;function Ae(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function am(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let p=e.get(f);if(p&&p.kind==="module"&&p.detail.path){let m=p.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function zu(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function sm(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function Fu(t){return t?t.kind==="module"||t.id.startsWith("vfolder:"):!1}function lm(t,e){return t.slice().sort((n,r)=>{let i=e.get(n),o=e.get(r),a=Fu(i),s=Fu(o);if(a!==s)return a?-1:1;let l=Ae(i),u=Ae(o);return l.localeCompare(u)})}function Ou(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function um(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?Ou(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?Ou(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function ko(t,e){let n=am(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=p=>{let w=(i.get(p)??[]).filter(y=>{let _=r.get(y);if(!_||_.kind!=="entryPoint")return!0;for(let[,k]of o)if(k.includes(y))return!1;return!0}).concat(o.get(p)??[]);return w=w.filter(y=>r.has(y)),e.showInternals||(w=w.filter(y=>{let _=r.get(y);return!(_&&sm(_.kind))})),lm(w,r)},l=e.provFilter!==null||e.query.length>0,u=p=>!(e.provFilter!==null&&p.provenance!==e.provFilter||e.query.length>0&&!Ae(p).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=p=>{let m=r.get(p),v=!1;for(let y of s(p))h(y)&&(v=!0);let w=u(m)||v;return w&&c.add(p),w};for(let p of a)h(p);let d=[],f=(p,m)=>{if(!c.has(p))return;let v=r.get(p),w=s(p),y=w.filter(k=>c.has(k)),_=l?y.length>0:e.expanded.has(p);if(d.push({id:p,depth:m,hasKids:w.length>0,expanded:_,label:Ae(v),kind:v.kind,provenance:v.provenance,meta:um(v)}),_)for(let k of y)f(k,m+1)};for(let p of a)f(p,0);return d}function Eo(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function En(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var cm=7;function So(t,e){if(t===null)return"";switch(t.kind){case"relTime":return En(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,cm);case"text":return t.text}}var dm=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function To(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of dm){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Ae(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Ae(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Ae(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Ao(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var hm=["contains","anchored-at"];function fm(t){return hm.includes(t)}function Gr(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=pm(t,n),i=zu(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,gm(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let p=s.get(d);u.set(d,{children:f,descendants:p,members:p.filter(m=>l.get(m)===d),provenance:mm(p,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:vm(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function pm(t,e){let n=new Map;for(let r of t.edges){if(!fm(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function gm(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function mm(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function vm(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function Ro(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var qt=[null,"human","agent","generated"];function $u(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Tt(t){return{...t.model,danglingLinks:t.dangling}}function Uu(t,e){return t===null?[]:ko(Tt(t),e)}var Yt="vfolder:\0draft";function Hu(t){return t.type==="vault"?"":t.type==="folder"?t.path:t.path.split("/").slice(0,-1).join("/")}function Wu(t,e){let n=e.trim();return n===""?null:t===""?n:`${t}/${n}`}function Bu(t,e){if(e===null)return[...t];let n={id:Yt,depth:e===""?1:e.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(e==="")return[...t,n];let r=t.findIndex(o=>o.id===`vfolder:${e}`);if(r===-1)return[...t,n];let i=r+1;for(;i<t.length&&t[i].depth>t[r].depth;)i++;return[...t.slice(0,i),n,...t.slice(i)]}function No(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Do(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function wm(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function Po(t){return t==="vault"?null:t.startsWith("vfolder:")?t.slice(8):void 0}function Sn(t){return t==="vault"?{type:"vault",path:""}:t.startsWith("note:")?{type:"note",path:t.slice(5)}:t.startsWith("vfolder:")?{type:"folder",path:t.slice(8)}:null}function Ku(t,e){return t===null?!1:e.type==="note"?t===`note:${e.path}`:e.type==="folder"?t===`vfolder:${e.path}`||t.startsWith(`vfolder:${e.path}/`)||t.startsWith(`note:${e.path}/`):!1}function Io(t){return t.type==="folder"}function Vu(t,e,n){return Io(t)?n?`Delete “${e}” and everything in it`:"Delete…":"Delete"}function ju(t,e){return t.query===e?t:{...t,query:e}}function qu(t){let e=qt.indexOf(t.provFilter),n=qt[(e+1)%qt.length]??null;return{...t,provFilter:n}}function Yu(t){return{...t,showInternals:!t.showInternals}}function Fr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function Lo(t,e){return t[e]?.id??null}function Co(t,e,n){if(t.length===0)return null;let r=Fr(t,e),i=r===-1?n>0?-1:t.length:r;return Lo(t,Math.min(t.length-1,Math.max(0,i+n)))}function bm(t,e){let n=Fr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var xm={j:"ArrowDown",k:"ArrowUp"};function _m(t){return xm[t]??t}function Xu(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=_m(r);if(s==="ArrowDown")return a(Co(t,n,1));if(s==="ArrowUp")return a(Co(t,n,-1));if(s==="Home")return a(Lo(t,0));if(s==="End")return a(Lo(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Fr(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(Co(t,n,1)):{state:Do(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:wm(e,n),selectedId:n,handled:!0};let c=bm(t,n);return c===null?o:a(c)}var km={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Go(t){return km[t]}var Em={human:"●",agent:"◐",generated:"○"};function At(t){return t===null?"":Em[t]}function Xt(t){return t===null?"":`${t}-authored`}function Zu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Sm(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function Tm(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:Zu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindIcon:Go(t.kind),provenance:t.provenance,provenanceGlyph:At(t.provenance),provenanceTitle:Xt(t.provenance),twisty:i,hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:So(t.meta,n),level:t.depth+1}}function Qu(t,e,n){let r=Sm(t);return t.map((i,o)=>Tm(i,e,n,r[o]))}function Ju(t,e){return Fr(t,e)===-1?null:Zu(e)}function ec(t){return{"--weave-depth":String(Math.max(0,t))}}function Mr(t){return t===null?"all":t}function tc(t){let e=qt.indexOf(t),n=qt[(e+1)%qt.length]??null;return`provenance filter: ${Mr(t)} — click for ${Mr(n)}`}function nc(t){return t?"internals":"knowledge"}function rc(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var ic="filter…",oc="Vault and repository",ac="Filter the tree",sc="Filter the tree (/)";function lc(t,e,n){if(t===null)return"loading…";let r=Eo(Tt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function uc(t){return t.length===1?"1 row":`${t.length} rows`}var Rt={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},Am={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Rm={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Cm(t,e){return Rt[e][Am[t]]}function cc(t,e){return Rt[e][Rm[t]]}function Lm(t,e){return Nm(t)?Mo(cc(t,e),e,Pm):cc(t,e)}function Nm(t){return t==="contains"||t==="anchored-at"}var Dm=.85,Pm=.3;function Or(t,e,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(t),o=r(e);if(i===null||o===null)return t;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function Mo(t,e,n=Dm){return Or(t,Rt[e].ground,n)}var Im={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},dc=1.6,fc=32,Gm=fc/2;function Mm(t,e=fc){if(e<=0)return t.length>0?"…":t;if(t.length<=e)return t;let n=e-1,i=t.slice(0,n).lastIndexOf(" "),o=i>=Gm?i:n;return`${t.slice(0,o).trimEnd()}…`}function Fm(t){let e=At(t.provenance),n=Ae(t);return Mm(e===""?n:`${e} ${n}`)}function pc(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var gc={nodes:[],edges:[]};function mc(t){return`${t.source}\0${t.target}\0${t.kind}`}function Om(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=mc(i);r.has(o)||(r.add(o),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function vc(t,e,n,r,i){let o=new Map;for(let h of t){if(o.has(h.id))continue;let d=n.get(h.id);d===void 0||!Number.isFinite(d.x)||!Number.isFinite(d.y)||o.set(h.id,h)}let a=new Set(o.keys()),s=Om(e,a),l=[];for(let[h,d]of o){let f=n.get(h),p=Ki(s.get(h)??0);l.push({id:h,x:f.x,y:f.y,size:p,label:Fm(d),color:i?.get(h)??Cm(d.kind,r),kind:d.kind,provenance:d.provenance,zIndex:Math.round(p),type:"circle"})}let u=[],c=new Set;for(let h of e){if(h.source===h.target||!a.has(h.source)||!a.has(h.target))continue;let d=mc(h);c.has(d)||(c.add(d),u.push({key:d,source:h.source,target:h.target,size:Im[h.kind],color:Lm(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:u}}function yc(t,e){return(n,r,i)=>t===null?{}:n===e&&t.has(n)?{zIndex:r.zIndex+hc*2,size:r.size*zm}:t.has(n)?{zIndex:r.zIndex+hc,size:r.size*$m}:{color:Mo(r.color,i),label:null,zIndex:0}}var zm=1.45,$m=1.15,hc=pr+1;function wc(t,e){return(n,r,i)=>t===null?{}:!t.has(r.source)||!t.has(r.target)?{color:Mo(r.color,i)}:e!=null&&(r.source===e||r.target===e)?{zIndex:2,size:r.size*dc*1.35,color:Rt[i].accent}:{zIndex:1,size:r.size*dc}}var Um=(fr+pr)/2,Hm=gr*4,Wm=1;function bc(t){let e=Rt[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Wm,labelGridCellSize:Hm,labelRenderedSizeThreshold:Um,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:gr,allowInvalidContainer:!0}}var Ec=dn(Sr(),1);function Bm(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var ce=Bm;typeof Object.assign=="function"&&(ce=Object.assign);function Ie(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function Sc(t){let e;for(e in t)return!1;return!0}function Pe(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function He(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function xc(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function Km(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function it(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function Qt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Rn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},L=class t extends Rn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},A=class t extends Rn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends Rn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function Tc(t,e){this.key=t,this.attributes=e,this.clear()}Tc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Ac(t,e){this.key=t,this.attributes=e,this.clear()}Ac.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Rc(t,e){this.key=t,this.attributes=e,this.clear()}Rc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Jt(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}Jt.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};Jt.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};Jt.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};Jt.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Cc=0,Lc=1,Vm=2,Nc=3;function ot(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===Cc){if(s=t._nodes.get(r),!s)throw new A(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===Nc){if(i=""+i,l=t._edges.get(i),!l)throw new A(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new A(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===Lc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return a.attributes[s]}}function qm(t,e,n){t.prototype[e]=function(r,i){let[o]=ot(this,e,n,r,i);return o.attributes}}function Ym(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function Xm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ot(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Zm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ot(this,e,n,r,i,o,a);if(typeof u!="function")throw new L(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Qm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(!me(s))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function ev(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(!me(s))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return ce(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function tv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(typeof s!="function")throw new L(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var nv=[{name:t=>`get${t}Attribute`,attacher:jm},{name:t=>`get${t}Attributes`,attacher:qm},{name:t=>`has${t}Attribute`,attacher:Ym},{name:t=>`set${t}Attribute`,attacher:Xm},{name:t=>`update${t}Attribute`,attacher:Zm},{name:t=>`remove${t}Attribute`,attacher:Qm},{name:t=>`replace${t}Attributes`,attacher:Jm},{name:t=>`merge${t}Attributes`,attacher:ev},{name:t=>`update${t}Attributes`,attacher:tv}];function rv(t){nv.forEach(function({name:e,attacher:n}){n(t,e("Node"),Cc),n(t,e("Source"),Lc),n(t,e("Target"),Vm),n(t,e("Opposite"),Nc)})}function iv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function ov(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=Ie(this,o,a,n),!i)throw new A(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function av(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function sv(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Ie(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function lv(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Ie(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new L(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function uv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function cv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function dv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return ce(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function hv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new L(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var fv=[{name:t=>`get${t}Attribute`,attacher:iv},{name:t=>`get${t}Attributes`,attacher:ov},{name:t=>`has${t}Attribute`,attacher:av},{name:t=>`set${t}Attribute`,attacher:sv},{name:t=>`update${t}Attribute`,attacher:lv},{name:t=>`remove${t}Attribute`,attacher:uv},{name:t=>`replace${t}Attributes`,attacher:cv},{name:t=>`merge${t}Attributes`,attacher:dv},{name:t=>`update${t}Attributes`,attacher:hv}];function pv(t){fv.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var gv=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function mv(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function vv(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function Fo(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function yv(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function wv(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function Oo(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function bv(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function Dc(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function xv(t,e){if(t.size===0)return Qt();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function zo(t,e,n,r,i,o){let a=e?vv:mv,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function _v(t,e,n,r){let i=[];return zo(!1,t,e,n,r,function(o){i.push(o)}),i}function kv(t,e,n){let r=Qt();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=it(r,Fo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=it(r,Fo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=it(r,Fo(n.undirected))),r}function $o(t,e,n,r,i,o,a){let s=n?wv:yv,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function Ev(t,e,n,r,i){let o=[];return $o(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Sv(t,e,n,r){let i=Qt();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=it(i,Oo(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=it(i,Oo(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=it(i,Oo(n.undirected,r))),i}function Tv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return bv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return _v(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){o=""+o,a=""+a;let s=this._nodes.get(o);if(!s)throw new A(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new A(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Ev(r,this.multi,i,s,a)}throw new L(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Av(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,Dc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return zo(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new A(`Graph.${o}: could not find the "${c}" target node in the graph.`);return $o(!1,r,this.multi,i,d,c,h)}throw new L(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((p,m,v,w,y,_,k)=>{h[f++]=c(p,m,v,w,y,_,k)})}else h=[],u.push((d,f,p,m,v,w,y)=>{h.push(c(d,f,p,m,v,w,y))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,p,m,v,w,y)=>{c(d,f,p,m,v,w,y)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new L(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new L(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,p,m,v,w,y,_)=>{d=c(d,f,p,m,v,w,y,_)}),this[o].apply(this,u),d}}function Rv(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,Dc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return zo(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new A(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new A(`Graph.${o}: could not find the "${u}" target node in the graph.`);return $o(!0,r,this.multi,i,h,u,c)}throw new L(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,p,m,v,w)=>u(h,d,f,p,m,v,w)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,p,m,v,w)=>!u(h,d,f,p,m,v,w)),!this[o].apply(this,l)}}function Cv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Qt();if(!arguments.length)return xv(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return kv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Sv(r,i,l,s)}throw new L(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Lv(t){gv.forEach(e=>{Tv(t,e),Av(t,e),Rv(t,e),Cv(t,e)})}var Nv=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Kr(){this.A=null,this.B=null}Kr.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Kr.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function Tn(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function Uo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return Tn(t,null,r,r.undirected,i);if(typeof n=="string")return Tn(t,null,r,r[n],i)}let o=new Kr,a;if(e!=="undirected"){if(n!=="out"){if(a=Tn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Tn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=Tn(t,o,r,r.undirected,i),t&&a))return a}function Dv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return Uo(!1,t,e,n,function(i){r.push(i)}),r}function An(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Pv(t,e,n){if(t!=="mixed"){if(t==="undirected")return An(null,n,n.undirected);if(typeof e=="string")return An(null,n,n[e])}let r=Qt(),i=new Kr;return t!=="undirected"&&(e!=="out"&&(r=it(r,An(i,n,n.in))),e!=="in"&&(r=it(r,An(i,n,n.out)))),t!=="directed"&&(r=it(r,An(i,n,n.undirected))),r}function Iv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return Dv(r==="mixed"?this.type:r,i,a)}}function Gv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);Uo(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new L(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=h;return this[o](u,(f,p)=>{d=c(d,f,p)}),d}}function Mv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Uo(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function Fv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Qt();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return Pv(r==="mixed"?this.type:r,i,s)}}function Ov(t){Nv.forEach(e=>{Iv(t,e),Gv(t,e),Mv(t,e),Fv(t,e)})}function zr(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let p=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,p=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),p=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!p&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function zv(t,e){let n={key:t};return Sc(e.attributes)||(n.attributes=ce({},e.attributes)),n}function $v(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return Sc(n.attributes)||(r.attributes=ce({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function Uv(t){if(!me(t))throw new L('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new L("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Hv(t){if(!me(t))throw new L('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new L("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new L("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Wv=Km(),Bv=new Set(["directed","undirected","mixed"]),_c=new Set(["domain","_events","_eventsCount","_maxListeners"]),Kv=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],Vv={allowSelfLoops:!0,multi:!1,type:"mixed"};function jv(t,e,n){if(n&&!me(n))throw new L(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function kc(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Pc(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new L(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new A(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new A(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new Jt(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function qv(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new L(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new L(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let y=[f.key,!1,!1,!1];if(l?!u:!s)return y;if(l){let _=f.attributes;f.attributes=u(_),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ce(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return y}s=s||{},l&&u&&(s=u(s));let p={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=kc(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=kc(t,a,{}),v=!0),d=new Jt(r,i,c,h,s),t._edges.set(i,d);let w=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,w&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,w&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,p.key=i,t.emit("edgeAdded",p),[i,!0,m,v]}function Zt(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var V=class t extends Ec.EventEmitter{constructor(e){if(super(),e=ce({},Vv,e),typeof e.multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Bv.has(e.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?Tc:e.type==="directed"?Ac:Rc;Pe(this,"NodeDataClass",n);let r="geid_"+Wv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Pe(this,"_attributes",{}),Pe(this,"_nodes",new Map),Pe(this,"_edges",new Map),Pe(this,"_directedSize",0),Pe(this,"_undirectedSize",0),Pe(this,"_directedSelfLoopCount",0),Pe(this,"_undirectedSelfLoopCount",0),Pe(this,"_edgeKeyGenerator",o),Pe(this,"_options",e),_c.forEach(a=>Pe(this,a,this[a])),He(this,"order",()=>this._nodes.size),He(this,"size",()=>this._edges.size),He(this,"directedSize",()=>this._directedSize),He(this,"undirectedSize",()=>this._undirectedSize),He(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),He(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),He(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),He(this,"multi",this._options.multi),He(this,"type",this._options.type),He(this,"allowSelfLoops",this._options.allowSelfLoops),He(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new L(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new A(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new A(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new A(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return jv(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new L(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ce(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new L(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Zt(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Zt(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Zt(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Ie(this,r,i,this.type),!n)throw new A(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new A(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Zt(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,n=""+n;let r=Ie(this,e,n,"directed");if(!r)throw new A(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Zt(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let r=Ie(this,e,n,"undirected");if(!r)throw new A(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Zt(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new L("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!me(e))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!me(e))throw new L("Graph.mergeAttributes: provided attributes are not a plain object.");return ce(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new L("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,n){if(typeof e!="function")throw new L("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!xc(n))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!xc(n))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");zr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");zr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");zr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new L("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");zr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new L("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new L("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new L("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new L("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new L("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new L("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=zv(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=$v(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,p)=>{n?p?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):p?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!me(e))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new L("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],Uv(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new L("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],Hv(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(ce({},this._options,e));return n.replaceAttributes(ce({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ce({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new M("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new M("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,Pc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ce({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!_c.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Pe(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(V.prototype[Symbol.for("nodejs.util.inspect.custom")]=V.prototype.inspect);Kv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?Pc:qv;t.generateKey?V.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:V.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});rv(V);pv(V);Lv(V);Ov(V);var $r=class extends V{constructor(e){let n=ce({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new L('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Ur=class extends V{constructor(e){let n=ce({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new L('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Hr=class extends V{constructor(e){let n=ce({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Wr=class extends V{constructor(e){let n=ce({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new L('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Br=class extends V{constructor(e){let n=ce({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new L('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function en(t){t.from=function(e,n){let r=ce({},e.options,n),i=new t(r);return i.import(e),i}}en(V);en($r);en(Ur);en(Hr);en(Wr);en(Br);V.Graph=V;V.DirectedGraph=$r;V.UndirectedGraph=Ur;V.MultiGraph=Hr;V.MultiDirectedGraph=Wr;V.MultiUndirectedGraph=Br;V.InvalidArgumentsGraphError=L;V.NotFoundGraphError=A;V.UsageGraphError=M;function Yv(){return new V({multi:!0,type:"directed"})}function Ho(t){let e=Yv();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function Ic(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Wo(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function Gc(t,e){let n=null,r=Ho({nodes:[],edges:[]}),i=null,o=null,a=()=>{},s=()=>{},l=()=>{},u=()=>{},c=null,h=p=>{if(c===null)return;let m=c;c=null,n?.setSetting("enableCameraPanning",!0),(p===null||p===m)&&u(m)},d=()=>pc([...Wo(r).values()]),f=p=>{let m=yc(i,o),v=wc(i,o);p.setSetting("nodeReducer",(w,y)=>({...y,...m(w,y,e)})),p.setSetting("edgeReducer",(w,y)=>({...y,...v(w,y,e)}))};return{mount(p){if(n!==null)return;let m=t(r,p,bc(e));m.on("clickNode",({node:v})=>a(v)),m.on("clickStage",()=>a(null)),m.on("downNode",({node:v})=>{c=v,n?.setSetting("enableCameraPanning",!1),s(v)}),m.on("moveBody",v=>{c!==null&&(v.preventSigmaDefault(),l(c,m.viewportToGraph({x:v.event.x,y:v.event.y})))}),m.on("upNode",()=>h(c)),m.on("upStage",()=>h(null)),f(m),m.setCustomBBox(d()),n=m},setGraph(p){r=Ho(p),n?.setGraph(r),n?.setCustomBBox(d())},setPositions(p){Ic(r,p),n?.refresh()},setHighlight(p,m=null){i=p,o=m,n!==null&&f(n)},onSelect(p){a=p},onDragStart(p){s=p},onDragMove(p){l=p},onDragEnd(p){u=p},fit(){n?.setCustomBBox(d()),n?.getCamera().animatedReset()},positions(){return Wo(r)},destroy(){n?.kill(),n=null}}}var Mc=t=>Gc((e,n,r)=>new Mu(e,n,r),t);var Fc=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Oc(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function zc(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function $c(t){return t===null?!1:(t.focus(),!0)}function Vr(){let t=Z(null);return oe(()=>{let e=document.activeElement;return t.current?.focus(),()=>{$c(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!zc(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(Fc)??[]],r=Oc(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function Wc(t,e){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i<0?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}function Xv(t){return Math.min(Math.max(t,0),10)*2}function Zv(t){return`note:${t}`}function Qv(t,e){return Wc(t.summary.title,e)+Xv(t.score)}function Jv(t,e){return Wc(t.label,e)}var ey=["path","manifest","url","slug"];function ty(t){for(let e of ey){let n=t.detail[e];if(typeof n=="string"&&n)return n}return""}function ny(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function ry(t,e,n,r){let i=new Map;for(let o of t){let a=Zv(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Qv(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Jv(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:ty(o),badge:o.kind,score:a})}return[...i.values()].sort(ny).slice(0,20)}function Bc(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Bo(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function Uc(t,e,n){return n<=0?0:((t+e)%n+n)%n}function Kc(t,e){return e===null?null:t[e]?.id??null}function Vc(t,e,n){let r={cursor:t,activate:null,dismiss:!1,handled:!1},i=Bo(t,n);return e==="ArrowDown"?{...r,cursor:Uc(i,1,n),handled:!0}:e==="ArrowUp"?{...r,cursor:Uc(i,-1,n),handled:!0}:e==="Home"?{...r,cursor:0,handled:!0}:e==="End"?{...r,cursor:Bo(n-1,n),handled:!0}:e==="Escape"?{...r,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var jr="Search the workspace",jc="Search notes and repository…",qc="↑↓ move · ↵ open · esc close";function iy(t,e){return t.query.trim()?e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading?"searching…":`no matches for “${t.query.trim()}”`:"Type to search notes, modules, files and entry points."}function oy(t){return t===1?"1 result":`${t} results`}function Hc(t){return`weave-search-row-${t}`}function Yc(t,e){let n=ry(t.hits,t.answered,e?.model.nodes??[],t.query),r=Bo(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Hc(a)})),status:iy(t,n.length),count:n.length,countLabel:oy(n.length),cursor:r,activeDomId:n.length?Hc(r):null}}var ay=0;function b(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ay,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return W.vnode&&W.vnode(u),u}function ly({row:t,onPick:e,onHover:n}){return b("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[b("span",{class:"weave-hit-badge",children:t.badge}),b("span",{class:"weave-hit-label",children:t.label}),b("span",{class:"weave-hit-detail",children:t.detail})]})}function Xc(t){let[e,n]=B(Bc),r=Z(0),i=Z(null),o=Vr(),a=Z(null);oe(()=>{a.current?.focus()},[]),oe(()=>{let u=e.query.trim(),c=!0;if(!u)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{c=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(m=>({...m,loading:!0,failed:!1}));let p=await El(t.ports.fetch,u,f.signal);!c||f.signal.aborted||d!==r.current||n(m=>p.ok?{...m,hits:p.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...m,loading:!1,failed:!0})},140);return()=>{c=!1,window.clearTimeout(h),i.current?.abort()}},[e.query,t.ports.fetch]);let s=Yc(e,t.graph),l=u=>{let c=Kc(s.rows,u);c!==null&&t.onSelect(c),t.onClose()};return b("div",{class:"weave-scrim",onClick:()=>l(null),children:b("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":jr,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let c=Vc(e.cursor,u.key,s.count);c.handled&&(u.preventDefault(),n(h=>({...h,cursor:c.cursor})),c.dismiss&&l(c.activate))},children:[b("input",{type:"search",class:"weave-palette-input",ref:a,value:e.query,placeholder:jc,"aria-label":jr,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:u=>n(c=>({...c,query:u.currentTarget.value,cursor:0}))}),s.status===null?b("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":jr,children:s.rows.map((u,c)=>b(ly,{row:u,onPick:()=>l(c),onHover:()=>n(h=>({...h,cursor:c}))},u.id))}):b("p",{class:"weave-palette-status",role:"status",children:s.status}),b("p",{class:"weave-palette-foot",children:[b("span",{children:s.countLabel}),b("span",{class:"weave-palette-hint",children:qc})]})]})})}var Zc="pi-weave.selection.v1";function Qc(t,e){try{return t.setItem(Zc,e??""),!0}catch{return!1}}function Jc(t,e){if(t===null)return null;let n;try{n=e.getItem(Zc)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}function ed(){return{graph:null,graphFailed:!1,note:null,recentIds:new Set,selectedId:null}}var uy=2e3,cy=3e3,nd=new Set;function dy(t,e){if(t===null)return nd;let n=new Set(t.model.nodes.map(r=>r.id));return new Set(e.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function td(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function rd(t){let e=t.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([f,p])=>e[f]===p)||(e={...e,...d},t.setState(e))},a=t.defer??((d,f)=>{let p=setTimeout(d,f);return()=>clearTimeout(p)}),s=async()=>{let d=td(e.selectedId);if(d===null){o({note:null});return}let f=await kl(t.fetch,d);f.ok&&o({note:f.data})},l=async()=>{let d=e.graph,f=await _l(t.fetch,e.graph);if(!f.ok)return e.graph===null&&o({graphFailed:!0}),f;if(!f.cached){let p=dy(d,f.data);o({graph:f.data,graphFailed:!1,recentIds:p}),i?.(),i=null,p.size>0&&(i=a(()=>{i=null,o({recentIds:nd})},cy))}return f},u=async()=>{if(!(n||r)){r=!0;try{let d=await l();d.ok&&!d.cached&&td(e.selectedId)!==null&&await s()}finally{r=!1}}},h=(t.repeat??((d,f)=>{let p=setInterval(d,f);return()=>clearInterval(p)}))(()=>{u()},uy);return u(),{refresh:()=>{u()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function id(t){return t==="contains"||t==="anchored-at"}function hy(t,e){let n=new Set(t.map(i=>i.id)),r=new Map;for(let i of e)id(i.kind)&&i.source!==i.target&&(!n.has(i.source)||!n.has(i.target)||r.has(i.target)||r.set(i.target,i.source));return r}function fy(t,e){let n=hy(t,e),r=new Map;for(let i of t){let o=i.id,a=i.id,s=0,l=new Set([o]);for(;;){let u=n.get(o);if(u===void 0||l.has(u))break;l.add(u),a=o,o=u,s++}r.set(i.id,{key:a,depth:Math.max(0,s-1)})}return r}function py(t){let e=new Map;for(let n of t.values())e.set(n,(e.get(n)??0)+1);return e}var gy={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},my=3;function vy(t,e){let n=gy[e],i=[...py(t).entries()].sort((a,s)=>s[1]-a[1]||(a[0]<s[0]?-1:a[0]>s[0]?1:0)),o=new Map;return i.forEach(([a],s)=>o.set(a,n[s*my%n.length])),o}var yy=.11,wy=.34;function by(t,e,n){let r=Number.isFinite(e)&&e>0?e:0;return Or(t,Rt[n].ground,Math.min(wy,r*yy))}var xy=.26,_y=.55;function ky(t,e,n){if(e.length===0)return t;let r=t,i=0;for(let o of e){let a=Math.min(xy,_y-i);if(a<=0)break;i+=a,r=Or(r,o,a)}return r}function od(t,e,n){let r=fy(t,e),i=new Map;for(let[c,h]of r)i.set(c,h.key);let o=vy(i,n),a=new Set(t.map(c=>c.id)),s=new Map,l=(c,h)=>{let d=r.get(c)?.key,f=r.get(h)?.key;if(d===void 0||f===void 0||d===f)return;let p=s.get(c);p===void 0?s.set(c,new Set([f])):p.add(f)};for(let c of e)id(c.kind)||c.source!==c.target&&(!a.has(c.source)||!a.has(c.target)||(l(c.source,c.target),l(c.target,c.source)));let u=new Map;for(let c of t){let h=r.get(c.id);if(h===void 0)continue;let d=o.get(h.key);if(d===void 0)continue;let f=by(d,h.depth,n),p=[...s.get(c.id)??[]].sort().map(m=>o.get(m)).filter(m=>m!==void 0);u.set(c.id,ky(f,p,n))}return u}function ad(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var Ey=300,Sy=1;function Ty(t,e,n){let r=new Map(n??[]);if(r.size>0)for(let o of e){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:Ey,seed:Sy,pinWarm:!0};return r.size>0&&(i.initial=r),Js({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function Ay(t,e){let n=0,r=0;for(let o of t){let a=ad(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=ad(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var qr="pi-weave.graph.positions.v4";function sd(t){return Math.round(t*10)/10}function Ry(t,e){let n={};for(let[r,i]of e)n[r]=[sd(i.x),sd(i.y)];return JSON.stringify({v:4,key:t,at:n})}function Cy(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==4||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function Ly(t,e){let n;try{n=t.getItem(qr)}catch{return null}return Cy(n,e)}function Ny(t,e,n){try{return t.setItem(qr,Ry(e,n)),!0}catch{return!1}}function ld(t,e,n){let r=Ay(e,n),i=Ly(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Ty(e,n);return Ny(t,r,o),{key:r,positions:o,cached:!1}}function Dy(t){return{expanded:new Set(Gr(t,new Set).clusters.keys())}}function cd(t,e){return e!==null?e:t===null?{expanded:new Set}:Dy(Tt(t))}function Py(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Iy(t,e){return e===null?null:Ao(e,t)}var dd="fit",hd="frame the whole graph",fd="sliders",pd="tune the layout physics and colours",Yr={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function gd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function Gy(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var My="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",ud={graph:gc,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function md(t,e,n,r,i,o=!1,a=!0){if(t===null)return o?{...ud,empty:My}:ud;let s=Tt(t),l=Gr(s,n.expanded),c=n.expanded.has("vault")?l.edges.filter(f=>f.source!=="vault"&&f.target!=="vault"):l.edges,h=ld(r,l.nodes,c),d=a?od(l.nodes,c,i):void 0;return{graph:vc(l.nodes,c,h.positions,i,d),highlight:Iy(c,e),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Gy(t,l.nodes.length)}}function vd(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:Py(t,n),selectedId:n}}var Fy=.06,Oy=.2,Ko=.001,yd=.5;function wd(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(s=>{let l=e?.get(s.id);return{id:s.id,x:l!==void 0&&Number.isFinite(l.x)?l.x:s.x,y:l!==void 0&&Number.isFinite(l.y)?l.y:s.y,vx:0,vy:0,r:Vi(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of t.edges){if(s.source===s.target||!r.has(s.source)||!r.has(s.target))continue;let l=`${s.source}\0${s.target}\0${s.kind}`;i.has(l)||(i.add(l),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=qi({nodes:n,links:o,seed:1}).alpha(Fy).alphaMin(Ko);return{tick(){a.tick()},awake(){return a.alphaTarget()>Ko||a.alpha()>Ko},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let u=r.get(s);if(!u)return;let c=u.fx!=null&&u.fy!=null&&Math.abs(u.fx-l.x)<yd&&Math.abs(u.fy-l.y)<yd;u.fx=l.x,u.fy=l.y,a.alphaTarget(c?0:Oy)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}function bd(t){let[,e]=B(0),[n,r]=B(!1),i=(a,s)=>{ji({[a.key]:rl(a,s)}),r(!1),e(l=>l+1),t.onChange()},o=a=>{ji(a),r(!1),e(s=>s+1),t.onChange()};return b("div",{class:"weave-tuner",children:[b("p",{class:"weave-tuner-title",children:"graph forces · ?sliders=1"}),b("label",{class:"weave-tuner-toggle",title:"hue per containment group, shade per kind",children:[b("input",{type:"checkbox",checked:t.groupColors,onChange:a=>t.onGroupColors(a.currentTarget.checked)}),b("span",{children:"colour by group"})]}),mr.map(a=>b("label",{class:"weave-tuner-row",title:a.hint,children:[b("span",{class:"weave-tuner-label",children:[a.label,b("b",{children:il(ve[a.key])})]}),b("input",{type:"range",min:a.min,max:a.max,step:a.step,value:nl(ve,a),onInput:s=>i(a,s.currentTarget.value)})]},a.key)),b("div",{class:"weave-tuner-actions",children:[b("button",{type:"button",class:"weave-chip",disabled:ol(ve),onClick:()=>o(vn),children:"reset"}),b("button",{type:"button",class:"weave-chip",title:"the pre-tuner constants, for comparison — see HAIRBALL",onClick:()=>o(tl),children:"before"}),b("button",{type:"button",class:"weave-chip",onClick:()=>{navigator.clipboard?.writeText(Yi(ve)).then(()=>r(!0),()=>r(!1))},children:n?"copied ✓":"copy values"})]}),b("pre",{class:"weave-tuner-snippet",children:Yi(ve)})]})}function xd(t){let e=Z(null),n=Z(null),r=Z(null),i=Z(null),o=yl(()=>{if(i.current!==null)return;let y=()=>{i.current=null;let _=r.current;_!==null&&(_.tick(),_.awake()&&(n.current?.setPositions(_.positions()),i.current=requestAnimationFrame(y)))};i.current=requestAnimationFrame(y)},[]),[a,s]=B(null),[l,u]=B(0),[c,h]=B(()=>sl(t.storage)),[d,f]=B(t.tuner===!0),p=t.scheme??br(t.host),m=cd(t.graph,a),v=Ze(()=>md(t.graph,t.selectedId,m,t.storage,p,t.bootFailed,c),[t.graph,t.selectedId,m,t.storage,p,t.bootFailed,l,c]),w=Z({view:m,model:v,onSelect:t.onSelect,selectedId:t.selectedId});return w.current={view:m,model:v,onSelect:t.onSelect,selectedId:t.selectedId},oe(()=>{let y=t.renderer(p);return y.onSelect(_=>{let k=vd(w.current.view,w.current.model.clusters,_);s(k.state),w.current.onSelect(k.selectedId)}),y.onDragStart(_=>{let k=n.current?.positions().get(_);k&&(r.current?.pin(_,k),o())}),y.onDragMove((_,k)=>{r.current?.pin(_,k)}),y.onDragEnd(_=>{r.current?.release(_)}),y.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=y,y.setGraph(w.current.model.graph),y.setHighlight(w.current.model.highlight,w.current.selectedId),t.fit.current=()=>y.fit(),()=>{y.destroy(),n.current=null,t.fit.current=null}},[t.renderer,p]),oe(()=>{n.current?.setGraph(v.graph)},[v.key,l,c]),oe(()=>{let y=wd(v.graph,n.current?.positions());return r.current=y,y!==null&&o(),()=>{r.current=null}},[v.key,o,l]),oe(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),oe(()=>{n.current?.setHighlight(v.highlight,t.selectedId)},[v.highlight,t.selectedId]),b("div",{class:"weave-graph",children:[v.empty===null?null:b("p",{class:"weave-graph-empty",children:v.empty}),b("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),d?b(bd,{groupColors:c,onGroupColors:y=>{ll(t.storage,y),h(y)},onChange:()=>{try{t.storage.setItem(qr,"")}catch{}u(y=>y+1)}}):null,b("div",{class:"weave-graph-controls",children:[b("button",{type:"button",class:"weave-chip",title:hd,onClick:()=>n.current?.fit(),children:dd}),b("button",{type:"button",class:d?"weave-chip weave-chip-on":"weave-chip",title:pd,"aria-pressed":d,onClick:()=>f(!d),children:fd}),b("span",{class:"weave-graph-legend",children:[b("span",{class:"weave-legend-on",children:["◉ ",Yr.selected]}),b("span",{class:"weave-legend-near",children:["● ",Yr.neighborhood]}),b("span",{class:"weave-legend-dim",children:["· ",Yr.dimmed]})]})]}),b("p",{class:"weave-graph-count",children:gd(v.visible,v.total)})]})}function _d(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function zy(t){if(Array.isArray(t))return t}function $y(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Uy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
334
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hy(t,e){return zy(t)||$y(t,e)||Wy(t,e)||Uy()}function Wy(t,e){if(t){if(typeof t=="string")return _d(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_d(t,e):void 0}}var Fd=Object.entries,kd=Object.setPrototypeOf,By=Object.isFrozen,Ky=Object.getPrototypeOf,Vy=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,tn=Object.create,Od=typeof Reflect<"u"&&Reflect,Qo=Od.apply,Jo=Od.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});Qo||(Qo=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});Jo||(Jo=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Lt=se(Array.prototype.forEach),jy=se(Array.prototype.lastIndexOf),Ed=se(Array.prototype.pop),Cn=se(Array.prototype.push),qy=se(Array.prototype.splice),nn=Array.isArray,Dn=se(String.prototype.toLowerCase),Vo=se(String.prototype.toString),Sd=se(String.prototype.match),Ln=se(String.prototype.replace),Td=se(String.prototype.indexOf),Yy=se(String.prototype.trim),Xy=se(Number.prototype.toString),Zy=se(Boolean.prototype.toString),Ad=typeof BigInt>"u"?null:se(BigInt.prototype.toString),Rd=typeof Symbol>"u"?null:se(Symbol.prototype.toString),Te=se(Object.prototype.hasOwnProperty),Nn=se(Object.prototype.toString),ye=se(RegExp.prototype.test),Ct=Qy(TypeError);function se(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Qo(t,e,r)}}function Qy(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Jo(t,n)}}function H(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Dn;if(kd&&kd(t,null),!nn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(By(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Jy(t){for(let e=0;e<t.length;e++)Te(t,e)||(t[e]=null);return t}function Ce(t){let e=tn(null);for(let r of Fd(t)){var n=Hy(r,2);let i=n[0],o=n[1];Te(t,i)&&(nn(o)?e[i]=Jy(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ce(o):e[i]=o)}return e}function ew(t){switch(typeof t){case"string":return t;case"number":return Xy(t);case"boolean":return Zy(t);case"bigint":return Ad?Ad(t):"0";case"symbol":return Rd?Rd(t):"Symbol()";case"undefined":return Nn(t);case"function":case"object":{if(t===null)return Nn(t);let e=t,n=We(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Nn(r)}return Nn(t)}default:return Nn(t)}}function We(t,e){for(;t!==null;){let r=Vy(t,e);if(r){if(r.get)return se(r.get);if(typeof r.value=="function")return se(r.value)}t=Ky(t)}function n(){return null}return n}function tw(t){try{return ye(t,""),!0}catch{return!1}}var Cd=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),jo=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),qo=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),nw=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Yo=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),rw=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ld=de(["#text"]),Nd=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Xo=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Dd=de(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xr=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),iw=pe(/{{[\w\W]*|^[\w\W]*}}/g),ow=pe(/<%[\w\W]*|^[\w\W]*%>/g),aw=pe(/\${[\w\W]*/g),sw=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),lw=pe(/^aria-[\-\w]+$/),Pd=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),uw=pe(/^(?:\w+script|data):/i),cw=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dw=pe(/^html$/i),hw=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),Id=pe(/<[/\w!]/g),Gd=pe(/<[/\w]/g),fw=pe(/<\/no(script|embed|frames)/i),pw=pe(/\/>/i),Re={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},zd=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],gw=de(H({},zd)),mw=(function(){let t={};return Lt(zd,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),vw=function(){return typeof window>"u"?null:window},yw=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Md=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},pt=function(e,n,r,i){return Te(e,n)&&nn(e[n])?H(i.base?Ce(i.base):{},e[n],i.transform):r},Zo=function(e,n,r){let i=Te(e,n)?e[n]:void 0;return i&&typeof i=="object"?Ce(i):r()};function $d(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vw(),e=T=>$d(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Re.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=We(d,"cloneNode"),p=We(d,"remove"),m=We(d,"nextSibling"),v=We(d,"childNodes"),w=We(d,"parentNode"),y=We(d,"shadowRoot"),_=We(d,"attributes"),k=a&&a.prototype?We(a.prototype,"nodeType"):null,N=a&&a.prototype?We(a.prototype,"nodeName"):null,R=a&&a.prototype?We(a.prototype,"ownerDocument"):null,P=function(g){return k?k(g):g.nodeType},z=function(g){return N?N(g):g.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let O,G="",U,q=!1,ee=0,ge=function(){if(ee>0)throw Ct('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},he=function(g){ge(),ee++;try{return O.createHTML(g)}finally{ee--}},Ve=function(g){ge(),ee++;try{return O.createScriptURL(g)}finally{ee--}},It=function(){return q||(U=yw(h,i),q=!0),U},Ge=n,Me=Ge.implementation,Fe=Ge.createNodeIterator,je=Ge.createDocumentFragment,an=Ge.getElementsByTagName,Ne=r.importNode,Y=Md();e.isSupported=typeof Fd=="function"&&typeof w=="function"&&Me&&Me.createHTMLDocument!==void 0;let sn=iw,Df=ow,Pf=aw,If=sw,Gf=lw,Mf=uw,Ta=cw,Ff=hw,Aa=Pd,Q=null,di=H({},[...Cd,...jo,...qo,...Yo,...Ld]),J=null,hi=H({},[...Nd,...Xo,...Dd,...Xr]),qe=Object.seal(tn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ln=null,Ra=null,lt=Object.seal(tn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ca=!0,fi=!0,La=!1,Na=!0,ut=!1,mt=!0,vt=!1,pi=!1,Un=null,Hn=null,gi=!1,Gt=!1,Wn=!1,Bn=!1,Da=!0,Pa=!1,Ia="user-content-",mi=!0,vi=!1,Mt={},Ft=null,Ga=H({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Ma=null,Fa=H({},["audio","video","img","source","image","track"]),Oa=null,za=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Kn="http://www.w3.org/1998/Math/MathML",Vn="http://www.w3.org/2000/svg",Ye="http://www.w3.org/1999/xhtml",Ot=Ye,yi=!1,wi=null,Of=H({},[Kn,Vn,Ye],Vo),$a=de(["mi","mo","mn","ms","mtext"]),bi=H({},$a),Ua=de(["annotation-xml"]),xi=H({},Ua),zf=H({},["title","style","font","a","script"]),un=null,$f=["application/xhtml+xml","text/html"],Uf="text/html",re=null,zt=null,Hf=n.createElement("form"),Ha=function(g){return g instanceof RegExp||g instanceof Function},_i=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(zt&&zt===g)return;(!g||typeof g!="object")&&(g={}),g=Ce(g),un=$f.indexOf(g.PARSER_MEDIA_TYPE)===-1?Uf:g.PARSER_MEDIA_TYPE,re=un==="application/xhtml+xml"?Vo:Dn,Q=pt(g,"ALLOWED_TAGS",di,{transform:re}),J=pt(g,"ALLOWED_ATTR",hi,{transform:re}),wi=pt(g,"ALLOWED_NAMESPACES",Of,{transform:Vo}),Oa=pt(g,"ADD_URI_SAFE_ATTR",za,{transform:re,base:za}),Ma=pt(g,"ADD_DATA_URI_TAGS",Fa,{transform:re,base:Fa}),Ft=pt(g,"FORBID_CONTENTS",Ga,{transform:re}),ln=pt(g,"FORBID_TAGS",Ce({}),{transform:re}),Ra=pt(g,"FORBID_ATTR",Ce({}),{transform:re}),Mt=Te(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?Ce(g.USE_PROFILES):g.USE_PROFILES:!1,Ca=g.ALLOW_ARIA_ATTR!==!1,fi=g.ALLOW_DATA_ATTR!==!1,La=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Na=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ut=g.SAFE_FOR_TEMPLATES||!1,mt=g.SAFE_FOR_XML!==!1,vt=g.WHOLE_DOCUMENT||!1,Gt=g.RETURN_DOM||!1,Wn=g.RETURN_DOM_FRAGMENT||!1,Bn=g.RETURN_TRUSTED_TYPE||!1,gi=g.FORCE_BODY||!1,Da=g.SANITIZE_DOM!==!1,Pa=g.SANITIZE_NAMED_PROPS||!1,mi=g.KEEP_CONTENT!==!1,vi=g.IN_PLACE||!1,Aa=tw(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:Pd,Ot=typeof g.NAMESPACE=="string"?g.NAMESPACE:Ye,bi=Zo(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},$a)),xi=Zo(g,"HTML_INTEGRATION_POINTS",()=>H({},Ua));let x=Zo(g,"CUSTOM_ELEMENT_HANDLING",()=>tn(null));if(qe=tn(null),Te(x,"tagNameCheck")&&Ha(x.tagNameCheck)&&(qe.tagNameCheck=x.tagNameCheck),Te(x,"attributeNameCheck")&&Ha(x.attributeNameCheck)&&(qe.attributeNameCheck=x.attributeNameCheck),Te(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(qe.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),pe(qe),ut&&(fi=!1),Wn&&(Gt=!0),Mt&&(Q=H({},Ld),J=tn(null),Mt.html===!0&&(H(Q,Cd),H(J,Nd)),Mt.svg===!0&&(H(Q,jo),H(J,Xo),H(J,Xr)),Mt.svgFilters===!0&&(H(Q,qo),H(J,Xo),H(J,Xr)),Mt.mathMl===!0&&(H(Q,Yo),H(J,Dd),H(J,Xr))),lt.tagCheck=null,lt.attributeCheck=null,Te(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?lt.tagCheck=g.ADD_TAGS:nn(g.ADD_TAGS)&&(Q===di&&(Q=Ce(Q)),H(Q,g.ADD_TAGS,re))),Te(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?lt.attributeCheck=g.ADD_ATTR:nn(g.ADD_ATTR)&&(J===hi&&(J=Ce(J)),H(J,g.ADD_ATTR,re))),Te(g,"ADD_FORBID_CONTENTS")&&nn(g.ADD_FORBID_CONTENTS)&&(Ft===Ga&&(Ft=Ce(Ft)),H(Ft,g.ADD_FORBID_CONTENTS,re)),mi&&(Q["#text"]=!0),vt&&H(Q,["html","head","body"]),Q.table&&(H(Q,["tbody"]),delete ln.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=O;O=g.TRUSTED_TYPES_POLICY;try{G=he("")}catch(C){throw O=E,C}}else g.TRUSTED_TYPES_POLICY===null?(O=void 0,G=""):(O===void 0&&(O=It()),O&&typeof G=="string"&&(G=he("")));de&&de(g),zt=g},Wa=H({},[...jo,...qo,...nw]),Ba=H({},[...Yo,...rw]),Wf=function(g,x,E){return x.namespaceURI===Ye?g==="svg":x.namespaceURI===Kn?g==="svg"&&(E==="annotation-xml"||bi[E]):!!Wa[g]},Bf=function(g,x,E){return x.namespaceURI===Ye?g==="math":x.namespaceURI===Vn?g==="math"&&xi[E]:!!Ba[g]},Kf=function(g,x,E){return x.namespaceURI===Vn&&!xi[E]||x.namespaceURI===Kn&&!bi[E]?!1:!Ba[g]&&(zf[g]||!Wa[g])},Vf=function(g){let x=w(g);(!x||!x.tagName)&&(x={namespaceURI:Ot,tagName:"template"});let E=Dn(g.tagName),C=Dn(x.tagName);return wi[g.namespaceURI]?g.namespaceURI===Vn?Wf(E,x,C):g.namespaceURI===Kn?Bf(E,x,C):g.namespaceURI===Ye?Kf(E,x,C):!!(un==="application/xhtml+xml"&&wi[g.namespaceURI]):!1},ct=function(g){Cn(e.removed,{element:g});try{w(g).removeChild(g)}catch{if(p(g),!w(g))throw Ct("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ka=function(g,x,E){try{g.removeAttributeNode(x)}catch{try{g.removeAttribute(E)}catch{}}},jn=function(g){qn(g);let x=v(g);if(x){let C=[];Lt(x,I=>{Cn(C,I)}),Lt(C,I=>{try{p(I)}catch{}})}let E=_(g);if(E)for(let C=E.length-1;C>=0;--C){let I=E[C],F=I&&I.name;typeof F=="string"&&Ka(g,I,F)}},yt=function(g,x,E){if(!E)try{E=x.getAttributeNode(g)}catch{E=null}Cn(e.removed,{attribute:E||null,from:x});try{E?x.removeAttributeNode(E):x.removeAttribute(g)}catch{try{x.removeAttribute(g)}catch{}}if(g==="is")if(Gt||Wn)try{ct(x)}catch{}else try{x.setAttribute(g,"")}catch{}},jf=function(g){let x=_(g);if(x)for(let E=x.length-1;E>=0;--E){let C=x[E],I=C&&C.name;typeof I!="string"||J[re(I)]||Ka(g,C,I)}},qn=function(g){let x=[g];for(;x.length>0;){let E=x.pop();P(E)===Re.element&&jf(E);let I=v(E);if(I)for(let F=I.length-1;F>=0;--F)x.push(I[F])}},Va=function(g,x){return mt?g==="patchsrc"?!0:g==="for"&&x!=="label"&&x!=="output":!1},qf=function(g){if(!mt)return;let x=[g];for(;x.length>0;){let E=x.pop(),C=P(E);if(C===Re.processingInstruction||C===Re.comment&&ye(Gd,E.data)){try{p(E)}catch{}continue}if(C===Re.element){let F=E,X=re(z(E));try{F.hasAttribute&&F.hasAttribute("patchsrc")&&F.removeAttribute("patchsrc"),F.hasAttribute&&F.hasAttribute("for")&&Va("for",X)&&F.removeAttribute("for")}catch{}}let I=v(E);if(I)for(let F=I.length-1;F>=0;--F)x.push(I[F])}},ja=function(g){let x=null,E=null;if(gi)g="<remove></remove>"+g;else{let F=Sd(g,/^[\r\n\t ]+/);E=F&&F[0]}un==="application/xhtml+xml"&&Ot===Ye&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let C=O?he(g):g;if(Ot===Ye)try{x=new c().parseFromString(C,un)}catch{}if(!x||!x.documentElement){x=Me.createDocument(Ot,"template",null);try{x.documentElement.innerHTML=yi?G:C}catch{}}let I=x.body||x.documentElement;return g&&E&&I.insertBefore(n.createTextNode(E),I.childNodes[0]||null),Ot===Ye?an.call(x,vt?"html":"body")[0]:vt?x.documentElement:I},qa=function(g){let x=R?R(g):g.ownerDocument;return Fe.call(x||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Yn=function(g){return g=Ln(g,sn," "),g=Ln(g,Df," "),g=Ln(g,Pf," "),g},ki=function(g){var x;g.normalize();let E=R?R(g):g.ownerDocument,C=Fe.call(E||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),I=C.nextNode();for(;I;)I.data=Yn(I.data),I=C.nextNode();let F=(x=g.querySelectorAll)===null||x===void 0?void 0:x.call(g,"template");F&&Lt(F,X=>{$t(X.content)&&ki(X.content)})},Xn=function(g){let x=N?N(g):null;return typeof x!="string"||re(x)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==_(g)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==k(g)||g.childNodes!==v(g)},$t=function(g){if(!k||typeof g!="object"||g===null)return!1;try{return k(g)===Re.documentFragment}catch{return!1}},cn=function(g){if(!k||typeof g!="object"||g===null)return!1;try{return typeof k(g)=="number"}catch{return!1}};function Xe(T,g,x){T.length!==0&&Lt(T,E=>{E.call(e,g,x,zt)})}let Yf=function(g,x){return!!(mt&&g.hasChildNodes()&&!cn(g.firstElementChild)&&ye(Id,g.textContent)&&ye(Id,g.innerHTML)||mt&&g.namespaceURI===Ye&&gw[x]&&(cn(g.firstElementChild)||typeof g.textContent=="string"&&ye(mw[x],g.textContent))||g.nodeType===Re.processingInstruction||mt&&g.nodeType===Re.comment&&ye(Gd,g.data))},Zn=function(g,x){if(g instanceof RegExp)return ye(g,x);if(g instanceof Function){for(var E=arguments.length,C=new Array(E>2?E-2:0),I=2;I<E;I++)C[I-2]=arguments[I];return!!g(x,...C)}return!1},Xf=function(g,x,E){if(!ln[x]&&Ja(x)&&Zn(qe.tagNameCheck,x))return!1;if(mi&&!Ft[x]){let C=w(g),I=v(g);if(I&&C){let F=I.length;for(let X=F-1;X>=0;--X){let te=g===E?f(I[X],!0):I[X];C.insertBefore(te,m(g))}}}return ct(g),!0},Ya=function(g,x,E,C){return g.length===0?x:x===E||x===C?Ce(x):x},Xa=function(g,x){return g===x||w(g)!==null?!1:(vi&&qn(g),!0)},Za=function(g,x){if(Xe(Y.beforeSanitizeElements,g,null),Xa(g,x))return!0;if(Xn(g))return ct(g),!0;let E=re(z(g));if(Q=Ya(Y.uponSanitizeElement,Q,di,Un),Xe(Y.uponSanitizeElement,g,{tagName:E,allowedTags:Q}),Xa(g,x))return!0;if(Yf(g,E))return ct(g),!0;if(ln[E]||!(lt.tagCheck instanceof Function&&lt.tagCheck(E))&&!Q[E]){let I=Xf(g,E,x);return I===!1&&Xe(Y.afterSanitizeElements,g,null),I}if(P(g)===Re.element&&!Vf(g)||(E==="noscript"||E==="noembed"||E==="noframes")&&ye(fw,g.innerHTML))return ct(g),!0;if(ut&&g.nodeType===Re.text){let I=Yn(g.textContent);g.textContent!==I&&(Cn(e.removed,{element:g.cloneNode()}),g.textContent=I)}return Xe(Y.afterSanitizeElements,g,null),!1},Qa=function(g,x,E){if(Ra[x]||Va(x,g)||Da&&(x==="id"||x==="name")&&(E in n||E in Hf))return!1;let C=J[x]||lt.attributeCheck instanceof Function&&lt.attributeCheck(x,g);return fi&&ye(If,x)||Ca&&ye(Gf,x)?!0:C?Oa[x]||ye(Aa,Ln(E,Ta,""))||(x==="src"||x==="xlink:href"||x==="href")&&g!=="script"&&Td(E,"data:")===0&&Ma[g]||La&&!ye(Mf,Ln(E,Ta,""))?!0:!E:Ja(g)&&Zn(qe.tagNameCheck,g)&&Zn(qe.attributeNameCheck,x,g)||x==="is"&&qe.allowCustomizedBuiltInElements&&Zn(qe.tagNameCheck,E)},Zf=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ja=function(g){return!Zf[Dn(g)]&&ye(Ff,g)},Qf=function(g,x,E,C){if(O&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(g,x)){case"TrustedHTML":return he(C);case"TrustedScriptURL":return Ve(C)}return C},Jf=function(g,x,E,C){try{E?g.setAttributeNS(E,x,C):g.setAttribute(x,C),Xn(g)?ct(g):Ed(e.removed)}catch{yt(x,g)}},es=function(g){Xe(Y.beforeSanitizeAttributes,g,null);let x=g.attributes;if(!x||Xn(g))return;J=Ya(Y.uponSanitizeAttribute,J,hi,Hn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0},C=x.length,I=re(g.nodeName);for(;C--;){let F=x[C],X=F.name,te=F.namespaceURI,Ee=F.value,Se=re(X),Si=Ee,be=X==="value"?Si:Yy(Si);if(E.attrName=Se,E.attrValue=be,E.keepAttr=!0,E.forceKeepAttr=void 0,Xe(Y.uponSanitizeAttribute,g,E),be=E.attrValue,Pa&&(Se==="id"||Se==="name")&&Td(be,Ia)!==0&&(yt(X,g,F),be=Ia+be),mt&&ye(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,be)){yt(X,g,F);continue}if(Se==="attributename"&&Sd(be,"href")){yt(X,g,F);continue}if(!E.forceKeepAttr){if(!E.keepAttr){yt(X,g,F);continue}if(!Na&&ye(pw,be)){yt(X,g,F);continue}if(ut&&(be=Yn(be)),!Qa(I,Se,be)){yt(X,g,F);continue}be=Qf(I,Se,te,be),be!==Si&&Jf(g,X,te,be)}}Xe(Y.afterSanitizeAttributes,g,null)},Qn=function(g){let x=null,E=qa(g);for(Xe(Y.beforeSanitizeShadowDOM,g,null);x=E.nextNode();)if(Xe(Y.uponSanitizeShadowNode,x,null),Za(x,g),es(x),$t(x.content)&&Qn(x.content),P(x)===Re.element){let C=y(x);$t(C)&&(Ei(C),Qn(C))}Xe(Y.afterSanitizeShadowDOM,g,null)},Ei=function(g){let x=[{node:g,shadow:null}];for(;x.length>0;){let E=x.pop();if(E.shadow){Qn(E.shadow);continue}let C=E.node,F=P(C)===Re.element,X=v(C);if(X)for(let te=X.length-1;te>=0;--te)x.push({node:X[te],shadow:null});if(F){let te=N?N(C):null;if(typeof te=="string"&&re(te)==="template"){let Ee=C.content;$t(Ee)&&x.push({node:Ee,shadow:null})}}if(F){let te=y(C);$t(te)&&x.push({node:null,shadow:te},{node:te,shadow:null})}}};return e.sanitize=function(T){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,E=null,C=null,I=null;if(yi=!T,yi&&(T="<!-->"),typeof T!="string"&&!cn(T)&&(T=ew(T),typeof T!="string"))throw Ct("dirty is not a string, aborting");if(!e.isSupported)return T;pi?(Q=Un,J=Hn):_i(g),(Y.uponSanitizeElement.length>0||Y.uponSanitizeAttribute.length>0)&&(Q=Ce(Q)),Y.uponSanitizeAttribute.length>0&&(J=Ce(J)),e.removed=[];let F=vi&&typeof T!="string"&&cn(T);if(F){qf(T);let Ee=z(T);if(typeof Ee=="string"){let Se=re(Ee);if(!Q[Se]||ln[Se])throw jn(T),Ct("root node is forbidden and cannot be sanitized in-place")}if(Xn(T))throw jn(T),Ct("root node is clobbered and cannot be sanitized in-place");try{Ei(T)}catch(Se){throw jn(T),Se}}else if(cn(T))x=ja("<!---->"),E=x.ownerDocument.importNode(T,!0),E.nodeType===Re.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?x=E:x.appendChild(E),Ei(E);else{if(!Gt&&!ut&&!vt&&T.indexOf("<")===-1)return O&&Bn?he(T):T;if(x=ja(T),!x)return Gt?null:Bn?G:""}x&&gi&&ct(x.firstChild);let X=F?T:x;try{let Ee=qa(X);for(;C=Ee.nextNode();)Za(C,X),es(C),$t(C.content)&&Qn(C.content)}catch(Ee){throw F&&(jn(T),Lt(e.removed,Se=>{Se.element&&qn(Se.element)})),Ee}if(F)return Lt(e.removed,Ee=>{Ee.element&&qn(Ee.element)}),ut&&ki(T),T;if(Gt){if(ut&&ki(x),Wn)for(I=je.call(x.ownerDocument);x.firstChild;)I.appendChild(x.firstChild);else I=x;return(J.shadowroot||J.shadowrootmode)&&(I=Ne.call(r,I,!0)),I}let te=vt?x.outerHTML:x.innerHTML;return vt&&Q["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&ye(dw,x.ownerDocument.doctype.name)&&(te="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
335
- `+te),ut&&(te=Yn(te)),O&&Bn?he(te):te},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_i(T),pi=!0,Un=Q,Hn=J},e.clearConfig=function(){zt=null,pi=!1,Un=null,Hn=null,O=U,G=""},e.isValidAttribute=function(T,g,x){zt||_i({});let E=re(T),C=re(g);return Qa(E,C,x)},e.addHook=function(T,g){typeof g=="function"&&Te(Y,T)&&Cn(Y[T],g)},e.removeHook=function(T,g){if(Te(Y,T)){if(g!==void 0){let x=jy(Y[T],g);return x===-1?void 0:qy(Y[T],x,1)[0]}return Ed(Y[T])}},e.removeHooks=function(T){Te(Y,T)&&(Y[T]=[])},e.removeAllHooks=function(){Y=Md()},e}var Ud=$d();function ra(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pt=ra();function Yd(t){Pt=t}var Nt={exec:()=>null};function rn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function $(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(we.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var ww=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),we={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:rn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:rn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:rn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:rn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:rn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:rn(t=>new RegExp(`^ {0,${t}}>`))},bw=/^(?:[ \t]*(?:\n|$))+/,xw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_w=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ia=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Xd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zd=$(Xd).replace(/bull/g,ia).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ew=$(Xd).replace(/bull/g,ia).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),oa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Sw=/^[^\n]+/,aa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Tw=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",aa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Aw=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ia).getRegex(),ti="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",sa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Rw=$("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",sa).replace("tag",ti).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qd=t=>$(oa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ti).getRegex(),Cw=Qd(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Lw=Qd(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Nw=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Lw).getRegex(),la={blockquote:Nw,code:xw,def:Tw,fences:_w,heading:kw,hr:Gn,html:Rw,lheading:Zd,list:Aw,newline:bw,paragraph:Cw,table:Nt,text:Sw},Hd=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ti).getRegex(),Dw={...la,lheading:Ew,table:Hd,paragraph:$(oa).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Hd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ti).getRegex()},Pw={...la,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",sa).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(oa).replace("hr",Gn).replace("heading",` *#{1,6} *[^
336
- ]`).replace("lheading",Zd).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Iw=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gw=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Jd=/^( {2,}|\\)\n(?!\s*$)/,Mw=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,at=/[\p{P}\p{S}]/u,on=/[\s\p{P}\p{S}]/u,Mn=/[^\s\p{P}\p{S}]/u,Fw=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,on).getRegex(),Ow=/[\p{Pi}\p{Ps}"']/u,eh=/(?!~)[\p{P}\p{S}]/u,zw=/(?!~)[\s\p{P}\p{S}]/u,$w=/(?:[^\s\p{P}\p{S}]|~)/u,Uw=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ww?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),th=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Hw=$(th,"u").replace(/punct/g,at).getRegex(),Ww=$(th,"u").replace(/punct/g,eh).getRegex(),Bw=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Kw=$(Bw,"u").replace(/openQuote/g,Ow).replace(/punct/g,at).getRegex(),nh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Vw=$(nh,"gu").replace(/notPunctSpace/g,Mn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),jw=$(nh,"gu").replace(/notPunctSpace/g,$w).replace(/punctSpace/g,zw).replace(/punct/g,eh).getRegex(),qw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Yw=$(qw,"gu").replace(/notPunctSpace/g,Mn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),Xw=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Mn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),Zw="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Qw=$(Zw,"gu").replace(/notPunctSpace/g,Mn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),Jw=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,at).getRegex(),eb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",tb=$(eb,"gu").replace(/notPunctSpace/g,Mn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),nb=$(/\\(punct)/,"gu").replace(/punct/g,at).getRegex(),rb=$(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ib=$(sa).replace("(?:-->|$)","-->").getRegex(),ob=$("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ib).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ab=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Qr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),rh=$(/^!?\[(label)\]\[(ref)\]/).replace("label",Qr).replace("ref",aa).getRegex(),ih=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",aa).getRegex(),sb=$("reflink|nolink(?!\\()","g").replace("reflink",rh).replace("nolink",ih).getRegex(),Wd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ua={_backpedal:Nt,anyPunctuation:nb,autolink:rb,blockSkip:Uw,br:Jd,code:Gw,del:Nt,delLDelim:Nt,delRDelim:Nt,emStrongLDelim:Hw,emStrongRDelimAst:Vw,emStrongRDelimUnd:Xw,escape:Iw,link:ab,nolink:ih,punctuation:Fw,reflink:rh,reflinkSearch:sb,tag:ob,text:Mw,url:Nt},lb={...ua,emStrongLDelim:Kw,emStrongRDelimAst:Yw,emStrongRDelimUnd:Qw,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",Qr).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qr).getRegex()},ea={...ua,emStrongRDelimAst:jw,emStrongLDelim:Ww,delLDelim:Jw,delRDelim:tb,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Wd).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Wd).getRegex()},ub={...ea,br:$(Jd).replace("{2,}","*").getRegex(),text:$(ea.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Zr={normal:la,gfm:Dw,pedantic:Pw},Pn={normal:ua,gfm:ea,breaks:ub,pedantic:lb},cb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Bd=t=>cb[t];function Qe(t,e){if(e){if(we.escapeTest.test(t))return t.replace(we.escapeReplace,Bd)}else if(we.escapeTestNoEncode.test(t))return t.replace(we.escapeReplaceNoEncode,Bd);return t}function Kd(t){try{t=encodeURI(t).replace(we.percentDecode,"%")}catch{return null}return t}function Vd(t,e){let n=t.replace(we.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(we.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(we.slashPipe,"|");return r}function gt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let o=t.charAt(r-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,r-i)}function jd(t){let e=t.split(`
332
+ `,Ng=Lg,au=WebGLRenderingContext,Vl=au.UNSIGNED_BYTE,bn=au.FLOAT,Dg=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],su=(function(t){function e(){return le(this,e),_e(this,e,arguments)}return ke(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ng,FRAGMENT_SHADER_SOURCE:nu,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Dg,ATTRIBUTES:[{name:"a_positionStart",size:2,type:bn},{name:"a_positionEnd",size:2,type:bn},{name:"a_normal",size:2,type:bn},{name:"a_color",size:4,type:Vl,normalized:!0},{name:"a_id",size:4,type:Vl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:bn},{name:"a_normalCoef",size:1,type:bn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=Kt(s.color),g=h-u,m=d-c,v=g*g+m*m,w=0,y=0;v&&(v=1/Math.sqrt(v),w=-m*v*l,y=g*v*l);var _=this.array;_[i++]=u,_[i++]=c,_[i++]=h,_[i++]=d,_[i++]=w,_[i++]=y,_[i++]=f,_[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(mo);var yu=dn(Tr()),Ar=(function(t){function e(){var n;return le(this,e),n=_e(this,e),n.rawEmitter=n,n}return ke(e,t),ue(e)})(yu.EventEmitter);var _u=dn(wo());var zg=function(e){return e},$g=function(e){return e*e},Ug=function(e){return e*(2-e)},Hg=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},Bg=function(e){return e*e*e},Wg=function(e){return--e*e*e+1},Kg=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},ku={linear:zg,quadraticIn:$g,quadraticOut:Ug,quadraticInOut:Hg,cubicIn:Bg,cubicOut:Wg,cubicInOut:Kg},Eu={easing:"quadraticInOut",duration:150};function De(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Rr(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function bu(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function xu(t,e,n){return t[6]=e,t[7]=n,t}function ft(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],g=e[3],m=e[4],v=e[5],w=e[6],y=e[7],_=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=g*n+m*o+v*l,t[4]=g*r+m*a+v*u,t[5]=g*i+m*s+v*c,t[6]=w*n+y*o+_*l,t[7]=w*r+y*a+_*u,t[8]=w*i+y*s+_*c,t}function Cr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Vg(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function jt(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=De(),d=Math.min(u,c)-2*r,f=Vg(e,n);return i?(ft(h,xu(De(),s,l)),ft(h,Rr(De(),a)),ft(h,bu(De(),o)),ft(h,Rr(De(),u/d/2/f,c/d/2/f))):(ft(h,Rr(De(),2*(d/u)*f,2*(d/c)*f)),ft(h,bu(De(),-o)),ft(h,Rr(De(),1/a)),ft(h,xu(De(),-s,-l))),h}function Su(t,e,n){var r=Cr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Tu(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function Au(t){if(!(0,_u.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Ru(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function bo(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function xo(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function _o(t){var e=ht(t.x,2),n=e[0],r=e[1],i=ht(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function Lr(t){"@babel/helpers - typeof";return Lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lr(t)}function ko(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function Nr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var Dr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:Xl,defaultDrawNodeLabel:vo,defaultDrawNodeHover:Zl,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},jg={circle:xn},qg={arrow:ou,line:su};function Pr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Cu(t){var e=Nr({},Dr,t);return e.nodeProgramClasses=Nr({},jg,e.nodeProgramClasses),e.edgeProgramClasses=Nr({},qg,e.edgeProgramClasses),e}var Fk=dn(Tr()),Ok=dn(wo()),Ir=1.5,Lu=(function(t){function e(){var n;return le(this,e),n=_e(this,e),T(n,"x",.5),T(n,"y",.5),T(n,"angle",0),T(n,"ratio",1),T(n,"minRatio",null),T(n,"maxRatio",null),T(n,"enabledZooming",!0),T(n,"enabledPanning",!0),T(n,"enabledRotation",!0),T(n,"clean",null),T(n,"nextFrame",null),T(n,"previousState",null),T(n,"enabled",!0),n.previousState=n.getState(),n}return ke(e,t),ue(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(P(P({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=P(P({},Eu),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:ku[s.easing],c=Date.now(),h=this.getState(),d=function(){var g=(Date.now()-c)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(g),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Ir)},r):this.animate({ratio:this.ratio/Ir})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Ir)},r):this.animate({ratio:this.ratio*Ir})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(Ar);function Ue(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function nt(t,e){var n=P(P({},Ue(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function _n(t){var e="x"in t?t:P(P({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function Yg(t,e){return P(P({},nt(t,e)),{},{delta:Mu(t)})}var Xg=2;function Gr(t){for(var e=[],n=0,r=Math.min(t.length,Xg);n<r;n++)e.push(t[n]);return e}function kn(t,e,n){var r={touches:Gr(t.touches).map(function(i){return Ue(i,n)}),previousTouches:e.map(function(i){return Ue(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Mu(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Fu=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e),i.container=n,i.renderer=r,i}return ke(e,t),ue(e)})(Ar),Zg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Qg=Zg.reduce(function(t,e){return P(P({},t),{},T({},e,Dr[e]))},{}),Jg=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e,[n,r]),T(i,"enabled",!0),T(i,"draggedEvents",0),T(i,"downStartTime",null),T(i,"lastMouseX",null),T(i,"lastMouseY",null),T(i,"isMouseDown",!1),T(i,"isMoving",!1),T(i,"movingTimeout",null),T(i,"startCameraState",null),T(i,"clicks",0),T(i,"doubleClickTimeout",null),T(i,"currentWheelDirection",0),T(i,"settings",Qg),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return ke(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",nt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",nt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=nt(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Ue(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Ue(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",nt(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=Ue(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",nt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=nt(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=Ue(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,g=a.getState(),m=g.x+d,v=g.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",nt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",nt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Mu(r);if(a){var s=Yg(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Ue(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Fu),em=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],tm=em.reduce(function(t,e){return P(P({},t),{},T({},e,Dr[e]))},{}),nm=(function(t){function e(n,r){var i;return le(this,e),i=_e(this,e,[n,r]),T(i,"enabled",!0),T(i,"isMoving",!1),T(i,"hasMoved",!1),T(i,"touchMode",0),T(i,"startTouchesPositions",[]),T(i,"lastTouches",[]),T(i,"lastTap",null),T(i,"settings",tm),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return ke(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=Gr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Ue(f,i.container)}),this.touchMode===2){var a=ht(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",kn(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",kn(r,this.lastTouches,this.container)),!r.touches.length){var s=Ue(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=kn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=kn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Gr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Gr(r.touches),a=o.map(function(je){return Ue(je,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=kn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(je,an){var Ne=i.startTouchesPositions[an];return Ne&&(je.x!==Ne.x||je.y!==Ne.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,g=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,w=m.y;u.setState({x:c.x+f-v,y:c.y+g-w});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},_=a[0],k=_.x,A=_.y,S=a[1],L=S.x,z=S.y,F=Math.atan2(z-A,L-k)-this.startTouchesAngle,G=Math.hypot(z-A,L-k)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);y.ratio=U,y.angle=c.angle+F;var q=this.getDimensions(),ee=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(q.width,q.height)-2*h,he=ge/q.width,Ve=ge/q.height,It=U/ge,Ge=k-ge/2/he,Me=A-ge/2/Ve,Fe=[Ge*Math.cos(-y.angle)-Me*Math.sin(-y.angle),Me*Math.cos(-y.angle)+Ge*Math.sin(-y.angle)];Ge=Fe[0],Me=Fe[1],y.x=ee.x-Ge*It,y.y=ee.y+Me*It,u.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Fu);function rm(t){if(Array.isArray(t))return _r(t)}function im(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function om(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
333
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nu(t){return rm(t)||im(t)||lo(t)||om()}function am(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Eo(t,e){if(t==null)return{};var n,r,i=am(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var Du=(function(){function t(e,n){le(this,t),this.key=e,this.size=n}return ue(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Pu=(function(){function t(){le(this,t),T(this,"width",0),T(this,"height",0),T(this,"cellSize",0),T(this,"columns",0),T(this,"rows",0),T(this,"cells",{})}return ue(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Du(n,r),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Du.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function sm(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var Iu=150,Gu=50,rt=Object.prototype.hasOwnProperty;function lm(t,e,n){if(!rt.call(n,"x")||!rt.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),rt.call(n,"hidden")||(n.hidden=!1),rt.call(n,"highlighted")||(n.highlighted=!1),rt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function um(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),rt.call(n,"hidden")||(n.hidden=!1),rt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var cm=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(le(this,e),i=_e(this,e),T(i,"elements",{}),T(i,"canvasContexts",{}),T(i,"webGLContexts",{}),T(i,"pickingLayers",new Set),T(i,"textures",{}),T(i,"frameBuffers",{}),T(i,"activeListeners",{}),T(i,"labelGrid",new Pu),T(i,"nodeDataCache",{}),T(i,"edgeDataCache",{}),T(i,"nodeProgramIndex",{}),T(i,"edgeProgramIndex",{}),T(i,"nodesWithForcedLabels",new Set),T(i,"edgesWithForcedLabels",new Set),T(i,"nodeExtent",{x:[0,1],y:[0,1]}),T(i,"nodeZExtent",[1/0,-1/0]),T(i,"edgeZExtent",[1/0,-1/0]),T(i,"matrix",De()),T(i,"invMatrix",De()),T(i,"correctionRatio",1),T(i,"customBBox",null),T(i,"normalizationFunction",_o({x:[0,1],y:[0,1]})),T(i,"graphToViewportRatio",1),T(i,"itemIDsIndex",{}),T(i,"nodeIndices",{}),T(i,"edgeIndices",{}),T(i,"width",0),T(i,"height",0),T(i,"pixelRatio",bo()),T(i,"pickingDownSizingRatio",2*i.pixelRatio),T(i,"displayedNodeLabels",new Set),T(i,"displayedEdgeLabels",new Set),T(i,"highlightedNodes",new Set),T(i,"hoveredNode",null),T(i,"hoveredEdge",null),T(i,"renderFrame",null),T(i,"renderHighlightedNodesFrame",null),T(i,"needToProcess",!1),T(i,"checkEdgesEventsFrame",null),T(i,"nodePrograms",{}),T(i,"nodeHoverPrograms",{}),T(i,"edgePrograms",{}),i.settings=Cu(o),Pr(i.settings),Au(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new Lu,i.bindCameraHandlers(),i.mouseCaptor=new Jg(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new nm(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return ke(e,t),ue(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=Eo(i,[r].map(St));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=Eo(s,[r].map(St));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Eo(i,[r].map(St));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=ho(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=co.apply(void 0,Nu(a)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",P(P({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",P(P({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",P(P({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=_n(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",P({},s))},this.activeListeners.handleEnter=function(o){var a=_n(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",P({},s))};var i=function(a){return function(s){var l=_n(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),P(P({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),P(P({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=ho(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=co.apply(void 0,Nu(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=Tu(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=_o(this.customBBox||this.nodeExtent);var d=new Lu,f=jt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},w={},y=1,_=i.nodes(),k=0,A=_.length;k<A;k++){var S=_[k],L=this.nodeDataCache[S],z=i.getNodeAttributes(S);L.x=z.x,L.y=z.y,this.normalizationFunction.applyTo(L),typeof L.label=="string"&&!L.hidden&&this.labelGrid.add(S,L.size,this.framedGraphToViewport(L,{matrix:f})),g[L.type]=(g[L.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!rt.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(g[F]||0),g[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(_=xo(this.nodeZExtent,function(sn){return r.nodeDataCache[sn].zIndex},_));for(var G=0,U=_.length;G<U;G++){var q=_[G];m[q]=y,w[m[q]]={type:"node",id:q},y++;var ee=this.nodeDataCache[q];this.addNodeToProgram(q,m[q],g[ee.type]++)}for(var ge={},he=i.edges(),Ve=0,It=he.length;Ve<It;Ve++){var Ge=he[Ve],Me=this.edgeDataCache[Ge];ge[Me.type]=(ge[Me.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=xo(this.edgeZExtent,function(sn){return r.edgeDataCache[sn].zIndex},he));for(var Fe in this.edgePrograms){if(!rt.call(this.edgePrograms,Fe))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Fe,'"!'));this.edgePrograms[Fe].reallocate(ge[Fe]||0),ge[Fe]=0}for(var je=0,an=he.length;je<an;je++){var Ne=he[je];v[Ne]=y,w[v[Ne]]={type:"edge",id:Ne},y++;var Y=this.edgeDataCache[Ne];this.addEdgeToProgram(Ne,v[Ne],ge[Y.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&Lr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=P({},r),u=s||this.nodeExtent,c=ht(u.x,2),h=c[0],d=c[1],f=ht(u.y,2),g=f[0],m=f[1],v=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],w=1/0,y=-1/0,_=1/0,k=-1/0;v.forEach(function(ge){var he=ge.x,Ve=ge.y;w=Math.min(w,he),y=Math.max(y,he),_=Math.min(_,Ve),k=Math.max(k,Ve)});var A=y-w,S=k-_,L=this.getDimensions(),z=L.width,F=L.height,G=0,U=0;if(A>=z?y<z-a?G=y-(z-a):w>a&&(G=w-a):y>z+a?G=y-(z+a):w<-a&&(G=w+a),S>=F?k<F-a?U=k-(F-a):_>a&&(U=_-a):k>F+a?U=k-(F+a):_<-a&&(U=_+a),G||U){var q=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),ee=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=ee.x-q.x,U=ee.y-q.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);ko(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-Iu||h>this.width+Iu||d<-Gu||d>this.height+Gu)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,P(P({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=sm({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ko(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[d.type],m=g?.drawLabel||f;m(r,P(P({key:l},d),{},{size:this.scaleSize(d.size)}),P(P(P({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),P(P(P({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var g=r.nodeDataCache[f],m=r.framedGraphToViewport(g),v=m.x,w=m.y,y=r.scaleSize(g.size),_=r.settings.defaultDrawNodeHover,k=r.nodePrograms[g.type],A=k?.drawHover||_;A(i,P(P({key:f},g),{},{size:y,x:v,y:w}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=jt(s,l,u,c),this.invMatrix=jt(s,l,u,c,!0),this.correctionRatio=Su(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var g in this.edgePrograms){var m=this.edgePrograms[g];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=lm(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=um(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Pu,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=Ru(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=P({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return P({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=P({},this.settings);return this.settings[r]=i,Pr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=P({},this.settings);return this.settings=P(P({},this.settings),r),Pr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=bo(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(k){return i.addNode(k)}),this.graph.forEachEdge(function(k){return i.addEdge(k)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,w=m.length;v<w;v++){var y=m[v];if(this.updateEdge(y),o){var _=this.edgeProgramIndex[y];if(_===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],_)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(P(P({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,g={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?jt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Cr(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?jt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Cr(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(Ar),Ou=cm;function Ae(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function dm(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let g=e.get(f);if(g&&g.kind==="module"&&g.detail.path){let m=g.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function Uu(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function hm(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function zu(t){return t?t.kind==="module"||t.id.startsWith("vfolder:"):!1}function fm(t,e){return t.slice().sort((n,r)=>{let i=e.get(n),o=e.get(r),a=zu(i),s=zu(o);if(a!==s)return a?-1:1;let l=Ae(i),u=Ae(o);return l.localeCompare(u)})}function $u(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function pm(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?$u(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?$u(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function So(t,e){let n=dm(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let w=(i.get(g)??[]).filter(y=>{let _=r.get(y);if(!_||_.kind!=="entryPoint")return!0;for(let[,k]of o)if(k.includes(y))return!1;return!0}).concat(o.get(g)??[]);return w=w.filter(y=>r.has(y)),e.showInternals||(w=w.filter(y=>{let _=r.get(y);return!(_&&hm(_.kind))})),fm(w,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Ae(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let m=r.get(g),v=!1;for(let y of s(g))h(y)&&(v=!0);let w=u(m)||v;return w&&c.add(g),w};for(let g of a)h(g);let d=[],f=(g,m)=>{if(!c.has(g))return;let v=r.get(g),w=s(g),y=w.filter(k=>c.has(k)),_=l?y.length>0:e.expanded.has(g);if(d.push({id:g,depth:m,hasKids:w.length>0,expanded:_,label:Ae(v),kind:v.kind,provenance:v.provenance,meta:pm(v)}),_)for(let k of y)f(k,m+1)};for(let g of a)f(g,0);return d}function To(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function En(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var gm=7;function Ao(t,e){if(t===null)return"";switch(t.kind){case"relTime":return En(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,gm);case"text":return t.text}}var mm=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function Ro(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of mm){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Ae(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Ae(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Ae(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Mr(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var vm=["contains","anchored-at"];function ym(t){return vm.includes(t)}function Fr(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=wm(t,n),i=Uu(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,bm(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let g=s.get(d);u.set(d,{children:f,descendants:g,members:g.filter(m=>l.get(m)===d),provenance:xm(g,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:_m(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function wm(t,e){let n=new Map;for(let r of t.edges){if(!ym(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function bm(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function xm(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function _m(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function Co(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var qt=[null,"human","agent","generated"];function Hu(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function At(t){return{...t.model,danglingLinks:t.dangling}}function Bu(t,e){return t===null?[]:So(At(t),e)}var Yt="vfolder:\0draft";function Wu(t){return t.type==="vault"?"":t.type==="folder"?t.path:t.path.split("/").slice(0,-1).join("/")}function Ku(t,e){let n=e.trim();return n===""?null:t===""?n:`${t}/${n}`}function Vu(t,e){if(e===null)return[...t];let n={id:Yt,depth:e===""?1:e.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(e==="")return[...t,n];let r=t.findIndex(o=>o.id===`vfolder:${e}`);if(r===-1)return[...t,n];let i=r+1;for(;i<t.length&&t[i].depth>t[r].depth;)i++;return[...t.slice(0,i),n,...t.slice(i)]}function Do(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Po(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function km(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function Io(t){return t==="vault"?null:t.startsWith("vfolder:")?t.slice(8):void 0}function Sn(t){return t==="vault"?{type:"vault",path:""}:t.startsWith("note:")?{type:"note",path:t.slice(5)}:t.startsWith("vfolder:")?{type:"folder",path:t.slice(8)}:null}function ju(t,e){return t===null?!1:e.type==="note"?t===`note:${e.path}`:e.type==="folder"?t===`vfolder:${e.path}`||t.startsWith(`vfolder:${e.path}/`)||t.startsWith(`note:${e.path}/`):!1}function Go(t){return t.type==="folder"}function qu(t,e,n){return Go(t)?n?`Delete “${e}” and everything in it`:"Delete…":"Delete"}function Yu(t,e){return t.query===e?t:{...t,query:e}}function Xu(t){let e=qt.indexOf(t.provFilter),n=qt[(e+1)%qt.length]??null;return{...t,provFilter:n}}function Zu(t){return{...t,showInternals:!t.showInternals}}function zr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function No(t,e){return t[e]?.id??null}function Lo(t,e,n){if(t.length===0)return null;let r=zr(t,e),i=r===-1?n>0?-1:t.length:r;return No(t,Math.min(t.length-1,Math.max(0,i+n)))}function Em(t,e){let n=zr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var Sm={j:"ArrowDown",k:"ArrowUp"};function Tm(t){return Sm[t]??t}function Qu(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=Tm(r);if(s==="ArrowDown")return a(Lo(t,n,1));if(s==="ArrowUp")return a(Lo(t,n,-1));if(s==="Home")return a(No(t,0));if(s==="End")return a(No(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=zr(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(Lo(t,n,1)):{state:Po(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:km(e,n),selectedId:n,handled:!0};let c=Em(t,n);return c===null?o:a(c)}var Am={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Mo(t){return Am[t]}var Rm={human:"●",agent:"◐",generated:"○"};function Rt(t){return t===null?"":Rm[t]}function Xt(t){return t===null?"":`${t}-authored`}function Ju(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Cm(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function Lm(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:Ju(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindIcon:Mo(t.kind),provenance:t.provenance,provenanceGlyph:Rt(t.provenance),provenanceTitle:Xt(t.provenance),twisty:i,hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:Ao(t.meta,n),level:t.depth+1}}function ec(t,e,n){let r=Cm(t);return t.map((i,o)=>Lm(i,e,n,r[o]))}function tc(t,e){return zr(t,e)===-1?null:Ju(e)}function nc(t){return{"--weave-depth":String(Math.max(0,t))}}function Or(t){return t===null?"all":t}function rc(t){let e=qt.indexOf(t),n=qt[(e+1)%qt.length]??null;return`provenance filter: ${Or(t)} — click for ${Or(n)}`}function ic(t){return t?"internals":"knowledge"}function oc(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var ac="filter…",sc="Vault and repository",lc="Filter the tree",uc="Filter the tree (/)";function cc(t,e,n){if(t===null)return"loading…";let r=To(At(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function dc(t){return t.length===1?"1 row":`${t.length} rows`}var pt={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},Nm={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Dm={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Pm(t,e){return pt[e][Nm[t]]}function hc(t,e){return pt[e][Dm[t]]}function Im(t,e){return Gm(t)?Oo(hc(t,e),e,Mm):hc(t,e)}function Gm(t){return t==="contains"||t==="anchored-at"}var Fo=.85,Mm=.3;function Tn(t,e,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(t),o=r(e);if(i===null||o===null)return t;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function Oo(t,e,n=Fo){return Tn(t,pt[e].ground,n)}var Fm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},fc=1.6,gc=32,Om=gc/2;function zm(t,e=gc){if(e<=0)return t.length>0?"…":t;if(t.length<=e)return t;let n=e-1,i=t.slice(0,n).lastIndexOf(" "),o=i>=Om?i:n;return`${t.slice(0,o).trimEnd()}…`}function $m(t){let e=Rt(t.provenance),n=Ae(t);return zm(e===""?n:`${e} ${n}`)}var Um=6,Hm=6;function Bm(t){return(e,n,r)=>{if(n.label===null||n.label==="")return;let i=pt[t];e.save(),e.font=`${r.labelSize}px ${r.labelFont}`,e.textAlign="center",e.shadowColor=i.ground,e.shadowBlur=Hm,e.fillStyle=i.text,e.fillText(n.label,n.x,n.y+n.size+r.labelSize+Um),e.restore()}}function mc(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var vc={nodes:[],edges:[]};function yc(t){return`${t.source}\0${t.target}\0${t.kind}`}function Wm(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=yc(i);r.has(o)||(r.add(o),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function wc(t,e,n,r,i){let o=new Map;for(let h of t){if(o.has(h.id))continue;let d=n.get(h.id);d===void 0||!Number.isFinite(d.x)||!Number.isFinite(d.y)||o.set(h.id,h)}let a=new Set(o.keys()),s=Wm(e,a),l=[];for(let[h,d]of o){let f=n.get(h),g=ji(s.get(h)??0);l.push({id:h,x:f.x,y:f.y,size:g,label:$m(d),color:i?.get(h)??Pm(d.kind,r),kind:d.kind,provenance:d.provenance,zIndex:Math.round(g),type:"circle"})}let u=[],c=new Set;for(let h of e){if(h.source===h.target||!a.has(h.source)||!a.has(h.target))continue;let d=yc(h);c.has(d)||(c.add(d),u.push({key:d,source:h.source,target:h.target,size:Fm[h.kind],color:Im(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:u}}function bc(t,e,n=1){return(r,i,o)=>t===null||n<=0?{}:r===e&&t.has(r)?{zIndex:i.zIndex+pc*2,size:i.size*$r(qm,n)}:t.has(r)?{zIndex:i.zIndex+pc,size:i.size*$r(Ym,n)}:{color:Oo(i.color,o,Fo*n),label:n>=jm?null:i.label,zIndex:0}}var Km=60,Vm=.004;function xc(t,e,n){let r=Number.isFinite(n)&&n>0?n:0,i=e+(t-e)*Math.exp(-r/Km);return Math.abs(e-i)<Vm?e:i}function $r(t,e){return 1+(t-1)*e}var jm=.5,qm=1.45,Ym=1.15,pc=gr+1;function _c(t,e,n=1){return(r,i,o)=>t===null||n<=0?{}:!t.has(i.source)||!t.has(i.target)?{color:Oo(i.color,o,Fo*n)}:e!=null&&(i.source===e||i.target===e)?{zIndex:2,size:i.size*$r(fc*1.35,n),color:Tn(i.color,pt[o].accent,n)}:{zIndex:1,size:i.size*$r(fc,n)}}var Xm=(pr+gr)/2,Zm=mr*4,Qm=1;function kc(t){let e=pt[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Qm,labelGridCellSize:Zm,labelRenderedSizeThreshold:Xm,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:mr,defaultDrawNodeHover:Bm(t),allowInvalidContainer:!0}}var Ac=dn(Tr(),1);function Jm(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var ce=Jm;typeof Object.assign=="function"&&(ce=Object.assign);function Ie(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function Rc(t){let e;for(e in t)return!1;return!0}function Pe(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function He(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function Ec(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function ev(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function it(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function Qt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Cn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},D=class t extends Cn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},C=class t extends Cn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends Cn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function Cc(t,e){this.key=t,this.attributes=e,this.clear()}Cc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Lc(t,e){this.key=t,this.attributes=e,this.clear()}Lc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Nc(t,e){this.key=t,this.attributes=e,this.clear()}Nc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Jt(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}Jt.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};Jt.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};Jt.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};Jt.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Dc=0,Pc=1,tv=2,Ic=3;function ot(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===Dc){if(s=t._nodes.get(r),!s)throw new C(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===Ic){if(i=""+i,l=t._edges.get(i),!l)throw new C(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new C(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===Pc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function nv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return a.attributes[s]}}function rv(t,e,n){t.prototype[e]=function(r,i){let[o]=ot(this,e,n,r,i);return o.attributes}}function iv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function ov(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ot(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function av(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ot(this,e,n,r,i,o,a);if(typeof u!="function")throw new D(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function sv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function lv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(!me(s))throw new D(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function uv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(!me(s))throw new D(`Graph.${e}: provided attributes are not a plain object.`);return ce(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function cv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ot(this,e,n,r,i,o);if(typeof s!="function")throw new D(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var dv=[{name:t=>`get${t}Attribute`,attacher:nv},{name:t=>`get${t}Attributes`,attacher:rv},{name:t=>`has${t}Attribute`,attacher:iv},{name:t=>`set${t}Attribute`,attacher:ov},{name:t=>`update${t}Attribute`,attacher:av},{name:t=>`remove${t}Attribute`,attacher:sv},{name:t=>`replace${t}Attributes`,attacher:lv},{name:t=>`merge${t}Attributes`,attacher:uv},{name:t=>`update${t}Attributes`,attacher:cv}];function hv(t){dv.forEach(function({name:e,attacher:n}){n(t,e("Node"),Dc),n(t,e("Source"),Pc),n(t,e("Target"),tv),n(t,e("Opposite"),Ic)})}function fv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function pv(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=Ie(this,o,a,n),!i)throw new C(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function gv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function mv(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Ie(this,s,l,n),!a)throw new C(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function vv(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Ie(this,s,l,n),!a)throw new C(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new D(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function yv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function wv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new D(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function bv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new D(`Graph.${e}: provided attributes are not a plain object.`);return ce(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function xv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Ie(this,a,s,n),!o)throw new C(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new C(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var _v=[{name:t=>`get${t}Attribute`,attacher:fv},{name:t=>`get${t}Attributes`,attacher:pv},{name:t=>`has${t}Attribute`,attacher:gv},{name:t=>`set${t}Attribute`,attacher:mv},{name:t=>`update${t}Attribute`,attacher:vv},{name:t=>`remove${t}Attribute`,attacher:yv},{name:t=>`replace${t}Attributes`,attacher:wv},{name:t=>`merge${t}Attributes`,attacher:bv},{name:t=>`update${t}Attributes`,attacher:xv}];function kv(t){_v.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var Ev=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function Sv(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function Tv(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function zo(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Av(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function Rv(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function $o(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Cv(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function Gc(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function Lv(t,e){if(t.size===0)return Qt();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Uo(t,e,n,r,i,o){let a=e?Tv:Sv,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function Nv(t,e,n,r){let i=[];return Uo(!1,t,e,n,r,function(o){i.push(o)}),i}function Dv(t,e,n){let r=Qt();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=it(r,zo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=it(r,zo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=it(r,zo(n.undirected))),r}function Ho(t,e,n,r,i,o,a){let s=n?Rv:Av,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function Pv(t,e,n,r,i){let o=[];return Ho(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Iv(t,e,n,r){let i=Qt();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=it(i,$o(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=it(i,$o(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=it(i,$o(n.undirected,r))),i}function Gv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return Cv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new C(`Graph.${n}: could not find the "${o}" node in the graph.`);return Nv(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){o=""+o,a=""+a;let s=this._nodes.get(o);if(!s)throw new C(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new C(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Pv(r,this.multi,i,s,a)}throw new D(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Mv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,Gc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new C(`Graph.${o}: could not find the "${u}" node in the graph.`);return Uo(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new C(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new C(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Ho(!1,r,this.multi,i,d,c,h)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((g,m,v,w,y,_,k)=>{h[f++]=c(g,m,v,w,y,_,k)})}else h=[],u.push((d,f,g,m,v,w,y)=>{h.push(c(d,f,g,m,v,w,y))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,g,m,v,w,y)=>{c(d,f,g,m,v,w,y)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new D(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new D(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,g,m,v,w,y,_)=>{d=c(d,f,g,m,v,w,y,_)}),this[o].apply(this,u),d}}function Fv(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,Gc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new C(`Graph.${o}: could not find the "${l}" node in the graph.`);return Uo(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new C(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new C(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Ho(!0,r,this.multi,i,h,u,c)}throw new D(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,w)=>u(h,d,f,g,m,v,w)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,w)=>!u(h,d,f,g,m,v,w)),!this[o].apply(this,l)}}function Ov(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Qt();if(!arguments.length)return Lv(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new C(`Graph.${o}: could not find the "${a}" node in the graph.`);return Dv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new C(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new C(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Iv(r,i,l,s)}throw new D(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function zv(t){Ev.forEach(e=>{Gv(t,e),Mv(t,e),Fv(t,e),Ov(t,e)})}var $v=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function jr(){this.A=null,this.B=null}jr.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};jr.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function An(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function Bo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return An(t,null,r,r.undirected,i);if(typeof n=="string")return An(t,null,r,r[n],i)}let o=new jr,a;if(e!=="undirected"){if(n!=="out"){if(a=An(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=An(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=An(t,o,r,r.undirected,i),t&&a))return a}function Uv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return Bo(!1,t,e,n,function(i){r.push(i)}),r}function Rn(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Hv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Rn(null,n,n.undirected);if(typeof e=="string")return Rn(null,n,n[e])}let r=Qt(),i=new jr;return t!=="undirected"&&(e!=="out"&&(r=it(r,Rn(i,n,n.in))),e!=="in"&&(r=it(r,Rn(i,n,n.out)))),t!=="directed"&&(r=it(r,Rn(i,n,n.undirected))),r}function Bv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new C(`Graph.${n}: could not find the "${o}" node in the graph.`);return Uv(r==="mixed"?this.type:r,i,a)}}function Wv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new C(`Graph.${o}: could not find the "${u}" node in the graph.`);Bo(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new D(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=h;return this[o](u,(f,g)=>{d=c(d,f,g)}),d}}function Kv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new C(`Graph.${a}: could not find the "${u}" node in the graph.`);return Bo(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function Vv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Qt();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new C(`Graph.${o}: could not find the "${a}" node in the graph.`);return Hv(r==="mixed"?this.type:r,i,s)}}function jv(t){$v.forEach(e=>{Bv(t,e),Wv(t,e),Kv(t,e),Vv(t,e)})}function Ur(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function qv(t,e){let n={key:t};return Rc(e.attributes)||(n.attributes=ce({},e.attributes)),n}function Yv(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return Rc(n.attributes)||(r.attributes=ce({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function Xv(t){if(!me(t))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Zv(t){if(!me(t))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Qv=ev(),Jv=new Set(["directed","undirected","mixed"]),Sc=new Set(["domain","_events","_eventsCount","_maxListeners"]),ey=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],ty={allowSelfLoops:!0,multi:!1,type:"mixed"};function ny(t,e,n){if(n&&!me(n))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Tc(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Mc(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new D(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new C(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new C(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new Jt(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function ry(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new D(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new D(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let y=[f.key,!1,!1,!1];if(l?!u:!s)return y;if(l){let _=f.attributes;f.attributes=u(_),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ce(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return y}s=s||{},l&&u&&(s=u(s));let g={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=Tc(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=Tc(t,a,{}),v=!0),d=new Jt(r,i,c,h,s),t._edges.set(i,d);let w=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,w&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,w&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,m,v]}function Zt(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var V=class t extends Ac.EventEmitter{constructor(e){if(super(),e=ce({},ty,e),typeof e.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Jv.has(e.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?Cc:e.type==="directed"?Lc:Nc;Pe(this,"NodeDataClass",n);let r="geid_"+Qv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Pe(this,"_attributes",{}),Pe(this,"_nodes",new Map),Pe(this,"_edges",new Map),Pe(this,"_directedSize",0),Pe(this,"_undirectedSize",0),Pe(this,"_directedSelfLoopCount",0),Pe(this,"_undirectedSelfLoopCount",0),Pe(this,"_edgeKeyGenerator",o),Pe(this,"_options",e),Sc.forEach(a=>Pe(this,a,this[a])),He(this,"order",()=>this._nodes.size),He(this,"size",()=>this._edges.size),He(this,"directedSize",()=>this._directedSize),He(this,"undirectedSize",()=>this._undirectedSize),He(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),He(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),He(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),He(this,"multi",this._options.multi),He(this,"type",this._options.type),He(this,"allowSelfLoops",this._options.allowSelfLoops),He(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new D(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new C(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new C(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new C(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new C(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new C(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new C(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new C(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new C(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return ny(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ce(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new C(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Zt(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Zt(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Zt(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Ie(this,r,i,this.type),!n)throw new C(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new C(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Zt(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,n=""+n;let r=Ie(this,e,n,"directed");if(!r)throw new C(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Zt(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let r=Ie(this,e,n,"undirected");if(!r)throw new C(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Zt(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new D("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!me(e))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!me(e))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return ce(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,n){if(typeof e!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Ec(n))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Ec(n))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");Ur(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ur(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ur(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ur(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new D("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new D("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new D("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new D("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new D("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new D("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=qv(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=Yv(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):g?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!me(e))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new D("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],Xv(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new D("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],Zv(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(ce({},this._options,e));return n.replaceAttributes(ce({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ce({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new M("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new M("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,Mc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ce({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!Sc.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Pe(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(V.prototype[Symbol.for("nodejs.util.inspect.custom")]=V.prototype.inspect);ey.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?Mc:ry;t.generateKey?V.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:V.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});hv(V);kv(V);zv(V);jv(V);var Hr=class extends V{constructor(e){let n=ce({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Br=class extends V{constructor(e){let n=ce({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Wr=class extends V{constructor(e){let n=ce({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Kr=class extends V{constructor(e){let n=ce({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Vr=class extends V{constructor(e){let n=ce({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function en(t){t.from=function(e,n){let r=ce({},e.options,n),i=new t(r);return i.import(e),i}}en(V);en(Hr);en(Br);en(Wr);en(Kr);en(Vr);V.Graph=V;V.DirectedGraph=Hr;V.UndirectedGraph=Br;V.MultiGraph=Wr;V.MultiDirectedGraph=Kr;V.MultiUndirectedGraph=Vr;V.InvalidArgumentsGraphError=D;V.NotFoundGraphError=C;V.UsageGraphError=M;function iy(){return new V({multi:!0,type:"directed"})}function Wo(t){let e=iy();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function Fc(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Ko(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}var Oc=t=>({now:()=>t.performance.now(),request:e=>t.requestAnimationFrame(()=>e()),cancel:e=>t.cancelAnimationFrame(e)});function zc(t,e,n){let r=null,i=Wo({nodes:[],edges:[]}),o=null,a=null,s=0,l=0,u=null,c=0,h=()=>{},d=()=>{},f=()=>{},g=()=>{},m=()=>{},v=null,w=A=>{if(v===null)return;let S=v;v=null,r?.setSetting("enableCameraPanning",!0),(A===null||A===S)&&m(S)},y=()=>mc([...Ko(i).values()]),_=A=>{let S=bc(o,a,s),L=_c(o,a,s);A.setSetting("nodeReducer",(z,F)=>({...F,...S(z,F,e)})),A.setSetting("edgeReducer",(z,F)=>({...F,...L(z,F,e)}))},k=()=>{if(n===void 0||u!==null)return;c=n.now();let A=()=>{u=null;let S=n.now();if(s=xc(s,l,S-c),c=S,r!==null&&_(r),s===l){s===0&&(o=null);return}u=n.request(A)};u=n.request(A)};return{mount(A){if(r!==null)return;let S=t(i,A,kc(e));S.on("clickNode",({node:L})=>h(L)),S.on("clickStage",()=>h(null)),S.on("downNode",({node:L})=>{v=L,r?.setSetting("enableCameraPanning",!1),f(L)}),S.on("moveBody",L=>{v!==null&&(L.preventSigmaDefault(),g(v,S.viewportToGraph({x:L.event.x,y:L.event.y})))}),S.on("enterNode",({node:L})=>d(L)),S.on("leaveNode",()=>d(null)),S.on("upNode",()=>w(v)),S.on("upStage",()=>w(null)),_(S),S.setCustomBBox(y()),r=S},setGraph(A){i=Wo(A),r?.setGraph(i),r?.setCustomBBox(y())},setPositions(A){Fc(i,A),r?.refresh()},setHighlight(A,S=null){if(n===void 0){o=A,a=S,s=A===null?0:1,l=s,r!==null&&_(r);return}if(A===null){if(l=0,o===null)return}else o=A,a=S,l=1;r!==null&&_(r),s!==l&&k()},onSelect(A){h=A},onHover(A){d=A},onDragStart(A){f=A},onDragMove(A){g=A},onDragEnd(A){m=A},fit(){r?.setCustomBBox(y()),r?.getCamera().animatedReset()},positions(){return Ko(i)},destroy(){u!==null&&(n?.cancel(u),u=null),r?.kill(),r=null}}}var $c=t=>zc((e,n,r)=>new Ou(e,n,r),t,Oc(window));var Uc=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Hc(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function Bc(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function Wc(t){return t===null?!1:(t.focus(),!0)}function qr(){let t=Z(null);return oe(()=>{let e=document.activeElement;return t.current?.focus(),()=>{Wc(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!Bc(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(Uc)??[]],r=Hc(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function jc(t,e){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i<0?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}function oy(t){return Math.min(Math.max(t,0),10)*2}function ay(t){return`note:${t}`}function sy(t,e){return jc(t.summary.title,e)+oy(t.score)}function ly(t,e){return jc(t.label,e)}var uy=["path","manifest","url","slug"];function cy(t){for(let e of uy){let n=t.detail[e];if(typeof n=="string"&&n)return n}return""}function dy(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function hy(t,e,n,r){let i=new Map;for(let o of t){let a=ay(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:sy(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=ly(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:cy(o),badge:o.kind,score:a})}return[...i.values()].sort(dy).slice(0,20)}function qc(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Vo(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function Kc(t,e,n){return n<=0?0:((t+e)%n+n)%n}function Yc(t,e){return e===null?null:t[e]?.id??null}function Xc(t,e,n){let r={cursor:t,activate:null,dismiss:!1,handled:!1},i=Vo(t,n);return e==="ArrowDown"?{...r,cursor:Kc(i,1,n),handled:!0}:e==="ArrowUp"?{...r,cursor:Kc(i,-1,n),handled:!0}:e==="Home"?{...r,cursor:0,handled:!0}:e==="End"?{...r,cursor:Vo(n-1,n),handled:!0}:e==="Escape"?{...r,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var Yr="Search the workspace",Zc="Search notes and repository…",Qc="↑↓ move · ↵ open · esc close";function fy(t,e){return t.query.trim()?e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading?"searching…":`no matches for “${t.query.trim()}”`:"Type to search notes, modules, files and entry points."}function py(t){return t===1?"1 result":`${t} results`}function Vc(t){return`weave-search-row-${t}`}function Jc(t,e){let n=hy(t.hits,t.answered,e?.model.nodes??[],t.query),r=Vo(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Vc(a)})),status:fy(t,n.length),count:n.length,countLabel:py(n.length),cursor:r,activeDomId:n.length?Vc(r):null}}var gy=0;function b(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gy,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return B.vnode&&B.vnode(u),u}function vy({row:t,onPick:e,onHover:n}){return b("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[b("span",{class:"weave-hit-badge",children:t.badge}),b("span",{class:"weave-hit-label",children:t.label}),b("span",{class:"weave-hit-detail",children:t.detail})]})}function ed(t){let[e,n]=W(qc),r=Z(0),i=Z(null),o=qr(),a=Z(null);oe(()=>{a.current?.focus()},[]),oe(()=>{let u=e.query.trim(),c=!0;if(!u)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{c=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(m=>({...m,loading:!0,failed:!1}));let g=await Tl(t.ports.fetch,u,f.signal);!c||f.signal.aborted||d!==r.current||n(m=>g.ok?{...m,hits:g.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...m,loading:!1,failed:!0})},140);return()=>{c=!1,window.clearTimeout(h),i.current?.abort()}},[e.query,t.ports.fetch]);let s=Jc(e,t.graph),l=u=>{let c=Yc(s.rows,u);c!==null&&t.onSelect(c),t.onClose()};return b("div",{class:"weave-scrim",onClick:()=>l(null),children:b("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Yr,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let c=Xc(e.cursor,u.key,s.count);c.handled&&(u.preventDefault(),n(h=>({...h,cursor:c.cursor})),c.dismiss&&l(c.activate))},children:[b("input",{type:"search",class:"weave-palette-input",ref:a,value:e.query,placeholder:Zc,"aria-label":Yr,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:u=>n(c=>({...c,query:u.currentTarget.value,cursor:0}))}),s.status===null?b("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Yr,children:s.rows.map((u,c)=>b(vy,{row:u,onPick:()=>l(c),onHover:()=>n(h=>({...h,cursor:c}))},u.id))}):b("p",{class:"weave-palette-status",role:"status",children:s.status}),b("p",{class:"weave-palette-foot",children:[b("span",{children:s.countLabel}),b("span",{class:"weave-palette-hint",children:Qc})]})]})})}var td="pi-weave.selection.v1";function nd(t,e){try{return t.setItem(td,e??""),!0}catch{return!1}}function rd(t,e){if(t===null)return null;let n;try{n=e.getItem(td)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}function id(){return{graph:null,graphFailed:!1,note:null,recentIds:new Set,selectedId:null}}var yy=2e3,wy=3e3,ad=new Set;function by(t,e){if(t===null)return ad;let n=new Set(t.model.nodes.map(r=>r.id));return new Set(e.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function od(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function sd(t){let e=t.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([f,g])=>e[f]===g)||(e={...e,...d},t.setState(e))},a=t.defer??((d,f)=>{let g=setTimeout(d,f);return()=>clearTimeout(g)}),s=async()=>{let d=od(e.selectedId);if(d===null){o({note:null});return}let f=await Sl(t.fetch,d);f.ok&&o({note:f.data})},l=async()=>{let d=e.graph,f=await El(t.fetch,e.graph);if(!f.ok)return e.graph===null&&o({graphFailed:!0}),f;if(!f.cached){let g=by(d,f.data);o({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=a(()=>{i=null,o({recentIds:ad})},wy))}return f},u=async()=>{if(!(n||r)){r=!0;try{let d=await l();d.ok&&!d.cached&&od(e.selectedId)!==null&&await s()}finally{r=!1}}},h=(t.repeat??((d,f)=>{let g=setInterval(d,f);return()=>clearInterval(g)}))(()=>{u()},yy);return u(),{refresh:()=>{u()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function ld(t){return t==="contains"||t==="anchored-at"}function xy(t,e){let n=new Set(t.map(i=>i.id)),r=new Map;for(let i of e)ld(i.kind)&&i.source!==i.target&&(!n.has(i.source)||!n.has(i.target)||r.has(i.target)||r.set(i.target,i.source));return r}function _y(t,e){let n=xy(t,e),r=new Map;for(let i of t){let o=i.id,a=i.id,s=0,l=new Set([o]);for(;;){let u=n.get(o);if(u===void 0||l.has(u))break;l.add(u),a=o,o=u,s++}r.set(i.id,{key:a,depth:Math.max(0,s-1)})}return r}function ky(t){let e=new Map;for(let n of t.values())e.set(n,(e.get(n)??0)+1);return e}var Ey={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},Sy=3;function Ty(t,e){let n=Ey[e],i=[...ky(t).entries()].sort((a,s)=>s[1]-a[1]||(a[0]<s[0]?-1:a[0]>s[0]?1:0)),o=new Map;return i.forEach(([a],s)=>o.set(a,n[s*Sy%n.length])),o}var Ay=.11,Ry=.34;function Cy(t,e,n){let r=Number.isFinite(e)&&e>0?e:0;return Tn(t,pt[n].ground,Math.min(Ry,r*Ay))}var Ly=.26,Ny=.55;function Dy(t,e,n){if(e.length===0)return t;let r=t,i=0;for(let o of e){let a=Math.min(Ly,Ny-i);if(a<=0)break;i+=a,r=Tn(r,o,a)}return r}function ud(t,e,n){let r=_y(t,e),i=new Map;for(let[c,h]of r)i.set(c,h.key);let o=Ty(i,n),a=new Set(t.map(c=>c.id)),s=new Map,l=(c,h)=>{let d=r.get(c)?.key,f=r.get(h)?.key;if(d===void 0||f===void 0||d===f)return;let g=s.get(c);g===void 0?s.set(c,new Set([f])):g.add(f)};for(let c of e)ld(c.kind)||c.source!==c.target&&(!a.has(c.source)||!a.has(c.target)||(l(c.source,c.target),l(c.target,c.source)));let u=new Map;for(let c of t){let h=r.get(c.id);if(h===void 0)continue;let d=o.get(h.key);if(d===void 0)continue;let f=Cy(d,h.depth,n),g=[...s.get(c.id)??[]].sort().map(m=>o.get(m)).filter(m=>m!==void 0);u.set(c.id,Dy(f,g,n))}return u}function cd(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var Py=300,Iy=1;function Gy(t,e,n){let r=new Map(n??[]);if(r.size>0)for(let o of e){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:Py,seed:Iy,pinWarm:!0};return r.size>0&&(i.initial=r),tl({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function My(t,e){let n=0,r=0;for(let o of t){let a=cd(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=cd(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Xr="pi-weave.graph.positions.v4";function dd(t){return Math.round(t*10)/10}function Fy(t,e){let n={};for(let[r,i]of e)n[r]=[dd(i.x),dd(i.y)];return JSON.stringify({v:4,key:t,at:n})}function Oy(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==4||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function zy(t,e){let n;try{n=t.getItem(Xr)}catch{return null}return Oy(n,e)}function $y(t,e,n){try{return t.setItem(Xr,Fy(e,n)),!0}catch{return!1}}function hd(t,e,n){let r=My(e,n),i=zy(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Gy(e,n);return $y(t,r,o),{key:r,positions:o,cached:!1}}function Uy(t){return{expanded:new Set(Fr(t,new Set).clusters.keys())}}function pd(t,e){return e!==null?e:t===null?{expanded:new Set}:Uy(At(t))}function Hy(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function By(t,e){return e===null?null:Mr(e,t)}function gd(t,e,n){return e===null?n:Mr(e,t)}var md="fit",vd="frame the whole graph",yd="sliders",wd="tune the layout physics and colours",Zr={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function bd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function Wy(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var Ky="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",fd={graph:vc,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function xd(t,e,n,r,i,o=!1,a=!0){if(t===null)return o?{...fd,empty:Ky}:fd;let s=At(t),l=Fr(s,n.expanded),c=n.expanded.has("vault")?l.edges.filter(f=>f.source!=="vault"&&f.target!=="vault"):l.edges,h=hd(r,l.nodes,c),d=a?ud(l.nodes,c,i):void 0;return{graph:wc(l.nodes,c,h.positions,i,d),highlight:By(c,e),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Wy(t,l.nodes.length)}}function _d(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:Hy(t,n),selectedId:n}}var Vy=.06,jy=.2,jo=.001,kd=.5;function Ed(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(s=>{let l=e?.get(s.id);return{id:s.id,x:l!==void 0&&Number.isFinite(l.x)?l.x:s.x,y:l!==void 0&&Number.isFinite(l.y)?l.y:s.y,vx:0,vy:0,r:qi(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of t.edges){if(s.source===s.target||!r.has(s.source)||!r.has(s.target))continue;let l=`${s.source}\0${s.target}\0${s.kind}`;i.has(l)||(i.add(l),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=Xi({nodes:n,links:o,seed:1}).alpha(Vy).alphaMin(jo);return{tick(){a.tick()},awake(){return a.alphaTarget()>jo||a.alpha()>jo},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let u=r.get(s);if(!u)return;let c=u.fx!=null&&u.fy!=null&&Math.abs(u.fx-l.x)<kd&&Math.abs(u.fy-l.y)<kd;u.fx=l.x,u.fy=l.y,a.alphaTarget(c?0:jy)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}function Sd(t){let[,e]=W(0),[n,r]=W(!1),i=(a,s)=>{Yi({[a.key]:ol(a,s)}),r(!1),e(l=>l+1),t.onChange()},o=a=>{Yi(a),r(!1),e(s=>s+1),t.onChange()};return b("div",{class:"weave-tuner",children:[b("p",{class:"weave-tuner-title",children:"graph forces · ?sliders=1"}),b("label",{class:"weave-tuner-toggle",title:"hue per containment group, shade per kind",children:[b("input",{type:"checkbox",checked:t.groupColors,onChange:a=>t.onGroupColors(a.currentTarget.checked)}),b("span",{children:"colour by group"})]}),vr.map(a=>b("label",{class:"weave-tuner-row",title:a.hint,children:[b("span",{class:"weave-tuner-label",children:[a.label,b("b",{children:al(ve[a.key])})]}),b("input",{type:"range",min:a.min,max:a.max,step:a.step,value:il(ve,a),onInput:s=>i(a,s.currentTarget.value)})]},a.key)),b("div",{class:"weave-tuner-actions",children:[b("button",{type:"button",class:"weave-chip",disabled:sl(ve),onClick:()=>o(vn),children:"reset"}),b("button",{type:"button",class:"weave-chip",title:"the pre-tuner constants, for comparison — see HAIRBALL",onClick:()=>o(rl),children:"before"}),b("button",{type:"button",class:"weave-chip",onClick:()=>{navigator.clipboard?.writeText(Zi(ve)).then(()=>r(!0),()=>r(!1))},children:n?"copied ✓":"copy values"})]}),b("pre",{class:"weave-tuner-snippet",children:Zi(ve)})]})}function Td(t){let e=Z(null),n=Z(null),r=Z(null),i=Z(null),o=bl(()=>{if(i.current!==null)return;let y=()=>{i.current=null;let _=r.current;_!==null&&(_.tick(),_.awake()&&(n.current?.setPositions(_.positions()),i.current=requestAnimationFrame(y)))};i.current=requestAnimationFrame(y)},[]),[a,s]=W(null),[l,u]=W(0),[c,h]=W(()=>ul(t.storage)),[d,f]=W(t.tuner===!0),g=t.scheme??xr(t.host),m=pd(t.graph,a),v=Ze(()=>xd(t.graph,t.selectedId,m,t.storage,g,t.bootFailed,c),[t.graph,t.selectedId,m,t.storage,g,t.bootFailed,l,c]),w=Z({view:m,model:v,onSelect:t.onSelect,selectedId:t.selectedId});return w.current={view:m,model:v,onSelect:t.onSelect,selectedId:t.selectedId},oe(()=>{let y=t.renderer(g);return y.onSelect(_=>{let k=_d(w.current.view,w.current.model.clusters,_);s(k.state),w.current.onSelect(k.selectedId)}),y.onHover(_=>{let{model:k,selectedId:A}=w.current;y.setHighlight(gd(k.graph.edges,_,k.highlight),_??A)}),y.onDragStart(_=>{let k=n.current?.positions().get(_);k&&(r.current?.pin(_,k),o())}),y.onDragMove((_,k)=>{r.current?.pin(_,k)}),y.onDragEnd(_=>{r.current?.release(_)}),y.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=y,y.setGraph(w.current.model.graph),y.setHighlight(w.current.model.highlight,w.current.selectedId),t.fit.current=()=>y.fit(),()=>{y.destroy(),n.current=null,t.fit.current=null}},[t.renderer,g]),oe(()=>{n.current?.setGraph(v.graph)},[v.key,l,c]),oe(()=>{let y=Ed(v.graph,n.current?.positions());return r.current=y,y!==null&&o(),()=>{r.current=null}},[v.key,o,l]),oe(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),oe(()=>{n.current?.setHighlight(v.highlight,t.selectedId)},[v.highlight,t.selectedId]),b("div",{class:"weave-graph",children:[v.empty===null?null:b("p",{class:"weave-graph-empty",children:v.empty}),b("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),d?b(Sd,{groupColors:c,onGroupColors:y=>{cl(t.storage,y),h(y)},onChange:()=>{try{t.storage.setItem(Xr,"")}catch{}u(y=>y+1)}}):null,b("div",{class:"weave-graph-controls",children:[b("button",{type:"button",class:"weave-chip",title:vd,onClick:()=>n.current?.fit(),children:md}),b("button",{type:"button",class:d?"weave-chip weave-chip-on":"weave-chip",title:wd,"aria-pressed":d,onClick:()=>f(!d),children:yd}),b("span",{class:"weave-graph-legend",children:[b("span",{class:"weave-legend-on",children:["◉ ",Zr.selected]}),b("span",{class:"weave-legend-near",children:["● ",Zr.neighborhood]}),b("span",{class:"weave-legend-dim",children:["· ",Zr.dimmed]})]})]}),b("p",{class:"weave-graph-count",children:bd(v.visible,v.total)})]})}function Ad(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qy(t){if(Array.isArray(t))return t}function Yy(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Xy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
334
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zy(t,e){return qy(t)||Yy(t,e)||Qy(t,e)||Xy()}function Qy(t,e){if(t){if(typeof t=="string")return Ad(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ad(t,e):void 0}}var Hd=Object.entries,Rd=Object.setPrototypeOf,Jy=Object.isFrozen,ew=Object.getPrototypeOf,tw=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,tn=Object.create,Bd=typeof Reflect<"u"&&Reflect,ea=Bd.apply,ta=Bd.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});ea||(ea=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});ta||(ta=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Lt=se(Array.prototype.forEach),nw=se(Array.prototype.lastIndexOf),Cd=se(Array.prototype.pop),Ln=se(Array.prototype.push),rw=se(Array.prototype.splice),nn=Array.isArray,Pn=se(String.prototype.toLowerCase),qo=se(String.prototype.toString),Ld=se(String.prototype.match),Nn=se(String.prototype.replace),Nd=se(String.prototype.indexOf),iw=se(String.prototype.trim),ow=se(Number.prototype.toString),aw=se(Boolean.prototype.toString),Dd=typeof BigInt>"u"?null:se(BigInt.prototype.toString),Pd=typeof Symbol>"u"?null:se(Symbol.prototype.toString),Te=se(Object.prototype.hasOwnProperty),Dn=se(Object.prototype.toString),ye=se(RegExp.prototype.test),Ct=sw(TypeError);function se(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return ea(t,e,r)}}function sw(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ta(t,n)}}function H(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pn;if(Rd&&Rd(t,null),!nn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(Jy(e)||(e[r]=o),i=o)}t[i]=!0}return t}function lw(t){for(let e=0;e<t.length;e++)Te(t,e)||(t[e]=null);return t}function Ce(t){let e=tn(null);for(let r of Hd(t)){var n=Zy(r,2);let i=n[0],o=n[1];Te(t,i)&&(nn(o)?e[i]=lw(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ce(o):e[i]=o)}return e}function uw(t){switch(typeof t){case"string":return t;case"number":return ow(t);case"boolean":return aw(t);case"bigint":return Dd?Dd(t):"0";case"symbol":return Pd?Pd(t):"Symbol()";case"undefined":return Dn(t);case"function":case"object":{if(t===null)return Dn(t);let e=t,n=Be(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Dn(r)}return Dn(t)}default:return Dn(t)}}function Be(t,e){for(;t!==null;){let r=tw(t,e);if(r){if(r.get)return se(r.get);if(typeof r.value=="function")return se(r.value)}t=ew(t)}function n(){return null}return n}function cw(t){try{return ye(t,""),!0}catch{return!1}}var Id=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Yo=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Xo=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),dw=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Zo=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hw=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Gd=de(["#text"]),Md=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Qo=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Fd=de(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Qr=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fw=pe(/{{[\w\W]*|^[\w\W]*}}/g),pw=pe(/<%[\w\W]*|^[\w\W]*%>/g),gw=pe(/\${[\w\W]*/g),mw=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),vw=pe(/^aria-[\-\w]+$/),Od=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),yw=pe(/^(?:\w+script|data):/i),ww=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bw=pe(/^html$/i),xw=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),zd=pe(/<[/\w!]/g),$d=pe(/<[/\w]/g),_w=pe(/<\/no(script|embed|frames)/i),kw=pe(/\/>/i),Re={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Wd=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Ew=de(H({},Wd)),Sw=(function(){let t={};return Lt(Wd,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Tw=function(){return typeof window>"u"?null:window},Aw=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Ud=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},gt=function(e,n,r,i){return Te(e,n)&&nn(e[n])?H(i.base?Ce(i.base):{},e[n],i.transform):r},Jo=function(e,n,r){let i=Te(e,n)?e[n]:void 0;return i&&typeof i=="object"?Ce(i):r()};function Kd(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Tw(),e=R=>Kd(R);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Re.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=Be(d,"cloneNode"),g=Be(d,"remove"),m=Be(d,"nextSibling"),v=Be(d,"childNodes"),w=Be(d,"parentNode"),y=Be(d,"shadowRoot"),_=Be(d,"attributes"),k=a&&a.prototype?Be(a.prototype,"nodeType"):null,A=a&&a.prototype?Be(a.prototype,"nodeName"):null,S=a&&a.prototype?Be(a.prototype,"ownerDocument"):null,L=function(p){return k?k(p):p.nodeType},z=function(p){return A?A(p):p.nodeName};if(typeof o=="function"){let R=n.createElement("template");R.content&&R.content.ownerDocument&&(n=R.content.ownerDocument)}let F,G="",U,q=!1,ee=0,ge=function(){if(ee>0)throw Ct('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},he=function(p){ge(),ee++;try{return F.createHTML(p)}finally{ee--}},Ve=function(p){ge(),ee++;try{return F.createScriptURL(p)}finally{ee--}},It=function(){return q||(U=Aw(h,i),q=!0),U},Ge=n,Me=Ge.implementation,Fe=Ge.createNodeIterator,je=Ge.createDocumentFragment,an=Ge.getElementsByTagName,Ne=r.importNode,Y=Ud();e.isSupported=typeof Hd=="function"&&typeof w=="function"&&Me&&Me.createHTMLDocument!==void 0;let sn=fw,Ff=pw,Of=gw,zf=mw,$f=vw,Uf=yw,Ra=ww,Hf=xw,Ca=Od,Q=null,fi=H({},[...Id,...Yo,...Xo,...Zo,...Gd]),J=null,pi=H({},[...Md,...Qo,...Fd,...Qr]),qe=Object.seal(tn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ln=null,La=null,lt=Object.seal(tn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Na=!0,gi=!0,Da=!1,Pa=!0,ut=!1,vt=!0,yt=!1,mi=!1,Hn=null,Bn=null,vi=!1,Gt=!1,Wn=!1,Kn=!1,Ia=!0,Ga=!1,Ma="user-content-",yi=!0,wi=!1,Mt={},Ft=null,Fa=H({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Oa=null,za=H({},["audio","video","img","source","image","track"]),$a=null,Ua=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vn="http://www.w3.org/1998/Math/MathML",jn="http://www.w3.org/2000/svg",Ye="http://www.w3.org/1999/xhtml",Ot=Ye,bi=!1,xi=null,Bf=H({},[Vn,jn,Ye],qo),Ha=de(["mi","mo","mn","ms","mtext"]),_i=H({},Ha),Ba=de(["annotation-xml"]),ki=H({},Ba),Wf=H({},["title","style","font","a","script"]),un=null,Kf=["application/xhtml+xml","text/html"],Vf="text/html",re=null,zt=null,jf=n.createElement("form"),Wa=function(p){return p instanceof RegExp||p instanceof Function},Ei=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(zt&&zt===p)return;(!p||typeof p!="object")&&(p={}),p=Ce(p),un=Kf.indexOf(p.PARSER_MEDIA_TYPE)===-1?Vf:p.PARSER_MEDIA_TYPE,re=un==="application/xhtml+xml"?qo:Pn,Q=gt(p,"ALLOWED_TAGS",fi,{transform:re}),J=gt(p,"ALLOWED_ATTR",pi,{transform:re}),xi=gt(p,"ALLOWED_NAMESPACES",Bf,{transform:qo}),$a=gt(p,"ADD_URI_SAFE_ATTR",Ua,{transform:re,base:Ua}),Oa=gt(p,"ADD_DATA_URI_TAGS",za,{transform:re,base:za}),Ft=gt(p,"FORBID_CONTENTS",Fa,{transform:re}),ln=gt(p,"FORBID_TAGS",Ce({}),{transform:re}),La=gt(p,"FORBID_ATTR",Ce({}),{transform:re}),Mt=Te(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Ce(p.USE_PROFILES):p.USE_PROFILES:!1,Na=p.ALLOW_ARIA_ATTR!==!1,gi=p.ALLOW_DATA_ATTR!==!1,Da=p.ALLOW_UNKNOWN_PROTOCOLS||!1,Pa=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ut=p.SAFE_FOR_TEMPLATES||!1,vt=p.SAFE_FOR_XML!==!1,yt=p.WHOLE_DOCUMENT||!1,Gt=p.RETURN_DOM||!1,Wn=p.RETURN_DOM_FRAGMENT||!1,Kn=p.RETURN_TRUSTED_TYPE||!1,vi=p.FORCE_BODY||!1,Ia=p.SANITIZE_DOM!==!1,Ga=p.SANITIZE_NAMED_PROPS||!1,yi=p.KEEP_CONTENT!==!1,wi=p.IN_PLACE||!1,Ca=cw(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Od,Ot=typeof p.NAMESPACE=="string"?p.NAMESPACE:Ye,_i=Jo(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},Ha)),ki=Jo(p,"HTML_INTEGRATION_POINTS",()=>H({},Ba));let x=Jo(p,"CUSTOM_ELEMENT_HANDLING",()=>tn(null));if(qe=tn(null),Te(x,"tagNameCheck")&&Wa(x.tagNameCheck)&&(qe.tagNameCheck=x.tagNameCheck),Te(x,"attributeNameCheck")&&Wa(x.attributeNameCheck)&&(qe.attributeNameCheck=x.attributeNameCheck),Te(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(qe.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),pe(qe),ut&&(gi=!1),Wn&&(Gt=!0),Mt&&(Q=H({},Gd),J=tn(null),Mt.html===!0&&(H(Q,Id),H(J,Md)),Mt.svg===!0&&(H(Q,Yo),H(J,Qo),H(J,Qr)),Mt.svgFilters===!0&&(H(Q,Xo),H(J,Qo),H(J,Qr)),Mt.mathMl===!0&&(H(Q,Zo),H(J,Fd),H(J,Qr))),lt.tagCheck=null,lt.attributeCheck=null,Te(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?lt.tagCheck=p.ADD_TAGS:nn(p.ADD_TAGS)&&(Q===fi&&(Q=Ce(Q)),H(Q,p.ADD_TAGS,re))),Te(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?lt.attributeCheck=p.ADD_ATTR:nn(p.ADD_ATTR)&&(J===pi&&(J=Ce(J)),H(J,p.ADD_ATTR,re))),Te(p,"ADD_FORBID_CONTENTS")&&nn(p.ADD_FORBID_CONTENTS)&&(Ft===Fa&&(Ft=Ce(Ft)),H(Ft,p.ADD_FORBID_CONTENTS,re)),yi&&(Q["#text"]=!0),yt&&H(Q,["html","head","body"]),Q.table&&(H(Q,["tbody"]),delete ln.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ct('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=F;F=p.TRUSTED_TYPES_POLICY;try{G=he("")}catch(N){throw F=E,N}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=It()),F&&typeof G=="string"&&(G=he("")));de&&de(p),zt=p},Ka=H({},[...Yo,...Xo,...dw]),Va=H({},[...Zo,...hw]),qf=function(p,x,E){return x.namespaceURI===Ye?p==="svg":x.namespaceURI===Vn?p==="svg"&&(E==="annotation-xml"||_i[E]):!!Ka[p]},Yf=function(p,x,E){return x.namespaceURI===Ye?p==="math":x.namespaceURI===jn?p==="math"&&ki[E]:!!Va[p]},Xf=function(p,x,E){return x.namespaceURI===jn&&!ki[E]||x.namespaceURI===Vn&&!_i[E]?!1:!Va[p]&&(Wf[p]||!Ka[p])},Zf=function(p){let x=w(p);(!x||!x.tagName)&&(x={namespaceURI:Ot,tagName:"template"});let E=Pn(p.tagName),N=Pn(x.tagName);return xi[p.namespaceURI]?p.namespaceURI===jn?qf(E,x,N):p.namespaceURI===Vn?Yf(E,x,N):p.namespaceURI===Ye?Xf(E,x,N):!!(un==="application/xhtml+xml"&&xi[p.namespaceURI]):!1},ct=function(p){Ln(e.removed,{element:p});try{w(p).removeChild(p)}catch{if(g(p),!w(p))throw Ct("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ja=function(p,x,E){try{p.removeAttributeNode(x)}catch{try{p.removeAttribute(E)}catch{}}},qn=function(p){Yn(p);let x=v(p);if(x){let N=[];Lt(x,I=>{Ln(N,I)}),Lt(N,I=>{try{g(I)}catch{}})}let E=_(p);if(E)for(let N=E.length-1;N>=0;--N){let I=E[N],O=I&&I.name;typeof O=="string"&&ja(p,I,O)}},wt=function(p,x,E){if(!E)try{E=x.getAttributeNode(p)}catch{E=null}Ln(e.removed,{attribute:E||null,from:x});try{E?x.removeAttributeNode(E):x.removeAttribute(p)}catch{try{x.removeAttribute(p)}catch{}}if(p==="is")if(Gt||Wn)try{ct(x)}catch{}else try{x.setAttribute(p,"")}catch{}},Qf=function(p){let x=_(p);if(x)for(let E=x.length-1;E>=0;--E){let N=x[E],I=N&&N.name;typeof I!="string"||J[re(I)]||ja(p,N,I)}},Yn=function(p){let x=[p];for(;x.length>0;){let E=x.pop();L(E)===Re.element&&Qf(E);let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)x.push(I[O])}},qa=function(p,x){return vt?p==="patchsrc"?!0:p==="for"&&x!=="label"&&x!=="output":!1},Jf=function(p){if(!vt)return;let x=[p];for(;x.length>0;){let E=x.pop(),N=L(E);if(N===Re.processingInstruction||N===Re.comment&&ye($d,E.data)){try{g(E)}catch{}continue}if(N===Re.element){let O=E,X=re(z(E));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&qa("for",X)&&O.removeAttribute("for")}catch{}}let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)x.push(I[O])}},Ya=function(p){let x=null,E=null;if(vi)p="<remove></remove>"+p;else{let O=Ld(p,/^[\r\n\t ]+/);E=O&&O[0]}un==="application/xhtml+xml"&&Ot===Ye&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let N=F?he(p):p;if(Ot===Ye)try{x=new c().parseFromString(N,un)}catch{}if(!x||!x.documentElement){x=Me.createDocument(Ot,"template",null);try{x.documentElement.innerHTML=bi?G:N}catch{}}let I=x.body||x.documentElement;return p&&E&&I.insertBefore(n.createTextNode(E),I.childNodes[0]||null),Ot===Ye?an.call(x,yt?"html":"body")[0]:yt?x.documentElement:I},Xa=function(p){let x=S?S(p):p.ownerDocument;return Fe.call(x||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Xn=function(p){return p=Nn(p,sn," "),p=Nn(p,Ff," "),p=Nn(p,Of," "),p},Si=function(p){var x;p.normalize();let E=S?S(p):p.ownerDocument,N=Fe.call(E||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),I=N.nextNode();for(;I;)I.data=Xn(I.data),I=N.nextNode();let O=(x=p.querySelectorAll)===null||x===void 0?void 0:x.call(p,"template");O&&Lt(O,X=>{$t(X.content)&&Si(X.content)})},Zn=function(p){let x=A?A(p):null;return typeof x!="string"||re(x)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==_(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==k(p)||p.childNodes!==v(p)},$t=function(p){if(!k||typeof p!="object"||p===null)return!1;try{return k(p)===Re.documentFragment}catch{return!1}},cn=function(p){if(!k||typeof p!="object"||p===null)return!1;try{return typeof k(p)=="number"}catch{return!1}};function Xe(R,p,x){R.length!==0&&Lt(R,E=>{E.call(e,p,x,zt)})}let ep=function(p,x){return!!(vt&&p.hasChildNodes()&&!cn(p.firstElementChild)&&ye(zd,p.textContent)&&ye(zd,p.innerHTML)||vt&&p.namespaceURI===Ye&&Ew[x]&&(cn(p.firstElementChild)||typeof p.textContent=="string"&&ye(Sw[x],p.textContent))||p.nodeType===Re.processingInstruction||vt&&p.nodeType===Re.comment&&ye($d,p.data))},Qn=function(p,x){if(p instanceof RegExp)return ye(p,x);if(p instanceof Function){for(var E=arguments.length,N=new Array(E>2?E-2:0),I=2;I<E;I++)N[I-2]=arguments[I];return!!p(x,...N)}return!1},tp=function(p,x,E){if(!ln[x]&&ts(x)&&Qn(qe.tagNameCheck,x))return!1;if(yi&&!Ft[x]){let N=w(p),I=v(p);if(I&&N){let O=I.length;for(let X=O-1;X>=0;--X){let te=p===E?f(I[X],!0):I[X];N.insertBefore(te,m(p))}}}return ct(p),!0},Za=function(p,x,E,N){return p.length===0?x:x===E||x===N?Ce(x):x},Qa=function(p,x){return p===x||w(p)!==null?!1:(wi&&Yn(p),!0)},Ja=function(p,x){if(Xe(Y.beforeSanitizeElements,p,null),Qa(p,x))return!0;if(Zn(p))return ct(p),!0;let E=re(z(p));if(Q=Za(Y.uponSanitizeElement,Q,fi,Hn),Xe(Y.uponSanitizeElement,p,{tagName:E,allowedTags:Q}),Qa(p,x))return!0;if(ep(p,E))return ct(p),!0;if(ln[E]||!(lt.tagCheck instanceof Function&&lt.tagCheck(E))&&!Q[E]){let I=tp(p,E,x);return I===!1&&Xe(Y.afterSanitizeElements,p,null),I}if(L(p)===Re.element&&!Zf(p)||(E==="noscript"||E==="noembed"||E==="noframes")&&ye(_w,p.innerHTML))return ct(p),!0;if(ut&&p.nodeType===Re.text){let I=Xn(p.textContent);p.textContent!==I&&(Ln(e.removed,{element:p.cloneNode()}),p.textContent=I)}return Xe(Y.afterSanitizeElements,p,null),!1},es=function(p,x,E){if(La[x]||qa(x,p)||Ia&&(x==="id"||x==="name")&&(E in n||E in jf))return!1;let N=J[x]||lt.attributeCheck instanceof Function&&lt.attributeCheck(x,p);return gi&&ye(zf,x)||Na&&ye($f,x)?!0:N?$a[x]||ye(Ca,Nn(E,Ra,""))||(x==="src"||x==="xlink:href"||x==="href")&&p!=="script"&&Nd(E,"data:")===0&&Oa[p]||Da&&!ye(Uf,Nn(E,Ra,""))?!0:!E:ts(p)&&Qn(qe.tagNameCheck,p)&&Qn(qe.attributeNameCheck,x,p)||x==="is"&&qe.allowCustomizedBuiltInElements&&Qn(qe.tagNameCheck,E)},np=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ts=function(p){return!np[Pn(p)]&&ye(Hf,p)},rp=function(p,x,E,N){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(p,x)){case"TrustedHTML":return he(N);case"TrustedScriptURL":return Ve(N)}return N},ip=function(p,x,E,N){try{E?p.setAttributeNS(E,x,N):p.setAttribute(x,N),Zn(p)?ct(p):Cd(e.removed)}catch{wt(x,p)}},ns=function(p){Xe(Y.beforeSanitizeAttributes,p,null);let x=p.attributes;if(!x||Zn(p))return;J=Za(Y.uponSanitizeAttribute,J,pi,Bn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0},N=x.length,I=re(p.nodeName);for(;N--;){let O=x[N],X=O.name,te=O.namespaceURI,Ee=O.value,Se=re(X),Ai=Ee,be=X==="value"?Ai:iw(Ai);if(E.attrName=Se,E.attrValue=be,E.keepAttr=!0,E.forceKeepAttr=void 0,Xe(Y.uponSanitizeAttribute,p,E),be=E.attrValue,Ga&&(Se==="id"||Se==="name")&&Nd(be,Ma)!==0&&(wt(X,p,O),be=Ma+be),vt&&ye(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,be)){wt(X,p,O);continue}if(Se==="attributename"&&Ld(be,"href")){wt(X,p,O);continue}if(!E.forceKeepAttr){if(!E.keepAttr){wt(X,p,O);continue}if(!Pa&&ye(kw,be)){wt(X,p,O);continue}if(ut&&(be=Xn(be)),!es(I,Se,be)){wt(X,p,O);continue}be=rp(I,Se,te,be),be!==Ai&&ip(p,X,te,be)}}Xe(Y.afterSanitizeAttributes,p,null)},Jn=function(p){let x=null,E=Xa(p);for(Xe(Y.beforeSanitizeShadowDOM,p,null);x=E.nextNode();)if(Xe(Y.uponSanitizeShadowNode,x,null),Ja(x,p),ns(x),$t(x.content)&&Jn(x.content),L(x)===Re.element){let N=y(x);$t(N)&&(Ti(N),Jn(N))}Xe(Y.afterSanitizeShadowDOM,p,null)},Ti=function(p){let x=[{node:p,shadow:null}];for(;x.length>0;){let E=x.pop();if(E.shadow){Jn(E.shadow);continue}let N=E.node,O=L(N)===Re.element,X=v(N);if(X)for(let te=X.length-1;te>=0;--te)x.push({node:X[te],shadow:null});if(O){let te=A?A(N):null;if(typeof te=="string"&&re(te)==="template"){let Ee=N.content;$t(Ee)&&x.push({node:Ee,shadow:null})}}if(O){let te=y(N);$t(te)&&x.push({node:null,shadow:te},{node:te,shadow:null})}}};return e.sanitize=function(R){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,E=null,N=null,I=null;if(bi=!R,bi&&(R="<!-->"),typeof R!="string"&&!cn(R)&&(R=uw(R),typeof R!="string"))throw Ct("dirty is not a string, aborting");if(!e.isSupported)return R;mi?(Q=Hn,J=Bn):Ei(p),(Y.uponSanitizeElement.length>0||Y.uponSanitizeAttribute.length>0)&&(Q=Ce(Q)),Y.uponSanitizeAttribute.length>0&&(J=Ce(J)),e.removed=[];let O=wi&&typeof R!="string"&&cn(R);if(O){Jf(R);let Ee=z(R);if(typeof Ee=="string"){let Se=re(Ee);if(!Q[Se]||ln[Se])throw qn(R),Ct("root node is forbidden and cannot be sanitized in-place")}if(Zn(R))throw qn(R),Ct("root node is clobbered and cannot be sanitized in-place");try{Ti(R)}catch(Se){throw qn(R),Se}}else if(cn(R))x=Ya("<!---->"),E=x.ownerDocument.importNode(R,!0),E.nodeType===Re.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?x=E:x.appendChild(E),Ti(E);else{if(!Gt&&!ut&&!yt&&R.indexOf("<")===-1)return F&&Kn?he(R):R;if(x=Ya(R),!x)return Gt?null:Kn?G:""}x&&vi&&ct(x.firstChild);let X=O?R:x;try{let Ee=Xa(X);for(;N=Ee.nextNode();)Ja(N,X),ns(N),$t(N.content)&&Jn(N.content)}catch(Ee){throw O&&(qn(R),Lt(e.removed,Se=>{Se.element&&Yn(Se.element)})),Ee}if(O)return Lt(e.removed,Ee=>{Ee.element&&Yn(Ee.element)}),ut&&Si(R),R;if(Gt){if(ut&&Si(x),Wn)for(I=je.call(x.ownerDocument);x.firstChild;)I.appendChild(x.firstChild);else I=x;return(J.shadowroot||J.shadowrootmode)&&(I=Ne.call(r,I,!0)),I}let te=yt?x.outerHTML:x.innerHTML;return yt&&Q["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&ye(bw,x.ownerDocument.doctype.name)&&(te="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
335
+ `+te),ut&&(te=Xn(te)),F&&Kn?he(te):te},e.setConfig=function(){let R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ei(R),mi=!0,Hn=Q,Bn=J},e.clearConfig=function(){zt=null,mi=!1,Hn=null,Bn=null,F=U,G=""},e.isValidAttribute=function(R,p,x){zt||Ei({});let E=re(R),N=re(p);return es(E,N,x)},e.addHook=function(R,p){typeof p=="function"&&Te(Y,R)&&Ln(Y[R],p)},e.removeHook=function(R,p){if(Te(Y,R)){if(p!==void 0){let x=nw(Y[R],p);return x===-1?void 0:rw(Y[R],x,1)[0]}return Cd(Y[R])}},e.removeHooks=function(R){Te(Y,R)&&(Y[R]=[])},e.removeAllHooks=function(){Y=Ud()},e}var Vd=Kd();function oa(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Pt=oa();function eh(t){Pt=t}var Nt={exec:()=>null};function rn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function $(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(we.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Rw=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),we={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:rn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:rn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:rn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:rn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:rn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:rn(t=>new RegExp(`^ {0,${t}}>`))},Cw=/^(?:[ \t]*(?:\n|$))+/,Lw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Nw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Mn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Dw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,aa=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,th=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,nh=$(th).replace(/bull/g,aa).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Pw=$(th).replace(/bull/g,aa).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),sa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Iw=/^[^\n]+/,la=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Gw=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",la).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Mw=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,aa).getRegex(),ri="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ua=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Fw=$("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ua).replace("tag",ri).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),rh=t=>$(sa).replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ri).getRegex(),Ow=rh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),zw=rh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),$w=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",zw).getRegex(),ca={blockquote:$w,code:Lw,def:Gw,fences:Nw,heading:Dw,hr:Mn,html:Fw,lheading:nh,list:Mw,newline:Cw,paragraph:Ow,table:Nt,text:Iw},jd=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ri).getRegex(),Uw={...ca,lheading:Pw,table:jd,paragraph:$(sa).replace("hr",Mn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ri).getRegex()},Hw={...ca,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ua).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(sa).replace("hr",Mn).replace("heading",` *#{1,6} *[^
336
+ ]`).replace("lheading",nh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Bw=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ww=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ih=/^( {2,}|\\)\n(?!\s*$)/,Kw=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,at=/[\p{P}\p{S}]/u,on=/[\s\p{P}\p{S}]/u,Fn=/[^\s\p{P}\p{S}]/u,Vw=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,on).getRegex(),jw=/[\p{Pi}\p{Ps}"']/u,oh=/(?!~)[\p{P}\p{S}]/u,qw=/(?!~)[\s\p{P}\p{S}]/u,Yw=/(?:[^\s\p{P}\p{S}]|~)/u,Xw=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Rw?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ah=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Zw=$(ah,"u").replace(/punct/g,at).getRegex(),Qw=$(ah,"u").replace(/punct/g,oh).getRegex(),Jw=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,eb=$(Jw,"u").replace(/openQuote/g,jw).replace(/punct/g,at).getRegex(),sh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tb=$(sh,"gu").replace(/notPunctSpace/g,Fn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),nb=$(sh,"gu").replace(/notPunctSpace/g,Yw).replace(/punctSpace/g,qw).replace(/punct/g,oh).getRegex(),rb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",ib=$(rb,"gu").replace(/notPunctSpace/g,Fn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),ob=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Fn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),ab="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",sb=$(ab,"gu").replace(/notPunctSpace/g,Fn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),lb=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,at).getRegex(),ub="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",cb=$(ub,"gu").replace(/notPunctSpace/g,Fn).replace(/punctSpace/g,on).replace(/punct/g,at).getRegex(),db=$(/\\(punct)/,"gu").replace(/punct/g,at).getRegex(),hb=$(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),fb=$(ua).replace("(?:-->|$)","-->").getRegex(),pb=$("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",fb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ei=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,gb=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",ei).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lh=$(/^!?\[(label)\]\[(ref)\]/).replace("label",ei).replace("ref",la).getRegex(),uh=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",la).getRegex(),mb=$("reflink|nolink(?!\\()","g").replace("reflink",lh).replace("nolink",uh).getRegex(),qd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,da={_backpedal:Nt,anyPunctuation:db,autolink:hb,blockSkip:Xw,br:ih,code:Ww,del:Nt,delLDelim:Nt,delRDelim:Nt,emStrongLDelim:Zw,emStrongRDelimAst:tb,emStrongRDelimUnd:ob,escape:Bw,link:gb,nolink:uh,punctuation:Vw,reflink:lh,reflinkSearch:mb,tag:pb,text:Kw,url:Nt},vb={...da,emStrongLDelim:eb,emStrongRDelimAst:ib,emStrongRDelimUnd:sb,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",ei).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ei).getRegex()},na={...da,emStrongRDelimAst:nb,emStrongLDelim:Qw,delLDelim:lb,delRDelim:cb,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",qd).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",qd).getRegex()},yb={...na,br:$(ih).replace("{2,}","*").getRegex(),text:$(na.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Jr={normal:ca,gfm:Uw,pedantic:Hw},In={normal:da,gfm:na,breaks:yb,pedantic:vb},wb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Yd=t=>wb[t];function Qe(t,e){if(e){if(we.escapeTest.test(t))return t.replace(we.escapeReplace,Yd)}else if(we.escapeTestNoEncode.test(t))return t.replace(we.escapeReplaceNoEncode,Yd);return t}function Xd(t){try{t=encodeURI(t).replace(we.percentDecode,"%")}catch{return null}return t}function Zd(t,e){let n=t.replace(we.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(we.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(we.slashPipe,"|");return r}function mt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let o=t.charAt(r-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,r-i)}function Qd(t){let e=t.split(`
337
337
  `),n=e.length-1;for(;n>=0&&we.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
338
- `)}function db(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function hb(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function qd(t,e,n,r,i){let o=e.href,a=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function fb(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
338
+ `)}function bb(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function xb(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function Jd(t,e,n,r,i){let o=e.href,a=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function _b(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
339
339
  `).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[s]=a;return s.length>=i.length?o.slice(i.length):o}).join(`
340
- `)}var Jr=class{options;rules;lexer;constructor(t){this.options=t||Pt}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:jd(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=fb(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=gt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:gt(e[0],`
341
- `),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:gt(e[0],`
342
- `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=gt(e[0],`
340
+ `)}var ti=class{options;rules;lexer;constructor(t){this.options=t||Pt}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Qd(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=_b(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=mt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:mt(e[0],`
341
+ `),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:mt(e[0],`
342
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=mt(e[0],`
343
343
  `).split(`
344
344
  `),r="",i="",o=[];for(;n.length>0;){let a=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),a=!0;else if(!a)s.push(n[l]);else break;n=n.slice(l);let u=s.join(`
345
345
  `),c=u.replace(this.rules.other.blockquoteSetextReplace,`
346
346
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
347
347
  ${u}`:u,i=i?`${i}
348
- ${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let f=d,p=n.join(`
348
+ ${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let f=d,g=n.join(`
349
349
  `),m=f.raw+`
350
- `+p.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(m);o[o.length-1]=v,r=`${r}
351
- ${p}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="list"){let f=d,p=f.raw+`
350
+ `+g.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(m);o[o.length-1]=v,r=`${r}
351
+ ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="list"){let f=d,g=f.raw+`
352
352
  `+n.join(`
353
- `),m=this.list(p);o[o.length-1]=m,r=r.substring(0,r.length-d.raw.length)+m.raw,i=i.substring(0,i.length-f.raw.length)+m.raw,n=p.substring(o.at(-1).raw.length).split(`
354
- `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=hb(e[2].split(`
353
+ `),m=this.list(g);o[o.length-1]=m,r=r.substring(0,r.length-d.raw.length)+m.raw,i=i.substring(0,i.length-f.raw.length)+m.raw,n=g.substring(o.at(-1).raw.length).split(`
354
+ `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=xb(e[2].split(`
355
355
  `,1)[0],e[1].length),d=t.split(`
356
- `,1)[0],f=!h.trim(),p=0;if(this.options.pedantic?(p=2,c=h.trimStart()):f?p=e[1].length+1:(p=h.search(this.rules.other.nonSpaceChar),p=p>4?1:p,c=h.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(d)&&(u+=d+`
357
- `,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(p),v=this.rules.other.hrRegex(p),w=this.rules.other.fencesBeginRegex(p),y=this.rules.other.headingBeginRegex(p),_=this.rules.other.htmlBeginRegex(p),k=this.rules.other.blockquoteBeginRegex(p);for(;t;){let N=t.split(`
358
- `,1)[0],R;if(d=N,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),R=d):R=d.replace(this.rules.other.tabCharGlobal," "),w.test(d)||y.test(d)||_.test(d)||k.test(d)||m.test(d)||v.test(d))break;if(R.search(this.rules.other.nonSpaceChar)>=p||!d.trim())c+=`
359
- `+R.slice(p);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(h)||y.test(h)||v.test(h))break;c+=`
360
- `+d}f=!d.trim(),u+=N+`
361
- `,t=t.substring(N.length+1),h=R.slice(p)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(a=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let u=l.tokens.filter(h=>h.type==="space"),c=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=c}for(let l of i.items){let u=l.tokens[0];if(l.task&&(u?.type==="text"||u?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=jd(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:gt(e[0],`
362
- `),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Vd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
363
- `):[],o={type:"table",raw:gt(e[0],`
364
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(Vd(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:gt(e[0],`
356
+ `,1)[0],f=!h.trim(),g=0;if(this.options.pedantic?(g=2,c=h.trimStart()):f?g=e[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=h.slice(g),g+=e[1].length),f&&this.rules.other.blankLine.test(d)&&(u+=d+`
357
+ `,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),w=this.rules.other.fencesBeginRegex(g),y=this.rules.other.headingBeginRegex(g),_=this.rules.other.htmlBeginRegex(g),k=this.rules.other.blockquoteBeginRegex(g);for(;t;){let A=t.split(`
358
+ `,1)[0],S;if(d=A,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),S=d):S=d.replace(this.rules.other.tabCharGlobal," "),w.test(d)||y.test(d)||_.test(d)||k.test(d)||m.test(d)||v.test(d))break;if(S.search(this.rules.other.nonSpaceChar)>=g||!d.trim())c+=`
359
+ `+S.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(h)||y.test(h)||v.test(h))break;c+=`
360
+ `+d}f=!d.trim(),u+=A+`
361
+ `,t=t.substring(A.length+1),h=S.slice(g)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(a=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let u=l.tokens.filter(h=>h.type==="space"),c=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=c}for(let l of i.items){let u=l.tokens[0];if(l.task&&(u?.type==="text"||u?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Qd(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:mt(e[0],`
362
+ `),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Zd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
363
+ `):[],o={type:"table",raw:mt(e[0],`
364
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(Zd(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:mt(e[0],`
365
365
  `),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
366
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=gt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=db(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),qd(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return qd(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=0,u=r[0][0],c=n===u,h=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(r=h.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(c)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,f=t.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let u=[...r[0]][0].length,c=t.slice(0,i+r.index+u+a),h=c.slice(i,-i);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Be=class ta{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Pt,this.options.tokenizer=this.options.tokenizer||new Jr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:we,block:Zr.normal,inline:Pn.normal};this.options.pedantic?(n.block=Zr.pedantic,n.inline=Pn.pedantic):this.options.gfm&&(n.block=Zr.gfm,this.options.breaks?n.inline=Pn.breaks:n.inline=Pn.gfm),this.tokenizer.rules=n}static get rules(){return{block:Zr,inline:Pn}}static lex(e,n){return new ta(n).lex(e)}static lexInline(e,n){return new ta(n).inlineTokens(e)}lex(e){e=e.replace(we.carriageReturn,`
366
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=mt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=bb(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Jd(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Jd(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=0,u=r[0][0],c=n===u,h=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(r=h.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(c)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,f=t.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let u=[...r[0]][0].length,c=t.slice(0,i+r.index+u+a),h=c.slice(i,-i);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},We=class ra{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Pt,this.options.tokenizer=this.options.tokenizer||new ti,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:we,block:Jr.normal,inline:In.normal};this.options.pedantic?(n.block=Jr.pedantic,n.inline=In.pedantic):this.options.gfm&&(n.block=Jr.gfm,this.options.breaks?n.inline=In.breaks:n.inline=In.gfm),this.tokenizer.rules=n}static get rules(){return{block:Jr,inline:In}}static lex(e,n){return new ra(n).lex(e)}static lexInline(e,n){return new ra(n).inlineTokens(e)}lex(e){e=e.replace(we.carriageReturn,`
367
367
  `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(we.tabCharGlobal," ").replace(we.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
368
368
  `:n.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
369
369
  `)?"":`
@@ -377,7 +377,7 @@ ${p}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="li
377
377
  `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
378
378
  `)?"":`
379
379
  `)+o.raw,s.text+=`
380
- `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},ei=class{options;parser;constructor(t){this.options=t||Pt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(we.notSpaceStart)?.[0],i=t.replace(we.endingNewline,"")+`
380
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},ni=class{options;parser;constructor(t){this.options=t||Pt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(we.notSpaceStart)?.[0],i=t.replace(we.endingNewline,"")+`
381
381
  `;return r?'<pre><code class="language-'+Qe(r)+'">'+(n?i:Qe(i,!0))+`</code></pre>
382
382
  `:"<pre><code>"+(n?i:Qe(i,!0))+`</code></pre>
383
383
  `}blockquote({tokens:t}){return`<blockquote>
@@ -395,14 +395,14 @@ ${this.parser.parse(t)}</blockquote>
395
395
  `}tablerow({text:t}){return`<tr>
396
396
  ${t}</tr>
397
397
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
398
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Qe(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Kd(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+Qe(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Kd(t);if(i===null)return Qe(n);t=i;let o=`<img src="${t}" alt="${Qe(n)}"`;return e&&(o+=` title="${Qe(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Qe(t.text)}},ca=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Ke=class na{options;renderer;textRenderer;constructor(e){this.options=e||Pt,this.options.renderer=this.options.renderer||new ei,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ca}static parse(e,n){return new na(n).parse(e)}static parseInline(e,n){return new na(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},In=class{options;block;constructor(t){this.options=t||Pt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Be.lex:Be.lexInline}provideParser(t=this.block){return t?Ke.parse:Ke.parseInline}},da=class{defaults=ra();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ke;Renderer=ei;TextRenderer=ca;Lexer=Be;Tokenizer=Jr;Hooks=In;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new ei(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Jr(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new In;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,s=n.hooks[a],l=i[a];In.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&In.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let c=s.call(i,u);return l.call(i,c)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,u);return h===!1&&(h=await l.apply(i,u)),h})();let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Be.lex(t,e??this.defaults)}parser(t,e){return Ke.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,s=await(i.hooks?await i.hooks.provideLexer(t):t?Be.lex:Be.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?Ke.parse:Ke.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?Be.lex:Be.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(t):t?Ke.parse:Ke.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
399
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Qe(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Dt=new da;function j(t,e){return Dt.parse(t,e)}j.options=j.setOptions=function(t){return Dt.setOptions(t),j.defaults=Dt.defaults,Yd(j.defaults),j};j.getDefaults=ra;j.defaults=Pt;function pb(...t){return Dt.use(...t),j.defaults=Dt.defaults,Yd(j.defaults),j}j.use=pb;j.walkTokens=function(t,e){return Dt.walkTokens(t,e)};j.parseInline=Dt.parseInline;j.Parser=Ke;j.parser=Ke.parse;j.Renderer=ei;j.TextRenderer=ca;j.Lexer=Be;j.lexer=Be.lex;j.Tokenizer=Jr;j.Hooks=In;j.parse=j;var QE=j.options,JE=j.setOptions,eS=j.walkTokens,tS=j.parseInline;var nS=Ke.parse,rS=Be.lex;var ah={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},gb=new RegExp(`[${Object.keys(ah).join("")}]`,"g");function Le(t){return t.replace(gb,e=>ah[e])}var mb=["http:","https:","mailto:"],sh=/^[a-z][a-z0-9+.-]*:/i,lh=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function oh(t){let e=t.replace(lh,""),n=sh.exec(e);return n===null?e===""?null:t:mb.includes(n[0].toLowerCase())?t:null}var st="data-weave-target",ni="note:",vb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function yb(t){if(t.kind!=="note"||!t.id.startsWith(ni))return null;let e=t.id.slice(ni.length);return e===""?null:e}function uh(t){if(t.kind!=="file"||!t.id.startsWith("artifact:"))return null;let e=t.detail.path;return e!==void 0&&/\.html?$/i.test(e)?e:null}function ch(t){let e=uh(t);return e===null?null:`${e}:${t.detail.updated??""}`}function dh(t,e){if(t===null||e===null)return null;let n=t.model.nodes.find(r=>r.id===e);return n===void 0?null:uh(n)}function hh(t,e){if(t===null)return vb;let n=new Map;for(let i of t.model.nodes){let o=yb(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:e}}function fh(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function wb(t,e){if(t.currentSlug===null||sh.test(e.replace(lh,"")))return null;try{let n=new URL(e,`https://weave.invalid/${t.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:fh(t,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function bb(t){return t.hasGhosts}var xb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function _b(t){let e=t.indexOf("[[");return e===-1?void 0:e}function kb(t){return{name:"wikilink",level:"inline",start:_b,tokenizer(e){return Sb(e)},renderer(e){return Eb(t,e)}}}function Eb(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Tb(t,n,r)}function Sb(t){let e=xb.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Tb(t,e,n){let r=Le((n===""?e:n).trim());if(r==="")return"";let i=fh(t,e);return i!==null?`<a class="weave-wiki" ${st}="${Le(i)}" role="link" tabindex="0" title="${Le(e.trim())}">${r}</a>`:bb(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Le(e.trim())}">${r}</span>`:r}function Ab(t){return new da({gfm:!0,async:!1,extensions:[kb(t)],renderer:{html({text:e}){return/^\s*<!--[\s\S]*?-->\s*$/.test(e)?"":Le(e)},link({href:e,title:n,tokens:r}){let i=oh(e),o=this.parser.parseInline(r),a=i===null?null:wb(t,i);if(a!==null){let l=n==null||n===""?"":` title="${Le(n)}"`;return`<a class="weave-wiki" ${st}="${Le(a)}" role="link" tabindex="0"${l}>${o}</a>`}return`<a${[i===null?"":` href="${Le(i)}"`,n==null||n===""?"":` title="${Le(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=oh(e);if(i===null)return Le(r);let o=n==null||n===""?"":` title="${Le(n)}"`;return`<img src="${Le(i)}" alt="${Le(r)}"${o}>`}}})}function Rb(t,e){return Ab(e).parse(t,{async:!1})}function Fn(t){return Object.freeze(t)}var Cb=Fn({ALLOWED_TAGS:Fn(["p","br","hr","h1","h2","h3","h4","h5","h6","em","strong","del","code","pre","blockquote","ul","ol","li","a","span","img","table","thead","tbody","tr","th","td","input"]),ALLOWED_ATTR:Fn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",st]),ADD_URI_SAFE_ATTR:Fn([st]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Fn({html:!0})});function ph(t,e,n){return t.sanitize(Rb(e,n),Cb)}var gh=32;function ha(t){let e=t;for(let n=0;e!==null&&n<gh;n++){let r=e.getAttribute(st);if(r!==null&&r!=="")return`${ni}${r}`;e=e.parentElement}return null}function mh(t){if(!t||t.isCollapsed===!0)return!1;let e=t.toString;return(typeof e=="function"&&e!==Object.prototype.toString?e.call(t):"").length>0}var vh="edited",yh="created";function wh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:At(t.source),provenanceTitle:Xt(t.source),updated:En(t.updated,e),updatedIso:t.updated,created:En(t.created,e),createdIso:t.created,tags:t.tags}}function bh(t){return`#${t}`}var Lb=200,Nb=8,Db="no note",fa="weave-preview";function pa(t){let e=t;for(let n=0;e!==null&&n<gh;n++){let r=e.getAttribute(st);if(r!==null&&r!=="")return{slug:r,text:(e.textContent??"").trim()};if((e.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(e.textContent??"").trim()};e=e.parentElement}return null}function Pb(t){return t.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(e,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function Ib(t,e=Lb){let n=Pb(t);if(n.length<=e)return n;let r=n.lastIndexOf(" ",e);return`${r>0?n.slice(0,r):n.slice(0,e)}…`}function xh(t,e){if(e.slug===null){let i=e.text===""?"this link":e.text;return{ghost:!0,title:i,kind:Db,text:`no note named “${i}” yet`}}let n=t?.model.nodes.find(i=>i.id===`note:${e.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Xt(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Ib(n.detail.preview??"")}}function _h(t,e,n,r,i,o,a=Nb){let s=t+a,l=e+a;return s+n>i-a&&(s=t-a-n),l+r>o-a&&(l=e-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var ri={anchor:null,pointerX:0,pointerY:0};function kh(t,e){switch(e.type){case"show":return e.anchor.slug===null&&e.anchor.text===""?t:{anchor:e.anchor,pointerX:e.x,pointerY:e.y};case"hide":return t.anchor===null?t:ri;case"dismiss":return ri}}function Eh(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(ni)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Gb="weave-preview-x",Mb="weave-preview-y";function Fb({view:t,open:e}){return b("header",{class:"weave-note-head",children:[b("h3",{class:"weave-note-title",children:t.title}),b("p",{class:"weave-note-meta",children:[b("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:e,children:b("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),b("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),b("span",{class:"weave-note-time",title:t.updatedIso,children:[vh," ",t.updated]}),b("span",{class:"weave-note-time",title:t.createdIso,children:[yh," ",t.created]})]}),b("p",{class:"weave-note-tags",children:t.tags.map(n=>b("span",{class:"weave-tag",children:bh(n)},n))})]})}function Sh(t){let e=t.note?.note??null,n=dh(t.graph,t.selectedId),r=Eh(t.selectedId,e),i=Ze(()=>e===null?null:hh(t.graph,e.slug),[e,t.graph]),o=Ze(()=>e===null||i===null?"":ph(Ud,e.body,i),[e,i]),[a,s]=B(ri),l=f=>{s(p=>kh(p,f))},u=Z(null),c=Z(null),h=a.anchor===null?null:xh(t.graph,a.anchor);if(_t(()=>{l({type:"hide"})},[e===null?null:e.slug]),_t(()=>{let f=u.current;if(f!==null){let v=a.anchor?.slug??null;for(let w of f.querySelectorAll(`a[${st}]`))v!==null&&w.getAttribute(st)===v?w.setAttribute("aria-describedby",fa):w.removeAttribute("aria-describedby")}let p=c.current;if(p===null||h===null)return;let m=_h(a.pointerX,a.pointerY,p.offsetWidth,p.offsetHeight,window.innerWidth,window.innerHeight);p.style.setProperty(`--${Gb}`,`${m.x}px`),p.style.setProperty(`--${Mb}`,`${m.y}px`)},[a,h]),n!==null){let f=t.graph?.model.nodes.find(v=>v.id===t.selectedId),p=f?.label??n,m=f===void 0?n:ch(f)??n;return b("article",{class:"weave-note weave-note-artifact",children:[b("header",{class:"weave-note-head",children:[b("h3",{class:"weave-note-title",children:p}),b("p",{class:"weave-note-meta",children:b("span",{class:"weave-note-time",children:n})})]}),b("iframe",{class:"weave-artifact-frame",title:p,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(n)}`},m)]},m)}if(e===null||i===null)return b("p",{class:"weave-note-empty",children:r});let d=wh(e,t.now);return b("article",{class:`weave-note weave-note-${d.provenance}`,children:[b(Fb,{view:d,open:()=>t.onOpen(e.slug)}),b("div",{ref:u,class:"weave-note-body",tabIndex:-1,onMouseOver:f=>{let p=pa(f.target);l(p!==null?{type:"show",anchor:p,x:f.clientX,y:f.clientY}:{type:"hide"})},onMouseLeave:()=>l({type:"hide"}),onFocus:f=>{let p=pa(f.target);if(p===null)return;let m=f.target.getBoundingClientRect?.();l({type:"show",anchor:p,x:m?.left??0,y:m?.bottom??0})},onBlur:()=>l({type:"hide"}),onClick:f=>{let p=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(mh(p))return;let m=ha(f.target);if(m!==null){t.onSelect(m);return}},onKeyDown:f=>{if(f.key==="Escape"&&a.anchor!==null){f.stopPropagation(),l({type:"dismiss"});return}if(f.key!=="Enter"&&f.key!==" ")return;let p=ha(f.target);p!==null&&(f.preventDefault(),t.onSelect(p))},dangerouslySetInnerHTML:{__html:o}}),h===null?null:b("div",{ref:c,id:fa,role:"tooltip",class:`weave-preview${h.ghost?" weave-preview-ghost":""}`,children:[b("span",{class:"weave-preview-kind",children:h.kind}),b("span",{class:"weave-preview-title",children:h.title}),h.text===""?null:b("p",{class:"weave-preview-text",children:h.text})]})]},e.slug)}var On=["tree","note","graph"],ga={tree:180,note:320,graph:260},Rh={tree:.22,note:.46,graph:.32},Ob=1100,zb=800;function Ch(t){return!Number.isFinite(t)||t<zb?"narrow":t<Ob?"medium":"wide"}function Th(t){return t==="wide"?On:t==="medium"?["tree","note"]:["note"]}function Lh(t,e,n){let r={tree:0,note:0,graph:0},i=0;for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:Rh[l],i+=r[l]}for(let l of t)r[l]/=i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function Nh(t,e){return Lh(On,t,e)}function va(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:ga.tree/e,note:ga.note/e,graph:ga.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function Dh(t,e){return{fractions:Nh(t,va(e))}}function Ah(t){return Dh(Rh,t)}function Ph(t,e,n){let r=Number.isFinite(e)&&e>0?e:0,i=Lh(Th(n),t.fractions,va(r));return Th(n).map(o=>({id:o,width:i[o]*r}))}function $b(t){return t==="tree"?["tree","note"]:["note","graph"]}function ya(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=$b(e),s=va(i),l=Math.max(-Math.max(0,t.fractions[o]-s[o]),Math.min(Math.max(0,t.fractions[a]-s[a]),n/i));return l===0?t:{fractions:Nh({...t.fractions,[o]:t.fractions[o]+l,[a]:t.fractions[a]-l},s)}}var Ih="pi-weave.layout.v1",ma=t=>Math.round(t*1e4)/1e4;function Ub(t){return JSON.stringify({v:1,tree:ma(t.fractions.tree),note:ma(t.fractions.note),graph:ma(t.fractions.graph)})}function Hb(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={};for(let o of On){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return Dh(i,e)}function Gh(t,e){try{return Hb(t.getItem(Ih),e)??Ah(e)}catch{return Ah(e)}}function Mh(t,e){try{return t.setItem(Ih,Ub(e)),!0}catch{return!1}}var Wb={notes:0,repo:null,nodes:0},Bb=["note"];function Fh(t){if(t===null)return Wb;let e=t.model.nodes;return{notes:e.filter(n=>Bb.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function Kb(t){return t===null||t==="missing"?"unindexed":t}function Oh(t){return[`vault:${t.notes}`,`repo:${Kb(t.repo)}`,`${t.nodes} nodes`]}var Vb={tree:{title:"Tree"},note:{title:"Note"},graph:{title:"Graph"}};function zh(t){return Vb[t]}var wa={title:"Context"},$h="—";function Uh(t,e,n){return{cwd:t===""?$h:t,selection:e??"nothing selected",stamp:n}}function Hh(t){return t===null?$h:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}var Wh=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],Bh=6e4,Kh="Search…";function ba(t){return t?"⌘K":"Ctrl K"}function Vh(t){return`Search notes and repository (${t})`}function xa(t){return/mac|iphone|ipad/i.test(t)}var jb={k:{type:"openSearch"}},jh={1:"tree",2:"note",3:"graph"},qb=new Set(["tree","graph"]);function Yb(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Xb(t){return!t.ctrl&&!t.meta&&!t.alt}var Zb={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function qh(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Yb(t)){let n=jb[t.key.toLowerCase()];if(n!==void 0)return n;let r=jh[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Xb(t)||t.typing?null:Zb[t.key]??null}var Qb=["INPUT","TEXTAREA","SELECT"];function _a(t,e){return e?!0:t!==null&&Qb.includes(t.toUpperCase())}function Yh(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:_a(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Jb={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},ex=".weave-col-tree .weave-filter";function tx(t){let e=t;return typeof e?.focus=="function"?e:null}function Xh(t,e){let n=tx(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function Zh(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(Jb[t.column]);case"filterTree":return void e.focusSelector(ex);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"cycleTheme":return e.cycleTheme()}}function Qh(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(jh).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${qb.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var ka="Keyboard shortcuts",Jh="esc close";var ef={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function zn({name:t,class:e}){let n=ef[t];return b("svg",{class:e,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>b("path",{d:r}))})}function rx({view:t,recentIds:e,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let u=Po(t.id);return b("li",{id:t.domId,"data-row-id":t.id,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${e.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:ec(t.depth),onClick:o,draggable:t.id.startsWith("note:"),"aria-label":t.id===Yt?"New folder":void 0,onDragStart:c=>c.dataTransfer?.setData("text/plain",t.id),onDragOver:u===void 0?void 0:c=>c.preventDefault(),onDrop:u===void 0?void 0:c=>{c.preventDefault(),l(c.dataTransfer?.getData("text/plain")??"")},onContextMenu:c=>{c.preventDefault(),c.stopPropagation(),s(c.clientX,c.clientY)},children:[b("span",{class:"weave-twisty","aria-hidden":"true",onClick:c=>{c.stopPropagation(),a()},children:t.hasKids?b(zn,{name:"chevron",class:t.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),b("span",{class:"weave-kind","aria-hidden":"true",children:b(zn,{name:t.kindIcon,class:"weave-icon"})}),b("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),n===null?b("span",{class:"weave-label",children:t.label}):b(ix,{value:n,draft:t.id===Yt,onEdit:r,onCommit:i}),b("span",{class:"weave-meta",children:t.meta})]})}function ix({value:t,draft:e,onEdit:n,onCommit:r}){let i=Z(null);return _t(()=>{let o=i.current;o!==null&&(o.focus(),o.select())},[]),b("input",{ref:i,class:"weave-tree-rename",value:t,placeholder:e?"New folder name…":void 0,onClick:o=>o.stopPropagation(),onInput:o=>n(o.currentTarget.value),onBlur:o=>r(o.currentTarget.value),onKeyDown:o=>{o.stopPropagation(),o.key==="Enter"?o.currentTarget.blur():o.key==="Escape"&&r(null)}})}function tf(t){let[e,n]=B($u),[r,i]=B(null),[o,a]=B(null),[s,l]=B(null),u=Bu(Uu(t.graph,e),s),c=lc(t.graph,u,e),h=async(m,v)=>{let w=await m;if(!w.ok)window.alert(w.message);else{let y=w.data.id??v;y!==void 0&&t.onSelect(y),t.onRefresh()}},d=async m=>{if(r===null)return;let v=Sn(r.id);if(i(null),v!==null)if(m==="newFolder"){let w=Hu(v);w!==""&&n(y=>Do(y,`vfolder:${w}`)),l(w),a({id:Yt,label:"",value:""})}else m==="rename"?a({id:r.id,label:r.label,value:r.label}):v.type!=="vault"&&await h(v.type==="note"?Rl($e,v.path):Nl($e,v.path),Ku(t.selectedId,v)?"vault":void 0)},f=m=>{if(r!==null){if(Io(m)&&r.armed!==!0){i({...r,armed:!0});return}d("delete")}},p=m=>{let v=o,w=s;if(a(null),l(null),v===null)return;let y=m?.trim();if(v.id===Yt){let k=w===null||!y?null:Wu(w,y);k!==null&&h(Cl($e,k));return}let _=Sn(v.id);_!==null&&y&&y!==v.label&&h(_.type==="note"?Tl($e,_.path,y):Ll($e,_.path,y))};return b("div",{class:"weave-tree",onKeyDown:m=>{let v=m.target,w=Xu(u,e,t.selectedId,m.key,_a(v?.tagName??null,v?.isContentEditable===!0));w.handled&&(m.preventDefault(),n(w.state),w.selectedId!==null&&t.onSelect(w.selectedId))},children:[b("div",{class:"weave-tree-controls",children:[b("input",{type:"search",class:"weave-filter",value:e.query,placeholder:ic,"aria-label":ac,title:sc,onInput:m=>n(ju(e,m.currentTarget.value))}),b("button",{type:"button",class:"weave-chip",title:tc(e.provFilter),onClick:()=>n(qu(e)),children:["◧ ",Mr(e.provFilter)]}),b("button",{type:"button",class:"weave-chip",title:rc(e.showInternals),onClick:()=>n(Yu(e)),children:["◧ ",nc(e.showInternals)]})]}),c===null?b("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":oc,"aria-activedescendant":Ju(u,t.selectedId)??void 0,onContextMenu:m=>{m.preventDefault(),i({id:"vault",label:"Vault",x:m.clientX,y:m.clientY})},children:Qu(u,t.selectedId,t.now).map(m=>b(rx,{view:m,recentIds:t.recentIds,edit:o?.id===m.id?o.value:null,onEdit:v=>a(w=>w===null?null:{...w,value:v}),onRename:p,onSelect:()=>{t.onSelect(m.id),m.hasKids&&n(v=>No(v,m.id))},onToggle:()=>n(No(e,m.id)),onMenu:(v,w)=>i({id:m.id,label:m.label,x:v,y:w}),onDrop:v=>{let w=Po(m.id);v.startsWith("note:")&&w!==void 0&&h(Al($e,v.slice(5),w))}},m.id))}):b("p",{class:"weave-tree-empty",children:c}),b("p",{class:"weave-tree-count",children:uc(u)}),r!==null&&Sn(r.id)!==null?(()=>{let m=Sn(r.id);return b(Oe,{children:[b("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:()=>i(null)}),b("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},children:[b("button",{type:"button",role:"menuitem",onClick:()=>{d("newFolder")},children:"New folder…"}),m.type!=="vault"?b(Oe,{children:[b("button",{type:"button",role:"menuitem",onClick:()=>{d("rename")},children:"Rename…"}),b("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>f(m),children:Vu(m,r.label,r.armed===!0)})]}):null]})]})})():null]})}var $n={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function ai(t,e,n){return{id:t,target:e.id,label:Ae(e),kind:e.kind,kindIcon:Go(e.kind),provenance:e.provenance,provenanceGlyph:At(e.provenance),provenanceTitle:Xt(e.provenance),selected:e.id===n}}function ox(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:ai(t.id,i,n)}function ax(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var sx=["link:links-to:"];function lx(t){return sx.some(e=>t.id.startsWith(e))}function ux(t){return t.id.startsWith("link:mentions:")}function cx(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(ai(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function dx(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(ai(`mentioned-by:${o.source}`,a,r))}return i}function hx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var oi={loading:"Loading…",noSelection:"Select anything to see what it connects to.",unknown:"This node is not in the current graph.",isolated:"Nothing links to or from this yet."};function Ea(t){return{subject:null,groups:[],tags:[],tagsCount:0,empty:t}}function nf(t,e){if(t===null)return Ea(oi.loading);if(e===null)return Ea(oi.noSelection);let n=Tt(t),r=To(n,e);if(r===null)return Ea(oi.unknown);let i=ax(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>ox(d,i,e)).filter(d=>d!==null);a($n.links,s(r.links.filter(lx)));let l=Ro(n.edges).get(e)??[];a($n.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>ai(`backlink:${h.id}`,h,e))),a($n.mentions,[...s(r.links.filter(ux)),...dx(n,e,i,e)]);let u=hx(e),c=u===null?[]:cx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:oi.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function rf(){return{open:new Set,closed:new Set}}var fx=8;function of(t,e,n,r){return r?!1:t.closed.has(e)?!0:t.open.has(e)?!1:n>fx}function px(t){return t.some(e=>e.selected)}function af(t,e){let n=of(e,t.heading,t.count,px(t.rows));return{heading:t.heading,count:t.count,collapsed:n,rows:n?[]:t.rows}}function sf(t,e){let n=of(e,$n.tags,t.length,t.some(r=>r.siblings.some(i=>i.selected)));return{heading:$n.tags,count:t.length,collapsed:n,rows:[]}}function lf(t,e,n){let r=new Set(t.open),i=new Set(t.closed);return n?(r.add(e),i.delete(e)):(i.add(e),r.delete(e)),{open:r,closed:i}}function si(t){return`weave-ctx-panel-${t.toLowerCase()}`}function uf({row:t,onSelect:e}){return b("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:b("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[b("span",{class:"weave-kind","aria-hidden":"true",children:b(zn,{name:t.kindIcon,class:"weave-icon"})}),b("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),b("span",{class:"weave-label",children:t.label})]})})}function cf({view:t,onToggle:e}){return b("h4",{class:"weave-ctx-head",children:b("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!t.collapsed,"aria-controls":si(t.heading),onClick:e,children:[b("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:b(zn,{name:"chevron",class:t.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),t.heading,b("span",{class:"weave-ctx-count",children:t.count})]})})}function gx({view:t,onSelect:e,onToggle:n}){return b("section",{class:"weave-ctx-group",children:[b(cf,{view:t,onToggle:n}),b("ul",{class:"weave-ctx-rows",id:si(t.heading),hidden:t.collapsed,children:t.rows.map(r=>b(uf,{row:r,onSelect:()=>e(r.target)},r.id))})]})}function mx({tag:t,onSelect:e}){return b("li",{class:"weave-ctx-tag",children:[b("span",{class:"weave-tag",children:["#",t.tag]}),b("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>b(uf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function df(t){let e=nf(t.graph,t.selectedId),[n,r]=B(rf),i=a=>()=>r(lf(n,a.heading,a.collapsed)),o=sf(e.tags,n);return b("div",{class:"weave-rail","aria-label":wa.title,children:[b("h2",{class:"weave-col-title",children:wa.title}),e.empty===null?null:b("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(a=>{let s=af(a,n);return b(gx,{view:s,onSelect:t.onSelect,onToggle:i(s)},a.heading)}),e.tags.length===0?null:b("section",{class:"weave-ctx-group",children:[b(cf,{view:o,onToggle:i(o)}),b("ul",{class:"weave-ctx-tags",id:si(o.heading),hidden:o.collapsed,children:e.tags.map(a=>b(mx,{tag:a,onSelect:t.onSelect},a.tag))})]})]})}function hf(t){return b("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function vx({id:t,props:e}){let n=zh(t);return b("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[b("h2",{class:"weave-col-title",children:n.title}),t==="tree"?b(tf,{graph:e.graph,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:e.onSelect,onRefresh:e.onRefresh,now:e.now}):null,t==="note"?b(Sh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,onOpen:e.onOpen}):null,t==="graph"?b(xd,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit,tuner:e.tuner}):null,t==="graph"?b(df,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function ff(t){let e=Z(null);return _t(()=>{let n=e.current;if(n!==null)for(let{id:r,width:i}of t.resolved)n.style.setProperty(`--weave-col-${r}`,`${Math.round(i)}px`)},[t.resolved]),b("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:t.resolved.map((n,r)=>{let i=r<t.resolved.length-1&&n.id!=="graph"?n.id:null;return[b(vx,{id:n.id,props:t},`${n.id}-column`),i===null?null:b(hf,{label:`Resize ${n.id} column`,onDown:o=>t.onDown(i,o),onMove:t.onMove,onUp:t.onUp,onKey:o=>t.onKey(i,o)},`${n.id}-divider`)]})})}function yx(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function pf(t,e){let n=yx(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function gf(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}function wx(t,e,n){return{divider:t,origin:e,base:n}}function bx(t,e,n){return ya(t.base,t.divider,e-t.origin,n)}function xx(t,e){return On.some(n=>t.base.fractions[n]!==e.fractions[n])}var mf=24;function _x(t){return t==="ArrowLeft"?-mf:t==="ArrowRight"?mf:0}function vf(t){let e=null;return{onDown(n,r){e=wx(n,r,t.layout())},onMove(n){e!==null&&t.setLayout(bx(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&xx(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=ya(t.layout(),n,_x(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var yf="image/png",wf="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAALxElEQVRoBe1ZCXCU1R3/f+d+u5s9sleyOUlICBAMkQQQgpqBKqAoFQZFEYwWUAShjsco7dg4njRtPQcoXhSxWMGCimIYj1QqeICAcoQrd0iy2c1+u/vdZ9+m0xnFVCKw0+kMb+fb7/vevnnv//v/f//jvQVIYWtsbCn47uTJ3BQuAXgqJzdRM9CVyjVSCkACCUBIpfgAZCqnl5D8GJ5aBCm1ACALiGIqVZRqC7AIAGApRZBSCiUUBVN14/8YAJfAdN1MKU1TagEuwWEgp1T+1EYhRVUMhdNSmgdSagFeEHVJU/RUOkFKAThIWknLZNRUAkhFjKPSg2Muszocl/i8/mLT1M1IpO/rCBvaK/cePXGhwVxAANacYEHlkmEjymeguFNKUhShaToYhgG6rgJuAifL4oHjpxo3xdu/fAkBuSCWuSAAPNljLsvPH/lCusdfSVlIkFUFVCS0CQYkazkMuTGJEUAQJMrMEkTD3TvaWg/dJUab2s7XIsT5TkA6Cifl5434sCCvqEAS4sBzMdAVFdxYOjgxF6ShD6VTkBCjoEkiEKYBAX9WsaGT0yKh8DsAYvx8ZDhPADnW4SXlr+XnDh0WY3tBlgQwDQ10UQe/NQgOygkexoe4E4WE0AdgIkohWskiD440t9/EKX+cbd36PwNgd+ffMyR/2GJZjoOmySAryfITAxNHQkoyiLLYT6U2thHRB0djNPSuAY4lnyVQVLlMEMm9utp3zs59XmnSmeaelmZzgq7KkIjHgY3FQFOUfs4HHYUgawLQuAVspgdZRgcFAWRZFlRFRmMMtJvCMIKiZpyPBX5WHnA4hvkom/N6VVc+T4S/bXU4XCUCokZSaJokUd3JIDBqP4CuWDMIegRaIhIQyIFV1A+GCXbG2n/XVR2NN4AkiYokAE+g4mqapsrZRHSzFDvWPFhQPweAy+HxfZQdLBgtSVxPs8I/gdji1ZA2RVEAl98D106fAjzPw57P9gAb7QQLZQHVjIOAAKYHAjCheiLgyOY7360HmZdQiNWSlilM95c9npeT9yBJMxS0Q013DMYiAPxgQAzaiTOyxt/rcqXPa2tvApLA0zCcmsrQFIVhBmaxW+DJVQ/BroZdEOrugoUL58LB/Y0gCRLKAQZk5GTA0uXz4Z2t28Fuo+GeZTWwc+enIAhC8nerlbFeoagScbqrA3wejx8j3L0C3/XFYAAMygfs9pIyl9O1MhYNQzzGrgj1hrZKsoYbhorzXByurL4Mwt2nYcNL68DvcUKWzwlFQ7OQU8ugagoMLciEHL8Lcd6Etc+sAcxQYEzFJSAl95zID+KcBD294Q2JRGI5G2fB5fI8YnGUlAwGwGAohNMMU4cWc/Sx7KuG2vI8x8Jawjpso81mmZNmRTRBcV9B/PbmFcNL6zfD9voGmFRZDiamIfEwiERZmHbDIojHBQgOLQBJ1UBE1jGQdRTN0AVBXGfIJ+9FAstRlqqgKOttDEU/JQPMRn0/Wc2elUIMkzGEsTlXJXi+XUzEb3K48m7Jy7/0EcOQFUXRhtusNN7dE4aJl08EX4YXWFGFkqJC6Go/jaKO0p+JNeSweYUFkOb3wby5M5AlLPD2W+8ix1ZAkuWEw2FrzM4tu0/RGUaMs8+aOH4NTuIVkkmvBzWe+ClLDFhK+EpmVyL1lbsN/vWOrhM3khbrBo7nZjot+JFA5tBGTdcJUeIhnuDAjixgtzKQGcyCEWWjkBNz0Hz8GIR6QuByu4GiCYhGYuAPeKFg2HCw0BQc2PsN9PR0I+2bIKJ84XQ60BwOFJFIs635cLEO5FCLzb5D4rnZdXJz/ZHPDyxDfNz38pTxn5wJ5kcWmANziGYf9iFGuhbqBN7Js20WXZY/MOSWjZnZZS/abday1o6WQ5KsHHc60rOCmQGcZaMgoeza2dIKXW0toMgyijYYTKwaC5mZGdDe2g4CL0BHczN0oOcYyhcySmrZwWyQUaWXiLEf83w84fP6gjhppWN9B59XJThlc1C23KorJkEw94+KwE+4IT+4tqGh4Qeb7IEsgPmLZ69EaX4egSmfUTR2imacR+OhZi7T5XqPZXvtPT1dNarUvKmoZFqb00ZmtnR2ogJOA4eVAgrlA5Ig+rmvo7LBRB+CJPqppOs6SMixeVRqoAgGOUE/RFi+tbNt9xAgcmbl5Q3ZYrenR4pmVNxUfvVUXzwSzVVwwq243NNNTd/46rSJz53pEwNFIbP3xNtP2OhEFYqRR2UdX6OqYjdtd47ri/bSmirL/iFF3ZfPucfNxkInBIEDK00jpcu7E6KcYHmUlUUZBFlFOcAE3cRAkDTgBBlinAhokxZFkekf6e505AIqJBJsY119faD6uqmGpkiapPE2f0awCJXeB8W+wPOuuNzl23tgChL+2TOFT9JpIADJfmj77v0oup2wEDCpff+bewvGD98IFBWxEDiDwsf9hM8/05WT2xxLJEyaJmm7le7ho9FxkswvS/Dc/dFY/LlonNvSF49vY+Pc6hifWIpC8Dw+dqrS7XIj7zaocJQ1Kqdc0YZJ9PRwT2QJCrOU2+8Jjysd/envp08+FtBbr8RVaF710J2xfqEG+PqRD3x/THG+rUU0PLPtROE39uyMcWxXVycKLZM5Nmoc++dbS1csvnnrRx/vxVE9M8GTkV3qyw6Ee1u/qtOVyB50fajJvZs1Ofw3XQl/sF2OfDtz6W29TYfaF1hp+0IBhdFYLPrI8f31D+x88y+H4qz2G4vV6qXtrqdLKyrJ2b+YcJITbTNDVGjTvu3bf8D778s4kA98/3fIKps1BjOpsa5AuuXIod2vOBStHsXpqr6+SHX1pJrPWaqlINTW8QeU1aZnlZdR+eUlvyU0vY1kLCRptZiMg0F1EkHjBBgUQVQ27W+8dt+2nXYbSW5cNOf2Y8hDTr++7a9MU1vTG2Coh2PRo1WPPrZ1kSpKhkbInz39WM2+Hwh0xstZE5nOmx2YlamPhGWtIOeSxlioqV6K81W+YPbdLN1ZihEWLm/kqId0XT7sLyzo0riEDyfpRlRRNxk4jRJcQiEMtLtXyOt0IHYXlA45Xgiz4tmZubvwU60tkjdQ6khzLZIVExsz8tK9117+6Aw9xDxoIWweTQmNOEPeH72eFYCVIXHJNATAqBzd0Ce7fJmbuGhjKaIRf2Bn9lqAWqNi8WIqXUhvf3/VijXXPFCbyTC2+QppYSinN6wIHI2Z2DTM1Hc4KAPFePygE7PLoUhk7JMvLD+GJPoGyLxWmmb+XpI36kFRkGehAtxiqFo3SgtnPZL5r078H6gthzd345g6iTbk0ThmNuMYE1S4ozWSzNYlhU+Oo7stowRePJ18/qCutnvT75bVaR5fjeTyf6va019WJellKsxyAqcH/jR/7sHTEaVN541MtF/+N4UJc7MiHJ8f8GVUaqZqSlhstAnRisdfXHDWsvqsFkgKdfrQm+3olrwOF1feOLdk4q23B4cVvdawvhZ1AaBN1nBTV79MPpfOqaXdQmQ838OC1euTUbncjHP4nSoeWGF09d2VHLNu3Z3C8kWruTvueMqHXntfe3hD56HOYzWKIsefeWUJOrFIHgMMrp3ViQeapqRqbiVOWyfjJLlTZZwdjMrfAgb/itXmrqJJy0gMx47rUmSXf/pV3m1Lbm655f4X51oY5zgqLh7Red5u8PoXhElngsnkY5i4h6TwaswkGla/sfTrgdb7qb5zApCcsKTqDlTAkLertPNhAsMkq5pYzxDYJ1+9v2bX9xe8fuHKDJr2/nLL6vv+nOxfsOBJryli1zFGcKWN8hbzemiLyLX/6o0dted0OnHOAJLClFy1LEvBiMMYQSgMSHUUgUcoEpOApFmaolkGw3UrYbuR0I3dhKoLlEGmo2LDhTb4HGV4J1Fgv17RYr9+ddvit5LznUs7LwDJBUurby1C1aPW2LC+pbT67jTKTfssFOFFB1lOdJSF6lSKoHCStSgGj0qkMNrDhN97r7b/j7M5U2s9m+tr0XnLxXZRAxc1cFEDFzVwUQPnpoF/AbqLsVZFbswxAAAAAElFTkSuQmCC";function kx({onRefresh:t}){let[e,n]=B(!1);return b("button",{type:"button",class:"weave-refresh",onClick:()=>{t(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":e?"true":void 0,children:b("svg",{class:e?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:Wh.map(r=>b("path",{d:r},r))})})}function bf(t){return b("header",{class:"weave-header",children:[b("span",{class:"weave-brand",children:[b("img",{class:"weave-brand-mark",src:`data:${yf};base64,${wf}`,alt:"",width:18,height:18}),"pi-weave"]}),b("button",{type:"button",class:"weave-search",title:Vh(t.shortcut),onClick:t.onSearch,children:[b("span",{class:"weave-search-text",children:Kh}),b("kbd",{children:t.shortcut})]}),b("span",{class:"weave-summary",children:Oh(t.summary).map(e=>b("span",{class:"weave-summary-part",children:e},e))}),b("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),b(kx,{onRefresh:t.onRefresh})]})}function Ex({group:t}){return b("div",{children:[b("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>b("div",{class:"weave-key-row",children:[b("kbd",{class:"weave-key-combo",children:e.combo}),b("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function xf(t){let e=Vr(),n=t.shortcut.slice(0,-1);return b("div",{class:"weave-scrim",onClick:t.onClose,children:b("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":ka,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[b("h2",{class:"weave-help-title",children:ka}),b("div",{class:"weave-keys",children:Qh(n).map(r=>b(Ex,{group:r},r.title))}),b("p",{class:"weave-help-foot",children:[b("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),b("span",{class:"weave-help-hint",children:Jh})]})]})})}function _f(t,e){let n=r=>{let i=qh(Yh(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function kf({model:t}){return b("footer",{class:"weave-status",children:[b("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),b("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),b("span",{class:"weave-status-stamp",title:"data as of",children:Hh(t.stamp)})]})}var Sa=["system","light","dark"],Ef="pi-weave.theme.v1";function Sx(t){return t==="system"||t==="light"||t==="dark"}function li(t){try{let e=t.getItem(Ef);return Sx(e)?e:null}catch{return null}}function Sf(t,e){try{return t.setItem(Ef,e),!0}catch{return!1}}function ui(t){let e=Sa.indexOf(t);return Sa[(e+1)%Sa.length]??"system"}function Tf(t,e){return t==="system"?e:t}function ci(t){return t==="system"?null:t}var Tx={dark:"●",system:"◐",light:"○"};function Af(t){return{glyph:Tx[t],hint:`Colour theme: ${t} — click for ${ui(t)}`}}function Ax(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function Rf(t){let[e,n]=B(ed),[r,i]=B(null),[o,a]=B(t.initialWidth),[s,l]=B(()=>Gh(localStorage,t.initialWidth)),[u,c]=B(()=>li(localStorage)??"system"),[h,d]=B(()=>br(window)),f=Z(null),p=Z(null),m=Z({overlay:r,selectedId:e.selectedId,layout:s,width:o});m.current={overlay:r,selectedId:e.selectedId,layout:s,width:o},oe(()=>{let R=rd({fetch:$e,state:e,setState:n});return f.current=R,()=>R.stop()},[]),oe(()=>{let R=()=>a(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let v=Z(!1),w=Z(location.hash);oe(()=>{v.current&&(Qc(localStorage,e.selectedId),history.replaceState(null,"",gf(e.selectedId)))},[e.selectedId]),oe(()=>{if(v.current||e.graph===null||(v.current=!0,e.selectedId!==null))return;let R=pf(w.current,e.graph);if(R!==null)f.current?.select(R);else{let P=Jc(e.graph,localStorage);P!==null&&f.current?.select(P)}},[e.graph]);let[y,_]=B(()=>Date.now());oe(()=>{let R=setInterval(()=>_(Date.now()),Bh);return()=>clearInterval(R)},[]),oe(()=>Ax(ci(u)),[u]),oe(()=>{Sf(localStorage,u)},[u]),oe(()=>Pl(window,d),[]),oe(()=>_f(document,{context:()=>({overlay:m.current.overlay,hasSelection:m.current.selectedId!==null}),run:R=>Zh(R,{setOverlay:i,focusSelector:P=>Xh(document,P),fitGraph:()=>p.current?.(),clearSelection:()=>{f.current?.select(null)},cycleTheme:()=>c(P=>ui(P))})}),[]);let k=Ze(()=>Ph(s,o,Ch(o)),[s,o]),N=Ze(()=>vf({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:l,persist:R=>{Mh(localStorage,R)}}),[]);return b(Oe,{children:[b(bf,{summary:Fh(e.graph),shortcut:ba(xa(t.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:Af(u),onTheme:()=>c(R=>ui(R))}),b(ff,{resolved:k,onDown:N.onDown,onMove:N.onMove,onUp:N.onUp,onKey:N.onKey,scheme:Tf(u,h),bootFailed:e.graphFailed,graph:e.graph,note:e.note,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:R=>{f.current?.select(R)},onRefresh:()=>f.current?.refresh(),onOpen:R=>{Sl($e,R)},now:y,renderer:Mc,storage:localStorage,host:window,fit:p,tuner:t.tuner===!0}),b(kf,{model:Uh(t.cwd,e.selectedId,e.graph?.model.generatedAt??null)}),r==="search"?b(Xc,{graph:e.graph,onSelect:R=>{f.current?.select(R)},onClose:()=>i(null),ports:{fetch:$e}}):null,r==="help"?b(xf,{shortcut:ba(xa(t.platform)),onClose:()=>i(null)}):null]})}var Cf=`
398
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Qe(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Xd(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+Qe(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Xd(t);if(i===null)return Qe(n);t=i;let o=`<img src="${t}" alt="${Qe(n)}"`;return e&&(o+=` title="${Qe(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Qe(t.text)}},ha=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Ke=class ia{options;renderer;textRenderer;constructor(e){this.options=e||Pt,this.options.renderer=this.options.renderer||new ni,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ha}static parse(e,n){return new ia(n).parse(e)}static parseInline(e,n){return new ia(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},Gn=class{options;block;constructor(t){this.options=t||Pt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?We.lex:We.lexInline}provideParser(t=this.block){return t?Ke.parse:Ke.parseInline}},fa=class{defaults=oa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ke;Renderer=ni;TextRenderer=ha;Lexer=We;Tokenizer=ti;Hooks=Gn;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new ni(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new ti(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Gn;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,s=n.hooks[a],l=i[a];Gn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&Gn.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let c=s.call(i,u);return l.call(i,c)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,u);return h===!1&&(h=await l.apply(i,u)),h})();let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return We.lex(t,e??this.defaults)}parser(t,e){return Ke.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,s=await(i.hooks?await i.hooks.provideLexer(t):t?We.lex:We.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?Ke.parse:Ke.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?We.lex:We.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(t):t?Ke.parse:Ke.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
399
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Qe(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Dt=new fa;function j(t,e){return Dt.parse(t,e)}j.options=j.setOptions=function(t){return Dt.setOptions(t),j.defaults=Dt.defaults,eh(j.defaults),j};j.getDefaults=oa;j.defaults=Pt;function kb(...t){return Dt.use(...t),j.defaults=Dt.defaults,eh(j.defaults),j}j.use=kb;j.walkTokens=function(t,e){return Dt.walkTokens(t,e)};j.parseInline=Dt.parseInline;j.Parser=Ke;j.parser=Ke.parse;j.Renderer=ni;j.TextRenderer=ha;j.Lexer=We;j.lexer=We.lex;j.Tokenizer=ti;j.Hooks=Gn;j.parse=j;var lS=j.options,uS=j.setOptions,cS=j.walkTokens,dS=j.parseInline;var hS=Ke.parse,fS=We.lex;var dh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Eb=new RegExp(`[${Object.keys(dh).join("")}]`,"g");function Le(t){return t.replace(Eb,e=>dh[e])}var Sb=["http:","https:","mailto:"],hh=/^[a-z][a-z0-9+.-]*:/i,fh=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function ch(t){let e=t.replace(fh,""),n=hh.exec(e);return n===null?e===""?null:t:Sb.includes(n[0].toLowerCase())?t:null}var st="data-weave-target",ii="note:",Tb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function Ab(t){if(t.kind!=="note"||!t.id.startsWith(ii))return null;let e=t.id.slice(ii.length);return e===""?null:e}function ph(t){if(t.kind!=="file"||!t.id.startsWith("artifact:"))return null;let e=t.detail.path;return e!==void 0&&/\.html?$/i.test(e)?e:null}function gh(t){let e=ph(t);return e===null?null:`${e}:${t.detail.updated??""}`}function mh(t,e){if(t===null||e===null)return null;let n=t.model.nodes.find(r=>r.id===e);return n===void 0?null:ph(n)}function vh(t,e){if(t===null)return Tb;let n=new Map;for(let i of t.model.nodes){let o=Ab(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:e}}function yh(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function Rb(t,e){if(t.currentSlug===null||hh.test(e.replace(fh,"")))return null;try{let n=new URL(e,`https://weave.invalid/${t.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:yh(t,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function Cb(t){return t.hasGhosts}var Lb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Nb(t){let e=t.indexOf("[[");return e===-1?void 0:e}function Db(t){return{name:"wikilink",level:"inline",start:Nb,tokenizer(e){return Ib(e)},renderer(e){return Pb(t,e)}}}function Pb(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Gb(t,n,r)}function Ib(t){let e=Lb.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Gb(t,e,n){let r=Le((n===""?e:n).trim());if(r==="")return"";let i=yh(t,e);return i!==null?`<a class="weave-wiki" ${st}="${Le(i)}" role="link" tabindex="0" title="${Le(e.trim())}">${r}</a>`:Cb(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Le(e.trim())}">${r}</span>`:r}function Mb(t){return new fa({gfm:!0,async:!1,extensions:[Db(t)],renderer:{html({text:e}){return/^\s*<!--[\s\S]*?-->\s*$/.test(e)?"":Le(e)},link({href:e,title:n,tokens:r}){let i=ch(e),o=this.parser.parseInline(r),a=i===null?null:Rb(t,i);if(a!==null){let l=n==null||n===""?"":` title="${Le(n)}"`;return`<a class="weave-wiki" ${st}="${Le(a)}" role="link" tabindex="0"${l}>${o}</a>`}return`<a${[i===null?"":` href="${Le(i)}"`,n==null||n===""?"":` title="${Le(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=ch(e);if(i===null)return Le(r);let o=n==null||n===""?"":` title="${Le(n)}"`;return`<img src="${Le(i)}" alt="${Le(r)}"${o}>`}}})}function Fb(t,e){return Mb(e).parse(t,{async:!1})}function On(t){return Object.freeze(t)}var Ob=On({ALLOWED_TAGS:On(["p","br","hr","h1","h2","h3","h4","h5","h6","em","strong","del","code","pre","blockquote","ul","ol","li","a","span","img","table","thead","tbody","tr","th","td","input"]),ALLOWED_ATTR:On(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",st]),ADD_URI_SAFE_ATTR:On([st]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:On({html:!0})});function wh(t,e,n){return t.sanitize(Fb(e,n),Ob)}var bh=32;function pa(t){let e=t;for(let n=0;e!==null&&n<bh;n++){let r=e.getAttribute(st);if(r!==null&&r!=="")return`${ii}${r}`;e=e.parentElement}return null}function xh(t){if(!t||t.isCollapsed===!0)return!1;let e=t.toString;return(typeof e=="function"&&e!==Object.prototype.toString?e.call(t):"").length>0}var _h="edited",kh="created";function Eh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Rt(t.source),provenanceTitle:Xt(t.source),updated:En(t.updated,e),updatedIso:t.updated,created:En(t.created,e),createdIso:t.created,tags:t.tags}}function Sh(t){return`#${t}`}var zb=200,$b=8,Ub="no note",ga="weave-preview";function ma(t){let e=t;for(let n=0;e!==null&&n<bh;n++){let r=e.getAttribute(st);if(r!==null&&r!=="")return{slug:r,text:(e.textContent??"").trim()};if((e.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(e.textContent??"").trim()};e=e.parentElement}return null}function Hb(t){return t.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(e,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function Bb(t,e=zb){let n=Hb(t);if(n.length<=e)return n;let r=n.lastIndexOf(" ",e);return`${r>0?n.slice(0,r):n.slice(0,e)}…`}function Th(t,e){if(e.slug===null){let i=e.text===""?"this link":e.text;return{ghost:!0,title:i,kind:Ub,text:`no note named “${i}” yet`}}let n=t?.model.nodes.find(i=>i.id===`note:${e.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Xt(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Bb(n.detail.preview??"")}}function Ah(t,e,n,r,i,o,a=$b){let s=t+a,l=e+a;return s+n>i-a&&(s=t-a-n),l+r>o-a&&(l=e-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var oi={anchor:null,pointerX:0,pointerY:0};function Rh(t,e){switch(e.type){case"show":return e.anchor.slug===null&&e.anchor.text===""?t:{anchor:e.anchor,pointerX:e.x,pointerY:e.y};case"hide":return t.anchor===null?t:oi;case"dismiss":return oi}}function Ch(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(ii)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Wb="weave-preview-x",Kb="weave-preview-y";function Vb({view:t,open:e}){return b("header",{class:"weave-note-head",children:[b("h3",{class:"weave-note-title",children:t.title}),b("p",{class:"weave-note-meta",children:[b("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:e,children:b("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),b("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),b("span",{class:"weave-note-time",title:t.updatedIso,children:[_h," ",t.updated]}),b("span",{class:"weave-note-time",title:t.createdIso,children:[kh," ",t.created]})]}),b("p",{class:"weave-note-tags",children:t.tags.map(n=>b("span",{class:"weave-tag",children:Sh(n)},n))})]})}function Lh(t){let e=t.note?.note??null,n=mh(t.graph,t.selectedId),r=Ch(t.selectedId,e),i=Ze(()=>e===null?null:vh(t.graph,e.slug),[e,t.graph]),o=Ze(()=>e===null||i===null?"":wh(Vd,e.body,i),[e,i]),[a,s]=W(oi),l=f=>{s(g=>Rh(g,f))},u=Z(null),c=Z(null),h=a.anchor===null?null:Th(t.graph,a.anchor);if(kt(()=>{l({type:"hide"})},[e===null?null:e.slug]),kt(()=>{let f=u.current;if(f!==null){let v=a.anchor?.slug??null;for(let w of f.querySelectorAll(`a[${st}]`))v!==null&&w.getAttribute(st)===v?w.setAttribute("aria-describedby",ga):w.removeAttribute("aria-describedby")}let g=c.current;if(g===null||h===null)return;let m=Ah(a.pointerX,a.pointerY,g.offsetWidth,g.offsetHeight,window.innerWidth,window.innerHeight);g.style.setProperty(`--${Wb}`,`${m.x}px`),g.style.setProperty(`--${Kb}`,`${m.y}px`)},[a,h]),n!==null){let f=t.graph?.model.nodes.find(v=>v.id===t.selectedId),g=f?.label??n,m=f===void 0?n:gh(f)??n;return b("article",{class:"weave-note weave-note-artifact",children:[b("header",{class:"weave-note-head",children:[b("h3",{class:"weave-note-title",children:g}),b("p",{class:"weave-note-meta",children:b("span",{class:"weave-note-time",children:n})})]}),b("iframe",{class:"weave-artifact-frame",title:g,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(n)}`},m)]},m)}if(e===null||i===null)return b("p",{class:"weave-note-empty",children:r});let d=Eh(e,t.now);return b("article",{class:`weave-note weave-note-${d.provenance}`,children:[b(Vb,{view:d,open:()=>t.onOpen(e.slug)}),b("div",{ref:u,class:"weave-note-body",tabIndex:-1,onMouseOver:f=>{let g=ma(f.target);l(g!==null?{type:"show",anchor:g,x:f.clientX,y:f.clientY}:{type:"hide"})},onMouseLeave:()=>l({type:"hide"}),onFocus:f=>{let g=ma(f.target);if(g===null)return;let m=f.target.getBoundingClientRect?.();l({type:"show",anchor:g,x:m?.left??0,y:m?.bottom??0})},onBlur:()=>l({type:"hide"}),onClick:f=>{let g=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(xh(g))return;let m=pa(f.target);if(m!==null){t.onSelect(m);return}},onKeyDown:f=>{if(f.key==="Escape"&&a.anchor!==null){f.stopPropagation(),l({type:"dismiss"});return}if(f.key!=="Enter"&&f.key!==" ")return;let g=pa(f.target);g!==null&&(f.preventDefault(),t.onSelect(g))},dangerouslySetInnerHTML:{__html:o}}),h===null?null:b("div",{ref:c,id:ga,role:"tooltip",class:`weave-preview${h.ghost?" weave-preview-ghost":""}`,children:[b("span",{class:"weave-preview-kind",children:h.kind}),b("span",{class:"weave-preview-title",children:h.title}),h.text===""?null:b("p",{class:"weave-preview-text",children:h.text})]})]},e.slug)}var zn=["tree","note","graph"],va={tree:180,note:320,graph:260},Ph={tree:.22,note:.46,graph:.32},jb=1100,qb=800;function Ih(t){return!Number.isFinite(t)||t<qb?"narrow":t<jb?"medium":"wide"}function Nh(t){return t==="wide"?zn:t==="medium"?["tree","note"]:["note"]}function Gh(t,e,n){let r={tree:0,note:0,graph:0},i=0;for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:Ph[l],i+=r[l]}for(let l of t)r[l]/=i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function Mh(t,e){return Gh(zn,t,e)}function wa(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:va.tree/e,note:va.note/e,graph:va.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function Fh(t,e){return{fractions:Mh(t,wa(e))}}function Dh(t){return Fh(Ph,t)}function Oh(t,e,n){let r=Number.isFinite(e)&&e>0?e:0,i=Gh(Nh(n),t.fractions,wa(r));return Nh(n).map(o=>({id:o,width:i[o]*r}))}function Yb(t){return t==="tree"?["tree","note"]:["note","graph"]}function ba(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=Yb(e),s=wa(i),l=Math.max(-Math.max(0,t.fractions[o]-s[o]),Math.min(Math.max(0,t.fractions[a]-s[a]),n/i));return l===0?t:{fractions:Mh({...t.fractions,[o]:t.fractions[o]+l,[a]:t.fractions[a]-l},s)}}var zh="pi-weave.layout.v1",ya=t=>Math.round(t*1e4)/1e4;function Xb(t){return JSON.stringify({v:1,tree:ya(t.fractions.tree),note:ya(t.fractions.note),graph:ya(t.fractions.graph)})}function Zb(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={};for(let o of zn){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return Fh(i,e)}function $h(t,e){try{return Zb(t.getItem(zh),e)??Dh(e)}catch{return Dh(e)}}function Uh(t,e){try{return t.setItem(zh,Xb(e)),!0}catch{return!1}}var Qb={notes:0,repo:null,nodes:0},Jb=["note"];function Hh(t){if(t===null)return Qb;let e=t.model.nodes;return{notes:e.filter(n=>Jb.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function ex(t){return t===null||t==="missing"?"unindexed":t}function Bh(t){return[`vault:${t.notes}`,`repo:${ex(t.repo)}`,`${t.nodes} nodes`]}var tx={tree:{title:"Tree"},note:{title:"Note"},graph:{title:"Graph"}};function Wh(t){return tx[t]}var xa={title:"Context"},Kh="—";function Vh(t,e,n){return{cwd:t===""?Kh:t,selection:e??"nothing selected",stamp:n}}function jh(t){return t===null?Kh:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}var qh=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],Yh=6e4,Xh="Search…";function _a(t){return t?"⌘K":"Ctrl K"}function Zh(t){return`Search notes and repository (${t})`}function ka(t){return/mac|iphone|ipad/i.test(t)}var nx={k:{type:"openSearch"}},Qh={1:"tree",2:"note",3:"graph"},rx=new Set(["tree","graph"]);function ix(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function ox(t){return!t.ctrl&&!t.meta&&!t.alt}var ax={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function Jh(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(ix(t)){let n=nx[t.key.toLowerCase()];if(n!==void 0)return n;let r=Qh[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!ox(t)||t.typing?null:ax[t.key]??null}var sx=["INPUT","TEXTAREA","SELECT"];function Ea(t,e){return e?!0:t!==null&&sx.includes(t.toUpperCase())}function ef(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:Ea(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var lx={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},ux=".weave-col-tree .weave-filter";function cx(t){let e=t;return typeof e?.focus=="function"?e:null}function tf(t,e){let n=cx(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function nf(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(lx[t.column]);case"filterTree":return void e.focusSelector(ux);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"cycleTheme":return e.cycleTheme()}}function rf(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(Qh).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${rx.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var Sa="Keyboard shortcuts",of="esc close";var af={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function $n({name:t,class:e}){let n=af[t];return b("svg",{class:e,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>b("path",{d:r}))})}function hx({view:t,recentIds:e,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let u=Io(t.id);return b("li",{id:t.domId,"data-row-id":t.id,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${e.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:nc(t.depth),onClick:o,draggable:t.id.startsWith("note:"),"aria-label":t.id===Yt?"New folder":void 0,onDragStart:c=>c.dataTransfer?.setData("text/plain",t.id),onDragOver:u===void 0?void 0:c=>c.preventDefault(),onDrop:u===void 0?void 0:c=>{c.preventDefault(),l(c.dataTransfer?.getData("text/plain")??"")},onContextMenu:c=>{c.preventDefault(),c.stopPropagation(),s(c.clientX,c.clientY)},children:[b("span",{class:"weave-twisty","aria-hidden":"true",onClick:c=>{c.stopPropagation(),a()},children:t.hasKids?b($n,{name:"chevron",class:t.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),b("span",{class:"weave-kind","aria-hidden":"true",children:b($n,{name:t.kindIcon,class:"weave-icon"})}),b("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),n===null?b("span",{class:"weave-label",children:t.label}):b(fx,{value:n,draft:t.id===Yt,onEdit:r,onCommit:i}),b("span",{class:"weave-meta",children:t.meta})]})}function fx({value:t,draft:e,onEdit:n,onCommit:r}){let i=Z(null);return kt(()=>{let o=i.current;o!==null&&(o.focus(),o.select())},[]),b("input",{ref:i,class:"weave-tree-rename",value:t,placeholder:e?"New folder name…":void 0,onClick:o=>o.stopPropagation(),onInput:o=>n(o.currentTarget.value),onBlur:o=>r(o.currentTarget.value),onKeyDown:o=>{o.stopPropagation(),o.key==="Enter"?o.currentTarget.blur():o.key==="Escape"&&r(null)}})}function sf(t){let[e,n]=W(Hu),[r,i]=W(null),[o,a]=W(null),[s,l]=W(null),u=Vu(Bu(t.graph,e),s),c=cc(t.graph,u,e),h=async(m,v)=>{let w=await m;if(!w.ok)window.alert(w.message);else{let y=w.data.id??v;y!==void 0&&t.onSelect(y),t.onRefresh()}},d=async m=>{if(r===null)return;let v=Sn(r.id);if(i(null),v!==null)if(m==="newFolder"){let w=Wu(v);w!==""&&n(y=>Po(y,`vfolder:${w}`)),l(w),a({id:Yt,label:"",value:""})}else m==="rename"?a({id:r.id,label:r.label,value:r.label}):v.type!=="vault"&&await h(v.type==="note"?Ll($e,v.path):Pl($e,v.path),ju(t.selectedId,v)?"vault":void 0)},f=m=>{if(r!==null){if(Go(m)&&r.armed!==!0){i({...r,armed:!0});return}d("delete")}},g=m=>{let v=o,w=s;if(a(null),l(null),v===null)return;let y=m?.trim();if(v.id===Yt){let k=w===null||!y?null:Ku(w,y);k!==null&&h(Nl($e,k));return}let _=Sn(v.id);_!==null&&y&&y!==v.label&&h(_.type==="note"?Rl($e,_.path,y):Dl($e,_.path,y))};return b("div",{class:"weave-tree",onKeyDown:m=>{let v=m.target,w=Qu(u,e,t.selectedId,m.key,Ea(v?.tagName??null,v?.isContentEditable===!0));w.handled&&(m.preventDefault(),n(w.state),w.selectedId!==null&&t.onSelect(w.selectedId))},children:[b("div",{class:"weave-tree-controls",children:[b("input",{type:"search",class:"weave-filter",value:e.query,placeholder:ac,"aria-label":lc,title:uc,onInput:m=>n(Yu(e,m.currentTarget.value))}),b("button",{type:"button",class:"weave-chip",title:rc(e.provFilter),onClick:()=>n(Xu(e)),children:["◧ ",Or(e.provFilter)]}),b("button",{type:"button",class:"weave-chip",title:oc(e.showInternals),onClick:()=>n(Zu(e)),children:["◧ ",ic(e.showInternals)]})]}),c===null?b("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":sc,"aria-activedescendant":tc(u,t.selectedId)??void 0,onContextMenu:m=>{m.preventDefault(),i({id:"vault",label:"Vault",x:m.clientX,y:m.clientY})},children:ec(u,t.selectedId,t.now).map(m=>b(hx,{view:m,recentIds:t.recentIds,edit:o?.id===m.id?o.value:null,onEdit:v=>a(w=>w===null?null:{...w,value:v}),onRename:g,onSelect:()=>{t.onSelect(m.id),m.hasKids&&n(v=>Do(v,m.id))},onToggle:()=>n(Do(e,m.id)),onMenu:(v,w)=>i({id:m.id,label:m.label,x:v,y:w}),onDrop:v=>{let w=Io(m.id);v.startsWith("note:")&&w!==void 0&&h(Cl($e,v.slice(5),w))}},m.id))}):b("p",{class:"weave-tree-empty",children:c}),b("p",{class:"weave-tree-count",children:dc(u)}),r!==null&&Sn(r.id)!==null?(()=>{let m=Sn(r.id);return b(Oe,{children:[b("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:()=>i(null)}),b("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},children:[b("button",{type:"button",role:"menuitem",onClick:()=>{d("newFolder")},children:"New folder…"}),m.type!=="vault"?b(Oe,{children:[b("button",{type:"button",role:"menuitem",onClick:()=>{d("rename")},children:"Rename…"}),b("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>f(m),children:qu(m,r.label,r.armed===!0)})]}):null]})]})})():null]})}var Un={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function li(t,e,n){return{id:t,target:e.id,label:Ae(e),kind:e.kind,kindIcon:Mo(e.kind),provenance:e.provenance,provenanceGlyph:Rt(e.provenance),provenanceTitle:Xt(e.provenance),selected:e.id===n}}function px(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:li(t.id,i,n)}function gx(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var mx=["link:links-to:"];function vx(t){return mx.some(e=>t.id.startsWith(e))}function yx(t){return t.id.startsWith("link:mentions:")}function wx(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(li(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function bx(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(li(`mentioned-by:${o.source}`,a,r))}return i}function xx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var si={loading:"Loading…",noSelection:"Select anything to see what it connects to.",unknown:"This node is not in the current graph.",isolated:"Nothing links to or from this yet."};function Ta(t){return{subject:null,groups:[],tags:[],tagsCount:0,empty:t}}function lf(t,e){if(t===null)return Ta(si.loading);if(e===null)return Ta(si.noSelection);let n=At(t),r=Ro(n,e);if(r===null)return Ta(si.unknown);let i=gx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>px(d,i,e)).filter(d=>d!==null);a(Un.links,s(r.links.filter(vx)));let l=Co(n.edges).get(e)??[];a(Un.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>li(`backlink:${h.id}`,h,e))),a(Un.mentions,[...s(r.links.filter(yx)),...bx(n,e,i,e)]);let u=xx(e),c=u===null?[]:wx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:si.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function uf(){return{open:new Set,closed:new Set}}var _x=8;function cf(t,e,n,r){return r?!1:t.closed.has(e)?!0:t.open.has(e)?!1:n>_x}function kx(t){return t.some(e=>e.selected)}function df(t,e){let n=cf(e,t.heading,t.count,kx(t.rows));return{heading:t.heading,count:t.count,collapsed:n,rows:n?[]:t.rows}}function hf(t,e){let n=cf(e,Un.tags,t.length,t.some(r=>r.siblings.some(i=>i.selected)));return{heading:Un.tags,count:t.length,collapsed:n,rows:[]}}function ff(t,e,n){let r=new Set(t.open),i=new Set(t.closed);return n?(r.add(e),i.delete(e)):(i.add(e),r.delete(e)),{open:r,closed:i}}function ui(t){return`weave-ctx-panel-${t.toLowerCase()}`}function pf({row:t,onSelect:e}){return b("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:b("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[b("span",{class:"weave-kind","aria-hidden":"true",children:b($n,{name:t.kindIcon,class:"weave-icon"})}),b("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),b("span",{class:"weave-label",children:t.label})]})})}function gf({view:t,onToggle:e}){return b("h4",{class:"weave-ctx-head",children:b("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!t.collapsed,"aria-controls":ui(t.heading),onClick:e,children:[b("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:b($n,{name:"chevron",class:t.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),t.heading,b("span",{class:"weave-ctx-count",children:t.count})]})})}function Ex({view:t,onSelect:e,onToggle:n}){return b("section",{class:"weave-ctx-group",children:[b(gf,{view:t,onToggle:n}),b("ul",{class:"weave-ctx-rows",id:ui(t.heading),hidden:t.collapsed,children:t.rows.map(r=>b(pf,{row:r,onSelect:()=>e(r.target)},r.id))})]})}function Sx({tag:t,onSelect:e}){return b("li",{class:"weave-ctx-tag",children:[b("span",{class:"weave-tag",children:["#",t.tag]}),b("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>b(pf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function mf(t){let e=lf(t.graph,t.selectedId),[n,r]=W(uf),i=a=>()=>r(ff(n,a.heading,a.collapsed)),o=hf(e.tags,n);return b("div",{class:"weave-rail","aria-label":xa.title,children:[b("h2",{class:"weave-col-title",children:xa.title}),e.empty===null?null:b("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(a=>{let s=df(a,n);return b(Ex,{view:s,onSelect:t.onSelect,onToggle:i(s)},a.heading)}),e.tags.length===0?null:b("section",{class:"weave-ctx-group",children:[b(gf,{view:o,onToggle:i(o)}),b("ul",{class:"weave-ctx-tags",id:ui(o.heading),hidden:o.collapsed,children:e.tags.map(a=>b(Sx,{tag:a,onSelect:t.onSelect},a.tag))})]})]})}function vf(t){return b("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function Tx({id:t,props:e}){let n=Wh(t);return b("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[b("h2",{class:"weave-col-title",children:n.title}),t==="tree"?b(sf,{graph:e.graph,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:e.onSelect,onRefresh:e.onRefresh,now:e.now}):null,t==="note"?b(Lh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,onOpen:e.onOpen}):null,t==="graph"?b(Td,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit,tuner:e.tuner}):null,t==="graph"?b(mf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function yf(t){let e=Z(null);return kt(()=>{let n=e.current;if(n!==null)for(let{id:r,width:i}of t.resolved)n.style.setProperty(`--weave-col-${r}`,`${Math.round(i)}px`)},[t.resolved]),b("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:t.resolved.map((n,r)=>{let i=r<t.resolved.length-1&&n.id!=="graph"?n.id:null;return[b(Tx,{id:n.id,props:t},`${n.id}-column`),i===null?null:b(vf,{label:`Resize ${n.id} column`,onDown:o=>t.onDown(i,o),onMove:t.onMove,onUp:t.onUp,onKey:o=>t.onKey(i,o)},`${n.id}-divider`)]})})}function Ax(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function wf(t,e){let n=Ax(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function bf(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}function Rx(t,e,n){return{divider:t,origin:e,base:n}}function Cx(t,e,n){return ba(t.base,t.divider,e-t.origin,n)}function Lx(t,e){return zn.some(n=>t.base.fractions[n]!==e.fractions[n])}var xf=24;function Nx(t){return t==="ArrowLeft"?-xf:t==="ArrowRight"?xf:0}function _f(t){let e=null;return{onDown(n,r){e=Rx(n,r,t.layout())},onMove(n){e!==null&&t.setLayout(Cx(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Lx(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=ba(t.layout(),n,Nx(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var kf="image/png",Ef="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAALxElEQVRoBe1ZCXCU1R3/f+d+u5s9sleyOUlICBAMkQQQgpqBKqAoFQZFEYwWUAShjsco7dg4njRtPQcoXhSxWMGCimIYj1QqeICAcoQrd0iy2c1+u/vdZ9+m0xnFVCKw0+kMb+fb7/vevnnv//v/f//jvQVIYWtsbCn47uTJ3BQuAXgqJzdRM9CVyjVSCkACCUBIpfgAZCqnl5D8GJ5aBCm1ACALiGIqVZRqC7AIAGApRZBSCiUUBVN14/8YAJfAdN1MKU1TagEuwWEgp1T+1EYhRVUMhdNSmgdSagFeEHVJU/RUOkFKAThIWknLZNRUAkhFjKPSg2Muszocl/i8/mLT1M1IpO/rCBvaK/cePXGhwVxAANacYEHlkmEjymeguFNKUhShaToYhgG6rgJuAifL4oHjpxo3xdu/fAkBuSCWuSAAPNljLsvPH/lCusdfSVlIkFUFVCS0CQYkazkMuTGJEUAQJMrMEkTD3TvaWg/dJUab2s7XIsT5TkA6Cifl5434sCCvqEAS4sBzMdAVFdxYOjgxF6ShD6VTkBCjoEkiEKYBAX9WsaGT0yKh8DsAYvx8ZDhPADnW4SXlr+XnDh0WY3tBlgQwDQ10UQe/NQgOygkexoe4E4WE0AdgIkohWskiD440t9/EKX+cbd36PwNgd+ffMyR/2GJZjoOmySAryfITAxNHQkoyiLLYT6U2thHRB0djNPSuAY4lnyVQVLlMEMm9utp3zs59XmnSmeaelmZzgq7KkIjHgY3FQFOUfs4HHYUgawLQuAVspgdZRgcFAWRZFlRFRmMMtJvCMIKiZpyPBX5WHnA4hvkom/N6VVc+T4S/bXU4XCUCokZSaJokUd3JIDBqP4CuWDMIegRaIhIQyIFV1A+GCXbG2n/XVR2NN4AkiYokAE+g4mqapsrZRHSzFDvWPFhQPweAy+HxfZQdLBgtSVxPs8I/gdji1ZA2RVEAl98D106fAjzPw57P9gAb7QQLZQHVjIOAAKYHAjCheiLgyOY7360HmZdQiNWSlilM95c9npeT9yBJMxS0Q013DMYiAPxgQAzaiTOyxt/rcqXPa2tvApLA0zCcmsrQFIVhBmaxW+DJVQ/BroZdEOrugoUL58LB/Y0gCRLKAQZk5GTA0uXz4Z2t28Fuo+GeZTWwc+enIAhC8nerlbFeoagScbqrA3wejx8j3L0C3/XFYAAMygfs9pIyl9O1MhYNQzzGrgj1hrZKsoYbhorzXByurL4Mwt2nYcNL68DvcUKWzwlFQ7OQU8ugagoMLciEHL8Lcd6Etc+sAcxQYEzFJSAl95zID+KcBD294Q2JRGI5G2fB5fI8YnGUlAwGwGAohNMMU4cWc/Sx7KuG2vI8x8Jawjpso81mmZNmRTRBcV9B/PbmFcNL6zfD9voGmFRZDiamIfEwiERZmHbDIojHBQgOLQBJ1UBE1jGQdRTN0AVBXGfIJ+9FAstRlqqgKOttDEU/JQPMRn0/Wc2elUIMkzGEsTlXJXi+XUzEb3K48m7Jy7/0EcOQFUXRhtusNN7dE4aJl08EX4YXWFGFkqJC6Go/jaKO0p+JNeSweYUFkOb3wby5M5AlLPD2W+8ix1ZAkuWEw2FrzM4tu0/RGUaMs8+aOH4NTuIVkkmvBzWe+ClLDFhK+EpmVyL1lbsN/vWOrhM3khbrBo7nZjot+JFA5tBGTdcJUeIhnuDAjixgtzKQGcyCEWWjkBNz0Hz8GIR6QuByu4GiCYhGYuAPeKFg2HCw0BQc2PsN9PR0I+2bIKJ84XQ60BwOFJFIs635cLEO5FCLzb5D4rnZdXJz/ZHPDyxDfNz38pTxn5wJ5kcWmANziGYf9iFGuhbqBN7Js20WXZY/MOSWjZnZZS/abday1o6WQ5KsHHc60rOCmQGcZaMgoeza2dIKXW0toMgyijYYTKwaC5mZGdDe2g4CL0BHczN0oOcYyhcySmrZwWyQUaWXiLEf83w84fP6gjhppWN9B59XJThlc1C23KorJkEw94+KwE+4IT+4tqGh4Qeb7IEsgPmLZ69EaX4egSmfUTR2imacR+OhZi7T5XqPZXvtPT1dNarUvKmoZFqb00ZmtnR2ogJOA4eVAgrlA5Ig+rmvo7LBRB+CJPqppOs6SMixeVRqoAgGOUE/RFi+tbNt9xAgcmbl5Q3ZYrenR4pmVNxUfvVUXzwSzVVwwq243NNNTd/46rSJz53pEwNFIbP3xNtP2OhEFYqRR2UdX6OqYjdtd47ri/bSmirL/iFF3ZfPucfNxkInBIEDK00jpcu7E6KcYHmUlUUZBFlFOcAE3cRAkDTgBBlinAhokxZFkekf6e505AIqJBJsY119faD6uqmGpkiapPE2f0awCJXeB8W+wPOuuNzl23tgChL+2TOFT9JpIADJfmj77v0oup2wEDCpff+bewvGD98IFBWxEDiDwsf9hM8/05WT2xxLJEyaJmm7le7ho9FxkswvS/Dc/dFY/LlonNvSF49vY+Pc6hifWIpC8Dw+dqrS7XIj7zaocJQ1Kqdc0YZJ9PRwT2QJCrOU2+8Jjysd/envp08+FtBbr8RVaF710J2xfqEG+PqRD3x/THG+rUU0PLPtROE39uyMcWxXVycKLZM5Nmoc++dbS1csvnnrRx/vxVE9M8GTkV3qyw6Ee1u/qtOVyB50fajJvZs1Ofw3XQl/sF2OfDtz6W29TYfaF1hp+0IBhdFYLPrI8f31D+x88y+H4qz2G4vV6qXtrqdLKyrJ2b+YcJITbTNDVGjTvu3bf8D778s4kA98/3fIKps1BjOpsa5AuuXIod2vOBStHsXpqr6+SHX1pJrPWaqlINTW8QeU1aZnlZdR+eUlvyU0vY1kLCRptZiMg0F1EkHjBBgUQVQ27W+8dt+2nXYbSW5cNOf2Y8hDTr++7a9MU1vTG2Coh2PRo1WPPrZ1kSpKhkbInz39WM2+Hwh0xstZE5nOmx2YlamPhGWtIOeSxlioqV6K81W+YPbdLN1ZihEWLm/kqId0XT7sLyzo0riEDyfpRlRRNxk4jRJcQiEMtLtXyOt0IHYXlA45Xgiz4tmZubvwU60tkjdQ6khzLZIVExsz8tK9117+6Aw9xDxoIWweTQmNOEPeH72eFYCVIXHJNATAqBzd0Ce7fJmbuGhjKaIRf2Bn9lqAWqNi8WIqXUhvf3/VijXXPFCbyTC2+QppYSinN6wIHI2Z2DTM1Hc4KAPFePygE7PLoUhk7JMvLD+GJPoGyLxWmmb+XpI36kFRkGehAtxiqFo3SgtnPZL5r078H6gthzd345g6iTbk0ThmNuMYE1S4ozWSzNYlhU+Oo7stowRePJ18/qCutnvT75bVaR5fjeTyf6va019WJellKsxyAqcH/jR/7sHTEaVN541MtF/+N4UJc7MiHJ8f8GVUaqZqSlhstAnRisdfXHDWsvqsFkgKdfrQm+3olrwOF1feOLdk4q23B4cVvdawvhZ1AaBN1nBTV79MPpfOqaXdQmQ838OC1euTUbncjHP4nSoeWGF09d2VHLNu3Z3C8kWruTvueMqHXntfe3hD56HOYzWKIsefeWUJOrFIHgMMrp3ViQeapqRqbiVOWyfjJLlTZZwdjMrfAgb/itXmrqJJy0gMx47rUmSXf/pV3m1Lbm655f4X51oY5zgqLh7Red5u8PoXhElngsnkY5i4h6TwaswkGla/sfTrgdb7qb5zApCcsKTqDlTAkLertPNhAsMkq5pYzxDYJ1+9v2bX9xe8fuHKDJr2/nLL6vv+nOxfsOBJryli1zFGcKWN8hbzemiLyLX/6o0dted0OnHOAJLClFy1LEvBiMMYQSgMSHUUgUcoEpOApFmaolkGw3UrYbuR0I3dhKoLlEGmo2LDhTb4HGV4J1Fgv17RYr9+ddvit5LznUs7LwDJBUurby1C1aPW2LC+pbT67jTKTfssFOFFB1lOdJSF6lSKoHCStSgGj0qkMNrDhN97r7b/j7M5U2s9m+tr0XnLxXZRAxc1cFEDFzVwUQPnpoF/AbqLsVZFbswxAAAAAElFTkSuQmCC";function Dx({onRefresh:t}){let[e,n]=W(!1);return b("button",{type:"button",class:"weave-refresh",onClick:()=>{t(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":e?"true":void 0,children:b("svg",{class:e?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:qh.map(r=>b("path",{d:r},r))})})}function Sf(t){return b("header",{class:"weave-header",children:[b("span",{class:"weave-brand",children:[b("img",{class:"weave-brand-mark",src:`data:${kf};base64,${Ef}`,alt:"",width:18,height:18}),"pi-weave"]}),b("button",{type:"button",class:"weave-search",title:Zh(t.shortcut),onClick:t.onSearch,children:[b("span",{class:"weave-search-text",children:Xh}),b("kbd",{children:t.shortcut})]}),b("span",{class:"weave-summary",children:Bh(t.summary).map(e=>b("span",{class:"weave-summary-part",children:e},e))}),b("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),b(Dx,{onRefresh:t.onRefresh})]})}function Px({group:t}){return b("div",{children:[b("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>b("div",{class:"weave-key-row",children:[b("kbd",{class:"weave-key-combo",children:e.combo}),b("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function Tf(t){let e=qr(),n=t.shortcut.slice(0,-1);return b("div",{class:"weave-scrim",onClick:t.onClose,children:b("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Sa,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[b("h2",{class:"weave-help-title",children:Sa}),b("div",{class:"weave-keys",children:rf(n).map(r=>b(Px,{group:r},r.title))}),b("p",{class:"weave-help-foot",children:[b("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),b("span",{class:"weave-help-hint",children:of})]})]})})}function Af(t,e){let n=r=>{let i=Jh(ef(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function Rf({model:t}){return b("footer",{class:"weave-status",children:[b("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),b("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),b("span",{class:"weave-status-stamp",title:"data as of",children:jh(t.stamp)})]})}var Aa=["system","light","dark"],Cf="pi-weave.theme.v1";function Ix(t){return t==="system"||t==="light"||t==="dark"}function ci(t){try{let e=t.getItem(Cf);return Ix(e)?e:null}catch{return null}}function Lf(t,e){try{return t.setItem(Cf,e),!0}catch{return!1}}function di(t){let e=Aa.indexOf(t);return Aa[(e+1)%Aa.length]??"system"}function Nf(t,e){return t==="system"?e:t}function hi(t){return t==="system"?null:t}var Gx={dark:"●",system:"◐",light:"○"};function Df(t){return{glyph:Gx[t],hint:`Colour theme: ${t} — click for ${di(t)}`}}function Mx(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function Pf(t){let[e,n]=W(id),[r,i]=W(null),[o,a]=W(t.initialWidth),[s,l]=W(()=>$h(localStorage,t.initialWidth)),[u,c]=W(()=>ci(localStorage)??"system"),[h,d]=W(()=>xr(window)),f=Z(null),g=Z(null),m=Z({overlay:r,selectedId:e.selectedId,layout:s,width:o});m.current={overlay:r,selectedId:e.selectedId,layout:s,width:o},oe(()=>{let S=sd({fetch:$e,state:e,setState:n});return f.current=S,()=>S.stop()},[]),oe(()=>{let S=()=>a(window.innerWidth);return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);let v=Z(!1),w=Z(location.hash);oe(()=>{v.current&&(nd(localStorage,e.selectedId),history.replaceState(null,"",bf(e.selectedId)))},[e.selectedId]),oe(()=>{if(v.current||e.graph===null||(v.current=!0,e.selectedId!==null))return;let S=wf(w.current,e.graph);if(S!==null)f.current?.select(S);else{let L=rd(e.graph,localStorage);L!==null&&f.current?.select(L)}},[e.graph]);let[y,_]=W(()=>Date.now());oe(()=>{let S=setInterval(()=>_(Date.now()),Yh);return()=>clearInterval(S)},[]),oe(()=>Mx(hi(u)),[u]),oe(()=>{Lf(localStorage,u)},[u]),oe(()=>Gl(window,d),[]),oe(()=>Af(document,{context:()=>({overlay:m.current.overlay,hasSelection:m.current.selectedId!==null}),run:S=>nf(S,{setOverlay:i,focusSelector:L=>tf(document,L),fitGraph:()=>g.current?.(),clearSelection:()=>{f.current?.select(null)},cycleTheme:()=>c(L=>di(L))})}),[]);let k=Ze(()=>Oh(s,o,Ih(o)),[s,o]),A=Ze(()=>_f({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:l,persist:S=>{Uh(localStorage,S)}}),[]);return b(Oe,{children:[b(Sf,{summary:Hh(e.graph),shortcut:_a(ka(t.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:Df(u),onTheme:()=>c(S=>di(S))}),b(yf,{resolved:k,onDown:A.onDown,onMove:A.onMove,onUp:A.onUp,onKey:A.onKey,scheme:Nf(u,h),bootFailed:e.graphFailed,graph:e.graph,note:e.note,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:S=>{f.current?.select(S)},onRefresh:()=>f.current?.refresh(),onOpen:S=>{Al($e,S)},now:y,renderer:$c,storage:localStorage,host:window,fit:g,tuner:t.tuner===!0}),b(Rf,{model:Vh(t.cwd,e.selectedId,e.graph?.model.generatedAt??null)}),r==="search"?b(ed,{graph:e.graph,onSelect:S=>{f.current?.select(S)},onClose:()=>i(null),ports:{fetch:$e}}):null,r==="help"?b(Tf,{shortcut:_a(ka(t.platform)),onClose:()=>i(null)}):null]})}var If=`
400
400
  --weave-bg:#eff1f5;--weave-panel:#e6e9ef;--weave-raise:#ccd0da;--weave-fg:#4c4f69;--weave-dim:#56586a;
401
401
  --weave-faint:#606274;--weave-line:#ccd0da;--weave-line-strong:#bcc0cc;
402
402
  --weave-accent:#7113ec;--weave-ok:#28641b;--weave-warn:#7c4f10;--weave-bad:#b20d30;
403
403
  --weave-new:rgba(113,19,236,.10);
404
404
  --weave-page:#dce0e8;
405
- `,Rx=`
405
+ `,Fx=`
406
406
  :root{
407
407
  --weave-bg:#24273a;--weave-panel:#1e2030;--weave-raise:#363a4f;--weave-fg:#cad3f5;--weave-dim:#a5adcb;
408
408
  --weave-faint:#939ab7;--weave-line:#363a4f;--weave-line-strong:#494d64;
@@ -464,11 +464,11 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
464
464
  without a manual "dark" being dragged back into light by the OS. */
465
465
  @media (prefers-color-scheme: light){
466
466
  :root:not([data-weave-theme="dark"]){
467
- ${Cf}
467
+ ${If}
468
468
  }
469
469
  }
470
470
  :root[data-weave-theme="light"]{
471
- ${Cf}
471
+ ${If}
472
472
  }
473
473
  body{font-size:var(--weave-px-base)}
474
474
  #app{height:100%;display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
@@ -1023,7 +1023,7 @@ body{font-size:var(--weave-px-base)}
1023
1023
  @keyframes weave-fade-in{from{opacity:0}}
1024
1024
  @keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
1025
1025
  @media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
1026
- `,Cx=["style[nonce]","style","script[nonce]","script[src]"];function Lx(t){for(let e of Cx){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function Lf(t,e=Rx){let n=t.createElement("style"),r=Lx(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var Nf=document.getElementById("app");if(Nf!==null){Lf(document),Nx();let t=bs(document.getElementById(ws)?.textContent??null);ys(b(Rf,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform,tuner:el(window.location.search)}),Nf)}function Nx(){let t=ci(li(localStorage)??"system");t!==null&&(document.documentElement.dataset.weaveTheme=t)}})();
1026
+ `,Ox=["style[nonce]","style","script[nonce]","script[src]"];function zx(t){for(let e of Ox){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function Gf(t,e=Fx){let n=t.createElement("style"),r=zx(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var Mf=document.getElementById("app");if(Mf!==null){Gf(document),$x();let t=_s(document.getElementById(xs)?.textContent??null);bs(b(Pf,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform,tuner:nl(window.location.search)}),Mf)}function $x(){let t=hi(ci(localStorage)??"system");t!==null&&(document.documentElement.dataset.weaveTheme=t)}})();
1027
1027
  /*! Bundled license information:
1028
1028
 
1029
1029
  dompurify/dist/purify.es.mjs: