pi-weave 0.1.8 → 0.1.10

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.
Files changed (52) hide show
  1. package/README.md +9 -3
  2. package/package.json +2 -2
  3. package/skills/weave-notepad/SKILL.md +13 -4
  4. package/src/core/concurrency.ts +36 -0
  5. package/src/core/frontmatter.ts +53 -0
  6. package/src/core/graph/build.ts +60 -1
  7. package/src/core/graph/model.ts +15 -0
  8. package/src/core/graph/wikilinks.ts +5 -1
  9. package/src/core/index.ts +2 -0
  10. package/src/core/paths.ts +7 -0
  11. package/src/core/sessions.ts +929 -0
  12. package/src/core/summaries.ts +1 -19
  13. package/src/core/vault.ts +264 -16
  14. package/src/core/workspace.ts +3 -3
  15. package/src/pi/index.ts +144 -37
  16. package/src/pi/sessionScan.ts +104 -0
  17. package/src/pi/summarize.ts +24 -4
  18. package/src/pi/tools/noteTool.ts +13 -4
  19. package/src/pi/viewer/tui/branding.ts +8 -7
  20. package/src/pi/viewer/tui/explorer.ts +1 -1
  21. package/src/web/client/dist/app.js +272 -113
  22. package/src/web/client/graph/Graph.tsx +112 -22
  23. package/src/web/client/graph/column.model.ts +52 -94
  24. package/src/web/client/graph/dynamics.ts +181 -0
  25. package/src/web/client/graph/graph.model.ts +113 -34
  26. package/src/web/client/graph/positions.ts +58 -13
  27. package/src/web/client/graph/renderer.ts +89 -5
  28. package/src/web/client/graph/scheme.ts +51 -6
  29. package/src/web/client/main.tsx +12 -0
  30. package/src/web/client/note/Editor.tsx +16 -9
  31. package/src/web/client/note/Note.tsx +40 -7
  32. package/src/web/client/note/note.model.ts +1 -1
  33. package/src/web/client/search/SearchPalette.tsx +11 -2
  34. package/src/web/client/selection.storage.ts +69 -0
  35. package/src/web/client/shell/Columns.tsx +13 -0
  36. package/src/web/client/shell/Header.tsx +25 -1
  37. package/src/web/client/shell/Shell.tsx +76 -2
  38. package/src/web/client/shell/deeplink.model.ts +61 -0
  39. package/src/web/client/shell/focus.model.ts +14 -6
  40. package/src/web/client/shell/keys.model.ts +27 -3
  41. package/src/web/client/shell/layout.model.ts +12 -38
  42. package/src/web/client/shell/theme.model.ts +147 -0
  43. package/src/web/client/shell/theme.ts +289 -79
  44. package/src/web/client/state.ts +22 -0
  45. package/src/web/client/tree/Tree.tsx +11 -2
  46. package/src/web/client/tree/tree.model.ts +12 -1
  47. package/src/web/client/workspace.ts +78 -6
  48. package/src/web/server/page.ts +6 -4
  49. package/src/web/server/routes.ts +19 -7
  50. package/src/web/shared/graph.ts +7 -0
  51. package/src/web/shared/layout.ts +393 -307
  52. package/src/web/shared/logo.ts +11 -0
@@ -20,11 +20,11 @@
20
20
  * sigma@3.0.3 — MIT
21
21
  */
22
22
 
23
- "use strict";(()=>{var Xf=Object.create;var ws=Object.defineProperty;var Zf=Object.getOwnPropertyDescriptor;var Qf=Object.getOwnPropertyNames;var Jf=Object.getPrototypeOf,ep=Object.prototype.hasOwnProperty;var bs=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var tp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Qf(e))!ep.call(t,i)&&i!==n&&ws(t,i,{get:()=>e[i],enumerable:!(r=Zf(e,i))||r.enumerable});return t};var bn=(t,e,n)=>(n=t!=null?Xf(Jf(t)):{},tp(e||!t||!t.__esModule?ws(n,"default",{value:t,enumerable:!0}):n,t));var Tr=bs((u_,fo)=>{"use strict";var Zt=typeof Reflect=="object"?Reflect:null,kl=Zt&&typeof Zt.apply=="function"?Zt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},kr;Zt&&typeof Zt.ownKeys=="function"?kr=Zt.ownKeys:Object.getOwnPropertySymbols?kr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:kr=function(e){return Object.getOwnPropertyNames(e)};function Jp(t){console&&console.warn&&console.warn(t)}var Tl=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}fo.exports=W;fo.exports.once=rg;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var Sl=10;function Sr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(W,"defaultMaxListeners",{enumerable:!0,get:function(){return Sl},set:function(t){if(typeof t!="number"||t<0||Tl(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Sl=t}});W.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};W.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Tl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Rl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return Rl(this)};W.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")kl(l,this,n);else for(var u=l.length,c=Dl(l,u),r=0;r<u;++r)kl(c[r],this,n);return!0};function Al(t,e,n,r){var i,o,a;if(Sr(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=Rl(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,Jp(s)}return t}W.prototype.addListener=function(e,n){return Al(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return Al(this,e,n,!0)};function eg(){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 Cl(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=eg.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return Sr(n),this.on(e,Cl(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return Sr(n),this.prependListener(e,Cl(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Sr(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():tg(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};W.prototype.off=W.prototype.removeListener;W.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function Ll(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?ng(i):Dl(i,i.length)}W.prototype.listeners=function(e){return Ll(this,e,!0)};W.prototype.rawListeners=function(e){return Ll(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Nl.call(t,e)};W.prototype.listenerCount=Nl;function Nl(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}W.prototype.eventNames=function(){return this._eventsCount>0?kr(this._events):[]};function Dl(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function tg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ng(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function rg(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}Pl(t,e,o,{once:!0}),e!=="error"&&ig(t,i,{once:!0})})}function ig(t,e,n){typeof t.on=="function"&&Pl(t,"error",e,n)}function Pl(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var po=bs((h_,Gl)=>{"use strict";Gl.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var vr,H,Ss,Wi,pt,xs,Ts,Rs,Ui,hr,xn,As,Ki,Hi,Bi,np,pr={},gr=[],rp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,yr=Array.isArray;function rt(t,e){for(var n in e)t[n]=e[n];return t}function Vi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ip(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?vr.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return fr(t,a,r,i,null)}function fr(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ss,__i:-1,__u:0};return i==null&&H.vnode!=null&&H.vnode(o),o}function Pe(t){return t.children}function Vt(t,e){this.props=t,this.context=e}function kt(t,e){if(e==null)return t.__?kt(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?kt(t):null}function op(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=rt({},e);o.__v=e.__v+1,H.vnode&&H.vnode(o),ji(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??kt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,Ps(r,o,i),e.__e=e.__=null,o.__e!=n&&Cs(o)}}function Cs(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),Cs(t)}function _s(t){(!t.__d&&(t.__d=!0)&&pt.push(t)&&!mr.__r++||xs!=H.debounceRendering)&&((xs=H.debounceRendering)||Ts)(mr)}function mr(){try{for(var t,e=1;pt.length;)pt.length>e&&pt.sort(Rs),t=pt.shift(),e=pt.length,op(t)}finally{pt.length=mr.__r=0}}function Ls(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,w=r&&r.__k||gr,b=e.length;for(l=ap(n,e,w,l,b),h=0;h<b;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&w[f.__i]||pr,f.__i=h,v=ji(t,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&qi(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=Ns(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=m,l}function ap(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=fr(null,a,null,null,null):yr(a)?a=t.__k[o]=fr(Pe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=fr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=sp(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=kt(s)),Gs(s,s));return r}function Ns(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=Ns(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=kt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function sp(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Es(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||rp.test(e)?n:n+"px"}function dr(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Es(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Es(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(As,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[xn]=r[xn]:(n[xn]=Ki,t.addEventListener(e,o?Bi:Hi,o)):t.removeEventListener(e,o?Bi:Hi,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function ks(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[hr]==null)e[hr]=Ki++;else if(e[hr]<n[xn])return;return n(H.event?H.event(e):e)}}}function ji(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,w,b,E,_,L,P,I,$,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=H.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(b=e.props,E=G.prototype&&G.prototype.render,_=(c=G.contextType)&&r[c.__c],L=c?_?_.props.value:c.__:r,n.__c?w=(d=e.__c=n.__c).__=d.__E:(E?e.__c=d=new G(b,L):(e.__c=d=new Vt(b,L),d.constructor=G,d.render=up),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),E&&d.__s==null&&(d.__s=d.state),E&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=rt({},d.__s)),rt(d.__s,G.getDerivedStateFromProps(b,d.__s))),g=d.props,m=d.state,d.__v=e,f)E&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),E&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(E&&G.getDerivedStateFromProps==null&&b!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(b,L),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(b,d.__s,L)===!1){e.__v!=n.__v&&(d.props=b,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),gr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=kt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(b,d.__s,L),E&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=L,d.props=b,d.__P=t,d.__e=!1,P=H.__r,I=0,E)d.state=d.__s,d.__d=!1,P&&P(e),c=d.render(d.props,d.state,d.context),gr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,P&&P(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++I<25);d.state=d.__s,d.getChildContext!=null&&(r=rt(rt({},r),d.getChildContext())),E&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),$=c!=null&&c.type===Pe&&c.key==null?Is(c.props.children):c,s=Ls(t,yr($)?$:[$],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),w&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(F=o.length;F--;)Vi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||Ds(e),H.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=lp(n.__e,e,n,r,i,o,a,l,u);return(c=H.diffed)&&c(e),128&e.__u?void 0:s}function Ds(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(Ds))}function Ps(t,e,n){for(var r=0;r<n.length;r++)qi(n[r],n[++r],n[++r]);H.__c&&H.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){H.__e(o,i.__v)}})}function Is(t){return typeof t!="object"||t==null||t.__b>0?t:yr(t)?t.map(Is):t.constructor!==void 0?null:rt({},t)}function lp(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||pr,w=e.props,b=e.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(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!b&&(b?f.localName==b:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(b==null)return document.createTextNode(w);t=document.createElementNS(i,b,w.is&&w),s&&(H.__m&&H.__m(e,o),s=!1),o=null}if(b==null)v===w||s&&t.data==w||(t.data=w);else{if(o=b=="textarea"&&w.defaultValue!=null?null:o&&vr.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in w||u=="value"&&"defaultValue"in w||u=="checked"&&"defaultChecked"in w||dr(t,u,null,f,i);for(u in w)f=w[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||dr(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),Ls(e.type=="template"?t.content:t,yr(d)?d:[d],e,n,r,b=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&kt(n,0),s,l),o!=null)for(u=o.length;u--;)Vi(o[u]);s&&b!="textarea"||(u="value",b=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||b=="progress"&&!g||b=="option"&&g!=v[u])&&dr(t,u,g,v[u],i),u="checked",m!=null&&m!=t[u]&&dr(t,u,m,v[u],i))}return t}function qi(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){H.__e(i,n)}}function Gs(t,e,n){var r,i;if(H.unmount&&H.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||qi(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){H.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Gs(r[i],e,n||typeof t.type!="function");n||Vi(t.__e),t.__c=t.__=t.__e=void 0}function up(t,e,n){return this.constructor(t,n)}function Ms(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),H.__&&H.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],ji(e,t=(!r&&n||e).__k=ip(Pe,null,[t]),i||pr,pr,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?vr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),Ps(o,t,a),t.props.children=null}vr=gr.slice,H={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},Ss=0,Wi=function(t){return t!=null&&t.constructor===void 0},Vt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=rt({},this.state),typeof t=="function"&&(t=t(rt({},n),this.props)),t&&rt(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),_s(this))},Vt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),_s(this))},Vt.prototype.render=Pe,pt=[],Ts=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Rs=function(t,e){return t.__v.__b-e.__v.__b},mr.__r=0,Ui=Math.random().toString(8),hr="__d"+Ui,xn="__a"+Ui,As=/(PointerCapture)$|Capture$/i,Ki=0,Hi=ks(!1),Bi=ks(!0),np=0;var cp=["vault","repo","git"],Os="change";function Fs(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.stamp!="string"?!1:cp.includes(e.scope)}var $s="weave-bootstrap";var Yi={cwd:"",vaultRoot:"",session:""};function dp(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.cwd=="string"&&typeof e.vaultRoot=="string"&&typeof e.session=="string"}function zs(t){if(t===null||t.trim()==="")return Yi;let e;try{e=JSON.parse(t)}catch{return Yi}return dp(e)?e:Yi}var jt,te,Xi,Us,br=0,Ys=[],re=H,Hs=re.__b,Bs=re.__r,Ws=re.diffed,Ks=re.__c,Vs=re.unmount,js=re.__;function xr(t,e){re.__h&&re.__h(te,t,br||e),br=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Ue(t){return br=1,hp(Zs,t)}function hp(t,e,n){var r=xr(jt++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):Zs(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=te,!te.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};te.__f=!0;var o=te.shouldComponentUpdate,a=te.componentWillUpdate;te.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},te.shouldComponentUpdate=i}return r.__N||r.__}function Re(t,e){var n=xr(jt++,3);!re.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function Xs(t,e){var n=xr(jt++,4);!re.__s&&Qi(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function Ae(t){return br=5,Ie(function(){return{current:t}},[])}function Ie(t,e){var n=xr(jt++,7);return Qi(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function fp(){for(var t;t=Ys.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(wr),e.__h.some(Zi),e.__h=[]}catch(n){e.__h=[],re.__e(n,t.__v)}}}re.__b=function(t){te=null,Hs&&Hs(t)},re.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),js&&js(t,e)},re.__r=function(t){Bs&&Bs(t),jt=0;var e=(te=t.__c).__H;e&&(Xi===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(wr),e.__h.some(Zi),e.__h=[],jt=0)),Xi=te},re.diffed=function(t){Ws&&Ws(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ys.push(e)!==1&&Us===re.requestAnimationFrame||((Us=re.requestAnimationFrame)||pp)(fp)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Xi=te=null},re.__c=function(t,e){e.some(function(n){try{n.__h.some(wr),n.__h=n.__h.filter(function(r){return!r.__||Zi(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],re.__e(r,n.__v)}}),Ks&&Ks(t,e)},re.unmount=function(t){Vs&&Vs(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{wr(r)}catch(i){e=i}}),n.__H=void 0,e&&re.__e(e,n.__v))};var qs=typeof requestAnimationFrame=="function";function pp(t){var e,n=function(){clearTimeout(r),qs&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);qs&&(e=requestAnimationFrame(n))}function wr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function Zi(t){var e=te;t.__c=t.__(),te=e}function Qi(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function Zs(t,e){return typeof e=="function"?e(t):e}var qt=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},credentials:"same-origin"});function gp(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Tt(t){var e=gp(t,"string");return typeof e=="symbol"?e:e+""}function se(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Qs(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Tt(r.key),r)}}function le(t,e,n){return e&&Qs(t.prototype,e),n&&Qs(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function St(t){return St=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},St(t)}function Js(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Js=function(){return!!t})()}function mp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function vp(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mp(t)}function be(t,e,n){return e=St(e),vp(t,Js()?Reflect.construct(e,n||[],St(t).constructor):e.apply(t,n))}function Ji(t,e){return Ji=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ji(t,e)}function xe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ji(t,e)}function yp(t){if(Array.isArray(t))return t}function wp(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function _r(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ro(t,e){if(t){if(typeof t=="string")return _r(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_r(t,e):void 0}}function bp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
24
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gt(t,e){return yp(t)||wp(t,e)||ro(t,e)||bp()}var eo={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 el=new Int8Array(4),to=new Int32Array(el.buffer,0,1),xp=new Float32Array(el.buffer,0,1),_p=/^\s*rgba?\s*\(/,Ep=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function kp(t){var e=0,n=0,r=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),n=parseInt(t.charAt(2)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(4),16),r=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(_p.test(t)){var o=t.match(Ep);o&&(e=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:e,g:n,b:r,a:i}}var Yt={};for(_n in eo)Yt[_n]=Xt(eo[_n]),Yt[eo[_n]]=Yt[_n];var _n;function tl(t,e,n,r,i){return to[0]=r<<24|n<<16|e<<8|t,i&&(to[0]=to[0]&4278190079),xp[0]}function Xt(t){if(t=t.toLowerCase(),typeof Yt[t]<"u")return Yt[t];var e=kp(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=tl(n,r,i,o,!0);return Yt[t]=a,a}var no={};function io(t){if(typeof no[t]<"u")return no[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=tl(e,n,r,i,!0);return no[t]=o,o}function oo(t,e,n,r){return n+(e<<8)+(t<<16)}function ao(t,e,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(t.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(a,s,1,1,t.RGBA,t.UNSIGNED_BYTE,l);var u=gt(l,4),c=u[0],h=u[1],d=u[2],f=u[3];return[c,h,d,f]}function S(t,e,n){return(e=Tt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nl(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function N(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nl(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nl(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Sp(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=St(t))!==null;);return t}function uo(){return uo=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=Sp(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},uo.apply(null,arguments)}function ul(t,e,n,r){var i=uo(St(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function Tp(t){return t.normalized?1:t.size}function so(t){var e=0;return t.forEach(function(n){return e+=Tp(n)}),e}function cl(t,e,n){var r=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,n),e.compileShader(i);var o=e.getShaderParameter(i,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
23
+ "use strict";(()=>{var yp=Object.create;var As=Object.defineProperty;var wp=Object.getOwnPropertyDescriptor;var bp=Object.getOwnPropertyNames;var xp=Object.getPrototypeOf,_p=Object.prototype.hasOwnProperty;var Rs=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var kp=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of bp(e))!_p.call(t,i)&&i!==n&&As(t,i,{get:()=>e[i],enumerable:!(r=wp(e,i))||r.enumerable});return t};var _n=(t,e,n)=>(n=t!=null?yp(xp(t)):{},kp(e||!t||!t.__esModule?As(n,"default",{value:t,enumerable:!0}):n,t));var Rr=Rs((I_,vo)=>{"use strict";var Zt=typeof Reflect=="object"?Reflect:null,Gl=Zt&&typeof Zt.apply=="function"?Zt.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},Tr;Zt&&typeof Zt.ownKeys=="function"?Tr=Zt.ownKeys:Object.getOwnPropertySymbols?Tr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Tr=function(e){return Object.getOwnPropertyNames(e)};function xg(t){console&&console.warn&&console.warn(t)}var Ol=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}vo.exports=W;vo.exports.once=Sg;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var Ml=10;function Ar(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(W,"defaultMaxListeners",{enumerable:!0,get:function(){return Ml},set:function(t){if(typeof t!="number"||t<0||Ol(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ml=t}});W.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};W.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ol(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Fl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return Fl(this)};W.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")Gl(l,this,n);else for(var u=l.length,c=Bl(l,u),r=0;r<u;++r)Gl(c[r],this,n);return!0};function zl(t,e,n,r){var i,o,a;if(Ar(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=Fl(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,xg(s)}return t}W.prototype.addListener=function(e,n){return zl(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return zl(this,e,n,!0)};function _g(){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 $l(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=_g.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return Ar(n),this.on(e,$l(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return Ar(n),this.prependListener(e,$l(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(Ar(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():kg(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};W.prototype.off=W.prototype.removeListener;W.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function Ul(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Eg(i):Bl(i,i.length)}W.prototype.listeners=function(e){return Ul(this,e,!0)};W.prototype.rawListeners=function(e){return Ul(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Hl.call(t,e)};W.prototype.listenerCount=Hl;function Hl(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}W.prototype.eventNames=function(){return this._eventsCount>0?Tr(this._events):[]};function Bl(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function kg(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Eg(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Sg(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}Wl(t,e,o,{once:!0}),e!=="error"&&Tg(t,i,{once:!0})})}function Tg(t,e,n){typeof t.on=="function"&&Wl(t,"error",e,n)}function Wl(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var yo=Rs((O_,Vl)=>{"use strict";Vl.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var wr,H,Ds,qi,mt,Cs,Is,Gs,Ki,pr,kn,Ms,Yi,Vi,ji,Ep,mr={},vr=[],Sp=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,br=Array.isArray;function ot(t,e){for(var n in e)t[n]=e[n];return t}function Xi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Tp(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?wr.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return gr(t,a,r,i,null)}function gr(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ds,__i:-1,__u:0};return i==null&&H.vnode!=null&&H.vnode(o),o}function Me(t){return t.children}function jt(t,e){this.props=t,this.context=e}function Et(t,e){if(e==null)return t.__?Et(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Et(t):null}function Ap(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=ot({},e);o.__v=e.__v+1,H.vnode&&H.vnode(o),Zi(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??Et(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,Us(r,o,i),e.__e=e.__=null,o.__e!=n&&Os(o)}}function Os(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),Os(t)}function Ls(t){(!t.__d&&(t.__d=!0)&&mt.push(t)&&!yr.__r++||Cs!=H.debounceRendering)&&((Cs=H.debounceRendering)||Is)(yr)}function yr(){try{for(var t,e=1;mt.length;)mt.length>e&&mt.sort(Gs),t=mt.shift(),e=mt.length,Ap(t)}finally{mt.length=yr.__r=0}}function Fs(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,y=r&&r.__k||vr,w=e.length;for(l=Rp(n,e,y,l,w),h=0;h<w;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&y[f.__i]||mr,f.__i=h,v=Zi(t,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Qi(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=zs(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=m,l}function Rp(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=gr(null,a,null,null,null):br(a)?a=t.__k[o]=gr(Me,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=gr(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=Cp(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=Et(s)),Bs(s,s));return r}function zs(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=zs(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=Et(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Cp(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Ns(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Sp.test(e)?n:n+"px"}function fr(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Ns(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Ns(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(Ms,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[kn]=r[kn]:(n[kn]=Yi,t.addEventListener(e,o?ji:Vi,o)):t.removeEventListener(e,o?ji:Vi,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Ps(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[pr]==null)e[pr]=Yi++;else if(e[pr]<n[kn])return;return n(H.event?H.event(e):e)}}}function Zi(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,y,w,k,_,A,N,I,z,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=H.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(w=e.props,k=G.prototype&&G.prototype.render,_=(c=G.contextType)&&r[c.__c],A=c?_?_.props.value:c.__:r,n.__c?y=(d=e.__c=n.__c).__=d.__E:(k?e.__c=d=new G(w,A):(e.__c=d=new jt(w,A),d.constructor=G,d.render=Np),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),k&&d.__s==null&&(d.__s=d.state),k&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ot({},d.__s)),ot(d.__s,G.getDerivedStateFromProps(w,d.__s))),g=d.props,m=d.state,d.__v=e,f)k&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),k&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(k&&G.getDerivedStateFromProps==null&&w!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(w,A),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(w,d.__s,A)===!1){e.__v!=n.__v&&(d.props=w,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),vr.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=Et(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(w,d.__s,A),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=A,d.props=w,d.__P=t,d.__e=!1,N=H.__r,I=0,k)d.state=d.__s,d.__d=!1,N&&N(e),c=d.render(d.props,d.state,d.context),vr.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,N&&N(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++I<25);d.state=d.__s,d.getChildContext!=null&&(r=ot(ot({},r),d.getChildContext())),k&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),z=c!=null&&c.type===Me&&c.key==null?Hs(c.props.children):c,s=Fs(t,br(z)?z:[z],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),y&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(F=o.length;F--;)Xi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||$s(e),H.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=Lp(n.__e,e,n,r,i,o,a,l,u);return(c=H.diffed)&&c(e),128&e.__u?void 0:s}function $s(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some($s))}function Us(t,e,n){for(var r=0;r<n.length;r++)Qi(n[r],n[++r],n[++r]);H.__c&&H.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){H.__e(o,i.__v)}})}function Hs(t){return typeof t!="object"||t==null||t.__b>0?t:br(t)?t.map(Hs):t.constructor!==void 0?null:ot({},t)}function Lp(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||mr,y=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(w==null)return document.createTextNode(y);t=document.createElementNS(i,w,y.is&&y),s&&(H.__m&&H.__m(e,o),s=!1),o=null}if(w==null)v===y||s&&t.data==y||(t.data=y);else{if(o=w=="textarea"&&y.defaultValue!=null?null:o&&wr.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||fr(t,u,null,f,i);for(u in y)f=y[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||fr(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),Fs(e.type=="template"?t.content:t,br(d)?d:[d],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&Et(n,0),s,l),o!=null)for(u=o.length;u--;)Xi(o[u]);s&&w!="textarea"||(u="value",w=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||w=="progress"&&!g||w=="option"&&g!=v[u])&&fr(t,u,g,v[u],i),u="checked",m!=null&&m!=t[u]&&fr(t,u,m,v[u],i))}return t}function Qi(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){H.__e(i,n)}}function Bs(t,e,n){var r,i;if(H.unmount&&H.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Qi(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){H.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&Bs(r[i],e,n||typeof t.type!="function");n||Xi(t.__e),t.__c=t.__=t.__e=void 0}function Np(t,e,n){return this.constructor(t,n)}function Ws(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),H.__&&H.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],Zi(e,t=(!r&&n||e).__k=Tp(Me,null,[t]),i||mr,mr,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?wr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),Us(o,t,a),t.props.children=null}wr=vr.slice,H={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},Ds=0,qi=function(t){return t!=null&&t.constructor===void 0},jt.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ot({},this.state),typeof t=="function"&&(t=t(ot({},n),this.props)),t&&ot(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Ls(this))},jt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ls(this))},jt.prototype.render=Me,mt=[],Is=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Gs=function(t,e){return t.__v.__b-e.__v.__b},yr.__r=0,Ki=Math.random().toString(8),pr="__d"+Ki,kn="__a"+Ki,Ms=/(PointerCapture)$|Capture$/i,Yi=0,Vi=Ps(!1),ji=Ps(!0),Ep=0;var Pp=["vault","repo","git"],Ks="change";function Vs(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.stamp!="string"?!1:Pp.includes(e.scope)}var js="weave-bootstrap";var Ji={cwd:"",vaultRoot:"",session:""};function Dp(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.cwd=="string"&&typeof e.vaultRoot=="string"&&typeof e.session=="string"}function qs(t){if(t===null||t.trim()==="")return Ji;let e;try{e=JSON.parse(t)}catch{return Ji}return Dp(e)?e:Ji}var qt,te,eo,Ys,En=0,rl=[],ie=H,Xs=ie.__b,Zs=ie.__r,Qs=ie.diffed,Js=ie.__c,el=ie.unmount,tl=ie.__;function _r(t,e){ie.__h&&ie.__h(te,t,En||e),En=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Ne(t){return En=1,Ip(al,t)}function Ip(t,e,n){var r=_r(qt++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):al(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=te,!te.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};te.__f=!0;var o=te.shouldComponentUpdate,a=te.componentWillUpdate;te.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},te.shouldComponentUpdate=i}return r.__N||r.__}function ne(t,e){var n=_r(qt++,3);!ie.__s&&no(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function il(t,e){var n=_r(qt++,4);!ie.__s&&no(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function le(t){return En=5,we(function(){return{current:t}},[])}function we(t,e){var n=_r(qt++,7);return no(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ol(t,e){return En=8,we(function(){return t},e)}function Gp(){for(var t;t=rl.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(xr),e.__h.some(to),e.__h=[]}catch(n){e.__h=[],ie.__e(n,t.__v)}}}ie.__b=function(t){te=null,Xs&&Xs(t)},ie.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),tl&&tl(t,e)},ie.__r=function(t){Zs&&Zs(t),qt=0;var e=(te=t.__c).__H;e&&(eo===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(xr),e.__h.some(to),e.__h=[],qt=0)),eo=te},ie.diffed=function(t){Qs&&Qs(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(rl.push(e)!==1&&Ys===ie.requestAnimationFrame||((Ys=ie.requestAnimationFrame)||Mp)(Gp)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),eo=te=null},ie.__c=function(t,e){e.some(function(n){try{n.__h.some(xr),n.__h=n.__h.filter(function(r){return!r.__||to(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],ie.__e(r,n.__v)}}),Js&&Js(t,e)},ie.unmount=function(t){el&&el(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{xr(r)}catch(i){e=i}}),n.__H=void 0,e&&ie.__e(e,n.__v))};var nl=typeof requestAnimationFrame=="function";function Mp(t){var e,n=function(){clearTimeout(r),nl&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);nl&&(e=requestAnimationFrame(n))}function xr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function to(t){var e=te;t.__c=t.__(),te=e}function no(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function al(t,e){return typeof e=="function"?e(t):e}var St=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},credentials:"same-origin"});var sl="(prefers-color-scheme: light)";function kr(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(sl).matches?"light":"dark"}function ll(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(sl);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function Op(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function At(t){var e=Op(t,"string");return typeof e=="symbol"?e:e+""}function ue(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ul(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,At(r.key),r)}}function ce(t,e,n){return e&&ul(t.prototype,e),n&&ul(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function Tt(t){return Tt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Tt(t)}function cl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cl=function(){return!!t})()}function Fp(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function zp(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fp(t)}function ke(t,e,n){return e=Tt(e),zp(t,cl()?Reflect.construct(e,n||[],Tt(t).constructor):e.apply(t,n))}function ro(t,e){return ro=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ro(t,e)}function Ee(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ro(t,e)}function $p(t){if(Array.isArray(t))return t}function Up(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Er(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function so(t,e){if(t){if(typeof t=="string")return Er(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Er(t,e):void 0}}function Hp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
24
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vt(t,e){return $p(t)||Up(t,e)||so(t,e)||Hp()}var io={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 dl=new Int8Array(4),oo=new Int32Array(dl.buffer,0,1),Bp=new Float32Array(dl.buffer,0,1),Wp=/^\s*rgba?\s*\(/,Kp=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Vp(t){var e=0,n=0,r=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),n=parseInt(t.charAt(2)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(4),16),r=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(Wp.test(t)){var o=t.match(Kp);o&&(e=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:e,g:n,b:r,a:i}}var Yt={};for(Sn in io)Yt[Sn]=Xt(io[Sn]),Yt[io[Sn]]=Yt[Sn];var Sn;function hl(t,e,n,r,i){return oo[0]=r<<24|n<<16|e<<8|t,i&&(oo[0]=oo[0]&4278190079),Bp[0]}function Xt(t){if(t=t.toLowerCase(),typeof Yt[t]<"u")return Yt[t];var e=Vp(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=hl(n,r,i,o,!0);return Yt[t]=a,a}var ao={};function lo(t){if(typeof ao[t]<"u")return ao[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=hl(e,n,r,i,!0);return ao[t]=o,o}function uo(t,e,n,r){return n+(e<<8)+(t<<16)}function co(t,e,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(t.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(a,s,1,1,t.RGBA,t.UNSIGNED_BYTE,l);var u=vt(l,4),c=u[0],h=u[1],d=u[2],f=u[3];return[c,h,d,f]}function S(t,e,n){return(e=At(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fl(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function P(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fl(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fl(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jp(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=Tt(t))!==null;);return t}function po(){return po=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=jp(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},po.apply(null,arguments)}function bl(t,e,n,r){var i=po(Tt(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function qp(t){return t.normalized?1:t.size}function ho(t){var e=0;return t.forEach(function(n){return e+=qp(n)}),e}function xl(t,e,n){var r=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,n),e.compileShader(i);var o=e.getShaderParameter(i,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
25
25
  `.concat(a,`
26
- `).concat(n))}return i}function Rp(t,e){return cl("VERTEX",t,e)}function Ap(t,e){return cl("FRAGMENT",t,e)}function Cp(t,e){var n=t.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=e.length;r<i;r++)t.attachShader(n,e[r]);t.linkProgram(n);var o=t.getProgramParameter(n,t.LINK_STATUS);if(!o){var a=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function rl(t){var e=t.gl,n=t.buffer,r=t.program,i=t.vertexShader,o=t.fragmentShader;e.deleteShader(i),e.deleteShader(o),e.deleteProgram(r),e.deleteBuffer(n)}var il=`#define PICKING_MODE
27
- `,Lp=S(S(S(S(S(S(S(S({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4);var dl=(function(){function t(e,n,r){se(this,t),S(this,"array",new Float32Array),S(this,"constantArray",new Float32Array),S(this,"capacity",0),S(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=so(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",e,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",e,il+i.VERTEX_SHADER_SOURCE,il+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=so(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 le(t,[{key:"kill",value:function(){rl(this.normalProgram),this.pickProgram&&(rl(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,a){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=Rp(r,i),c=Ap(r,o),h=Cp(r,[u,c]),d={};s.UNIFORMS.forEach(function(m){var v=r.getUniformLocation(h,m);v&&(d[m]=v)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:g||{},uniformLocations:d,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var a=Lp[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=r.attributeLocations[n.name],l=r.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:so(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],a=r.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(N(N({},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 Np=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"kill",value:function(){ul(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(io(r),a,o)}}])})(dl);var co=(function(t){function e(){var n;se(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=be(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return xe(e,t),le(e,[{key:"kill",value:function(){ul(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(io(r),l,o,a,s)}}])})(dl);function Dp(t,e){return(function(){function n(r,i,o){se(this,n),S(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return le(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function hl(t,e,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?e[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=e.label;if(u){t.fillStyle=l,t.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,f=n.y,g=r.x,m=r.y,v=(d+g)/2,w=(f+m)/2,b=g-d,E=m-f,_=Math.sqrt(b*b+E*E);if(!(_<c+h)){d+=b*c/_,f+=E*c/_,g-=b*h/_,m-=E*h/_,v=(d+g)/2,w=(f+m)/2,b=g-d,E=m-f,_=Math.sqrt(b*b+E*E);var L=t.measureText(u).width;if(L>_){var P="…";for(u=u+P,L=t.measureText(u).width;L>_&&u.length>1;)u=u.slice(0,-2)+P,L=t.measureText(u).width;if(u.length<4)return}var I;b>0?E>0?I=Math.acos(b/_):I=Math.asin(E/_):E>0?I=Math.acos(b/_)+Math.PI:I=Math.asin(b/_)+Math.PI/2,t.save(),t.translate(v,w),t.rotate(I),t.fillText(u,-L/2,e.size/2+o),t.restore()}}}function ho(t,e,n){if(e.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?e[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;t.fillStyle=a,t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillText(e.label,e.x+e.size+3,e.y+r/3)}}function fl(t,e,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000";var a=2;if(typeof e.label=="string"){var s=t.measureText(e.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(e.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+u/2),t.lineTo(e.x+c+l,e.y+u/2),t.lineTo(e.x+c+l,e.y-u/2),t.lineTo(e.x+d,e.y-u/2),t.arc(e.x,e.y,c,h,-h),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+a,0,Math.PI*2),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,ho(t,e,n)}var Pp=`
26
+ `).concat(n))}return i}function Yp(t,e){return xl("VERTEX",t,e)}function Xp(t,e){return xl("FRAGMENT",t,e)}function Zp(t,e){var n=t.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=e.length;r<i;r++)t.attachShader(n,e[r]);t.linkProgram(n);var o=t.getProgramParameter(n,t.LINK_STATUS);if(!o){var a=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function pl(t){var e=t.gl,n=t.buffer,r=t.program,i=t.vertexShader,o=t.fragmentShader;e.deleteShader(i),e.deleteShader(o),e.deleteProgram(r),e.deleteBuffer(n)}var gl=`#define PICKING_MODE
27
+ `,Qp=S(S(S(S(S(S(S(S({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4);var _l=(function(){function t(e,n,r){ue(this,t),S(this,"array",new Float32Array),S(this,"constantArray",new Float32Array),S(this,"capacity",0),S(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=ho(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",e,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",e,gl+i.VERTEX_SHADER_SOURCE,gl+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=ho(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 ce(t,[{key:"kill",value:function(){pl(this.normalProgram),this.pickProgram&&(pl(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,a){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=Yp(r,i),c=Xp(r,o),h=Zp(r,[u,c]),d={};s.UNIFORMS.forEach(function(m){var v=r.getUniformLocation(h,m);v&&(d[m]=v)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)});var g;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)}),g=r.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:g||{},uniformLocations:d,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var a=Qp[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=r.attributeLocations[n.name],l=r.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:ho(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],a=r.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(P(P({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var Jp=(function(t){function e(){return ue(this,e),ke(this,e,arguments)}return Ee(e,t),ce(e,[{key:"kill",value:function(){bl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(lo(r),a,o)}}])})(_l);var go=(function(t){function e(){var n;ue(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=ke(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return Ee(e,t),ce(e,[{key:"kill",value:function(){bl(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(lo(r),l,o,a,s)}}])})(_l);function eg(t,e){return(function(){function n(r,i,o){ue(this,n),S(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return ce(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function kl(t,e,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?e[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=e.label;if(u){t.fillStyle=l,t.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,f=n.y,g=r.x,m=r.y,v=(d+g)/2,y=(f+m)/2,w=g-d,k=m-f,_=Math.sqrt(w*w+k*k);if(!(_<c+h)){d+=w*c/_,f+=k*c/_,g-=w*h/_,m-=k*h/_,v=(d+g)/2,y=(f+m)/2,w=g-d,k=m-f,_=Math.sqrt(w*w+k*k);var A=t.measureText(u).width;if(A>_){var N="…";for(u=u+N,A=t.measureText(u).width;A>_&&u.length>1;)u=u.slice(0,-2)+N,A=t.measureText(u).width;if(u.length<4)return}var I;w>0?k>0?I=Math.acos(w/_):I=Math.asin(k/_):k>0?I=Math.acos(w/_)+Math.PI:I=Math.asin(w/_)+Math.PI/2,t.save(),t.translate(v,y),t.rotate(I),t.fillText(u,-A/2,e.size/2+o),t.restore()}}}function mo(t,e,n){if(e.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?e[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;t.fillStyle=a,t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillText(e.label,e.x+e.size+3,e.y+r/3)}}function El(t,e,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000";var a=2;if(typeof e.label=="string"){var s=t.measureText(e.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(e.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+u/2),t.lineTo(e.x+c+l,e.y+u/2),t.lineTo(e.x+c+l,e.y-u/2),t.lineTo(e.x+d,e.y-u/2),t.arc(e.x,e.y,c,h,-h),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+a,0,Math.PI*2),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,mo(t,e,n)}var tg=`
28
28
  precision highp float;
29
29
 
30
30
  varying vec4 v_color;
@@ -56,7 +56,7 @@ void main(void) {
56
56
  gl_FragColor = mix(v_color, transparent, t);
57
57
  #endif
58
58
  }
59
- `,Ip=Pp,Gp=`
59
+ `,ng=tg,rg=`
60
60
  attribute vec4 a_id;
61
61
  attribute vec4 a_color;
62
62
  attribute vec2 a_position;
@@ -97,7 +97,7 @@ void main() {
97
97
 
98
98
  v_color.a *= bias;
99
99
  }
100
- `,Mp=Gp,pl=WebGLRenderingContext,ol=pl.UNSIGNED_BYTE,lo=pl.FLOAT,Op=["u_sizeRatio","u_correctionRatio","u_matrix"],kn=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Mp,FRAGMENT_SHADER_SOURCE:Ip,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Op,ATTRIBUTES:[{name:"a_position",size:2,type:lo},{name:"a_size",size:1,type:lo},{name:"a_color",size:4,type:ol,normalized:!0},{name:"a_id",size:4,type:ol,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:lo}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Xt(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(u,!1,r.matrix)}}])})(Np);S(kn,"ANGLE_1",0);S(kn,"ANGLE_2",2*Math.PI/3);S(kn,"ANGLE_3",4*Math.PI/3);var Fp=`
100
+ `,ig=rg,Sl=WebGLRenderingContext,ml=Sl.UNSIGNED_BYTE,fo=Sl.FLOAT,og=["u_sizeRatio","u_correctionRatio","u_matrix"],An=(function(t){function e(){return ue(this,e),ke(this,e,arguments)}return Ee(e,t),ce(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:ig,FRAGMENT_SHADER_SOURCE:ng,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:og,ATTRIBUTES:[{name:"a_position",size:2,type:fo},{name:"a_size",size:1,type:fo},{name:"a_color",size:4,type:ml,normalized:!0},{name:"a_id",size:4,type:ml,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:fo}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=Xt(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(u,!1,r.matrix)}}])})(Jp);S(An,"ANGLE_1",0);S(An,"ANGLE_2",2*Math.PI/3);S(An,"ANGLE_3",4*Math.PI/3);var ag=`
101
101
  precision mediump float;
102
102
 
103
103
  varying vec4 v_color;
@@ -105,7 +105,7 @@ varying vec4 v_color;
105
105
  void main(void) {
106
106
  gl_FragColor = v_color;
107
107
  }
108
- `,$p=Fp,zp=`
108
+ `,sg=ag,lg=`
109
109
  attribute vec2 a_position;
110
110
  attribute vec2 a_normal;
111
111
  attribute float a_radius;
@@ -171,7 +171,7 @@ void main() {
171
171
 
172
172
  v_color.a *= bias;
173
173
  }
174
- `,Up=zp,gl=WebGLRenderingContext,al=gl.UNSIGNED_BYTE,Er=gl.FLOAT,Hp=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],ml={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function vl(t){var e=N(N({},ml),t||{});return(function(n){function r(){return se(this,r),be(this,r,arguments)}return xe(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Up,FRAGMENT_SHADER_SOURCE:$p,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Hp,ATTRIBUTES:[{name:"a_position",size:2,type:Er},{name:"a_normal",size:2,type:Er},{name:"a_radius",size:1,type:Er},{name:"a_color",size:4,type:al,normalized:!0},{name:"a_id",size:4,type:al,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Er}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(e.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,f=s.x,g=s.y,m=l.x,v=l.y,w=Xt(u.color),b=m-f,E=v-g,_=b*b+E*E,L=0,P=0;_&&(_=1/Math.sqrt(_),L=-E*_*h,P=b*_*h);var I=this.array;I[a++]=m,I[a++]=v,I[a++]=-L,I[a++]=-P,I[a++]=d,I[a++]=w,I[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(g,e.widenessToThicknessRatio)}}])})(co)}var a_=vl();var Bp=`
174
+ `,ug=lg,Tl=WebGLRenderingContext,vl=Tl.UNSIGNED_BYTE,Sr=Tl.FLOAT,cg=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Al={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Rl(t){var e=P(P({},Al),t||{});return(function(n){function r(){return ue(this,r),ke(this,r,arguments)}return Ee(r,n),ce(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:ug,FRAGMENT_SHADER_SOURCE:sg,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:cg,ATTRIBUTES:[{name:"a_position",size:2,type:Sr},{name:"a_normal",size:2,type:Sr},{name:"a_radius",size:1,type:Sr},{name:"a_color",size:4,type:vl,normalized:!0},{name:"a_id",size:4,type:vl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Sr}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(e.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,f=s.x,g=s.y,m=l.x,v=l.y,y=Xt(u.color),w=m-f,k=v-g,_=w*w+k*k,A=0,N=0;_&&(_=1/Math.sqrt(_),A=-k*_*h,N=w*_*h);var I=this.array;I[a++]=m,I[a++]=v,I[a++]=-A,I[a++]=-N,I[a++]=d,I[a++]=y,I[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,g=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(g,e.widenessToThicknessRatio)}}])})(go)}var N_=Rl();var dg=`
175
175
  precision mediump float;
176
176
 
177
177
  varying vec4 v_color;
@@ -197,7 +197,7 @@ void main(void) {
197
197
  gl_FragColor = mix(v_color, transparent, t);
198
198
  #endif
199
199
  }
200
- `,yl=Bp,Wp=`
200
+ `,Cl=dg,hg=`
201
201
  attribute vec4 a_id;
202
202
  attribute vec4 a_color;
203
203
  attribute vec2 a_normal;
@@ -265,7 +265,7 @@ void main() {
265
265
 
266
266
  v_color.a *= bias;
267
267
  }
268
- `,Kp=Wp,wl=WebGLRenderingContext,sl=wl.UNSIGNED_BYTE,Rt=wl.FLOAT,Vp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],jp={lengthToThicknessRatio:ml.lengthToThicknessRatio};function bl(t){var e=N(N({},jp),t||{});return(function(n){function r(){return se(this,r),be(this,r,arguments)}return xe(r,n),le(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Kp,FRAGMENT_SHADER_SOURCE:yl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Vp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Rt},{name:"a_positionEnd",size:2,type:Rt},{name:"a_normal",size:2,type:Rt},{name:"a_color",size:4,type:sl,normalized:!0},{name:"a_id",size:4,type:sl,normalized:!0},{name:"a_radius",size:1,type:Rt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Rt},{name:"a_normalCoef",size:1,type:Rt},{name:"a_radiusCoef",size:1,type:Rt}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,d=s.y,f=l.x,g=l.y,m=Xt(u.color),v=f-h,w=g-d,b=l.size||1,E=v*v+w*w,_=0,L=0;E&&(E=1/Math.sqrt(E),_=-w*E*c,L=v*E*c);var P=this.array;P[a++]=h,P[a++]=d,P[a++]=f,P[a++]=g,P[a++]=_,P[a++]=L,P[a++]=m,P[a++]=o,P[a++]=b}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,f=l.u_correctionRatio,g=l.u_sizeRatio,m=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(g,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(v,e.lengthToThicknessRatio)}}])})(co)}var s_=bl();function qp(t){return Dp([bl(t),vl(t)])}var Yp=qp(),xl=Yp,Xp=`
268
+ `,fg=hg,Ll=WebGLRenderingContext,yl=Ll.UNSIGNED_BYTE,Rt=Ll.FLOAT,pg=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],gg={lengthToThicknessRatio:Al.lengthToThicknessRatio};function Nl(t){var e=P(P({},gg),t||{});return(function(n){function r(){return ue(this,r),ke(this,r,arguments)}return Ee(r,n),ce(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:fg,FRAGMENT_SHADER_SOURCE:Cl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:pg,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Rt},{name:"a_positionEnd",size:2,type:Rt},{name:"a_normal",size:2,type:Rt},{name:"a_color",size:4,type:yl,normalized:!0},{name:"a_id",size:4,type:yl,normalized:!0},{name:"a_radius",size:1,type:Rt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Rt},{name:"a_normalCoef",size:1,type:Rt},{name:"a_radiusCoef",size:1,type:Rt}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,d=s.y,f=l.x,g=l.y,m=Xt(u.color),v=f-h,y=g-d,w=l.size||1,k=v*v+y*y,_=0,A=0;k&&(k=1/Math.sqrt(k),_=-y*k*c,A=v*k*c);var N=this.array;N[a++]=h,N[a++]=d,N[a++]=f,N[a++]=g,N[a++]=_,N[a++]=A,N[a++]=m,N[a++]=o,N[a++]=w}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,f=l.u_correctionRatio,g=l.u_sizeRatio,m=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(g,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(v,e.lengthToThicknessRatio)}}])})(go)}var P_=Nl();function mg(t){return eg([Nl(t),Rl(t)])}var vg=mg(),Pl=vg,yg=`
269
269
  attribute vec4 a_id;
270
270
  attribute vec4 a_color;
271
271
  attribute vec2 a_normal;
@@ -330,15 +330,15 @@ void main() {
330
330
 
331
331
  v_color.a *= bias;
332
332
  }
333
- `,Zp=Xp,_l=WebGLRenderingContext,ll=_l.UNSIGNED_BYTE,En=_l.FLOAT,Qp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],El=(function(t){function e(){return se(this,e),be(this,e,arguments)}return xe(e,t),le(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Zp,FRAGMENT_SHADER_SOURCE:yl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Qp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:En},{name:"a_positionEnd",size:2,type:En},{name:"a_normal",size:2,type:En},{name:"a_color",size:4,type:ll,normalized:!0},{name:"a_id",size:4,type:ll,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:En},{name:"a_normalCoef",size:1,type:En}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=Xt(s.color),g=h-u,m=d-c,v=g*g+m*m,w=0,b=0;v&&(v=1/Math.sqrt(v),w=-m*v*l,b=g*v*l);var E=this.array;E[i++]=u,E[i++]=c,E[i++]=h,E[i++]=d,E[i++]=w,E[i++]=b,E[i++]=f,E[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(co);var Il=bn(Tr()),Rr=(function(t){function e(){var n;return se(this,e),n=be(this,e),n.rawEmitter=n,n}return xe(e,t),le(e)})(Il.EventEmitter);var Fl=bn(po());var og=function(e){return e},ag=function(e){return e*e},sg=function(e){return e*(2-e)},lg=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},ug=function(e){return e*e*e},cg=function(e){return--e*e*e+1},dg=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},$l={linear:og,quadraticIn:ag,quadraticOut:sg,quadraticInOut:lg,cubicIn:ug,cubicOut:cg,cubicInOut:dg},zl={easing:"quadraticInOut",duration:150};function Ge(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ar(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function Ml(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function Ol(t,e,n){return t[6]=e,t[7]=n,t}function mt(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],g=e[3],m=e[4],v=e[5],w=e[6],b=e[7],E=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=g*n+m*o+v*l,t[4]=g*r+m*a+v*u,t[5]=g*i+m*s+v*c,t[6]=w*n+b*o+E*l,t[7]=w*r+b*a+E*u,t[8]=w*i+b*s+E*c,t}function Cr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function hg(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Qt(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=Ge(),d=Math.min(u,c)-2*r,f=hg(e,n);return i?(mt(h,Ol(Ge(),s,l)),mt(h,Ar(Ge(),a)),mt(h,Ml(Ge(),o)),mt(h,Ar(Ge(),u/d/2/f,c/d/2/f))):(mt(h,Ar(Ge(),2*(d/u)*f,2*(d/c)*f)),mt(h,Ml(Ge(),-o)),mt(h,Ar(Ge(),1/a)),mt(h,Ol(Ge(),-s,-l))),h}function Ul(t,e,n){var r=Cr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Hl(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function Bl(t){if(!(0,Fl.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Wl(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function go(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function mo(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function vo(t){var e=gt(t.x,2),n=e[0],r=e[1],i=gt(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function Lr(t){"@babel/helpers - typeof";return Lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lr(t)}function yo(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function Nr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var Dr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:hl,defaultDrawNodeLabel:ho,defaultDrawNodeHover:fl,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:{}},fg={circle:kn},pg={arrow:xl,line:El};function Pr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Kl(t){var e=Nr({},Dr,t);return e.nodeProgramClasses=Nr({},fg,e.nodeProgramClasses),e.edgeProgramClasses=Nr({},pg,e.edgeProgramClasses),e}var T_=bn(Tr()),R_=bn(po()),Ir=1.5,Vl=(function(t){function e(){var n;return se(this,e),n=be(this,e),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return xe(e,t),le(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(N(N({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=N(N({},zl),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:$l[s.easing],c=Date.now(),h=this.getState(),d=function(){var g=(Date.now()-c)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(g),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Ir)},r):this.animate({ratio:this.ratio/Ir})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Ir)},r):this.animate({ratio:this.ratio*Ir})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(Rr);function He(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function it(t,e){var n=N(N({},He(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function Sn(t){var e="x"in t?t:N(N({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function gg(t,e){return N(N({},it(t,e)),{},{delta:Ql(t)})}var mg=2;function Gr(t){for(var e=[],n=0,r=Math.min(t.length,mg);n<r;n++)e.push(t[n]);return e}function Tn(t,e,n){var r={touches:Gr(t.touches).map(function(i){return He(i,n)}),previousTouches:e.map(function(i){return He(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Ql(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Jl=(function(t){function e(n,r){var i;return se(this,e),i=be(this,e),i.container=n,i.renderer=r,i}return xe(e,t),le(e)})(Rr),vg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],yg=vg.reduce(function(t,e){return N(N({},t),{},S({},e,Dr[e]))},{}),wg=(function(t){function e(n,r){var i;return se(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",yg),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 xe(e,t),le(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",it(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",it(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=it(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(He(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=He(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",it(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=He(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",it(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=it(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=He(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,g=a.getState(),m=g.x+d,v=g.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",it(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",it(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Ql(r);if(a){var s=gg(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(He(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Jl),bg=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],xg=bg.reduce(function(t,e){return N(N({},t),{},S({},e,Dr[e]))},{}),_g=(function(t){function e(n,r){var i;return se(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",xg),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return xe(e,t),le(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=Gr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return He(f,i.container)}),this.touchMode===2){var a=gt(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",Tn(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",Tn(r,this.lastTouches,this.container)),!r.touches.length){var s=He(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=Tn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=Tn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Gr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Gr(r.touches),a=o.map(function(Xe){return He(Xe,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Tn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Xe,gn){var De=i.startTouchesPositions[gn];return De&&(Xe.x!==De.x||Xe.y!==De.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,g=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,w=m.y;u.setState({x:c.x+f-v,y:c.y+g-w});break}case 2:{var b={x:.5,y:.5,angle:0,ratio:1},E=a[0],_=E.x,L=E.y,P=a[1],I=P.x,$=P.y,F=Math.atan2($-L,I-_)-this.startTouchesAngle,G=Math.hypot($-L,I-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);b.ratio=U,b.angle=c.angle+F;var j=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(j.width,j.height)-2*h,he=ge/j.width,Ye=ge/j.height,$t=U/ge,Fe=_-ge/2/he,$e=L-ge/2/Ye,ze=[Fe*Math.cos(-b.angle)-$e*Math.sin(-b.angle),$e*Math.cos(-b.angle)+Fe*Math.sin(-b.angle)];Fe=ze[0],$e=ze[1],b.x=J.x-Fe*$t,b.y=J.y+$e*$t,u.setState(b);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Jl);function Eg(t){if(Array.isArray(t))return _r(t)}function kg(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Sg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
334
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jl(t){return Eg(t)||kg(t)||ro(t)||Sg()}function Tg(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function wo(t,e){if(t==null)return{};var n,r,i=Tg(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var ql=(function(){function t(e,n){se(this,t),this.key=e,this.size=n}return le(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Yl=(function(){function t(){se(this,t),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return le(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new ql(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(ql.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function Rg(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var Xl=150,Zl=50,ot=Object.prototype.hasOwnProperty;function Ag(t,e,n){if(!ot.call(n,"x")||!ot.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),ot.call(n,"hidden")||(n.hidden=!1),ot.call(n,"highlighted")||(n.highlighted=!1),ot.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Cg(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),ot.call(n,"hidden")||(n.hidden=!1),ot.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Lg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(se(this,e),i=be(this,e),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new Yl),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",Ge()),S(i,"invMatrix",Ge()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",vo({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",go()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=Kl(o),Pr(i.settings),Bl(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 Vl,i.bindCameraHandlers(),i.mouseCaptor=new wg(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new _g(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return xe(e,t),le(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=wo(i,[r].map(Tt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=wo(s,[r].map(Tt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=wo(i,[r].map(Tt));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=ao(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=oo.apply(void 0,jl(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=Sn(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",N(N({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",N(N({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",N(N({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",N(N({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",N(N({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=Sn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Sn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",N(N({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",N(N({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",N({},s))},this.activeListeners.handleEnter=function(o){var a=Sn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",N({},s))};var i=function(a){return function(s){var l=Sn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),N(N({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),N(N({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=ao(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=oo.apply(void 0,jl(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=Hl(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=vo(this.customBBox||this.nodeExtent);var d=new Vl,f=Qt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},w={},b=1,E=i.nodes(),_=0,L=E.length;_<L;_++){var P=E[_],I=this.nodeDataCache[P],$=i.getNodeAttributes(P);I.x=$.x,I.y=$.y,this.normalizationFunction.applyTo(I),typeof I.label=="string"&&!I.hidden&&this.labelGrid.add(P,I.size,this.framedGraphToViewport(I,{matrix:f})),g[I.type]=(g[I.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!ot.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(g[F]||0),g[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(E=mo(this.nodeZExtent,function(mn){return r.nodeDataCache[mn].zIndex},E));for(var G=0,U=E.length;G<U;G++){var j=E[G];m[j]=b,w[m[j]]={type:"node",id:j},b++;var J=this.nodeDataCache[j];this.addNodeToProgram(j,m[j],g[J.type]++)}for(var ge={},he=i.edges(),Ye=0,$t=he.length;Ye<$t;Ye++){var Fe=he[Ye],$e=this.edgeDataCache[Fe];ge[$e.type]=(ge[$e.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=mo(this.edgeZExtent,function(mn){return r.edgeDataCache[mn].zIndex},he));for(var ze in this.edgePrograms){if(!ot.call(this.edgePrograms,ze))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ze,'"!'));this.edgePrograms[ze].reallocate(ge[ze]||0),ge[ze]=0}for(var Xe=0,gn=he.length;Xe<gn;Xe++){var De=he[Xe];v[De]=b,w[v[De]]={type:"edge",id:De},b++;var q=this.edgeDataCache[De];this.addEdgeToProgram(De,v[De],ge[q.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&Lr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=N({},r),u=s||this.nodeExtent,c=gt(u.x,2),h=c[0],d=c[1],f=gt(u.y,2),g=f[0],m=f[1],v=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],w=1/0,b=-1/0,E=1/0,_=-1/0;v.forEach(function(ge){var he=ge.x,Ye=ge.y;w=Math.min(w,he),b=Math.max(b,he),E=Math.min(E,Ye),_=Math.max(_,Ye)});var L=b-w,P=_-E,I=this.getDimensions(),$=I.width,F=I.height,G=0,U=0;if(L>=$?b<$-a?G=b-($-a):w>a&&(G=w-a):b>$+a?G=b-($+a):w<-a&&(G=w+a),P>=F?_<F-a?U=_-(F-a):E>a&&(U=E-a):_>F+a?U=_-(F+a):E<-a&&(U=E+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),J=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=J.x-j.x,U=J.y-j.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);yo(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-Xl||h>this.width+Xl||d<-Zl||d>this.height+Zl)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,N(N({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=Rg({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});yo(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[d.type],m=g?.drawLabel||f;m(r,N(N({key:l},d),{},{size:this.scaleSize(d.size)}),N(N(N({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),N(N(N({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var g=r.nodeDataCache[f],m=r.framedGraphToViewport(g),v=m.x,w=m.y,b=r.scaleSize(g.size),E=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],L=_?.drawHover||E;L(i,N(N({key:f},g),{},{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 f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=Qt(s,l,u,c),this.invMatrix=Qt(s,l,u,c,!0),this.correctionRatio=Ul(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var g in this.edgePrograms){var m=this.edgePrograms[g];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=Ag(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=Cg(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 Yl,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=Wl(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=N({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return N({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=N({},this.settings);return this.settings[r]=i,Pr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=N({},this.settings);return this.settings=N(N({},this.settings),r),Pr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=go(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(_){return i.addNode(_)}),this.graph.forEachEdge(function(_){return i.addEdge(_)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,w=m.length;v<w;v++){var b=m[v];if(this.updateEdge(b),o){var E=this.edgeProgramIndex[b];if(E===void 0)throw new Error('Sigma: edge "'.concat(b,`" can't be repaint`));this.addEdgeToProgram(b,this.edgeIndices[b],E)}}}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(N(N({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,g={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Cr(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Cr(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(Rr),eu=Lg;function tu(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return nu(this.cover(e,n),e,n,t)}function nu(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,g,m,v,w,b;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[w=v<<1|m]))return i[w]=a,t;if(f=+t._x.call(null,o.data),g=+t._y.call(null,o.data),e===f&&n===g)return a.next=o,i?i[w]=a:t._root=a,t;do i=i?i[w]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((w=v<<1|m)===(b=(g>=d)<<1|f>=h));return i[b]=o,i[w]=a,t}function ru(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)nu(this,a[n],s[n],t[n]);return this}function iu(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function ou(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function au(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function fe(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function su(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,g,m;for(f&&d.push(new fe(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);g=d.pop();)if(!(!(f=g.node)||(a=g.x0)>c||(s=g.y0)>h||(l=g.x1)<i||(u=g.y1)<o))if(f.length){var v=(a+l)/2,w=(s+u)/2;d.push(new fe(f[3],v,w,l,u),new fe(f[2],a,w,v,u),new fe(f[1],v,s,l,w),new fe(f[0],a,s,v,w)),(m=(e>=w)<<1|t>=v)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=g)}else{var b=t-+this._x.call(null,f.data),E=e-+this._y.call(null,f.data),_=b*b+E*E;if(_<n){var L=Math.sqrt(n=_);i=t-L,o=e-L,c=t+L,h=e+L,r=f.data}}return r}function lu(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,g,m,v,w;if(!n)return this;if(n.length)for(;;){if((g=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|g]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,w=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[w]=n:this._root=n),this):(this._root=o,this)}function uu(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function cu(){return this._root}function du(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function hu(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new fe(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,c,s,l)),(i=r[2])&&e.push(new fe(i,o,c,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,c)),(i=r[0])&&e.push(new fe(i,o,a,u,c))}return this}function fu(t){var e=[],n=[],r;for(this._root&&e.push(new fe(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,c,h)),(o=i[1])&&e.push(new fe(o,c,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,c,u)),(o=i[3])&&e.push(new fe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function pu(t){return t[0]}function gu(t){return arguments.length?(this._x=t,this):this._x}function mu(t){return t[1]}function vu(t){return arguments.length?(this._y=t,this):this._y}function At(t,e,n){var r=new bo(e??pu,n??mu,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function bo(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function yu(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var _e=At.prototype=bo.prototype;_e.copy=function(){var t=new bo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=yu(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=yu(r));return t};_e.add=tu;_e.addAll=ru;_e.cover=iu;_e.data=ou;_e.extent=au;_e.find=su;_e.remove=lu;_e.removeAll=uu;_e.root=cu;_e.size=du;_e.visit=hu;_e.visitAfter=fu;_e.x=gu;_e.y=vu;function ie(t){return function(){return t}}function Be(t){return(t()-.5)*1e-6}function Ng(t){return t.x+t.vx}function Dg(t){return t.y+t.vy}function xo(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ie(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,m,v,w=0;w<o;++w)for(h=At(e,Ng,Dg).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,g=d.y+d.vy,h.visit(b);function b(E,_,L,P,I){var $=E.data,F=E.r,G=m+F;if($){if($.index>d.index){var U=f-$.x-$.vx,j=g-$.y-$.vy,J=U*U+j*j;J<G*G&&(U===0&&(U=Be(r),J+=U*U),j===0&&(j=Be(r),J+=j*j),J=(G-(J=Math.sqrt(J)))/J*i,d.vx+=(U*=J)*(G=(F*=F)/(v+F)),d.vy+=(j*=J)*G,$.vx-=U*(G=1-G),$.vy-=j*G)}return}return _>f+G||P<f-G||L>g+G||I<g-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:ie(+u),l(),a):t},a}function Pg(t){return t.index}function wu(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function _o(t){var e=Pg,n=h,r,i=ie(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var w=0,b=t.length;w<c;++w)for(var E=0,_,L,P,I,$,F,G;E<b;++E)_=t[E],L=_.source,P=_.target,I=P.x+P.vx-L.x-L.vx||Be(u),$=P.y+P.vy-L.y-L.vy||Be(u),F=Math.sqrt(I*I+$*$),F=(F-o[E])/F*v*r[E],I*=F,$*=F,P.vx-=I*(G=l[E]),P.vy-=$*G,L.vx+=I*(G=1-G),L.vy+=$*G}function f(){if(a){var v,w=a.length,b=t.length,E=new Map(a.map((L,P)=>[e(L,P,a),L])),_;for(v=0,s=new Array(w);v<b;++v)_=t[v],_.index=v,typeof _.source!="object"&&(_.source=wu(E,_.source)),typeof _.target!="object"&&(_.target=wu(E,_.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)_=t[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(b),g(),o=new Array(b),m()}}function g(){if(a)for(var v=0,w=t.length;v<w;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,w=t.length;v<w;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,w){a=v,u=w,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ie(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ie(+v),m(),d):i},d}var Ig={value:()=>{}};function xu(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Mr(n)}function Mr(t){this._=t}function Gg(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Mr.prototype=xu.prototype={constructor:Mr,on:function(t,e){var n=this._,r=Gg(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=Mg(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=bu(n[i],t.name,e);else if(e==null)for(i in n)n[i]=bu(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Mr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function Mg(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function bu(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=Ig,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Eo=xu;var Jt=0,An=0,Rn=0,Eu=1e3,Or,Cn,Fr=0,Ct=0,$r=0,Ln=typeof performance=="object"&&performance.now?performance:Date,ku=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function To(){return Ct||(ku(Og),Ct=Ln.now()+$r)}function Og(){Ct=0}function ko(){this._call=this._time=this._next=null}ko.prototype=zr.prototype={constructor:ko,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?To():+n)+(e==null?0:+e),!this._next&&Cn!==this&&(Cn?Cn._next=this:Or=this,Cn=this),this._call=t,this._time=n,So()},stop:function(){this._call&&(this._call=null,this._time=1/0,So())}};function zr(t,e,n){var r=new ko;return r.restart(t,e,n),r}function Su(){To(),++Jt;for(var t=Or,e;t;)(e=Ct-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Jt}function _u(){Ct=(Fr=Ln.now())+$r,Jt=An=0;try{Su()}finally{Jt=0,$g(),Ct=0}}function Fg(){var t=Ln.now(),e=t-Fr;e>Eu&&($r-=e,Fr=t)}function $g(){for(var t,e=Or,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Or=n);Cn=t,So(r)}function So(t){if(!Jt){An&&(An=clearTimeout(An));var e=t-Ct;e>24?(t<1/0&&(An=setTimeout(_u,t-Ln.now()-$r)),Rn&&(Rn=clearInterval(Rn))):(Rn||(Fr=Ln.now(),Rn=setInterval(Fg,Eu)),Jt=1,ku(_u))}}function Tu(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Ru(t){return t.x}function Au(t){return t.y}var zg=10,Ug=Math.PI*(3-Math.sqrt(5));function Ro(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=zr(h),u=Eo("tick","end"),c=Tu();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,w=t.length,b;m===void 0&&(m=1);for(var E=0;E<m;++E)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<w;++v)b=t[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 e}function f(){for(var m=0,v=t.length,w;m<v;++m){if(w=t[m],w.index=m,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var b=zg*Math.sqrt(.5+m),E=m*Ug;w.x=b*Math.cos(E),w.y=b*Math.sin(E)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function g(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(g),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(g),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,g(v)),e):s.get(m)},find:function(m,v,w){var b=0,E=t.length,_,L,P,I,$;for(w==null?w=1/0:w*=w,b=0;b<E;++b)I=t[b],_=m-I.x,L=v-I.y,P=_*_+L*L,P<w&&($=I,w=P);return $},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function Ao(){var t,e,n,r,i=ie(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=t.length,v=At(t,Ru,Au).visitAfter(h);for(r=f,g=0;g<m;++g)e=t[g],v.visit(d)}function c(){if(t){var f,g=t.length,m;for(o=new Array(g),f=0;f<g;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var g=0,m,v,w=0,b,E,_;if(f.length){for(b=E=_=0;_<4;++_)(m=f[_])&&(v=Math.abs(m.value))&&(g+=m.value,w+=v,b+=v*m.x,E+=v*m.y);f.x=b/w,f.y=E/w}else{m=f,m.x=m.data.x,m.y=m.data.y;do g+=o[m.data.index];while(m=m.next)}f.value=g}function d(f,g,m,v){if(!f.value)return!0;var w=f.x-e.x,b=f.y-e.y,E=v-g,_=w*w+b*b;if(E*E/l<_)return _<s&&(w===0&&(w=Be(n),_+=w*w),b===0&&(b=Be(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)),e.vx+=w*f.value*r/_,e.vy+=b*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(w===0&&(w=Be(n),_+=w*w),b===0&&(b=Be(n),_+=b*b),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(E=o[f.data.index]*r/_,e.vx+=w*E,e.vy+=b*E);while(f=f.next)}return u.initialize=function(f,g){t=f,n=g,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ie(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function Co(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ie(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}function Lo(t){var e=ie(.1),n,r,i;typeof t!="function"&&(t=ie(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ie(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ie(+s),a(),o):t},o}var Dn=9,Pn=Dn+9,Hg=2*Pn+4,Po=70,Bg=220,Wg=.35;function Kg(t,e){let n=Po;for(let r of t){let i=Br(e.get(r)?.length??0);i>n&&(n=i)}return n}var Vg=-180,jg=.1,qg=.02,Yg=.4,Xg=300,Zg=1,Nu=1280,Du=800,Cu=.001,Ur=Math.PI*2,Qg=-Math.PI/2;function Do(t){return t==="contains"||t==="anchored-at"}function Hr(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}function Nn(t,e){return Hr(`${e}\0${t}`)/4294967296}function Jg(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Br(t){return Math.max(Po,Hg*t/Ur)}function Pu(t){let e=[],n=new Set;for(let u of t.nodes)n.has(u.id)||(n.add(u.id),e.push(u.id));let r=[],i=new Set,o=new Map,a=new Map,s=new Map;for(let u of t.edges){if(u.source===u.target||!n.has(u.source)||!n.has(u.target))continue;let c=`${u.source}\0${u.target}\0${u.kind}`;if(i.has(c)||(i.add(c),r.push(u),s.set(u.source,(s.get(u.source)??0)+1),s.set(u.target,(s.get(u.target)??0)+1),!Do(u.kind)||o.has(u.target)))continue;o.set(u.target,u.source);let h=a.get(u.source);h?h.push(u.target):a.set(u.source,[u.target])}let l=e.filter(u=>!o.has(u));return{ids:e,parent:o,children:a,roots:l,edges:r,degree:s}}function em(t,e,n){return 2*Br(e.get(t)?.length??0)+n}function tm(t,e){let n=0;return t.forEach((r,i)=>{let o=r+t[(i+1)%t.length],a=o/(4*Math.sin(Math.PI*o/(2*e)));a>n&&(n=a)}),n}function nm(t,e,n){let r=0;return e.map((i,o)=>{let a=Qg+Ur*((r+i/2)/n)+(Nn(t[o],3)-.5)*.05;return r+=i,a})}function rm(t,e=Nu,n=Du){let{ids:r,children:i,roots:o}=Pu(t),a=new Map,s=e/2,l=n/2;if(o.length===1)a.set(o[0],{x:s,y:l});else if(o.length>1){let c=Kg(o,i),h=o.map(m=>em(m,i,c)),d=0;for(let m of h)d+=m;let f=tm(h,d),g=nm(o,h,d);o.forEach((m,v)=>{let w=g[v];a.set(m,{x:s+f*Math.cos(w),y:l+f*Math.sin(w)})})}let u=[...o];for(let c=0;c<u.length;c++){let h=u[c],d=i.get(h);if(d===void 0)continue;let f=a.get(h),g=.7*Br(d.length);for(let m of d){let v=Ur*Nn(m,1),w=.85+.3*Nn(m,2);a.set(m,{x:f.x+g*w*Math.cos(v),y:f.y+g*w*Math.sin(v)}),u.push(m)}}for(let c of r){if(a.has(c))continue;let h=Ur*Nn(c,4),d=Po*(1+Nn(c,5));a.set(c,{x:s+d*Math.cos(h),y:l+d*Math.sin(h)})}return a}function No(t){return t.id}function Iu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Xg)),r=e.seed??Zg,i=e.width??Nu,o=e.height??Du,{ids:a,children:s,edges:l,degree:u,roots:c}=Pu(t),h=new Map;if(a.length===0)return h;let d=rm(t,i,o),f=e.initial,g=a.map(m=>{let v=d.get(m);return{id:m,...Lu(f?.get(m),v),vx:0,vy:0}});g.length>1&&im(g,l,s,u,d,new Set(c),{ticks:n,seed:r});for(let m of g)h.set(m.id,Lu(m,d.get(m.id)));return h}function Lu(t,e){return t===void 0?e:{x:Number.isFinite(t.x)?t.x:e.x,y:Number.isFinite(t.y)?t.y:e.y}}function im(t,e,n,r,i,o,a){let s=e.map(g=>({source:g.source,target:g.target,kind:g.kind})),l=g=>n.get(g)?.length??0,u=g=>Math.max(l(No(g.source)),l(No(g.target))),c=g=>r.get(No(g)),h=g=>o.has(g.id)?jg:qg,d=_o(s).id(g=>g.id).distance(g=>Do(g.kind)?Br(u(g)):Bg).strength(g=>{let m=1/Math.min(c(g.source),c(g.target));return Do(g.kind)?m:m*Wg}).iterations(2),f=Ro(t).randomSource(Jg(a.seed)).force("charge",Ao().strength(Vg)).force("link",d).force("collide",xo(Pn).strength(1).iterations(3)).force("x",Co(g=>i.get(g.id).x).strength(h)).force("y",Lo(g=>i.get(g.id).y).strength(h)).alpha(1).alphaMin(Cu).alphaDecay(a.ticks>0?1-Math.pow(Cu,1/a.ticks):0).velocityDecay(Yg);f.stop();for(let g=0;g<a.ticks;g++)f.tick()}function Ce(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function om(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let g=e.get(f);if(g&&g.kind==="module"&&g.detail.path){let m=g.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function Mu(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function am(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function sm(t,e){return t.slice().sort((n,r)=>{let i=Ce(e.get(n)),o=Ce(e.get(r));return i.localeCompare(o)})}function Gu(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function lm(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?Gu(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?Gu(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function Io(t,e){let n=om(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let w=(i.get(g)??[]).filter(b=>{let E=r.get(b);if(!E||E.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(b))return!1;return!0}).concat(o.get(g)??[]);return w=w.filter(b=>r.has(b)),e.showInternals||(w=w.filter(b=>{let E=r.get(b);return!(E&&am(E.kind))})),sm(w,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Ce(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let m=r.get(g),v=!1;for(let b of s(g))h(b)&&(v=!0);let w=u(m)||v;return w&&c.add(g),w};for(let g of a)h(g);let d=[],f=(g,m)=>{if(!c.has(g))return;let v=r.get(g),w=s(g),b=w.filter(_=>c.has(_)),E=l?b.length>0:e.expanded.has(g);if(d.push({id:g,depth:m,hasKids:w.length>0,expanded:E,label:Ce(v),kind:v.kind,provenance:v.provenance,meta:lm(v)}),E)for(let _ of b)f(_,m+1)};for(let g of a)f(g,0);return d}function Go(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function In(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var um=7;function Mo(t,e){if(t===null)return"";switch(t.kind){case"relTime":return In(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,um);case"text":return t.text}}var cm=["path","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","warning","stale","preview","root","notes","state"];function Oo(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of cm){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Ce(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Ce(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Ce(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Wr(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var dm=["contains","anchored-at"];function hm(t){return dm.includes(t)}function Kr(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=fm(t,n),i=Mu(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,pm(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let g=s.get(d);u.set(d,{children:f,descendants:g,members:g.filter(m=>l.get(m)===d),provenance:gm(g,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:mm(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function fm(t,e){let n=new Map;for(let r of t.edges){if(!hm(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function pm(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function gm(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function mm(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function Fo(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var en=[null,"human","agent","generated"];function Ou(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Lt(t){return{...t.model,danglingLinks:t.dangling}}function Fu(t,e){return t===null?[]:Io(Lt(t),e)}function $u(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function ym(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function wm(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function zu(t,e){return t.query===e?t:{...t,query:e}}function Uu(t){let e=en.indexOf(t.provFilter),n=en[(e+1)%en.length]??null;return{...t,provFilter:n}}function Hu(t){return{...t,showInternals:!t.showInternals}}function jr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function zo(t,e){return t[e]?.id??null}function $o(t,e,n){if(t.length===0)return null;let r=jr(t,e),i=r===-1?n>0?-1:t.length:r;return zo(t,Math.min(t.length-1,Math.max(0,i+n)))}function bm(t,e){let n=jr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var xm={j:"ArrowDown",k:"ArrowUp"};function _m(t){return xm[t]??t}function Bu(t,e,n,r){let i={state:e,selectedId:n,handled:!1},o=c=>({state:e,selectedId:c,handled:!0}),a=_m(r);if(a==="ArrowDown")return o($o(t,n,1));if(a==="ArrowUp")return o($o(t,n,-1));if(a==="Home")return o(zo(t,0));if(a==="End")return o(zo(t,t.length-1));if(a!=="ArrowRight"&&a!=="ArrowLeft")return i;let s=jr(t,n),l=s===-1?void 0:t[s];if(l===void 0||n===null)return i;if(a==="ArrowRight")return l.hasKids?l.expanded?o($o(t,n,1)):{state:ym(e,n),selectedId:n,handled:!0}:i;if(l.hasKids&&l.expanded)return{state:wm(e,n),selectedId:n,handled:!0};let u=bm(t,n);return u===null?i:o(u)}var Em={vault:"◆",note:"▪",repository:"▣",module:"▤",package:"◈",entryPoint:"▷",gitState:"◇",external:"↗",file:"·"};function Uo(t){return Em[t]}var km={human:"●",agent:"◐",generated:"○"};function Nt(t){return t===null?"":km[t]}function Gn(t){return t===null?"":`${t}-authored`}var Sm={open:"▾",closed:"▸",leaf:""};function Wu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Tm(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function Rm(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:Wu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindGlyph:Uo(t.kind),provenance:t.provenance,provenanceGlyph:Nt(t.provenance),provenanceTitle:Gn(t.provenance),twisty:i,twistyGlyph:Sm[i],hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:Mo(t.meta,n),level:t.depth+1}}function Ku(t,e,n){let r=Tm(t);return t.map((i,o)=>Rm(i,e,n,r[o]))}function Vu(t,e){return jr(t,e)===-1?null:Wu(e)}function ju(t){return{"--weave-depth":String(Math.max(0,t))}}function Vr(t){return t===null?"all":t}function qu(t){let e=en.indexOf(t),n=en[(e+1)%en.length]??null;return`provenance filter: ${Vr(t)} — click for ${Vr(n)}`}function Yu(t){return t?"internals":"knowledge"}function Xu(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Zu="filter…",Qu="Vault and repository",Ju="Filter the tree",ec="Filter the tree (/)";function tc(t,e,n){if(t===null)return"loading…";let r=Go(Lt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter":"nothing to show"}function nc(t){return t.length===1?"1 row":`${t.length} rows`}var qr={dark:{accent:"#a48cff",success:"#4ade80",warning:"#fbbf24",dim:"#8f8a9c",text:"#e8e6ee",muted:"#5d5869",line:"#343141"},light:{accent:"#6d4aff",success:"#15803d",warning:"#b45309",dim:"#6f6b66",text:"#1c1b19",muted:"#9a958e",line:"#d2cec8"}},Am={vault:"accent",note:"text",repository:"accent",module:"success",package:"success",entryPoint:"warning",gitState:"warning",external:"warning",file:"dim"},Cm={contains:"line","anchored-at":"line","links-to":"accent",mentions:"warning"};function Lm(t,e){return qr[e][Am[t]]}function Nm(t,e){return qr[e][Cm[t]]}var Ho=3,Dm=32;function Pm(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Dm));return Ho+(Dn-Ho)*n}var Im={contains:.8,"anchored-at":.8,"links-to":1.4,mentions:1};function Gm(t){let e=Nt(t.provenance),n=Ce(t);return e===""?n:`${e} ${n}`}var rc={nodes:[],edges:[]};function ic(t){return`${t.source}\0${t.target}\0${t.kind}`}function Mm(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=ic(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 oc(t,e,n,r){let i=new Map;for(let c of t){if(i.has(c.id))continue;let h=n.get(c.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||i.set(c.id,c)}let o=new Set(i.keys()),a=Mm(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=Pm(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:Gm(h),color:Lm(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let c of e){if(c.source===c.target||!o.has(c.source)||!o.has(c.target))continue;let h=ic(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:Im[c.kind],color:Nm(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Om(t){return qr[t].muted}function ac(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+Fm}:{color:Om(r),label:null,zIndex:0}}var Fm=Dn+1;function sc(t){return(e,n)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1}:{hidden:!0}}var $m=(Ho+Dn)/2,zm=Pn*4,Um=1;function lc(t){let e=qr[t];return{hideEdgesOnMove:!0,renderEdgeLabels:!1,labelDensity:Um,labelGridCellSize:zm,labelRenderedSizeThreshold:$m,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:Pn,allowInvalidContainer:!0}}var hc=bn(Tr(),1);function Hm(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var ue=Hm;typeof Object.assign=="function"&&(ue=Object.assign);function Oe(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function fc(t){let e;for(e in t)return!1;return!0}function Me(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function We(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function uc(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function Bm(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function at(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function nn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var Fn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},C=class t extends Fn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},R=class t extends Fn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends Fn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function pc(t,e){this.key=t,this.attributes=e,this.clear()}pc.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 gc(t,e){this.key=t,this.attributes=e,this.clear()}gc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function mc(t,e){this.key=t,this.attributes=e,this.clear()}mc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function rn(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}rn.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};rn.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};rn.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};rn.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var vc=0,yc=1,Wm=2,wc=3;function st(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===vc){if(s=t._nodes.get(r),!s)throw new R(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===wc){if(i=""+i,l=t._edges.get(i),!l)throw new R(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new R(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===yc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function Km(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);return a.attributes[s]}}function Vm(t,e,n){t.prototype[e]=function(r,i){let[o]=st(this,e,n,r,i);return o.attributes}}function jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function qm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=st(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Ym(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=st(this,e,n,r,i,o,a);if(typeof u!="function")throw new C(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Xm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Zm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(!me(s))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Qm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(!me(s))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Jm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=st(this,e,n,r,i,o);if(typeof s!="function")throw new C(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var ev=[{name:t=>`get${t}Attribute`,attacher:Km},{name:t=>`get${t}Attributes`,attacher:Vm},{name:t=>`has${t}Attribute`,attacher:jm},{name:t=>`set${t}Attribute`,attacher:qm},{name:t=>`update${t}Attribute`,attacher:Ym},{name:t=>`remove${t}Attribute`,attacher:Xm},{name:t=>`replace${t}Attributes`,attacher:Zm},{name:t=>`merge${t}Attributes`,attacher:Qm},{name:t=>`update${t}Attributes`,attacher:Jm}];function tv(t){ev.forEach(function({name:e,attacher:n}){n(t,e("Node"),vc),n(t,e("Source"),yc),n(t,e("Target"),Wm),n(t,e("Opposite"),wc)})}function nv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function rv(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=Oe(this,o,a,n),!i)throw new R(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function iv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function ov(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Oe(this,s,l,n),!a)throw new R(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function av(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Oe(this,s,l,n),!a)throw new R(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new C(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function sv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function lv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function uv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new C(`Graph.${e}: provided attributes are not a plain object.`);return ue(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function cv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=Oe(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new C(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var dv=[{name:t=>`get${t}Attribute`,attacher:nv},{name:t=>`get${t}Attributes`,attacher:rv},{name:t=>`has${t}Attribute`,attacher:iv},{name:t=>`set${t}Attribute`,attacher:ov},{name:t=>`update${t}Attribute`,attacher:av},{name:t=>`remove${t}Attribute`,attacher:sv},{name:t=>`replace${t}Attributes`,attacher:lv},{name:t=>`merge${t}Attributes`,attacher:uv},{name:t=>`update${t}Attributes`,attacher:cv}];function hv(t){dv.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var fv=[{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 pv(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function gv(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function Bo(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function mv(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function vv(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function Wo(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function yv(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function bc(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function wv(t,e){if(t.size===0)return nn();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Ko(t,e,n,r,i,o){let a=e?gv:pv,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function bv(t,e,n,r){let i=[];return Ko(!1,t,e,n,r,function(o){i.push(o)}),i}function xv(t,e,n){let r=nn();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=at(r,Bo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=at(r,Bo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=at(r,Bo(n.undirected))),r}function Vo(t,e,n,r,i,o,a){let s=n?vv:mv,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function _v(t,e,n,r,i){let o=[];return Vo(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Ev(t,e,n,r){let i=nn();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=at(i,Wo(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=at(i,Wo(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=at(i,Wo(n.undirected,r))),i}function kv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return yv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${n}: could not find the "${o}" node in the graph.`);return bv(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 R(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new R(`Graph.${n}: could not find the "${a}" target node in the graph.`);return _v(r,this.multi,i,s,a)}throw new C(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,bc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new R(`Graph.${o}: could not find the "${u}" node in the graph.`);return Ko(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new R(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new R(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Vo(!1,r,this.multi,i,d,c,h)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((g,m,v,w,b,E,_)=>{h[f++]=c(g,m,v,w,b,E,_)})}else h=[],u.push((d,f,g,m,v,w,b)=>{h.push(c(d,f,g,m,v,w,b))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,g,m,v,w,b)=>{c(d,f,g,m,v,w,b)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new C(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new C(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,g,m,v,w,b,E)=>{d=c(d,f,g,m,v,w,b,E)}),this[o].apply(this,u),d}}function Tv(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,bc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new R(`Graph.${o}: could not find the "${l}" node in the graph.`);return Ko(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new R(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new R(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Vo(!0,r,this.multi,i,h,u,c)}throw new C(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,w)=>u(h,d,f,g,m,v,w)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,w)=>!u(h,d,f,g,m,v,w)),!this[o].apply(this,l)}}function Rv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return nn();if(!arguments.length)return wv(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return xv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Ev(r,i,l,s)}throw new C(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Av(t){fv.forEach(e=>{kv(t,e),Sv(t,e),Tv(t,e),Rv(t,e)})}var Cv=[{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 ti(){this.A=null,this.B=null}ti.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};ti.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function Mn(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function jo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return Mn(t,null,r,r.undirected,i);if(typeof n=="string")return Mn(t,null,r,r[n],i)}let o=new ti,a;if(e!=="undirected"){if(n!=="out"){if(a=Mn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=Mn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=Mn(t,o,r,r.undirected,i),t&&a))return a}function Lv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return jo(!1,t,e,n,function(i){r.push(i)}),r}function On(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Nv(t,e,n){if(t!=="mixed"){if(t==="undirected")return On(null,n,n.undirected);if(typeof e=="string")return On(null,n,n[e])}let r=nn(),i=new ti;return t!=="undirected"&&(e!=="out"&&(r=at(r,On(i,n,n.in))),e!=="in"&&(r=at(r,On(i,n,n.out)))),t!=="directed"&&(r=at(r,On(i,n,n.undirected))),r}function Dv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new R(`Graph.${n}: could not find the "${o}" node in the graph.`);return Lv(r==="mixed"?this.type:r,i,a)}}function Pv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new R(`Graph.${o}: could not find the "${u}" node in the graph.`);jo(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new C(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=h;return this[o](u,(f,g)=>{d=c(d,f,g)}),d}}function Iv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new R(`Graph.${a}: could not find the "${u}" node in the graph.`);return jo(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function Gv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return nn();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return Nv(r==="mixed"?this.type:r,i,s)}}function Mv(t){Cv.forEach(e=>{Dv(t,e),Pv(t,e),Iv(t,e),Gv(t,e)})}function Yr(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function Ov(t,e){let n={key:t};return fc(e.attributes)||(n.attributes=ue({},e.attributes)),n}function Fv(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return fc(n.attributes)||(r.attributes=ue({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function $v(t){if(!me(t))throw new C('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new C("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function zv(t){if(!me(t))throw new C('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new C("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new C("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new C("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new C("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Uv=Bm(),Hv=new Set(["directed","undirected","mixed"]),cc=new Set(["domain","_events","_eventsCount","_maxListeners"]),Bv=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],Wv={allowSelfLoops:!0,multi:!1,type:"mixed"};function Kv(t,e,n){if(n&&!me(n))throw new C(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function dc(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function xc(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new C(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new R(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new R(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new rn(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function Vv(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new C(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new C(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let b=[f.key,!1,!1,!1];if(l?!u:!s)return b;if(l){let E=f.attributes;f.attributes=u(E),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ue(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return b}s=s||{},l&&u&&(s=u(s));let g={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=dc(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=dc(t,a,{}),v=!0),d=new rn(r,i,c,h,s),t._edges.set(i,d);let w=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,w&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,w&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,m,v]}function tn(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var K=class t extends hc.EventEmitter{constructor(e){if(super(),e=ue({},Wv,e),typeof e.multi!="boolean")throw new C(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Hv.has(e.type))throw new C(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new C(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?pc:e.type==="directed"?gc:mc;Me(this,"NodeDataClass",n);let r="geid_"+Uv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Me(this,"_attributes",{}),Me(this,"_nodes",new Map),Me(this,"_edges",new Map),Me(this,"_directedSize",0),Me(this,"_undirectedSize",0),Me(this,"_directedSelfLoopCount",0),Me(this,"_undirectedSelfLoopCount",0),Me(this,"_edgeKeyGenerator",o),Me(this,"_options",e),cc.forEach(a=>Me(this,a,this[a])),We(this,"order",()=>this._nodes.size),We(this,"size",()=>this._edges.size),We(this,"directedSize",()=>this._directedSize),We(this,"undirectedSize",()=>this._undirectedSize),We(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),We(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),We(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),We(this,"multi",this._options.multi),We(this,"type",this._options.type),We(this,"allowSelfLoops",this._options.allowSelfLoops),We(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new C(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new C(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new R(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new R(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new R(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new R(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new R(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return Kv(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new C(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ue(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new C(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do tn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do tn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do tn(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Oe(this,r,i,this.type),!n)throw new R(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new R(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return tn(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,n=""+n;let r=Oe(this,e,n,"directed");if(!r)throw new R(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let r=Oe(this,e,n,"undirected");if(!r)throw new R(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return tn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new C("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!me(e))throw new C("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!me(e))throw new C("Graph.mergeAttributes: provided attributes are not a plain object.");return ue(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new C("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,n){if(typeof e!="function")throw new C("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!uc(n))throw new C("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new C("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!uc(n))throw new C("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new C("Graph.forEachAdjacencyEntry: expecting a callback.");Yr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Yr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Yr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new C("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Yr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new C("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new C("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new C("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new C("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new C("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new C("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new C("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new C("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=Ov(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=Fv(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):g?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!me(e))throw new C("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new C("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new C("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],$v(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new C("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],zv(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(ue({},this._options,e));return n.replaceAttributes(ue({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ue({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new M("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new M("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,xc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ue({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!cc.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Me(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);Bv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?xc:Vv;t.generateKey?K.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:K.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});tv(K);hv(K);Av(K);Mv(K);var Xr=class extends K{constructor(e){let n=ue({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new C("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new C('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Zr=class extends K{constructor(e){let n=ue({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new C("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new C('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Qr=class extends K{constructor(e){let n=ue({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Jr=class extends K{constructor(e){let n=ue({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new C('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},ei=class extends K{constructor(e){let n=ue({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new C("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new C('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function on(t){t.from=function(e,n){let r=ue({},e.options,n),i=new t(r);return i.import(e),i}}on(K);on(Xr);on(Zr);on(Qr);on(Jr);on(ei);K.Graph=K;K.DirectedGraph=Xr;K.UndirectedGraph=Zr;K.MultiGraph=Qr;K.MultiDirectedGraph=Jr;K.MultiUndirectedGraph=ei;K.InvalidArgumentsGraphError=C;K.NotFoundGraphError=R;K.UsageGraphError=M;function jv(){return new K({multi:!0,type:"directed"})}function qo(t){let e=jv();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function _c(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Ec(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function kc(t,e){let n=null,r=qo({nodes:[],edges:[]}),i=null,o=()=>{},a=s=>{let l=ac(i),u=sc(i);s.setSetting("nodeReducer",(c,h)=>({...h,...l(c,h,e)})),s.setSetting("edgeReducer",(c,h)=>({...h,...u(c,h)}))};return{mount(s){if(n!==null)return;let l=t(r,s,lc(e));l.on("clickNode",({node:u})=>o(u)),l.on("clickStage",()=>o(null)),a(l),n=l},setGraph(s){r=qo(s),n?.setGraph(r)},setPositions(s){_c(r,s),n?.refresh()},setHighlight(s){i=s,n!==null&&a(n)},onSelect(s){o=s},fit(){n?.getCamera().animatedReset()},positions(){return Ec(r)},destroy(){n?.kill(),n=null}}}var qv=(t,e,n)=>new eu(t,e,n),Sc=t=>kc(qv,t);var Rc="/events";var Yv=2,ni={graph:!1,note:!1};function Ac(t){return!t.graph&&!t.note}function Xv(t,e){return{graph:!0,note:t==="vault"&&e}}function Tc(t){return{graph:!0,note:t}}function Cc(){return{connection:"live",stamp:null,opened:!1}}function Lc(t,e){return t.stamp===e?t:{...t,stamp:e}}function Zv(t){return t===Yv?"offline":"reconnecting"}function Nc(t,e,n){switch(e.type){case"open":{let r=t.opened?Tc(n):ni;return{state:{...t,connection:"live",opened:!0},plan:r}}case"error":return{state:{...t,connection:Zv(e.readyState)},plan:ni};case"frame":return e.event.stamp===t.stamp?{state:t,plan:ni}:{state:{...t,connection:"live"},plan:Xv(e.event.scope,n)};case"refresh":return{state:t,plan:Tc(n)};case"closed":return{state:{...t,connection:"offline"},plan:ni}}}function Dc(t){let e;try{e=JSON.parse(t)}catch{return null}return Fs(e)?e:null}var Qv=Symbol.for("preact-signals");function ai(){if(lt>1)lt--;else{var t,e=!1;for((function(){var i=ii;for(ii=void 0;i!==void 0;){var o=i.S;if(o.v===i.v)for(var a=o.t;a!==void 0;a=a.x)a.i===i.i&&(a.i=o.i);i=i.o}})();zn!==void 0;){var n=zn;for(zn=void 0,ri++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Ic(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(ri=0,lt--,e)throw t}}function Xo(t){if(lt>0)return t();Yo=++Jv,lt++;try{return t()}finally{ai()}}var $n,Q=void 0;function Un(t){var e=Q,n=$n;Q=void 0,$n=void 0;try{return t()}finally{Q=e,$n=n}}var zn=void 0,lt=0,ri=0,Jv=0,Yo=0,ii=void 0,oi=0;function Pc(t){if(Q!==void 0){var e=t.n;if(e===void 0||e.t!==Q)return e={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:e},Q.s!==void 0&&(Q.s.n=e),Q.s=e,t.n=e,32&Q.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Q.s,e.n=void 0,Q.s.n=e,Q.s=e),e}}function ce(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}ce.prototype.brand=Qv;ce.prototype.h=function(){return!0};ce.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Un(function(){var r;(r=e.W)==null||r.call(e)}))};ce.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&Un(function(){var i;(i=e.Z)==null||i.call(e)}))}};ce.prototype.subscribe=function(t){var e=this;return Pt(function(){var n=e.value;Un(function(){return t(n)})},{name:"sub"})};ce.prototype.valueOf=function(){return this.value};ce.prototype.toString=function(){return this.value+""};ce.prototype.toJSON=function(){return this.value};ce.prototype.peek=function(){var t=this;return Un(function(){return t.value})};Object.defineProperty(ce.prototype,"value",{get:function(){var t=Pc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(ri>100)throw new Error("Cycle detected");(function(n){lt!==0&&ri===0&&n.l!==Yo&&(n.l=Yo,ii={S:n,v:n.v,i:n.i,o:ii})})(this),this.v=t,this.i++,oi++,lt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ai()}}}});function et(t,e){return new ce(t,e)}function Ic(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function Gc(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Mc(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function Dt(t,e){ce.call(this,void 0,e),this.x=t,this.s=void 0,this.g=oi-1,this.f=4}Dt.prototype=new ce;Dt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===oi))return!0;if(this.g=oi,this.f|=1,this.i>0&&!Ic(this))return this.f&=-2,!0;var t=Q;try{Gc(this),Q=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Q=t,Mc(this),this.f&=-2,!0};Dt.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}ce.prototype.S.call(this,t)};Dt.prototype.U=function(t){if(this.t!==void 0&&(ce.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Dt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Dt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Pc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function si(t,e){return new Dt(t,e)}function Oc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){lt++;var n=Q;Q=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,Zo(t),r}finally{Q=n,ai()}}}function Zo(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Oc(t)}function ey(t){if(Q!==this)throw new Error("Out-of-order effect");Mc(this),Q=t,this.f&=-2,8&this.f&&Zo(this),ai()}function an(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,$n&&$n.push(this)}an.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};an.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Oc(this),Gc(this),lt++;var t=Q;return Q=this,ey.bind(this,t)};an.prototype.N=function(){2&this.f||(this.f|=2,this.u=zn,zn=this)};an.prototype.d=function(){this.f|=8,1&this.f||Zo(this)};an.prototype.dispose=function(){this.d()};function Pt(t,e){var n=new an(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Fc,Qo,li,ty=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var $c=[];Pt(function(){Fc=this.N})();function sn(t,e){H[t]=e.bind(null,H[t]||function(){})}function ui(t){if(li){var e=li;li=void 0,e()}li=t&&t.S()}function zc(t){var e=this,n=t.data,r=ry(n);r.name="ReactiveDom",r.value=n;var i=Ie(function(){for(var s=e,l=e.__v;l=l.__;)if(l.__c){l.__c.__$f|=4;break}var u=si(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),c=si(function(){return!Array.isArray(u.value)&&!Wi(u.value)}),h=Pt(function(){if(this.N=Uc,c.value){var f=u.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=e.__$u.d;return e.__$u.d=function(){h(),d.call(this)},[c,u]},[]),o=i[0],a=i[1];return o.value?a.peek():a.value}zc.displayName="ReactiveTextNode";Object.defineProperties(ce.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:zc},props:{configurable:!0,get:function(){var t=this;return{data:{get value(){return t.value}}}}},__b:{configurable:!0,value:1}});sn("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof ce&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)});sn("__r",function(t,e){if(t(e),e.type!==Pe){ui();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var a;return Pt(function(){a=this},{name:o}),a.c=i,a})((function(i){return function(){var o;ty&&((o=this.y)==null||o.call(this)),i.__$f|=1,i.setState({})}})(r),typeof e.type=="function"?e.type.displayName||e.type.name:""))),Qo=r,ui(n)}});sn("__e",function(t,e,n,r){ui(),Qo=void 0,t(e,n,r)});sn("diffed",function(t,e){ui(),Qo=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props,o=n.U;if(o)for(var a in o){var s=o[a];s===void 0||r&&a in r||(s.d(),o[a]=void 0)}if(r){o||(o={},n.U=o);for(var l in r){var u=o[l],c=r[l];u===void 0?(u=ny(n,l,c,i),o[l]=u):u.o(c,i)}}}t(e)});function ny(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=et(n);return{o:function(a,s){o.value=a,r=s},d:Pt(function(){this.N=Uc;var a=o.value.value;r[e]!==a&&(r[e]=a,i?t[e]=a:a!=null&&(a!==!1||e[4]==="-")?t.setAttribute(e,a):t.removeAttribute(e))})}}sn("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}var a=e.__np;if(a){var s=e.props;for(var l in a)s[l]=a[l]}e.__np=void 0}else{var u=e.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}t(e)});sn("__h",function(t,e,n,r){r<3&&(e.__$f|=2),t(e,n,r)});Vt.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var a in t)if(a!=="__source"&&t[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in t))return!0;return!1};function ry(t,e){return Ie(function(){return et(t,e)},[])}var iy=function(t){queueMicrotask(function(){queueMicrotask(t)})};function oy(){Xo(function(){for(var t;t=$c.shift();)Fc.call(t)})}function Uc(){$c.push(this)===1&&(H.requestAnimationFrame||iy)(oy)}function ay(){return{expanded:[]}}var vt=et(null),yt=et(null),Hn=et(null),Nk=et(ay()),ln=et("live");function Hc(t){let e=Cc(),n=!1,r=t.open(t.path??Rc),i=o=>{let a=Nc(e,o,t.hasSelection());e=a.state,ln.value=e.connection,Ac(a.plan)||t.refetch(a.plan)};return r.addEventListener("open",()=>i({type:"open"})),r.addEventListener("error",()=>i({type:"error",readyState:r.readyState})),r.addEventListener(Os,o=>{let a=Dc(o.data);a!==null&&i({type:"frame",event:a})}),{stop(){n||(n=!0,r.close(),i({type:"closed"}))},refresh(){i({type:"refresh"})},seen(o){e=Lc(e,o)},state(){return e}}}function Bc(t){return new EventSource(t)}function ci(t,e=!1){return{ok:!0,data:t,cached:e}}function Ee(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function Jo(t){return t===403?"auth":t===404?"missing":"server"}function ea(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function ta(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ee("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Ee(Jo(i.status),i.status,ea(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?ci(o):Ee("malformed",i.status,"response did not match the expected shape")}function ut(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sy(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function ly(t){if(!ut(t)||typeof t.stamp!="string")return!1;let e=t.model;return!ut(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:ut(t.tags)&&ut(t.dangling)}function uy(t){if(!ut(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return sy(t.tags)}function na(t){return ut(t)&&typeof t.revision=="string"&&uy(t.note)}function cy(t){return!ut(t)||typeof t.error!="string"?!1:t.reason==="collision"?typeof t.slug=="string":t.reason!=="conflict"?!1:na(t.current)}function dy(t){return ut(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function hy(t){return ut(t)&&typeof t.opened=="boolean"}async function Wc(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return Ee("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Ee("malformed",304,"server sent 304 for an unconditional request"):ci(e,!0);if(!r.ok)return Ee(Jo(r.status),r.status,ea(r.status));let i;try{i=await r.json()}catch{return Ee("malformed",r.status,"response was not valid JSON")}return ly(i)?ci(i):Ee("malformed",r.status,"response did not match the expected shape")}function Kc(t,e){return ta(t,`/api/note/${encodeURIComponent(e)}`,na)}function fy(t,e=""){return`/api/note/${encodeURIComponent(t)}${e}`}function py(t,e){return{method:t,headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function gy(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ee("network",0,a instanceof Error?a.message:"network request failed")}if(i.status===409){let a;try{a=await i.json()}catch{return Ee("malformed",409,"response was not valid JSON")}return cy(a)?{ok:!1,kind:"conflict",status:409,message:a.error,conflict:a}:Ee("malformed",409,"response did not match the expected shape")}if(!i.ok)return Ee(Jo(i.status),i.status,ea(i.status));let o;try{o=await i.json()}catch{return Ee("malformed",i.status,"response was not valid JSON")}return n(o)?ci(o):Ee("malformed",i.status,"response did not match the expected shape")}function Vc(t,e,n){return gy(t,fy(e),na,py("POST",n))}function jc(t,e){return ta(t,`/api/search?q=${encodeURIComponent(e)}`,dy)}function qc(t,e){return ta(t,"/api/open",hy,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function un(){return{mode:"read",slug:null,baseline:"",draft:"",revision:null,status:"idle",message:null,saving:null,conflict:null,external:null,pending:null}}function cn(t){return t.mode==="edit"&&t.draft!==t.baseline}function Xc(t){return cn(t)&&t.slug!==null&&t.status!=="saving"}function oe(t){return{state:t,effect:null}}function ra(t,e,n){return{...t,mode:n,slug:e.note.slug,baseline:e.note.body,draft:e.note.body,revision:e.revision,status:"idle",message:null,saving:null,conflict:null,external:null}}function my(t,e){return e.note.slug!==t.slug?ra(t,e,"read"):cn(t)&&e.revision!==t.revision?{...t,external:e}:ra(t,e,t.mode)}function Zc(t,e){switch(e.type){case"loaded":return oe(my(t,e.payload));case"cleared":return oe(un());case"toggle":return t.slug===null?oe(t):t.mode==="read"?oe({...t,mode:"edit",draft:t.baseline,status:"idle",message:null}):cn(t)?oe({...t,status:"error",message:Qc}):oe({...t,mode:"read",status:"idle",message:null});case"draft":return oe({...t,draft:e.text,status:t.status==="saving"?"saving":"idle",message:null});case"save":return!Xc(t)||t.slug===null||t.conflict!==null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft},effect:{type:"save",slug:t.slug,input:vy(t)}};case"saved":return oe(yy(t,e.payload));case"failed":return oe({...t,status:"error",message:e.message,saving:null});case"conflicted":return oe({...t,status:"error",message:e.conflict.error,saving:null,conflict:e.conflict});case"reload":return oe(wy(t));case"overwrite":return by(t);case"dismiss":return oe({...t,conflict:null,external:null,status:"idle",message:null});case"navigate":return xy(t,e.id);case"discard":return t.pending===null?oe(t):{state:un(),effect:{type:"select",id:t.pending.id}};case"stay":return oe({...t,pending:null});case"open":return t.slug===null?oe(t):{state:t,effect:{type:"open",slug:t.slug}};case"opened":return oe({...t,status:e.ok?"idle":"error",message:e.ok?Ey:ky})}}function vy(t){return t.revision===null?{body:t.draft}:{body:t.draft,expectedRevision:t.revision}}function yy(t,e){let n=t.saving!==null&&t.saving!==t.draft;return{...t,slug:e.note.slug,baseline:e.note.body,draft:n?t.draft:e.note.body,revision:e.revision,status:"saved",message:_y,saving:null,conflict:null,external:null}}function wy(t){let e=t.conflict?.reason==="conflict"?t.conflict.current:t.external;return e==null?t:ra(t,e,t.mode)}function by(t){return t.slug===null?oe(t):{state:{...t,status:"saving",message:null,saving:t.draft,conflict:null,external:null},effect:{type:"save",slug:t.slug,input:{body:t.draft}}}}function xy(t,e){return cn(t)?oe({...t,pending:{id:e}}):{state:t,effect:{type:"select",id:e}}}function ia(t){return cn(t)}var _y="saved",Qc="unsaved changes — save with the button, or discard them",Ey="opened in your editor",ky="could not open the note in an editor",Sy="Edit",Ty="Done",Ry="Save",Ay="Saving…",Jc="Open in $EDITOR",ed="Hand this note to $EDITOR (or your platform's opener)",Cy="Discard changes",di="Keep editing",Yc="Reload from disk",Ly="Overwrite",Ny="this note changed on disk while you were editing",Dy="pick a different name";function td(t){let e=t.conflict;return e?.reason==="conflict"?{kind:"conflict",message:e.error,actions:[{label:Yc,event:{type:"reload"}},{label:Ly,event:{type:"overwrite"}},{label:di,event:{type:"dismiss"}}]}:e?.reason==="collision"?{kind:"collision",message:`${e.error} (${e.slug}) — ${Dy}`,actions:[{label:di,event:{type:"dismiss"}}]}:t.pending!==null?{kind:"discard",message:Qc,actions:[{label:di,event:{type:"stay"}},{label:Cy,event:{type:"discard"}}]}:t.external!==null?{kind:"external",message:Ny,actions:[{label:Yc,event:{type:"reload"}},{label:di,event:{type:"dismiss"}}]}:null}function nd(t){let e=t.mode==="edit";return{toggleLabel:e?Ty:Sy,editing:e,saveLabel:t.status==="saving"?Ay:Ry,canSave:Xc(t)&&t.conflict===null,message:t.message,tone:t.message===null?"none":t.status==="error"?"warn":"ok",dirty:cn(t)}}function rd(t){let e=un(),n=i=>{let o=Zc(e,i);e=o.state,t.onChange(e),o.effect!==null&&r(o.effect)},r=i=>{if(i.type==="select"){t.select(i.id);return}if(i.type==="open"){(async()=>{let o=await qc(t.fetch,i.slug);n({type:"opened",ok:o.ok&&o.data.opened})})();return}(async()=>{let o=await Vc(t.fetch,i.slug,i.input);if(o.ok){n({type:"saved",payload:o.data});return}n(o.kind==="conflict"?{type:"conflicted",conflict:o.conflict}:{type:"failed",message:o.message})})()};return{state:()=>e,send:n}}function id(t,e){let n=r=>{e()&&(r.preventDefault(),r.returnValue="")};return t.addEventListener("beforeunload",n),()=>t.removeEventListener("beforeunload",n)}var od=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function ad(t,e,n){return t<=1?null:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function sd(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function ld(t){return t===null?!1:(t.focus(),!0)}function hi(){let t=Ae(null);return Re(()=>{let e=document.activeElement;return t.current?.focus(),()=>{ld(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!sd(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(od)??[]],r=ad(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function hd(t,e){let n=e.trim().toLowerCase();if(n==="")return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i===-1?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}var Py=10;function Iy(t){return Math.min(Math.max(t,0),Py)*2}function Gy(t){return`note:${t}`}function My(t,e){return hd(t.summary.title,e)+Iy(t.score)}function Oy(t,e){return hd(t.label,e)}var Fy=["path","manifest","url","slug"];function $y(t){for(let e of Fy){let n=t.detail[e];if(typeof n=="string"&&n!=="")return n}return""}function zy(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function Uy(t,e,n,r){let i=new Map;for(let o of t){let a=Gy(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:My(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Oy(o,r);a!==0&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:$y(o),badge:o.kind,score:a})}return[...i.values()].sort(zy).slice(0,20)}function fi(){return{query:"",typedAt:0,issued:"",answered:"",seq:0,applied:0,hits:[],cursor:0,pending:!1,loading:!1,failed:!1}}var oa=140;function tt(t){return{state:t,request:null,schedule:null}}function ud(t,e){return e>t.applied}function fd(t,e){switch(e.type){case"query":{let n={...t,query:e.query,typedAt:e.now,cursor:0};return e.query.trim()===""?tt({...n,hits:[],answered:"",issued:"",loading:!1,failed:!1,pending:!1}):t.pending?tt(n):{state:{...n,pending:!0},request:null,schedule:oa}}case"tick":{if(!t.pending)return tt(t);let n=e.now-t.typedAt;if(n<oa)return{state:t,request:null,schedule:oa-n};let r=t.query.trim();if(r===""||r===t.issued)return tt({...t,pending:!1});let i=t.seq+1;return{state:{...t,pending:!1,loading:!0,seq:i,issued:r},request:{seq:i,query:r},schedule:null}}case"response":return ud(t,e.seq)?tt({...t,applied:e.seq,hits:e.hits,answered:e.query,loading:e.seq<t.seq,failed:!1,cursor:0}):tt(t);case"failed":return ud(t,e.seq)?tt({...t,applied:e.seq,loading:e.seq<t.seq,failed:!0}):tt(t);case"cursor":return tt({...t,cursor:e.cursor});case"dismiss":return tt({...t,pending:!1})}}function aa(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function cd(t,e,n){return n<=0?0:((t+e)%n+n)%n}function pd(t,e){return e===null?null:t[e]?.id??null}function gd(t,e,n){let r={state:t,activate:null,dismiss:!1,handled:!1},i=a=>({state:{...t,cursor:a},activate:null,dismiss:!1,handled:!0}),o=aa(t.cursor,n);return e==="ArrowDown"?i(cd(o,1,n)):e==="ArrowUp"?i(cd(o,-1,n)):e==="Home"?i(0):e==="End"?i(aa(n-1,n)):e==="Escape"?{state:t,activate:null,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{state:t,activate:o,dismiss:!0,handled:!0}}var pi="Search the workspace",md="Search notes and repository…",vd="↑↓ move · ↵ open · esc close";function Hy(t,e){return t.query.trim()===""?"Type to search notes, modules, files and entry points.":e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading||t.pending?"searching…":`no matches for “${t.query.trim()}”`}function By(t){return t===1?"1 result":`${t} results`}function dd(t){return`weave-search-row-${t}`}function yd(t,e){let n=Uy(t.hits,t.answered,e?.model.nodes??[],t.query),r=aa(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:dd(a)})),status:Hy(t,n.length),count:n.length,countLabel:By(n.length),cursor:r,activeDomId:n.length===0?null:dd(r)}}function wd(t){let e=fi(),n=r=>{let i=fd(e,r);e=i.state,t.onChange(e),i.schedule!==null&&t.delay(()=>n({type:"tick",now:t.now()}),i.schedule);let o=i.request;o!==null&&(async()=>{let a=await jc(t.fetch,o.query);n(a.ok?{type:"response",seq:o.seq,query:o.query,hits:a.data.hits}:{type:"failed",seq:o.seq})})()};return{state:()=>e,setQuery:r=>n({type:"query",query:r,now:t.now()}),setCursor:r=>n({type:"cursor",cursor:r}),dismiss:()=>n({type:"dismiss"})}}var Wy=0;function x(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Wy,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return H.vnode&&H.vnode(u),u}function Ky({row:t,onPick:e,onHover:n}){return x("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[x("span",{class:"weave-hit-badge",children:t.badge}),x("span",{class:"weave-hit-label",children:t.label}),x("span",{class:"weave-hit-detail",children:t.detail})]})}function bd(t){let[e,n]=Ue(fi),r=Ie(()=>wd({...t.ports,onChange:n}),[]),i=hi(),o=yd(e,t.graph),a=s=>{let l=pd(o.rows,s);l!==null&&t.onSelect(l),r.dismiss(),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>a(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":pi,tabIndex:-1,ref:i.ref,onClick:s=>s.stopPropagation(),onKeyDown:s=>{if(i.onKeyDown(s))return;let l=gd(e,s.key,o.count);l.handled&&(s.preventDefault(),r.setCursor(l.state.cursor),l.dismiss&&a(l.activate))},children:[x("input",{type:"search",class:"weave-palette-input",autofocus:!0,value:e.query,placeholder:md,"aria-label":pi,"aria-controls":"weave-search-results","aria-activedescendant":o.activeDomId??void 0,onInput:s=>r.setQuery(s.currentTarget.value)}),o.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":pi,children:o.rows.map((s,l)=>x(Ky,{row:s,onPick:()=>a(l),onHover:()=>r.setCursor(l)},s.id))}):x("p",{class:"weave-palette-status",role:"status",children:o.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:o.countLabel}),x("span",{class:"weave-palette-hint",children:vd})]})]})})}var gi=null;function _d(t){return gi=t,()=>{gi===t&&(gi=null)}}async function xd(t,e){let n=await Wc(t,yt.value);return n.ok&&(n.cached||(yt.value=n.data),e?.seen(n.data.stamp)),n}async function sa(t){let e=Ed(vt.value);if(e===null){Hn.value=null;return}let n=await Kc(t,e);n.ok&&(Hn.value=n.data,gi?.(n.data))}function Ed(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function kd(t){let e=null,n=r=>{(async()=>(r.graph&&await xd(t.fetch,e),r.note&&await sa(t.fetch)))()};return e=Hc({open:t.open,refetch:n,hasSelection:()=>Ed(vt.value)!==null,...t.path===void 0?{}:{path:t.path}}),xd(t.fetch,e),{refresh(){e?.refresh()},syncNote(){return sa(t.fetch)},stop(){e?.stop(),e=null}}}function la(t,e){return vt.value=e,sa(t)}var Vy=300,jy=1;function qy(t,e,n){let r={ticks:Vy,seed:jy};return Iu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e]},n===void 0?r:{...r,initial:n})}function Yy(t,e){let n=0,r=0;for(let o of t){let a=Hr(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=Hr(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Td="pi-weave.graph.positions.v1";function Sd(t){return Math.round(t*10)/10}function Xy(t,e){let n={};for(let[r,i]of e)n[r]=[Sd(i.x),Sd(i.y)];return JSON.stringify({v:1,key:t,at:n})}function Zy(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function Qy(t,e){let n;try{n=t.getItem(Td)}catch{return null}return Zy(n,e)}function Jy(t,e,n){try{return t.setItem(Td,Xy(e,n)),!0}catch{return!1}}function Rd(t,e,n){let r=Yy(e,n),i=Qy(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=qy(e,n);return Jy(t,r,o),{key:r,positions:o,cached:!1}}var ua=[1,2,3],ew=120;function tw(t){return{expanded:t.nodes.length>ew?new Set:new Set(Kr(t,new Set).clusters.keys()),depth:1}}function Ad(t,e){return e!==null?e:t===null?{expanded:new Set,depth:1}:tw(Lt(t))}function nw(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function rw(t,e){return{...t,expanded:new Set(e.keys())}}function iw(t){return{...t,expanded:new Set}}function Cd(t,e){return t.depth===e?t:{...t,depth:e}}function ow(t,e,n){if(e===null)return null;let r=Wr(e,t);for(let i=1;i<n;i++){let o=new Set(r);for(let a of r)for(let s of Wr(a,t))o.add(s);if(o.size===r.size)break;r=o}return r}function Ld(t){return`depth ${t}`}function Nd(t){return t===1?"highlighting direct neighbours of the selection":`highlighting everything within ${t} hops of the selection`}function Dd(t){return t?"collapse":"expand"}function Pd(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function ca(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Id(t,e){return ca(t,e)?iw(t):rw(t,e)}function Gd(t,e){let n=Number(t);return ua.includes(n)?n:e}var Md="fit",Od="frame the whole graph",da={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Fd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function aw(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var sw={graph:rc,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function $d(t,e,n,r,i){if(t===null)return sw;let o=Lt(t),a=Kr(o,n.expanded),s=Rd(r,a.nodes,a.edges);return{graph:oc(a.nodes,a.edges,s.positions,i),highlight:ow(a.edges,e,n.depth),key:s.key,cached:s.cached,clusters:a.clusters,visible:a.nodes.length,total:o.nodes.length,empty:aw(t,a.nodes.length)}}function zd(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:nw(t,n),selectedId:n}}var lw="(prefers-color-scheme: light)";function Ud(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(lw).matches?"light":"dark"}function Hd(t){let e=Ae(null),n=Ae(null),[r,i]=Ue(null),o=Ie(()=>Ud(t.host),[t.host]),a=Ad(t.graph,r),s=$d(t.graph,t.selectedId,a,t.storage,o),l=ca(a,s.clusters),u=Ae({view:a,model:s,onSelect:t.onSelect});return u.current={view:a,model:s,onSelect:t.onSelect},Re(()=>{let c=t.renderer(o);return c.onSelect(h=>{let d=zd(u.current.view,u.current.model.clusters,h);i(d.state),u.current.onSelect(d.selectedId)}),c.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=c,t.fit.current=()=>c.fit(),()=>{c.destroy(),n.current=null,t.fit.current=null}},[t.renderer,o]),Re(()=>{n.current?.setGraph(s.graph)},[s.key]),Re(()=>{n.current?.setHighlight(s.highlight)},[s.highlight]),x("div",{class:"weave-graph",children:[s.empty===null?null:x("p",{class:"weave-graph-empty",children:s.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph"}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Od,onClick:()=>n.current?.fit(),children:Md}),x("button",{type:"button",class:"weave-chip",title:Pd(l),onClick:()=>i(Id(a,s.clusters)),children:Dd(l)}),x("select",{class:"weave-chip weave-depth",title:Nd(a.depth),"aria-label":"Highlight depth",value:String(a.depth),onChange:c=>i(Cd(a,Gd(c.currentTarget.value,a.depth))),children:ua.map(c=>x("option",{value:String(c),children:Ld(c)},c))}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",da.selected]}),x("span",{class:"weave-legend-near",children:["● ",da.neighborhood]})]})]}),x("p",{class:"weave-graph-count",children:Fd(s.visible,s.total)})]})}function Bd(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function uw(t){if(Array.isArray(t))return t}function cw(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function dw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
335
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hw(t,e){return uw(t)||cw(t,e)||fw(t,e)||dw()}function fw(t,e){if(t){if(typeof t=="string")return Bd(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Bd(t,e):void 0}}var ih=Object.entries,Wd=Object.setPrototypeOf,pw=Object.isFrozen,gw=Object.getPrototypeOf,mw=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,dn=Object.create,oh=typeof Reflect<"u"&&Reflect,ya=oh.apply,wa=oh.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});ya||(ya=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});wa||(wa=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Gt=ae(Array.prototype.forEach),vw=ae(Array.prototype.lastIndexOf),Kd=ae(Array.prototype.pop),Bn=ae(Array.prototype.push),yw=ae(Array.prototype.splice),hn=Array.isArray,Vn=ae(String.prototype.toLowerCase),ha=ae(String.prototype.toString),Vd=ae(String.prototype.match),Wn=ae(String.prototype.replace),jd=ae(String.prototype.indexOf),ww=ae(String.prototype.trim),bw=ae(Number.prototype.toString),xw=ae(Boolean.prototype.toString),qd=typeof BigInt>"u"?null:ae(BigInt.prototype.toString),Yd=typeof Symbol>"u"?null:ae(Symbol.prototype.toString),Te=ae(Object.prototype.hasOwnProperty),Kn=ae(Object.prototype.toString),ve=ae(RegExp.prototype.test),It=_w(TypeError);function ae(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return ya(t,e,r)}}function _w(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return wa(t,n)}}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vn;if(Wd&&Wd(t,null),!hn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(pw(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Ew(t){for(let e=0;e<t.length;e++)Te(t,e)||(t[e]=null);return t}function Ne(t){let e=dn(null);for(let r of ih(t)){var n=hw(r,2);let i=n[0],o=n[1];Te(t,i)&&(hn(o)?e[i]=Ew(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ne(o):e[i]=o)}return e}function kw(t){switch(typeof t){case"string":return t;case"number":return bw(t);case"boolean":return xw(t);case"bigint":return qd?qd(t):"0";case"symbol":return Yd?Yd(t):"Symbol()";case"undefined":return Kn(t);case"function":case"object":{if(t===null)return Kn(t);let e=t,n=Ke(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Kn(r)}return Kn(t)}default:return Kn(t)}}function Ke(t,e){for(;t!==null;){let r=mw(t,e);if(r){if(r.get)return ae(r.get);if(typeof r.value=="function")return ae(r.value)}t=gw(t)}function n(){return null}return n}function Sw(t){try{return ve(t,""),!0}catch{return!1}}var Xd=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),fa=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),pa=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Tw=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),ga=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Rw=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Zd=de(["#text"]),Qd=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ma=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Jd=de(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),mi=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Aw=pe(/{{[\w\W]*|^[\w\W]*}}/g),Cw=pe(/<%[\w\W]*|^[\w\W]*%>/g),Lw=pe(/\${[\w\W]*/g),Nw=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Dw=pe(/^aria-[\-\w]+$/),eh=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pw=pe(/^(?:\w+script|data):/i),Iw=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Gw=pe(/^html$/i),Mw=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),th=pe(/<[/\w!]/g),nh=pe(/<[/\w]/g),Ow=pe(/<\/no(script|embed|frames)/i),Fw=pe(/\/>/i),Le={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},ah=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],$w=de(B({},ah)),zw=(function(){let t={};return Gt(ah,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Uw=function(){return typeof window>"u"?null:window},Hw=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},rh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wt=function(e,n,r,i){return Te(e,n)&&hn(e[n])?B(i.base?Ne(i.base):{},e[n],i.transform):r},va=function(e,n,r){let i=Te(e,n)?e[n]:void 0;return i&&typeof i=="object"?Ne(i):r()};function sh(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uw(),e=T=>sh(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Le.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=Ke(d,"cloneNode"),g=Ke(d,"remove"),m=Ke(d,"nextSibling"),v=Ke(d,"childNodes"),w=Ke(d,"parentNode"),b=Ke(d,"shadowRoot"),E=Ke(d,"attributes"),_=a&&a.prototype?Ke(a.prototype,"nodeType"):null,L=a&&a.prototype?Ke(a.prototype,"nodeName"):null,P=a&&a.prototype?Ke(a.prototype,"ownerDocument"):null,I=function(p){return _?_(p):p.nodeType},$=function(p){return L?L(p):p.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let F,G="",U,j=!1,J=0,ge=function(){if(J>0)throw It('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},he=function(p){ge(),J++;try{return F.createHTML(p)}finally{J--}},Ye=function(p){ge(),J++;try{return F.createScriptURL(p)}finally{J--}},$t=function(){return j||(U=Hw(h,i),j=!0),U},Fe=n,$e=Fe.implementation,ze=Fe.createNodeIterator,Xe=Fe.createDocumentFragment,gn=Fe.getElementsByTagName,De=r.importNode,q=rh();e.isSupported=typeof ih=="function"&&typeof w=="function"&&$e&&$e.createHTMLDocument!==void 0;let mn=Aw,Af=Cw,Cf=Lw,Lf=Nw,Nf=Dw,Df=Pw,Wa=Iw,Pf=Mw,Ka=eh,X=null,Ti=B({},[...Xd,...fa,...pa,...ga,...Zd]),Z=null,Ri=B({},[...Qd,...ma,...Jd,...mi]),Ze=Object.seal(dn(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}})),vn=null,Va=null,dt=Object.seal(dn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ja=!0,Ai=!0,qa=!1,Ya=!0,ht=!1,xt=!0,_t=!1,Ci=!1,Jn=null,er=null,Li=!1,zt=!1,tr=!1,nr=!1,Xa=!0,Za=!1,Qa="user-content-",Ni=!0,Di=!1,Ut={},Ht=null,Ja=B({},["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"]),es=null,ts=B({},["audio","video","img","source","image","track"]),ns=null,rs=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rr="http://www.w3.org/1998/Math/MathML",ir="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",Bt=Qe,Pi=!1,Ii=null,If=B({},[rr,ir,Qe],ha),is=de(["mi","mo","mn","ms","mtext"]),Gi=B({},is),os=de(["annotation-xml"]),Mi=B({},os),Gf=B({},["title","style","font","a","script"]),yn=null,Mf=["application/xhtml+xml","text/html"],Of="text/html",ne=null,Wt=null,Ff=n.createElement("form"),as=function(p){return p instanceof RegExp||p instanceof Function},Oi=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Wt&&Wt===p)return;(!p||typeof p!="object")&&(p={}),p=Ne(p),yn=Mf.indexOf(p.PARSER_MEDIA_TYPE)===-1?Of:p.PARSER_MEDIA_TYPE,ne=yn==="application/xhtml+xml"?ha:Vn,X=wt(p,"ALLOWED_TAGS",Ti,{transform:ne}),Z=wt(p,"ALLOWED_ATTR",Ri,{transform:ne}),Ii=wt(p,"ALLOWED_NAMESPACES",If,{transform:ha}),ns=wt(p,"ADD_URI_SAFE_ATTR",rs,{transform:ne,base:rs}),es=wt(p,"ADD_DATA_URI_TAGS",ts,{transform:ne,base:ts}),Ht=wt(p,"FORBID_CONTENTS",Ja,{transform:ne}),vn=wt(p,"FORBID_TAGS",Ne({}),{transform:ne}),Va=wt(p,"FORBID_ATTR",Ne({}),{transform:ne}),Ut=Te(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Ne(p.USE_PROFILES):p.USE_PROFILES:!1,ja=p.ALLOW_ARIA_ATTR!==!1,Ai=p.ALLOW_DATA_ATTR!==!1,qa=p.ALLOW_UNKNOWN_PROTOCOLS||!1,Ya=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ht=p.SAFE_FOR_TEMPLATES||!1,xt=p.SAFE_FOR_XML!==!1,_t=p.WHOLE_DOCUMENT||!1,zt=p.RETURN_DOM||!1,tr=p.RETURN_DOM_FRAGMENT||!1,nr=p.RETURN_TRUSTED_TYPE||!1,Li=p.FORCE_BODY||!1,Xa=p.SANITIZE_DOM!==!1,Za=p.SANITIZE_NAMED_PROPS||!1,Ni=p.KEEP_CONTENT!==!1,Di=p.IN_PLACE||!1,Ka=Sw(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:eh,Bt=typeof p.NAMESPACE=="string"?p.NAMESPACE:Qe,Gi=va(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},is)),Mi=va(p,"HTML_INTEGRATION_POINTS",()=>B({},os));let y=va(p,"CUSTOM_ELEMENT_HANDLING",()=>dn(null));if(Ze=dn(null),Te(y,"tagNameCheck")&&as(y.tagNameCheck)&&(Ze.tagNameCheck=y.tagNameCheck),Te(y,"attributeNameCheck")&&as(y.attributeNameCheck)&&(Ze.attributeNameCheck=y.attributeNameCheck),Te(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(Ze.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),pe(Ze),ht&&(Ai=!1),tr&&(zt=!0),Ut&&(X=B({},Zd),Z=dn(null),Ut.html===!0&&(B(X,Xd),B(Z,Qd)),Ut.svg===!0&&(B(X,fa),B(Z,ma),B(Z,mi)),Ut.svgFilters===!0&&(B(X,pa),B(Z,ma),B(Z,mi)),Ut.mathMl===!0&&(B(X,ga),B(Z,Jd),B(Z,mi))),dt.tagCheck=null,dt.attributeCheck=null,Te(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?dt.tagCheck=p.ADD_TAGS:hn(p.ADD_TAGS)&&(X===Ti&&(X=Ne(X)),B(X,p.ADD_TAGS,ne))),Te(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?dt.attributeCheck=p.ADD_ATTR:hn(p.ADD_ATTR)&&(Z===Ri&&(Z=Ne(Z)),B(Z,p.ADD_ATTR,ne))),Te(p,"ADD_FORBID_CONTENTS")&&hn(p.ADD_FORBID_CONTENTS)&&(Ht===Ja&&(Ht=Ne(Ht)),B(Ht,p.ADD_FORBID_CONTENTS,ne)),Ni&&(X["#text"]=!0),_t&&B(X,["html","head","body"]),X.table&&(B(X,["tbody"]),delete vn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw It('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let k=F;F=p.TRUSTED_TYPES_POLICY;try{G=he("")}catch(A){throw F=k,A}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=$t()),F&&typeof G=="string"&&(G=he("")));de&&de(p),Wt=p},ss=B({},[...fa,...pa,...Tw]),ls=B({},[...ga,...Rw]),$f=function(p,y,k){return y.namespaceURI===Qe?p==="svg":y.namespaceURI===rr?p==="svg"&&(k==="annotation-xml"||Gi[k]):!!ss[p]},zf=function(p,y,k){return y.namespaceURI===Qe?p==="math":y.namespaceURI===ir?p==="math"&&Mi[k]:!!ls[p]},Uf=function(p,y,k){return y.namespaceURI===ir&&!Mi[k]||y.namespaceURI===rr&&!Gi[k]?!1:!ls[p]&&(Gf[p]||!ss[p])},Hf=function(p){let y=w(p);(!y||!y.tagName)&&(y={namespaceURI:Bt,tagName:"template"});let k=Vn(p.tagName),A=Vn(y.tagName);return Ii[p.namespaceURI]?p.namespaceURI===ir?$f(k,y,A):p.namespaceURI===rr?zf(k,y,A):p.namespaceURI===Qe?Uf(k,y,A):!!(yn==="application/xhtml+xml"&&Ii[p.namespaceURI]):!1},ft=function(p){Bn(e.removed,{element:p});try{w(p).removeChild(p)}catch{if(g(p),!w(p))throw It("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},us=function(p,y,k){try{p.removeAttributeNode(y)}catch{try{p.removeAttribute(k)}catch{}}},or=function(p){ar(p);let y=v(p);if(y){let A=[];Gt(y,D=>{Bn(A,D)}),Gt(A,D=>{try{g(D)}catch{}})}let k=E(p);if(k)for(let A=k.length-1;A>=0;--A){let D=k[A],O=D&&D.name;typeof O=="string"&&us(p,D,O)}},Et=function(p,y,k){if(!k)try{k=y.getAttributeNode(p)}catch{k=null}Bn(e.removed,{attribute:k||null,from:y});try{k?y.removeAttributeNode(k):y.removeAttribute(p)}catch{try{y.removeAttribute(p)}catch{}}if(p==="is")if(zt||tr)try{ft(y)}catch{}else try{y.setAttribute(p,"")}catch{}},Bf=function(p){let y=E(p);if(y)for(let k=y.length-1;k>=0;--k){let A=y[k],D=A&&A.name;typeof D!="string"||Z[ne(D)]||us(p,A,D)}},ar=function(p){let y=[p];for(;y.length>0;){let k=y.pop();I(k)===Le.element&&Bf(k);let D=v(k);if(D)for(let O=D.length-1;O>=0;--O)y.push(D[O])}},cs=function(p,y){return xt?p==="patchsrc"?!0:p==="for"&&y!=="label"&&y!=="output":!1},Wf=function(p){if(!xt)return;let y=[p];for(;y.length>0;){let k=y.pop(),A=I(k);if(A===Le.processingInstruction||A===Le.comment&&ve(nh,k.data)){try{g(k)}catch{}continue}if(A===Le.element){let O=k,Y=ne($(k));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&cs("for",Y)&&O.removeAttribute("for")}catch{}}let D=v(k);if(D)for(let O=D.length-1;O>=0;--O)y.push(D[O])}},ds=function(p){let y=null,k=null;if(Li)p="<remove></remove>"+p;else{let O=Vd(p,/^[\r\n\t ]+/);k=O&&O[0]}yn==="application/xhtml+xml"&&Bt===Qe&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let A=F?he(p):p;if(Bt===Qe)try{y=new c().parseFromString(A,yn)}catch{}if(!y||!y.documentElement){y=$e.createDocument(Bt,"template",null);try{y.documentElement.innerHTML=Pi?G:A}catch{}}let D=y.body||y.documentElement;return p&&k&&D.insertBefore(n.createTextNode(k),D.childNodes[0]||null),Bt===Qe?gn.call(y,_t?"html":"body")[0]:_t?y.documentElement:D},hs=function(p){let y=P?P(p):p.ownerDocument;return ze.call(y||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},sr=function(p){return p=Wn(p,mn," "),p=Wn(p,Af," "),p=Wn(p,Cf," "),p},Fi=function(p){var y;p.normalize();let k=P?P(p):p.ownerDocument,A=ze.call(k||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),D=A.nextNode();for(;D;)D.data=sr(D.data),D=A.nextNode();let O=(y=p.querySelectorAll)===null||y===void 0?void 0:y.call(p,"template");O&&Gt(O,Y=>{Kt(Y.content)&&Fi(Y.content)})},lr=function(p){let y=L?L(p):null;return typeof y!="string"||ne(y)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==E(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==_(p)||p.childNodes!==v(p)},Kt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===Le.documentFragment}catch{return!1}},wn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function Je(T,p,y){T.length!==0&&Gt(T,k=>{k.call(e,p,y,Wt)})}let Kf=function(p,y){return!!(xt&&p.hasChildNodes()&&!wn(p.firstElementChild)&&ve(th,p.textContent)&&ve(th,p.innerHTML)||xt&&p.namespaceURI===Qe&&$w[y]&&(wn(p.firstElementChild)||typeof p.textContent=="string"&&ve(zw[y],p.textContent))||p.nodeType===Le.processingInstruction||xt&&p.nodeType===Le.comment&&ve(nh,p.data))},ur=function(p,y){if(p instanceof RegExp)return ve(p,y);if(p instanceof Function){for(var k=arguments.length,A=new Array(k>2?k-2:0),D=2;D<k;D++)A[D-2]=arguments[D];return!!p(y,...A)}return!1},Vf=function(p,y,k){if(!vn[y]&&vs(y)&&ur(Ze.tagNameCheck,y))return!1;if(Ni&&!Ht[y]){let A=w(p),D=v(p);if(D&&A){let O=D.length;for(let Y=O-1;Y>=0;--Y){let ee=p===k?f(D[Y],!0):D[Y];A.insertBefore(ee,m(p))}}}return ft(p),!0},fs=function(p,y,k,A){return p.length===0?y:y===k||y===A?Ne(y):y},ps=function(p,y){return p===y||w(p)!==null?!1:(Di&&ar(p),!0)},gs=function(p,y){if(Je(q.beforeSanitizeElements,p,null),ps(p,y))return!0;if(lr(p))return ft(p),!0;let k=ne($(p));if(X=fs(q.uponSanitizeElement,X,Ti,Jn),Je(q.uponSanitizeElement,p,{tagName:k,allowedTags:X}),ps(p,y))return!0;if(Kf(p,k))return ft(p),!0;if(vn[k]||!(dt.tagCheck instanceof Function&&dt.tagCheck(k))&&!X[k]){let D=Vf(p,k,y);return D===!1&&Je(q.afterSanitizeElements,p,null),D}if(I(p)===Le.element&&!Hf(p)||(k==="noscript"||k==="noembed"||k==="noframes")&&ve(Ow,p.innerHTML))return ft(p),!0;if(ht&&p.nodeType===Le.text){let D=sr(p.textContent);p.textContent!==D&&(Bn(e.removed,{element:p.cloneNode()}),p.textContent=D)}return Je(q.afterSanitizeElements,p,null),!1},ms=function(p,y,k){if(Va[y]||cs(y,p)||Xa&&(y==="id"||y==="name")&&(k in n||k in Ff))return!1;let A=Z[y]||dt.attributeCheck instanceof Function&&dt.attributeCheck(y,p);return Ai&&ve(Lf,y)||ja&&ve(Nf,y)?!0:A?ns[y]||ve(Ka,Wn(k,Wa,""))||(y==="src"||y==="xlink:href"||y==="href")&&p!=="script"&&jd(k,"data:")===0&&es[p]||qa&&!ve(Df,Wn(k,Wa,""))?!0:!k:vs(p)&&ur(Ze.tagNameCheck,p)&&ur(Ze.attributeNameCheck,y,p)||y==="is"&&Ze.allowCustomizedBuiltInElements&&ur(Ze.tagNameCheck,k)},jf=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),vs=function(p){return!jf[Vn(p)]&&ve(Pf,p)},qf=function(p,y,k,A){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!k)switch(h.getAttributeType(p,y)){case"TrustedHTML":return he(A);case"TrustedScriptURL":return Ye(A)}return A},Yf=function(p,y,k,A){try{k?p.setAttributeNS(k,y,A):p.setAttribute(y,A),lr(p)?ft(p):Kd(e.removed)}catch{Et(y,p)}},ys=function(p){Je(q.beforeSanitizeAttributes,p,null);let y=p.attributes;if(!y||lr(p))return;Z=fs(q.uponSanitizeAttribute,Z,Ri,er);let k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},A=y.length,D=ne(p.nodeName);for(;A--;){let O=y[A],Y=O.name,ee=O.namespaceURI,ke=O.value,Se=ne(Y),zi=ke,we=Y==="value"?zi:ww(zi);if(k.attrName=Se,k.attrValue=we,k.keepAttr=!0,k.forceKeepAttr=void 0,Je(q.uponSanitizeAttribute,p,k),we=k.attrValue,Za&&(Se==="id"||Se==="name")&&jd(we,Qa)!==0&&(Et(Y,p,O),we=Qa+we),xt&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){Et(Y,p,O);continue}if(Se==="attributename"&&Vd(we,"href")){Et(Y,p,O);continue}if(!k.forceKeepAttr){if(!k.keepAttr){Et(Y,p,O);continue}if(!Ya&&ve(Fw,we)){Et(Y,p,O);continue}if(ht&&(we=sr(we)),!ms(D,Se,we)){Et(Y,p,O);continue}we=qf(D,Se,ee,we),we!==zi&&Yf(p,Y,ee,we)}}Je(q.afterSanitizeAttributes,p,null)},cr=function(p){let y=null,k=hs(p);for(Je(q.beforeSanitizeShadowDOM,p,null);y=k.nextNode();)if(Je(q.uponSanitizeShadowNode,y,null),gs(y,p),ys(y),Kt(y.content)&&cr(y.content),I(y)===Le.element){let A=b(y);Kt(A)&&($i(A),cr(A))}Je(q.afterSanitizeShadowDOM,p,null)},$i=function(p){let y=[{node:p,shadow:null}];for(;y.length>0;){let k=y.pop();if(k.shadow){cr(k.shadow);continue}let A=k.node,O=I(A)===Le.element,Y=v(A);if(Y)for(let ee=Y.length-1;ee>=0;--ee)y.push({node:Y[ee],shadow:null});if(O){let ee=L?L(A):null;if(typeof ee=="string"&&ne(ee)==="template"){let ke=A.content;Kt(ke)&&y.push({node:ke,shadow:null})}}if(O){let ee=b(A);Kt(ee)&&y.push({node:null,shadow:ee},{node:ee,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,k=null,A=null,D=null;if(Pi=!T,Pi&&(T="<!-->"),typeof T!="string"&&!wn(T)&&(T=kw(T),typeof T!="string"))throw It("dirty is not a string, aborting");if(!e.isSupported)return T;Ci?(X=Jn,Z=er):Oi(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Ne(X)),q.uponSanitizeAttribute.length>0&&(Z=Ne(Z)),e.removed=[];let O=Di&&typeof T!="string"&&wn(T);if(O){Wf(T);let ke=$(T);if(typeof ke=="string"){let Se=ne(ke);if(!X[Se]||vn[Se])throw or(T),It("root node is forbidden and cannot be sanitized in-place")}if(lr(T))throw or(T),It("root node is clobbered and cannot be sanitized in-place");try{$i(T)}catch(Se){throw or(T),Se}}else if(wn(T))y=ds("<!---->"),k=y.ownerDocument.importNode(T,!0),k.nodeType===Le.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?y=k:y.appendChild(k),$i(k);else{if(!zt&&!ht&&!_t&&T.indexOf("<")===-1)return F&&nr?he(T):T;if(y=ds(T),!y)return zt?null:nr?G:""}y&&Li&&ft(y.firstChild);let Y=O?T:y;try{let ke=hs(Y);for(;A=ke.nextNode();)gs(A,Y),ys(A),Kt(A.content)&&cr(A.content)}catch(ke){throw O&&(or(T),Gt(e.removed,Se=>{Se.element&&ar(Se.element)})),ke}if(O)return Gt(e.removed,ke=>{ke.element&&ar(ke.element)}),ht&&Fi(T),T;if(zt){if(ht&&Fi(y),tr)for(D=Xe.call(y.ownerDocument);y.firstChild;)D.appendChild(y.firstChild);else D=y;return(Z.shadowroot||Z.shadowrootmode)&&(D=De.call(r,D,!0)),D}let ee=_t?y.outerHTML:y.innerHTML;return _t&&X["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&ve(Gw,y.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
336
- `+ee),ht&&(ee=sr(ee)),F&&nr?he(ee):ee},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Oi(T),Ci=!0,Jn=X,er=Z},e.clearConfig=function(){Wt=null,Ci=!1,Jn=null,er=null,F=U,G=""},e.isValidAttribute=function(T,p,y){Wt||Oi({});let k=ne(T),A=ne(p);return ms(k,A,y)},e.addHook=function(T,p){typeof p=="function"&&Te(q,T)&&Bn(q[T],p)},e.removeHook=function(T,p){if(Te(q,T)){if(p!==void 0){let y=vw(q[T],p);return y===-1?void 0:yw(q[T],y,1)[0]}return Kd(q[T])}},e.removeHooks=function(T){Te(q,T)&&(q[T]=[])},e.removeAllHooks=function(){q=rh()},e}var lh=sh();function Bw({prompt:t,send:e}){return x("div",{class:`weave-note-prompt weave-note-prompt-${t.kind}`,role:"alert",children:[x("p",{class:"weave-note-prompt-text",children:t.message}),x("p",{class:"weave-note-prompt-actions",children:t.actions.map(n=>x("button",{type:"button",class:"weave-note-action",onClick:()=>e(n.event),children:n.label},n.label))})]})}function uh(t){let{toolbar:e,send:n}=t;return x("div",{class:"weave-note-bar",children:[x("button",{type:"button",class:"weave-note-toggle","aria-pressed":e.editing,onClick:()=>n({type:"toggle"}),children:e.toggleLabel}),e.editing?x("button",{type:"button",class:"weave-note-save",disabled:!e.canSave,onClick:()=>n({type:"save"}),children:e.saveLabel}):null,x("button",{type:"button",class:"weave-note-open",title:ed,onClick:()=>n({type:"open"}),children:Jc}),e.dirty?x("span",{class:"weave-note-dirty",title:"unsaved changes","aria-hidden":"true",children:"•"}):null,e.message===null?null:x("span",{class:`weave-note-status weave-note-status-${e.tone}`,children:e.message}),t.prompt===null?null:x(Bw,{prompt:t.prompt,send:n})]})}function ch(t){return x("textarea",{class:"weave-note-editor","aria-label":"Note body",spellcheck:!0,value:t.draft,onInput:e=>t.send({type:"draft",text:e.target.value}),onKeyDown:e=>{e.key.toLowerCase()!=="s"||!(e.metaKey||e.ctrlKey)||(e.preventDefault(),t.send({type:"save"}))}})}function Ea(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ft=Ea();function yh(t){Ft=t}var Mt={exec:()=>null};function fn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function z(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ye.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Ww=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ye={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:fn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:fn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:fn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:fn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:fn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:fn(t=>new RegExp(`^ {0,${t}}>`))},Kw=/^(?:[ \t]*(?:\n|$))+/,Vw=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jw=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Yn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,qw=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ka=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wh=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bh=z(wh).replace(/bull/g,ka).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(),Yw=z(wh).replace(/bull/g,ka).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Sa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Xw=/^[^\n]+/,Ta=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Zw=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Ta).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qw=z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ka).getRegex(),xi="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",Ra=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Jw=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",Ra).replace("tag",xi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),xh=t=>z(Sa).replace("hr",Yn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xi).getRegex(),eb=xh(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),tb=xh(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),nb=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tb).getRegex(),Aa={blockquote:nb,code:Vw,def:Zw,fences:jw,heading:qw,hr:Yn,html:Jw,lheading:bh,list:Qw,newline:Kw,paragraph:eb,table:Mt,text:Xw},dh=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Yn).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",xi).getRegex(),rb={...Aa,lheading:Yw,table:dh,paragraph:z(Sa).replace("hr",Yn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",dh).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xi).getRegex()},ib={...Aa,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ra).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:Mt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(Sa).replace("hr",Yn).replace("heading",` *#{1,6} *[^
337
- ]`).replace("lheading",bh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ob=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ab=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_h=/^( {2,}|\\)\n(?!\s*$)/,sb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ct=/[\p{P}\p{S}]/u,pn=/[\s\p{P}\p{S}]/u,Xn=/[^\s\p{P}\p{S}]/u,lb=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,pn).getRegex(),ub=/[\p{Pi}\p{Ps}"']/u,Eh=/(?!~)[\p{P}\p{S}]/u,cb=/(?!~)[\s\p{P}\p{S}]/u,db=/(?:[^\s\p{P}\p{S}]|~)/u,hb=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ww?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),kh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,fb=z(kh,"u").replace(/punct/g,ct).getRegex(),pb=z(kh,"u").replace(/punct/g,Eh).getRegex(),gb=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,mb=z(gb,"u").replace(/openQuote/g,ub).replace(/punct/g,ct).getRegex(),Sh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",vb=z(Sh,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,pn).replace(/punct/g,ct).getRegex(),yb=z(Sh,"gu").replace(/notPunctSpace/g,db).replace(/punctSpace/g,cb).replace(/punct/g,Eh).getRegex(),wb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",bb=z(wb,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,pn).replace(/punct/g,ct).getRegex(),xb=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,pn).replace(/punct/g,ct).getRegex(),_b="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Eb=z(_b,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,pn).replace(/punct/g,ct).getRegex(),kb=z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ct).getRegex(),Sb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Tb=z(Sb,"gu").replace(/notPunctSpace/g,Xn).replace(/punctSpace/g,pn).replace(/punct/g,ct).getRegex(),Rb=z(/\\(punct)/,"gu").replace(/punct/g,ct).getRegex(),Ab=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(),Cb=z(Ra).replace("(?:-->|$)","-->").getRegex(),Lb=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",Cb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Nb=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",yi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Th=z(/^!?\[(label)\]\[(ref)\]/).replace("label",yi).replace("ref",Ta).getRegex(),Rh=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",Ta).getRegex(),Db=z("reflink|nolink(?!\\()","g").replace("reflink",Th).replace("nolink",Rh).getRegex(),hh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ca={_backpedal:Mt,anyPunctuation:Rb,autolink:Ab,blockSkip:hb,br:_h,code:ab,del:Mt,delLDelim:Mt,delRDelim:Mt,emStrongLDelim:fb,emStrongRDelimAst:vb,emStrongRDelimUnd:xb,escape:ob,link:Nb,nolink:Rh,punctuation:lb,reflink:Th,reflinkSearch:Db,tag:Lb,text:sb,url:Mt},Pb={...Ca,emStrongLDelim:mb,emStrongRDelimAst:bb,emStrongRDelimUnd:Eb,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",yi).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yi).getRegex()},ba={...Ca,emStrongRDelimAst:yb,emStrongLDelim:pb,delLDelim:kb,delRDelim:Tb,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",hh).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",hh).getRegex()},Ib={...ba,br:z(_h).replace("{2,}","*").getRegex(),text:z(ba.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vi={normal:Aa,gfm:rb,pedantic:ib},jn={normal:Ca,gfm:ba,breaks:Ib,pedantic:Pb},Gb={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},fh=t=>Gb[t];function nt(t,e){if(e){if(ye.escapeTest.test(t))return t.replace(ye.escapeReplace,fh)}else if(ye.escapeTestNoEncode.test(t))return t.replace(ye.escapeReplaceNoEncode,fh);return t}function ph(t){try{t=encodeURI(t).replace(ye.percentDecode,"%")}catch{return null}return t}function gh(t,e){let n=t.replace(ye.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(ye.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ye.slashPipe,"|");return r}function bt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let o=t.charAt(r-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,r-i)}function mh(t){let e=t.split(`
338
- `),n=e.length-1;for(;n>=0&&ye.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
339
- `)}function Mb(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ob(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function vh(t,e,n,r,i){let o=e.href,a=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function Fb(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
333
+ `,wg=yg,Dl=WebGLRenderingContext,wl=Dl.UNSIGNED_BYTE,Tn=Dl.FLOAT,bg=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Il=(function(t){function e(){return ue(this,e),ke(this,e,arguments)}return Ee(e,t),ce(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:wg,FRAGMENT_SHADER_SOURCE:Cl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:bg,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Tn},{name:"a_positionEnd",size:2,type:Tn},{name:"a_normal",size:2,type:Tn},{name:"a_color",size:4,type:wl,normalized:!0},{name:"a_id",size:4,type:wl,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Tn},{name:"a_normalCoef",size:1,type:Tn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=Xt(s.color),g=h-u,m=d-c,v=g*g+m*m,y=0,w=0;v&&(v=1/Math.sqrt(v),y=-m*v*l,w=g*v*l);var k=this.array;k[i++]=u,k[i++]=c,k[i++]=h,k[i++]=d,k[i++]=y,k[i++]=w,k[i++]=f,k[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(go);var Kl=_n(Rr()),Cr=(function(t){function e(){var n;return ue(this,e),n=ke(this,e),n.rawEmitter=n,n}return Ee(e,t),ce(e)})(Kl.EventEmitter);var Yl=_n(yo());var Ag=function(e){return e},Rg=function(e){return e*e},Cg=function(e){return e*(2-e)},Lg=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},Ng=function(e){return e*e*e},Pg=function(e){return--e*e*e+1},Dg=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},Xl={linear:Ag,quadraticIn:Rg,quadraticOut:Cg,quadraticInOut:Lg,cubicIn:Ng,cubicOut:Pg,cubicInOut:Dg},Zl={easing:"quadraticInOut",duration:150};function Oe(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Lr(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function jl(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function ql(t,e,n){return t[6]=e,t[7]=n,t}function yt(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],g=e[3],m=e[4],v=e[5],y=e[6],w=e[7],k=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=g*n+m*o+v*l,t[4]=g*r+m*a+v*u,t[5]=g*i+m*s+v*c,t[6]=y*n+w*o+k*l,t[7]=y*r+w*a+k*u,t[8]=y*i+w*s+k*c,t}function Nr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Ig(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Qt(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=Oe(),d=Math.min(u,c)-2*r,f=Ig(e,n);return i?(yt(h,ql(Oe(),s,l)),yt(h,Lr(Oe(),a)),yt(h,jl(Oe(),o)),yt(h,Lr(Oe(),u/d/2/f,c/d/2/f))):(yt(h,Lr(Oe(),2*(d/u)*f,2*(d/c)*f)),yt(h,jl(Oe(),-o)),yt(h,Lr(Oe(),1/a)),yt(h,ql(Oe(),-s,-l))),h}function Ql(t,e,n){var r=Nr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Jl(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function eu(t){if(!(0,Yl.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function tu(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function wo(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function bo(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function xo(t){var e=vt(t.x,2),n=e[0],r=e[1],i=vt(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function Pr(t){"@babel/helpers - typeof";return Pr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pr(t)}function _o(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function Dr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var Ir={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:kl,defaultDrawNodeLabel:mo,defaultDrawNodeHover:El,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:{}},Gg={circle:An},Mg={arrow:Pl,line:Il};function Gr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function nu(t){var e=Dr({},Ir,t);return e.nodeProgramClasses=Dr({},Gg,e.nodeProgramClasses),e.edgeProgramClasses=Dr({},Mg,e.edgeProgramClasses),e}var Z_=_n(Rr()),Q_=_n(yo()),Mr=1.5,ru=(function(t){function e(){var n;return ue(this,e),n=ke(this,e),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return Ee(e,t),ce(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(P(P({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=P(P({},Zl),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:Xl[s.easing],c=Date.now(),h=this.getState(),d=function(){var g=(Date.now()-c)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(g),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Mr)},r):this.animate({ratio:this.ratio/Mr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Mr)},r):this.animate({ratio:this.ratio*Mr})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(Cr);function Ke(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function at(t,e){var n=P(P({},Ke(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function Rn(t){var e="x"in t?t:P(P({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function Og(t,e){return P(P({},at(t,e)),{},{delta:uu(t)})}var Fg=2;function Or(t){for(var e=[],n=0,r=Math.min(t.length,Fg);n<r;n++)e.push(t[n]);return e}function Cn(t,e,n){var r={touches:Or(t.touches).map(function(i){return Ke(i,n)}),previousTouches:e.map(function(i){return Ke(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function uu(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var cu=(function(t){function e(n,r){var i;return ue(this,e),i=ke(this,e),i.container=n,i.renderer=r,i}return Ee(e,t),ce(e)})(Cr),zg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],$g=zg.reduce(function(t,e){return P(P({},t),{},S({},e,Ir[e]))},{}),Ug=(function(t){function e(n,r){var i;return ue(this,e),i=ke(this,e,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",$g),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 Ee(e,t),ce(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",at(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",at(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=at(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(Ke(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=Ke(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",at(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=Ke(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",at(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=at(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=Ke(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,g=a.getState(),m=g.x+d,v=g.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",at(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",at(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=uu(r);if(a){var s=Og(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Ke(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(cu),Hg=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Bg=Hg.reduce(function(t,e){return P(P({},t),{},S({},e,Ir[e]))},{}),Wg=(function(t){function e(n,r){var i;return ue(this,e),i=ke(this,e,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",Bg),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 Ee(e,t),ce(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=Or(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Ke(f,i.container)}),this.touchMode===2){var a=vt(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",Cn(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",Cn(r,this.lastTouches,this.container)),!r.touches.length){var s=Ke(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=Cn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=Cn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Or(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=Or(r.touches),a=o.map(function(Je){return Ke(Je,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=Cn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(Je,vn){var Ge=i.startTouchesPositions[vn];return Ge&&(Je.x!==Ge.x||Je.y!==Ge.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,g=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,y=m.y;u.setState({x:c.x+f-v,y:c.y+g-y});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},k=a[0],_=k.x,A=k.y,N=a[1],I=N.x,z=N.y,F=Math.atan2(z-A,I-_)-this.startTouchesAngle,G=Math.hypot(z-A,I-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);w.ratio=U,w.angle=c.angle+F;var j=this.getDimensions(),J=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ve=Math.min(j.width,j.height)-2*h,pe=ve/j.width,Qe=ve/j.height,$t=U/ve,He=_-ve/2/pe,Be=A-ve/2/Qe,We=[He*Math.cos(-w.angle)-Be*Math.sin(-w.angle),Be*Math.cos(-w.angle)+He*Math.sin(-w.angle)];He=We[0],Be=We[1],w.x=J.x-He*$t,w.y=J.y+Be*$t,u.setState(w);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(cu);function Kg(t){if(Array.isArray(t))return Er(t)}function Vg(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
334
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iu(t){return Kg(t)||Vg(t)||so(t)||jg()}function qg(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function ko(t,e){if(t==null)return{};var n,r,i=qg(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var ou=(function(){function t(e,n){ue(this,t),this.key=e,this.size=n}return ce(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),au=(function(){function t(){ue(this,t),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return ce(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new ou(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(ou.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function Yg(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var su=150,lu=50,st=Object.prototype.hasOwnProperty;function Xg(t,e,n){if(!st.call(n,"x")||!st.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),st.call(n,"hidden")||(n.hidden=!1),st.call(n,"highlighted")||(n.highlighted=!1),st.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Zg(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),st.call(n,"hidden")||(n.hidden=!1),st.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Qg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(ue(this,e),i=ke(this,e),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new au),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",Oe()),S(i,"invMatrix",Oe()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",xo({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",wo()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=nu(o),Gr(i.settings),eu(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new ru,i.bindCameraHandlers(),i.mouseCaptor=new Ug(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Wg(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ee(e,t),ce(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=ko(i,[r].map(At));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=ko(s,[r].map(At));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=ko(i,[r].map(At));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=co(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=uo.apply(void 0,iu(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=Rn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",P(P({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",P(P({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",P(P({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=Rn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=Rn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",P({},s))},this.activeListeners.handleEnter=function(o){var a=Rn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",P({},s))};var i=function(a){return function(s){var l=Rn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),P(P({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),P(P({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=co(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=uo.apply(void 0,iu(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=Jl(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=xo(this.customBBox||this.nodeExtent);var d=new ru,f=Qt(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},y={},w=1,k=i.nodes(),_=0,A=k.length;_<A;_++){var N=k[_],I=this.nodeDataCache[N],z=i.getNodeAttributes(N);I.x=z.x,I.y=z.y,this.normalizationFunction.applyTo(I),typeof I.label=="string"&&!I.hidden&&this.labelGrid.add(N,I.size,this.framedGraphToViewport(I,{matrix:f})),g[I.type]=(g[I.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!st.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(g[F]||0),g[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=bo(this.nodeZExtent,function(yn){return r.nodeDataCache[yn].zIndex},k));for(var G=0,U=k.length;G<U;G++){var j=k[G];m[j]=w,y[m[j]]={type:"node",id:j},w++;var J=this.nodeDataCache[j];this.addNodeToProgram(j,m[j],g[J.type]++)}for(var ve={},pe=i.edges(),Qe=0,$t=pe.length;Qe<$t;Qe++){var He=pe[Qe],Be=this.edgeDataCache[He];ve[Be.type]=(ve[Be.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(pe=bo(this.edgeZExtent,function(yn){return r.edgeDataCache[yn].zIndex},pe));for(var We in this.edgePrograms){if(!st.call(this.edgePrograms,We))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(We,'"!'));this.edgePrograms[We].reallocate(ve[We]||0),ve[We]=0}for(var Je=0,vn=pe.length;Je<vn;Je++){var Ge=pe[Je];v[Ge]=w,y[v[Ge]]={type:"edge",id:Ge},w++;var q=this.edgeDataCache[Ge];this.addEdgeToProgram(Ge,v[Ge],ve[q.type]++)}return this.itemIDsIndex=y,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&Pr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=P({},r),u=s||this.nodeExtent,c=vt(u.x,2),h=c[0],d=c[1],f=vt(u.y,2),g=f[0],m=f[1],v=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],y=1/0,w=-1/0,k=1/0,_=-1/0;v.forEach(function(ve){var pe=ve.x,Qe=ve.y;y=Math.min(y,pe),w=Math.max(w,pe),k=Math.min(k,Qe),_=Math.max(_,Qe)});var A=w-y,N=_-k,I=this.getDimensions(),z=I.width,F=I.height,G=0,U=0;if(A>=z?w<z-a?G=w-(z-a):y>a&&(G=y-a):w>z+a?G=w-(z+a):y<-a&&(G=y+a),N>=F?_<F-a?U=_-(F-a):k>a&&(U=k-a):_>F+a?U=_-(F+a):k<-a&&(U=k+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),J=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=J.x-j.x,U=J.y-j.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);_o(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-su||h>this.width+su||d<-lu||d>this.height+lu)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,P(P({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=Yg({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});_o(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[d.type],m=g?.drawLabel||f;m(r,P(P({key:l},d),{},{size:this.scaleSize(d.size)}),P(P(P({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),P(P(P({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var g=r.nodeDataCache[f],m=r.framedGraphToViewport(g),v=m.x,y=m.y,w=r.scaleSize(g.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],A=_?.drawHover||k;A(i,P(P({key:f},g),{},{size:w,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 f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=Qt(s,l,u,c),this.invMatrix=Qt(s,l,u,c,!0),this.correctionRatio=Ql(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var g in this.edgePrograms){var m=this.edgePrograms[g];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=Xg(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=Zg(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 au,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=tu(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=P({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return P({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=P({},this.settings);return this.settings[r]=i,Gr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=P({},this.settings);return this.settings=P(P({},this.settings),r),Gr(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=wo(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(_){return i.addNode(_)}),this.graph.forEachEdge(function(_){return i.addEdge(_)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,y=m.length;v<y;v++){var w=m[v];if(this.updateEdge(w),o){var k=this.edgeProgramIndex[w];if(k===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],k)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(P(P({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,g={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=Nr(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?Qt(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=Nr(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}}])})(Cr),du=Qg;function hu(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return fu(this.cover(e,n),e,n,t)}function fu(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,g,m,v,y,w;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[y=v<<1|m]))return i[y]=a,t;if(f=+t._x.call(null,o.data),g=+t._y.call(null,o.data),e===f&&n===g)return a.next=o,i?i[y]=a:t._root=a,t;do i=i?i[y]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((y=v<<1|m)===(w=(g>=d)<<1|f>=h));return i[w]=o,i[y]=a,t}function pu(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)fu(this,a[n],s[n],t[n]);return this}function gu(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function mu(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function vu(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function ge(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function yu(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,g,m;for(f&&d.push(new ge(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);g=d.pop();)if(!(!(f=g.node)||(a=g.x0)>c||(s=g.y0)>h||(l=g.x1)<i||(u=g.y1)<o))if(f.length){var v=(a+l)/2,y=(s+u)/2;d.push(new ge(f[3],v,y,l,u),new ge(f[2],a,y,v,u),new ge(f[1],v,s,l,y),new ge(f[0],a,s,v,y)),(m=(e>=y)<<1|t>=v)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=g)}else{var w=t-+this._x.call(null,f.data),k=e-+this._y.call(null,f.data),_=w*w+k*k;if(_<n){var A=Math.sqrt(n=_);i=t-A,o=e-A,c=t+A,h=e+A,r=f.data}}return r}function wu(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,g,m,v,y;if(!n)return this;if(n.length)for(;;){if((g=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|g]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,y=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[y]=n:this._root=n),this):(this._root=o,this)}function bu(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function xu(){return this._root}function _u(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function ku(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new ge(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new ge(i,u,c,s,l)),(i=r[2])&&e.push(new ge(i,o,c,u,l)),(i=r[1])&&e.push(new ge(i,u,a,s,c)),(i=r[0])&&e.push(new ge(i,o,a,u,c))}return this}function Eu(t){var e=[],n=[],r;for(this._root&&e.push(new ge(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new ge(o,a,s,c,h)),(o=i[1])&&e.push(new ge(o,c,s,l,h)),(o=i[2])&&e.push(new ge(o,a,h,c,u)),(o=i[3])&&e.push(new ge(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Su(t){return t[0]}function Tu(t){return arguments.length?(this._x=t,this):this._x}function Au(t){return t[1]}function Ru(t){return arguments.length?(this._y=t,this):this._y}function Ct(t,e,n){var r=new Eo(e??Su,n??Au,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Eo(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Cu(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Se=Ct.prototype=Eo.prototype;Se.copy=function(){var t=new Eo(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Cu(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=Cu(r));return t};Se.add=hu;Se.addAll=pu;Se.cover=gu;Se.data=mu;Se.extent=vu;Se.find=yu;Se.remove=wu;Se.removeAll=bu;Se.root=xu;Se.size=_u;Se.visit=ku;Se.visitAfter=Eu;Se.x=Tu;Se.y=Ru;function oe(t){return function(){return t}}function Ve(t){return(t()-.5)*1e-6}function Jg(t){return t.x+t.vx}function em(t){return t.y+t.vy}function So(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=oe(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,m,v,y=0;y<o;++y)for(h=Ct(e,Jg,em).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,g=d.y+d.vy,h.visit(w);function w(k,_,A,N,I){var z=k.data,F=k.r,G=m+F;if(z){if(z.index>d.index){var U=f-z.x-z.vx,j=g-z.y-z.vy,J=U*U+j*j;J<G*G&&(U===0&&(U=Ve(r),J+=U*U),j===0&&(j=Ve(r),J+=j*j),J=(G-(J=Math.sqrt(J)))/J*i,d.vx+=(U*=J)*(G=(F*=F)/(v+F)),d.vy+=(j*=J)*G,z.vx-=U*(G=1-G),z.vy-=j*G)}return}return _>f+G||N<f-G||A>g+G||I<g-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:oe(+u),l(),a):t},a}function tm(t){return t.index}function Lu(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function To(t){var e=tm,n=h,r,i=oe(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var y=0,w=t.length;y<c;++y)for(var k=0,_,A,N,I,z,F,G;k<w;++k)_=t[k],A=_.source,N=_.target,I=N.x+N.vx-A.x-A.vx||Ve(u),z=N.y+N.vy-A.y-A.vy||Ve(u),F=Math.sqrt(I*I+z*z),F=(F-o[k])/F*v*r[k],I*=F,z*=F,N.vx-=I*(G=l[k]),N.vy-=z*G,A.vx+=I*(G=1-G),A.vy+=z*G}function f(){if(a){var v,y=a.length,w=t.length,k=new Map(a.map((A,N)=>[e(A,N,a),A])),_;for(v=0,s=new Array(y);v<w;++v)_=t[v],_.index=v,typeof _.source!="object"&&(_.source=Lu(k,_.source)),typeof _.target!="object"&&(_.target=Lu(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(v=0,l=new Array(w);v<w;++v)_=t[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(w),g(),o=new Array(w),m()}}function g(){if(a)for(var v=0,y=t.length;v<y;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,y=t.length;v<y;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,y){a=v,u=y,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:oe(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:oe(+v),m(),d):i},d}var nm={value:()=>{}};function Pu(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Fr(n)}function Fr(t){this._=t}function rm(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Fr.prototype=Pu.prototype={constructor:Fr,on:function(t,e){var n=this._,r=rm(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=im(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=Nu(n[i],t.name,e);else if(e==null)for(i in n)n[i]=Nu(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new Fr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function im(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function Nu(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=nm,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Ao=Pu;var Jt=0,Nn=0,Ln=0,Iu=1e3,zr,Pn,$r=0,Lt=0,Ur=0,Dn=typeof performance=="object"&&performance.now?performance:Date,Gu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Lo(){return Lt||(Gu(om),Lt=Dn.now()+Ur)}function om(){Lt=0}function Ro(){this._call=this._time=this._next=null}Ro.prototype=Hr.prototype={constructor:Ro,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Lo():+n)+(e==null?0:+e),!this._next&&Pn!==this&&(Pn?Pn._next=this:zr=this,Pn=this),this._call=t,this._time=n,Co()},stop:function(){this._call&&(this._call=null,this._time=1/0,Co())}};function Hr(t,e,n){var r=new Ro;return r.restart(t,e,n),r}function Mu(){Lo(),++Jt;for(var t=zr,e;t;)(e=Lt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Jt}function Du(){Lt=($r=Dn.now())+Ur,Jt=Nn=0;try{Mu()}finally{Jt=0,sm(),Lt=0}}function am(){var t=Dn.now(),e=t-$r;e>Iu&&(Ur-=e,$r=t)}function sm(){for(var t,e=zr,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:zr=n);Pn=t,Co(r)}function Co(t){if(!Jt){Nn&&(Nn=clearTimeout(Nn));var e=t-Lt;e>24?(t<1/0&&(Nn=setTimeout(Du,t-Dn.now()-Ur)),Ln&&(Ln=clearInterval(Ln))):(Ln||($r=Dn.now(),Ln=setInterval(am,Iu)),Jt=1,Gu(Du))}}function Ou(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function Fu(t){return t.x}function zu(t){return t.y}var lm=10,um=Math.PI*(3-Math.sqrt(5));function No(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=Hr(h),u=Ao("tick","end"),c=Ou();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,y=t.length,w;m===void 0&&(m=1);for(var k=0;k<m;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<y;++v)w=t[v],w.fx==null?w.x+=w.vx*=a:(w.x=w.fx,w.vx=0),w.fy==null?w.y+=w.vy*=a:(w.y=w.fy,w.vy=0);return e}function f(){for(var m=0,v=t.length,y;m<v;++m){if(y=t[m],y.index=m,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var w=lm*Math.sqrt(.5+m),k=m*um;y.x=w*Math.cos(k),y.y=w*Math.sin(k)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function g(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(g),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(g),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,g(v)),e):s.get(m)},find:function(m,v,y){var w=0,k=t.length,_,A,N,I,z;for(y==null?y=1/0:y*=y,w=0;w<k;++w)I=t[w],_=m-I.x,A=v-I.y,N=_*_+A*A,N<y&&(z=I,y=N);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function Po(){var t,e,n,r,i=oe(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=t.length,v=Ct(t,Fu,zu).visitAfter(h);for(r=f,g=0;g<m;++g)e=t[g],v.visit(d)}function c(){if(t){var f,g=t.length,m;for(o=new Array(g),f=0;f<g;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var g=0,m,v,y=0,w,k,_;if(f.length){for(w=k=_=0;_<4;++_)(m=f[_])&&(v=Math.abs(m.value))&&(g+=m.value,y+=v,w+=v*m.x,k+=v*m.y);f.x=w/y,f.y=k/y}else{m=f,m.x=m.data.x,m.y=m.data.y;do g+=o[m.data.index];while(m=m.next)}f.value=g}function d(f,g,m,v){if(!f.value)return!0;var y=f.x-e.x,w=f.y-e.y,k=v-g,_=y*y+w*w;if(k*k/l<_)return _<s&&(y===0&&(y=Ve(n),_+=y*y),w===0&&(w=Ve(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),e.vx+=y*f.value*r/_,e.vy+=w*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(y===0&&(y=Ve(n),_+=y*y),w===0&&(w=Ve(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(k=o[f.data.index]*r/_,e.vx+=y*k,e.vy+=w*k);while(f=f.next)}return u.initialize=function(f,g){t=f,n=g,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:oe(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function Do(t){var e=oe(.1),n,r,i;typeof t!="function"&&(t=oe(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:oe(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:oe(+s),a(),o):t},o}function Io(t){var e=oe(.1),n,r,i;typeof t!="function"&&(t=oe(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:oe(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:oe(+s),a(),o):t},o}var cm={minX:0,minY:0,maxX:0,maxY:0,w:0,h:0,cx:0,cy:0};function $u(t){if(t.length===0)return cm;let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o of t)o.x<e&&(e=o.x),o.x>r&&(r=o.x),o.y<n&&(n=o.y),o.y>i&&(i=o.y);return{minX:e,minY:n,maxX:r,maxY:i,w:r-e,h:i-n,cx:(e+r)/2,cy:(n+i)/2}}var In=9,en=In+9,dm=220,hm=.05,fm=-50,pm=90,gm=.02,mm=8,Uu=2*en,vm=300,Wu=1,Hu=.001;function Mo(t){return t==="contains"||t==="anchored-at"}function ym(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function wm(t){let e=[],n=new Set;for(let o of t.nodes)n.has(o.id)||(n.add(o.id),e.push(o.id));let r=[],i=new Set;for(let o of t.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:e,edges:r}}function bm(t){let e=new Set(t.nodes.map(o=>o.id)),n=new Map,r=new Set;for(let o of t.edges){if(!Mo(o.kind)||o.source===o.target||!e.has(o.source)||!e.has(o.target)||r.has(o.target))continue;r.add(o.target);let a=n.get(o.source);a===void 0?n.set(o.source,[o.target]):a.push(o.target)}let i=t.nodes.filter(o=>!r.has(o.id)).map(o=>o.id);return{kids:n,roots:i}}function Ku(t){let{kids:e,roots:n}=bm(t),r=(o,a)=>{if(a.has(o))return[];a.add(o);let s=[o];for(let l of e.get(o)??[])for(let u of r(l,a))s.push(u);return s},i=[];for(let o of n)for(let a of e.get(o)??[]){let s=r(a,new Set);s.length>=mm&&i.push({id:a,members:s})}return i.sort((o,a)=>o.id<a.id?-1:o.id>a.id?1:0),i}function xm(t){let e=new Map;for(let n of t)n.x!==void 0&&n.y!==void 0&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&e.set(n.id,{x:n.x,y:n.y});return e}function Bu(t,e){let n=[];for(let i of t){let o=e.get(i);o!==void 0&&n.push(o)}if(n.length===0)return en;let r=$u(n);return Math.hypot(r.w,r.h)/2}function Oo(t,e,n){let r=n??Ku(t);if(r.length===0)return new Map;let i=new Set;for(let f of r)for(let g of f.members)i.add(g);let o=t.nodes.filter(f=>!i.has(f.id)).map(f=>f.id),a=Bu(o,e),s=r.map(f=>Bu(f.members,e)),l=s.map(f=>2*f+Uu),u=l.reduce((f,g)=>f+g,0),c=Math.max(u/(2*Math.PI),a+Uu+Math.max(...s)),h=new Map,d=0;for(let f=0;f<r.length;f++){let g=r[f],m=l[f],v=-Math.PI/2+(d+m/2)/u*2*Math.PI;d+=m;let y={x:Math.cos(v)*c,y:Math.sin(v)*c};for(let w of g.members)h.set(w,y)}return h}function _m(t,e,n,r){let i=new Map(t.map(o=>[o.id,o]));for(let o of e){let a=n.get(o.id);if(a===void 0)continue;let s=0,l=0,u=0;for(let d of o.members){let f=r.get(d);f!==void 0&&(s+=f.x,l+=f.y,u++)}if(u===0)continue;let c=a.x-s/u,h=a.y-l/u;for(let d of o.members){let f=i.get(d);f===void 0||f.x===void 0||f.y===void 0||f.fx!=null||f.fy!=null||(f.x+=c,f.y+=h)}}}function Vu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??vm)),r=e.seed??Wu,{ids:i,edges:o}=wm(t),a=new Map;if(i.length===0)return a;let s=e.initial,l=i.map(u=>{let c=s?.get(u),h={id:u,vx:0,vy:0};return c!==void 0&&Number.isFinite(c.x)&&Number.isFinite(c.y)&&(h.x=c.x,h.y=c.y,e.pinWarm===!0&&(h.fx=c.x,h.fy=c.y)),h});if(l.length>1){let u=Ku(t);if(u.length===0||n===0)Go(l,o,{ticks:n,seed:r,warm:s!==void 0});else{let c=Math.ceil(n/2);Go(l,o,{ticks:c,seed:r,warm:s!==void 0});let h=xm(l),d=Oo(t,h,u);_m(l,u,d,h),Go(l,o,{ticks:n-c,seed:r,warm:!0,anchors:d})}}if(e.pinWarm===!0)for(let u of l)u.fx=null,u.fy=null;for(let u of l)a.set(u.id,{x:Number.isFinite(u.x)?u.x:0,y:Number.isFinite(u.y)?u.y:0});return a}function Fo(t){let e=To(t.links).id(n=>n.id).distance(n=>Mo(n.kind)?pm:dm).strength(n=>Mo(n.kind)?gm:hm).iterations(2);return No(t.nodes).randomSource(ym(t.seed??Wu)).force("charge",Po().strength(fm)).force("link",e).force("collide",So(en).strength(1).iterations(1)).force("x",Do(n=>t.anchors?.get(n.id)?.x??0)).force("y",Io(n=>t.anchors?.get(n.id)?.y??0)).stop()}function Go(t,e,n){let r=e.map(o=>({source:o.source,target:o.target,kind:o.kind})),i=Fo({nodes:t,links:r,seed:n.seed,anchors:n.anchors});i.alpha(n.warm?.3:1).alphaMin(Hu).alphaDecay(n.ticks>0?1-Math.pow(Hu,1/n.ticks):0);for(let o=0;o<n.ticks;o++)i.tick()}function Pe(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function km(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let g=e.get(f);if(g&&g.kind==="module"&&g.detail.path){let m=g.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function qu(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function Em(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function Sm(t,e){return t.slice().sort((n,r)=>{let i=Pe(e.get(n)),o=Pe(e.get(r));return i.localeCompare(o)})}function ju(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function Tm(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?ju(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?ju(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function zo(t,e){let n=km(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let y=(i.get(g)??[]).filter(w=>{let k=r.get(w);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(w))return!1;return!0}).concat(o.get(g)??[]);return y=y.filter(w=>r.has(w)),e.showInternals||(y=y.filter(w=>{let k=r.get(w);return!(k&&Em(k.kind))})),Sm(y,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Pe(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let m=r.get(g),v=!1;for(let w of s(g))h(w)&&(v=!0);let y=u(m)||v;return y&&c.add(g),y};for(let g of a)h(g);let d=[],f=(g,m)=>{if(!c.has(g))return;let v=r.get(g),y=s(g),w=y.filter(_=>c.has(_)),k=l?w.length>0:e.expanded.has(g);if(d.push({id:g,depth:m,hasKids:y.length>0,expanded:k,label:Pe(v),kind:v.kind,provenance:v.provenance,meta:Tm(v)}),k)for(let _ of w)f(_,m+1)};for(let g of a)f(g,0);return d}function $o(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function Gn(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var Am=7;function Uo(t,e){if(t===null)return"";switch(t.kind){case"relTime":return Gn(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,Am);case"text":return t.text}}var Rm=["path","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","warning","stale","preview","root","notes","state"];function Ho(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of Rm){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Pe(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Pe(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Pe(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function Bo(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var Cm=["contains","anchored-at"];function Lm(t){return Cm.includes(t)}function Br(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=Nm(t,n),i=qu(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,Pm(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let g=s.get(d);u.set(d,{children:f,descendants:g,members:g.filter(m=>l.get(m)===d),provenance:Dm(g,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:Im(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function Nm(t,e){let n=new Map;for(let r of t.edges){if(!Lm(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function Pm(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function Dm(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Im(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function Wo(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var tn=[null,"human","agent","generated"];function Yu(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Nt(t){return{...t.model,danglingLinks:t.dangling}}function Xu(t,e){return t===null?[]:zo(Nt(t),e)}function Zu(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Mm(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function Om(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function Qu(t,e){return t.query===e?t:{...t,query:e}}function Ju(t){let e=tn.indexOf(t.provFilter),n=tn[(e+1)%tn.length]??null;return{...t,provFilter:n}}function ec(t){return{...t,showInternals:!t.showInternals}}function Kr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function Vo(t,e){return t[e]?.id??null}function Ko(t,e,n){if(t.length===0)return null;let r=Kr(t,e),i=r===-1?n>0?-1:t.length:r;return Vo(t,Math.min(t.length-1,Math.max(0,i+n)))}function Fm(t,e){let n=Kr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var zm={j:"ArrowDown",k:"ArrowUp"};function $m(t){return zm[t]??t}function tc(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=$m(r);if(s==="ArrowDown")return a(Ko(t,n,1));if(s==="ArrowUp")return a(Ko(t,n,-1));if(s==="Home")return a(Vo(t,0));if(s==="End")return a(Vo(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Kr(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(Ko(t,n,1)):{state:Mm(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:Om(e,n),selectedId:n,handled:!0};let c=Fm(t,n);return c===null?o:a(c)}var Um={vault:"◆",note:"▪",repository:"▣",module:"▤",package:"◈",entryPoint:"▷",gitState:"◇",external:"↗",file:"·"};function jo(t){return Um[t]}var Hm={human:"●",agent:"◐",generated:"○"};function Pt(t){return t===null?"":Hm[t]}function Mn(t){return t===null?"":`${t}-authored`}var Bm={open:"▾",closed:"▸",leaf:""};function nc(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Wm(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function Km(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:nc(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindGlyph:jo(t.kind),provenance:t.provenance,provenanceGlyph:Pt(t.provenance),provenanceTitle:Mn(t.provenance),twisty:i,twistyGlyph:Bm[i],hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:Uo(t.meta,n),level:t.depth+1}}function rc(t,e,n){let r=Wm(t);return t.map((i,o)=>Km(i,e,n,r[o]))}function ic(t,e){return Kr(t,e)===-1?null:nc(e)}function oc(t){return{"--weave-depth":String(Math.max(0,t))}}function Wr(t){return t===null?"all":t}function ac(t){let e=tn.indexOf(t),n=tn[(e+1)%tn.length]??null;return`provenance filter: ${Wr(t)} — click for ${Wr(n)}`}function sc(t){return t?"internals":"knowledge"}function lc(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var uc="filter…",cc="Vault and repository",dc="Filter the tree",hc="Filter the tree (/)";function fc(t,e,n){if(t===null)return"loading…";let r=$o(Nt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function pc(t){return t.length===1?"1 row":`${t.length} rows`}var Vr={dark:{accent:"#b79fdd",success:"#7fc49a",warning:"#e8b04c",dim:"#bb9ecf",text:"#fde2f3",muted:"#aca3d4",line:"#4a527e"},light:{accent:"#85586f",success:"#3f704e",warning:"#a05a1c",dim:"#7c6257",text:"#43303a",muted:"#7f6455",line:"#d0b8a8"}},Vm={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},jm={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function qm(t,e){return Vr[e][Vm[t]]}function Ym(t,e){return Vr[e][jm[t]]}var qo=6,Xm=32;function Zm(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Xm));return qo+(In-qo)*n}var Qm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1};function Jm(t){let e=Pt(t.provenance),n=Pe(t);return e===""?n:`${e} ${n}`}function gc(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var mc={nodes:[],edges:[]};function vc(t){return`${t.source}\0${t.target}\0${t.kind}`}function ev(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=vc(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 yc(t,e,n,r){let i=new Map;for(let c of t){if(i.has(c.id))continue;let h=n.get(c.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||i.set(c.id,c)}let o=new Set(i.keys()),a=ev(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=Zm(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:Jm(h),color:qm(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let c of e){if(c.source===c.target||!o.has(c.source)||!o.has(c.target))continue;let h=vc(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:Qm[c.kind],color:Ym(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function tv(t){return Vr[t].muted}function wc(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+nv}:{color:tv(r),label:null,zIndex:0}}var nv=In+1;function bc(t){return(e,n)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1}:{hidden:!0}}var rv=(qo+In)/2,iv=en*4,ov=1;function xc(t){let e=Vr[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:ov,labelGridCellSize:iv,labelRenderedSizeThreshold:rv,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:en,allowInvalidContainer:!0}}var Sc=_n(Rr(),1);function av(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var de=av;typeof Object.assign=="function"&&(de=Object.assign);function ze(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function ye(t){return typeof t=="object"&&t!==null}function Tc(t){let e;for(e in t)return!1;return!0}function Fe(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function je(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function _c(t){return!(!ye(t)||t.attributes&&!Array.isArray(t.attributes))}function sv(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function lt(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function rn(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var zn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},L=class t extends zn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},R=class t extends zn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends zn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function Ac(t,e){this.key=t,this.attributes=e,this.clear()}Ac.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 Rc(t,e){this.key=t,this.attributes=e,this.clear()}Rc.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Cc(t,e){this.key=t,this.attributes=e,this.clear()}Cc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function on(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}on.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};on.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};on.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};on.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Lc=0,Nc=1,lv=2,Pc=3;function ut(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===Lc){if(s=t._nodes.get(r),!s)throw new R(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===Pc){if(i=""+i,l=t._edges.get(i),!l)throw new R(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new R(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===Nc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function uv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);return a.attributes[s]}}function cv(t,e,n){t.prototype[e]=function(r,i){let[o]=ut(this,e,n,r,i);return o.attributes}}function dv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function hv(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ut(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function fv(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=ut(this,e,n,r,i,o,a);if(typeof u!="function")throw new L(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function pv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function gv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);if(!ye(s))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function mv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);if(!ye(s))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return de(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function vv(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=ut(this,e,n,r,i,o);if(typeof s!="function")throw new L(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var yv=[{name:t=>`get${t}Attribute`,attacher:uv},{name:t=>`get${t}Attributes`,attacher:cv},{name:t=>`has${t}Attribute`,attacher:dv},{name:t=>`set${t}Attribute`,attacher:hv},{name:t=>`update${t}Attribute`,attacher:fv},{name:t=>`remove${t}Attribute`,attacher:pv},{name:t=>`replace${t}Attributes`,attacher:gv},{name:t=>`merge${t}Attributes`,attacher:mv},{name:t=>`update${t}Attributes`,attacher:vv}];function wv(t){yv.forEach(function({name:e,attacher:n}){n(t,e("Node"),Lc),n(t,e("Source"),Nc),n(t,e("Target"),lv),n(t,e("Opposite"),Pc)})}function bv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function xv(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=""+r,a=""+arguments[1];if(i=ze(this,o,a,n),!i)throw new R(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function _v(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function kv(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ze(this,s,l,n),!a)throw new R(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Ev(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=ze(this,s,l,n),!a)throw new R(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,a=this._edges.get(r),!a)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new L(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Sv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function Tv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!ye(i))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Av(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!ye(i))throw new L(`Graph.${e}: provided attributes are not a plain object.`);return de(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Rv(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=""+r,s=""+i;if(i=arguments[2],o=ze(this,a,s,n),!o)throw new R(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new R(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new L(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var Cv=[{name:t=>`get${t}Attribute`,attacher:bv},{name:t=>`get${t}Attributes`,attacher:xv},{name:t=>`has${t}Attribute`,attacher:_v},{name:t=>`set${t}Attribute`,attacher:kv},{name:t=>`update${t}Attribute`,attacher:Ev},{name:t=>`remove${t}Attribute`,attacher:Sv},{name:t=>`replace${t}Attributes`,attacher:Tv},{name:t=>`merge${t}Attributes`,attacher:Av},{name:t=>`update${t}Attributes`,attacher:Rv}];function Lv(t){Cv.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var Nv=[{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 Pv(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function Dv(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function Yo(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Iv(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function Gv(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function Xo(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Mv(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function Dc(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function Ov(t,e){if(t.size===0)return rn();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Zo(t,e,n,r,i,o){let a=e?Dv:Pv,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function Fv(t,e,n,r){let i=[];return Zo(!1,t,e,n,r,function(o){i.push(o)}),i}function zv(t,e,n){let r=rn();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=lt(r,Yo(n.in))),e!=="in"&&typeof n.out<"u"&&(r=lt(r,Yo(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=lt(r,Yo(n.undirected))),r}function Qo(t,e,n,r,i,o,a){let s=n?Gv:Iv,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function $v(t,e,n,r,i){let o=[];return Qo(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Uv(t,e,n,r){let i=rn();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=lt(i,Xo(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=lt(i,Xo(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=lt(i,Xo(n.undirected,r))),i}function Hv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return Mv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${n}: could not find the "${o}" node in the graph.`);return Fv(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 R(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new R(`Graph.${n}: could not find the "${a}" target node in the graph.`);return $v(r,this.multi,i,s,a)}throw new L(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Bv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,Dc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new R(`Graph.${o}: could not find the "${u}" node in the graph.`);return Zo(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new R(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new R(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Qo(!1,r,this.multi,i,d,c,h)}throw new L(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((g,m,v,y,w,k,_)=>{h[f++]=c(g,m,v,y,w,k,_)})}else h=[],u.push((d,f,g,m,v,y,w)=>{h.push(c(d,f,g,m,v,y,w))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,g,m,v,y,w)=>{c(d,f,g,m,v,y,w)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new L(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new L(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,g,m,v,y,w,k)=>{d=c(d,f,g,m,v,y,w,k)}),this[o].apply(this,u),d}}function Wv(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,Dc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new R(`Graph.${o}: could not find the "${l}" node in the graph.`);return Zo(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new R(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new R(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Qo(!0,r,this.multi,i,h,u,c)}throw new L(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,y)=>u(h,d,f,g,m,v,y)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,y)=>!u(h,d,f,g,m,v,y)),!this[o].apply(this,l)}}function Kv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return rn();if(!arguments.length)return Ov(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return zv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new R(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Uv(r,i,l,s)}throw new L(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Vv(t){Nv.forEach(e=>{Hv(t,e),Bv(t,e),Wv(t,e),Kv(t,e)})}var jv=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Jr(){this.A=null,this.B=null}Jr.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Jr.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function On(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function Jo(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return On(t,null,r,r.undirected,i);if(typeof n=="string")return On(t,null,r,r[n],i)}let o=new Jr,a;if(e!=="undirected"){if(n!=="out"){if(a=On(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=On(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=On(t,o,r,r.undirected,i),t&&a))return a}function qv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return Jo(!1,t,e,n,function(i){r.push(i)}),r}function Fn(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Yv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Fn(null,n,n.undirected);if(typeof e=="string")return Fn(null,n,n[e])}let r=rn(),i=new Jr;return t!=="undirected"&&(e!=="out"&&(r=lt(r,Fn(i,n,n.in))),e!=="in"&&(r=lt(r,Fn(i,n,n.out)))),t!=="directed"&&(r=lt(r,Fn(i,n,n.undirected))),r}function Xv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new R(`Graph.${n}: could not find the "${o}" node in the graph.`);return qv(r==="mixed"?this.type:r,i,a)}}function Zv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new R(`Graph.${o}: could not find the "${u}" node in the graph.`);Jo(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new L(`Graph.${l}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let d=h;return this[o](u,(f,g)=>{d=c(d,f,g)}),d}}function Qv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new R(`Graph.${a}: could not find the "${u}" node in the graph.`);return Jo(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function Jv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return rn();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${o}: could not find the "${a}" node in the graph.`);return Yv(r==="mixed"?this.type:r,i,s)}}function ey(t){jv.forEach(e=>{Xv(t,e),Zv(t,e),Qv(t,e),Jv(t,e)})}function jr(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function ty(t,e){let n={key:t};return Tc(e.attributes)||(n.attributes=de({},e.attributes)),n}function ny(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return Tc(n.attributes)||(r.attributes=de({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function ry(t){if(!ye(t))throw new L('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new L("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!ye(t.attributes)||t.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function iy(t){if(!ye(t))throw new L('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new L("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!ye(t.attributes)||t.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new L("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var oy=sv(),ay=new Set(["directed","undirected","mixed"]),kc=new Set(["domain","_events","_eventsCount","_maxListeners"]),sy=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],ly={allowSelfLoops:!0,multi:!1,type:"mixed"};function uy(t,e,n){if(n&&!ye(n))throw new L(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Ec(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Ic(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!ye(s))throw new L(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new R(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new R(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let h=new on(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function cy(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new L(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!ye(s))throw new L(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let w=[f.key,!1,!1,!1];if(l?!u:!s)return w;if(l){let k=f.attributes;f.attributes=u(k),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else de(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return w}s=s||{},l&&u&&(s=u(s));let g={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=Ec(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=Ec(t,a,{}),v=!0),d=new on(r,i,c,h,s),t._edges.set(i,d);let y=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,y&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,y&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,m,v]}function nn(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var K=class t extends Sc.EventEmitter{constructor(e){if(super(),e=de({},ly,e),typeof e.multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!ay.has(e.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?Ac:e.type==="directed"?Rc:Cc;Fe(this,"NodeDataClass",n);let r="geid_"+oy()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Fe(this,"_attributes",{}),Fe(this,"_nodes",new Map),Fe(this,"_edges",new Map),Fe(this,"_directedSize",0),Fe(this,"_undirectedSize",0),Fe(this,"_directedSelfLoopCount",0),Fe(this,"_undirectedSelfLoopCount",0),Fe(this,"_edgeKeyGenerator",o),Fe(this,"_options",e),kc.forEach(a=>Fe(this,a,this[a])),je(this,"order",()=>this._nodes.size),je(this,"size",()=>this._edges.size),je(this,"directedSize",()=>this._directedSize),je(this,"undirectedSize",()=>this._undirectedSize),je(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),je(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),je(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),je(this,"multi",this._options.multi),je(this,"type",this._options.type),je(this,"allowSelfLoops",this._options.allowSelfLoops),je(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new L(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new L(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new R(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new R(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new R(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new R(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new R(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new R(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new R(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new R(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return uy(this,e,n).key}mergeNode(e,n){if(n&&!ye(n))throw new L(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(de(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new L(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new R(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do nn(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do nn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do nn(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=ze(this,r,i,this.type),!n)throw new R(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new R(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return nn(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,n=""+n;let r=ze(this,e,n,"directed");if(!r)throw new R(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return nn(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new M("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");let r=ze(this,e,n,"undirected");if(!r)throw new R(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return nn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new L("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!ye(e))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!ye(e))throw new L("Graph.mergeAttributes: provided attributes are not a plain object.");return de(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new L("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,n){if(typeof e!="function")throw new L("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!_c(n))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!_c(n))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");jr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");jr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");jr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new L("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");jr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new L("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new L("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new L("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new L("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new L("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new L("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=ty(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=ny(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):g?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!ye(e))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!ye(e.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new L("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],ry(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new L("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],iy(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(de({},this._options,e));return n.replaceAttributes(de({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=de({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new M("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new M("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");let n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,Ic(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,de({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!kc.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Fe(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);sy.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?Ic:cy;t.generateKey?K.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:K.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});wv(K);Lv(K);Vv(K);ey(K);var qr=class extends K{constructor(e){let n=de({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new L('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Yr=class extends K{constructor(e){let n=de({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new L('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Xr=class extends K{constructor(e){let n=de({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Zr=class extends K{constructor(e){let n=de({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new L('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Qr=class extends K{constructor(e){let n=de({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new L('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function an(t){t.from=function(e,n){let r=de({},e.options,n),i=new t(r);return i.import(e),i}}an(K);an(qr);an(Yr);an(Xr);an(Zr);an(Qr);K.Graph=K;K.DirectedGraph=qr;K.UndirectedGraph=Yr;K.MultiGraph=Xr;K.MultiDirectedGraph=Zr;K.MultiUndirectedGraph=Qr;K.InvalidArgumentsGraphError=L;K.NotFoundGraphError=R;K.UsageGraphError=M;function dy(){return new K({multi:!0,type:"directed"})}function ea(t){let e=dy();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function Gc(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function ta(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function Mc(t,e){let n=null,r=ea({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,c=f=>{if(u===null)return;let g=u;u=null,n?.setSetting("enableCameraPanning",!0),(f===null||f===g)&&l(g)},h=()=>gc([...ta(r).values()]),d=f=>{let g=wc(i),m=bc(i);f.setSetting("nodeReducer",(v,y)=>({...y,...g(v,y,e)})),f.setSetting("edgeReducer",(v,y)=>({...y,...m(v,y)}))};return{mount(f){if(n!==null)return;let g=t(r,f,xc(e));g.on("clickNode",({node:m})=>o(m)),g.on("clickStage",()=>o(null)),g.on("downNode",({node:m})=>{u=m,n?.setSetting("enableCameraPanning",!1),a(m)}),g.on("moveBody",m=>{u!==null&&(m.preventSigmaDefault(),s(u,g.viewportToGraph({x:m.event.x,y:m.event.y})))}),g.on("upNode",()=>c(u)),g.on("upStage",()=>c(null)),d(g),g.setCustomBBox(h()),n=g},setGraph(f){r=ea(f),n?.setGraph(r),n?.setCustomBBox(h())},setPositions(f){Gc(r,f),n?.refresh()},setHighlight(f){i=f,n!==null&&d(n)},onSelect(f){o=f},onDragStart(f){a=f},onDragMove(f){s=f},onDragEnd(f){l=f},fit(){n?.setCustomBBox(h()),n?.getCamera().animatedReset()},positions(){return ta(r)},destroy(){n?.kill(),n=null}}}var hy=(t,e,n)=>new du(t,e,n),Oc=t=>Mc(hy,t);var zc="/events";var fy=2,ei={graph:!1,note:!1};function $c(t){return!t.graph&&!t.note}function py(t,e){return{graph:!0,note:t==="vault"&&e}}function Fc(t){return{graph:!0,note:t}}function Uc(){return{connection:"live",stamp:null,opened:!1}}function Hc(t,e){return t.stamp===e?t:{...t,stamp:e}}function gy(t){return t===fy?"offline":"reconnecting"}function Bc(t,e,n){switch(e.type){case"open":{let r=t.opened?Fc(n):ei;return{state:{...t,connection:"live",opened:!0},plan:r}}case"error":return{state:{...t,connection:gy(e.readyState)},plan:ei};case"frame":return e.event.stamp===t.stamp?{state:t,plan:ei}:{state:{...t,connection:"live"},plan:py(e.event.scope,n)};case"refresh":return{state:t,plan:Fc(n)};case"closed":return{state:{...t,connection:"offline"},plan:ei}}}function Wc(t){let e;try{e=JSON.parse(t)}catch{return null}return Vs(e)?e:null}var my=Symbol.for("preact-signals");function ii(){if(ct>1)ct--;else{var t,e=!1;for((function(){var i=ni;for(ni=void 0;i!==void 0;){var o=i.S;if(o.v===i.v)for(var a=o.t;a!==void 0;a=a.x)a.i===i.i&&(a.i=o.i);i=i.o}})();Un!==void 0;){var n=Un;for(Un=void 0,ti++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Vc(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=r}}if(ti=0,ct--,e)throw t}}function ra(t){if(ct>0)return t();na=++vy,ct++;try{return t()}finally{ii()}}var $n,Q=void 0;function Hn(t){var e=Q,n=$n;Q=void 0,$n=void 0;try{return t()}finally{Q=e,$n=n}}var Un=void 0,ct=0,ti=0,vy=0,na=0,ni=void 0,ri=0;function Kc(t){if(Q!==void 0){var e=t.n;if(e===void 0||e.t!==Q)return e={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:e},Q.s!==void 0&&(Q.s.n=e),Q.s=e,t.n=e,32&Q.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Q.s,e.n=void 0,Q.s.n=e,Q.s=e),e}}function he(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}he.prototype.brand=my;he.prototype.h=function(){return!0};he.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Hn(function(){var r;(r=e.W)==null||r.call(e)}))};he.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,r=t.x;n!==void 0&&(n.x=r,t.e=void 0),r!==void 0&&(r.e=n,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&Hn(function(){var i;(i=e.Z)==null||i.call(e)}))}};he.prototype.subscribe=function(t){var e=this;return It(function(){var n=e.value;Hn(function(){return t(n)})},{name:"sub"})};he.prototype.valueOf=function(){return this.value};he.prototype.toString=function(){return this.value+""};he.prototype.toJSON=function(){return this.value};he.prototype.peek=function(){var t=this;return Hn(function(){return t.value})};Object.defineProperty(he.prototype,"value",{get:function(){var t=Kc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(ti>100)throw new Error("Cycle detected");(function(n){ct!==0&&ti===0&&n.l!==na&&(n.l=na,ni={S:n,v:n.v,i:n.i,o:ni})})(this),this.v=t,this.i++,ri++,ct++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{ii()}}}});function $e(t,e){return new he(t,e)}function Vc(t){for(var e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function jc(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function qc(t){for(var e=t.s,n=void 0;e!==void 0;){var r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}t.s=n}function Dt(t,e){he.call(this,void 0,e),this.x=t,this.s=void 0,this.g=ri-1,this.f=4}Dt.prototype=new he;Dt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===ri))return!0;if(this.g=ri,this.f|=1,this.i>0&&!Vc(this))return this.f&=-2,!0;var t=Q;try{jc(this),Q=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Q=t,qc(this),this.f&=-2,!0};Dt.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}he.prototype.S.call(this,t)};Dt.prototype.U=function(t){if(this.t!==void 0&&(he.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Dt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Dt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Kc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function oi(t,e){return new Dt(t,e)}function Yc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){ct++;var n=Q;Q=void 0;try{e()}catch(r){throw t.f&=-2,t.f|=8,ia(t),r}finally{Q=n,ii()}}}function ia(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Yc(t)}function yy(t){if(Q!==this)throw new Error("Out-of-order effect");qc(this),Q=t,this.f&=-2,8&this.f&&ia(this),ii()}function sn(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,$n&&$n.push(this)}sn.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};sn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Yc(this),jc(this),ct++;var t=Q;return Q=this,yy.bind(this,t)};sn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Un,Un=this)};sn.prototype.d=function(){this.f|=8,1&this.f||ia(this)};sn.prototype.dispose=function(){this.d()};function It(t,e){var n=new sn(t,e);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Xc,oa,ai,wy=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var Zc=[];It(function(){Xc=this.N})();function ln(t,e){H[t]=e.bind(null,H[t]||function(){})}function si(t){if(ai){var e=ai;ai=void 0,e()}ai=t&&t.S()}function Qc(t){var e=this,n=t.data,r=xy(n);r.name="ReactiveDom",r.value=n;var i=we(function(){for(var s=e,l=e.__v;l=l.__;)if(l.__c){l.__c.__$f|=4;break}var u=oi(function(){var f=r.value.value;return f===0?0:f===!0?"":f||""}),c=oi(function(){return!Array.isArray(u.value)&&!qi(u.value)}),h=It(function(){if(this.N=Jc,c.value){var f=u.value;s.__v&&s.__v.__e&&s.__v.__e.nodeType===3&&(s.__v.__e.data=f)}}),d=e.__$u.d;return e.__$u.d=function(){h(),d.call(this)},[c,u]},[]),o=i[0],a=i[1];return o.value?a.peek():a.value}Qc.displayName="ReactiveTextNode";Object.defineProperties(he.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Qc},props:{configurable:!0,get:function(){var t=this;return{data:{get value(){return t.value}}}}},__b:{configurable:!0,value:1}});ln("__b",function(t,e){if(typeof e.type=="string"){var n,r=e.props;for(var i in r)if(i!=="children"){var o=r[i];o instanceof he&&(n||(e.__np=n={}),n[i]=o,r[i]=o.peek())}}t(e)});ln("__r",function(t,e){if(t(e),e.type!==Me){si();var n,r=e.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=(function(i,o){var a;return It(function(){a=this},{name:o}),a.c=i,a})((function(i){return function(){var o;wy&&((o=this.y)==null||o.call(this)),i.__$f|=1,i.setState({})}})(r),typeof e.type=="function"?e.type.displayName||e.type.name:""))),oa=r,si(n)}});ln("__e",function(t,e,n,r){si(),oa=void 0,t(e,n,r)});ln("diffed",function(t,e){si(),oa=void 0;var n;if(typeof e.type=="string"&&(n=e.__e)){var r=e.__np,i=e.props,o=n.U;if(o)for(var a in o){var s=o[a];s===void 0||r&&a in r||(s.d(),o[a]=void 0)}if(r){o||(o={},n.U=o);for(var l in r){var u=o[l],c=r[l];u===void 0?(u=by(n,l,c,i),o[l]=u):u.o(c,i)}}}t(e)});function by(t,e,n,r){var i=e in t&&t.ownerSVGElement===void 0,o=$e(n);return{o:function(a,s){o.value=a,r=s},d:It(function(){this.N=Jc;var a=o.value.value;r[e]!==a&&(r[e]=a,i?t[e]=a:a!=null&&(a!==!1||e[4]==="-")?t.setAttribute(e,a):t.removeAttribute(e))})}}ln("unmount",function(t,e){if(typeof e.type=="string"){var n=e.__e;if(n){var r=n.U;if(r){n.U=void 0;for(var i in r){var o=r[i];o&&o.d()}}}var a=e.__np;if(a){var s=e.props;for(var l in a)s[l]=a[l]}e.__np=void 0}else{var u=e.__c;if(u){var c=u.__$u;c&&(u.__$u=void 0,c.d())}}t(e)});ln("__h",function(t,e,n,r){r<3&&(e.__$f|=2),t(e,n,r)});jt.prototype.shouldComponentUpdate=function(t,e){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in e)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var o=2&this.__$f;if(!(r||o||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var a in t)if(a!=="__source"&&t[a]!==this.props[a])return!0;for(var s in this.props)if(!(s in t))return!0;return!1};function xy(t,e){return we(function(){return $e(t,e)},[])}var _y=function(t){queueMicrotask(function(){queueMicrotask(t)})};function ky(){ra(function(){for(var t;t=Zc.shift();)Xc.call(t)})}function Jc(){Zc.push(this)===1&&(H.requestAnimationFrame||_y)(ky)}function Ey(){return{expanded:[]}}var Ue=$e(null),Ce=$e(null),Bn=$e(!1),Wn=$e(null),iS=$e(Ey()),un=$e("live"),cn=$e(new Set);function ed(t){let e=Uc(),n=!1,r=t.open(t.path??zc),i=o=>{let a=Bc(e,o,t.hasSelection());e=a.state,un.value=e.connection,$c(a.plan)||t.refetch(a.plan)};return r.addEventListener("open",()=>i({type:"open"})),r.addEventListener("error",()=>i({type:"error",readyState:r.readyState})),r.addEventListener(Ks,o=>{let a=Wc(o.data);a!==null&&i({type:"frame",event:a})}),{stop(){n||(n=!0,r.close(),i({type:"closed"}))},refresh(){i({type:"refresh"})},seen(o){e=Hc(e,o)},state(){return e}}}function td(t){return new EventSource(t)}function li(t,e=!1){return{ok:!0,data:t,cached:e}}function Te(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function aa(t){return t===403?"auth":t===404?"missing":"server"}function sa(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function la(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Te("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Te(aa(i.status),i.status,sa(i.status));let o;try{o=await i.json()}catch{return Te("malformed",i.status,"response was not valid JSON")}return n(o)?li(o):Te("malformed",i.status,"response did not match the expected shape")}function dt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Sy(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Ty(t){if(!dt(t)||typeof t.stamp!="string")return!1;let e=t.model;return!dt(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:dt(t.tags)&&dt(t.dangling)}function Ay(t){if(!dt(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return Sy(t.tags)}function ua(t){return dt(t)&&typeof t.revision=="string"&&Ay(t.note)}function Ry(t){return!dt(t)||typeof t.error!="string"?!1:t.reason==="collision"?typeof t.slug=="string":t.reason!=="conflict"?!1:ua(t.current)}function Cy(t){return dt(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function Ly(t){return dt(t)&&typeof t.opened=="boolean"}async function nd(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return Te("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Te("malformed",304,"server sent 304 for an unconditional request"):li(e,!0);if(!r.ok)return Te(aa(r.status),r.status,sa(r.status));let i;try{i=await r.json()}catch{return Te("malformed",r.status,"response was not valid JSON")}return Ty(i)?li(i):Te("malformed",r.status,"response did not match the expected shape")}function rd(t,e){return la(t,`/api/note/${encodeURIComponent(e)}`,ua)}function Ny(t,e=""){return`/api/note/${encodeURIComponent(t)}${e}`}function Py(t,e){return{method:t,headers:{"content-type":"application/json"},body:JSON.stringify(e)}}async function Dy(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Te("network",0,a instanceof Error?a.message:"network request failed")}if(i.status===409){let a;try{a=await i.json()}catch{return Te("malformed",409,"response was not valid JSON")}return Ry(a)?{ok:!1,kind:"conflict",status:409,message:a.error,conflict:a}:Te("malformed",409,"response did not match the expected shape")}if(!i.ok)return Te(aa(i.status),i.status,sa(i.status));let o;try{o=await i.json()}catch{return Te("malformed",i.status,"response was not valid JSON")}return n(o)?li(o):Te("malformed",i.status,"response did not match the expected shape")}function id(t,e,n){return Dy(t,Ny(e),ua,Py("POST",n))}function od(t,e){return la(t,`/api/search?q=${encodeURIComponent(e)}`,Cy)}function ad(t,e){return la(t,"/api/open",Ly,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function dn(){return{mode:"read",slug:null,baseline:"",draft:"",revision:null,status:"idle",message:null,saving:null,conflict:null,external:null,pending:null}}function hn(t){return t.mode==="edit"&&t.draft!==t.baseline}function ld(t){return hn(t)&&t.slug!==null&&t.status!=="saving"}function ae(t){return{state:t,effect:null}}function ca(t,e,n){return{...t,mode:n,slug:e.note.slug,baseline:e.note.body,draft:e.note.body,revision:e.revision,status:"idle",message:null,saving:null,conflict:null,external:null}}function Iy(t,e){return e.note.slug!==t.slug?ca(t,e,"read"):hn(t)&&e.revision!==t.revision?{...t,external:e}:ca(t,e,t.mode)}function ud(t,e){switch(e.type){case"loaded":return ae(Iy(t,e.payload));case"cleared":return ae(dn());case"toggle":return t.slug===null?ae(t):t.mode==="read"?ae({...t,mode:"edit",draft:t.baseline,status:"idle",message:null}):hn(t)?ae({...t,status:"error",message:cd}):ae({...t,mode:"read",status:"idle",message:null});case"draft":return ae({...t,draft:e.text,status:t.status==="saving"?"saving":"idle",message:null});case"save":return!ld(t)||t.slug===null||t.conflict!==null?ae(t):{state:{...t,status:"saving",message:null,saving:t.draft},effect:{type:"save",slug:t.slug,input:Gy(t)}};case"saved":return ae(My(t,e.payload));case"failed":return ae({...t,status:"error",message:e.message,saving:null});case"conflicted":return ae({...t,status:"error",message:e.conflict.error,saving:null,conflict:e.conflict});case"reload":return ae(Oy(t));case"overwrite":return Fy(t);case"dismiss":return ae({...t,conflict:null,external:null,status:"idle",message:null});case"navigate":return zy(t,e.id);case"discard":return t.pending===null?ae(t):{state:dn(),effect:{type:"select",id:t.pending.id}};case"stay":return ae({...t,pending:null});case"open":return t.slug===null?ae(t):{state:t,effect:{type:"open",slug:t.slug}};case"opened":return ae({...t,status:e.ok?"idle":"error",message:e.ok?Uy:Hy})}}function Gy(t){return t.revision===null?{body:t.draft}:{body:t.draft,expectedRevision:t.revision}}function My(t,e){let n=t.saving!==null&&t.saving!==t.draft;return{...t,slug:e.note.slug,baseline:e.note.body,draft:n?t.draft:e.note.body,revision:e.revision,status:"saved",message:$y,saving:null,conflict:null,external:null}}function Oy(t){let e=t.conflict?.reason==="conflict"?t.conflict.current:t.external;return e==null?t:ca(t,e,t.mode)}function Fy(t){return t.slug===null?ae(t):{state:{...t,status:"saving",message:null,saving:t.draft,conflict:null,external:null},effect:{type:"save",slug:t.slug,input:{body:t.draft}}}}function zy(t,e){return hn(t)?ae({...t,pending:{id:e}}):{state:t,effect:{type:"select",id:e}}}function da(t){return hn(t)}var $y="saved",cd="unsaved changes — save with the button, or discard them",Uy="opened in your editor",Hy="could not open the note in an editor",By="Edit",Wy="Done",Ky="Save",Vy="Saving…",dd="Open in $EDITOR",hd="Hand this note to $EDITOR (or your platform's opener)",jy="Discard changes",ui="Keep editing",sd="Reload from disk",qy="Overwrite",Yy="this note changed on disk while you were editing",Xy="pick a different name";function fd(t){let e=t.conflict;return e?.reason==="conflict"?{kind:"conflict",message:e.error,actions:[{label:sd,event:{type:"reload"}},{label:qy,event:{type:"overwrite"}},{label:ui,event:{type:"dismiss"}}]}:e?.reason==="collision"?{kind:"collision",message:`${e.error} (${e.slug}) — ${Xy}`,actions:[{label:ui,event:{type:"dismiss"}}]}:t.pending!==null?{kind:"discard",message:cd,actions:[{label:ui,event:{type:"stay"}},{label:jy,event:{type:"discard"}}]}:t.external!==null?{kind:"external",message:Yy,actions:[{label:sd,event:{type:"reload"}},{label:ui,event:{type:"dismiss"}}]}:null}function pd(t){let e=t.mode==="edit";return{toggleLabel:e?Wy:By,editing:e,saveLabel:t.status==="saving"?Vy:Ky,canSave:ld(t)&&t.conflict===null,message:t.message,tone:t.message===null?"none":t.status==="error"?"warn":"ok",dirty:hn(t)}}function gd(t){let e=dn(),n=i=>{let o=ud(e,i);e=o.state,t.onChange(e),o.effect!==null&&r(o.effect)},r=i=>{if(i.type==="select"){t.select(i.id);return}if(i.type==="open"){(async()=>{let o=await ad(t.fetch,i.slug);n({type:"opened",ok:o.ok&&o.data.opened})})();return}(async()=>{let o=await id(t.fetch,i.slug,i.input);if(o.ok){n({type:"saved",payload:o.data});return}n(o.kind==="conflict"?{type:"conflicted",conflict:o.conflict}:{type:"failed",message:o.message})})()};return{state:()=>e,send:n}}function md(t,e){let n=r=>{e()&&(r.preventDefault(),r.returnValue="")};return t.addEventListener("beforeunload",n),()=>t.removeEventListener("beforeunload",n)}var vd=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function yd(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function wd(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function bd(t){return t===null?!1:(t.focus(),!0)}function ci(){let t=le(null);return ne(()=>{let e=document.activeElement;return t.current?.focus(),()=>{bd(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!wd(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(vd)??[]],r=yd(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function Ed(t,e){let n=e.trim().toLowerCase();if(n==="")return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i===-1?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}var Zy=10;function Qy(t){return Math.min(Math.max(t,0),Zy)*2}function Jy(t){return`note:${t}`}function ew(t,e){return Ed(t.summary.title,e)+Qy(t.score)}function tw(t,e){return Ed(t.label,e)}var nw=["path","manifest","url","slug"];function rw(t){for(let e of nw){let n=t.detail[e];if(typeof n=="string"&&n!=="")return n}return""}function iw(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function ow(t,e,n,r){let i=new Map;for(let o of t){let a=Jy(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:ew(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=tw(o,r);a!==0&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:rw(o),badge:o.kind,score:a})}return[...i.values()].sort(iw).slice(0,20)}function di(){return{query:"",typedAt:0,issued:"",answered:"",seq:0,applied:0,hits:[],cursor:0,pending:!1,loading:!1,failed:!1}}var ha=140;function rt(t){return{state:t,request:null,schedule:null}}function xd(t,e){return e>t.applied}function Sd(t,e){switch(e.type){case"query":{let n={...t,query:e.query,typedAt:e.now,cursor:0};return e.query.trim()===""?rt({...n,hits:[],answered:"",issued:"",loading:!1,failed:!1,pending:!1}):t.pending?rt(n):{state:{...n,pending:!0},request:null,schedule:ha}}case"tick":{if(!t.pending)return rt(t);let n=e.now-t.typedAt;if(n<ha)return{state:t,request:null,schedule:ha-n};let r=t.query.trim();if(r===""||r===t.issued)return rt({...t,pending:!1});let i=t.seq+1;return{state:{...t,pending:!1,loading:!0,seq:i,issued:r},request:{seq:i,query:r},schedule:null}}case"response":return xd(t,e.seq)?rt({...t,applied:e.seq,hits:e.hits,answered:e.query,loading:e.seq<t.seq,failed:!1,cursor:0}):rt(t);case"failed":return xd(t,e.seq)?rt({...t,applied:e.seq,loading:e.seq<t.seq,failed:!0}):rt(t);case"cursor":return rt({...t,cursor:e.cursor});case"dismiss":return rt({...t,pending:!1})}}function fa(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function _d(t,e,n){return n<=0?0:((t+e)%n+n)%n}function Td(t,e){return e===null?null:t[e]?.id??null}function Ad(t,e,n){let r={state:t,activate:null,dismiss:!1,handled:!1},i=a=>({state:{...t,cursor:a},activate:null,dismiss:!1,handled:!0}),o=fa(t.cursor,n);return e==="ArrowDown"?i(_d(o,1,n)):e==="ArrowUp"?i(_d(o,-1,n)):e==="Home"?i(0):e==="End"?i(fa(n-1,n)):e==="Escape"?{state:t,activate:null,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{state:t,activate:o,dismiss:!0,handled:!0}}var hi="Search the workspace",Rd="Search notes and repository…",Cd="↑↓ move · ↵ open · esc close";function aw(t,e){return t.query.trim()===""?"Type to search notes, modules, files and entry points.":e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading||t.pending?"searching…":`no matches for “${t.query.trim()}”`}function sw(t){return t===1?"1 result":`${t} results`}function kd(t){return`weave-search-row-${t}`}function Ld(t,e){let n=ow(t.hits,t.answered,e?.model.nodes??[],t.query),r=fa(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:kd(a)})),status:aw(t,n.length),count:n.length,countLabel:sw(n.length),cursor:r,activeDomId:n.length===0?null:kd(r)}}function Nd(t){let e=di(),n=r=>{let i=Sd(e,r);e=i.state,t.onChange(e),i.schedule!==null&&t.delay(()=>n({type:"tick",now:t.now()}),i.schedule);let o=i.request;o!==null&&(async()=>{let a=await od(t.fetch,o.query);n(a.ok?{type:"response",seq:o.seq,query:o.query,hits:a.data.hits}:{type:"failed",seq:o.seq})})()};return{state:()=>e,setQuery:r=>n({type:"query",query:r,now:t.now()}),setCursor:r=>n({type:"cursor",cursor:r}),dismiss:()=>n({type:"dismiss"})}}var lw=0;function x(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lw,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return H.vnode&&H.vnode(u),u}function uw({row:t,onPick:e,onHover:n}){return x("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[x("span",{class:"weave-hit-badge",children:t.badge}),x("span",{class:"weave-hit-label",children:t.label}),x("span",{class:"weave-hit-detail",children:t.detail})]})}function Pd(t){let[e,n]=Ne(di),r=we(()=>Nd({...t.ports,onChange:n}),[]),i=ci(),o=le(null);ne(()=>{o.current?.focus()},[]);let a=Ld(e,t.graph),s=l=>{let u=Td(a.rows,l);u!==null&&t.onSelect(u),r.dismiss(),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>s(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":hi,tabIndex:-1,ref:i.ref,onClick:l=>l.stopPropagation(),onKeyDown:l=>{if(i.onKeyDown(l))return;let u=Ad(e,l.key,a.count);u.handled&&(l.preventDefault(),r.setCursor(u.state.cursor),u.dismiss&&s(u.activate))},children:[x("input",{type:"search",class:"weave-palette-input",ref:o,value:e.query,placeholder:Rd,"aria-label":hi,"aria-controls":"weave-search-results","aria-activedescendant":a.activeDomId??void 0,onInput:l=>r.setQuery(l.currentTarget.value)}),a.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":hi,children:a.rows.map((l,u)=>x(uw,{row:l,onPick:()=>s(u),onHover:()=>r.setCursor(u)},l.id))}):x("p",{class:"weave-palette-status",role:"status",children:a.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:a.countLabel}),x("span",{class:"weave-palette-hint",children:Cd})]})]})})}var Dd="pi-weave.selection.v1";function Id(t,e){try{return t.setItem(Dd,e??""),!0}catch{return!1}}function Gd(t,e){if(t===null)return null;let n;try{n=e.getItem(Dd)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}var cw=3e3,pa=new Set;function dw(t,e){if(t===null)return pa;let n=new Set(t.model.nodes.map(i=>i.id)),r=new Set;for(let i of e.model.nodes)n.has(i.id)||r.add(i.id);return r}var fi=null;function Od(t){return fi=t,()=>{fi===t&&(fi=null)}}async function Md(t,e,n){let r=Ce.value,i=await nd(t,Ce.value);return i.ok?(Bn.value=!1,i.cached||(Ce.value=i.data,n?.(r,i.data)),e?.seen(i.data.stamp),i):(Ce.value===null&&(Bn.value=!0),i)}async function ga(t){let e=Fd(Ue.value);if(e===null){Wn.value=null;return}let n=await rd(t,e);n.ok&&(Wn.value=n.data,fi?.(n.data))}function Fd(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function zd(t){let e=null,n=null,r=t.defer??((a,s)=>{let l=setTimeout(a,s);return()=>clearTimeout(l)}),i=(a,s)=>{let l=dw(a,s);cn.value=l,n?.(),n=null,l.size>0&&(n=r(()=>{n=null,cn.value=pa},cw))},o=a=>{(async()=>(a.graph&&await Md(t.fetch,e,i),a.note&&await ga(t.fetch)))()};return e=ed({open:t.open,refetch:o,hasSelection:()=>Fd(Ue.value)!==null,...t.path===void 0?{}:{path:t.path}}),Md(t.fetch,e,i),{refresh(){e?.refresh()},syncNote(){return ga(t.fetch)},stop(){e?.stop(),e=null,n?.(),n=null,cn.value=pa}}}function pi(t,e){return Ue.value=e,ga(t)}function $d(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var hw=300,fw=1;function pw(t,e,n){let r=new Map(n??[]);if(r.size>0)for(let o of e){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:hw,seed:fw,pinWarm:!0};return r.size>0&&(i.initial=r),Vu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function gw(t,e){let n=0,r=0;for(let o of t){let a=$d(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=$d(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Hd="pi-weave.graph.positions.v2";function Ud(t){return Math.round(t*10)/10}function mw(t,e){let n={};for(let[r,i]of e)n[r]=[Ud(i.x),Ud(i.y)];return JSON.stringify({v:2,key:t,at:n})}function vw(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==2||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function yw(t,e){let n;try{n=t.getItem(Hd)}catch{return null}return vw(n,e)}function ww(t,e,n){try{return t.setItem(Hd,mw(e,n)),!0}catch{return!1}}function Bd(t,e,n){let r=gw(e,n),i=yw(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=pw(e,n);return ww(t,r,o),{key:r,positions:o,cached:!1}}function bw(t){return{expanded:new Set(Br(t,new Set).clusters.keys())}}function Kd(t,e){return e!==null?e:t===null?{expanded:new Set}:bw(Nt(t))}function xw(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function _w(t,e){return{...t,expanded:new Set(e.keys())}}function kw(t){return{...t,expanded:new Set}}function Ew(t,e){return e===null?null:Bo(e,t)}function Vd(t){return t?"collapse":"expand"}function jd(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function ma(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function qd(t,e){return ma(t,e)?kw(t):_w(t,e)}var Yd="fit",Xd="frame the whole graph",gi={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Zd(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function Sw(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var Tw="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Wd={graph:mc,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Qd(t,e,n,r,i,o=!1){if(t===null)return o?{...Wd,empty:Tw}:Wd;let a=Nt(t),s=Br(a,n.expanded),l=Bd(r,s.nodes,s.edges);return{graph:yc(s.nodes,s.edges,l.positions,i),highlight:Ew(s.edges,e),key:l.key,cached:l.cached,clusters:s.clusters,visible:s.nodes.length,total:a.nodes.length,empty:Sw(t,s.nodes.length)}}function Jd(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:xw(t,n),selectedId:n}}var Aw=.06,Rw=.2,va=.001;function eh(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(u=>{let c=e?.get(u.id);return{id:u.id,x:c!==void 0&&Number.isFinite(c.x)?c.x:u.x,y:c!==void 0&&Number.isFinite(c.y)?c.y:u.y,vx:0,vy:0}}),r=new Map(n.map(u=>[u.id,u])),i=new Set,o=[];for(let u of t.edges){if(u.source===u.target||!r.has(u.source)||!r.has(u.target))continue;let c=`${u.source}\0${u.target}\0${u.kind}`;i.has(c)||(i.add(c),o.push({source:u.source,target:u.target,kind:u.kind}))}let a=new Map;for(let u of t.nodes)a.set(u.id,{x:u.x,y:u.y});let s=new Map(Oo(t,a)),l=Fo({nodes:n,links:o,anchors:s,seed:1}).alpha(Aw).alphaMin(va);return{tick(){l.tick()},awake(){return l.alphaTarget()>va||l.alpha()>va},positions(){return new Map(n.map(u=>[u.id,{x:u.x??0,y:u.y??0}]))},pin(u,c){let h=r.get(u);h&&(h.fx=c.x,h.fy=c.y,l.alphaTarget(Rw))},release(u){let c=r.get(u);c&&(s.set(u,{x:c.x??0,y:c.y??0}),c.fx=null,c.fy=null,l.alphaTarget(0))}}}function th(t){let e=le(null),n=le(null),r=le(null),i=le(null),o=ol(()=>{if(i.current!==null)return;let f=()=>{i.current=null;let g=r.current;g!==null&&(g.tick(),g.awake()&&(n.current?.setPositions(g.positions()),i.current=requestAnimationFrame(f)))};i.current=requestAnimationFrame(f)},[]),[a,s]=Ne(null),l=t.scheme??kr(t.host),u=Kd(t.graph,a),c=we(()=>Qd(t.graph,t.selectedId,u,t.storage,l,t.bootFailed),[t.graph,t.selectedId,u,t.storage,l,t.bootFailed]),h=ma(u,c.clusters),d=le({view:u,model:c,onSelect:t.onSelect});return d.current={view:u,model:c,onSelect:t.onSelect},ne(()=>{let f=t.renderer(l);return f.onSelect(g=>{let m=Jd(d.current.view,d.current.model.clusters,g);s(m.state),d.current.onSelect(m.selectedId)}),f.onDragStart(g=>{let m=n.current?.positions().get(g);m&&(r.current?.pin(g,m),o())}),f.onDragMove((g,m)=>{r.current?.pin(g,m)}),f.onDragEnd(g=>{r.current?.release(g)}),f.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=f,f.setGraph(d.current.model.graph),f.setHighlight(d.current.model.highlight),t.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,t.fit.current=null}},[t.renderer,l]),ne(()=>{n.current?.setGraph(c.graph)},[c.key]),ne(()=>{let f=eh(c.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[c.key,o]),ne(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ne(()=>{n.current?.setHighlight(c.highlight)},[c.highlight]),x("div",{class:"weave-graph",children:[c.empty===null?null:x("p",{class:"weave-graph-empty",children:c.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Xd,onClick:()=>n.current?.fit(),children:Yd}),x("button",{type:"button",class:"weave-chip",title:jd(h),onClick:()=>s(qd(u,c.clusters)),children:Vd(h)}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",gi.selected]}),x("span",{class:"weave-legend-near",children:["● ",gi.neighborhood]}),x("span",{class:"weave-legend-dim",children:["· ",gi.dimmed]})]})]}),x("p",{class:"weave-graph-count",children:Zd(c.visible,c.total)})]})}function nh(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Cw(t){if(Array.isArray(t))return t}function Lw(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Nw(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
335
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pw(t,e){return Cw(t)||Lw(t,e)||Dw(t,e)||Nw()}function Dw(t,e){if(t){if(typeof t=="string")return nh(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nh(t,e):void 0}}var vh=Object.entries,rh=Object.setPrototypeOf,Iw=Object.isFrozen,Gw=Object.getPrototypeOf,Mw=Object.getOwnPropertyDescriptor,fe=Object.freeze,me=Object.seal,fn=Object.create,yh=typeof Reflect<"u"&&Reflect,Ea=yh.apply,Sa=yh.construct;fe||(fe=function(e){return e});me||(me=function(e){return e});Ea||(Ea=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});Sa||(Sa=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Mt=se(Array.prototype.forEach),Ow=se(Array.prototype.lastIndexOf),ih=se(Array.prototype.pop),Kn=se(Array.prototype.push),Fw=se(Array.prototype.splice),pn=Array.isArray,qn=se(String.prototype.toLowerCase),ya=se(String.prototype.toString),oh=se(String.prototype.match),Vn=se(String.prototype.replace),ah=se(String.prototype.indexOf),zw=se(String.prototype.trim),$w=se(Number.prototype.toString),Uw=se(Boolean.prototype.toString),sh=typeof BigInt>"u"?null:se(BigInt.prototype.toString),lh=typeof Symbol>"u"?null:se(Symbol.prototype.toString),Le=se(Object.prototype.hasOwnProperty),jn=se(Object.prototype.toString),be=se(RegExp.prototype.test),Gt=Hw(TypeError);function se(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Ea(t,e,r)}}function Hw(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Sa(t,n)}}function B(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:qn;if(rh&&rh(t,null),!pn(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(Iw(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Bw(t){for(let e=0;e<t.length;e++)Le(t,e)||(t[e]=null);return t}function Ie(t){let e=fn(null);for(let r of vh(t)){var n=Pw(r,2);let i=n[0],o=n[1];Le(t,i)&&(pn(o)?e[i]=Bw(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Ie(o):e[i]=o)}return e}function Ww(t){switch(typeof t){case"string":return t;case"number":return $w(t);case"boolean":return Uw(t);case"bigint":return sh?sh(t):"0";case"symbol":return lh?lh(t):"Symbol()";case"undefined":return jn(t);case"function":case"object":{if(t===null)return jn(t);let e=t,n=qe(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:jn(r)}return jn(t)}default:return jn(t)}}function qe(t,e){for(;t!==null;){let r=Mw(t,e);if(r){if(r.get)return se(r.get);if(typeof r.value=="function")return se(r.value)}t=Gw(t)}function n(){return null}return n}function Kw(t){try{return be(t,""),!0}catch{return!1}}var uh=fe(["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"]),wa=fe(["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"]),ba=fe(["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"]),Vw=fe(["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"]),xa=fe(["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"]),jw=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ch=fe(["#text"]),dh=fe(["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"]),_a=fe(["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"]),hh=fe(["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"]),mi=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),qw=me(/{{[\w\W]*|^[\w\W]*}}/g),Yw=me(/<%[\w\W]*|^[\w\W]*%>/g),Xw=me(/\${[\w\W]*/g),Zw=me(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qw=me(/^aria-[\-\w]+$/),fh=me(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Jw=me(/^(?:\w+script|data):/i),eb=me(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tb=me(/^html$/i),nb=me(/^[a-z][.\w]*(-[.\w]+)+$/i),ph=me(/<[/\w!]/g),gh=me(/<[/\w]/g),rb=me(/<\/no(script|embed|frames)/i),ib=me(/\/>/i),De={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},wh=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ob=fe(B({},wh)),ab=(function(){let t={};return Mt(wh,e=>{t[e]=me(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),fe(t)})(),sb=function(){return typeof window>"u"?null:window},lb=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},mh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},wt=function(e,n,r,i){return Le(e,n)&&pn(e[n])?B(i.base?Ie(i.base):{},e[n],i.transform):r},ka=function(e,n,r){let i=Le(e,n)?e[n]:void 0;return i&&typeof i=="object"?Ie(i):r()};function bh(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sb(),e=T=>bh(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==De.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=qe(d,"cloneNode"),g=qe(d,"remove"),m=qe(d,"nextSibling"),v=qe(d,"childNodes"),y=qe(d,"parentNode"),w=qe(d,"shadowRoot"),k=qe(d,"attributes"),_=a&&a.prototype?qe(a.prototype,"nodeType"):null,A=a&&a.prototype?qe(a.prototype,"nodeName"):null,N=a&&a.prototype?qe(a.prototype,"ownerDocument"):null,I=function(p){return _?_(p):p.nodeType},z=function(p){return A?A(p):p.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let F,G="",U,j=!1,J=0,ve=function(){if(J>0)throw Gt('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.')},pe=function(p){ve(),J++;try{return F.createHTML(p)}finally{J--}},Qe=function(p){ve(),J++;try{return F.createScriptURL(p)}finally{J--}},$t=function(){return j||(U=lb(h,i),j=!0),U},He=n,Be=He.implementation,We=He.createNodeIterator,Je=He.createDocumentFragment,vn=He.getElementsByTagName,Ge=r.importNode,q=mh();e.isSupported=typeof vh=="function"&&typeof y=="function"&&Be&&Be.createHTMLDocument!==void 0;let yn=qw,Xf=Yw,Zf=Xw,Qf=Zw,Jf=Qw,ep=Jw,Qa=eb,tp=nb,Ja=fh,X=null,Li=B({},[...uh,...wa,...ba,...xa,...ch]),Z=null,Ni=B({},[...dh,..._a,...hh,...mi]),et=Object.seal(fn(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}})),wn=null,es=null,ft=Object.seal(fn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ts=!0,Pi=!0,ns=!1,rs=!0,pt=!1,xt=!0,_t=!1,Di=!1,tr=null,nr=null,Ii=!1,Ut=!1,rr=!1,ir=!1,is=!0,os=!1,as="user-content-",Gi=!0,Mi=!1,Ht={},Bt=null,ss=B({},["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"]),ls=null,us=B({},["audio","video","img","source","image","track"]),cs=null,ds=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),or="http://www.w3.org/1998/Math/MathML",ar="http://www.w3.org/2000/svg",tt="http://www.w3.org/1999/xhtml",Wt=tt,Oi=!1,Fi=null,np=B({},[or,ar,tt],ya),hs=fe(["mi","mo","mn","ms","mtext"]),zi=B({},hs),fs=fe(["annotation-xml"]),$i=B({},fs),rp=B({},["title","style","font","a","script"]),bn=null,ip=["application/xhtml+xml","text/html"],op="text/html",re=null,Kt=null,ap=n.createElement("form"),ps=function(p){return p instanceof RegExp||p instanceof Function},Ui=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Kt&&Kt===p)return;(!p||typeof p!="object")&&(p={}),p=Ie(p),bn=ip.indexOf(p.PARSER_MEDIA_TYPE)===-1?op:p.PARSER_MEDIA_TYPE,re=bn==="application/xhtml+xml"?ya:qn,X=wt(p,"ALLOWED_TAGS",Li,{transform:re}),Z=wt(p,"ALLOWED_ATTR",Ni,{transform:re}),Fi=wt(p,"ALLOWED_NAMESPACES",np,{transform:ya}),cs=wt(p,"ADD_URI_SAFE_ATTR",ds,{transform:re,base:ds}),ls=wt(p,"ADD_DATA_URI_TAGS",us,{transform:re,base:us}),Bt=wt(p,"FORBID_CONTENTS",ss,{transform:re}),wn=wt(p,"FORBID_TAGS",Ie({}),{transform:re}),es=wt(p,"FORBID_ATTR",Ie({}),{transform:re}),Ht=Le(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Ie(p.USE_PROFILES):p.USE_PROFILES:!1,ts=p.ALLOW_ARIA_ATTR!==!1,Pi=p.ALLOW_DATA_ATTR!==!1,ns=p.ALLOW_UNKNOWN_PROTOCOLS||!1,rs=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,pt=p.SAFE_FOR_TEMPLATES||!1,xt=p.SAFE_FOR_XML!==!1,_t=p.WHOLE_DOCUMENT||!1,Ut=p.RETURN_DOM||!1,rr=p.RETURN_DOM_FRAGMENT||!1,ir=p.RETURN_TRUSTED_TYPE||!1,Ii=p.FORCE_BODY||!1,is=p.SANITIZE_DOM!==!1,os=p.SANITIZE_NAMED_PROPS||!1,Gi=p.KEEP_CONTENT!==!1,Mi=p.IN_PLACE||!1,Ja=Kw(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:fh,Wt=typeof p.NAMESPACE=="string"?p.NAMESPACE:tt,zi=ka(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},hs)),$i=ka(p,"HTML_INTEGRATION_POINTS",()=>B({},fs));let b=ka(p,"CUSTOM_ELEMENT_HANDLING",()=>fn(null));if(et=fn(null),Le(b,"tagNameCheck")&&ps(b.tagNameCheck)&&(et.tagNameCheck=b.tagNameCheck),Le(b,"attributeNameCheck")&&ps(b.attributeNameCheck)&&(et.attributeNameCheck=b.attributeNameCheck),Le(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),me(et),pt&&(Pi=!1),rr&&(Ut=!0),Ht&&(X=B({},ch),Z=fn(null),Ht.html===!0&&(B(X,uh),B(Z,dh)),Ht.svg===!0&&(B(X,wa),B(Z,_a),B(Z,mi)),Ht.svgFilters===!0&&(B(X,ba),B(Z,_a),B(Z,mi)),Ht.mathMl===!0&&(B(X,xa),B(Z,hh),B(Z,mi))),ft.tagCheck=null,ft.attributeCheck=null,Le(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?ft.tagCheck=p.ADD_TAGS:pn(p.ADD_TAGS)&&(X===Li&&(X=Ie(X)),B(X,p.ADD_TAGS,re))),Le(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?ft.attributeCheck=p.ADD_ATTR:pn(p.ADD_ATTR)&&(Z===Ni&&(Z=Ie(Z)),B(Z,p.ADD_ATTR,re))),Le(p,"ADD_FORBID_CONTENTS")&&pn(p.ADD_FORBID_CONTENTS)&&(Bt===ss&&(Bt=Ie(Bt)),B(Bt,p.ADD_FORBID_CONTENTS,re)),Gi&&(X["#text"]=!0),_t&&B(X,["html","head","body"]),X.table&&(B(X,["tbody"]),delete wn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=F;F=p.TRUSTED_TYPES_POLICY;try{G=pe("")}catch(C){throw F=E,C}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=$t()),F&&typeof G=="string"&&(G=pe("")));fe&&fe(p),Kt=p},gs=B({},[...wa,...ba,...Vw]),ms=B({},[...xa,...jw]),sp=function(p,b,E){return b.namespaceURI===tt?p==="svg":b.namespaceURI===or?p==="svg"&&(E==="annotation-xml"||zi[E]):!!gs[p]},lp=function(p,b,E){return b.namespaceURI===tt?p==="math":b.namespaceURI===ar?p==="math"&&$i[E]:!!ms[p]},up=function(p,b,E){return b.namespaceURI===ar&&!$i[E]||b.namespaceURI===or&&!zi[E]?!1:!ms[p]&&(rp[p]||!gs[p])},cp=function(p){let b=y(p);(!b||!b.tagName)&&(b={namespaceURI:Wt,tagName:"template"});let E=qn(p.tagName),C=qn(b.tagName);return Fi[p.namespaceURI]?p.namespaceURI===ar?sp(E,b,C):p.namespaceURI===or?lp(E,b,C):p.namespaceURI===tt?up(E,b,C):!!(bn==="application/xhtml+xml"&&Fi[p.namespaceURI]):!1},gt=function(p){Kn(e.removed,{element:p});try{y(p).removeChild(p)}catch{if(g(p),!y(p))throw Gt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},vs=function(p,b,E){try{p.removeAttributeNode(b)}catch{try{p.removeAttribute(E)}catch{}}},sr=function(p){lr(p);let b=v(p);if(b){let C=[];Mt(b,D=>{Kn(C,D)}),Mt(C,D=>{try{g(D)}catch{}})}let E=k(p);if(E)for(let C=E.length-1;C>=0;--C){let D=E[C],O=D&&D.name;typeof O=="string"&&vs(p,D,O)}},kt=function(p,b,E){if(!E)try{E=b.getAttributeNode(p)}catch{E=null}Kn(e.removed,{attribute:E||null,from:b});try{E?b.removeAttributeNode(E):b.removeAttribute(p)}catch{try{b.removeAttribute(p)}catch{}}if(p==="is")if(Ut||rr)try{gt(b)}catch{}else try{b.setAttribute(p,"")}catch{}},dp=function(p){let b=k(p);if(b)for(let E=b.length-1;E>=0;--E){let C=b[E],D=C&&C.name;typeof D!="string"||Z[re(D)]||vs(p,C,D)}},lr=function(p){let b=[p];for(;b.length>0;){let E=b.pop();I(E)===De.element&&dp(E);let D=v(E);if(D)for(let O=D.length-1;O>=0;--O)b.push(D[O])}},ys=function(p,b){return xt?p==="patchsrc"?!0:p==="for"&&b!=="label"&&b!=="output":!1},hp=function(p){if(!xt)return;let b=[p];for(;b.length>0;){let E=b.pop(),C=I(E);if(C===De.processingInstruction||C===De.comment&&be(gh,E.data)){try{g(E)}catch{}continue}if(C===De.element){let O=E,Y=re(z(E));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&ys("for",Y)&&O.removeAttribute("for")}catch{}}let D=v(E);if(D)for(let O=D.length-1;O>=0;--O)b.push(D[O])}},ws=function(p){let b=null,E=null;if(Ii)p="<remove></remove>"+p;else{let O=oh(p,/^[\r\n\t ]+/);E=O&&O[0]}bn==="application/xhtml+xml"&&Wt===tt&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let C=F?pe(p):p;if(Wt===tt)try{b=new c().parseFromString(C,bn)}catch{}if(!b||!b.documentElement){b=Be.createDocument(Wt,"template",null);try{b.documentElement.innerHTML=Oi?G:C}catch{}}let D=b.body||b.documentElement;return p&&E&&D.insertBefore(n.createTextNode(E),D.childNodes[0]||null),Wt===tt?vn.call(b,_t?"html":"body")[0]:_t?b.documentElement:D},bs=function(p){let b=N?N(p):p.ownerDocument;return We.call(b||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},ur=function(p){return p=Vn(p,yn," "),p=Vn(p,Xf," "),p=Vn(p,Zf," "),p},Hi=function(p){var b;p.normalize();let E=N?N(p):p.ownerDocument,C=We.call(E||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),D=C.nextNode();for(;D;)D.data=ur(D.data),D=C.nextNode();let O=(b=p.querySelectorAll)===null||b===void 0?void 0:b.call(p,"template");O&&Mt(O,Y=>{Vt(Y.content)&&Hi(Y.content)})},cr=function(p){let b=A?A(p):null;return typeof b!="string"||re(b)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==k(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==_(p)||p.childNodes!==v(p)},Vt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===De.documentFragment}catch{return!1}},xn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function nt(T,p,b){T.length!==0&&Mt(T,E=>{E.call(e,p,b,Kt)})}let fp=function(p,b){return!!(xt&&p.hasChildNodes()&&!xn(p.firstElementChild)&&be(ph,p.textContent)&&be(ph,p.innerHTML)||xt&&p.namespaceURI===tt&&ob[b]&&(xn(p.firstElementChild)||typeof p.textContent=="string"&&be(ab[b],p.textContent))||p.nodeType===De.processingInstruction||xt&&p.nodeType===De.comment&&be(gh,p.data))},dr=function(p,b){if(p instanceof RegExp)return be(p,b);if(p instanceof Function){for(var E=arguments.length,C=new Array(E>2?E-2:0),D=2;D<E;D++)C[D-2]=arguments[D];return!!p(b,...C)}return!1},pp=function(p,b,E){if(!wn[b]&&Ss(b)&&dr(et.tagNameCheck,b))return!1;if(Gi&&!Bt[b]){let C=y(p),D=v(p);if(D&&C){let O=D.length;for(let Y=O-1;Y>=0;--Y){let ee=p===E?f(D[Y],!0):D[Y];C.insertBefore(ee,m(p))}}}return gt(p),!0},xs=function(p,b,E,C){return p.length===0?b:b===E||b===C?Ie(b):b},_s=function(p,b){return p===b||y(p)!==null?!1:(Mi&&lr(p),!0)},ks=function(p,b){if(nt(q.beforeSanitizeElements,p,null),_s(p,b))return!0;if(cr(p))return gt(p),!0;let E=re(z(p));if(X=xs(q.uponSanitizeElement,X,Li,tr),nt(q.uponSanitizeElement,p,{tagName:E,allowedTags:X}),_s(p,b))return!0;if(fp(p,E))return gt(p),!0;if(wn[E]||!(ft.tagCheck instanceof Function&&ft.tagCheck(E))&&!X[E]){let D=pp(p,E,b);return D===!1&&nt(q.afterSanitizeElements,p,null),D}if(I(p)===De.element&&!cp(p)||(E==="noscript"||E==="noembed"||E==="noframes")&&be(rb,p.innerHTML))return gt(p),!0;if(pt&&p.nodeType===De.text){let D=ur(p.textContent);p.textContent!==D&&(Kn(e.removed,{element:p.cloneNode()}),p.textContent=D)}return nt(q.afterSanitizeElements,p,null),!1},Es=function(p,b,E){if(es[b]||ys(b,p)||is&&(b==="id"||b==="name")&&(E in n||E in ap))return!1;let C=Z[b]||ft.attributeCheck instanceof Function&&ft.attributeCheck(b,p);return Pi&&be(Qf,b)||ts&&be(Jf,b)?!0:C?cs[b]||be(Ja,Vn(E,Qa,""))||(b==="src"||b==="xlink:href"||b==="href")&&p!=="script"&&ah(E,"data:")===0&&ls[p]||ns&&!be(ep,Vn(E,Qa,""))?!0:!E:Ss(p)&&dr(et.tagNameCheck,p)&&dr(et.attributeNameCheck,b,p)||b==="is"&&et.allowCustomizedBuiltInElements&&dr(et.tagNameCheck,E)},gp=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ss=function(p){return!gp[qn(p)]&&be(tp,p)},mp=function(p,b,E,C){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(p,b)){case"TrustedHTML":return pe(C);case"TrustedScriptURL":return Qe(C)}return C},vp=function(p,b,E,C){try{E?p.setAttributeNS(E,b,C):p.setAttribute(b,C),cr(p)?gt(p):ih(e.removed)}catch{kt(b,p)}},Ts=function(p){nt(q.beforeSanitizeAttributes,p,null);let b=p.attributes;if(!b||cr(p))return;Z=xs(q.uponSanitizeAttribute,Z,Ni,nr);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},C=b.length,D=re(p.nodeName);for(;C--;){let O=b[C],Y=O.name,ee=O.namespaceURI,Ae=O.value,Re=re(Y),Wi=Ae,_e=Y==="value"?Wi:zw(Wi);if(E.attrName=Re,E.attrValue=_e,E.keepAttr=!0,E.forceKeepAttr=void 0,nt(q.uponSanitizeAttribute,p,E),_e=E.attrValue,os&&(Re==="id"||Re==="name")&&ah(_e,as)!==0&&(kt(Y,p,O),_e=as+_e),xt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,_e)){kt(Y,p,O);continue}if(Re==="attributename"&&oh(_e,"href")){kt(Y,p,O);continue}if(!E.forceKeepAttr){if(!E.keepAttr){kt(Y,p,O);continue}if(!rs&&be(ib,_e)){kt(Y,p,O);continue}if(pt&&(_e=ur(_e)),!Es(D,Re,_e)){kt(Y,p,O);continue}_e=mp(D,Re,ee,_e),_e!==Wi&&vp(p,Y,ee,_e)}}nt(q.afterSanitizeAttributes,p,null)},hr=function(p){let b=null,E=bs(p);for(nt(q.beforeSanitizeShadowDOM,p,null);b=E.nextNode();)if(nt(q.uponSanitizeShadowNode,b,null),ks(b,p),Ts(b),Vt(b.content)&&hr(b.content),I(b)===De.element){let C=w(b);Vt(C)&&(Bi(C),hr(C))}nt(q.afterSanitizeShadowDOM,p,null)},Bi=function(p){let b=[{node:p,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){hr(E.shadow);continue}let C=E.node,O=I(C)===De.element,Y=v(C);if(Y)for(let ee=Y.length-1;ee>=0;--ee)b.push({node:Y[ee],shadow:null});if(O){let ee=A?A(C):null;if(typeof ee=="string"&&re(ee)==="template"){let Ae=C.content;Vt(Ae)&&b.push({node:Ae,shadow:null})}}if(O){let ee=w(C);Vt(ee)&&b.push({node:null,shadow:ee},{node:ee,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,C=null,D=null;if(Oi=!T,Oi&&(T="<!-->"),typeof T!="string"&&!xn(T)&&(T=Ww(T),typeof T!="string"))throw Gt("dirty is not a string, aborting");if(!e.isSupported)return T;Di?(X=tr,Z=nr):Ui(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Ie(X)),q.uponSanitizeAttribute.length>0&&(Z=Ie(Z)),e.removed=[];let O=Mi&&typeof T!="string"&&xn(T);if(O){hp(T);let Ae=z(T);if(typeof Ae=="string"){let Re=re(Ae);if(!X[Re]||wn[Re])throw sr(T),Gt("root node is forbidden and cannot be sanitized in-place")}if(cr(T))throw sr(T),Gt("root node is clobbered and cannot be sanitized in-place");try{Bi(T)}catch(Re){throw sr(T),Re}}else if(xn(T))b=ws("<!---->"),E=b.ownerDocument.importNode(T,!0),E.nodeType===De.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),Bi(E);else{if(!Ut&&!pt&&!_t&&T.indexOf("<")===-1)return F&&ir?pe(T):T;if(b=ws(T),!b)return Ut?null:ir?G:""}b&&Ii&&gt(b.firstChild);let Y=O?T:b;try{let Ae=bs(Y);for(;C=Ae.nextNode();)ks(C,Y),Ts(C),Vt(C.content)&&hr(C.content)}catch(Ae){throw O&&(sr(T),Mt(e.removed,Re=>{Re.element&&lr(Re.element)})),Ae}if(O)return Mt(e.removed,Ae=>{Ae.element&&lr(Ae.element)}),pt&&Hi(T),T;if(Ut){if(pt&&Hi(b),rr)for(D=Je.call(b.ownerDocument);b.firstChild;)D.appendChild(b.firstChild);else D=b;return(Z.shadowroot||Z.shadowrootmode)&&(D=Ge.call(r,D,!0)),D}let ee=_t?b.outerHTML:b.innerHTML;return _t&&X["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(tb,b.ownerDocument.doctype.name)&&(ee="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
336
+ `+ee),pt&&(ee=ur(ee)),F&&ir?pe(ee):ee},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ui(T),Di=!0,tr=X,nr=Z},e.clearConfig=function(){Kt=null,Di=!1,tr=null,nr=null,F=U,G=""},e.isValidAttribute=function(T,p,b){Kt||Ui({});let E=re(T),C=re(p);return Es(E,C,b)},e.addHook=function(T,p){typeof p=="function"&&Le(q,T)&&Kn(q[T],p)},e.removeHook=function(T,p){if(Le(q,T)){if(p!==void 0){let b=Ow(q[T],p);return b===-1?void 0:Fw(q[T],b,1)[0]}return ih(q[T])}},e.removeHooks=function(T){Le(q,T)&&(q[T]=[])},e.removeAllHooks=function(){q=mh()},e}var xh=bh();function ub({prompt:t,send:e}){return x("div",{class:`weave-note-prompt weave-note-prompt-${t.kind}`,role:"alert",children:[x("p",{class:"weave-note-prompt-text",children:t.message}),x("p",{class:"weave-note-prompt-actions",children:t.actions.map(n=>x("button",{type:"button",class:"weave-note-action",onClick:()=>e(n.event),children:n.label},n.label))})]})}function _h(t){let{toolbar:e,send:n}=t;return x("div",{class:"weave-note-bar",children:[e.editing?x("button",{type:"button",class:"weave-note-toggle","aria-pressed":e.editing,onClick:()=>n({type:"toggle"}),children:e.toggleLabel}):null,e.editing?x("button",{type:"button",class:"weave-note-save",disabled:!e.canSave,onClick:()=>n({type:"save"}),children:e.saveLabel}):null,x("button",{type:"button",class:"weave-note-open",title:hd,onClick:()=>n({type:"open"}),children:dd}),e.dirty?x("span",{class:"weave-note-dirty",title:"unsaved changes","aria-hidden":"true",children:"•"}):null,e.message===null?null:x("span",{class:`weave-note-status weave-note-status-${e.tone}`,children:e.message}),t.prompt===null?null:x(ub,{prompt:t.prompt,send:n})]})}function kh(t){return x("textarea",{class:"weave-note-editor","aria-label":"Note body",spellcheck:!0,value:t.draft,onInput:e=>t.send({type:"draft",text:e.target.value}),onKeyDown:e=>{e.key.toLowerCase()!=="s"||!(e.metaKey||e.ctrlKey)||(e.preventDefault(),t.send({type:"save"}))}})}function Ca(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var zt=Ca();function Nh(t){zt=t}var Ot={exec:()=>null};function gn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function $(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(xe.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var cb=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),xe={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:gn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:gn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:gn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:gn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:gn(t=>new RegExp(`^ {0,${t}}>`))},db=/^(?:[ \t]*(?:\n|$))+/,hb=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,fb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,pb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,La=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ph=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Dh=$(Ph).replace(/bull/g,La).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(),gb=$(Ph).replace(/bull/g,La).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(),Na=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,mb=/^[^\n]+/,Pa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,vb=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Pa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),yb=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,La).getRegex(),xi="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",Da=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wb=$("^ {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",Da).replace("tag",xi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ih=t=>$(Na).replace("hr",Zn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xi).getRegex(),bb=Ih(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),xb=Ih(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),_b=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",xb).getRegex(),Ia={blockquote:_b,code:hb,def:vb,fences:fb,heading:pb,hr:Zn,html:wb,lheading:Dh,list:yb,newline:db,paragraph:bb,table:Ot,text:mb},Eh=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zn).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",xi).getRegex(),kb={...Ia,lheading:gb,table:Eh,paragraph:$(Na).replace("hr",Zn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Eh).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",xi).getRegex()},Eb={...Ia,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Da).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:Ot,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(Na).replace("hr",Zn).replace("heading",` *#{1,6} *[^
337
+ ]`).replace("lheading",Dh).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Sb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gh=/^( {2,}|\\)\n(?!\s*$)/,Ab=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ht=/[\p{P}\p{S}]/u,mn=/[\s\p{P}\p{S}]/u,Qn=/[^\s\p{P}\p{S}]/u,Rb=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,mn).getRegex(),Cb=/[\p{Pi}\p{Ps}"']/u,Mh=/(?!~)[\p{P}\p{S}]/u,Lb=/(?!~)[\s\p{P}\p{S}]/u,Nb=/(?:[^\s\p{P}\p{S}]|~)/u,Pb=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",cb?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Oh=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Db=$(Oh,"u").replace(/punct/g,ht).getRegex(),Ib=$(Oh,"u").replace(/punct/g,Mh).getRegex(),Gb=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,Mb=$(Gb,"u").replace(/openQuote/g,Cb).replace(/punct/g,ht).getRegex(),Fh="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ob=$(Fh,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,mn).replace(/punct/g,ht).getRegex(),Fb=$(Fh,"gu").replace(/notPunctSpace/g,Nb).replace(/punctSpace/g,Lb).replace(/punct/g,Mh).getRegex(),zb="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",$b=$(zb,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,mn).replace(/punct/g,ht).getRegex(),Ub=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,mn).replace(/punct/g,ht).getRegex(),Hb="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Bb=$(Hb,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,mn).replace(/punct/g,ht).getRegex(),Wb=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ht).getRegex(),Kb="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Vb=$(Kb,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,mn).replace(/punct/g,ht).getRegex(),jb=$(/\\(punct)/,"gu").replace(/punct/g,ht).getRegex(),qb=$(/^<(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(),Yb=$(Da).replace("(?:-->|$)","-->").getRegex(),Xb=$("^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",Yb).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Zb=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",yi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zh=$(/^!?\[(label)\]\[(ref)\]/).replace("label",yi).replace("ref",Pa).getRegex(),$h=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",Pa).getRegex(),Qb=$("reflink|nolink(?!\\()","g").replace("reflink",zh).replace("nolink",$h).getRegex(),Sh=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ga={_backpedal:Ot,anyPunctuation:jb,autolink:qb,blockSkip:Pb,br:Gh,code:Tb,del:Ot,delLDelim:Ot,delRDelim:Ot,emStrongLDelim:Db,emStrongRDelimAst:Ob,emStrongRDelimUnd:Ub,escape:Sb,link:Zb,nolink:$h,punctuation:Rb,reflink:zh,reflinkSearch:Qb,tag:Xb,text:Ab,url:Ot},Jb={...Ga,emStrongLDelim:Mb,emStrongRDelimAst:$b,emStrongRDelimUnd:Bb,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",yi).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yi).getRegex()},Ta={...Ga,emStrongRDelimAst:Fb,emStrongLDelim:Ib,delLDelim:Wb,delRDelim:Vb,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Sh).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Sh).getRegex()},ex={...Ta,br:$(Gh).replace("{2,}","*").getRegex(),text:$(Ta.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vi={normal:Ia,gfm:kb,pedantic:Eb},Yn={normal:Ga,gfm:Ta,breaks:ex,pedantic:Jb},tx={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Th=t=>tx[t];function it(t,e){if(e){if(xe.escapeTest.test(t))return t.replace(xe.escapeReplace,Th)}else if(xe.escapeTestNoEncode.test(t))return t.replace(xe.escapeReplaceNoEncode,Th);return t}function Ah(t){try{t=encodeURI(t).replace(xe.percentDecode,"%")}catch{return null}return t}function Rh(t,e){let n=t.replace(xe.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(xe.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(xe.slashPipe,"|");return r}function bt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let o=t.charAt(r-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,r-i)}function Ch(t){let e=t.split(`
338
+ `),n=e.length-1;for(;n>=0&&xe.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
339
+ `)}function nx(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function rx(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function Lh(t,e,n,r,i){let o=e.href,a=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function ix(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
340
340
  `).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(`
341
- `)}var wi=class{options;rules;lexer;constructor(t){this.options=t||Ft}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:mh(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=Fb(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=bt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:bt(e[0],`
341
+ `)}var wi=class{options;rules;lexer;constructor(t){this.options=t||zt}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Ch(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=ix(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=bt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:bt(e[0],`
342
342
  `),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:bt(e[0],`
343
343
  `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=bt(e[0],`
344
344
  `).split(`
@@ -352,20 +352,20 @@ ${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
352
352
  ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="list"){let f=d,g=f.raw+`
353
353
  `+n.join(`
354
354
  `),m=this.list(g);o[o.length-1]=m,r=r.substring(0,r.length-d.raw.length)+m.raw,i=i.substring(0,i.length-f.raw.length)+m.raw,n=g.substring(o.at(-1).raw.length).split(`
355
- `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=Ob(e[2].split(`
355
+ `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=rx(e[2].split(`
356
356
  `,1)[0],e[1].length),d=t.split(`
357
357
  `,1)[0],f=!h.trim(),g=0;if(this.options.pedantic?(g=2,c=h.trimStart()):f?g=e[1].length+1:(g=h.search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=h.slice(g),g+=e[1].length),f&&this.rules.other.blankLine.test(d)&&(u+=d+`
358
- `,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),w=this.rules.other.fencesBeginRegex(g),b=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g),_=this.rules.other.blockquoteBeginRegex(g);for(;t;){let L=t.split(`
359
- `,1)[0],P;if(d=L,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),P=d):P=d.replace(this.rules.other.tabCharGlobal," "),w.test(d)||b.test(d)||E.test(d)||_.test(d)||m.test(d)||v.test(d))break;if(P.search(this.rules.other.nonSpaceChar)>=g||!d.trim())c+=`
360
- `+P.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||w.test(h)||b.test(h)||v.test(h))break;c+=`
361
- `+d}f=!d.trim(),u+=L+`
362
- `,t=t.substring(L.length+1),h=P.slice(g)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(a=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let u=l.tokens.filter(h=>h.type==="space"),c=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=c}for(let l of i.items){let u=l.tokens[0];if(l.task&&(u?.type==="text"||u?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=mh(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:bt(e[0],`
363
- `),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=gh(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
358
+ `,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(g),v=this.rules.other.hrRegex(g),y=this.rules.other.fencesBeginRegex(g),w=this.rules.other.headingBeginRegex(g),k=this.rules.other.htmlBeginRegex(g),_=this.rules.other.blockquoteBeginRegex(g);for(;t;){let A=t.split(`
359
+ `,1)[0],N;if(d=A,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),N=d):N=d.replace(this.rules.other.tabCharGlobal," "),y.test(d)||w.test(d)||k.test(d)||_.test(d)||m.test(d)||v.test(d))break;if(N.search(this.rules.other.nonSpaceChar)>=g||!d.trim())c+=`
360
+ `+N.slice(g);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(h)||w.test(h)||v.test(h))break;c+=`
361
+ `+d}f=!d.trim(),u+=A+`
362
+ `,t=t.substring(A.length+1),h=N.slice(g)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(a=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let u=l.tokens.filter(h=>h.type==="space"),c=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=c}for(let l of i.items){let u=l.tokens[0];if(l.task&&(u?.type==="text"||u?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Ch(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:bt(e[0],`
363
+ `),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Rh(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
364
364
  `):[],o={type:"table",raw:bt(e[0],`
365
- `),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(gh(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:bt(e[0],`
365
+ `),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(Rh(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:bt(e[0],`
366
366
  `),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
367
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Mb(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),vh(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return vh(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=0,u=r[0][0],c=n===u,h=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(r=h.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(c)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,f=t.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let u=[...r[0]][0].length,c=t.slice(0,i+r.index+u+a),h=c.slice(i,-i);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Ve=class xa{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ft,this.options.tokenizer=this.options.tokenizer||new wi,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:ye,block:vi.normal,inline:jn.normal};this.options.pedantic?(n.block=vi.pedantic,n.inline=jn.pedantic):this.options.gfm&&(n.block=vi.gfm,this.options.breaks?n.inline=jn.breaks:n.inline=jn.gfm),this.tokenizer.rules=n}static get rules(){return{block:vi,inline:jn}}static lex(e,n){return new xa(n).lex(e)}static lexInline(e,n){return new xa(n).inlineTokens(e)}lex(e){e=e.replace(ye.carriageReturn,`
368
- `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ye.tabCharGlobal," ").replace(ye.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
367
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=bt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=nx(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Lh(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Lh(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=0,u=r[0][0],c=n===u,h=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(r=h.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(c)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,f=t.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let u=[...r[0]][0].length,c=t.slice(0,i+r.index+u+a),h=c.slice(i,-i);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Ye=class Aa{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||zt,this.options.tokenizer=this.options.tokenizer||new wi,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:xe,block:vi.normal,inline:Yn.normal};this.options.pedantic?(n.block=vi.pedantic,n.inline=Yn.pedantic):this.options.gfm&&(n.block=vi.gfm,this.options.breaks?n.inline=Yn.breaks:n.inline=Yn.gfm),this.tokenizer.rules=n}static get rules(){return{block:vi,inline:Yn}}static lex(e,n){return new Aa(n).lex(e)}static lexInline(e,n){return new Aa(n).inlineTokens(e)}lex(e){e=e.replace(xe.carriageReturn,`
368
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(xe.tabCharGlobal," ").replace(xe.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
369
369
  `:n.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
370
370
  `)?"":`
371
371
  `)+o.raw,s.text+=`
@@ -378,9 +378,9 @@ ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="li
378
378
  `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
379
379
  `)?"":`
380
380
  `)+o.raw,s.text+=`
381
- `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},bi=class{options;parser;constructor(t){this.options=t||Ft}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ye.notSpaceStart)?.[0],i=t.replace(ye.endingNewline,"")+`
382
- `;return r?'<pre><code class="language-'+nt(r)+'">'+(n?i:nt(i,!0))+`</code></pre>
383
- `:"<pre><code>"+(n?i:nt(i,!0))+`</code></pre>
381
+ `+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},bi=class{options;parser;constructor(t){this.options=t||zt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(xe.notSpaceStart)?.[0],i=t.replace(xe.endingNewline,"")+`
382
+ `;return r?'<pre><code class="language-'+it(r)+'">'+(n?i:it(i,!0))+`</code></pre>
383
+ `:"<pre><code>"+(n?i:it(i,!0))+`</code></pre>
384
384
  `}blockquote({tokens:t}){return`<blockquote>
385
385
  ${this.parser.parse(t)}</blockquote>
386
386
  `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
@@ -396,22 +396,70 @@ ${this.parser.parse(t)}</blockquote>
396
396
  `}tablerow({text:t}){return`<tr>
397
397
  ${t}</tr>
398
398
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
399
- `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${nt(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=ph(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+nt(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ph(t);if(i===null)return nt(n);t=i;let o=`<img src="${t}" alt="${nt(n)}"`;return e&&(o+=` title="${nt(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:nt(t.text)}},La=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},je=class _a{options;renderer;textRenderer;constructor(e){this.options=e||Ft,this.options.renderer=this.options.renderer||new bi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new La}static parse(e,n){return new _a(n).parse(e)}static parseInline(e,n){return new _a(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},qn=class{options;block;constructor(t){this.options=t||Ft}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ve.lex:Ve.lexInline}provideParser(t=this.block){return t?je.parse:je.parseInline}},Na=class{defaults=Ea();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=je;Renderer=bi;TextRenderer=La;Lexer=Ve;Tokenizer=wi;Hooks=qn;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new bi(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new wi(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new qn;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];qn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&qn.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let c=s.call(i,u);return l.call(i,c)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,u);return h===!1&&(h=await l.apply(i,u)),h})();let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ve.lex(t,e??this.defaults)}parser(t,e){return je.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,s=await(i.hooks?await i.hooks.provideLexer(t):t?Ve.lex:Ve.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?je.parse:je.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?Ve.lex:Ve.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(t):t?je.parse:je.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
400
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+nt(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ot=new Na;function V(t,e){return Ot.parse(t,e)}V.options=V.setOptions=function(t){return Ot.setOptions(t),V.defaults=Ot.defaults,yh(V.defaults),V};V.getDefaults=Ea;V.defaults=Ft;function $b(...t){return Ot.use(...t),V.defaults=Ot.defaults,yh(V.defaults),V}V.use=$b;V.walkTokens=function(t,e){return Ot.walkTokens(t,e)};V.parseInline=Ot.parseInline;V.Parser=je;V.parser=je.parse;V.Renderer=bi;V.TextRenderer=La;V.Lexer=Ve;V.lexer=Ve.lex;V.Tokenizer=wi;V.Hooks=qn;V.parse=V;var TS=V.options,RS=V.setOptions,AS=V.walkTokens,CS=V.parseInline;var LS=je.parse,NS=Ve.lex;var Ch={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},zb=new RegExp(`[${Object.keys(Ch).join("")}]`,"g");function qe(t){return t.replace(zb,e=>Ch[e])}var Ub=["http:","https:","mailto:"],Hb=/^[a-z][a-z0-9+.-]*:/i,Bb=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Ah(t){let e=t.replace(Bb,""),n=Hb.exec(e);return n===null?e===""?null:t:Ub.includes(n[0].toLowerCase())?t:null}var _i="data-weave-target",Ei="note:",Wb={bySpelling:new Map,hasGhosts:!1};function Kb(t){if(t.kind!=="note"||!t.id.startsWith(Ei))return null;let e=t.id.slice(Ei.length);return e===""?null:e}function Lh(t,e){if(t===null)return Wb;let n=new Map;for(let i of t.model.nodes){let o=Kb(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r}}function Vb(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function jb(t){return t.hasGhosts}var qb=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Yb(t){let e=t.indexOf("[[");return e===-1?void 0:e}function Xb(t){return{name:"wikilink",level:"inline",start:Yb,tokenizer(e){return Qb(e)},renderer(e){return Zb(t,e)}}}function Zb(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Jb(t,n,r)}function Qb(t){let e=qb.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Jb(t,e,n){let r=qe((n===""?e:n).trim());if(r==="")return"";let i=Vb(t,e);return i!==null?`<a class="weave-wiki" ${_i}="${qe(i)}" role="link" tabindex="0" title="${qe(e.trim())}">${r}</a>`:jb(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${qe(e.trim())}">${r}</span>`:r}function ex(t){return new Na({gfm:!0,async:!1,extensions:[Xb(t)],renderer:{html({text:e}){return qe(e)},link({href:e,title:n,tokens:r}){let i=Ah(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${qe(i)}"`,n==null||n===""?"":` title="${qe(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=Ah(e);if(i===null)return qe(r);let o=n==null||n===""?"":` title="${qe(n)}"`;return`<img src="${qe(i)}" alt="${qe(r)}"${o}>`}}})}function tx(t,e){return ex(e).parse(t,{async:!1})}function Zn(t){return Object.freeze(t)}var nx=Zn({ALLOWED_TAGS:Zn(["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:Zn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",_i]),ADD_URI_SAFE_ATTR:Zn([_i]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Zn({html:!0})});function Nh(t,e,n){return t.sanitize(tx(e,n),nx)}var rx=32;function Da(t){let e=t;for(let n=0;e!==null&&n<rx;n++){let r=e.getAttribute(_i);if(r!==null&&r!=="")return`${Ei}${r}`;e=e.parentElement}return null}function Dh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Nt(t.source),provenanceTitle:Gn(t.source),updated:In(t.updated,e),updatedIso:t.updated,created:In(t.created,e),createdIso:t.created,tags:t.tags}}function Ph(t){return`#${t}`}function Ih(t,e){return e!==null?null:t===null?"Select a note to read it here.":t.startsWith(Ei)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function ix({view:t}){return x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:t.title}),x("p",{class:"weave-note-meta",children:[x("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),x("span",{class:"weave-note-time",title:t.updatedIso,children:["updated ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:["created ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(e=>x("span",{class:"weave-tag",children:Ph(e)},e))})]})}function Gh(t){let e=t.note?.note??null,n=Ih(t.selectedId,e);if(e===null)return x("p",{class:"weave-note-empty",children:n});let r=Lh(t.graph,e.slug),i=t.toolbar,o={draft:t.draft,prompt:t.prompt,send:t.send};return x("article",{class:"weave-note",children:[x(ix,{view:Dh(e,t.now)}),i===null?null:x(uh,{toolbar:i,...o}),i!==null&&i.editing?x(ch,{toolbar:i,...o}):x("div",{class:"weave-note-body",onClick:a=>{let s=Da(a.target);s!==null&&t.onSelect(s)},onKeyDown:a=>{if(a.key!=="Enter"&&a.key!==" ")return;let s=Da(a.target);s!==null&&(a.preventDefault(),t.onSelect(s))},dangerouslySetInnerHTML:{__html:Nh(lh,e.body,r)}})]})}function ox({view:t,onSelect:e,onToggle:n}){return x("li",{id:t.domId,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:ju(t.depth),onClick:e,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:r=>{r.stopPropagation(),n()},children:t.twistyGlyph}),x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label}),x("span",{class:"weave-meta",children:t.meta})]})}function Mh(t){let[e,n]=Ue(Ou),r=Fu(t.graph,e),i=tc(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=Bu(r,e,t.selectedId,o.key);a.handled&&(o.preventDefault(),n(a.state),a.selectedId!==null&&t.onSelect(a.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:Zu,"aria-label":Ju,title:ec,onInput:o=>n(zu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:qu(e.provFilter),onClick:()=>n(Uu(e)),children:["◧ ",Vr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:Xu(e.showInternals),onClick:()=>n(Hu(e)),children:["◧ ",Yu(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Qu,"aria-activedescendant":Vu(r,t.selectedId)??void 0,children:Ku(r,t.selectedId,t.now).map(o=>x(ox,{view:o,onSelect:()=>t.onSelect(o.id),onToggle:()=>n($u(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:nc(r)})]})}function Oh(t,e){if(t===null)return 0;for(let[n,r]of e)t.style.setProperty(n,r);return e.length}var Qn=["tree","note","graph"],Pa={tree:180,note:320,graph:260},$h={tree:.22,note:.46,graph:.32},ax=1100,sx=800;function zh(t){return!Number.isFinite(t)||t<sx?"narrow":t<ax?"medium":"wide"}function lx(t){return t==="wide"?Qn:t==="medium"?["tree","note"]:["note"]}function Uh(t,e){return Hh(Qn,t,e)}function Hh(t,e,n){let r={tree:0,note:0,graph:0};for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:$h[l]}let i=0;for(let l of t)i+=r[l];for(let l of t)r[l]=r[l]/i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function Ga(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:Pa.tree/e,note:Pa.note/e,graph:Pa.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function Bh(t,e,n=[]){return{fractions:Uh(t,Ga(e)),revealed:Qn.filter(r=>n.includes(r))}}function Fh(t){return Bh($h,t)}function Wh(t,e,n){let r=lx(n),i=Number.isFinite(e)&&e>0?e:0,o=Hh(r,t.fractions,Ga(i));return r.map(a=>({id:a,width:o[a]*i}))}var Kh=["tree","note"];function ux(t){return t==="tree"?["tree","note"]:["note","graph"]}function Ma(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=ux(e),s=Ga(i),l=Math.max(0,t.fractions[o]-s[o]),u=Math.max(0,t.fractions[a]-s[a]),c=Math.max(-l,Math.min(u,n/i));if(c===0)return t;let h={...t.fractions,[o]:t.fractions[o]+c,[a]:t.fractions[a]-c};return{fractions:Uh(h,s),revealed:t.revealed}}var Vh="pi-weave.layout.v1";function cx(t){return JSON.stringify({v:1,tree:Ia(t.fractions.tree),note:Ia(t.fractions.note),graph:Ia(t.fractions.graph),revealed:[...t.revealed]})}function Ia(t){return Math.round(t*1e4)/1e4}function dx(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={tree:0,note:0,graph:0};for(let s of Qn){let l=r[s];if(typeof l!="number"||!Number.isFinite(l)||l<=0)return null;i[s]=l}let o=r.revealed,a=Array.isArray(o)?Qn.filter(s=>o.includes(s)):[];return Bh(i,e,a)}function jh(t,e){let n;try{n=t.getItem(Vh)}catch{return Fh(e)}return dx(n,e)??Fh(e)}function qh(t,e){try{return t.setItem(Vh,cx(e)),!0}catch{return!1}}function hx(t){return`--weave-col-${t}`}function fx(t){return`${Math.round(t)}px`}function Yh(t){return t.map(e=>[hx(e.id),fx(e.width)])}var Oa={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Si(t,e,n){return{id:t,target:e.id,label:Ce(e),kind:e.kind,kindGlyph:Uo(e.kind),provenance:e.provenance,provenanceGlyph:Nt(e.provenance),provenanceTitle:Gn(e.provenance),selected:e.id===n}}function px(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:Si(t.id,i,n)}function gx(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var mx=["link:links-to:"];function vx(t){return mx.some(e=>t.id.startsWith(e))}function yx(t){return t.id.startsWith("link:mentions:")}function wx(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(Si(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function bx(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(Si(`mentioned-by:${o.source}`,a,r))}return i}function xx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var ki={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 Fa(t){return{subject:null,groups:[],tags:[],empty:t}}function Xh(t,e){if(t===null)return Fa(ki.loading);if(e===null)return Fa(ki.noSelection);let n=Lt(t),r=Oo(n,e);if(r===null)return Fa(ki.unknown);let i=gx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,rows:d})},s=h=>h.map(d=>px(d,i,e)).filter(d=>d!==null);a(Oa.links,s(r.links.filter(vx)));let l=Fo(n.edges).get(e)??[];a(Oa.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Si(`backlink:${h.id}`,h,e))),a(Oa.mentions,[...s(r.links.filter(yx)),...bx(n,e,i,e)]);let u=xx(e),c=u===null?[]:wx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],empty:ki.isolated}:{subject:r.label,groups:o,tags:c,empty:null}}var _x={notes:0,repo:null,nodes:0},Ex=["note"];function Zh(t){if(t===null)return _x;let e=t.model.nodes;return{notes:e.filter(n=>Ex.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function kx(t){return t===null||t==="missing"?"unindexed":t}function Qh(t){return[`vault:${t.notes}`,`repo:${kx(t.repo)}`,`${t.nodes} nodes`]}var Sx={live:{label:"live",tone:"ok",hint:"watching the vault and the repository for changes"},reconnecting:{label:"reconnecting",tone:"warn",hint:"the event stream dropped — retrying, and everything refetches when it returns"},offline:{label:"offline",tone:"bad",hint:"the workspace server is gone — use ⟳ to retry"}};function $a(t){return Sx[t]}var Tx={tree:{title:"Tree",body:"The vault and repository outline, expandable, filterable, with provenance markers.",phase:"P2"},note:{title:"Note",body:"Select anything to read it here — rendered Markdown, front matter, tags and wikilinks.",phase:"P2"},graph:{title:"Graph",body:"The knowledge graph, laid out and navigable, with the selection's neighbourhood highlighted.",phase:"P3"}};function Jh(t){return Tx[t]}var za={title:"Context",body:"Links, backlinks and mentions for whatever is selected.",phase:"P2"},ef="—";function tf(t,e,n,r){return{cwd:t===""?ef:t,selection:e??"nothing selected",connection:$a(n),stamp:r}}function nf(t){return t===null?ef:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}function rf(t){return t.map((e,n)=>({column:e,divider:n<t.length-1&&Rx(e.id)?e.id:null}))}function Rx(t){return Kh.includes(t)}var of="Search…";function Ua(t){return t?"⌘K":"Ctrl K"}function af(t){return`Search notes and repository (${t})`}function Ha(t){return/mac|iphone|ipad/i.test(t)}function sf({row:t,onSelect:e}){return x("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:x("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label})]})})}function Ax({group:t,onSelect:e}){return x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:t.heading}),x("ul",{class:"weave-ctx-rows",children:t.rows.map(n=>x(sf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function Cx({tag:t,onSelect:e}){return x("li",{class:"weave-ctx-tag",children:[x("span",{class:"weave-tag",children:["#",t.tag]}),x("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>x(sf,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function lf(t){let e=Xh(t.graph,t.selectedId);return x("div",{class:"weave-rail","aria-label":za.title,children:[x("h2",{class:"weave-col-title",children:za.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(n=>x(Ax,{group:n,onSelect:t.onSelect},n.heading)),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:"TAGS"}),x("ul",{class:"weave-ctx-tags",children:e.tags.map(n=>x(Cx,{tag:n,onSelect:t.onSelect},n.tag))})]})]})}function uf(t){return x("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX,e.pointerId)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function Lx({id:t,props:e}){let n=Jh(t);return x("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[x("h2",{class:"weave-col-title",children:n.title}),t==="tree"?x(Mh,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(Gh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,toolbar:e.toolbar,prompt:e.prompt,draft:e.draft,send:e.send}):null,t==="graph"?x(Hd,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,fit:e.fit}):null,t==="graph"?x(lf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function Nx({slot:t,props:e}){let n=t.divider;return x(Pe,{children:[x(Lx,{id:t.column.id,props:e}),n===null?null:x(uf,{id:n,label:`Resize ${t.column.id} column`,onDown:(r,i)=>e.onDown(n,r,i),onMove:e.onMove,onUp:e.onUp,onKey:r=>e.onKey(n,r)})]})}function cf(t){let e=Ae(null);return Xs(()=>{Oh(e.current,Yh(t.resolved))},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:rf(t.resolved).map(n=>x(Nx,{slot:n,props:t},n.column.id))})}function Dx(t,e,n,r){return{divider:t,origin:e,base:n,pointerId:r}}function Px(t,e,n){return Ma(t.base,t.divider,e-t.origin,n)}function Ix(t,e){let n=t.base.fractions,r=e.fractions;return n.tree!==r.tree||n.note!==r.note||n.graph!==r.graph}var df=24;function Gx(t){return t==="ArrowLeft"?-df:t==="ArrowRight"?df:0}function hf(t){let e=null;return{onDown(n,r,i){e=Dx(n,r,t.layout(),i)},onMove(n){e!==null&&t.setLayout(Px(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Ix(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=Ma(t.layout(),n,Gx(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}function ff(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:"🧵 pi-weave"}),x("button",{type:"button",class:"weave-search",title:af(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:of}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:Qh(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-refresh",onClick:t.onRefresh,title:"Refetch everything",children:"⟳"}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:[x("span",{class:"weave-conn-dot","aria-hidden":"true",children:"●"}),t.connection.label]})]})}var Mx={k:{type:"openSearch"},e:{type:"toggleEdit"},s:{type:"saveNote"}},pf={1:"tree",2:"note",3:"graph"};function Ox(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Fx(t){return!t.ctrl&&!t.meta&&!t.alt}var $x={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"}};function gf(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Ox(t)){let n=Mx[t.key.toLowerCase()];if(n!==void 0)return n;let r=pf[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Fx(t)||t.typing?null:$x[t.key]??null}var zx=["INPUT","TEXTAREA","SELECT"];function Ux(t,e){return e?!0:t!==null&&zx.includes(t.toUpperCase())}function mf(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:Ux(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Hx={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},Bx=".weave-col-tree .weave-filter";function Wx(t){let e=t;return typeof e?.focus=="function"?e:null}function vf(t,e){let n=Wx(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function yf(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(Hx[t.column]);case"filterTree":return void e.focusSelector(Bx);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"toggleEdit":return e.toggleEdit();case"saveNote":return e.saveNote()}}function wf(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(pf).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column`})),{combo:"?",what:"This help"},{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:"Note",entries:[{combo:`${t}E`,what:"Toggle read / edit"},{combo:`${t}S`,what:"Save the open draft"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var Ba="Keyboard shortcuts",bf="esc close";function Kx({group:t}){return x("div",{children:[x("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>x("div",{class:"weave-key-row",children:[x("kbd",{class:"weave-key-combo",children:e.combo}),x("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function xf(t){let e=hi(),n=t.shortcut.slice(0,-1);return x("div",{class:"weave-scrim",onClick:t.onClose,children:x("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Ba,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:Ba}),x("div",{class:"weave-keys",children:wf(n).map(r=>x(Kx,{group:r},r.title))}),x("p",{class:"weave-help-foot",children:[x("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),x("span",{class:"weave-help-hint",children:bf})]})]})})}function _f(t,e){let n=r=>{let i=gf(mf(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function Ef({model:t}){return x("footer",{class:"weave-status",children:[x("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),x("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),x("span",{class:"weave-status-stamp",title:"data as of",children:nf(t.stamp)}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:t.connection.label})]})}function kf(t,e){let n=()=>e(t.innerWidth);return t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)}function Sf(t){let[e,n]=Ue(t.initialWidth),[r,i]=Ue(null),[o,a]=Ue(()=>jh(localStorage,t.initialWidth)),[s,l]=Ue(un),u=Ae(null),c=Ae(null),h=Ae({layout:o,width:e,overlay:r});h.current={layout:o,width:e,overlay:r};let d=Ie(()=>rd({fetch:qt,select:m=>{la(qt,m)},onChange:l}),[]);Re(()=>{let m=kd({fetch:qt,open:Bc});return u.current=m,()=>m.stop()},[]),Re(()=>_d(m=>d.send({type:"loaded",payload:m})),[]),Re(()=>id(window,()=>ia(d.state())),[]),Re(()=>kf(window,n),[]),Re(()=>_f(document,{context:()=>({overlay:h.current.overlay,hasSelection:vt.value!==null}),run:m=>yf(m,{setOverlay:i,focusSelector:v=>vf(document,v),fitGraph:()=>c.current?.(),clearSelection:()=>d.send({type:"navigate",id:null}),toggleEdit:()=>d.send({type:"toggle"}),saveNote:()=>d.send({type:"save"})})}),[]);let f=Ie(()=>Wh(o,e,zh(e)),[o,e]),g=Ie(()=>hf({layout:()=>h.current.layout,width:()=>h.current.width,setLayout:a,persist:m=>{qh(localStorage,m)}}),[]);return x(Pe,{children:[x(ff,{summary:Zh(yt.value),connection:$a(ln.value),shortcut:Ua(Ha(t.platform)),onRefresh:()=>u.current?.refresh(),onSearch:()=>i("search")}),x(cf,{resolved:f,onDown:g.onDown,onMove:g.onMove,onUp:g.onUp,onKey:g.onKey,graph:yt.value,note:Hn.value,selectedId:vt.value,onSelect:m=>d.send({type:"navigate",id:m}),now:Date.now(),toolbar:nd(s),prompt:td(s),draft:s.draft,send:d.send,renderer:Sc,storage:localStorage,host:window,fit:c}),x(Ef,{model:tf(t.cwd,vt.value,ln.value,yt.value?.model.generatedAt??null)}),r==="search"?x(bd,{graph:yt.value,onSelect:m=>{la(qt,m)},onClose:()=>i(null),ports:{fetch:qt,now:Date.now,delay:(m,v)=>{setTimeout(m,v)}}}):null,r==="help"?x(xf,{shortcut:Ua(Ha(t.platform)),onClose:()=>i(null)}):null]})}var Vx=`
399
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${it(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=Ah(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+it(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ah(t);if(i===null)return it(n);t=i;let o=`<img src="${t}" alt="${it(n)}"`;return e&&(o+=` title="${it(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:it(t.text)}},Ma=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Xe=class Ra{options;renderer;textRenderer;constructor(e){this.options=e||zt,this.options.renderer=this.options.renderer||new bi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ma}static parse(e,n){return new Ra(n).parse(e)}static parseInline(e,n){return new Ra(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},Xn=class{options;block;constructor(t){this.options=t||zt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ye.lex:Ye.lexInline}provideParser(t=this.block){return t?Xe.parse:Xe.parseInline}},Oa=class{defaults=Ca();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Xe;Renderer=bi;TextRenderer=Ma;Lexer=Ye;Tokenizer=wi;Hooks=Xn;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new bi(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new wi(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Xn;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];Xn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&Xn.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let c=s.call(i,u);return l.call(i,c)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,u);return h===!1&&(h=await l.apply(i,u)),h})();let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ye.lex(t,e??this.defaults)}parser(t,e){return Xe.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,s=await(i.hooks?await i.hooks.provideLexer(t):t?Ye.lex:Ye.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?Xe.parse:Xe.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?Ye.lex:Ye.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(t):t?Xe.parse:Xe.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
400
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+it(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ft=new Oa;function V(t,e){return Ft.parse(t,e)}V.options=V.setOptions=function(t){return Ft.setOptions(t),V.defaults=Ft.defaults,Nh(V.defaults),V};V.getDefaults=Ca;V.defaults=zt;function ox(...t){return Ft.use(...t),V.defaults=Ft.defaults,Nh(V.defaults),V}V.use=ox;V.walkTokens=function(t,e){return Ft.walkTokens(t,e)};V.parseInline=Ft.parseInline;V.Parser=Xe;V.parser=Xe.parse;V.Renderer=bi;V.TextRenderer=Ma;V.Lexer=Ye;V.lexer=Ye.lex;V.Tokenizer=wi;V.Hooks=Xn;V.parse=V;var i0=V.options,o0=V.setOptions,a0=V.walkTokens,s0=V.parseInline;var l0=Xe.parse,u0=Ye.lex;var Hh={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ax=new RegExp(`[${Object.keys(Hh).join("")}]`,"g");function Ze(t){return t.replace(ax,e=>Hh[e])}var sx=["http:","https:","mailto:"],lx=/^[a-z][a-z0-9+.-]*:/i,ux=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Uh(t){let e=t.replace(ux,""),n=lx.exec(e);return n===null?e===""?null:t:sx.includes(n[0].toLowerCase())?t:null}var _i="data-weave-target",ki="note:",cx={bySpelling:new Map,hasGhosts:!1};function dx(t){if(t.kind!=="note"||!t.id.startsWith(ki))return null;let e=t.id.slice(ki.length);return e===""?null:e}function Bh(t,e){if(t===null)return cx;let n=new Map;for(let i of t.model.nodes){let o=dx(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r}}function hx(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function fx(t){return t.hasGhosts}var px=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function gx(t){let e=t.indexOf("[[");return e===-1?void 0:e}function mx(t){return{name:"wikilink",level:"inline",start:gx,tokenizer(e){return yx(e)},renderer(e){return vx(t,e)}}}function vx(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return wx(t,n,r)}function yx(t){let e=px.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function wx(t,e,n){let r=Ze((n===""?e:n).trim());if(r==="")return"";let i=hx(t,e);return i!==null?`<a class="weave-wiki" ${_i}="${Ze(i)}" role="link" tabindex="0" title="${Ze(e.trim())}">${r}</a>`:fx(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Ze(e.trim())}">${r}</span>`:r}function bx(t){return new Oa({gfm:!0,async:!1,extensions:[mx(t)],renderer:{html({text:e}){return Ze(e)},link({href:e,title:n,tokens:r}){let i=Uh(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${Ze(i)}"`,n==null||n===""?"":` title="${Ze(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=Uh(e);if(i===null)return Ze(r);let o=n==null||n===""?"":` title="${Ze(n)}"`;return`<img src="${Ze(i)}" alt="${Ze(r)}"${o}>`}}})}function xx(t,e){return bx(e).parse(t,{async:!1})}function Jn(t){return Object.freeze(t)}var _x=Jn({ALLOWED_TAGS:Jn(["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:Jn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",_i]),ADD_URI_SAFE_ATTR:Jn([_i]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Jn({html:!0})});function Wh(t,e,n){return t.sanitize(xx(e,n),_x)}var kx=32;function Fa(t){let e=t;for(let n=0;e!==null&&n<kx;n++){let r=e.getAttribute(_i);if(r!==null&&r!=="")return`${ki}${r}`;e=e.parentElement}return null}function Kh(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Pt(t.source),provenanceTitle:Mn(t.source),updated:Gn(t.updated,e),updatedIso:t.updated,created:Gn(t.created,e),createdIso:t.created,tags:t.tags}}function Vh(t){return`#${t}`}function jh(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(ki)?"Loading…":"This node has no note body — see the context rail for what it connects to."}function Ex({view:t}){return x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:t.title}),x("p",{class:"weave-note-meta",children:[x("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),x("span",{class:"weave-note-time",title:t.updatedIso,children:["updated ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:["created ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(e=>x("span",{class:"weave-tag",children:Vh(e)},e))})]})}function qh(t){let e=t.note?.note??null,n=jh(t.selectedId,e),r=we(()=>e===null?null:Bh(t.graph,e.slug),[e,t.graph]),i=we(()=>e===null||r===null?"":Wh(xh,e.body,r),[e,r]);if(e===null||r===null)return x("p",{class:"weave-note-empty",children:n});let o=t.toolbar,a={draft:t.draft,prompt:t.prompt,send:t.send},s=Kh(e,t.now);return x("article",{class:`weave-note weave-note-${s.provenance}`,children:[x(Ex,{view:s}),o===null?null:x(_h,{toolbar:o,...a}),o!==null&&o.editing?x(kh,{toolbar:o,...a}):x("div",{class:"weave-note-body",tabIndex:-1,onClick:l=>{let u=Fa(l.target);if(u!==null){t.onSelect(u);return}t.toolbar!==null&&t.send({type:"toggle"})},onKeyDown:l=>{if(l.key!=="Enter"&&l.key!==" ")return;let u=Fa(l.target);u!==null&&(l.preventDefault(),t.onSelect(u))},dangerouslySetInnerHTML:{__html:i}})]},e.slug)}var er=["tree","note","graph"],za={tree:180,note:320,graph:260},Xh={tree:.22,note:.46,graph:.32},Sx=1100,Tx=800;function Zh(t){return!Number.isFinite(t)||t<Tx?"narrow":t<Sx?"medium":"wide"}function Ei(t){return t==="wide"?er:t==="medium"?["tree","note"]:["note"]}function Qh(t,e){return Jh(er,t,e)}function Jh(t,e,n){let r={tree:0,note:0,graph:0};for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:Xh[l]}let i=0;for(let l of t)i+=r[l];for(let l of t)r[l]=r[l]/i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function Ua(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:za.tree/e,note:za.note/e,graph:za.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function ef(t,e){return{fractions:Qh(t,Ua(e))}}function Yh(t){return ef(Xh,t)}function tf(t,e,n){let r=Ei(n),i=Number.isFinite(e)&&e>0?e:0,o=Jh(r,t.fractions,Ua(i));return r.map(a=>({id:a,width:o[a]*i}))}var nf=["tree","note"];function Ax(t){return t==="tree"?["tree","note"]:["note","graph"]}function Ha(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=Ax(e),s=Ua(i),l=Math.max(0,t.fractions[o]-s[o]),u=Math.max(0,t.fractions[a]-s[a]),c=Math.max(-l,Math.min(u,n/i));if(c===0)return t;let h={...t.fractions,[o]:t.fractions[o]+c,[a]:t.fractions[a]-c};return{fractions:Qh(h,s)}}var rf="pi-weave.layout.v1";function Rx(t){return JSON.stringify({v:1,tree:$a(t.fractions.tree),note:$a(t.fractions.note),graph:$a(t.fractions.graph)})}function $a(t){return Math.round(t*1e4)/1e4}function Cx(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={tree:0,note:0,graph:0};for(let o of er){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return ef(i,e)}function of(t,e){let n;try{n=t.getItem(rf)}catch{return Yh(e)}return Cx(n,e)??Yh(e)}function af(t,e){try{return t.setItem(rf,Rx(e)),!0}catch{return!1}}function Lx(t){return`--weave-col-${t}`}function Nx(t){return`${Math.round(t)}px`}function sf(t){return t.map(e=>[Lx(e.id),Nx(e.width)])}var Px={k:{type:"openSearch"},e:{type:"toggleEdit"},s:{type:"saveNote"}},lf={1:"tree",2:"note",3:"graph"},Dx=new Set(er.filter(t=>Ei("medium").includes(t)===!1||Ei("narrow").includes(t)===!1));function Ix(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function Gx(t){return!t.ctrl&&!t.meta&&!t.alt}var Mx={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function uf(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(Ix(t)){let n=Px[t.key.toLowerCase()];if(n!==void 0)return n;let r=lf[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!Gx(t)||t.typing?null:Mx[t.key]??null}var Ox=["INPUT","TEXTAREA","SELECT"];function Ba(t,e){return e?!0:t!==null&&Ox.includes(t.toUpperCase())}function cf(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:Ba(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Fx={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},zx=".weave-col-tree .weave-filter";function $x(t){let e=t;return typeof e?.focus=="function"?e:null}function df(t,e){let n=$x(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function hf(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(Fx[t.column]);case"filterTree":return void e.focusSelector(zx);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"toggleEdit":return e.toggleEdit();case"saveNote":return e.saveNote();case"cycleTheme":return e.cycleTheme()}}function ff(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(lf).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${Dx.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Note",entries:[{combo:`${t}E`,what:"Toggle read / edit"},{combo:`${t}S`,what:"Save the open draft"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var Wa="Keyboard shortcuts",pf="esc close";function Ux({view:t,onSelect:e,onToggle:n}){return x("li",{id:t.domId,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${cn.value.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:oc(t.depth),onClick:e,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:r=>{r.stopPropagation(),n()},children:t.twistyGlyph}),x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label}),x("span",{class:"weave-meta",children:t.meta})]})}function gf(t){let[e,n]=Ne(Yu),r=Xu(t.graph,e),i=fc(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=o.target,s=Ba(a?.tagName??null,a?.isContentEditable===!0),l=tc(r,e,t.selectedId,o.key,s);l.handled&&(o.preventDefault(),n(l.state),l.selectedId!==null&&t.onSelect(l.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:uc,"aria-label":dc,title:hc,onInput:o=>n(Qu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:ac(e.provFilter),onClick:()=>n(Ju(e)),children:["◧ ",Wr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:lc(e.showInternals),onClick:()=>n(ec(e)),children:["◧ ",sc(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":cc,"aria-activedescendant":ic(r,t.selectedId)??void 0,children:rc(r,t.selectedId,t.now).map(o=>x(Ux,{view:o,onSelect:()=>t.onSelect(o.id),onToggle:()=>n(Zu(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:pc(r)})]})}function mf(t,e){if(t===null)return 0;for(let[n,r]of e)t.style.setProperty(n,r);return e.length}var Ka={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Ti(t,e,n){return{id:t,target:e.id,label:Pe(e),kind:e.kind,kindGlyph:jo(e.kind),provenance:e.provenance,provenanceGlyph:Pt(e.provenance),provenanceTitle:Mn(e.provenance),selected:e.id===n}}function Hx(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:Ti(t.id,i,n)}function Bx(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var Wx=["link:links-to:"];function Kx(t){return Wx.some(e=>t.id.startsWith(e))}function Vx(t){return t.id.startsWith("link:mentions:")}function jx(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(Ti(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function qx(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(Ti(`mentioned-by:${o.source}`,a,r))}return i}function Yx(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var Si={loading:"Loading…",noSelection:"Select anything to see what it connects to.",unknown:"This node is not in the current graph.",isolated:"Nothing links to or from this yet."};function Va(t){return{subject:null,groups:[],tags:[],empty:t}}function vf(t,e){if(t===null)return Va(Si.loading);if(e===null)return Va(Si.noSelection);let n=Nt(t),r=Ho(n,e);if(r===null)return Va(Si.unknown);let i=Bx(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,rows:d})},s=h=>h.map(d=>Hx(d,i,e)).filter(d=>d!==null);a(Ka.links,s(r.links.filter(Kx)));let l=Wo(n.edges).get(e)??[];a(Ka.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Ti(`backlink:${h.id}`,h,e))),a(Ka.mentions,[...s(r.links.filter(Vx)),...qx(n,e,i,e)]);let u=Yx(e),c=u===null?[]:jx(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],empty:Si.isolated}:{subject:r.label,groups:o,tags:c,empty:null}}var Xx={notes:0,repo:null,nodes:0},Zx=["note"];function yf(t){if(t===null)return Xx;let e=t.model.nodes;return{notes:e.filter(n=>Zx.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function Qx(t){return t===null||t==="missing"?"unindexed":t}function wf(t){return[`vault:${t.notes}`,`repo:${Qx(t.repo)}`,`${t.nodes} nodes`]}var Jx={live:{label:"live",tone:"ok",hint:"watching the vault and the repository for changes"},reconnecting:{label:"reconnecting",tone:"warn",hint:"the event stream dropped — retrying, and everything refetches when it returns"},offline:{label:"offline",tone:"bad",hint:"the workspace server is gone — use ⟳ to retry"}};function ja(t){return Jx[t]}var e_={tree:{title:"Tree",body:"The vault and repository outline, expandable, filterable, with provenance markers.",phase:"P2"},note:{title:"Note",body:"Select anything to read it here — rendered Markdown, front matter, tags and wikilinks.",phase:"P2"},graph:{title:"Graph",body:"The knowledge graph, laid out and navigable, with the selection's neighbourhood highlighted.",phase:"P3"}};function bf(t){return e_[t]}var qa={title:"Context",body:"Links, backlinks and mentions for whatever is selected.",phase:"P2"},xf="—";function _f(t,e,n,r){return{cwd:t===""?xf:t,selection:e??"nothing selected",connection:ja(n),stamp:r}}function kf(t){return t===null?xf:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}function Ef(t){return t.map((e,n)=>({column:e,divider:n<t.length-1&&t_(e.id)?e.id:null}))}function t_(t){return nf.includes(t)}var Sf="Search…";function Ya(t){return t?"⌘K":"Ctrl K"}function Tf(t){return`Search notes and repository (${t})`}function Xa(t){return/mac|iphone|ipad/i.test(t)}function Af({row:t,onSelect:e}){return x("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:x("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[x("span",{class:"weave-kind","aria-hidden":"true",children:t.kindGlyph}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label})]})})}function n_({group:t,onSelect:e}){return x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:t.heading}),x("ul",{class:"weave-ctx-rows",children:t.rows.map(n=>x(Af,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function r_({tag:t,onSelect:e}){return x("li",{class:"weave-ctx-tag",children:[x("span",{class:"weave-tag",children:["#",t.tag]}),x("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>x(Af,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function Rf(t){let e=vf(t.graph,t.selectedId);return x("div",{class:"weave-rail","aria-label":qa.title,children:[x("h2",{class:"weave-col-title",children:qa.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(n=>x(n_,{group:n,onSelect:t.onSelect},n.heading)),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x("h4",{class:"weave-ctx-heading",children:"TAGS"}),x("ul",{class:"weave-ctx-tags",children:e.tags.map(n=>x(r_,{tag:n,onSelect:t.onSelect},n.tag))})]})]})}function Cf(t){return x("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX,e.pointerId)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function i_({id:t,props:e}){let n=bf(t);return x("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[x("h2",{class:"weave-col-title",children:n.title}),t==="tree"?x(gf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(qh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,toolbar:e.toolbar,prompt:e.prompt,draft:e.draft,send:e.send}):null,t==="graph"?x(th,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit}):null,t==="graph"?x(Rf,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function o_({slot:t,props:e}){let n=t.divider;return x(Me,{children:[x(i_,{id:t.column.id,props:e}),n===null?null:x(Cf,{id:n,label:`Resize ${t.column.id} column`,onDown:(r,i)=>e.onDown(n,r,i),onMove:e.onMove,onUp:e.onUp,onKey:r=>e.onKey(n,r)})]})}function Lf(t){let e=le(null);return il(()=>{mf(e.current,sf(t.resolved))},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:Ef(t.resolved).map(n=>x(o_,{slot:n,props:t},n.column.id))})}function a_(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function Nf(t,e){let n=a_(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function Pf(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}function s_(t,e,n,r){return{divider:t,origin:e,base:n,pointerId:r}}function l_(t,e,n){return Ha(t.base,t.divider,e-t.origin,n)}function u_(t,e){let n=t.base.fractions,r=e.fractions;return n.tree!==r.tree||n.note!==r.note||n.graph!==r.graph}var Df=24;function c_(t){return t==="ArrowLeft"?-Df:t==="ArrowRight"?Df:0}function If(t){let e=null;return{onDown(n,r,i){e=s_(n,r,t.layout(),i)},onMove(n){e!==null&&t.setLayout(l_(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&u_(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=Ha(t.layout(),n,c_(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var Gf="image/png",Mf="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAALxElEQVRoBe1ZCXCU1R3/f+d+u5s9sleyOUlICBAMkQQQgpqBKqAoFQZFEYwWUAShjsco7dg4njRtPQcoXhSxWMGCimIYj1QqeICAcoQrd0iy2c1+u/vdZ9+m0xnFVCKw0+kMb+fb7/vevnnv//v/f//jvQVIYWtsbCn47uTJ3BQuAXgqJzdRM9CVyjVSCkACCUBIpfgAZCqnl5D8GJ5aBCm1ACALiGIqVZRqC7AIAGApRZBSCiUUBVN14/8YAJfAdN1MKU1TagEuwWEgp1T+1EYhRVUMhdNSmgdSagFeEHVJU/RUOkFKAThIWknLZNRUAkhFjKPSg2Muszocl/i8/mLT1M1IpO/rCBvaK/cePXGhwVxAANacYEHlkmEjymeguFNKUhShaToYhgG6rgJuAifL4oHjpxo3xdu/fAkBuSCWuSAAPNljLsvPH/lCusdfSVlIkFUFVCS0CQYkazkMuTGJEUAQJMrMEkTD3TvaWg/dJUab2s7XIsT5TkA6Cifl5434sCCvqEAS4sBzMdAVFdxYOjgxF6ShD6VTkBCjoEkiEKYBAX9WsaGT0yKh8DsAYvx8ZDhPADnW4SXlr+XnDh0WY3tBlgQwDQ10UQe/NQgOygkexoe4E4WE0AdgIkohWskiD440t9/EKX+cbd36PwNgd+ffMyR/2GJZjoOmySAryfITAxNHQkoyiLLYT6U2thHRB0djNPSuAY4lnyVQVLlMEMm9utp3zs59XmnSmeaelmZzgq7KkIjHgY3FQFOUfs4HHYUgawLQuAVspgdZRgcFAWRZFlRFRmMMtJvCMIKiZpyPBX5WHnA4hvkom/N6VVc+T4S/bXU4XCUCokZSaJokUd3JIDBqP4CuWDMIegRaIhIQyIFV1A+GCXbG2n/XVR2NN4AkiYokAE+g4mqapsrZRHSzFDvWPFhQPweAy+HxfZQdLBgtSVxPs8I/gdji1ZA2RVEAl98D106fAjzPw57P9gAb7QQLZQHVjIOAAKYHAjCheiLgyOY7360HmZdQiNWSlilM95c9npeT9yBJMxS0Q013DMYiAPxgQAzaiTOyxt/rcqXPa2tvApLA0zCcmsrQFIVhBmaxW+DJVQ/BroZdEOrugoUL58LB/Y0gCRLKAQZk5GTA0uXz4Z2t28Fuo+GeZTWwc+enIAhC8nerlbFeoagScbqrA3wejx8j3L0C3/XFYAAMygfs9pIyl9O1MhYNQzzGrgj1hrZKsoYbhorzXByurL4Mwt2nYcNL68DvcUKWzwlFQ7OQU8ugagoMLciEHL8Lcd6Etc+sAcxQYEzFJSAl95zID+KcBD294Q2JRGI5G2fB5fI8YnGUlAwGwGAohNMMU4cWc/Sx7KuG2vI8x8Jawjpso81mmZNmRTRBcV9B/PbmFcNL6zfD9voGmFRZDiamIfEwiERZmHbDIojHBQgOLQBJ1UBE1jGQdRTN0AVBXGfIJ+9FAstRlqqgKOttDEU/JQPMRn0/Wc2elUIMkzGEsTlXJXi+XUzEb3K48m7Jy7/0EcOQFUXRhtusNN7dE4aJl08EX4YXWFGFkqJC6Go/jaKO0p+JNeSweYUFkOb3wby5M5AlLPD2W+8ix1ZAkuWEw2FrzM4tu0/RGUaMs8+aOH4NTuIVkkmvBzWe+ClLDFhK+EpmVyL1lbsN/vWOrhM3khbrBo7nZjot+JFA5tBGTdcJUeIhnuDAjixgtzKQGcyCEWWjkBNz0Hz8GIR6QuByu4GiCYhGYuAPeKFg2HCw0BQc2PsN9PR0I+2bIKJ84XQ60BwOFJFIs635cLEO5FCLzb5D4rnZdXJz/ZHPDyxDfNz38pTxn5wJ5kcWmANziGYf9iFGuhbqBN7Js20WXZY/MOSWjZnZZS/abday1o6WQ5KsHHc60rOCmQGcZaMgoeza2dIKXW0toMgyijYYTKwaC5mZGdDe2g4CL0BHczN0oOcYyhcySmrZwWyQUaWXiLEf83w84fP6gjhppWN9B59XJThlc1C23KorJkEw94+KwE+4IT+4tqGh4Qeb7IEsgPmLZ69EaX4egSmfUTR2imacR+OhZi7T5XqPZXvtPT1dNarUvKmoZFqb00ZmtnR2ogJOA4eVAgrlA5Ig+rmvo7LBRB+CJPqppOs6SMixeVRqoAgGOUE/RFi+tbNt9xAgcmbl5Q3ZYrenR4pmVNxUfvVUXzwSzVVwwq243NNNTd/46rSJz53pEwNFIbP3xNtP2OhEFYqRR2UdX6OqYjdtd47ri/bSmirL/iFF3ZfPucfNxkInBIEDK00jpcu7E6KcYHmUlUUZBFlFOcAE3cRAkDTgBBlinAhokxZFkekf6e505AIqJBJsY119faD6uqmGpkiapPE2f0awCJXeB8W+wPOuuNzl23tgChL+2TOFT9JpIADJfmj77v0oup2wEDCpff+bewvGD98IFBWxEDiDwsf9hM8/05WT2xxLJEyaJmm7le7ho9FxkswvS/Dc/dFY/LlonNvSF49vY+Pc6hifWIpC8Dw+dqrS7XIj7zaocJQ1Kqdc0YZJ9PRwT2QJCrOU2+8Jjysd/envp08+FtBbr8RVaF710J2xfqEG+PqRD3x/THG+rUU0PLPtROE39uyMcWxXVycKLZM5Nmoc++dbS1csvnnrRx/vxVE9M8GTkV3qyw6Ee1u/qtOVyB50fajJvZs1Ofw3XQl/sF2OfDtz6W29TYfaF1hp+0IBhdFYLPrI8f31D+x88y+H4qz2G4vV6qXtrqdLKyrJ2b+YcJITbTNDVGjTvu3bf8D778s4kA98/3fIKps1BjOpsa5AuuXIod2vOBStHsXpqr6+SHX1pJrPWaqlINTW8QeU1aZnlZdR+eUlvyU0vY1kLCRptZiMg0F1EkHjBBgUQVQ27W+8dt+2nXYbSW5cNOf2Y8hDTr++7a9MU1vTG2Coh2PRo1WPPrZ1kSpKhkbInz39WM2+Hwh0xstZE5nOmx2YlamPhGWtIOeSxlioqV6K81W+YPbdLN1ZihEWLm/kqId0XT7sLyzo0riEDyfpRlRRNxk4jRJcQiEMtLtXyOt0IHYXlA45Xgiz4tmZubvwU60tkjdQ6khzLZIVExsz8tK9117+6Aw9xDxoIWweTQmNOEPeH72eFYCVIXHJNATAqBzd0Ce7fJmbuGhjKaIRf2Bn9lqAWqNi8WIqXUhvf3/VijXXPFCbyTC2+QppYSinN6wIHI2Z2DTM1Hc4KAPFePygE7PLoUhk7JMvLD+GJPoGyLxWmmb+XpI36kFRkGehAtxiqFo3SgtnPZL5r078H6gthzd345g6iTbk0ThmNuMYE1S4ozWSzNYlhU+Oo7stowRePJ18/qCutnvT75bVaR5fjeTyf6va019WJellKsxyAqcH/jR/7sHTEaVN541MtF/+N4UJc7MiHJ8f8GVUaqZqSlhstAnRisdfXHDWsvqsFkgKdfrQm+3olrwOF1feOLdk4q23B4cVvdawvhZ1AaBN1nBTV79MPpfOqaXdQmQ838OC1euTUbncjHP4nSoeWGF09d2VHLNu3Z3C8kWruTvueMqHXntfe3hD56HOYzWKIsefeWUJOrFIHgMMrp3ViQeapqRqbiVOWyfjJLlTZZwdjMrfAgb/itXmrqJJy0gMx47rUmSXf/pV3m1Lbm655f4X51oY5zgqLh7Red5u8PoXhElngsnkY5i4h6TwaswkGla/sfTrgdb7qb5zApCcsKTqDlTAkLertPNhAsMkq5pYzxDYJ1+9v2bX9xe8fuHKDJr2/nLL6vv+nOxfsOBJryli1zFGcKWN8hbzemiLyLX/6o0dted0OnHOAJLClFy1LEvBiMMYQSgMSHUUgUcoEpOApFmaolkGw3UrYbuR0I3dhKoLlEGmo2LDhTb4HGV4J1Fgv17RYr9+ddvit5LznUs7LwDJBUurby1C1aPW2LC+pbT67jTKTfssFOFFB1lOdJSF6lSKoHCStSgGj0qkMNrDhN97r7b/j7M5U2s9m+tr0XnLxXZRAxc1cFEDFzVwUQPnpoF/AbqLsVZFbswxAAAAAElFTkSuQmCC";function Of(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:[x("img",{class:"weave-brand-mark",src:`data:${Gf};base64,${Mf}`,alt:"",width:18,height:18}),"pi-weave"]}),x("button",{type:"button",class:"weave-search",title:Tf(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:Sf}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:wf(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),x("button",{type:"button",class:"weave-refresh",onClick:t.onRefresh,title:"Refetch everything",children:"⟳"}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:[x("span",{class:"weave-conn-dot","aria-hidden":"true",children:"●"}),t.connection.label]})]})}function d_({group:t}){return x("div",{children:[x("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>x("div",{class:"weave-key-row",children:[x("kbd",{class:"weave-key-combo",children:e.combo}),x("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function Ff(t){let e=ci(),n=t.shortcut.slice(0,-1);return x("div",{class:"weave-scrim",onClick:t.onClose,children:x("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":Wa,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:Wa}),x("div",{class:"weave-keys",children:ff(n).map(r=>x(d_,{group:r},r.title))}),x("p",{class:"weave-help-foot",children:[x("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),x("span",{class:"weave-help-hint",children:pf})]})]})})}function zf(t,e){let n=r=>{let i=uf(cf(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function $f({model:t}){return x("footer",{class:"weave-status",children:[x("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),x("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),x("span",{class:"weave-status-stamp",title:"data as of",children:kf(t.stamp)}),x("span",{class:`weave-conn weave-conn-${t.connection.tone}`,title:t.connection.hint,children:t.connection.label})]})}var Za=["system","light","dark"],Uf="pi-weave.theme.v1";function h_(t){return t==="system"||t==="light"||t==="dark"}function Ai(t){try{let e=t.getItem(Uf);return h_(e)?e:null}catch{return null}}function Hf(t,e){try{return t.setItem(Uf,e),!0}catch{return!1}}function Ri(t){let e=Za.indexOf(t);return Za[(e+1)%Za.length]??"system"}function Bf(t,e){return t==="system"?e:t}function Ci(t){return t==="system"?null:t}var f_={dark:"●",system:"◐",light:"○"};function Wf(t){return{glyph:f_[t],hint:`Colour theme: ${t} — click for ${Ri(t)}`}}function Kf(t,e){let n=()=>e(t.innerWidth);return t.addEventListener("resize",n),()=>t.removeEventListener("resize",n)}function p_(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function Vf(t){let[e,n]=Ne(t.initialWidth),[r,i]=Ne(null),[o,a]=Ne(()=>of(localStorage,t.initialWidth)),[s,l]=Ne(dn),[u,c]=Ne(()=>Ai(localStorage)??"system"),[h,d]=Ne(()=>kr(window)),f=le(null),g=le(null),m=le({layout:o,width:e,overlay:r});m.current={layout:o,width:e,overlay:r};let v=we(()=>gd({fetch:St,select:A=>{pi(St,A)},onChange:l}),[]);ne(()=>{let A=zd({fetch:St,open:td});return f.current=A,()=>A.stop()},[]);let y=le(!1),w=le(location.hash);ne(()=>{y.current&&(Id(localStorage,Ue.value),history.replaceState(null,"",Pf(Ue.value)))},[Ue.value]),ne(()=>{if(y.current||Ce.value===null||(y.current=!0,Ue.value!==null))return;let A=Nf(w.current,Ce.value);if(A!==null)pi(St,A);else{let N=Gd(Ce.value,localStorage);N!==null&&pi(St,N)}},[Ce.value]),ne(()=>Od(A=>v.send({type:"loaded",payload:A})),[]),ne(()=>md(window,()=>da(v.state())),[]),ne(()=>Kf(window,n),[]),ne(()=>p_(Ci(u)),[u]),ne(()=>{Hf(localStorage,u)},[u]),ne(()=>ll(window,d),[]),ne(()=>zf(document,{context:()=>({overlay:m.current.overlay,hasSelection:Ue.value!==null}),run:A=>hf(A,{setOverlay:i,focusSelector:N=>df(document,N),fitGraph:()=>g.current?.(),clearSelection:()=>v.send({type:"navigate",id:null}),toggleEdit:()=>v.send({type:"toggle"}),saveNote:()=>v.send({type:"save"}),cycleTheme:()=>c(N=>Ri(N))})}),[]);let k=we(()=>tf(o,e,Zh(e)),[o,e]),_=we(()=>If({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:a,persist:A=>{af(localStorage,A)}}),[]);return x(Me,{children:[x(Of,{summary:yf(Ce.value),connection:ja(un.value),shortcut:Ya(Xa(t.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:Wf(u),onTheme:()=>c(A=>Ri(A))}),x(Lf,{resolved:k,onDown:_.onDown,onMove:_.onMove,onUp:_.onUp,onKey:_.onKey,scheme:Bf(u,h),bootFailed:Bn.value,graph:Ce.value,note:Wn.value,selectedId:Ue.value,onSelect:A=>v.send({type:"navigate",id:A}),now:Date.now(),toolbar:pd(s),prompt:fd(s),draft:s.draft,send:v.send,renderer:Oc,storage:localStorage,host:window,fit:g}),x($f,{model:_f(t.cwd,Ue.value,un.value,Ce.value?.model.generatedAt??null)}),r==="search"?x(Pd,{graph:Ce.value,onSelect:A=>v.send({type:"navigate",id:A}),onClose:()=>i(null),ports:{fetch:St,now:Date.now,delay:(A,N)=>{setTimeout(A,N)}}}):null,r==="help"?x(Ff,{shortcut:Ya(Xa(t.platform)),onClose:()=>i(null)}):null]})}var jf=`
401
+ --weave-bg:#f8ede3;--weave-panel:#fdf9f3;--weave-raise:#f1e3d4;--weave-fg:#43303a;--weave-dim:#7c6257;
402
+ --weave-faint:#7f6455;--weave-line:#dfd3c3;--weave-line-strong:#d0b8a8;
403
+ --weave-accent:#85586f;--weave-ok:#3f704e;--weave-warn:#a05a1c;--weave-bad:#a93b45;
404
+ --weave-new:rgba(133,88,111,.16);
405
+ --weave-page:#fdf9f3;
406
+ `,g_=`
401
407
  :root{
402
- --weave-bg:#141317;--weave-panel:#191820;--weave-fg:#e8e6ee;--weave-dim:#8f8a9c;
403
- --weave-faint:#5d5869;--weave-line:#26242e;--weave-line-strong:#343141;
404
- --weave-accent:#a48cff;--weave-ok:#4ade80;--weave-warn:#fbbf24;--weave-bad:#f87171;
408
+ --weave-bg:#2a2f4f;--weave-panel:#343b61;--weave-raise:#3d4570;--weave-fg:#fde2f3;--weave-dim:#bb9ecf;
409
+ --weave-faint:#aca3d4;--weave-line:#3b4266;--weave-line-strong:#4a527e;
410
+ --weave-accent:#b79fdd;--weave-ok:#7fc49a;--weave-warn:#e8b04c;--weave-bad:#eb93a1;
411
+ --weave-new:rgba(145,127,179,.22);
405
412
  --weave-row:26px;--weave-gutter:10px;
406
- }
413
+ /* The reading gutter is note-only: prose wants a wider margin than chrome.
414
+ Rails, rows and bars keep --weave-gutter, so density is a property of the
415
+ furniture and generosity a property of the page. */
416
+ --weave-note-gutter:18px;
417
+ /* The desk-and-page split. The workspace is a desk of instruments — tree,
418
+ graph, rail, bars — on the --weave-bg ground; the note column is the one
419
+ *page* lying on it, one step off the desk and one step off the canvas:
420
+ dark keeps a deeper indigo sheet, light keeps the linen panel. Two voices
421
+ in total: sans for instruments and prose alike, mono for data — a third
422
+ face was tried (serif prose) and withdrawn at the user's call; two voices
423
+ read calmer than three. The CSP allows nothing fetched, and both are
424
+ system stacks. */
425
+ --weave-page:#272c4a;
426
+ /* Two radii, per the plan: hairline-sharp for controls (a 4 px corner is
427
+ the difference between a control and a card), one softer corner for the
428
+ two overlays that float above the grid. Tag pills are 999px — a capsule
429
+ shape, not a scale step. The gate test below refuses any literal px
430
+ radius so the scale cannot drift back. */
431
+ --weave-radius:4px;--weave-radius-pop:7px;
432
+ /* The type ramp, role-named because sizes drift and roles stick. Seven
433
+ steps (9.5/10.5/11.5/12/13/14/15px); every font-size in this sheet is
434
+ one of these vars — that is a gate, not a convention:
435
+ prov 9.5 micro badges, kind glyphs, uppercase key groups
436
+ caption 10.5 chips, meta, counts, legend, column overlines
437
+ ui 11.5 status bar, note meta line, small controls
438
+ row 12 list rows, text inputs, the mono editor, inline code
439
+ base 13 body copy, h3-h6
440
+ subhead 14 palette input, h2, header icon buttons
441
+ title 15 note title, h1
442
+ Two earlier sizes were merged into neighbours: 9px glyphs to prov, and
443
+ the 10px column overlines to caption (caps plus .09em tracking already
444
+ read larger than their point size suggests). */
445
+ --weave-px-prov:9.5px;--weave-px-caption:10.5px;--weave-px-ui:11.5px;
446
+ --weave-px-row:12px;--weave-px-base:13px;--weave-px-subhead:14px;--weave-px-title:15px;
447
+ }
448
+ /* The light tokens, shared verbatim by the attribute branch and the media
449
+ query below — one const interpolated twice is the only way CSS gets
450
+ "these are the same colours" without a preprocessor. Which branch wins is
451
+ theme.model.ts's business: the attribute carries a *manual* choice, the
452
+ media query the system default, and the :not() is what lets the two coexist
453
+ without a manual "dark" being dragged back into light by the OS. */
407
454
  @media (prefers-color-scheme: light){
408
- :root{
409
- --weave-bg:#faf9f7;--weave-panel:#ffffff;--weave-fg:#1c1b19;--weave-dim:#6f6b66;
410
- --weave-faint:#9a958e;--weave-line:#e6e3de;--weave-line-strong:#d2cec8;
411
- --weave-accent:#6d4aff;--weave-ok:#15803d;--weave-warn:#b45309;--weave-bad:#b91c1c;
455
+ :root:not([data-weave-theme="dark"]){
456
+ ${jf}
412
457
  }
413
458
  }
414
- body{font-size:13px}
459
+ :root[data-weave-theme="light"]{
460
+ ${jf}
461
+ }
462
+ body{font-size:var(--weave-px-base)}
415
463
  #app{height:100%;display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
416
464
 
417
465
  /* header --------------------------------------------------------------- */
@@ -419,35 +467,44 @@ body{font-size:13px}
419
467
  display:flex;align-items:center;gap:14px;padding:0 var(--weave-gutter);
420
468
  height:34px;border-bottom:1px solid var(--weave-line);background:var(--weave-panel);
421
469
  }
422
- .weave-brand{font-weight:600;letter-spacing:.01em;white-space:nowrap}
470
+ .weave-brand{display:inline-flex;align-items:center;gap:6px;font-size:var(--weave-px-subhead);font-weight:600;letter-spacing:.01em;white-space:nowrap}
471
+ .weave-brand-mark{height:20px;width:20px;border-radius:var(--weave-radius)}
423
472
  /* A button styled as a search field: the palette owns the only text input,
424
473
  so this opens it rather than pretending to accept a query. */
425
474
  .weave-search{
426
475
  display:flex;align-items:center;gap:6px;flex:0 1 260px;min-width:0;
427
- height:22px;padding:0 7px;font:inherit;font-size:12px;text-align:left;cursor:pointer;
476
+ height:22px;padding:0 7px;font:inherit;font-size:var(--weave-px-row);text-align:left;cursor:pointer;
428
477
  color:var(--weave-dim);background:var(--weave-bg);
429
- border:1px solid var(--weave-line-strong);border-radius:4px;
478
+ border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
430
479
  }
431
480
  .weave-search:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
432
481
  .weave-search-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
433
482
  .weave-search kbd{
434
- font-family:var(--weave-mono);font-size:10.5px;color:var(--weave-faint);
435
- padding:1px 5px;border:1px solid var(--weave-line-strong);border-radius:3px;white-space:nowrap;
483
+ font-family:var(--weave-mono);font-size:var(--weave-px-caption);color:var(--weave-faint);
484
+ padding:1px 5px;border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);white-space:nowrap;
436
485
  }
437
486
  .weave-summary{
438
487
  margin-left:auto;display:flex;gap:9px;font-family:var(--weave-mono);
439
- font-size:11.5px;color:var(--weave-dim);white-space:nowrap;
488
+ font-size:var(--weave-px-ui);color:var(--weave-dim);white-space:nowrap;
440
489
  }
441
490
  .weave-summary-part+.weave-summary-part::before{content:"·";margin-right:9px;color:var(--weave-faint)}
442
491
  .weave-refresh{
443
- font:inherit;font-size:14px;line-height:1;color:var(--weave-dim);background:none;
444
- border:0;padding:3px 5px;border-radius:4px;cursor:pointer;
492
+ font:inherit;font-size:var(--weave-px-subhead);line-height:1;color:var(--weave-dim);background:none;
493
+ border:0;padding:3px 5px;border-radius:var(--weave-radius);cursor:pointer;
445
494
  }
446
495
  .weave-refresh:hover{color:var(--weave-fg);background:var(--weave-line)}
496
+ /* The theme cycle (shell/theme.model.ts). Same shape as the refresh button:
497
+ an icon-size control in a 34 px bar, glyph-only because the filled/half/
498
+ hollow family already means something in this workspace. */
499
+ .weave-theme{
500
+ font:inherit;font-size:var(--weave-px-base);line-height:1;color:var(--weave-dim);background:none;
501
+ border:0;padding:3px 6px;border-radius:var(--weave-radius);cursor:pointer;
502
+ }
503
+ .weave-theme:hover{color:var(--weave-fg);background:var(--weave-line)}
447
504
 
448
505
  /* connection indicator -------------------------------------------------- */
449
- .weave-conn{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;color:var(--weave-dim);white-space:nowrap}
450
- .weave-conn-dot{font-size:9px;line-height:1}
506
+ .weave-conn{display:inline-flex;align-items:center;gap:5px;font-size:var(--weave-px-ui);white-space:nowrap}
507
+ .weave-conn-dot{font-size:var(--weave-px-prov);line-height:1}
451
508
  .weave-conn-ok .weave-conn-dot,.weave-conn-ok{color:var(--weave-ok)}
452
509
  .weave-conn-warn .weave-conn-dot,.weave-conn-warn{color:var(--weave-warn)}
453
510
  .weave-conn-bad .weave-conn-dot,.weave-conn-bad{color:var(--weave-bad)}
@@ -468,13 +525,17 @@ body{font-size:13px}
468
525
  background:var(--weave-bg);
469
526
  }
470
527
  .weave-col-title{
471
- margin:0;padding:5px var(--weave-gutter) 4px;font-size:10px;font-weight:600;
528
+ margin:0;padding:5px var(--weave-gutter) 4px;font-size:var(--weave-px-caption);font-weight:600;
472
529
  letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint);
473
530
  border-bottom:1px solid var(--weave-line);
474
531
  }
475
532
  /* Title, then the graph (which takes the slack), then the context rail. The
476
- \`1fr\` is what gives \`.weave-graph-canvas\` a definite height to measure. */
477
- .weave-col-graph{display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
533
+ 1fr is what gives .weave-graph-canvas a definite height to measure, and the
534
+ rail's row is a fixed fraction of the column — not content-sized — so
535
+ moving the selection between a sparsely-connected note and a richly
536
+ connected one never repartitions the right-hand column: the rail scrolls
537
+ inside the same region instead of squeezing the graph. */
538
+ .weave-col-graph{display:grid;grid-template-rows:auto minmax(0,1fr) minmax(96px,40%);background:var(--weave-bg)}
478
539
 
479
540
  /* dividers -------------------------------------------------------------- */
480
541
  .weave-divider{
@@ -496,14 +557,14 @@ body{font-size:13px}
496
557
  border-bottom:1px solid var(--weave-line);
497
558
  }
498
559
  .weave-filter{
499
- flex:1;min-width:0;height:21px;padding:0 6px;font:inherit;font-size:11.5px;
560
+ flex:1;min-width:0;height:21px;padding:0 6px;font:inherit;font-size:var(--weave-px-row);
500
561
  color:var(--weave-fg);background:var(--weave-panel);
501
- border:1px solid var(--weave-line-strong);border-radius:4px;
562
+ border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
502
563
  }
503
564
  .weave-chip{
504
- font:inherit;font-size:10.5px;line-height:1;white-space:nowrap;cursor:pointer;
565
+ font:inherit;font-size:var(--weave-px-caption);line-height:1;white-space:nowrap;cursor:pointer;
505
566
  color:var(--weave-dim);background:var(--weave-panel);padding:4px 6px;
506
- border:1px solid var(--weave-line-strong);border-radius:4px;
567
+ border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius);
507
568
  }
508
569
  .weave-chip:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
509
570
  .weave-rows{
@@ -518,41 +579,78 @@ body{font-size:13px}
518
579
  }
519
580
  .weave-row:hover{background:var(--weave-line)}
520
581
  .weave-row-on{background:var(--weave-line-strong);color:var(--weave-fg)}
582
+ /* The selection has one voice. On the stronger --weave-line-strong ground
583
+ every quieter token fails contrast — measured 3.2:1 (dark faint) to 2.9:1
584
+ (light faint), and even --weave-dim lands under 3 — so a selected row's
585
+ kind, provenance and meta children join its label in --weave-fg. The
586
+ provenance glyph shape carries the distinction the colour swap drops;
587
+ elsewhere the hues are unaffected. The palette's hit rows need the same
588
+ remap: same selected ground, same failure. */
589
+ .weave-row-on .weave-twisty,.weave-row-on .weave-kind,.weave-row-on .weave-prov,
590
+ .weave-row-on .weave-meta{color:var(--weave-fg)}
591
+ .weave-hit-on .weave-hit-badge,.weave-hit-on .weave-hit-detail{color:var(--weave-fg)}
592
+ /* A newly-arrived node (a file or note added since the last update, §6):
593
+ one short highlight that fades while the label settles from bold back to
594
+ normal. The class is computed from the frame diff in workspace.ts and
595
+ expires with it, so collapsing and re-expanding later does not replay the
596
+ arrival, and the first load never flashes the whole tree. */
597
+ .weave-row-new{animation:weave-row-new 2.6s ease-out both}
598
+ @keyframes weave-row-new{
599
+ 0%{background:var(--weave-new);font-weight:700}
600
+ 40%{font-weight:700}
601
+ 100%{background:transparent;font-weight:400}
602
+ }
521
603
  .weave-twisty{width:10px;flex:none;color:var(--weave-faint);cursor:pointer;text-align:center}
522
- .weave-kind{flex:none;color:var(--weave-faint);font-size:11px}
523
- .weave-prov{flex:none;font-size:9px}
604
+ .weave-kind{flex:none;color:var(--weave-faint);font-size:var(--weave-px-ui)}
605
+ .weave-prov{flex:none;font-size:var(--weave-px-prov)}
524
606
  .weave-prov-human{color:var(--weave-ok)}
525
607
  .weave-prov-agent{color:var(--weave-accent)}
526
608
  .weave-prov-generated{color:var(--weave-faint)}
527
609
  .weave-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
528
- .weave-meta{flex:none;font-size:10.5px;color:var(--weave-faint)}
610
+ .weave-meta{flex:none;font-size:var(--weave-px-caption);color:var(--weave-faint)}
529
611
  .weave-tree-empty{flex:1;margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim)}
530
612
  .weave-tree-count{
531
- margin:0;padding:3px var(--weave-gutter);font-size:10.5px;color:var(--weave-faint);
613
+ margin:0;padding:3px var(--weave-gutter);font-size:var(--weave-px-caption);color:var(--weave-faint);
532
614
  border-top:1px solid var(--weave-line);
533
615
  }
534
616
 
535
617
  /* note column ----------------------------------------------------------- */
536
- .weave-note{display:flex;flex-direction:column;min-height:0;flex:1;overflow:auto}
537
- .weave-note-empty{flex:1;margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim);max-width:44ch;line-height:1.5}
538
- .weave-note-head{padding:10px var(--weave-gutter) 8px;border-bottom:1px solid var(--weave-line)}
539
- .weave-note-title{margin:0 0 4px;font-size:15px;font-weight:600;line-height:1.3;color:var(--weave-fg)}
540
- .weave-note-meta{margin:0;display:flex;gap:10px;font-size:11px;color:var(--weave-dim);flex-wrap:wrap}
618
+ /* The page. The desk holds instruments; this column is what the user reads,
619
+ so it lies on --weave-page — one step off the desk and the canvas grounds —
620
+ in the serif reading voice. The 2px rule flush to its left edge is the
621
+ spine: it takes the note's provenance colour (see the --weave-spine map),
622
+ so the document's origin is readable peripherally, before any glyph is.
623
+ Head, body and editor share the --weave-note-gutter so toggling the editor
624
+ does not reflow the measure. */
625
+ .weave-note{display:flex;flex-direction:column;min-height:0;flex:1;overflow:auto;background:var(--weave-page)}
626
+ .weave-note-human{--weave-spine:var(--weave-ok)}
627
+ .weave-note-agent{--weave-spine:var(--weave-accent)}
628
+ .weave-note-generated{--weave-spine:var(--weave-faint)}
629
+ .weave-note{border-left:2px solid var(--weave-spine,transparent)}
630
+ .weave-note-empty{flex:1;margin:0;padding:14px var(--weave-note-gutter);color:var(--weave-dim);max-width:44ch;line-height:1.5;background:var(--weave-page)}
631
+ .weave-note-head{padding:12px var(--weave-note-gutter) 8px;border-bottom:1px solid var(--weave-line)}
632
+ .weave-note-title{margin:0 0 4px;font-size:var(--weave-px-title);font-weight:600;line-height:1.3;color:var(--weave-fg)}
633
+ .weave-note-meta{margin:0;display:flex;gap:10px;font-size:var(--weave-px-ui);color:var(--weave-dim);flex-wrap:wrap}
541
634
  .weave-note-time{color:var(--weave-faint)}
542
635
  .weave-note-tags{margin:5px 0 0;display:flex;gap:5px;flex-wrap:wrap}
543
636
  .weave-tag{
544
- font-size:10.5px;color:var(--weave-accent);background:var(--weave-panel);
545
- padding:1px 6px;border:1px solid var(--weave-line-strong);border-radius:9px;
546
- }
547
- .weave-note-body{padding:10px var(--weave-gutter) 24px;line-height:1.6;max-width:78ch;color:var(--weave-fg)}
637
+ font-size:var(--weave-px-caption);color:var(--weave-accent);background:var(--weave-panel);
638
+ padding:1px 6px;border:1px solid var(--weave-line-strong);border-radius:999px;
639
+ }
640
+ /* Prose runs the column's full width — a 66ch measure was tried and
641
+ withdrawn at the user's call: this is a workspace, and the note shares the
642
+ width the desk gives it. Code and the raw editor stay mono deliberately —
643
+ reading prose and reading raw are different postures, and the face switch
644
+ is the toggle. */
645
+ .weave-note-body{padding:12px var(--weave-note-gutter) 28px;line-height:1.6;color:var(--weave-fg)}
548
646
  .weave-note-body>*:first-child{margin-top:0}
549
647
  .weave-note-body h1,.weave-note-body h2,.weave-note-body h3,
550
648
  .weave-note-body h4,.weave-note-body h5,.weave-note-body h6{
551
- margin:18px 0 6px;font-weight:600;line-height:1.3;
649
+ margin:20px 0 7px;font-weight:600;line-height:1.35;letter-spacing:.005em;
552
650
  }
553
- .weave-note-body h1{font-size:15px}
554
- .weave-note-body h2{font-size:14px}
555
- .weave-note-body h3,.weave-note-body h4,.weave-note-body h5,.weave-note-body h6{font-size:13px}
651
+ .weave-note-body h1{font-size:var(--weave-px-title)}
652
+ .weave-note-body h2{font-size:var(--weave-px-subhead)}
653
+ .weave-note-body h3,.weave-note-body h4,.weave-note-body h5,.weave-note-body h6{font-size:var(--weave-px-base)}
556
654
  .weave-note-body p,.weave-note-body ul,.weave-note-body ol,.weave-note-body blockquote{margin:0 0 10px}
557
655
  .weave-note-body ul,.weave-note-body ol{padding-left:20px}
558
656
  .weave-note-body li{margin:2px 0}
@@ -560,24 +658,32 @@ body{font-size:13px}
560
658
  padding-left:10px;border-left:2px solid var(--weave-line-strong);color:var(--weave-dim);
561
659
  }
562
660
  .weave-note-body code{
563
- font-family:var(--weave-mono);font-size:11.5px;padding:1px 4px;
564
- background:var(--weave-panel);border:1px solid var(--weave-line);border-radius:3px;
661
+ font-family:var(--weave-mono);font-size:var(--weave-px-row);padding:1px 4px;
662
+ background:var(--weave-panel);border:1px solid var(--weave-line);border-radius:var(--weave-radius);
565
663
  }
566
664
  .weave-note-body pre{
567
665
  margin:0 0 10px;padding:8px 10px;overflow:auto;
568
- background:var(--weave-panel);border:1px solid var(--weave-line);border-radius:5px;
666
+ background:var(--weave-panel);border:1px solid var(--weave-line);border-radius:var(--weave-radius);
569
667
  }
570
668
  .weave-note-body pre code{padding:0;background:none;border:0}
571
669
  .weave-note-body hr{margin:14px 0;border:0;border-top:1px solid var(--weave-line)}
572
- .weave-note-body table{border-collapse:collapse;margin:0 0 10px;font-size:12px}
670
+ .weave-note-body table{border-collapse:collapse;margin:0 0 10px;font-size:var(--weave-px-row)}
573
671
  .weave-note-body th,.weave-note-body td{padding:3px 8px;border:1px solid var(--weave-line);text-align:left}
574
672
  .weave-note-body th{color:var(--weave-dim);font-weight:600}
575
673
  .weave-note-body img{max-width:100%;height:auto}
576
- .weave-note-body a{color:var(--weave-accent);text-decoration:none}
577
- .weave-note-body a:hover{text-decoration:underline}
578
- /* Wikilinks carry no href — they drive the §1.3 bus, not the browser — so the
579
- pointer has to be restored by hand. A ghost is a name with no note behind
580
- it: Obsidian's dashed, dimmed affordance to create one. */
674
+ /* Two link species, one underline discipline. An external link is underlined
675
+ *before* any hover, in the quiet line-strong rather than the accent — it
676
+ announces "this leaves the workspace" while it is still inert. A wikilink
677
+ stays clean text until hover (it drives the §1.3 bus, not the browser, so
678
+ the pointer is restored by hand); leaving vs staying is legible at a
679
+ glance, with the same hover response once you commit. */
680
+ .weave-note-body a{
681
+ color:var(--weave-accent);text-decoration:underline;text-decoration-color:var(--weave-line-strong);
682
+ text-decoration-thickness:1px;text-underline-offset:2px;
683
+ }
684
+ .weave-note-body a:hover{text-decoration-color:var(--weave-accent)}
685
+ /* A ghost is a name with no note behind it: Obsidian's dashed, dimmed
686
+ affordance to create one. */
581
687
  .weave-wiki{cursor:pointer;color:var(--weave-accent);text-decoration:none}
582
688
  .weave-wiki:hover{text-decoration:underline}
583
689
  .weave-wiki-ghost{
@@ -594,17 +700,17 @@ body{font-size:13px}
594
700
  padding:5px var(--weave-gutter);border-bottom:1px solid var(--weave-line);
595
701
  }
596
702
  .weave-note-toggle,.weave-note-save,.weave-note-open,.weave-note-action{
597
- font:inherit;font-size:11px;padding:2px 8px;cursor:pointer;
703
+ font:inherit;font-size:var(--weave-px-ui);padding:2px 8px;cursor:pointer;
598
704
  color:var(--weave-fg);background:var(--weave-raise);
599
- border:1px solid var(--weave-line);border-radius:4px;
705
+ border:1px solid var(--weave-line);border-radius:var(--weave-radius);
600
706
  }
601
707
  .weave-note-toggle:hover,.weave-note-save:hover,.weave-note-open:hover,.weave-note-action:hover{
602
708
  border-color:var(--weave-accent);
603
709
  }
604
710
  .weave-note-toggle[aria-pressed="true"]{border-color:var(--weave-accent);color:var(--weave-accent)}
605
711
  .weave-note-save:disabled{opacity:.45;cursor:default;border-color:var(--weave-line)}
606
- .weave-note-dirty{color:var(--weave-accent);font-size:14px;line-height:1}
607
- .weave-note-status{font-size:11px;color:var(--weave-dim)}
712
+ .weave-note-dirty{color:var(--weave-accent);font-size:var(--weave-px-subhead);line-height:1}
713
+ .weave-note-status{font-size:var(--weave-px-ui);color:var(--weave-dim)}
608
714
  .weave-note-status-ok{color:var(--weave-ok)}
609
715
  .weave-note-status-warn{color:var(--weave-warn)}
610
716
  /* The prompt takes the full row rather than sitting inline: reload-or-overwrite
@@ -612,18 +718,18 @@ body{font-size:13px}
612
718
  two buttons reads as a hint. */
613
719
  .weave-note-prompt{
614
720
  flex-basis:100%;display:flex;align-items:center;gap:8px;flex-wrap:wrap;
615
- margin-top:4px;padding:5px 8px;border-radius:4px;
721
+ margin-top:4px;padding:5px 8px;border-radius:var(--weave-radius);
616
722
  background:var(--weave-raise);border:1px solid var(--weave-warn);
617
723
  }
618
724
  .weave-note-prompt-conflict,.weave-note-prompt-collision{border-color:var(--weave-warn)}
619
725
  .weave-note-prompt-external,.weave-note-prompt-discard{border-color:var(--weave-line)}
620
- .weave-note-prompt-text{margin:0;font-size:11px;color:var(--weave-fg)}
726
+ .weave-note-prompt-text{margin:0;font-size:var(--weave-px-ui);color:var(--weave-fg)}
621
727
  .weave-note-prompt-actions{margin:0;display:flex;gap:6px;flex-wrap:wrap}
622
728
  .weave-note-editor{
623
729
  flex:1;min-height:240px;resize:none;
624
- padding:10px var(--weave-gutter) 24px;
625
- font:inherit;font-family:var(--weave-mono);font-size:12px;line-height:1.6;
626
- color:var(--weave-fg);background:var(--weave-bg);border:0;outline-offset:-2px;
730
+ padding:10px var(--weave-note-gutter) 24px;
731
+ font:inherit;font-family:var(--weave-mono);font-size:var(--weave-px-row);line-height:1.6;
732
+ color:var(--weave-fg);background:var(--weave-page);border:0;outline-offset:-2px;
627
733
  }
628
734
 
629
735
  /* graph column ---------------------------------------------------------- */
@@ -642,15 +748,18 @@ body{font-size:13px}
642
748
  display:flex;align-items:center;gap:6px;flex-wrap:wrap;
643
749
  padding:5px var(--weave-gutter);border-top:1px solid var(--weave-line);
644
750
  }
645
- .weave-depth{font:inherit;font-size:10.5px;padding:3px 4px}
646
751
  .weave-graph-legend{
647
- margin-left:auto;display:flex;gap:9px;font-size:10.5px;color:var(--weave-faint);
752
+ margin-left:auto;display:flex;gap:9px;font-size:var(--weave-px-caption);color:var(--weave-faint);
648
753
  white-space:nowrap;
649
754
  }
650
755
  .weave-legend-on{color:var(--weave-accent)}
651
756
  .weave-legend-near{color:var(--weave-fg)}
757
+ /* The third entry is the one the graph actually draws most when a selection
758
+ dims its neighbourhood: unrelated nodes recede to --weave-faint, and the
759
+ legend names that state instead of leaving it unexplained. */
760
+ .weave-legend-dim{color:var(--weave-faint)}
652
761
  .weave-graph-count{
653
- margin:0;padding:3px var(--weave-gutter);font-size:10.5px;color:var(--weave-faint);
762
+ margin:0;padding:3px var(--weave-gutter);font-size:var(--weave-px-caption);color:var(--weave-faint);
654
763
  border-top:1px solid var(--weave-line);
655
764
  }
656
765
 
@@ -660,21 +769,21 @@ body{font-size:13px}
660
769
  \`noteEmptyMessage\`, \`graphEmptyMessage\`, \`RAIL_EMPTY\`), each rendered as a
661
770
  plain paragraph, so the shared placeholder had no callers left. */
662
771
  .weave-rail{
663
- display:flex;flex-direction:column;min-height:96px;max-height:46%;overflow:auto;
772
+ display:flex;flex-direction:column;min-height:0;overflow:auto;
664
773
  border-top:1px solid var(--weave-line);background:var(--weave-panel);
665
774
  }
666
775
  .weave-ctx-empty{margin:0;padding:10px var(--weave-gutter);color:var(--weave-dim);line-height:1.5}
667
776
  .weave-ctx-group{padding:5px var(--weave-gutter) 2px}
668
777
  .weave-ctx-heading{
669
- margin:0 0 2px;font-size:9.5px;font-weight:600;letter-spacing:.09em;color:var(--weave-faint);
778
+ margin:0 0 2px;font-size:var(--weave-px-caption);font-weight:600;letter-spacing:.09em;color:var(--weave-faint);
670
779
  }
671
780
  .weave-ctx-rows,.weave-ctx-tags{margin:0;padding:0;list-style:none}
672
781
  .weave-ctx-row{display:flex}
673
782
  .weave-ctx-link{
674
783
  display:flex;align-items:center;gap:5px;width:100%;min-width:0;
675
- font:inherit;font-size:12px;text-align:left;color:var(--weave-fg);
784
+ font:inherit;font-size:var(--weave-px-row);text-align:left;color:var(--weave-fg);
676
785
  background:none;border:0;padding:2px var(--weave-gutter) 2px 0;cursor:pointer;
677
- border-radius:3px;
786
+ border-radius:var(--weave-radius);
678
787
  }
679
788
  .weave-ctx-link:hover{background:var(--weave-line)}
680
789
  .weave-ctx-row.weave-row-on .weave-ctx-link{background:var(--weave-line-strong)}
@@ -682,11 +791,16 @@ body{font-size:13px}
682
791
  .weave-ctx-tag .weave-ctx-rows{padding-left:12px}
683
792
 
684
793
  /* status bar ------------------------------------------------------------ */
794
+ /* One separator vocabulary, shared with the header summary: every run of
795
+ status items after the first opens with the same mid-dot, in the same
796
+ --weave-faint. cwd · selection | stamp · connection reads as one grammar,
797
+ the same way the header's three-part summary does. */
685
798
  .weave-status{
686
- display:flex;align-items:center;gap:12px;height:22px;padding:0 var(--weave-gutter);
687
- font-family:var(--weave-mono);font-size:11px;color:var(--weave-dim);
799
+ display:flex;align-items:center;gap:8px;height:22px;padding:0 var(--weave-gutter);
800
+ font-family:var(--weave-mono);font-size:var(--weave-px-ui);color:var(--weave-dim);
688
801
  border-top:1px solid var(--weave-line);background:var(--weave-panel);
689
802
  }
803
+ .weave-status-sel::before,.weave-conn::before{content:"·";margin-right:8px;color:var(--weave-faint)}
690
804
  .weave-status-cwd,.weave-status-sel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
691
805
  .weave-status-cwd{max-width:38%;color:var(--weave-faint)}
692
806
  .weave-status-sel{color:var(--weave-fg)}
@@ -701,13 +815,21 @@ body{font-size:13px}
701
815
  position:fixed;inset:0;z-index:10;display:flex;justify-content:center;
702
816
  align-items:flex-start;padding:9vh 16px 16px;background:rgba(0,0,0,.45);
703
817
  }
818
+ /* The scrim above is tuned for the dark ground, where a neutral black veil
819
+ reads as depth. On the linen ground the same veil reads as a power cut, so
820
+ the light scheme gets its own — a plum-tinted veil at reduced strength,
821
+ drawn from the foreground ramp rather than from grey. */
822
+ :root[data-weave-theme="light"] .weave-scrim{background:rgba(67,48,58,.28)}
823
+ @media (prefers-color-scheme: light){
824
+ :root:not([data-weave-theme="dark"]) .weave-scrim{background:rgba(67,48,58,.28)}
825
+ }
704
826
  .weave-palette,.weave-help{
705
827
  display:flex;flex-direction:column;width:100%;max-width:560px;max-height:72vh;
706
828
  overflow:hidden;background:var(--weave-panel);color:var(--weave-fg);
707
- border:1px solid var(--weave-line-strong);border-radius:7px;
829
+ border:1px solid var(--weave-line-strong);border-radius:var(--weave-radius-pop);
708
830
  }
709
831
  .weave-palette-input{
710
- flex:none;height:34px;padding:0 11px;font:inherit;font-size:14px;
832
+ flex:none;height:34px;padding:0 11px;font:inherit;font-size:var(--weave-px-subhead);
711
833
  color:var(--weave-fg);background:transparent;border:0;
712
834
  border-bottom:1px solid var(--weave-line);border-radius:0;
713
835
  }
@@ -719,31 +841,68 @@ body{font-size:13px}
719
841
  }
720
842
  .weave-hit-on{background:var(--weave-line-strong)}
721
843
  .weave-hit-badge{
722
- flex:none;font-size:9.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--weave-faint);
844
+ flex:none;font-size:var(--weave-px-prov);letter-spacing:.06em;text-transform:uppercase;color:var(--weave-faint);
723
845
  min-width:56px;
724
846
  }
725
847
  .weave-hit-note .weave-hit-badge{color:var(--weave-accent)}
726
848
  .weave-hit-label{flex:none;max-width:46%;overflow:hidden;text-overflow:ellipsis}
727
- .weave-hit-detail{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:11px;color:var(--weave-dim)}
849
+ .weave-hit-detail{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:var(--weave-px-ui);color:var(--weave-dim)}
728
850
  .weave-palette-status{margin:0;padding:14px 11px;color:var(--weave-dim);line-height:1.5}
729
851
  .weave-palette-foot,.weave-help-foot{
730
- display:flex;gap:12px;margin:0;padding:4px 11px;font-size:10.5px;color:var(--weave-faint);
852
+ display:flex;gap:12px;margin:0;padding:4px 11px;font-size:var(--weave-px-caption);color:var(--weave-faint);
731
853
  border-top:1px solid var(--weave-line);
732
854
  }
733
855
  .weave-palette-hint,.weave-help-hint{margin-left:auto}
734
- .weave-help-title{margin:0;padding:9px 11px;font-size:13px;font-weight:600;border-bottom:1px solid var(--weave-line)}
856
+ .weave-help-title{margin:0;padding:9px 11px;font-size:var(--weave-px-base);font-weight:600;border-bottom:1px solid var(--weave-line)}
735
857
  .weave-keys{flex:1;min-height:0;overflow:auto;margin:0;padding:5px 11px}
736
- .weave-key-group{margin:0 0 3px;font-size:9.5px;letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint)}
858
+ .weave-key-group{margin:0 0 3px;font-size:var(--weave-px-prov);letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint)}
737
859
  .weave-key-row{display:flex;align-items:baseline;gap:9px;padding:1px 0}
738
860
  .weave-key-combo{
739
- flex:none;min-width:74px;font-family:var(--weave-mono);font-size:11px;color:var(--weave-accent);
861
+ flex:none;min-width:74px;font-family:var(--weave-mono);font-size:var(--weave-px-ui);color:var(--weave-accent);
740
862
  }
741
- .weave-key-what{flex:1;min-width:0;font-size:12px}
863
+ .weave-key-what{flex:1;min-width:0;font-size:var(--weave-px-row)}
742
864
 
743
865
  /* focus ----------------------------------------------------------------- */
744
866
  :focus-visible{outline:2px solid var(--weave-accent);outline-offset:1px}
867
+ /* Text selection rides the accent, not the browser default: a selection in
868
+ the ⌘K palette and a selection while editing stay *of* this theme, and the
869
+ --weave-new tint is exactly an accent at a strength text stays legible in. */
870
+ ::selection{background:var(--weave-new)}
871
+ /* Every scroller in the workspace (rows, note body, rail, palette results,
872
+ help sheet, editor) gets the same thin chrome: the default scrollbar is a
873
+ 15 px system object the hairline aesthetic cannot afford, and Firefox and
874
+ the Blink/WebKit pair cover the whole surface with these five rules. */
875
+ *{scrollbar-width:thin;scrollbar-color:var(--weave-line-strong) transparent}
876
+ ::-webkit-scrollbar{width:8px;height:8px}
877
+ ::-webkit-scrollbar-track{background:transparent}
878
+ ::-webkit-scrollbar-thumb{background:var(--weave-line-strong);border-radius:var(--weave-radius)}
879
+ ::-webkit-scrollbar-thumb:hover{background:var(--weave-faint)}
880
+ /* motion -----------------------------------------------------------------
881
+ The one place motion is declared, directly above the kill switch that
882
+ neutralises it: every animated thing in the sheet is either in the
883
+ transition list or carries one of the three animation names, which is what
884
+ keeps the reduced-motion rule sufficient by construction — a future
885
+ element.animate() call would duck under it and is therefore not motion
886
+ this sheet may use. Transitions cover the interactive set (hover states
887
+ that would otherwise snap); entrances are overlay-only, because exits
888
+ would need delay-unmount plumbing far past polish. Compositor-safe
889
+ properties only — colour, border, opacity, transform; height and padding
890
+ snap. */
891
+ .weave-row,.weave-ctx-link,.weave-chip,.weave-search,.weave-refresh,.weave-theme,
892
+ .weave-divider,.weave-hit,.weave-note-toggle,.weave-note-save,.weave-note-open,
893
+ .weave-note-action{
894
+ transition:background-color 120ms ease,border-color 120ms ease,color 120ms ease;
895
+ }
896
+ .weave-scrim{animation:weave-fade-in 140ms ease-out both}
897
+ .weave-palette,.weave-help{animation:weave-overlay-in 160ms ease-out both}
898
+ /* The conflict prompt mounts once per conflict, so its entrance cannot strobe
899
+ the way a context-rail flash would — that rail deliberately stays still. */
900
+ .weave-note-prompt{animation:weave-prompt-in 180ms ease-out both}
901
+ @keyframes weave-fade-in{from{opacity:0}}
902
+ @keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
903
+ @keyframes weave-prompt-in{from{opacity:0;transform:translateY(-2px)}}
745
904
  @media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
746
- `,jx=["style[nonce]","style","script[nonce]","script[src]"];function qx(t){for(let e of jx){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function Tf(t,e=Vx){let n=t.createElement("style"),r=qx(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var Rf=document.getElementById("app");if(Rf!==null){Tf(document);let t=zs(document.getElementById($s)?.textContent??null);Ms(x(Sf,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),Rf)}})();
905
+ `,m_=["style[nonce]","style","script[nonce]","script[src]"];function v_(t){for(let e of m_){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function qf(t,e=g_){let n=t.createElement("style"),r=v_(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var Yf=document.getElementById("app");if(Yf!==null){qf(document),y_();let t=qs(document.getElementById(js)?.textContent??null);Ws(x(Vf,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),Yf)}function y_(){let t=Ci(Ai(localStorage)??"system");t!==null&&(document.documentElement.dataset.weaveTheme=t)}})();
747
906
  /*! Bundled license information:
748
907
 
749
908
  dompurify/dist/purify.es.mjs: