pi-weave 0.3.1 → 0.3.2

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,11 @@
18
18
  * sigma@3.0.3 — MIT
19
19
  */
20
20
 
21
- "use strict";(()=>{var Af=Object.create;var Fs=Object.defineProperty;var Cf=Object.getOwnPropertyDescriptor;var Lf=Object.getOwnPropertyNames;var Nf=Object.getPrototypeOf,Pf=Object.prototype.hasOwnProperty;var $s=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Df=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lf(t))!Pf.call(e,i)&&i!==n&&Fs(e,i,{get:()=>t[i],enumerable:!(r=Cf(t,i))||r.enumerable});return e};var $n=(e,t,n)=>(n=e!=null?Af(Nf(e)):{},Df(t||!e||!e.__esModule?Fs(n,"default",{value:e,enumerable:!0}):n,e));var di=$s((z0,La)=>{"use strict";var _n=typeof Reflect=="object"?Reflect:null,md=_n&&typeof _n.apply=="function"?_n.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},ui;_n&&typeof _n.ownKeys=="function"?ui=_n.ownKeys:Object.getOwnPropertySymbols?ui=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ui=function(t){return Object.getOwnPropertyNames(t)};function Av(e){console&&console.warn&&console.warn(e)}var yd=Number.isNaN||function(t){return t!==t};function te(){te.init.call(this)}La.exports=te;La.exports.once=Pv;te.EventEmitter=te;te.prototype._events=void 0;te.prototype._eventsCount=0;te.prototype._maxListeners=void 0;var vd=10;function ci(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(te,"defaultMaxListeners",{enumerable:!0,get:function(){return vd},set:function(e){if(typeof e!="number"||e<0||yd(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");vd=e}});te.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};te.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||yd(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function wd(e){return e._maxListeners===void 0?te.defaultMaxListeners:e._maxListeners}te.prototype.getMaxListeners=function(){return wd(this)};te.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="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[t];if(l===void 0)return!1;if(typeof l=="function")md(l,this,n);else for(var u=l.length,c=Ed(l,u),r=0;r<u;++r)md(c[r],this,n);return!0};function bd(e,t,n,r){var i,o,a;if(ci(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=wd(e),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=a.length,Av(s)}return e}te.prototype.addListener=function(t,n){return bd(this,t,n,!1)};te.prototype.on=te.prototype.addListener;te.prototype.prependListener=function(t,n){return bd(this,t,n,!0)};function Cv(){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 xd(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Cv.bind(r);return i.listener=n,r.wrapFn=i,i}te.prototype.once=function(t,n){return ci(n),this.on(t,xd(this,t,n)),this};te.prototype.prependOnceListener=function(t,n){return ci(n),this.prependListener(t,xd(this,t,n)),this};te.prototype.removeListener=function(t,n){var r,i,o,a,s;if(ci(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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():Lv(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};te.prototype.off=te.prototype.removeListener;te.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),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[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function kd(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Nv(i):Ed(i,i.length)}te.prototype.listeners=function(t){return kd(this,t,!0)};te.prototype.rawListeners=function(t){return kd(this,t,!1)};te.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):_d.call(e,t)};te.prototype.listenerCount=_d;function _d(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}te.prototype.eventNames=function(){return this._eventsCount>0?ui(this._events):[]};function Ed(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Lv(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Nv(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Pv(e,t){return new Promise(function(n,r){function i(a){e.removeListener(t,o),r(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}Sd(e,t,o,{once:!0}),t!=="error"&&Dv(e,i,{once:!0})})}function Dv(e,t,n){typeof e.on=="function"&&Sd(e,"error",t,n)}function Sd(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Na=$s((U0,Rd)=>{"use strict";Rd.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Ir,ee,Bs,If,Nt,zs,Ks,Vs,lo,Ar,zn,js,ho,uo,co,Mf,Nr={},Pr=[],Gf=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Mr=Array.isArray;function vt(e,t){for(var n in t)e[n]=t[n];return e}function po(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Of(e,t,n){var r,i,o,a={};for(o in t)o=="key"?r=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Ir.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Cr(e,a,r,i,null)}function Cr(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Bs,__i:-1,__u:0};return i==null&&ee.vnode!=null&&ee.vnode(o),o}function De(e){return e.children}function Lr(e,t){this.props=e,this.context=t}function Wt(e,t){if(t==null)return e.__?Wt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Wt(e):null}function Ff(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=vt({},t);o.__v=t.__v+1,ee.vnode&&ee.vnode(o),fo(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Wt(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,Qs(r,o,i),t.__e=t.__=null,o.__e!=n&&qs(o)}}function qs(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),qs(e)}function Ws(e){(!e.__d&&(e.__d=!0)&&Nt.push(e)&&!Dr.__r++||zs!=ee.debounceRendering)&&((zs=ee.debounceRendering)||Ks)(Dr)}function Dr(){try{for(var e,t=1;Nt.length;)Nt.length>t&&Nt.sort(Vs),e=Nt.shift(),t=Nt.length,Ff(e)}finally{Nt.length=Dr.__r=0}}function Ys(e,t,n,r,i,o,a,s,l,u,c){var h,d,p,m,w,v,b=r&&r.__k||Pr,y=t.length;for(l=$f(n,t,b,l,y),h=0;h<y;h++)(p=n.__k[h])!=null&&(d=p.__i!=-1&&b[p.__i]||Nr,p.__i=h,v=fo(e,p,d,i,o,a,s,l,u,c),m=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&go(d.ref,null,p),c.push(p.ref,p.__c||m,p)),w==null&&m!=null&&(w=m),4&p.__u?(l=Xs(p,l,e),d.__e&&(d.__e=null)):typeof p.type=="function"&&v!==void 0?l=v:m&&(l=m.nextSibling),p.__u&=-7);return n.__e=w,l}function $f(e,t,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[o]=Cr(null,a,null,null,null):Mr(a)?a=e.__k[o]=Cr(De,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=Cr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,l=o+d,a.__=e,a.__b=e.__b+1,s=null,(u=a.__i=zf(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))):e.__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)),el(s,s));return r}function Xs(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Xs(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Wt(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function zf(e,t,n,r){var i,o,a,s=e.key,l=e.type,u=t[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<t.length;)if((u=t[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Hs(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Gf.test(t)?n:n+"px"}function Rr(e,t,n,r,i){var o,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Hs(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Hs(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(js,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[zn]=r[zn]:(n[zn]=ho,e.addEventListener(t,o?co:uo,o)):e.removeEventListener(t,o?co:uo,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Us(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Ar]==null)t[Ar]=ho++;else if(t[Ar]<n[zn])return;return n(ee.event?ee.event(t):t)}}}function fo(e,t,n,r,i,o,a,s,l,u){var c,h,d,p,m,w,v,b,y,x,k,N,A,P,F,T,C=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=t.__e=n.__e]),(c=ee.__b)&&c(t);e:if(typeof C=="function"){h=a.length;try{if(y=t.props,x=C.prototype&&C.prototype.render,k=(c=C.contextType)&&r[c.__c],N=c?k?k.props.value:c.__:r,n.__c?b=(d=t.__c=n.__c).__=d.__E:(x?t.__c=d=new C(y,N):(t.__c=d=new Lr(y,N),d.constructor=C,d.render=Hf),k&&k.sub(d),d.state||(d.state={}),d.__n=r,p=d.__d=!0,d.__h=[],d._sb=[]),x&&d.__s==null&&(d.__s=d.state),x&&C.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=vt({},d.__s)),vt(d.__s,C.getDerivedStateFromProps(y,d.__s))),m=d.props,w=d.state,d.__v=t,p)x&&C.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),x&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(x&&C.getDerivedStateFromProps==null&&y!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(y,N),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(y,d.__s,N)===!1){t.__v!=n.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(W){W&&(W.__=t)}),Pr.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),x&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,w,v)})}if(d.context=N,d.props=y,d.__P=e,d.__e=!1,A=ee.__r,P=0,x)d.state=d.__s,d.__d=!1,A&&A(t),c=d.render(d.props,d.state,d.context),Pr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,A&&A(t),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=vt(vt({},r),d.getChildContext())),x&&!p&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(m,w)),F=c!=null&&c.type===De&&c.key==null?Js(c.props.children):c,s=Ys(e,Mr(F)?F:[F],t,n,r,i,o,a,s,l,u),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),b&&(d.__E=d.__=null)}catch(W){if(a.length=h,t.__v=null,l||o!=null){if(W.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),t.__e=s}else if(o!=null)for(T=o.length;T--;)po(o[T])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),W.then||Zs(t),ee.__e(W,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Wf(n.__e,t,n,r,i,o,a,l,u);return(c=ee.diffed)&&c(t),128&t.__u?void 0:s}function Zs(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Zs))}function Qs(e,t,n){for(var r=0;r<n.length;r++)go(n[r],n[++r],n[++r]);ee.__c&&ee.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){ee.__e(o,i.__v)}})}function Js(e){return typeof e!="object"||e==null||e.__b>0?e:Mr(e)?e.map(Js):e.constructor!==void 0?null:vt({},e)}function Wf(e,t,n,r,i,o,a,s,l){var u,c,h,d,p,m,w,v=n.props||Nr,b=t.props,y=t.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((p=o[u])&&"setAttribute"in p==!!y&&(y?p.localName==y:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(y==null)return document.createTextNode(b);e=document.createElementNS(i,y,b.is&&b),s&&(ee.__m&&ee.__m(t,o),s=!1),o=null}if(y==null)v===b||s&&e.data==b||(e.data=b);else{if(o=y=="textarea"&&b.defaultValue!=null?null:o&&Ir.call(e.childNodes),!s&&o!=null)for(v={},u=0;u<e.attributes.length;u++)v[(p=e.attributes[u]).name]=p.value;for(u in v)p=v[u],u=="dangerouslySetInnerHTML"?h=p:u=="children"||u in b||u=="value"&&"defaultValue"in b||u=="checked"&&"defaultChecked"in b||Rr(e,u,null,p,i);for(u in b)p=b[u],u=="children"?d=p:u=="dangerouslySetInnerHTML"?c=p:u=="value"?m=p:u=="checked"?w=p:s&&typeof p!="function"||v[u]===p||Rr(e,u,p,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(h&&(e.innerHTML=""),Ys(t.type=="template"?e.content:e,Mr(d)?d:[d],t,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--;)po(o[u]);s&&y!="textarea"||(u="value",y=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[u]||y=="progress"&&!m||y=="option"&&m!=v[u])&&Rr(e,u,m,v[u],i),u="checked",w!=null&&w!=e[u]&&Rr(e,u,w,v[u],i))}return e}function go(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){ee.__e(i,n)}}function el(e,t,n){var r,i;if(ee.unmount&&ee.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||go(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){ee.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&el(r[i],t,n||typeof e.type!="function");n||po(e.__e),e.__c=e.__=e.__e=void 0}function Hf(e,t,n){return this.constructor(e,n)}function tl(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),ee.__&&ee.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,o=[],a=[],fo(t,e=(!r&&n||t).__k=Of(De,null,[e]),i||Nr,Nr,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Ir.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),Qs(o,e,a),e.props.children=null}Ir=Pr.slice,ee={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Bs=0,If=function(e){return e!=null&&e.constructor===void 0},Lr.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=vt({},this.state),typeof e=="function"&&(e=e(vt({},n),this.props)),e&&vt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Ws(this))},Lr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ws(this))},Lr.prototype.render=De,Nt=[],Ks=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Vs=function(e,t){return e.__v.__b-t.__v.__b},Dr.__r=0,lo=Math.random().toString(8),Ar="__d"+lo,zn="__a"+lo,js=/(PointerCapture)$|Capture$/i,ho=0,uo=Us(!1),co=Us(!0),Mf=0;var nl="weave-bootstrap";var mo={cwd:""};function Uf(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function rl(e){if(e===null||e.trim()==="")return mo;let t;try{t=JSON.parse(e)}catch{return mo}return Uf(t)?t:mo}function il(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return ol(this.cover(t,n),t,n,e)}function ol(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,a={data:r},s=e._x0,l=e._y0,u=e._x1,c=e._y1,h,d,p,m,w,v,b,y;if(!o)return e._root=a,e;for(;o.length;)if((w=t>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[b=v<<1|w]))return i[b]=a,e;if(p=+e._x.call(null,o.data),m=+e._y.call(null,o.data),t===p&&n===m)return a.next=o,i?i[b]=a:e._root=a,e;do i=i?i[b]=new Array(4):e._root=new Array(4),(w=t>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((b=v<<1|w)===(y=(m>=d)<<1|p>=h));return i[y]=o,i[b]=a,e}function al(e){var t,n,r=e.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,t=e[n]))||isNaN(o=+this._y.call(null,t))||(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)ol(this,a[n],s[n],e[n]);return this}function sl(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,o=(r=Math.floor(t))+1;else{for(var a=i-n||1,s=this._root,l,u;n>e||e>=i||r>t||t>=o;)switch(u=(t<r)<<1|e<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 ll(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function ul(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function xe(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function cl(e,t,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],p=this._root,m,w;for(p&&d.push(new xe(p,i,o,c,h)),n==null?n=1/0:(i=e-n,o=t-n,c=e+n,h=t+n,n*=n);m=d.pop();)if(!(!(p=m.node)||(a=m.x0)>c||(s=m.y0)>h||(l=m.x1)<i||(u=m.y1)<o))if(p.length){var v=(a+l)/2,b=(s+u)/2;d.push(new xe(p[3],v,b,l,u),new xe(p[2],a,b,v,u),new xe(p[1],v,s,l,b),new xe(p[0],a,s,v,b)),(w=(t>=b)<<1|e>=v)&&(m=d[d.length-1],d[d.length-1]=d[d.length-1-w],d[d.length-1-w]=m)}else{var y=e-+this._x.call(null,p.data),x=t-+this._y.call(null,p.data),k=y*y+x*x;if(k<n){var N=Math.sqrt(n=k);i=e-N,o=t-N,c=e+N,h=t+N,r=p.data}}return r}function dl(e){if(isNaN(c=+this._x.call(null,e))||isNaN(h=+this._y.call(null,e)))return this;var t,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,p,m,w,v,b;if(!n)return this;if(n.length)for(;;){if((m=c>=(d=(a+l)/2))?a=d:l=d,(w=h>=(p=(s+u)/2))?s=p:u=p,t=n,!(n=n[v=w<<1|m]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,b=v)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[v]=o:delete t[v],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[b]=n:this._root=n),this):(this._root=o,this)}function hl(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function pl(){return this._root}function fl(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function gl(e){var t=[],n,r=this._root,i,o,a,s,l;for(r&&t.push(new xe(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(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])&&t.push(new xe(i,u,c,s,l)),(i=r[2])&&t.push(new xe(i,o,c,u,l)),(i=r[1])&&t.push(new xe(i,u,a,s,c)),(i=r[0])&&t.push(new xe(i,o,a,u,c))}return this}function ml(e){var t=[],n=[],r;for(this._root&&t.push(new xe(this._root,this._x0,this._y0,this._x1,this._y1));r=t.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])&&t.push(new xe(o,a,s,c,h)),(o=i[1])&&t.push(new xe(o,c,s,l,h)),(o=i[2])&&t.push(new xe(o,a,h,c,u)),(o=i[3])&&t.push(new xe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function vl(e){return e[0]}function yl(e){return arguments.length?(this._x=e,this):this._x}function wl(e){return e[1]}function bl(e){return arguments.length?(this._y=e,this):this._y}function Ht(e,t,n){var r=new vo(t??vl,n??wl,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function vo(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function xl(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ie=Ht.prototype=vo.prototype;Ie.copy=function(){var e=new vo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=xl(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=new Array(4)}):t.target[i]=xl(r));return e};Ie.add=il;Ie.addAll=al;Ie.cover=sl;Ie.data=ll;Ie.extent=ul;Ie.find=cl;Ie.remove=dl;Ie.removeAll=hl;Ie.root=pl;Ie.size=fl;Ie.visit=gl;Ie.visitAfter=ml;Ie.x=yl;Ie.y=bl;function fe(e){return function(){return e}}function it(e){return(e()-.5)*1e-6}function Bf(e){return e.x+e.vx}function Kf(e){return e.y+e.vy}function yo(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=fe(e==null?1:+e));function a(){for(var u,c=t.length,h,d,p,m,w,v,b=0;b<o;++b)for(h=Ht(t,Bf,Kf).visitAfter(s),u=0;u<c;++u)d=t[u],w=n[d.index],v=w*w,p=d.x+d.vx,m=d.y+d.vy,h.visit(y);function y(x,k,N,A,P){var F=x.data,T=x.r,C=w+T;if(F){if(F.index>d.index){var W=p-F.x-F.vx,j=m-F.y-F.vy,Y=W*W+j*j;Y<C*C&&(W===0&&(W=it(r),Y+=W*W),j===0&&(j=it(r),Y+=j*j),Y=(C-(Y=Math.sqrt(Y)))/Y*i,d.vx+=(W*=Y)*(C=(T*=T)/(v+T)),d.vy+=(j*=Y)*C,F.vx-=W*(C=1-C),F.vy-=j*C)}return}return k>p+C||A<p-C||N>m+C||P<m-C}}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(t){var u,c=t.length,h;for(n=new Array(c),u=0;u<c;++u)h=t[u],n[h.index]=+e(h,u,t)}}return a.initialize=function(u,c){t=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?(e=typeof u=="function"?u:fe(+u),l(),a):e},a}function Vf(e){return e.index}function kl(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function wo(e){var t=Vf,n=h,r,i=fe(30),o,a,s,l,u,c=1;e==null&&(e=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var b=0,y=e.length;b<c;++b)for(var x=0,k,N,A,P,F,T,C;x<y;++x)k=e[x],N=k.source,A=k.target,P=A.x+A.vx-N.x-N.vx||it(u),F=A.y+A.vy-N.y-N.vy||it(u),T=Math.sqrt(P*P+F*F),T=(T-o[x])/T*v*r[x],P*=T,F*=T,A.vx-=P*(C=l[x]),A.vy-=F*C,N.vx+=P*(C=1-C),N.vy+=F*C}function p(){if(a){var v,b=a.length,y=e.length,x=new Map(a.map((N,A)=>[t(N,A,a),N])),k;for(v=0,s=new Array(b);v<y;++v)k=e[v],k.index=v,typeof k.source!="object"&&(k.source=kl(x,k.source)),typeof k.target!="object"&&(k.target=kl(x,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=e[v],l[v]=s[k.source.index]/(s[k.source.index]+s[k.target.index]);r=new Array(y),m(),o=new Array(y),w()}}function m(){if(a)for(var v=0,b=e.length;v<b;++v)r[v]=+n(e[v],v,e)}function w(){if(a)for(var v=0,b=e.length;v<b;++v)o[v]=+i(e[v],v,e)}return d.initialize=function(v,b){a=v,u=b,p()},d.links=function(v){return arguments.length?(e=v,p(),d):e},d.id=function(v){return arguments.length?(t=v,d):t},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:fe(+v),m(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:fe(+v),w(),d):i},d}var jf={value:()=>{}};function El(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Gr(n)}function Gr(e){this._=e}function qf(e,t){return e.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&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Gr.prototype=El.prototype={constructor:Gr,on:function(e,t){var n=this._,r=qf(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=Yf(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=_l(n[i],e.name,t);else if(t==null)for(i in n)n[i]=_l(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Gr(e)},call:function(e,t){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(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function Yf(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function _l(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=jf,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var bo=El;var pn=0,Hn=0,Wn=0,Tl=1e3,Or,Un,Fr=0,Ut=0,$r=0,Bn=typeof performance=="object"&&performance.now?performance:Date,Rl=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function _o(){return Ut||(Rl(Xf),Ut=Bn.now()+$r)}function Xf(){Ut=0}function xo(){this._call=this._time=this._next=null}xo.prototype=zr.prototype={constructor:xo,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?_o():+n)+(t==null?0:+t),!this._next&&Un!==this&&(Un?Un._next=this:Or=this,Un=this),this._call=e,this._time=n,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function zr(e,t,n){var r=new xo;return r.restart(e,t,n),r}function Al(){_o(),++pn;for(var e=Or,t;e;)(t=Ut-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pn}function Sl(){Ut=(Fr=Bn.now())+$r,pn=Hn=0;try{Al()}finally{pn=0,Qf(),Ut=0}}function Zf(){var e=Bn.now(),t=e-Fr;t>Tl&&($r-=t,Fr=e)}function Qf(){for(var e,t=Or,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Or=n);Un=e,ko(r)}function ko(e){if(!pn){Hn&&(Hn=clearTimeout(Hn));var t=e-Ut;t>24?(e<1/0&&(Hn=setTimeout(Sl,e-Bn.now()-$r)),Wn&&(Wn=clearInterval(Wn))):(Wn||(Fr=Bn.now(),Wn=setInterval(Zf,Tl)),pn=1,Rl(Sl))}}function Cl(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Ll(e){return e.x}function Nl(e){return e.y}var Jf=10,eg=Math.PI*(3-Math.sqrt(5));function Eo(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=zr(h),u=bo("tick","end"),c=Cl();e==null&&(e=[]);function h(){d(),u.call("tick",t),n<r&&(l.stop(),u.call("end",t))}function d(w){var v,b=e.length,y;w===void 0&&(w=1);for(var x=0;x<w;++x)for(n+=(o-n)*i,s.forEach(function(k){k(n)}),v=0;v<b;++v)y=e[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 t}function p(){for(var w=0,v=e.length,b;w<v;++w){if(b=e[w],b.index=w,b.fx!=null&&(b.x=b.fx),b.fy!=null&&(b.y=b.fy),isNaN(b.x)||isNaN(b.y)){var y=Jf*Math.sqrt(.5+w),x=w*eg;b.x=y*Math.cos(x),b.y=y*Math.sin(x)}(isNaN(b.vx)||isNaN(b.vy))&&(b.vx=b.vy=0)}}function m(w){return w.initialize&&w.initialize(e,c),w}return p(),t={tick:d,restart:function(){return l.restart(h),t},stop:function(){return l.stop(),t},nodes:function(w){return arguments.length?(e=w,p(),s.forEach(m),t):e},alpha:function(w){return arguments.length?(n=+w,t):n},alphaMin:function(w){return arguments.length?(r=+w,t):r},alphaDecay:function(w){return arguments.length?(i=+w,t):+i},alphaTarget:function(w){return arguments.length?(o=+w,t):o},velocityDecay:function(w){return arguments.length?(a=1-w,t):1-a},randomSource:function(w){return arguments.length?(c=w,s.forEach(m),t):c},force:function(w,v){return arguments.length>1?(v==null?s.delete(w):s.set(w,m(v)),t):s.get(w)},find:function(w,v,b){var y=0,x=e.length,k,N,A,P,F;for(b==null?b=1/0:b*=b,y=0;y<x;++y)P=e[y],k=w-P.x,N=v-P.y,A=k*k+N*N,A<b&&(F=P,b=A);return F},on:function(w,v){return arguments.length>1?(u.on(w,v),t):u.on(w)}}}function So(){var e,t,n,r,i=fe(-30),o,a=1,s=1/0,l=.81;function u(p){var m,w=e.length,v=Ht(e,Ll,Nl).visitAfter(h);for(r=p,m=0;m<w;++m)t=e[m],v.visit(d)}function c(){if(e){var p,m=e.length,w;for(o=new Array(m),p=0;p<m;++p)w=e[p],o[w.index]=+i(w,p,e)}}function h(p){var m=0,w,v,b=0,y,x,k;if(p.length){for(y=x=k=0;k<4;++k)(w=p[k])&&(v=Math.abs(w.value))&&(m+=w.value,b+=v,y+=v*w.x,x+=v*w.y);p.x=y/b,p.y=x/b}else{w=p,w.x=w.data.x,w.y=w.data.y;do m+=o[w.data.index];while(w=w.next)}p.value=m}function d(p,m,w,v){if(!p.value)return!0;var b=p.x-t.x,y=p.y-t.y,x=v-m,k=b*b+y*y;if(x*x/l<k)return k<s&&(b===0&&(b=it(n),k+=b*b),y===0&&(y=it(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)),t.vx+=b*p.value*r/k,t.vy+=y*p.value*r/k),!0;if(p.length||k>=s)return;(p.data!==t||p.next)&&(b===0&&(b=it(n),k+=b*b),y===0&&(y=it(n),k+=y*y),k<a&&(k=Math.sqrt(a*k)));do p.data!==t&&(x=o[p.data.index]*r/k,t.vx+=b*x,t.vy+=y*x);while(p=p.next)}return u.initialize=function(p,m){e=p,n=m,c()},u.strength=function(p){return arguments.length?(i=typeof p=="function"?p:fe(+p),c(),u):i},u.distanceMin=function(p){return arguments.length?(a=p*p,u):Math.sqrt(a)},u.distanceMax=function(p){return arguments.length?(s=p*p,u):Math.sqrt(s)},u.theta=function(p){return arguments.length?(l=p*p,u):Math.sqrt(l)},u}function To(e){var t=fe(.1),n,r,i;typeof e!="function"&&(e=fe(e==null?0:+e));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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:fe(+s),a(),o):t},o.x=function(s){return arguments.length?(e=typeof s=="function"?s:fe(+s),a(),o):e},o}function Ro(e){var t=fe(.1),n,r,i;typeof e!="function"&&(e=fe(e==null?0:+e));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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:fe(+s),a(),o):t},o.y=function(s){return arguments.length?(e=typeof s=="function"?s:fe(+s),a(),o):e},o}var tg=9,Wr=6,Hr=18,ng=32,Il=9,Kn=tg+Il;function Ao(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+ng));return Wr+(Hr-Wr)*n}function Co(e){return e+Il}var rg=300,Ml=1,Pl=.001,Re={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},Vn={...Re};function Lo(e){Object.assign(Re,e)}function Dl(e){return e==="contains"||e==="anchored-at"}function ig(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function og(e){let t=[],n=new Set;for(let o of e.nodes)n.has(o.id)||(n.add(o.id),t.push(o.id));let r=[],i=new Set;for(let o of e.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:t,edges:r}}function No(e){let t=wo(e.links).id(n=>n.id).distance(n=>Dl(n.kind)?Re.containsRest:Re.relationDistance).strength(n=>Dl(n.kind)?Re.containsStrength:Re.relationStrength).iterations(2);return Eo(e.nodes).randomSource(ig(e.seed??Ml)).force("charge",So().strength(Re.charge).distanceMax(Re.chargeMax)).force("link",t).force("collide",yo(n=>n.r??Kn).strength(1)).force("x",To(0).strength(Re.center)).force("y",Ro(0).strength(Re.center)).stop()}function ag(e,t,n){let r=No({nodes:e,links:t.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(Pl).alphaDecay(n.ticks>0?1-Math.pow(Pl,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function Gl(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??rg)),{ids:r,edges:i}=og(e),o=r.map(l=>{let u=t.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,t.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=Co(Ao(a.get(l.id)??0));o.length>1&&ag(o,i,{ticks:n,seed:t.seed??Ml,warm:t.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 sg="sliders";function Ol(e){for(let t of e.replace(/^\?/,"").split("&")){let n=t.indexOf("=");if((n===-1?t:t.slice(0,n))!==sg)continue;let i=n===-1?"":t.slice(n+1).toLowerCase();return i!=="0"&&i!=="false"}return!1}var Ur=[{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}],Fl={containsRest:90,containsStrength:.02,relationDistance:170,relationStrength:.05,charge:-50,chargeMax:1/0,center:.09};function $l(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function zl(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):Vn[e.key]}function Wl(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function Po(e){let t=n=>` ${n}: ${Number.isFinite(e[n])?e[n]:"Infinity"},`;return["export const FORCES: ForceConstants = {",...Ur.map(n=>t(n.key)),"};"].join(`
22
- `)}function Hl(e){return Ur.every(t=>Object.is(e[t.key],Vn[t.key]))}var Ul="pi-weave.graph.groupColors.v1";function Bl(e){try{return e.getItem(Ul)!=="off"}catch{return!0}}function Kl(e,t){try{e.setItem(Ul,t?"on":"off")}catch{}}var Bt,ue,Do,Vl,jn=0,eu=[],he=ee,jl=he.__b,ql=he.__r,Yl=he.diffed,Xl=he.__c,Zl=he.unmount,Ql=he.__;function qn(e,t){he.__h&&he.__h(ue,e,jn||t),jn=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function V(e){return jn=1,lg(ru,e)}function lg(e,t,n){var r=qn(Bt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ru(void 0,t),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=ue,!ue.__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(p){if(p.__N){c=!0;var m=p.__[0];p.__=p.__N,p.__N=void 0,m!==p.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};ue.__f=!0;var o=ue.shouldComponentUpdate,a=ue.componentWillUpdate;ue.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)},ue.shouldComponentUpdate=i}return r.__N||r.__}function se(e,t){var n=qn(Bt++,3);!he.__s&&Mo(n.__H,t)&&(n.__=e,n.u=t,ue.__H.__h.push(n))}function Qe(e,t){var n=qn(Bt++,4);!he.__s&&Mo(n.__H,t)&&(n.__=e,n.u=t,ue.__h.push(n))}function X(e){return jn=5,Kt(function(){return{current:e}},[])}function Kt(e,t){var n=qn(Bt++,7);return Mo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function tu(e,t){return jn=8,Kt(function(){return e},t)}function nu(){var e=qn(Bt++,11);if(!e.__){for(var t=ue.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function ug(){for(var e;e=eu.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Br),t.__h.some(Io),t.__h=[]}catch(n){t.__h=[],he.__e(n,e.__v)}}}he.__b=function(e){ue=null,jl&&jl(e)},he.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ql&&Ql(e,t)},he.__r=function(e){ql&&ql(e),Bt=0;var t=(ue=e.__c).__H;t&&(Do===ue?(t.__h=[],ue.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Br),t.__h.some(Io),t.__h=[],Bt=0)),Do=ue},he.diffed=function(e){Yl&&Yl(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(eu.push(t)!==1&&Vl===he.requestAnimationFrame||((Vl=he.requestAnimationFrame)||cg)(ug)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Do=ue=null},he.__c=function(e,t){t.some(function(n){try{n.__h.some(Br),n.__h=n.__h.filter(function(r){return!r.__||Io(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],he.__e(r,n.__v)}}),Xl&&Xl(e,t)},he.unmount=function(e){Zl&&Zl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Br(r)}catch(i){t=i}}),n.__H=void 0,t&&he.__e(t,n.__v))};var Jl=typeof requestAnimationFrame=="function";function cg(e){var t,n=function(){clearTimeout(r),Jl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Jl&&(t=requestAnimationFrame(n))}function Br(e){var t=ue,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ue=t}function Io(e){var t=ue;e.__c=e.__(),ue=t}function Mo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function ru(e,t){return typeof t=="function"?t(e):t}var gn=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function iu(){return{version:1,panes:[{id:"pane-1",tabs:[gn("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,treeWidth:240,contextWidth:240,theme:"system"}}function Yn(e){return e.panes.find(t=>t.id===e.activePane)}function mn(e){let t=Yn(e);return t.tabs.find(n=>n.id===t.activeTab)}function yt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function Pt(e,t){let n=new Set(e.panes.flatMap(i=>[i.id,...i.tabs.map(o=>o.id)])),r=1;for(;n.has(`${t}-${r}`);)r++;return`${t}-${r}`}function Vt(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?Kr({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function zo(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function Kr(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??zo(e);return r?{...n,lastDocumentTab:r.id}:n}function ou(e){if(mn(e).kind==="document")return e;let t=Yn(e),n=zo(t);return n?Vt(e,t,n):Vr(e,null,{newTab:!0})}function Wo(e,t,n){let r=e.panes.find(o=>o.id===t),i=r?.tabs.find(o=>o.id===n);return r&&i?{pane:r,tab:i}:null}function $o(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=40?e:Vt(e,{...t,tabs:[...t.tabs,n]},n)}function Go(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>100&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function Vr(e,t,n={}){let r=e.panes.find(s=>s.id===(n.paneId??e.activePane));if(!r)return e;let i=r.activeTab,o=r.tabs.find(s=>s.id===i);if(o?.kind==="graph"&&(o=zo(r),o?r={...r,activeTab:o.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!o)return $o(e,r,Go(gn(Pt(e,"tab")),t));let a=Go(o,t);return a===o&&r.id===e.activePane&&i===o.id?e:Vt(e,r,a)}function Ho(e){let t=e.panes.flatMap(r=>r.tabs.filter(i=>i.kind==="graph").map(i=>({pane:r,tab:i})))[0];if(t)return t.pane.id===e.activePane&&t.pane.activeTab===t.tab.id?e:Vt(e,t.pane,t.tab);let n=Yn(e);return $o(e,n,{id:Pt(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function Uo(e,t,n){let r=Wo(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:Vt(e,r.pane,r.tab)}function Bo(e,t,n){let r=Wo(e,t,n);if(!r)return e;let{pane:i}=r;if(i.tabs.length===1){let u=e.panes.find(h=>h.id!==t);if(u)return{...e,panes:[u],activePane:u.id};let c=gn(Pt(e,"tab"));return Vt(e,{...i,tabs:[c]},c)}let o=i.tabs.filter(u=>u.id!==n),a=i.activeTab===n,s=o[Math.max(0,i.tabs.findIndex(u=>u.id===n)-1)],l=Kr({...i,tabs:o,activeTab:a?s.id:i.activeTab});return{...e,activePane:a?t:e.activePane,panes:e.panes.map(u=>u.id===t?l:u)}}function Ko(e,t,n){let r=e.panes.find(a=>a.id===t),i=r?.tabs.find(a=>a.id===r.activeTab);if(!r||!i||i.kind!=="document")return e;let o=i.cursor+n;return o<0||o>=i.history.length?e:Vt(e,r,{...i,cursor:o,scroll:0})}function Vo(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};if(e.panes.reduce((o,a)=>o+a.tabs.length,0)>=40)return e;let n=mn(e),r=Pt(e,"pane"),i=gn(Pt(e,"tab"));return n.kind==="document"&&(i={...n,id:i.id,history:[...n.history],scroll:n.scroll}),{...e,panes:[...e.panes,{id:r,tabs:[i],activeTab:i.id}],activePane:r,split:t}}function au(e,t){if(e.panes.length!==2||!e.panes.some(i=>i.id===t))return e;let n=e.panes.find(i=>i.id===t),r=e.panes.find(i=>i.id!==t);return{...e,panes:[{...r,tabs:[...r.tabs,...n.tabs]}],activePane:r.id}}function jr(e,t,n){return e.panes.some(r=>r.id===t)?e.panes.find(r=>r.id!==t&&r.tabs.some(i=>i.id===n))?.id??null:null}function jo(e,t,n){let r=Wo(e,t,n);if(!r)return e;let i=e.panes.find(c=>c.id!==t)??{id:Pt(e,"pane"),tabs:[],activeTab:""},o=r.pane.tabs.filter(c=>c.id!==n),a=Kr({...i,tabs:[...i.tabs,r.tab],activeTab:r.tab.id});if(!o.length&&e.panes.length===2)return{...e,panes:[a],activePane:i.id};if(!o.length&&e.panes.reduce((c,h)=>c+h.tabs.length,0)>=40)return e;let s=o.length?null:gn(Pt(e,"tab")),l=o.length?o:[s],u=Kr({...r.pane,tabs:l,activeTab:r.pane.activeTab===n?l[Math.max(0,r.pane.tabs.findIndex(c=>c.id===n)-1)].id:r.pane.activeTab});return{...e,activePane:i.id,panes:e.panes.length===1?[u,a]:e.panes.map(c=>c.id===u.id?u:a)}}function Oo(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function Fo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fn(e,t){return typeof e=="string"&&e.length<=2048&&(t===void 0?e.length>0&&!/[\u0000-\u001f\u007f]/.test(e):new RegExp(`^${t}-[1-9][0-9]{0,8}$`).test(e))}function su(e){if(!Fo(e)||!Oo(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme"])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!fn(e.activePane,"pane")||e.split!=="right"&&e.split!=="down"||typeof e.ratio!="number"||!Number.isFinite(e.ratio)||e.ratio<.1||e.ratio>.9||typeof e.treeVisible!="boolean"||typeof e.contextVisible!="boolean"||typeof e.treeWidth!="number"||!Number.isFinite(e.treeWidth)||e.treeWidth<120||e.treeWidth>800||typeof e.contextWidth!="number"||!Number.isFinite(e.contextWidth)||e.contextWidth<120||e.contextWidth>800||e.theme!=="system"&&e.theme!=="light"&&e.theme!=="dark")return null;let t=new Set,n=0,r=0,i=[];for(let o of e.panes){if(!Fo(o)||!Oo(o,Object.hasOwn(o,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!fn(o.id,"pane")||!Array.isArray(o.tabs)||o.tabs.length<1||!fn(o.activeTab,"tab")||t.has(o.id))return null;t.add(o.id);let a=[],s=!1;for(let u of o.tabs){if(!Fo(u)||!Oo(u,["id","kind","history","cursor","scroll"])||!fn(u.id,"tab")||t.has(u.id)||(t.add(u.id),u.kind!=="document"&&u.kind!=="graph"))return null;let c=u.kind;if(!Array.isArray(u.history)||u.history.length<1||u.history.length>100||!Number.isInteger(u.cursor)||u.cursor<0||u.cursor>=u.history.length||u.history.some(h=>h!==null&&!fn(h))||typeof u.scroll!="number"||!Number.isFinite(u.scroll)||u.scroll<0||u.scroll>1e9)return null;c==="graph"&&r++,n++,u.id===o.activeTab&&(s=!0),a.push({id:u.id,kind:c,history:u.history,cursor:u.cursor,scroll:u.scroll})}if(!s)return null;let l=o.lastDocumentTab;if(Object.hasOwn(o,"lastDocumentTab")&&(!fn(l,"tab")||!a.some(u=>u.id===l&&u.kind==="document")))return null;i.push({id:o.id,tabs:a,activeTab:o.activeTab,...typeof l=="string"?{lastDocumentTab:l}:{}})}return n>40||r>1||!i.some(o=>o.id===e.activePane)?null:{version:1,panes:i,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,treeWidth:e.treeWidth,contextWidth:e.contextWidth,theme:e.theme}}var Me=(e,t)=>fetch(e,{...t?.method===void 0?{}:{method:t.method},...t?.headers===void 0?{}:{headers:t.headers},...t?.body===void 0?{}:{body:t.body},...t?.signal===void 0?{}:{signal:t.signal},credentials:"same-origin"});function qo(e,t=!1){return{ok:!0,data:e,cached:t}}function wt(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function lu(e){return e===403?"auth":e===404?"missing":"server"}function uu(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function qr(e,t,n,r){let i;try{i=await e(t,r)}catch(a){return wt("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return wt(lu(i.status),i.status,uu(i.status));let o;try{o=await i.json()}catch{return wt("malformed",i.status,"response was not valid JSON")}return n(o)?qo(o):wt("malformed",i.status,"response did not match the expected shape")}function bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dg(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function hg(e){if(!bt(e)||typeof e.stamp!="string")return!1;let t=e.model;return!bt(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:bt(e.tags)&&bt(e.dangling)}function pg(e){if(!bt(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return dg(e.tags)}function fg(e){return bt(e)&&pg(e.note)}function gg(e){return bt(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function mg(e){return bt(e)&&typeof e.opened=="boolean"}function vg(e){return bt(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}async function cu(e,t=null){let n=t===null?void 0:{"if-none-match":`"${t.stamp}"`},r;try{r=await e("/api/graph",n===void 0?{}:{headers:n})}catch(o){return wt("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return t===null?wt("malformed",304,"server sent 304 for an unconditional request"):qo(t,!0);if(!r.ok)return wt(lu(r.status),r.status,uu(r.status));let i;try{i=await r.json()}catch{return wt("malformed",r.status,"response was not valid JSON")}return hg(i)?qo(i):wt("malformed",r.status,"response did not match the expected shape")}function Yo(e,t){return qr(e,`/api/note/${encodeURIComponent(t)}`,fg)}function du(e,t,n){return qr(e,`/api/search?q=${encodeURIComponent(t)}`,gg,n===void 0?void 0:{signal:n})}function hu(e,t){return qr(e,"/api/open",mg,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function jt(e,t,n,r){return qr(e,t,vg,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Yr=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,Xo=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,pu=(e,t,n)=>jt(e,Yr(t),"POST",{body:n}),fu=(e,t,n)=>jt(e,Yr(t,"/rename"),"POST",{name:n}),gu=(e,t,n)=>jt(e,Yr(t,"/move"),"POST",{folder:n}),mu=(e,t)=>jt(e,Yr(t),"DELETE"),vu=(e,t)=>jt(e,Xo(t),"POST"),yu=(e,t,n)=>jt(e,Xo(t,"/rename"),"POST",{name:n}),wu=(e,t)=>jt(e,Xo(t),"DELETE");function je(e){if(e.kind==="external"&&e.detail.url){let t=e.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(t)return t}return e.kind==="package"&&e.detail.manifest?`${e.label} (${e.detail.manifest})`:e.label}function yg(e){let t=new Map;for(let l of e.nodes)t.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of e.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 p of d){let m=t.get(p);if(m&&m.kind==="module"&&m.detail.path){let w=m.detail.path;u.startsWith(w+"/")&&w.length>h&&(c=p,h=w.length)}}return c},a=new Map;for(let l of e.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=e.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:t,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function ku(e){let t=new Set;for(let n of e.edges)(n.kind==="contains"||n.kind==="anchored-at")&&t.add(n.target);return e.nodes.filter(n=>!t.has(n.id)).map(n=>n.id)}function wg(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function bu(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function bg(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=bu(i),s=bu(o);if(a!==s)return a?-1:1;let l=je(i),u=je(o);return l.localeCompare(u)})}function xu(e,t,n){let r=Number(e);return Number.isFinite(r)?{kind:"count",n:r,unit:t,phrasing:n}:{kind:"text",text:n==="attribute"?`${t}=${e}`:`${e} ${t}`}}function xg(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?xu(e.detail.files,"files","attribute"):null;case"gitState":return e.detail.commit?{kind:"commit",sha:e.detail.commit}:null;case"repository":return e.detail.files?xu(e.detail.files,"files","prose"):null;case"package":return e.detail.kind?{kind:"text",text:e.detail.kind}:null;case"entryPoint":return e.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function Zo(e,t){let n=yg(e),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=m=>{let b=(i.get(m)??[]).filter(y=>{let x=r.get(y);if(!x||x.kind!=="entryPoint")return!0;for(let[,k]of o)if(k.includes(y))return!1;return!0}).concat(o.get(m)??[]);return b=b.filter(y=>r.has(y)),t.showInternals||(b=b.filter(y=>{let x=r.get(y);return!(x&&wg(x.kind))})),bg(b,r)},l=t.provFilter!==null||t.query.length>0,u=m=>!(t.provFilter!==null&&m.provenance!==t.provFilter||t.query.length>0&&!je(m).toLowerCase().includes(t.query.toLowerCase())),c=new Set,h=m=>{let w=r.get(m),v=!1;for(let y of s(m))h(y)&&(v=!0);let b=u(w)||v;return b&&c.add(m),b};for(let m of a)h(m);let d=[],p=(m,w)=>{if(!c.has(m))return;let v=r.get(m),b=s(m),y=b.filter(k=>c.has(k)),x=l?y.length>0:t.expanded.has(m);if(d.push({id:m,depth:w,hasKids:b.length>0,expanded:x,label:je(v),kind:v.kind,provenance:v.provenance,meta:xg(v)}),x)for(let k of y)p(k,w+1)};for(let m of a)p(m,0);return d}function Qo(e){if(!e.nodes.find(i=>i.kind==="vault"))return null;let n=e.nodes.some(i=>i.kind==="note"),r=e.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function Xn(e,t){if(!e)return"";let n=Date.parse(e);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((t-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 kg=7;function Jo(e,t){if(e===null)return"";switch(e.kind){case"relTime":return Xn(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,kg);case"text":return e.text}}var _g=["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 ea(e,t){let n=new Map;for(let s of e.nodes)n.set(s.id,s);let r=n.get(t);if(!r)return null;let i=[];for(let s of _g){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${je(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${je(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:je(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Xr(e,t){let n=new Set([e]);for(let r of t)r.source===e&&n.add(r.target),r.target===e&&n.add(r.source);return n}var Eg=["contains","anchored-at"];function Sg(e){return Eg.includes(e)}function Zr(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=Tg(e,n),i=ku(e),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!t.has(d)))for(let p of r.get(d)??[])a(p)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,Rg(d,r));let l=new Map;for(let d of e.nodes)if(!(!o.has(d.id)||t.has(d.id)))for(let p of s.get(d.id)??[])!o.has(p)&&!l.has(p)&&l.set(p,d.id);for(let d of e.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,p]of r){let m=s.get(d);u.set(d,{children:p,descendants:m,members:m.filter(w=>l.get(w)===d),provenance:Ag(m,n),expanded:t.has(d)})}let c=new Set,h=[];for(let d of e.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:Cg(e.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function Tg(e,t){let n=new Map;for(let r of e.edges){if(!Sg(r.kind)||!t.has(r.source)||!t.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 Rg(e,t){let n=[],r=new Set([e]),i=o=>{for(let a of t.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(e),n}function Ag(e,t){let n={human:0,agent:0,generated:0,none:0};for(let r of e){let i=t.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Cg(e,t,n){let r=a=>t.has(a)?a:n.get(a),i=[],o=new Set;for(let a of e){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 ta(e){let t=new Map;for(let n of e){if(n.kind!=="links-to")continue;let r=t.get(n.target);r?r.push(n.source):t.set(n.target,[n.source])}return t}var vn=[null,"human","agent","generated"];function _u(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function ia(e,t){let n=new Set(e.expanded).add("vault"),r="";for(let i of t?t.split("/"):[])r=r?`${r}/${i}`:i,n.add(`vfolder:${r}`);return{...e,expanded:n,query:"",provFilter:null}}function qt(e){return{...e.model,danglingLinks:e.dangling}}function Eu(e,t){return e===null?[]:Zo(qt(e),t)}var yn="vfolder:\0draft";function Su(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function Tu(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function Ru(e,t){if(t===null)return[...e];let n={id:yn,depth:t===""?1:t.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(t==="")return[...e,n];let r=e.findIndex(o=>o.id===`vfolder:${t}`);if(r===-1)return[...e,n];let i=r+1;for(;i<e.length&&e[i].depth>e[r].depth;)i++;return[...e.slice(0,i),n,...e.slice(i)]}function oa(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Lg(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function Ng(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function aa(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function Yt(e){return e==="vault"?{type:"vault",path:""}:e.startsWith("note:")?{type:"note",path:e.slice(5)}:e.startsWith("vfolder:")?{type:"folder",path:e.slice(8)}:null}function Jr(e,t){if(t.type==="note")return[t.path];if(t.type!=="folder"||e===null)return[];let n=`note:${t.path}/`;return e.model.nodes.filter(r=>r.kind==="note"&&r.id.startsWith(n)).map(r=>r.id.slice(5))}function Au(e,t){return e===null?!1:t.type==="note"?e===`note:${t.path}`:t.type==="folder"?e===`vfolder:${t.path}`||e.startsWith(`vfolder:${t.path}/`)||e.startsWith(`note:${t.path}/`):!1}function sa(e){return e.type==="folder"}function Cu(e,t,n){return sa(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function Lu(e,t){return e.query===t?e:{...e,query:t}}function Nu(e){let t=vn.indexOf(e.provFilter),n=vn[(t+1)%vn.length]??null;return{...e,provFilter:n}}function Pu(e){return{...e,showInternals:!e.showInternals}}function ei(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function ra(e,t){return e[t]?.id??null}function na(e,t,n){if(e.length===0)return null;let r=ei(e,t),i=r===-1?n>0?-1:e.length:r;return ra(e,Math.min(e.length-1,Math.max(0,i+n)))}function Pg(e,t){let n=ei(e,t),r=n<=0?void 0:e[n];if(r===void 0)return null;for(let i of e.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var Dg={j:"ArrowDown",k:"ArrowUp"};function Ig(e){return Dg[e]??e}function Du(e,t,n,r,i=!1){let o={state:t,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:t,selectedId:h,handled:!0}),s=Ig(r);if(s==="ArrowDown")return a(na(e,n,1));if(s==="ArrowUp")return a(na(e,n,-1));if(s==="Home")return a(ra(e,0));if(s==="End")return a(ra(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=ei(e,n),u=l===-1?void 0:e[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(na(e,n,1)):{state:Lg(t,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:Ng(t,n),selectedId:n,handled:!0};let c=Pg(e,n);return c===null?o:a(c)}var Mg={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Xt(e){return Mg[e]}var Gg={human:"●",agent:"◐",generated:"○"};function Zt(e){return e===null?"":Gg[e]}function wn(e){return e===null?"":`${e}-authored`}function Iu(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Og(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())t[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of e.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),t}function Fg(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:Iu(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:Xt(e.kind),provenance:e.provenance,provenanceGlyph:Zt(e.provenance),provenanceTitle:wn(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:Jo(e.meta,n),level:e.depth+1}}function Mu(e,t,n){let r=Og(e);return e.map((i,o)=>Fg(i,t,n,r[o]))}function Gu(e,t){return ei(e,t)===-1?null:Iu(t)}function Ou(e){return{"--weave-depth":String(Math.max(0,e))}}function Qr(e){return e===null?"all":e}function Fu(e){let t=vn.indexOf(e),n=vn[(t+1)%vn.length]??null;return`provenance filter: ${Qr(e)} — click for ${Qr(n)}`}function $u(e){return e?"internals":"knowledge"}function zu(e){return e?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Wu="filter…",Hu="Vault and repository",Uu="Filter the tree",Bu="Filter the tree (/)";function Ku(e,t,n){if(e===null)return"loading…";let r=Qo(qt(e));return r!==null?r:t.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 Vu(e){return e.length===1?"1 row":`${e.length} rows`}var Dt={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"}},$g={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},zg={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Wg(e,t){return Dt[t][$g[e]]}function ju(e,t){return Dt[t][zg[e]]}function Hg(e,t){return Ug(e)?ua(ju(e,t),t,Bg):ju(e,t)}function Ug(e){return e==="contains"||e==="anchored-at"}var la=.85,Bg=.3;function Zn(e,t,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(e),o=r(t);if(i===null||o===null)return e;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 ua(e,t,n=la){return Zn(e,Dt[t].ground,n)}var Kg={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},qu=1.6,Xu=32,Vg=Xu/2;function jg(e,t=Xu){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),o=i>=Vg?i:n;return`${e.slice(0,o).trimEnd()}…`}function qg(e){let t=Zt(e.provenance),n=je(e);return jg(t===""?n:`${t} ${n}`)}var Yg=6,Xg=6;function Zg(e){return(t,n,r)=>{if(n.label===null||n.label==="")return;let i=Dt[e];t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=Xg,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+Yg),t.restore()}}function Zu(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(o++,s.x<t&&(t=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y));if(o===0)return null;let a=Math.max(0,(Kn*4-Math.max(r-t,i-n))/2);return{x:[t-a,r+a],y:[n-a,i+a]}}var Qu={nodes:[],edges:[]};function Ju(e){return`${e.source}\0${e.target}\0${e.kind}`}function Qg(e,t){let n=new Map,r=new Set;for(let i of e){if(i.source===i.target||!t.has(i.source)||!t.has(i.target))continue;let o=Ju(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 ec(e,t,n,r,i){let o=new Map;for(let h of e){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=Qg(t,a),l=[];for(let[h,d]of o){let p=n.get(h),m=Ao(s.get(h)??0);l.push({id:h,x:p.x,y:p.y,size:m,label:qg(d),color:i?.get(h)??Wg(d.kind,r),kind:d.kind,provenance:d.provenance,zIndex:Math.round(m),type:"circle"})}let u=[],c=new Set;for(let h of t){if(h.source===h.target||!a.has(h.source)||!a.has(h.target))continue;let d=Ju(h);c.has(d)||(c.add(d),u.push({key:d,source:h.source,target:h.target,size:Kg[h.kind],color:Hg(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:u}}function tc(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:r===t&&e.has(r)?{zIndex:i.zIndex+Yu*2,size:i.size*ti(nm,n)}:e.has(r)?{zIndex:i.zIndex+Yu,size:i.size*ti(rm,n)}:{color:ua(i.color,o,la*n),label:n>=tm?null:i.label,zIndex:0}}var Jg=60,em=.004;function nc(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/Jg);return Math.abs(t-i)<em?t:i}function ti(e,t){return 1+(e-1)*t}var tm=.5,nm=1.45,rm=1.15,Yu=Hr+1;function rc(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:!e.has(i.source)||!e.has(i.target)?{color:ua(i.color,o,la*n)}:t!=null&&(i.source===t||i.target===t)?{zIndex:2,size:i.size*ti(qu*1.35,n),color:Zn(i.color,Dt[o].accent,n)}:{zIndex:1,size:i.size*ti(qu,n)}}var im=(Wr+Hr)/2,om=Kn*4,am=1;function ic(e){let t=Dt[e];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:am,labelGridCellSize:om,labelRenderedSizeThreshold:im,labelFont:"inherit",labelSize:11,labelColor:{color:t.text},defaultNodeColor:t.dim,defaultEdgeColor:t.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:Kn,defaultDrawNodeHover:Zg(e),allowInvalidContainer:!0}}function oc(e){return e==="contains"||e==="anchored-at"}function sm(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)oc(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 lm(e,t){let n=sm(e,t),r=new Map;for(let i of e){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 um(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var cm={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},dm=3;function hm(e,t){let n=cm[t],i=[...um(e).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*dm%n.length])),o}var pm=.11,fm=.34;function gm(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return Zn(e,Dt[n].ground,Math.min(fm,r*pm))}var mm=.26,vm=.55;function ym(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let o of t){let a=Math.min(mm,vm-i);if(a<=0)break;i+=a,r=Zn(r,o,a)}return r}function ac(e,t,n){let r=lm(e,t),i=new Map;for(let[c,h]of r)i.set(c,h.key);let o=hm(i,n),a=new Set(e.map(c=>c.id)),s=new Map,l=(c,h)=>{let d=r.get(c)?.key,p=r.get(h)?.key;if(d===void 0||p===void 0||d===p)return;let m=s.get(c);m===void 0?s.set(c,new Set([p])):m.add(p)};for(let c of t)oc(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 e){let h=r.get(c.id);if(h===void 0)continue;let d=o.get(h.key);if(d===void 0)continue;let p=gm(d,h.depth,n),m=[...s.get(c.id)??[]].sort().map(w=>o.get(w)).filter(w=>w!==void 0);u.set(c.id,ym(p,m,n))}return u}function sc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}var wm=300,bm=1;function xm(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let o of t){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:wm,seed:bm,pinWarm:!0};return r.size>0&&(i.initial=r),Gl({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function km(e,t){let n=0,r=0;for(let o of e){let a=sc(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=sc(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[e.length,t.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var ni="pi-weave.graph.positions.v4";function lc(e){return Math.round(e*10)/10}function _m(e,t){let n={};for(let[r,i]of t)n[r]=[lc(i.x),lc(i.y)];return JSON.stringify({v:4,key:e,at:n})}function Em(e,t){if(e===null)return null;let n;try{n=JSON.parse(e)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==4||r.key!==t)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 Sm(e,t){let n;try{n=e.getItem(ni)}catch{return null}return Em(n,t)}function Tm(e,t,n){try{return e.setItem(ni,_m(t,n)),!0}catch{return!1}}function uc(e,t,n){let r=km(t,n),i=Sm(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=xm(t,n);return Tm(e,r,o),{key:r,positions:o,cached:!1}}function dc(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(i=>i.id===t);if(n===void 0)return null;let r=t.startsWith("artifact:")?"HTML artifact":t.startsWith("vfolder:")?"Folder":n.kind;return{id:t,title:n.label,kind:r,icon:Xt(n.kind)}}function Rm(e){return{expanded:new Set(Zr(e,new Set).clusters.keys())}}function hc(e,t){return t!==null?t:e===null?{expanded:new Set}:Rm(qt(e))}function Am(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function Cm(e,t){return t===null?null:Xr(t,e)}function pc(e,t,n){return t===null?n:Xr(t,e)}var fc="fit",gc="frame the whole graph",mc="sliders",vc="tune the layout physics and colours",ri={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function yc(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function Lm(e,t){return e===null?"Loading…":e.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":t===0?"Nothing to draw at this expansion.":null}var Nm="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",cc={graph:Qu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function wc(e,t,n,r,i,o=!1,a=!0){if(e===null)return o?{...cc,empty:Nm}:cc;let s=qt(e),l=Zr(s,n.expanded),c=n.expanded.has("vault")?l.edges.filter(p=>p.source!=="vault"&&p.target!=="vault"):l.edges,h=uc(r,l.nodes,c),d=a?ac(l.nodes,c,i):void 0;return{graph:ec(l.nodes,c,h.positions,i,d),highlight:Cm(c,t),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Lm(e,l.nodes.length)}}function bc(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:Am(e,n),selectedId:n}}var xc="(prefers-color-scheme: light)";function ii(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(xc).matches?"light":"dark"}function kc(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(xc);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var Pm=.06,Dm=.2,ca=.001,_c=.5;function Ec(e,t){if(e.nodes.length===0)return null;let n=e.nodes.map(s=>{let l=t?.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:Co(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of e.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=No({nodes:n,links:o,seed:1}).alpha(Pm).alphaMin(ca);return{tick(){a.tick()},awake(){return a.alphaTarget()>ca||a.alpha()>ca},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)<_c&&Math.abs(u.fy-l.y)<_c;u.fx=l.x,u.fy=l.y,a.alphaTarget(c?0:Dm)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}var Im=0;function g(e,t,n,r,i,o){t||(t={});var a,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?a=t[s]:l[s]=t[s];var u={type:e,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Im,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return ee.vnode&&ee.vnode(u),u}function Sc(e){let[,t]=V(0),[n,r]=V(!1),i=(a,s)=>{Lo({[a.key]:zl(a,s)}),r(!1),t(l=>l+1),e.onChange()},o=a=>{Lo(a),r(!1),t(s=>s+1),e.onChange()};return g("div",{class:"weave-tuner",children:[g("p",{class:"weave-tuner-title",children:"graph forces · ?sliders=1"}),g("label",{class:"weave-tuner-toggle",title:"hue per containment group, shade per kind",children:[g("input",{type:"checkbox",checked:e.groupColors,onChange:a=>e.onGroupColors(a.currentTarget.checked)}),g("span",{children:"colour by group"})]}),Ur.map(a=>g("label",{class:"weave-tuner-row",title:a.hint,children:[g("span",{class:"weave-tuner-label",children:[a.label,g("b",{children:Wl(Re[a.key])})]}),g("input",{type:"range",min:a.min,max:a.max,step:a.step,value:$l(Re,a),onInput:s=>i(a,s.currentTarget.value)})]},a.key)),g("div",{class:"weave-tuner-actions",children:[g("button",{type:"button",class:"weave-chip",disabled:Hl(Re),onClick:()=>o(Vn),children:"reset"}),g("button",{type:"button",class:"weave-chip",title:"the pre-tuner constants, for comparison — see HAIRBALL",onClick:()=>o(Fl),children:"before"}),g("button",{type:"button",class:"weave-chip",onClick:()=>{navigator.clipboard?.writeText(Po(Re)).then(()=>r(!0),()=>r(!1))},children:n?"copied ✓":"copy values"})]}),g("pre",{class:"weave-tuner-snippet",children:Po(Re)})]})}var Qn="application/x-weave-note";function Tc(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function da(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function Rc(e,t){return t!==null&&t===e}function Ac(e,t,n){return e.map(r=>{let i=t?.model.nodes.find(a=>a.id===r),o=i?.kind??(r.startsWith("vfolder:")?"module":r.startsWith("artifact:")?"file":"note");return{id:r,label:i?.label??r.replace(/^[^:]+:/,""),icon:Xt(o),selected:r===n}})}var Cc={title:"Context"},Lc="—";function Nc(e,t,n){return{cwd:e===""?Lc:e,selection:t??"nothing selected",stamp:n}}function Pc(e){return e===null?Lc:/T(\d{2}:\d{2}:\d{2})/.exec(e)?.[1]??e}var Dc=6e4;function ha(e){return e?"⌘K":"Ctrl K"}function Ic(e){return`Search notes and repository (${e})`}function pa(e){return/mac|iphone|ipad/i.test(e)}var Mm={k:{type:"openSearch"}},Mc={1:"tree",2:"note",3:"graph"};function Gm(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function Om(e){return!e.ctrl&&!e.meta&&!e.alt}var Fm={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function Gc(e,t){if(t.overlay!==null)return e.key==="Escape"?{type:"closeOverlay"}:null;if(e.alt&&!e.meta&&!e.ctrl&&!e.shift&&e.key.toLowerCase()==="w")return{type:"closeTab"};if(Gm(e)){let n=Mm[e.key.toLowerCase()];if(n!==void 0)return n;let r=Mc[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection?{type:"clearSelection"}:null:!Om(e)||e.typing?null:Fm[e.key]??null}var $m=["INPUT","TEXTAREA","SELECT"];function fa(e,t){return t?!0:e!==null&&$m.includes(e.toUpperCase())}function Oc(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:fa(e.target?.tagName??null,e.target?.isContentEditable===!0)}}var bn={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},ga=".weave-sidebar-notes .weave-filter";function zm(e){let t=e;return typeof t?.focus=="function"?t:null}function oi(e,t){let n=zm(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function Fc(e,t){switch(e.type){case"openSearch":return t.setOverlay("search");case"openHelp":return t.setOverlay("help");case"closeOverlay":return t.setOverlay(null);case"focusColumn":return void t.focusSelector(bn[e.column]);case"filterTree":return void t.focusSelector(ga);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"cycleTheme":return t.cycleTheme()}}function $c(e){return[{title:"Global",entries:[{combo:"⌥W / Alt W",what:"Close the active tab"},{combo:`${e}K`,what:"Search notes and the repository"},...Object.entries(Mc).map(([t,n])=>({combo:`${e}${t}`,what:n==="tree"?"Open and focus the notes sidebar":n==="graph"?"Open and focus Graph view":"Focus the note"})),{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:"Tabs and panes",entries:[{combo:"← / → / Home / End",what:"Select a tab when the tab strip is focused"},{combo:`${e}click`,what:"Open a note or search result in a new tab"},{combo:"Pane options (···)",what:"Split right or down, move a tab, or close a pane"}]},{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:`${e}↵`,what:"Open the highlighted result in a new tab"},{combo:"Esc",what:"Close the palette"}]}]}var ma="Keyboard shortcuts",zc="esc close";var Wc={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 xt({name:e,class:t}){let n=Wc[e];return g("svg",{class:t,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=>g("path",{d:r}))})}function Hm({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let u=aa(e.id);return g("li",{id:e.domId,"data-row-id":e.id,class:`weave-row weave-row-${e.kind}${e.selected?" weave-row-on":""}${t.has(e.id)?" weave-row-new":""}`,role:"treeitem","aria-level":e.level,"aria-posinset":e.posinset,"aria-setsize":e.setsize,"aria-selected":e.selected,"aria-expanded":e.hasKids?e.expanded:void 0,style:Ou(e.depth),onClick:c=>o(c.metaKey||c.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===yn?"New folder":void 0,onDragStart:c=>{c.dataTransfer?.setData("text/plain",e.id),c.dataTransfer?.setData(Qn,e.id),c.dataTransfer&&(c.dataTransfer.effectAllowed="copyMove")},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:[g("span",{class:"weave-twisty","aria-hidden":"true",onClick:c=>{c.stopPropagation(),a()},children:e.hasKids?g(xt,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),g("span",{class:"weave-kind","aria-hidden":"true",children:g(xt,{name:e.kindIcon,class:"weave-icon"})}),g("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),n===null?g("span",{class:"weave-label",children:e.label}):g(Um,{value:n,draft:e.id===yn,onEdit:r,onCommit:i}),g("span",{class:"weave-meta",children:e.meta})]})}function Um({value:e,draft:t,onEdit:n,onCommit:r}){let i=X(null);return Qe(()=>{let o=i.current;o!==null&&(o.focus(),o.select())},[]),g("input",{ref:i,class:"weave-tree-rename",value:e,placeholder:t?"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 Hc(e){let[t,n]=V(_u),[r,i]=V(null),o=X(null);Qe(()=>{r!==null&&o.current?.querySelector(".weave-menu button")?.focus()},[r?.id]);let a=()=>{i(null),o.current?.querySelector(".weave-tree-actions")?.focus()},[s,l]=V(null),[u,c]=V(null),h=Ru(Eu(e.graph,t),u),d=Ku(e.graph,h,t),p=async(b,y)=>{let x=await b;if(!x.ok)window.alert(x.message);else{let k=x.data.id??y;k!==void 0&&e.onSelect(k),e.onRefresh()}},m=async b=>{if(r===null)return;let y=Yt(r.id);if(i(null),y!==null){if(b==="newFolder"){let x=Su(y);n(k=>ia(k,x)),c(x),l({id:yn,label:"",value:""})}else if(b==="rename")n(x=>ia(x,y.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(y.type!=="vault"){if(!e.onMutate(Jr(e.graph,y)))return;await p(y.type==="note"?mu(Me,y.path):wu(Me,y.path),Au(e.selectedId,y)?"vault":void 0)}}},w=b=>{if(r!==null){if(sa(b)&&r.armed!==!0){i({...r,armed:!0});return}m("delete")}},v=b=>{let y=s,x=u;if(l(null),c(null),y===null)return;let k=b?.trim();if(y.id===yn){let A=x===null||!k?null:Tu(x,k);A!==null&&p(vu(Me,A));return}let N=Yt(y.id);if(N!==null&&k&&k!==y.label){if(!e.onMutate(Jr(e.graph,N)))return;p(N.type==="note"?fu(Me,N.path,k):yu(Me,N.path,k))}};return g("div",{class:"weave-tree",ref:o,onKeyDown:b=>{if(r!==null&&b.key==="Escape"){b.preventDefault(),b.stopPropagation(),a();return}let y=b.target,x=Du(h,t,e.selectedId,b.key,fa(y?.tagName??null,y?.isContentEditable===!0));x.handled&&(b.preventDefault(),n(x.state),x.selectedId!==null&&e.onSelect(x.selectedId,!1,!0))},children:[g("div",{class:"weave-tree-controls",children:[g("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Wu,"aria-label":Uu,title:Bu,onInput:b=>n(Lu(t,b.currentTarget.value))}),g("button",{type:"button",class:"weave-chip",title:Fu(t.provFilter),onClick:()=>n(Nu(t)),children:["◧ ",Qr(t.provFilter)]}),g("button",{type:"button",class:"weave-chip",title:zu(t.showInternals),onClick:()=>n(Pu(t)),children:["◧ ",$u(t.showInternals)]}),g("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:b=>{let y=e.selectedId!==null&&Yt(e.selectedId)!==null?e.selectedId:"vault",x=b.currentTarget.getBoundingClientRect();i({id:y,label:e.graph?.model.nodes.find(k=>k.id===y)?.label??"Vault",x:x.left,y:x.bottom})},children:"···"})]}),d===null?g("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Hu,"aria-activedescendant":Gu(h,e.selectedId)??void 0,onContextMenu:b=>{b.preventDefault(),i({id:"vault",label:"Vault",x:b.clientX,y:b.clientY})},children:Mu(h,e.selectedId,e.now).map(b=>g(Hm,{view:b,recentIds:e.recentIds,edit:s?.id===b.id?s.value:null,onEdit:y=>l(x=>x===null?null:{...x,value:y}),onRename:v,onSelect:y=>{e.onSelect(b.id,y),b.hasKids&&n(x=>oa(x,b.id))},onToggle:()=>n(oa(t,b.id)),onMenu:(y,x)=>i({id:b.id,label:b.label,x:y,y:x}),onDrop:y=>{let x=aa(b.id);if(y.startsWith("note:")&&x!==void 0){let k=Yt(y);if(k!==null&&!e.onMutate(Jr(e.graph,k)))return;p(gu(Me,y.slice(5),x))}}},b.id))}):g("p",{class:"weave-tree-empty",children:d}),g("p",{class:"weave-tree-count",children:Vu(h)}),r!==null&&Yt(r.id)!==null?(()=>{let b=Yt(r.id);return g(De,{children:[g("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:a}),g("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},onKeyDown:y=>{if(y.key==="Escape")y.preventDefault(),a();else if(["ArrowDown","ArrowUp","Home","End"].includes(y.key)){y.preventDefault();let x=[...y.currentTarget.querySelectorAll("button")],k=x.indexOf(document.activeElement),N=y.key==="Home"?0:y.key==="End"?x.length-1:(k+(y.key==="ArrowDown"?1:-1)+x.length)%x.length;x[N]?.focus()}y.stopPropagation()},children:[g("button",{type:"button",role:"menuitem",onClick:()=>{m("newFolder")},children:"New folder…"}),b.type!=="vault"?g(De,{children:[g("button",{type:"button",role:"menuitem",onClick:()=>{m("rename")},children:"Rename…"}),g("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>w(b),children:Cu(b,r.label,r.armed===!0)})]}):null]})]})})():null]})}function Uc(e){let t=X(null),n=X(null),r=X(null),i=X(null),o=tu(()=>{if(i.current!==null)return;let x=()=>{i.current=null;let k=r.current;k!==null&&(k.tick(),k.awake()&&(n.current?.setPositions(k.positions()),i.current=requestAnimationFrame(x)))};i.current=requestAnimationFrame(x)},[]),[a,s]=V(null),[l,u]=V(0),[c,h]=V(()=>Bl(e.storage)),[d,p]=V(e.tuner===!0),m=e.scheme??ii(e.host),w=hc(e.graph,a),v=Kt(()=>wc(e.graph,e.selectedId,w,e.storage,m,e.bootFailed,c),[e.graph,e.selectedId,w,e.storage,m,e.bootFailed,l,c]),b=dc(e.graph,e.previewId),y=X({view:w,model:v,onSelect:e.onSelect,selectedId:e.selectedId});return y.current={view:w,model:v,onSelect:e.onSelect,selectedId:e.selectedId},se(()=>{let x=e.renderer(m);return x.onSelect(k=>{let N=bc(y.current.view,y.current.model.clusters,k);s(N.state),y.current.onSelect(N.selectedId)}),x.onHover(k=>{let{model:N,selectedId:A}=y.current;x.setHighlight(pc(N.graph.edges,k,N.highlight),k??A)}),x.onDragStart(k=>{let N=n.current?.positions().get(k);N&&(r.current?.pin(k,N),o())}),x.onDragMove((k,N)=>{r.current?.pin(k,N)}),x.onDragEnd(k=>{r.current?.release(k)}),x.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=x,x.setGraph(y.current.model.graph),x.setHighlight(y.current.model.highlight,y.current.selectedId),e.fit.current=()=>x.fit(),()=>{x.destroy(),n.current=null,e.fit.current=null}},[e.renderer,m]),se(()=>{n.current?.setGraph(v.graph)},[v.key,l,c]),se(()=>{let x=Ec(v.graph,n.current?.positions());return r.current=x,x!==null&&o(),()=>{r.current=null}},[v.key,o,l]),se(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),se(()=>{n.current?.setHighlight(v.highlight,e.selectedId)},[v.highlight,e.selectedId]),g("div",{class:"weave-graph",children:[v.empty===null?null:g("p",{class:"weave-graph-empty",children:v.empty}),g("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),b===null?null:g("aside",{class:"weave-graph-preview","aria-label":"Selected graph node",children:[g("div",{class:"weave-graph-preview-info",children:[g("span",{class:"weave-kind","aria-hidden":"true",children:g(xt,{name:b.icon,class:"weave-icon"})}),g("div",{class:"weave-graph-preview-copy",children:[g("span",{class:"weave-graph-preview-kind",children:b.kind}),g("strong",{class:"weave-graph-preview-title",title:b.title,children:b.title})]})]}),g("button",{type:"button",class:"weave-graph-preview-close","aria-label":"Clear graph selection",onClick:()=>e.onSelect(null),children:"×"}),g("button",{type:"button",class:"weave-chip",onClick:()=>e.onOpen(b.id),children:"Open in new tab"})]}),d?g(Sc,{groupColors:c,onGroupColors:x=>{Kl(e.storage,x),h(x)},onChange:()=>{try{e.storage.setItem(ni,"")}catch{}u(x=>x+1)}}):null,g("div",{class:"weave-graph-controls",children:[g("button",{type:"button",class:"weave-chip",title:gc,onClick:()=>n.current?.fit(),children:fc}),g("button",{type:"button",class:d?"weave-chip weave-chip-on":"weave-chip",title:vc,"aria-pressed":d,onClick:()=>p(!d),children:mc}),g("span",{class:"weave-graph-legend",children:[g("span",{class:"weave-legend-on",children:["◉ ",ri.selected]}),g("span",{class:"weave-legend-near",children:["● ",ri.neighborhood]}),g("span",{class:"weave-legend-dim",children:["· ",ri.dimmed]})]})]}),g("p",{class:"weave-graph-count",children:yc(v.visible,v.total)})]})}function Bm(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Jt(e){var t=Bm(e,"string");return typeof t=="symbol"?t:t+""}function me(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Bc(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Jt(r.key),r)}}function ve(e,t,n){return t&&Bc(e.prototype,t),n&&Bc(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Qt(e){return Qt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Qt(e)}function Kc(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Kc=function(){return!!e})()}function Km(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Vm(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Km(e)}function Ge(e,t,n){return t=Qt(t),Vm(e,Kc()?Reflect.construct(t,n||[],Qt(e).constructor):t.apply(e,n))}function va(e,t){return va=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},va(e,t)}function Oe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&va(e,t)}function jm(e){if(Array.isArray(e))return e}function qm(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);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 si(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xa(e,t){if(e){if(typeof e=="string")return si(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?si(e,t):void 0}}function Ym(){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 It(e,t){return jm(e)||qm(e,t)||xa(e,t)||Ym()}var ya={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 Vc=new Int8Array(4),wa=new Int32Array(Vc.buffer,0,1),Xm=new Float32Array(Vc.buffer,0,1),Zm=/^\s*rgba?\s*\(/,Qm=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jm(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(Zm.test(e)){var o=e.match(Qm);o&&(t=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:t,g:n,b:r,a:i}}var xn={};for(Jn in ya)xn[Jn]=kn(ya[Jn]),xn[ya[Jn]]=xn[Jn];var Jn;function jc(e,t,n,r,i){return wa[0]=r<<24|n<<16|t<<8|e,i&&(wa[0]=wa[0]&4278190079),Xm[0]}function kn(e){if(e=e.toLowerCase(),typeof xn[e]<"u")return xn[e];var t=Jm(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var a=jc(n,r,i,o,!0);return xn[e]=a,a}var ba={};function ka(e){if(typeof ba[e]<"u")return ba[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=jc(t,n,r,i,!0);return ba[e]=o,o}function _a(e,t,n,r){return n+(t<<8)+(e<<16)}function Ea(e,t,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(e.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(a,s,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var u=It(l,4),c=u[0],h=u[1],d=u[2],p=u[3];return[c,h,d,p]}function R(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?qc(Object(n),!0).forEach(function(r){R(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qc(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ev(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=Qt(e))!==null;);return e}function Ra(){return Ra=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=ev(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Ra.apply(null,arguments)}function td(e,t,n,r){var i=Ra(Qt(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function tv(e){return e.normalized?1:e.size}function Sa(e){var t=0;return e.forEach(function(n){return t+=tv(n)}),t}function nd(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var o=t.getShaderParameter(i,t.COMPILE_STATUS);if(!o){var a=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
21
+ "use strict";(()=>{var Of=Object.create;var js=Object.defineProperty;var Ff=Object.getOwnPropertyDescriptor;var $f=Object.getOwnPropertyNames;var zf=Object.getPrototypeOf,Wf=Object.prototype.hasOwnProperty;var qs=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Uf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $f(t))!Wf.call(e,i)&&i!==n&&js(e,i,{get:()=>t[i],enumerable:!(r=Ff(t,i))||r.enumerable});return e};var Zn=(e,t,n)=>(n=e!=null?Of(zf(e)):{},Uf(t||!e||!e.__esModule?js(n,"default",{value:e,enumerable:!0}):n,e));var Ni=qs((q0,Ha)=>{"use strict";var In=typeof Reflect=="object"?Reflect:null,wd=In&&typeof In.apply=="function"?In.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Ci;In&&typeof In.ownKeys=="function"?Ci=In.ownKeys:Object.getOwnPropertySymbols?Ci=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Ci=function(t){return Object.getOwnPropertyNames(t)};function $v(e){console&&console.warn&&console.warn(e)}var xd=Number.isNaN||function(t){return t!==t};function ie(){ie.init.call(this)}Ha.exports=ie;Ha.exports.once=Hv;ie.EventEmitter=ie;ie.prototype._events=void 0;ie.prototype._eventsCount=0;ie.prototype._maxListeners=void 0;var bd=10;function Li(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(ie,"defaultMaxListeners",{enumerable:!0,get:function(){return bd},set:function(e){if(typeof e!="number"||e<0||xd(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");bd=e}});ie.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};ie.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||xd(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function kd(e){return e._maxListeners===void 0?ie.defaultMaxListeners:e._maxListeners}ie.prototype.getMaxListeners=function(){return kd(this)};ie.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=t==="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[t];if(l===void 0)return!1;if(typeof l=="function")wd(l,this,n);else for(var c=l.length,u=Rd(l,c),r=0;r<c;++r)wd(u[r],this,n);return!0};function _d(e,t,n,r){var i,o,a;if(Li(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=kd(e),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=a.length,$v(s)}return e}ie.prototype.addListener=function(t,n){return _d(this,t,n,!1)};ie.prototype.on=ie.prototype.addListener;ie.prototype.prependListener=function(t,n){return _d(this,t,n,!0)};function zv(){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 Ed(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=zv.bind(r);return i.listener=n,r.wrapFn=i,i}ie.prototype.once=function(t,n){return Li(n),this.on(t,Ed(this,t,n)),this};ie.prototype.prependOnceListener=function(t,n){return Li(n),this.prependListener(t,Ed(this,t,n)),this};ie.prototype.removeListener=function(t,n){var r,i,o,a,s;if(Li(n),i=this._events,i===void 0)return this;if(r=i[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,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():Wv(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};ie.prototype.off=ie.prototype.removeListener;ie.prototype.removeAllListeners=function(t){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[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),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[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this};function Td(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Uv(i):Rd(i,i.length)}ie.prototype.listeners=function(t){return Td(this,t,!0)};ie.prototype.rawListeners=function(t){return Td(this,t,!1)};ie.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Sd.call(e,t)};ie.prototype.listenerCount=Sd;function Sd(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}ie.prototype.eventNames=function(){return this._eventsCount>0?Ci(this._events):[]};function Rd(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Wv(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Uv(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Hv(e,t){return new Promise(function(n,r){function i(a){e.removeListener(t,o),r(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",i),n([].slice.call(arguments))}Ad(e,t,o,{once:!0}),t!=="error"&&Bv(e,i,{once:!0})})}function Bv(e,t,n){typeof e.on=="function"&&Ad(e,"error",t,n)}function Ad(e,t,n,r){if(typeof e.on=="function")r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(o){r.once&&e.removeEventListener(t,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}});var Ba=qs((Z0,Ld)=>{"use strict";Ld.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Zr,te,Js,Hf,Gt,Ys,el,tl,To,Kr,Qn,nl,Ao,So,Ro,Bf,qr={},Yr=[],Kf=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Qr=Array.isArray;function wt(e,t){for(var n in t)e[n]=t[n];return e}function Co(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Vf(e,t,n){var r,i,o,a={};for(o in t)o=="key"?r=t[o]:o=="ref"?i=t[o]:a[o]=t[o];if(arguments.length>2&&(a.children=arguments.length>3?Zr.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)a[o]===void 0&&(a[o]=e.defaultProps[o]);return Vr(e,a,r,i,null)}function Vr(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Js,__i:-1,__u:0};return i==null&&te.vnode!=null&&te.vnode(o),o}function pe(e){return e.children}function jr(e,t){this.props=e,this.context=t}function qt(e,t){if(t==null)return e.__?qt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?qt(e):null}function jf(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=wt({},t);o.__v=t.__v+1,te.vnode&&te.vnode(o),Lo(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??qt(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,sl(r,o,i),t.__e=t.__=null,o.__e!=n&&rl(o)}}function rl(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),rl(e)}function Xs(e){(!e.__d&&(e.__d=!0)&&Gt.push(e)&&!Xr.__r++||Ys!=te.debounceRendering)&&((Ys=te.debounceRendering)||el)(Xr)}function Xr(){try{for(var e,t=1;Gt.length;)Gt.length>t&&Gt.sort(tl),e=Gt.shift(),t=Gt.length,jf(e)}finally{Gt.length=Xr.__r=0}}function il(e,t,n,r,i,o,a,s,l,c,u){var h,d,p,m,v,y,b=r&&r.__k||Yr,w=t.length;for(l=qf(n,t,b,l,w),h=0;h<w;h++)(p=n.__k[h])!=null&&(d=p.__i!=-1&&b[p.__i]||qr,p.__i=h,y=Lo(e,p,d,i,o,a,s,l,c,u),m=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&No(d.ref,null,p),u.push(p.ref,p.__c||m,p)),v==null&&m!=null&&(v=m),4&p.__u?(l=ol(p,l,e),d.__e&&(d.__e=null)):typeof p.type=="function"&&y!==void 0?l=y:m&&(l=m.nextSibling),p.__u&=-7);return n.__e=v,l}function qf(e,t,n,r,i){var o,a,s,l,c,u=n.length,h=u,d=0;for(e.__k=new Array(i),o=0;o<i;o++)(a=t[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[o]=Vr(null,a,null,null,null):Qr(a)?a=e.__k[o]=Vr(pe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=Vr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[o]=a,l=o+d,a.__=e,a.__b=e.__b+1,s=null,(c=a.__i=Yf(a,n,l,h))!=-1&&(h--,(s=n[c])&&(s.__u|=2)),s==null||s.__v==null?(c==-1&&(i>u?d--:i<u&&d++),typeof a.type!="function"&&(a.__u|=4)):c!=l&&(c==l-1?d--:c==l+1?d++:(c>l?d--:d++,a.__u|=4))):e.__k[o]=null;if(h)for(o=0;o<u;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=qt(s)),cl(s,s));return r}function ol(e,t,n){var r,i;if(typeof e.type=="function"){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=ol(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=qt(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Yf(e,t,n,r){var i,o,a,s=e.key,l=e.type,c=t[n],u=c!=null&&(2&c.__u)==0;if(c===null&&s==null||u&&s==c.key&&l==c.type)return n;if(r>(u?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((c=t[a=i>=0?i--:o++])!=null&&(2&c.__u)==0&&s==c.key&&l==c.type)return a}return-1}function Zs(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||Kf.test(t)?n:n+"px"}function Br(e,t,n,r,i){var o,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof r=="string"&&(e.style.cssText=r=""),r)for(t in r)n&&t in n||Zs(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Zs(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(nl,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[Qn]=r[Qn]:(n[Qn]=Ao,e.addEventListener(t,o?Ro:So,o)):e.removeEventListener(t,o?Ro:So,o);else{if(i=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function Qs(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Kr]==null)t[Kr]=Ao++;else if(t[Kr]<n[Qn])return;return n(te.event?te.event(t):t)}}}function Lo(e,t,n,r,i,o,a,s,l,c){var u,h,d,p,m,v,y,b,w,k,_,I,A,D,O,U,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=t.__e=n.__e]),(u=te.__b)&&u(t);e:if(typeof T=="function"){h=a.length;try{if(w=t.props,k=T.prototype&&T.prototype.render,_=(u=T.contextType)&&r[u.__c],I=u?_?_.props.value:u.__:r,n.__c?b=(d=t.__c=n.__c).__=d.__E:(k?t.__c=d=new T(w,I):(t.__c=d=new jr(w,I),d.constructor=T,d.render=Zf),_&&_.sub(d),d.state||(d.state={}),d.__n=r,p=d.__d=!0,d.__h=[],d._sb=[]),k&&d.__s==null&&(d.__s=d.state),k&&T.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=wt({},d.__s)),wt(d.__s,T.getDerivedStateFromProps(w,d.__s))),m=d.props,v=d.state,d.__v=t,p)k&&T.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),k&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(k&&T.getDerivedStateFromProps==null&&w!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(w,I),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(w,d.__s,I)===!1){t.__v!=n.__v&&(d.props=w,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(F){F&&(F.__=t)}),Yr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=qt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(w,d.__s,I),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,v,y)})}if(d.context=I,d.props=w,d.__P=e,d.__e=!1,A=te.__r,D=0,k)d.state=d.__s,d.__d=!1,A&&A(t),u=d.render(d.props,d.state,d.context),Yr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,A&&A(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++D<25);d.state=d.__s,d.getChildContext!=null&&(r=wt(wt({},r),d.getChildContext())),k&&!p&&d.getSnapshotBeforeUpdate!=null&&(y=d.getSnapshotBeforeUpdate(m,v)),O=u!=null&&u.type===pe&&u.key==null?ll(u.props.children):u,s=il(e,Qr(O)?O:[O],t,n,r,i,o,a,s,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),b&&(d.__E=d.__=null)}catch(F){if(a.length=h,t.__v=null,l||o!=null){if(F.then){for(t.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),t.__e=s}else if(o!=null)for(U=o.length;U--;)Co(o[U])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),F.then||al(t),te.__e(F,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Xf(n.__e,t,n,r,i,o,a,l,c);return(u=te.diffed)&&u(t),128&t.__u?void 0:s}function al(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(al))}function sl(e,t,n){for(var r=0;r<n.length;r++)No(n[r],n[++r],n[++r]);te.__c&&te.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){te.__e(o,i.__v)}})}function ll(e){return typeof e!="object"||e==null||e.__b>0?e:Qr(e)?e.map(ll):e.constructor!==void 0?null:wt({},e)}function Xf(e,t,n,r,i,o,a,s,l){var c,u,h,d,p,m,v,y=n.props||qr,b=t.props,w=t.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((p=o[c])&&"setAttribute"in p==!!w&&(w?p.localName==w:p.nodeType==3)){e=p,o[c]=null;break}}if(e==null){if(w==null)return document.createTextNode(b);e=document.createElementNS(i,w,b.is&&b),s&&(te.__m&&te.__m(t,o),s=!1),o=null}if(w==null)y===b||s&&e.data==b||(e.data=b);else{if(o=w=="textarea"&&b.defaultValue!=null?null:o&&Zr.call(e.childNodes),!s&&o!=null)for(y={},c=0;c<e.attributes.length;c++)y[(p=e.attributes[c]).name]=p.value;for(c in y)p=y[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in b||c=="value"&&"defaultValue"in b||c=="checked"&&"defaultChecked"in b||Br(e,c,null,p,i);for(c in b)p=b[c],c=="children"?d=p:c=="dangerouslySetInnerHTML"?u=p:c=="value"?m=p:c=="checked"?v=p:s&&typeof p!="function"||y[c]===p||Br(e,c,p,y[c],i);if(u)s||h&&(u.__html==h.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(h&&(e.innerHTML=""),il(t.type=="template"?e.content:e,Qr(d)?d:[d],t,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&qt(n,0),s,l),o!=null)for(c=o.length;c--;)Co(o[c]);s&&w!="textarea"||(c="value",w=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||w=="progress"&&!m||w=="option"&&m!=y[c])&&Br(e,c,m,y[c],i),c="checked",v!=null&&v!=e[c]&&Br(e,c,v,y[c],i))}return e}function No(e,t,n){try{if(typeof e=="function"){var r=typeof e.__u=="function";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(i){te.__e(i,n)}}function cl(e,t,n){var r,i;if(te.unmount&&te.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||No(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){te.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&cl(r[i],t,n||typeof e.type!="function");n||Co(e.__e),e.__c=e.__=e.__e=void 0}function Zf(e,t,n){return this.constructor(e,n)}function ul(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),te.__&&te.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,o=[],a=[],Lo(t,e=(!r&&n||t).__k=Vf(pe,null,[e]),i||qr,qr,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Zr.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),sl(o,e,a),e.props.children=null}Zr=Yr.slice,te={__e:function(e,t,n,r){for(var i,o,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),a=i.__d),a)return i.__E=i}catch(s){e=s}throw e}},Js=0,Hf=function(e){return e!=null&&e.constructor===void 0},jr.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=wt({},this.state),typeof e=="function"&&(e=e(wt({},n),this.props)),e&&wt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Xs(this))},jr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Xs(this))},jr.prototype.render=pe,Gt=[],el=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,tl=function(e,t){return e.__v.__b-t.__v.__b},Xr.__r=0,To=Math.random().toString(8),Kr="__d"+To,Qn="__a"+To,nl=/(PointerCapture)$|Capture$/i,Ao=0,So=Qs(!1),Ro=Qs(!0),Bf=0;var dl="weave-bootstrap";var Po={cwd:""};function Qf(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function hl(e){if(e===null||e.trim()==="")return Po;let t;try{t=JSON.parse(e)}catch{return Po}return Qf(t)?t:Po}var Yt,he,Do,pl,Jn=0,xl=[],ge=te,fl=ge.__b,gl=ge.__r,ml=ge.diffed,vl=ge.__c,yl=ge.unmount,wl=ge.__;function er(e,t){ge.__h&&ge.__h(he,e,Jn||t),Jn=0;var n=he.__H||(he.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function j(e){return Jn=1,Jf(El,e)}function Jf(e,t,n){var r=er(Yt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):El(void 0,t),function(s){var l=r.__N?r.__N[0]:r.__[0],c=r.t(l,s);l!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=he,!he.__f)){var i=function(s,l,c){if(!r.__c.__H)return!0;var u=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(p){if(p.__N){u=!0;var m=p.__[0];p.__=p.__N,p.__N=void 0,m!==p.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,c);return u?d||h:d}return!u||h};he.__f=!0;var o=he.shouldComponentUpdate,a=he.componentWillUpdate;he.componentWillUpdate=function(s,l,c){if(this.__e){var u=o;o=void 0,i(s,l,c),o=u}a&&a.call(this,s,l,c)},he.shouldComponentUpdate=i}return r.__N||r.__}function le(e,t){var n=er(Yt++,3);!ge.__s&&Go(n.__H,t)&&(n.__=e,n.u=t,he.__H.__h.push(n))}function Ze(e,t){var n=er(Yt++,4);!ge.__s&&Go(n.__H,t)&&(n.__=e,n.u=t,he.__h.push(n))}function Q(e){return Jn=5,ft(function(){return{current:e}},[])}function ft(e,t){var n=er(Yt++,7);return Go(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function kl(e,t){return Jn=8,ft(function(){return e},t)}function _l(){var e=er(Yt++,11);if(!e.__){for(var t=he.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function eg(){for(var e;e=xl.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Jr),t.__h.some(Io),t.__h=[]}catch(n){t.__h=[],ge.__e(n,e.__v)}}}ge.__b=function(e){he=null,fl&&fl(e)},ge.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),wl&&wl(e,t)},ge.__r=function(e){gl&&gl(e),Yt=0;var t=(he=e.__c).__H;t&&(Do===he?(t.__h=[],he.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Jr),t.__h.some(Io),t.__h=[],Yt=0)),Do=he},ge.diffed=function(e){ml&&ml(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(xl.push(t)!==1&&pl===ge.requestAnimationFrame||((pl=ge.requestAnimationFrame)||tg)(eg)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Do=he=null},ge.__c=function(e,t){t.some(function(n){try{n.__h.some(Jr),n.__h=n.__h.filter(function(r){return!r.__||Io(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],ge.__e(r,n.__v)}}),vl&&vl(e,t)},ge.unmount=function(e){yl&&yl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{Jr(r)}catch(i){t=i}}),n.__H=void 0,t&&ge.__e(t,n.__v))};var bl=typeof requestAnimationFrame=="function";function tg(e){var t,n=function(){clearTimeout(r),bl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);bl&&(t=requestAnimationFrame(n))}function Jr(e){var t=he,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),he=t}function Io(e){var t=he;e.__c=e.__(),he=t}function Go(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function El(e,t){return typeof t=="function"?t(e):t}var Tl={bg:"#eff1f5",panel:"#e6e9ef",page:"#dce0e8",raise:"#ccd0da",fg:"#4c4f69",dim:"#56586a",faint:"#606274",line:"#ccd0da","line-strong":"#bcc0cc",accent:"#7113ec",ok:"#28641b",warn:"#7c4f10",bad:"#b20d30"},Sl={bg:"#24273a",panel:"#1e2030",page:"#181926",raise:"#363a4f",fg:"#cad3f5",dim:"#a5adcb",faint:"#939ab7",line:"#363a4f","line-strong":"#494d64",accent:"#c6a0f6",ok:"#a6da95",warn:"#eed49f",bad:"#ed8796"},ue={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:Tl},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Tl,accent:"#1750bf"}},"frappe-teal":{name:"Catppuccin Frappé · Teal",scheme:"dark",colors:{bg:"#303446",panel:"#292c3c",page:"#232634",raise:"#414559",fg:"#c6d0f5",dim:"#b5bfe2",faint:"#a5adce",line:"#414559","line-strong":"#51576d",accent:"#81c8be",ok:"#a6d189",warn:"#e5c890",bad:"#f4a4a6"}},dark:{name:"Catppuccin Macchiato · Mauve",scheme:"dark",colors:Sl},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Sl,accent:"#f5a97f"}},"mocha-lavender":{name:"Catppuccin Mocha · Lavender",scheme:"dark",colors:{bg:"#1e1e2e",panel:"#181825",page:"#11111b",raise:"#313244",fg:"#cdd6f4",dim:"#a6adc8",faint:"#9399b2",line:"#313244","line-strong":"#45475a",accent:"#b4befe",ok:"#a6e3a1",warn:"#f9e2af",bad:"#f38ba8"}},"paper-blue":{name:"Paper · Blue",scheme:"light",colors:{bg:"#f4f6f8",panel:"#e9edf2",page:"#ffffff",raise:"#dce3eb",fg:"#182334",dim:"#42536a",faint:"#526176",line:"#dce3eb","line-strong":"#bac6d4",accent:"#174ea6",ok:"#21623b",warn:"#805300",bad:"#a3223c"}},"ink-blue":{name:"Ink · Blue",scheme:"dark",colors:{bg:"#1b2430",panel:"#141c27",page:"#101720",raise:"#2b3748",fg:"#edf2f8",dim:"#becadc",faint:"#a5b5cb",line:"#2b3748","line-strong":"#46566d",accent:"#8bbcff",ok:"#91d5a5",warn:"#edc47b",bad:"#ff9fae"}},"sand-amber":{name:"Sand · Amber",scheme:"light",colors:{bg:"#f7f3ec",panel:"#ede6da",page:"#fffdf8",raise:"#e2d8c8",fg:"#30291f",dim:"#5b4e3f",faint:"#675847",line:"#e2d8c8","line-strong":"#c7b8a2",accent:"#814500",ok:"#365c2a",warn:"#795000",bad:"#a12c32"}},"ember-amber":{name:"Ember · Amber",scheme:"dark",colors:{bg:"#29231f",panel:"#211c19",page:"#191512",raise:"#3c322b",fg:"#f3e9dc",dim:"#d0bfab",faint:"#bfa991",line:"#3c322b","line-strong":"#5c4d40",accent:"#edb96b",ok:"#b5cf8a",warn:"#efc57a",bad:"#f69a91"}},"mist-teal":{name:"Mist · Teal",scheme:"light",colors:{bg:"#eff5f3",panel:"#e1ece8",page:"#fafffd",raise:"#d2e2dc",fg:"#18342e",dim:"#3c5b52",faint:"#48655b",line:"#d2e2dc","line-strong":"#acc5bc",accent:"#006457",ok:"#2a5e35",warn:"#795300",bad:"#a52a43"}},"forest-teal":{name:"Forest · Teal",scheme:"dark",colors:{bg:"#1c2b27",panel:"#16221e",page:"#101b17",raise:"#2b4038",fg:"#e6f2ec",dim:"#b8d0c4",faint:"#a2bfb0",line:"#2b4038","line-strong":"#456255",accent:"#7cd8bb",ok:"#a5d6a0",warn:"#e6c582",bad:"#f5a2ac"}}},Rl=["system",...Object.keys(ue)];function kn(e){return typeof e=="string"&&Rl.includes(e)}var Xt={mauve:{name:"Mauve",light:"#7113ec",dark:"#cba9f8"},blue:{name:"Blue",light:"#1750bf",dark:"#8bbcff"},teal:{name:"Teal",light:"#006457",dark:"#7cd8bb"},peach:{name:"Peach",light:"#814500",dark:"#f5a97f"},rose:{name:"Rose",light:"#a52a43",dark:"#f4a4a6"},green:{name:"Green",light:"#28641b",dark:"#a6da95"},amber:{name:"Amber",light:"#775000",dark:"#edb96b"},lavender:{name:"Lavender",light:"#445198",dark:"#b4befe"}};function ei(e){return typeof e=="string"?e:e.theme}function Al(e,t){return t==="theme"?ue[e].colors.accent:Xt[t][ue[e].scheme]}function Cl(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Ll(this.cover(t,n),t,n,e)}function Ll(e,t,n,r){if(isNaN(t)||isNaN(n))return e;var i,o=e._root,a={data:r},s=e._x0,l=e._y0,c=e._x1,u=e._y1,h,d,p,m,v,y,b,w;if(!o)return e._root=a,e;for(;o.length;)if((v=t>=(h=(s+c)/2))?s=h:c=h,(y=n>=(d=(l+u)/2))?l=d:u=d,i=o,!(o=o[b=y<<1|v]))return i[b]=a,e;if(p=+e._x.call(null,o.data),m=+e._y.call(null,o.data),t===p&&n===m)return a.next=o,i?i[b]=a:e._root=a,e;do i=i?i[b]=new Array(4):e._root=new Array(4),(v=t>=(h=(s+c)/2))?s=h:c=h,(y=n>=(d=(l+u)/2))?l=d:u=d;while((b=y<<1|v)===(w=(m>=d)<<1|p>=h));return i[w]=o,i[b]=a,e}function Nl(e){var t,n,r=e.length,i,o,a=new Array(r),s=new Array(r),l=1/0,c=1/0,u=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,t=e[n]))||isNaN(o=+this._y.call(null,t))||(a[n]=i,s[n]=o,i<l&&(l=i),i>u&&(u=i),o<c&&(c=o),o>h&&(h=o));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<r;++n)Ll(this,a[n],s[n],e[n]);return this}function Pl(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(e))+1,o=(r=Math.floor(t))+1;else{for(var a=i-n||1,s=this._root,l,c;n>e||e>=i||r>t||t>=o;)switch(c=(t<r)<<1|e<n,l=new Array(4),l[c]=s,s=l,a*=2,c){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 Dl(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Il(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Se(e,t,n,r,i){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=i}function Gl(e,t,n){var r,i=this._x0,o=this._y0,a,s,l,c,u=this._x1,h=this._y1,d=[],p=this._root,m,v;for(p&&d.push(new Se(p,i,o,u,h)),n==null?n=1/0:(i=e-n,o=t-n,u=e+n,h=t+n,n*=n);m=d.pop();)if(!(!(p=m.node)||(a=m.x0)>u||(s=m.y0)>h||(l=m.x1)<i||(c=m.y1)<o))if(p.length){var y=(a+l)/2,b=(s+c)/2;d.push(new Se(p[3],y,b,l,c),new Se(p[2],a,b,y,c),new Se(p[1],y,s,l,b),new Se(p[0],a,s,y,b)),(v=(t>=b)<<1|e>=y)&&(m=d[d.length-1],d[d.length-1]=d[d.length-1-v],d[d.length-1-v]=m)}else{var w=e-+this._x.call(null,p.data),k=t-+this._y.call(null,p.data),_=w*w+k*k;if(_<n){var I=Math.sqrt(n=_);i=e-I,o=t-I,u=e+I,h=t+I,r=p.data}}return r}function Ml(e){if(isNaN(u=+this._x.call(null,e))||isNaN(h=+this._y.call(null,e)))return this;var t,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,c=this._y1,u,h,d,p,m,v,y,b;if(!n)return this;if(n.length)for(;;){if((m=u>=(d=(a+l)/2))?a=d:l=d,(v=h>=(p=(s+c)/2))?s=p:c=p,t=n,!(n=n[y=v<<1|m]))return this;if(!n.length)break;(t[y+1&3]||t[y+2&3]||t[y+3&3])&&(r=t,b=y)}for(;n.data!==e;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):t?(o?t[y]=o:delete t[y],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(r?r[b]=n:this._root=n),this):(this._root=o,this)}function Ol(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Fl(){return this._root}function $l(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function zl(e){var t=[],n,r=this._root,i,o,a,s,l;for(r&&t.push(new Se(r,this._x0,this._y0,this._x1,this._y1));n=t.pop();)if(!e(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var c=(o+s)/2,u=(a+l)/2;(i=r[3])&&t.push(new Se(i,c,u,s,l)),(i=r[2])&&t.push(new Se(i,o,u,c,l)),(i=r[1])&&t.push(new Se(i,c,a,s,u)),(i=r[0])&&t.push(new Se(i,o,a,c,u))}return this}function Wl(e){var t=[],n=[],r;for(this._root&&t.push(new Se(this._root,this._x0,this._y0,this._x1,this._y1));r=t.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,c=r.y1,u=(a+l)/2,h=(s+c)/2;(o=i[0])&&t.push(new Se(o,a,s,u,h)),(o=i[1])&&t.push(new Se(o,u,s,l,h)),(o=i[2])&&t.push(new Se(o,a,h,u,c)),(o=i[3])&&t.push(new Se(o,u,h,l,c))}n.push(r)}for(;r=n.pop();)e(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Ul(e){return e[0]}function Hl(e){return arguments.length?(this._x=e,this):this._x}function Bl(e){return e[1]}function Kl(e){return arguments.length?(this._y=e,this):this._y}function Zt(e,t,n){var r=new Mo(t??Ul,n??Bl,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function Mo(e,t,n,r,i,o){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Vl(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ie=Zt.prototype=Mo.prototype;Ie.copy=function(){var e=new Mo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,n,r;if(!t)return e;if(!t.length)return e._root=Vl(t),e;for(n=[{source:t,target:e._root=new Array(4)}];t=n.pop();)for(var i=0;i<4;++i)(r=t.source[i])&&(r.length?n.push({source:r,target:t.target[i]=new Array(4)}):t.target[i]=Vl(r));return e};Ie.add=Cl;Ie.addAll=Nl;Ie.cover=Pl;Ie.data=Dl;Ie.extent=Il;Ie.find=Gl;Ie.remove=Ml;Ie.removeAll=Ol;Ie.root=Fl;Ie.size=$l;Ie.visit=zl;Ie.visitAfter=Wl;Ie.x=Hl;Ie.y=Kl;function ve(e){return function(){return e}}function ot(e){return(e()-.5)*1e-6}function ng(e){return e.x+e.vx}function rg(e){return e.y+e.vy}function Oo(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=ve(e==null?1:+e));function a(){for(var c,u=t.length,h,d,p,m,v,y,b=0;b<o;++b)for(h=Zt(t,ng,rg).visitAfter(s),c=0;c<u;++c)d=t[c],v=n[d.index],y=v*v,p=d.x+d.vx,m=d.y+d.vy,h.visit(w);function w(k,_,I,A,D){var O=k.data,U=k.r,T=v+U;if(O){if(O.index>d.index){var F=p-O.x-O.vx,K=m-O.y-O.vy,Z=F*F+K*K;Z<T*T&&(F===0&&(F=ot(r),Z+=F*F),K===0&&(K=ot(r),Z+=K*K),Z=(T-(Z=Math.sqrt(Z)))/Z*i,d.vx+=(F*=Z)*(T=(U*=U)/(y+U)),d.vy+=(K*=Z)*T,O.vx-=F*(T=1-T),O.vy-=K*T)}return}return _>p+T||A<p-T||I>m+T||D<m-T}}function s(c){if(c.data)return c.r=n[c.data.index];for(var u=c.r=0;u<4;++u)c[u]&&c[u].r>c.r&&(c.r=c[u].r)}function l(){if(t){var c,u=t.length,h;for(n=new Array(u),c=0;c<u;++c)h=t[c],n[h.index]=+e(h,c,t)}}return a.initialize=function(c,u){t=c,r=u,l()},a.iterations=function(c){return arguments.length?(o=+c,a):o},a.strength=function(c){return arguments.length?(i=+c,a):i},a.radius=function(c){return arguments.length?(e=typeof c=="function"?c:ve(+c),l(),a):e},a}function ig(e){return e.index}function jl(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function Fo(e){var t=ig,n=h,r,i=ve(30),o,a,s,l,c,u=1;e==null&&(e=[]);function h(y){return 1/Math.min(s[y.source.index],s[y.target.index])}function d(y){for(var b=0,w=e.length;b<u;++b)for(var k=0,_,I,A,D,O,U,T;k<w;++k)_=e[k],I=_.source,A=_.target,D=A.x+A.vx-I.x-I.vx||ot(c),O=A.y+A.vy-I.y-I.vy||ot(c),U=Math.sqrt(D*D+O*O),U=(U-o[k])/U*y*r[k],D*=U,O*=U,A.vx-=D*(T=l[k]),A.vy-=O*T,I.vx+=D*(T=1-T),I.vy+=O*T}function p(){if(a){var y,b=a.length,w=e.length,k=new Map(a.map((I,A)=>[t(I,A,a),I])),_;for(y=0,s=new Array(b);y<w;++y)_=e[y],_.index=y,typeof _.source!="object"&&(_.source=jl(k,_.source)),typeof _.target!="object"&&(_.target=jl(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(y=0,l=new Array(w);y<w;++y)_=e[y],l[y]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(w),m(),o=new Array(w),v()}}function m(){if(a)for(var y=0,b=e.length;y<b;++y)r[y]=+n(e[y],y,e)}function v(){if(a)for(var y=0,b=e.length;y<b;++y)o[y]=+i(e[y],y,e)}return d.initialize=function(y,b){a=y,c=b,p()},d.links=function(y){return arguments.length?(e=y,p(),d):e},d.id=function(y){return arguments.length?(t=y,d):t},d.iterations=function(y){return arguments.length?(u=+y,d):u},d.strength=function(y){return arguments.length?(n=typeof y=="function"?y:ve(+y),m(),d):n},d.distance=function(y){return arguments.length?(i=typeof y=="function"?y:ve(+y),v(),d):i},d}var og={value:()=>{}};function Yl(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ti(n)}function ti(e){this._=e}function ag(e,t){return e.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&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ti.prototype=Yl.prototype={constructor:ti,on:function(e,t){var n=this._,r=ag(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=sg(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=ql(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ql(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ti(e)},call:function(e,t){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(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function sg(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ql(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=og,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var $o=Yl;var _n=0,nr=0,tr=0,Zl=1e3,ni,rr,ri=0,Qt=0,ii=0,ir=typeof performance=="object"&&performance.now?performance:Date,Ql=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uo(){return Qt||(Ql(lg),Qt=ir.now()+ii)}function lg(){Qt=0}function zo(){this._call=this._time=this._next=null}zo.prototype=oi.prototype={constructor:zo,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Uo():+n)+(t==null?0:+t),!this._next&&rr!==this&&(rr?rr._next=this:ni=this,rr=this),this._call=e,this._time=n,Wo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wo())}};function oi(e,t,n){var r=new zo;return r.restart(e,t,n),r}function Jl(){Uo(),++_n;for(var e=ni,t;e;)(t=Qt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_n}function Xl(){Qt=(ri=ir.now())+ii,_n=nr=0;try{Jl()}finally{_n=0,ug(),Qt=0}}function cg(){var e=ir.now(),t=e-ri;t>Zl&&(ii-=t,ri=e)}function ug(){for(var e,t=ni,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ni=n);rr=e,Wo(r)}function Wo(e){if(!_n){nr&&(nr=clearTimeout(nr));var t=e-Qt;t>24?(e<1/0&&(nr=setTimeout(Xl,e-ir.now()-ii)),tr&&(tr=clearInterval(tr))):(tr||(ri=ir.now(),tr=setInterval(cg,Zl)),_n=1,Ql(Xl))}}function ec(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function tc(e){return e.x}function nc(e){return e.y}var dg=10,hg=Math.PI*(3-Math.sqrt(5));function Ho(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=oi(h),c=$o("tick","end"),u=ec();e==null&&(e=[]);function h(){d(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function d(v){var y,b=e.length,w;v===void 0&&(v=1);for(var k=0;k<v;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),y=0;y<b;++y)w=e[y],w.fx==null?w.x+=w.vx*=a:(w.x=w.fx,w.vx=0),w.fy==null?w.y+=w.vy*=a:(w.y=w.fy,w.vy=0);return t}function p(){for(var v=0,y=e.length,b;v<y;++v){if(b=e[v],b.index=v,b.fx!=null&&(b.x=b.fx),b.fy!=null&&(b.y=b.fy),isNaN(b.x)||isNaN(b.y)){var w=dg*Math.sqrt(.5+v),k=v*hg;b.x=w*Math.cos(k),b.y=w*Math.sin(k)}(isNaN(b.vx)||isNaN(b.vy))&&(b.vx=b.vy=0)}}function m(v){return v.initialize&&v.initialize(e,u),v}return p(),t={tick:d,restart:function(){return l.restart(h),t},stop:function(){return l.stop(),t},nodes:function(v){return arguments.length?(e=v,p(),s.forEach(m),t):e},alpha:function(v){return arguments.length?(n=+v,t):n},alphaMin:function(v){return arguments.length?(r=+v,t):r},alphaDecay:function(v){return arguments.length?(i=+v,t):+i},alphaTarget:function(v){return arguments.length?(o=+v,t):o},velocityDecay:function(v){return arguments.length?(a=1-v,t):1-a},randomSource:function(v){return arguments.length?(u=v,s.forEach(m),t):u},force:function(v,y){return arguments.length>1?(y==null?s.delete(v):s.set(v,m(y)),t):s.get(v)},find:function(v,y,b){var w=0,k=e.length,_,I,A,D,O;for(b==null?b=1/0:b*=b,w=0;w<k;++w)D=e[w],_=v-D.x,I=y-D.y,A=_*_+I*I,A<b&&(O=D,b=A);return O},on:function(v,y){return arguments.length>1?(c.on(v,y),t):c.on(v)}}}function Bo(){var e,t,n,r,i=ve(-30),o,a=1,s=1/0,l=.81;function c(p){var m,v=e.length,y=Zt(e,tc,nc).visitAfter(h);for(r=p,m=0;m<v;++m)t=e[m],y.visit(d)}function u(){if(e){var p,m=e.length,v;for(o=new Array(m),p=0;p<m;++p)v=e[p],o[v.index]=+i(v,p,e)}}function h(p){var m=0,v,y,b=0,w,k,_;if(p.length){for(w=k=_=0;_<4;++_)(v=p[_])&&(y=Math.abs(v.value))&&(m+=v.value,b+=y,w+=y*v.x,k+=y*v.y);p.x=w/b,p.y=k/b}else{v=p,v.x=v.data.x,v.y=v.data.y;do m+=o[v.data.index];while(v=v.next)}p.value=m}function d(p,m,v,y){if(!p.value)return!0;var b=p.x-t.x,w=p.y-t.y,k=y-m,_=b*b+w*w;if(k*k/l<_)return _<s&&(b===0&&(b=ot(n),_+=b*b),w===0&&(w=ot(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),t.vx+=b*p.value*r/_,t.vy+=w*p.value*r/_),!0;if(p.length||_>=s)return;(p.data!==t||p.next)&&(b===0&&(b=ot(n),_+=b*b),w===0&&(w=ot(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do p.data!==t&&(k=o[p.data.index]*r/_,t.vx+=b*k,t.vy+=w*k);while(p=p.next)}return c.initialize=function(p,m){e=p,n=m,u()},c.strength=function(p){return arguments.length?(i=typeof p=="function"?p:ve(+p),u(),c):i},c.distanceMin=function(p){return arguments.length?(a=p*p,c):Math.sqrt(a)},c.distanceMax=function(p){return arguments.length?(s=p*p,c):Math.sqrt(s)},c.theta=function(p){return arguments.length?(l=p*p,c):Math.sqrt(l)},c}function Ko(e){var t=ve(.1),n,r,i;typeof e!="function"&&(e=ve(e==null?0:+e));function o(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vx+=(i[l]-u.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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:ve(+s),a(),o):t},o.x=function(s){return arguments.length?(e=typeof s=="function"?s:ve(+s),a(),o):e},o}function Vo(e){var t=ve(.1),n,r,i;typeof e!="function"&&(e=ve(e==null?0:+e));function o(s){for(var l=0,c=n.length,u;l<c;++l)u=n[l],u.vy+=(i[l]-u.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]=+e(n[s],s,n))?0:+t(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(t=typeof s=="function"?s:ve(+s),a(),o):t},o.y=function(s){return arguments.length?(e=typeof s=="function"?s:ve(+s),a(),o):e},o}var pg=9,ai=6,si=18,fg=32,oc=9,or=pg+oc;function jo(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+fg));return ai+(si-ai)*n}function qo(e){return e+oc}var gg=300,ac=1,rc=.001,Qe={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},Jt={...Qe};function sc(e){Object.assign(Qe,e)}function ic(e){return e==="contains"||e==="anchored-at"}function mg(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function vg(e){let t=[],n=new Set;for(let o of e.nodes)n.has(o.id)||(n.add(o.id),t.push(o.id));let r=[],i=new Set;for(let o of e.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:t,edges:r}}function Yo(e){let t=Fo(e.links).id(n=>n.id).distance(n=>ic(n.kind)?Qe.containsRest:Qe.relationDistance).strength(n=>ic(n.kind)?Qe.containsStrength:Qe.relationStrength).iterations(2);return Ho(e.nodes).randomSource(mg(e.seed??ac)).force("charge",Bo().strength(Qe.charge).distanceMax(Qe.chargeMax)).force("link",t).force("collide",Oo(n=>n.r??or).strength(1)).force("x",Ko(0).strength(Qe.center)).force("y",Vo(0).strength(Qe.center)).stop()}function yg(e,t,n){let r=Yo({nodes:e,links:t.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(rc).alphaDecay(n.ticks>0?1-Math.pow(rc,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function lc(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??gg)),{ids:r,edges:i}=vg(e),o=r.map(l=>{let c=t.initial?.get(l),u={id:l,vx:0,vy:0};return c!==void 0&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&(u.x=c.x,u.y=c.y,t.pinWarm===!0&&(u.fx=c.x,u.fy=c.y)),u}),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=qo(jo(a.get(l.id)??0));o.length>1&&yg(o,i,{ticks:n,seed:t.seed??ac,warm:t.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 En=[{key:"containsStrength",label:"Group cohesion",hint:"how hard a parent holds its children — group cohesion",min:0,max:1,step:.01},{key:"containsRest",label:"Group radius",hint:"how far children sit from their parent — rosette radius",min:10,max:300,step:5},{key:"relationStrength",label:"Link strength",hint:"pull of links-to / mentions across groups",min:0,max:1,step:.01},{key:"relationDistance",label:"Link distance",hint:"how long those cross-group springs are",min:20,max:600,step:10},{key:"charge",label:"Repulsion",hint:"node-to-node repulsion — more negative pushes harder",min:-1200,max:0,step:10},{key:"chargeMax",label:"Repulsion range",hint:"distance past which repulsion stops — caps overall spread",min:100,max:4e3,step:50},{key:"center",label:"Center gravity",hint:"pull toward the origin — too much makes one blob",min:0,max:.3,step:.005}],Mt={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...Jt}};function cc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function uc(e){if(!cc(e))return null;let n=!Object.hasOwn(e,"lightTheme")&&!Object.hasOwn(e,"darkTheme")?{...e,lightTheme:"light",darkTheme:"dark"}:e;if(Object.keys(n).length!==Object.keys(Mt).length)return null;for(let i of["light","dark"]){let o=n[`${i}Theme`];if(!kn(o)||o==="system"||ue[o].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(Xt,n.accent))||typeof n.fontSize!="number"||!Number.isInteger(n.fontSize)||n.fontSize<12||n.fontSize>22)return null;for(let i of["readable","spellcheck","defaultEdit","focusNewTabs","groupColors"])if(typeof n[i]!="boolean")return null;if(n.startup!=="restore"&&n.startup!=="empty")return null;let r=n.forces;if(!cc(r)||Object.keys(r).length!==En.length)return null;for(let{key:i,min:o,max:a}of En){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<o||s>a)return null}return n}var ui=40,dc=100,wg=1e9,Sn=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function Jo(){return{version:1,panes:[{id:"pane-1",tabs:[Sn("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,treeWidth:240,contextWidth:240,theme:"system",preferences:Mt}}function ar(e){return e.panes.find(t=>t.id===e.activePane)}function Rn(e){let t=ar(e);return t.tabs.find(n=>n.id===t.activeTab)}function bt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function Ot(e,t){let n=new Set(e.panes.flatMap(i=>[i.id,...i.tabs.map(o=>o.id)])),r=1;for(;n.has(`${t}-${r}`);)r++;return`${t}-${r}`}function en(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?ci({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function ea(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function ci(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??ea(e);return r?{...n,lastDocumentTab:r.id}:n}function hc(e){if(Rn(e).kind==="document")return e;let t=ar(e),n=ea(t);return n?en(e,t,n):sr(e,null,{newTab:!0})}function di(e,t,n){let r=e.panes.find(o=>o.id===t),i=r?.tabs.find(o=>o.id===n);return r&&i?{pane:r,tab:i}:null}function Qo(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=ui?e:en(e,{...t,tabs:[...t.tabs,n]},n)}function Xo(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>dc&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function sr(e,t,n={}){let r=e.panes.find(s=>s.id===(n.paneId??e.activePane));if(!r)return e;let i=r.activeTab,o=r.tabs.find(s=>s.id===i);if(o?.kind==="graph"&&(o=ea(r),o?r={...r,activeTab:o.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!o)return Qo(e,r,Xo(Sn(Ot(e,"tab")),t));let a=Xo(o,t);return a===o&&r.id===e.activePane&&i===o.id?e:en(e,r,a)}function ta(e){let t=e.panes.flatMap(r=>r.tabs.filter(i=>i.kind==="graph").map(i=>({pane:r,tab:i})))[0];if(t)return t.pane.id===e.activePane&&t.pane.activeTab===t.tab.id?e:en(e,t.pane,t.tab);let n=ar(e);return Qo(e,n,{id:Ot(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function na(e,t,n){let r=di(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:en(e,r.pane,r.tab)}function ra(e,t,n){let r=di(e,t,n);if(!r)return e;let{pane:i}=r;if(i.tabs.length===1){let c=e.panes.find(h=>h.id!==t);if(c)return{...e,panes:[c],activePane:c.id};let u=Sn(Ot(e,"tab"));return en(e,{...i,tabs:[u]},u)}let o=i.tabs.filter(c=>c.id!==n),a=i.activeTab===n,s=o[Math.max(0,i.tabs.findIndex(c=>c.id===n)-1)],l=ci({...i,tabs:o,activeTab:a?s.id:i.activeTab});return{...e,activePane:a?t:e.activePane,panes:e.panes.map(c=>c.id===t?l:c)}}function ia(e,t,n){let r=e.panes.find(a=>a.id===t),i=r?.tabs.find(a=>a.id===r.activeTab);if(!r||!i||i.kind!=="document")return e;let o=i.cursor+n;return o<0||o>=i.history.length?e:en(e,r,{...i,cursor:o,scroll:0})}function oa(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};if(e.panes.reduce((o,a)=>o+a.tabs.length,0)>=ui)return e;let n=Rn(e),r=Ot(e,"pane"),i=Sn(Ot(e,"tab"));return n.kind==="document"&&(i={...n,id:i.id,history:[...n.history],scroll:n.scroll}),{...e,panes:[...e.panes,{id:r,tabs:[i],activeTab:i.id}],activePane:r,split:t}}function pc(e,t){if(e.panes.length!==2||!e.panes.some(i=>i.id===t))return e;let n=e.panes.find(i=>i.id===t),r=e.panes.find(i=>i.id!==t);return{...e,panes:[{...r,tabs:[...r.tabs,...n.tabs]}],activePane:r.id}}function aa(e,t,n,r){let i=di(e,t,n);if(!i||r===n||r!==null&&!i.pane.tabs.some(a=>a.id===r))return e;let o=i.pane.tabs.filter(a=>a.id!==n);return o.splice(r===null?o.length:o.findIndex(a=>a.id===r),0,i.tab),o.every((a,s)=>a===i.pane.tabs[s])?e:{...e,panes:e.panes.map(a=>a.id===t?{...a,tabs:o}:a)}}function hi(e,t,n){return e.panes.some(r=>r.id===t)?e.panes.find(r=>r.id!==t&&r.tabs.some(i=>i.id===n))?.id??null:null}function sa(e,t,n){let r=di(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:Ot(e,"pane"),tabs:[],activeTab:""},o=r.pane.tabs.filter(u=>u.id!==n),a=ci({...i,tabs:[...i.tabs,r.tab],activeTab:r.tab.id});if(!o.length&&e.panes.length===2)return{...e,panes:[a],activePane:i.id};if(!o.length&&e.panes.reduce((u,h)=>u+h.tabs.length,0)>=ui)return e;let s=o.length?null:Sn(Ot(e,"tab")),l=o.length?o:[s],c=ci({...r.pane,tabs:l,activeTab:r.pane.activeTab===n?l[Math.max(0,r.pane.tabs.findIndex(u=>u.id===n)-1)].id:r.pane.activeTab});return{...e,activePane:i.id,panes:e.panes.length===1?[c,a]:e.panes.map(u=>u.id===c.id?c:a)}}function Zo(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function li(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tn(e,t){return typeof e=="string"&&e.length<=2048&&(t===void 0?e.length>0&&!/[\u0000-\u001f\u007f]/.test(e):new RegExp(`^${t}-[1-9][0-9]{0,8}$`).test(e))}function fc(e){if(!li(e)||!Zo(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme",...Object.hasOwn(e,"preferences")?["preferences"]:[]])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!Tn(e.activePane,"pane")||e.split!=="right"&&e.split!=="down"||typeof e.ratio!="number"||!Number.isFinite(e.ratio)||e.ratio<.1||e.ratio>.9||typeof e.treeVisible!="boolean"||typeof e.contextVisible!="boolean"||typeof e.treeWidth!="number"||!Number.isFinite(e.treeWidth)||e.treeWidth<120||e.treeWidth>800||typeof e.contextWidth!="number"||!Number.isFinite(e.contextWidth)||e.contextWidth<120||e.contextWidth>800||!kn(e.theme))return null;let t=Object.hasOwn(e,"preferences")?uc(e.preferences):Mt;if(t===null)return null;let n=e.preferences;e.theme!=="system"&&(!li(n)||!Object.hasOwn(n,"lightTheme"))&&(t={...t,[`${ue[e.theme].scheme}Theme`]:e.theme});let r=new Set,i=0,o=0,a=[];for(let s of e.panes){if(!li(s)||!Zo(s,Object.hasOwn(s,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!Tn(s.id,"pane")||!Array.isArray(s.tabs)||s.tabs.length<1||!Tn(s.activeTab,"tab")||r.has(s.id))return null;r.add(s.id);let l=[],c=!1;for(let h of s.tabs){if(!li(h)||!Zo(h,["id","kind","history","cursor","scroll"])||!Tn(h.id,"tab")||r.has(h.id)||(r.add(h.id),h.kind!=="document"&&h.kind!=="graph"))return null;let d=h.kind;if(!Array.isArray(h.history)||h.history.length<1||h.history.length>dc||!Number.isInteger(h.cursor)||h.cursor<0||h.cursor>=h.history.length||h.history.some(p=>p!==null&&!Tn(p))||typeof h.scroll!="number"||!Number.isFinite(h.scroll)||h.scroll<0||h.scroll>wg)return null;d==="graph"&&o++,i++,h.id===s.activeTab&&(c=!0),l.push({id:h.id,kind:d,history:h.history,cursor:h.cursor,scroll:h.scroll})}if(!c)return null;let u=s.lastDocumentTab;if(Object.hasOwn(s,"lastDocumentTab")&&(!Tn(u,"tab")||!l.some(h=>h.id===u&&h.kind==="document")))return null;a.push({id:s.id,tabs:l,activeTab:s.activeTab,...typeof u=="string"?{lastDocumentTab:u}:{}})}return i>ui||o>1||!a.some(s=>s.id===e.activePane)?null:{version:1,panes:a,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,treeWidth:e.treeWidth,contextWidth:e.contextWidth,theme:e.theme,preferences:t}}function gc(e){if(e.preferences.startup==="restore")return e;let t=Jo();return{...e,panes:t.panes,activePane:t.activePane}}function mc(e,t,n={}){let r=sr(e,t,n);return!n.newTab||e.preferences.focusNewTabs?r:{...r,activePane:e.activePane,panes:r.panes.map(i=>{let o=e.panes.find(l=>l.id===i.id),{lastDocumentTab:a,...s}=i;return{...s,activeTab:o.activeTab,...o.lastDocumentTab?{lastDocumentTab:o.lastDocumentTab}:{}}})}}var Ge=(e,t)=>fetch(e,{...t?.method===void 0?{}:{method:t.method},...t?.headers===void 0?{}:{headers:t.headers},...t?.body===void 0?{}:{body:t.body},...t?.signal===void 0?{}:{signal:t.signal},credentials:"same-origin"});function la(e,t=!1){return{ok:!0,data:e,cached:t}}function xt(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function vc(e){return e===403?"auth":e===404?"missing":"server"}function yc(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function pi(e,t,n,r){let i;try{i=await e(t,r)}catch(a){return xt("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return xt(vc(i.status),i.status,yc(i.status));let o;try{o=await i.json()}catch{return xt("malformed",i.status,"response was not valid JSON")}return n(o)?la(o):xt("malformed",i.status,"response did not match the expected shape")}function kt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bg(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function xg(e){if(!kt(e)||typeof e.stamp!="string")return!1;let t=e.model;return!kt(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:kt(e.tags)&&kt(e.dangling)}function kg(e){if(!kt(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return bg(e.tags)}function _g(e){return kt(e)&&kg(e.note)}function Eg(e){return kt(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function Tg(e){return kt(e)&&typeof e.opened=="boolean"}function Sg(e){return kt(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}async function wc(e,t=null){let n=t===null?void 0:{"if-none-match":`"${t.stamp}"`},r;try{r=await e("/api/graph",n===void 0?{}:{headers:n})}catch(o){return xt("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return t===null?xt("malformed",304,"server sent 304 for an unconditional request"):la(t,!0);if(!r.ok)return xt(vc(r.status),r.status,yc(r.status));let i;try{i=await r.json()}catch{return xt("malformed",r.status,"response was not valid JSON")}return xg(i)?la(i):xt("malformed",r.status,"response did not match the expected shape")}function ca(e,t){return pi(e,`/api/note/${encodeURIComponent(t)}`,_g)}function bc(e,t,n){return pi(e,`/api/search?q=${encodeURIComponent(t)}`,Eg,n===void 0?void 0:{signal:n})}function xc(e,t){return pi(e,"/api/open",Tg,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function tn(e,t,n,r){return pi(e,t,Sg,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var fi=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,ua=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,kc=(e,t,n)=>tn(e,fi(t),"POST",{body:n}),_c=(e,t,n)=>tn(e,fi(t,"/rename"),"POST",{name:n}),Ec=(e,t,n)=>tn(e,fi(t,"/move"),"POST",{folder:n}),Tc=(e,t)=>tn(e,fi(t),"DELETE"),Sc=(e,t)=>tn(e,ua(t),"POST"),Rc=(e,t,n)=>tn(e,ua(t,"/rename"),"POST",{name:n}),Ac=(e,t)=>tn(e,ua(t),"DELETE");function Ke(e){if(e.kind==="external"&&e.detail.url){let t=e.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(t)return t}return e.kind==="package"&&e.detail.manifest?`${e.label} (${e.detail.manifest})`:e.label}function Rg(e){let t=new Map;for(let l of e.nodes)t.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of e.edges){if(l.kind==="contains"){let c=n.get(l.source);c?c.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let c=r.get(l.source);c?c.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let c=l.detail.path,u=null,h=0,d=n.get("repository")??[];for(let p of d){let m=t.get(p);if(m&&m.kind==="module"&&m.detail.path){let v=m.detail.path;c.startsWith(v+"/")&&v.length>h&&(u=p,h=v.length)}}return u},a=new Map;for(let l of e.nodes){if(l.kind!=="entryPoint")continue;let c=o(l);if(c){let u=a.get(c);u?u.push(l.id):a.set(c,[l.id])}}let s=e.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:t,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function Nc(e){let t=new Set;for(let n of e.edges)(n.kind==="contains"||n.kind==="anchored-at")&&t.add(n.target);return e.nodes.filter(n=>!t.has(n.id)).map(n=>n.id)}function Ag(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function Cc(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function Cg(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=Cc(i),s=Cc(o);if(a!==s)return a?-1:1;let l=Ke(i),c=Ke(o);return l.localeCompare(c)})}function Lc(e,t,n){let r=Number(e);return Number.isFinite(r)?{kind:"count",n:r,unit:t,phrasing:n}:{kind:"text",text:n==="attribute"?`${t}=${e}`:`${e} ${t}`}}function Lg(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?Lc(e.detail.files,"files","attribute"):null;case"gitState":return e.detail.commit?{kind:"commit",sha:e.detail.commit}:null;case"repository":return e.detail.files?Lc(e.detail.files,"files","prose"):null;case"package":return e.detail.kind?{kind:"text",text:e.detail.kind}:null;case"entryPoint":return e.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function da(e,t){let n=Rg(e),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=m=>{let b=(i.get(m)??[]).filter(w=>{let k=r.get(w);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(w))return!1;return!0}).concat(o.get(m)??[]);return b=b.filter(w=>r.has(w)),t.showInternals||(b=b.filter(w=>{let k=r.get(w);return!(k&&Ag(k.kind))})),Cg(b,r)},l=t.provFilter!==null||t.query.length>0,c=m=>!(t.provFilter!==null&&m.provenance!==t.provFilter||t.query.length>0&&!Ke(m).toLowerCase().includes(t.query.toLowerCase())),u=new Set,h=m=>{let v=r.get(m),y=!1;for(let w of s(m))h(w)&&(y=!0);let b=c(v)||y;return b&&u.add(m),b};for(let m of a)h(m);let d=[],p=(m,v)=>{if(!u.has(m))return;let y=r.get(m),b=s(m),w=b.filter(_=>u.has(_)),k=l?w.length>0:t.expanded.has(m);if(d.push({id:m,depth:v,hasKids:b.length>0,expanded:k,label:Ke(y),kind:y.kind,provenance:y.provenance,meta:Lg(y)}),k)for(let _ of w)p(_,v+1)};for(let m of a)p(m,0);return d}function ha(e){if(!e.nodes.find(i=>i.kind==="vault"))return null;let n=e.nodes.some(i=>i.kind==="note"),r=e.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function lr(e,t){if(!e)return"";let n=Date.parse(e);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((t-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 Ng=7;function pa(e,t){if(e===null)return"";switch(e.kind){case"relTime":return lr(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,Ng);case"text":return e.text}}var Pg=["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 fa(e,t){let n=new Map;for(let s of e.nodes)n.set(s.id,s);let r=n.get(t);if(!r)return null;let i=[];for(let s of Pg){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of e.edges){if(s.source!==t)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Ke(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of e.edges){if(s.kind!=="links-to"||s.target!==t)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Ke(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:Ke(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function gi(e,t){let n=new Set([e]);for(let r of t)r.source===e&&n.add(r.target),r.target===e&&n.add(r.source);return n}var Dg=["contains","anchored-at"];function Ig(e){return Dg.includes(e)}function mi(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=Gg(e,n),i=Nc(e),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!t.has(d)))for(let p of r.get(d)??[])a(p)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,Mg(d,r));let l=new Map;for(let d of e.nodes)if(!(!o.has(d.id)||t.has(d.id)))for(let p of s.get(d.id)??[])!o.has(p)&&!l.has(p)&&l.set(p,d.id);for(let d of e.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let c=new Map;for(let[d,p]of r){let m=s.get(d);c.set(d,{children:p,descendants:m,members:m.filter(v=>l.get(v)===d),provenance:Og(m,n),expanded:t.has(d)})}let u=new Set,h=[];for(let d of e.nodes)o.has(d.id)?h.push(d):u.add(d.id);return{nodes:h,edges:Fg(e.edges,o,l),clusters:c,hidden:u,representative:l,roots:i}}function Gg(e,t){let n=new Map;for(let r of e.edges){if(!Ig(r.kind)||!t.has(r.source)||!t.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 Mg(e,t){let n=[],r=new Set([e]),i=o=>{for(let a of t.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(e),n}function Og(e,t){let n={human:0,agent:0,generated:0,none:0};for(let r of e){let i=t.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Fg(e,t,n){let r=a=>t.has(a)?a:n.get(a),i=[],o=new Set;for(let a of e){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let c=`${s}\0${l}\0${a.kind}`;o.has(c)||(o.add(c),i.push({source:s,target:l,kind:a.kind}))}return i}function ga(e){let t=new Map;for(let n of e){if(n.kind!=="links-to")continue;let r=t.get(n.target);r?r.push(n.source):t.set(n.target,[n.source])}return t}var An=[null,"human","agent","generated"];function Pc(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function ya(e,t){let n=new Set(e.expanded).add("vault"),r="";for(let i of t?t.split("/"):[])r=r?`${r}/${i}`:i,n.add(`vfolder:${r}`);return{...e,expanded:n,query:"",provFilter:null}}function nn(e){return{...e.model,danglingLinks:e.dangling}}function Dc(e,t){return e===null?[]:da(nn(e),t)}var Cn="vfolder:\0draft";function Ic(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function Gc(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function Mc(e,t){if(t===null)return[...e];let n={id:Cn,depth:t===""?1:t.split("/").length+1,hasKids:!1,expanded:!1,label:"",kind:"module",provenance:null,meta:null};if(t==="")return[...e,n];let r=e.findIndex(o=>o.id===`vfolder:${t}`);if(r===-1)return[...e,n];let i=r+1;for(;i<e.length&&e[i].depth>e[r].depth;)i++;return[...e.slice(0,i),n,...e.slice(i)]}function wa(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function $g(e,t){if(e.expanded.has(t))return e;let n=new Set(e.expanded);return n.add(t),{...e,expanded:n}}function zg(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function ba(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function rn(e){return e==="vault"?{type:"vault",path:""}:e.startsWith("note:")?{type:"note",path:e.slice(5)}:e.startsWith("vfolder:")?{type:"folder",path:e.slice(8)}:null}function yi(e,t){if(t.type==="note")return[t.path];if(t.type!=="folder"||e===null)return[];let n=`note:${t.path}/`;return e.model.nodes.filter(r=>r.kind==="note"&&r.id.startsWith(n)).map(r=>r.id.slice(5))}function Oc(e,t){return e===null?!1:t.type==="note"?e===`note:${t.path}`:t.type==="folder"?e===`vfolder:${t.path}`||e.startsWith(`vfolder:${t.path}/`)||e.startsWith(`note:${t.path}/`):!1}function xa(e){return e.type==="folder"}function Fc(e,t,n){return xa(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function $c(e,t){return e.query===t?e:{...e,query:t}}function zc(e){let t=An.indexOf(e.provFilter),n=An[(t+1)%An.length]??null;return{...e,provFilter:n}}function Wc(e){return{...e,showInternals:!e.showInternals}}function wi(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function va(e,t){return e[t]?.id??null}function ma(e,t,n){if(e.length===0)return null;let r=wi(e,t),i=r===-1?n>0?-1:e.length:r;return va(e,Math.min(e.length-1,Math.max(0,i+n)))}function Wg(e,t){let n=wi(e,t),r=n<=0?void 0:e[n];if(r===void 0)return null;for(let i of e.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var Ug={j:"ArrowDown",k:"ArrowUp"};function Hg(e){return Ug[e]??e}function Uc(e,t,n,r,i=!1){let o={state:t,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:t,selectedId:h,handled:!0}),s=Hg(r);if(s==="ArrowDown")return a(ma(e,n,1));if(s==="ArrowUp")return a(ma(e,n,-1));if(s==="Home")return a(va(e,0));if(s==="End")return a(va(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=wi(e,n),c=l===-1?void 0:e[l];if(c===void 0||n===null)return o;if(s==="ArrowRight")return c.hasKids?c.expanded?a(ma(e,n,1)):{state:$g(t,n),selectedId:n,handled:!0}:o;if(c.hasKids&&c.expanded)return{state:zg(t,n),selectedId:n,handled:!0};let u=Wg(e,n);return u===null?o:a(u)}var Bg={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function on(e){return Bg[e]}var Kg={human:"●",agent:"◐",generated:"○"};function an(e){return e===null?"":Kg[e]}function Ln(e){return e===null?"":`${e}-authored`}function Hc(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Vg(e){let t=e.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())t[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of e.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),t}function jg(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:Hc(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:on(e.kind),provenance:e.provenance,provenanceGlyph:an(e.provenance),provenanceTitle:Ln(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:pa(e.meta,n),level:e.depth+1}}function Bc(e,t,n){let r=Vg(e);return e.map((i,o)=>jg(i,t,n,r[o]))}function Kc(e,t){return wi(e,t)===-1?null:Hc(t)}function Vc(e){return{"--weave-depth":String(Math.max(0,e))}}function vi(e){return e===null?"all":e}function jc(e){let t=An.indexOf(e),n=An[(t+1)%An.length]??null;return`provenance filter: ${vi(e)} — click for ${vi(n)}`}function qc(e){return e?"internals":"knowledge"}function Yc(e){return e?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Xc="filter…",Zc="Vault and repository",Qc="Filter the tree",Jc="Filter the tree (/)";function eu(e,t,n){if(e===null)return"loading…";let r=ha(nn(e));return r!==null?r:t.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 tu(e){return e.length===1?"1 row":`${e.length} rows`}var qg=Object.fromEntries(Object.entries(ue).map(([e,{colors:t}])=>[e,{accent:t.accent,success:t.ok,warning:t.warn,dim:t.dim,text:t.fg,muted:t.faint,line:t["line-strong"],ground:t.bg}]));function Ft(e){let t=qg[ei(e)];return typeof e=="string"?t:{...t,accent:Al(e.theme,e.accent)}}var Yg={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Xg={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function Zg(e,t){return Ft(t)[Yg[e]]}function nu(e,t){return Ft(t)[Xg[e]]}function Qg(e,t){return Jg(e)?_a(nu(e,t),t,em):nu(e,t)}function Jg(e){return e==="contains"||e==="anchored-at"}var ka=.85,em=.3;function cr(e,t,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(e),o=r(t);if(i===null||o===null)return e;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,c)=>Math.round(l+(c-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function _a(e,t,n=ka){return cr(e,Ft(t).ground,n)}var tm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},ru=1.6,ou=32,nm=ou/2;function rm(e,t=ou){if(t<=0)return e.length>0?"…":e;if(e.length<=t)return e;let n=t-1,i=e.slice(0,n).lastIndexOf(" "),o=i>=nm?i:n;return`${e.slice(0,o).trimEnd()}…`}function im(e){let t=an(e.provenance),n=Ke(e);return rm(t===""?n:`${t} ${n}`)}var om=6,am=6;function sm(e){return(t,n,r)=>{if(n.label===null||n.label==="")return;let i=Ft(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=am,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+om),t.restore()}}function au(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(o++,s.x<t&&(t=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>i&&(i=s.y));if(o===0)return null;let a=Math.max(0,(or*4-Math.max(r-t,i-n))/2);return{x:[t-a,r+a],y:[n-a,i+a]}}var su={nodes:[],edges:[]};function lu(e){return`${e.source}\0${e.target}\0${e.kind}`}function lm(e,t){let n=new Map,r=new Set;for(let i of e){if(i.source===i.target||!t.has(i.source)||!t.has(i.target))continue;let o=lu(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 cu(e,t,n,r,i){let o=new Map;for(let h of e){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=lm(t,a),l=[];for(let[h,d]of o){let p=n.get(h),m=jo(s.get(h)??0);l.push({id:h,x:p.x,y:p.y,size:m,label:im(d),color:i?.get(h)??Zg(d.kind,r),kind:d.kind,provenance:d.provenance,zIndex:Math.round(m),type:"circle"})}let c=[],u=new Set;for(let h of t){if(h.source===h.target||!a.has(h.source)||!a.has(h.target))continue;let d=lu(h);u.has(d)||(u.add(d),c.push({key:d,source:h.source,target:h.target,size:tm[h.kind],color:Qg(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function uu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:r===t&&e.has(r)?{zIndex:i.zIndex+iu*2,size:i.size*bi(hm,n)}:e.has(r)?{zIndex:i.zIndex+iu,size:i.size*bi(pm,n)}:{color:_a(i.color,o,ka*n),label:n>=dm?null:i.label,zIndex:0}}var cm=60,um=.004;function du(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/cm);return Math.abs(t-i)<um?t:i}function bi(e,t){return 1+(e-1)*t}var dm=.5,hm=1.45,pm=1.15,iu=si+1;function hu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:!e.has(i.source)||!e.has(i.target)?{color:_a(i.color,o,ka*n)}:t!=null&&(i.source===t||i.target===t)?{zIndex:2,size:i.size*bi(ru*1.35,n),color:cr(i.color,Ft(o).accent,n)}:{zIndex:1,size:i.size*bi(ru,n)}}var fm=(ai+si)/2,gm=or*4,mm=1;function pu(e){let t=Ft(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:mm,labelGridCellSize:gm,labelRenderedSizeThreshold:fm,labelFont:"inherit",labelSize:11,labelColor:{color:t.text},defaultNodeColor:t.dim,defaultEdgeColor:t.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:or,defaultDrawNodeHover:sm(e),allowInvalidContainer:!0}}function fu(e){return e==="contains"||e==="anchored-at"}function vm(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)fu(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 ym(e,t){let n=vm(e,t),r=new Map;for(let i of e){let o=i.id,a=i.id,s=0,l=new Set([o]);for(;;){let c=n.get(o);if(c===void 0||l.has(c))break;l.add(c),a=o,o=c,s++}r.set(i.id,{key:a,depth:Math.max(0,s-1)})}return r}function wm(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var bm={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},xm=3;function km(e,t){let n=bm[ue[ei(t)].scheme],i=[...wm(e).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*xm%n.length])),o}var _m=.11,Em=.34;function Tm(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return cr(e,Ft(n).ground,Math.min(Em,r*_m))}var Sm=.26,Rm=.55;function Am(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let o of t){let a=Math.min(Sm,Rm-i);if(a<=0)break;i+=a,r=cr(r,o,a)}return r}function gu(e,t,n){let r=ym(e,t),i=new Map;for(let[u,h]of r)i.set(u,h.key);let o=km(i,n),a=new Set(e.map(u=>u.id)),s=new Map,l=(u,h)=>{let d=r.get(u)?.key,p=r.get(h)?.key;if(d===void 0||p===void 0||d===p)return;let m=s.get(u);m===void 0?s.set(u,new Set([p])):m.add(p)};for(let u of t)fu(u.kind)||u.source!==u.target&&(!a.has(u.source)||!a.has(u.target)||(l(u.source,u.target),l(u.target,u.source)));let c=new Map;for(let u of e){let h=r.get(u.id);if(h===void 0)continue;let d=o.get(h.key);if(d===void 0)continue;let p=Tm(d,h.depth,n),m=[...s.get(u.id)??[]].sort().map(v=>o.get(v)).filter(v=>v!==void 0);c.set(u.id,Am(p,m,n))}return c}function Ea(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}var Cm=300,Lm=1;function Nm(e,t,n){let r=new Map(n??[]);if(r.size>0)for(let o of t){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:Cm,seed:Lm,pinWarm:!0};return r.size>0&&(i.initial=r),lc({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function Pm(e,t){let n=0,r=0;for(let o of e){let a=Ea(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=Ea(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[...[e.length,t.length,n>>>0,r].map(o=>o.toString(16)),Ea(JSON.stringify(Qe)).toString(16)].join("-")}var vu="pi-weave.graph.positions.v4";function mu(e){return Math.round(e*10)/10}function Dm(e,t){let n={};for(let[r,i]of t)n[r]=[mu(i.x),mu(i.y)];return JSON.stringify({v:4,key:e,at:n})}function Im(e,t){if(e===null)return null;let n;try{n=JSON.parse(e)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==4||r.key!==t)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,c]=s;if(typeof l!="number"||typeof c!="number"||!Number.isFinite(l)||!Number.isFinite(c))return null;o.set(a,{x:l,y:c})}return o.size===0?null:o}function Gm(e,t){let n;try{n=e.getItem(vu)}catch{return null}return Im(n,t)}function Mm(e,t,n){try{return e.setItem(vu,Dm(t,n)),!0}catch{return!1}}function yu(e,t,n){let r=Pm(t,n),i=Gm(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Nm(t,n);return Mm(e,r,o),{key:r,positions:o,cached:!1}}function bu(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(i=>i.id===t);if(n===void 0)return null;let r=t.startsWith("artifact:")?"HTML artifact":t.startsWith("vfolder:")?"Folder":n.kind;return{id:t,title:n.label,kind:r,icon:on(n.kind)}}function Om(e){return{expanded:new Set(mi(e,new Set).clusters.keys())}}function xu(e,t){return t!==null?t:e===null?{expanded:new Set}:Om(nn(e))}function Fm(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function $m(e,t){return t===null?null:gi(t,e)}function ku(e,t,n){return t===null?n:gi(t,e)}var _u="fit",Eu="frame the whole graph",xi={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Tu(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function zm(e,t){return e===null?"Loading…":e.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":t===0?"Nothing to draw at this expansion.":null}var Wm="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",wu={graph:su,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Su(e,t,n,r,i,o=!1,a=!0){if(e===null)return o?{...wu,empty:Wm}:wu;let s=nn(e),l=mi(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(p=>p.source!=="vault"&&p.target!=="vault"):l.edges,h=yu(r,l.nodes,u),d=a?gu(l.nodes,u,i):void 0;return{graph:cu(l.nodes,u,h.positions,i,d),highlight:$m(u,t),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:zm(e,l.nodes.length)}}function Ru(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:Fm(e,n),selectedId:n}}var Au="(prefers-color-scheme: light)";function ur(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Au).matches?"light":"dark"}function Cu(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Au);if(typeof n.addEventListener!="function")return()=>{};let r=()=>t(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}var Um=.06,Hm=.2,Ta=.001,Lu=.5;function Nu(e,t){if(e.nodes.length===0)return null;let n=e.nodes.map(s=>{let l=t?.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:qo(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of e.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=Yo({nodes:n,links:o,seed:1}).alpha(Um).alphaMin(Ta);return{tick(){a.tick()},awake(){return a.alphaTarget()>Ta||a.alpha()>Ta},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let c=r.get(s);if(!c)return;let u=c.fx!=null&&c.fy!=null&&Math.abs(c.fx-l.x)<Lu&&Math.abs(c.fy-l.y)<Lu;c.fx=l.x,c.fy=l.y,a.alphaTarget(u?0:Hm)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}var dr="application/x-weave-note";function Pu(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function Sa(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function Du(e,t){return t!==null&&t===e}function Iu(e,t,n){return e.map(r=>{let i=t?.model.nodes.find(a=>a.id===r),o=i?.kind??(r.startsWith("vfolder:")?"module":r.startsWith("artifact:")?"file":"note");return{id:r,label:i?.label??r.replace(/^[^:]+:/,""),icon:on(o),selected:r===n}})}var Gu={title:"Context"},Bm="—";function Mu(e,t){return{cwd:e===""?Bm:e,selection:t??"nothing selected"}}var Ou=6e4;function ki(e){return e?"⌘K":"Ctrl K"}function Fu(e){return`Search notes and repository (${e})`}function _i(e){return/mac|iphone|ipad/i.test(e)}var Km={k:{type:"openSearch"},",":{type:"openSettings"}},$u={1:"tree",2:"note",3:"graph"};function Vm(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function jm(e){return!e.ctrl&&!e.meta&&!e.alt}var qm={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"}};function zu(e,t){if(t.overlay!==null)return e.key==="Escape"?{type:"closeOverlay"}:null;if(e.alt&&!e.meta&&!e.ctrl&&!e.shift&&e.key.toLowerCase()==="w")return{type:"closeTab"};if(Vm(e)){let n=Km[e.key.toLowerCase()];if(n!==void 0)return n;let r=$u[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection?{type:"clearSelection"}:null:!jm(e)||e.typing?null:qm[e.key]??null}var Ym=["INPUT","TEXTAREA","SELECT"];function Ra(e,t){return t?!0:e!==null&&Ym.includes(e.toUpperCase())}function Wu(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Ra(e.target?.tagName??null,e.target?.isContentEditable===!0)}}var Nn={tree:".weave-sidebar-notes .weave-rows",note:".weave-pane-active .weave-note-body",graph:".weave-graph-host .weave-graph-canvas"},Aa=".weave-sidebar-notes .weave-filter";function Xm(e){let t=e;return typeof t?.focus=="function"?t:null}function Ei(e,t){let n=Xm(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function Uu(e,t){switch(e.type){case"openSearch":return t.setOverlay("search");case"openSettings":return t.setOverlay("settings");case"openHelp":return t.setOverlay("help");case"closeOverlay":return t.setOverlay(null);case"focusColumn":return void t.focusSelector(Nn[e.column]);case"filterTree":return void t.focusSelector(Aa);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"toggleTheme":return t.toggleTheme()}}function Ti(e){return[{title:"Global",entries:[{combo:"⌥W / Alt W",what:"Close the active tab"},{combo:`${e},`,what:"Open settings"},{combo:`${e}K`,what:"Search notes and the repository"},...Object.entries($u).map(([t,n])=>({combo:`${e}${t}`,what:n==="tree"?"Open and focus the notes sidebar":n==="graph"?"Open and focus Graph view":"Focus the note"})),{combo:"?",what:"This help"},{combo:"t",what:"Switch between selected light and dark themes"},{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:"Tabs and panes",entries:[{combo:"Alt ← / →",what:"Reorder the focused tab"},{combo:"← / → / Home / End",what:"Select a tab when the tab strip is focused"},{combo:`${e}click`,what:"Open a note or search result in a new tab"},{combo:"Pane options (···)",what:"Split right or down, move a tab, or close a pane"}]},{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:`${e}↵`,what:"Open the highlighted result in a new tab"},{combo:"Esc",what:"Close the palette"}]}]}var Ca="Keyboard shortcuts",Hu="esc close";var Bu={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}};var Zm=0;function f(e,t,n,r,i,o){t||(t={});var a,s,l=t;if("ref"in l)for(s in l={},t)s=="ref"?a=t[s]:l[s]=t[s];var c={type:e,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Zm,__i:-1,__u:0,__source:i,__self:o};if(typeof e=="function"&&(a=e.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return te.vnode&&te.vnode(c),c}function _t({name:e,class:t}){let n=Bu[e];return f("svg",{class:t,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=>f("path",{d:r}))})}function Jm({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let c=ba(e.id);return f("li",{id:e.domId,"data-row-id":e.id,class:`weave-row weave-row-${e.kind}${e.selected?" weave-row-on":""}${t.has(e.id)?" weave-row-new":""}`,role:"treeitem","aria-level":e.level,"aria-posinset":e.posinset,"aria-setsize":e.setsize,"aria-selected":e.selected,"aria-expanded":e.hasKids?e.expanded:void 0,style:Vc(e.depth),onClick:u=>o(u.metaKey||u.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===Cn?"New folder":void 0,onDragStart:u=>{u.dataTransfer?.setData("text/plain",e.id),u.dataTransfer?.setData(dr,e.id),u.dataTransfer&&(u.dataTransfer.effectAllowed="copyMove")},onDragOver:c===void 0?void 0:u=>u.preventDefault(),onDrop:c===void 0?void 0:u=>{u.preventDefault(),l(u.dataTransfer?.getData("text/plain")??"")},onContextMenu:u=>{u.preventDefault(),u.stopPropagation(),s(u.clientX,u.clientY)},children:[f("span",{class:"weave-twisty","aria-hidden":"true",onClick:u=>{u.stopPropagation(),a()},children:e.hasKids?f(_t,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),f("span",{class:"weave-kind","aria-hidden":"true",children:f(_t,{name:e.kindIcon,class:"weave-icon"})}),f("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),n===null?f("span",{class:"weave-label",children:e.label}):f(ev,{value:n,draft:e.id===Cn,onEdit:r,onCommit:i}),f("span",{class:"weave-meta",children:e.meta})]})}function ev({value:e,draft:t,onEdit:n,onCommit:r}){let i=Q(null);return Ze(()=>{let o=i.current;o!==null&&(o.focus(),o.select())},[]),f("input",{ref:i,class:"weave-tree-rename",value:e,placeholder:t?"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 Ku(e){let[t,n]=j(Pc),[r,i]=j(null),o=Q(null);Ze(()=>{r!==null&&o.current?.querySelector(".weave-menu button")?.focus()},[r?.id]);let a=()=>{i(null),o.current?.querySelector(".weave-tree-actions")?.focus()},[s,l]=j(null),[c,u]=j(null),h=Mc(Dc(e.graph,t),c),d=eu(e.graph,h,t),p=async(b,w)=>{let k=await b;if(!k.ok)window.alert(k.message);else{let _=k.data.id??w;_!==void 0&&e.onSelect(_),e.onRefresh()}},m=async b=>{if(r===null)return;let w=rn(r.id);if(i(null),w!==null){if(b==="newFolder"){let k=Ic(w);n(_=>ya(_,k)),u(k),l({id:Cn,label:"",value:""})}else if(b==="rename")n(k=>ya(k,w.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(w.type!=="vault"){if(!e.onMutate(yi(e.graph,w)))return;await p(w.type==="note"?Tc(Ge,w.path):Ac(Ge,w.path),Oc(e.selectedId,w)?"vault":void 0)}}},v=b=>{if(r!==null){if(xa(b)&&r.armed!==!0){i({...r,armed:!0});return}m("delete")}},y=b=>{let w=s,k=c;if(l(null),u(null),w===null)return;let _=b?.trim();if(w.id===Cn){let A=k===null||!_?null:Gc(k,_);A!==null&&p(Sc(Ge,A));return}let I=rn(w.id);if(I!==null&&_&&_!==w.label){if(!e.onMutate(yi(e.graph,I)))return;p(I.type==="note"?_c(Ge,I.path,_):Rc(Ge,I.path,_))}};return f("div",{class:"weave-tree",ref:o,onKeyDown:b=>{if(r!==null&&b.key==="Escape"){b.preventDefault(),b.stopPropagation(),a();return}let w=b.target,k=Uc(h,t,e.selectedId,b.key,Ra(w?.tagName??null,w?.isContentEditable===!0));k.handled&&(b.preventDefault(),n(k.state),k.selectedId!==null&&e.onSelect(k.selectedId,!1,!0))},children:[f("div",{class:"weave-tree-controls",children:[f("input",{type:"search",class:"weave-filter",value:t.query,placeholder:Xc,"aria-label":Qc,title:Jc,onInput:b=>n($c(t,b.currentTarget.value))}),f("button",{type:"button",class:"weave-chip",title:jc(t.provFilter),onClick:()=>n(zc(t)),children:["◧ ",vi(t.provFilter)]}),f("button",{type:"button",class:"weave-chip",title:Yc(t.showInternals),onClick:()=>n(Wc(t)),children:["◧ ",qc(t.showInternals)]}),f("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:b=>{let w=e.selectedId!==null&&rn(e.selectedId)!==null?e.selectedId:"vault",k=b.currentTarget.getBoundingClientRect();i({id:w,label:e.graph?.model.nodes.find(_=>_.id===w)?.label??"Vault",x:k.left,y:k.bottom})},children:"···"})]}),d===null?f("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Zc,"aria-activedescendant":Kc(h,e.selectedId)??void 0,onContextMenu:b=>{b.preventDefault(),i({id:"vault",label:"Vault",x:b.clientX,y:b.clientY})},children:Bc(h,e.selectedId,e.now).map(b=>f(Jm,{view:b,recentIds:e.recentIds,edit:s?.id===b.id?s.value:null,onEdit:w=>l(k=>k===null?null:{...k,value:w}),onRename:y,onSelect:w=>{e.onSelect(b.id,w),b.hasKids&&n(k=>wa(k,b.id))},onToggle:()=>n(wa(t,b.id)),onMenu:(w,k)=>i({id:b.id,label:b.label,x:w,y:k}),onDrop:w=>{let k=ba(b.id);if(w.startsWith("note:")&&k!==void 0){let _=rn(w);if(_!==null&&!e.onMutate(yi(e.graph,_)))return;p(Ec(Ge,w.slice(5),k))}}},b.id))}):f("p",{class:"weave-tree-empty",children:d}),f("p",{class:"weave-tree-count",children:tu(h)}),r!==null&&rn(r.id)!==null?(()=>{let b=rn(r.id);return f(pe,{children:[f("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:a}),f("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),a();else if(["ArrowDown","ArrowUp","Home","End"].includes(w.key)){w.preventDefault();let k=[...w.currentTarget.querySelectorAll("button")],_=k.indexOf(document.activeElement),I=w.key==="Home"?0:w.key==="End"?k.length-1:(_+(w.key==="ArrowDown"?1:-1)+k.length)%k.length;k[I]?.focus()}w.stopPropagation()},children:[f("button",{type:"button",role:"menuitem",onClick:()=>{m("newFolder")},children:"New folder…"}),b.type!=="vault"?f(pe,{children:[f("button",{type:"button",role:"menuitem",onClick:()=>{m("rename")},children:"Rename…"}),f("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>v(b),children:Fc(b,r.label,r.armed===!0)})]}):null]})]})})():null]})}function Vu(e){let t=Q(null),n=Q(null),r=Q(null),i=Q(null),o=kl(()=>{if(i.current!==null)return;let v=()=>{i.current=null;let y=r.current;y!==null&&(y.tick(),y.awake()&&(n.current?.setPositions(y.positions()),i.current=requestAnimationFrame(v)))};i.current=requestAnimationFrame(v)},[]),[a,s]=j(null),l=ft(()=>(sc(e.forces),JSON.stringify(e.forces)),[e.forces]),c=e.groupColors,u=e.scheme??ur(e.host),h=xu(e.graph,a),d=ft(()=>Su(e.graph,e.selectedId,h,e.storage,u,e.bootFailed,c),[e.graph,e.selectedId,h,e.storage,u,e.bootFailed,l,c]),p=bu(e.graph,e.previewId),m=Q({view:h,model:d,onSelect:e.onSelect,selectedId:e.selectedId});return m.current={view:h,model:d,onSelect:e.onSelect,selectedId:e.selectedId},le(()=>{let v=e.renderer(u);return v.onSelect(y=>{let b=Ru(m.current.view,m.current.model.clusters,y);s(b.state),m.current.onSelect(b.selectedId)}),v.onHover(y=>{let{model:b,selectedId:w}=m.current;v.setHighlight(ku(b.graph.edges,y,b.highlight),y??w)}),v.onDragStart(y=>{let b=n.current?.positions().get(y);b&&(r.current?.pin(y,b),o())}),v.onDragMove((y,b)=>{r.current?.pin(y,b)}),v.onDragEnd(y=>{r.current?.release(y)}),v.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=v,v.setGraph(m.current.model.graph),v.setHighlight(m.current.model.highlight,m.current.selectedId),e.fit.current=()=>v.fit(),()=>{v.destroy(),n.current=null,e.fit.current=null}},[e.renderer,u]),le(()=>{n.current?.setGraph(d.graph)},[d.key,l,c]),le(()=>{let v=Nu(d.graph,n.current?.positions());return r.current=v,v!==null&&o(),()=>{r.current=null}},[d.key,o,l]),le(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),le(()=>{n.current?.setHighlight(d.highlight,e.selectedId)},[d.highlight,e.selectedId]),f("div",{class:"weave-graph",children:[d.empty===null?null:f("p",{class:"weave-graph-empty",children:d.empty}),f("div",{class:"weave-graph-canvas",ref:t,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),p===null?null:f("aside",{class:"weave-graph-preview","aria-label":"Selected graph node",children:[f("div",{class:"weave-graph-preview-info",children:[f("span",{class:"weave-kind","aria-hidden":"true",children:f(_t,{name:p.icon,class:"weave-icon"})}),f("div",{class:"weave-graph-preview-copy",children:[f("span",{class:"weave-graph-preview-kind",children:p.kind}),f("strong",{class:"weave-graph-preview-title",title:p.title,children:p.title})]})]}),f("button",{type:"button",class:"weave-graph-preview-close","aria-label":"Clear graph selection",onClick:()=>e.onSelect(null),children:"×"}),f("button",{type:"button",class:"weave-chip",onClick:()=>e.onOpen(p.id),children:"Open in new tab"})]}),f("div",{class:"weave-graph-controls",children:[f("button",{type:"button",class:"weave-chip",title:Eu,onClick:()=>n.current?.fit(),children:_u}),f("span",{class:"weave-graph-legend",children:[f("span",{class:"weave-legend-on",children:["◉ ",xi.selected]}),f("span",{class:"weave-legend-near",children:["● ",xi.neighborhood]}),f("span",{class:"weave-legend-dim",children:["· ",xi.dimmed]})]})]}),f("p",{class:"weave-graph-count",children:Tu(d.visible,d.total)})]})}function tv(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ln(e){var t=tv(e,"string");return typeof t=="symbol"?t:t+""}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ju(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ln(r.key),r)}}function xe(e,t,n){return t&&ju(e.prototype,t),n&&ju(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function sn(e){return sn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},sn(e)}function qu(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(qu=function(){return!!e})()}function nv(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function rv(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return nv(e)}function Me(e,t,n){return t=sn(t),rv(e,qu()?Reflect.construct(t,n||[],sn(e).constructor):t.apply(e,n))}function La(e,t){return La=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},La(e,t)}function Oe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&La(e,t)}function iv(e){if(Array.isArray(e))return e}function ov(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Ri(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ia(e,t){if(e){if(typeof e=="string")return Ri(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ri(e,t):void 0}}function av(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
22
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $t(e,t){return iv(e)||ov(e,t)||Ia(e,t)||av()}var Na={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 Yu=new Int8Array(4),Pa=new Int32Array(Yu.buffer,0,1),sv=new Float32Array(Yu.buffer,0,1),lv=/^\s*rgba?\s*\(/,cv=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function uv(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(lv.test(e)){var o=e.match(cv);o&&(t=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:t,g:n,b:r,a:i}}var Pn={};for(hr in Na)Pn[hr]=Dn(Na[hr]),Pn[Na[hr]]=Pn[hr];var hr;function Xu(e,t,n,r,i){return Pa[0]=r<<24|n<<16|t<<8|e,i&&(Pa[0]=Pa[0]&4278190079),sv[0]}function Dn(e){if(e=e.toLowerCase(),typeof Pn[e]<"u")return Pn[e];var t=uv(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var a=Xu(n,r,i,o,!0);return Pn[e]=a,a}var Da={};function Ga(e){if(typeof Da[e]<"u")return Da[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Xu(t,n,r,i,!0);return Da[e]=o,o}function Ma(e,t,n,r){return n+(t<<8)+(e<<16)}function Oa(e,t,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(e.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(a,s,1,1,e.RGBA,e.UNSIGNED_BYTE,l);var c=$t(l,4),u=c[0],h=c[1],d=c[2],p=c[3];return[u,h,d,p]}function R(e,t,n){return(t=ln(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Zu(Object(n),!0).forEach(function(r){R(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zu(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function dv(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=sn(e))!==null;);return e}function za(){return za=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=dv(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},za.apply(null,arguments)}function id(e,t,n,r){var i=za(sn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function hv(e){return e.normalized?1:e.size}function Fa(e){var t=0;return e.forEach(function(n){return t+=hv(n)}),t}function od(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var o=t.getShaderParameter(i,t.COMPILE_STATUS);if(!o){var a=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
24
23
  `.concat(a,`
25
- `).concat(n))}return i}function nv(e,t){return nd("VERTEX",e,t)}function rv(e,t){return nd("FRAGMENT",e,t)}function iv(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var a=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function Yc(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,o=e.fragmentShader;t.deleteShader(i),t.deleteShader(o),t.deleteProgram(r),t.deleteBuffer(n)}var Xc=`#define PICKING_MODE
26
- `,ov=R(R(R(R(R(R(R(R({},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 rd=(function(){function e(t,n,r){me(this,e),R(this,"array",new Float32Array),R(this,"constantArray",new Float32Array),R(this,"capacity",0),R(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=Sa(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,Xc+i.VERTEX_SHADER_SOURCE,Xc+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Sa(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 ve(e,[{key:"kill",value:function(){Yc(this.normalProgram),this.pickProgram&&(Yc(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=nv(r,i),c=rv(r,o),h=iv(r,[u,c]),d={};s.UNIFORMS.forEach(function(w){var v=r.getUniformLocation(h,w);v&&(d[w]=v)});var p={};s.ATTRIBUTES.forEach(function(w){p[w.name]=r.getAttribLocation(h,w.name)});var m;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(w){p[w.name]=r.getAttribLocation(h,w.name)}),m=r.createBuffer(),m===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:m||{},uniformLocations:d,attributeLocations:p,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=ov[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:Sa(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($($({},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 av=(function(e){function t(){return me(this,t),Ge(this,t,arguments)}return Oe(t,e),ve(t,[{key:"kill",value:function(){td(t,"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(ka(r),a,o)}}])})(rd);var Aa=(function(e){function t(){var n;me(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Ge(this,t,[].concat(i)),R(n,"drawLabel",void 0),n}return Oe(t,e),ve(t,[{key:"kill",value:function(){td(t,"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(ka(r),l,o,a,s)}}])})(rd);function sv(e,t){return(function(){function n(r,i,o){me(this,n),R(this,"drawLabel",t),this.programs=e.map(function(a){return new a(r,i,o)})}return ve(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 id(e,t,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=t.label;if(u){e.fillStyle=l,e.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,p=n.y,m=r.x,w=r.y,v=(d+m)/2,b=(p+w)/2,y=m-d,x=w-p,k=Math.sqrt(y*y+x*x);if(!(k<c+h)){d+=y*c/k,p+=x*c/k,m-=y*h/k,w-=x*h/k,v=(d+m)/2,b=(p+w)/2,y=m-d,x=w-p,k=Math.sqrt(y*y+x*x);var N=e.measureText(u).width;if(N>k){var A="…";for(u=u+A,N=e.measureText(u).width;N>k&&u.length>1;)u=u.slice(0,-2)+A,N=e.measureText(u).width;if(u.length<4)return}var P;y>0?x>0?P=Math.acos(y/k):P=Math.asin(x/k):x>0?P=Math.acos(y/k)+Math.PI:P=Math.asin(y/k)+Math.PI/2,e.save(),e.translate(v,b),e.rotate(P),e.fillText(u,-N/2,t.size/2+o),e.restore()}}}function Ca(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=a,e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function od(e,t,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var a=2;if(typeof t.label=="string"){var s=e.measureText(t.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(t.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));e.beginPath(),e.moveTo(t.x+d,t.y+u/2),e.lineTo(t.x+c+l,t.y+u/2),e.lineTo(t.x+c+l,t.y-u/2),e.lineTo(t.x+d,t.y-u/2),e.arc(t.x,t.y,c,h,-h),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+a,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,Ca(e,t,n)}var lv=`
24
+ `).concat(n))}return i}function pv(e,t){return od("VERTEX",e,t)}function fv(e,t){return od("FRAGMENT",e,t)}function gv(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var a=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function Qu(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,o=e.fragmentShader;t.deleteShader(i),t.deleteShader(o),t.deleteProgram(r),t.deleteBuffer(n)}var Ju=`#define PICKING_MODE
25
+ `,mv=R(R(R(R(R(R(R(R({},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 ad=(function(){function e(t,n,r){be(this,e),R(this,"array",new Float32Array),R(this,"constantArray",new Float32Array),R(this,"capacity",0),R(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=Fa(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,Ju+i.VERTEX_SHADER_SOURCE,Ju+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Fa(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 xe(e,[{key:"kill",value:function(){Qu(this.normalProgram),this.pickProgram&&(Qu(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 c=pv(r,i),u=fv(r,o),h=gv(r,[c,u]),d={};s.UNIFORMS.forEach(function(v){var y=r.getUniformLocation(h,v);y&&(d[v]=y)});var p={};s.ATTRIBUTES.forEach(function(v){p[v.name]=r.getAttribLocation(h,v.name)});var m;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(v){p[v.name]=r.getAttribLocation(h,v.name)}),m=r.createBuffer(),m===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:m||{},uniformLocations:d,attributeLocations:p,isPicking:n==="pick",vertexShader:c,fragmentShader:u}}},{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=mv[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 c=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:Fa(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,c,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var u=l.getExtension("ANGLE_instanced_arrays");u&&u.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($($({},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 vv=(function(e){function t(){return be(this,t),Me(this,t,arguments)}return Oe(t,e),xe(t,[{key:"kill",value:function(){id(t,"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(Ga(r),a,o)}}])})(ad);var Wa=(function(e){function t(){var n;be(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Me(this,t,[].concat(i)),R(n,"drawLabel",void 0),n}return Oe(t,e),xe(t,[{key:"kill",value:function(){id(t,"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 c=l+this.STRIDE;l<c;l++)this.array[l]=0;return}return this.processVisibleItem(Ga(r),l,o,a,s)}}])})(ad);function yv(e,t){return(function(){function n(r,i,o){be(this,n),R(this,"drawLabel",t),this.programs=e.map(function(a){return new a(r,i,o)})}return xe(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(c){return c.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 sd(e,t,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=l,e.font="".concat(s," ").concat(o,"px ").concat(a);var u=n.size,h=r.size,d=n.x,p=n.y,m=r.x,v=r.y,y=(d+m)/2,b=(p+v)/2,w=m-d,k=v-p,_=Math.sqrt(w*w+k*k);if(!(_<u+h)){d+=w*u/_,p+=k*u/_,m-=w*h/_,v-=k*h/_,y=(d+m)/2,b=(p+v)/2,w=m-d,k=v-p,_=Math.sqrt(w*w+k*k);var I=e.measureText(c).width;if(I>_){var A="…";for(c=c+A,I=e.measureText(c).width;I>_&&c.length>1;)c=c.slice(0,-2)+A,I=e.measureText(c).width;if(c.length<4)return}var D;w>0?k>0?D=Math.acos(w/_):D=Math.asin(k/_):k>0?D=Math.acos(w/_)+Math.PI:D=Math.asin(w/_)+Math.PI/2,e.save(),e.translate(y,b),e.rotate(D),e.fillText(c,-I/2,t.size/2+o),e.restore()}}}function Ua(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=a,e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function ld(e,t,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var a=2;if(typeof t.label=="string"){var s=e.measureText(t.label).width,l=Math.round(s+5),c=Math.round(r+2*a),u=Math.max(t.size,r/2)+a,h=Math.asin(c/2/u),d=Math.sqrt(Math.abs(Math.pow(u,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+d,t.y+c/2),e.lineTo(t.x+u+l,t.y+c/2),e.lineTo(t.x+u+l,t.y-c/2),e.lineTo(t.x+d,t.y-c/2),e.arc(t.x,t.y,u,h,-h),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+a,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,Ua(e,t,n)}var wv=`
27
26
  precision highp float;
28
27
 
29
28
  varying vec4 v_color;
@@ -55,7 +54,7 @@ void main(void) {
55
54
  gl_FragColor = mix(v_color, transparent, t);
56
55
  #endif
57
56
  }
58
- `,uv=lv,cv=`
57
+ `,bv=wv,xv=`
59
58
  attribute vec4 a_id;
60
59
  attribute vec4 a_color;
61
60
  attribute vec2 a_position;
@@ -96,7 +95,7 @@ void main() {
96
95
 
97
96
  v_color.a *= bias;
98
97
  }
99
- `,dv=cv,ad=WebGLRenderingContext,Zc=ad.UNSIGNED_BYTE,Ta=ad.FLOAT,hv=["u_sizeRatio","u_correctionRatio","u_matrix"],tr=(function(e){function t(){return me(this,t),Ge(this,t,arguments)}return Oe(t,e),ve(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:dv,FRAGMENT_SHADER_SOURCE:uv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:hv,ATTRIBUTES:[{name:"a_position",size:2,type:Ta},{name:"a_size",size:1,type:Ta},{name:"a_color",size:4,type:Zc,normalized:!0},{name:"a_id",size:4,type:Zc,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Ta}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=kn(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)}}])})(av);R(tr,"ANGLE_1",0);R(tr,"ANGLE_2",2*Math.PI/3);R(tr,"ANGLE_3",4*Math.PI/3);var pv=`
98
+ `,kv=xv,cd=WebGLRenderingContext,ed=cd.UNSIGNED_BYTE,$a=cd.FLOAT,_v=["u_sizeRatio","u_correctionRatio","u_matrix"],fr=(function(e){function t(){return be(this,t),Me(this,t,arguments)}return Oe(t,e),xe(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:kv,FRAGMENT_SHADER_SOURCE:bv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:_v,ATTRIBUTES:[{name:"a_position",size:2,type:$a},{name:"a_size",size:1,type:$a},{name:"a_color",size:4,type:ed,normalized:!0},{name:"a_id",size:4,type:ed,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:$a}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Dn(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,c=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(c,!1,r.matrix)}}])})(vv);R(fr,"ANGLE_1",0);R(fr,"ANGLE_2",2*Math.PI/3);R(fr,"ANGLE_3",4*Math.PI/3);var Ev=`
100
99
  precision mediump float;
101
100
 
102
101
  varying vec4 v_color;
@@ -104,7 +103,7 @@ varying vec4 v_color;
104
103
  void main(void) {
105
104
  gl_FragColor = v_color;
106
105
  }
107
- `,fv=pv,gv=`
106
+ `,Tv=Ev,Sv=`
108
107
  attribute vec2 a_position;
109
108
  attribute vec2 a_normal;
110
109
  attribute float a_radius;
@@ -170,7 +169,7 @@ void main() {
170
169
 
171
170
  v_color.a *= bias;
172
171
  }
173
- `,mv=gv,sd=WebGLRenderingContext,Qc=sd.UNSIGNED_BYTE,li=sd.FLOAT,vv=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],ld={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function ud(e){var t=$($({},ld),e||{});return(function(n){function r(){return me(this,r),Ge(this,r,arguments)}return Oe(r,n),ve(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:mv,FRAGMENT_SHADER_SOURCE:fv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vv,ATTRIBUTES:[{name:"a_position",size:2,type:li},{name:"a_normal",size:2,type:li},{name:"a_radius",size:1,type:li},{name:"a_color",size:4,type:Qc,normalized:!0},{name:"a_id",size:4,type:Qc,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:li}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(t.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,p=s.x,m=s.y,w=l.x,v=l.y,b=kn(u.color),y=w-p,x=v-m,k=y*y+x*x,N=0,A=0;k&&(k=1/Math.sqrt(k),N=-x*k*h,A=y*k*h);var P=this.array;P[a++]=w,P[a++]=v,P[a++]=-N,P[a++]=-A,P[a++]=d,P[a++]=b,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,p=l.u_lengthToThicknessRatio,m=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(p,t.lengthToThicknessRatio),s.uniform1f(m,t.widenessToThicknessRatio)}}])})(Aa)}var O0=ud();var yv=`
172
+ `,Rv=Sv,ud=WebGLRenderingContext,td=ud.UNSIGNED_BYTE,Ai=ud.FLOAT,Av=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],dd={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function hd(e){var t=$($({},dd),e||{});return(function(n){function r(){return be(this,r),Me(this,r,arguments)}return Oe(r,n),xe(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Rv,FRAGMENT_SHADER_SOURCE:Tv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Av,ATTRIBUTES:[{name:"a_position",size:2,type:Ai},{name:"a_normal",size:2,type:Ai},{name:"a_radius",size:1,type:Ai},{name:"a_color",size:4,type:td,normalized:!0},{name:"a_id",size:4,type:td,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Ai}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,c){if(t.extremity==="source"){var u=[l,s];s=u[0],l=u[1]}var h=c.size||1,d=l.size||1,p=s.x,m=s.y,v=l.x,y=l.y,b=Dn(c.color),w=v-p,k=y-m,_=w*w+k*k,I=0,A=0;_&&(_=1/Math.sqrt(_),I=-k*_*h,A=w*_*h);var D=this.array;D[a++]=v,D[a++]=y,D[a++]=-I,D[a++]=-A,D[a++]=d,D[a++]=b,D[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,c=l.u_matrix,u=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,p=l.u_lengthToThicknessRatio,m=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(c,!1,o.matrix),s.uniform1f(u,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(p,t.lengthToThicknessRatio),s.uniform1f(m,t.widenessToThicknessRatio)}}])})(Wa)}var K0=hd();var Cv=`
174
173
  precision mediump float;
175
174
 
176
175
  varying vec4 v_color;
@@ -196,7 +195,7 @@ void main(void) {
196
195
  gl_FragColor = mix(v_color, transparent, t);
197
196
  #endif
198
197
  }
199
- `,cd=yv,wv=`
198
+ `,pd=Cv,Lv=`
200
199
  attribute vec4 a_id;
201
200
  attribute vec4 a_color;
202
201
  attribute vec2 a_normal;
@@ -264,7 +263,7 @@ void main() {
264
263
 
265
264
  v_color.a *= bias;
266
265
  }
267
- `,bv=wv,dd=WebGLRenderingContext,Jc=dd.UNSIGNED_BYTE,en=dd.FLOAT,xv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],kv={lengthToThicknessRatio:ld.lengthToThicknessRatio};function hd(e){var t=$($({},kv),e||{});return(function(n){function r(){return me(this,r),Ge(this,r,arguments)}return Oe(r,n),ve(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:bv,FRAGMENT_SHADER_SOURCE:cd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:xv,ATTRIBUTES:[{name:"a_positionStart",size:2,type:en},{name:"a_positionEnd",size:2,type:en},{name:"a_normal",size:2,type:en},{name:"a_color",size:4,type:Jc,normalized:!0},{name:"a_id",size:4,type:Jc,normalized:!0},{name:"a_radius",size:1,type:en}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:en},{name:"a_normalCoef",size:1,type:en},{name:"a_radiusCoef",size:1,type:en}],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,p=l.x,m=l.y,w=kn(u.color),v=p-h,b=m-d,y=l.size||1,x=v*v+b*b,k=0,N=0;x&&(x=1/Math.sqrt(x),k=-b*x*c,N=v*x*c);var A=this.array;A[a++]=h,A[a++]=d,A[a++]=p,A[a++]=m,A[a++]=k,A[a++]=N,A[a++]=w,A[a++]=o,A[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,p=l.u_correctionRatio,m=l.u_sizeRatio,w=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(m,o.sizeRatio),s.uniform1f(p,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(w,o.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(Aa)}var F0=hd();function _v(e){return sv([hd(e),ud(e)])}var Ev=_v(),pd=Ev,Sv=`
266
+ `,Nv=Lv,fd=WebGLRenderingContext,nd=fd.UNSIGNED_BYTE,cn=fd.FLOAT,Pv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Dv={lengthToThicknessRatio:dd.lengthToThicknessRatio};function gd(e){var t=$($({},Dv),e||{});return(function(n){function r(){return be(this,r),Me(this,r,arguments)}return Oe(r,n),xe(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Nv,FRAGMENT_SHADER_SOURCE:pd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Pv,ATTRIBUTES:[{name:"a_positionStart",size:2,type:cn},{name:"a_positionEnd",size:2,type:cn},{name:"a_normal",size:2,type:cn},{name:"a_color",size:4,type:nd,normalized:!0},{name:"a_id",size:4,type:nd,normalized:!0},{name:"a_radius",size:1,type:cn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:cn},{name:"a_normalCoef",size:1,type:cn},{name:"a_radiusCoef",size:1,type:cn}],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,c){var u=c.size||1,h=s.x,d=s.y,p=l.x,m=l.y,v=Dn(c.color),y=p-h,b=m-d,w=l.size||1,k=y*y+b*b,_=0,I=0;k&&(k=1/Math.sqrt(k),_=-b*k*u,I=y*k*u);var A=this.array;A[a++]=h,A[a++]=d,A[a++]=p,A[a++]=m,A[a++]=_,A[a++]=I,A[a++]=v,A[a++]=o,A[a++]=w}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,c=l.u_matrix,u=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,p=l.u_correctionRatio,m=l.u_sizeRatio,v=l.u_minEdgeThickness,y=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(c,!1,o.matrix),s.uniform1f(u,o.zoomRatio),s.uniform1f(m,o.sizeRatio),s.uniform1f(p,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(v,o.minEdgeThickness),s.uniform1f(y,t.lengthToThicknessRatio)}}])})(Wa)}var V0=gd();function Iv(e){return yv([gd(e),hd(e)])}var Gv=Iv(),md=Gv,Mv=`
268
267
  attribute vec4 a_id;
269
268
  attribute vec4 a_color;
270
269
  attribute vec2 a_normal;
@@ -329,57 +328,57 @@ void main() {
329
328
 
330
329
  v_color.a *= bias;
331
330
  }
332
- `,Tv=Sv,fd=WebGLRenderingContext,ed=fd.UNSIGNED_BYTE,er=fd.FLOAT,Rv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],gd=(function(e){function t(){return me(this,t),Ge(this,t,arguments)}return Oe(t,e),ve(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Tv,FRAGMENT_SHADER_SOURCE:cd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Rv,ATTRIBUTES:[{name:"a_positionStart",size:2,type:er},{name:"a_positionEnd",size:2,type:er},{name:"a_normal",size:2,type:er},{name:"a_color",size:4,type:ed,normalized:!0},{name:"a_id",size:4,type:ed,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:er},{name:"a_normalCoef",size:1,type:er}],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,p=kn(s.color),m=h-u,w=d-c,v=m*m+w*w,b=0,y=0;v&&(v=1/Math.sqrt(v),b=-w*v*l,y=m*v*l);var x=this.array;x[i++]=u,x[i++]=c,x[i++]=h,x[i++]=d,x[i++]=b,x[i++]=y,x[i++]=p,x[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,p=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(p,r.minEdgeThickness)}}])})(Aa);var Td=$n(di()),hi=(function(e){function t(){var n;return me(this,t),n=Ge(this,t),n.rawEmitter=n,n}return Oe(t,e),ve(t)})(Td.EventEmitter);var Ld=$n(Na());var Iv=function(t){return t},Mv=function(t){return t*t},Gv=function(t){return t*(2-t)},Ov=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Fv=function(t){return t*t*t},$v=function(t){return--t*t*t+1},zv=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Nd={linear:Iv,quadraticIn:Mv,quadraticOut:Gv,quadraticInOut:Ov,cubicIn:Fv,cubicOut:$v,cubicInOut:zv},Pd={easing:"quadraticInOut",duration:150};function Je(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function pi(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Ad(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Cd(e,t,n){return e[6]=t,e[7]=n,e}function Mt(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=t[0],d=t[1],p=t[2],m=t[3],w=t[4],v=t[5],b=t[6],y=t[7],x=t[8];return e[0]=h*n+d*o+p*l,e[1]=h*r+d*a+p*u,e[2]=h*i+d*s+p*c,e[3]=m*n+w*o+v*l,e[4]=m*r+w*a+v*u,e[5]=m*i+w*s+v*c,e[6]=b*n+y*o+x*l,e[7]=b*r+y*a+x*u,e[8]=b*i+y*s+x*c,e}function fi(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],a=e[4],s=e[6],l=e[7],u=t.x,c=t.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Wv(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function En(e,t,n,r,i){var o=e.angle,a=e.ratio,s=e.x,l=e.y,u=t.width,c=t.height,h=Je(),d=Math.min(u,c)-2*r,p=Wv(t,n);return i?(Mt(h,Cd(Je(),s,l)),Mt(h,pi(Je(),a)),Mt(h,Ad(Je(),o)),Mt(h,pi(Je(),u/d/2/p,c/d/2/p))):(Mt(h,pi(Je(),2*(d/u)*p,2*(d/c)*p)),Mt(h,Ad(Je(),-o)),Mt(h,pi(Je(),1/a)),Mt(h,Cd(Je(),-s,-l))),h}function Dd(e,t,n){var r=fi(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Id(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,a){var s=a.x,l=a.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function Md(e){if(!(0,Ld.default)(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Gd(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Pa(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Da(e,t,n){return n.sort(function(r,i){var o=t(r)||0,a=t(i)||0;return o<a?-1:o>a?1:0})}function Ia(e){var t=It(e.x,2),n=t[0],r=t[1],i=It(e.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 gi(e){"@babel/helpers - typeof";return gi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gi(e)}function Ma(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function mi(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var vi={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:id,defaultDrawNodeLabel:Ca,defaultDrawNodeHover:od,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:{}},Hv={circle:tr},Uv={arrow:pd,line:gd};function yi(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Od(e){var t=mi({},vi,e);return t.nodeProgramClasses=mi({},Hv,t.nodeProgramClasses),t.edgeProgramClasses=mi({},Uv,t.edgeProgramClasses),t}var rE=$n(di()),iE=$n(Na()),wi=1.5,Fd=(function(e){function t(){var n;return me(this,t),n=Ge(this,t),R(n,"x",.5),R(n,"y",.5),R(n,"angle",0),R(n,"ratio",1),R(n,"minRatio",null),R(n,"maxRatio",null),R(n,"enabledZooming",!0),R(n,"enabledPanning",!0),R(n,"enabledRotation",!0),R(n,"clean",null),R(n,"nextFrame",null),R(n,"previousState",null),R(n,"enabled",!0),n.previousState=n.getState(),n}return Oe(t,e),ve(t,[{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($($({},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(p){return i.animate(r,o,p)});if(this.enabled){var s=$($({},Pd),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:Nd[s.easing],c=Date.now(),h=this.getState(),d=function(){var m=(Date.now()-c)/s.duration;if(m>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=u(m),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*w),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*w),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*w),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*w),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||wi)},r):this.animate({ratio:this.ratio/wi})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||wi)},r):this.animate({ratio:this.ratio*wi})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(hi);function ot(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function kt(e,t){var n=$($({},ot(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function nr(e){var t="x"in e?e:$($({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function Bv(e,t){return $($({},kt(e,t)),{},{delta:Bd(e)})}var Kv=2;function bi(e){for(var t=[],n=0,r=Math.min(e.length,Kv);n<r;n++)t.push(e[n]);return t}function rr(e,t,n){var r={touches:bi(e.touches).map(function(i){return ot(i,n)}),previousTouches:t.map(function(i){return ot(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Bd(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Kd=(function(e){function t(n,r){var i;return me(this,t),i=Ge(this,t),i.container=n,i.renderer=r,i}return Oe(t,e),ve(t)})(hi),Vv=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],jv=Vv.reduce(function(e,t){return $($({},e),{},R({},t,vi[t]))},{}),qv=(function(e){function t(n,r){var i;return me(this,t),i=Ge(this,t,[n,r]),R(i,"enabled",!0),R(i,"draggedEvents",0),R(i,"downStartTime",null),R(i,"lastMouseX",null),R(i,"lastMouseY",null),R(i,"isMouseDown",!1),R(i,"isMoving",!1),R(i,"movingTimeout",null),R(i,"startCameraState",null),R(i,"clicks",0),R(i,"doubleClickTimeout",null),R(i,"currentWheelDirection",0),R(i,"settings",jv),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 Oe(t,e),ve(t,[{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",kt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",kt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=kt(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(ot(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=ot(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",kt(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=ot(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",kt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=kt(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=ot(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,p=c.y-h.y,m=a.getState(),w=m.x+d,v=m.y+p;a.setState({x:w,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",kt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",kt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Bd(r);if(a){var s=Bv(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(ot(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}}])})(Kd),Yv=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Xv=Yv.reduce(function(e,t){return $($({},e),{},R({},t,vi[t]))},{}),Zv=(function(e){function t(n,r){var i;return me(this,t),i=Ge(this,t,[n,r]),R(i,"enabled",!0),R(i,"isMoving",!1),R(i,"hasMoved",!1),R(i,"touchMode",0),R(i,"startTouchesPositions",[]),R(i,"lastTouches",[]),R(i,"lastTap",null),R(i,"settings",Xv),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 Oe(t,e),ve(t,[{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=bi(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(p){return ot(p,i.container)}),this.touchMode===2){var a=It(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",rr(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",rr(r,this.lastTouches,this.container)),!r.touches.length){var s=ot(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=rr(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 p=rr(r,this.lastTouches,this.container);this.emit("tap",p),this.lastTap={time:Date.now(),position:p.touches[0]||p.previousTouches[0]}}}this.lastTouches=bi(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=bi(r.touches),a=o.map(function(Ke){return ot(Ke,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=rr(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Ke,Ze){var Le=i.startTouchesPositions[Ze];return Le&&(Ke.x!==Le.x||Ke.y!==Le.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]),p=d.x,m=d.y,w=this.renderer.viewportToFramedGraph(a[0]),v=w.x,b=w.y;u.setState({x:c.x+p-v,y:c.y+m-b});break}case 2:{var y={x:.5,y:.5,angle:0,ratio:1},x=a[0],k=x.x,N=x.y,A=a[1],P=A.x,F=A.y,T=Math.atan2(F-N,P-k)-this.startTouchesAngle,C=Math.hypot(F-N,P-k)/this.startTouchesDistance,W=u.getBoundedRatio(c.ratio/C);y.ratio=W,y.angle=c.angle+T;var j=this.getDimensions(),Y=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ie=Math.min(j.width,j.height)-2*h,ce=ie/j.width,Fe=ie/j.height,Te=W/ie,_e=k-ie/2/ce,Ee=N-ie/2/Fe,Be=[_e*Math.cos(-y.angle)-Ee*Math.sin(-y.angle),Ee*Math.cos(-y.angle)+_e*Math.sin(-y.angle)];_e=Be[0],Ee=Be[1],y.x=Y.x-_e*Te,y.y=Y.y+Ee*Te,u.setState(y);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Kd);function Qv(e){if(Array.isArray(e))return si(e)}function Jv(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ey(){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 $d(e){return Qv(e)||Jv(e)||xa(e)||ey()}function ty(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ga(e,t){if(e==null)return{};var n,r,i=ty(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var zd=(function(){function e(t,n){me(this,e),this.key=t,this.size=n}return ve(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Wd=(function(){function e(){me(this,e),R(this,"width",0),R(this,"height",0),R(this,"cellSize",0),R(this,"columns",0),R(this,"rows",0),R(this,"cells",{})}return ve(e,[{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 zd(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(zd.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 ny(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.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 Hd=150,Ud=50,_t=Object.prototype.hasOwnProperty;function ry(e,t,n){if(!_t.call(n,"x")||!_t.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". 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=e.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),_t.call(n,"hidden")||(n.hidden=!1),_t.call(n,"highlighted")||(n.highlighted=!1),_t.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function iy(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),_t.call(n,"hidden")||(n.hidden=!1),_t.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var oy=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(me(this,t),i=Ge(this,t),R(i,"elements",{}),R(i,"canvasContexts",{}),R(i,"webGLContexts",{}),R(i,"pickingLayers",new Set),R(i,"textures",{}),R(i,"frameBuffers",{}),R(i,"activeListeners",{}),R(i,"labelGrid",new Wd),R(i,"nodeDataCache",{}),R(i,"edgeDataCache",{}),R(i,"nodeProgramIndex",{}),R(i,"edgeProgramIndex",{}),R(i,"nodesWithForcedLabels",new Set),R(i,"edgesWithForcedLabels",new Set),R(i,"nodeExtent",{x:[0,1],y:[0,1]}),R(i,"nodeZExtent",[1/0,-1/0]),R(i,"edgeZExtent",[1/0,-1/0]),R(i,"matrix",Je()),R(i,"invMatrix",Je()),R(i,"correctionRatio",1),R(i,"customBBox",null),R(i,"normalizationFunction",Ia({x:[0,1],y:[0,1]})),R(i,"graphToViewportRatio",1),R(i,"itemIDsIndex",{}),R(i,"nodeIndices",{}),R(i,"edgeIndices",{}),R(i,"width",0),R(i,"height",0),R(i,"pixelRatio",Pa()),R(i,"pickingDownSizingRatio",2*i.pixelRatio),R(i,"displayedNodeLabels",new Set),R(i,"displayedEdgeLabels",new Set),R(i,"highlightedNodes",new Set),R(i,"hoveredNode",null),R(i,"hoveredEdge",null),R(i,"renderFrame",null),R(i,"renderHighlightedNodesFrame",null),R(i,"needToProcess",!1),R(i,"checkEdgesEventsFrame",null),R(i,"nodePrograms",{}),R(i,"nodeHoverPrograms",{}),R(i,"edgePrograms",{}),i.settings=Od(o),yi(i.settings),Md(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 Fd,i.bindCameraHandlers(),i.mouseCaptor=new qv(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Zv(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Oe(t,e),ve(t,[{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=Ga(i,[r].map(Jt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=Ga(s,[r].map(Jt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Ga(i,[r].map(Jt));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=Ea(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=_a.apply(void 0,$d(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=nr(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",$($({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",$($({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",$($({},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",$($({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",$($({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=nr(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=nr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",$($({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",$($({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",$({},s))},this.activeListeners.handleEnter=function(o){var a=nr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",$({},s))};var i=function(a){return function(s){var l=nr(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),$($({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),$($({},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=Ea(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=_a.apply(void 0,$d(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=Id(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=Ia(this.customBBox||this.nodeExtent);var d=new Fd,p=En(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var m={},w={},v={},b={},y=1,x=i.nodes(),k=0,N=x.length;k<N;k++){var A=x[k],P=this.nodeDataCache[A],F=i.getNodeAttributes(A);P.x=F.x,P.y=F.y,this.normalizationFunction.applyTo(P),typeof P.label=="string"&&!P.hidden&&this.labelGrid.add(A,P.size,this.framedGraphToViewport(P,{matrix:p})),m[P.type]=(m[P.type]||0)+1}this.labelGrid.organize();for(var T in this.nodePrograms){if(!_t.call(this.nodePrograms,T))throw new Error('Sigma: could not find a suitable program for node type "'.concat(T,'"!'));this.nodePrograms[T].reallocate(m[T]||0),m[T]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(x=Da(this.nodeZExtent,function(Ft){return r.nodeDataCache[Ft].zIndex},x));for(var C=0,W=x.length;C<W;C++){var j=x[C];w[j]=y,b[w[j]]={type:"node",id:j},y++;var Y=this.nodeDataCache[j];this.addNodeToProgram(j,w[j],m[Y.type]++)}for(var ie={},ce=i.edges(),Fe=0,Te=ce.length;Fe<Te;Fe++){var _e=ce[Fe],Ee=this.edgeDataCache[_e];ie[Ee.type]=(ie[Ee.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ce=Da(this.edgeZExtent,function(Ft){return r.edgeDataCache[Ft].zIndex},ce));for(var Be in this.edgePrograms){if(!_t.call(this.edgePrograms,Be))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Be,'"!'));this.edgePrograms[Be].reallocate(ie[Be]||0),ie[Be]=0}for(var Ke=0,Ze=ce.length;Ke<Ze;Ke++){var Le=ce[Ke];v[Le]=y,b[v[Le]]={type:"edge",id:Le},y++;var Q=this.edgeDataCache[Le];this.addEdgeToProgram(Le,v[Le],ie[Q.type]++)}return this.itemIDsIndex=b,this.nodeIndices=w,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&&gi(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=$({},r),u=s||this.nodeExtent,c=It(u.x,2),h=c[0],d=c[1],p=It(u.y,2),m=p[0],w=p[1],v=[this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:h,y:w},{cameraState:r}),this.graphToViewport({x:d,y:w},{cameraState:r})],b=1/0,y=-1/0,x=1/0,k=-1/0;v.forEach(function(ie){var ce=ie.x,Fe=ie.y;b=Math.min(b,ce),y=Math.max(y,ce),x=Math.min(x,Fe),k=Math.max(k,Fe)});var N=y-b,A=k-x,P=this.getDimensions(),F=P.width,T=P.height,C=0,W=0;if(N>=F?y<F-a?C=y-(F-a):b>a&&(C=b-a):y>F+a?C=y-(F+a):b<-a&&(C=b+a),A>=T?k<T-a?W=k-(T-a):x>a&&(W=x-a):k>T+a?W=k-(T+a):x<-a&&(W=x+a),C||W){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Y=this.viewportToFramedGraph({x:C,y:W},{cameraState:r});C=Y.x-j.x,W=Y.y-j.y,l.x+=C,l.y+=W}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);Ma(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,p=this.scaleSize(u.size);if(!(!u.forceLabel&&p<this.settings.labelRenderedSizeThreshold)&&!(h<-Hd||h>this.width+Hd||d<-Ud||d>this.height+Ud)){this.displayedNodeLabels.add(l);var m=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[u.type],v=w?.drawLabel||m;v(o,$($({key:l},u),{},{size:p,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=ny({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ma(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 p=this.settings.defaultDrawEdgeLabel,m=this.edgePrograms[d.type],w=m?.drawLabel||p;w(r,$($({key:l},d),{},{size:this.scaleSize(d.size)}),$($($({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),$($($({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(p){var m=r.nodeDataCache[p],w=r.framedGraphToViewport(m),v=w.x,b=w.y,y=r.scaleSize(m.size),x=r.settings.defaultDrawNodeHover,k=r.nodePrograms[m.type],N=k?.drawHover||x;N(i,$($({key:p},m),{},{size:y,x:v,y:b}),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 p=r.nodeDataCache[d].type;s[p]=(s[p]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var p=r.nodeDataCache[d];r.nodeHoverPrograms[p.type].process(0,s[p.type]++,p)}),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=En(s,l,u,c),this.invMatrix=En(s,l,u,c,!0),this.correctionRatio=Dd(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var p=this.nodePrograms[d];p.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var m in this.edgePrograms){var w=this.edgePrograms[m];w.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=ry(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=iy(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 Wd,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=Gd(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=$({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 $({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=$({},this.settings);return this.settings[r]=i,yi(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=$({},this.settings);return this.settings=$($({},this.settings),r),yi(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=Pa(),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 p=c[h];if(this.updateNode(p),o){var m=this.nodeProgramIndex[p];if(m===void 0)throw new Error('Sigma: node "'.concat(p,`" can't be repaint`));this.addNodeToProgram(p,this.nodeIndices[p],m)}}for(var w=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,b=w.length;v<b;v++){var y=w[v];if(this.updateEdge(y),o){var x=this.edgeProgramIndex[y];if(x===void 0)throw new Error('Sigma: edge "'.concat(y,`" can't be repaint`));this.addEdgeToProgram(y,this.edgeIndices[y],x)}}}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($($({},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 p=i/a,m={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(m);return{angle:s,x:(w.x-v.x)*(1-p)+l,y:(w.y-v.y)*(1-p)+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?En(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=fi(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?En(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=fi(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}}])})(hi),Vd=oy;var Xd=$n(di(),1);function ay(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let r in arguments[t])e[r]=arguments[t][r];return e}var ye=ay;typeof Object.assign=="function"&&(ye=Object.assign);function tt(e,t,n,r){let i=e._nodes.get(t),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 Se(e){return typeof e=="object"&&e!==null}function Zd(e){let t;for(t in e)return!1;return!0}function et(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function at(e,t,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function jd(e){return!(!Se(e)||e.attributes&&!Array.isArray(e.attributes))}function sy(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Et(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Tn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var ar=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},G=class e extends ar{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},D=class e extends ar{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},H=class e extends ar{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function Qd(e,t){this.key=e,this.attributes=t,this.clear()}Qd.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 Jd(e,t){this.key=e,this.attributes=t,this.clear()}Jd.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function eh(e,t){this.key=e,this.attributes=t,this.clear()}eh.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Rn(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Rn.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Rn.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};Rn.prototype.detach=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Rn.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var th=0,nh=1,ly=2,rh=3;function St(e,t,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===th){if(s=e._nodes.get(r),!s)throw new D(`Graph.${t}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===rh){if(i=""+i,l=e._edges.get(i),!l)throw new D(`Graph.${t}: 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 D(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=e._edges.get(r),!l)throw new D(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===nh?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function uy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);return a.attributes[s]}}function cy(e,t,n){e.prototype[t]=function(r,i){let[o]=St(this,t,n,r,i);return o.attributes}}function dy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function hy(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,u]=St(this,t,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 py(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,u]=St(this,t,n,r,i,o,a);if(typeof u!="function")throw new G(`Graph.${t}: 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 fy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function gy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);if(!Se(s))throw new G(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function my(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);if(!Se(s))throw new G(`Graph.${t}: provided attributes are not a plain object.`);return ye(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function vy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=St(this,t,n,r,i,o);if(typeof s!="function")throw new G(`Graph.${t}: 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 yy=[{name:e=>`get${e}Attribute`,attacher:uy},{name:e=>`get${e}Attributes`,attacher:cy},{name:e=>`has${e}Attribute`,attacher:dy},{name:e=>`set${e}Attribute`,attacher:hy},{name:e=>`update${e}Attribute`,attacher:py},{name:e=>`remove${e}Attribute`,attacher:fy},{name:e=>`replace${e}Attributes`,attacher:gy},{name:e=>`merge${e}Attributes`,attacher:my},{name:e=>`update${e}Attributes`,attacher:vy}];function wy(e){yy.forEach(function({name:t,attacher:n}){n(e,t("Node"),th),n(e,t("Source"),nh),n(e,t("Target"),ly),n(e,t("Opposite"),rh)})}function by(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function xy(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,o,a,n),!i)throw new D(`Graph.${t}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function ky(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function _y(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,s,l,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: 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 Ey(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,s,l,n),!a)throw new D(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new G(`Graph.${t}: 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 Sy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: 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 Ty(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Se(i))throw new G(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ry(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Se(i))throw new G(`Graph.${t}: provided attributes are not a plain object.`);return ye(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Ay(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new D(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 D(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new G(`Graph.${t}: 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 Cy=[{name:e=>`get${e}Attribute`,attacher:by},{name:e=>`get${e}Attributes`,attacher:xy},{name:e=>`has${e}Attribute`,attacher:ky},{name:e=>`set${e}Attribute`,attacher:_y},{name:e=>`update${e}Attribute`,attacher:Ey},{name:e=>`remove${e}Attribute`,attacher:Sy},{name:e=>`replace${e}Attributes`,attacher:Ty},{name:e=>`merge${e}Attributes`,attacher:Ry},{name:e=>`update${e}Attributes`,attacher:Ay}];function Ly(e){Cy.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Ny=[{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 Py(e,t,n,r){let i=!1;for(let o in t){if(o===r)continue;let a=t[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&i)return a.key}}function Dy(e,t,n,r){let i,o,a,s=!1;for(let l in t)if(l!==r){i=t[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),e&&s)return i.key;i=i.next}while(i!==void 0)}}function Oa(e,t){let n=Object.keys(e),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===t){i=void 0;continue}i=e[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 Iy(e,t,n,r){let i=t[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)&&e)return i.key}function My(e,t,n,r){let i=t[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),e&&o)return i.key;i=i.next}while(i!==void 0)}function Fa(e,t){let n=e[t];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 Gy(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());let n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._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 ih(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,o=n==="undirected",a,s,l=!1,u=t._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:p}=s;if(l=r(c,h,d.key,p.key,d.attributes,p.attributes,s.undirected),e&&l)return c}}function Oy(e,t){if(e.size===0)return Tn();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._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 $a(e,t,n,r,i,o){let a=t?Dy:Py,s;if(n!=="undirected"&&(r!=="out"&&(s=a(e,i.in,o),e&&s)||r!=="in"&&(s=a(e,i.out,o,r?void 0:i.key),e&&s))||n!=="directed"&&(s=a(e,i.undirected,o),e&&s))return s}function Fy(e,t,n,r){let i=[];return $a(!1,e,t,n,r,function(o){i.push(o)}),i}function $y(e,t,n){let r=Tn();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Et(r,Oa(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Et(r,Oa(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Et(r,Oa(n.undirected))),r}function za(e,t,n,r,i,o,a){let s=n?My:Iy,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,o,a),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(e,i.out,o,a),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,o,a),e&&l))return l}function zy(e,t,n,r,i){let o=[];return za(!1,e,t,n,r,i,function(a){o.push(a)}),o}function Wy(e,t,n,r){let i=Tn();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=Et(i,Fa(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=Et(i,Fa(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Et(i,Fa(n.undirected,r))),i}function Hy(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return Gy(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new D(`Graph.${n}: could not find the "${o}" node in the graph.`);return Fy(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 D(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new D(`Graph.${n}: could not find the "${a}" target node in the graph.`);return zy(r,this.multi,i,s,a)}throw new G(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Uy(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,ih(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new D(`Graph.${o}: could not find the "${u}" node in the graph.`);return $a(!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 D(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new D(`Graph.${o}: could not find the "${c}" target node in the graph.`);return za(!1,r,this.multi,i,d,c,h)}throw new G(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);e.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 p=0;u.push((m,w,v,b,y,x,k)=>{h[p++]=c(m,w,v,b,y,x,k)})}else h=[],u.push((d,p,m,w,v,b,y)=>{h.push(c(d,p,m,w,v,b,y))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,p,m,w,v,b,y)=>{c(d,p,m,w,v,b,y)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new G(`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 G(`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((p,m,w,v,b,y,x)=>{d=c(d,p,m,w,v,b,y,x)}),this[o].apply(this,u),d}}function By(e,t){let{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,ih(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new D(`Graph.${o}: could not find the "${l}" node in the graph.`);return $a(!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 D(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new D(`Graph.${o}: could not find the "${u}" target node in the graph.`);return za(!0,r,this.multi,i,h,u,c)}throw new G(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,p,m,w,v,b)=>u(h,d,p,m,w,v,b)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,p,m,w,v,b)=>!u(h,d,p,m,w,v,b)),!this[o].apply(this,l)}}function Ky(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Tn();if(!arguments.length)return Oy(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new D(`Graph.${o}: could not find the "${a}" node in the graph.`);return $y(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new D(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new D(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Wy(r,i,l,s)}throw new G(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Vy(e){Ny.forEach(t=>{Hy(e,t),Uy(e,t),By(e,t),Ky(e,t)})}var jy=[{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 Ri(){this.A=null,this.B=null}Ri.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};Ri.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function ir(e,t,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(t&&t.has(u.key))continue;let c=i(u.key,u.attributes);if(e&&c)return u.key}}function Wa(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return ir(e,null,r,r.undirected,i);if(typeof n=="string")return ir(e,null,r,r[n],i)}let o=new Ri,a;if(t!=="undirected"){if(n!=="out"){if(a=ir(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=ir(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=ir(e,o,r,r.undirected,i),e&&a))return a}function qy(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}let r=[];return Wa(!1,e,t,n,function(i){r.push(i)}),r}function or(e,t,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 e&&e.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===t?u:l,e&&e.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Yy(e,t,n){if(e!=="mixed"){if(e==="undirected")return or(null,n,n.undirected);if(typeof t=="string")return or(null,n,n[t])}let r=Tn(),i=new Ri;return e!=="undirected"&&(t!=="out"&&(r=Et(r,or(i,n,n.in))),t!=="in"&&(r=Et(r,or(i,n,n.out)))),e!=="directed"&&(r=Et(r,or(i,n,n.undirected))),r}function Xy(e,t){let{name:n,type:r,direction:i}=t;e.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 D(`Graph.${n}: could not find the "${o}" node in the graph.`);return qy(r==="mixed"?this.type:r,i,a)}}function Zy(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.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 D(`Graph.${o}: could not find the "${u}" node in the graph.`);Wa(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(u,c){let h=[];return this[o](u,(d,p)=>{h.push(c(d,p))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(u,c){let h=[];return this[o](u,(d,p)=>{c(d,p)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(u,c,h){if(arguments.length<3)throw new G(`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,(p,m)=>{d=c(d,p,m)}),d}}function Qy(e,t){let{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;e.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 D(`Graph.${a}: could not find the "${u}" node in the graph.`);return Wa(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;e.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;e.prototype[l]=function(u,c){return!this[a](u,(d,p)=>!c(d,p))}}function Jy(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Tn();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new D(`Graph.${o}: could not find the "${a}" node in the graph.`);return Yy(r==="mixed"?this.type:r,i,s)}}function ew(e){jy.forEach(t=>{Xy(e,t),Zy(e,t),Qy(e,t),Jy(e,t)})}function xi(e,t,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,p;for(;s=o.next(),s.done!==!0;){let m=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,m=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(t&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),m=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(n&&!m&&(p=i(l.key,null,l.attributes,null,null,null,null),e&&p))return null}}function tw(e,t){let n={key:e};return Zd(t.attributes)||(n.attributes=ye({},t.attributes)),n}function nw(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return Zd(n.attributes)||(r.attributes=ye({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function rw(e){if(!Se(e))throw new G('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new G("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!Se(e.attributes)||e.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function iw(e){if(!Se(e))throw new G('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new G("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new G("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!Se(e.attributes)||e.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new G("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var ow=sy(),aw=new Set(["directed","undirected","mixed"]),qd=new Set(["domain","_events","_eventsCount","_maxListeners"]),sw=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],lw={allowSelfLoops:!0,multi:!1,type:"mixed"};function uw(e,t,n){if(n&&!Se(n))throw new G(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new H(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function Yd(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function oh(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new H(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new H(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Se(s))throw new G(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!e.allowSelfLoops&&o===a)throw new H(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),u=e._nodes.get(a);if(!l)throw new D(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new D(`Graph.${t}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new H(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new H(`Graph.${t}: 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 Rn(r,i,l,u,s);e._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,c.key=i,e.emit("edgeAdded",c),i}function cw(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new H(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new H(`Graph.${t}: 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 G(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!Se(s))throw new G(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!e.allowSelfLoops&&o===a)throw new H(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=e._nodes.get(o),h=e._nodes.get(a),d,p;if(!n&&(d=e._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new H(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);p=d}if(!p&&!e.multi&&c&&(p=r?c.undirected[a]:c.out[a]),p){let y=[p.key,!1,!1,!1];if(l?!u:!s)return y;if(l){let x=p.attributes;p.attributes=u(x),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else ye(p.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:s});return y}s=s||{},l&&u&&(s=u(s));let m={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new H(`Graph.${t}: the "${i}" edge already exists in the graph.`);let w=!1,v=!1;c||(c=Yd(e,o,{}),w=!0,o===a&&(h=c,v=!0)),h||(h=Yd(e,a,{}),v=!0),d=new Rn(r,i,c,h,s),e._edges.set(i,d);let b=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,b&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,b&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,m.key=i,e.emit("edgeAdded",m),[i,!0,w,v]}function Sn(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,o=t.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}var ne=class e extends Xd.EventEmitter{constructor(t){if(super(),t=ye({},lw,t),typeof t.multi!="boolean")throw new G(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!aw.has(t.type))throw new G(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new G(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?Qd:t.type==="directed"?Jd:eh;et(this,"NodeDataClass",n);let r="geid_"+ow()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};et(this,"_attributes",{}),et(this,"_nodes",new Map),et(this,"_edges",new Map),et(this,"_directedSize",0),et(this,"_undirectedSize",0),et(this,"_directedSelfLoopCount",0),et(this,"_undirectedSelfLoopCount",0),et(this,"_edgeKeyGenerator",o),et(this,"_options",t),qd.forEach(a=>et(this,a,this[a])),at(this,"order",()=>this._nodes.size),at(this,"size",()=>this._edges.size),at(this,"directedSize",()=>this._directedSize),at(this,"undirectedSize",()=>this._undirectedSize),at(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),at(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),at(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),at(this,"multi",this._options.multi),at(this,"type",this._options.type),at(this,"allowSelfLoops",this._options.allowSelfLoops),at(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new G(`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(t,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new G(`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(t,n){if(arguments.length===1){let r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new G(`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(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new H("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(t);if(!r)throw new D(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new H("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(t);if(!r)throw new D(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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(t,n){if(this.multi)throw new H("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new D(`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(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new D(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.degreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;let r=this._edges.get(n);if(!r)throw new D(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new D(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new D(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;let n=this._edges.get(t);if(!n)throw new D(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return uw(this,t,n).key}mergeNode(t,n){if(n&&!Se(n))throw new G(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(ye(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new G(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new D(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Sn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Sn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Sn(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=tt(this,r,i,this.type),!n)throw new D(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new D(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Sn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new H("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 H("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.");t=""+t,n=""+n;let r=tt(this,t,n,"directed");if(!r)throw new D(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Sn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new H("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 H("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=tt(this,t,n,"undirected");if(!r)throw new D(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Sn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let t=this._nodes.values(),n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new G("Graph.updateAttribute: updater should be a function.");let r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!Se(t))throw new G("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!Se(t))throw new G("Graph.mergeAttributes: provided attributes are not a plain object.");return ye(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new G("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new G("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!jd(n))throw new G("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=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new G("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!jd(n))throw new G("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=t(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new G("Graph.forEachAdjacencyEntry: expecting a callback.");xi(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new G("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");xi(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new G("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");xi(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new G("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");xi(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new G("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new G("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new G("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++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new G("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new G("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new G("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new G("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new G("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=t(r,a.key,a.attributes);return r}nodeEntries(){let t=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let t=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{t[n++]=tw(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=nw(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof e)return t.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),t.forEachEdge((l,u,c,h,d,p,m)=>{n?m?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):m?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!Se(t))throw new G("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Se(t.attributes))throw new G("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,a,s;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new G("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],rw(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=t.edges,!Array.isArray(o))throw new G("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],iw(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,p;"key"in s?(p=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,p.call(this,s.key,u,c,h)):(p=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,p.call(this,u,c,h))}}return this}nullCopy(t){let n=new e(ye({},this._options,t));return n.replaceAttributes(ye({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let o=ye({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new H(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new H("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new H("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(t),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,oh(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ye({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((o,a)=>{t[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)&&!qd.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,et(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(ne.prototype[Symbol.for("nodejs.util.inspect.custom")]=ne.prototype.inspect);sw.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?oh:cw;e.generateKey?ne.prototype[n]=function(i,o,a){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,a,t==="update")}:ne.prototype[n]=function(i,o,a,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,a,s,t==="update")}})});wy(ne);Ly(ne);Vy(ne);ew(ne);var ki=class extends ne{constructor(t){let n=ye({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new G("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new G('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},_i=class extends ne{constructor(t){let n=ye({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new G("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new G('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Ei=class extends ne{constructor(t){let n=ye({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new G("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Si=class extends ne{constructor(t){let n=ye({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new G("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new G('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Ti=class extends ne{constructor(t){let n=ye({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new G("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new G('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function An(e){e.from=function(t,n){let r=ye({},t.options,n),i=new e(r);return i.import(t),i}}An(ne);An(ki);An(_i);An(Ei);An(Si);An(Ti);ne.Graph=ne;ne.DirectedGraph=ki;ne.UndirectedGraph=_i;ne.MultiGraph=Ei;ne.MultiDirectedGraph=Si;ne.MultiUndirectedGraph=Ti;ne.InvalidArgumentsGraphError=G;ne.NotFoundGraphError=D;ne.UsageGraphError=H;function dw(){return new ne({multi:!0,type:"directed"})}function Ha(e){let t=dw();for(let n of e.nodes){let{id:r,...i}=n;t.addNode(r,i)}for(let n of e.edges){let{key:r,source:i,target:o,...a}=n;t.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return t}function ah(e,t){let n=0;for(let[r,i]of t)e.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(e.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Ua(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var sh=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function lh(e,t,n){let r=null,i=Ha({nodes:[],edges:[]}),o=null,a=null,s=0,l=0,u=null,c=0,h=()=>{},d=()=>{},p=()=>{},m=()=>{},w=()=>{},v=null,b=!1,y=A=>{if(v===null)return;let P=v;v=null,r?.setSetting("enableCameraPanning",!0),(A===null||A===P)&&w(P)},x=()=>Zu([...Ua(i).values()]),k=A=>{let P=tc(o,a,s),F=rc(o,a,s);A.setSetting("nodeReducer",(T,C)=>({...C,...P(T,C,t)})),A.setSetting("edgeReducer",(T,C)=>({...C,...F(T,C,t)}))},N=()=>{if(n===void 0||u!==null)return;c=n.now();let A=()=>{u=null;let P=n.now();if(s=nc(s,l,P-c),c=P,r!==null&&k(r),s===l){s===0&&(o=null);return}u=n.request(A)};u=n.request(A)};return{mount(A){if(r!==null)return;let P=e(i,A,ic(t));P.on("clickNode",({node:F})=>{b||h(F)}),P.on("doubleClickNode",({node:F,preventSigmaDefault:T})=>{T(),b||h(F)}),P.on("clickStage",()=>h(null)),P.on("downNode",({node:F})=>{v=F,b=!1,r?.setSetting("enableCameraPanning",!1),p(F)}),P.on("moveBody",F=>{v!==null&&(b=!0,F.preventSigmaDefault(),m(v,P.viewportToGraph({x:F.event.x,y:F.event.y})))}),P.on("enterNode",({node:F})=>d(F)),P.on("leaveNode",()=>d(null)),P.on("upNode",()=>y(v)),P.on("upStage",()=>y(null)),k(P),P.setCustomBBox(x()),r=P},setGraph(A){i=Ha(A),r?.setGraph(i),r?.setCustomBBox(x())},setPositions(A){ah(i,A),r?.refresh()},setHighlight(A,P=null){if(n===void 0){o=A,a=P,s=A===null?0:1,l=s,r!==null&&k(r);return}if(A===null){if(l=0,o===null)return}else o=A,a=P,l=1;r!==null&&k(r),s!==l&&N()},onSelect(A){h=A},onHover(A){d=A},onDragStart(A){p=A},onDragMove(A){m=A},onDragEnd(A){w=A},fit(){r?.setCustomBBox(x()),r?.getCamera().animatedReset()},positions(){return Ua(i)},destroy(){u!==null&&(n?.cancel(u),u=null),r?.kill(),r=null}}}var uh=e=>lh((t,n,r)=>new Vd(t,n,r),e,sh(window));function ch(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hw(e){if(Array.isArray(e))return e}function pw(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);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 fw(){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 gw(e,t){return hw(e)||pw(e,t)||mw(e,t)||fw()}function mw(e,t){if(e){if(typeof e=="string")return ch(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ch(e,t):void 0}}var Sh=Object.entries,dh=Object.setPrototypeOf,vw=Object.isFrozen,yw=Object.getPrototypeOf,ww=Object.getOwnPropertyDescriptor,we=Object.freeze,ke=Object.seal,Cn=Object.create,Th=typeof Reflect<"u"&&Reflect,Xa=Th.apply,Za=Th.construct;we||(we=function(t){return t});ke||(ke=function(t){return t});Xa||(Xa=function(t,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 t.apply(n,i)});Za||(Za=function(t){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 t(...r)});var nn=ge(Array.prototype.forEach),bw=ge(Array.prototype.lastIndexOf),hh=ge(Array.prototype.pop),sr=ge(Array.prototype.push),xw=ge(Array.prototype.splice),Ln=Array.isArray,cr=ge(String.prototype.toLowerCase),Ba=ge(String.prototype.toString),ph=ge(String.prototype.match),lr=ge(String.prototype.replace),fh=ge(String.prototype.indexOf),kw=ge(String.prototype.trim),_w=ge(Number.prototype.toString),Ew=ge(Boolean.prototype.toString),gh=typeof BigInt>"u"?null:ge(BigInt.prototype.toString),mh=typeof Symbol>"u"?null:ge(Symbol.prototype.toString),He=ge(Object.prototype.hasOwnProperty),ur=ge(Object.prototype.toString),Ae=ge(RegExp.prototype.test),tn=Sw(TypeError);function ge(e){return function(t){t instanceof RegExp&&(t.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 Xa(e,t,r)}}function Sw(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Za(e,n)}}function Z(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:cr;if(dh&&dh(e,null),!Ln(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let o=n(i);o!==i&&(vw(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Tw(e){for(let t=0;t<e.length;t++)He(e,t)||(e[t]=null);return e}function Ye(e){let t=Cn(null);for(let r of Sh(e)){var n=gw(r,2);let i=n[0],o=n[1];He(e,i)&&(Ln(o)?t[i]=Tw(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Ye(o):t[i]=o)}return t}function Rw(e){switch(typeof e){case"string":return e;case"number":return _w(e);case"boolean":return Ew(e);case"bigint":return gh?gh(e):"0";case"symbol":return mh?mh(e):"Symbol()";case"undefined":return ur(e);case"function":case"object":{if(e===null)return ur(e);let t=e,n=st(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:ur(r)}return ur(e)}default:return ur(e)}}function st(e,t){for(;e!==null;){let r=ww(e,t);if(r){if(r.get)return ge(r.get);if(typeof r.value=="function")return ge(r.value)}e=yw(e)}function n(){return null}return n}function Aw(e){try{return Ae(e,""),!0}catch{return!1}}var vh=we(["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"]),Ka=we(["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"]),Va=we(["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"]),Cw=we(["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"]),ja=we(["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"]),Lw=we(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),yh=we(["#text"]),wh=we(["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"]),qa=we(["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"]),bh=we(["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"]),Ai=we(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Nw=ke(/{{[\w\W]*|^[\w\W]*}}/g),Pw=ke(/<%[\w\W]*|^[\w\W]*%>/g),Dw=ke(/\${[\w\W]*/g),Iw=ke(/^data-[\-\w.\u00B7-\uFFFF]+$/),Mw=ke(/^aria-[\-\w]+$/),xh=ke(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Gw=ke(/^(?:\w+script|data):/i),Ow=ke(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Fw=ke(/^html$/i),$w=ke(/^[a-z][.\w]*(-[.\w]+)+$/i),kh=ke(/<[/\w!]/g),_h=ke(/<[/\w]/g),zw=ke(/<\/no(script|embed|frames)/i),Ww=ke(/\/>/i),qe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Rh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Hw=we(Z({},Rh)),Uw=(function(){let e={};return nn(Rh,t=>{e[t]=ke(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),we(e)})(),Bw=function(){return typeof window>"u"?null:window},Kw=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Eh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Gt=function(t,n,r,i){return He(t,n)&&Ln(t[n])?Z(i.base?Ye(i.base):{},t[n],i.transform):r},Ya=function(t,n,r){let i=He(t,n)?t[n]:void 0;return i&&typeof i=="object"?Ye(i):r()};function Ah(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Bw(),t=L=>Ah(L);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==qe.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,a=e.Node,s=e.Element,l=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let c=e.DOMParser,h=e.trustedTypes,d=s.prototype,p=st(d,"cloneNode"),m=st(d,"remove"),w=st(d,"nextSibling"),v=st(d,"childNodes"),b=st(d,"parentNode"),y=st(d,"shadowRoot"),x=st(d,"attributes"),k=a&&a.prototype?st(a.prototype,"nodeType"):null,N=a&&a.prototype?st(a.prototype,"nodeName"):null,A=a&&a.prototype?st(a.prototype,"ownerDocument"):null,P=function(f){return k?k(f):f.nodeType},F=function(f){return N?N(f):f.nodeName};if(typeof o=="function"){let L=n.createElement("template");L.content&&L.content.ownerDocument&&(n=L.content.ownerDocument)}let T,C="",W,j=!1,Y=0,ie=function(){if(Y>0)throw tn('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.')},ce=function(f){ie(),Y++;try{return T.createHTML(f)}finally{Y--}},Fe=function(f){ie(),Y++;try{return T.createScriptURL(f)}finally{Y--}},Te=function(){return j||(W=Kw(h,i),j=!0),W},_e=n,Ee=_e.implementation,Be=_e.createNodeIterator,Ke=_e.createDocumentFragment,Ze=_e.getElementsByTagName,Le=r.importNode,Q=Eh();t.isSupported=typeof Sh=="function"&&typeof b=="function"&&Ee&&Ee.createHTMLDocument!==void 0;let Ft=Nw,Xi=Pw,Zi=Dw,mr=Iw,Dn=Mw,Ve=Gw,Ne=Ow,ft=$w,$t=xh,oe=null,$e=Z({},[...vh,...Ka,...Va,...ja,...yh]),J=null,gt=Z({},[...wh,...qa,...bh,...Ai]),pe=Object.seal(Cn(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}})),At=null,In=null,ut=Object.seal(Cn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),vr=!0,Mn=!0,Gn=!1,yr=!0,nt=!1,ct=!0,mt=!1,E=!1,I=null,K=null,O=!1,B=!1,be=!1,rt=!1,Ct=!0,ms=!1,vs="user-content-",Qi=!0,Ji=!1,ln={},un=null,ys=Z({},["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"]),ws=null,bs=Z({},["audio","video","img","source","image","track"]),xs=null,ks=Z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),wr="http://www.w3.org/1998/Math/MathML",br="http://www.w3.org/2000/svg",dt="http://www.w3.org/1999/xhtml",cn=dt,eo=!1,to=null,hf=Z({},[wr,br,dt],Ba),_s=we(["mi","mo","mn","ms","mtext"]),no=Z({},_s),Es=we(["annotation-xml"]),ro=Z({},Es),pf=Z({},["title","style","font","a","script"]),On=null,ff=["application/xhtml+xml","text/html"],gf="text/html",de=null,dn=null,mf=n.createElement("form"),Ss=function(f){return f instanceof RegExp||f instanceof Function},io=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(dn&&dn===f)return;(!f||typeof f!="object")&&(f={}),f=Ye(f),On=ff.indexOf(f.PARSER_MEDIA_TYPE)===-1?gf:f.PARSER_MEDIA_TYPE,de=On==="application/xhtml+xml"?Ba:cr,oe=Gt(f,"ALLOWED_TAGS",$e,{transform:de}),J=Gt(f,"ALLOWED_ATTR",gt,{transform:de}),to=Gt(f,"ALLOWED_NAMESPACES",hf,{transform:Ba}),xs=Gt(f,"ADD_URI_SAFE_ATTR",ks,{transform:de,base:ks}),ws=Gt(f,"ADD_DATA_URI_TAGS",bs,{transform:de,base:bs}),un=Gt(f,"FORBID_CONTENTS",ys,{transform:de}),At=Gt(f,"FORBID_TAGS",Ye({}),{transform:de}),In=Gt(f,"FORBID_ATTR",Ye({}),{transform:de}),ln=He(f,"USE_PROFILES")?f.USE_PROFILES&&typeof f.USE_PROFILES=="object"?Ye(f.USE_PROFILES):f.USE_PROFILES:!1,vr=f.ALLOW_ARIA_ATTR!==!1,Mn=f.ALLOW_DATA_ATTR!==!1,Gn=f.ALLOW_UNKNOWN_PROTOCOLS||!1,yr=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,nt=f.SAFE_FOR_TEMPLATES||!1,ct=f.SAFE_FOR_XML!==!1,mt=f.WHOLE_DOCUMENT||!1,B=f.RETURN_DOM||!1,be=f.RETURN_DOM_FRAGMENT||!1,rt=f.RETURN_TRUSTED_TYPE||!1,O=f.FORCE_BODY||!1,Ct=f.SANITIZE_DOM!==!1,ms=f.SANITIZE_NAMED_PROPS||!1,Qi=f.KEEP_CONTENT!==!1,Ji=f.IN_PLACE||!1,$t=Aw(f.ALLOWED_URI_REGEXP)?f.ALLOWED_URI_REGEXP:xh,cn=typeof f.NAMESPACE=="string"?f.NAMESPACE:dt,no=Ya(f,"MATHML_TEXT_INTEGRATION_POINTS",()=>Z({},_s)),ro=Ya(f,"HTML_INTEGRATION_POINTS",()=>Z({},Es));let _=Ya(f,"CUSTOM_ELEMENT_HANDLING",()=>Cn(null));if(pe=Cn(null),He(_,"tagNameCheck")&&Ss(_.tagNameCheck)&&(pe.tagNameCheck=_.tagNameCheck),He(_,"attributeNameCheck")&&Ss(_.attributeNameCheck)&&(pe.attributeNameCheck=_.attributeNameCheck),He(_,"allowCustomizedBuiltInElements")&&typeof _.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=_.allowCustomizedBuiltInElements),ke(pe),nt&&(Mn=!1),be&&(B=!0),ln&&(oe=Z({},yh),J=Cn(null),ln.html===!0&&(Z(oe,vh),Z(J,wh)),ln.svg===!0&&(Z(oe,Ka),Z(J,qa),Z(J,Ai)),ln.svgFilters===!0&&(Z(oe,Va),Z(J,qa),Z(J,Ai)),ln.mathMl===!0&&(Z(oe,ja),Z(J,bh),Z(J,Ai))),ut.tagCheck=null,ut.attributeCheck=null,He(f,"ADD_TAGS")&&(typeof f.ADD_TAGS=="function"?ut.tagCheck=f.ADD_TAGS:Ln(f.ADD_TAGS)&&(oe===$e&&(oe=Ye(oe)),Z(oe,f.ADD_TAGS,de))),He(f,"ADD_ATTR")&&(typeof f.ADD_ATTR=="function"?ut.attributeCheck=f.ADD_ATTR:Ln(f.ADD_ATTR)&&(J===gt&&(J=Ye(J)),Z(J,f.ADD_ATTR,de))),He(f,"ADD_FORBID_CONTENTS")&&Ln(f.ADD_FORBID_CONTENTS)&&(un===ys&&(un=Ye(un)),Z(un,f.ADD_FORBID_CONTENTS,de)),Qi&&(oe["#text"]=!0),mt&&Z(oe,["html","head","body"]),oe.table&&(Z(oe,["tbody"]),delete At.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let S=T;T=f.TRUSTED_TYPES_POLICY;try{C=ce("")}catch(M){throw T=S,M}}else f.TRUSTED_TYPES_POLICY===null?(T=void 0,C=""):(T===void 0&&(T=Te()),T&&typeof C=="string"&&(C=ce("")));we&&we(f),dn=f},Ts=Z({},[...Ka,...Va,...Cw]),Rs=Z({},[...ja,...Lw]),vf=function(f,_,S){return _.namespaceURI===dt?f==="svg":_.namespaceURI===wr?f==="svg"&&(S==="annotation-xml"||no[S]):!!Ts[f]},yf=function(f,_,S){return _.namespaceURI===dt?f==="math":_.namespaceURI===br?f==="math"&&ro[S]:!!Rs[f]},wf=function(f,_,S){return _.namespaceURI===br&&!ro[S]||_.namespaceURI===wr&&!no[S]?!1:!Rs[f]&&(pf[f]||!Ts[f])},bf=function(f){let _=b(f);(!_||!_.tagName)&&(_={namespaceURI:cn,tagName:"template"});let S=cr(f.tagName),M=cr(_.tagName);return to[f.namespaceURI]?f.namespaceURI===br?vf(S,_,M):f.namespaceURI===wr?yf(S,_,M):f.namespaceURI===dt?wf(S,_,M):!!(On==="application/xhtml+xml"&&to[f.namespaceURI]):!1},Lt=function(f){sr(t.removed,{element:f});try{b(f).removeChild(f)}catch{if(m(f),!b(f))throw tn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},As=function(f,_,S){try{f.removeAttributeNode(_)}catch{try{f.removeAttribute(S)}catch{}}},xr=function(f){kr(f);let _=v(f);if(_){let M=[];nn(_,z=>{sr(M,z)}),nn(M,z=>{try{m(z)}catch{}})}let S=x(f);if(S)for(let M=S.length-1;M>=0;--M){let z=S[M],U=z&&z.name;typeof U=="string"&&As(f,z,U)}},zt=function(f,_,S){if(!S)try{S=_.getAttributeNode(f)}catch{S=null}sr(t.removed,{attribute:S||null,from:_});try{S?_.removeAttributeNode(S):_.removeAttribute(f)}catch{try{_.removeAttribute(f)}catch{}}if(f==="is")if(B||be)try{Lt(_)}catch{}else try{_.setAttribute(f,"")}catch{}},xf=function(f){let _=x(f);if(_)for(let S=_.length-1;S>=0;--S){let M=_[S],z=M&&M.name;typeof z!="string"||J[de(z)]||As(f,M,z)}},kr=function(f){let _=[f];for(;_.length>0;){let S=_.pop();P(S)===qe.element&&xf(S);let z=v(S);if(z)for(let U=z.length-1;U>=0;--U)_.push(z[U])}},Cs=function(f,_){return ct?f==="patchsrc"?!0:f==="for"&&_!=="label"&&_!=="output":!1},kf=function(f){if(!ct)return;let _=[f];for(;_.length>0;){let S=_.pop(),M=P(S);if(M===qe.processingInstruction||M===qe.comment&&Ae(_h,S.data)){try{m(S)}catch{}continue}if(M===qe.element){let U=S,ae=de(F(S));try{U.hasAttribute&&U.hasAttribute("patchsrc")&&U.removeAttribute("patchsrc"),U.hasAttribute&&U.hasAttribute("for")&&Cs("for",ae)&&U.removeAttribute("for")}catch{}}let z=v(S);if(z)for(let U=z.length-1;U>=0;--U)_.push(z[U])}},Ls=function(f){let _=null,S=null;if(O)f="<remove></remove>"+f;else{let U=ph(f,/^[\r\n\t ]+/);S=U&&U[0]}On==="application/xhtml+xml"&&cn===dt&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");let M=T?ce(f):f;if(cn===dt)try{_=new c().parseFromString(M,On)}catch{}if(!_||!_.documentElement){_=Ee.createDocument(cn,"template",null);try{_.documentElement.innerHTML=eo?C:M}catch{}}let z=_.body||_.documentElement;return f&&S&&z.insertBefore(n.createTextNode(S),z.childNodes[0]||null),cn===dt?Ze.call(_,mt?"html":"body")[0]:mt?_.documentElement:z},Ns=function(f){let _=A?A(f):f.ownerDocument;return Be.call(_||f,f,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},_r=function(f){return f=lr(f,Ft," "),f=lr(f,Xi," "),f=lr(f,Zi," "),f},oo=function(f){var _;f.normalize();let S=A?A(f):f.ownerDocument,M=Be.call(S||f,f,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),z=M.nextNode();for(;z;)z.data=_r(z.data),z=M.nextNode();let U=(_=f.querySelectorAll)===null||_===void 0?void 0:_.call(f,"template");U&&nn(U,ae=>{hn(ae.content)&&oo(ae.content)})},Er=function(f){let _=N?N(f):null;return typeof _!="string"||de(_)!=="form"?!1:typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||f.attributes!==x(f)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function"||f.nodeType!==k(f)||f.childNodes!==v(f)},hn=function(f){if(!k||typeof f!="object"||f===null)return!1;try{return k(f)===qe.documentFragment}catch{return!1}},Fn=function(f){if(!k||typeof f!="object"||f===null)return!1;try{return typeof k(f)=="number"}catch{return!1}};function ht(L,f,_){L.length!==0&&nn(L,S=>{S.call(t,f,_,dn)})}let _f=function(f,_){return!!(ct&&f.hasChildNodes()&&!Fn(f.firstElementChild)&&Ae(kh,f.textContent)&&Ae(kh,f.innerHTML)||ct&&f.namespaceURI===dt&&Hw[_]&&(Fn(f.firstElementChild)||typeof f.textContent=="string"&&Ae(Uw[_],f.textContent))||f.nodeType===qe.processingInstruction||ct&&f.nodeType===qe.comment&&Ae(_h,f.data))},Sr=function(f,_){if(f instanceof RegExp)return Ae(f,_);if(f instanceof Function){for(var S=arguments.length,M=new Array(S>2?S-2:0),z=2;z<S;z++)M[z-2]=arguments[z];return!!f(_,...M)}return!1},Ef=function(f,_,S){if(!At[_]&&Gs(_)&&Sr(pe.tagNameCheck,_))return!1;if(Qi&&!un[_]){let M=b(f),z=v(f);if(z&&M){let U=z.length;for(let ae=U-1;ae>=0;--ae){let le=f===S?p(z[ae],!0):z[ae];M.insertBefore(le,w(f))}}}return Lt(f),!0},Ps=function(f,_,S,M){return f.length===0?_:_===S||_===M?Ye(_):_},Ds=function(f,_){return f===_||b(f)!==null?!1:(Ji&&kr(f),!0)},Is=function(f,_){if(ht(Q.beforeSanitizeElements,f,null),Ds(f,_))return!0;if(Er(f))return Lt(f),!0;let S=de(F(f));if(oe=Ps(Q.uponSanitizeElement,oe,$e,I),ht(Q.uponSanitizeElement,f,{tagName:S,allowedTags:oe}),Ds(f,_))return!0;if(_f(f,S))return Lt(f),!0;if(At[S]||!(ut.tagCheck instanceof Function&&ut.tagCheck(S))&&!oe[S]){let z=Ef(f,S,_);return z===!1&&ht(Q.afterSanitizeElements,f,null),z}if(P(f)===qe.element&&!bf(f)||(S==="noscript"||S==="noembed"||S==="noframes")&&Ae(zw,f.innerHTML))return Lt(f),!0;if(nt&&f.nodeType===qe.text){let z=_r(f.textContent);f.textContent!==z&&(sr(t.removed,{element:f.cloneNode()}),f.textContent=z)}return ht(Q.afterSanitizeElements,f,null),!1},Ms=function(f,_,S){if(In[_]||Cs(_,f)||Ct&&(_==="id"||_==="name")&&(S in n||S in mf))return!1;let M=J[_]||ut.attributeCheck instanceof Function&&ut.attributeCheck(_,f);return Mn&&Ae(mr,_)||vr&&Ae(Dn,_)?!0:M?xs[_]||Ae($t,lr(S,Ne,""))||(_==="src"||_==="xlink:href"||_==="href")&&f!=="script"&&fh(S,"data:")===0&&ws[f]||Gn&&!Ae(Ve,lr(S,Ne,""))?!0:!S:Gs(f)&&Sr(pe.tagNameCheck,f)&&Sr(pe.attributeNameCheck,_,f)||_==="is"&&pe.allowCustomizedBuiltInElements&&Sr(pe.tagNameCheck,S)},Sf=Z({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Gs=function(f){return!Sf[cr(f)]&&Ae(ft,f)},Tf=function(f,_,S,M){if(T&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!S)switch(h.getAttributeType(f,_)){case"TrustedHTML":return ce(M);case"TrustedScriptURL":return Fe(M)}return M},Rf=function(f,_,S,M){try{S?f.setAttributeNS(S,_,M):f.setAttribute(_,M),Er(f)?Lt(f):hh(t.removed)}catch{zt(_,f)}},Os=function(f){ht(Q.beforeSanitizeAttributes,f,null);let _=f.attributes;if(!_||Er(f))return;J=Ps(Q.uponSanitizeAttribute,J,gt,K);let S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J,forceKeepAttr:void 0},M=_.length,z=de(f.nodeName);for(;M--;){let U=_[M],ae=U.name,le=U.namespaceURI,ze=U.value,We=de(ae),so=ze,Pe=ae==="value"?so:kw(so);if(S.attrName=We,S.attrValue=Pe,S.keepAttr=!0,S.forceKeepAttr=void 0,ht(Q.uponSanitizeAttribute,f,S),Pe=S.attrValue,ms&&(We==="id"||We==="name")&&fh(Pe,vs)!==0&&(zt(ae,f,U),Pe=vs+Pe),ct&&Ae(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Pe)){zt(ae,f,U);continue}if(We==="attributename"&&ph(Pe,"href")){zt(ae,f,U);continue}if(!S.forceKeepAttr){if(!S.keepAttr){zt(ae,f,U);continue}if(!yr&&Ae(Ww,Pe)){zt(ae,f,U);continue}if(nt&&(Pe=_r(Pe)),!Ms(z,We,Pe)){zt(ae,f,U);continue}Pe=Tf(z,We,le,Pe),Pe!==so&&Rf(f,ae,le,Pe)}}ht(Q.afterSanitizeAttributes,f,null)},Tr=function(f){let _=null,S=Ns(f);for(ht(Q.beforeSanitizeShadowDOM,f,null);_=S.nextNode();)if(ht(Q.uponSanitizeShadowNode,_,null),Is(_,f),Os(_),hn(_.content)&&Tr(_.content),P(_)===qe.element){let M=y(_);hn(M)&&(ao(M),Tr(M))}ht(Q.afterSanitizeShadowDOM,f,null)},ao=function(f){let _=[{node:f,shadow:null}];for(;_.length>0;){let S=_.pop();if(S.shadow){Tr(S.shadow);continue}let M=S.node,U=P(M)===qe.element,ae=v(M);if(ae)for(let le=ae.length-1;le>=0;--le)_.push({node:ae[le],shadow:null});if(U){let le=N?N(M):null;if(typeof le=="string"&&de(le)==="template"){let ze=M.content;hn(ze)&&_.push({node:ze,shadow:null})}}if(U){let le=y(M);hn(le)&&_.push({node:null,shadow:le},{node:le,shadow:null})}}};return t.sanitize=function(L){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_=null,S=null,M=null,z=null;if(eo=!L,eo&&(L="<!-->"),typeof L!="string"&&!Fn(L)&&(L=Rw(L),typeof L!="string"))throw tn("dirty is not a string, aborting");if(!t.isSupported)return L;E?(oe=I,J=K):io(f),(Q.uponSanitizeElement.length>0||Q.uponSanitizeAttribute.length>0)&&(oe=Ye(oe)),Q.uponSanitizeAttribute.length>0&&(J=Ye(J)),t.removed=[];let U=Ji&&typeof L!="string"&&Fn(L);if(U){kf(L);let ze=F(L);if(typeof ze=="string"){let We=de(ze);if(!oe[We]||At[We])throw xr(L),tn("root node is forbidden and cannot be sanitized in-place")}if(Er(L))throw xr(L),tn("root node is clobbered and cannot be sanitized in-place");try{ao(L)}catch(We){throw xr(L),We}}else if(Fn(L))_=Ls("<!---->"),S=_.ownerDocument.importNode(L,!0),S.nodeType===qe.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?_=S:_.appendChild(S),ao(S);else{if(!B&&!nt&&!mt&&L.indexOf("<")===-1)return T&&rt?ce(L):L;if(_=Ls(L),!_)return B?null:rt?C:""}_&&O&&Lt(_.firstChild);let ae=U?L:_;try{let ze=Ns(ae);for(;M=ze.nextNode();)Is(M,ae),Os(M),hn(M.content)&&Tr(M.content)}catch(ze){throw U&&(xr(L),nn(t.removed,We=>{We.element&&kr(We.element)})),ze}if(U)return nn(t.removed,ze=>{ze.element&&kr(ze.element)}),nt&&oo(L),L;if(B){if(nt&&oo(_),be)for(z=Ke.call(_.ownerDocument);_.firstChild;)z.appendChild(_.firstChild);else z=_;return(J.shadowroot||J.shadowrootmode)&&(z=Le.call(r,z,!0)),z}let le=mt?_.outerHTML:_.innerHTML;return mt&&oe["!doctype"]&&_.ownerDocument&&_.ownerDocument.doctype&&_.ownerDocument.doctype.name&&Ae(Fw,_.ownerDocument.doctype.name)&&(le="<!DOCTYPE "+_.ownerDocument.doctype.name+`>
335
- `+le),nt&&(le=_r(le)),T&&rt?ce(le):le},t.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};io(L),E=!0,I=oe,K=J},t.clearConfig=function(){dn=null,E=!1,I=null,K=null,T=W,C=""},t.isValidAttribute=function(L,f,_){dn||io({});let S=de(L),M=de(f);return Ms(S,M,_)},t.addHook=function(L,f){typeof f=="function"&&He(Q,L)&&sr(Q[L],f)},t.removeHook=function(L,f){if(He(Q,L)){if(f!==void 0){let _=bw(Q[L],f);return _===-1?void 0:xw(Q[L],_,1)[0]}return hh(Q[L])}},t.removeHooks=function(L){He(Q,L)&&(Q[L]=[])},t.removeAllHooks=function(){Q=Eh()},t}var Ch=Ah();function ts(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var an=ts();function Oh(e){an=e}var rn={exec:()=>null};function Nn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function q(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(Ce.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,t)};return r}var Vw=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ce={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:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Nn(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Nn(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Nn(e=>new RegExp(`^ {0,${e}}>`))},jw=/^(?:[ \t]*(?:\n|$))+/,qw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Yw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,pr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ns=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Fh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$h=q(Fh).replace(/bull/g,ns).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(),Zw=q(Fh).replace(/bull/g,ns).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(),rs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Qw=/^[^\n]+/,is=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Jw=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",is).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),eb=q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ns).getRegex(),Di="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",os=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,tb=q("^ {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",os).replace("tag",Di).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),zh=e=>q(rs).replace("hr",pr).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",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Di).getRegex(),nb=zh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),rb=zh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ib=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",rb).getRegex(),as={blockquote:ib,code:qw,def:Jw,fences:Yw,heading:Xw,hr:pr,html:tb,lheading:$h,list:eb,newline:jw,paragraph:nb,table:rn,text:Qw},Lh=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pr).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",Di).getRegex(),ob={...as,lheading:Zw,table:Lh,paragraph:q(rs).replace("hr",pr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Lh).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",Di).getRegex()},ab={...as,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",os).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:rn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(rs).replace("hr",pr).replace("heading",` *#{1,6} *[^
336
- ]`).replace("lheading",$h).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},sb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,lb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wh=/^( {2,}|\\)\n(?!\s*$)/,ub=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Tt=/[\p{P}\p{S}]/u,Pn=/[\s\p{P}\p{S}]/u,fr=/[^\s\p{P}\p{S}]/u,cb=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pn).getRegex(),db=/[\p{Pi}\p{Ps}"']/u,Hh=/(?!~)[\p{P}\p{S}]/u,hb=/(?!~)[\s\p{P}\p{S}]/u,pb=/(?:[^\s\p{P}\p{S}]|~)/u,fb=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vw?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Uh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,gb=q(Uh,"u").replace(/punct/g,Tt).getRegex(),mb=q(Uh,"u").replace(/punct/g,Hh).getRegex(),vb=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,yb=q(vb,"u").replace(/openQuote/g,db).replace(/punct/g,Tt).getRegex(),Bh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wb=q(Bh,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Pn).replace(/punct/g,Tt).getRegex(),bb=q(Bh,"gu").replace(/notPunctSpace/g,pb).replace(/punctSpace/g,hb).replace(/punct/g,Hh).getRegex(),xb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",kb=q(xb,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Pn).replace(/punct/g,Tt).getRegex(),_b=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Pn).replace(/punct/g,Tt).getRegex(),Eb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Sb=q(Eb,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Pn).replace(/punct/g,Tt).getRegex(),Tb=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Tt).getRegex(),Rb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ab=q(Rb,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Pn).replace(/punct/g,Tt).getRegex(),Cb=q(/\\(punct)/,"gu").replace(/punct/g,Tt).getRegex(),Lb=q(/^<(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(),Nb=q(os).replace("(?:-->|$)","-->").getRegex(),Pb=q("^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",Nb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Li=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Db=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Li).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Kh=q(/^!?\[(label)\]\[(ref)\]/).replace("label",Li).replace("ref",is).getRegex(),Vh=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",is).getRegex(),Ib=q("reflink|nolink(?!\\()","g").replace("reflink",Kh).replace("nolink",Vh).getRegex(),Nh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ss={_backpedal:rn,anyPunctuation:Cb,autolink:Lb,blockSkip:fb,br:Wh,code:lb,del:rn,delLDelim:rn,delRDelim:rn,emStrongLDelim:gb,emStrongRDelimAst:wb,emStrongRDelimUnd:_b,escape:sb,link:Db,nolink:Vh,punctuation:cb,reflink:Kh,reflinkSearch:Ib,tag:Pb,text:ub,url:rn},Mb={...ss,emStrongLDelim:yb,emStrongRDelimAst:kb,emStrongRDelimUnd:Sb,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",Li).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Li).getRegex()},Qa={...ss,emStrongRDelimAst:bb,emStrongLDelim:mb,delLDelim:Tb,delRDelim:Ab,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Nh).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:q(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Nh).getRegex()},Gb={...Qa,br:q(Wh).replace("{2,}","*").getRegex(),text:q(Qa.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ci={normal:as,gfm:ob,pedantic:ab},dr={normal:ss,gfm:Qa,breaks:Gb,pedantic:Mb},Ob={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ph=e=>Ob[e];function pt(e,t){if(t){if(Ce.escapeTest.test(e))return e.replace(Ce.escapeReplace,Ph)}else if(Ce.escapeTestNoEncode.test(e))return e.replace(Ce.escapeReplaceNoEncode,Ph);return e}function Dh(e){try{e=encodeURI(e).replace(Ce.percentDecode,"%")}catch{return null}return e}function Ih(e,t){let n=e.replace(Ce.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Ce.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ce.slashPipe,"|");return r}function Ot(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r;){let o=e.charAt(r-i-1);if(o===t&&!n)i++;else if(o!==t&&n)i++;else break}return e.slice(0,r-i)}function Mh(e){let t=e.split(`
337
- `),n=t.length-1;for(;n>=0&&Ce.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
338
- `)}function Fb(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function $b(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function Gh(e,t,n,r,i){let o=t.href,a=t.title||null,s=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function zb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
331
+ `,Ov=Mv,vd=WebGLRenderingContext,rd=vd.UNSIGNED_BYTE,pr=vd.FLOAT,Fv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],yd=(function(e){function t(){return be(this,t),Me(this,t,arguments)}return Oe(t,e),xe(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Ov,FRAGMENT_SHADER_SOURCE:pd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Fv,ATTRIBUTES:[{name:"a_positionStart",size:2,type:pr},{name:"a_positionEnd",size:2,type:pr},{name:"a_normal",size:2,type:pr},{name:"a_color",size:4,type:rd,normalized:!0},{name:"a_id",size:4,type:rd,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:pr},{name:"a_normalCoef",size:1,type:pr}],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,c=o.x,u=o.y,h=a.x,d=a.y,p=Dn(s.color),m=h-c,v=d-u,y=m*m+v*v,b=0,w=0;y&&(y=1/Math.sqrt(y),b=-v*y*l,w=m*y*l);var k=this.array;k[i++]=c,k[i++]=u,k[i++]=h,k[i++]=d,k[i++]=b,k[i++]=w,k[i++]=p,k[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,c=a.u_feather,u=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,p=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(u,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(p,r.minEdgeThickness)}}])})(Wa);var Cd=Zn(Ni()),Pi=(function(e){function t(){var n;return be(this,t),n=Me(this,t),n.rawEmitter=n,n}return Oe(t,e),xe(t)})(Cd.EventEmitter);var Dd=Zn(Ba());var Kv=function(t){return t},Vv=function(t){return t*t},jv=function(t){return t*(2-t)},qv=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Yv=function(t){return t*t*t},Xv=function(t){return--t*t*t+1},Zv=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Id={linear:Kv,quadraticIn:Vv,quadraticOut:jv,quadraticInOut:qv,cubicIn:Yv,cubicOut:Xv,cubicInOut:Zv},Gd={easing:"quadraticInOut",duration:150};function Je(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Di(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Nd(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Pd(e,t,n){return e[6]=t,e[7]=n,e}function zt(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=t[0],d=t[1],p=t[2],m=t[3],v=t[4],y=t[5],b=t[6],w=t[7],k=t[8];return e[0]=h*n+d*o+p*l,e[1]=h*r+d*a+p*c,e[2]=h*i+d*s+p*u,e[3]=m*n+v*o+y*l,e[4]=m*r+v*a+y*c,e[5]=m*i+v*s+y*u,e[6]=b*n+w*o+k*l,e[7]=b*r+w*a+k*c,e[8]=b*i+w*s+k*u,e}function Ii(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],a=e[4],s=e[6],l=e[7],c=t.x,u=t.y;return{x:c*r+u*o+s*n,y:c*i+u*a+l*n}}function Qv(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Gn(e,t,n,r,i){var o=e.angle,a=e.ratio,s=e.x,l=e.y,c=t.width,u=t.height,h=Je(),d=Math.min(c,u)-2*r,p=Qv(t,n);return i?(zt(h,Pd(Je(),s,l)),zt(h,Di(Je(),a)),zt(h,Nd(Je(),o)),zt(h,Di(Je(),c/d/2/p,u/d/2/p))):(zt(h,Di(Je(),2*(d/c)*p,2*(d/u)*p)),zt(h,Nd(Je(),-o)),zt(h,Di(Je(),1/a)),zt(h,Pd(Je(),-s,-l))),h}function Md(e,t,n){var r=Ii(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Od(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,a){var s=a.x,l=a.y;s<t&&(t=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[t,n],y:[r,i]}}function Fd(e){if(!(0,Dd.default)(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function $d(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Ka(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Va(e,t,n){return n.sort(function(r,i){var o=t(r)||0,a=t(i)||0;return o<a?-1:o>a?1:0})}function ja(e){var t=$t(e.x,2),n=t[0],r=t[1],i=$t(e.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,c=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(c)&&(c=0);var u=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-c)/s}};return u.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-c)/s},u.inverse=function(h){return{x:l+s*(h.x-.5),y:c+s*(h.y-.5)}},u.ratio=s,u}function Gi(e){"@babel/helpers - typeof";return Gi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gi(e)}function qa(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function Mi(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var Oi={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:sd,defaultDrawNodeLabel:Ua,defaultDrawNodeHover:ld,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:{}},Jv={circle:fr},ey={arrow:md,line:yd};function Fi(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function zd(e){var t=Mi({},Oi,e);return t.nodeProgramClasses=Mi({},Jv,t.nodeProgramClasses),t.edgeProgramClasses=Mi({},ey,t.edgeProgramClasses),t}var dE=Zn(Ni()),hE=Zn(Ba()),$i=1.5,Wd=(function(e){function t(){var n;return be(this,t),n=Me(this,t),R(n,"x",.5),R(n,"y",.5),R(n,"angle",0),R(n,"ratio",1),R(n,"minRatio",null),R(n,"maxRatio",null),R(n,"enabledZooming",!0),R(n,"enabledPanning",!0),R(n,"enabledRotation",!0),R(n,"clean",null),R(n,"nextFrame",null),R(n,"previousState",null),R(n,"enabled",!0),n.previousState=n.getState(),n}return Oe(t,e),xe(t,[{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($($({},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(p){return i.animate(r,o,p)});if(this.enabled){var s=$($({},Gd),o),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:Id[s.easing],u=Date.now(),h=this.getState(),d=function(){var m=(Date.now()-u)/s.duration;if(m>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var v=c(m),y={};typeof l.x=="number"&&(y.x=h.x+(l.x-h.x)*v),typeof l.y=="number"&&(y.y=h.y+(l.y-h.y)*v),i.enabledRotation&&typeof l.angle=="number"&&(y.angle=h.angle+(l.angle-h.angle)*v),typeof l.ratio=="number"&&(y.ratio=h.ratio+(l.ratio-h.ratio)*v),i.setState(y),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||$i)},r):this.animate({ratio:this.ratio/$i})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||$i)},r):this.animate({ratio:this.ratio*$i})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(Pi);function at(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Et(e,t){var n=$($({},at(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function gr(e){var t="x"in e?e:$($({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function ty(e,t){return $($({},Et(e,t)),{},{delta:jd(e)})}var ny=2;function zi(e){for(var t=[],n=0,r=Math.min(e.length,ny);n<r;n++)t.push(e[n]);return t}function mr(e,t,n){var r={touches:zi(e.touches).map(function(i){return at(i,n)}),previousTouches:t.map(function(i){return at(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function jd(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var qd=(function(e){function t(n,r){var i;return be(this,t),i=Me(this,t),i.container=n,i.renderer=r,i}return Oe(t,e),xe(t)})(Pi),ry=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],iy=ry.reduce(function(e,t){return $($({},e),{},R({},t,Oi[t]))},{}),oy=(function(e){function t(n,r){var i;return be(this,t),i=Me(this,t,[n,r]),R(i,"enabled",!0),R(i,"draggedEvents",0),R(i,"downStartTime",null),R(i,"lastMouseX",null),R(i,"lastMouseY",null),R(i,"isMouseDown",!1),R(i,"isMoving",!1),R(i,"movingTimeout",null),R(i,"startCameraState",null),R(i,"clicks",0),R(i,"doubleClickTimeout",null),R(i,"currentWheelDirection",0),R(i,"settings",iy),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 Oe(t,e),xe(t,[{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",Et(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Et(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Et(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(at(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=at(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",Et(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=at(r,this.container),s=a.x,l=a.y,c=o.getState(),u=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:c.x+this.settings.inertiaRatio*(c.x-u.x),y:c.y+this.settings.inertiaRatio*(c.y-u.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:c.x,y:c.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",Et(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Et(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=at(r,this.container),l=s.x,c=s.y,u=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:c}),d=u.x-h.x,p=u.y-h.y,m=a.getState(),v=m.x+d,y=m.y+p;a.setState({x:v,y}),this.lastMouseX=l,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Et(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Et(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=jd(r);if(a){var s=ty(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,c=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,u=o.getBoundedRatio(l*c),h=a>0?1:-1,d=Date.now();l!==u&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(at(r,this.container),u),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(qd),ay=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],sy=ay.reduce(function(e,t){return $($({},e),{},R({},t,Oi[t]))},{}),ly=(function(e){function t(n,r){var i;return be(this,t),i=Me(this,t,[n,r]),R(i,"enabled",!0),R(i,"isMoving",!1),R(i,"hasMoved",!1),R(i,"touchMode",0),R(i,"startTouchesPositions",[]),R(i,"lastTouches",[]),R(i,"lastTap",null),R(i,"settings",sy),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 Oe(t,e),xe(t,[{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=zi(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(p){return at(p,i.container)}),this.touchMode===2){var a=$t(this.startTouchesPositions,2),s=a[0],l=s.x,c=s.y,u=a[1],h=u.x,d=u.y;this.startTouchesAngle=Math.atan2(d-c,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-c,2))}this.emit("touchdown",mr(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",mr(r,this.lastTouches,this.container)),!r.touches.length){var s=at(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],c=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var u=mr(r,this.lastTouches,this.container);if(this.emit("doubletap",u),this.lastTap=null,!u.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 p=mr(r,this.lastTouches,this.container);this.emit("tap",p),this.lastTap={time:Date.now(),position:p.touches[0]||p.previousTouches[0]}}}this.lastTouches=zi(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=zi(r.touches),a=o.map(function(me){return at(me,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=mr(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(me,Ye){var Ee=i.startTouchesPositions[Ye];return Ee&&(me.x!==Ee.x||me.y!==Ee.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),u=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),p=d.x,m=d.y,v=this.renderer.viewportToFramedGraph(a[0]),y=v.x,b=v.y;c.setState({x:u.x+p-y,y:u.y+m-b});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},k=a[0],_=k.x,I=k.y,A=a[1],D=A.x,O=A.y,U=Math.atan2(O-I,D-_)-this.startTouchesAngle,T=Math.hypot(O-I,D-_)/this.startTouchesDistance,F=c.getBoundedRatio(u.ratio/T);w.ratio=F,w.angle=u.angle+U;var K=this.getDimensions(),Z=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),Y=Math.min(K.width,K.height)-2*h,ne=Y/K.width,Be=Y/K.height,Lt=F/Y,Fe=_-Y/2/ne,$e=I-Y/2/Be,Ce=[Fe*Math.cos(-w.angle)-$e*Math.sin(-w.angle),$e*Math.cos(-w.angle)+Fe*Math.sin(-w.angle)];Fe=Ce[0],$e=Ce[1],w.x=Z.x-Fe*Lt,w.y=Z.y+$e*Lt,c.setState(w);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(qd);function cy(e){if(Array.isArray(e))return Ri(e)}function uy(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function dy(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
332
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ud(e){return cy(e)||uy(e)||Ia(e)||dy()}function hy(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ya(e,t){if(e==null)return{};var n,r,i=hy(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var Hd=(function(){function e(t,n){be(this,e),this.key=t,this.size=n}return xe(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Bd=(function(){function e(){be(this,e),R(this,"width",0),R(this,"height",0),R(this,"cellSize",0),R(this,"columns",0),R(this,"rows",0),R(this,"cells",{})}return xe(e,[{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 Hd(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(Hd.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 c in this.cells)for(var u=this.cells[c],h=0;h<Math.min(s,u.length);h++)l.push(u[h].key);return l}}])})();function py(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(a,s,l,c){(l===n||c===n||r.has(l)||r.has(c)||i.has(l)&&i.has(c))&&o.push(a)}),o}var Kd=150,Vd=50,Tt=Object.prototype.hasOwnProperty;function fy(e,t,n){if(!Tt.call(n,"x")||!Tt.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". 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=e.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),Tt.call(n,"hidden")||(n.hidden=!1),Tt.call(n,"highlighted")||(n.highlighted=!1),Tt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function gy(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Tt.call(n,"hidden")||(n.hidden=!1),Tt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var my=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(be(this,t),i=Me(this,t),R(i,"elements",{}),R(i,"canvasContexts",{}),R(i,"webGLContexts",{}),R(i,"pickingLayers",new Set),R(i,"textures",{}),R(i,"frameBuffers",{}),R(i,"activeListeners",{}),R(i,"labelGrid",new Bd),R(i,"nodeDataCache",{}),R(i,"edgeDataCache",{}),R(i,"nodeProgramIndex",{}),R(i,"edgeProgramIndex",{}),R(i,"nodesWithForcedLabels",new Set),R(i,"edgesWithForcedLabels",new Set),R(i,"nodeExtent",{x:[0,1],y:[0,1]}),R(i,"nodeZExtent",[1/0,-1/0]),R(i,"edgeZExtent",[1/0,-1/0]),R(i,"matrix",Je()),R(i,"invMatrix",Je()),R(i,"correctionRatio",1),R(i,"customBBox",null),R(i,"normalizationFunction",ja({x:[0,1],y:[0,1]})),R(i,"graphToViewportRatio",1),R(i,"itemIDsIndex",{}),R(i,"nodeIndices",{}),R(i,"edgeIndices",{}),R(i,"width",0),R(i,"height",0),R(i,"pixelRatio",Ka()),R(i,"pickingDownSizingRatio",2*i.pixelRatio),R(i,"displayedNodeLabels",new Set),R(i,"displayedEdgeLabels",new Set),R(i,"highlightedNodes",new Set),R(i,"hoveredNode",null),R(i,"hoveredEdge",null),R(i,"renderFrame",null),R(i,"renderHighlightedNodesFrame",null),R(i,"needToProcess",!1),R(i,"checkEdgesEventsFrame",null),R(i,"nodePrograms",{}),R(i,"nodeHoverPrograms",{}),R(i,"edgePrograms",{}),i.settings=zd(o),Fi(i.settings),Fd(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 Wd,i.bindCameraHandlers(),i.mouseCaptor=new oy(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new ly(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Oe(t,e),xe(t,[{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=Ya(i,[r].map(ln));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=Ya(s,[r].map(ln));l.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Ya(i,[r].map(ln));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=Oa(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=Ma.apply(void 0,Ud(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=gr(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",$($({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",$($({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",$($({},s),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var u=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);u!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",$($({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",$($({},s),{},{edge:u})),r.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(o){var a=gr(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=gr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",$($({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",$($({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",$({},s))},this.activeListeners.handleEnter=function(o){var a=gr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",$({},s))};var i=function(a){return function(s){var l=gr(s),c={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=r.getNodeAtPosition(l);if(u)return r.emit("".concat(a,"Node"),$($({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),$($({},c),{},{edge:h}))}return r.emit("".concat(a,"Stage"),c)}};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(u){return r.updateNode(u)});var c=!l||l.some(function(u){return o.has(u)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,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(u){return r.updateEdge(u)});var c=l&&["zIndex","type"].some(function(u){return l?.includes(u)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,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=Oa(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=Ma.apply(void 0,Ud(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=Od(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,c=this.nodeExtent,u=c.x,h=c.y;this.nodeExtent={x:[(u[0]+u[1])/2-s/2,(u[0]+u[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=ja(this.customBBox||this.nodeExtent);var d=new Wd,p=Gn(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var m={},v={},y={},b={},w=1,k=i.nodes(),_=0,I=k.length;_<I;_++){var A=k[_],D=this.nodeDataCache[A],O=i.getNodeAttributes(A);D.x=O.x,D.y=O.y,this.normalizationFunction.applyTo(D),typeof D.label=="string"&&!D.hidden&&this.labelGrid.add(A,D.size,this.framedGraphToViewport(D,{matrix:p})),m[D.type]=(m[D.type]||0)+1}this.labelGrid.organize();for(var U in this.nodePrograms){if(!Tt.call(this.nodePrograms,U))throw new Error('Sigma: could not find a suitable program for node type "'.concat(U,'"!'));this.nodePrograms[U].reallocate(m[U]||0),m[U]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=Va(this.nodeZExtent,function(Nt){return r.nodeDataCache[Nt].zIndex},k));for(var T=0,F=k.length;T<F;T++){var K=k[T];v[K]=w,b[v[K]]={type:"node",id:K},w++;var Z=this.nodeDataCache[K];this.addNodeToProgram(K,v[K],m[Z.type]++)}for(var Y={},ne=i.edges(),Be=0,Lt=ne.length;Be<Lt;Be++){var Fe=ne[Be],$e=this.edgeDataCache[Fe];Y[$e.type]=(Y[$e.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=Va(this.edgeZExtent,function(Nt){return r.edgeDataCache[Nt].zIndex},ne));for(var Ce in this.edgePrograms){if(!Tt.call(this.edgePrograms,Ce))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Ce,'"!'));this.edgePrograms[Ce].reallocate(Y[Ce]||0),Y[Ce]=0}for(var me=0,Ye=ne.length;me<Ye;me++){var Ee=ne[me];y[Ee]=w,b[y[Ee]]={type:"edge",id:Ee},w++;var re=this.edgeDataCache[Ee];this.addEdgeToProgram(Ee,y[Ee],Y[re.type]++)}return this.itemIDsIndex=b,this.nodeIndices=v,this.edgeIndices=y,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(u){return i.cleanCameraState(u,o.cameraPanBoundaries&&Gi(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 c in r.nodeProgramClasses)o.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}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=$({},r),c=s||this.nodeExtent,u=$t(c.x,2),h=u[0],d=u[1],p=$t(c.y,2),m=p[0],v=p[1],y=[this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:h,y:v},{cameraState:r}),this.graphToViewport({x:d,y:v},{cameraState:r})],b=1/0,w=-1/0,k=1/0,_=-1/0;y.forEach(function(Y){var ne=Y.x,Be=Y.y;b=Math.min(b,ne),w=Math.max(w,ne),k=Math.min(k,Be),_=Math.max(_,Be)});var I=w-b,A=_-k,D=this.getDimensions(),O=D.width,U=D.height,T=0,F=0;if(I>=O?w<O-a?T=w-(O-a):b>a&&(T=b-a):w>O+a?T=w-(O+a):b<-a&&(T=b+a),A>=U?_<U-a?F=_-(U-a):k>a&&(F=k-a):_>U+a?F=_-(U+a):k<-a&&(F=k+a),T||F){var K=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Z=this.viewportToFramedGraph({x:T,y:F},{cameraState:r});T=Z.x-K.x,F=Z.y-K.y,l.x+=T,l.y+=F}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);qa(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],c=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!c.hidden){var u=this.framedGraphToViewport(c),h=u.x,d=u.y,p=this.scaleSize(c.size);if(!(!c.forceLabel&&p<this.settings.labelRenderedSizeThreshold)&&!(h<-Kd||h>this.width+Kd||d<-Vd||d>this.height+Vd)){this.displayedNodeLabels.add(l);var m=this.settings.defaultDrawNodeLabel,v=this.nodePrograms[c.type],y=v?.drawLabel||m;y(o,$($({key:l},c),{},{size:p,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=py({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});qa(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],c=this.graph.extremities(l),u=this.nodeDataCache[c[0]],h=this.nodeDataCache[c[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||u.hidden||h.hidden)){var p=this.settings.defaultDrawEdgeLabel,m=this.edgePrograms[d.type],v=m?.drawLabel||p;v(r,$($({key:l},d),{},{size:this.scaleSize(d.size)}),$($($({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),$($($({key:c[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(p){var m=r.nodeDataCache[p],v=r.framedGraphToViewport(m),y=v.x,b=v.y,w=r.scaleSize(m.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[m.type],I=_?.drawHover||k;I(i,$($({key:p},m),{},{size:w,x:y,y:b}),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 p=r.nodeDataCache[d].type;s[p]=(s[p]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var p=r.nodeDataCache[d];r.nodeHoverPrograms[p.type].process(0,s[p.type]++,p)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var u in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[u];h.render(c)}}},{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(y){return r.resetWebGLTexture(y)}),!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(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=Gn(s,l,c,u),this.invMatrix=Gn(s,l,c,u,!0),this.correctionRatio=Md(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var p=this.nodePrograms[d];p.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var m in this.edgePrograms){var v=this.edgePrograms[m];v.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=fy(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=gy(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 Bd,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),c=this.nodeDataCache[l[0]],u=this.nodeDataCache[l[1]];s.process(i,o,c,u,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=$d(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=$({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 c=l.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}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 $({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=$({},this.settings);return this.settings[r]=i,Fi(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=$({},this.settings);return this.settings=$($({},this.settings),r),Fi(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=Ka(),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 c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var u=this.webGLContexts[c];if(u.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var h=this.textures[c];h&&u.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(_){return i.addNode(_)}),this.graph.forEachEdge(function(_){return i.addEdge(_)});else{for(var l,c,u=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=u?.length||0;h<d;h++){var p=u[h];if(this.updateNode(p),o){var m=this.nodeProgramIndex[p];if(m===void 0)throw new Error('Sigma: node "'.concat(p,`" can't be repaint`));this.addNodeToProgram(p,this.nodeIndices[p],m)}}for(var v=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],y=0,b=v.length;y<b;y++){var w=v[y];if(this.updateEdge(w),o){var k=this.edgeProgramIndex[w];if(k===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],k)}}}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($($({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,c=o.y,u=this.settings,h=u.minCameraRatio,d=u.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var p=i/a,m={x:this.width/2,y:this.height/2},v=this.viewportToFramedGraph(r),y=this.viewportToFramedGraph(m);return{angle:s,x:(v.x-y.x)*(1-p)+l,y:(v.y-y.y)*(1-p)+c,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?Gn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Ii(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?Gn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Ii(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}}])})(Pi),Yd=my;var Jd=Zn(Ni(),1);function vy(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let r in arguments[t])e[r]=arguments[t][r];return e}var ke=vy;typeof Object.assign=="function"&&(ke=Object.assign);function tt(e,t,n,r){let i=e._nodes.get(t),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 Ae(e){return typeof e=="object"&&e!==null}function eh(e){let t;for(t in e)return!1;return!0}function et(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function st(e,t,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function Xd(e){return!(!Ae(e)||e.attributes&&!Array.isArray(e.attributes))}function yy(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function St(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function On(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var wr=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},M=class e extends wr{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},P=class e extends wr{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},H=class e extends wr{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function th(e,t){this.key=e,this.attributes=t,this.clear()}th.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 nh(e,t){this.key=e,this.attributes=t,this.clear()}nh.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function rh(e,t){this.key=e,this.attributes=t,this.clear()}rh.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Fn(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Fn.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Fn.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");let i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};Fn.prototype.detach=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Fn.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var ih=0,oh=1,wy=2,ah=3;function Rt(e,t,n,r,i,o,a){let s,l,c,u;if(r=""+r,n===ih){if(s=e._nodes.get(r),!s)throw new P(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,u=o}else if(n===ah){if(i=""+i,l=e._edges.get(i),!l)throw new P(`Graph.${t}: 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 P(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);c=o,u=a}else{if(l=e._edges.get(r),!l)throw new P(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===oh?s=l.source:s=l.target,c=i,u=o}return[s,c,u]}function by(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);return a.attributes[s]}}function xy(e,t,n){e.prototype[t]=function(r,i){let[o]=Rt(this,t,n,r,i);return o.attributes}}function ky(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function _y(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=Rt(this,t,n,r,i,o,a);return s.attributes[l]=c,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ey(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=Rt(this,t,n,r,i,o,a);if(typeof c!="function")throw new M(`Graph.${t}: updater should be a function.`);let u=s.attributes,h=c(u[l]);return u[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ty(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Sy(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);if(!Ae(s))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Ry(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);if(!Ae(s))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return ke(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Ay(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);if(typeof s!="function")throw new M(`Graph.${t}: 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 Cy=[{name:e=>`get${e}Attribute`,attacher:by},{name:e=>`get${e}Attributes`,attacher:xy},{name:e=>`has${e}Attribute`,attacher:ky},{name:e=>`set${e}Attribute`,attacher:_y},{name:e=>`update${e}Attribute`,attacher:Ey},{name:e=>`remove${e}Attribute`,attacher:Ty},{name:e=>`replace${e}Attributes`,attacher:Sy},{name:e=>`merge${e}Attributes`,attacher:Ry},{name:e=>`update${e}Attributes`,attacher:Ay}];function Ly(e){Cy.forEach(function({name:t,attacher:n}){n(e,t("Node"),ih),n(e,t("Source"),oh),n(e,t("Target"),wy),n(e,t("Opposite"),ah)})}function Ny(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function Py(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,o,a,n),!i)throw new P(`Graph.${t}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function Dy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Iy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,s,l,n),!a)throw new P(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: 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 Gy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,s,l,n),!a)throw new P(`Graph.${t}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new M(`Graph.${t}: 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 My(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: 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 Oy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Ae(i))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Fy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!Ae(i))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return ke(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function $y(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new H(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new H(`Graph.${t}: 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=tt(this,a,s,n),!o)throw new P(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new H(`Graph.${t}: 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 P(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new M(`Graph.${t}: 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 zy=[{name:e=>`get${e}Attribute`,attacher:Ny},{name:e=>`get${e}Attributes`,attacher:Py},{name:e=>`has${e}Attribute`,attacher:Dy},{name:e=>`set${e}Attribute`,attacher:Iy},{name:e=>`update${e}Attribute`,attacher:Gy},{name:e=>`remove${e}Attribute`,attacher:My},{name:e=>`replace${e}Attributes`,attacher:Oy},{name:e=>`merge${e}Attributes`,attacher:Fy},{name:e=>`update${e}Attributes`,attacher:$y}];function Wy(e){zy.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Uy=[{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 Hy(e,t,n,r){let i=!1;for(let o in t){if(o===r)continue;let a=t[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),e&&i)return a.key}}function By(e,t,n,r){let i,o,a,s=!1;for(let l in t)if(l!==r){i=t[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),e&&s)return i.key;i=i.next}while(i!==void 0)}}function Xa(e,t){let n=Object.keys(e),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===t){i=void 0;continue}i=e[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 Ky(e,t,n,r){let i=t[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)&&e)return i.key}function Vy(e,t,n,r){let i=t[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),e&&o)return i.key;i=i.next}while(i!==void 0)}function Za(e,t){let n=e[t];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 jy(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());let n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._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 sh(e,t,n,r){if(t.size===0)return;let i=n!=="mixed"&&n!==t.type,o=n==="undirected",a,s,l=!1,c=t._edges.values();for(;a=c.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:u,attributes:h,source:d,target:p}=s;if(l=r(u,h,d.key,p.key,d.attributes,p.attributes,s.undirected),e&&l)return u}}function qy(e,t){if(e.size===0)return On();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._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 Qa(e,t,n,r,i,o){let a=t?By:Hy,s;if(n!=="undirected"&&(r!=="out"&&(s=a(e,i.in,o),e&&s)||r!=="in"&&(s=a(e,i.out,o,r?void 0:i.key),e&&s))||n!=="directed"&&(s=a(e,i.undirected,o),e&&s))return s}function Yy(e,t,n,r){let i=[];return Qa(!1,e,t,n,r,function(o){i.push(o)}),i}function Xy(e,t,n){let r=On();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=St(r,Xa(n.in))),t!=="in"&&typeof n.out<"u"&&(r=St(r,Xa(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=St(r,Xa(n.undirected))),r}function Ja(e,t,n,r,i,o,a){let s=n?Vy:Ky,l;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(e,i.in,o,a),e&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(e,i.out,o,a),e&&l))||t!=="directed"&&typeof i.undirected<"u"&&(l=s(e,i.undirected,o,a),e&&l))return l}function Zy(e,t,n,r,i){let o=[];return Ja(!1,e,t,n,r,i,function(a){o.push(a)}),o}function Qy(e,t,n,r){let i=On();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=St(i,Za(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=St(i,Za(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=St(i,Za(n.undirected,r))),i}function Jy(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return jy(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new P(`Graph.${n}: could not find the "${o}" node in the graph.`);return Yy(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 P(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new P(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Zy(r,this.multi,i,s,a)}throw new M(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ew(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=c,sh(!1,this,r,h);if(arguments.length===2){c=""+c,h=u;let d=this._nodes.get(c);if(typeof d>"u")throw new P(`Graph.${o}: could not find the "${c}" node in the graph.`);return Qa(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){c=""+c,u=""+u;let d=this._nodes.get(c);if(!d)throw new P(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new P(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Ja(!1,r,this.multi,i,d,u,h)}throw new M(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),h;if(c.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let p=0;c.push((m,v,y,b,w,k,_)=>{h[p++]=u(m,v,y,b,w,k,_)})}else h=[],c.push((d,p,m,v,y,b,w)=>{h.push(u(d,p,m,v,y,b,w))});return this[o].apply(this,c),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let c=Array.prototype.slice.call(arguments),u=c.pop(),h=[];return c.push((d,p,m,v,y,b,w)=>{u(d,p,m,v,y,b,w)&&h.push(d)}),this[o].apply(this,c),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new M(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new M(`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 u,h;c.length===2?(u=c[0],h=c[1],c=[]):c.length===3?(u=c[1],h=c[2],c=[c[0]]):c.length===4&&(u=c[2],h=c[3],c=[c[0],c[1]]);let d=h;return c.push((p,m,v,y,b,w,k)=>{d=u(d,p,m,v,y,b,w,k)}),this[o].apply(this,c),d}}function tw(e,t){let{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(l,c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return u=l,sh(!0,this,r,u);if(arguments.length===2){l=""+l,u=c;let h=this._nodes.get(l);if(typeof h>"u")throw new P(`Graph.${o}: could not find the "${l}" node in the graph.`);return Qa(!0,this.multi,r==="mixed"?this.type:r,i,h,u)}if(arguments.length===3){l=""+l,c=""+c;let h=this._nodes.get(l);if(!h)throw new P(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(c))throw new P(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Ja(!0,r,this.multi,i,h,c,u)}throw new M(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,d,p,m,v,y,b)=>c(h,d,p,m,v,y,b)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),c=l.pop();return l.push((h,d,p,m,v,y,b)=>!c(h,d,p,m,v,y,b)),!this[o].apply(this,l)}}function nw(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return On();if(!arguments.length)return qy(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new P(`Graph.${o}: could not find the "${a}" node in the graph.`);return Xy(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new P(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new P(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Qy(r,i,l,s)}throw new M(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rw(e){Uy.forEach(t=>{Jy(e,t),ew(e,t),tw(e,t),nw(e,t)})}var iw=[{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 ji(){this.A=null,this.B=null}ji.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};ji.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function vr(e,t,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,c=s===n?l:s;if(t&&t.has(c.key))continue;let u=i(c.key,c.attributes);if(e&&u)return c.key}}function es(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return vr(e,null,r,r.undirected,i);if(typeof n=="string")return vr(e,null,r,r[n],i)}let o=new ji,a;if(t!=="undirected"){if(n!=="out"){if(a=vr(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=vr(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=vr(e,o,r,r.undirected,i),e&&a))return a}function ow(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}let r=[];return es(!1,e,t,n,function(i){r.push(i)}),r}function yr(e,t,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 e&&e.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,c=s.target;if(a=l===t?c:l,e&&e.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function aw(e,t,n){if(e!=="mixed"){if(e==="undirected")return yr(null,n,n.undirected);if(typeof t=="string")return yr(null,n,n[t])}let r=On(),i=new ji;return e!=="undirected"&&(t!=="out"&&(r=St(r,yr(i,n,n.in))),t!=="in"&&(r=St(r,yr(i,n,n.out)))),e!=="directed"&&(r=St(r,yr(i,n,n.undirected))),r}function sw(e,t){let{name:n,type:r,direction:i}=t;e.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 P(`Graph.${n}: could not find the "${o}" node in the graph.`);return ow(r==="mixed"?this.type:r,i,a)}}function lw(e,t){let{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let h=this._nodes.get(c);if(typeof h>"u")throw new P(`Graph.${o}: could not find the "${c}" node in the graph.`);es(!1,r==="mixed"?this.type:r,i,h,u)};let a="map"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,u){let h=[];return this[o](c,(d,p)=>{h.push(u(d,p))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,u){let h=[];return this[o](c,(d,p)=>{u(d,p)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[l]=function(c,u,h){if(arguments.length<3)throw new M(`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](c,(p,m)=>{d=u(d,p,m)}),d}}function cw(e,t){let{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;e.prototype[a]=function(c,u){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;let h=this._nodes.get(c);if(typeof h>"u")throw new P(`Graph.${a}: could not find the "${c}" node in the graph.`);return es(!0,r==="mixed"?this.type:r,i,h,u)};let s="some"+o;e.prototype[s]=function(c,u){return!!this[a](c,u)};let l="every"+o;e.prototype[l]=function(c,u){return!this[a](c,(d,p)=>!u(d,p))}}function uw(e,t){let{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return On();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new P(`Graph.${o}: could not find the "${a}" node in the graph.`);return aw(r==="mixed"?this.type:r,i,s)}}function dw(e){iw.forEach(t=>{sw(e,t),lw(e,t),cw(e,t),uw(e,t)})}function Wi(e,t,n,r,i){let o=r._nodes.values(),a=r.type,s,l,c,u,h,d,p;for(;s=o.next(),s.done!==!0;){let m=!1;if(l=s.value,a!=="undirected"){u=l.out;for(c in u){h=u[c];do{if(d=h.target,m=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(a!=="directed"){u=l.undirected;for(c in u)if(!(t&&l.key>c)){h=u[c];do{if(d=h.target,d.key!==c&&(d=h.source),m=!0,p=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),e&&p)return h;h=h.next}while(h)}}if(n&&!m&&(p=i(l.key,null,l.attributes,null,null,null,null),e&&p))return null}}function hw(e,t){let n={key:e};return eh(t.attributes)||(n.attributes=ke({},t.attributes)),n}function pw(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return eh(n.attributes)||(r.attributes=ke({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function fw(e){if(!Ae(e))throw new M('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new M("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!Ae(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function gw(e){if(!Ae(e))throw new M('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new M("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new M("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!Ae(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new M("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var mw=yy(),vw=new Set(["directed","undirected","mixed"]),Zd=new Set(["domain","_events","_eventsCount","_maxListeners"]),yw=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],ww={allowSelfLoops:!0,multi:!1,type:"mixed"};function bw(e,t,n){if(n&&!Ae(n))throw new M(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new H(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function Qd(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function lh(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new H(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new H(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Ae(s))throw new M(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!e.allowSelfLoops&&o===a)throw new H(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),c=e._nodes.get(a);if(!l)throw new P(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new P(`Graph.${t}: target node "${a}" not found.`);let u={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new H(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new H(`Graph.${t}: 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 Fn(r,i,l,c,s);e._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,c.undirectedDegree++,d&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,c.inDegree++,d&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),r?e._undirectedSize++:e._directedSize++,u.key=i,e.emit("edgeAdded",u),i}function xw(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new H(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new H(`Graph.${t}: 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 M(`Graph.${t}: invalid updater function. Expecting a function but got "${s}"`)}else if(!Ae(s))throw new M(`Graph.${t}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let c;if(l&&(c=s,s=void 0),!e.allowSelfLoops&&o===a)throw new H(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let u=e._nodes.get(o),h=e._nodes.get(a),d,p;if(!n&&(d=e._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new H(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);p=d}if(!p&&!e.multi&&u&&(p=r?u.undirected[a]:u.out[a]),p){let w=[p.key,!1,!1,!1];if(l?!c:!s)return w;if(l){let k=p.attributes;p.attributes=c(k),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else ke(p.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:s});return w}s=s||{},l&&c&&(s=c(s));let m={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new H(`Graph.${t}: the "${i}" edge already exists in the graph.`);let v=!1,y=!1;u||(u=Qd(e,o,{}),v=!0,o===a&&(h=u,y=!0)),h||(h=Qd(e,a,{}),y=!0),d=new Fn(r,i,u,h,s),e._edges.set(i,d);let b=o===a;return r?(u.undirectedDegree++,h.undirectedDegree++,b&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,b&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,m.key=i,e.emit("edgeAdded",m),[i,!0,v,y]}function Mn(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,o=t.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}var oe=class e extends Jd.EventEmitter{constructor(t){if(super(),t=ke({},ww,t),typeof t.multi!="boolean")throw new M(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!vw.has(t.type))throw new M(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new M(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);let n=t.type==="mixed"?th:t.type==="directed"?nh:rh;et(this,"NodeDataClass",n);let r="geid_"+mw()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};et(this,"_attributes",{}),et(this,"_nodes",new Map),et(this,"_edges",new Map),et(this,"_directedSize",0),et(this,"_undirectedSize",0),et(this,"_directedSelfLoopCount",0),et(this,"_undirectedSelfLoopCount",0),et(this,"_edgeKeyGenerator",o),et(this,"_options",t),Zd.forEach(a=>et(this,a,this[a])),st(this,"order",()=>this._nodes.size),st(this,"size",()=>this._edges.size),st(this,"directedSize",()=>this._directedSize),st(this,"undirectedSize",()=>this._undirectedSize),st(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),st(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),st(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),st(this,"multi",this._options.multi),st(this,"type",this._options.type),st(this,"allowSelfLoops",this._options.allowSelfLoops),st(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new M(`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(t,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new M(`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(t,n){if(arguments.length===1){let r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;let r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new M(`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(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new H("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(t);if(!r)throw new P(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new P(`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(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new H("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(t);if(!r)throw new P(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new P(`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(t,n){if(this.multi)throw new H("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new P(`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(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;let r=this._nodes.get(t);if(!r)throw new P(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.degreeWithoutSelfLoops: could not find the "${t}" 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(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;let r=this._edges.get(n);if(!r)throw new P(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new P(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;let r=this._edges.get(t);if(!r)throw new P(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;let n=this._edges.get(t);if(!n)throw new P(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return bw(this,t,n).key}mergeNode(t,n){if(n&&!Ae(n))throw new M(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(ke(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new M(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;let n=this._nodes.get(t);if(!n)throw new P(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Mn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Mn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Mn(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=tt(this,r,i,this.type),!n)throw new P(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new P(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Mn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new H("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 H("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.");t=""+t,n=""+n;let r=tt(this,t,n,"directed");if(!r)throw new P(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Mn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new H("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 H("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=tt(this,t,n,"undirected");if(!r)throw new P(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Mn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let t=this._nodes.values(),n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new M("Graph.updateAttribute: updater should be a function.");let r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!Ae(t))throw new M("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!Ae(t))throw new M("Graph.mergeAttributes: provided attributes are not a plain object.");return ke(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new M("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new M("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Xd(n))throw new M("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=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new M("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Xd(n))throw new M("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=t(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntry: expecting a callback.");Wi(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Wi(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Wi(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Wi(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new M("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new M("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new M("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++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new M("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new M("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new M("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new M("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new M("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=t(r,a.key,a.attributes);return r}nodeEntries(){let t=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=t.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let t=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{t[n++]=hw(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=pw(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof e)return t.forEachNode((l,c)=>{n?this.mergeNode(l,c):this.addNode(l,c)}),t.forEachEdge((l,c,u,h,d,p,m)=>{n?m?this.mergeUndirectedEdgeWithKey(l,u,h,c):this.mergeDirectedEdgeWithKey(l,u,h,c):m?this.addUndirectedEdgeWithKey(l,u,h,c):this.addDirectedEdgeWithKey(l,u,h,c)}),this;if(!Ae(t))throw new M("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Ae(t.attributes))throw new M("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,a,s;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new M("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],fw(a);let{key:l,attributes:c}=a;n?this.mergeNode(l,c):this.addNode(l,c)}}if(t.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=t.edges,!Array.isArray(o))throw new M("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],gw(s);let{source:c,target:u,attributes:h,undirected:d=l}=s,p;"key"in s?(p=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,p.call(this,s.key,c,u,h)):(p=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,p.call(this,c,u,h))}}return this}nullCopy(t){let n=new e(ke({},this._options,t));return n.replaceAttributes(ke({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let o=ke({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new H(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new H("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new H("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(t),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,lh(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ke({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let t={};this._nodes.forEach((o,a)=>{t[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",c=o.source.key,u=o.target.key,h;o.undirected&&c>u&&(h=c,c=u,u=h);let d=`(${c})${s}(${u})`;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)&&!Zd.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,et(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(oe.prototype[Symbol.for("nodejs.util.inspect.custom")]=oe.prototype.inspect);yw.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?lh:xw;e.generateKey?oe.prototype[n]=function(i,o,a){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,a,t==="update")}:oe.prototype[n]=function(i,o,a,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,a,s,t==="update")}})});Ly(oe);Wy(oe);rw(oe);dw(oe);var Ui=class extends oe{constructor(t){let n=ke({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new M("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new M('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Hi=class extends oe{constructor(t){let n=ke({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new M("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new M('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Bi=class extends oe{constructor(t){let n=ke({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Ki=class extends oe{constructor(t){let n=ke({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new M('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Vi=class extends oe{constructor(t){let n=ke({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new M("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new M('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function $n(e){e.from=function(t,n){let r=ke({},t.options,n),i=new e(r);return i.import(t),i}}$n(oe);$n(Ui);$n(Hi);$n(Bi);$n(Ki);$n(Vi);oe.Graph=oe;oe.DirectedGraph=Ui;oe.UndirectedGraph=Hi;oe.MultiGraph=Bi;oe.MultiDirectedGraph=Ki;oe.MultiUndirectedGraph=Vi;oe.InvalidArgumentsGraphError=M;oe.NotFoundGraphError=P;oe.UsageGraphError=H;function kw(){return new oe({multi:!0,type:"directed"})}function ts(e){let t=kw();for(let n of e.nodes){let{id:r,...i}=n;t.addNode(r,i)}for(let n of e.edges){let{key:r,source:i,target:o,...a}=n;t.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return t}function ch(e,t){let n=0;for(let[r,i]of t)e.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(e.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function ns(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var uh=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function dh(e,t,n){let r=null,i=ts({nodes:[],edges:[]}),o=null,a=null,s=0,l=0,c=null,u=0,h=()=>{},d=()=>{},p=()=>{},m=()=>{},v=()=>{},y=null,b=!1,w=A=>{if(y===null)return;let D=y;y=null,r?.setSetting("enableCameraPanning",!0),(A===null||A===D)&&v(D)},k=()=>au([...ns(i).values()]),_=A=>{let D=uu(o,a,s),O=hu(o,a,s);A.setSetting("nodeReducer",(U,T)=>({...T,...D(U,T,t)})),A.setSetting("edgeReducer",(U,T)=>({...T,...O(U,T,t)}))},I=()=>{if(n===void 0||c!==null)return;u=n.now();let A=()=>{c=null;let D=n.now();if(s=du(s,l,D-u),u=D,r!==null&&_(r),s===l){s===0&&(o=null);return}c=n.request(A)};c=n.request(A)};return{mount(A){if(r!==null)return;let D=e(i,A,pu(t));D.on("clickNode",({node:O})=>{b||h(O)}),D.on("doubleClickNode",({node:O,preventSigmaDefault:U})=>{U(),b||h(O)}),D.on("clickStage",()=>h(null)),D.on("downNode",({node:O})=>{y=O,b=!1,r?.setSetting("enableCameraPanning",!1),p(O)}),D.on("moveBody",O=>{y!==null&&(b=!0,O.preventSigmaDefault(),m(y,D.viewportToGraph({x:O.event.x,y:O.event.y})))}),D.on("enterNode",({node:O})=>d(O)),D.on("leaveNode",()=>d(null)),D.on("upNode",()=>w(y)),D.on("upStage",()=>w(null)),_(D),D.setCustomBBox(k()),r=D},setGraph(A){i=ts(A),r?.setGraph(i),r?.setCustomBBox(k())},setPositions(A){ch(i,A),r?.refresh()},setHighlight(A,D=null){if(n===void 0){o=A,a=D,s=A===null?0:1,l=s,r!==null&&_(r);return}if(A===null){if(l=0,o===null)return}else o=A,a=D,l=1;r!==null&&_(r),s!==l&&I()},onSelect(A){h=A},onHover(A){d=A},onDragStart(A){p=A},onDragMove(A){m=A},onDragEnd(A){v=A},fit(){r?.setCustomBBox(k()),r?.getCamera().animatedReset()},positions(){return ns(i)},destroy(){c!==null&&(n?.cancel(c),c=null),r?.kill(),r=null}}}var hh=e=>dh((t,n,r)=>new Yd(t,n,r),e,uh(window));function ph(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _w(e){if(Array.isArray(e))return e}function Ew(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function Tw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
333
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sw(e,t){return _w(e)||Ew(e,t)||Rw(e,t)||Tw()}function Rw(e,t){if(e){if(typeof e=="string")return ph(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ph(e,t):void 0}}var Ah=Object.entries,fh=Object.setPrototypeOf,Aw=Object.isFrozen,Cw=Object.getPrototypeOf,Lw=Object.getOwnPropertyDescriptor,_e=Object.freeze,Re=Object.seal,zn=Object.create,Ch=typeof Reflect<"u"&&Reflect,cs=Ch.apply,us=Ch.construct;_e||(_e=function(t){return t});Re||(Re=function(t){return t});cs||(cs=function(t,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 t.apply(n,i)});us||(us=function(t){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 t(...r)});var dn=ye(Array.prototype.forEach),Nw=ye(Array.prototype.lastIndexOf),gh=ye(Array.prototype.pop),br=ye(Array.prototype.push),Pw=ye(Array.prototype.splice),Wn=Array.isArray,_r=ye(String.prototype.toLowerCase),rs=ye(String.prototype.toString),mh=ye(String.prototype.match),xr=ye(String.prototype.replace),vh=ye(String.prototype.indexOf),Dw=ye(String.prototype.trim),Iw=ye(Number.prototype.toString),Gw=ye(Boolean.prototype.toString),yh=typeof BigInt>"u"?null:ye(BigInt.prototype.toString),wh=typeof Symbol>"u"?null:ye(Symbol.prototype.toString),Ue=ye(Object.prototype.hasOwnProperty),kr=ye(Object.prototype.toString),Ne=ye(RegExp.prototype.test),un=Mw(TypeError);function ye(e){return function(t){t instanceof RegExp&&(t.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 cs(e,t,r)}}function Mw(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return us(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_r;if(fh&&fh(e,null),!Wn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let o=n(i);o!==i&&(Aw(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Ow(e){for(let t=0;t<e.length;t++)Ue(e,t)||(e[t]=null);return e}function je(e){let t=zn(null);for(let r of Ah(e)){var n=Sw(r,2);let i=n[0],o=n[1];Ue(e,i)&&(Wn(o)?t[i]=Ow(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=je(o):t[i]=o)}return t}function Fw(e){switch(typeof e){case"string":return e;case"number":return Iw(e);case"boolean":return Gw(e);case"bigint":return yh?yh(e):"0";case"symbol":return wh?wh(e):"Symbol()";case"undefined":return kr(e);case"function":case"object":{if(e===null)return kr(e);let t=e,n=lt(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:kr(r)}return kr(e)}default:return kr(e)}}function lt(e,t){for(;e!==null;){let r=Lw(e,t);if(r){if(r.get)return ye(r.get);if(typeof r.value=="function")return ye(r.value)}e=Cw(e)}function n(){return null}return n}function $w(e){try{return Ne(e,""),!0}catch{return!1}}var bh=_e(["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"]),is=_e(["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"]),os=_e(["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"]),zw=_e(["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"]),as=_e(["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"]),Ww=_e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),xh=_e(["#text"]),kh=_e(["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"]),ss=_e(["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"]),_h=_e(["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"]),qi=_e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Uw=Re(/{{[\w\W]*|^[\w\W]*}}/g),Hw=Re(/<%[\w\W]*|^[\w\W]*%>/g),Bw=Re(/\${[\w\W]*/g),Kw=Re(/^data-[\-\w.\u00B7-\uFFFF]+$/),Vw=Re(/^aria-[\-\w]+$/),Eh=Re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),jw=Re(/^(?:\w+script|data):/i),qw=Re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Yw=Re(/^html$/i),Xw=Re(/^[a-z][.\w]*(-[.\w]+)+$/i),Th=Re(/<[/\w!]/g),Sh=Re(/<[/\w]/g),Zw=Re(/<\/no(script|embed|frames)/i),Qw=Re(/\/>/i),Ve={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Lh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Jw=_e(J({},Lh)),eb=(function(){let e={};return dn(Lh,t=>{e[t]=Re(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),_e(e)})(),tb=function(){return typeof window>"u"?null:window},nb=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Rh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Wt=function(t,n,r,i){return Ue(t,n)&&Wn(t[n])?J(i.base?je(i.base):{},t[n],i.transform):r},ls=function(t,n,r){let i=Ue(t,n)?t[n]:void 0;return i&&typeof i=="object"?je(i):r()};function Nh(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:tb(),t=C=>Nh(C);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Ve.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let o=e.HTMLTemplateElement,a=e.Node,s=e.Element,l=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let u=e.DOMParser,h=e.trustedTypes,d=s.prototype,p=lt(d,"cloneNode"),m=lt(d,"remove"),v=lt(d,"nextSibling"),y=lt(d,"childNodes"),b=lt(d,"parentNode"),w=lt(d,"shadowRoot"),k=lt(d,"attributes"),_=a&&a.prototype?lt(a.prototype,"nodeType"):null,I=a&&a.prototype?lt(a.prototype,"nodeName"):null,A=a&&a.prototype?lt(a.prototype,"ownerDocument"):null,D=function(g){return _?_(g):g.nodeType},O=function(g){return I?I(g):g.nodeName};if(typeof o=="function"){let C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let U,T="",F,K=!1,Z=0,Y=function(){if(Z>0)throw un('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.')},ne=function(g){Y(),Z++;try{return U.createHTML(g)}finally{Z--}},Be=function(g){Y(),Z++;try{return U.createScriptURL(g)}finally{Z--}},Lt=function(){return K||(F=nb(h,i),K=!0),F},Fe=n,$e=Fe.implementation,Ce=Fe.createNodeIterator,me=Fe.createDocumentFragment,Ye=Fe.getElementsByTagName,Ee=r.importNode,re=Rh();t.isSupported=typeof Ah=="function"&&typeof b=="function"&&$e&&$e.createHTMLDocument!==void 0;let Nt=Uw,Pt=Hw,Cr=Bw,Lr=Kw,go=Vw,mo=jw,Nr=qw,Pr=Xw,mn=Eh,ee=null,Kn=J({},[...bh,...is,...os,...as,...xh]),X=null,Le=J({},[...kh,...ss,..._h,...qi]),Te=Object.seal(zn(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}})),ut=null,Dr=null,we=Object.seal(zn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ht=!0,dt=!0,Xe=!1,Vn=!0,rt=!1,mt=!0,vt=!1,jn=!1,Bt=null,vn=null,yn=!1,yt=!1,Kt=!1,Vt=!1,Ir=!0,E=!1,L="user-content-",B=!0,N=!1,W={},ce=null,it=J({},["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"]),Dt=null,qn=J({},["audio","video","img","source","image","track"]),Gr=null,Ns=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Mr="http://www.w3.org/1998/Math/MathML",Or="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml",wn=ht,vo=!1,yo=null,xf=J({},[Mr,Or,ht],rs),Ps=_e(["mi","mo","mn","ms","mtext"]),wo=J({},Ps),Ds=_e(["annotation-xml"]),bo=J({},Ds),kf=J({},["title","style","font","a","script"]),Yn=null,_f=["application/xhtml+xml","text/html"],Ef="text/html",fe=null,bn=null,Tf=n.createElement("form"),Is=function(g){return g instanceof RegExp||g instanceof Function},xo=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(bn&&bn===g)return;(!g||typeof g!="object")&&(g={}),g=je(g),Yn=_f.indexOf(g.PARSER_MEDIA_TYPE)===-1?Ef:g.PARSER_MEDIA_TYPE,fe=Yn==="application/xhtml+xml"?rs:_r,ee=Wt(g,"ALLOWED_TAGS",Kn,{transform:fe}),X=Wt(g,"ALLOWED_ATTR",Le,{transform:fe}),yo=Wt(g,"ALLOWED_NAMESPACES",xf,{transform:rs}),Gr=Wt(g,"ADD_URI_SAFE_ATTR",Ns,{transform:fe,base:Ns}),Dt=Wt(g,"ADD_DATA_URI_TAGS",qn,{transform:fe,base:qn}),ce=Wt(g,"FORBID_CONTENTS",it,{transform:fe}),ut=Wt(g,"FORBID_TAGS",je({}),{transform:fe}),Dr=Wt(g,"FORBID_ATTR",je({}),{transform:fe}),W=Ue(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?je(g.USE_PROFILES):g.USE_PROFILES:!1,Ht=g.ALLOW_ARIA_ATTR!==!1,dt=g.ALLOW_DATA_ATTR!==!1,Xe=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Vn=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,rt=g.SAFE_FOR_TEMPLATES||!1,mt=g.SAFE_FOR_XML!==!1,vt=g.WHOLE_DOCUMENT||!1,yt=g.RETURN_DOM||!1,Kt=g.RETURN_DOM_FRAGMENT||!1,Vt=g.RETURN_TRUSTED_TYPE||!1,yn=g.FORCE_BODY||!1,Ir=g.SANITIZE_DOM!==!1,E=g.SANITIZE_NAMED_PROPS||!1,B=g.KEEP_CONTENT!==!1,N=g.IN_PLACE||!1,mn=$w(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:Eh,wn=typeof g.NAMESPACE=="string"?g.NAMESPACE:ht,wo=ls(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>J({},Ps)),bo=ls(g,"HTML_INTEGRATION_POINTS",()=>J({},Ds));let x=ls(g,"CUSTOM_ELEMENT_HANDLING",()=>zn(null));if(Te=zn(null),Ue(x,"tagNameCheck")&&Is(x.tagNameCheck)&&(Te.tagNameCheck=x.tagNameCheck),Ue(x,"attributeNameCheck")&&Is(x.attributeNameCheck)&&(Te.attributeNameCheck=x.attributeNameCheck),Ue(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(Te.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),Re(Te),rt&&(dt=!1),Kt&&(yt=!0),W&&(ee=J({},xh),X=zn(null),W.html===!0&&(J(ee,bh),J(X,kh)),W.svg===!0&&(J(ee,is),J(X,ss),J(X,qi)),W.svgFilters===!0&&(J(ee,os),J(X,ss),J(X,qi)),W.mathMl===!0&&(J(ee,as),J(X,_h),J(X,qi))),we.tagCheck=null,we.attributeCheck=null,Ue(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?we.tagCheck=g.ADD_TAGS:Wn(g.ADD_TAGS)&&(ee===Kn&&(ee=je(ee)),J(ee,g.ADD_TAGS,fe))),Ue(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?we.attributeCheck=g.ADD_ATTR:Wn(g.ADD_ATTR)&&(X===Le&&(X=je(X)),J(X,g.ADD_ATTR,fe))),Ue(g,"ADD_FORBID_CONTENTS")&&Wn(g.ADD_FORBID_CONTENTS)&&(ce===it&&(ce=je(ce)),J(ce,g.ADD_FORBID_CONTENTS,fe)),B&&(ee["#text"]=!0),vt&&J(ee,["html","head","body"]),ee.table&&(J(ee,["tbody"]),delete ut.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw un('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let S=U;U=g.TRUSTED_TYPES_POLICY;try{T=ne("")}catch(G){throw U=S,G}}else g.TRUSTED_TYPES_POLICY===null?(U=void 0,T=""):(U===void 0&&(U=Lt()),U&&typeof T=="string"&&(T=ne("")));_e&&_e(g),bn=g},Gs=J({},[...is,...os,...zw]),Ms=J({},[...as,...Ww]),Sf=function(g,x,S){return x.namespaceURI===ht?g==="svg":x.namespaceURI===Mr?g==="svg"&&(S==="annotation-xml"||wo[S]):!!Gs[g]},Rf=function(g,x,S){return x.namespaceURI===ht?g==="math":x.namespaceURI===Or?g==="math"&&bo[S]:!!Ms[g]},Af=function(g,x,S){return x.namespaceURI===Or&&!bo[S]||x.namespaceURI===Mr&&!wo[S]?!1:!Ms[g]&&(kf[g]||!Gs[g])},Cf=function(g){let x=b(g);(!x||!x.tagName)&&(x={namespaceURI:wn,tagName:"template"});let S=_r(g.tagName),G=_r(x.tagName);return yo[g.namespaceURI]?g.namespaceURI===Or?Sf(S,x,G):g.namespaceURI===Mr?Rf(S,x,G):g.namespaceURI===ht?Af(S,x,G):!!(Yn==="application/xhtml+xml"&&yo[g.namespaceURI]):!1},It=function(g){br(t.removed,{element:g});try{b(g).removeChild(g)}catch{if(m(g),!b(g))throw un("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Os=function(g,x,S){try{g.removeAttributeNode(x)}catch{try{g.removeAttribute(S)}catch{}}},Fr=function(g){$r(g);let x=y(g);if(x){let G=[];dn(x,z=>{br(G,z)}),dn(G,z=>{try{m(z)}catch{}})}let S=k(g);if(S)for(let G=S.length-1;G>=0;--G){let z=S[G],V=z&&z.name;typeof V=="string"&&Os(g,z,V)}},jt=function(g,x,S){if(!S)try{S=x.getAttributeNode(g)}catch{S=null}br(t.removed,{attribute:S||null,from:x});try{S?x.removeAttributeNode(S):x.removeAttribute(g)}catch{try{x.removeAttribute(g)}catch{}}if(g==="is")if(yt||Kt)try{It(x)}catch{}else try{x.setAttribute(g,"")}catch{}},Lf=function(g){let x=k(g);if(x)for(let S=x.length-1;S>=0;--S){let G=x[S],z=G&&G.name;typeof z!="string"||X[fe(z)]||Os(g,G,z)}},$r=function(g){let x=[g];for(;x.length>0;){let S=x.pop();D(S)===Ve.element&&Lf(S);let z=y(S);if(z)for(let V=z.length-1;V>=0;--V)x.push(z[V])}},Fs=function(g,x){return mt?g==="patchsrc"?!0:g==="for"&&x!=="label"&&x!=="output":!1},Nf=function(g){if(!mt)return;let x=[g];for(;x.length>0;){let S=x.pop(),G=D(S);if(G===Ve.processingInstruction||G===Ve.comment&&Ne(Sh,S.data)){try{m(S)}catch{}continue}if(G===Ve.element){let V=S,se=fe(O(S));try{V.hasAttribute&&V.hasAttribute("patchsrc")&&V.removeAttribute("patchsrc"),V.hasAttribute&&V.hasAttribute("for")&&Fs("for",se)&&V.removeAttribute("for")}catch{}}let z=y(S);if(z)for(let V=z.length-1;V>=0;--V)x.push(z[V])}},$s=function(g){let x=null,S=null;if(yn)g="<remove></remove>"+g;else{let V=mh(g,/^[\r\n\t ]+/);S=V&&V[0]}Yn==="application/xhtml+xml"&&wn===ht&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let G=U?ne(g):g;if(wn===ht)try{x=new u().parseFromString(G,Yn)}catch{}if(!x||!x.documentElement){x=$e.createDocument(wn,"template",null);try{x.documentElement.innerHTML=vo?T:G}catch{}}let z=x.body||x.documentElement;return g&&S&&z.insertBefore(n.createTextNode(S),z.childNodes[0]||null),wn===ht?Ye.call(x,vt?"html":"body")[0]:vt?x.documentElement:z},zs=function(g){let x=A?A(g):g.ownerDocument;return Ce.call(x||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},zr=function(g){return g=xr(g,Nt," "),g=xr(g,Pt," "),g=xr(g,Cr," "),g},ko=function(g){var x;g.normalize();let S=A?A(g):g.ownerDocument,G=Ce.call(S||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),z=G.nextNode();for(;z;)z.data=zr(z.data),z=G.nextNode();let V=(x=g.querySelectorAll)===null||x===void 0?void 0:x.call(g,"template");V&&dn(V,se=>{xn(se.content)&&ko(se.content)})},Wr=function(g){let x=I?I(g):null;return typeof x!="string"||fe(x)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==k(g)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==_(g)||g.childNodes!==y(g)},xn=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return _(g)===Ve.documentFragment}catch{return!1}},Xn=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return typeof _(g)=="number"}catch{return!1}};function pt(C,g,x){C.length!==0&&dn(C,S=>{S.call(t,g,x,bn)})}let Pf=function(g,x){return!!(mt&&g.hasChildNodes()&&!Xn(g.firstElementChild)&&Ne(Th,g.textContent)&&Ne(Th,g.innerHTML)||mt&&g.namespaceURI===ht&&Jw[x]&&(Xn(g.firstElementChild)||typeof g.textContent=="string"&&Ne(eb[x],g.textContent))||g.nodeType===Ve.processingInstruction||mt&&g.nodeType===Ve.comment&&Ne(Sh,g.data))},Ur=function(g,x){if(g instanceof RegExp)return Ne(g,x);if(g instanceof Function){for(var S=arguments.length,G=new Array(S>2?S-2:0),z=2;z<S;z++)G[z-2]=arguments[z];return!!g(x,...G)}return!1},Df=function(g,x,S){if(!ut[x]&&Ks(x)&&Ur(Te.tagNameCheck,x))return!1;if(B&&!ce[x]){let G=b(g),z=y(g);if(z&&G){let V=z.length;for(let se=V-1;se>=0;--se){let de=g===S?p(z[se],!0):z[se];G.insertBefore(de,v(g))}}}return It(g),!0},Ws=function(g,x,S,G){return g.length===0?x:x===S||x===G?je(x):x},Us=function(g,x){return g===x||b(g)!==null?!1:(N&&$r(g),!0)},Hs=function(g,x){if(pt(re.beforeSanitizeElements,g,null),Us(g,x))return!0;if(Wr(g))return It(g),!0;let S=fe(O(g));if(ee=Ws(re.uponSanitizeElement,ee,Kn,Bt),pt(re.uponSanitizeElement,g,{tagName:S,allowedTags:ee}),Us(g,x))return!0;if(Pf(g,S))return It(g),!0;if(ut[S]||!(we.tagCheck instanceof Function&&we.tagCheck(S))&&!ee[S]){let z=Df(g,S,x);return z===!1&&pt(re.afterSanitizeElements,g,null),z}if(D(g)===Ve.element&&!Cf(g)||(S==="noscript"||S==="noembed"||S==="noframes")&&Ne(Zw,g.innerHTML))return It(g),!0;if(rt&&g.nodeType===Ve.text){let z=zr(g.textContent);g.textContent!==z&&(br(t.removed,{element:g.cloneNode()}),g.textContent=z)}return pt(re.afterSanitizeElements,g,null),!1},Bs=function(g,x,S){if(Dr[x]||Fs(x,g)||Ir&&(x==="id"||x==="name")&&(S in n||S in Tf))return!1;let G=X[x]||we.attributeCheck instanceof Function&&we.attributeCheck(x,g);return dt&&Ne(Lr,x)||Ht&&Ne(go,x)?!0:G?Gr[x]||Ne(mn,xr(S,Nr,""))||(x==="src"||x==="xlink:href"||x==="href")&&g!=="script"&&vh(S,"data:")===0&&Dt[g]||Xe&&!Ne(mo,xr(S,Nr,""))?!0:!S:Ks(g)&&Ur(Te.tagNameCheck,g)&&Ur(Te.attributeNameCheck,x,g)||x==="is"&&Te.allowCustomizedBuiltInElements&&Ur(Te.tagNameCheck,S)},If=J({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ks=function(g){return!If[_r(g)]&&Ne(Pr,g)},Gf=function(g,x,S,G){if(U&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!S)switch(h.getAttributeType(g,x)){case"TrustedHTML":return ne(G);case"TrustedScriptURL":return Be(G)}return G},Mf=function(g,x,S,G){try{S?g.setAttributeNS(S,x,G):g.setAttribute(x,G),Wr(g)?It(g):gh(t.removed)}catch{jt(x,g)}},Vs=function(g){pt(re.beforeSanitizeAttributes,g,null);let x=g.attributes;if(!x||Wr(g))return;X=Ws(re.uponSanitizeAttribute,X,Le,vn);let S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0},G=x.length,z=fe(g.nodeName);for(;G--;){let V=x[G],se=V.name,de=V.namespaceURI,ze=V.value,We=fe(se),Eo=ze,De=se==="value"?Eo:Dw(Eo);if(S.attrName=We,S.attrValue=De,S.keepAttr=!0,S.forceKeepAttr=void 0,pt(re.uponSanitizeAttribute,g,S),De=S.attrValue,E&&(We==="id"||We==="name")&&vh(De,L)!==0&&(jt(se,g,V),De=L+De),mt&&Ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){jt(se,g,V);continue}if(We==="attributename"&&mh(De,"href")){jt(se,g,V);continue}if(!S.forceKeepAttr){if(!S.keepAttr){jt(se,g,V);continue}if(!Vn&&Ne(Qw,De)){jt(se,g,V);continue}if(rt&&(De=zr(De)),!Bs(z,We,De)){jt(se,g,V);continue}De=Gf(z,We,de,De),De!==Eo&&Mf(g,se,de,De)}}pt(re.afterSanitizeAttributes,g,null)},Hr=function(g){let x=null,S=zs(g);for(pt(re.beforeSanitizeShadowDOM,g,null);x=S.nextNode();)if(pt(re.uponSanitizeShadowNode,x,null),Hs(x,g),Vs(x),xn(x.content)&&Hr(x.content),D(x)===Ve.element){let G=w(x);xn(G)&&(_o(G),Hr(G))}pt(re.afterSanitizeShadowDOM,g,null)},_o=function(g){let x=[{node:g,shadow:null}];for(;x.length>0;){let S=x.pop();if(S.shadow){Hr(S.shadow);continue}let G=S.node,V=D(G)===Ve.element,se=y(G);if(se)for(let de=se.length-1;de>=0;--de)x.push({node:se[de],shadow:null});if(V){let de=I?I(G):null;if(typeof de=="string"&&fe(de)==="template"){let ze=G.content;xn(ze)&&x.push({node:ze,shadow:null})}}if(V){let de=w(G);xn(de)&&x.push({node:null,shadow:de},{node:de,shadow:null})}}};return t.sanitize=function(C){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,G=null,z=null;if(vo=!C,vo&&(C="<!-->"),typeof C!="string"&&!Xn(C)&&(C=Fw(C),typeof C!="string"))throw un("dirty is not a string, aborting");if(!t.isSupported)return C;jn?(ee=Bt,X=vn):xo(g),(re.uponSanitizeElement.length>0||re.uponSanitizeAttribute.length>0)&&(ee=je(ee)),re.uponSanitizeAttribute.length>0&&(X=je(X)),t.removed=[];let V=N&&typeof C!="string"&&Xn(C);if(V){Nf(C);let ze=O(C);if(typeof ze=="string"){let We=fe(ze);if(!ee[We]||ut[We])throw Fr(C),un("root node is forbidden and cannot be sanitized in-place")}if(Wr(C))throw Fr(C),un("root node is clobbered and cannot be sanitized in-place");try{_o(C)}catch(We){throw Fr(C),We}}else if(Xn(C))x=$s("<!---->"),S=x.ownerDocument.importNode(C,!0),S.nodeType===Ve.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S),_o(S);else{if(!yt&&!rt&&!vt&&C.indexOf("<")===-1)return U&&Vt?ne(C):C;if(x=$s(C),!x)return yt?null:Vt?T:""}x&&yn&&It(x.firstChild);let se=V?C:x;try{let ze=zs(se);for(;G=ze.nextNode();)Hs(G,se),Vs(G),xn(G.content)&&Hr(G.content)}catch(ze){throw V&&(Fr(C),dn(t.removed,We=>{We.element&&$r(We.element)})),ze}if(V)return dn(t.removed,ze=>{ze.element&&$r(ze.element)}),rt&&ko(C),C;if(yt){if(rt&&ko(x),Kt)for(z=me.call(x.ownerDocument);x.firstChild;)z.appendChild(x.firstChild);else z=x;return(X.shadowroot||X.shadowrootmode)&&(z=Ee.call(r,z,!0)),z}let de=vt?x.outerHTML:x.innerHTML;return vt&&ee["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Ne(Yw,x.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
334
+ `+de),rt&&(de=zr(de)),U&&Vt?ne(de):de},t.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xo(C),jn=!0,Bt=ee,vn=X},t.clearConfig=function(){bn=null,jn=!1,Bt=null,vn=null,U=F,T=""},t.isValidAttribute=function(C,g,x){bn||xo({});let S=fe(C),G=fe(g);return Bs(S,G,x)},t.addHook=function(C,g){typeof g=="function"&&Ue(re,C)&&br(re[C],g)},t.removeHook=function(C,g){if(Ue(re,C)){if(g!==void 0){let x=Nw(re[C],g);return x===-1?void 0:Pw(re[C],x,1)[0]}return gh(re[C])}},t.removeHooks=function(C){Ue(re,C)&&(re[C]=[])},t.removeAllHooks=function(){re=Rh()},t}var Ph=Nh();function fs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fn=fs();function zh(e){fn=e}var hn={exec:()=>null};function Un(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function q(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(Pe.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,t)};return r}var rb=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Pe={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:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Un(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Un(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Un(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Un(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Un(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Un(e=>new RegExp(`^ {0,${e}}>`))},ib=/^(?:[ \t]*(?:\n|$))+/,ob=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ab=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,gs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Wh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Uh=q(Wh).replace(/bull/g,gs).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(),lb=q(Wh).replace(/bull/g,gs).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(),ms=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,cb=/^[^\n]+/,vs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ub=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",vs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),db=q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,gs).getRegex(),Ji="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",ys=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,hb=q("^ {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",ys).replace("tag",Ji).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hh=e=>q(ms).replace("hr",Sr).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",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ji).getRegex(),pb=Hh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),fb=Hh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),gb=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fb).getRegex(),ws={blockquote:gb,code:ob,def:ub,fences:ab,heading:sb,hr:Sr,html:hb,lheading:Uh,list:db,newline:ib,paragraph:pb,table:hn,text:cb},Dh=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sr).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",Ji).getRegex(),mb={...ws,lheading:lb,table:Dh,paragraph:q(ms).replace("hr",Sr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Dh).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",Ji).getRegex()},vb={...ws,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ys).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:hn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:q(ms).replace("hr",Sr).replace("heading",` *#{1,6} *[^
335
+ ]`).replace("lheading",Uh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},yb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,wb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Bh=/^( {2,}|\\)\n(?!\s*$)/,bb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,At=/[\p{P}\p{S}]/u,Hn=/[\s\p{P}\p{S}]/u,Rr=/[^\s\p{P}\p{S}]/u,xb=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Hn).getRegex(),kb=/[\p{Pi}\p{Ps}"']/u,Kh=/(?!~)[\p{P}\p{S}]/u,_b=/(?!~)[\s\p{P}\p{S}]/u,Eb=/(?:[^\s\p{P}\p{S}]|~)/u,Tb=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",rb?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Vh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Sb=q(Vh,"u").replace(/punct/g,At).getRegex(),Rb=q(Vh,"u").replace(/punct/g,Kh).getRegex(),Ab=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Cb=q(Ab,"u").replace(/openQuote/g,kb).replace(/punct/g,At).getRegex(),jh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Lb=q(jh,"gu").replace(/notPunctSpace/g,Rr).replace(/punctSpace/g,Hn).replace(/punct/g,At).getRegex(),Nb=q(jh,"gu").replace(/notPunctSpace/g,Eb).replace(/punctSpace/g,_b).replace(/punct/g,Kh).getRegex(),Pb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Db=q(Pb,"gu").replace(/notPunctSpace/g,Rr).replace(/punctSpace/g,Hn).replace(/punct/g,At).getRegex(),Ib=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Rr).replace(/punctSpace/g,Hn).replace(/punct/g,At).getRegex(),Gb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Mb=q(Gb,"gu").replace(/notPunctSpace/g,Rr).replace(/punctSpace/g,Hn).replace(/punct/g,At).getRegex(),Ob=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,At).getRegex(),Fb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",$b=q(Fb,"gu").replace(/notPunctSpace/g,Rr).replace(/punctSpace/g,Hn).replace(/punct/g,At).getRegex(),zb=q(/\\(punct)/,"gu").replace(/punct/g,At).getRegex(),Wb=q(/^<(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(),Ub=q(ys).replace("(?:-->|$)","-->").getRegex(),Hb=q("^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",Ub).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Bb=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Xi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),qh=q(/^!?\[(label)\]\[(ref)\]/).replace("label",Xi).replace("ref",vs).getRegex(),Yh=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",vs).getRegex(),Kb=q("reflink|nolink(?!\\()","g").replace("reflink",qh).replace("nolink",Yh).getRegex(),Ih=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,bs={_backpedal:hn,anyPunctuation:zb,autolink:Wb,blockSkip:Tb,br:Bh,code:wb,del:hn,delLDelim:hn,delRDelim:hn,emStrongLDelim:Sb,emStrongRDelimAst:Lb,emStrongRDelimUnd:Ib,escape:yb,link:Bb,nolink:Yh,punctuation:xb,reflink:qh,reflinkSearch:Kb,tag:Hb,text:bb,url:hn},Vb={...bs,emStrongLDelim:Cb,emStrongRDelimAst:Db,emStrongRDelimUnd:Mb,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",Xi).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xi).getRegex()},ds={...bs,emStrongRDelimAst:Nb,emStrongLDelim:Rb,delLDelim:Ob,delRDelim:$b,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ih).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:q(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ih).getRegex()},jb={...ds,br:q(Bh).replace("{2,}","*").getRegex(),text:q(ds.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Yi={normal:ws,gfm:mb,pedantic:vb},Er={normal:bs,gfm:ds,breaks:jb,pedantic:Vb},qb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Gh=e=>qb[e];function gt(e,t){if(t){if(Pe.escapeTest.test(e))return e.replace(Pe.escapeReplace,Gh)}else if(Pe.escapeTestNoEncode.test(e))return e.replace(Pe.escapeReplaceNoEncode,Gh);return e}function Mh(e){try{e=encodeURI(e).replace(Pe.percentDecode,"%")}catch{return null}return e}function Oh(e,t){let n=e.replace(Pe.findPipe,(o,a,s)=>{let l=!1,c=a;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Pe.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Pe.slashPipe,"|");return r}function Ut(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r;){let o=e.charAt(r-i-1);if(o===t&&!n)i++;else if(o!==t&&n)i++;else break}return e.slice(0,r-i)}function Fh(e){let t=e.split(`
336
+ `),n=t.length-1;for(;n>=0&&Pe.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
337
+ `)}function Yb(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Xb(e,t=0){let n=t,r="";for(let i of e)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function $h(e,t,n,r,i){let o=t.href,a=t.title||null,s=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function Zb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
339
338
  `).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 Ni=class{options;rules;lexer;constructor(e){this.options=e||an}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Mh(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=zb(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ot(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ot(t[0],`
341
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ot(t[0],`
342
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Ot(t[0],`
339
+ `)}var Zi=class{options;rules;lexer;constructor(e){this.options=e||fn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Fh(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Zb(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ut(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ut(t[0],`
340
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Ut(t[0],`
341
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Ut(t[0],`
343
342
  `).split(`
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
- `),c=u.replace(this.rules.other.blockquoteSetextReplace,`
343
+ `),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 c=s.join(`
344
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
346
345
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
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 p=d,m=n.join(`
349
- `),w=p.raw+`
350
- `+m.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(w);o[o.length-1]=v,r=`${r}
351
- ${m}`,i=i.substring(0,i.length-p.text.length)+v.text;break}else if(d?.type==="list"){let p=d,m=p.raw+`
346
+ ${c}`:c,i=i?`${i}
347
+ ${u}`:u;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,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 p=d,m=n.join(`
348
+ `),v=p.raw+`
349
+ `+m.replace(this.rules.other.blockquoteSetextReplace2,""),y=this.blockquote(v);o[o.length-1]=y,r=`${r}
350
+ ${m}`,i=i.substring(0,i.length-p.text.length)+y.text;break}else if(d?.type==="list"){let p=d,m=p.raw+`
352
351
  `+n.join(`
353
- `),w=this.list(m);o[o.length-1]=w,r=r.substring(0,r.length-d.raw.length)+w.raw,i=i.substring(0,i.length-p.raw.length)+w.raw,n=m.substring(o.at(-1).raw.length).split(`
354
- `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[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(;e;){let l=!1,u="",c="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let h=$b(t[2].split(`
352
+ `),v=this.list(m);o[o.length-1]=v,r=r.substring(0,r.length-d.raw.length)+v.raw,i=i.substring(0,i.length-p.raw.length)+v.raw,n=m.substring(o.at(-1).raw.length).split(`
353
+ `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[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(;e;){let l=!1,c="",u="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let h=Xb(t[2].split(`
355
354
  `,1)[0],t[1].length),d=e.split(`
356
- `,1)[0],p=!h.trim(),m=0;if(this.options.pedantic?(m=2,c=h.trimStart()):p?m=t[1].length+1:(m=h.search(this.rules.other.nonSpaceChar),m=m>4?1:m,c=h.slice(m),m+=t[1].length),p&&this.rules.other.blankLine.test(d)&&(u+=d+`
357
- `,e=e.substring(d.length+1),l=!0),!l){let w=this.rules.other.nextBulletRegex(m),v=this.rules.other.hrRegex(m),b=this.rules.other.fencesBeginRegex(m),y=this.rules.other.headingBeginRegex(m),x=this.rules.other.htmlBeginRegex(m),k=this.rules.other.blockquoteBeginRegex(m);for(;e;){let N=e.split(`
358
- `,1)[0],A;if(d=N,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),A=d):A=d.replace(this.rules.other.tabCharGlobal," "),b.test(d)||y.test(d)||x.test(d)||k.test(d)||w.test(d)||v.test(d))break;if(A.search(this.rules.other.nonSpaceChar)>=m||!d.trim())c+=`
359
- `+A.slice(m);else{if(p||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(h)||y.test(h)||v.test(h))break;c+=`
360
- `+d}p=!d.trim(),u+=N+`
361
- `,e=e.substring(N.length+1),h=A.slice(m)}}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(e){let t=this.rules.block.html.exec(e);if(t){let n=Mh(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Ot(t[0],`
362
- `),href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ih(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
363
- `):[],o={type:"table",raw:Ot(t[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(Ih(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Ot(t[0],`
355
+ `,1)[0],p=!h.trim(),m=0;if(this.options.pedantic?(m=2,u=h.trimStart()):p?m=t[1].length+1:(m=h.search(this.rules.other.nonSpaceChar),m=m>4?1:m,u=h.slice(m),m+=t[1].length),p&&this.rules.other.blankLine.test(d)&&(c+=d+`
356
+ `,e=e.substring(d.length+1),l=!0),!l){let v=this.rules.other.nextBulletRegex(m),y=this.rules.other.hrRegex(m),b=this.rules.other.fencesBeginRegex(m),w=this.rules.other.headingBeginRegex(m),k=this.rules.other.htmlBeginRegex(m),_=this.rules.other.blockquoteBeginRegex(m);for(;e;){let I=e.split(`
357
+ `,1)[0],A;if(d=I,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),A=d):A=d.replace(this.rules.other.tabCharGlobal," "),b.test(d)||w.test(d)||k.test(d)||_.test(d)||v.test(d)||y.test(d))break;if(A.search(this.rules.other.nonSpaceChar)>=m||!d.trim())u+=`
358
+ `+A.slice(m);else{if(p||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(h)||w.test(h)||y.test(h))break;u+=`
359
+ `+d}p=!d.trim(),c+=I+`
360
+ `,e=e.substring(I.length+1),h=A.slice(m)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),i.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),i.raw+=c}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 c=l.tokens.filter(h=>h.type==="space"),u=c.length>0&&c.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=u}for(let l of i.items){let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.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 u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let h={type:"checkbox",raw:u[0]+" ",checked:u[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 c of l.tokens)c.type==="text"&&(c.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Fh(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:Ut(t[0],`
361
+ `),href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Oh(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
362
+ `):[],o={type:"table",raw:Ut(t[0],`
363
+ `),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(Oh(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:Ut(t[0],`
365
364
  `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
366
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Ot(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Fb(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=t[3]?t[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)),Gh(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Gh(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);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,t=t.slice(-1*e.length+i);(r=h.exec(t))!==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,p=e.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let w=p.slice(1,-1);return{type:"em",raw:p,text:w,tokens:this.lexer.inlineTokens(w)}}let m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[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:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);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,t=t.slice(-1*e.length+i);(r=l.exec(t))!==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=e.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(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ue=class Ja{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||an,this.options.tokenizer=this.options.tokenizer||new Ni,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:Ce,block:Ci.normal,inline:dr.normal};this.options.pedantic?(n.block=Ci.pedantic,n.inline=dr.pedantic):this.options.gfm&&(n.block=Ci.gfm,this.options.breaks?n.inline=dr.breaks:n.inline=dr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ci,inline:dr}}static lex(t,n){return new Ja(n).lex(t)}static lexInline(t,n){return new Ja(n).inlineTokens(t)}lex(t){t=t.replace(Ce.carriageReturn,`
367
- `),this.blockTokens(t,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(t,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ce.tabCharGlobal," ").replace(Ce.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
365
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Ut(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Yb(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=t[3]?t[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)),$h(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return $h(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);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,c=r[0][0],u=n===c,h=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+i);(r=h.exec(t))!==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(u)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,p=e.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let v=p.slice(1,-1);return{type:"em",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}let m=p.slice(2,-2);return{type:"strong",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[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:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);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,t=t.slice(-1*e.length+i);(r=l.exec(t))!==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 c=[...r[0]][0].length,u=e.slice(0,i+r.index+c+a),h=u.slice(i,-i);return{type:"del",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},He=class hs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||fn,this.options.tokenizer=this.options.tokenizer||new Zi,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:Pe,block:Yi.normal,inline:Er.normal};this.options.pedantic?(n.block=Yi.pedantic,n.inline=Er.pedantic):this.options.gfm&&(n.block=Yi.gfm,this.options.breaks?n.inline=Er.breaks:n.inline=Er.gfm),this.tokenizer.rules=n}static get rules(){return{block:Yi,inline:Er}}static lex(t,n){return new hs(n).lex(t)}static lexInline(t,n){return new hs(n).inlineTokens(t)}lex(t){t=t.replace(Pe.carriageReturn,`
366
+ `),this.blockTokens(t,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(t,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Pe.tabCharGlobal," ").replace(Pe.spaceLine,""));let i=1/0;for(;t;){if(t.length<i)i=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},t,n))?(t=t.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(t)){t=t.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
368
367
  `:n.push(o);continue}if(o=this.tokenizer.code(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
369
368
  `)?"":`
370
369
  `)+o.raw,s.text+=`
371
370
  `+o.text,this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(o=this.tokenizer.fences(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
372
371
  `)?"":`
373
372
  `)+o.raw,s.text+=`
374
- `+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),n.push(o);continue}let a=t;if(this.options.extensions?.startBlock){let s=1/0,l=t.slice(1),u;this.options.extensions.startBlock.forEach(c=>{u=c.call({lexer:this},l),typeof u=="number"&&u>=0&&(s=Math.min(s,u))}),s<1/0&&s>=0&&(a=t.substring(0,s+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
373
+ `+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(t)){t=t.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(t)){t=t.substring(o.raw.length),n.push(o);continue}let a=t;if(this.options.extensions?.startBlock){let s=1/0,l=t.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(s=Math.min(s,c))}),s<1/0&&s>=0&&(a=t.substring(0,s+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
375
374
  `)?"":`
376
375
  `)+o.raw,s.text+=`
377
376
  `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==t.length,t=t.substring(o.raw.length);continue}if(o=this.tokenizer.text(t)){t=t.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
378
377
  `)?"":`
379
378
  `)+o.raw,s.text+=`
380
- `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t;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(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.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(t,r,o)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(t,r,o)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),n.push(s);continue}let l=t;if(this.options.extensions?.startInline){let u=1/0,c=t.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=t.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){t=t.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(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Pi=class{options;parser;constructor(e){this.options=e||an}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(Ce.notSpaceStart)?.[0],i=e.replace(Ce.endingNewline,"")+`
381
- `;return r?'<pre><code class="language-'+pt(r)+'">'+(n?i:pt(i,!0))+`</code></pre>
382
- `:"<pre><code>"+(n?i:pt(i,!0))+`</code></pre>
379
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t;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,c)=>{let u=c?c.length:0;return s.slice(0,u)+"["+"a".repeat(s.length-u-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;t;){if(t.length<a)a=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(c=>(s=c.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(s.raw.length);let c=n.at(-1);s.type==="text"&&c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(t,r,o)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(t)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(t,r,o)){t=t.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(t)){t=t.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(t))){t=t.substring(s.raw.length),n.push(s);continue}let l=t;if(this.options.extensions?.startInline){let c=1/0,u=t.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},u),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(l=t.substring(0,c+1))}if(s=this.tokenizer.inlineText(l)){t=t.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=s.raw,c.text+=s.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Qi=class{options;parser;constructor(e){this.options=e||fn}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(Pe.notSpaceStart)?.[0],i=e.replace(Pe.endingNewline,"")+`
380
+ `;return r?'<pre><code class="language-'+gt(r)+'">'+(n?i:gt(i,!0))+`</code></pre>
381
+ `:"<pre><code>"+(n?i:gt(i,!0))+`</code></pre>
383
382
  `}blockquote({tokens:e}){return`<blockquote>
384
383
  ${this.parser.parse(e)}</blockquote>
385
384
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -395,11 +394,11 @@ ${this.parser.parse(e)}</blockquote>
395
394
  `}tablerow({text:e}){return`<tr>
396
395
  ${e}</tr>
397
396
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
398
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${pt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Dh(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+pt(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Dh(e);if(i===null)return pt(n);e=i;let o=`<img src="${e}" alt="${pt(n)}"`;return t&&(o+=` title="${pt(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:pt(e.text)}},ls=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},lt=class es{options;renderer;textRenderer;constructor(t){this.options=t||an,this.options.renderer=this.options.renderer||new Pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ls}static parse(t,n){return new es(n).parse(t)}static parseInline(t,n){return new es(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let i=t[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(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let o=t[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}},hr=class{options;block;constructor(e){this.options=e||an}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ue.lex:Ue.lexInline}provideParser(e=this.block){return e?lt.parse:lt.parseInline}},Ii=class{defaults=ts();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=lt;Renderer=Pi;TextRenderer=ls;Lexer=Ue;Tokenizer=Ni;Hooks=hr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));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,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.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=t.renderers[i.name];o?t.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:t.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=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Pi(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 Ni(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 hr;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];hr.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&hr.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(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ue.lex(e,t??this.defaults)}parser(e,t){return lt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,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 t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(t):t,s=await(i.hooks?await i.hooks.provideLexer(e):e?Ue.lex:Ue.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(e):e?lt.parse:lt.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer(e):e?Ue.lex:Ue.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(e):e?lt.parse:lt.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
399
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+pt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},on=new Ii;function re(e,t){return on.parse(e,t)}re.options=re.setOptions=function(e){return on.setOptions(e),re.defaults=on.defaults,Oh(re.defaults),re};re.getDefaults=ts;re.defaults=an;function Wb(...e){return on.use(...e),re.defaults=on.defaults,Oh(re.defaults),re}re.use=Wb;re.walkTokens=function(e,t){return on.walkTokens(e,t)};re.parseInline=on.parseInline;re.Parser=lt;re.parser=lt.parse;re.Renderer=Pi;re.TextRenderer=ls;re.Lexer=Ue;re.lexer=Ue.lex;re.Tokenizer=Ni;re.Hooks=hr;re.parse=re;var mE=re.options,vE=re.setOptions,yE=re.walkTokens,wE=re.parseInline;var bE=lt.parse,xE=Ue.lex;var qh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hb=new RegExp(`[${Object.keys(qh).join("")}]`,"g");function Xe(e){return e.replace(Hb,t=>qh[t])}var Ub=["http:","https:","mailto:"],Yh=/^[a-z][a-z0-9+.-]*:/i,Xh=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function jh(e){let t=e.replace(Xh,""),n=Yh.exec(t);return n===null?t===""?null:e:Ub.includes(n[0].toLowerCase())?e:null}var Rt="data-weave-target",sn="data-weave-task";function Fi(e){return e?"Mark task incomplete":"Mark task complete"}var Gi="note:",Bb={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function Kb(e){if(e.kind!=="note"||!e.id.startsWith(Gi))return null;let t=e.id.slice(Gi.length);return t===""?null:t}function Zh(e){if(e.kind!=="file"||!e.id.startsWith("artifact:"))return null;let t=e.detail.path;return t!==void 0&&/\.html?$/i.test(t)?t:null}function Qh(e){let t=Zh(e);return t===null?null:`${t}:${e.detail.updated??""}`}function Jh(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:Zh(n)}function ep(e,t){if(e===null)return Bb;let n=new Map;for(let i of e.model.nodes){let o=Kb(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:t}}function tp(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function Vb(e,t){if(e.currentSlug===null||Yh.test(t.replace(Xh,"")))return null;try{let n=new URL(t,`https://weave.invalid/${e.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:tp(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function jb(e){return e.hasGhosts}var qb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Yb(e){let t=e.indexOf("[[");return t===-1?void 0:t}function Xb(e){return{name:"wikilink",level:"inline",start:Yb,tokenizer(t){return Qb(t)},renderer(t){return Zb(e,t)}}}function Zb(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return Jb(e,n,r)}function Qb(e){let t=qb.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function Jb(e,t,n){let r=Xe((n===""?t:n).trim());if(r==="")return"";let i=tp(e,t);return i!==null?`<a class="weave-wiki" ${Rt}="${Xe(i)}" role="link" tabindex="0" title="${Xe(t.trim())}">${r}</a>`:jb(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Xe(t.trim())}">${r}</span>`:r}function ex(e){let t=0;return new Ii({gfm:!0,async:!1,extensions:[Xb(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${sn}="${t++}" aria-label="${Fi(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":Xe(n)},link({href:n,title:r,tokens:i}){let o=jh(n),a=this.parser.parseInline(i),s=o===null?null:Vb(e,o);if(s!==null){let u=r==null||r===""?"":` title="${Xe(r)}"`;return`<a class="weave-wiki" ${Rt}="${Xe(s)}" role="link" tabindex="0"${u}>${a}</a>`}return`<a${[o===null?"":` href="${Xe(o)}"`,r==null||r===""?"":` title="${Xe(r)}"`,o===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${a}</a>`},image({href:n,title:r,text:i}){let o=jh(n);if(o===null)return Xe(i);let a=r==null||r===""?"":` title="${Xe(r)}"`;return`<img src="${Xe(o)}" alt="${Xe(i)}"${a}>`}}})}function tx(e,t){return ex(t).parse(e,{async:!1})}function Mi(e){return Object.freeze(e)}var nx=Mi({ALLOWED_TAGS:Mi(["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:Mi(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Rt,sn]),ADD_URI_SAFE_ATTR:Mi([Rt,sn]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function np(e,t,n){return e.sanitize(tx(t,n),nx)}var rx=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function ix(e){let t=[],n=e.replace(/\r\n?/g,`
400
- `),r=0;for(let l of Ue.lex(n,{gfm:!0})){let u=n.indexOf(l.raw,r);if(u===-1||(r=u+l.raw.length,l.type!=="list"&&l.type!=="blockquote"))continue;let c=0;for(;c<l.raw.length;){let h=l.raw.indexOf(`
401
- `,c),d=h===-1?l.raw.length:h,p=l.raw.slice(c,d).replace(/\r$/,""),m=rx.exec(p);m!==null&&t.push(u+c+m[1].length),c=h===-1?l.raw.length:h+1}}let i=new Ii,o=l=>{let u=[];return i.walkTokens(Ue.lex(l,{gfm:!0}),c=>{c.type==="checkbox"&&u.push(c.checked)}),u},a=o(n),s=a.map(()=>null);for(let l of t){let u=`${n.slice(0,l)}${n[l]===" "?"x":" "}${n.slice(l+1)}`,c=o(u);if(c.length!==a.length)continue;let h=-1;for(let d=0;d<a.length;d+=1)if(c[d]!==a[d]){if(h!==-1){h=-1;break}h=d}h!==-1&&(s[h]=l)}return s.map(l=>{if(l===null)return null;let u=0,c=0;for(;c<l;)u+=e[u]==="\r"&&e[u+1]===`
402
- `?2:1,c+=1;return u})}function rp(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=ix(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function ip(e){let t=e?.getAttribute(sn);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var op=32;function us(e){let t=e;for(let n=0;t!==null&&n<op;n++){let r=t.getAttribute(Rt);if(r!==null&&r!=="")return`${Gi}${r}`;t=t.parentElement}return null}function ap(e){if(!e||e.isCollapsed===!0)return!1;let t=e.toString;return(typeof t=="function"&&t!==Object.prototype.toString?t.call(e):"").length>0}var sp="edited",lp="created",up="Edit",cp="Done",dp="Save",hp="Saving…",pp="Note body",$i="Discard unsaved changes to this note?";function fp(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:Zt(e.source),provenanceTitle:wn(e.source),updated:Xn(e.updated,t),updatedIso:e.updated,created:Xn(e.created,t),createdIso:e.created,tags:e.tags}}function gp(e){return`#${e}`}var ox=200,ax=8,sx="no note";function cs(e){let t=e;for(let n=0;t!==null&&n<op;n++){let r=t.getAttribute(Rt);if(r!==null&&r!=="")return{slug:r,text:(t.textContent??"").trim()};if((t.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(t.textContent??"").trim()};t=t.parentElement}return null}function lx(e){return e.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(t,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 ux(e,t=ox){let n=lx(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function mp(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:sx,text:`no note named “${i}” yet`}}let n=e?.model.nodes.find(i=>i.id===`note:${t.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${wn(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:ux(n.detail.preview??"")}}function vp(e,t,n,r,i,o,a=ax){let s=e+a,l=t+a;return s+n>i-a&&(s=e-a-n),l+r>o-a&&(l=t-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 yp(e,t){switch(t.type){case"show":return t.anchor.slug===null&&t.anchor.text===""?e:{anchor:t.anchor,pointerX:t.x,pointerY:t.y};case"hide":return e.anchor===null?e:Oi;case"dismiss":return Oi}}function wp(e,t,n=!1){return t!==null?null:e===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":n?"Couldn’t load this note — retrying…":e.startsWith(Gi)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function zi(){let e=new Map,t=new Map,n=new Set,r=0,i=()=>n.forEach(o=>o());return{get:o=>e.get(o)??null,subscribe(o){return n.add(o),()=>n.delete(o)},open(o,a){e.has(o)||(e.set(o,{body:a,baseline:a,saving:!1}),i())},edit(o,a){let s=e.get(o);s===void 0||s.body===a||(s.body=a,i())},discard(o){e.delete(o)&&i()},isDirty(o){let a=e.get(o);return a!==void 0&&a.body!==a.baseline},dirtySlugs(){return[...e].filter(([,o])=>o.body!==o.baseline).map(([o])=>o)},async save(o,a){let s=e.get(o);if(s===void 0||s.saving||t.get(o)?.saving)return;let l=s.body;s.saving=!0,i();let u=!1;try{u=await a(o,l)}finally{if(e.get(o)===s){let c=t.get(o);u&&c!==void 0&&(c.body=l,c.version=++r,delete c.pending),u&&s.body===l?e.delete(o):(u&&(s.baseline=l),s.saving=!1),i()}}},nextLoadVersion(){return++r},getTaskBody(o,a){return t.get(o)?.body??a},taskBody(o,a,s){let l=t.get(o),u=!1;return l===void 0?(l={body:a,version:s,saving:!1},t.set(o,l)):s>l.version&&(l.saving?(l.pending===void 0||s>l.pending.version)&&(l.pending={body:a,version:s}):(u=l.body!==a,l.body=a,l.version=s)),u&&i(),l.body},isTaskSaving:o=>t.get(o)?.saving??!1,async saveTask(o,a,s){let l=t.get(o);if(l===void 0||l.saving||e.get(o)?.saving)return!1;l.saving=!0,i();let u=!1;try{return u=await s(o,a),u}finally{t.get(o)===l&&(u?(l.body=a,l.version=++r):l.pending!==void 0&&l.pending.version>l.version&&(l.body=l.pending.body,l.version=l.pending.version),delete l.pending,l.saving=!1,i())}},clearTaskSources(o){let a=!1;for(let s of o)a=t.delete(s)||a;a&&i()}}}function bp(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(yt))),o=new Set(n.panes.flatMap(s=>s.tabs.map(yt))),a=[...i].filter(s=>s!==null&&s.startsWith("note:")&&!o.has(s)).map(s=>s.slice(5));return a.some(s=>e.isDirty(s))&&!r()?!1:(a.forEach(s=>e.discard(s)),e.clearTaskSources(a),!0)}function xp(e,t,n){let r=new Set(t);return e.dirtySlugs().filter(o=>r.has(o)).length>0&&!n()?!1:(r.forEach(o=>e.discard(o)),e.clearTaskSources([...r]),!0)}var cx="weave-preview-x",dx="weave-preview-y";function hx({view:e,open:t,editing:n,saving:r,taskSaving:i,onToggle:o,onSave:a}){return g("header",{class:"weave-note-head",children:[g("h3",{class:"weave-note-title",children:e.title}),g("p",{class:"weave-note-meta",children:[n?g(De,{children:[g("button",{type:"button",class:"weave-note-save",disabled:r||i,onClick:a,children:r?hp:dp}),g("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:cp})]}):g("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:up}),g("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:t,children:g("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),g("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[e.provenanceGlyph," ",e.provenance]}),g("span",{class:"weave-note-time",title:e.updatedIso,children:[sp," ",e.updated]}),g("span",{class:"weave-note-time",title:e.createdIso,children:[lp," ",e.created]})]}),g("p",{class:"weave-note-tags",children:e.tags.map(s=>g("span",{class:"weave-tag",children:gp(s)},s))})]})}function kp(e){let t=X(zi()),n=e.drafts??t.current,r=nu(),i=`${e.idPrefix??r}-weave-preview`,[o,a]=V(0);se(()=>n.subscribe(()=>a(T=>T+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),u=Jh(e.graph,e.selectedId),c=wp(e.selectedId,s,e.loadFailed),h=Kt(()=>s===null?null:ep(e.graph,s.slug),[s,e.graph]),d=Kt(()=>s===null||h===null?"":np(Ch,l,h),[s,l,h]),[p,m]=V(Oi),w=T=>{m(C=>yp(C,T))},v=X(null),b=X(null),y=s===null?null:n.get(s.slug),x=s!==null&&n.isTaskSaving(s.slug),k=async()=>{s!==null&&!n.isTaskSaving(s.slug)&&await n.save(s.slug,e.onSave)},N=async(T,C)=>{let W=()=>{T.checked=!T.checked,T.setAttribute("aria-label",Fi(T.checked))};if(s===null||n.isTaskSaving(s.slug)){W();return}let j=rp(n.getTaskBody(s.slug,s.body),C);if(j===null){W();return}let Y=[...v.current?.querySelectorAll(`input[${sn}]`)??[]];T.setAttribute("aria-label",Fi(T.checked));for(let ie of Y)ie.disabled=!0;try{await n.saveTask(s.slug,j,e.onSave)||W()}catch(ie){throw W(),ie}finally{for(let ie of Y)ie.disabled=n.isTaskSaving(s.slug)}},A=()=>{s===null||n.isTaskSaving(s.slug)||(n.get(s.slug)===null?n.open(s.slug,l):(!n.isDirty(s.slug)||window.confirm($i))&&n.discard(s.slug))},P=p.anchor===null?null:mp(e.graph,p.anchor);if(Qe(()=>{s!==null&&n.taskBody(s.slug,s.body,e.loadVersion)},[n,s===null?null:s.slug,s?.body,e.loadVersion]),Qe(()=>{w({type:"hide"})},[s===null?null:s.slug]),Qe(()=>{if(s===null)return;let T=n.isTaskSaving(s.slug);for(let C of v.current?.querySelectorAll(`input[${sn}]`)??[])C.disabled=T},[s===null?null:s.slug,o,d]),Qe(()=>{let T=v.current;if(T!==null){let j=p.anchor?.slug??null;for(let Y of T.querySelectorAll(`a[${Rt}]`))j!==null&&Y.getAttribute(Rt)===j?Y.setAttribute("aria-describedby",i):Y.removeAttribute("aria-describedby")}let C=b.current;if(C===null||P===null)return;let W=vp(p.pointerX,p.pointerY,C.offsetWidth,C.offsetHeight,window.innerWidth,window.innerHeight);C.style.setProperty(`--${cx}`,`${W.x}px`),C.style.setProperty(`--${dx}`,`${W.y}px`)},[p,P,i]),u!==null){let T=e.graph?.model.nodes.find(j=>j.id===e.selectedId),C=T?.label??u,W=T===void 0?u:Qh(T)??u;return g("article",{class:"weave-note weave-note-artifact",children:[g("header",{class:"weave-note-head",children:[g("h3",{class:"weave-note-title",children:C}),g("p",{class:"weave-note-meta",children:g("span",{class:"weave-note-time",children:u})})]}),g("iframe",{class:"weave-artifact-frame",title:C,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(u)}`},W)]},W)}if(s===null||h===null)return g("p",{class:"weave-note-empty",children:c});let F=fp(s,e.now);return g("article",{class:`weave-note weave-note-${F.provenance}`,children:[g(hx,{view:F,open:()=>e.onOpen(s.slug),editing:y!==null,saving:y?.saving??!1,taskSaving:x,onToggle:A,onSave:()=>{k()}}),y!==null?g("textarea",{class:"weave-note-editor","aria-label":pp,spellcheck:!0,value:y.body,onInput:T=>n.edit(s.slug,T.target.value),onKeyDown:T=>{if(T.key==="Escape"){T.stopPropagation(),A();return}T.key.toLowerCase()!=="s"||!(T.metaKey||T.ctrlKey)||(T.preventDefault(),k())}}):g("div",{ref:v,class:"weave-note-body",tabIndex:-1,onMouseOver:T=>{let C=cs(T.target);w(C!==null?{type:"show",anchor:C,x:T.clientX,y:T.clientY}:{type:"hide"})},onMouseLeave:()=>w({type:"hide"}),onFocus:T=>{let C=cs(T.target);if(C===null)return;let W=T.target.getBoundingClientRect?.();w({type:"show",anchor:C,x:W?.left??0,y:W?.bottom??0})},onBlur:()=>w({type:"hide"}),onClick:T=>{let C=T.target,W=ip(C);if(W!==null){N(C,W);return}let j=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(ap(j))return;let Y=us(T.target);Y!==null&&e.onSelect(Y,T.metaKey||T.ctrlKey||T.shiftKey)},onKeyDown:T=>{if(T.key==="Escape"&&p.anchor!==null){T.stopPropagation(),w({type:"dismiss"});return}if(T.key!=="Enter"&&T.key!==" ")return;let C=us(T.target);C!==null&&(T.preventDefault(),e.onSelect(C,T.metaKey||T.ctrlKey||T.shiftKey))},dangerouslySetInnerHTML:{__html:d}}),P===null?null:g("div",{ref:b,id:i,role:"tooltip",class:`weave-preview${P.ghost?" weave-preview-ghost":""}`,children:[g("span",{class:"weave-preview-kind",children:P.kind}),g("span",{class:"weave-preview-title",children:P.title}),P.text===""?null:g("p",{class:"weave-preview-text",children:P.text})]})]},s.slug)}var _p=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Ep(e,t,n){return e===0?null:e===1?0:t<0?n?e-1:0:n?t===0?e-1:t-1:t===e-1?0:t+1}function Sp(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Tp(e){return e===null?!1:(e.focus(),!0)}function Wi(){let e=X(null);return se(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Tp(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Sp(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(_p)??[]],r=Ep(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function Cp(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.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 px(e){return Math.min(Math.max(e,0),10)*2}function fx(e){return`note:${e}`}function gx(e,t){return Cp(e.summary.title,t)+px(e.score)}function mx(e,t){return Cp(e.label,t)}var vx=["path","manifest","url","slug"];function yx(e){for(let t of vx){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}function wx(e,t){return e.score!==t.score?t.score-e.score:e.kind!==t.kind?e.kind==="note"?-1:1:e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function bx(e,t,n,r){let i=new Map;for(let o of e){let a=fx(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:gx(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=mx(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:yx(o),badge:o.kind,score:a})}return[...i.values()].sort(wx).slice(0,20)}function Lp(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function ds(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Rp(e,t,n){return n<=0?0:((e+t)%n+n)%n}function Np(e,t){return t===null?null:e[t]?.id??null}function Pp(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=ds(e,n);return t==="ArrowDown"?{...r,cursor:Rp(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Rp(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:ds(n-1,n),handled:!0}:t==="Escape"?{...r,dismiss:!0,handled:!0}:t!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var Hi="Search the workspace",Dp="Search notes and repository…",Ip="↑↓ move · ↵ open · esc close";function xx(e,t){return e.query.trim()?t>0?null:e.failed?"search failed — the workspace server may be gone":e.loading?"searching…":`no matches for “${e.query.trim()}”`:"Type to search notes, modules, files and entry points."}function kx(e){return e===1?"1 result":`${e} results`}function Ap(e){return`weave-search-row-${e}`}function Mp(e,t){let n=bx(e.hits,e.answered,t?.model.nodes??[],e.query),r=ds(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Ap(a)})),status:xx(e,n.length),count:n.length,countLabel:kx(n.length),cursor:r,activeDomId:n.length?Ap(r):null}}function Ex({row:e,onPick:t,onHover:n}){return g("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.kind}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:r=>t(r.metaKey||r.ctrlKey),children:[g("span",{class:"weave-hit-badge",children:e.badge}),g("span",{class:"weave-hit-label",children:e.label}),g("span",{class:"weave-hit-detail",children:e.detail})]})}function Gp(e){let[t,n]=V(Lp),r=X(0),i=X(null),o=Wi(),a=X(null);se(()=>{a.current?.focus()},[]),se(()=>{let u=t.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 p=new AbortController;i.current=p,n(w=>({...w,loading:!0,failed:!1}));let m=await du(e.ports.fetch,u,p.signal);!c||p.signal.aborted||d!==r.current||n(w=>m.ok?{...w,hits:m.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...w,loading:!1,failed:!0})},140);return()=>{c=!1,window.clearTimeout(h),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Mp(t,e.graph),l=(u,c=!1)=>{let h=Np(s.rows,u);h!==null&&e.onSelect(h,c),e.onClose()};return g("div",{class:"weave-scrim",onClick:()=>l(null),children:g("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Hi,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let c=Pp(t.cursor,u.key,s.count);c.handled&&(u.preventDefault(),n(h=>({...h,cursor:c.cursor})),c.dismiss&&l(c.activate,u.metaKey||u.ctrlKey))},children:[g("input",{type:"search",class:"weave-palette-input",ref:a,value:t.query,placeholder:Dp,"aria-label":Hi,"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?g("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Hi,children:s.rows.map((u,c)=>g(Ex,{row:u,onPick:h=>l(c,h),onHover:()=>n(h=>({...h,cursor:c}))},u.id))}):g("p",{class:"weave-palette-status",role:"status",children:s.status}),g("p",{class:"weave-palette-foot",children:[g("span",{children:s.countLabel}),g("button",{type:"button",class:"weave-chip",disabled:s.count===0,onClick:()=>l(t.cursor,!0),children:"Open in new tab"}),g("span",{class:"weave-palette-hint",children:[Ip," · ⌘/Ctrl ↵ new tab"]})]})]})})}function hs(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Fp=2e3,Sx=3e3,$p=new Set;function Tx(e,t){if(e===null)return $p;let n=new Set(e.model.nodes.map(r=>r.id));return new Set(t.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function Op(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function zp(e){let t=e.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([p,m])=>t[p]===m)||(t={...t,...d},e.setState(t))},a=e.defer??((d,p)=>{let m=setTimeout(d,p);return()=>clearTimeout(m)}),s=async()=>{let d=Op(t.selectedId);if(d===null){o({note:null,noteFailed:!1});return}let p=await Yo(e.fetch,d);p.ok?o({note:p.data,noteFailed:!1}):o({note:null,noteFailed:!0})},l=async()=>{let d=t.graph,p=await cu(e.fetch,t.graph);if(!p.ok)return t.graph===null&&o({graphFailed:!0}),p;if(!p.cached){let m=Tx(d,p.data);o({graph:p.data,graphFailed:!1,recentIds:m}),i?.(),i=null,m.size>0&&(i=a(()=>{i=null,o({recentIds:$p})},Sx))}return p},u=async()=>{if(!(n||r)){r=!0;try{let d=await l();Op(t.selectedId)!==null&&(t.note===null||d.ok&&!d.cached)&&await s()}finally{r=!1}}},h=(e.repeat??((d,p)=>{let m=setInterval(d,p);return()=>clearInterval(m)}))(()=>{u()},Fp);return u(),{refresh:()=>{u()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function Wp(e,t,n,r=(i,o)=>{let a=setTimeout(i,o);return()=>clearTimeout(a)}){let i=!1,o=null,a=async()=>{if(i)return;let s=await Yo(e,t);i||(n(s),s.ok||(o=r(()=>{a()},Fp)))};return a(),()=>{i=!0,o?.()}}var gr={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Bi(e,t,n){return{id:e,target:t.id,label:je(t),kind:t.kind,kindIcon:Xt(t.kind),provenance:t.provenance,provenanceGlyph:Zt(t.provenance),provenanceTitle:wn(t.provenance),selected:t.id===n}}function Rx(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:Bi(e.id,i,n)}function Ax(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var Cx=["link:links-to:"];function Lx(e){return Cx.some(t=>e.id.startsWith(t))}function Nx(e){return e.id.startsWith("link:mentions:")}function Px(e,t,n,r){let i=[];for(let[o,a]of Object.entries(e.tags)){if(!a.includes(t))continue;let s=[];for(let l of a){if(l===t)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(Bi(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Dx(e,t,n,r){let i=[];for(let o of e.edges){if(o.kind!=="mentions"||o.target!==t)continue;let a=n.get(o.source);a!==void 0&&i.push(Bi(`mentioned-by:${o.source}`,a,r))}return i}function Ix(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var Ui={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 ps(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function Hp(e,t){if(e===null)return ps(Ui.loading);if(t===null)return ps(Ui.noSelection);let n=qt(e),r=ea(n,t);if(r===null)return ps(Ui.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=>Rx(d,i,t)).filter(d=>d!==null);a(gr.links,s(r.links.filter(Lx)));let l=ta(n.edges).get(t)??[];a(gr.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Bi(`backlink:${h.id}`,h,t))),a(gr.mentions,[...s(r.links.filter(Nx)),...Dx(n,t,i,t)]);let u=Ix(t),c=u===null?[]:Px(e,u,i,t);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Ui.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function Up(){return{open:new Set,closed:new Set}}var Mx=8;function Bp(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>Mx}function Gx(e){return e.some(t=>t.selected)}function Kp(e,t){let n=Bp(t,e.heading,e.count,Gx(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function Vp(e,t){let n=Bp(t,gr.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:gr.tags,count:e.length,collapsed:n,rows:[]}}function jp(e,t,n){let r=new Set(e.open),i=new Set(e.closed);return n?(r.add(t),i.delete(t)):(i.add(t),r.delete(t)),{open:r,closed:i}}function Ki(e){return`weave-ctx-panel-${e.toLowerCase()}`}function qp({row:e,onSelect:t}){return g("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:g("button",{type:"button",class:"weave-ctx-link",onClick:n=>t(n.metaKey||n.ctrlKey),children:[g("span",{class:"weave-kind","aria-hidden":"true",children:g(xt,{name:e.kindIcon,class:"weave-icon"})}),g("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),g("span",{class:"weave-label",children:e.label})]})})}function Yp({view:e,onToggle:t}){return g("h4",{class:"weave-ctx-head",children:g("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":Ki(e.heading),onClick:t,children:[g("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:g(xt,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,g("span",{class:"weave-ctx-count",children:e.count})]})})}function Ox({view:e,onSelect:t,onToggle:n}){return g("section",{class:"weave-ctx-group",children:[g(Yp,{view:e,onToggle:n}),g("ul",{class:"weave-ctx-rows",id:Ki(e.heading),hidden:e.collapsed,children:e.rows.map(r=>g(qp,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function Fx({tag:e,onSelect:t}){return g("li",{class:"weave-ctx-tag",children:[g("span",{class:"weave-tag",children:["#",e.tag]}),g("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>g(qp,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function Xp(e){let t=Hp(e.graph,e.selectedId),[n,r]=V(Up),i=a=>()=>r(jp(n,a.heading,a.collapsed)),o=Vp(t.tags,n);return g("div",{class:"weave-rail","aria-label":Cc.title,children:[t.empty===null?null:g("p",{class:"weave-ctx-empty",children:t.empty}),t.groups.map(a=>{let s=Kp(a,n);return g(Ox,{view:s,onSelect:e.onSelect,onToggle:i(s)},a.heading)}),t.tags.length===0?null:g("section",{class:"weave-ctx-group",children:[g(Yp,{view:o,onToggle:i(o)}),g("ul",{class:"weave-ctx-tags",id:Ki(o.heading),hidden:o.collapsed,children:t.tags.map(a=>g(Fx,{tag:a,onSelect:e.onSelect},a.tag))})]})]})}function $x(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function Zp(e,t){let n=$x(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function Qp(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function zx({group:e}){return g("div",{children:[g("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>g("div",{class:"weave-key-row",children:[g("kbd",{class:"weave-key-combo",children:t.combo}),g("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function Jp(e){let t=Wi(),n=e.shortcut.slice(0,-1);return g("div",{class:"weave-scrim",onClick:e.onClose,children:g("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":ma,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[g("h2",{class:"weave-help-title",children:ma}),g("div",{class:"weave-keys",children:$c(n).map(r=>g(zx,{group:r},r.title))}),g("p",{class:"weave-help-foot",children:[g("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),g("span",{class:"weave-help-hint",children:zc})]})]})})}function ef(e,t){let n=r=>{if(r.defaultPrevented)return;let i=Gc(Oc(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function tf({model:e}){return g("footer",{class:"weave-status",children:[g("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),g("span",{class:"weave-status-sel",title:"Current item",children:e.selection}),g("span",{class:"weave-status-stamp",title:"data as of",children:Pc(e.stamp)})]})}var fs=["system","light","dark"],nf="pi-weave.theme.v1";function Wx(e){return e==="system"||e==="light"||e==="dark"}function Vi(e){try{let t=e.getItem(nf);return Wx(t)?t:null}catch{return null}}function rf(e,t){try{return e.setItem(nf,t),!0}catch{return!1}}function ji(e){let t=fs.indexOf(e);return fs[(t+1)%fs.length]??"system"}function of(e,t){return e==="system"?t:e}function qi(e){return e==="system"?null:e}var Hx={dark:"●",system:"◐",light:"○"};function af(e){return{glyph:Hx[e],hint:`Colour theme: ${e} — click for ${ji(e)}`}}function Yi(e,t){if(e.kind==="graph")return"Graph view";let n=yt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function Ux(e){let[t]=V(e.visits);return g("div",{class:"weave-recents",children:Ac(t,e.graph,e.selectedId).map(n=>g("button",{type:"button","aria-current":n.selected?"page":void 0,title:n.label,onClick:r=>e.onSelect(n.id,r.metaKey||r.ctrlKey),children:[g("span",{class:"weave-kind",children:g(xt,{name:n.icon,class:"weave-icon"})}),g("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function Bx(e){let t=yt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=V(null),o=X(null),a=X(e.tab.scroll);se(()=>{if(n===null)return;let u=e.drafts.nextLoadVersion();return Wp(Me,n,c=>{i({slug:n,note:c.ok?c.data:null,failed:!c.ok,version:u})})},[n,e.graph?.stamp,e.revision]);let s=r?.slug===n?r:null;if(Qe(()=>{let u=o.current?.querySelector(".weave-note");u!=null&&(u.scrollTop=a.current)},[t,s?.note?.note.slug]),t===null)return g("div",{class:"weave-welcome",children:[g("span",{class:"weave-welcome-mark","aria-hidden":"true",children:"✳"}),g("h1",{children:"Your knowledge, connected."}),g("p",{children:"Open a note from the sidebar, find something you remember, or follow a connection."}),g("div",{children:[g("button",{type:"button",onClick:e.onSearch,children:["Search workspace ",g("kbd",{children:"⌘K"})]}),g("button",{type:"button",onClick:e.onGraph,children:"Explore graph"})]})]});let l=e.graph!==null&&!e.graph.model.nodes.some(u=>u.id===t);if(l||s?.failed&&e.drafts.isDirty(n??"")){let u=n===null?null:e.drafts.get(n);return u!==null&&n!==null&&e.drafts.isDirty(n)?g("div",{class:"weave-welcome",children:[g("h2",{children:l?"This item is no longer here":"This note could not be loaded"}),g("p",{children:["Your unsaved draft is preserved below. Select and copy it before closing this workspace. ",l?"Saving cannot restore or recreate the missing note.":"Reopen this tab to retry loading the note."]}),g("label",{class:"weave-note-meta",for:`missing-draft-${e.tab.id}`,children:"Unsaved draft (read-only)"}),g("textarea",{id:`missing-draft-${e.tab.id}`,class:"weave-note-editor","aria-label":"Unsaved draft for missing note",rows:16,readOnly:!0,value:u.body}),g("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]}):g("div",{class:"weave-welcome",children:[g("h2",{children:"This item is no longer here"}),g("p",{children:"It may have been moved or deleted. Your other tabs are still available."}),g("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]})}return g("div",{class:"weave-document",ref:o,onScrollCapture:u=>{let c=u.target;c.classList.contains("weave-note")&&(a.current=c.scrollTop,e.onScroll(c.scrollTop))},children:g(kp,{note:s?.note??null,loadFailed:s?.failed??!1,loadVersion:s?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:u=>{hu(Me,u).then(c=>{c.ok?c.data.opened||window.alert("Could not open the note in an editor."):window.alert(c.message)})},onSave:e.onSave,drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function gs(e){let t=X(null);return g("div",{class:"weave-workspace-divider",role:"separator",tabIndex:0,"aria-label":e.label,"aria-orientation":e.horizontal?"horizontal":"vertical","aria-valuenow":Math.round(e.value),"aria-valuemin":e.min,"aria-valuemax":e.max,onPointerDown:n=>{t.current=e.horizontal?n.clientY:n.clientX,n.currentTarget.setPointerCapture(n.pointerId)},onPointerMove:n=>{if(t.current===null)return;let r=e.horizontal?n.clientY:n.clientX;e.onChange(r-t.current),t.current=r},onPointerUp:n=>{t.current=null,n.currentTarget.releasePointerCapture(n.pointerId)},onPointerCancel:()=>{t.current=null},onKeyDown:n=>{["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(n.key)&&(n.preventDefault(),e.onChange(n.key==="ArrowLeft"||n.key==="ArrowUp"?-20:20))}})}function sf(e){let[t,n]=V(hs),[r,i]=V(()=>({...iu(),theme:Vi(localStorage)??"system"})),[o,a]=V(null),[s,l]=V(Date.now),[u,c]=V(e.initialWidth),[h,d]=V(()=>ii(window)),[p,m]=V(!1),[w,v]=V(!1),[b,y]=V(0),[,x]=V(0),[k,N]=V(null),[A,P]=V(null),F=X(null),[T,C]=V(null),[W,j]=V(!1),[Y,ie]=V([]),[ce,Fe]=V(!1),[Te]=V(zi),_e=X(null),Ee=X(null),Be=X(location.hash),Ke=X(!1),Ze=X(null),Le=X(null),Q=X(null),[Ft,Xi]=V({left:0,top:0,width:600,height:500}),Zi=Yn(r),mr=mn(r),Dn=af(r.theme),Ve=mr.kind==="graph"?k:yt(mr),Ne=r.panes.find(E=>E.tabs.some(I=>I.id===E.activeTab&&I.kind==="graph")),ft=Ne!==void 0&&(u>=850||Ne.id===r.activePane),$t=u<1050?ce:r.contextVisible,oe=r.panes.some(E=>E.tabs.some(I=>I.kind==="graph")),$e=X({layout:r,overlay:o,selectedId:Ve,graphPreviewId:A,select:E=>{}}),J=E=>{$e.current.graphPreviewId=E,P(E)};se(()=>{ft||J(null)},[ft]);let gt=E=>{bp(Te,$e.current.layout,E,()=>window.confirm($i))&&i(E)},pe=(E,I=!1,K=r.activePane,O=!1)=>{let B=Vr(r,E,{newTab:I,paneId:K});gt(u<850&&!O?{...B,treeVisible:!1}:B),Fe(!1)},At=()=>i(E=>({...Ho(E),...u<850?{treeVisible:!1}:{}})),In=E=>{J(null);let I=r.panes.find(K=>K.id!==Ne?.id);pe(E,!0,I?.id??Ne?.id??r.activePane)},ut=E=>{N(E),Rc($e.current.graphPreviewId,E)?In(E):J(E)};$e.current={layout:r,overlay:o,selectedId:Ve,graphPreviewId:A,select:pe};let vr=E=>xp(Te,E,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Mn=async(E,I)=>{let K=await pu(Me,E,I);return K.ok?(y(O=>O+1),_e.current?.refresh(),!0):(window.alert(K.message),!1)};se(()=>Te.subscribe(()=>x(E=>E+1)),[Te]),se(()=>(_e.current=zp({fetch:Me,state:hs(),setState:n}),()=>_e.current?.stop()),[]),se(()=>{let E=!0;return(async()=>{try{let I=await Me("/api/workspace-state"),K=await I.json();if(!E)return;if(I.ok&&typeof K.viewId=="string"){Ee.current=K.viewId;let O=su(K.layout);O&&(i(O),ie(O.panes.flatMap(B=>B.tabs.flatMap(be=>be.history)).reduce(da,[])))}else v(!0)}catch{E&&v(!0)}finally{E&&m(!0)}})(),()=>{E=!1}},[]),se(()=>{if(!p||t.graph===null||Ke.current)return;Ke.current=!0;let E=Zp(Be.current,t.graph);E!==null&&i(I=>Vr(I,E))},[p,t.graph]),se(()=>{p&&ie(E=>da(E,Ve))},[p,Ve]),se(()=>{if(!p)return;history.replaceState(null,"",Qp(Ve));let E=qi(r.theme);E===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=E,rf(localStorage,r.theme)},[p,Ve,r.theme]);let Gn=X(Promise.resolve());se(()=>{if(!p||!Ee.current)return;let E=Ee.current,I=window.setTimeout(()=>{Gn.current=Gn.current.then(async()=>{try{let K=await Me("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:E,layout:r})});v(!K.ok)}catch{v(!0)}})},350);return()=>window.clearTimeout(I)},[r,p]),se(()=>{let E=window.setInterval(()=>l(Date.now()),Dc),I=()=>c(window.innerWidth);window.addEventListener("resize",I);let K=kc(window,d),O=rt=>{for(let Ct of document.querySelectorAll(".weave-pane-menu[open]"))Ct.contains(rt.target)||(Ct.open=!1)};document.addEventListener("pointerdown",O);let B=rt=>{Te.dirtySlugs().length&&(rt.preventDefault(),rt.returnValue="")},be=()=>{Ee.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ee.current,layout:$e.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",be),window.addEventListener("beforeunload",B),()=>{window.clearInterval(E),window.removeEventListener("resize",I),window.removeEventListener("beforeunload",B),window.removeEventListener("pagehide",be),document.removeEventListener("pointerdown",O),K()}},[]),se(()=>ef(document,{context:()=>({overlay:$e.current.overlay,hasSelection:$e.current.selectedId!==null}),run:E=>Fc(E,{setOverlay:a,fitGraph:()=>Q.current?.(),clearSelection:()=>{mn($e.current.layout).kind==="graph"?(N(null),J(null)):$e.current.select(null)},closeTab:()=>{let I=$e.current.layout;gt(Bo(I,I.activePane,mn(I).id))},cycleTheme:()=>i(I=>({...I,theme:ji(I.theme)})),focusSelector:I=>(I===bn.graph?i(K=>({...Ho(K),...window.innerWidth<850?{treeVisible:!1}:{}})):I===bn.tree||I===ga?i(K=>({...K,treeVisible:!0})):i(ou),requestAnimationFrame(()=>{I===bn.note&&oi(document,".weave-pane-active .weave-note-editor")||!oi(document,I)&&I===bn.note&&oi(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),Qe(()=>{for(let E of r.panes)document.getElementById(`tab-${E.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(E=>E.activeTab).join(","),r.activePane,u,p,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),Qe(()=>{let E=Le.current,I=Ze.current;if(!ft||!E||!I)return;let K=()=>{let B=E.getBoundingClientRect(),be=I.getBoundingClientRect();Xi({left:B.left-be.left,top:B.top-be.top,width:B.width,height:B.height})};K();let O=new ResizeObserver(K);return O.observe(E),O.observe(I),()=>O.disconnect()},[ft,r,u]);let yr=(E,I)=>i(K=>({...K,panes:K.panes.map(O=>({...O,tabs:O.tabs.map(B=>B.id===E?{...B,scroll:I}:B)}))})),nt=(E,I)=>{jr(r,E,F.current)===null&&!I.dataTransfer?.types.includes(Qn)||(I.preventDefault(),I.dataTransfer&&(I.dataTransfer.dropEffect=F.current===null?"copy":"move"),C(E))},ct=(E,I)=>{let K=Tc(t.graph,I.dataTransfer?.getData(Qn)??"");if(K!==null){I.preventDefault(),pe(K,!0,E),C(null);return}let O=F.current;jr(r,E,O)!==null&&(I.preventDefault(),i(B=>{let be=jr(B,E,O);return be===null?B:jo(B,be,O)}),F.current=null,C(null))},mt=E=>{let I=E.tabs.find(O=>O.id===E.activeTab),K=E.id===r.activePane;return g("section",{class:`weave-pane${K?" weave-pane-active":""}${T===E.id?" weave-pane-drop":""}`,"data-drop-label":F.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(E)+1}`,onDragOver:O=>nt(E.id,O),onDrop:O=>ct(E.id,O),onDragLeave:O=>{O.currentTarget.contains(O.relatedTarget)||C(null)},hidden:u<850&&!K,onFocusCapture:()=>{K||i(O=>({...O,activePane:E.id}))},onPointerDown:()=>{K||i(O=>({...O,activePane:E.id}))},children:[g("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",children:[E.tabs.map(O=>g("div",{class:`weave-tab${O.id===I.id?" weave-tab-active":""}`,children:[g("button",{type:"button",role:"tab",title:Yi(O,t.graph),id:`tab-${O.id}`,"aria-selected":O.id===I.id,"aria-controls":`panel-${E.id}`,tabIndex:O.id===I.id?0:-1,draggable:r.panes.length===2,onDragStart:B=>{F.current=O.id,B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("application/x-weave-tab",O.id)},onClick:()=>i(Uo(r,E.id,O.id)),onKeyDown:B=>{let be=B.key==="ArrowRight"?1:B.key==="ArrowLeft"?-1:0;if(!be&&B.key!=="Home"&&B.key!=="End")return;B.preventDefault();let rt=B.key==="Home"?0:B.key==="End"?E.tabs.length-1:(E.tabs.indexOf(O)+be+E.tabs.length)%E.tabs.length,Ct=E.tabs[rt];i(Uo(r,E.id,Ct.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Ct.id}`)?.focus())},children:[g("span",{"aria-hidden":"true",children:O.kind==="graph"?"◌":"▤"}),g("span",{children:Yi(O,t.graph)}),Te.isDirty((yt(O)??"").slice(5))?g("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),g("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${Yi(O,t.graph)}`,onClick:()=>gt(Bo(r,E.id,O.id)),children:"×"})]},O.id)),g("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>pe(null,!0,E.id),children:"+"})]}),g("div",{class:"weave-pane-toolbar",children:[g("button",{type:"button","aria-label":"Navigate back",disabled:I.kind==="graph"||I.cursor===0,onClick:()=>gt(Ko({...r,activePane:E.id},E.id,-1)),children:"←"}),g("button",{type:"button","aria-label":"Navigate forward",disabled:I.kind==="graph"||I.cursor>=I.history.length-1,onClick:()=>gt(Ko({...r,activePane:E.id},E.id,1)),children:"→"}),g("span",{class:"weave-breadcrumb",children:Yi(I,t.graph)}),g("details",{class:"weave-pane-menu",onKeyDown:O=>{O.key==="Escape"&&(O.preventDefault(),O.stopPropagation(),O.currentTarget.open=!1,O.currentTarget.querySelector("summary")?.focus())},children:[g("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),g("div",{onClick:O=>{let B=O.currentTarget.closest("details");B&&(B.open=!1)},children:[g("button",{type:"button",onClick:()=>i(Vo({...r,activePane:E.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),g("button",{type:"button",onClick:()=>i(Vo({...r,activePane:E.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?g(De,{children:[g("button",{type:"button",onClick:()=>i(jo(r,E.id,I.id)),children:"Move tab to other pane"}),g("button",{type:"button",title:"Move all tabs to the other pane and close this pane",onClick:()=>i(au(r,E.id)),children:"Close pane"})]}):null]})]})]}),g("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${E.id}`,"aria-labelledby":`tab-${I.id}`,...I.kind==="graph"?{ref:Le}:{},children:I.kind==="document"?g(Bx,{tab:I,graph:t.graph,drafts:Te,revision:b,now:s,onSelect:(O,B)=>pe(O,B,E.id),onSave:Mn,onScroll:O=>yr(I.id,O),onSearch:()=>a("search"),onGraph:At},`${I.id}:${I.cursor}:${yt(I)}`):null})]},E.id)};return g(De,{children:[g("div",{class:"weave-workbench",ref:Ze,onDragEnd:()=>{F.current=null,C(null)},children:[g("nav",{class:"weave-ribbon","aria-label":"Workspace tools",children:[g("button",{type:"button","aria-label":"Toggle notes sidebar","aria-pressed":r.treeVisible,title:"Notes",onClick:()=>i({...r,treeVisible:!r.treeVisible}),children:"▤"}),g("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:At,children:"◌"}),g("button",{type:"button","aria-label":"Search notes and repository",title:Ic(ha(pa(e.platform))),onClick:()=>a("search"),children:g("svg",{viewBox:"0 0 20 20",width:16,height:16,fill:"none",stroke:"currentColor","stroke-width":1.7,"aria-hidden":"true",children:[g("circle",{cx:"8.5",cy:"8.5",r:"5.5"}),g("path",{d:"m13 13 4 4"})]})}),g("span",{class:"weave-ribbon-space"}),g("button",{type:"button","aria-label":"Toggle context sidebar","aria-pressed":$t,title:"Context",onClick:()=>u<1050?Fe(!ce):i({...r,contextVisible:!r.contextVisible}),children:"☷"}),g("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{_e.current?.refresh(),y(E=>E+1)},children:"↻"}),g("button",{type:"button","aria-label":Dn.hint,title:Dn.hint,onClick:()=>i({...r,theme:ji(r.theme)}),children:Dn.glyph}),g("button",{type:"button","aria-label":"Keyboard shortcuts",onClick:()=>a("help"),children:"?"})]}),g("div",{class:"weave-sidebar-dock weave-notes-dock","data-open":r.treeVisible,inert:!r.treeVisible,"aria-hidden":!r.treeVisible,style:{"--weave-sidebar-width":`${Math.min(r.treeWidth,u-90)}px`},children:[g("aside",{class:"weave-sidebar weave-sidebar-notes","aria-label":"Notes sidebar",children:[g("div",{class:"weave-sidebar-heading",children:[g("button",{type:"button","aria-pressed":!W,onClick:()=>j(!1),children:"Files"}),g("button",{type:"button","aria-pressed":W,onClick:()=>j(!0),children:"Recent"}),g("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{Ze.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),W?g(Ux,{visits:Y,graph:t.graph,selectedId:Ve,onSelect:pe}):g(Hc,{graph:t.graph,selectedId:Ve,recentIds:t.recentIds,onSelect:(E,I,K)=>pe(E,I,r.activePane,K),onMutate:vr,onRefresh:()=>_e.current?.refresh(),now:s}),g("div",{class:"weave-vault-label",children:[g("span",{children:"Workspace"}),g("strong",{title:e.cwd,children:e.cwd.split(/[\\/]/).filter(Boolean).pop()??"Weave"})]})]}),g(gs,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:E=>i(I=>({...I,treeWidth:Math.max(180,Math.min(420,I.treeWidth+E))}))})]}),g("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&u>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:p?r.panes.map((E,I)=>g(De,{children:[I>0&&u>=850?g(gs,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:K=>{let O=r.split==="right"?Ze.current?.querySelector("main")?.clientWidth:Ze.current?.querySelector("main")?.clientHeight;i(B=>({...B,ratio:Math.max(.2,Math.min(.8,B.ratio+K/(O??800)))}))}}):null,mt(E)]})):g("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),g("div",{class:"weave-sidebar-dock weave-context-dock","data-open":$t,inert:!$t,"aria-hidden":!$t,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[g(gs,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:E=>i(I=>({...I,contextWidth:Math.max(180,Math.min(400,I.contextWidth-E))}))}),g("aside",{class:"weave-sidebar weave-sidebar-context","aria-label":"Context sidebar",children:[g("div",{class:"weave-sidebar-heading",children:[g("strong",{children:"Context"}),g("button",{type:"button","aria-label":"Hide context sidebar",onClick:()=>{Ze.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),Fe(!1),i({...r,contextVisible:!1})},children:"»"})]}),g(Xp,{graph:t.graph,selectedId:Ve,onSelect:pe})]})]}),oe?g("div",{class:"weave-graph-host",onDragOver:E=>{Ne&&nt(Ne.id,E)},onDrop:E=>{Ne&&ct(Ne.id,E)},onDragLeave:E=>{E.currentTarget.contains(E.relatedTarget)||C(null)},onPointerDown:()=>{Ne&&i(E=>({...E,activePane:Ne.id}))},onFocusCapture:()=>{Ne&&i(E=>({...E,activePane:Ne.id}))},"aria-hidden":!ft,style:{...Ft,visibility:ft?"visible":"hidden",pointerEvents:ft?"auto":"none"},children:g(Uc,{graph:t.graph,selectedId:Ve,previewId:A,onSelect:ut,onOpen:In,renderer:uh,storage:localStorage,host:window,scheme:of(r.theme,h),bootFailed:t.graphFailed,fit:Q,tuner:e.tuner===!0})}):null]}),g("div",{class:"weave-footer",children:[g(tf,{model:Nc(e.cwd,Ve,t.graph?.model.generatedAt??null)}),w?g("span",{role:"status",children:"Workspace restoration unavailable"}):null,Te.dirtySlugs().length?g("span",{children:[Te.dirtySlugs().length," unsaved"]}):null,u<850&&r.panes.length>1?g("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(E=>E.id!==Zi.id).id}),children:"Switch pane"}):null]}),o==="search"?g(Gp,{graph:t.graph,onSelect:pe,onClose:()=>a(null),ports:{fetch:Me}}):null,o==="help"?g(Jp,{shortcut:ha(pa(e.platform)),onClose:()=>a(null)}):null]})}var lf=`
397
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${gt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Mh(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+gt(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Mh(e);if(i===null)return gt(n);e=i;let o=`<img src="${e}" alt="${gt(n)}"`;return t&&(o+=` title="${gt(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:gt(e.text)}},xs=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ct=class ps{options;renderer;textRenderer;constructor(t){this.options=t||fn,this.options.renderer=this.options.renderer||new Qi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xs}static parse(t,n){return new ps(n).parse(t)}static parseInline(t,n){return new ps(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let i=t[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(t,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<t.length;i++){let o=t[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}},Tr=class{options;block;constructor(e){this.options=e||fn}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?He.lex:He.lexInline}provideParser(e=this.block){return e?ct.parse:ct.parseInline}},eo=class{defaults=fs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ct;Renderer=Qi;TextRenderer=xs;Lexer=He;Tokenizer=Zi;Hooks=Tr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));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,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.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=t.renderers[i.name];o?t.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:t.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=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Qi(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]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Zi(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]=(...c)=>{let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Tr;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];Tr.passThroughHooks.has(o)?i[a]=c=>{if(this.defaults.async&&Tr.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,c);return l.call(i,h)})();let u=s.call(i,c);return l.call(i,u)}:i[a]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,c);return h===!1&&(h=await l.apply(i,c)),h})();let u=s.apply(i,c);return u===!1&&(u=l.apply(i,c)),u}}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(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return He.lex(e,t??this.defaults)}parser(e,t){return ct.parse(e,t??this.defaults)}parseMarkdown(e){return(t,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 t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(t):t,s=await(i.hooks?await i.hooks.provideLexer(e):e?He.lex:He.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?ct.parse:ct.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(c):c})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let a=(i.hooks?i.hooks.provideLexer(e):e?He.lex:He.lexInline)(t,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(e):e?ct.parse:ct.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
398
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},pn=new eo;function ae(e,t){return pn.parse(e,t)}ae.options=ae.setOptions=function(e){return pn.setOptions(e),ae.defaults=pn.defaults,zh(ae.defaults),ae};ae.getDefaults=fs;ae.defaults=fn;function Qb(...e){return pn.use(...e),ae.defaults=pn.defaults,zh(ae.defaults),ae}ae.use=Qb;ae.walkTokens=function(e,t){return pn.walkTokens(e,t)};ae.parseInline=pn.parseInline;ae.Parser=ct;ae.parser=ct.parse;ae.Renderer=Qi;ae.TextRenderer=xs;ae.Lexer=He;ae.lexer=He.lex;ae.Tokenizer=Zi;ae.Hooks=Tr;ae.parse=ae;var EE=ae.options,TE=ae.setOptions,SE=ae.walkTokens,RE=ae.parseInline;var AE=ct.parse,CE=He.lex;var Zh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Jb=new RegExp(`[${Object.keys(Zh).join("")}]`,"g");function qe(e){return e.replace(Jb,t=>Zh[t])}var ex=["http:","https:","mailto:"],Qh=/^[a-z][a-z0-9+.-]*:/i,Jh=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Xh(e){let t=e.replace(Jh,""),n=Qh.exec(t);return n===null?t===""?null:e:ex.includes(n[0].toLowerCase())?e:null}var Ct="data-weave-target",gn="data-weave-task";function io(e){return e?"Mark task incomplete":"Mark task complete"}var no="note:",tx={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function nx(e){if(e.kind!=="note"||!e.id.startsWith(no))return null;let t=e.id.slice(no.length);return t===""?null:t}function ep(e){if(e.kind!=="file"||!e.id.startsWith("artifact:"))return null;let t=e.detail.path;return t!==void 0&&/\.html?$/i.test(t)?t:null}function tp(e){let t=ep(e);return t===null?null:`${t}:${e.detail.updated??""}`}function np(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:ep(n)}function rp(e,t){if(e===null)return tx;let n=new Map;for(let i of e.model.nodes){let o=nx(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=t!==null&&(e.dangling[t]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:t}}function ip(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function rx(e,t){if(e.currentSlug===null||Qh.test(t.replace(Jh,"")))return null;try{let n=new URL(t,`https://weave.invalid/${e.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:ip(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function ix(e){return e.hasGhosts}var ox=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function ax(e){let t=e.indexOf("[[");return t===-1?void 0:t}function sx(e){return{name:"wikilink",level:"inline",start:ax,tokenizer(t){return cx(t)},renderer(t){return lx(e,t)}}}function lx(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return ux(e,n,r)}function cx(e){let t=ox.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function ux(e,t,n){let r=qe((n===""?t:n).trim());if(r==="")return"";let i=ip(e,t);return i!==null?`<a class="weave-wiki" ${Ct}="${qe(i)}" role="link" tabindex="0" title="${qe(t.trim())}">${r}</a>`:ix(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${qe(t.trim())}">${r}</span>`:r}function dx(e){let t=0;return new eo({gfm:!0,async:!1,extensions:[sx(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${gn}="${t++}" aria-label="${io(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":qe(n)},link({href:n,title:r,tokens:i}){let o=Xh(n),a=this.parser.parseInline(i),s=o===null?null:rx(e,o);if(s!==null){let c=r==null||r===""?"":` title="${qe(r)}"`;return`<a class="weave-wiki" ${Ct}="${qe(s)}" role="link" tabindex="0"${c}>${a}</a>`}return`<a${[o===null?"":` href="${qe(o)}"`,r==null||r===""?"":` title="${qe(r)}"`,o===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${a}</a>`},image({href:n,title:r,text:i}){let o=Xh(n);if(o===null)return qe(i);let a=r==null||r===""?"":` title="${qe(r)}"`;return`<img src="${qe(o)}" alt="${qe(i)}"${a}>`}}})}function hx(e,t){return dx(t).parse(e,{async:!1})}function to(e){return Object.freeze(e)}var px=to({ALLOWED_TAGS:to(["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:to(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Ct,gn]),ADD_URI_SAFE_ATTR:to([Ct,gn]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function op(e,t,n){return e.sanitize(hx(t,n),px)}var fx=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function gx(e){let t=[],n=e.replace(/\r\n?/g,`
399
+ `),r=0;for(let l of He.lex(n,{gfm:!0})){let c=n.indexOf(l.raw,r);if(c===-1||(r=c+l.raw.length,l.type!=="list"&&l.type!=="blockquote"))continue;let u=0;for(;u<l.raw.length;){let h=l.raw.indexOf(`
400
+ `,u),d=h===-1?l.raw.length:h,p=l.raw.slice(u,d).replace(/\r$/,""),m=fx.exec(p);m!==null&&t.push(c+u+m[1].length),u=h===-1?l.raw.length:h+1}}let i=new eo,o=l=>{let c=[];return i.walkTokens(He.lex(l,{gfm:!0}),u=>{u.type==="checkbox"&&c.push(u.checked)}),c},a=o(n),s=a.map(()=>null);for(let l of t){let c=`${n.slice(0,l)}${n[l]===" "?"x":" "}${n.slice(l+1)}`,u=o(c);if(u.length!==a.length)continue;let h=-1;for(let d=0;d<a.length;d+=1)if(u[d]!==a[d]){if(h!==-1){h=-1;break}h=d}h!==-1&&(s[h]=l)}return s.map(l=>{if(l===null)return null;let c=0,u=0;for(;u<l;)c+=e[c]==="\r"&&e[c+1]===`
401
+ `?2:1,u+=1;return c})}function ap(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=gx(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function sp(e){let t=e?.getAttribute(gn);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var lp=32;function ks(e){let t=e;for(let n=0;t!==null&&n<lp;n++){let r=t.getAttribute(Ct);if(r!==null&&r!=="")return`${no}${r}`;t=t.parentElement}return null}function cp(e){if(!e||e.isCollapsed===!0)return!1;let t=e.toString;return(typeof t=="function"&&t!==Object.prototype.toString?t.call(e):"").length>0}var up="edited",dp="created",hp="Edit",pp="Done",fp="Save",gp="Saving…",mp="Note body",oo="Discard unsaved changes to this note?";function vp(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:an(e.source),provenanceTitle:Ln(e.source),updated:lr(e.updated,t),updatedIso:e.updated,created:lr(e.created,t),createdIso:e.created,tags:e.tags}}function yp(e){return`#${e}`}var mx=200,vx=8,yx="no note";function _s(e){let t=e;for(let n=0;t!==null&&n<lp;n++){let r=t.getAttribute(Ct);if(r!==null&&r!=="")return{slug:r,text:(t.textContent??"").trim()};if((t.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(t.textContent??"").trim()};t=t.parentElement}return null}function wx(e){return e.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(t,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 bx(e,t=mx){let n=wx(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function wp(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:yx,text:`no note named “${i}” yet`}}let n=e?.model.nodes.find(i=>i.id===`note:${t.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Ln(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:bx(n.detail.preview??"")}}function bp(e,t,n,r,i,o,a=vx){let s=e+a,l=t+a;return s+n>i-a&&(s=e-a-n),l+r>o-a&&(l=t-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 ro={anchor:null,pointerX:0,pointerY:0};function xp(e,t){switch(t.type){case"show":return t.anchor.slug===null&&t.anchor.text===""?e:{anchor:t.anchor,pointerX:t.x,pointerY:t.y};case"hide":return e.anchor===null?e:ro;case"dismiss":return ro}}function kp(e,t,n=!1){return t!==null?null:e===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":n?"Couldn’t load this note — retrying…":e.startsWith(no)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function ao(){let e=new Map,t=new Map,n=new Set,r=0,i=()=>n.forEach(o=>o());return{get:o=>e.get(o)??null,subscribe(o){return n.add(o),()=>n.delete(o)},open(o,a){e.has(o)||(e.set(o,{body:a,baseline:a,saving:!1}),i())},edit(o,a){let s=e.get(o);s===void 0||s.body===a||(s.body=a,i())},discard(o){e.delete(o)&&i()},isDirty(o){let a=e.get(o);return a!==void 0&&a.body!==a.baseline},dirtySlugs(){return[...e].filter(([,o])=>o.body!==o.baseline).map(([o])=>o)},async save(o,a){let s=e.get(o);if(s===void 0||s.saving||t.get(o)?.saving)return;let l=s.body;s.saving=!0,i();let c=!1;try{c=await a(o,l)}finally{if(e.get(o)===s){let u=t.get(o);c&&u!==void 0&&(u.body=l,u.version=++r,delete u.pending),c&&s.body===l?e.delete(o):(c&&(s.baseline=l),s.saving=!1),i()}}},nextLoadVersion(){return++r},getTaskBody(o,a){return t.get(o)?.body??a},taskBody(o,a,s){let l=t.get(o),c=!1;return l===void 0?(l={body:a,version:s,saving:!1},t.set(o,l)):s>l.version&&(l.saving?(l.pending===void 0||s>l.pending.version)&&(l.pending={body:a,version:s}):(c=l.body!==a,l.body=a,l.version=s)),c&&i(),l.body},isTaskSaving:o=>t.get(o)?.saving??!1,async saveTask(o,a,s){let l=t.get(o);if(l===void 0||l.saving||e.get(o)?.saving)return!1;l.saving=!0,i();let c=!1;try{return c=await s(o,a),c}finally{t.get(o)===l&&(c?(l.body=a,l.version=++r):l.pending!==void 0&&l.pending.version>l.version&&(l.body=l.pending.body,l.version=l.pending.version),delete l.pending,l.saving=!1,i())}},clearTaskSources(o){let a=!1;for(let s of o)a=t.delete(s)||a;a&&i()}}}function _p(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(bt))),o=new Set(n.panes.flatMap(s=>s.tabs.map(bt))),a=[...i].filter(s=>s!==null&&s.startsWith("note:")&&!o.has(s)).map(s=>s.slice(5));return a.some(s=>e.isDirty(s))&&!r()?!1:(a.forEach(s=>e.discard(s)),e.clearTaskSources(a),!0)}function Ep(e,t,n){let r=new Set(t);return e.dirtySlugs().filter(o=>r.has(o)).length>0&&!n()?!1:(r.forEach(o=>e.discard(o)),e.clearTaskSources([...r]),!0)}var xx="weave-preview-x",kx="weave-preview-y";function _x({view:e,open:t,editing:n,saving:r,taskSaving:i,onToggle:o,onSave:a}){return f("header",{class:"weave-note-head",children:[f("h3",{class:"weave-note-title",children:e.title}),f("p",{class:"weave-note-meta",children:[n?f(pe,{children:[f("button",{type:"button",class:"weave-note-save",disabled:r||i,onClick:a,children:r?gp:fp}),f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:pp})]}):f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:hp}),f("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:t,children:f("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),f("span",{class:`weave-prov weave-prov-${e.provenance}`,title:e.provenanceTitle,children:[e.provenanceGlyph," ",e.provenance]}),f("span",{class:"weave-note-time",title:e.updatedIso,children:[up," ",e.updated]}),f("span",{class:"weave-note-time",title:e.createdIso,children:[dp," ",e.created]})]}),f("p",{class:"weave-note-tags",children:e.tags.map(s=>f("span",{class:"weave-tag",children:yp(s)},s))})]})}function Tp(e){let t=Q(ao()),n=e.drafts??t.current,r=_l(),i=`${e.idPrefix??r}-weave-preview`,[o,a]=j(0);le(()=>n.subscribe(()=>a(T=>T+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=np(e.graph,e.selectedId),u=kp(e.selectedId,s,e.loadFailed),h=ft(()=>s===null?null:rp(e.graph,s.slug),[s,e.graph]),d=ft(()=>s===null||h===null?"":op(Ph,l,h),[s,l,h]),[p,m]=j(ro),v=T=>{m(F=>xp(F,T))},y=Q(null),b=Q(null),w=s===null?null:n.get(s.slug),k=s!==null&&n.isTaskSaving(s.slug),_=async()=>{s!==null&&!n.isTaskSaving(s.slug)&&await n.save(s.slug,e.onSave)},I=async(T,F)=>{let K=()=>{T.checked=!T.checked,T.setAttribute("aria-label",io(T.checked))};if(s===null||n.isTaskSaving(s.slug)){K();return}let Z=ap(n.getTaskBody(s.slug,s.body),F);if(Z===null){K();return}let Y=[...y.current?.querySelectorAll(`input[${gn}]`)??[]];T.setAttribute("aria-label",io(T.checked));for(let ne of Y)ne.disabled=!0;try{await n.saveTask(s.slug,Z,e.onSave)||K()}catch(ne){throw K(),ne}finally{for(let ne of Y)ne.disabled=n.isTaskSaving(s.slug)}},A=Q(null);le(()=>{s!==null&&A.current!==s.slug&&(A.current=s.slug,e.defaultEdit&&n.get(s.slug)===null&&n.open(s.slug,l))},[s?.slug,e.defaultEdit]);let D=()=>{s===null||n.isTaskSaving(s.slug)||(n.get(s.slug)===null?n.open(s.slug,l):(!n.isDirty(s.slug)||window.confirm(oo))&&n.discard(s.slug))},O=p.anchor===null?null:wp(e.graph,p.anchor);if(Ze(()=>{s!==null&&n.taskBody(s.slug,s.body,e.loadVersion)},[n,s===null?null:s.slug,s?.body,e.loadVersion]),Ze(()=>{v({type:"hide"})},[s===null?null:s.slug]),Ze(()=>{if(s===null)return;let T=n.isTaskSaving(s.slug);for(let F of y.current?.querySelectorAll(`input[${gn}]`)??[])F.disabled=T},[s===null?null:s.slug,o,d]),Ze(()=>{let T=y.current;if(T!==null){let Z=p.anchor?.slug??null;for(let Y of T.querySelectorAll(`a[${Ct}]`))Z!==null&&Y.getAttribute(Ct)===Z?Y.setAttribute("aria-describedby",i):Y.removeAttribute("aria-describedby")}let F=b.current;if(F===null||O===null)return;let K=bp(p.pointerX,p.pointerY,F.offsetWidth,F.offsetHeight,window.innerWidth,window.innerHeight);F.style.setProperty(`--${xx}`,`${K.x}px`),F.style.setProperty(`--${kx}`,`${K.y}px`)},[p,O,i]),c!==null){let T=e.graph?.model.nodes.find(Z=>Z.id===e.selectedId),F=T?.label??c,K=T===void 0?c:tp(T)??c;return f("article",{class:"weave-note weave-note-artifact",children:[f("header",{class:"weave-note-head",children:[f("h3",{class:"weave-note-title",children:F}),f("p",{class:"weave-note-meta",children:f("span",{class:"weave-note-time",children:c})})]}),f("iframe",{class:"weave-artifact-frame",title:F,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(c)}`},K)]},K)}if(s===null||h===null)return f("p",{class:"weave-note-empty",children:u});let U=vp(s,e.now);return f("article",{class:`weave-note weave-note-${U.provenance}`,children:[f(_x,{view:U,open:()=>e.onOpen(s.slug),editing:w!==null,saving:w?.saving??!1,taskSaving:k,onToggle:D,onSave:()=>{_()}}),w!==null?f("textarea",{class:"weave-note-editor","aria-label":mp,spellcheck:e.spellcheck??!0,value:w.body,onInput:T=>n.edit(s.slug,T.target.value),onKeyDown:T=>{if(T.key==="Escape"){T.stopPropagation(),D();return}T.key.toLowerCase()!=="s"||!(T.metaKey||T.ctrlKey)||(T.preventDefault(),_())}}):f("div",{ref:y,class:"weave-note-body",tabIndex:-1,onMouseOver:T=>{let F=_s(T.target);v(F!==null?{type:"show",anchor:F,x:T.clientX,y:T.clientY}:{type:"hide"})},onMouseLeave:()=>v({type:"hide"}),onFocus:T=>{let F=_s(T.target);if(F===null)return;let K=T.target.getBoundingClientRect?.();v({type:"show",anchor:F,x:K?.left??0,y:K?.bottom??0})},onBlur:()=>v({type:"hide"}),onClick:T=>{let F=T.target,K=sp(F);if(K!==null){I(F,K);return}let Z=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(cp(Z))return;let Y=ks(T.target);Y!==null&&e.onSelect(Y,T.metaKey||T.ctrlKey||T.shiftKey)},onKeyDown:T=>{if(T.key==="Escape"&&p.anchor!==null){T.stopPropagation(),v({type:"dismiss"});return}if(T.key!=="Enter"&&T.key!==" ")return;let F=ks(T.target);F!==null&&(T.preventDefault(),e.onSelect(F,T.metaKey||T.ctrlKey||T.shiftKey))},dangerouslySetInnerHTML:{__html:d}}),O===null?null:f("div",{ref:b,id:i,role:"tooltip",class:`weave-preview${O.ghost?" weave-preview-ghost":""}`,children:[f("span",{class:"weave-preview-kind",children:O.kind}),f("span",{class:"weave-preview-title",children:O.title}),O.text===""?null:f("p",{class:"weave-preview-text",children:O.text})]})]},s.slug)}var Sp=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Rp(e,t,n){return e===0?null:e===1?0:t<0?n?e-1:0:n?t===0?e-1:t-1:t===e-1?0:t+1}function Ap(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Cp(e){return e===null?!1:(e.focus(),!0)}function Bn(){let e=Q(null);return le(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Cp(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Ap(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Sp)??[]],r=Rp(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function Pp(e,t){let n=t.trim().toLowerCase();if(!n)return 0;let r=e.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 Ex(e){return Math.min(Math.max(e,0),10)*2}function Tx(e){return`note:${e}`}function Sx(e,t){return Pp(e.summary.title,t)+Ex(e.score)}function Rx(e,t){return Pp(e.label,t)}var Ax=["path","manifest","url","slug"];function Cx(e){for(let t of Ax){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}function Lx(e,t){return e.score!==t.score?t.score-e.score:e.kind!==t.kind?e.kind==="note"?-1:1:e.label.localeCompare(t.label)||e.id.localeCompare(t.id)}function Nx(e,t,n,r){let i=new Map;for(let o of e){let a=Tx(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Sx(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=Rx(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Cx(o),badge:o.kind,score:a})}return[...i.values()].sort(Lx).slice(0,20)}function Dp(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Es(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Lp(e,t,n){return n<=0?0:((e+t)%n+n)%n}function Ip(e,t){return t===null?null:e[t]?.id??null}function Gp(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Es(e,n);return t==="ArrowDown"?{...r,cursor:Lp(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Lp(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Es(n-1,n),handled:!0}:t==="Escape"?{...r,dismiss:!0,handled:!0}:t!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var so="Search the workspace",Mp="Search notes and repository…",Op="↑↓ move · ↵ open · esc close";function Px(e,t){return e.query.trim()?t>0?null:e.failed?"search failed — the workspace server may be gone":e.loading?"searching…":`no matches for “${e.query.trim()}”`:"Type to search notes, modules, files and entry points."}function Dx(e){return e===1?"1 result":`${e} results`}function Np(e){return`weave-search-row-${e}`}function Fp(e,t){let n=Nx(e.hits,e.answered,t?.model.nodes??[],e.query),r=Es(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Np(a)})),status:Px(e,n.length),count:n.length,countLabel:Dx(n.length),cursor:r,activeDomId:n.length?Np(r):null}}function Gx({row:e,onPick:t,onHover:n}){return f("li",{id:e.domId,role:"option","aria-selected":e.active,class:`weave-hit weave-hit-${e.kind}${e.active?" weave-hit-on":""}`,onMouseMove:n,onClick:r=>t(r.metaKey||r.ctrlKey),children:[f("span",{class:"weave-hit-badge",children:e.badge}),f("span",{class:"weave-hit-label",children:e.label}),f("span",{class:"weave-hit-detail",children:e.detail})]})}function $p(e){let[t,n]=j(Dp),r=Q(0),i=Q(null),o=Bn(),a=Q(null);le(()=>{a.current?.focus()},[]),le(()=>{let c=t.query.trim(),u=!0;if(!c)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{u=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let p=new AbortController;i.current=p,n(v=>({...v,loading:!0,failed:!1}));let m=await bc(e.ports.fetch,c,p.signal);!u||p.signal.aborted||d!==r.current||n(v=>m.ok?{...v,hits:m.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...v,loading:!1,failed:!0})},140);return()=>{u=!1,window.clearTimeout(h),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Fp(t,e.graph),l=(c,u=!1)=>{let h=Ip(s.rows,c);h!==null&&e.onSelect(h,u),e.onClose()};return f("div",{class:"weave-scrim",onClick:()=>l(null),children:f("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":so,tabIndex:-1,ref:o.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{if(o.onKeyDown(c))return;let u=Gp(t.cursor,c.key,s.count);u.handled&&(c.preventDefault(),n(h=>({...h,cursor:u.cursor})),u.dismiss&&l(u.activate,c.metaKey||c.ctrlKey))},children:[f("input",{type:"search",class:"weave-palette-input",ref:a,value:t.query,placeholder:Mp,"aria-label":so,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:c=>n(u=>({...u,query:c.currentTarget.value,cursor:0}))}),s.status===null?f("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":so,children:s.rows.map((c,u)=>f(Gx,{row:c,onPick:h=>l(u,h),onHover:()=>n(h=>({...h,cursor:u}))},c.id))}):f("p",{class:"weave-palette-status",role:"status",children:s.status}),f("p",{class:"weave-palette-foot",children:[f("span",{children:s.countLabel}),f("button",{type:"button",class:"weave-chip",disabled:s.count===0,onClick:()=>l(t.cursor,!0),children:"Open in new tab"}),f("span",{class:"weave-palette-hint",children:[Op," · ⌘/Ctrl ↵ new tab"]})]})]})})}function Ts(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Wp=2e3,Mx=3e3,Up=new Set;function Ox(e,t){if(e===null)return Up;let n=new Set(e.model.nodes.map(r=>r.id));return new Set(t.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function zp(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function Hp(e){let t=e.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([p,m])=>t[p]===m)||(t={...t,...d},e.setState(t))},a=e.defer??((d,p)=>{let m=setTimeout(d,p);return()=>clearTimeout(m)}),s=async()=>{let d=zp(t.selectedId);if(d===null){o({note:null,noteFailed:!1});return}let p=await ca(e.fetch,d);p.ok?o({note:p.data,noteFailed:!1}):o({note:null,noteFailed:!0})},l=async()=>{let d=t.graph,p=await wc(e.fetch,t.graph);if(!p.ok)return t.graph===null&&o({graphFailed:!0}),p;if(!p.cached){let m=Ox(d,p.data);o({graph:p.data,graphFailed:!1,recentIds:m}),i?.(),i=null,m.size>0&&(i=a(()=>{i=null,o({recentIds:Up})},Mx))}return p},c=async()=>{if(!(n||r)){r=!0;try{let d=await l();zp(t.selectedId)!==null&&(t.note===null||d.ok&&!d.cached)&&await s()}finally{r=!1}}},h=(e.repeat??((d,p)=>{let m=setInterval(d,p);return()=>clearInterval(m)}))(()=>{c()},Wp);return c(),{refresh:()=>{c()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function Bp(e,t,n,r=(i,o)=>{let a=setTimeout(i,o);return()=>clearTimeout(a)}){let i=!1,o=null,a=async()=>{if(i)return;let s=await ca(e,t);i||(n(s),s.ok||(o=r(()=>{a()},Wp)))};return a(),()=>{i=!0,o?.()}}var Ar={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function co(e,t,n){return{id:e,target:t.id,label:Ke(t),kind:t.kind,kindIcon:on(t.kind),provenance:t.provenance,provenanceGlyph:an(t.provenance),provenanceTitle:Ln(t.provenance),selected:t.id===n}}function Fx(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:co(e.id,i,n)}function $x(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var zx=["link:links-to:"];function Wx(e){return zx.some(t=>e.id.startsWith(t))}function Ux(e){return e.id.startsWith("link:mentions:")}function Hx(e,t,n,r){let i=[];for(let[o,a]of Object.entries(e.tags)){if(!a.includes(t))continue;let s=[];for(let l of a){if(l===t)continue;let c=n.get(`note:${l}`);c!==void 0&&s.push(co(`tag:${o}:${l}`,c,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Bx(e,t,n,r){let i=[];for(let o of e.edges){if(o.kind!=="mentions"||o.target!==t)continue;let a=n.get(o.source);a!==void 0&&i.push(co(`mentioned-by:${o.source}`,a,r))}return i}function Kx(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var lo={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 Ss(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function Kp(e,t){if(e===null)return Ss(lo.loading);if(t===null)return Ss(lo.noSelection);let n=nn(e),r=fa(n,t);if(r===null)return Ss(lo.unknown);let i=$x(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>Fx(d,i,t)).filter(d=>d!==null);a(Ar.links,s(r.links.filter(Wx)));let l=ga(n.edges).get(t)??[];a(Ar.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>co(`backlink:${h.id}`,h,t))),a(Ar.mentions,[...s(r.links.filter(Ux)),...Bx(n,t,i,t)]);let c=Kx(t),u=c===null?[]:Hx(e,c,i,t);return o.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:lo.isolated}:{subject:r.label,groups:o,tags:u,tagsCount:u.length,empty:null}}function Vp(){return{open:new Set,closed:new Set}}var Vx=8;function jp(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>Vx}function jx(e){return e.some(t=>t.selected)}function qp(e,t){let n=jp(t,e.heading,e.count,jx(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function Yp(e,t){let n=jp(t,Ar.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:Ar.tags,count:e.length,collapsed:n,rows:[]}}function Xp(e,t,n){let r=new Set(e.open),i=new Set(e.closed);return n?(r.add(t),i.delete(t)):(i.add(t),r.delete(t)),{open:r,closed:i}}function uo(e){return`weave-ctx-panel-${e.toLowerCase()}`}function Zp({row:e,onSelect:t}){return f("li",{class:`weave-ctx-row${e.selected?" weave-row-on":""}`,children:f("button",{type:"button",class:"weave-ctx-link",onClick:n=>t(n.metaKey||n.ctrlKey),children:[f("span",{class:"weave-kind","aria-hidden":"true",children:f(_t,{name:e.kindIcon,class:"weave-icon"})}),f("span",{class:`weave-prov weave-prov-${e.provenance??"none"}`,title:e.provenanceTitle,children:e.provenanceGlyph}),f("span",{class:"weave-label",children:e.label})]})})}function Qp({view:e,onToggle:t}){return f("h4",{class:"weave-ctx-head",children:f("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!e.collapsed,"aria-controls":uo(e.heading),onClick:t,children:[f("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:f(_t,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,f("span",{class:"weave-ctx-count",children:e.count})]})})}function qx({view:e,onSelect:t,onToggle:n}){return f("section",{class:"weave-ctx-group",children:[f(Qp,{view:e,onToggle:n}),f("ul",{class:"weave-ctx-rows",id:uo(e.heading),hidden:e.collapsed,children:e.rows.map(r=>f(Zp,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function Yx({tag:e,onSelect:t}){return f("li",{class:"weave-ctx-tag",children:[f("span",{class:"weave-tag",children:["#",e.tag]}),f("ul",{class:"weave-ctx-rows",children:e.siblings.map(n=>f(Zp,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function Jp(e){let t=Kp(e.graph,e.selectedId),[n,r]=j(Vp),i=a=>()=>r(Xp(n,a.heading,a.collapsed)),o=Yp(t.tags,n);return f("div",{class:"weave-rail","aria-label":Gu.title,children:[t.empty===null?null:f("p",{class:"weave-ctx-empty",children:t.empty}),t.groups.map(a=>{let s=qp(a,n);return f(qx,{view:s,onSelect:e.onSelect,onToggle:i(s)},a.heading)}),t.tags.length===0?null:f("section",{class:"weave-ctx-group",children:[f(Qp,{view:o,onToggle:i(o)}),f("ul",{class:"weave-ctx-tags",id:uo(o.heading),hidden:o.collapsed,children:t.tags.map(a=>f(Yx,{tag:a,onSelect:e.onSelect},a.tag))})]})]})}function Xx(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function ef(e,t){let n=Xx(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function tf(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function nf(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function rf(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):Jt[e.key]}function of(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function af(e){return En.every(t=>Object.is(e[t.key],Jt[t.key]))}function sf(e){return f("div",{class:"weave-settings-forces",children:[En.map(t=>f("label",{class:"weave-setting-row",children:[f("span",{children:[f("strong",{children:t.label}),f("small",{children:t.hint})]}),f("span",{class:"weave-setting-range",children:[f("input",{"aria-label":t.label,type:"range",min:t.min,max:t.max,step:t.step,value:nf(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:rf(t,n.currentTarget.value)})}),f("output",{children:of(e.forces[t.key])})]})]},t.key)),f("button",{type:"button",disabled:af(e.forces),onClick:()=>e.onChange({...Jt}),children:"Reset graph layout"})]})}var lf=["General","Appearance","Interface","Editor","Files","Backup"];function nt(e){return f("label",{class:"weave-setting-row",children:[f("span",{children:[f("strong",{children:e.name}),f("small",{children:e.hint})]}),e.children]})}function cf(e){let[t,n]=j("General"),r=Bn(),i=e.layout.preferences,o=a=>e.onChange({...e.layout,preferences:{...i,...a}});return f("div",{class:"weave-scrim weave-settings-scrim",onClick:e.onClose,children:f("div",{class:"weave-settings",role:"dialog","aria-modal":"true","aria-label":"Settings",tabIndex:-1,ref:r.ref,onClick:a=>a.stopPropagation(),onKeyDown:a=>{r.onKeyDown(a)},children:[f("header",{children:[f("h2",{children:"Settings"}),f("button",{type:"button","aria-label":"Close settings",onClick:e.onClose,children:"×"})]}),f("nav",{"aria-label":"Settings categories",children:e.compact?f("select",{class:"weave-settings-category","aria-label":"Settings category",value:t,onChange:a=>n(a.currentTarget.value),children:lf.map(a=>f("option",{value:a,children:a},a))}):lf.map(a=>f("button",{type:"button","aria-current":t===a?"page":void 0,onClick:()=>n(a),children:a},a))}),f("section",{"aria-label":`${t} settings`,children:[f("h3",{children:t}),t==="General"?f(pe,{children:[f("p",{children:["Pi Weave ",e.info.version]}),f("dl",{class:"weave-settings-locations",children:[f("dt",{children:"Vault"}),f("dd",{children:e.info.vaultRoot||"Loading…"}),f("dt",{children:"Repository"}),f("dd",{children:e.cwd})]}),f("div",{class:"weave-settings-actions",children:[f("button",{type:"button",onClick:e.onRefresh,children:"Refresh workspace"}),f("a",{href:"https://github.com/EranYonai/pi-weave#readme",target:"_blank",rel:"noreferrer",children:"Documentation ↗"})]}),f("details",{children:[f("summary",{tabIndex:0,children:"Keyboard shortcuts"}),Ti(e.shortcut.slice(0,-1)).map(a=>f("div",{children:[f("h4",{children:a.title}),a.entries.map(s=>f("div",{class:"weave-key-row",children:[f("kbd",{children:s.combo}),f("span",{children:s.what})]},s.combo))]},a.title))]})]}):null,t==="Appearance"?f(pe,{children:[f(nt,{name:"Color scheme",hint:"System follows your device and uses your chosen light and dark themes.",children:f("select",{"aria-label":"Color scheme",value:e.layout.theme==="system"?"system":ue[e.layout.theme].scheme,onChange:a=>e.onChange({...e.layout,theme:a.currentTarget.value==="system"?"system":a.currentTarget.value==="light"?i.lightTheme:i.darkTheme}),children:[f("option",{value:"system",children:"System"}),f("option",{value:"light",children:"Light"}),f("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(a=>f(nt,{name:`${a==="light"?"Light":"Dark"} theme`,hint:`Used in ${a} mode and by the ribbon theme button.`,children:f("select",{"aria-label":`${a==="light"?"Light":"Dark"} theme`,value:i[`${a}Theme`],onChange:s=>{let l=s.currentTarget.value;e.onChange({...e.layout,preferences:{...i,[`${a}Theme`]:l},theme:e.layout.theme!=="system"&&ue[e.layout.theme].scheme===a?l:e.layout.theme})},children:Object.entries(ue).filter(([,s])=>s.scheme===a).map(([s,l])=>f("option",{value:s,children:l.name},s))})},a)),f(nt,{name:"Accent color",hint:"Choose independently of the theme. Shades adapt to light and dark backgrounds.",children:f("select",{"aria-label":"Accent color",value:i.accent,onChange:a=>o({accent:a.currentTarget.value}),children:[f("option",{value:"theme",children:"Theme default"}),Object.entries(Xt).map(([a,s])=>f("option",{value:a,children:s.name},a))]})}),f(nt,{name:"Note font size",hint:"Applies to reading and editing notes.",children:f("span",{class:"weave-setting-range",children:[f("input",{"aria-label":"Note font size",type:"range",min:12,max:22,step:1,value:i.fontSize,onInput:a=>o({fontSize:Number(a.currentTarget.value)})}),f("output",{children:[i.fontSize,"px"]})]})})]}):null,t==="Interface"?f(pe,{children:[f(nt,{name:"Notes sidebar",hint:"Show files and recent notes.",children:f("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:a=>e.onChange({...e.layout,treeVisible:a.currentTarget.checked})})}),f(nt,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:f("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:a=>e.onChange({...e.layout,contextVisible:a.currentTarget.checked})})}),f(nt,{name:"Color graph by group",hint:"Give each containment group its own color.",children:f("input",{type:"checkbox",checked:i.groupColors,onChange:a=>o({groupColors:a.currentTarget.checked})})}),f("h4",{children:"Graph layout"}),f("p",{class:"weave-settings-hint",children:"Adjust the graph live. Your choices are saved for this workspace."}),f(sf,{forces:i.forces,onChange:a=>o({forces:a})})]}):null,t==="Editor"?f(pe,{children:[f(nt,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:f("input",{type:"checkbox",checked:i.spellcheck,onChange:a=>o({spellcheck:a.currentTarget.checked})})}),f(nt,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:f("input",{type:"checkbox",checked:i.readable,onChange:a=>o({readable:a.currentTarget.checked})})}),f(nt,{name:"Open notes in editing mode",hint:"Newly opened notes start in the editor. Existing drafts are preserved.",children:f("input",{type:"checkbox",checked:i.defaultEdit,onChange:a=>o({defaultEdit:a.currentTarget.checked})})})]}):null,t==="Files"?f(pe,{children:[f(nt,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:f("select",{"aria-label":"On startup",value:i.startup,onChange:a=>o({startup:a.currentTarget.value}),children:[f("option",{value:"restore",children:"Restore open tabs"}),f("option",{value:"empty",children:"Start with an empty tab"})]})}),f(nt,{name:"Focus new tabs",hint:"Switch to notes opened in a new tab, including from the graph.",children:f("input",{type:"checkbox",checked:i.focusNewTabs,onChange:a=>o({focusNewTabs:a.currentTarget.checked})})}),f("h4",{children:"Deleting files"}),f("p",{children:"Deleting a note or folder removes it from the vault after confirmation. Download a backup before deleting anything you may need again."})]}):null,t==="Backup"?f(pe,{children:[f("h4",{children:"Download your vault"}),f("p",{children:"Save a ZIP containing the vault’s files and folders, including notes, metadata, and attachments. Linked files and folders are included as files."}),f("p",{children:"Save any unsaved edits first. The download contains files saved on disk. Backups are manual; store the ZIP somewhere safe."}),f("a",{class:"weave-settings-download",href:"/api/backup",download:!0,children:"Download vault ZIP"})]}):null]})]})})}function Zx({group:e}){return f("div",{children:[f("p",{class:"weave-key-group",children:e.title}),e.entries.map(t=>f("div",{class:"weave-key-row",children:[f("kbd",{class:"weave-key-combo",children:t.combo}),f("span",{class:"weave-key-what",children:t.what})]},t.combo))]})}function uf(e){let t=Bn(),n=e.shortcut.slice(0,-1);return f("div",{class:"weave-scrim",onClick:e.onClose,children:f("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Ca,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[f("h2",{class:"weave-help-title",children:Ca}),f("div",{class:"weave-keys",children:Ti(n).map(r=>f(Zx,{group:r},r.title))}),f("p",{class:"weave-help-foot",children:[f("button",{type:"button",class:"weave-chip",onClick:e.onClose,children:"close"}),f("span",{class:"weave-help-hint",children:Hu})]})]})})}function df(e,t){let n=r=>{if(r.defaultPrevented)return;let i=zu(Wu(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function hf({model:e}){return f("footer",{class:"weave-status",children:[f("span",{class:"weave-status-cwd",title:e.cwd,children:e.cwd}),f("span",{class:"weave-status-sel",title:"Current item",children:e.selection})]})}var pf="pi-weave.theme.v1";function ho(e){try{let t=e.getItem(pf);return kn(t)?t:null}catch{return null}}function ff(e,t){try{return e.setItem(pf,t),!0}catch{return!1}}function po(e,t,n=Mt){return ue[As(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function As(e,t,n=Mt){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function gf(e){return e==="system"?null:e}function Rs(e){return e==="system"?"System":ue[e].name}function mf(e,t="dark",n=Mt){return{glyph:e==="system"?"◐":ue[e].scheme==="light"?"○":"●",label:Rs(e),hint:`Colour theme: ${Rs(e)} — click for ${Rs(po(e,t,n))}`}}function fo(e,t){if(e.kind==="graph")return"Graph view";let n=bt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function Qx(e){let[t]=j(e.visits);return f("div",{class:"weave-recents",children:Iu(t,e.graph,e.selectedId).map(n=>f("button",{type:"button","aria-current":n.selected?"page":void 0,title:n.label,onClick:r=>e.onSelect(n.id,r.metaKey||r.ctrlKey),children:[f("span",{class:"weave-kind",children:f(_t,{name:n.icon,class:"weave-icon"})}),f("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function Jx(e){let t=bt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=j(null),o=Q(null),a=Q(e.tab.scroll);le(()=>{if(n===null)return;let c=e.drafts.nextLoadVersion();return Bp(Ge,n,u=>{i({slug:n,note:u.ok?u.data:null,failed:!u.ok,version:c})})},[n,e.graph?.stamp,e.revision]);let s=r?.slug===n?r:null;if(Ze(()=>{let c=o.current?.querySelector(".weave-note");c!=null&&(c.scrollTop=a.current)},[t,s?.note?.note.slug]),t===null)return f("div",{class:"weave-welcome",children:[f("span",{class:"weave-welcome-mark","aria-hidden":"true",children:"✳"}),f("h1",{children:"Your knowledge, connected."}),f("p",{children:"Open a note from the sidebar, find something you remember, or follow a connection."}),f("div",{children:[f("button",{type:"button",onClick:e.onSearch,children:["Search workspace ",f("kbd",{children:"⌘K"})]}),f("button",{type:"button",onClick:e.onGraph,children:"Explore graph"})]})]});let l=e.graph!==null&&!e.graph.model.nodes.some(c=>c.id===t);if(l||s?.failed&&e.drafts.isDirty(n??"")){let c=n===null?null:e.drafts.get(n);return c!==null&&n!==null&&e.drafts.isDirty(n)?f("div",{class:"weave-welcome",children:[f("h2",{children:l?"This item is no longer here":"This note could not be loaded"}),f("p",{children:["Your unsaved draft is preserved below. Select and copy it before closing this workspace. ",l?"Saving cannot restore or recreate the missing note.":"Reopen this tab to retry loading the note."]}),f("label",{class:"weave-note-meta",for:`missing-draft-${e.tab.id}`,children:"Unsaved draft (read-only)"}),f("textarea",{id:`missing-draft-${e.tab.id}`,class:"weave-note-editor","aria-label":"Unsaved draft for missing note",rows:16,readOnly:!0,value:c.body}),f("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]}):f("div",{class:"weave-welcome",children:[f("h2",{children:"This item is no longer here"}),f("p",{children:"It may have been moved or deleted. Your other tabs are still available."}),f("button",{type:"button",onClick:e.onSearch,children:"Find another note"})]})}return f("div",{class:"weave-document",ref:o,onScrollCapture:c=>{let u=c.target;u.classList.contains("weave-note")&&(a.current=u.scrollTop,e.onScroll(u.scrollTop))},children:f(Tp,{spellcheck:e.preferences.spellcheck,defaultEdit:e.preferences.defaultEdit,note:s?.note??null,loadFailed:s?.failed??!1,loadVersion:s?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:c=>{xc(Ge,c).then(u=>{u.ok?u.data.opened||window.alert("Could not open the note in an editor."):window.alert(u.message)})},onSave:e.onSave,drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function Cs(e){let t=Q(null);return f("div",{class:"weave-workspace-divider",role:"separator",tabIndex:0,"aria-label":e.label,"aria-orientation":e.horizontal?"horizontal":"vertical","aria-valuenow":Math.round(e.value),"aria-valuemin":e.min,"aria-valuemax":e.max,onPointerDown:n=>{t.current=e.horizontal?n.clientY:n.clientX,n.currentTarget.setPointerCapture(n.pointerId)},onPointerMove:n=>{if(t.current===null)return;let r=e.horizontal?n.clientY:n.clientX;e.onChange(r-t.current),t.current=r},onPointerUp:n=>{t.current=null,n.currentTarget.releasePointerCapture(n.pointerId)},onPointerCancel:()=>{t.current=null},onKeyDown:n=>{["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(n.key)&&(n.preventDefault(),e.onChange(n.key==="ArrowLeft"||n.key==="ArrowUp"?-20:20))}})}function vf(e){let[t,n]=j(Ts),[r,i]=j(()=>({...Jo(),theme:ho(localStorage)??"system"})),[o,a]=j(null),[s,l]=j(Date.now),[c,u]=j(e.initialWidth),[h,d]=j(()=>ur(window)),[p,m]=j(!1),[v,y]=j({version:"",vaultRoot:""}),[b,w]=j(!1),[k,_]=j(0),[,I]=j(0),[A,D]=j(null),[O,U]=j(null),T=Q(null),[F,K]=j(null),[Z,Y]=j(null),[ne,Be]=j(!1),[Lt,Fe]=j([]),[$e,Ce]=j(!1),[me]=j(ao),Ye=Q(null),Ee=Q(null),re=Q(location.hash),Nt=Q(!1),Pt=Q(null),Cr=Q(null),Lr=Q(null),[go,mo]=j({left:0,top:0,width:600,height:500}),Nr=ar(r),Pr=Rn(r),mn=mf(r.theme,h,r.preferences),ee=As(r.theme,h,r.preferences),Kn=ft(()=>({theme:ee,accent:r.preferences.accent}),[ee,r.preferences.accent]),X=Pr.kind==="graph"?A:bt(Pr),Le=r.panes.find(E=>E.tabs.some(L=>L.id===E.activeTab&&L.kind==="graph")),Te=Le!==void 0&&(c>=850||Le.id===r.activePane),ut=c<1050?$e:r.contextVisible,Dr=r.panes.some(E=>E.tabs.some(L=>L.kind==="graph")),we=Q({layout:r,overlay:o,selectedId:X,graphPreviewId:O,select:E=>{}}),Ht=E=>{we.current.graphPreviewId=E,U(E)};le(()=>{Te||Ht(null)},[Te]);let dt=E=>{_p(me,we.current.layout,E,()=>window.confirm(oo))&&i(E)},Xe=(E,L=!1,B=r.activePane,N=!1)=>{let W=(E===null?sr:mc)(r,E,{newTab:L,paneId:B});dt(c<850&&!N?{...W,treeVisible:!1}:W),Ce(!1)},Vn=()=>i(E=>({...ta(E),...c<850?{treeVisible:!1}:{}})),rt=E=>{Ht(null);let L=r.panes.find(B=>B.id!==Le?.id);Xe(E,!0,L?.id??Le?.id??r.activePane)},mt=E=>{D(E),Du(we.current.graphPreviewId,E)?rt(E):Ht(E)};we.current={layout:r,overlay:o,selectedId:X,graphPreviewId:O,select:Xe};let vt=E=>Ep(me,E,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),jn=async(E,L)=>{let B=await kc(Ge,E,L);return B.ok?(_(N=>N+1),Ye.current?.refresh(),!0):(window.alert(B.message),!1)};le(()=>me.subscribe(()=>I(E=>E+1)),[me]),le(()=>(Ye.current=Hp({fetch:Ge,state:Ts(),setState:n}),()=>Ye.current?.stop()),[]),le(()=>{let E=!0;return(async()=>{try{let L=await Ge("/api/workspace-state"),B=await L.json();if(!E)return;if(L.ok&&typeof B.viewId=="string"){Ee.current=B.viewId,B.info&&y(B.info);let N=fc(B.layout);N&&(i(gc(N)),Fe(N.panes.flatMap(W=>W.tabs.flatMap(ce=>ce.history)).reduce(Sa,[])))}else w(!0)}catch{E&&w(!0)}finally{E&&m(!0)}})(),()=>{E=!1}},[]),le(()=>{if(!p||t.graph===null||Nt.current)return;Nt.current=!0;let E=ef(re.current,t.graph);E!==null&&i(L=>sr(L,E))},[p,t.graph]),le(()=>{p&&Fe(E=>Sa(E,X))},[p,X]),le(()=>{p&&(history.replaceState(null,"",tf(X)),document.documentElement.dataset.weaveTheme=ee,document.documentElement.dataset.weaveScheme=ue[ee].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,ff(localStorage,r.theme))},[p,X,r.theme,ee,r.preferences.accent]);let Bt=Q(Promise.resolve());le(()=>{if(!p||!Ee.current)return;let E=Ee.current,L=window.setTimeout(()=>{Bt.current=Bt.current.then(async()=>{try{let B=await Ge("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:E,layout:r})});w(!B.ok)}catch{w(!0)}})},350);return()=>window.clearTimeout(L)},[r,p]),le(()=>{let E=window.setInterval(()=>l(Date.now()),Ou),L=()=>u(window.innerWidth);window.addEventListener("resize",L);let B=Cu(window,d),N=it=>{for(let Dt of document.querySelectorAll(".weave-pane-menu[open]"))Dt.contains(it.target)||(Dt.open=!1)};document.addEventListener("pointerdown",N);let W=it=>{me.dirtySlugs().length&&(it.preventDefault(),it.returnValue="")},ce=()=>{Ee.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ee.current,layout:we.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",ce),window.addEventListener("beforeunload",W),()=>{window.clearInterval(E),window.removeEventListener("resize",L),window.removeEventListener("beforeunload",W),window.removeEventListener("pagehide",ce),document.removeEventListener("pointerdown",N),B()}},[]),le(()=>df(document,{context:()=>({overlay:we.current.overlay,hasSelection:we.current.selectedId!==null}),run:E=>Uu(E,{setOverlay:a,fitGraph:()=>Lr.current?.(),clearSelection:()=>{Rn(we.current.layout).kind==="graph"?(D(null),Ht(null)):we.current.select(null)},closeTab:()=>{let L=we.current.layout;dt(ra(L,L.activePane,Rn(L).id))},toggleTheme:()=>i(L=>({...L,theme:po(L.theme,ur(window),L.preferences)})),focusSelector:L=>(L===Nn.graph?i(B=>({...ta(B),...window.innerWidth<850?{treeVisible:!1}:{}})):L===Nn.tree||L===Aa?i(B=>({...B,treeVisible:!0})):i(hc),requestAnimationFrame(()=>{L===Nn.note&&Ei(document,".weave-pane-active .weave-note-editor")||!Ei(document,L)&&L===Nn.note&&Ei(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),Ze(()=>{for(let E of r.panes)document.getElementById(`tab-${E.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(E=>E.activeTab).join(","),r.activePane,c,p,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),Ze(()=>{let E=Cr.current,L=Pt.current;if(!Te||!E||!L)return;let B=()=>{let W=E.getBoundingClientRect(),ce=L.getBoundingClientRect();mo({left:W.left-ce.left,top:W.top-ce.top,width:W.width,height:W.height})};B();let N=new ResizeObserver(B);return N.observe(E),N.observe(L),()=>N.disconnect()},[Te,r,c]);let vn=(E,L)=>i(B=>({...B,panes:B.panes.map(N=>({...N,tabs:N.tabs.map(W=>W.id===E?{...W,scroll:L}:W)}))})),yn=(E,L)=>{hi(r,E,T.current)===null&&!L.dataTransfer?.types.includes(dr)||(L.preventDefault(),L.dataTransfer&&(L.dataTransfer.dropEffect=T.current===null?"copy":"move"),K(null),Y(E))},yt=(E,L)=>{let B=Pu(t.graph,L.dataTransfer?.getData(dr)??"");if(B!==null){L.preventDefault(),Xe(B,!0,E),Y(null);return}let N=T.current;hi(r,E,N)!==null&&(L.preventDefault(),i(W=>{let ce=hi(W,E,N);return ce===null?W:sa(W,ce,N)}),T.current=null,Y(null),K(null))},Kt=(E,L,B)=>{E.tabs.some(N=>N.id===T.current)&&(B.preventDefault(),B.stopPropagation(),B.dataTransfer.dropEffect="move",Y(null),K({paneId:E.id,before:L}))},Vt=(E,L)=>{let B=T.current;B===null||!E.tabs.some(N=>N.id===B)||(L.preventDefault(),L.stopPropagation(),i(N=>aa(N,E.id,B,F?.paneId===E.id?F.before:null)),T.current=null,K(null),Y(null))},Ir=E=>{let L=E.tabs.find(N=>N.id===E.activeTab),B=E.id===r.activePane;return f("section",{class:`weave-pane${B?" weave-pane-active":""}${Z===E.id?" weave-pane-drop":""}`,"data-drop-label":T.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(E)+1}`,onDragOver:N=>yn(E.id,N),onDrop:N=>yt(E.id,N),onDragLeave:N=>{N.currentTarget.contains(N.relatedTarget)||Y(null)},hidden:c<850&&!B,onFocusCapture:()=>{B||i(N=>({...N,activePane:E.id}))},onPointerDown:()=>{B||i(N=>({...N,activePane:E.id}))},children:[f("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:N=>Kt(E,null,N),onDrop:N=>Vt(E,N),children:[E.tabs.map(N=>f("div",{class:`weave-tab${N.id===L.id?" weave-tab-active":""}${F?.paneId===E.id&&F.before===N.id?" weave-tab-drop-before":""}${F?.paneId===E.id&&F.before===null&&N===E.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:W=>{let ce=W.currentTarget.getBoundingClientRect(),it=W.clientX<ce.left+ce.width/2?N.id:E.tabs[E.tabs.indexOf(N)+1]?.id??null;Kt(E,it,W)},onDrop:W=>Vt(E,W),children:[f("button",{type:"button",role:"tab",title:fo(N,t.graph),id:`tab-${N.id}`,"aria-selected":N.id===L.id,"aria-controls":`panel-${E.id}`,tabIndex:N.id===L.id?0:-1,draggable:!0,onDragStart:W=>{T.current=N.id,W.dataTransfer.effectAllowed="move",W.dataTransfer.setData("application/x-weave-tab",N.id)},onClick:()=>i(na(r,E.id,N.id)),onKeyDown:W=>{let ce=W.key==="ArrowRight"?1:W.key==="ArrowLeft"?-1:0;if(ce&&W.altKey&&!W.ctrlKey&&!W.metaKey){W.preventDefault(),W.stopPropagation();let qn=E.tabs.indexOf(N),Gr=ce<0?E.tabs[Math.max(0,qn-1)].id:E.tabs[qn+2]?.id??null;i(aa(r,E.id,N.id,Gr)),requestAnimationFrame(()=>document.getElementById(`tab-${N.id}`)?.focus());return}if(!ce&&W.key!=="Home"&&W.key!=="End")return;W.preventDefault();let it=W.key==="Home"?0:W.key==="End"?E.tabs.length-1:(E.tabs.indexOf(N)+ce+E.tabs.length)%E.tabs.length,Dt=E.tabs[it];i(na(r,E.id,Dt.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Dt.id}`)?.focus())},children:[f("span",{"aria-hidden":"true",children:N.kind==="graph"?"◌":"▤"}),f("span",{children:fo(N,t.graph)}),me.isDirty((bt(N)??"").slice(5))?f("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),f("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${fo(N,t.graph)}`,onClick:()=>dt(ra(r,E.id,N.id)),children:"×"})]},N.id)),f("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>Xe(null,!0,E.id),children:"+"})]}),f("div",{class:"weave-pane-toolbar",children:[f("button",{type:"button","aria-label":"Navigate back",disabled:L.kind==="graph"||L.cursor===0,onClick:()=>dt(ia({...r,activePane:E.id},E.id,-1)),children:"←"}),f("button",{type:"button","aria-label":"Navigate forward",disabled:L.kind==="graph"||L.cursor>=L.history.length-1,onClick:()=>dt(ia({...r,activePane:E.id},E.id,1)),children:"→"}),f("span",{class:"weave-breadcrumb",children:fo(L,t.graph)}),f("details",{class:"weave-pane-menu",onKeyDown:N=>{N.key==="Escape"&&(N.preventDefault(),N.stopPropagation(),N.currentTarget.open=!1,N.currentTarget.querySelector("summary")?.focus())},children:[f("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),f("div",{onClick:N=>{let W=N.currentTarget.closest("details");W&&(W.open=!1)},children:[f("button",{type:"button",onClick:()=>i(oa({...r,activePane:E.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),f("button",{type:"button",onClick:()=>i(oa({...r,activePane:E.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?f(pe,{children:[f("button",{type:"button",onClick:()=>i(sa(r,E.id,L.id)),children:"Move tab to other pane"}),f("button",{type:"button",title:"Move all tabs to the other pane and close this pane",onClick:()=>i(pc(r,E.id)),children:"Close pane"})]}):null]})]})]}),f("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${E.id}`,"aria-labelledby":`tab-${L.id}`,...L.kind==="graph"?{ref:Cr}:{},children:L.kind==="document"?f(Jx,{preferences:r.preferences,tab:L,graph:t.graph,drafts:me,revision:k,now:s,onSelect:(N,W)=>Xe(N,W,E.id),onSave:jn,onScroll:N=>vn(L.id,N),onSearch:()=>a("search"),onGraph:Vn},`${L.id}:${L.cursor}:${bt(L)}`):null})]},E.id)};return f(pe,{children:[f("div",{class:"weave-workbench",style:{"--weave-note-size":`${r.preferences.fontSize}px`,"--weave-reading-width":r.preferences.readable?"760px":"100%"},ref:Pt,onDragEnd:()=>{T.current=null,Y(null),K(null)},children:[f("nav",{class:"weave-ribbon","aria-label":"Workspace tools",children:[f("button",{type:"button","aria-label":"Toggle notes sidebar","aria-pressed":r.treeVisible,title:"Notes",onClick:()=>i({...r,treeVisible:!r.treeVisible}),children:"▤"}),f("button",{type:"button","aria-label":"Open graph view",title:"Graph view",onClick:Vn,children:"◌"}),f("button",{type:"button","aria-label":"Search notes and repository",title:Fu(ki(_i(e.platform))),onClick:()=>a("search"),children:f("svg",{viewBox:"0 0 20 20",width:16,height:16,fill:"none",stroke:"currentColor","stroke-width":1.7,"aria-hidden":"true",children:[f("circle",{cx:"8.5",cy:"8.5",r:"5.5"}),f("path",{d:"m13 13 4 4"})]})}),f("span",{class:"weave-ribbon-space"}),f("button",{type:"button","aria-label":"Toggle context sidebar","aria-pressed":ut,title:"Context",onClick:()=>c<1050?Ce(!$e):i({...r,contextVisible:!r.contextVisible}),children:"☷"}),f("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Ye.current?.refresh(),_(E=>E+1)},children:"↻"}),f("button",{type:"button","aria-label":mn.hint,title:mn.hint,onClick:()=>i({...r,theme:po(r.theme,h,r.preferences)}),children:mn.glyph}),f("button",{type:"button","aria-label":"Settings",title:"Settings",onClick:()=>a("settings"),children:"⚙"})]}),f("div",{class:"weave-sidebar-dock weave-notes-dock","data-open":r.treeVisible,inert:!r.treeVisible,"aria-hidden":!r.treeVisible,style:{"--weave-sidebar-width":`${Math.min(r.treeWidth,c-90)}px`},children:[f("aside",{class:"weave-sidebar weave-sidebar-notes","aria-label":"Notes sidebar",children:[f("div",{class:"weave-sidebar-heading",children:[f("button",{type:"button","aria-pressed":!ne,onClick:()=>Be(!1),children:"Files"}),f("button",{type:"button","aria-pressed":ne,onClick:()=>Be(!0),children:"Recent"}),f("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{Pt.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),ne?f(Qx,{visits:Lt,graph:t.graph,selectedId:X,onSelect:Xe}):f(Ku,{graph:t.graph,selectedId:X,recentIds:t.recentIds,onSelect:(E,L,B)=>Xe(E,L,r.activePane,B),onMutate:vt,onRefresh:()=>Ye.current?.refresh(),now:s}),f("div",{class:"weave-vault-label",children:[f("span",{children:"Workspace"}),f("strong",{title:e.cwd,children:e.cwd.split(/[\\/]/).filter(Boolean).pop()??"Weave"})]})]}),f(Cs,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:E=>i(L=>({...L,treeWidth:Math.max(180,Math.min(420,L.treeWidth+E))}))})]}),f("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&c>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:p?r.panes.map((E,L)=>f(pe,{children:[L>0&&c>=850?f(Cs,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:B=>{let N=r.split==="right"?Pt.current?.querySelector("main")?.clientWidth:Pt.current?.querySelector("main")?.clientHeight;i(W=>({...W,ratio:Math.max(.2,Math.min(.8,W.ratio+B/(N??800)))}))}}):null,Ir(E)]})):f("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),f("div",{class:"weave-sidebar-dock weave-context-dock","data-open":ut,inert:!ut,"aria-hidden":!ut,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[f(Cs,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:E=>i(L=>({...L,contextWidth:Math.max(180,Math.min(400,L.contextWidth-E))}))}),f("aside",{class:"weave-sidebar weave-sidebar-context","aria-label":"Context sidebar",children:[f("div",{class:"weave-sidebar-heading",children:[f("strong",{children:"Context"}),f("button",{type:"button","aria-label":"Hide context sidebar",onClick:()=>{Pt.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),Ce(!1),i({...r,contextVisible:!1})},children:"»"})]}),f(Jp,{graph:t.graph,selectedId:X,onSelect:Xe})]})]}),Dr?f("div",{class:"weave-graph-host",onDragOver:E=>{Le&&yn(Le.id,E)},onDrop:E=>{Le&&yt(Le.id,E)},onDragLeave:E=>{E.currentTarget.contains(E.relatedTarget)||Y(null)},onPointerDown:()=>{Le&&i(E=>({...E,activePane:Le.id}))},onFocusCapture:()=>{Le&&i(E=>({...E,activePane:Le.id}))},"aria-hidden":!Te,style:{...go,visibility:Te?"visible":"hidden",pointerEvents:Te?"auto":"none"},children:f(Vu,{graph:t.graph,selectedId:X,previewId:O,onSelect:mt,onOpen:rt,renderer:hh,storage:localStorage,host:window,scheme:Kn,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:Lr})}):null]}),f("div",{class:"weave-footer",children:[f(hf,{model:Mu(e.cwd,X)}),b?f("span",{role:"status",children:"Workspace restoration unavailable"}):null,me.dirtySlugs().length?f("span",{children:[me.dirtySlugs().length," unsaved"]}):null,c<850&&r.panes.length>1?f("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(E=>E.id!==Nr.id).id}),children:"Switch pane"}):null]}),o==="search"?f($p,{graph:t.graph,onSelect:Xe,onClose:()=>a(null),ports:{fetch:Ge}}):null,o==="settings"?f(cf,{compact:c<=650,layout:r,info:v,cwd:e.cwd,shortcut:ki(_i(e.platform)),onChange:E=>{dt(E),Ce(E.contextVisible)},onRefresh:()=>{Ye.current?.refresh(),_(E=>E+1)},onClose:()=>a(null)}):null,o==="help"?f(uf,{shortcut:ki(_i(e.platform)),onClose:()=>a(null)}):null]})}var yf=`
403
402
  .weave-workbench{position:relative;display:flex;min-height:0;overflow:hidden;background:var(--weave-page)}
404
403
  .weave-workbench button{font:inherit;color:inherit;cursor:pointer}
405
404
  .weave-workbench button:focus-visible,.weave-workbench summary:focus-visible{outline:2px solid var(--weave-accent);outline-offset:-2px}
@@ -441,7 +440,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
441
440
  .weave-pane-drop{position:relative}
442
441
  .weave-pane-drop::after{content:attr(data-drop-label);position:absolute;inset:4px;z-index:20;display:grid;place-items:center;pointer-events:none;border:2px dashed var(--weave-accent);border-radius:var(--weave-radius);color:var(--weave-accent);background:var(--weave-new)}
443
442
  .weave-tabs{display:flex;align-items:stretch;min-width:0;overflow-x:auto;background:var(--weave-panel);gap:3px;padding:5px 6px 0;border-bottom:1px solid var(--weave-line);scrollbar-width:thin}
444
- .weave-tab{display:flex;align-items:center;min-width:90px;max-width:210px;border-radius:var(--weave-radius) var(--weave-radius) 0 0;color:var(--weave-dim);flex-shrink:0;border-bottom:2px solid transparent}
443
+ .weave-tab{position:relative;display:flex;align-items:center;min-width:90px;max-width:210px;border-radius:var(--weave-radius) var(--weave-radius) 0 0;color:var(--weave-dim);flex-shrink:0;border-bottom:2px solid transparent}
444
+ .weave-tab-drop-before::before,.weave-tab-drop-after::after{content:"";position:absolute;top:2px;bottom:2px;width:3px;background:var(--weave-accent);pointer-events:none}
445
+ .weave-tab-drop-before::before{left:-3px}.weave-tab-drop-after::after{right:-3px}
445
446
  .weave-tab-active{background:var(--weave-page);color:var(--weave-fg)}
446
447
  .weave-pane-active .weave-tab-active{border-bottom-color:var(--weave-accent)}
447
448
  .weave-tab button{border:0;background:none}
@@ -465,12 +466,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
465
466
  .weave-pane-content{min-width:0;min-height:0;display:flex;overflow:hidden;position:relative}
466
467
  .weave-document{display:flex;min-width:0;min-height:0;flex:1}
467
468
  .weave-document .weave-note{width:100%;border-left:0}
468
- .weave-document .weave-note-head{position:static;padding:28px max(24px,calc((100% - 760px)/2)) 18px;border:0}
469
+ .weave-document .weave-note-head{position:static;padding:28px max(24px,calc((100% - var(--weave-reading-width,760px))/2)) 18px;border:0}
469
470
  .weave-document .weave-note-title{font-size:var(--weave-px-display);letter-spacing:-.03em;margin-bottom:12px}
470
- .weave-document .weave-note-body{padding:10px max(24px,calc((100% - 760px)/2)) 64px;font-size:var(--weave-px-subhead);line-height:1.8}
471
+ .weave-document .weave-note-body{padding:10px max(24px,calc((100% - var(--weave-reading-width,760px))/2)) 64px;font-size:var(--weave-note-size,var(--weave-px-subhead));line-height:1.8}
471
472
  .weave-document .weave-note-body h1{font-size:var(--weave-px-display);line-height:1.4;margin-bottom:18px}
472
473
  .weave-document .weave-note-body h2{font-size:var(--weave-px-title);margin-top:28px}
473
- .weave-document .weave-note-editor{padding:14px 28px;min-height:220px;flex:1}
474
+ .weave-document .weave-note-editor{padding:14px max(24px,calc((100% - var(--weave-reading-width,760px))/2));min-height:220px;flex:1;font-size:var(--weave-note-size,var(--weave-px-subhead))}
474
475
  .weave-document .weave-note-tags{margin-top:12px}
475
476
  .weave-document .weave-note-edit,.weave-document .weave-note-save{padding:5px 10px;border-radius:var(--weave-radius)}
476
477
  .weave-welcome{align-self:center;margin:auto;padding:35px;max-width:560px;color:var(--weave-dim);line-height:1.7}
@@ -514,18 +515,30 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
514
515
  @media(prefers-reduced-motion:reduce){
515
516
  .weave-sidebar-dock,.weave-sidebar-dock[data-open=false],.weave-sidebar-dock>.weave-sidebar{transition:none}
516
517
  }
517
- `;var uf=`
518
- --weave-bg:#eff1f5;--weave-panel:#e6e9ef;--weave-raise:#ccd0da;--weave-fg:#4c4f69;--weave-dim:#56586a;
519
- --weave-faint:#606274;--weave-line:#ccd0da;--weave-line-strong:#bcc0cc;
520
- --weave-accent:#7113ec;--weave-ok:#28641b;--weave-warn:#7c4f10;--weave-bad:#b20d30;
521
- --weave-new:rgba(113,19,236,.10);
522
- --weave-page:#dce0e8;
523
- `,Kx=`
518
+
519
+ .weave-settings-scrim{align-items:center;padding:24px 16px}
520
+ .weave-settings button{font:inherit;color:inherit;cursor:pointer;border:0;background:transparent}
521
+ .weave-settings a{color:var(--weave-accent)}
522
+ .weave-settings{display:grid;grid-template-columns:180px minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);width:min(900px,calc(100vw - 32px));height:min(680px,calc(100dvh - 48px));background:var(--weave-panel);border:1px solid var(--weave-line-strong);border-radius:12px;box-shadow:0 24px 80px var(--weave-scrim);overflow:hidden}
523
+ .weave-settings header{grid-column:1/-1;display:flex;justify-content:space-between;align-items:center;padding:16px 24px;border-bottom:1px solid var(--weave-line)}
524
+ .weave-settings h2,.weave-settings h3{margin:0}.weave-settings h3{font-size:20px;margin-bottom:24px}
525
+ .weave-settings header button{font-size:24px}.weave-settings nav{padding:16px 12px;background:var(--weave-bg);overflow:auto;border-right:1px solid var(--weave-line)}
526
+ .weave-settings nav button{display:block;width:100%;text-align:left;padding:10px 12px;border-radius:6px;color:var(--weave-dim)}
527
+ .weave-settings nav button[aria-current]{color:var(--weave-accent);background:var(--weave-new)}
528
+ .weave-settings section{padding:28px;overflow:auto;min-width:0}.weave-settings p{line-height:1.6;color:var(--weave-dim)}
529
+ .weave-setting-row{display:flex;justify-content:space-between;align-items:center;gap:24px;padding:16px 0;border-bottom:1px solid var(--weave-line)}
530
+ .weave-setting-row>span:first-child{min-width:0;flex:1}.weave-setting-row strong{display:block;font-weight:500}.weave-setting-row small{display:block;color:var(--weave-dim);margin-top:6px;line-height:1.5}
531
+ .weave-settings select{background:var(--weave-raise);border:1px solid var(--weave-line-strong);border-radius:6px;padding:7px;color:var(--weave-fg);max-width:230px;font:inherit}
532
+ .weave-settings input{accent-color:var(--weave-accent)}.weave-settings input[type=checkbox]{width:18px;height:18px;flex-shrink:0}
533
+ .weave-setting-range{display:flex;align-items:center;gap:12px;width:190px}.weave-setting-range input{width:130px;min-width:0}.weave-setting-range output{min-width:42px;text-align:right;color:var(--weave-accent);font-variant-numeric:tabular-nums}
534
+ .weave-settings button:focus-visible,.weave-settings a:focus-visible,.weave-settings summary:focus-visible{outline:2px solid var(--weave-accent);outline-offset:2px}
535
+ .weave-settings-actions{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin:24px 0}.weave-settings-actions button,.weave-settings-download,.weave-settings-forces>button{display:inline-block;padding:9px 14px;border:1px solid var(--weave-line-strong);border-radius:6px;color:var(--weave-accent);background:var(--weave-raise);text-decoration:none}
536
+ .weave-settings-forces>button{margin-top:20px}.weave-settings-forces>button:disabled{opacity:.5}.weave-settings-locations dd{margin:6px 0 18px;overflow-wrap:anywhere;color:var(--weave-dim);font-family:var(--weave-font-mono)}
537
+ .weave-settings details summary{cursor:pointer;padding:12px 0}.weave-settings .weave-key-row{gap:16px;align-items:baseline}.weave-settings .weave-key-row kbd{min-width:150px;color:var(--weave-accent)}
538
+ @media(max-width:650px){.weave-settings{grid-template-columns:1fr;grid-template-rows:auto auto minmax(0,1fr)}.weave-settings nav{border-right:0;border-bottom:1px solid var(--weave-line);padding:8px 16px}.weave-settings nav select{width:100%;max-width:none}.weave-settings section{padding:20px}.weave-setting-row{align-items:flex-start;gap:12px}.weave-settings select{max-width:170px}.weave-setting-range{width:140px}.weave-setting-range input{width:90px}}
539
+ `;function Ls(e){let{scheme:t,colors:n}=ue[e];return Object.entries(n).map(([r,i])=>`--weave-${r}:${i};`).join("")+`--weave-new:color-mix(in srgb,var(--weave-accent) ${t==="light"?10:16}%,transparent);color-scheme:${t};--weave-vignette:radial-gradient(ellipse at center,transparent 55%,${t==="light"?"rgba(0,0,0,.10)":"rgba(0,0,0,.22)"} 100%);--weave-scrim:rgba(0,0,0,${t==="light"?".30":".45"});`}var ek=`
524
540
  :root{
525
- --weave-bg:#24273a;--weave-panel:#1e2030;--weave-raise:#363a4f;--weave-fg:#cad3f5;--weave-dim:#a5adcb;
526
- --weave-faint:#939ab7;--weave-line:#363a4f;--weave-line-strong:#494d64;
527
- --weave-accent:#c6a0f6;--weave-ok:#a6da95;--weave-warn:#eed49f;--weave-bad:#ed8796;
528
- --weave-new:rgba(198,160,246,.16);
541
+ ${Ls("dark")}
529
542
  --weave-row:26px;--weave-gutter:10px;
530
543
  /* The reading gutter is note-only: prose wants a wider margin than chrome.
531
544
  Rails, rows and bars keep --weave-gutter, so density is a property of the
@@ -539,7 +552,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
539
552
  third face was tried (serif prose) and withdrawn at the user's call; two
540
553
  voices read calmer than three. The CSP allows nothing fetched, and both
541
554
  are system stacks. */
542
- --weave-page:#181926;
555
+
543
556
  /* Two radii, per the plan: hairline-sharp for controls (a 4 px corner is
544
557
  the difference between a control and a card), one softer corner for the
545
558
  two overlays that float above the grid. Tag pills are 999px — a capsule
@@ -574,20 +587,14 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
574
587
  --weave-px-row:12px;--weave-px-base:13px;--weave-px-body:13.5px;
575
588
  --weave-px-subhead:14px;--weave-px-title:15px;--weave-px-display:20px;
576
589
  }
577
- /* The light tokens, shared verbatim by the attribute branch and the media
578
- query below — one const interpolated twice is the only way CSS gets
579
- "these are the same colours" without a preprocessor. Which branch wins is
580
- theme.model.ts's business: the attribute carries a *manual* choice, the
581
- media query the system default, and the :not() is what lets the two coexist
582
- without a manual "dark" being dragged back into light by the OS. */
583
590
  @media (prefers-color-scheme: light){
584
- :root:not([data-weave-theme="dark"]){
585
- ${uf}
586
- }
587
- }
588
- :root[data-weave-theme="light"]{
589
- ${uf}
591
+ :root:not([data-weave-theme]){${Ls("light")}}
590
592
  }
593
+ ${Object.keys(ue).map(e=>`:root[data-weave-theme="${e}"]{${Ls(e)}}`).join(`
594
+ `)}
595
+ ${Object.entries(Xt).map(([e,t])=>["light","dark"].map(n=>`:root[data-weave-scheme="${n}"][data-weave-accent="${e}"]{--weave-accent:${t[n]};}`).join(`
596
+ `)).join(`
597
+ `)}
591
598
  body{font-size:var(--weave-px-base)}
592
599
  #app{height:100%;display:grid;grid-template-rows:minmax(0,1fr) auto;background:var(--weave-bg)}
593
600
 
@@ -864,15 +871,7 @@ body{font-size:var(--weave-px-base)}
864
871
  faster than a dark one under a black veil. */
865
872
  .weave-graph-canvas::after{
866
873
  content:"";position:absolute;inset:0;pointer-events:none;
867
- background:radial-gradient(ellipse at center,transparent 55%,rgba(0,0,0,.22) 100%);
868
- }
869
- :root[data-weave-theme="light"] .weave-graph-canvas::after{
870
- background:radial-gradient(ellipse at center,transparent 55%,rgba(76,79,105,.10) 100%);
871
- }
872
- @media (prefers-color-scheme: light){
873
- :root:not([data-weave-theme="dark"]) .weave-graph-canvas::after{
874
- background:radial-gradient(ellipse at center,transparent 55%,rgba(76,79,105,.10) 100%);
875
- }
874
+ background:var(--weave-vignette);
876
875
  }
877
876
  .weave-graph-empty{
878
877
  margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim);
@@ -898,32 +897,6 @@ body{font-size:var(--weave-px-base)}
898
897
  border-top:1px solid var(--weave-line);
899
898
  }
900
899
 
901
- /* the hidden force tuner (?sliders=1, docs/weave-workspace.md 15.7) --------- */
902
- /* Absolutely positioned over the canvas rather than given a grid row: the
903
- panel is a debug overlay and must not change the layout the graph is being
904
- judged in — moving the canvas while tuning it would falsify the very thing
905
- being looked at. */
906
- .weave-tuner{
907
- position:absolute;top:8px;right:8px;z-index:3;width:232px;max-height:calc(100% - 16px);
908
- overflow:auto;display:flex;flex-direction:column;gap:6px;padding:9px 10px;
909
- font-size:var(--weave-px-caption);color:var(--weave-fg);
910
- background:var(--weave-panel);border:1px solid var(--weave-line-strong);
911
- border-radius:var(--weave-radius);
912
- }
913
- .weave-tuner-title{margin:0;color:var(--weave-faint);letter-spacing:.04em;text-transform:uppercase}
914
- .weave-tuner-row{display:flex;flex-direction:column;gap:2px;cursor:pointer}
915
- .weave-tuner-label{display:flex;justify-content:space-between;gap:8px;color:var(--weave-dim)}
916
- .weave-tuner-label b{color:var(--weave-accent);font-weight:600;font-variant-numeric:tabular-nums}
917
- .weave-tuner-row input{width:100%;margin:0;accent-color:var(--weave-accent)}
918
- .weave-tuner-toggle{display:flex;align-items:center;gap:6px;cursor:pointer;color:var(--weave-dim)}
919
- .weave-tuner-toggle input{margin:0;accent-color:var(--weave-accent)}
920
- .weave-tuner-actions{display:flex;gap:6px;margin-top:2px;flex-wrap:wrap}
921
- .weave-tuner-snippet{
922
- margin:0;padding:6px;overflow:auto;white-space:pre;color:var(--weave-faint);
923
- background:var(--weave-bg);border:1px solid var(--weave-line);border-radius:var(--weave-radius);
924
- font-size:var(--weave-px-prov);line-height:1.45;
925
- }
926
-
927
900
  /* context rail ---------------------------------------------------------- */
928
901
  /* The \`.weave-empty\` block that used to sit above went with \`EmptyState.tsx\`
929
902
  in P3: every column now has its own empty state (\`treeEmptyMessage\`,
@@ -986,7 +959,6 @@ body{font-size:var(--weave-px-base)}
986
959
  .weave-status-cwd,.weave-status-sel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
987
960
  .weave-status-cwd{max-width:38%;color:var(--weave-faint)}
988
961
  .weave-status-sel{color:var(--weave-fg)}
989
- .weave-status-stamp{margin-left:auto;color:var(--weave-faint)}
990
962
 
991
963
  /* overlays: the ⌘K palette and the ? help sheet (P4) --------------------- */
992
964
  /* The scrim is a click target that closes, and the reason both overlays sit
@@ -995,15 +967,7 @@ body{font-size:var(--weave-px-base)}
995
967
  the wrong breakpoint. */
996
968
  .weave-scrim{
997
969
  position:fixed;inset:0;z-index:10;display:flex;justify-content:center;
998
- align-items:flex-start;padding:9vh 16px 16px;background:rgba(0,0,0,.45);
999
- }
1000
- /* The scrim above is tuned for the dark ground, where a neutral black veil
1001
- reads as depth. On the linen ground the same veil reads as a power cut, so
1002
- the light scheme gets its own — a plum-tinted veil at reduced strength,
1003
- drawn from the foreground ramp rather than from grey. */
1004
- :root[data-weave-theme="light"] .weave-scrim{background:rgba(76,79,105,.30)}
1005
- @media (prefers-color-scheme: light){
1006
- :root:not([data-weave-theme="dark"]) .weave-scrim{background:rgba(76,79,105,.30)}
970
+ align-items:flex-start;padding:9vh 16px 16px;background:var(--weave-scrim);
1007
971
  }
1008
972
  .weave-palette,.weave-help{
1009
973
  display:flex;flex-direction:column;width:100%;max-width:560px;max-height:72vh;
@@ -1079,7 +1043,7 @@ body{font-size:var(--weave-px-base)}
1079
1043
  @keyframes weave-fade-in{from{opacity:0}}
1080
1044
  @keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
1081
1045
  @media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
1082
- `,Vx=["style[nonce]","style","script[nonce]","script[src]"];function jx(e){for(let t of Vx){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function cf(e,t=Kx+lf){let n=e.createElement("style"),r=jx(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var df=document.getElementById("app");if(df!==null){cf(document),qx();let e=rl(document.getElementById(nl)?.textContent??null);tl(g(sf,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform,tuner:Ol(window.location.search)}),df)}function qx(){let e=qi(Vi(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1046
+ `,tk=["style[nonce]","style","script[nonce]","script[src]"];function nk(e){for(let t of tk){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function wf(e,t=ek+yf){let n=e.createElement("style"),r=nk(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var bf=document.getElementById("app");if(bf!==null){wf(document),rk();let e=hl(document.getElementById(dl)?.textContent??null);ul(f(vf,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),bf)}function rk(){let e=gf(ho(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1083
1047
  /*! Bundled license information:
1084
1048
 
1085
1049
  dompurify/dist/purify.es.mjs: