pi-weave 0.3.6 → 0.3.8

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,11 +18,11 @@
18
18
  * sigma@3.0.3 — MIT
19
19
  */
20
20
 
21
- "use strict";(()=>{var $f=Object.create;var Ys=Object.defineProperty;var zf=Object.getOwnPropertyDescriptor;var Wf=Object.getOwnPropertyNames;var Hf=Object.getPrototypeOf,Uf=Object.prototype.hasOwnProperty;var Xs=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Bf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wf(t))!Uf.call(e,i)&&i!==n&&Ys(e,i,{get:()=>t[i],enumerable:!(r=zf(t,i))||r.enumerable});return e};var Jn=(e,t,n)=>(n=e!=null?$f(Hf(e)):{},Bf(t||!e||!e.__esModule?Ys(n,"default",{value:e,enumerable:!0}):n,e));var Di=Xs((Q0,Va)=>{"use strict";var In=typeof Reflect=="object"?Reflect:null,xd=In&&typeof In.apply=="function"?In.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Ni;In&&typeof In.ownKeys=="function"?Ni=In.ownKeys:Object.getOwnPropertySymbols?Ni=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Ni=function(t){return Object.getOwnPropertyNames(t)};function zv(e){console&&console.warn&&console.warn(e)}var _d=Number.isNaN||function(t){return t!==t};function ie(){ie.init.call(this)}Va.exports=ie;Va.exports.once=Bv;ie.EventEmitter=ie;ie.prototype._events=void 0;ie.prototype._eventsCount=0;ie.prototype._maxListeners=void 0;var kd=10;function Pi(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 kd},set:function(e){if(typeof e!="number"||e<0||_d(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");kd=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||_d(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 Ed(e){return e._maxListeners===void 0?ie.defaultMaxListeners:e._maxListeners}ie.prototype.getMaxListeners=function(){return Ed(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")xd(l,this,n);else for(var c=l.length,u=Cd(l,c),r=0;r<c;++r)xd(u[r],this,n);return!0};function Td(e,t,n,r){var i,o,a;if(Pi(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=Ed(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,zv(s)}return e}ie.prototype.addListener=function(t,n){return Td(this,t,n,!1)};ie.prototype.on=ie.prototype.addListener;ie.prototype.prependListener=function(t,n){return Td(this,t,n,!0)};function Wv(){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 Sd(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Wv.bind(r);return i.listener=n,r.wrapFn=i,i}ie.prototype.once=function(t,n){return Pi(n),this.on(t,Sd(this,t,n)),this};ie.prototype.prependOnceListener=function(t,n){return Pi(n),this.prependListener(t,Sd(this,t,n)),this};ie.prototype.removeListener=function(t,n){var r,i,o,a,s;if(Pi(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():Hv(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 Rd(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):Cd(i,i.length)}ie.prototype.listeners=function(t){return Rd(this,t,!0)};ie.prototype.rawListeners=function(t){return Rd(this,t,!1)};ie.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Ad.call(e,t)};ie.prototype.listenerCount=Ad;function Ad(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?Ni(this._events):[]};function Cd(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Hv(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 Bv(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))}Ld(e,t,o,{once:!0}),t!=="error"&&Kv(e,i,{once:!0})})}function Kv(e,t,n){typeof e.on=="function"&&Ld(e,"error",t,n)}function Ld(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 ja=Xs((tE,Pd)=>{"use strict";Pd.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var Jr,te,tl,Kf,Gt,Zs,nl,rl,Ro,jr,er,il,Lo,Ao,Co,Vf,Xr={},Zr=[],jf=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ei=Array.isArray;function wt(e,t){for(var n in t)e[n]=t[n];return e}function No(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qf(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?Jr.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 qr(e,a,r,i,null)}function qr(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??++tl,__i:-1,__u:0};return i==null&&te.vnode!=null&&te.vnode(o),o}function he(e){return e.children}function Yr(e,t){this.props=e,this.context=t}function Yt(e,t){if(t==null)return e.__?Yt(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"?Yt(e):null}function Yf(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),Po(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Yt(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,cl(r,o,i),t.__e=t.__=null,o.__e!=n&&ol(o)}}function ol(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}),ol(e)}function Qs(e){(!e.__d&&(e.__d=!0)&&Gt.push(e)&&!Qr.__r++||Zs!=te.debounceRendering)&&((Zs=te.debounceRendering)||nl)(Qr)}function Qr(){try{for(var e,t=1;Gt.length;)Gt.length>t&&Gt.sort(rl),e=Gt.shift(),t=Gt.length,Yf(e)}finally{Gt.length=Qr.__r=0}}function al(e,t,n,r,i,o,a,s,l,c,u){var h,d,p,m,y,v,w=r&&r.__k||Zr,b=t.length;for(l=Xf(n,t,w,l,b),h=0;h<b;h++)(p=n.__k[h])!=null&&(d=p.__i!=-1&&w[p.__i]||Xr,p.__i=h,v=Po(e,p,d,i,o,a,s,l,c,u),m=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&Do(d.ref,null,p),u.push(p.ref,p.__c||m,p)),y==null&&m!=null&&(y=m),4&p.__u?(l=sl(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=y,l}function Xf(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]=qr(null,a,null,null,null):ei(a)?a=e.__k[o]=qr(he,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=qr(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=Zf(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=Yt(s)),dl(s,s));return r}function sl(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=sl(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Yt(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,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 Js(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||jf.test(t)?n:n+"px"}function Vr(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||Js(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||Js(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(il,"$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[er]=r[er]:(n[er]=Lo,e.addEventListener(t,o?Co:Ao,o)):e.removeEventListener(t,o?Co:Ao,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 el(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[jr]==null)t[jr]=Lo++;else if(t[jr]<n[er])return;return n(te.event?te.event(t):t)}}}function Po(e,t,n,r,i,o,a,s,l,c){var u,h,d,p,m,y,v,w,b,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(b=t.props,k=T.prototype&&T.prototype.render,_=(u=T.contextType)&&r[u.__c],I=u?_?_.props.value:u.__:r,n.__c?w=(d=t.__c=n.__c).__=d.__E:(k?t.__c=d=new T(b,I):(t.__c=d=new Yr(b,I),d.constructor=T,d.render=Jf),_&&_.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(b,d.__s))),m=d.props,y=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&&b!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,I),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,I)===!1){t.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(F){F&&(F.__=t)}),Zr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=Yt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,I),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,y,v)})}if(d.context=I,d.props=b,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),Zr.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&&(v=d.getSnapshotBeforeUpdate(m,y)),O=u!=null&&u.type===he&&u.key==null?ul(u.props.children):u,s=al(e,ei(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),w&&(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--;)No(o[U])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),F.then||ll(t),te.__e(F,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Qf(n.__e,t,n,r,i,o,a,l,c);return(u=te.diffed)&&u(t),128&t.__u?void 0:s}function ll(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ll))}function cl(e,t,n){for(var r=0;r<n.length;r++)Do(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 ul(e){return typeof e!="object"||e==null||e.__b>0?e:ei(e)?e.map(ul):e.constructor!==void 0?null:wt({},e)}function Qf(e,t,n,r,i,o,a,s,l){var c,u,h,d,p,m,y,v=n.props||Xr,w=t.props,b=t.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((p=o[c])&&"setAttribute"in p==!!b&&(b?p.localName==b:p.nodeType==3)){e=p,o[c]=null;break}}if(e==null){if(b==null)return document.createTextNode(w);e=document.createElementNS(i,b,w.is&&w),s&&(te.__m&&te.__m(t,o),s=!1),o=null}if(b==null)v===w||s&&e.data==w||(e.data=w);else{if(o=b=="textarea"&&w.defaultValue!=null?null:o&&Jr.call(e.childNodes),!s&&o!=null)for(v={},c=0;c<e.attributes.length;c++)v[(p=e.attributes[c]).name]=p.value;for(c in v)p=v[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in w||c=="value"&&"defaultValue"in w||c=="checked"&&"defaultChecked"in w||Vr(e,c,null,p,i);for(c in w)p=w[c],c=="children"?d=p:c=="dangerouslySetInnerHTML"?u=p:c=="value"?m=p:c=="checked"?y=p:s&&typeof p!="function"||v[c]===p||Vr(e,c,p,v[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=""),al(t.type=="template"?e.content:e,ei(d)?d:[d],t,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&Yt(n,0),s,l),o!=null)for(c=o.length;c--;)No(o[c]);s&&b!="textarea"||(c="value",b=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||b=="progress"&&!m||b=="option"&&m!=v[c])&&Vr(e,c,m,v[c],i),c="checked",y!=null&&y!=e[c]&&Vr(e,c,y,v[c],i))}return e}function Do(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 dl(e,t,n){var r,i;if(te.unmount&&te.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Do(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]&&dl(r[i],t,n||typeof e.type!="function");n||No(e.__e),e.__c=e.__=e.__e=void 0}function Jf(e,t,n){return this.constructor(e,n)}function hl(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=[],Po(t,e=(!r&&n||t).__k=qf(he,null,[e]),i||Xr,Xr,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?Jr.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),cl(o,e,a),e.props.children=null}Jr=Zr.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}},tl=0,Kf=function(e){return e!=null&&e.constructor===void 0},Yr.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),Qs(this))},Yr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Qs(this))},Yr.prototype.render=he,Gt=[],nl=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,rl=function(e,t){return e.__v.__b-t.__v.__b},Qr.__r=0,Ro=Math.random().toString(8),jr="__d"+Ro,er="__a"+Ro,il=/(PointerCapture)$|Capture$/i,Lo=0,Ao=el(!1),Co=el(!0),Vf=0;var pl="weave-bootstrap";var Io={cwd:""};function eg(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function fl(e){if(e===null||e.trim()==="")return Io;let t;try{t=JSON.parse(e)}catch{return Io}return eg(t)?t:Io}var Xt,de,Go,gl,tr=0,_l=[],me=te,ml=me.__b,vl=me.__r,yl=me.diffed,wl=me.__c,bl=me.unmount,xl=me.__;function nr(e,t){me.__h&&me.__h(de,e,tr||t),tr=0;var n=de.__H||(de.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function j(e){return tr=1,tg(Sl,e)}function tg(e,t,n){var r=nr(Xt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Sl(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=de,!de.__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};de.__f=!0;var o=de.shouldComponentUpdate,a=de.componentWillUpdate;de.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)},de.shouldComponentUpdate=i}return r.__N||r.__}function le(e,t){var n=nr(Xt++,3);!me.__s&&Oo(n.__H,t)&&(n.__=e,n.u=t,de.__H.__h.push(n))}function je(e,t){var n=nr(Xt++,4);!me.__s&&Oo(n.__H,t)&&(n.__=e,n.u=t,de.__h.push(n))}function Q(e){return tr=5,ft(function(){return{current:e}},[])}function ft(e,t){var n=nr(Xt++,7);return Oo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function El(e,t){return tr=8,ft(function(){return e},t)}function Tl(){var e=nr(Xt++,11);if(!e.__){for(var t=de.__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 ng(){for(var e;e=_l.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ti),t.__h.some(Mo),t.__h=[]}catch(n){t.__h=[],me.__e(n,e.__v)}}}me.__b=function(e){de=null,ml&&ml(e)},me.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xl&&xl(e,t)},me.__r=function(e){vl&&vl(e),Xt=0;var t=(de=e.__c).__H;t&&(Go===de?(t.__h=[],de.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ti),t.__h.some(Mo),t.__h=[],Xt=0)),Go=de},me.diffed=function(e){yl&&yl(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(_l.push(t)!==1&&gl===me.requestAnimationFrame||((gl=me.requestAnimationFrame)||rg)(ng)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Go=de=null},me.__c=function(e,t){t.some(function(n){try{n.__h.some(ti),n.__h=n.__h.filter(function(r){return!r.__||Mo(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],me.__e(r,n.__v)}}),wl&&wl(e,t)},me.unmount=function(e){bl&&bl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ti(r)}catch(i){t=i}}),n.__H=void 0,t&&me.__e(t,n.__v))};var kl=typeof requestAnimationFrame=="function";function rg(e){var t,n=function(){clearTimeout(r),kl&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);kl&&(t=requestAnimationFrame(n))}function ti(e){var t=de,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),de=t}function Mo(e){var t=de;e.__c=e.__(),de=t}function Oo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Sl(e,t){return typeof t=="function"?t(e):t}var Rl={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"},Al={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"},ce={light:{name:"Catppuccin Latte · Mauve",scheme:"light",colors:Rl},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Rl,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:Al},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Al,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"}}},Cl=["system",...Object.keys(ce)];function xn(e){return typeof e=="string"&&Cl.includes(e)}var Zt={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 ni(e){return typeof e=="string"?e:e.theme}function Ll(e,t){return t==="theme"?ce[e].colors.accent:Zt[t][ce[e].scheme]}var He={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},Mt={...He};function Fo(e){Object.assign(He,e)}var kn=[{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}],Ot={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...Mt}};function Nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Pl(e){if(!Nl(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(Ot).length)return null;for(let i of["light","dark"]){let o=n[`${i}Theme`];if(!xn(o)||o==="system"||ce[o].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(Zt,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(!Nl(r)||Object.keys(r).length!==kn.length)return null;for(let{key:i,min:o,max:a}of kn){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<o||s>a)return null}return n}var oi=40,Dl=100,ig=1e9,En=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function Ho(){return{version:1,panes:[{id:"pane-1",tabs:[En("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,treeWidth:240,contextWidth:240,theme:"system",preferences:Ot}}function rr(e){return e.panes.find(t=>t.id===e.activePane)}function Tn(e){let t=rr(e);return t.tabs.find(n=>n.id===t.activeTab)}function bt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function Ft(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 Qt(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?ii({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function Uo(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function ii(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??Uo(e);return r?{...n,lastDocumentTab:r.id}:n}function Il(e){if(Tn(e).kind==="document")return e;let t=rr(e),n=Uo(t);return n?Qt(e,t,n):Sn(e,null,{newTab:!0})}function ai(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 Wo(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=oi?e:Qt(e,{...t,tabs:[...t.tabs,n]},n)}function $o(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Dl&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function Sn(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=Uo(r),o?r={...r,activeTab:o.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!o)return Wo(e,r,$o(En(Ft(e,"tab")),t));let a=$o(o,t);return a===o&&r.id===e.activePane&&i===o.id?e:Qt(e,r,a)}function Bo(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:Qt(e,t.pane,t.tab);let n=rr(e);return Wo(e,n,{id:Ft(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function Ko(e,t,n){let r=ai(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:Qt(e,r.pane,r.tab)}function Vo(e,t,n){let r=ai(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=En(Ft(e,"tab"));return Qt(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=ii({...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 jo(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:Qt(e,r,{...i,cursor:o,scroll:0})}function qo(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)>=oi)return e;let n=Tn(e),r=Ft(e,"pane"),i=En(Ft(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 Gl(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 Yo(e,t,n,r){let i=ai(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 si(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 Xo(e,t,n){let r=ai(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:Ft(e,"pane"),tabs:[],activeTab:""},o=r.pane.tabs.filter(u=>u.id!==n),a=ii({...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)>=oi)return e;let s=o.length?null:En(Ft(e,"tab")),l=o.length?o:[s],c=ii({...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 ri(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _n(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 Ml(e){if(!ri(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||!_n(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||!xn(e.theme))return null;let t=Object.hasOwn(e,"preferences")?Pl(e.preferences):Ot;if(t===null)return null;let n=e.preferences;e.theme!=="system"&&(!ri(n)||!Object.hasOwn(n,"lightTheme"))&&(t={...t,[`${ce[e.theme].scheme}Theme`]:e.theme});let r=new Set,i=0,o=0,a=[];for(let s of e.panes){if(!ri(s)||!zo(s,Object.hasOwn(s,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!_n(s.id,"pane")||!Array.isArray(s.tabs)||s.tabs.length<1||!_n(s.activeTab,"tab")||r.has(s.id))return null;r.add(s.id);let l=[],c=!1;for(let h of s.tabs){if(!ri(h)||!zo(h,["id","kind","history","cursor","scroll"])||!_n(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>Dl||!Number.isInteger(h.cursor)||h.cursor<0||h.cursor>=h.history.length||h.history.some(p=>p!==null&&!_n(p))||typeof h.scroll!="number"||!Number.isFinite(h.scroll)||h.scroll<0||h.scroll>ig)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")&&(!_n(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>oi||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 Ol(e){if(e.preferences.startup==="restore")return e;let t=Ho();return{...e,panes:t.panes,activePane:t.activePane}}function Fl(e,t,n={}){let r=Sn(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 Ae=(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 Zo(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 $l(e){return e===403?"auth":e===404?"missing":"server"}function zl(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function ir(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($l(i.status),i.status,zl(i.status));let o;try{o=await i.json()}catch{return xt("malformed",i.status,"response was not valid JSON")}return n(o)?Zo(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 og(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ag(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 sg(e){if(!kt(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return og(e.tags)}function Wl(e){return kt(e)&&sg(e.note)}function lg(e){return kt(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function cg(e){return kt(e)&&typeof e.opened=="boolean"}function ug(e){return kt(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}async function li(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"):Zo(t,!0);if(!r.ok)return xt($l(r.status),r.status,zl(r.status));let i;try{i=await r.json()}catch{return xt("malformed",r.status,"response was not valid JSON")}return ag(i)?Zo(i):xt("malformed",r.status,"response did not match the expected shape")}function Qo(e,t){return ir(e,`/api/note/${encodeURIComponent(t)}`,Wl)}function Hl(e,t,n){return ir(e,`/api/search?q=${encodeURIComponent(t)}`,lg,n===void 0?void 0:{signal:n})}function Ul(e,t){return ir(e,"/api/open",cg,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function Bl(e,t){return ir(e,"/api/notes",Wl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function Jt(e,t,n,r){return ir(e,t,ug,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var ci=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,Jo=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,Kl=(e,t,n)=>Jt(e,ci(t),"POST",{body:n}),Vl=(e,t,n)=>Jt(e,ci(t,"/rename"),"POST",{name:n}),jl=(e,t,n)=>Jt(e,ci(t,"/move"),"POST",{folder:n}),ql=(e,t)=>Jt(e,ci(t),"DELETE"),Yl=(e,t)=>Jt(e,Jo(t),"POST"),Xl=(e,t,n)=>Jt(e,Jo(t,"/rename"),"POST",{name:n}),Zl=(e,t)=>Jt(e,Jo(t),"DELETE");function qe(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 dg(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 y=m.detail.path;c.startsWith(y+"/")&&y.length>h&&(u=p,h=y.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 ec(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 hg(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function Ql(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function pg(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=Ql(i),s=Ql(o);if(a!==s)return a?-1:1;let l=qe(i),c=qe(o);return l.localeCompare(c)})}function Jl(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 fg(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?Jl(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?Jl(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 ea(e,t){let n=dg(e),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=m=>{let w=(i.get(m)??[]).filter(b=>{let k=r.get(b);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(b))return!1;return!0}).concat(o.get(m)??[]);return w=w.filter(b=>r.has(b)),t.showInternals||(w=w.filter(b=>{let k=r.get(b);return!(k&&hg(k.kind))})),pg(w,r)},l=t.provFilter!==null||t.query.length>0,c=m=>!(t.provFilter!==null&&m.provenance!==t.provFilter||t.query.length>0&&!qe(m).toLowerCase().includes(t.query.toLowerCase())),u=new Set,h=m=>{let y=r.get(m),v=!1;for(let b of s(m))h(b)&&(v=!0);let w=c(y)||v;return w&&u.add(m),w};for(let m of a)h(m);let d=[],p=(m,y)=>{if(!u.has(m))return;let v=r.get(m),w=s(m),b=w.filter(_=>u.has(_)),k=l?b.length>0:t.expanded.has(m);if(d.push({id:m,depth:y,hasKids:w.length>0,expanded:k,label:qe(v),kind:v.kind,provenance:v.provenance,meta:fg(v)}),k)for(let _ of b)p(_,y+1)};for(let m of a)p(m,0);return d}function ta(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 or(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 gg=7;function na(e,t){if(e===null)return"";switch(e.kind){case"relTime":return or(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,gg);case"text":return e.text}}var mg=["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 ra(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 mg){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} → ${qe(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:`← ${qe(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:t,label:qe(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function ui(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 vg=["contains","anchored-at"];function yg(e){return vg.includes(e)}function di(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=wg(e,n),i=ec(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,bg(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(y=>l.get(y)===d),provenance:xg(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:kg(e.edges,o,l),clusters:c,hidden:u,representative:l,roots:i}}function wg(e,t){let n=new Map;for(let r of e.edges){if(!yg(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 bg(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 xg(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 kg(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 ia(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 Rn=[null,"human","agent","generated"];function tc(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function sa(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 en(e){return{...e.model,danglingLinks:e.dangling}}function nc(e,t){return e===null?[]:ea(en(e),t)}var An="vfolder:\0draft";function rc(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function ic(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function oc(e,t){if(t===null)return[...e];let n={id:An,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 la(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 Eg(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function ca(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function tn(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 pi(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 ac(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 ua(e){return e.type==="folder"}function sc(e,t,n){return ua(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function lc(e,t){return e.query===t?e:{...e,query:t}}function cc(e){let t=Rn.indexOf(e.provFilter),n=Rn[(t+1)%Rn.length]??null;return{...e,provFilter:n}}function uc(e){return{...e,showInternals:!e.showInternals}}function fi(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function aa(e,t){return e[t]?.id??null}function oa(e,t,n){if(e.length===0)return null;let r=fi(e,t),i=r===-1?n>0?-1:e.length:r;return aa(e,Math.min(e.length-1,Math.max(0,i+n)))}function Tg(e,t){let n=fi(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 Sg={j:"ArrowDown",k:"ArrowUp"};function Rg(e){return Sg[e]??e}function dc(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=Rg(r);if(s==="ArrowDown")return a(oa(e,n,1));if(s==="ArrowUp")return a(oa(e,n,-1));if(s==="Home")return a(aa(e,0));if(s==="End")return a(aa(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=fi(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(oa(e,n,1)):{state:_g(t,n),selectedId:n,handled:!0}:o;if(c.hasKids&&c.expanded)return{state:Eg(t,n),selectedId:n,handled:!0};let u=Tg(e,n);return u===null?o:a(u)}var Ag={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function nn(e){return Ag[e]}var Cg={human:"●",agent:"◐",generated:"○"};function rn(e){return e===null?"":Cg[e]}function Cn(e){return e===null?"":`${e}-authored`}function hc(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Lg(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 Ng(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:nn(e.kind),provenance:e.provenance,provenanceGlyph:rn(e.provenance),provenanceTitle:Cn(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:na(e.meta,n),level:e.depth+1}}function pc(e,t,n){let r=Lg(e);return e.map((i,o)=>Ng(i,t,n,r[o]))}function fc(e,t){return fi(e,t)===-1?null:hc(t)}function gc(e){return{"--weave-depth":String(Math.max(0,e))}}function hi(e){return e===null?"all":e}function mc(e){let t=Rn.indexOf(e),n=Rn[(t+1)%Rn.length]??null;return`provenance filter: ${hi(e)} — click for ${hi(n)}`}function vc(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 wc="filter…",bc="Vault and repository",xc="Filter the tree",kc="Filter the tree (/)";function _c(e,t,n){if(e===null)return"loading…";let r=ta(en(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 Ec(e){return e.length===1?"1 row":`${e.length} rows`}function Tc(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Sc(this.cover(t,n),t,n,e)}function Sc(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,y,v,w,b;if(!o)return e._root=a,e;for(;o.length;)if((y=t>=(h=(s+c)/2))?s=h:c=h,(v=n>=(d=(l+u)/2))?l=d:u=d,i=o,!(o=o[w=v<<1|y]))return i[w]=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[w]=a:e._root=a,e;do i=i?i[w]=new Array(4):e._root=new Array(4),(y=t>=(h=(s+c)/2))?s=h:c=h,(v=n>=(d=(l+u)/2))?l=d:u=d;while((w=v<<1|y)===(b=(m>=d)<<1|p>=h));return i[b]=o,i[w]=a,e}function Rc(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)Sc(this,a[n],s[n],e[n]);return this}function Ac(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 Cc(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Lc(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 Nc(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,y;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 v=(a+l)/2,w=(s+c)/2;d.push(new Se(p[3],v,w,l,c),new Se(p[2],a,w,v,c),new Se(p[1],v,s,l,w),new Se(p[0],a,s,v,w)),(y=(t>=w)<<1|e>=v)&&(m=d[d.length-1],d[d.length-1]=d[d.length-1-y],d[d.length-1-y]=m)}else{var b=e-+this._x.call(null,p.data),k=t-+this._y.call(null,p.data),_=b*b+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 Pc(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,y,v,w;if(!n)return this;if(n.length)for(;;){if((m=u>=(d=(a+l)/2))?a=d:l=d,(y=h>=(p=(s+c)/2))?s=p:c=p,t=n,!(n=n[v=y<<1|m]))return this;if(!n.length)break;(t[v+1&3]||t[v+2&3]||t[v+3&3])&&(r=t,w=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[w]=n:this._root=n),this):(this._root=o,this)}function Dc(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Ic(){return this._root}function Gc(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Mc(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 Oc(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 Fc(e){return e[0]}function $c(e){return arguments.length?(this._x=e,this):this._x}function zc(e){return e[1]}function Wc(e){return arguments.length?(this._y=e,this):this._y}function on(e,t,n){var r=new da(t??Fc,n??zc,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function da(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 Hc(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Ge=on.prototype=da.prototype;Ge.copy=function(){var e=new da(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=Hc(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]=Hc(r));return e};Ge.add=Tc;Ge.addAll=Rc;Ge.cover=Ac;Ge.data=Cc;Ge.extent=Lc;Ge.find=Nc;Ge.remove=Pc;Ge.removeAll=Dc;Ge.root=Ic;Ge.size=Gc;Ge.visit=Mc;Ge.visitAfter=Oc;Ge.x=$c;Ge.y=Wc;function ye(e){return function(){return e}}function at(e){return(e()-.5)*1e-6}function Pg(e){return e.x+e.vx}function Dg(e){return e.y+e.vy}function ha(e){var t,n,r,i=1,o=1;typeof e!="function"&&(e=ye(e==null?1:+e));function a(){for(var c,u=t.length,h,d,p,m,y,v,w=0;w<o;++w)for(h=on(t,Pg,Dg).visitAfter(s),c=0;c<u;++c)d=t[c],y=n[d.index],v=y*y,p=d.x+d.vx,m=d.y+d.vy,h.visit(b);function b(k,_,I,A,D){var O=k.data,U=k.r,T=y+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=at(r),Z+=F*F),K===0&&(K=at(r),Z+=K*K),Z=(T-(Z=Math.sqrt(Z)))/Z*i,d.vx+=(F*=Z)*(T=(U*=U)/(v+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:ye(+c),l(),a):e},a}function Ig(e){return e.index}function Uc(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function pa(e){var t=Ig,n=h,r,i=ye(30),o,a,s,l,c,u=1;e==null&&(e=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var w=0,b=e.length;w<u;++w)for(var k=0,_,I,A,D,O,U,T;k<b;++k)_=e[k],I=_.source,A=_.target,D=A.x+A.vx-I.x-I.vx||at(c),O=A.y+A.vy-I.y-I.vy||at(c),U=Math.sqrt(D*D+O*O),U=(U-o[k])/U*v*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 v,w=a.length,b=e.length,k=new Map(a.map((I,A)=>[t(I,A,a),I])),_;for(v=0,s=new Array(w);v<b;++v)_=e[v],_.index=v,typeof _.source!="object"&&(_.source=Uc(k,_.source)),typeof _.target!="object"&&(_.target=Uc(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)_=e[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(b),m(),o=new Array(b),y()}}function m(){if(a)for(var v=0,w=e.length;v<w;++v)r[v]=+n(e[v],v,e)}function y(){if(a)for(var v=0,w=e.length;v<w;++v)o[v]=+i(e[v],v,e)}return d.initialize=function(v,w){a=v,c=w,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?(u=+v,d):u},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ye(+v),m(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ye(+v),y(),d):i},d}var Gg={value:()=>{}};function Kc(){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 gi(n)}function gi(e){this._=e}function Mg(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}})}gi.prototype=Kc.prototype={constructor:gi,on:function(e,t){var n=this._,r=Mg(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=Og(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]=Bc(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Bc(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 gi(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 Og(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Bc(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Gg,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var fa=Kc;var Ln=0,sr=0,ar=0,jc=1e3,mi,lr,vi=0,an=0,yi=0,cr=typeof performance=="object"&&performance.now?performance:Date,qc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function va(){return an||(qc(Fg),an=cr.now()+yi)}function Fg(){an=0}function ga(){this._call=this._time=this._next=null}ga.prototype=wi.prototype={constructor:ga,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?va():+n)+(t==null?0:+t),!this._next&&lr!==this&&(lr?lr._next=this:mi=this,lr=this),this._call=e,this._time=n,ma()},stop:function(){this._call&&(this._call=null,this._time=1/0,ma())}};function wi(e,t,n){var r=new ga;return r.restart(e,t,n),r}function Yc(){va(),++Ln;for(var e=mi,t;e;)(t=an-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ln}function Vc(){an=(vi=cr.now())+yi,Ln=sr=0;try{Yc()}finally{Ln=0,zg(),an=0}}function $g(){var e=cr.now(),t=e-vi;t>jc&&(yi-=t,vi=e)}function zg(){for(var e,t=mi,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:mi=n);lr=e,ma(r)}function ma(e){if(!Ln){sr&&(sr=clearTimeout(sr));var t=e-an;t>24?(e<1/0&&(sr=setTimeout(Vc,e-cr.now()-yi)),ar&&(ar=clearInterval(ar))):(ar||(vi=cr.now(),ar=setInterval($g,jc)),Ln=1,qc(Vc))}}function Xc(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Zc(e){return e.x}function Qc(e){return e.y}var Wg=10,Hg=Math.PI*(3-Math.sqrt(5));function ya(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=wi(h),c=fa("tick","end"),u=Xc();e==null&&(e=[]);function h(){d(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function d(y){var v,w=e.length,b;y===void 0&&(y=1);for(var k=0;k<y;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<w;++v)b=e[v],b.fx==null?b.x+=b.vx*=a:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=a:(b.y=b.fy,b.vy=0);return t}function p(){for(var y=0,v=e.length,w;y<v;++y){if(w=e[y],w.index=y,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var b=Wg*Math.sqrt(.5+y),k=y*Hg;w.x=b*Math.cos(k),w.y=b*Math.sin(k)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function m(y){return y.initialize&&y.initialize(e,u),y}return p(),t={tick:d,restart:function(){return l.restart(h),t},stop:function(){return l.stop(),t},nodes:function(y){return arguments.length?(e=y,p(),s.forEach(m),t):e},alpha:function(y){return arguments.length?(n=+y,t):n},alphaMin:function(y){return arguments.length?(r=+y,t):r},alphaDecay:function(y){return arguments.length?(i=+y,t):+i},alphaTarget:function(y){return arguments.length?(o=+y,t):o},velocityDecay:function(y){return arguments.length?(a=1-y,t):1-a},randomSource:function(y){return arguments.length?(u=y,s.forEach(m),t):u},force:function(y,v){return arguments.length>1?(v==null?s.delete(y):s.set(y,m(v)),t):s.get(y)},find:function(y,v,w){var b=0,k=e.length,_,I,A,D,O;for(w==null?w=1/0:w*=w,b=0;b<k;++b)D=e[b],_=y-D.x,I=v-D.y,A=_*_+I*I,A<w&&(O=D,w=A);return O},on:function(y,v){return arguments.length>1?(c.on(y,v),t):c.on(y)}}}function wa(){var e,t,n,r,i=ye(-30),o,a=1,s=1/0,l=.81;function c(p){var m,y=e.length,v=on(e,Zc,Qc).visitAfter(h);for(r=p,m=0;m<y;++m)t=e[m],v.visit(d)}function u(){if(e){var p,m=e.length,y;for(o=new Array(m),p=0;p<m;++p)y=e[p],o[y.index]=+i(y,p,e)}}function h(p){var m=0,y,v,w=0,b,k,_;if(p.length){for(b=k=_=0;_<4;++_)(y=p[_])&&(v=Math.abs(y.value))&&(m+=y.value,w+=v,b+=v*y.x,k+=v*y.y);p.x=b/w,p.y=k/w}else{y=p,y.x=y.data.x,y.y=y.data.y;do m+=o[y.data.index];while(y=y.next)}p.value=m}function d(p,m,y,v){if(!p.value)return!0;var w=p.x-t.x,b=p.y-t.y,k=v-m,_=w*w+b*b;if(k*k/l<_)return _<s&&(w===0&&(w=at(n),_+=w*w),b===0&&(b=at(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)),t.vx+=w*p.value*r/_,t.vy+=b*p.value*r/_),!0;if(p.length||_>=s)return;(p.data!==t||p.next)&&(w===0&&(w=at(n),_+=w*w),b===0&&(b=at(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)));do p.data!==t&&(k=o[p.data.index]*r/_,t.vx+=w*k,t.vy+=b*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:ye(+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 ba(e){var t=ye(.1),n,r,i;typeof e!="function"&&(e=ye(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:ye(+s),a(),o):t},o.x=function(s){return arguments.length?(e=typeof s=="function"?s:ye(+s),a(),o):e},o}function xa(e){var t=ye(.1),n,r,i;typeof e!="function"&&(e=ye(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:ye(+s),a(),o):t},o.y=function(s){return arguments.length?(e=typeof s=="function"?s:ye(+s),a(),o):e},o}var Ug=9,bi=6,xi=18,Bg=32,tu=9,ur=Ug+tu;function ka(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+Bg));return bi+(xi-bi)*n}function _a(e){return e+tu}var Kg=300,nu=1,Jc=.001;function eu(e){return e==="contains"||e==="anchored-at"}function Vg(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function jg(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 Ea(e){let t=pa(e.links).id(n=>n.id).distance(n=>eu(n.kind)?He.containsRest:He.relationDistance).strength(n=>eu(n.kind)?He.containsStrength:He.relationStrength).iterations(2);return ya(e.nodes).randomSource(Vg(e.seed??nu)).force("charge",wa().strength(He.charge).distanceMax(He.chargeMax)).force("link",t).force("collide",ha(n=>n.r??ur).strength(1)).force("x",ba(0).strength(He.center)).force("y",xa(0).strength(He.center)).stop()}function qg(e,t,n){let r=Ea({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(Jc).alphaDecay(n.ticks>0?1-Math.pow(Jc,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function ru(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??Kg)),{ids:r,edges:i}=jg(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=_a(ka(a.get(l.id)??0));o.length>1&&qg(o,i,{ticks:n,seed:t.seed??nu,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 Yg=Object.fromEntries(Object.entries(ce).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 $t(e){let t=Yg[ni(e)];return typeof e=="string"?t:{...t,accent:Ll(e.theme,e.accent)}}var Xg={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 Qg(e,t){return $t(t)[Xg[e]]}function iu(e,t){return $t(t)[Zg[e]]}function Jg(e,t){return em(e)?Sa(iu(e,t),t,tm):iu(e,t)}function em(e){return e==="contains"||e==="anchored-at"}var Ta=.85,tm=.3;function dr(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 Sa(e,t,n=Ta){return dr(e,$t(t).ground,n)}var nm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},ou=1.6,su=32,rm=su/2;function im(e,t=su){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>=rm?i:n;return`${e.slice(0,o).trimEnd()}…`}function om(e){let t=rn(e.provenance),n=qe(e);return im(t===""?n:`${t} ${n}`)}var am=6,sm=6;function lm(e){return(t,n,r)=>{if(n.label===null||n.label==="")return;let i=$t(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=sm,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+am),t.restore()}}function lu(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,(ur*4-Math.max(r-t,i-n))/2);return{x:[t-a,r+a],y:[n-a,i+a]}}var cu={nodes:[],edges:[]};function uu(e){return`${e.source}\0${e.target}\0${e.kind}`}function cm(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=uu(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 du(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=cm(t,a),l=[];for(let[h,d]of o){let p=n.get(h),m=ka(s.get(h)??0);l.push({id:h,x:p.x,y:p.y,size:m,label:om(d),color:i?.get(h)??Qg(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=uu(h);u.has(d)||(u.add(d),c.push({key:d,source:h.source,target:h.target,size:nm[h.kind],color:Jg(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function hu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:r===t&&e.has(r)?{zIndex:i.zIndex+au*2,size:i.size*ki(pm,n)}:e.has(r)?{zIndex:i.zIndex+au,size:i.size*ki(fm,n)}:{color:Sa(i.color,o,Ta*n),label:n>=hm?null:i.label,zIndex:0}}var um=60,dm=.004;function pu(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/um);return Math.abs(t-i)<dm?t:i}function ki(e,t){return 1+(e-1)*t}var hm=.5,pm=1.45,fm=1.15,au=xi+1;function fu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:!e.has(i.source)||!e.has(i.target)?{color:Sa(i.color,o,Ta*n)}:t!=null&&(i.source===t||i.target===t)?{zIndex:2,size:i.size*ki(ou*1.35,n),color:dr(i.color,$t(o).accent,n)}:{zIndex:1,size:i.size*ki(ou,n)}}var gm=(bi+xi)/2,mm=ur*4,vm=1;function gu(e){let t=$t(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:vm,labelGridCellSize:mm,labelRenderedSizeThreshold:gm,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:ur,defaultDrawNodeHover:lm(e),allowInvalidContainer:!0}}function mu(e){return e==="contains"||e==="anchored-at"}function ym(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)mu(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 wm(e,t){let n=ym(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 bm(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var xm={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},km=3;function _m(e,t){let n=xm[ce[ni(t)].scheme],i=[...bm(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*km%n.length])),o}var Em=.11,Tm=.34;function Sm(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return dr(e,$t(n).ground,Math.min(Tm,r*Em))}var Rm=.26,Am=.55;function Cm(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let o of t){let a=Math.min(Rm,Am-i);if(a<=0)break;i+=a,r=dr(r,o,a)}return r}function vu(e,t,n){let r=wm(e,t),i=new Map;for(let[u,h]of r)i.set(u,h.key);let o=_m(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)mu(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=Sm(d,h.depth,n),m=[...s.get(u.id)??[]].sort().map(y=>o.get(y)).filter(y=>y!==void 0);c.set(u.id,Cm(p,m,n))}return c}function Ra(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 Lm=300,Nm=1;function Pm(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:Lm,seed:Nm,pinWarm:!0};return r.size>0&&(i.initial=r),ru({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function Dm(e,t){let n=0,r=0;for(let o of e){let a=Ra(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=Ra(`${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)),Ra(JSON.stringify(He)).toString(16)].join("-")}var wu="pi-weave.graph.positions.v4";function yu(e){return Math.round(e*10)/10}function Im(e,t){let n={};for(let[r,i]of t)n[r]=[yu(i.x),yu(i.y)];return JSON.stringify({v:4,key:e,at:n})}function Gm(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 Mm(e,t){let n;try{n=e.getItem(wu)}catch{return null}return Gm(n,t)}function Om(e,t,n){try{return e.setItem(wu,Im(t,n)),!0}catch{return!1}}function bu(e,t,n){let r=Dm(t,n),i=Mm(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Pm(t,n);return Om(e,r,o),{key:r,positions:o,cached:!1}}function ku(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:nn(n.kind)}}function Fm(e){return{expanded:new Set(di(e,new Set).clusters.keys())}}function _u(e,t){return t!==null?t:e===null?{expanded:new Set}:Fm(en(e))}function $m(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function zm(e,t){return t===null?null:ui(t,e)}function Eu(e,t,n){return t===null?n:ui(t,e)}var Tu="fit",Su="frame the whole graph",_i={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Ru(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function Wm(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 Hm="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",xu={graph:cu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Au(e,t,n,r,i,o=!1,a=!0){if(e===null)return o?{...xu,empty:Hm}:xu;let s=en(e),l=di(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(p=>p.source!=="vault"&&p.target!=="vault"):l.edges,h=bu(r,l.nodes,u),d=a?vu(l.nodes,u,i):void 0;return{graph:du(l.nodes,u,h.positions,i,d),highlight:zm(u,t),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Wm(e,l.nodes.length)}}function Cu(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:$m(e,n),selectedId:n}}var Lu="(prefers-color-scheme: light)";function hr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Lu).matches?"light":"dark"}function Nu(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Lu);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,Bm=.2,Aa=.001,Pu=.5;function Du(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:_a(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=Ea({nodes:n,links:o,seed:1}).alpha(Um).alphaMin(Aa);return{tick(){a.tick()},awake(){return a.alphaTarget()>Aa||a.alpha()>Aa},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)<Pu&&Math.abs(c.fy-l.y)<Pu;c.fx=l.x,c.fy=l.y,a.alphaTarget(u?0:Bm)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}var pr="application/x-weave-note";function Iu(e,t){return t.startsWith("note:")&&e?.model.nodes.some(n=>n.id===t&&n.kind==="note")?t:null}function Ca(e,t){return t===null?e:[t,...e.filter(n=>n!==t)].slice(0,100)}function Gu(e,t){return t!==null&&t===e}function Mu(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:nn(o),selected:r===n}})}var Ou={title:"Context"},Km="—";function Fu(e,t){return{cwd:e===""?Km:e,selection:t??"nothing selected"}}var $u=6e4;function Ei(e){return e?"⌘K":"Ctrl K"}function zu(e){return`Search notes and repository (${e})`}function Ti(e){return/mac|iphone|ipad/i.test(e)}var Vm={k:{type:"openSearch"},",":{type:"openSettings"}},Wu={1:"tree",2:"note",3:"graph"};function jm(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function qm(e){return!e.ctrl&&!e.meta&&!e.alt}var Ym={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"}};function Hu(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(jm(e)){let n=Vm[e.key.toLowerCase()];if(n!==void 0)return n;let r=Wu[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection?{type:"clearSelection"}:null:!qm(e)||e.typing?null:Ym[e.key]??null}var Xm=["INPUT","TEXTAREA","SELECT"];function La(e,t){return t?!0:e!==null&&Xm.includes(e.toUpperCase())}function Uu(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:La(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"},Na=".weave-sidebar-notes .weave-filter";function Zm(e){let t=e;return typeof t?.focus=="function"?t:null}function Si(e,t){let n=Zm(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function Bu(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(Na);case"fitGraph":return t.fitGraph();case"clearSelection":return t.clearSelection();case"closeTab":return t.closeTab();case"toggleTheme":return t.toggleTheme()}}function Ri(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(Wu).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 Pa="Keyboard shortcuts",Ku="esc close";var Vu={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 Qm=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:--Qm,__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=Vu[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 ev({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let c=ca(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:gc(e.depth),onClick:u=>o(u.metaKey||u.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===An?"New folder":void 0,onDragStart:u=>{u.dataTransfer?.setData("text/plain",e.id),u.dataTransfer?.setData(pr,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(tv,{value:n,draft:e.id===An,onEdit:r,onCommit:i}),f("span",{class:"weave-meta",children:e.meta})]})}function tv({value:e,draft:t,onEdit:n,onCommit:r}){let i=Q(null);return je(()=>{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 ju(e){let[t,n]=j(tc),[r,i]=j(null),o=Q(null);je(()=>{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=oc(nc(e.graph,t),c),d=_c(e.graph,h,t),p=async(w,b)=>{let k=await w;if(!k.ok)window.alert(k.message);else{let _=k.data.id??b;_!==void 0&&e.onSelect(_),e.onRefresh()}},m=async w=>{if(r===null)return;let b=tn(r.id);if(i(null),b!==null){if(w==="newFolder"){let k=rc(b);n(_=>sa(_,k)),u(k),l({id:An,label:"",value:""})}else if(w==="rename")n(k=>sa(k,b.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(b.type!=="vault"){if(!e.onMutate(pi(e.graph,b)))return;await p(b.type==="note"?ql(Ae,b.path):Zl(Ae,b.path),ac(e.selectedId,b)?"vault":void 0)}}},y=w=>{if(r!==null){if(ua(w)&&r.armed!==!0){i({...r,armed:!0});return}m("delete")}},v=w=>{let b=s,k=c;if(l(null),u(null),b===null)return;let _=w?.trim();if(b.id===An){let A=k===null||!_?null:ic(k,_);A!==null&&p(Yl(Ae,A));return}let I=tn(b.id);if(I!==null&&_&&_!==b.label){if(!e.onMutate(pi(e.graph,I)))return;p(I.type==="note"?Vl(Ae,I.path,_):Xl(Ae,I.path,_))}};return f("div",{class:"weave-tree",ref:o,onKeyDown:w=>{if(r!==null&&w.key==="Escape"){w.preventDefault(),w.stopPropagation(),a();return}let b=w.target,k=dc(h,t,e.selectedId,w.key,La(b?.tagName??null,b?.isContentEditable===!0));k.handled&&(w.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:wc,"aria-label":xc,title:kc,onInput:w=>n(lc(t,w.currentTarget.value))}),f("button",{type:"button",class:"weave-chip",title:mc(t.provFilter),onClick:()=>n(cc(t)),children:["◧ ",hi(t.provFilter)]}),f("button",{type:"button",class:"weave-chip",title:yc(t.showInternals),onClick:()=>n(uc(t)),children:["◧ ",vc(t.showInternals)]}),f("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:w=>{let b=e.selectedId!==null&&tn(e.selectedId)!==null?e.selectedId:"vault",k=w.currentTarget.getBoundingClientRect();i({id:b,label:e.graph?.model.nodes.find(_=>_.id===b)?.label??"Vault",x:k.left,y:k.bottom})},children:"···"})]}),d===null?f("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":bc,"aria-activedescendant":fc(h,e.selectedId)??void 0,onContextMenu:w=>{w.preventDefault(),i({id:"vault",label:"Vault",x:w.clientX,y:w.clientY})},children:pc(h,e.selectedId,e.now).map(w=>f(ev,{view:w,recentIds:e.recentIds,edit:s?.id===w.id?s.value:null,onEdit:b=>l(k=>k===null?null:{...k,value:b}),onRename:v,onSelect:b=>{e.onSelect(w.id,b),w.hasKids&&n(k=>la(k,w.id))},onToggle:()=>n(la(t,w.id)),onMenu:(b,k)=>i({id:w.id,label:w.label,x:b,y:k}),onDrop:b=>{let k=ca(w.id);if(b.startsWith("note:")&&k!==void 0){let _=tn(b);if(_!==null&&!e.onMutate(pi(e.graph,_)))return;p(jl(Ae,b.slice(5),k))}}},w.id))}):f("p",{class:"weave-tree-empty",children:d}),f("p",{class:"weave-tree-count",children:Ec(h)}),r!==null&&tn(r.id)!==null?(()=>{let w=tn(r.id);return f(he,{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:b=>{if(b.key==="Escape")b.preventDefault(),a();else if(["ArrowDown","ArrowUp","Home","End"].includes(b.key)){b.preventDefault();let k=[...b.currentTarget.querySelectorAll("button")],_=k.indexOf(document.activeElement),I=b.key==="Home"?0:b.key==="End"?k.length-1:(_+(b.key==="ArrowDown"?1:-1)+k.length)%k.length;k[I]?.focus()}b.stopPropagation()},children:[f("button",{type:"button",role:"menuitem",onClick:()=>{m("newFolder")},children:"New folder…"}),w.type!=="vault"?f(he,{children:[f("button",{type:"button",role:"menuitem",onClick:()=>{m("rename")},children:"Rename…"}),f("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>y(w),children:sc(w,r.label,r.armed===!0)})]}):null]})]})})():null]})}function qu(e){let t=Q(null),n=Q(null),r=Q(null),i=Q(null),o=El(()=>{if(i.current!==null)return;let y=()=>{i.current=null;let v=r.current;v!==null&&(v.tick(),v.awake()&&(n.current?.setPositions(v.positions()),i.current=requestAnimationFrame(y)))};i.current=requestAnimationFrame(y)},[]),[a,s]=j(null),l=ft(()=>(Fo(e.forces),JSON.stringify(e.forces)),[e.forces]),c=e.groupColors,u=e.scheme??hr(e.host),h=_u(e.graph,a),d=ft(()=>Au(e.graph,e.selectedId,h,e.storage,u,e.bootFailed,c),[e.graph,e.selectedId,h,e.storage,u,e.bootFailed,l,c]),p=ku(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 y=e.renderer(u);return y.onSelect(v=>{let w=Cu(m.current.view,m.current.model.clusters,v);s(w.state),m.current.onSelect(w.selectedId)}),y.onHover(v=>{let{model:w,selectedId:b}=m.current;y.setHighlight(Eu(w.graph.edges,v,w.highlight),v??b)}),y.onDragStart(v=>{let w=n.current?.positions().get(v);w&&(r.current?.pin(v,w),o())}),y.onDragMove((v,w)=>{r.current?.pin(v,w)}),y.onDragEnd(v=>{r.current?.release(v)}),y.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=y,y.setGraph(m.current.model.graph),y.setHighlight(m.current.model.highlight,m.current.selectedId),e.fit.current=()=>y.fit(),()=>{y.destroy(),n.current=null,e.fit.current=null}},[e.renderer,u]),le(()=>{n.current?.setGraph(d.graph)},[d.key,l,c]),le(()=>{let y=Du(d.graph,n.current?.positions());return r.current=y,y!==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:Su,onClick:()=>n.current?.fit(),children:Tu}),f("span",{class:"weave-graph-legend",children:[f("span",{class:"weave-legend-on",children:["◉ ",_i.selected]}),f("span",{class:"weave-legend-near",children:["● ",_i.neighborhood]}),f("span",{class:"weave-legend-dim",children:["· ",_i.dimmed]})]})]}),f("p",{class:"weave-graph-count",children:Ru(d.visible,d.total)})]})}function nv(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=nv(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 Yu(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&&Yu(e.prototype,t),n&&Yu(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 Xu(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xu=function(){return!!e})()}function rv(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function iv(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 rv(e)}function Me(e,t,n){return t=sn(t),iv(e,Xu()?Reflect.construct(t,n||[],sn(e).constructor):t.apply(e,n))}function Da(e,t){return Da=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Da(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&&Da(e,t)}function ov(e){if(Array.isArray(e))return e}function av(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 Ci(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 Oa(e,t){if(e){if(typeof e=="string")return Ci(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)?Ci(e,t):void 0}}function sv(){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 zt(e,t){return ov(e)||av(e,t)||Oa(e,t)||sv()}var Ia={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 Zu=new Int8Array(4),Ga=new Int32Array(Zu.buffer,0,1),lv=new Float32Array(Zu.buffer,0,1),cv=/^\s*rgba?\s*\(/,uv=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function dv(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(cv.test(e)){var o=e.match(uv);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(fr in Ia)Pn[fr]=Dn(Ia[fr]),Pn[Ia[fr]]=Pn[fr];var fr;function Qu(e,t,n,r,i){return Ga[0]=r<<24|n<<16|t<<8|e,i&&(Ga[0]=Ga[0]&4278190079),lv[0]}function Dn(e){if(e=e.toLowerCase(),typeof Pn[e]<"u")return Pn[e];var t=dv(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var a=Qu(n,r,i,o,!0);return Pn[e]=a,a}var Ma={};function Fa(e){if(typeof Ma[e]<"u")return Ma[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Qu(t,n,r,i,!0);return Ma[e]=o,o}function $a(e,t,n,r){return n+(t<<8)+(e<<16)}function za(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=zt(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 Ju(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?Ju(Object(n),!0).forEach(function(r){R(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ju(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function hv(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=sn(e))!==null;);return e}function Ua(){return Ua=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=hv(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},Ua.apply(null,arguments)}function ad(e,t,n,r){var i=Ua(sn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function pv(e){return e.normalized?1:e.size}function Wa(e){var t=0;return e.forEach(function(n){return t+=pv(n)}),t}function sd(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 $f=Object.create;var Zs=Object.defineProperty;var zf=Object.getOwnPropertyDescriptor;var Wf=Object.getOwnPropertyNames;var Hf=Object.getPrototypeOf,Uf=Object.prototype.hasOwnProperty;var Qs=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Bf=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Wf(t))!Uf.call(e,i)&&i!==n&&Zs(e,i,{get:()=>t[i],enumerable:!(r=zf(t,i))||r.enumerable});return e};var ir=(e,t,n)=>(n=e!=null?$f(Hf(e)):{},Bf(t||!e||!e.__esModule?Zs(n,"default",{value:e,enumerable:!0}):n,e));var zi=Qs((Q0,Xa)=>{"use strict";var $n=typeof Reflect=="object"?Reflect:null,kd=$n&&typeof $n.apply=="function"?$n.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},Fi;$n&&typeof $n.ownKeys=="function"?Fi=$n.ownKeys:Object.getOwnPropertySymbols?Fi=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Fi=function(t){return Object.getOwnPropertyNames(t)};function zv(e){console&&console.warn&&console.warn(e)}var Ed=Number.isNaN||function(t){return t!==t};function re(){re.init.call(this)}Xa.exports=re;Xa.exports.once=Bv;re.EventEmitter=re;re.prototype._events=void 0;re.prototype._eventsCount=0;re.prototype._maxListeners=void 0;var _d=10;function $i(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(re,"defaultMaxListeners",{enumerable:!0,get:function(){return _d},set:function(e){if(typeof e!="number"||e<0||Ed(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");_d=e}});re.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};re.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Ed(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 Td(e){return e._maxListeners===void 0?re.defaultMaxListeners:e._maxListeners}re.prototype.getMaxListeners=function(){return Td(this)};re.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")kd(l,this,n);else for(var c=l.length,u=Ld(l,c),r=0;r<c;++r)kd(u[r],this,n);return!0};function Sd(e,t,n,r){var i,o,a;if($i(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=Td(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,zv(s)}return e}re.prototype.addListener=function(t,n){return Sd(this,t,n,!1)};re.prototype.on=re.prototype.addListener;re.prototype.prependListener=function(t,n){return Sd(this,t,n,!0)};function Wv(){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 Rd(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=Wv.bind(r);return i.listener=n,r.wrapFn=i,i}re.prototype.once=function(t,n){return $i(n),this.on(t,Rd(this,t,n)),this};re.prototype.prependOnceListener=function(t,n){return $i(n),this.prependListener(t,Rd(this,t,n)),this};re.prototype.removeListener=function(t,n){var r,i,o,a,s;if($i(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():Hv(r,o),r.length===1&&(i[t]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",t,s||n)}return this};re.prototype.off=re.prototype.removeListener;re.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 Ad(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):Ld(i,i.length)}re.prototype.listeners=function(t){return Ad(this,t,!0)};re.prototype.rawListeners=function(t){return Ad(this,t,!1)};re.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Cd.call(e,t)};re.prototype.listenerCount=Cd;function Cd(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}re.prototype.eventNames=function(){return this._eventsCount>0?Fi(this._events):[]};function Ld(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function Hv(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 Bv(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))}Nd(e,t,o,{once:!0}),t!=="error"&&Kv(e,i,{once:!0})})}function Kv(e,t,n){typeof e.on=="function"&&Nd(e,"error",t,n)}function Nd(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 Za=Qs((tE,Dd)=>{"use strict";Dd.exports=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}});var oi,ne,rl,Kf,$t,Js,il,ol,No,Jr,or,al,Io,Po,Do,Vf,ni={},ri=[],jf=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ai=Array.isArray;function St(e,t){for(var n in t)e[n]=t[n];return e}function Go(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qf(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?oi.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 ei(e,a,r,i,null)}function ei(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??++rl,__i:-1,__u:0};return i==null&&ne.vnode!=null&&ne.vnode(o),o}function pe(e){return e.children}function ti(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 Yf(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=St({},t);o.__v=t.__v+1,ne.vnode&&ne.vnode(o),Mo(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,dl(r,o,i),t.__e=t.__=null,o.__e!=n&&sl(o)}}function sl(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}),sl(e)}function el(e){(!e.__d&&(e.__d=!0)&&$t.push(e)&&!ii.__r++||Js!=ne.debounceRendering)&&((Js=ne.debounceRendering)||il)(ii)}function ii(){try{for(var e,t=1;$t.length;)$t.length>t&&$t.sort(ol),e=$t.shift(),t=$t.length,Yf(e)}finally{$t.length=ii.__r=0}}function ll(e,t,n,r,i,o,a,s,l,c,u){var h,d,p,m,w,v,y=r&&r.__k||ri,b=t.length;for(l=Xf(n,t,y,l,b),h=0;h<b;h++)(p=n.__k[h])!=null&&(d=p.__i!=-1&&y[p.__i]||ni,p.__i=h,v=Mo(e,p,d,i,o,a,s,l,c,u),m=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&Oo(d.ref,null,p),u.push(p.ref,p.__c||m,p)),w==null&&m!=null&&(w=m),4&p.__u?(l=cl(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 Xf(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]=ei(null,a,null,null,null):ai(a)?a=e.__k[o]=ei(pe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[o]=ei(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=Zf(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)),pl(s,s));return r}function cl(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=cl(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 Zf(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 tl(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||jf.test(t)?n:n+"px"}function Qr(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||tl(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||tl(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(al,"$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[or]=r[or]:(n[or]=Io,e.addEventListener(t,o?Do:Po,o)):e.removeEventListener(t,o?Do:Po,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 nl(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Jr]==null)t[Jr]=Io++;else if(t[Jr]<n[or])return;return n(ne.event?ne.event(t):t)}}}function Mo(e,t,n,r,i,o,a,s,l,c){var u,h,d,p,m,w,v,y,b,k,E,I,A,D,O,W,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=t.__e=n.__e]),(u=ne.__b)&&u(t);e:if(typeof T=="function"){h=a.length;try{if(b=t.props,k=T.prototype&&T.prototype.render,E=(u=T.contextType)&&r[u.__c],I=u?E?E.props.value:u.__:r,n.__c?y=(d=t.__c=n.__c).__=d.__E:(k?t.__c=d=new T(b,I):(t.__c=d=new ti(b,I),d.constructor=T,d.render=Jf),E&&E.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=St({},d.__s)),St(d.__s,T.getDerivedStateFromProps(b,d.__s))),m=d.props,w=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&&b!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,I),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,I)===!1){t.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(F){F&&(F.__=t)}),ri.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=Qt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,I),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,w,v)})}if(d.context=I,d.props=b,d.__P=e,d.__e=!1,A=ne.__r,D=0,k)d.state=d.__s,d.__d=!1,A&&A(t),u=d.render(d.props,d.state,d.context),ri.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=St(St({},r),d.getChildContext())),k&&!p&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(m,w)),O=u!=null&&u.type===pe&&u.key==null?hl(u.props.children):u,s=ll(e,ai(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),y&&(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(W=o.length;W--;)Go(o[W])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),F.then||ul(t),ne.__e(F,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Qf(n.__e,t,n,r,i,o,a,l,c);return(u=ne.diffed)&&u(t),128&t.__u?void 0:s}function ul(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ul))}function dl(e,t,n){for(var r=0;r<n.length;r++)Oo(n[r],n[++r],n[++r]);ne.__c&&ne.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){ne.__e(o,i.__v)}})}function hl(e){return typeof e!="object"||e==null||e.__b>0?e:ai(e)?e.map(hl):e.constructor!==void 0?null:St({},e)}function Qf(e,t,n,r,i,o,a,s,l){var c,u,h,d,p,m,w,v=n.props||ni,y=t.props,b=t.type;if(b=="svg"?i="http://www.w3.org/2000/svg":b=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(c=0;c<o.length;c++)if((p=o[c])&&"setAttribute"in p==!!b&&(b?p.localName==b:p.nodeType==3)){e=p,o[c]=null;break}}if(e==null){if(b==null)return document.createTextNode(y);e=document.createElementNS(i,b,y.is&&y),s&&(ne.__m&&ne.__m(t,o),s=!1),o=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(o=b=="textarea"&&y.defaultValue!=null?null:o&&oi.call(e.childNodes),!s&&o!=null)for(v={},c=0;c<e.attributes.length;c++)v[(p=e.attributes[c]).name]=p.value;for(c in v)p=v[c],c=="dangerouslySetInnerHTML"?h=p:c=="children"||c in y||c=="value"&&"defaultValue"in y||c=="checked"&&"defaultChecked"in y||Qr(e,c,null,p,i);for(c in y)p=y[c],c=="children"?d=p:c=="dangerouslySetInnerHTML"?u=p:c=="value"?m=p:c=="checked"?w=p:s&&typeof p!="function"||v[c]===p||Qr(e,c,p,v[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=""),ll(t.type=="template"?e.content:e,ai(d)?d:[d],t,n,r,b=="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--;)Go(o[c]);s&&b!="textarea"||(c="value",b=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[c]||b=="progress"&&!m||b=="option"&&m!=v[c])&&Qr(e,c,m,v[c],i),c="checked",w!=null&&w!=e[c]&&Qr(e,c,w,v[c],i))}return e}function Oo(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){ne.__e(i,n)}}function pl(e,t,n){var r,i;if(ne.unmount&&ne.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Oo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){ne.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&pl(r[i],t,n||typeof e.type!="function");n||Go(e.__e),e.__c=e.__=e.__e=void 0}function Jf(e,t,n){return this.constructor(e,n)}function fl(e,t,n){var r,i,o,a;t==document&&(t=document.documentElement),ne.__&&ne.__(e,t),i=(r=typeof n=="function")?null:n&&n.__k||t.__k,o=[],a=[],Mo(t,e=(!r&&n||t).__k=qf(pe,null,[e]),i||ni,ni,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?oi.call(t.childNodes):null,o,!r&&n?n:i?i.__e:t.firstChild,r,a),dl(o,e,a),e.props.children=null}oi=ri.slice,ne={__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}},rl=0,Kf=function(e){return e!=null&&e.constructor===void 0},ti.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=St({},this.state),typeof e=="function"&&(e=e(St({},n),this.props)),e&&St(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),el(this))},ti.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),el(this))},ti.prototype.render=pe,$t=[],il=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ol=function(e,t){return e.__v.__b-t.__v.__b},ii.__r=0,No=Math.random().toString(8),Jr="__d"+No,or="__a"+No,al=/(PointerCapture)$|Capture$/i,Io=0,Po=nl(!1),Do=nl(!0),Vf=0;var gl="weave-bootstrap";var Fo={cwd:""};function eg(e){return typeof e!="object"||e===null?!1:typeof e.cwd=="string"}function ml(e){if(e===null||e.trim()==="")return Fo;let t;try{t=JSON.parse(e)}catch{return Fo}return eg(t)?t:Fo}var Jt,he,$o,vl,ar=0,Tl=[],ge=ne,wl=ge.__b,yl=ge.__r,bl=ge.diffed,xl=ge.__c,kl=ge.unmount,_l=ge.__;function sr(e,t){ge.__h&&ge.__h(he,e,ar||t),ar=0;var n=he.__H||(he.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function q(e){return ar=1,tg(Al,e)}function tg(e,t,n){var r=sr(Jt++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Al(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 oe(e,t){var n=sr(Jt++,3);!ge.__s&&Wo(n.__H,t)&&(n.__=e,n.u=t,he.__H.__h.push(n))}function Qe(e,t){var n=sr(Jt++,4);!ge.__s&&Wo(n.__H,t)&&(n.__=e,n.u=t,he.__h.push(n))}function Y(e){return ar=5,vt(function(){return{current:e}},[])}function vt(e,t){var n=sr(Jt++,7);return Wo(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Sl(e,t){return ar=8,vt(function(){return e},t)}function Rl(){var e=sr(Jt++,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 ng(){for(var e;e=Tl.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(si),t.__h.some(zo),t.__h=[]}catch(n){t.__h=[],ge.__e(n,e.__v)}}}ge.__b=function(e){he=null,wl&&wl(e)},ge.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),_l&&_l(e,t)},ge.__r=function(e){yl&&yl(e),Jt=0;var t=(he=e.__c).__H;t&&($o===he?(t.__h=[],he.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(si),t.__h.some(zo),t.__h=[],Jt=0)),$o=he},ge.diffed=function(e){bl&&bl(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Tl.push(t)!==1&&vl===ge.requestAnimationFrame||((vl=ge.requestAnimationFrame)||rg)(ng)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),$o=he=null},ge.__c=function(e,t){t.some(function(n){try{n.__h.some(si),n.__h=n.__h.filter(function(r){return!r.__||zo(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],ge.__e(r,n.__v)}}),xl&&xl(e,t)},ge.unmount=function(e){kl&&kl(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{si(r)}catch(i){t=i}}),n.__H=void 0,t&&ge.__e(t,n.__v))};var El=typeof requestAnimationFrame=="function";function rg(e){var t,n=function(){clearTimeout(r),El&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);El&&(t=requestAnimationFrame(n))}function si(e){var t=he,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),he=t}function zo(e){var t=he;e.__c=e.__(),he=t}function Wo(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function Al(e,t){return typeof t=="function"?t(e):t}var Cl={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"},Ll={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:Cl},"latte-blue":{name:"Catppuccin Latte · Blue",scheme:"light",colors:{...Cl,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:Ll},"macchiato-peach":{name:"Catppuccin Macchiato · Peach",scheme:"dark",colors:{...Ll,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"}}},Nl=["system",...Object.keys(ue)];function Rn(e){return typeof e=="string"&&Nl.includes(e)}var en={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 li(e){return typeof e=="string"?e:e.theme}function Pl(e,t){return t==="theme"?ue[e].colors.accent:en[t][ue[e].scheme]}var Ve={containsRest:55,containsStrength:.12,relationDistance:50,relationStrength:.07,charge:-200,chargeMax:800,center:.05},zt={...Ve};function Ho(e){Object.assign(Ve,e)}var An=[{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}],Wt={lightTheme:"light",darkTheme:"dark",accent:"theme",fontSize:14,readable:!0,spellcheck:!0,defaultEdit:!1,startup:"restore",focusNewTabs:!0,groupColors:!0,forces:{...zt}};function Dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Il(e){if(!Dl(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(Wt).length)return null;for(let i of["light","dark"]){let o=n[`${i}Theme`];if(!Rn(o)||o==="system"||ue[o].scheme!==i)return null}if(n.accent!=="theme"&&(typeof n.accent!="string"||!Object.hasOwn(en,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(!Dl(r)||Object.keys(r).length!==An.length)return null;for(let{key:i,min:o,max:a}of An){let s=r[i];if(typeof s!="number"||!Number.isFinite(s)||s<o||s>a)return null}return n}var Vo=40,Gl=100,ig=1e9,lr=e=>({id:e,kind:"document",history:[null],cursor:0,scroll:0});function jo(){return{version:1,panes:[{id:"pane-1",tabs:[lr("tab-1")],activeTab:"tab-1"}],activePane:"pane-1",split:"right",ratio:.5,treeVisible:!0,contextVisible:!0,treeWidth:240,contextWidth:240,contextGraphHeight:260,contextTagsHeight:180,theme:"system",preferences:Wt}}function cr(e){return e.panes.find(t=>t.id===e.activePane)}function tn(e){let t=cr(e);return t.tabs.find(n=>n.id===t.activeTab)}function wt(e){return e.kind==="document"?e.history[e.cursor]??null:null}function Ln(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 nn(e,t,n){return{...e,activePane:t.id,panes:e.panes.map(r=>r.id===t.id?ui({...t,activeTab:n.id,tabs:t.tabs.map(i=>i.id===n.id?n:i)}):r)}}function qo(e){return e.tabs.find(t=>t.id===e.lastDocumentTab&&t.kind==="document")??[...e.tabs].reverse().find(t=>t.kind==="document")}function ui(e){let{lastDocumentTab:t,...n}=e,r=e.tabs.find(i=>i.id===e.activeTab&&i.kind==="document")??qo(e);return r?{...n,lastDocumentTab:r.id}:n}function di(e){if(tn(e).kind==="document")return e;let t=cr(e),n=qo(t);return n?nn(e,t,n):Nn(e,null,{newTab:!0})}function hi(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 Ko(e,t,n){return e.panes.reduce((r,i)=>r+i.tabs.length,0)>=Vo?e:nn(e,{...t,tabs:[...t.tabs,n]},n)}function Uo(e,t){let n=e.history.slice(0,e.cursor+1);return n.at(-1)===t?e:(n.push(t),n.length>Gl&&n.shift(),{...e,history:n,cursor:n.length-1,scroll:0})}function Nn(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=qo(r),o?r={...r,activeTab:o.id}:n.newTab||(n={...n,newTab:!0})),n.newTab||!o)return Ko(e,r,Uo(lr(Ln(e,"tab")),t));let a=Uo(o,t);return a===o&&r.id===e.activePane&&i===o.id?e:nn(e,r,a)}function Yo(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:nn(e,t.pane,t.tab);let n=cr(e);return Ko(e,n,{id:Ln(e,"tab"),kind:"graph",history:[null],cursor:0,scroll:0})}function Xo(e,t,n){let r=hi(e,t,n);return!r||e.activePane===t&&r.pane.activeTab===n?e:nn(e,r.pane,r.tab)}function Zo(e,t,n){let r=hi(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=lr(Ln(e,"tab"));return nn(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=ui({...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 Qo(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:nn(e,r,{...i,cursor:o,scroll:0})}function Jo(e,t){if(e.panes.length===2)return e.split===t?e:{...e,split:t};let n=fi(e,e.activePane,tn(e).id);return n===e?e:{...n,split:t}}function Ml(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 ea(e,t,n,r){let i=hi(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 pi(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 fi(e,t,n){let r=hi(e,t,n);if(!r)return e;let i=e.panes.find(u=>u.id!==t)??{id:Ln(e,"pane"),tabs:[],activeTab:""},o=r.pane.tabs.filter(u=>u.id!==n),a=ui({...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)>=Vo)return e;let s=o.length?null:lr(Ln(e,"tab")),l=o.length?o:[s],c=ui({...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 Bo(e,t){return Object.keys(e).length===t.length&&t.every(n=>Object.hasOwn(e,n))}function ci(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Cn(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 Ol(e){if(!ci(e)||!Bo(e,["version","panes","activePane","split","ratio","treeVisible","contextVisible","treeWidth","contextWidth","theme",...["preferences","contextGraphHeight","contextTagsHeight"].filter(c=>Object.hasOwn(e,c))])||e.version!==1||!Array.isArray(e.panes)||e.panes.length<1||e.panes.length>2||!Cn(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)return null;let t=Object.hasOwn(e,"contextGraphHeight")?e.contextGraphHeight:260,n=Object.hasOwn(e,"contextTagsHeight")?e.contextTagsHeight:180;if(typeof t!="number"||!Number.isFinite(t)||t<120||t>800||typeof n!="number"||!Number.isFinite(n)||n<60||n>600||!Rn(e.theme))return null;let r=Object.hasOwn(e,"preferences")?Il(e.preferences):Wt;if(r===null)return null;let i=e.preferences;e.theme!=="system"&&(!ci(i)||!Object.hasOwn(i,"lightTheme"))&&(r={...r,[`${ue[e.theme].scheme}Theme`]:e.theme});let o=new Set,a=0,s=0,l=[];for(let c of e.panes){if(!ci(c)||!Bo(c,Object.hasOwn(c,"lastDocumentTab")?["id","tabs","activeTab","lastDocumentTab"]:["id","tabs","activeTab"])||!Cn(c.id,"pane")||!Array.isArray(c.tabs)||c.tabs.length<1||!Cn(c.activeTab,"tab")||o.has(c.id))return null;o.add(c.id);let u=[],h=!1;for(let p of c.tabs){if(!ci(p)||!Bo(p,["id","kind","history","cursor","scroll"])||!Cn(p.id,"tab")||o.has(p.id)||(o.add(p.id),p.kind!=="document"&&p.kind!=="graph"))return null;let m=p.kind;if(!Array.isArray(p.history)||p.history.length<1||p.history.length>Gl||!Number.isInteger(p.cursor)||p.cursor<0||p.cursor>=p.history.length||p.history.some(w=>w!==null&&!Cn(w))||typeof p.scroll!="number"||!Number.isFinite(p.scroll)||p.scroll<0||p.scroll>ig)return null;m==="graph"&&s++,a++,p.id===c.activeTab&&(h=!0),u.push({id:p.id,kind:m,history:p.history,cursor:p.cursor,scroll:p.scroll})}if(!h)return null;let d=c.lastDocumentTab;if(Object.hasOwn(c,"lastDocumentTab")&&(!Cn(d,"tab")||!u.some(p=>p.id===d&&p.kind==="document")))return null;l.push({id:c.id,tabs:u,activeTab:c.activeTab,...typeof d=="string"?{lastDocumentTab:d}:{}})}return a>Vo||s>1||!l.some(c=>c.id===e.activePane)?null:{version:1,panes:l,activePane:e.activePane,split:e.split,ratio:e.ratio,treeVisible:e.treeVisible,contextVisible:e.contextVisible,treeWidth:e.treeWidth,contextWidth:e.contextWidth,contextGraphHeight:t,contextTagsHeight:n,theme:e.theme,preferences:r}}function Fl(e){if(e.preferences.startup==="restore")return e;let t=jo();return{...e,panes:t.panes,activePane:t.activePane}}function $l(e,t,n={}){let r=Nn(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 Ae=(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 ta(e,t=!1){return{ok:!0,data:e,cached:t}}function Rt(e,t,n){return{ok:!1,kind:e,status:t,message:n}}function zl(e){return e===403?"auth":e===404?"missing":"server"}function Wl(e){return e===403?"not authorised — this workspace session has ended":e===404?"not found":`server error (${e})`}async function ur(e,t,n,r){let i;try{i=await e(t,r)}catch(a){return Rt("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Rt(zl(i.status),i.status,Wl(i.status));let o;try{o=await i.json()}catch{return Rt("malformed",i.status,"response was not valid JSON")}return n(o)?ta(o):Rt("malformed",i.status,"response did not match the expected shape")}function At(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function og(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ag(e){if(!At(e)||typeof e.stamp!="string")return!1;let t=e.model;return!At(t)||!Array.isArray(t.nodes)||!Array.isArray(t.edges)?!1:At(e.tags)&&At(e.dangling)}function sg(e){if(!At(e))return!1;for(let t of["slug","title","body","created","updated","source"])if(typeof e[t]!="string")return!1;return og(e.tags)}function Hl(e){return At(e)&&sg(e.note)}function lg(e){return At(e)&&typeof e.query=="string"&&Array.isArray(e.hits)}function cg(e){return At(e)&&typeof e.opened=="boolean"}function ug(e){return At(e)&&e.ok===!0&&(e.id===void 0||typeof e.id=="string")}async function gi(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 Rt("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return t===null?Rt("malformed",304,"server sent 304 for an unconditional request"):ta(t,!0);if(!r.ok)return Rt(zl(r.status),r.status,Wl(r.status));let i;try{i=await r.json()}catch{return Rt("malformed",r.status,"response was not valid JSON")}return ag(i)?ta(i):Rt("malformed",r.status,"response did not match the expected shape")}function na(e,t){return ur(e,`/api/note/${encodeURIComponent(t)}`,Hl)}function Ul(e,t,n){return ur(e,`/api/search?q=${encodeURIComponent(t)}`,lg,n===void 0?void 0:{signal:n})}function Bl(e,t){return ur(e,"/api/open",cg,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:t})})}function Kl(e,t){return ur(e,"/api/notes",Hl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})}function rn(e,t,n,r){return ur(e,t,ug,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var mi=(e,t="")=>`/api/note/${encodeURIComponent(e)}${t}`,ra=(e,t="")=>`/api/folder/${e.split("/").map(encodeURIComponent).join("/")}${t}`,Vl=(e,t,n)=>rn(e,mi(t),"POST",{body:n}),jl=(e,t,n)=>rn(e,mi(t,"/rename"),"POST",{name:n}),ql=(e,t,n)=>rn(e,mi(t,"/move"),"POST",{folder:n}),Yl=(e,t)=>rn(e,mi(t),"DELETE"),Xl=(e,t)=>rn(e,ra(t),"POST"),Zl=(e,t,n)=>rn(e,ra(t,"/rename"),"POST",{name:n}),Ql=(e,t)=>rn(e,ra(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 dg(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 w=m.detail.path;c.startsWith(w+"/")&&w.length>h&&(u=p,h=w.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 tc(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 hg(e){return e==="gitState"||e==="external"||e==="package"||e==="entryPoint"}function Jl(e){return e?e.kind==="module"||e.id.startsWith("vfolder:"):!1}function pg(e,t){return e.slice().sort((n,r)=>{let i=t.get(n),o=t.get(r),a=Jl(i),s=Jl(o);if(a!==s)return a?-1:1;let l=Je(i),c=Je(o);return l.localeCompare(c)})}function ec(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 fg(e){switch(e.kind){case"note":return e.detail.updated?{kind:"relTime",iso:e.detail.updated}:null;case"module":return e.detail.files?ec(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?ec(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 ia(e,t){let n=dg(e),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=m=>{let y=(i.get(m)??[]).filter(b=>{let k=r.get(b);if(!k||k.kind!=="entryPoint")return!0;for(let[,E]of o)if(E.includes(b))return!1;return!0}).concat(o.get(m)??[]);return y=y.filter(b=>r.has(b)),t.showInternals||(y=y.filter(b=>{let k=r.get(b);return!(k&&hg(k.kind))})),pg(y,r)},l=t.provFilter!==null||t.query.length>0,c=m=>!(t.provFilter!==null&&m.provenance!==t.provFilter||t.query.length>0&&!Je(m).toLowerCase().includes(t.query.toLowerCase())),u=new Set,h=m=>{let w=r.get(m),v=!1;for(let b of s(m))h(b)&&(v=!0);let y=c(w)||v;return y&&u.add(m),y};for(let m of a)h(m);let d=[],p=(m,w)=>{if(!u.has(m))return;let v=r.get(m),y=s(m),b=y.filter(E=>u.has(E)),k=l?b.length>0:t.expanded.has(m);if(d.push({id:m,depth:w,hasKids:y.length>0,expanded:k,label:Je(v),kind:v.kind,provenance:v.provenance,meta:fg(v)}),k)for(let E of b)p(E,w+1)};for(let m of a)p(m,0);return d}function oa(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 dr(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 gg=7;function aa(e,t){if(e===null)return"";switch(e.kind){case"relTime":return dr(e.iso,t);case"count":return e.phrasing==="attribute"?`${e.unit}=${e.n}`:`${e.n} ${e.unit}`;case"commit":return e.sha.slice(0,gg);case"text":return e.text}}var mg=["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 sa(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 mg){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 vi(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 vg=["contains","anchored-at"];function wg(e){return vg.includes(e)}function wi(e,t){let n=new Map;for(let d of e.nodes)n.set(d.id,d);let r=yg(e,n),i=tc(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,bg(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(w=>l.get(w)===d),provenance:xg(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:kg(e.edges,o,l),clusters:c,hidden:u,representative:l,roots:i}}function yg(e,t){let n=new Map;for(let r of e.edges){if(!wg(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 bg(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 xg(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 kg(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 la(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 Pn=[null,"human","agent","generated"];function nc(e=["vault","repository"]){return{expanded:new Set(e),showInternals:!1,provFilter:null,query:""}}function da(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 on(e){return{...e.model,danglingLinks:e.dangling}}function rc(e,t){return e===null?[]:ia(on(e),t)}var Dn="vfolder:\0draft";function ic(e){return e.type==="vault"?"":e.type==="folder"?e.path:e.path.split("/").slice(0,-1).join("/")}function oc(e,t){let n=t.trim();return n===""?null:e===""?n:`${e}/${n}`}function ac(e,t){if(t===null)return[...e];let n={id:Dn,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 ha(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 Eg(e,t){if(!e.expanded.has(t))return e;let n=new Set(e.expanded);return n.delete(t),{...e,expanded:n}}function pa(e){return e==="vault"?null:e.startsWith("vfolder:")?e.slice(8):void 0}function an(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 bi(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 sc(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 fa(e){return e.type==="folder"}function lc(e,t,n){return fa(e)?n?`Delete “${t}” and everything in it`:"Delete…":"Delete"}function cc(e,t){return e.query===t?e:{...e,query:t}}function uc(e){let t=Pn.indexOf(e.provFilter),n=Pn[(t+1)%Pn.length]??null;return{...e,provFilter:n}}function dc(e){return{...e,showInternals:!e.showInternals}}function xi(e,t){return t===null?-1:e.findIndex(n=>n.id===t)}function ua(e,t){return e[t]?.id??null}function ca(e,t,n){if(e.length===0)return null;let r=xi(e,t),i=r===-1?n>0?-1:e.length:r;return ua(e,Math.min(e.length-1,Math.max(0,i+n)))}function Tg(e,t){let n=xi(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 Sg={j:"ArrowDown",k:"ArrowUp"};function Rg(e){return Sg[e]??e}function hc(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=Rg(r);if(s==="ArrowDown")return a(ca(e,n,1));if(s==="ArrowUp")return a(ca(e,n,-1));if(s==="Home")return a(ua(e,0));if(s==="End")return a(ua(e,e.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=xi(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(ca(e,n,1)):{state:_g(t,n),selectedId:n,handled:!0}:o;if(c.hasKids&&c.expanded)return{state:Eg(t,n),selectedId:n,handled:!0};let u=Tg(e,n);return u===null?o:a(u)}var Ag={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function sn(e){return Ag[e]}var Cg={human:"●",agent:"◐",generated:"○"};function ln(e){return e===null?"":Cg[e]}function In(e){return e===null?"":`${e}-authored`}function pc(e){return`weave-row-${e.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Lg(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 Ng(e,t,n,r={posinset:1,setsize:1}){let i=e.hasKids?e.expanded?"open":"closed":"leaf";return{id:e.id,domId:pc(e.id),posinset:r.posinset,setsize:r.setsize,depth:e.depth,label:e.label,kind:e.kind,kindIcon:sn(e.kind),provenance:e.provenance,provenanceGlyph:ln(e.provenance),provenanceTitle:In(e.provenance),twisty:i,hasKids:e.hasKids,expanded:e.expanded,selected:e.id===t,meta:aa(e.meta,n),level:e.depth+1}}function fc(e,t,n){let r=Lg(e);return e.map((i,o)=>Ng(i,t,n,r[o]))}function gc(e,t){return xi(e,t)===-1?null:pc(t)}function mc(e){return{"--weave-depth":String(Math.max(0,e))}}function yi(e){return e===null?"all":e}function vc(e){let t=Pn.indexOf(e),n=Pn[(t+1)%Pn.length]??null;return`provenance filter: ${yi(e)} — click for ${yi(n)}`}function wc(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 bc="filter…",xc="Vault and repository",kc="Filter the tree",_c="Filter the tree (/)";function Ec(e,t,n){if(e===null)return"loading…";let r=oa(on(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 Tc(e){return e.length===1?"1 row":`${e.length} rows`}function Sc(e){let t=+this._x.call(null,e),n=+this._y.call(null,e);return Rc(this.cover(t,n),t,n,e)}function Rc(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,w,v,y,b;if(!o)return e._root=a,e;for(;o.length;)if((w=t>=(h=(s+c)/2))?s=h:c=h,(v=n>=(d=(l+u)/2))?l=d:u=d,i=o,!(o=o[y=v<<1|w]))return i[y]=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[y]=a:e._root=a,e;do i=i?i[y]=new Array(4):e._root=new Array(4),(w=t>=(h=(s+c)/2))?s=h:c=h,(v=n>=(d=(l+u)/2))?l=d:u=d;while((y=v<<1|w)===(b=(m>=d)<<1|p>=h));return i[b]=o,i[y]=a,e}function Ac(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)Rc(this,a[n],s[n],e[n]);return this}function Cc(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 Lc(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Nc(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 Pc(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,w;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 v=(a+l)/2,y=(s+c)/2;d.push(new Se(p[3],v,y,l,c),new Se(p[2],a,y,v,c),new Se(p[1],v,s,l,y),new Se(p[0],a,s,v,y)),(w=(t>=y)<<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 b=e-+this._x.call(null,p.data),k=t-+this._y.call(null,p.data),E=b*b+k*k;if(E<n){var I=Math.sqrt(n=E);i=e-I,o=t-I,u=e+I,h=t+I,r=p.data}}return r}function Dc(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,w,v,y;if(!n)return this;if(n.length)for(;;){if((m=u>=(d=(a+l)/2))?a=d:l=d,(w=h>=(p=(s+c)/2))?s=p:c=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,y=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[y]=n:this._root=n),this):(this._root=o,this)}function Ic(e){for(var t=0,n=e.length;t<n;++t)this.remove(e[t]);return this}function Gc(){return this._root}function Mc(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Oc(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 Fc(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 $c(e){return e[0]}function zc(e){return arguments.length?(this._x=e,this):this._x}function Wc(e){return e[1]}function Hc(e){return arguments.length?(this._y=e,this):this._y}function cn(e,t,n){var r=new ga(t??$c,n??Wc,NaN,NaN,NaN,NaN);return e==null?r:r.addAll(e)}function ga(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 Uc(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var $e=cn.prototype=ga.prototype;$e.copy=function(){var e=new ga(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=Uc(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]=Uc(r));return e};$e.add=Sc;$e.addAll=Ac;$e.cover=Cc;$e.data=Lc;$e.extent=Nc;$e.find=Pc;$e.remove=Dc;$e.removeAll=Ic;$e.root=Gc;$e.size=Mc;$e.visit=Oc;$e.visitAfter=Fc;$e.x=zc;$e.y=Hc;function ve(e){return function(){return e}}function ut(e){return(e()-.5)*1e-6}function Pg(e){return e.x+e.vx}function Dg(e){return e.y+e.vy}function ma(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,w,v,y=0;y<o;++y)for(h=cn(t,Pg,Dg).visitAfter(s),c=0;c<u;++c)d=t[c],w=n[d.index],v=w*w,p=d.x+d.vx,m=d.y+d.vy,h.visit(b);function b(k,E,I,A,D){var O=k.data,W=k.r,T=w+W;if(O){if(O.index>d.index){var F=p-O.x-O.vx,V=m-O.y-O.vy,j=F*F+V*V;j<T*T&&(F===0&&(F=ut(r),j+=F*F),V===0&&(V=ut(r),j+=V*V),j=(T-(j=Math.sqrt(j)))/j*i,d.vx+=(F*=j)*(T=(W*=W)/(v+W)),d.vy+=(V*=j)*T,O.vx-=F*(T=1-T),O.vy-=V*T)}return}return E>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 Bc(e,t){var n=e.get(t);if(!n)throw new Error("node not found: "+t);return n}function va(e){var t=Ig,n=h,r,i=ve(30),o,a,s,l,c,u=1;e==null&&(e=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var y=0,b=e.length;y<u;++y)for(var k=0,E,I,A,D,O,W,T;k<b;++k)E=e[k],I=E.source,A=E.target,D=A.x+A.vx-I.x-I.vx||ut(c),O=A.y+A.vy-I.y-I.vy||ut(c),W=Math.sqrt(D*D+O*O),W=(W-o[k])/W*v*r[k],D*=W,O*=W,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 v,y=a.length,b=e.length,k=new Map(a.map((I,A)=>[t(I,A,a),I])),E;for(v=0,s=new Array(y);v<b;++v)E=e[v],E.index=v,typeof E.source!="object"&&(E.source=Bc(k,E.source)),typeof E.target!="object"&&(E.target=Bc(k,E.target)),s[E.source.index]=(s[E.source.index]||0)+1,s[E.target.index]=(s[E.target.index]||0)+1;for(v=0,l=new Array(b);v<b;++v)E=e[v],l[v]=s[E.source.index]/(s[E.source.index]+s[E.target.index]);r=new Array(b),m(),o=new Array(b),w()}}function m(){if(a)for(var v=0,y=e.length;v<y;++v)r[v]=+n(e[v],v,e)}function w(){if(a)for(var v=0,y=e.length;v<y;++v)o[v]=+i(e[v],v,e)}return d.initialize=function(v,y){a=v,c=y,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?(u=+v,d):u},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ve(+v),m(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ve(+v),w(),d):i},d}var Gg={value:()=>{}};function Vc(){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 ki(n)}function ki(e){this._=e}function Mg(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}})}ki.prototype=Vc.prototype={constructor:ki,on:function(e,t){var n=this._,r=Mg(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=Og(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]=Kc(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Kc(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 ki(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 Og(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Kc(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Gg,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var wa=Vc;var Gn=0,pr=0,hr=0,qc=1e3,_i,fr,Ei=0,un=0,Ti=0,gr=typeof performance=="object"&&performance.now?performance:Date,Yc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function xa(){return un||(Yc(Fg),un=gr.now()+Ti)}function Fg(){un=0}function ya(){this._call=this._time=this._next=null}ya.prototype=Si.prototype={constructor:ya,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?xa():+n)+(t==null?0:+t),!this._next&&fr!==this&&(fr?fr._next=this:_i=this,fr=this),this._call=e,this._time=n,ba()},stop:function(){this._call&&(this._call=null,this._time=1/0,ba())}};function Si(e,t,n){var r=new ya;return r.restart(e,t,n),r}function Xc(){xa(),++Gn;for(var e=_i,t;e;)(t=un-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gn}function jc(){un=(Ei=gr.now())+Ti,Gn=pr=0;try{Xc()}finally{Gn=0,zg(),un=0}}function $g(){var e=gr.now(),t=e-Ei;t>qc&&(Ti-=t,Ei=e)}function zg(){for(var e,t=_i,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:_i=n);fr=e,ba(r)}function ba(e){if(!Gn){pr&&(pr=clearTimeout(pr));var t=e-un;t>24?(e<1/0&&(pr=setTimeout(jc,e-gr.now()-Ti)),hr&&(hr=clearInterval(hr))):(hr||(Ei=gr.now(),hr=setInterval($g,qc)),Gn=1,Yc(jc))}}function Zc(){let e=1;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Qc(e){return e.x}function Jc(e){return e.y}var Wg=10,Hg=Math.PI*(3-Math.sqrt(5));function ka(e){var t,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=Si(h),c=wa("tick","end"),u=Zc();e==null&&(e=[]);function h(){d(),c.call("tick",t),n<r&&(l.stop(),c.call("end",t))}function d(w){var v,y=e.length,b;w===void 0&&(w=1);for(var k=0;k<w;++k)for(n+=(o-n)*i,s.forEach(function(E){E(n)}),v=0;v<y;++v)b=e[v],b.fx==null?b.x+=b.vx*=a:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=a:(b.y=b.fy,b.vy=0);return t}function p(){for(var w=0,v=e.length,y;w<v;++w){if(y=e[w],y.index=w,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var b=Wg*Math.sqrt(.5+w),k=w*Hg;y.x=b*Math.cos(k),y.y=b*Math.sin(k)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function m(w){return w.initialize&&w.initialize(e,u),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?(u=w,s.forEach(m),t):u},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,y){var b=0,k=e.length,E,I,A,D,O;for(y==null?y=1/0:y*=y,b=0;b<k;++b)D=e[b],E=w-D.x,I=v-D.y,A=E*E+I*I,A<y&&(O=D,y=A);return O},on:function(w,v){return arguments.length>1?(c.on(w,v),t):c.on(w)}}}function _a(){var e,t,n,r,i=ve(-30),o,a=1,s=1/0,l=.81;function c(p){var m,w=e.length,v=cn(e,Qc,Jc).visitAfter(h);for(r=p,m=0;m<w;++m)t=e[m],v.visit(d)}function u(){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,y=0,b,k,E;if(p.length){for(b=k=E=0;E<4;++E)(w=p[E])&&(v=Math.abs(w.value))&&(m+=w.value,y+=v,b+=v*w.x,k+=v*w.y);p.x=b/y,p.y=k/y}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 y=p.x-t.x,b=p.y-t.y,k=v-m,E=y*y+b*b;if(k*k/l<E)return E<s&&(y===0&&(y=ut(n),E+=y*y),b===0&&(b=ut(n),E+=b*b),E<a&&(E=Math.sqrt(a*E)),t.vx+=y*p.value*r/E,t.vy+=b*p.value*r/E),!0;if(p.length||E>=s)return;(p.data!==t||p.next)&&(y===0&&(y=ut(n),E+=y*y),b===0&&(b=ut(n),E+=b*b),E<a&&(E=Math.sqrt(a*E)));do p.data!==t&&(k=o[p.data.index]*r/E,t.vx+=y*k,t.vy+=b*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 Ea(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 Ta(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 Ug=9,Ri=6,Ai=18,Bg=32,nu=9,mr=Ug+nu;function Sa(e){let t=Number.isFinite(e)&&e>0?e:0,n=Math.min(1,Math.log2(1+t)/Math.log2(1+Bg));return Ri+(Ai-Ri)*n}function Ra(e){return e+nu}var Kg=300,ru=1,eu=.001;function tu(e){return e==="contains"||e==="anchored-at"}function Vg(e){let t=Math.trunc(e)>>>0;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function jg(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 Aa(e){let t=va(e.links).id(n=>n.id).distance(n=>tu(n.kind)?Ve.containsRest:Ve.relationDistance).strength(n=>tu(n.kind)?Ve.containsStrength:Ve.relationStrength).iterations(2);return ka(e.nodes).randomSource(Vg(e.seed??ru)).force("charge",_a().strength(Ve.charge).distanceMax(Ve.chargeMax)).force("link",t).force("collide",ma(n=>n.r??mr).strength(1)).force("x",Ea(0).strength(Ve.center)).force("y",Ta(0).strength(Ve.center)).stop()}function qg(e,t,n){let r=Aa({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(eu).alphaDecay(n.ticks>0?1-Math.pow(eu,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function iu(e,t={}){let n=Math.max(0,Math.trunc(t.ticks??Kg)),{ids:r,edges:i}=jg(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=Ra(Sa(a.get(l.id)??0));o.length>1&&qg(o,i,{ticks:n,seed:t.seed??ru,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 Yg=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 Ht(e){let t=Yg[li(e)];return typeof e=="string"?t:{...t,accent:Pl(e.theme,e.accent)}}var Xg={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 Qg(e,t){return Ht(t)[Xg[e]]}function ou(e,t){return Ht(t)[Zg[e]]}function Jg(e,t){return em(e)?La(ou(e,t),t,tm):ou(e,t)}function em(e){return e==="contains"||e==="anchored-at"}var Ca=.85,tm=.3;function vr(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 La(e,t,n=Ca){return vr(e,Ht(t).ground,n)}var nm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},au=1.6,lu=32,rm=lu/2;function im(e,t=lu){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>=rm?i:n;return`${e.slice(0,o).trimEnd()}…`}function om(e){let t=ln(e.provenance),n=Je(e);return im(t===""?n:`${t} ${n}`)}var am=6,sm=6;function lm(e){return(t,n,r)=>{if(n.label===null||n.label==="")return;let i=Ht(e);t.save(),t.font=`${r.labelSize}px ${r.labelFont}`,t.textAlign="center",t.shadowColor=i.ground,t.shadowBlur=sm,t.fillStyle=i.text,t.fillText(n.label,n.x,n.y+n.size+r.labelSize+am),t.restore()}}function cu(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,(mr*4-Math.max(r-t,i-n))/2);return{x:[t-a,r+a],y:[n-a,i+a]}}var uu={nodes:[],edges:[]};function du(e){return`${e.source}\0${e.target}\0${e.kind}`}function cm(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=du(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 hu(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=cm(t,a),l=[];for(let[h,d]of o){let p=n.get(h),m=Sa(s.get(h)??0);l.push({id:h,x:p.x,y:p.y,size:m,label:om(d),color:i?.get(h)??Qg(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=du(h);u.has(d)||(u.add(d),c.push({key:d,source:h.source,target:h.target,size:nm[h.kind],color:Jg(h.kind,r),kind:h.kind,zIndex:0,type:"line"}))}return{nodes:l,edges:c}}function pu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:r===t&&e.has(r)?{zIndex:i.zIndex+su*2,size:i.size*Ci(pm,n)}:e.has(r)?{zIndex:i.zIndex+su,size:i.size*Ci(fm,n)}:{color:La(i.color,o,Ca*n),label:n>=hm?null:i.label,zIndex:0}}var um=60,dm=.004;function fu(e,t,n){let r=Number.isFinite(n)&&n>0?n:0,i=t+(e-t)*Math.exp(-r/um);return Math.abs(t-i)<dm?t:i}function Ci(e,t){return 1+(e-1)*t}var hm=.5,pm=1.45,fm=1.15,su=Ai+1;function gu(e,t,n=1){return(r,i,o)=>e===null||n<=0?{}:!e.has(i.source)||!e.has(i.target)?{color:La(i.color,o,Ca*n)}:t!=null&&(i.source===t||i.target===t)?{zIndex:2,size:i.size*Ci(au*1.35,n),color:vr(i.color,Ht(o).accent,n)}:{zIndex:1,size:i.size*Ci(au,n)}}var gm=(Ri+Ai)/2,mm=mr*4,vm=1;function mu(e){let t=Ht(e);return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:vm,labelGridCellSize:mm,labelRenderedSizeThreshold:gm,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:mr,defaultDrawNodeHover:lm(e),allowInvalidContainer:!0}}function vu(e){return e==="contains"||e==="anchored-at"}function wm(e,t){let n=new Set(e.map(i=>i.id)),r=new Map;for(let i of t)vu(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=wm(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 bm(e){let t=new Map;for(let n of e.values())t.set(n,(t.get(n)??0)+1);return t}var xm={dark:["#f5bde6","#c6a0f6","#ed8796","#f5a97f","#eed49f","#a6da95","#8bd5ca","#7dc4e4","#8aadf4","#b7bdf8"],light:["#824171","#7832d4","#d20f39","#9f3e07","#7b4e10","#28641b","#106368","#14616e","#1853c8","#445198"]},km=3;function _m(e,t){let n=xm[ue[li(t)].scheme],i=[...bm(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*km%n.length])),o}var Em=.11,Tm=.34;function Sm(e,t,n){let r=Number.isFinite(t)&&t>0?t:0;return vr(e,Ht(n).ground,Math.min(Tm,r*Em))}var Rm=.26,Am=.55;function Cm(e,t,n){if(t.length===0)return e;let r=e,i=0;for(let o of t){let a=Math.min(Rm,Am-i);if(a<=0)break;i+=a,r=vr(r,o,a)}return r}function wu(e,t,n){let r=ym(e,t),i=new Map;for(let[u,h]of r)i.set(u,h.key);let o=_m(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)vu(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=Sm(d,h.depth,n),m=[...s.get(u.id)??[]].sort().map(w=>o.get(w)).filter(w=>w!==void 0);c.set(u.id,Cm(p,m,n))}return c}function Na(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 Lm=300,Nm=1;function Pm(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:Lm,seed:Nm,pinWarm:!0};return r.size>0&&(i.initial=r),iu({generatedAt:"",staleness:null,nodes:[...e],edges:[...t],contentDigest:""},i)}function Dm(e,t){let n=0,r=0;for(let o of e){let a=Na(o.id);n^=a,r=r+a>>>0}for(let o of t){let a=Na(`${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)),Na(JSON.stringify(Ve)).toString(16)].join("-")}var bu="pi-weave.graph.positions.v4";function yu(e){return Math.round(e*10)/10}function Im(e,t){let n={};for(let[r,i]of t)n[r]=[yu(i.x),yu(i.y)];return JSON.stringify({v:4,key:e,at:n})}function Gm(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 Mm(e,t){let n;try{n=e.getItem(bu)}catch{return null}return Gm(n,t)}function Om(e,t,n){try{return e.setItem(bu,Im(t,n)),!0}catch{return!1}}function xu(e,t,n){let r=Dm(t,n),i=Mm(e,r);if(i!==null&&t.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Pm(t,n);return Om(e,r,o),{key:r,positions:o,cached:!1}}function _u(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:sn(n.kind)}}function Fm(e){return{expanded:new Set(wi(e,new Set).clusters.keys())}}function Eu(e,t){return t!==null?t:e===null?{expanded:new Set}:Fm(on(e))}function $m(e,t){let n=new Set(e.expanded);return n.delete(t)||n.add(t),{...e,expanded:n}}function zm(e,t){return t===null?null:vi(t,e)}function Tu(e,t,n){return t===null?n:vi(t,e)}var Su="fit",Ru="frame the whole graph",Li={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Au(e,t){let n=t===1?"node":"nodes";return e===t?`${t} ${n}`:`${e} of ${t} ${n}`}function Wm(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 Hm="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",ku={graph:uu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Cu(e,t,n,r,i,o=!1,a=!0){if(e===null)return o?{...ku,empty:Hm}:ku;let s=on(e),l=wi(s,n.expanded),u=n.expanded.has("vault")?l.edges.filter(m=>m.source!=="vault"&&m.target!=="vault"):l.edges,h=xu(r,l.nodes,u),d=a?wu(l.nodes,u,i):void 0;return{graph:hu(l.nodes,u,h.positions,i,d),highlight:zm(u,t),key:h.key,cached:h.cached,clusters:l.clusters,visible:l.nodes.length,total:s.nodes.length,empty:Wm(e,l.nodes.length)}}function Lu(e,t,n){return n===null?{state:e,selectedId:null}:t.get(n)===void 0||e.expanded.has(n)?{state:e,selectedId:n}:{state:$m(e,n),selectedId:n}}var Nu="(prefers-color-scheme: light)";function wr(e){return e==null||typeof e.matchMedia!="function"?"dark":e.matchMedia(Nu).matches?"light":"dark"}function Pu(e,t){if(typeof e.matchMedia!="function")return()=>{};let n=e.matchMedia(Nu);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,Bm=.2,Pa=.001,Du=.5;function Iu(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:Ra(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=Aa({nodes:n,links:o,seed:1}).alpha(Um).alphaMin(Pa);return{tick(){a.tick()},awake(){return a.alphaTarget()>Pa||a.alpha()>Pa},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)<Du&&Math.abs(c.fy-l.y)<Du;c.fx=l.x,c.fy=l.y,a.alphaTarget(u?0:Bm)},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}var yr="application/x-weave-note";function Gu(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 Mu(e,t){return t!==null&&t===e}function Ou(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:sn(o),selected:r===n}})}var Fu={title:"Context"},Km="—";function $u(e,t){return{cwd:e===""?Km:e,selection:t??"nothing selected"}}var zu=6e4;function Ni(e){return e?"⌘K":"Ctrl K"}function Wu(e){return`Search notes and repository (${e})`}function Pi(e){return/mac|iphone|ipad/i.test(e)}var Vm={k:{type:"openSearch"},",":{type:"openSettings"}},Hu={1:"tree",2:"note",3:"graph"};function jm(e){return e.ctrl!==e.meta&&!e.alt&&!e.shift}function qm(e){return!e.ctrl&&!e.meta&&!e.alt}var Ym={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"toggleTheme"}};function Uu(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(jm(e)){let n=Vm[e.key.toLowerCase()];if(n!==void 0)return n;let r=Hu[e.key];return r===void 0?null:{type:"focusColumn",column:r}}return e.key==="Escape"?t.hasSelection?{type:"clearSelection"}:null:!qm(e)||e.typing?null:Ym[e.key]??null}var Xm=["INPUT","TEXTAREA","SELECT"];function Ia(e,t){return t?!0:e!==null&&Xm.includes(e.toUpperCase())}function Bu(e){return{key:e.altKey&&e.code==="KeyW"?"w":e.key,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey,alt:e.altKey,typing:Ia(e.target?.tagName??null,e.target?.isContentEditable===!0)}}var Mn={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 Di(e,t){let n=Zm(e.querySelector(t));return n===null?!1:(n.focus(),!0)}function Ku(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(Mn[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"toggleTheme":return t.toggleTheme()}}function Ii(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(Hu).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 Ma="Keyboard shortcuts",Vu="esc close";var ju={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 Qm=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:--Qm,__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 ne.vnode&&ne.vnode(c),c}function Ct({name:e,class:t}){let n=ju[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 ev({view:e,recentIds:t,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let c=pa(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:mc(e.depth),onClick:u=>o(u.metaKey||u.ctrlKey),draggable:e.id.startsWith("note:"),"aria-label":e.id===Dn?"New folder":void 0,onDragStart:u=>{u.dataTransfer?.setData("text/plain",e.id),u.dataTransfer?.setData(yr,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(Ct,{name:"chevron",class:e.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),f("span",{class:"weave-kind","aria-hidden":"true",children:f(Ct,{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(tv,{value:n,draft:e.id===Dn,onEdit:r,onCommit:i}),f("span",{class:"weave-meta",children:e.meta})]})}function tv({value:e,draft:t,onEdit:n,onCommit:r}){let i=Y(null);return Qe(()=>{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 qu(e){let[t,n]=q(nc),[r,i]=q(null),o=Y(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]=q(null),[c,u]=q(null),h=ac(rc(e.graph,t),c),d=Ec(e.graph,h,t),p=async(y,b)=>{let k=await y;if(!k.ok)window.alert(k.message);else{let E=k.data.id??b;E!==void 0&&e.onSelect(E),e.onRefresh()}},m=async y=>{if(r===null)return;let b=an(r.id);if(i(null),b!==null){if(y==="newFolder"){let k=ic(b);n(E=>da(E,k)),u(k),l({id:Dn,label:"",value:""})}else if(y==="rename")n(k=>da(k,b.path.split("/").slice(0,-1).join("/"))),l({id:r.id,label:r.label,value:r.label});else if(b.type!=="vault"){if(!e.onMutate(bi(e.graph,b)))return;await p(b.type==="note"?Yl(Ae,b.path):Ql(Ae,b.path),sc(e.selectedId,b)?"vault":void 0)}}},w=y=>{if(r!==null){if(fa(y)&&r.armed!==!0){i({...r,armed:!0});return}m("delete")}},v=y=>{let b=s,k=c;if(l(null),u(null),b===null)return;let E=y?.trim();if(b.id===Dn){let A=k===null||!E?null:oc(k,E);A!==null&&p(Xl(Ae,A));return}let I=an(b.id);if(I!==null&&E&&E!==b.label){if(!e.onMutate(bi(e.graph,I)))return;p(I.type==="note"?jl(Ae,I.path,E):Zl(Ae,I.path,E))}};return f("div",{class:"weave-tree",ref:o,onKeyDown:y=>{if(r!==null&&y.key==="Escape"){y.preventDefault(),y.stopPropagation(),a();return}let b=y.target,k=hc(h,t,e.selectedId,y.key,Ia(b?.tagName??null,b?.isContentEditable===!0));k.handled&&(y.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:bc,"aria-label":kc,title:_c,onInput:y=>n(cc(t,y.currentTarget.value))}),f("button",{type:"button",class:"weave-chip",title:vc(t.provFilter),onClick:()=>n(uc(t)),children:["◧ ",yi(t.provFilter)]}),f("button",{type:"button",class:"weave-chip",title:yc(t.showInternals),onClick:()=>n(dc(t)),children:["◧ ",wc(t.showInternals)]}),f("button",{type:"button",class:"weave-chip weave-tree-actions","aria-label":"File actions",title:"File actions for the selected item",onClick:y=>{let b=e.selectedId!==null&&an(e.selectedId)!==null?e.selectedId:"vault",k=y.currentTarget.getBoundingClientRect();i({id:b,label:e.graph?.model.nodes.find(E=>E.id===b)?.label??"Vault",x:k.left,y:k.bottom})},children:"···"})]}),d===null?f("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":xc,"aria-activedescendant":gc(h,e.selectedId)??void 0,onContextMenu:y=>{y.preventDefault(),i({id:"vault",label:"Vault",x:y.clientX,y:y.clientY})},children:fc(h,e.selectedId,e.now).map(y=>f(ev,{view:y,recentIds:e.recentIds,edit:s?.id===y.id?s.value:null,onEdit:b=>l(k=>k===null?null:{...k,value:b}),onRename:v,onSelect:b=>{e.onSelect(y.id,b),y.hasKids&&n(k=>ha(k,y.id))},onToggle:()=>n(ha(t,y.id)),onMenu:(b,k)=>i({id:y.id,label:y.label,x:b,y:k}),onDrop:b=>{let k=pa(y.id);if(b.startsWith("note:")&&k!==void 0){let E=an(b);if(E!==null&&!e.onMutate(bi(e.graph,E)))return;p(ql(Ae,b.slice(5),k))}}},y.id))}):f("p",{class:"weave-tree-empty",children:d}),f("p",{class:"weave-tree-count",children:Tc(h)}),r!==null&&an(r.id)!==null?(()=>{let y=an(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:b=>{if(b.key==="Escape")b.preventDefault(),a();else if(["ArrowDown","ArrowUp","Home","End"].includes(b.key)){b.preventDefault();let k=[...b.currentTarget.querySelectorAll("button")],E=k.indexOf(document.activeElement),I=b.key==="Home"?0:b.key==="End"?k.length-1:(E+(b.key==="ArrowDown"?1:-1)+k.length)%k.length;k[I]?.focus()}b.stopPropagation()},children:[f("button",{type:"button",role:"menuitem",onClick:()=>{m("newFolder")},children:"New folder…"}),y.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:()=>w(y),children:lc(y,r.label,r.armed===!0)})]}):null]})]})})():null]})}function Yu(e){let t=Y(null),n=Y(null),r=Y(null),i=Y(null),o=Sl(()=>{if(i.current!==null)return;let w=()=>{i.current=null;let v=r.current;v!==null&&(v.tick(),v.awake()&&(n.current?.setPositions(v.positions()),i.current=requestAnimationFrame(w)))};i.current=requestAnimationFrame(w)},[]),[a,s]=q(null),l=vt(()=>(Ho(e.forces),JSON.stringify(e.forces)),[e.forces]),c=e.groupColors,u=e.scheme??wr(e.host),h=Eu(e.graph,a),d=vt(()=>Cu(e.graph,e.selectedId,h,e.storage,u,e.bootFailed,c),[e.graph,e.selectedId,h,e.storage,u,e.bootFailed,l,c]),p=_u(e.graph,e.previewId),m=Y({view:h,model:d,onSelect:e.onSelect,selectedId:e.selectedId});return m.current={view:h,model:d,onSelect:e.onSelect,selectedId:e.selectedId},oe(()=>{let w=e.renderer(u);return w.onSelect(v=>{let y=Lu(m.current.view,m.current.model.clusters,v);s(y.state),m.current.onSelect(y.selectedId)}),w.onHover(v=>{let{model:y,selectedId:b}=m.current;w.setHighlight(Tu(y.graph.edges,v,y.highlight),v??b)}),w.onDragStart(v=>{let y=n.current?.positions().get(v);y&&(r.current?.pin(v,y),o())}),w.onDragMove((v,y)=>{r.current?.pin(v,y)}),w.onDragEnd(v=>{r.current?.release(v)}),w.mount(t.current??{clientWidth:0,clientHeight:0}),n.current=w,w.setGraph(m.current.model.graph),w.setHighlight(m.current.model.highlight,m.current.selectedId),e.fit.current=()=>w.fit(),()=>{w.destroy(),n.current=null,e.fit.current=null}},[e.renderer,u]),oe(()=>{n.current?.setGraph(d.graph)},[d.key,l,c]),oe(()=>{let w=Iu(d.graph,n.current?.positions());return r.current=w,w!==null&&o(),()=>{r.current=null}},[d.key,o,l]),oe(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),oe(()=>{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(Ct,{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:Ru,onClick:()=>n.current?.fit(),children:Su}),f("span",{class:"weave-graph-legend",children:[f("span",{class:"weave-legend-on",children:["◉ ",Li.selected]}),f("span",{class:"weave-legend-near",children:["● ",Li.neighborhood]}),f("span",{class:"weave-legend-dim",children:["· ",Li.dimmed]})]})]}),f("p",{class:"weave-graph-count",children:Au(d.visible,d.total)})]})}function nv(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 hn(e){var t=nv(e,"string");return typeof t=="symbol"?t:t+""}function xe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xu(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,hn(r.key),r)}}function ke(e,t,n){return t&&Xu(e.prototype,t),n&&Xu(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function dn(e){return dn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},dn(e)}function Zu(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Zu=function(){return!!e})()}function rv(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function iv(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 rv(e)}function ze(e,t,n){return t=dn(t),iv(e,Zu()?Reflect.construct(t,n||[],dn(e).constructor):t.apply(e,n))}function Oa(e,t){return Oa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Oa(e,t)}function We(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&&Oa(e,t)}function ov(e){if(Array.isArray(e))return e}function av(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 Mi(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 Wa(e,t){if(e){if(typeof e=="string")return Mi(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)?Mi(e,t):void 0}}function sv(){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 Ut(e,t){return ov(e)||av(e,t)||Wa(e,t)||sv()}var Fa={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 Qu=new Int8Array(4),$a=new Int32Array(Qu.buffer,0,1),lv=new Float32Array(Qu.buffer,0,1),cv=/^\s*rgba?\s*\(/,uv=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function dv(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(cv.test(e)){var o=e.match(uv);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 On={};for(br in Fa)On[br]=Fn(Fa[br]),On[Fa[br]]=On[br];var br;function Ju(e,t,n,r,i){return $a[0]=r<<24|n<<16|t<<8|e,i&&($a[0]=$a[0]&4278190079),lv[0]}function Fn(e){if(e=e.toLowerCase(),typeof On[e]<"u")return On[e];var t=dv(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var a=Ju(n,r,i,o,!0);return On[e]=a,a}var za={};function Ha(e){if(typeof za[e]<"u")return za[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=Ju(t,n,r,i,!0);return za[e]=o,o}function Ua(e,t,n,r){return n+(t<<8)+(e<<16)}function Ba(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=Ut(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=hn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ed(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 z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ed(Object(n),!0).forEach(function(r){R(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ed(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function hv(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=dn(e))!==null;);return e}function ja(){return ja=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=hv(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},ja.apply(null,arguments)}function sd(e,t,n,r){var i=ja(dn(1&r?e.prototype:e),t,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function pv(e){return e.normalized?1:e.size}function Ka(e){var t=0;return e.forEach(function(n){return t+=pv(n)}),t}function ld(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:
23
23
  `.concat(a,`
24
- `).concat(n))}return i}function fv(e,t){return sd("VERTEX",e,t)}function gv(e,t){return sd("FRAGMENT",e,t)}function mv(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 ed(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 td=`#define PICKING_MODE
25
- `,vv=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 ld=(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=Wa(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,td+i.VERTEX_SHADER_SOURCE,td+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Wa(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(){ed(this.normalProgram),this.pickProgram&&(ed(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=fv(r,i),u=gv(r,o),h=mv(r,[c,u]),d={};s.UNIFORMS.forEach(function(y){var v=r.getUniformLocation(h,y);v&&(d[y]=v)});var p={};s.ATTRIBUTES.forEach(function(y){p[y.name]=r.getAttribLocation(h,y.name)});var m;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(y){p[y.name]=r.getAttribLocation(h,y.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=vv[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:Wa(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 yv=(function(e){function t(){return be(this,t),Me(this,t,arguments)}return Oe(t,e),xe(t,[{key:"kill",value:function(){ad(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(Fa(r),a,o)}}])})(ld);var Ba=(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(){ad(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(Fa(r),l,o,a,s)}}])})(ld);function wv(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 cd(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,y=r.y,v=(d+m)/2,w=(p+y)/2,b=m-d,k=y-p,_=Math.sqrt(b*b+k*k);if(!(_<u+h)){d+=b*u/_,p+=k*u/_,m-=b*h/_,y-=k*h/_,v=(d+m)/2,w=(p+y)/2,b=m-d,k=y-p,_=Math.sqrt(b*b+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;b>0?k>0?D=Math.acos(b/_):D=Math.asin(k/_):k>0?D=Math.acos(b/_)+Math.PI:D=Math.asin(b/_)+Math.PI/2,e.save(),e.translate(v,w),e.rotate(D),e.fillText(c,-I/2,t.size/2+o),e.restore()}}}function Ka(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 ud(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,Ka(e,t,n)}var bv=`
24
+ `).concat(n))}return i}function fv(e,t){return ld("VERTEX",e,t)}function gv(e,t){return ld("FRAGMENT",e,t)}function mv(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 td(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 nd=`#define PICKING_MODE
25
+ `,vv=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 cd=(function(){function e(t,n,r){xe(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=Ka(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,nd+i.VERTEX_SHADER_SOURCE,nd+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Ka(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 ke(e,[{key:"kill",value:function(){td(this.normalProgram),this.pickProgram&&(td(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=fv(r,i),u=gv(r,o),h=mv(r,[c,u]),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: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=vv[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:Ka(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(z(z({},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 wv=(function(e){function t(){return xe(this,t),ze(this,t,arguments)}return We(t,e),ke(t,[{key:"kill",value:function(){sd(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(Ha(r),a,o)}}])})(cd);var qa=(function(e){function t(){var n;xe(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=ze(this,t,[].concat(i)),R(n,"drawLabel",void 0),n}return We(t,e),ke(t,[{key:"kill",value:function(){sd(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(Ha(r),l,o,a,s)}}])})(cd);function yv(e,t){return(function(){function n(r,i,o){xe(this,n),R(this,"drawLabel",t),this.programs=e.map(function(a){return new a(r,i,o)})}return ke(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 ud(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,w=r.y,v=(d+m)/2,y=(p+w)/2,b=m-d,k=w-p,E=Math.sqrt(b*b+k*k);if(!(E<u+h)){d+=b*u/E,p+=k*u/E,m-=b*h/E,w-=k*h/E,v=(d+m)/2,y=(p+w)/2,b=m-d,k=w-p,E=Math.sqrt(b*b+k*k);var I=e.measureText(c).width;if(I>E){var A="…";for(c=c+A,I=e.measureText(c).width;I>E&&c.length>1;)c=c.slice(0,-2)+A,I=e.measureText(c).width;if(c.length<4)return}var D;b>0?k>0?D=Math.acos(b/E):D=Math.asin(k/E):k>0?D=Math.acos(b/E)+Math.PI:D=Math.asin(b/E)+Math.PI/2,e.save(),e.translate(v,y),e.rotate(D),e.fillText(c,-I/2,t.size/2+o),e.restore()}}}function Ya(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 dd(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,Ya(e,t,n)}var bv=`
26
26
  precision highp float;
27
27
 
28
28
  varying vec4 v_color;
@@ -95,7 +95,7 @@ void main() {
95
95
 
96
96
  v_color.a *= bias;
97
97
  }
98
- `,_v=kv,dd=WebGLRenderingContext,nd=dd.UNSIGNED_BYTE,Ha=dd.FLOAT,Ev=["u_sizeRatio","u_correctionRatio","u_matrix"],mr=(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:_v,FRAGMENT_SHADER_SOURCE:xv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ev,ATTRIBUTES:[{name:"a_position",size:2,type:Ha},{name:"a_size",size:1,type:Ha},{name:"a_color",size:4,type:nd,normalized:!0},{name:"a_id",size:4,type:nd,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Ha}],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)}}])})(yv);R(mr,"ANGLE_1",0);R(mr,"ANGLE_2",2*Math.PI/3);R(mr,"ANGLE_3",4*Math.PI/3);var Tv=`
98
+ `,_v=kv,hd=WebGLRenderingContext,rd=hd.UNSIGNED_BYTE,Va=hd.FLOAT,Ev=["u_sizeRatio","u_correctionRatio","u_matrix"],kr=(function(e){function t(){return xe(this,t),ze(this,t,arguments)}return We(t,e),ke(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:_v,FRAGMENT_SHADER_SOURCE:xv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Ev,ATTRIBUTES:[{name:"a_position",size:2,type:Va},{name:"a_size",size:1,type:Va},{name:"a_color",size:4,type:rd,normalized:!0},{name:"a_id",size:4,type:rd,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Va}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Fn(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)}}])})(wv);R(kr,"ANGLE_1",0);R(kr,"ANGLE_2",2*Math.PI/3);R(kr,"ANGLE_3",4*Math.PI/3);var Tv=`
99
99
  precision mediump float;
100
100
 
101
101
  varying vec4 v_color;
@@ -169,7 +169,7 @@ void main() {
169
169
 
170
170
  v_color.a *= bias;
171
171
  }
172
- `,Av=Rv,hd=WebGLRenderingContext,rd=hd.UNSIGNED_BYTE,Li=hd.FLOAT,Cv=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],pd={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function fd(e){var t=$($({},pd),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:Av,FRAGMENT_SHADER_SOURCE:Sv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Cv,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:rd,normalized:!0},{name:"a_id",size:4,type:rd,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,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,y=l.x,v=l.y,w=Dn(c.color),b=y-p,k=v-m,_=b*b+k*k,I=0,A=0;_&&(_=1/Math.sqrt(_),I=-k*_*h,A=b*_*h);var D=this.array;D[a++]=y,D[a++]=v,D[a++]=-I,D[a++]=-A,D[a++]=d,D[a++]=w,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)}}])})(Ba)}var Y0=fd();var Lv=`
172
+ `,Av=Rv,pd=WebGLRenderingContext,id=pd.UNSIGNED_BYTE,Oi=pd.FLOAT,Cv=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],fd={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function gd(e){var t=z(z({},fd),e||{});return(function(n){function r(){return xe(this,r),ze(this,r,arguments)}return We(r,n),ke(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Av,FRAGMENT_SHADER_SOURCE:Sv,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Cv,ATTRIBUTES:[{name:"a_position",size:2,type:Oi},{name:"a_normal",size:2,type:Oi},{name:"a_radius",size:1,type:Oi},{name:"a_color",size:4,type:id,normalized:!0},{name:"a_id",size:4,type:id,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Oi}],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,w=l.x,v=l.y,y=Fn(c.color),b=w-p,k=v-m,E=b*b+k*k,I=0,A=0;E&&(E=1/Math.sqrt(E),I=-k*E*h,A=b*E*h);var D=this.array;D[a++]=w,D[a++]=v,D[a++]=-I,D[a++]=-A,D[a++]=d,D[a++]=y,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)}}])})(qa)}var Y0=gd();var Lv=`
173
173
  precision mediump float;
174
174
 
175
175
  varying vec4 v_color;
@@ -195,7 +195,7 @@ void main(void) {
195
195
  gl_FragColor = mix(v_color, transparent, t);
196
196
  #endif
197
197
  }
198
- `,gd=Lv,Nv=`
198
+ `,md=Lv,Nv=`
199
199
  attribute vec4 a_id;
200
200
  attribute vec4 a_color;
201
201
  attribute vec2 a_normal;
@@ -263,7 +263,7 @@ void main() {
263
263
 
264
264
  v_color.a *= bias;
265
265
  }
266
- `,Pv=Nv,md=WebGLRenderingContext,id=md.UNSIGNED_BYTE,cn=md.FLOAT,Dv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Iv={lengthToThicknessRatio:pd.lengthToThicknessRatio};function vd(e){var t=$($({},Iv),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:Pv,FRAGMENT_SHADER_SOURCE:gd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Dv,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:id,normalized:!0},{name:"a_id",size:4,type:id,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,y=Dn(c.color),v=p-h,w=m-d,b=l.size||1,k=v*v+w*w,_=0,I=0;k&&(k=1/Math.sqrt(k),_=-w*k*u,I=v*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++]=y,A[a++]=o,A[a++]=b}},{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,y=l.u_minEdgeThickness,v=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(y,o.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(Ba)}var X0=vd();function Gv(e){return wv([vd(e),fd(e)])}var Mv=Gv(),yd=Mv,Ov=`
266
+ `,Pv=Nv,vd=WebGLRenderingContext,od=vd.UNSIGNED_BYTE,pn=vd.FLOAT,Dv=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Iv={lengthToThicknessRatio:fd.lengthToThicknessRatio};function wd(e){var t=z(z({},Iv),e||{});return(function(n){function r(){return xe(this,r),ze(this,r,arguments)}return We(r,n),ke(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Pv,FRAGMENT_SHADER_SOURCE:md,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Dv,ATTRIBUTES:[{name:"a_positionStart",size:2,type:pn},{name:"a_positionEnd",size:2,type:pn},{name:"a_normal",size:2,type:pn},{name:"a_color",size:4,type:od,normalized:!0},{name:"a_id",size:4,type:od,normalized:!0},{name:"a_radius",size:1,type:pn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:pn},{name:"a_normalCoef",size:1,type:pn},{name:"a_radiusCoef",size:1,type:pn}],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,w=Fn(c.color),v=p-h,y=m-d,b=l.size||1,k=v*v+y*y,E=0,I=0;k&&(k=1/Math.sqrt(k),E=-y*k*u,I=v*k*u);var A=this.array;A[a++]=h,A[a++]=d,A[a++]=p,A[a++]=m,A[a++]=E,A[a++]=I,A[a++]=w,A[a++]=o,A[a++]=b}},{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,w=l.u_minEdgeThickness,v=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(w,o.minEdgeThickness),s.uniform1f(v,t.lengthToThicknessRatio)}}])})(qa)}var X0=wd();function Gv(e){return yv([wd(e),gd(e)])}var Mv=Gv(),yd=Mv,Ov=`
267
267
  attribute vec4 a_id;
268
268
  attribute vec4 a_color;
269
269
  attribute vec2 a_normal;
@@ -328,41 +328,41 @@ void main() {
328
328
 
329
329
  v_color.a *= bias;
330
330
  }
331
- `,Fv=Ov,wd=WebGLRenderingContext,od=wd.UNSIGNED_BYTE,gr=wd.FLOAT,$v=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],bd=(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:Fv,FRAGMENT_SHADER_SOURCE:gd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$v,ATTRIBUTES:[{name:"a_positionStart",size:2,type:gr},{name:"a_positionEnd",size:2,type:gr},{name:"a_normal",size:2,type:gr},{name:"a_color",size:4,type:od,normalized:!0},{name:"a_id",size:4,type:od,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:gr},{name:"a_normalCoef",size:1,type:gr}],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,y=d-u,v=m*m+y*y,w=0,b=0;v&&(v=1/Math.sqrt(v),w=-y*v*l,b=m*v*l);var k=this.array;k[i++]=c,k[i++]=u,k[i++]=h,k[i++]=d,k[i++]=w,k[i++]=b,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)}}])})(Ba);var Nd=Jn(Di()),Ii=(function(e){function t(){var n;return be(this,t),n=Me(this,t),n.rawEmitter=n,n}return Oe(t,e),xe(t)})(Nd.EventEmitter);var Gd=Jn(ja());var Vv=function(t){return t},jv=function(t){return t*t},qv=function(t){return t*(2-t)},Yv=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Xv=function(t){return t*t*t},Zv=function(t){return--t*t*t+1},Qv=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Md={linear:Vv,quadraticIn:jv,quadraticOut:qv,quadraticInOut:Yv,cubicIn:Xv,cubicOut:Zv,cubicInOut:Qv},Od={easing:"quadraticInOut",duration:150};function Je(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Gi(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Dd(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 Id(e,t,n){return e[6]=t,e[7]=n,e}function Wt(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],y=t[4],v=t[5],w=t[6],b=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+y*o+v*l,e[4]=m*r+y*a+v*c,e[5]=m*i+y*s+v*u,e[6]=w*n+b*o+k*l,e[7]=w*r+b*a+k*c,e[8]=w*i+b*s+k*u,e}function Mi(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 Jv(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=Jv(t,n);return i?(Wt(h,Id(Je(),s,l)),Wt(h,Gi(Je(),a)),Wt(h,Dd(Je(),o)),Wt(h,Gi(Je(),c/d/2/p,u/d/2/p))):(Wt(h,Gi(Je(),2*(d/c)*p,2*(d/u)*p)),Wt(h,Dd(Je(),-o)),Wt(h,Gi(Je(),1/a)),Wt(h,Id(Je(),-s,-l))),h}function Fd(e,t,n){var r=Mi(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 $d(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 zd(e){if(!(0,Gd.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 Wd(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 qa(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ya(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 Xa(e){var t=zt(e.x,2),n=t[0],r=t[1],i=zt(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 Oi(e){"@babel/helpers - typeof";return Oi=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},Oi(e)}function Za(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 Fi(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 $i={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:cd,defaultDrawNodeLabel:Ka,defaultDrawNodeHover:ud,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:{}},ey={circle:mr},ty={arrow:yd,line:bd};function zi(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 Hd(e){var t=Fi({},$i,e);return t.nodeProgramClasses=Fi({},ey,t.nodeProgramClasses),t.edgeProgramClasses=Fi({},ty,t.edgeProgramClasses),t}var gE=Jn(Di()),mE=Jn(ja()),Wi=1.5,Ud=(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=$($({},Od),o),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:Md[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 y=c(m),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*y),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*y),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*y),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*y),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)}}])})(Ii);function st(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Et(e,t){var n=$($({},st(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function vr(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 ny(e,t){return $($({},Et(e,t)),{},{delta:Yd(e)})}var ry=2;function Hi(e){for(var t=[],n=0,r=Math.min(e.length,ry);n<r;n++)t.push(e[n]);return t}function yr(e,t,n){var r={touches:Hi(e.touches).map(function(i){return st(i,n)}),previousTouches:t.map(function(i){return st(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Yd(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 Xd=(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)})(Ii),iy=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],oy=iy.reduce(function(e,t){return $($({},e),{},R({},t,$i[t]))},{}),ay=(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",oy),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(st(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=st(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=st(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=st(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(),y=m.x+d,v=m.y+p;a.setState({x:y,y:v}),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=Yd(r);if(a){var s=ny(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(st(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}}])})(Xd),sy=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],ly=sy.reduce(function(e,t){return $($({},e),{},R({},t,$i[t]))},{}),cy=(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",ly),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=Hi(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(p){return st(p,i.container)}),this.touchMode===2){var a=zt(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",yr(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",yr(r,this.lastTouches,this.container)),!r.touches.length){var s=st(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=yr(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=yr(r,this.lastTouches,this.container);this.emit("tap",p),this.lastTap={time:Date.now(),position:p.touches[0]||p.previousTouches[0]}}}this.lastTouches=Hi(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Hi(r.touches),a=o.map(function(pe){return st(pe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=yr(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(pe,Ve){var Ee=i.startTouchesPositions[Ve];return Ee&&(pe.x!==Ee.x||pe.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,y=this.renderer.viewportToFramedGraph(a[0]),v=y.x,w=y.y;c.setState({x:u.x+p-v,y:u.y+m-w});break}case 2:{var b={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);b.ratio=F,b.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,Ke=Y/K.height,Lt=F/Y,Fe=_-Y/2/ne,$e=I-Y/2/Ke,Le=[Fe*Math.cos(-b.angle)-$e*Math.sin(-b.angle),$e*Math.cos(-b.angle)+Fe*Math.sin(-b.angle)];Fe=Le[0],$e=Le[1],b.x=Z.x-Fe*Lt,b.y=Z.y+$e*Lt,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Xd);function uy(e){if(Array.isArray(e))return Ci(e)}function dy(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hy(){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 Bd(e){return uy(e)||dy(e)||Oa(e)||hy()}function py(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 Qa(e,t){if(e==null)return{};var n,r,i=py(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 Kd=(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}}])})(),Vd=(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 Kd(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(Kd.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 fy(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 jd=150,qd=50,Tt=Object.prototype.hasOwnProperty;function gy(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 my(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 vy=(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 Vd),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",Xa({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",qa()),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=Hd(o),zi(i.settings),zd(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 Ud,i.bindCameraHandlers(),i.mouseCaptor=new ay(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new cy(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=Qa(i,[r].map(ln));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=Qa(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=Qa(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=za(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=$a.apply(void 0,Bd(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=vr(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=vr(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=vr(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=vr(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",$({},s))};var i=function(a){return function(s){var l=vr(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=za(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=$a.apply(void 0,Bd(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=$d(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=Xa(this.customBBox||this.nodeExtent);var d=new Ud,p=Gn(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var m={},y={},v={},w={},b=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=Ya(this.nodeZExtent,function(Nt){return r.nodeDataCache[Nt].zIndex},k));for(var T=0,F=k.length;T<F;T++){var K=k[T];y[K]=b,w[y[K]]={type:"node",id:K},b++;var Z=this.nodeDataCache[K];this.addNodeToProgram(K,y[K],m[Z.type]++)}for(var Y={},ne=i.edges(),Ke=0,Lt=ne.length;Ke<Lt;Ke++){var Fe=ne[Ke],$e=this.edgeDataCache[Fe];Y[$e.type]=(Y[$e.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(ne=Ya(this.edgeZExtent,function(Nt){return r.edgeDataCache[Nt].zIndex},ne));for(var Le in this.edgePrograms){if(!Tt.call(this.edgePrograms,Le))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Le,'"!'));this.edgePrograms[Le].reallocate(Y[Le]||0),Y[Le]=0}for(var pe=0,Ve=ne.length;pe<Ve;pe++){var Ee=ne[pe];v[Ee]=b,w[v[Ee]]={type:"edge",id:Ee},b++;var re=this.edgeDataCache[Ee];this.addEdgeToProgram(Ee,v[Ee],Y[re.type]++)}return this.itemIDsIndex=w,this.nodeIndices=y,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(u){return i.cleanCameraState(u,o.cameraPanBoundaries&&Oi(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=zt(c.x,2),h=u[0],d=u[1],p=zt(c.y,2),m=p[0],y=p[1],v=[this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:h,y},{cameraState:r}),this.graphToViewport({x:d,y},{cameraState:r})],w=1/0,b=-1/0,k=1/0,_=-1/0;v.forEach(function(Y){var ne=Y.x,Ke=Y.y;w=Math.min(w,ne),b=Math.max(b,ne),k=Math.min(k,Ke),_=Math.max(_,Ke)});var I=b-w,A=_-k,D=this.getDimensions(),O=D.width,U=D.height,T=0,F=0;if(I>=O?b<O-a?T=b-(O-a):w>a&&(T=w-a):b>O+a?T=b-(O+a):w<-a&&(T=w+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);Za(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<-jd||h>this.width+jd||d<-qd||d>this.height+qd)){this.displayedNodeLabels.add(l);var m=this.settings.defaultDrawNodeLabel,y=this.nodePrograms[c.type],v=y?.drawLabel||m;v(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=fy({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Za(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],y=m?.drawLabel||p;y(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],y=r.framedGraphToViewport(m),v=y.x,w=y.y,b=r.scaleSize(m.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[m.type],I=_?.drawHover||k;I(i,$($({key:p},m),{},{size:b,x:v,y:w}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var 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(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(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=Gn(s,l,c,u),this.invMatrix=Gn(s,l,c,u,!0),this.correctionRatio=Fd(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 y=this.edgePrograms[m];y.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=gy(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=my(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 Vd,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=Wd(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,zi(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),zi(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=qa(),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 y=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],v=0,w=y.length;v<w;v++){var b=y[v];if(this.updateEdge(b),o){var k=this.edgeProgramIndex[b];if(k===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],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},y=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(m);return{angle:s,x:(y.x-v.x)*(1-p)+l,y:(y.y-v.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=Mi(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=Mi(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}}])})(Ii),Zd=vy;var th=Jn(Di(),1);function yy(){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=yy;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 Ce(e){return typeof e=="object"&&e!==null}function nh(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 lt(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 Qd(e){return!(!Ce(e)||e.attributes&&!Array.isArray(e.attributes))}function wy(){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 xr=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},M=class e extends xr{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},P=class e extends xr{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},B=class e extends xr{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function rh(e,t){this.key=e,this.attributes=t,this.clear()}rh.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 ih(e,t){this.key=e,this.attributes=t,this.clear()}ih.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function oh(e,t){this.key=e,this.attributes=t,this.clear()}oh.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 ah=0,sh=1,by=2,lh=3;function Rt(e,t,n,r,i,o,a){let s,l,c,u;if(r=""+r,n===ah){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===lh){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===sh?s=l.source:s=l.target,c=i,u=o}return[s,c,u]}function xy(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 ky(e,t,n){e.prototype[t]=function(r,i){let[o]=Rt(this,t,n,r,i);return o.attributes}}function _y(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 Ey(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 Ty(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 Sy(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 Ry(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);if(!Ce(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 Ay(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Rt(this,t,n,r,i,o);if(!Ce(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 Cy(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 Ly=[{name:e=>`get${e}Attribute`,attacher:xy},{name:e=>`get${e}Attributes`,attacher:ky},{name:e=>`has${e}Attribute`,attacher:_y},{name:e=>`set${e}Attribute`,attacher:Ey},{name:e=>`update${e}Attribute`,attacher:Ty},{name:e=>`remove${e}Attribute`,attacher:Sy},{name:e=>`replace${e}Attributes`,attacher:Ry},{name:e=>`merge${e}Attributes`,attacher:Ay},{name:e=>`update${e}Attributes`,attacher:Cy}];function Ny(e){Ly.forEach(function({name:t,attacher:n}){n(e,t("Node"),ah),n(e,t("Source"),sh),n(e,t("Target"),by),n(e,t("Opposite"),lh)})}function Py(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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 Dy(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new B(`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 B(`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 Iy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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 Gy(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new B(`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 B(`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 My(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new B(`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 B(`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 Oy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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 Fy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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(!Ce(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 $y(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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(!Ce(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 zy(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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 B(`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 Wy=[{name:e=>`get${e}Attribute`,attacher:Py},{name:e=>`get${e}Attributes`,attacher:Dy},{name:e=>`has${e}Attribute`,attacher:Iy},{name:e=>`set${e}Attribute`,attacher:Gy},{name:e=>`update${e}Attribute`,attacher:My},{name:e=>`remove${e}Attribute`,attacher:Oy},{name:e=>`replace${e}Attributes`,attacher:Fy},{name:e=>`merge${e}Attributes`,attacher:$y},{name:e=>`update${e}Attributes`,attacher:zy}];function Hy(e){Wy.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 By(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 Ky(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 Ja(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 Vy(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 jy(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 es(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 qy(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 ch(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 Yy(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 ts(e,t,n,r,i,o){let a=t?Ky:By,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 Xy(e,t,n,r){let i=[];return ts(!1,e,t,n,r,function(o){i.push(o)}),i}function Zy(e,t,n){let r=On();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=St(r,Ja(n.in))),t!=="in"&&typeof n.out<"u"&&(r=St(r,Ja(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=St(r,Ja(n.undirected))),r}function ns(e,t,n,r,i,o,a){let s=n?jy:Vy,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 Qy(e,t,n,r,i){let o=[];return ns(!1,e,t,n,r,i,function(a){o.push(a)}),o}function Jy(e,t,n,r){let i=On();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=St(i,es(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=St(i,es(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=St(i,es(n.undirected,r))),i}function ew(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 qy(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 Xy(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 Qy(r,this.multi,i,s,a)}throw new M(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function tw(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,ch(!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 ts(!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 ns(!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,y,v,w,b,k,_)=>{h[p++]=u(m,y,v,w,b,k,_)})}else h=[],c.push((d,p,m,y,v,w,b)=>{h.push(u(d,p,m,y,v,w,b))});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,y,v,w,b)=>{u(d,p,m,y,v,w,b)&&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,y,v,w,b,k)=>{d=u(d,p,m,y,v,w,b,k)}),this[o].apply(this,c),d}}function nw(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,ch(!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 ts(!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 ns(!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,y,v,w)=>c(h,d,p,m,y,v,w)),!!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,y,v,w)=>!c(h,d,p,m,y,v,w)),!this[o].apply(this,l)}}function rw(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 Yy(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 Zy(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 Jy(r,i,l,s)}throw new M(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function iw(e){Uy.forEach(t=>{ew(e,t),tw(e,t),nw(e,t),rw(e,t)})}var ow=[{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 Yi(){this.A=null,this.B=null}Yi.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};Yi.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function wr(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 rs(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return wr(e,null,r,r.undirected,i);if(typeof n=="string")return wr(e,null,r,r[n],i)}let o=new Yi,a;if(t!=="undirected"){if(n!=="out"){if(a=wr(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=wr(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=wr(e,o,r,r.undirected,i),e&&a))return a}function aw(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 rs(!1,e,t,n,function(i){r.push(i)}),r}function br(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 sw(e,t,n){if(e!=="mixed"){if(e==="undirected")return br(null,n,n.undirected);if(typeof t=="string")return br(null,n,n[t])}let r=On(),i=new Yi;return e!=="undirected"&&(t!=="out"&&(r=St(r,br(i,n,n.in))),t!=="in"&&(r=St(r,br(i,n,n.out)))),e!=="directed"&&(r=St(r,br(i,n,n.undirected))),r}function lw(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 aw(r==="mixed"?this.type:r,i,a)}}function cw(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.`);rs(!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 uw(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 rs(!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 dw(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 sw(r==="mixed"?this.type:r,i,s)}}function hw(e){ow.forEach(t=>{lw(e,t),cw(e,t),uw(e,t),dw(e,t)})}function Ui(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 pw(e,t){let n={key:e};return nh(t.attributes)||(n.attributes=ke({},t.attributes)),n}function fw(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return nh(n.attributes)||(r.attributes=ke({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function gw(e){if(!Ce(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&&(!Ce(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function mw(e){if(!Ce(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&&(!Ce(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 vw=wy(),yw=new Set(["directed","undirected","mixed"]),Jd=new Set(["domain","_events","_eventsCount","_maxListeners"]),ww=[{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"}],bw={allowSelfLoops:!0,multi:!1,type:"mixed"};function xw(e,t,n){if(n&&!Ce(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 B(`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 eh(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 uh(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new B(`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 B(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Ce(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 B(`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 B(`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 B(`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 kw(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new B(`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 B(`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(!Ce(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 B(`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 B(`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 b=[p.key,!1,!1,!1];if(l?!c:!s)return b;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 b}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 B(`Graph.${t}: the "${i}" edge already exists in the graph.`);let y=!1,v=!1;u||(u=eh(e,o,{}),y=!0,o===a&&(h=u,v=!0)),h||(h=eh(e,a,{}),v=!0),d=new Fn(r,i,u,h,s),e._edges.set(i,d);let w=o===a;return r?(u.undirectedDegree++,h.undirectedDegree++,w&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,w&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,m.key=i,e.emit("edgeAdded",m),[i,!0,y,v]}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 th.EventEmitter{constructor(t){if(super(),t=ke({},bw,t),typeof t.multi!="boolean")throw new M(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!yw.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"?rh:t.type==="directed"?ih:oh;et(this,"NodeDataClass",n);let r="geid_"+vw()+"_",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),Jd.forEach(a=>et(this,a,this[a])),lt(this,"order",()=>this._nodes.size),lt(this,"size",()=>this._edges.size),lt(this,"directedSize",()=>this._directedSize),lt(this,"undirectedSize",()=>this._undirectedSize),lt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),lt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),lt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),lt(this,"multi",this._options.multi),lt(this,"type",this._options.type),lt(this,"allowSelfLoops",this._options.allowSelfLoops),lt(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 B("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 B("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 B("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 xw(this,t,n).key}mergeNode(t,n){if(n&&!Ce(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 B("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 B("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 B("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 B("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(!Ce(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(!Ce(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&&!Qd(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&&!Qd(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.");Ui(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ui(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ui(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ui(!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++]=pw(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=fw(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(!Ce(t))throw new M("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Ce(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],gw(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],mw(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 B(`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 B("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 B("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,uh(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)&&!Jd.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);ww.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?uh:kw;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")}})});Ny(oe);Hy(oe);iw(oe);hw(oe);var Bi=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)}},Ki=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)}},Vi=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)}},ji=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)}},qi=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(Bi);$n(Ki);$n(Vi);$n(ji);$n(qi);oe.Graph=oe;oe.DirectedGraph=Bi;oe.UndirectedGraph=Ki;oe.MultiGraph=Vi;oe.MultiDirectedGraph=ji;oe.MultiUndirectedGraph=qi;oe.InvalidArgumentsGraphError=M;oe.NotFoundGraphError=P;oe.UsageGraphError=B;function _w(){return new oe({multi:!0,type:"directed"})}function is(e){let t=_w();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 dh(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 os(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var hh=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function ph(e,t,n){let r=null,i=is({nodes:[],edges:[]}),o=null,a=null,s=0,l=0,c=null,u=0,h=()=>{},d=()=>{},p=()=>{},m=()=>{},y=()=>{},v=null,w=!1,b=A=>{if(v===null)return;let D=v;v=null,r?.setSetting("enableCameraPanning",!0),(A===null||A===D)&&y(D)},k=()=>lu([...os(i).values()]),_=A=>{let D=hu(o,a,s),O=fu(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=pu(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,gu(t));D.on("clickNode",({node:O})=>{w||h(O)}),D.on("doubleClickNode",({node:O,preventSigmaDefault:U})=>{U(),w||h(O)}),D.on("clickStage",()=>h(null)),D.on("downNode",({node:O})=>{v=O,w=!1,r?.setSetting("enableCameraPanning",!1),p(O)}),D.on("moveBody",O=>{v!==null&&(w=!0,O.preventSigmaDefault(),m(v,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",()=>b(v)),D.on("upStage",()=>b(null)),_(D),D.setCustomBBox(k()),r=D},setGraph(A){i=is(A),r?.setGraph(i),r?.setCustomBBox(k())},setPositions(A){dh(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){y=A},fit(){r?.setCustomBBox(k()),r?.getCamera().animatedReset()},positions(){return os(i)},destroy(){c!==null&&(n?.cancel(c),c=null),r?.kill(),r=null}}}var fh=e=>ph((t,n,r)=>new Zd(t,n,r),e,hh(window));function gh(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 Ew(e){if(Array.isArray(e))return e}function Tw(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 Sw(){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 Rw(e,t){return Ew(e)||Tw(e,t)||Aw(e,t)||Sw()}function Aw(e,t){if(e){if(typeof e=="string")return gh(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)?gh(e,t):void 0}}var Lh=Object.entries,mh=Object.setPrototypeOf,Cw=Object.isFrozen,Lw=Object.getPrototypeOf,Nw=Object.getOwnPropertyDescriptor,_e=Object.freeze,Re=Object.seal,zn=Object.create,Nh=typeof Reflect<"u"&&Reflect,hs=Nh.apply,ps=Nh.construct;_e||(_e=function(t){return t});Re||(Re=function(t){return t});hs||(hs=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)});ps||(ps=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=we(Array.prototype.forEach),Pw=we(Array.prototype.lastIndexOf),vh=we(Array.prototype.pop),kr=we(Array.prototype.push),Dw=we(Array.prototype.splice),Wn=Array.isArray,Tr=we(String.prototype.toLowerCase),as=we(String.prototype.toString),yh=we(String.prototype.match),_r=we(String.prototype.replace),wh=we(String.prototype.indexOf),Iw=we(String.prototype.trim),Gw=we(Number.prototype.toString),Mw=we(Boolean.prototype.toString),bh=typeof BigInt>"u"?null:we(BigInt.prototype.toString),xh=typeof Symbol>"u"?null:we(Symbol.prototype.toString),Ue=we(Object.prototype.hasOwnProperty),Er=we(Object.prototype.toString),Pe=we(RegExp.prototype.test),un=Ow(TypeError);function we(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 hs(e,t,r)}}function Ow(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ps(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tr;if(mh&&mh(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&&(Cw(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Fw(e){for(let t=0;t<e.length;t++)Ue(e,t)||(e[t]=null);return e}function Xe(e){let t=zn(null);for(let r of Lh(e)){var n=Rw(r,2);let i=n[0],o=n[1];Ue(e,i)&&(Wn(o)?t[i]=Fw(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Xe(o):t[i]=o)}return t}function $w(e){switch(typeof e){case"string":return e;case"number":return Gw(e);case"boolean":return Mw(e);case"bigint":return bh?bh(e):"0";case"symbol":return xh?xh(e):"Symbol()";case"undefined":return Er(e);case"function":case"object":{if(e===null)return Er(e);let t=e,n=ct(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:Er(r)}return Er(e)}default:return Er(e)}}function ct(e,t){for(;e!==null;){let r=Nw(e,t);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}e=Lw(e)}function n(){return null}return n}function zw(e){try{return Pe(e,""),!0}catch{return!1}}var kh=_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"]),ss=_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"]),ls=_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"]),Ww=_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"]),cs=_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"]),Hw=_e(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_h=_e(["#text"]),Eh=_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"]),us=_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"]),Th=_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"]),Xi=_e(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Uw=Re(/{{[\w\W]*|^[\w\W]*}}/g),Bw=Re(/<%[\w\W]*|^[\w\W]*%>/g),Kw=Re(/\${[\w\W]*/g),Vw=Re(/^data-[\-\w.\u00B7-\uFFFF]+$/),jw=Re(/^aria-[\-\w]+$/),Sh=Re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qw=Re(/^(?:\w+script|data):/i),Yw=Re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xw=Re(/^html$/i),Zw=Re(/^[a-z][.\w]*(-[.\w]+)+$/i),Rh=Re(/<[/\w!]/g),Ah=Re(/<[/\w]/g),Qw=Re(/<\/no(script|embed|frames)/i),Jw=Re(/\/>/i),Ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ph=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],eb=_e(J({},Ph)),tb=(function(){let e={};return dn(Ph,t=>{e[t]=Re(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),_e(e)})(),nb=function(){return typeof window>"u"?null:window},rb=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}},Ch=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ht=function(t,n,r,i){return Ue(t,n)&&Wn(t[n])?J(i.base?Xe(i.base):{},t[n],i.transform):r},ds=function(t,n,r){let i=Ue(t,n)?t[n]:void 0;return i&&typeof i=="object"?Xe(i):r()};function Dh(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nb(),t=L=>Dh(L);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==Ye.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=ct(d,"cloneNode"),m=ct(d,"remove"),y=ct(d,"nextSibling"),v=ct(d,"childNodes"),w=ct(d,"parentNode"),b=ct(d,"shadowRoot"),k=ct(d,"attributes"),_=a&&a.prototype?ct(a.prototype,"nodeType"):null,I=a&&a.prototype?ct(a.prototype,"nodeName"):null,A=a&&a.prototype?ct(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 L=n.createElement("template");L.content&&L.content.ownerDocument&&(n=L.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--}},Ke=function(g){Y(),Z++;try{return U.createScriptURL(g)}finally{Z--}},Lt=function(){return K||(F=rb(h,i),K=!0),F},Fe=n,$e=Fe.implementation,Le=Fe.createNodeIterator,pe=Fe.createDocumentFragment,Ve=Fe.getElementsByTagName,Ee=r.importNode,re=Ch();t.isSupported=typeof Lh=="function"&&typeof w=="function"&&$e&&$e.createHTMLDocument!==void 0;let Nt=Uw,Pt=Bw,Nr=Kw,Pr=Vw,vo=jw,yo=qw,Dr=Yw,Ir=Zw,mn=Sh,ee=null,Kn=J({},[...kh,...ss,...ls,...cs,..._h]),X=null,Ne=J({},[...Eh,...us,...Th,...Xi]),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}})),dt=null,Gr=null,ve=Object.seal(zn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Bt=!0,rt=!0,Qe=!1,Vn=!0,it=!1,mt=!0,vt=!1,jn=!1,vn=null,Kt=null,qn=!1,yt=!1,Vt=!1,jt=!1,Yn=!0,Mr=!1,E="user-content-",N=!0,H=!1,C={},z=null,fe=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"]),ot=null,Dt=J({},["audio","video","img","source","image","track"]),Xn=null,Or=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fr="http://www.w3.org/1998/Math/MathML",$r="http://www.w3.org/2000/svg",ht="http://www.w3.org/1999/xhtml",yn=ht,wo=!1,bo=null,_f=J({},[Fr,$r,ht],as),Is=_e(["mi","mo","mn","ms","mtext"]),xo=J({},Is),Gs=_e(["annotation-xml"]),ko=J({},Gs),Ef=J({},["title","style","font","a","script"]),Zn=null,Tf=["application/xhtml+xml","text/html"],Sf="text/html",ge=null,wn=null,Rf=n.createElement("form"),Ms=function(g){return g instanceof RegExp||g instanceof Function},_o=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(wn&&wn===g)return;(!g||typeof g!="object")&&(g={}),g=Xe(g),Zn=Tf.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sf:g.PARSER_MEDIA_TYPE,ge=Zn==="application/xhtml+xml"?as:Tr,ee=Ht(g,"ALLOWED_TAGS",Kn,{transform:ge}),X=Ht(g,"ALLOWED_ATTR",Ne,{transform:ge}),bo=Ht(g,"ALLOWED_NAMESPACES",_f,{transform:as}),Xn=Ht(g,"ADD_URI_SAFE_ATTR",Or,{transform:ge,base:Or}),ot=Ht(g,"ADD_DATA_URI_TAGS",Dt,{transform:ge,base:Dt}),z=Ht(g,"FORBID_CONTENTS",fe,{transform:ge}),dt=Ht(g,"FORBID_TAGS",Xe({}),{transform:ge}),Gr=Ht(g,"FORBID_ATTR",Xe({}),{transform:ge}),C=Ue(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?Xe(g.USE_PROFILES):g.USE_PROFILES:!1,Bt=g.ALLOW_ARIA_ATTR!==!1,rt=g.ALLOW_DATA_ATTR!==!1,Qe=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Vn=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,it=g.SAFE_FOR_TEMPLATES||!1,mt=g.SAFE_FOR_XML!==!1,vt=g.WHOLE_DOCUMENT||!1,yt=g.RETURN_DOM||!1,Vt=g.RETURN_DOM_FRAGMENT||!1,jt=g.RETURN_TRUSTED_TYPE||!1,qn=g.FORCE_BODY||!1,Yn=g.SANITIZE_DOM!==!1,Mr=g.SANITIZE_NAMED_PROPS||!1,N=g.KEEP_CONTENT!==!1,H=g.IN_PLACE||!1,mn=zw(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:Sh,yn=typeof g.NAMESPACE=="string"?g.NAMESPACE:ht,xo=ds(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>J({},Is)),ko=ds(g,"HTML_INTEGRATION_POINTS",()=>J({},Gs));let x=ds(g,"CUSTOM_ELEMENT_HANDLING",()=>zn(null));if(Te=zn(null),Ue(x,"tagNameCheck")&&Ms(x.tagNameCheck)&&(Te.tagNameCheck=x.tagNameCheck),Ue(x,"attributeNameCheck")&&Ms(x.attributeNameCheck)&&(Te.attributeNameCheck=x.attributeNameCheck),Ue(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(Te.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),Re(Te),it&&(rt=!1),Vt&&(yt=!0),C&&(ee=J({},_h),X=zn(null),C.html===!0&&(J(ee,kh),J(X,Eh)),C.svg===!0&&(J(ee,ss),J(X,us),J(X,Xi)),C.svgFilters===!0&&(J(ee,ls),J(X,us),J(X,Xi)),C.mathMl===!0&&(J(ee,cs),J(X,Th),J(X,Xi))),ve.tagCheck=null,ve.attributeCheck=null,Ue(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?ve.tagCheck=g.ADD_TAGS:Wn(g.ADD_TAGS)&&(ee===Kn&&(ee=Xe(ee)),J(ee,g.ADD_TAGS,ge))),Ue(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?ve.attributeCheck=g.ADD_ATTR:Wn(g.ADD_ATTR)&&(X===Ne&&(X=Xe(X)),J(X,g.ADD_ATTR,ge))),Ue(g,"ADD_FORBID_CONTENTS")&&Wn(g.ADD_FORBID_CONTENTS)&&(z===fe&&(z=Xe(z)),J(z,g.ADD_FORBID_CONTENTS,ge)),N&&(ee["#text"]=!0),vt&&J(ee,["html","head","body"]),ee.table&&(J(ee,["tbody"]),delete dt.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),wn=g},Os=J({},[...ss,...ls,...Ww]),Fs=J({},[...cs,...Hw]),Af=function(g,x,S){return x.namespaceURI===ht?g==="svg":x.namespaceURI===Fr?g==="svg"&&(S==="annotation-xml"||xo[S]):!!Os[g]},Cf=function(g,x,S){return x.namespaceURI===ht?g==="math":x.namespaceURI===$r?g==="math"&&ko[S]:!!Fs[g]},Lf=function(g,x,S){return x.namespaceURI===$r&&!ko[S]||x.namespaceURI===Fr&&!xo[S]?!1:!Fs[g]&&(Ef[g]||!Os[g])},Nf=function(g){let x=w(g);(!x||!x.tagName)&&(x={namespaceURI:yn,tagName:"template"});let S=Tr(g.tagName),G=Tr(x.tagName);return bo[g.namespaceURI]?g.namespaceURI===$r?Af(S,x,G):g.namespaceURI===Fr?Cf(S,x,G):g.namespaceURI===ht?Lf(S,x,G):!!(Zn==="application/xhtml+xml"&&bo[g.namespaceURI]):!1},It=function(g){kr(t.removed,{element:g});try{w(g).removeChild(g)}catch{if(m(g),!w(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")}},$s=function(g,x,S){try{g.removeAttributeNode(x)}catch{try{g.removeAttribute(S)}catch{}}},zr=function(g){Wr(g);let x=v(g);if(x){let G=[];dn(x,W=>{kr(G,W)}),dn(G,W=>{try{m(W)}catch{}})}let S=k(g);if(S)for(let G=S.length-1;G>=0;--G){let W=S[G],V=W&&W.name;typeof V=="string"&&$s(g,W,V)}},qt=function(g,x,S){if(!S)try{S=x.getAttributeNode(g)}catch{S=null}kr(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||Vt)try{It(x)}catch{}else try{x.setAttribute(g,"")}catch{}},Pf=function(g){let x=k(g);if(x)for(let S=x.length-1;S>=0;--S){let G=x[S],W=G&&G.name;typeof W!="string"||X[ge(W)]||$s(g,G,W)}},Wr=function(g){let x=[g];for(;x.length>0;){let S=x.pop();D(S)===Ye.element&&Pf(S);let W=v(S);if(W)for(let V=W.length-1;V>=0;--V)x.push(W[V])}},zs=function(g,x){return mt?g==="patchsrc"?!0:g==="for"&&x!=="label"&&x!=="output":!1},Df=function(g){if(!mt)return;let x=[g];for(;x.length>0;){let S=x.pop(),G=D(S);if(G===Ye.processingInstruction||G===Ye.comment&&Pe(Ah,S.data)){try{m(S)}catch{}continue}if(G===Ye.element){let V=S,se=ge(O(S));try{V.hasAttribute&&V.hasAttribute("patchsrc")&&V.removeAttribute("patchsrc"),V.hasAttribute&&V.hasAttribute("for")&&zs("for",se)&&V.removeAttribute("for")}catch{}}let W=v(S);if(W)for(let V=W.length-1;V>=0;--V)x.push(W[V])}},Ws=function(g){let x=null,S=null;if(qn)g="<remove></remove>"+g;else{let V=yh(g,/^[\r\n\t ]+/);S=V&&V[0]}Zn==="application/xhtml+xml"&&yn===ht&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let G=U?ne(g):g;if(yn===ht)try{x=new u().parseFromString(G,Zn)}catch{}if(!x||!x.documentElement){x=$e.createDocument(yn,"template",null);try{x.documentElement.innerHTML=wo?T:G}catch{}}let W=x.body||x.documentElement;return g&&S&&W.insertBefore(n.createTextNode(S),W.childNodes[0]||null),yn===ht?Ve.call(x,vt?"html":"body")[0]:vt?x.documentElement:W},Hs=function(g){let x=A?A(g):g.ownerDocument;return Le.call(x||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Hr=function(g){return g=_r(g,Nt," "),g=_r(g,Pt," "),g=_r(g,Nr," "),g},Eo=function(g){var x;g.normalize();let S=A?A(g):g.ownerDocument,G=Le.call(S||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),W=G.nextNode();for(;W;)W.data=Hr(W.data),W=G.nextNode();let V=(x=g.querySelectorAll)===null||x===void 0?void 0:x.call(g,"template");V&&dn(V,se=>{bn(se.content)&&Eo(se.content)})},Ur=function(g){let x=I?I(g):null;return typeof x!="string"||ge(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!==v(g)},bn=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return _(g)===Ye.documentFragment}catch{return!1}},Qn=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return typeof _(g)=="number"}catch{return!1}};function pt(L,g,x){L.length!==0&&dn(L,S=>{S.call(t,g,x,wn)})}let If=function(g,x){return!!(mt&&g.hasChildNodes()&&!Qn(g.firstElementChild)&&Pe(Rh,g.textContent)&&Pe(Rh,g.innerHTML)||mt&&g.namespaceURI===ht&&eb[x]&&(Qn(g.firstElementChild)||typeof g.textContent=="string"&&Pe(tb[x],g.textContent))||g.nodeType===Ye.processingInstruction||mt&&g.nodeType===Ye.comment&&Pe(Ah,g.data))},Br=function(g,x){if(g instanceof RegExp)return Pe(g,x);if(g instanceof Function){for(var S=arguments.length,G=new Array(S>2?S-2:0),W=2;W<S;W++)G[W-2]=arguments[W];return!!g(x,...G)}return!1},Gf=function(g,x,S){if(!dt[x]&&js(x)&&Br(Te.tagNameCheck,x))return!1;if(N&&!z[x]){let G=w(g),W=v(g);if(W&&G){let V=W.length;for(let se=V-1;se>=0;--se){let ue=g===S?p(W[se],!0):W[se];G.insertBefore(ue,y(g))}}}return It(g),!0},Us=function(g,x,S,G){return g.length===0?x:x===S||x===G?Xe(x):x},Bs=function(g,x){return g===x||w(g)!==null?!1:(H&&Wr(g),!0)},Ks=function(g,x){if(pt(re.beforeSanitizeElements,g,null),Bs(g,x))return!0;if(Ur(g))return It(g),!0;let S=ge(O(g));if(ee=Us(re.uponSanitizeElement,ee,Kn,vn),pt(re.uponSanitizeElement,g,{tagName:S,allowedTags:ee}),Bs(g,x))return!0;if(If(g,S))return It(g),!0;if(dt[S]||!(ve.tagCheck instanceof Function&&ve.tagCheck(S))&&!ee[S]){let W=Gf(g,S,x);return W===!1&&pt(re.afterSanitizeElements,g,null),W}if(D(g)===Ye.element&&!Nf(g)||(S==="noscript"||S==="noembed"||S==="noframes")&&Pe(Qw,g.innerHTML))return It(g),!0;if(it&&g.nodeType===Ye.text){let W=Hr(g.textContent);g.textContent!==W&&(kr(t.removed,{element:g.cloneNode()}),g.textContent=W)}return pt(re.afterSanitizeElements,g,null),!1},Vs=function(g,x,S){if(Gr[x]||zs(x,g)||Yn&&(x==="id"||x==="name")&&(S in n||S in Rf))return!1;let G=X[x]||ve.attributeCheck instanceof Function&&ve.attributeCheck(x,g);return rt&&Pe(Pr,x)||Bt&&Pe(vo,x)?!0:G?Xn[x]||Pe(mn,_r(S,Dr,""))||(x==="src"||x==="xlink:href"||x==="href")&&g!=="script"&&wh(S,"data:")===0&&ot[g]||Qe&&!Pe(yo,_r(S,Dr,""))?!0:!S:js(g)&&Br(Te.tagNameCheck,g)&&Br(Te.attributeNameCheck,x,g)||x==="is"&&Te.allowCustomizedBuiltInElements&&Br(Te.tagNameCheck,S)},Mf=J({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),js=function(g){return!Mf[Tr(g)]&&Pe(Ir,g)},Of=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 Ke(G)}return G},Ff=function(g,x,S,G){try{S?g.setAttributeNS(S,x,G):g.setAttribute(x,G),Ur(g)?It(g):vh(t.removed)}catch{qt(x,g)}},qs=function(g){pt(re.beforeSanitizeAttributes,g,null);let x=g.attributes;if(!x||Ur(g))return;X=Us(re.uponSanitizeAttribute,X,Ne,Kt);let S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0},G=x.length,W=ge(g.nodeName);for(;G--;){let V=x[G],se=V.name,ue=V.namespaceURI,ze=V.value,We=ge(se),So=ze,Ie=se==="value"?So:Iw(So);if(S.attrName=We,S.attrValue=Ie,S.keepAttr=!0,S.forceKeepAttr=void 0,pt(re.uponSanitizeAttribute,g,S),Ie=S.attrValue,Mr&&(We==="id"||We==="name")&&wh(Ie,E)!==0&&(qt(se,g,V),Ie=E+Ie),mt&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ie)){qt(se,g,V);continue}if(We==="attributename"&&yh(Ie,"href")){qt(se,g,V);continue}if(!S.forceKeepAttr){if(!S.keepAttr){qt(se,g,V);continue}if(!Vn&&Pe(Jw,Ie)){qt(se,g,V);continue}if(it&&(Ie=Hr(Ie)),!Vs(W,We,Ie)){qt(se,g,V);continue}Ie=Of(W,We,ue,Ie),Ie!==So&&Ff(g,se,ue,Ie)}}pt(re.afterSanitizeAttributes,g,null)},Kr=function(g){let x=null,S=Hs(g);for(pt(re.beforeSanitizeShadowDOM,g,null);x=S.nextNode();)if(pt(re.uponSanitizeShadowNode,x,null),Ks(x,g),qs(x),bn(x.content)&&Kr(x.content),D(x)===Ye.element){let G=b(x);bn(G)&&(To(G),Kr(G))}pt(re.afterSanitizeShadowDOM,g,null)},To=function(g){let x=[{node:g,shadow:null}];for(;x.length>0;){let S=x.pop();if(S.shadow){Kr(S.shadow);continue}let G=S.node,V=D(G)===Ye.element,se=v(G);if(se)for(let ue=se.length-1;ue>=0;--ue)x.push({node:se[ue],shadow:null});if(V){let ue=I?I(G):null;if(typeof ue=="string"&&ge(ue)==="template"){let ze=G.content;bn(ze)&&x.push({node:ze,shadow:null})}}if(V){let ue=b(G);bn(ue)&&x.push({node:null,shadow:ue},{node:ue,shadow:null})}}};return t.sanitize=function(L){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,G=null,W=null;if(wo=!L,wo&&(L="<!-->"),typeof L!="string"&&!Qn(L)&&(L=$w(L),typeof L!="string"))throw un("dirty is not a string, aborting");if(!t.isSupported)return L;jn?(ee=vn,X=Kt):_o(g),(re.uponSanitizeElement.length>0||re.uponSanitizeAttribute.length>0)&&(ee=Xe(ee)),re.uponSanitizeAttribute.length>0&&(X=Xe(X)),t.removed=[];let V=H&&typeof L!="string"&&Qn(L);if(V){Df(L);let ze=O(L);if(typeof ze=="string"){let We=ge(ze);if(!ee[We]||dt[We])throw zr(L),un("root node is forbidden and cannot be sanitized in-place")}if(Ur(L))throw zr(L),un("root node is clobbered and cannot be sanitized in-place");try{To(L)}catch(We){throw zr(L),We}}else if(Qn(L))x=Ws("<!---->"),S=x.ownerDocument.importNode(L,!0),S.nodeType===Ye.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S),To(S);else{if(!yt&&!it&&!vt&&L.indexOf("<")===-1)return U&&jt?ne(L):L;if(x=Ws(L),!x)return yt?null:jt?T:""}x&&qn&&It(x.firstChild);let se=V?L:x;try{let ze=Hs(se);for(;G=ze.nextNode();)Ks(G,se),qs(G),bn(G.content)&&Kr(G.content)}catch(ze){throw V&&(zr(L),dn(t.removed,We=>{We.element&&Wr(We.element)})),ze}if(V)return dn(t.removed,ze=>{ze.element&&Wr(ze.element)}),it&&Eo(L),L;if(yt){if(it&&Eo(x),Vt)for(W=pe.call(x.ownerDocument);x.firstChild;)W.appendChild(x.firstChild);else W=x;return(X.shadowroot||X.shadowrootmode)&&(W=Ee.call(r,W,!0)),W}let ue=vt?x.outerHTML:x.innerHTML;return vt&&ee["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Pe(Xw,x.ownerDocument.doctype.name)&&(ue="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
334
- `+ue),it&&(ue=Hr(ue)),U&&jt?ne(ue):ue},t.setConfig=function(){let L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};_o(L),jn=!0,vn=ee,Kt=X},t.clearConfig=function(){wn=null,jn=!1,vn=null,Kt=null,U=F,T=""},t.isValidAttribute=function(L,g,x){wn||_o({});let S=ge(L),G=ge(g);return Vs(S,G,x)},t.addHook=function(L,g){typeof g=="function"&&Ue(re,L)&&kr(re[L],g)},t.removeHook=function(L,g){if(Ue(re,L)){if(g!==void 0){let x=Pw(re[L],g);return x===-1?void 0:Dw(re[L],x,1)[0]}return vh(re[L])}},t.removeHooks=function(L){Ue(re,L)&&(re[L]=[])},t.removeAllHooks=function(){re=Ch()},t}var Ih=Dh();function vs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var fn=vs();function Hh(e){fn=e}var hn={exec:()=>null};function Hn(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(De.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,t)};return r}var ib=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),De={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:Hn(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Hn(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Hn(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Hn(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Hn(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Hn(e=>new RegExp(`^ {0,${e}}>`))},ob=/^(?:[ \t]*(?:\n|$))+/,ab=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,sb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ar=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ys=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Uh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Bh=q(Uh).replace(/bull/g,ys).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(),cb=q(Uh).replace(/bull/g,ys).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(),ws=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,ub=/^[^\n]+/,bs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,db=q(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",bs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hb=q(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ys).getRegex(),to="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",xs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,pb=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",xs).replace("tag",to).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Kh=e=>q(ws).replace("hr",Ar).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",to).getRegex(),fb=Kh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),gb=Kh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),mb=q(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",gb).getRegex(),ks={blockquote:mb,code:ab,def:db,fences:sb,heading:lb,hr:Ar,html:pb,lheading:Bh,list:hb,newline:ob,paragraph:fb,table:hn,text:ub},Gh=q("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ar).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",to).getRegex(),vb={...ks,lheading:cb,table:Gh,paragraph:q(ws).replace("hr",Ar).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Gh).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",to).getRegex()},yb={...ks,html:q(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",xs).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(ws).replace("hr",Ar).replace("heading",` *#{1,6} *[^
335
- ]`).replace("lheading",Bh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},wb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,bb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Vh=/^( {2,}|\\)\n(?!\s*$)/,xb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,At=/[\p{P}\p{S}]/u,Un=/[\s\p{P}\p{S}]/u,Cr=/[^\s\p{P}\p{S}]/u,kb=q(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Un).getRegex(),_b=/[\p{Pi}\p{Ps}"']/u,jh=/(?!~)[\p{P}\p{S}]/u,Eb=/(?!~)[\s\p{P}\p{S}]/u,Tb=/(?:[^\s\p{P}\p{S}]|~)/u,Sb=q(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ib?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),qh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Rb=q(qh,"u").replace(/punct/g,At).getRegex(),Ab=q(qh,"u").replace(/punct/g,jh).getRegex(),Cb=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Lb=q(Cb,"u").replace(/openQuote/g,_b).replace(/punct/g,At).getRegex(),Yh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Nb=q(Yh,"gu").replace(/notPunctSpace/g,Cr).replace(/punctSpace/g,Un).replace(/punct/g,At).getRegex(),Pb=q(Yh,"gu").replace(/notPunctSpace/g,Tb).replace(/punctSpace/g,Eb).replace(/punct/g,jh).getRegex(),Db="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Ib=q(Db,"gu").replace(/notPunctSpace/g,Cr).replace(/punctSpace/g,Un).replace(/punct/g,At).getRegex(),Gb=q("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Cr).replace(/punctSpace/g,Un).replace(/punct/g,At).getRegex(),Mb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Ob=q(Mb,"gu").replace(/notPunctSpace/g,Cr).replace(/punctSpace/g,Un).replace(/punct/g,At).getRegex(),Fb=q(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,At).getRegex(),$b="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zb=q($b,"gu").replace(/notPunctSpace/g,Cr).replace(/punctSpace/g,Un).replace(/punct/g,At).getRegex(),Wb=q(/\\(punct)/,"gu").replace(/punct/g,At).getRegex(),Hb=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(xs).replace("(?:-->|$)","-->").getRegex(),Bb=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(),Qi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Kb=q(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Qi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Xh=q(/^!?\[(label)\]\[(ref)\]/).replace("label",Qi).replace("ref",bs).getRegex(),Zh=q(/^!?\[(ref)\](?:\[\])?/).replace("ref",bs).getRegex(),Vb=q("reflink|nolink(?!\\()","g").replace("reflink",Xh).replace("nolink",Zh).getRegex(),Mh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_s={_backpedal:hn,anyPunctuation:Wb,autolink:Hb,blockSkip:Sb,br:Vh,code:bb,del:hn,delLDelim:hn,delRDelim:hn,emStrongLDelim:Rb,emStrongRDelimAst:Nb,emStrongRDelimUnd:Gb,escape:wb,link:Kb,nolink:Zh,punctuation:kb,reflink:Xh,reflinkSearch:Vb,tag:Bb,text:xb,url:hn},jb={..._s,emStrongLDelim:Lb,emStrongRDelimAst:Ib,emStrongRDelimUnd:Ob,link:q(/^!?\[(label)\]\((.*?)\)/).replace("label",Qi).getRegex(),reflink:q(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Qi).getRegex()},fs={..._s,emStrongRDelimAst:Pb,emStrongLDelim:Ab,delLDelim:Fb,delRDelim:zb,url:q(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Mh).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",Mh).getRegex()},qb={...fs,br:q(Vh).replace("{2,}","*").getRegex(),text:q(fs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Zi={normal:ks,gfm:vb,pedantic:yb},Sr={normal:_s,gfm:fs,breaks:qb,pedantic:jb},Yb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Oh=e=>Yb[e];function gt(e,t){if(t){if(De.escapeTest.test(e))return e.replace(De.escapeReplace,Oh)}else if(De.escapeTestNoEncode.test(e))return e.replace(De.escapeReplaceNoEncode,Oh);return e}function Fh(e){try{e=encodeURI(e).replace(De.percentDecode,"%")}catch{return null}return e}function $h(e,t){let n=e.replace(De.findPipe,(o,a,s)=>{let l=!1,c=a;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(De.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(De.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 zh(e){let t=e.split(`
331
+ `,Fv=Ov,bd=WebGLRenderingContext,ad=bd.UNSIGNED_BYTE,xr=bd.FLOAT,$v=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],xd=(function(e){function t(){return xe(this,t),ze(this,t,arguments)}return We(t,e),ke(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Fv,FRAGMENT_SHADER_SOURCE:md,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:$v,ATTRIBUTES:[{name:"a_positionStart",size:2,type:xr},{name:"a_positionEnd",size:2,type:xr},{name:"a_normal",size:2,type:xr},{name:"a_color",size:4,type:ad,normalized:!0},{name:"a_id",size:4,type:ad,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:xr},{name:"a_normalCoef",size:1,type:xr}],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=Fn(s.color),m=h-c,w=d-u,v=m*m+w*w,y=0,b=0;v&&(v=1/Math.sqrt(v),y=-w*v*l,b=m*v*l);var k=this.array;k[i++]=c,k[i++]=u,k[i++]=h,k[i++]=d,k[i++]=y,k[i++]=b,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)}}])})(qa);var Pd=ir(zi()),Wi=(function(e){function t(){var n;return xe(this,t),n=ze(this,t),n.rawEmitter=n,n}return We(t,e),ke(t)})(Pd.EventEmitter);var Md=ir(Za());var Vv=function(t){return t},jv=function(t){return t*t},qv=function(t){return t*(2-t)},Yv=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Xv=function(t){return t*t*t},Zv=function(t){return--t*t*t+1},Qv=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Od={linear:Vv,quadraticIn:jv,quadraticOut:qv,quadraticInOut:Yv,cubicIn:Xv,cubicOut:Zv,cubicInOut:Qv},Fd={easing:"quadraticInOut",duration:150};function ot(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Hi(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Id(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 Gd(e,t,n){return e[6]=t,e[7]=n,e}function Bt(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],w=t[4],v=t[5],y=t[6],b=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+w*o+v*l,e[4]=m*r+w*a+v*c,e[5]=m*i+w*s+v*u,e[6]=y*n+b*o+k*l,e[7]=y*r+b*a+k*c,e[8]=y*i+b*s+k*u,e}function Ui(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 Jv(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 zn(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=ot(),d=Math.min(c,u)-2*r,p=Jv(t,n);return i?(Bt(h,Gd(ot(),s,l)),Bt(h,Hi(ot(),a)),Bt(h,Id(ot(),o)),Bt(h,Hi(ot(),c/d/2/p,u/d/2/p))):(Bt(h,Hi(ot(),2*(d/c)*p,2*(d/u)*p)),Bt(h,Id(ot(),-o)),Bt(h,Hi(ot(),1/a)),Bt(h,Gd(ot(),-s,-l))),h}function $d(e,t,n){var r=Ui(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 zd(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 Wd(e){if(!(0,Md.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 Hd(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 Qa(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ja(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 es(e){var t=Ut(e.x,2),n=t[0],r=t[1],i=Ut(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 Bi(e){"@babel/helpers - typeof";return Bi=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},Bi(e)}function ts(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 Ki(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:ud,defaultDrawNodeLabel:Ya,defaultDrawNodeHover:dd,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:{}},ew={circle:kr},tw={arrow:yd,line:xd};function ji(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 Ud(e){var t=Ki({},Vi,e);return t.nodeProgramClasses=Ki({},ew,t.nodeProgramClasses),t.edgeProgramClasses=Ki({},tw,t.edgeProgramClasses),t}var gE=ir(zi()),mE=ir(Za()),qi=1.5,Bd=(function(e){function t(){var n;return xe(this,t),n=ze(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 We(t,e),ke(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(z(z({},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=z(z({},Fd),o),l=this.validateState(r),c=typeof s.easing=="function"?s.easing:Od[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 w=c(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||qi)},r):this.animate({ratio:this.ratio/qi})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||qi)},r):this.animate({ratio:this.ratio*qi})}},{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)}}])})(Wi);function dt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Lt(e,t){var n=z(z({},dt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function _r(e){var t="x"in e?e:z(z({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function nw(e,t){return z(z({},Lt(e,t)),{},{delta:Xd(e)})}var rw=2;function Yi(e){for(var t=[],n=0,r=Math.min(e.length,rw);n<r;n++)t.push(e[n]);return t}function Er(e,t,n){var r={touches:Yi(e.touches).map(function(i){return dt(i,n)}),previousTouches:t.map(function(i){return dt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function Xd(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 Zd=(function(e){function t(n,r){var i;return xe(this,t),i=ze(this,t),i.container=n,i.renderer=r,i}return We(t,e),ke(t)})(Wi),iw=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],ow=iw.reduce(function(e,t){return z(z({},e),{},R({},t,Vi[t]))},{}),aw=(function(e){function t(n,r){var i;return xe(this,t),i=ze(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",ow),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 We(t,e),ke(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",Lt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Lt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Lt(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(dt(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=dt(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",Lt(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=dt(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",Lt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Lt(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=dt(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(),w=m.x+d,v=m.y+p;a.setState({x:w,y:v}),this.lastMouseX=l,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Lt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Lt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Xd(r);if(a){var s=nw(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(dt(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}}])})(Zd),sw=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],lw=sw.reduce(function(e,t){return z(z({},e),{},R({},t,Vi[t]))},{}),cw=(function(e){function t(n,r){var i;return xe(this,t),i=ze(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",lw),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 We(t,e),ke(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=Yi(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(p){return dt(p,i.container)}),this.touchMode===2){var a=Ut(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",Er(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",Er(r,this.lastTouches,this.container)),!r.touches.length){var s=dt(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=Er(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=Er(r,this.lastTouches,this.container);this.emit("tap",p),this.lastTap={time:Date.now(),position:p.touches[0]||p.previousTouches[0]}}}this.lastTouches=Yi(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Yi(r.touches),a=o.map(function(Xe){return dt(Xe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Er(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Xe,Mt){var Te=i.startTouchesPositions[Mt];return Te&&(Xe.x!==Te.x||Xe.y!==Te.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,w=this.renderer.viewportToFramedGraph(a[0]),v=w.x,y=w.y;c.setState({x:u.x+p-v,y:u.y+m-y});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},k=a[0],E=k.x,I=k.y,A=a[1],D=A.x,O=A.y,W=Math.atan2(O-I,D-E)-this.startTouchesAngle,T=Math.hypot(O-I,D-E)/this.startTouchesDistance,F=c.getBoundedRatio(u.ratio/T);b.ratio=F,b.angle=u.angle+W;var V=this.getDimensions(),j=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:u}),Q=Math.min(V.width,V.height)-2*h,te=Q/V.width,rt=Q/V.height,Ie=F/Q,Ge=E-Q/2/te,He=I-Q/2/rt,Ye=[Ge*Math.cos(-b.angle)-He*Math.sin(-b.angle),He*Math.cos(-b.angle)+Ge*Math.sin(-b.angle)];Ge=Ye[0],He=Ye[1],b.x=j.x-Ge*Ie,b.y=j.y+He*Ie,c.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Zd);function uw(e){if(Array.isArray(e))return Mi(e)}function dw(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hw(){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 Kd(e){return uw(e)||dw(e)||Wa(e)||hw()}function pw(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 ns(e,t){if(e==null)return{};var n,r,i=pw(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 Vd=(function(){function e(t,n){xe(this,e),this.key=t,this.size=n}return ke(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),jd=(function(){function e(){xe(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 ke(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 Vd(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(Vd.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 fw(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 qd=150,Yd=50,Nt=Object.prototype.hasOwnProperty;function gw(e,t,n){if(!Nt.call(n,"x")||!Nt.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),Nt.call(n,"hidden")||(n.hidden=!1),Nt.call(n,"highlighted")||(n.highlighted=!1),Nt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function mw(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Nt.call(n,"hidden")||(n.hidden=!1),Nt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var vw=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(xe(this,t),i=ze(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 jd),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",ot()),R(i,"invMatrix",ot()),R(i,"correctionRatio",1),R(i,"customBBox",null),R(i,"normalizationFunction",es({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",Qa()),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=Ud(o),ji(i.settings),Wd(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 Bd,i.bindCameraHandlers(),i.mouseCaptor=new aw(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new cw(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return We(t,e),ke(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=ns(i,[r].map(hn));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],c=ns(s,[r].map(hn));l.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=ns(i,[r].map(hn));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=Ba(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=Ua.apply(void 0,Kd(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=_r(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",z(z({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",z(z({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",z(z({},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",z(z({},s),{},{edge:r.hoveredEdge})),u&&r.emit("enterEdge",z(z({},s),{},{edge:u})),r.hoveredEdge=u)}},this.activeListeners.handleMoveBody=function(o){var a=_r(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=_r(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",z(z({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",z(z({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",z({},s))},this.activeListeners.handleEnter=function(o){var a=_r(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",z({},s))};var i=function(a){return function(s){var l=_r(s),c={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},u=r.getNodeAtPosition(l);if(u)return r.emit("".concat(a,"Node"),z(z({},c),{},{node:u}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),z(z({},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=Ba(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=Ua.apply(void 0,Kd(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=zd(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=es(this.customBBox||this.nodeExtent);var d=new Bd,p=zn(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var m={},w={},v={},y={},b=1,k=i.nodes(),E=0,I=k.length;E<I;E++){var A=k[E],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 W in this.nodePrograms){if(!Nt.call(this.nodePrograms,W))throw new Error('Sigma: could not find a suitable program for node type "'.concat(W,'"!'));this.nodePrograms[W].reallocate(m[W]||0),m[W]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=Ja(this.nodeZExtent,function(Ze){return r.nodeDataCache[Ze].zIndex},k));for(var T=0,F=k.length;T<F;T++){var V=k[T];w[V]=b,y[w[V]]={type:"node",id:V},b++;var j=this.nodeDataCache[V];this.addNodeToProgram(V,w[V],m[j.type]++)}for(var Q={},te=i.edges(),rt=0,Ie=te.length;rt<Ie;rt++){var Ge=te[rt],He=this.edgeDataCache[Ge];Q[He.type]=(Q[He.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(te=Ja(this.edgeZExtent,function(Ze){return r.edgeDataCache[Ze].zIndex},te));for(var Ye in this.edgePrograms){if(!Nt.call(this.edgePrograms,Ye))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Ye,'"!'));this.edgePrograms[Ye].reallocate(Q[Ye]||0),Q[Ye]=0}for(var Xe=0,Mt=te.length;Xe<Mt;Xe++){var Te=te[Xe];v[Te]=b,y[v[Te]]={type:"edge",id:Te},b++;var X=this.edgeDataCache[Te];this.addEdgeToProgram(Te,v[Te],Q[X.type]++)}return this.itemIDsIndex=y,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(u){return i.cleanCameraState(u,o.cameraPanBoundaries&&Bi(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=z({},r),c=s||this.nodeExtent,u=Ut(c.x,2),h=u[0],d=u[1],p=Ut(c.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})],y=1/0,b=-1/0,k=1/0,E=-1/0;v.forEach(function(Q){var te=Q.x,rt=Q.y;y=Math.min(y,te),b=Math.max(b,te),k=Math.min(k,rt),E=Math.max(E,rt)});var I=b-y,A=E-k,D=this.getDimensions(),O=D.width,W=D.height,T=0,F=0;if(I>=O?b<O-a?T=b-(O-a):y>a&&(T=y-a):b>O+a?T=b-(O+a):y<-a&&(T=y+a),A>=W?E<W-a?F=E-(W-a):k>a&&(F=k-a):E>W+a?F=E-(W+a):k<-a&&(F=k+a),T||F){var V=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),j=this.viewportToFramedGraph({x:T,y:F},{cameraState:r});T=j.x-V.x,F=j.y-V.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);ts(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<-qd||h>this.width+qd||d<-Yd||d>this.height+Yd)){this.displayedNodeLabels.add(l);var m=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[c.type],v=w?.drawLabel||m;v(o,z(z({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=fw({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ts(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],w=m?.drawLabel||p;w(r,z(z({key:l},d),{},{size:this.scaleSize(d.size)}),z(z(z({key:c[0]},u),this.framedGraphToViewport(u)),{},{size:this.scaleSize(u.size)}),z(z(z({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],w=r.framedGraphToViewport(m),v=w.x,y=w.y,b=r.scaleSize(m.size),k=r.settings.defaultDrawNodeHover,E=r.nodePrograms[m.type],I=E?.drawHover||k;I(i,z(z({key:p},m),{},{size:b,x:v,y}),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(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(),c=this.getGraphDimensions(),u=this.getStagePadding();this.matrix=zn(s,l,c,u),this.invMatrix=zn(s,l,c,u,!0),this.correctionRatio=$d(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=gw(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=mw(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 jd,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=Hd(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=z({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 z({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=z({},this.settings);return this.settings[r]=i,ji(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=z({},this.settings);return this.settings=z(z({},this.settings),r),ji(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=Qa(),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(E){return i.addNode(E)}),this.graph.forEachEdge(function(E){return i.addEdge(E)});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 w=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],v=0,y=w.length;v<y;v++){var b=w[v];if(this.updateEdge(b),o){var k=this.edgeProgramIndex[b];if(k===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],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(z(z({},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},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)+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?zn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Ui(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?zn(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Ui(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}}])})(Wi),Qd=vw;var nh=ir(zi(),1);function ww(){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 _e=ww;typeof Object.assign=="function"&&(_e=Object.assign);function st(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 Ce(e){return typeof e=="object"&&e!==null}function rh(e){let t;for(t in e)return!1;return!0}function at(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function ht(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!(!Ce(e)||e.attributes&&!Array.isArray(e.attributes))}function yw(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Pt(){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 Hn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Rr=class extends Error{constructor(t){super(),this.name="GraphError",this.message=t}},M=class e extends Rr{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},P=class e extends Rr{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}},B=class e extends Rr{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e.prototype.constructor)}};function ih(e,t){this.key=e,this.attributes=t,this.clear()}ih.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 oh(e,t){this.key=e,this.attributes=t,this.clear()}oh.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function ah(e,t){this.key=e,this.attributes=t,this.clear()}ah.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Un(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Un.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)};Un.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};Un.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]};Un.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 sh=0,lh=1,bw=2,ch=3;function Dt(e,t,n,r,i,o,a){let s,l,c,u;if(r=""+r,n===sh){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===ch){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===lh?s=l.source:s=l.target,c=i,u=o}return[s,c,u]}function xw(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(this,t,n,r,i,o);return a.attributes[s]}}function kw(e,t,n){e.prototype[t]=function(r,i){let[o]=Dt(this,t,n,r,i);return o.attributes}}function _w(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(this,t,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function Ew(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=Dt(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 Tw(e,t,n){e.prototype[t]=function(r,i,o,a){let[s,l,c]=Dt(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 Sw(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(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 Rw(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(this,t,n,r,i,o);if(!Ce(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 Aw(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(this,t,n,r,i,o);if(!Ce(s))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return _e(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Cw(e,t,n){e.prototype[t]=function(r,i,o){let[a,s]=Dt(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 Lw=[{name:e=>`get${e}Attribute`,attacher:xw},{name:e=>`get${e}Attributes`,attacher:kw},{name:e=>`has${e}Attribute`,attacher:_w},{name:e=>`set${e}Attribute`,attacher:Ew},{name:e=>`update${e}Attribute`,attacher:Tw},{name:e=>`remove${e}Attribute`,attacher:Sw},{name:e=>`replace${e}Attributes`,attacher:Rw},{name:e=>`merge${e}Attributes`,attacher:Aw},{name:e=>`update${e}Attributes`,attacher:Cw}];function Nw(e){Lw.forEach(function({name:t,attacher:n}){n(e,t("Node"),sh),n(e,t("Source"),lh),n(e,t("Target"),bw),n(e,t("Opposite"),ch)})}function Pw(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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 Dw(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new B(`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=st(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 B(`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 Iw(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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 Gw(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new B(`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=st(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 B(`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 Mw(e,t,n){e.prototype[t]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new B(`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=st(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 B(`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 Ow(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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 Fw(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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(!Ce(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 $w(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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(!Ce(i))throw new M(`Graph.${t}: provided attributes are not a plain object.`);return _e(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function zw(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new B(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new B(`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=st(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 B(`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 Ww=[{name:e=>`get${e}Attribute`,attacher:Pw},{name:e=>`get${e}Attributes`,attacher:Dw},{name:e=>`has${e}Attribute`,attacher:Iw},{name:e=>`set${e}Attribute`,attacher:Gw},{name:e=>`update${e}Attribute`,attacher:Mw},{name:e=>`remove${e}Attribute`,attacher:Ow},{name:e=>`replace${e}Attributes`,attacher:Fw},{name:e=>`merge${e}Attributes`,attacher:$w},{name:e=>`update${e}Attributes`,attacher:zw}];function Hw(e){Ww.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var Uw=[{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 Bw(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 Kw(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 rs(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 Vw(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 jw(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 is(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 qw(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 uh(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 Yw(e,t){if(e.size===0)return Hn();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 os(e,t,n,r,i,o){let a=t?Kw:Bw,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 Xw(e,t,n,r){let i=[];return os(!1,e,t,n,r,function(o){i.push(o)}),i}function Zw(e,t,n){let r=Hn();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=Pt(r,rs(n.in))),t!=="in"&&typeof n.out<"u"&&(r=Pt(r,rs(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=Pt(r,rs(n.undirected))),r}function as(e,t,n,r,i,o,a){let s=n?jw:Vw,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 Qw(e,t,n,r,i){let o=[];return as(!1,e,t,n,r,i,function(a){o.push(a)}),o}function Jw(e,t,n,r){let i=Hn();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=Pt(i,is(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=Pt(i,is(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=Pt(i,is(n.undirected,r))),i}function ey(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 qw(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 Xw(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 Qw(r,this.multi,i,s,a)}throw new M(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function ty(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,uh(!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 os(!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 as(!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,w,v,y,b,k,E)=>{h[p++]=u(m,w,v,y,b,k,E)})}else h=[],c.push((d,p,m,w,v,y,b)=>{h.push(u(d,p,m,w,v,y,b))});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,w,v,y,b)=>{u(d,p,m,w,v,y,b)&&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,w,v,y,b,k)=>{d=u(d,p,m,w,v,y,b,k)}),this[o].apply(this,c),d}}function ny(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,uh(!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 os(!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 as(!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,w,v,y)=>c(h,d,p,m,w,v,y)),!!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,w,v,y)=>!c(h,d,p,m,w,v,y)),!this[o].apply(this,l)}}function ry(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 Hn();if(!arguments.length)return Yw(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 Zw(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 Jw(r,i,l,s)}throw new M(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function iy(e){Uw.forEach(t=>{ey(e,t),ty(e,t),ny(e,t),ry(e,t)})}var oy=[{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 no(){this.A=null,this.B=null}no.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};no.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Tr(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 ss(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Tr(e,null,r,r.undirected,i);if(typeof n=="string")return Tr(e,null,r,r[n],i)}let o=new no,a;if(t!=="undirected"){if(n!=="out"){if(a=Tr(e,null,r,r.in,i),e&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Tr(e,o,r,r.out,i),e&&a)return a;o.wrap(r.out)}}if(t!=="directed"&&(a=Tr(e,o,r,r.undirected,i),e&&a))return a}function ay(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 ss(!1,e,t,n,function(i){r.push(i)}),r}function Sr(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 sy(e,t,n){if(e!=="mixed"){if(e==="undirected")return Sr(null,n,n.undirected);if(typeof t=="string")return Sr(null,n,n[t])}let r=Hn(),i=new no;return e!=="undirected"&&(t!=="out"&&(r=Pt(r,Sr(i,n,n.in))),t!=="in"&&(r=Pt(r,Sr(i,n,n.out)))),e!=="directed"&&(r=Pt(r,Sr(i,n,n.undirected))),r}function ly(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 ay(r==="mixed"?this.type:r,i,a)}}function cy(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.`);ss(!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 uy(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 ss(!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 dy(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 Hn();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 sy(r==="mixed"?this.type:r,i,s)}}function hy(e){oy.forEach(t=>{ly(e,t),cy(e,t),uy(e,t),dy(e,t)})}function Xi(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 py(e,t){let n={key:e};return rh(t.attributes)||(n.attributes=_e({},t.attributes)),n}function fy(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};return rh(n.attributes)||(r.attributes=_e({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function gy(e){if(!Ce(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&&(!Ce(e.attributes)||e.attributes===null))throw new M("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function my(e){if(!Ce(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&&(!Ce(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 vy=yw(),wy=new Set(["directed","undirected","mixed"]),eh=new Set(["domain","_events","_eventsCount","_maxListeners"]),yy=[{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"}],by={allowSelfLoops:!0,multi:!1,type:"mixed"};function xy(e,t,n){if(n&&!Ce(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 B(`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 th(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 dh(e,t,n,r,i,o,a,s){if(!r&&e.type==="undirected")throw new B(`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 B(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!Ce(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 B(`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 B(`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 B(`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 Un(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 ky(e,t,n,r,i,o,a,s,l){if(!r&&e.type==="undirected")throw new B(`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 B(`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(!Ce(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 B(`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 B(`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 b=[p.key,!1,!1,!1];if(l?!c:!s)return b;if(l){let k=p.attributes;p.attributes=c(k),e.emit("edgeAttributesUpdated",{type:"replace",key:p.key,attributes:p.attributes})}else _e(p.attributes,s),e.emit("edgeAttributesUpdated",{type:"merge",key:p.key,attributes:p.attributes,data:s});return b}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 B(`Graph.${t}: the "${i}" edge already exists in the graph.`);let w=!1,v=!1;u||(u=th(e,o,{}),w=!0,o===a&&(h=u,v=!0)),h||(h=th(e,a,{}),v=!0),d=new Un(r,i,u,h,s),e._edges.set(i,d);let y=o===a;return r?(u.undirectedDegree++,h.undirectedDegree++,y&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,y&&(u.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 Wn(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 ie=class e extends nh.EventEmitter{constructor(t){if(super(),t=_e({},by,t),typeof t.multi!="boolean")throw new M(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!wy.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"?ih:t.type==="directed"?oh:ah;at(this,"NodeDataClass",n);let r="geid_"+vy()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};at(this,"_attributes",{}),at(this,"_nodes",new Map),at(this,"_edges",new Map),at(this,"_directedSize",0),at(this,"_undirectedSize",0),at(this,"_directedSelfLoopCount",0),at(this,"_undirectedSelfLoopCount",0),at(this,"_edgeKeyGenerator",o),at(this,"_options",t),eh.forEach(a=>at(this,a,this[a])),ht(this,"order",()=>this._nodes.size),ht(this,"size",()=>this._edges.size),ht(this,"directedSize",()=>this._directedSize),ht(this,"undirectedSize",()=>this._undirectedSize),ht(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ht(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ht(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ht(this,"multi",this._options.multi),ht(this,"type",this._options.type),ht(this,"allowSelfLoops",this._options.allowSelfLoops),ht(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 B("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 B("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 B("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 xy(this,t,n).key}mergeNode(t,n){if(n&&!Ce(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&&(_e(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 Wn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Wn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Wn(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=st(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 Wn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new B("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 B("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=st(this,t,n,"directed");if(!r)throw new P(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Wn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new B("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 B("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=st(this,t,n,"undirected");if(!r)throw new P(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Wn(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(!Ce(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(!Ce(t))throw new M("Graph.mergeAttributes: provided attributes are not a plain object.");return _e(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&&!Jd(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&&!Jd(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.");Xi(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Xi(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new M("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Xi(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new M("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 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++]=py(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=fy(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(!Ce(t))throw new M("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!Ce(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],gy(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],my(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(_e({},this._options,t));return n.replaceAttributes(_e({},this.getAttributes())),n}emptyCopy(t){let n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{let o=_e({},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 B(`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 B("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 B("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,dh(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,_e({},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)&&!eh.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,at(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=ie.prototype.inspect);yy.forEach(e=>{["add","merge","update"].forEach(t=>{let n=e.name(t),r=t==="add"?dh:ky;e.generateKey?ie.prototype[n]=function(i,o,a){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,a,t==="update")}:ie.prototype[n]=function(i,o,a,s){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,a,s,t==="update")}})});Nw(ie);Hw(ie);iy(ie);hy(ie);var Zi=class extends ie{constructor(t){let n=_e({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)}},Qi=class extends ie{constructor(t){let n=_e({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)}},Ji=class extends ie{constructor(t){let n=_e({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)}},eo=class extends ie{constructor(t){let n=_e({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)}},to=class extends ie{constructor(t){let n=_e({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 Bn(e){e.from=function(t,n){let r=_e({},t.options,n),i=new e(r);return i.import(t),i}}Bn(ie);Bn(Zi);Bn(Qi);Bn(Ji);Bn(eo);Bn(to);ie.Graph=ie;ie.DirectedGraph=Zi;ie.UndirectedGraph=Qi;ie.MultiGraph=Ji;ie.MultiDirectedGraph=eo;ie.MultiUndirectedGraph=to;ie.InvalidArgumentsGraphError=M;ie.NotFoundGraphError=P;ie.UsageGraphError=B;function _y(){return new ie({multi:!0,type:"directed"})}function ls(e){let t=_y();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 hh(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 cs(e){let t=new Map;return e.forEachNode((n,r)=>{t.set(n,{x:r.x,y:r.y})}),t}var ph=e=>({now:()=>e.performance.now(),request:t=>e.requestAnimationFrame(()=>t()),cancel:t=>e.cancelAnimationFrame(t)});function fh(e,t,n){let r=null,i=ls({nodes:[],edges:[]}),o=null,a=null,s=0,l=0,c=null,u=0,h=()=>{},d=()=>{},p=()=>{},m=()=>{},w=()=>{},v=null,y=!1,b=A=>{if(v===null)return;let D=v;v=null,r?.setSetting("enableCameraPanning",!0),(A===null||A===D)&&w(D)},k=()=>cu([...cs(i).values()]),E=A=>{let D=pu(o,a,s),O=gu(o,a,s);A.setSetting("nodeReducer",(W,T)=>({...T,...D(W,T,t)})),A.setSetting("edgeReducer",(W,T)=>({...T,...O(W,T,t)}))},I=()=>{if(n===void 0||c!==null)return;u=n.now();let A=()=>{c=null;let D=n.now();if(s=fu(s,l,D-u),u=D,r!==null&&E(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,mu(t));D.on("clickNode",({node:O})=>{y||h(O)}),D.on("doubleClickNode",({node:O,preventSigmaDefault:W})=>{W(),y||h(O)}),D.on("clickStage",()=>h(null)),D.on("downNode",({node:O})=>{v=O,y=!1,r?.setSetting("enableCameraPanning",!1),p(O)}),D.on("moveBody",O=>{v!==null&&(y=!0,O.preventSigmaDefault(),m(v,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",()=>b(v)),D.on("upStage",()=>b(null)),E(D),D.setCustomBBox(k()),r=D},setGraph(A){i=ls(A),r?.setGraph(i),r?.setCustomBBox(k())},setPositions(A){hh(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&&E(r);return}if(A===null){if(l=0,o===null)return}else o=A,a=D,l=1;r!==null&&E(r),s!==l&&I()},onSelect(A){h=A},onHover(A){d=A},onDragStart(A){p=A},onDragMove(A){m=A},onDragEnd(A){w=A},fit(){r?.setCustomBBox(k()),r?.getCamera().animatedReset()},positions(){return cs(i)},destroy(){c!==null&&(n?.cancel(c),c=null),r?.kill(),r=null}}}var gh=e=>fh((t,n,r)=>new Qd(t,n,r),e,ph(window));function mh(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 Ey(e){if(Array.isArray(e))return e}function Ty(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 Sy(){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 Ry(e,t){return Ey(e)||Ty(e,t)||Ay(e,t)||Sy()}function Ay(e,t){if(e){if(typeof e=="string")return mh(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)?mh(e,t):void 0}}var Nh=Object.entries,vh=Object.setPrototypeOf,Cy=Object.isFrozen,Ly=Object.getPrototypeOf,Ny=Object.getOwnPropertyDescriptor,Ee=Object.freeze,Re=Object.seal,Kn=Object.create,Ph=typeof Reflect<"u"&&Reflect,ms=Ph.apply,vs=Ph.construct;Ee||(Ee=function(t){return t});Re||(Re=function(t){return t});ms||(ms=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)});vs||(vs=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 gn=we(Array.prototype.forEach),Py=we(Array.prototype.lastIndexOf),wh=we(Array.prototype.pop),Ar=we(Array.prototype.push),Dy=we(Array.prototype.splice),Vn=Array.isArray,Nr=we(String.prototype.toLowerCase),us=we(String.prototype.toString),yh=we(String.prototype.match),Cr=we(String.prototype.replace),bh=we(String.prototype.indexOf),Iy=we(String.prototype.trim),Gy=we(Number.prototype.toString),My=we(Boolean.prototype.toString),xh=typeof BigInt>"u"?null:we(BigInt.prototype.toString),kh=typeof Symbol>"u"?null:we(Symbol.prototype.toString),je=we(Object.prototype.hasOwnProperty),Lr=we(Object.prototype.toString),Pe=we(RegExp.prototype.test),fn=Oy(TypeError);function we(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 ms(e,t,r)}}function Oy(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return vs(e,n)}}function J(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Nr;if(vh&&vh(e,null),!Vn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){let o=n(i);o!==i&&(Cy(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Fy(e){for(let t=0;t<e.length;t++)je(e,t)||(e[t]=null);return e}function tt(e){let t=Kn(null);for(let r of Nh(e)){var n=Ry(r,2);let i=n[0],o=n[1];je(e,i)&&(Vn(o)?t[i]=Fy(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=tt(o):t[i]=o)}return t}function $y(e){switch(typeof e){case"string":return e;case"number":return Gy(e);case"boolean":return My(e);case"bigint":return xh?xh(e):"0";case"symbol":return kh?kh(e):"Symbol()";case"undefined":return Lr(e);case"function":case"object":{if(e===null)return Lr(e);let t=e,n=pt(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:Lr(r)}return Lr(e)}default:return Lr(e)}}function pt(e,t){for(;e!==null;){let r=Ny(e,t);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}e=Ly(e)}function n(){return null}return n}function zy(e){try{return Pe(e,""),!0}catch{return!1}}var _h=Ee(["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"]),ds=Ee(["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"]),hs=Ee(["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"]),Wy=Ee(["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"]),ps=Ee(["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"]),Hy=Ee(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Eh=Ee(["#text"]),Th=Ee(["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"]),fs=Ee(["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"]),Sh=Ee(["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"]),ro=Ee(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Uy=Re(/{{[\w\W]*|^[\w\W]*}}/g),By=Re(/<%[\w\W]*|^[\w\W]*%>/g),Ky=Re(/\${[\w\W]*/g),Vy=Re(/^data-[\-\w.\u00B7-\uFFFF]+$/),jy=Re(/^aria-[\-\w]+$/),Rh=Re(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qy=Re(/^(?:\w+script|data):/i),Yy=Re(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xy=Re(/^html$/i),Zy=Re(/^[a-z][.\w]*(-[.\w]+)+$/i),Ah=Re(/<[/\w!]/g),Ch=Re(/<[/\w]/g),Qy=Re(/<\/no(script|embed|frames)/i),Jy=Re(/\/>/i),et={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Dh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],eb=Ee(J({},Dh)),tb=(function(){let e={};return gn(Dh,t=>{e[t]=Re(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),Ee(e)})(),nb=function(){return typeof window>"u"?null:window},rb=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}},Lh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Kt=function(t,n,r,i){return je(t,n)&&Vn(t[n])?J(i.base?tt(i.base):{},t[n],i.transform):r},gs=function(t,n,r){let i=je(t,n)?t[n]:void 0;return i&&typeof i=="object"?tt(i):r()};function Ih(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nb(),t=N=>Ih(N);if(t.version="3.4.14",t.removed=[],!e||!e.document||e.document.nodeType!==et.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=pt(d,"cloneNode"),m=pt(d,"remove"),w=pt(d,"nextSibling"),v=pt(d,"childNodes"),y=pt(d,"parentNode"),b=pt(d,"shadowRoot"),k=pt(d,"attributes"),E=a&&a.prototype?pt(a.prototype,"nodeType"):null,I=a&&a.prototype?pt(a.prototype,"nodeName"):null,A=a&&a.prototype?pt(a.prototype,"ownerDocument"):null,D=function(g){return E?E(g):g.nodeType},O=function(g){return I?I(g):g.nodeName};if(typeof o=="function"){let N=n.createElement("template");N.content&&N.content.ownerDocument&&(n=N.content.ownerDocument)}let W,T="",F,V=!1,j=0,Q=function(){if(j>0)throw fn('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.')},te=function(g){Q(),j++;try{return W.createHTML(g)}finally{j--}},rt=function(g){Q(),j++;try{return W.createScriptURL(g)}finally{j--}},Ie=function(){return V||(F=rb(h,i),V=!0),F},Ge=n,He=Ge.implementation,Ye=Ge.createNodeIterator,Xe=Ge.createDocumentFragment,Mt=Ge.getElementsByTagName,Te=r.importNode,X=Lh();t.isSupported=typeof Nh=="function"&&typeof y=="function"&&He&&He.createHTMLDocument!==void 0;let Ze=Uy,jt=By,Eo=Ky,Or=Vy,bt=jy,Fr=qy,xn=Yy,$r=Zy,Xn=Rh,se=null,Zn=J({},[..._h,...ds,...hs,...ps,...Eh]),ee=null,qt=J({},[...Th,...fs,...Sh,...ro]),Le=Object.seal(Kn(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}})),Yt=null,ct=null,me=Object.seal(Kn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Me=!0,kn=!0,ye=!1,gt=!0,Ne=!1,xt=!0,be=!1,Ot=!1,it=null,Oe=null,Qn=!1,kt=!1,Xt=!1,_n=!1,zr=!0,Wr=!1,Hr="user-content-",En=!0,Jn=!1,_t={},Et=null,er=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"]),tr=null,Ur=J({},["audio","video","img","source","image","track"]),_=null,C=J({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),U="http://www.w3.org/1998/Math/MathML",L="http://www.w3.org/2000/svg",$="http://www.w3.org/1999/xhtml",ce=$,Ue=!1,Tt=null,Br=J({},[U,L,$],us),Kr=Ee(["mi","mo","mn","ms","mtext"]),To=J({},Kr),Os=Ee(["annotation-xml"]),So=J({},Os),Ef=J({},["title","style","font","a","script"]),nr=null,Tf=["application/xhtml+xml","text/html"],Sf="text/html",fe=null,Tn=null,Rf=n.createElement("form"),Fs=function(g){return g instanceof RegExp||g instanceof Function},Ro=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tn&&Tn===g)return;(!g||typeof g!="object")&&(g={}),g=tt(g),nr=Tf.indexOf(g.PARSER_MEDIA_TYPE)===-1?Sf:g.PARSER_MEDIA_TYPE,fe=nr==="application/xhtml+xml"?us:Nr,se=Kt(g,"ALLOWED_TAGS",Zn,{transform:fe}),ee=Kt(g,"ALLOWED_ATTR",qt,{transform:fe}),Tt=Kt(g,"ALLOWED_NAMESPACES",Br,{transform:us}),_=Kt(g,"ADD_URI_SAFE_ATTR",C,{transform:fe,base:C}),tr=Kt(g,"ADD_DATA_URI_TAGS",Ur,{transform:fe,base:Ur}),Et=Kt(g,"FORBID_CONTENTS",er,{transform:fe}),Yt=Kt(g,"FORBID_TAGS",tt({}),{transform:fe}),ct=Kt(g,"FORBID_ATTR",tt({}),{transform:fe}),_t=je(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?tt(g.USE_PROFILES):g.USE_PROFILES:!1,Me=g.ALLOW_ARIA_ATTR!==!1,kn=g.ALLOW_DATA_ATTR!==!1,ye=g.ALLOW_UNKNOWN_PROTOCOLS||!1,gt=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ne=g.SAFE_FOR_TEMPLATES||!1,xt=g.SAFE_FOR_XML!==!1,be=g.WHOLE_DOCUMENT||!1,kt=g.RETURN_DOM||!1,Xt=g.RETURN_DOM_FRAGMENT||!1,_n=g.RETURN_TRUSTED_TYPE||!1,Qn=g.FORCE_BODY||!1,zr=g.SANITIZE_DOM!==!1,Wr=g.SANITIZE_NAMED_PROPS||!1,En=g.KEEP_CONTENT!==!1,Jn=g.IN_PLACE||!1,Xn=zy(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:Rh,ce=typeof g.NAMESPACE=="string"?g.NAMESPACE:$,To=gs(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>J({},Kr)),So=gs(g,"HTML_INTEGRATION_POINTS",()=>J({},Os));let x=gs(g,"CUSTOM_ELEMENT_HANDLING",()=>Kn(null));if(Le=Kn(null),je(x,"tagNameCheck")&&Fs(x.tagNameCheck)&&(Le.tagNameCheck=x.tagNameCheck),je(x,"attributeNameCheck")&&Fs(x.attributeNameCheck)&&(Le.attributeNameCheck=x.attributeNameCheck),je(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(Le.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),Re(Le),Ne&&(kn=!1),Xt&&(kt=!0),_t&&(se=J({},Eh),ee=Kn(null),_t.html===!0&&(J(se,_h),J(ee,Th)),_t.svg===!0&&(J(se,ds),J(ee,fs),J(ee,ro)),_t.svgFilters===!0&&(J(se,hs),J(ee,fs),J(ee,ro)),_t.mathMl===!0&&(J(se,ps),J(ee,Sh),J(ee,ro))),me.tagCheck=null,me.attributeCheck=null,je(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?me.tagCheck=g.ADD_TAGS:Vn(g.ADD_TAGS)&&(se===Zn&&(se=tt(se)),J(se,g.ADD_TAGS,fe))),je(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?me.attributeCheck=g.ADD_ATTR:Vn(g.ADD_ATTR)&&(ee===qt&&(ee=tt(ee)),J(ee,g.ADD_ATTR,fe))),je(g,"ADD_FORBID_CONTENTS")&&Vn(g.ADD_FORBID_CONTENTS)&&(Et===er&&(Et=tt(Et)),J(Et,g.ADD_FORBID_CONTENTS,fe)),En&&(se["#text"]=!0),be&&J(se,["html","head","body"]),se.table&&(J(se,["tbody"]),delete Yt.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw fn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let S=W;W=g.TRUSTED_TYPES_POLICY;try{T=te("")}catch(G){throw W=S,G}}else g.TRUSTED_TYPES_POLICY===null?(W=void 0,T=""):(W===void 0&&(W=Ie()),W&&typeof T=="string"&&(T=te("")));Ee&&Ee(g),Tn=g},$s=J({},[...ds,...hs,...Wy]),zs=J({},[...ps,...Hy]),Af=function(g,x,S){return x.namespaceURI===$?g==="svg":x.namespaceURI===U?g==="svg"&&(S==="annotation-xml"||To[S]):!!$s[g]},Cf=function(g,x,S){return x.namespaceURI===$?g==="math":x.namespaceURI===L?g==="math"&&So[S]:!!zs[g]},Lf=function(g,x,S){return x.namespaceURI===L&&!So[S]||x.namespaceURI===U&&!To[S]?!1:!zs[g]&&(Ef[g]||!$s[g])},Nf=function(g){let x=y(g);(!x||!x.tagName)&&(x={namespaceURI:ce,tagName:"template"});let S=Nr(g.tagName),G=Nr(x.tagName);return Tt[g.namespaceURI]?g.namespaceURI===L?Af(S,x,G):g.namespaceURI===U?Cf(S,x,G):g.namespaceURI===$?Lf(S,x,G):!!(nr==="application/xhtml+xml"&&Tt[g.namespaceURI]):!1},Ft=function(g){Ar(t.removed,{element:g});try{y(g).removeChild(g)}catch{if(m(g),!y(g))throw fn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ws=function(g,x,S){try{g.removeAttributeNode(x)}catch{try{g.removeAttribute(S)}catch{}}},Vr=function(g){jr(g);let x=v(g);if(x){let G=[];gn(x,H=>{Ar(G,H)}),gn(G,H=>{try{m(H)}catch{}})}let S=k(g);if(S)for(let G=S.length-1;G>=0;--G){let H=S[G],K=H&&H.name;typeof K=="string"&&Ws(g,H,K)}},Zt=function(g,x,S){if(!S)try{S=x.getAttributeNode(g)}catch{S=null}Ar(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(kt||Xt)try{Ft(x)}catch{}else try{x.setAttribute(g,"")}catch{}},Pf=function(g){let x=k(g);if(x)for(let S=x.length-1;S>=0;--S){let G=x[S],H=G&&G.name;typeof H!="string"||ee[fe(H)]||Ws(g,G,H)}},jr=function(g){let x=[g];for(;x.length>0;){let S=x.pop();D(S)===et.element&&Pf(S);let H=v(S);if(H)for(let K=H.length-1;K>=0;--K)x.push(H[K])}},Hs=function(g,x){return xt?g==="patchsrc"?!0:g==="for"&&x!=="label"&&x!=="output":!1},Df=function(g){if(!xt)return;let x=[g];for(;x.length>0;){let S=x.pop(),G=D(S);if(G===et.processingInstruction||G===et.comment&&Pe(Ch,S.data)){try{m(S)}catch{}continue}if(G===et.element){let K=S,le=fe(O(S));try{K.hasAttribute&&K.hasAttribute("patchsrc")&&K.removeAttribute("patchsrc"),K.hasAttribute&&K.hasAttribute("for")&&Hs("for",le)&&K.removeAttribute("for")}catch{}}let H=v(S);if(H)for(let K=H.length-1;K>=0;--K)x.push(H[K])}},Us=function(g){let x=null,S=null;if(Qn)g="<remove></remove>"+g;else{let K=yh(g,/^[\r\n\t ]+/);S=K&&K[0]}nr==="application/xhtml+xml"&&ce===$&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let G=W?te(g):g;if(ce===$)try{x=new u().parseFromString(G,nr)}catch{}if(!x||!x.documentElement){x=He.createDocument(ce,"template",null);try{x.documentElement.innerHTML=Ue?T:G}catch{}}let H=x.body||x.documentElement;return g&&S&&H.insertBefore(n.createTextNode(S),H.childNodes[0]||null),ce===$?Mt.call(x,be?"html":"body")[0]:be?x.documentElement:H},Bs=function(g){let x=A?A(g):g.ownerDocument;return Ye.call(x||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},qr=function(g){return g=Cr(g,Ze," "),g=Cr(g,jt," "),g=Cr(g,Eo," "),g},Ao=function(g){var x;g.normalize();let S=A?A(g):g.ownerDocument,G=Ye.call(S||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),H=G.nextNode();for(;H;)H.data=qr(H.data),H=G.nextNode();let K=(x=g.querySelectorAll)===null||x===void 0?void 0:x.call(g,"template");K&&gn(K,le=>{Sn(le.content)&&Ao(le.content)})},Yr=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!==E(g)||g.childNodes!==v(g)},Sn=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return E(g)===et.documentFragment}catch{return!1}},rr=function(g){if(!E||typeof g!="object"||g===null)return!1;try{return typeof E(g)=="number"}catch{return!1}};function mt(N,g,x){N.length!==0&&gn(N,S=>{S.call(t,g,x,Tn)})}let If=function(g,x){return!!(xt&&g.hasChildNodes()&&!rr(g.firstElementChild)&&Pe(Ah,g.textContent)&&Pe(Ah,g.innerHTML)||xt&&g.namespaceURI===$&&eb[x]&&(rr(g.firstElementChild)||typeof g.textContent=="string"&&Pe(tb[x],g.textContent))||g.nodeType===et.processingInstruction||xt&&g.nodeType===et.comment&&Pe(Ch,g.data))},Xr=function(g,x){if(g instanceof RegExp)return Pe(g,x);if(g instanceof Function){for(var S=arguments.length,G=new Array(S>2?S-2:0),H=2;H<S;H++)G[H-2]=arguments[H];return!!g(x,...G)}return!1},Gf=function(g,x,S){if(!Yt[x]&&Ys(x)&&Xr(Le.tagNameCheck,x))return!1;if(En&&!Et[x]){let G=y(g),H=v(g);if(H&&G){let K=H.length;for(let le=K-1;le>=0;--le){let de=g===S?p(H[le],!0):H[le];G.insertBefore(de,w(g))}}}return Ft(g),!0},Ks=function(g,x,S,G){return g.length===0?x:x===S||x===G?tt(x):x},Vs=function(g,x){return g===x||y(g)!==null?!1:(Jn&&jr(g),!0)},js=function(g,x){if(mt(X.beforeSanitizeElements,g,null),Vs(g,x))return!0;if(Yr(g))return Ft(g),!0;let S=fe(O(g));if(se=Ks(X.uponSanitizeElement,se,Zn,it),mt(X.uponSanitizeElement,g,{tagName:S,allowedTags:se}),Vs(g,x))return!0;if(If(g,S))return Ft(g),!0;if(Yt[S]||!(me.tagCheck instanceof Function&&me.tagCheck(S))&&!se[S]){let H=Gf(g,S,x);return H===!1&&mt(X.afterSanitizeElements,g,null),H}if(D(g)===et.element&&!Nf(g)||(S==="noscript"||S==="noembed"||S==="noframes")&&Pe(Qy,g.innerHTML))return Ft(g),!0;if(Ne&&g.nodeType===et.text){let H=qr(g.textContent);g.textContent!==H&&(Ar(t.removed,{element:g.cloneNode()}),g.textContent=H)}return mt(X.afterSanitizeElements,g,null),!1},qs=function(g,x,S){if(ct[x]||Hs(x,g)||zr&&(x==="id"||x==="name")&&(S in n||S in Rf))return!1;let G=ee[x]||me.attributeCheck instanceof Function&&me.attributeCheck(x,g);return kn&&Pe(Or,x)||Me&&Pe(bt,x)?!0:G?_[x]||Pe(Xn,Cr(S,xn,""))||(x==="src"||x==="xlink:href"||x==="href")&&g!=="script"&&bh(S,"data:")===0&&tr[g]||ye&&!Pe(Fr,Cr(S,xn,""))?!0:!S:Ys(g)&&Xr(Le.tagNameCheck,g)&&Xr(Le.attributeNameCheck,x,g)||x==="is"&&Le.allowCustomizedBuiltInElements&&Xr(Le.tagNameCheck,S)},Mf=J({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ys=function(g){return!Mf[Nr(g)]&&Pe($r,g)},Of=function(g,x,S,G){if(W&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!S)switch(h.getAttributeType(g,x)){case"TrustedHTML":return te(G);case"TrustedScriptURL":return rt(G)}return G},Ff=function(g,x,S,G){try{S?g.setAttributeNS(S,x,G):g.setAttribute(x,G),Yr(g)?Ft(g):wh(t.removed)}catch{Zt(x,g)}},Xs=function(g){mt(X.beforeSanitizeAttributes,g,null);let x=g.attributes;if(!x||Yr(g))return;ee=Ks(X.uponSanitizeAttribute,ee,qt,Oe);let S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0},G=x.length,H=fe(g.nodeName);for(;G--;){let K=x[G],le=K.name,de=K.namespaceURI,Be=K.value,Ke=fe(le),Lo=Be,Fe=le==="value"?Lo:Iy(Lo);if(S.attrName=Ke,S.attrValue=Fe,S.keepAttr=!0,S.forceKeepAttr=void 0,mt(X.uponSanitizeAttribute,g,S),Fe=S.attrValue,Wr&&(Ke==="id"||Ke==="name")&&bh(Fe,Hr)!==0&&(Zt(le,g,K),Fe=Hr+Fe),xt&&Pe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Fe)){Zt(le,g,K);continue}if(Ke==="attributename"&&yh(Fe,"href")){Zt(le,g,K);continue}if(!S.forceKeepAttr){if(!S.keepAttr){Zt(le,g,K);continue}if(!gt&&Pe(Jy,Fe)){Zt(le,g,K);continue}if(Ne&&(Fe=qr(Fe)),!qs(H,Ke,Fe)){Zt(le,g,K);continue}Fe=Of(H,Ke,de,Fe),Fe!==Lo&&Ff(g,le,de,Fe)}}mt(X.afterSanitizeAttributes,g,null)},Zr=function(g){let x=null,S=Bs(g);for(mt(X.beforeSanitizeShadowDOM,g,null);x=S.nextNode();)if(mt(X.uponSanitizeShadowNode,x,null),js(x,g),Xs(x),Sn(x.content)&&Zr(x.content),D(x)===et.element){let G=b(x);Sn(G)&&(Co(G),Zr(G))}mt(X.afterSanitizeShadowDOM,g,null)},Co=function(g){let x=[{node:g,shadow:null}];for(;x.length>0;){let S=x.pop();if(S.shadow){Zr(S.shadow);continue}let G=S.node,K=D(G)===et.element,le=v(G);if(le)for(let de=le.length-1;de>=0;--de)x.push({node:le[de],shadow:null});if(K){let de=I?I(G):null;if(typeof de=="string"&&fe(de)==="template"){let Be=G.content;Sn(Be)&&x.push({node:Be,shadow:null})}}if(K){let de=b(G);Sn(de)&&x.push({node:null,shadow:de},{node:de,shadow:null})}}};return t.sanitize=function(N){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,G=null,H=null;if(Ue=!N,Ue&&(N="<!-->"),typeof N!="string"&&!rr(N)&&(N=$y(N),typeof N!="string"))throw fn("dirty is not a string, aborting");if(!t.isSupported)return N;Ot?(se=it,ee=Oe):Ro(g),(X.uponSanitizeElement.length>0||X.uponSanitizeAttribute.length>0)&&(se=tt(se)),X.uponSanitizeAttribute.length>0&&(ee=tt(ee)),t.removed=[];let K=Jn&&typeof N!="string"&&rr(N);if(K){Df(N);let Be=O(N);if(typeof Be=="string"){let Ke=fe(Be);if(!se[Ke]||Yt[Ke])throw Vr(N),fn("root node is forbidden and cannot be sanitized in-place")}if(Yr(N))throw Vr(N),fn("root node is clobbered and cannot be sanitized in-place");try{Co(N)}catch(Ke){throw Vr(N),Ke}}else if(rr(N))x=Us("<!---->"),S=x.ownerDocument.importNode(N,!0),S.nodeType===et.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S),Co(S);else{if(!kt&&!Ne&&!be&&N.indexOf("<")===-1)return W&&_n?te(N):N;if(x=Us(N),!x)return kt?null:_n?T:""}x&&Qn&&Ft(x.firstChild);let le=K?N:x;try{let Be=Bs(le);for(;G=Be.nextNode();)js(G,le),Xs(G),Sn(G.content)&&Zr(G.content)}catch(Be){throw K&&(Vr(N),gn(t.removed,Ke=>{Ke.element&&jr(Ke.element)})),Be}if(K)return gn(t.removed,Be=>{Be.element&&jr(Be.element)}),Ne&&Ao(N),N;if(kt){if(Ne&&Ao(x),Xt)for(H=Xe.call(x.ownerDocument);x.firstChild;)H.appendChild(x.firstChild);else H=x;return(ee.shadowroot||ee.shadowrootmode)&&(H=Te.call(r,H,!0)),H}let de=be?x.outerHTML:x.innerHTML;return be&&se["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Pe(Xy,x.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
334
+ `+de),Ne&&(de=qr(de)),W&&_n?te(de):de},t.setConfig=function(){let N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ro(N),Ot=!0,it=se,Oe=ee},t.clearConfig=function(){Tn=null,Ot=!1,it=null,Oe=null,W=F,T=""},t.isValidAttribute=function(N,g,x){Tn||Ro({});let S=fe(N),G=fe(g);return qs(S,G,x)},t.addHook=function(N,g){typeof g=="function"&&je(X,N)&&Ar(X[N],g)},t.removeHook=function(N,g){if(je(X,N)){if(g!==void 0){let x=Py(X[N],g);return x===-1?void 0:Dy(X[N],x,1)[0]}return wh(X[N])}},t.removeHooks=function(N){je(X,N)&&(X[N]=[])},t.removeAllHooks=function(){X=Lh()},t}var Gh=Ih();function xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var wn=xs();function Uh(e){wn=e}var mn={exec:()=>null};function jn(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 Z(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(De.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,t)};return r}var ib=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),De={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:jn(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:jn(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:jn(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:jn(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:jn(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:jn(e=>new RegExp(`^ {0,${e}}>`))},ob=/^(?:[ \t]*(?:\n|$))+/,ab=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,sb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ir=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ks=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Bh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Kh=Z(Bh).replace(/bull/g,ks).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(),cb=Z(Bh).replace(/bull/g,ks).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(),_s=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,ub=/^[^\n]+/,Es=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,db=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Es).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hb=Z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ks).getRegex(),lo="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",Ts=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,pb=Z("^ {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",Ts).replace("tag",lo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vh=e=>Z(_s).replace("hr",Ir).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",lo).getRegex(),fb=Vh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),gb=Vh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),mb=Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",gb).getRegex(),Ss={blockquote:mb,code:ab,def:db,fences:sb,heading:lb,hr:Ir,html:pb,lheading:Kh,list:hb,newline:ob,paragraph:fb,table:mn,text:ub},Mh=Z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ir).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",lo).getRegex(),vb={...Ss,lheading:cb,table:Mh,paragraph:Z(_s).replace("hr",Ir).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Mh).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",lo).getRegex()},wb={...Ss,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ts).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:mn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(_s).replace("hr",Ir).replace("heading",` *#{1,6} *[^
335
+ ]`).replace("lheading",Kh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},yb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,bb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,jh=/^( {2,}|\\)\n(?!\s*$)/,xb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,It=/[\p{P}\p{S}]/u,qn=/[\s\p{P}\p{S}]/u,Gr=/[^\s\p{P}\p{S}]/u,kb=Z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,qn).getRegex(),_b=/[\p{Pi}\p{Ps}"']/u,qh=/(?!~)[\p{P}\p{S}]/u,Eb=/(?!~)[\s\p{P}\p{S}]/u,Tb=/(?:[^\s\p{P}\p{S}]|~)/u,Sb=Z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ib?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Yh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Rb=Z(Yh,"u").replace(/punct/g,It).getRegex(),Ab=Z(Yh,"u").replace(/punct/g,qh).getRegex(),Cb=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Lb=Z(Cb,"u").replace(/openQuote/g,_b).replace(/punct/g,It).getRegex(),Xh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Nb=Z(Xh,"gu").replace(/notPunctSpace/g,Gr).replace(/punctSpace/g,qn).replace(/punct/g,It).getRegex(),Pb=Z(Xh,"gu").replace(/notPunctSpace/g,Tb).replace(/punctSpace/g,Eb).replace(/punct/g,qh).getRegex(),Db="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",Ib=Z(Db,"gu").replace(/notPunctSpace/g,Gr).replace(/punctSpace/g,qn).replace(/punct/g,It).getRegex(),Gb=Z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Gr).replace(/punctSpace/g,qn).replace(/punct/g,It).getRegex(),Mb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Ob=Z(Mb,"gu").replace(/notPunctSpace/g,Gr).replace(/punctSpace/g,qn).replace(/punct/g,It).getRegex(),Fb=Z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,It).getRegex(),$b="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",zb=Z($b,"gu").replace(/notPunctSpace/g,Gr).replace(/punctSpace/g,qn).replace(/punct/g,It).getRegex(),Wb=Z(/\\(punct)/,"gu").replace(/punct/g,It).getRegex(),Hb=Z(/^<(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=Z(Ts).replace("(?:-->|$)","-->").getRegex(),Bb=Z("^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(),oo=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Kb=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",oo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Zh=Z(/^!?\[(label)\]\[(ref)\]/).replace("label",oo).replace("ref",Es).getRegex(),Qh=Z(/^!?\[(ref)\](?:\[\])?/).replace("ref",Es).getRegex(),Vb=Z("reflink|nolink(?!\\()","g").replace("reflink",Zh).replace("nolink",Qh).getRegex(),Oh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Rs={_backpedal:mn,anyPunctuation:Wb,autolink:Hb,blockSkip:Sb,br:jh,code:bb,del:mn,delLDelim:mn,delRDelim:mn,emStrongLDelim:Rb,emStrongRDelimAst:Nb,emStrongRDelimUnd:Gb,escape:yb,link:Kb,nolink:Qh,punctuation:kb,reflink:Zh,reflinkSearch:Vb,tag:Bb,text:xb,url:mn},jb={...Rs,emStrongLDelim:Lb,emStrongRDelimAst:Ib,emStrongRDelimUnd:Ob,link:Z(/^!?\[(label)\]\((.*?)\)/).replace("label",oo).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",oo).getRegex()},ws={...Rs,emStrongRDelimAst:Pb,emStrongLDelim:Ab,delLDelim:Fb,delRDelim:zb,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Oh).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:Z(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Oh).getRegex()},qb={...ws,br:Z(jh).replace("{2,}","*").getRegex(),text:Z(ws.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},io={normal:Ss,gfm:vb,pedantic:wb},Pr={normal:Rs,gfm:ws,breaks:qb,pedantic:jb},Yb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Fh=e=>Yb[e];function yt(e,t){if(t){if(De.escapeTest.test(e))return e.replace(De.escapeReplace,Fh)}else if(De.escapeTestNoEncode.test(e))return e.replace(De.escapeReplaceNoEncode,Fh);return e}function $h(e){try{e=encodeURI(e).replace(De.percentDecode,"%")}catch{return null}return e}function zh(e,t){let n=e.replace(De.findPipe,(o,a,s)=>{let l=!1,c=a;for(;--c>=0&&s[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(De.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(De.slashPipe,"|");return r}function Vt(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 Wh(e){let t=e.split(`
336
336
  `),n=t.length-1;for(;n>=0&&De.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
337
- `)}function Xb(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 Zb(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 Wh(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 Qb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
337
+ `)}function Xb(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 Zb(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 Hh(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 Qb(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
338
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(`
339
- `)}var Ji=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]:zh(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=Qb(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],`
339
+ `)}var ao=class{options;rules;lexer;constructor(e){this.options=e||wn}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]:Wh(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=Qb(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=Vt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Vt(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:Vt(t[0],`
341
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Vt(t[0],`
342
342
  `).split(`
343
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
344
  `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
345
345
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
346
346
  ${c}`:c,i=i?`${i}
347
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
- `),y=p.raw+`
349
- `+m.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(y);o[o.length-1]=v,r=`${r}
348
+ `),w=p.raw+`
349
+ `+m.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(w);o[o.length-1]=v,r=`${r}
350
350
  ${m}`,i=i.substring(0,i.length-p.text.length)+v.text;break}else if(d?.type==="list"){let p=d,m=p.raw+`
351
351
  `+n.join(`
352
- `),y=this.list(m);o[o.length-1]=y,r=r.substring(0,r.length-d.raw.length)+y.raw,i=i.substring(0,i.length-p.raw.length)+y.raw,n=m.substring(o.at(-1).raw.length).split(`
352
+ `),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(`
353
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=Zb(t[2].split(`
354
354
  `,1)[0],t[1].length),d=e.split(`
355
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 y=this.rules.other.nextBulletRegex(m),v=this.rules.other.hrRegex(m),w=this.rules.other.fencesBeginRegex(m),b=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," "),w.test(d)||b.test(d)||k.test(d)||_.test(d)||y.test(d)||v.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||w.test(h)||b.test(h)||v.test(h))break;u+=`
356
+ `,e=e.substring(d.length+1),l=!0),!l){let w=this.rules.other.nextBulletRegex(m),v=this.rules.other.hrRegex(m),y=this.rules.other.fencesBeginRegex(m),b=this.rules.other.headingBeginRegex(m),k=this.rules.other.htmlBeginRegex(m),E=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," "),y.test(d)||b.test(d)||k.test(d)||E.test(d)||w.test(d)||v.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||y.test(h)||b.test(h)||v.test(h))break;u+=`
359
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=zh(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=$h(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($h(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],`
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=Wh(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:Vt(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=zh(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:Vt(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(zh(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:Vt(t[0],`
364
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)===`
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=Xb(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)),Wh(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 Wh(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 y=p.slice(1,-1);return{type:"em",raw:p,text:y,tokens:this.lexer.inlineTokens(y)}}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}}}},Be=class gs{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 Ji,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:De,block:Zi.normal,inline:Sr.normal};this.options.pedantic?(n.block=Zi.pedantic,n.inline=Sr.pedantic):this.options.gfm&&(n.block=Zi.gfm,this.options.breaks?n.inline=Sr.breaks:n.inline=Sr.gfm),this.tokenizer.rules=n}static get rules(){return{block:Zi,inline:Sr}}static lex(t,n){return new gs(n).lex(t)}static lexInline(t,n){return new gs(n).inlineTokens(t)}lex(t){t=t.replace(De.carriageReturn,`
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=Vt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Xb(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)),Hh(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 Hh(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 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 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}}}},qe=class ys{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||wn,this.options.tokenizer=this.options.tokenizer||new ao,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:De,block:io.normal,inline:Pr.normal};this.options.pedantic?(n.block=io.pedantic,n.inline=Pr.pedantic):this.options.gfm&&(n.block=io.gfm,this.options.breaks?n.inline=Pr.breaks:n.inline=Pr.gfm),this.tokenizer.rules=n}static get rules(){return{block:io,inline:Pr}}static lex(t,n){return new ys(n).lex(t)}static lexInline(t,n){return new ys(n).inlineTokens(t)}lex(t){t=t.replace(De.carriageReturn,`
366
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(De.tabCharGlobal," ").replace(De.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+=`
367
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(`
368
368
  `)?"":`
@@ -376,9 +376,9 @@ ${m}`,i=i.substring(0,i.length-p.text.length)+v.text;break}else if(d?.type==="li
376
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(`
377
377
  `)?"":`
378
378
  `)+o.raw,s.text+=`
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)}},eo=class{options;parser;constructor(e){this.options=e||fn}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(De.notSpaceStart)?.[0],i=e.replace(De.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>
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)}},so=class{options;parser;constructor(e){this.options=e||wn}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(De.notSpaceStart)?.[0],i=e.replace(De.endingNewline,"")+`
380
+ `;return r?'<pre><code class="language-'+yt(r)+'">'+(n?i:yt(i,!0))+`</code></pre>
381
+ `:"<pre><code>"+(n?i:yt(i,!0))+`</code></pre>
382
382
  `}blockquote({tokens:e}){return`<blockquote>
383
383
  ${this.parser.parse(e)}</blockquote>
384
384
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -394,12 +394,12 @@ ${this.parser.parse(e)}</blockquote>
394
394
  `}tablerow({text:e}){return`<tr>
395
395
  ${e}</tr>
396
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}>
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=Fh(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=Fh(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)}},Es=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}},ut=class ms{options;renderer;textRenderer;constructor(t){this.options=t||fn,this.options.renderer=this.options.renderer||new eo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Es}static parse(t,n){return new ms(n).parse(t)}static parseInline(t,n){return new ms(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}},Rr=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?Be.lex:Be.lexInline}provideParser(e=this.block){return e?ut.parse:ut.parseInline}},no=class{defaults=vs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ut;Renderer=eo;TextRenderer=Es;Lexer=Be;Tokenizer=Ji;Hooks=Rr;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 eo(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 Ji(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 Rr;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];Rr.passThroughHooks.has(o)?i[a]=c=>{if(this.defaults.async&&Rr.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 Be.lex(e,t??this.defaults)}parser(e,t){return ut.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?Be.lex:Be.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let c=await(i.hooks?await i.hooks.provideParser(e):e?ut.parse:ut.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?Be.lex:Be.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?ut.parse:ut.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 no;function ae(e,t){return pn.parse(e,t)}ae.options=ae.setOptions=function(e){return pn.setOptions(e),ae.defaults=pn.defaults,Hh(ae.defaults),ae};ae.getDefaults=vs;ae.defaults=fn;function Jb(...e){return pn.use(...e),ae.defaults=pn.defaults,Hh(ae.defaults),ae}ae.use=Jb;ae.walkTokens=function(e,t){return pn.walkTokens(e,t)};ae.parseInline=pn.parseInline;ae.Parser=ut;ae.parser=ut.parse;ae.Renderer=eo;ae.TextRenderer=Es;ae.Lexer=Be;ae.lexer=Be.lex;ae.Tokenizer=Ji;ae.Hooks=Rr;ae.parse=ae;var AE=ae.options,CE=ae.setOptions,LE=ae.walkTokens,NE=ae.parseInline;var PE=ut.parse,DE=Be.lex;var Jh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ex=new RegExp(`[${Object.keys(Jh).join("")}]`,"g");function Ze(e){return e.replace(ex,t=>Jh[t])}var tx=["http:","https:","mailto:"],ep=/^[a-z][a-z0-9+.-]*:/i,tp=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Qh(e){let t=e.replace(tp,""),n=ep.exec(t);return n===null?t===""?null:e:tx.includes(n[0].toLowerCase())?e:null}var Ct="data-weave-target",gn="data-weave-task";function ao(e){return e?"Mark task incomplete":"Mark task complete"}var io="note:",nx={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function rx(e){if(e.kind!=="note"||!e.id.startsWith(io))return null;let t=e.id.slice(io.length);return t===""?null:t}function np(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 rp(e){let t=np(e);return t===null?null:`${t}:${e.detail.updated??""}`}function ip(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:np(n)}function op(e,t){if(e===null)return nx;let n=new Map;for(let i of e.model.nodes){let o=rx(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 ap(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function ix(e,t){if(e.currentSlug===null||ep.test(t.replace(tp,"")))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:ap(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function ox(e){return e.hasGhosts}var ax=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function sx(e){let t=e.indexOf("[[");return t===-1?void 0:t}function lx(e){return{name:"wikilink",level:"inline",start:sx,tokenizer(t){return ux(t)},renderer(t){return cx(e,t)}}}function cx(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return dx(e,n,r)}function ux(e){let t=ax.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function dx(e,t,n){let r=Ze((n===""?t:n).trim());if(r==="")return"";let i=ap(e,t);return i!==null?`<a class="weave-wiki" ${Ct}="${Ze(i)}" role="link" tabindex="0" title="${Ze(t.trim())}">${r}</a>`:ox(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Ze(t.trim())}">${r}</span>`:r}function hx(e){let t=0;return new no({gfm:!0,async:!1,extensions:[lx(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${gn}="${t++}" aria-label="${ao(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":Ze(n)},link({href:n,title:r,tokens:i}){let o=Qh(n),a=this.parser.parseInline(i),s=o===null?null:ix(e,o);if(s!==null){let c=r==null||r===""?"":` title="${Ze(r)}"`;return`<a class="weave-wiki" ${Ct}="${Ze(s)}" role="link" tabindex="0"${c}>${a}</a>`}return`<a${[o===null?"":` href="${Ze(o)}"`,r==null||r===""?"":` title="${Ze(r)}"`,o===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${a}</a>`},image({href:n,title:r,text:i}){let o=Qh(n);if(o===null)return Ze(i);let a=r==null||r===""?"":` title="${Ze(r)}"`;return`<img src="${Ze(o)}" alt="${Ze(i)}"${a}>`}}})}function px(e,t){return hx(t).parse(e,{async:!1})}function ro(e){return Object.freeze(e)}var fx=ro({ALLOWED_TAGS:ro(["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:ro(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Ct,gn]),ADD_URI_SAFE_ATTR:ro([Ct,gn]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function sp(e,t,n){return e.sanitize(px(t,n),fx)}var gx=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function mx(e){let t=[],n=e.replace(/\r\n?/g,`
399
- `),r=0;for(let l of Be.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=gx.exec(p);m!==null&&t.push(c+u+m[1].length),u=h===-1?l.raw.length:h+1}}let i=new no,o=l=>{let c=[];return i.walkTokens(Be.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 lp(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=mx(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function cp(e){let t=e?.getAttribute(gn);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var up=32;function Ts(e){let t=e;for(let n=0;t!==null&&n<up;n++){let r=t.getAttribute(Ct);if(r!==null&&r!=="")return`${io}${r}`;t=t.parentElement}return null}function dp(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 hp="edited",pp="created",fp="Edit",gp="Done",mp="Save",vp="Saving…",yp="Note body",so="Discard unsaved changes to this note?";function wp(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:rn(e.source),provenanceTitle:Cn(e.source),updated:or(e.updated,t),updatedIso:e.updated,created:or(e.created,t),createdIso:e.created,tags:e.tags}}function bp(e){return`#${e}`}var vx=200,yx=8,wx="no note";function Ss(e){let t=e;for(let n=0;t!==null&&n<up;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 bx(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 xx(e,t=vx){let n=bx(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function xp(e,t){if(t.slug===null){let i=t.text===""?"this link":t.text;return{ghost:!0,title:i,kind:wx,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} · ${Cn(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:xx(n.detail.preview??"")}}function kp(e,t,n,r,i,o,a=yx){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 oo={anchor:null,pointerX:0,pointerY:0};function _p(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:oo;case"dismiss":return oo}}function Ep(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(io)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function lo(){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 Tp(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 Sp(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 kx="weave-preview-x",_x="weave-preview-y";function Ex({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(he,{children:[f("button",{type:"button",class:"weave-note-save",disabled:r||i,onClick:a,children:r?vp:mp}),f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:gp})]}):f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:fp}),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:[hp," ",e.updated]}),f("span",{class:"weave-note-time",title:e.createdIso,children:[pp," ",e.created]})]}),f("p",{class:"weave-note-tags",children:e.tags.map(s=>f("span",{class:"weave-tag",children:bp(s)},s))})]})}function Rp(e){let t=Q(lo()),n=e.drafts??t.current,r=Tl(),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=ip(e.graph,e.selectedId),u=Ep(e.selectedId,s,e.loadFailed),h=ft(()=>s===null?null:op(e.graph,s.slug),[s,e.graph]),d=ft(()=>s===null||h===null?"":sp(Ih,l,h),[s,l,h]),[p,m]=j(oo),y=T=>{m(F=>_p(F,T))},v=Q(null),w=Q(null),b=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",ao(T.checked))};if(s===null||n.isTaskSaving(s.slug)){K();return}let Z=lp(n.getTaskBody(s.slug,s.body),F);if(Z===null){K();return}let Y=[...v.current?.querySelectorAll(`input[${gn}]`)??[]];T.setAttribute("aria-label",ao(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(so))&&n.discard(s.slug))},O=p.anchor===null?null:xp(e.graph,p.anchor);if(je(()=>{s!==null&&n.taskBody(s.slug,s.body,e.loadVersion)},[n,s===null?null:s.slug,s?.body,e.loadVersion]),je(()=>{y({type:"hide"})},[s===null?null:s.slug]),je(()=>{if(s===null)return;let T=n.isTaskSaving(s.slug);for(let F of v.current?.querySelectorAll(`input[${gn}]`)??[])F.disabled=T},[s===null?null:s.slug,o,d]),je(()=>{let T=v.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=w.current;if(F===null||O===null)return;let K=kp(p.pointerX,p.pointerY,F.offsetWidth,F.offsetHeight,window.innerWidth,window.innerHeight);F.style.setProperty(`--${kx}`,`${K.x}px`),F.style.setProperty(`--${_x}`,`${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:rp(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=wp(s,e.now);return f("article",{class:`weave-note weave-note-${U.provenance}`,children:[f(Ex,{view:U,open:()=>e.onOpen(s.slug),editing:b!==null,saving:b?.saving??!1,taskSaving:k,onToggle:D,onSave:()=>{_()}}),b!==null?f("textarea",{class:"weave-note-editor","aria-label":yp,spellcheck:e.spellcheck??!0,value:b.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:v,class:"weave-note-body",tabIndex:-1,onMouseOver:T=>{let F=Ss(T.target);y(F!==null?{type:"show",anchor:F,x:T.clientX,y:T.clientY}:{type:"hide"})},onMouseLeave:()=>y({type:"hide"}),onFocus:T=>{let F=Ss(T.target);if(F===null)return;let K=T.target.getBoundingClientRect?.();y({type:"show",anchor:F,x:K?.left??0,y:K?.bottom??0})},onBlur:()=>y({type:"hide"}),onClick:T=>{let F=T.target,K=cp(F);if(K!==null){I(F,K);return}let Z=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(dp(Z))return;let Y=Ts(T.target);Y!==null&&e.onSelect(Y,T.metaKey||T.ctrlKey||T.shiftKey)},onKeyDown:T=>{if(T.key==="Escape"&&p.anchor!==null){T.stopPropagation(),y({type:"dismiss"});return}if(T.key!=="Enter"&&T.key!==" ")return;let F=Ts(T.target);F!==null&&(T.preventDefault(),e.onSelect(F,T.metaKey||T.ctrlKey||T.shiftKey))},dangerouslySetInnerHTML:{__html:d}}),O===null?null:f("div",{ref:w,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 Ap=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Cp(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 Lp(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Np(e){return e===null?!1:(e.focus(),!0)}function Bn(){let e=Q(null);return le(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Np(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Lp(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Ap)??[]],r=Cp(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function Ip(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 Tx(e){return Math.min(Math.max(e,0),10)*2}function Sx(e){return`note:${e}`}function Rx(e,t){return Ip(e.summary.title,t)+Tx(e.score)}function Ax(e,t){return Ip(e.label,t)}var Cx=["path","manifest","url","slug"];function Lx(e){for(let t of Cx){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}function Nx(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 Px(e,t,n,r){let i=new Map;for(let o of e){let a=Sx(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Rx(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=Ax(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Lx(o),badge:o.kind,score:a})}return[...i.values()].sort(Nx).slice(0,20)}function Gp(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Rs(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Pp(e,t,n){return n<=0?0:((e+t)%n+n)%n}function Mp(e,t){return t===null?null:e[t]?.id??null}function Op(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Rs(e,n);return t==="ArrowDown"?{...r,cursor:Pp(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Pp(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Rs(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 co="Search the workspace",Fp="Search notes and repository…",$p="↑↓ move · ↵ open · esc close";function Dx(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 Ix(e){return e===1?"1 result":`${e} results`}function Dp(e){return`weave-search-row-${e}`}function zp(e,t){let n=Px(e.hits,e.answered,t?.model.nodes??[],e.query),r=Rs(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Dp(a)})),status:Dx(e,n.length),count:n.length,countLabel:Ix(n.length),cursor:r,activeDomId:n.length?Dp(r):null}}function Mx({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 Wp(e){let[t,n]=j(Gp),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(y=>({...y,loading:!0,failed:!1}));let m=await Hl(e.ports.fetch,c,p.signal);!u||p.signal.aborted||d!==r.current||n(y=>m.ok?{...y,hits:m.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...y,loading:!1,failed:!0})},140);return()=>{u=!1,window.clearTimeout(h),i.current?.abort()}},[t.query,e.ports.fetch]);let s=zp(t,e.graph),l=(c,u=!1)=>{let h=Mp(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":co,tabIndex:-1,ref:o.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{if(o.onKeyDown(c))return;let u=Op(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:Fp,"aria-label":co,"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":co,children:s.rows.map((c,u)=>f(Mx,{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:[$p," · ⌘/Ctrl ↵ new tab"]})]})]})})}function As(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Up=2e3,Ox=3e3,Bp=new Set;function Fx(e,t){if(e===null)return Bp;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 Hp(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function Kp(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=Hp(t.selectedId);if(d===null){o({note:null,noteFailed:!1});return}let p=await Qo(e.fetch,d);p.ok?o({note:p.data,noteFailed:!1}):o({note:null,noteFailed:!0})},l=async()=>{let d=t.graph,p=await li(e.fetch,t.graph);if(!p.ok)return t.graph===null&&o({graphFailed:!0}),p;if(!p.cached){let m=Fx(d,p.data);o({graph:p.data,graphFailed:!1,recentIds:m}),i?.(),i=null,m.size>0&&(i=a(()=>{i=null,o({recentIds:Bp})},Ox))}return p},c=async()=>{if(!(n||r)){r=!0;try{let d=await l();Hp(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()},Up);return c(),{refresh:()=>{c()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function Vp(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 Qo(e,t);i||(n(s),s.ok||(o=r(()=>{a()},Up)))};return a(),()=>{i=!0,o?.()}}var Lr={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function ho(e,t,n){return{id:e,target:t.id,label:qe(t),kind:t.kind,kindIcon:nn(t.kind),provenance:t.provenance,provenanceGlyph:rn(t.provenance),provenanceTitle:Cn(t.provenance),selected:t.id===n}}function $x(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:ho(e.id,i,n)}function zx(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var Wx=["link:links-to:"];function Hx(e){return Wx.some(t=>e.id.startsWith(t))}function Ux(e){return e.id.startsWith("link:mentions:")}function Bx(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(ho(`tag:${o}:${l}`,c,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Kx(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(ho(`mentioned-by:${o.source}`,a,r))}return i}function Vx(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var uo={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 Cs(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function jp(e,t){if(e===null)return Cs(uo.loading);if(t===null)return Cs(uo.noSelection);let n=en(e),r=ra(n,t);if(r===null)return Cs(uo.unknown);let i=zx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>$x(d,i,t)).filter(d=>d!==null);a(Lr.links,s(r.links.filter(Hx)));let l=ia(n.edges).get(t)??[];a(Lr.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>ho(`backlink:${h.id}`,h,t))),a(Lr.mentions,[...s(r.links.filter(Ux)),...Kx(n,t,i,t)]);let c=Vx(t),u=c===null?[]:Bx(e,c,i,t);return o.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:uo.isolated}:{subject:r.label,groups:o,tags:u,tagsCount:u.length,empty:null}}function qp(){return{open:new Set,closed:new Set}}var jx=8;function Yp(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>jx}function qx(e){return e.some(t=>t.selected)}function Xp(e,t){let n=Yp(t,e.heading,e.count,qx(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function Zp(e,t){let n=Yp(t,Lr.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:Lr.tags,count:e.length,collapsed:n,rows:[]}}function Qp(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 po(e){return`weave-ctx-panel-${e.toLowerCase()}`}function Jp({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 ef({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":po(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 Yx({view:e,onSelect:t,onToggle:n}){return f("section",{class:"weave-ctx-group",children:[f(ef,{view:e,onToggle:n}),f("ul",{class:"weave-ctx-rows",id:po(e.heading),hidden:e.collapsed,children:e.rows.map(r=>f(Jp,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function Xx({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(Jp,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function tf(e){let t=jp(e.graph,e.selectedId),[n,r]=j(qp),i=a=>()=>r(Qp(n,a.heading,a.collapsed)),o=Zp(t.tags,n);return f("div",{class:"weave-rail","aria-label":Ou.title,children:[t.empty===null?null:f("p",{class:"weave-ctx-empty",children:t.empty}),t.groups.map(a=>{let s=Xp(a,n);return f(Yx,{view:s,onSelect:e.onSelect,onToggle:i(s)},a.heading)}),t.tags.length===0?null:f("section",{class:"weave-ctx-group",children:[f(ef,{view:o,onToggle:i(o)}),f("ul",{class:"weave-ctx-tags",id:po(o.heading),hidden:o.collapsed,children:t.tags.map(a=>f(Xx,{tag:a,onSelect:e.onSelect},a.tag))})]})]})}function Zx(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function nf(e,t){let n=Zx(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function rf(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function of(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function af(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):Mt[e.key]}function sf(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function lf(e){return kn.every(t=>Object.is(e[t.key],Mt[t.key]))}function cf(e){return f("div",{class:"weave-settings-forces",children:[kn.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:of(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:af(t,n.currentTarget.value)})}),f("output",{children:sf(e.forces[t.key])})]})]},t.key)),f("button",{type:"button",disabled:lf(e.forces),onClick:()=>e.onChange({...Mt}),children:"Reset graph layout"})]})}var uf=["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 df(e){let[t,n]=j("General"),[r,i]=j(0),o=Bn(),a=e.layout.preferences,s=l=>e.onChange({...e.layout,preferences:{...a,...l}});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:o.ref,onClick:l=>l.stopPropagation(),onKeyDown:l=>{o.onKeyDown(l)},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:l=>n(l.currentTarget.value),children:uf.map(l=>f("option",{value:l,children:l},l))}):uf.map(l=>f("button",{type:"button","aria-current":t===l?"page":void 0,onClick:()=>n(l),children:l},l))}),f("section",{"aria-label":`${t} settings`,children:[f("h3",{children:t}),t==="General"?f(he,{children:[f("p",{children:["Pi Weave ",e.info.version]}),f("dl",{class:"weave-settings-locations",children:[f("dt",{children:"Vault"}),f("dd",{children:f("code",{children:e.info.vaultRoot||"Loading…"})}),f("dt",{children:"Repository"}),f("dd",{children:f("code",{children:e.cwd})})]}),f("div",{class:"weave-settings-actions",children:[f("button",{type:"button",onClick:()=>{i(l=>l+1),e.onRefresh()},children:[f("span",{class:r?"weave-refresh-spin":"","aria-hidden":"true",children:"↻"},r)," 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"}),Ri(e.shortcut.slice(0,-1)).map(l=>f("div",{children:[f("h4",{children:l.title}),l.entries.map(c=>f("div",{class:"weave-key-row",children:[f("kbd",{children:c.combo}),f("span",{children:c.what})]},c.combo))]},l.title))]})]}):null,t==="Appearance"?f(he,{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":ce[e.layout.theme].scheme,onChange:l=>e.onChange({...e.layout,theme:l.currentTarget.value==="system"?"system":l.currentTarget.value==="light"?a.lightTheme:a.darkTheme}),children:[f("option",{value:"system",children:"System"}),f("option",{value:"light",children:"Light"}),f("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(l=>f(nt,{name:`${l==="light"?"Light":"Dark"} theme`,hint:`Used in ${l} mode and by the ribbon theme button.`,children:f("select",{"aria-label":`${l==="light"?"Light":"Dark"} theme`,value:a[`${l}Theme`],onChange:c=>{let u=c.currentTarget.value;e.onChange({...e.layout,preferences:{...a,[`${l}Theme`]:u},theme:e.layout.theme!=="system"&&ce[e.layout.theme].scheme===l?u:e.layout.theme})},children:Object.entries(ce).filter(([,c])=>c.scheme===l).map(([c,u])=>f("option",{value:c,children:u.name},c))})},l)),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:a.accent,onChange:l=>s({accent:l.currentTarget.value}),children:[f("option",{value:"theme",children:"Theme default"}),Object.entries(Zt).map(([l,c])=>f("option",{value:l,children:c.name},l))]})}),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:a.fontSize,onInput:l=>s({fontSize:Number(l.currentTarget.value)})}),f("output",{children:[a.fontSize,"px"]})]})})]}):null,t==="Interface"?f(he,{children:[f(nt,{name:"Notes sidebar",hint:"Show files and recent notes.",children:f("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:l=>e.onChange({...e.layout,treeVisible:l.currentTarget.checked})})}),f(nt,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:f("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:l=>e.onChange({...e.layout,contextVisible:l.currentTarget.checked})})}),f(nt,{name:"Color graph by group",hint:"Give each containment group its own color.",children:f("input",{type:"checkbox",checked:a.groupColors,onChange:l=>s({groupColors:l.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(cf,{forces:a.forces,onChange:l=>s({forces:l})})]}):null,t==="Editor"?f(he,{children:[f(nt,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:f("input",{type:"checkbox",checked:a.spellcheck,onChange:l=>s({spellcheck:l.currentTarget.checked})})}),f(nt,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:f("input",{type:"checkbox",checked:a.readable,onChange:l=>s({readable:l.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:a.defaultEdit,onChange:l=>s({defaultEdit:l.currentTarget.checked})})})]}):null,t==="Files"?f(he,{children:[f(nt,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:f("select",{"aria-label":"On startup",value:a.startup,onChange:l=>s({startup:l.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:a.focusNewTabs,onChange:l=>s({focusNewTabs:l.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(he,{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 Qx({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 hf(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":Pa,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[f("h2",{class:"weave-help-title",children:Pa}),f("div",{class:"weave-keys",children:Ri(n).map(r=>f(Qx,{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:Ku})]})]})})}function pf(e,t){let n=r=>{if(r.defaultPrevented)return;let i=Hu(Uu(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function ff({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 gf="pi-weave.theme.v1";function fo(e){try{let t=e.getItem(gf);return xn(t)?t:null}catch{return null}}function mf(e,t){try{return e.setItem(gf,t),!0}catch{return!1}}function go(e,t,n=Ot){return ce[Ns(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function Ns(e,t,n=Ot){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function vf(e){return e==="system"?null:e}function Ls(e){return e==="system"?"System":ce[e].name}function yf(e,t="dark",n=Ot){return{glyph:e==="system"?"◐":ce[e].scheme==="light"?"○":"●",label:Ls(e),hint:`Colour theme: ${Ls(e)} — click for ${Ls(go(e,t,n))}`}}function mo(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 Jx(e){let[t]=j(e.visits);return f("div",{class:"weave-recents",children:Mu(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 ek(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),[s,l]=j(!1),[c,u]=j(""),[h,d]=j(!1),p=Q(null);je(()=>{s&&p.current?.focus()},[s]),le(()=>{if(n===null)return;let v=e.drafts.nextLoadVersion();return Vp(Ae,n,w=>{i({slug:n,note:w.ok?w.data:null,failed:!w.ok,version:v})})},[n,e.graph?.stamp,e.revision]);let m=r?.slug===n?r:null;if(je(()=>{let v=o.current?.querySelector(".weave-note");v!=null&&(v.scrollTop=a.current),n!==null&&e.drafts.get(n)!==null&&o.current?.querySelector(".weave-note-editor")?.focus()},[t,m?.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:"Ask your agent to write, organize, and connect your notes. Browse that knowledge here, or start a note yourself."}),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"}),f("button",{type:"button",onClick:()=>l(!0),children:"New note"})]}),s?f("form",{class:"weave-new-note",onSubmit:v=>{v.preventDefault(),!(h||!c.trim())&&(d(!0),e.onCreate(c.trim()).finally(()=>d(!1)))},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),h||l(!1))},children:[f("label",{for:`new-note-${e.tab.id}`,children:"Note title"}),f("input",{id:`new-note-${e.tab.id}`,ref:p,required:!0,value:c,disabled:h,onInput:v=>u(v.currentTarget.value)}),f("div",{children:[f("button",{type:"submit",disabled:h||!c.trim(),children:h?"Creating…":"Create note"}),f("button",{type:"button",disabled:h,onClick:()=>l(!1),children:"Cancel"})]})]}):null]});let y=e.graph!==null&&!e.graph.model.nodes.some(v=>v.id===t);if(y||m?.failed&&e.drafts.isDirty(n??"")){let v=n===null?null:e.drafts.get(n);return v!==null&&n!==null&&e.drafts.isDirty(n)?f("div",{class:"weave-welcome",children:[f("h2",{children:y?"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. ",y?"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:v.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:v=>{let w=v.target;w.classList.contains("weave-note")&&(a.current=w.scrollTop,e.onScroll(w.scrollTop))},children:f(Rp,{spellcheck:e.preferences.spellcheck,defaultEdit:e.preferences.defaultEdit,note:m?.note??null,loadFailed:m?.failed??!1,loadVersion:m?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:v=>{Ul(Ae,v).then(w=>{w.ok?w.data.opened||window.alert("Could not open the note in an editor."):window.alert(w.message)})},onSave:e.onSave,drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function Ps(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 wf(e){let[t,n]=j(As),[r,i]=j(()=>({...Ho(),theme:fo(localStorage)??"system"})),[o,a]=j(null),[s,l]=j(Date.now),[c,u]=j(e.initialWidth),[h,d]=j(()=>hr(window)),[p,m]=j(!1),[y,v]=j({version:"",vaultRoot:""}),[w,b]=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,Ke]=j(!1),[Lt,Fe]=j([]),[$e,Le]=j(!1),[pe]=j(lo),Ve=Q(null),Ee=Q(null),re=Q(location.hash),Nt=Q(!1),Pt=Q(null),Nr=Q(null),Pr=Q(null),[vo,yo]=j({left:0,top:0,width:600,height:500}),Dr=rr(r),Ir=Tn(r),mn=yf(r.theme,h,r.preferences),ee=Ns(r.theme,h,r.preferences),Kn=ft(()=>({theme:ee,accent:r.preferences.accent}),[ee,r.preferences.accent]),X=Ir.kind==="graph"?A:bt(Ir),Ne=r.panes.find(E=>E.tabs.some(N=>N.id===E.activeTab&&N.kind==="graph")),Te=Ne!==void 0&&(c>=850||Ne.id===r.activePane),dt=c<1050?$e:r.contextVisible,Gr=r.panes.some(E=>E.tabs.some(N=>N.kind==="graph")),ve=Q({layout:r,overlay:o,selectedId:X,graphPreviewId:O,select:E=>{}}),Bt=E=>{ve.current.graphPreviewId=E,U(E)};le(()=>{Te||Bt(null)},[Te]);let rt=E=>{Tp(pe,ve.current.layout,E,()=>window.confirm(so))&&i(E)},Qe=(E,N=!1,H=r.activePane,C=!1)=>{let z=(E===null?Sn:Fl)(r,E,{newTab:N,paneId:H});rt(c<850&&!C?{...z,treeVisible:!1}:z),Le(!1)},Vn=()=>i(E=>({...Bo(E),...c<850?{treeVisible:!1}:{}})),it=E=>{Bt(null);let N=r.panes.find(H=>H.id!==Ne?.id);Qe(E,!0,N?.id??Ne?.id??r.activePane)},mt=E=>{D(E),Gu(ve.current.graphPreviewId,E)?it(E):Bt(E)};ve.current={layout:r,overlay:o,selectedId:X,graphPreviewId:O,select:Qe};let vt=E=>Sp(pe,E,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),jn=async(E,N)=>{let H=await Kl(Ae,E,N);return H.ok?(_(C=>C+1),Ve.current?.refresh(),!0):(window.alert(H.message),!1)},vn=async(E,N)=>{let H=await Bl(Ae,E);if(!H.ok)return window.alert(H.message),!1;let C=await li(Ae);return n(z=>({...z,graph:C.ok?C.data:null,graphFailed:!C.ok})),pe.open(H.data.note.slug,H.data.note.body),rt(Sn(ve.current.layout,`note:${H.data.note.slug}`,{paneId:N})),Ve.current?.refresh(),!0};le(()=>pe.subscribe(()=>I(E=>E+1)),[pe]),le(()=>(Ve.current=Kp({fetch:Ae,state:As(),setState:n}),()=>Ve.current?.stop()),[]),le(()=>{let E=!0;return(async()=>{try{let N=await Ae("/api/workspace-state"),H=await N.json();if(!E)return;if(N.ok&&typeof H.viewId=="string"){Ee.current=H.viewId,H.info&&v(H.info);let C=Ml(H.layout);C&&(i(Ol(C)),Fe(C.panes.flatMap(z=>z.tabs.flatMap(fe=>fe.history)).reduce(Ca,[])))}else b(!0)}catch{E&&b(!0)}finally{E&&m(!0)}})(),()=>{E=!1}},[]),le(()=>{if(!p||t.graph===null||Nt.current)return;Nt.current=!0;let E=nf(re.current,t.graph);E!==null&&i(N=>Sn(N,E))},[p,t.graph]),le(()=>{p&&Fe(E=>Ca(E,X))},[p,X]),le(()=>{p&&(history.replaceState(null,"",rf(X)),document.documentElement.dataset.weaveTheme=ee,document.documentElement.dataset.weaveScheme=ce[ee].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,mf(localStorage,r.theme))},[p,X,r.theme,ee,r.preferences.accent]);let Kt=Q(Promise.resolve());le(()=>{if(!p||!Ee.current)return;let E=Ee.current,N=window.setTimeout(()=>{Kt.current=Kt.current.then(async()=>{try{let H=await Ae("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:E,layout:r})});b(!H.ok)}catch{b(!0)}})},350);return()=>window.clearTimeout(N)},[r,p]),le(()=>{let E=window.setInterval(()=>l(Date.now()),$u),N=()=>u(window.innerWidth);window.addEventListener("resize",N);let H=Nu(window,d),C=ot=>{for(let Dt of document.querySelectorAll(".weave-pane-menu[open]"))Dt.contains(ot.target)||(Dt.open=!1)};document.addEventListener("pointerdown",C);let z=ot=>{pe.dirtySlugs().length&&(ot.preventDefault(),ot.returnValue="")},fe=()=>{Ee.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:Ee.current,layout:ve.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",fe),window.addEventListener("beforeunload",z),()=>{window.clearInterval(E),window.removeEventListener("resize",N),window.removeEventListener("beforeunload",z),window.removeEventListener("pagehide",fe),document.removeEventListener("pointerdown",C),H()}},[]),le(()=>pf(document,{context:()=>({overlay:ve.current.overlay,hasSelection:ve.current.selectedId!==null}),run:E=>Bu(E,{setOverlay:a,fitGraph:()=>Pr.current?.(),clearSelection:()=>{Tn(ve.current.layout).kind==="graph"?(D(null),Bt(null)):ve.current.select(null)},closeTab:()=>{let N=ve.current.layout;rt(Vo(N,N.activePane,Tn(N).id))},toggleTheme:()=>i(N=>({...N,theme:go(N.theme,hr(window),N.preferences)})),focusSelector:N=>(N===Nn.graph?i(H=>({...Bo(H),...window.innerWidth<850?{treeVisible:!1}:{}})):N===Nn.tree||N===Na?i(H=>({...H,treeVisible:!0})):i(Il),requestAnimationFrame(()=>{N===Nn.note&&Si(document,".weave-pane-active .weave-note-editor")||!Si(document,N)&&N===Nn.note&&Si(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),je(()=>{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]),je(()=>{let E=Nr.current,N=Pt.current;if(!Te||!E||!N)return;let H=()=>{let z=E.getBoundingClientRect(),fe=N.getBoundingClientRect();yo({left:z.left-fe.left,top:z.top-fe.top,width:z.width,height:z.height})};H();let C=new ResizeObserver(H);return C.observe(E),C.observe(N),()=>C.disconnect()},[Te,r,c]);let qn=(E,N)=>i(H=>({...H,panes:H.panes.map(C=>({...C,tabs:C.tabs.map(z=>z.id===E?{...z,scroll:N}:z)}))})),yt=(E,N)=>{si(r,E,T.current)===null&&!N.dataTransfer?.types.includes(pr)||(N.preventDefault(),N.dataTransfer&&(N.dataTransfer.dropEffect=T.current===null?"copy":"move"),K(null),Y(E))},Vt=(E,N)=>{let H=Iu(t.graph,N.dataTransfer?.getData(pr)??"");if(H!==null){N.preventDefault(),Qe(H,!0,E),Y(null);return}let C=T.current;si(r,E,C)!==null&&(N.preventDefault(),i(z=>{let fe=si(z,E,C);return fe===null?z:Xo(z,fe,C)}),T.current=null,Y(null),K(null))},jt=(E,N,H)=>{E.tabs.some(C=>C.id===T.current)&&(H.preventDefault(),H.stopPropagation(),H.dataTransfer.dropEffect="move",Y(null),K({paneId:E.id,before:N}))},Yn=(E,N)=>{let H=T.current;H===null||!E.tabs.some(C=>C.id===H)||(N.preventDefault(),N.stopPropagation(),i(C=>Yo(C,E.id,H,F?.paneId===E.id?F.before:null)),T.current=null,K(null),Y(null))},Mr=E=>{let N=E.tabs.find(C=>C.id===E.activeTab),H=E.id===r.activePane;return f("section",{class:`weave-pane${H?" 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:C=>yt(E.id,C),onDrop:C=>Vt(E.id,C),onDragLeave:C=>{C.currentTarget.contains(C.relatedTarget)||Y(null)},hidden:c<850&&!H,onFocusCapture:()=>{H||i(C=>({...C,activePane:E.id}))},onPointerDown:()=>{H||i(C=>({...C,activePane:E.id}))},children:[f("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:C=>jt(E,null,C),onDrop:C=>Yn(E,C),children:[E.tabs.map(C=>f("div",{class:`weave-tab${C.id===N.id?" weave-tab-active":""}${F?.paneId===E.id&&F.before===C.id?" weave-tab-drop-before":""}${F?.paneId===E.id&&F.before===null&&C===E.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:z=>{let fe=z.currentTarget.getBoundingClientRect(),ot=z.clientX<fe.left+fe.width/2?C.id:E.tabs[E.tabs.indexOf(C)+1]?.id??null;jt(E,ot,z)},onDrop:z=>Yn(E,z),children:[f("button",{type:"button",role:"tab",title:mo(C,t.graph),id:`tab-${C.id}`,"aria-selected":C.id===N.id,"aria-controls":`panel-${E.id}`,tabIndex:C.id===N.id?0:-1,draggable:!0,onDragStart:z=>{T.current=C.id,z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("application/x-weave-tab",C.id)},onClick:()=>i(Ko(r,E.id,C.id)),onKeyDown:z=>{let fe=z.key==="ArrowRight"?1:z.key==="ArrowLeft"?-1:0;if(fe&&z.altKey&&!z.ctrlKey&&!z.metaKey){z.preventDefault(),z.stopPropagation();let Xn=E.tabs.indexOf(C),Or=fe<0?E.tabs[Math.max(0,Xn-1)].id:E.tabs[Xn+2]?.id??null;i(Yo(r,E.id,C.id,Or)),requestAnimationFrame(()=>document.getElementById(`tab-${C.id}`)?.focus());return}if(!fe&&z.key!=="Home"&&z.key!=="End")return;z.preventDefault();let ot=z.key==="Home"?0:z.key==="End"?E.tabs.length-1:(E.tabs.indexOf(C)+fe+E.tabs.length)%E.tabs.length,Dt=E.tabs[ot];i(Ko(r,E.id,Dt.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Dt.id}`)?.focus())},children:[f("span",{"aria-hidden":"true",children:C.kind==="graph"?"◌":"▤"}),f("span",{children:mo(C,t.graph)}),pe.isDirty((bt(C)??"").slice(5))?f("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),f("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${mo(C,t.graph)}`,onClick:()=>rt(Vo(r,E.id,C.id)),children:"×"})]},C.id)),f("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>Qe(null,!0,E.id),children:"+"})]}),f("div",{class:"weave-pane-toolbar",children:[f("button",{type:"button","aria-label":"Navigate back",disabled:N.kind==="graph"||N.cursor===0,onClick:()=>rt(jo({...r,activePane:E.id},E.id,-1)),children:"←"}),f("button",{type:"button","aria-label":"Navigate forward",disabled:N.kind==="graph"||N.cursor>=N.history.length-1,onClick:()=>rt(jo({...r,activePane:E.id},E.id,1)),children:"→"}),f("span",{class:"weave-breadcrumb",children:mo(N,t.graph)}),f("details",{class:"weave-pane-menu",onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),C.stopPropagation(),C.currentTarget.open=!1,C.currentTarget.querySelector("summary")?.focus())},children:[f("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),f("div",{onClick:C=>{let z=C.currentTarget.closest("details");z&&(z.open=!1)},children:[f("button",{type:"button",onClick:()=>i(qo({...r,activePane:E.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),f("button",{type:"button",onClick:()=>i(qo({...r,activePane:E.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?f(he,{children:[f("button",{type:"button",onClick:()=>i(Xo(r,E.id,N.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(Gl(r,E.id)),children:"Close pane"})]}):null]})]})]}),f("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${E.id}`,"aria-labelledby":`tab-${N.id}`,...N.kind==="graph"?{ref:Nr}:{},children:N.kind==="document"?f(ek,{preferences:r.preferences,tab:N,graph:t.graph,drafts:pe,revision:k,now:s,onSelect:(C,z)=>Qe(C,z,E.id),onSave:jn,onScroll:C=>qn(N.id,C),onSearch:()=>a("search"),onGraph:Vn,onCreate:C=>vn(C,E.id)},`${N.id}:${N.cursor}:${bt(N)}`):null})]},E.id)};return f(he,{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:zu(Ei(Ti(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":dt,title:"Context",onClick:()=>c<1050?Le(!$e):i({...r,contextVisible:!r.contextVisible}),children:"☷"}),f("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Ve.current?.refresh(),_(E=>E+1)},children:"↻"}),f("button",{type:"button","aria-label":mn.hint,title:mn.hint,onClick:()=>i({...r,theme:go(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:()=>Ke(!1),children:"Files"}),f("button",{type:"button","aria-pressed":ne,onClick:()=>Ke(!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(Jx,{visits:Lt,graph:t.graph,selectedId:X,onSelect:Qe}):f(ju,{graph:t.graph,selectedId:X,recentIds:t.recentIds,onSelect:(E,N,H)=>Qe(E,N,r.activePane,H),onMutate:vt,onRefresh:()=>Ve.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(Ps,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:E=>i(N=>({...N,treeWidth:Math.max(180,Math.min(420,N.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,N)=>f(he,{children:[N>0&&c>=850?f(Ps,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:H=>{let C=r.split==="right"?Pt.current?.querySelector("main")?.clientWidth:Pt.current?.querySelector("main")?.clientHeight;i(z=>({...z,ratio:Math.max(.2,Math.min(.8,z.ratio+H/(C??800)))}))}}):null,Mr(E)]})):f("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),f("div",{class:"weave-sidebar-dock weave-context-dock","data-open":dt,inert:!dt,"aria-hidden":!dt,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[f(Ps,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:E=>i(N=>({...N,contextWidth:Math.max(180,Math.min(400,N.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(),Le(!1),i({...r,contextVisible:!1})},children:"»"})]}),f(tf,{graph:t.graph,selectedId:X,onSelect:Qe})]})]}),Gr?f("div",{class:"weave-graph-host",onDragOver:E=>{Ne&&yt(Ne.id,E)},onDrop:E=>{Ne&&Vt(Ne.id,E)},onDragLeave:E=>{E.currentTarget.contains(E.relatedTarget)||Y(null)},onPointerDown:()=>{Ne&&i(E=>({...E,activePane:Ne.id}))},onFocusCapture:()=>{Ne&&i(E=>({...E,activePane:Ne.id}))},"aria-hidden":!Te,style:{...vo,visibility:Te?"visible":"hidden",pointerEvents:Te?"auto":"none"},children:f(qu,{graph:t.graph,selectedId:X,previewId:O,onSelect:mt,onOpen:it,renderer:fh,storage:localStorage,host:window,scheme:Kn,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:Pr})}):null]}),f("div",{class:"weave-footer",children:[f(ff,{model:Fu(e.cwd,X)}),w?f("span",{role:"status",children:"Workspace restoration unavailable"}):null,pe.dirtySlugs().length?f("span",{children:[pe.dirtySlugs().length," unsaved"]}):null,c<850&&r.panes.length>1?f("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(E=>E.id!==Dr.id).id}),children:"Switch pane"}):null]}),o==="search"?f(Wp,{graph:t.graph,onSelect:Qe,onClose:()=>a(null),ports:{fetch:Ae}}):null,o==="settings"?f(df,{compact:c<=650,layout:r,info:y,cwd:e.cwd,shortcut:Ei(Ti(e.platform)),onChange:E=>{rt(E),Le(E.contextVisible)},onRefresh:()=>{Ve.current?.refresh(),_(E=>E+1)},onClose:()=>a(null)}):null,o==="help"?f(hf,{shortcut:Ei(Ti(e.platform)),onClose:()=>a(null)}):null]})}var bf=`
402
- .weave-workbench{position:relative;display:flex;min-height:0;overflow:hidden;background:var(--weave-page)}
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>${yt(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=$h(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+yt(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=$h(e);if(i===null)return yt(n);e=i;let o=`<img src="${e}" alt="${yt(n)}"`;return t&&(o+=` title="${yt(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:yt(e.text)}},As=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}},ft=class bs{options;renderer;textRenderer;constructor(t){this.options=t||wn,this.options.renderer=this.options.renderer||new so,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new As}static parse(t,n){return new bs(n).parse(t)}static parseInline(t,n){return new bs(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}},Dr=class{options;block;constructor(e){this.options=e||wn}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?qe.lex:qe.lexInline}provideParser(e=this.block){return e?ft.parse:ft.parseInline}},co=class{defaults=xs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ft;Renderer=so;TextRenderer=As;Lexer=qe;Tokenizer=ao;Hooks=Dr;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 so(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 ao(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 Dr;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];Dr.passThroughHooks.has(o)?i[a]=c=>{if(this.defaults.async&&Dr.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 qe.lex(e,t??this.defaults)}parser(e,t){return ft.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?qe.lex:qe.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?ft.parse:ft.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?qe.lex:qe.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?ft.parse:ft.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>"+yt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},vn=new co;function ae(e,t){return vn.parse(e,t)}ae.options=ae.setOptions=function(e){return vn.setOptions(e),ae.defaults=vn.defaults,Uh(ae.defaults),ae};ae.getDefaults=xs;ae.defaults=wn;function Jb(...e){return vn.use(...e),ae.defaults=vn.defaults,Uh(ae.defaults),ae}ae.use=Jb;ae.walkTokens=function(e,t){return vn.walkTokens(e,t)};ae.parseInline=vn.parseInline;ae.Parser=ft;ae.parser=ft.parse;ae.Renderer=so;ae.TextRenderer=As;ae.Lexer=qe;ae.lexer=qe.lex;ae.Tokenizer=ao;ae.Hooks=Dr;ae.parse=ae;var AE=ae.options,CE=ae.setOptions,LE=ae.walkTokens,NE=ae.parseInline;var PE=ft.parse,DE=qe.lex;var ep={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ex=new RegExp(`[${Object.keys(ep).join("")}]`,"g");function nt(e){return e.replace(ex,t=>ep[t])}var tx=["http:","https:","mailto:"],tp=/^[a-z][a-z0-9+.-]*:/i,np=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Jh(e){let t=e.replace(np,""),n=tp.exec(t);return n===null?t===""?null:e:tx.includes(n[0].toLowerCase())?e:null}var Gt="data-weave-target",yn="data-weave-task";function fo(e){return e?"Mark task incomplete":"Mark task complete"}var ho="note:",nx={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function rx(e){if(e.kind!=="note"||!e.id.startsWith(ho))return null;let t=e.id.slice(ho.length);return t===""?null:t}function rp(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 ip(e){let t=rp(e);return t===null?null:`${t}:${e.detail.updated??""}`}function op(e,t){if(e===null||t===null)return null;let n=e.model.nodes.find(r=>r.id===t);return n===void 0?null:rp(n)}function ap(e,t){if(e===null)return nx;let n=new Map;for(let i of e.model.nodes){let o=rx(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 sp(e,t){let n=t.trim();return e.bySpelling.get(n)??e.bySpelling.get(n.toLowerCase())??null}function ix(e,t){if(e.currentSlug===null||tp.test(t.replace(np,"")))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:sp(e,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function ox(e){return e.hasGhosts}var ax=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function sx(e){let t=e.indexOf("[[");return t===-1?void 0:t}function lx(e){return{name:"wikilink",level:"inline",start:sx,tokenizer(t){return ux(t)},renderer(t){return cx(e,t)}}}function cx(e,t){let n=typeof t.target=="string"?t.target:"",r=typeof t.alias=="string"?t.alias:"";return dx(e,n,r)}function ux(e){let t=ax.exec(e);if(t!==null)return{type:"wikilink",raw:t[0],target:t[1],alias:t[2]??""}}function dx(e,t,n){let r=nt((n===""?t:n).trim());if(r==="")return"";let i=sp(e,t);return i!==null?`<a class="weave-wiki" ${Gt}="${nt(i)}" role="link" tabindex="0" title="${nt(t.trim())}">${r}</a>`:ox(e)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${nt(t.trim())}">${r}</span>`:r}function hx(e){let t=0;return new co({gfm:!0,async:!1,extensions:[lx(e)],renderer:{checkbox({checked:n}){return`<input type="checkbox"${n?' checked=""':""} ${yn}="${t++}" aria-label="${fo(n)}"> `},html({text:n}){return/^\s*<!--[\s\S]*?-->\s*$/.test(n)?"":nt(n)},link({href:n,title:r,tokens:i}){let o=Jh(n),a=this.parser.parseInline(i),s=o===null?null:ix(e,o);if(s!==null){let c=r==null||r===""?"":` title="${nt(r)}"`;return`<a class="weave-wiki" ${Gt}="${nt(s)}" role="link" tabindex="0"${c}>${a}</a>`}return`<a${[o===null?"":` href="${nt(o)}"`,r==null||r===""?"":` title="${nt(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 nt(i);let a=r==null||r===""?"":` title="${nt(r)}"`;return`<img src="${nt(o)}" alt="${nt(i)}"${a}>`}}})}function px(e,t){return hx(t).parse(e,{async:!1})}function uo(e){return Object.freeze(e)}var fx=uo({ALLOWED_TAGS:uo(["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:uo(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","aria-label","start",Gt,yn]),ADD_URI_SAFE_ATTR:uo([Gt,yn]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1});function lp(e,t,n){return e.sanitize(px(t,n),fx)}var gx=/^((?: {0,3}>[ \t]?)*[ \t]*(?:[*+-]|\d{1,9}[.)])[ \t]+\[)([ xX])(\] +\S)/;function mx(e){let t=[],n=e.replace(/\r\n?/g,`
399
+ `),r=0;for(let l of qe.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=gx.exec(p);m!==null&&t.push(c+u+m[1].length),u=h===-1?l.raw.length:h+1}}let i=new co,o=l=>{let c=[];return i.walkTokens(qe.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 cp(e,t){if(!Number.isSafeInteger(t)||t<0)return null;let n=mx(e)[t];return n==null?null:`${e.slice(0,n)}${e[n]===" "?"x":" "}${e.slice(n+1)}`}function up(e){let t=e?.getAttribute(yn);return t==null||!/^(?:0|[1-9]\d*)$/.test(t)?null:Number(t)}var dp=32;function Cs(e){let t=e;for(let n=0;t!==null&&n<dp;n++){let r=t.getAttribute(Gt);if(r!==null&&r!=="")return`${ho}${r}`;t=t.parentElement}return null}function hp(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 pp="edited",fp="created",gp="Edit",mp="Done",vp="Save",wp="Saving…",yp="Note body",go="Discard unsaved changes to this note?";function bp(e,t){return{title:e.title,slug:e.slug,provenance:e.source,provenanceGlyph:ln(e.source),provenanceTitle:In(e.source),updated:dr(e.updated,t),updatedIso:e.updated,created:dr(e.created,t),createdIso:e.created,tags:e.tags}}function xp(e){return`#${e}`}var vx=200,wx=8,yx="no note";function Ls(e){let t=e;for(let n=0;t!==null&&n<dp;n++){let r=t.getAttribute(Gt);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 bx(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 xx(e,t=vx){let n=bx(e);if(n.length<=t)return n;let r=n.lastIndexOf(" ",t);return`${r>0?n.slice(0,r):n.slice(0,t)}…`}function kp(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} · ${In(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:xx(n.detail.preview??"")}}function _p(e,t,n,r,i,o,a=wx){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 po={anchor:null,pointerX:0,pointerY:0};function Ep(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:po;case"dismiss":return po}}function Tp(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(ho)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function mo(){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 Sp(e,t,n,r){let i=new Set(t.panes.flatMap(s=>s.tabs.map(wt))),o=new Set(n.panes.flatMap(s=>s.tabs.map(wt))),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 Rp(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 kx="weave-preview-x",_x="weave-preview-y";function Ex({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?wp:vp}),f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:mp})]}):f("button",{type:"button",class:"weave-note-edit",disabled:i,onClick:o,children:gp}),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:[pp," ",e.updated]}),f("span",{class:"weave-note-time",title:e.createdIso,children:[fp," ",e.created]})]}),f("p",{class:"weave-note-tags",children:e.tags.map(s=>f("span",{class:"weave-tag",children:xp(s)},s))})]})}function Ap(e){let t=Y(mo()),n=e.drafts??t.current,r=Rl(),i=`${e.idPrefix??r}-weave-preview`,[o,a]=q(0);oe(()=>n.subscribe(()=>a(T=>T+1)),[n]);let s=e.note?.note??null,l=s===null?"":n.getTaskBody(s.slug,s.body),c=op(e.graph,e.selectedId),u=Tp(e.selectedId,s,e.loadFailed),h=vt(()=>s===null?null:ap(e.graph,s.slug),[s,e.graph]),d=vt(()=>s===null||h===null?"":lp(Gh,l,h),[s,l,h]),[p,m]=q(po),w=T=>{m(F=>Ep(F,T))},v=Y(null),y=Y(null),b=s===null?null:n.get(s.slug),k=s!==null&&n.isTaskSaving(s.slug),E=async()=>{s!==null&&!n.isTaskSaving(s.slug)&&await n.save(s.slug,e.onSave)},I=async(T,F)=>{let V=()=>{T.checked=!T.checked,T.setAttribute("aria-label",fo(T.checked))};if(s===null||n.isTaskSaving(s.slug)){V();return}let j=cp(n.getTaskBody(s.slug,s.body),F);if(j===null){V();return}let Q=[...v.current?.querySelectorAll(`input[${yn}]`)??[]];T.setAttribute("aria-label",fo(T.checked));for(let te of Q)te.disabled=!0;try{await n.saveTask(s.slug,j,e.onSave)||V()}catch(te){throw V(),te}finally{for(let te of Q)te.disabled=n.isTaskSaving(s.slug)}},A=Y(null);oe(()=>{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(go))&&n.discard(s.slug))},O=p.anchor===null?null:kp(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 F of v.current?.querySelectorAll(`input[${yn}]`)??[])F.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 Q of T.querySelectorAll(`a[${Gt}]`))j!==null&&Q.getAttribute(Gt)===j?Q.setAttribute("aria-describedby",i):Q.removeAttribute("aria-describedby")}let F=y.current;if(F===null||O===null)return;let V=_p(p.pointerX,p.pointerY,F.offsetWidth,F.offsetHeight,window.innerWidth,window.innerHeight);F.style.setProperty(`--${kx}`,`${V.x}px`),F.style.setProperty(`--${_x}`,`${V.y}px`)},[p,O,i]),c!==null){let T=e.graph?.model.nodes.find(j=>j.id===e.selectedId),F=T?.label??c,V=T===void 0?c:ip(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)}`},V)]},V)}if(s===null||h===null)return f("p",{class:"weave-note-empty",children:u});let W=bp(s,e.now);return f("article",{class:`weave-note weave-note-${W.provenance}`,children:[f(Ex,{view:W,open:()=>e.onOpen(s.slug),editing:b!==null,saving:b?.saving??!1,taskSaving:k,onToggle:D,onSave:()=>{E()}}),b!==null?f("textarea",{class:"weave-note-editor","aria-label":yp,spellcheck:e.spellcheck??!0,value:b.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(),E())}}):f("div",{ref:v,class:"weave-note-body",tabIndex:-1,onMouseOver:T=>{let F=Ls(T.target);w(F!==null?{type:"show",anchor:F,x:T.clientX,y:T.clientY}:{type:"hide"})},onMouseLeave:()=>w({type:"hide"}),onFocus:T=>{let F=Ls(T.target);if(F===null)return;let V=T.target.getBoundingClientRect?.();w({type:"show",anchor:F,x:V?.left??0,y:V?.bottom??0})},onBlur:()=>w({type:"hide"}),onClick:T=>{let F=T.target,V=up(F);if(V!==null){I(F,V);return}let j=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(hp(j))return;let Q=Cs(T.target);Q!==null&&e.onSelect(Q,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 F=Cs(T.target);F!==null&&(T.preventDefault(),e.onSelect(F,T.metaKey||T.ctrlKey||T.shiftKey))},dangerouslySetInnerHTML:{__html:d}}),O===null?null:f("div",{ref:y,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 Cp=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function Lp(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 Np(e,t,n,r){return e==="Tab"&&!t&&!n&&!r}function Pp(e){return e===null?!1:(e.focus(),!0)}function Yn(){let e=Y(null);return oe(()=>{let t=document.activeElement;return e.current?.focus(),()=>{Pp(t instanceof HTMLElement?t:null)}},[]),{ref:e,onKeyDown(t){if(!Np(t.key,t.ctrlKey,t.metaKey,t.altKey))return!1;let n=[...e.current?.querySelectorAll(Cp)??[]],r=Lp(n.length,n.indexOf(document.activeElement),t.shiftKey);return r===null?!1:(t.preventDefault(),n[r]?.focus(),!0)}}}function Gp(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 Tx(e){return Math.min(Math.max(e,0),10)*2}function Sx(e){return`note:${e}`}function Rx(e,t){return Gp(e.summary.title,t)+Tx(e.score)}function Ax(e,t){return Gp(e.label,t)}var Cx=["path","manifest","url","slug"];function Lx(e){for(let t of Cx){let n=e.detail[t];if(typeof n=="string"&&n)return n}return""}function Nx(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 Px(e,t,n,r){let i=new Map;for(let o of e){let a=Sx(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Rx(o,t)})}for(let o of n){if(i.has(o.id))continue;let a=Ax(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Lx(o),badge:o.kind,score:a})}return[...i.values()].sort(Nx).slice(0,20)}function Mp(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Ns(e,t){return t<=0?0:Math.min(Math.max(e,0),t-1)}function Dp(e,t,n){return n<=0?0:((e+t)%n+n)%n}function Op(e,t){return t===null?null:e[t]?.id??null}function Fp(e,t,n){let r={cursor:e,activate:null,dismiss:!1,handled:!1},i=Ns(e,n);return t==="ArrowDown"?{...r,cursor:Dp(i,1,n),handled:!0}:t==="ArrowUp"?{...r,cursor:Dp(i,-1,n),handled:!0}:t==="Home"?{...r,cursor:0,handled:!0}:t==="End"?{...r,cursor:Ns(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 vo="Search the workspace",$p="Search notes and repository…",zp="↑↓ move · ↵ open · esc close";function Dx(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 Ix(e){return e===1?"1 result":`${e} results`}function Ip(e){return`weave-search-row-${e}`}function Wp(e,t){let n=Px(e.hits,e.answered,t?.model.nodes??[],e.query),r=Ns(e.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:Ip(a)})),status:Dx(e,n.length),count:n.length,countLabel:Ix(n.length),cursor:r,activeDomId:n.length?Ip(r):null}}function Mx({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 Hp(e){let[t,n]=q(Mp),r=Y(0),i=Y(null),o=Yn(),a=Y(null);oe(()=>{a.current?.focus()},[]),oe(()=>{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(w=>({...w,loading:!0,failed:!1}));let m=await Ul(e.ports.fetch,c,p.signal);!u||p.signal.aborted||d!==r.current||n(w=>m.ok?{...w,hits:m.data.hits,answered:c,loading:!1,failed:!1,cursor:0}:{...w,loading:!1,failed:!0})},140);return()=>{u=!1,window.clearTimeout(h),i.current?.abort()}},[t.query,e.ports.fetch]);let s=Wp(t,e.graph),l=(c,u=!1)=>{let h=Op(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":vo,tabIndex:-1,ref:o.ref,onClick:c=>c.stopPropagation(),onKeyDown:c=>{if(o.onKeyDown(c))return;let u=Fp(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:$p,"aria-label":vo,"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":vo,children:s.rows.map((c,u)=>f(Mx,{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:[zp," · ⌘/Ctrl ↵ new tab"]})]})]})})}function Ps(){return{graph:null,graphFailed:!1,note:null,noteFailed:!1,recentIds:new Set,selectedId:null}}var Bp=2e3,Ox=3e3,Kp=new Set;function Fx(e,t){if(e===null)return Kp;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 Up(e){if(e===null||!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}function Vp(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=Up(t.selectedId);if(d===null){o({note:null,noteFailed:!1});return}let p=await na(e.fetch,d);p.ok?o({note:p.data,noteFailed:!1}):o({note:null,noteFailed:!0})},l=async()=>{let d=t.graph,p=await gi(e.fetch,t.graph);if(!p.ok)return t.graph===null&&o({graphFailed:!0}),p;if(!p.cached){let m=Fx(d,p.data);o({graph:p.data,graphFailed:!1,recentIds:m}),i?.(),i=null,m.size>0&&(i=a(()=>{i=null,o({recentIds:Kp})},Ox))}return p},c=async()=>{if(!(n||r)){r=!0;try{let d=await l();Up(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()},Bp);return c(),{refresh:()=>{c()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function jp(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 na(e,t);i||(n(s),s.ok||(o=r(()=>{a()},Bp)))};return a(),()=>{i=!0,o?.()}}var Mr={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function yo(e,t,n){return{id:e,target:t.id,label:Je(t),kind:t.kind,kindIcon:sn(t.kind),provenance:t.provenance,provenanceGlyph:ln(t.provenance),provenanceTitle:In(t.provenance),selected:t.id===n}}function $x(e,t,n){let r=e.target;if(r===void 0)return null;let i=t.get(r);return i===void 0?null:yo(e.id,i,n)}function zx(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);return t}var Wx=["link:links-to:"];function Hx(e){return Wx.some(t=>e.id.startsWith(t))}function Ux(e){return e.id.startsWith("link:mentions:")}function Bx(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(yo(`tag:${o}:${l}`,c,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Kx(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(yo(`mentioned-by:${o.source}`,a,r))}return i}function Vx(e){if(!e.startsWith("note:"))return null;let t=e.slice(5);return t===""?null:t}var wo={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 Ds(e){return{subject:null,groups:[],tags:[],tagsCount:0,empty:e}}function qp(e,t){if(e===null)return Ds(wo.loading);if(t===null)return Ds(wo.noSelection);let n=on(e),r=sa(n,t);if(r===null)return Ds(wo.unknown);let i=zx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>$x(d,i,t)).filter(d=>d!==null);a(Mr.links,s(r.links.filter(Hx)));let l=la(n.edges).get(t)??[];a(Mr.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>yo(`backlink:${h.id}`,h,t))),a(Mr.mentions,[...s(r.links.filter(Ux)),...Kx(n,t,i,t)]);let c=Vx(t),u=c===null?[]:Bx(e,c,i,t);return o.length===0&&u.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:wo.isolated}:{subject:r.label,groups:o,tags:u,tagsCount:u.length,empty:null}}function Yp(){return{open:new Set,closed:new Set}}var jx=8;function Xp(e,t,n,r){return r?!1:e.closed.has(t)?!0:e.open.has(t)?!1:n>jx}function qx(e){return e.some(t=>t.selected)}function Zp(e,t){let n=Xp(t,e.heading,e.count,qx(e.rows));return{heading:e.heading,count:e.count,collapsed:n,rows:n?[]:e.rows}}function Qp(e,t){let n=Xp(t,Mr.tags,e.length,e.some(r=>r.siblings.some(i=>i.selected)));return{heading:Mr.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 bo(e){return`weave-ctx-panel-${e.toLowerCase()}`}function bn(e){let t=Y(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 ef({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(Ct,{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 tf({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":bo(e.heading),onClick:t,children:[f("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:f(Ct,{name:"chevron",class:e.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),e.heading,f("span",{class:"weave-ctx-count",children:e.count})]})})}function Yx({view:e,onSelect:t,onToggle:n}){return f("section",{class:"weave-ctx-group",children:[f(tf,{view:e,onToggle:n}),f("ul",{class:"weave-ctx-rows",id:bo(e.heading),hidden:e.collapsed,children:e.rows.map(r=>f(ef,{row:r,onSelect:i=>t(r.target,i)},r.id))})]})}function Xx({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(ef,{row:n,onSelect:r=>t(n.target,r)},n.id))})]})}function nf(e){let t=Y(null),n=qp(e.graph,e.selectedId),[r,i]=q(Yp),o=s=>()=>i(Jp(r,s.heading,s.collapsed)),a=Qp(n.tags,r);return f("div",{class:"weave-rail","aria-label":Fu.title,children:[n.empty===null?null:f("p",{class:"weave-ctx-empty",children:n.empty}),n.groups.map(s=>{let l=Zp(s,r);return f(Yx,{view:l,onSelect:e.onSelect,onToggle:o(l)},s.heading)}),n.tags.length===0?null:f("section",{class:"weave-ctx-group",children:[f(tf,{view:a,onToggle:o(a)}),f("ul",{class:"weave-ctx-tags weave-context-tags",ref:t,style:{height:e.tagHeight},id:bo(a.heading),hidden:a.collapsed,children:n.tags.map(s=>f(Xx,{tag:s,onSelect:e.onSelect},s.tag))}),a.collapsed?null:f(bn,{label:"Resize tags section",horizontal:!0,min:60,max:600,value:e.tagHeight,onChange:s=>e.onTagResize(Math.max(60,Math.min(600,(t.current?.clientHeight??e.tagHeight)+s)))})]})]})}function Zx(e){if(e===""||e==="#")return null;let t=e.slice(1),n=/^note[/:](.+)$/.exec(t);return n===null?null:`note:${n[1]}`}function rf(e,t){let n=Zx(e);return n===null||t===null?null:t.model.nodes.some(r=>r.id===n)?n:null}function of(e){let t=e===null?null:e.startsWith("note:")?e.slice(5):null;return t===null||t===""?"":`#note/${t}`}function af(e,t){let n=e[t.key];return Number.isFinite(n)?Math.min(t.max,Math.max(t.min,n)):t.max}function sf(e,t){let n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(e.max,Math.max(e.min,n)):zt[e.key]}function lf(e){return Number.isFinite(e)?Number.isInteger(e)?String(e):e.toFixed(3).replace(/0+$/,"").replace(/\.$/,""):"∞"}function cf(e){return An.every(t=>Object.is(e[t.key],zt[t.key]))}function uf(e){return f("div",{class:"weave-settings-forces",children:[An.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:af(e.forces,t),onInput:n=>e.onChange({...e.forces,[t.key]:sf(t,n.currentTarget.value)})}),f("output",{children:lf(e.forces[t.key])})]})]},t.key)),f("button",{type:"button",disabled:cf(e.forces),onClick:()=>e.onChange({...zt}),children:"Reset graph layout"})]})}var df=["General","Appearance","Interface","Editor","Files","Backup"];function lt(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 hf(e){let[t,n]=q("General"),[r,i]=q(0),o=Yn(),a=e.layout.preferences,s=l=>e.onChange({...e.layout,preferences:{...a,...l}});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:o.ref,onClick:l=>l.stopPropagation(),onKeyDown:l=>{o.onKeyDown(l)},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:l=>n(l.currentTarget.value),children:df.map(l=>f("option",{value:l,children:l},l))}):df.map(l=>f("button",{type:"button","aria-current":t===l?"page":void 0,onClick:()=>n(l),children:l},l))}),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:f("code",{children:e.info.vaultRoot||"Loading…"})}),f("dt",{children:"Repository"}),f("dd",{children:f("code",{children:e.cwd})})]}),f("div",{class:"weave-settings-actions",children:[f("button",{type:"button",onClick:()=>{i(l=>l+1),e.onRefresh()},children:[f("span",{class:r?"weave-refresh-spin":"","aria-hidden":"true",children:"↻"},r)," 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"}),Ii(e.shortcut.slice(0,-1)).map(l=>f("div",{children:[f("h4",{children:l.title}),l.entries.map(c=>f("div",{class:"weave-key-row",children:[f("kbd",{children:c.combo}),f("span",{children:c.what})]},c.combo))]},l.title))]})]}):null,t==="Appearance"?f(pe,{children:[f(lt,{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:l=>e.onChange({...e.layout,theme:l.currentTarget.value==="system"?"system":l.currentTarget.value==="light"?a.lightTheme:a.darkTheme}),children:[f("option",{value:"system",children:"System"}),f("option",{value:"light",children:"Light"}),f("option",{value:"dark",children:"Dark"})]})}),["light","dark"].map(l=>f(lt,{name:`${l==="light"?"Light":"Dark"} theme`,hint:`Used in ${l} mode and by the ribbon theme button.`,children:f("select",{"aria-label":`${l==="light"?"Light":"Dark"} theme`,value:a[`${l}Theme`],onChange:c=>{let u=c.currentTarget.value;e.onChange({...e.layout,preferences:{...a,[`${l}Theme`]:u},theme:e.layout.theme!=="system"&&ue[e.layout.theme].scheme===l?u:e.layout.theme})},children:Object.entries(ue).filter(([,c])=>c.scheme===l).map(([c,u])=>f("option",{value:c,children:u.name},c))})},l)),f(lt,{name:"Accent color",hint:"Choose independently of the theme. Shades adapt to light and dark backgrounds.",children:f("select",{"aria-label":"Accent color",value:a.accent,onChange:l=>s({accent:l.currentTarget.value}),children:[f("option",{value:"theme",children:"Theme default"}),Object.entries(en).map(([l,c])=>f("option",{value:l,children:c.name},l))]})}),f(lt,{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:a.fontSize,onInput:l=>s({fontSize:Number(l.currentTarget.value)})}),f("output",{children:[a.fontSize,"px"]})]})})]}):null,t==="Interface"?f(pe,{children:[f(lt,{name:"Notes sidebar",hint:"Show files and recent notes.",children:f("input",{type:"checkbox",checked:e.layout.treeVisible,onChange:l=>e.onChange({...e.layout,treeVisible:l.currentTarget.checked})})}),f(lt,{name:"Context sidebar",hint:"Show links, backlinks, and related items.",children:f("input",{type:"checkbox",checked:e.layout.contextVisible,onChange:l=>e.onChange({...e.layout,contextVisible:l.currentTarget.checked})})}),f(lt,{name:"Color graph by group",hint:"Give each containment group its own color.",children:f("input",{type:"checkbox",checked:a.groupColors,onChange:l=>s({groupColors:l.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(uf,{forces:a.forces,onChange:l=>s({forces:l})})]}):null,t==="Editor"?f(pe,{children:[f(lt,{name:"Spellcheck",hint:"Use your browser or device’s spellchecker while editing.",children:f("input",{type:"checkbox",checked:a.spellcheck,onChange:l=>s({spellcheck:l.currentTarget.checked})})}),f(lt,{name:"Readable line length",hint:"Keep note text in a comfortable reading column.",children:f("input",{type:"checkbox",checked:a.readable,onChange:l=>s({readable:l.currentTarget.checked})})}),f(lt,{name:"Open notes in editing mode",hint:"Newly opened notes start in the editor. Existing drafts are preserved.",children:f("input",{type:"checkbox",checked:a.defaultEdit,onChange:l=>s({defaultEdit:l.currentTarget.checked})})})]}):null,t==="Files"?f(pe,{children:[f(lt,{name:"On startup",hint:"Choose which tabs appear when you reopen this workspace.",children:f("select",{"aria-label":"On startup",value:a.startup,onChange:l=>s({startup:l.currentTarget.value}),children:[f("option",{value:"restore",children:"Restore open tabs"}),f("option",{value:"empty",children:"Start with an empty tab"})]})}),f(lt,{name:"Focus new tabs",hint:"Switch to notes opened in a new tab, including from the graph.",children:f("input",{type:"checkbox",checked:a.focusNewTabs,onChange:l=>s({focusNewTabs:l.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 Qx({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 pf(e){let t=Yn(),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":Ma,tabIndex:-1,ref:t.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{t.onKeyDown(r)},children:[f("h2",{class:"weave-help-title",children:Ma}),f("div",{class:"weave-keys",children:Ii(n).map(r=>f(Qx,{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:Vu})]})]})})}function ff(e,t){let n=r=>{if(r.defaultPrevented)return;let i=Uu(Bu(r),t.context());i!==null&&(r.preventDefault(),t.run(i))};return e.addEventListener("keydown",n),()=>e.removeEventListener("keydown",n)}function gf({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 mf="pi-weave.theme.v1";function xo(e){try{let t=e.getItem(mf);return Rn(t)?t:null}catch{return null}}function vf(e,t){try{return e.setItem(mf,t),!0}catch{return!1}}function ko(e,t,n=Wt){return ue[Gs(e,t,n)].scheme==="light"?n.darkTheme:n.lightTheme}function Gs(e,t,n=Wt){return e==="system"?t==="light"?n.lightTheme:n.darkTheme:e}function wf(e){return e==="system"?null:e}function Is(e){return e==="system"?"System":ue[e].name}function yf(e,t="dark",n=Wt){return{glyph:e==="system"?"◐":ue[e].scheme==="light"?"○":"●",label:Is(e),hint:`Colour theme: ${Is(e)} — click for ${Is(ko(e,t,n))}`}}function _o(e,t){if(e.kind==="graph")return"Graph view";let n=wt(e);return n===null?"New tab":t?.model.nodes.find(r=>r.id===n)?.label??n.replace(/^[^:]+:/,"")}function Jx(e){let[t]=q(e.visits);return f("div",{class:"weave-recents",children:Ou(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(Ct,{name:n.icon,class:"weave-icon"})}),f("span",{class:"weave-recent-label",children:n.label})]},n.id))})}function ek(e){let t=wt(e.tab),n=t?.startsWith("note:")?t.slice(5):null,[r,i]=q(null),o=Y(null),a=Y(e.tab.scroll),[s,l]=q(!1),[c,u]=q(""),[h,d]=q(!1),p=Y(null);Qe(()=>{s&&p.current?.focus()},[s]),oe(()=>{if(n===null)return;let v=e.drafts.nextLoadVersion();return jp(Ae,n,y=>{i({slug:n,note:y.ok?y.data:null,failed:!y.ok,version:v})})},[n,e.graph?.stamp,e.revision]);let m=r?.slug===n?r:null;if(Qe(()=>{let v=o.current?.querySelector(".weave-note");v!=null&&(v.scrollTop=a.current),n!==null&&e.drafts.get(n)!==null&&o.current?.querySelector(".weave-note-editor")?.focus()},[t,m?.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:"Ask your agent to write, organize, and connect your notes. Browse that knowledge here, or start a note yourself."}),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"}),f("button",{type:"button",onClick:()=>l(!0),children:"New note"})]}),s?f("form",{class:"weave-new-note",onSubmit:v=>{v.preventDefault(),!(h||!c.trim())&&(d(!0),e.onCreate(c.trim()).finally(()=>d(!1)))},onKeyDown:v=>{v.key==="Escape"&&(v.stopPropagation(),h||l(!1))},children:[f("label",{for:`new-note-${e.tab.id}`,children:"Note title"}),f("input",{id:`new-note-${e.tab.id}`,ref:p,required:!0,value:c,disabled:h,onInput:v=>u(v.currentTarget.value)}),f("div",{children:[f("button",{type:"submit",disabled:h||!c.trim(),children:h?"Creating…":"Create note"}),f("button",{type:"button",disabled:h,onClick:()=>l(!1),children:"Cancel"})]})]}):null]});let w=e.graph!==null&&!e.graph.model.nodes.some(v=>v.id===t);if(w||m?.failed&&e.drafts.isDirty(n??"")){let v=n===null?null:e.drafts.get(n);return v!==null&&n!==null&&e.drafts.isDirty(n)?f("div",{class:"weave-welcome",children:[f("h2",{children:w?"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. ",w?"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:v.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:v=>{let y=v.target;y.classList.contains("weave-note")&&(a.current=y.scrollTop,e.onScroll(y.scrollTop))},children:f(Ap,{spellcheck:e.preferences.spellcheck,defaultEdit:e.preferences.defaultEdit,note:m?.note??null,loadFailed:m?.failed??!1,loadVersion:m?.version??0,graph:e.graph,selectedId:t,onSelect:e.onSelect,onOpen:v=>{Bl(Ae,v).then(y=>{y.ok?y.data.opened||window.alert("Could not open the note in an editor."):window.alert(y.message)})},onSave:e.onSave,drafts:e.drafts,idPrefix:e.tab.id,now:e.now})})}function bf(e){let[t,n]=q(Ps),[r,i]=q(()=>({...jo(),theme:xo(localStorage)??"system"})),[o,a]=q(null),[s,l]=q(!1),[c,u]=q(Date.now),[h,d]=q(e.initialWidth),[p,m]=q(()=>wr(window)),[w,v]=q(!1),[y,b]=q({version:"",vaultRoot:""}),[k,E]=q(!1),[I,A]=q(0),[,D]=q(0),[O,W]=q(null),T=Y(null),[F,V]=q(null),j=Y(null),[Q,te]=q(null),[rt,Ie]=q(null),[Ge,He]=q(!1),[Ye,Xe]=q([]),[Mt,Te]=q(!1),[X]=q(mo),Ze=Y(null),jt=Y(null),Eo=Y(location.hash),Or=Y(!1),bt=Y(null),Fr=Y(null),xn=Y(null),$r=Y(null),[Xn,se]=q({left:0,top:0,width:600,height:500}),Zn=cr(r),ee=tn(r),qt=yf(r.theme,p,r.preferences),Le=Gs(r.theme,p,r.preferences),Yt=vt(()=>({theme:Le,accent:r.preferences.accent}),[Le,r.preferences.accent]),ct=wt(ee),me=ee.kind==="graph"?O:ct,Me=r.panes.find(_=>_.tabs.some(C=>C.id===_.activeTab&&C.kind==="graph")),kn=Me!==void 0&&(h>=850||Me.id===r.activePane),ye=s&&ee.kind==="document"&&!kn,gt=h<1050?Mt:r.contextVisible,Ne=kn||ye&&gt&&ct!==null,xt=r.panes.some(_=>_.tabs.some(C=>C.kind==="graph")),be=Y({layout:r,overlay:o,selectedId:me,graphPreviewId:F,select:_=>{}}),Ot=_=>{be.current.graphPreviewId=_,V(_)};oe(()=>{Ot(null)},[Ne,ye,ct]),oe(()=>{ct!==null?(T.current=ct,W(ct)):ee.kind==="graph"&&W(T.current)},[ee.id,ee.kind,ct]);let it=_=>{Sp(X,be.current.layout,_,()=>window.confirm(go))&&i(_)},Oe=(_,C=!1,U=r.activePane,L=!1)=>{let $=(_===null?Nn:$l)(r,_,{newTab:C,paneId:U});it(h<850&&!L?{...$,treeVisible:!1}:$),s||Te(!1)},Qn=()=>{let _=!(ye&&gt);l(_),_&&(i(C=>({...di(C),contextVisible:!0})),Te(!0))},kt=()=>i(_=>({...Yo(_),...h<850?{treeVisible:!1}:{}})),Xt=_=>{if(Ot(null),ye){Oe(_,!0);return}let C=r.panes.find(U=>U.id!==Me?.id);Oe(_,!0,C?.id??Me?.id??r.activePane)},_n=_=>{ye||W(_),Mu(be.current.graphPreviewId,_)?Xt(_):Ot(_)};be.current={layout:r,overlay:o,selectedId:me,graphPreviewId:F,select:Oe};let zr=_=>Rp(X,_,()=>window.confirm("Discard unsaved changes to the affected notes before changing files?")),Wr=async(_,C)=>{let U=await Vl(Ae,_,C);return U.ok?(A(L=>L+1),Ze.current?.refresh(),!0):(window.alert(U.message),!1)},Hr=async(_,C)=>{let U=await Kl(Ae,_);if(!U.ok)return window.alert(U.message),!1;let L=await gi(Ae);return n($=>({...$,graph:L.ok?L.data:null,graphFailed:!L.ok})),X.open(U.data.note.slug,U.data.note.body),it(Nn(be.current.layout,`note:${U.data.note.slug}`,{paneId:C})),Ze.current?.refresh(),!0};oe(()=>X.subscribe(()=>D(_=>_+1)),[X]),oe(()=>(Ze.current=Vp({fetch:Ae,state:Ps(),setState:n}),()=>Ze.current?.stop()),[]),oe(()=>{let _=!0;return(async()=>{try{let C=await Ae("/api/workspace-state"),U=await C.json();if(!_)return;if(C.ok&&typeof U.viewId=="string"){jt.current=U.viewId,U.info&&b(U.info);let L=Ol(U.layout);if(L){let $=Fl(L);i($),T.current=wt(tn(di($))),W(T.current),Xe(L.panes.flatMap(ce=>ce.tabs.flatMap(Ue=>Ue.history)).reduce(Da,[]))}}else E(!0)}catch{_&&E(!0)}finally{_&&v(!0)}})(),()=>{_=!1}},[]),oe(()=>{if(!w||t.graph===null||Or.current)return;Or.current=!0;let _=rf(Eo.current,t.graph);_!==null&&i(C=>Nn(C,_))},[w,t.graph]),oe(()=>{w&&Xe(_=>Da(_,me))},[w,me]),oe(()=>{w&&(history.replaceState(null,"",of(me)),document.documentElement.dataset.weaveTheme=Le,document.documentElement.dataset.weaveScheme=ue[Le].scheme,document.documentElement.dataset.weaveAccent=r.preferences.accent,vf(localStorage,r.theme))},[w,me,r.theme,Le,r.preferences.accent]);let En=Y(Promise.resolve());oe(()=>{if(!w||!jt.current)return;let _=jt.current,C=window.setTimeout(()=>{En.current=En.current.then(async()=>{try{let U=await Ae("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:_,layout:r})});E(!U.ok)}catch{E(!0)}})},350);return()=>window.clearTimeout(C)},[r,w]),oe(()=>{let _=window.setInterval(()=>u(Date.now()),zu),C=()=>d(window.innerWidth);window.addEventListener("resize",C);let U=Pu(window,m),L=Ue=>{for(let Tt of document.querySelectorAll(".weave-pane-menu[open]"))Tt.contains(Ue.target)||(Tt.open=!1)};document.addEventListener("pointerdown",L);let $=Ue=>{X.dirtySlugs().length&&(Ue.preventDefault(),Ue.returnValue="")},ce=()=>{jt.current&&fetch("/api/workspace-state",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({viewId:jt.current,layout:be.current.layout}),credentials:"same-origin",keepalive:!0}).catch(()=>{})};return window.addEventListener("pagehide",ce),window.addEventListener("beforeunload",$),()=>{window.clearInterval(_),window.removeEventListener("resize",C),window.removeEventListener("beforeunload",$),window.removeEventListener("pagehide",ce),document.removeEventListener("pointerdown",L),U()}},[]),oe(()=>ff(document,{context:()=>({overlay:be.current.overlay,hasSelection:be.current.selectedId!==null}),run:_=>Ku(_,{setOverlay:a,fitGraph:()=>$r.current?.(),clearSelection:()=>{tn(be.current.layout).kind==="graph"?(W(null),Ot(null)):be.current.select(null)},closeTab:()=>{let C=be.current.layout;it(Zo(C,C.activePane,tn(C).id))},toggleTheme:()=>i(C=>({...C,theme:ko(C.theme,wr(window),C.preferences)})),focusSelector:C=>(C===Mn.graph?i(U=>({...Yo(U),...window.innerWidth<850?{treeVisible:!1}:{}})):C===Mn.tree||C===Ga?i(U=>({...U,treeVisible:!0})):i(di),requestAnimationFrame(()=>{C===Mn.note&&Di(document,".weave-pane-active .weave-note-editor")||!Di(document,C)&&C===Mn.note&&Di(document,".weave-pane-active .weave-pane-content")}),!0)})}),[]),Qe(()=>{for(let _ of r.panes)document.getElementById(`tab-${_.activeTab}`)?.scrollIntoView({block:"nearest",inline:"nearest"})},[r.panes.map(_=>_.activeTab).join(","),r.activePane,h,w,t.graph?.stamp,r.treeVisible,r.treeWidth,r.contextVisible,r.contextWidth,r.ratio,r.split]),Qe(()=>{let _=ye?xn.current:Fr.current,C=bt.current;if(!Ne||!_||!C)return;let U=()=>{let $=_.getBoundingClientRect(),ce=C.getBoundingClientRect();se({left:$.left-ce.left,top:$.top-ce.top,width:$.width,height:$.height})};U();let L=new ResizeObserver(U);return L.observe(_),L.observe(C),()=>L.disconnect()},[ye,Ne,r,h]);let Jn=(_,C)=>i(U=>({...U,panes:U.panes.map(L=>({...L,tabs:L.tabs.map($=>$.id===_?{...$,scroll:C}:$)}))})),_t=(_,C)=>{pi(r,_,j.current)===null&&!C.dataTransfer?.types.includes(yr)||(C.preventDefault(),C.dataTransfer&&(C.dataTransfer.dropEffect=j.current===null?"copy":"move"),te(null),Ie(_))},Et=(_,C)=>{let U=Gu(t.graph,C.dataTransfer?.getData(yr)??"");if(U!==null){C.preventDefault(),Oe(U,!0,_),Ie(null);return}let L=j.current;pi(r,_,L)!==null&&(C.preventDefault(),i($=>{let ce=pi($,_,L);return ce===null?$:fi($,ce,L)}),j.current=null,Ie(null),te(null))},er=(_,C,U)=>{_.tabs.some(L=>L.id===j.current)&&(U.preventDefault(),U.stopPropagation(),U.dataTransfer.dropEffect="move",Ie(null),te({paneId:_.id,before:C}))},tr=(_,C)=>{let U=j.current;U===null||!_.tabs.some(L=>L.id===U)||(C.preventDefault(),C.stopPropagation(),i(L=>ea(L,_.id,U,Q?.paneId===_.id?Q.before:null)),j.current=null,te(null),Ie(null))},Ur=_=>{let C=_.tabs.find(L=>L.id===_.activeTab),U=_.id===r.activePane;return f("section",{class:`weave-pane${U?" weave-pane-active":""}${rt===_.id?" weave-pane-drop":""}`,"data-drop-label":j.current===null?"Open note here":"Move tab here","aria-label":`Workspace pane ${r.panes.indexOf(_)+1}`,onDragOver:L=>_t(_.id,L),onDrop:L=>Et(_.id,L),onDragLeave:L=>{L.currentTarget.contains(L.relatedTarget)||Ie(null)},hidden:h<850&&!U,onFocusCapture:()=>{U||i(L=>({...L,activePane:_.id}))},onPointerDown:()=>{U||i(L=>({...L,activePane:_.id}))},children:[f("div",{class:"weave-tabs",role:"tablist","aria-label":"Open documents",onDragOver:L=>er(_,null,L),onDrop:L=>tr(_,L),children:[_.tabs.map(L=>f("div",{class:`weave-tab${L.id===C.id?" weave-tab-active":""}${Q?.paneId===_.id&&Q.before===L.id?" weave-tab-drop-before":""}${Q?.paneId===_.id&&Q.before===null&&L===_.tabs.at(-1)?" weave-tab-drop-after":""}`,onDragOver:$=>{let ce=$.currentTarget.getBoundingClientRect(),Ue=$.clientX<ce.left+ce.width/2?L.id:_.tabs[_.tabs.indexOf(L)+1]?.id??null;er(_,Ue,$)},onDrop:$=>tr(_,$),children:[f("button",{type:"button",role:"tab",title:_o(L,t.graph),id:`tab-${L.id}`,"aria-selected":L.id===C.id,"aria-controls":`panel-${_.id}`,tabIndex:L.id===C.id?0:-1,draggable:!0,onDragStart:$=>{j.current=L.id,$.dataTransfer.effectAllowed="move",$.dataTransfer.setData("application/x-weave-tab",L.id)},onClick:()=>i(Xo(r,_.id,L.id)),onKeyDown:$=>{let ce=$.key==="ArrowRight"?1:$.key==="ArrowLeft"?-1:0;if(ce&&$.altKey&&!$.ctrlKey&&!$.metaKey){$.preventDefault(),$.stopPropagation();let Br=_.tabs.indexOf(L),Kr=ce<0?_.tabs[Math.max(0,Br-1)].id:_.tabs[Br+2]?.id??null;i(ea(r,_.id,L.id,Kr)),requestAnimationFrame(()=>document.getElementById(`tab-${L.id}`)?.focus());return}if(!ce&&$.key!=="Home"&&$.key!=="End")return;$.preventDefault();let Ue=$.key==="Home"?0:$.key==="End"?_.tabs.length-1:(_.tabs.indexOf(L)+ce+_.tabs.length)%_.tabs.length,Tt=_.tabs[Ue];i(Xo(r,_.id,Tt.id)),requestAnimationFrame(()=>document.getElementById(`tab-${Tt.id}`)?.focus())},children:[f("span",{"aria-hidden":"true",children:L.kind==="graph"?"◌":"▤"}),f("span",{children:_o(L,t.graph)}),X.isDirty((wt(L)??"").slice(5))?f("span",{class:"weave-dirty","aria-label":"Unsaved changes",children:"●"}):null]}),f("button",{type:"button",class:"weave-tab-close","aria-label":`Close ${_o(L,t.graph)}`,onClick:()=>it(Zo(r,_.id,L.id)),children:"×"})]},L.id)),f("button",{type:"button",class:"weave-new-tab","aria-label":"New tab",onClick:()=>Oe(null,!0,_.id),children:"+"})]}),f("div",{class:"weave-pane-toolbar",children:[f("button",{type:"button","aria-label":"Navigate back",disabled:C.kind==="graph"||C.cursor===0,onClick:()=>it(Qo({...r,activePane:_.id},_.id,-1)),children:"←"}),f("button",{type:"button","aria-label":"Navigate forward",disabled:C.kind==="graph"||C.cursor>=C.history.length-1,onClick:()=>it(Qo({...r,activePane:_.id},_.id,1)),children:"→"}),f("span",{class:"weave-breadcrumb",children:_o(C,t.graph)}),f("details",{class:"weave-pane-menu",onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),L.stopPropagation(),L.currentTarget.open=!1,L.currentTarget.querySelector("summary")?.focus())},children:[f("summary",{"aria-label":"Pane options",title:"Pane options",children:"···"}),f("div",{onClick:L=>{let $=L.currentTarget.closest("details");$&&($.open=!1)},children:[f("button",{type:"button",onClick:()=>i(Jo({...r,activePane:_.id},"right")),children:r.panes.length>1?"Arrange side by side":"Split right"}),f("button",{type:"button",onClick:()=>i(Jo({...r,activePane:_.id},"down")),children:r.panes.length>1?"Stack panes":"Split down"}),r.panes.length>1?f(pe,{children:[f("button",{type:"button",onClick:()=>i(fi(r,_.id,C.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(Ml(r,_.id)),children:"Close pane"})]}):null]})]})]}),f("div",{class:"weave-pane-content",role:"tabpanel",tabIndex:-1,id:`panel-${_.id}`,"aria-labelledby":`tab-${C.id}`,...C.kind==="graph"?{ref:Fr}:{},children:C.kind==="document"?f(ek,{preferences:r.preferences,tab:C,graph:t.graph,drafts:X,revision:I,now:c,onSelect:(L,$)=>Oe(L,$,_.id),onSave:Wr,onScroll:L=>Jn(C.id,L),onSearch:()=>a("search"),onGraph:kt,onCreate:L=>Hr(L,_.id)},`${C.id}:${C.cursor}:${wt(C)}`):null})]},_.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:bt,onDragEnd:()=>{j.current=null,Ie(null),te(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:kt,children:"◌"}),f("button",{type:"button","aria-label":"Toggle note graph",title:"Note graph","aria-pressed":ye&&gt,onClick:Qn,children:f("svg",{viewBox:"0 0 20 20",width:18,height:18,fill:"none",stroke:"currentColor","stroke-width":1.5,"aria-hidden":"true",children:[f("rect",{x:"2",y:"2",width:"16",height:"16",rx:"3"}),f("circle",{cx:"10",cy:"10",r:"4"})]})}),f("button",{type:"button","aria-label":"Search notes and repository",title:Wu(Ni(Pi(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":gt,title:"Context",onClick:()=>h<1050?Te(!Mt):i({...r,contextVisible:!r.contextVisible}),children:"☷"}),f("button",{type:"button","aria-label":"Refresh workspace",title:"Refresh workspace",onClick:()=>{Ze.current?.refresh(),A(_=>_+1)},children:"↻"}),f("button",{type:"button","aria-label":qt.hint,title:qt.hint,onClick:()=>i({...r,theme:ko(r.theme,p,r.preferences)}),children:qt.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,h-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":!Ge,onClick:()=>He(!1),children:"Files"}),f("button",{type:"button","aria-pressed":Ge,onClick:()=>He(!0),children:"Recent"}),f("button",{type:"button","aria-label":"Hide notes sidebar",onClick:()=>{bt.current?.querySelector('[aria-label="Toggle notes sidebar"]')?.focus(),i({...r,treeVisible:!1})},children:"«"})]}),Ge?f(Jx,{visits:Ye,graph:t.graph,selectedId:me,onSelect:Oe}):f(qu,{graph:t.graph,selectedId:me,recentIds:t.recentIds,onSelect:(_,C,U)=>Oe(_,C,r.activePane,U),onMutate:zr,onRefresh:()=>Ze.current?.refresh(),now:c}),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(bn,{label:"Resize notes sidebar",min:180,max:420,value:r.treeWidth,onChange:_=>i(C=>({...C,treeWidth:Math.max(180,Math.min(420,C.treeWidth+_))}))})]}),f("main",{class:`weave-panes weave-split-${r.split}`,style:r.panes.length===2&&h>=850?{[r.split==="right"?"gridTemplateColumns":"gridTemplateRows"]:`minmax(0, ${r.ratio}fr) 4px minmax(0, ${1-r.ratio}fr)`}:{},children:w?r.panes.map((_,C)=>f(pe,{children:[C>0&&h>=850?f(bn,{label:"Resize split panes",min:20,max:80,horizontal:r.split==="down",value:r.ratio*100,onChange:U=>{let L=r.split==="right"?bt.current?.querySelector("main")?.clientWidth:bt.current?.querySelector("main")?.clientHeight;i($=>({...$,ratio:Math.max(.2,Math.min(.8,$.ratio+U/(L??800)))}))}}):null,Ur(_)]})):f("div",{class:"weave-welcome",role:"status",children:"Opening workspace…"})}),f("div",{class:"weave-sidebar-dock weave-context-dock","data-open":gt,inert:!gt,"aria-hidden":!gt,style:{"--weave-sidebar-width":`${r.contextWidth}px`},children:[f(bn,{label:"Resize context sidebar",min:180,max:400,value:r.contextWidth,onChange:_=>i(C=>({...C,contextWidth:Math.max(180,Math.min(400,C.contextWidth-_))}))}),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:()=>{bt.current?.querySelector('[aria-label="Toggle context sidebar"]')?.focus(),Te(!1),i({...r,contextVisible:!1})},children:"»"})]}),ye?f("section",{class:"weave-context-graph-section","aria-label":"Note connections",children:[f("div",{class:"weave-context-graph-heading",children:[f("strong",{children:"Note graph"}),f("button",{type:"button","aria-label":"Hide note graph",onClick:()=>{bt.current?.querySelector('[aria-label="Toggle note graph"]')?.focus(),l(!1)},children:"×"})]}),f("div",{class:"weave-context-graph-slot",ref:xn,style:{height:r.contextGraphHeight},children:ct===null?f("p",{children:"Select a note to see its connections."}):null}),f(bn,{label:"Resize note graph",horizontal:!0,min:120,max:800,value:Xn.height,onChange:_=>i(C=>({...C,contextGraphHeight:Math.max(120,Math.min(800,(xn.current?.clientHeight??C.contextGraphHeight)+_))}))})]}):null,f(nf,{graph:t.graph,selectedId:me,onSelect:Oe,tagHeight:r.contextTagsHeight,onTagResize:_=>i(C=>({...C,contextTagsHeight:_}))})]})]}),xt||s?f("div",{class:`weave-graph-host${ye?" weave-context-graph-host":""}`,onDragOver:_=>{!ye&&Me&&_t(Me.id,_)},onDrop:_=>{!ye&&Me&&Et(Me.id,_)},onDragLeave:_=>{_.currentTarget.contains(_.relatedTarget)||Ie(null)},onPointerDown:()=>{!ye&&Me&&i(_=>({..._,activePane:Me.id}))},onFocusCapture:()=>{!ye&&Me&&i(_=>({..._,activePane:Me.id}))},"aria-hidden":!Ne,inert:!Ne,role:ye?"region":void 0,"aria-label":ye?"Note graph":void 0,style:{...Xn,visibility:Ne?"visible":"hidden",pointerEvents:Ne?"auto":"none"},children:f(Yu,{graph:t.graph,selectedId:me,previewId:F,onSelect:_n,onOpen:Xt,renderer:gh,storage:localStorage,host:window,scheme:Yt,forces:r.preferences.forces,groupColors:r.preferences.groupColors,bootFailed:t.graphFailed,fit:$r})}):null]}),f("div",{class:"weave-footer",children:[f(gf,{model:$u(e.cwd,me)}),k?f("span",{role:"status",children:"Workspace restoration unavailable"}):null,X.dirtySlugs().length?f("span",{children:[X.dirtySlugs().length," unsaved"]}):null,h<850&&r.panes.length>1?f("button",{type:"button",onClick:()=>i({...r,activePane:r.panes.find(_=>_.id!==Zn.id).id}),children:"Switch pane"}):null]}),o==="search"?f(Hp,{graph:t.graph,onSelect:Oe,onClose:()=>a(null),ports:{fetch:Ae}}):null,o==="settings"?f(hf,{compact:h<=650,layout:r,info:y,cwd:e.cwd,shortcut:Ni(Pi(e.platform)),onChange:_=>{it(_),Te(_.contextVisible)},onRefresh:()=>{Ze.current?.refresh(),A(_=>_+1)},onClose:()=>a(null)}):null,o==="help"?f(pf,{shortcut:Ni(Pi(e.platform)),onClose:()=>a(null)}):null]})}var xf=`
402
+ .weave-workbench{position:relative;isolation:isolate;display:flex;min-height:0;overflow:hidden;background:var(--weave-page)}
403
403
  .weave-workbench button{font:inherit;color:inherit;cursor:pointer}
404
404
  .weave-workbench button:focus-visible,.weave-workbench summary:focus-visible{outline:2px solid var(--weave-accent);outline-offset:-2px}
405
405
  .weave-workbench button:disabled{opacity:.35;cursor:default}
@@ -492,6 +492,16 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
492
492
  .weave-sidebar-context .weave-ctx-link{padding-top:7px;padding-bottom:7px}
493
493
  .weave-graph-host{position:absolute;z-index:2;display:flex;background:var(--weave-bg)}
494
494
  .weave-graph-host>.weave-graph{width:100%;height:100%;flex:1}
495
+ .weave-context-graph-section{flex:none;border-bottom:1px solid var(--weave-line)}
496
+ .weave-context-graph-heading{display:flex;align-items:center;justify-content:space-between;padding:4px 12px;font-size:var(--weave-px-caption);color:var(--weave-dim)}
497
+ .weave-context-graph-heading button{border:0;background:none;padding:2px 6px;font-size:18px}
498
+ .weave-context-graph-slot{max-height:calc(100dvh - 180px);min-height:120px}
499
+ .weave-context-tags{min-height:60px;max-height:60vh;overflow:auto}
500
+ .weave-context-graph-slot>p{padding:16px;margin:0;color:var(--weave-dim);font-size:var(--weave-px-row)}
501
+ .weave-context-graph-host{z-index:11}
502
+ .weave-context-graph-host .weave-graph-legend{display:none}
503
+ .weave-context-graph-host .weave-graph-preview{bottom:56px;padding:8px 28px 8px 8px}
504
+ .weave-context-graph-host .weave-graph-preview-title{font-size:var(--weave-px-caption)}
495
505
  .weave-graph-preview{pointer-events:none;position:absolute;z-index:2;right:8px;bottom:64px;width:min(280px,calc(100% - 16px));box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:10px 34px 10px 10px;background:var(--weave-panel);border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);box-shadow:0 6px 22px #0003}
496
506
  .weave-graph-preview-info{display:flex;align-items:center;gap:8px;min-width:0}
497
507
  .weave-graph-preview-copy{display:flex;flex-direction:column;min-width:0;gap:2px}
@@ -550,9 +560,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
550
560
  @media(prefers-reduced-motion:reduce){.weave-settings-actions button{transition:none}.weave-settings-actions button:active{transform:none}.weave-refresh-spin{animation:none}}
551
561
  .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)}
552
562
  @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}}
553
- `;function Ds(e){let{scheme:t,colors:n}=ce[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 tk=`
563
+ `;function Ms(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 tk=`
554
564
  :root{
555
- ${Ds("dark")}
565
+ ${Ms("dark")}
556
566
  --weave-row:26px;--weave-gutter:10px;
557
567
  /* The reading gutter is note-only: prose wants a wider margin than chrome.
558
568
  Rails, rows and bars keep --weave-gutter, so density is a property of the
@@ -602,11 +612,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
602
612
  --weave-px-subhead:14px;--weave-px-title:15px;--weave-px-display:20px;
603
613
  }
604
614
  @media (prefers-color-scheme: light){
605
- :root:not([data-weave-theme]){${Ds("light")}}
615
+ :root:not([data-weave-theme]){${Ms("light")}}
606
616
  }
607
- ${Object.keys(ce).map(e=>`:root[data-weave-theme="${e}"]{${Ds(e)}}`).join(`
617
+ ${Object.keys(ue).map(e=>`:root[data-weave-theme="${e}"]{${Ms(e)}}`).join(`
608
618
  `)}
609
- ${Object.entries(Zt).map(([e,t])=>["light","dark"].map(n=>`:root[data-weave-scheme="${n}"][data-weave-accent="${e}"]{--weave-accent:${t[n]};}`).join(`
619
+ ${Object.entries(en).map(([e,t])=>["light","dark"].map(n=>`:root[data-weave-scheme="${n}"][data-weave-accent="${e}"]{--weave-accent:${t[n]};}`).join(`
610
620
  `)).join(`
611
621
  `)}
612
622
  body{font-size:var(--weave-px-base)}
@@ -1057,7 +1067,7 @@ body{font-size:var(--weave-px-base)}
1057
1067
  @keyframes weave-fade-in{from{opacity:0}}
1058
1068
  @keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
1059
1069
  @media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
1060
- `,nk=["style[nonce]","style","script[nonce]","script[src]"];function rk(e){for(let t of nk){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function xf(e,t=tk+bf){let n=e.createElement("style"),r=rk(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var kf=document.getElementById("app");if(kf!==null){xf(document),ik();let e=fl(document.getElementById(pl)?.textContent??null);hl(f(wf,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),kf)}function ik(){let e=vf(fo(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1070
+ `,nk=["style[nonce]","style","script[nonce]","script[src]"];function rk(e){for(let t of nk){let n=e.querySelector(t)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function kf(e,t=tk+xf){let n=e.createElement("style"),r=rk(e);return r!==null&&(n.nonce=r),n.textContent=t,e.head.appendChild(n),r!==null}var _f=document.getElementById("app");if(_f!==null){kf(document),ik();let e=ml(document.getElementById(gl)?.textContent??null);fl(f(bf,{cwd:e.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),_f)}function ik(){let e=wf(xo(localStorage)??"system");e!==null&&(document.documentElement.dataset.weaveTheme=e)}})();
1061
1071
  /*! Bundled license information:
1062
1072
 
1063
1073
  dompurify/dist/purify.es.mjs: