pi-weave 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +114 -34
  2. package/package.json +16 -4
  3. package/src/core/cache/workspace.ts +466 -0
  4. package/src/core/frontmatter.ts +217 -23
  5. package/src/core/git.ts +19 -0
  6. package/src/core/graph/build.ts +37 -4
  7. package/src/core/graph/current.ts +41 -28
  8. package/src/core/graph/mentions.ts +170 -0
  9. package/src/core/graph/model.ts +24 -0
  10. package/src/core/index.ts +12 -0
  11. package/src/core/openInEditor.ts +69 -0
  12. package/src/core/types.ts +40 -0
  13. package/src/core/vault.ts +477 -43
  14. package/src/core/view/cluster.ts +262 -0
  15. package/src/core/view/detail.ts +118 -0
  16. package/src/core/view/focus.ts +109 -0
  17. package/src/core/view/health.ts +156 -0
  18. package/src/core/view/index.ts +15 -0
  19. package/src/core/view/links.ts +105 -0
  20. package/src/core/view/time.ts +47 -0
  21. package/src/core/view/tree.ts +269 -0
  22. package/src/core/view/types.ts +39 -0
  23. package/src/pi/index.ts +104 -11
  24. package/src/pi/viewer/tui/explorer.ts +4 -2
  25. package/src/pi/viewer/tui/model.ts +46 -667
  26. package/src/pi/viewer/tui/openNote.ts +7 -56
  27. package/src/pi/viewer/tui/surface/explore.ts +4 -2
  28. package/src/pi/viewer/web/run.ts +331 -0
  29. package/src/web/client/api.dom.ts +40 -0
  30. package/src/web/client/api.ts +472 -0
  31. package/src/web/client/bootstrap.ts +58 -0
  32. package/src/web/client/context/context.model.ts +313 -0
  33. package/src/web/client/dist/app.js +751 -0
  34. package/src/web/client/graph/Graph.tsx +158 -0
  35. package/src/web/client/graph/column.model.ts +431 -0
  36. package/src/web/client/graph/graph.model.ts +538 -0
  37. package/src/web/client/graph/positions.ts +339 -0
  38. package/src/web/client/graph/project.ts +153 -0
  39. package/src/web/client/graph/renderer.dom.ts +52 -0
  40. package/src/web/client/graph/renderer.ts +279 -0
  41. package/src/web/client/graph/scheme.ts +44 -0
  42. package/src/web/client/live.model.ts +275 -0
  43. package/src/web/client/live.ts +151 -0
  44. package/src/web/client/main.tsx +27 -0
  45. package/src/web/client/note/Editor.tsx +102 -0
  46. package/src/web/client/note/Note.tsx +113 -0
  47. package/src/web/client/note/editor.controller.ts +151 -0
  48. package/src/web/client/note/editor.model.ts +636 -0
  49. package/src/web/client/note/note.model.ts +738 -0
  50. package/src/web/client/search/SearchPalette.tsx +105 -0
  51. package/src/web/client/search/search.model.ts +588 -0
  52. package/src/web/client/search/search.ts +107 -0
  53. package/src/web/client/shell/Columns.tsx +161 -0
  54. package/src/web/client/shell/ContextRail.tsx +87 -0
  55. package/src/web/client/shell/Divider.tsx +44 -0
  56. package/src/web/client/shell/FocusTrap.tsx +56 -0
  57. package/src/web/client/shell/Header.tsx +54 -0
  58. package/src/web/client/shell/HelpOverlay.tsx +70 -0
  59. package/src/web/client/shell/Shell.tsx +193 -0
  60. package/src/web/client/shell/StatusBar.tsx +28 -0
  61. package/src/web/client/shell/cssvars.ts +70 -0
  62. package/src/web/client/shell/drag.model.ts +170 -0
  63. package/src/web/client/shell/focus.model.ts +100 -0
  64. package/src/web/client/shell/keys.model.ts +453 -0
  65. package/src/web/client/shell/keys.ts +59 -0
  66. package/src/web/client/shell/layout.model.ts +526 -0
  67. package/src/web/client/shell/shell.model.ts +333 -0
  68. package/src/web/client/shell/theme.ts +477 -0
  69. package/src/web/client/shell/viewport.ts +29 -0
  70. package/src/web/client/state.ts +78 -0
  71. package/src/web/client/tree/Tree.tsx +138 -0
  72. package/src/web/client/tree/tree.model.ts +674 -0
  73. package/src/web/client/workspace.ts +214 -0
  74. package/src/web/server/page.ts +256 -0
  75. package/src/web/server/routes.ts +975 -0
  76. package/src/web/server/security.ts +361 -0
  77. package/src/web/server/server.ts +275 -0
  78. package/src/web/server/sse.ts +321 -0
  79. package/src/web/server/watcher.ts +507 -0
  80. package/src/web/shared/graph.ts +206 -0
  81. package/src/web/shared/layout.ts +497 -0
  82. package/src/web/shared/metrics.ts +136 -0
  83. package/src/web/shared/view.ts +200 -0
  84. package/src/web/shared/wire.ts +358 -0
@@ -0,0 +1,751 @@
1
+ /*!
2
+ * pi-weave web client — generated bundle. Do not edit.
3
+ * Source: src/web/client/. Rebuild with `npm run build:web`.
4
+ *
5
+ * pi-weave itself is MIT (see LICENSE).
6
+ *
7
+ * Bundled dependencies and their licences:
8
+ * @preact/signals@2.11.1 — MIT
9
+ * @preact/signals-core@1.14.4 — MIT
10
+ * d3-dispatch@3.0.1 — ISC
11
+ * d3-force@3.0.0 — ISC
12
+ * d3-quadtree@3.0.1 — ISC
13
+ * d3-timer@3.0.1 — ISC
14
+ * dompurify@3.4.14 — MPL-2.0 OR Apache-2.0
15
+ * events@3.3.0 — MIT
16
+ * graphology@0.26.0 — MIT
17
+ * graphology-utils@2.5.2 — MIT
18
+ * marked@18.0.10 — MIT
19
+ * preact@10.29.8 — MIT
20
+ * sigma@3.0.3 — MIT
21
+ */
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:
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=`
28
+ precision highp float;
29
+
30
+ varying vec4 v_color;
31
+ varying vec2 v_diffVector;
32
+ varying float v_radius;
33
+
34
+ uniform float u_correctionRatio;
35
+
36
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
37
+
38
+ void main(void) {
39
+ float border = u_correctionRatio * 2.0;
40
+ float dist = length(v_diffVector) - v_radius + border;
41
+
42
+ // No antialiasing for picking mode:
43
+ #ifdef PICKING_MODE
44
+ if (dist > border)
45
+ gl_FragColor = transparent;
46
+ else
47
+ gl_FragColor = v_color;
48
+
49
+ #else
50
+ float t = 0.0;
51
+ if (dist > border)
52
+ t = 1.0;
53
+ else if (dist > 0.0)
54
+ t = dist / border;
55
+
56
+ gl_FragColor = mix(v_color, transparent, t);
57
+ #endif
58
+ }
59
+ `,Ip=Pp,Gp=`
60
+ attribute vec4 a_id;
61
+ attribute vec4 a_color;
62
+ attribute vec2 a_position;
63
+ attribute float a_size;
64
+ attribute float a_angle;
65
+
66
+ uniform mat3 u_matrix;
67
+ uniform float u_sizeRatio;
68
+ uniform float u_correctionRatio;
69
+
70
+ varying vec4 v_color;
71
+ varying vec2 v_diffVector;
72
+ varying float v_radius;
73
+ varying float v_border;
74
+
75
+ const float bias = 255.0 / 254.0;
76
+
77
+ void main() {
78
+ float size = a_size * u_correctionRatio / u_sizeRatio * 4.0;
79
+ vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));
80
+ vec2 position = a_position + diffVector;
81
+ gl_Position = vec4(
82
+ (u_matrix * vec3(position, 1)).xy,
83
+ 0,
84
+ 1
85
+ );
86
+
87
+ v_diffVector = diffVector;
88
+ v_radius = size / 2.0;
89
+
90
+ #ifdef PICKING_MODE
91
+ // For picking mode, we use the ID as the color:
92
+ v_color = a_id;
93
+ #else
94
+ // For normal mode, we use the color:
95
+ v_color = a_color;
96
+ #endif
97
+
98
+ v_color.a *= bias;
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=`
101
+ precision mediump float;
102
+
103
+ varying vec4 v_color;
104
+
105
+ void main(void) {
106
+ gl_FragColor = v_color;
107
+ }
108
+ `,$p=Fp,zp=`
109
+ attribute vec2 a_position;
110
+ attribute vec2 a_normal;
111
+ attribute float a_radius;
112
+ attribute vec3 a_barycentric;
113
+
114
+ #ifdef PICKING_MODE
115
+ attribute vec4 a_id;
116
+ #else
117
+ attribute vec4 a_color;
118
+ #endif
119
+
120
+ uniform mat3 u_matrix;
121
+ uniform float u_sizeRatio;
122
+ uniform float u_correctionRatio;
123
+ uniform float u_minEdgeThickness;
124
+ uniform float u_lengthToThicknessRatio;
125
+ uniform float u_widenessToThicknessRatio;
126
+
127
+ varying vec4 v_color;
128
+
129
+ const float bias = 255.0 / 254.0;
130
+
131
+ void main() {
132
+ float minThickness = u_minEdgeThickness;
133
+
134
+ float normalLength = length(a_normal);
135
+ vec2 unitNormal = a_normal / normalLength;
136
+
137
+ // These first computations are taken from edge.vert.glsl and
138
+ // edge.clamped.vert.glsl. Please read it to get better comments on what's
139
+ // happening:
140
+ float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);
141
+ float webGLThickness = pixelsThickness * u_correctionRatio;
142
+ float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;
143
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
144
+ float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;
145
+
146
+ float da = a_barycentric.x;
147
+ float db = a_barycentric.y;
148
+ float dc = a_barycentric.z;
149
+
150
+ vec2 delta = vec2(
151
+ da * (webGLNodeRadius * unitNormal.y)
152
+ + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)
153
+ + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),
154
+
155
+ da * (-webGLNodeRadius * unitNormal.x)
156
+ + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)
157
+ + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)
158
+ );
159
+
160
+ vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;
161
+
162
+ gl_Position = vec4(position, 0, 1);
163
+
164
+ #ifdef PICKING_MODE
165
+ // For picking mode, we use the ID as the color:
166
+ v_color = a_id;
167
+ #else
168
+ // For normal mode, we use the color:
169
+ v_color = a_color;
170
+ #endif
171
+
172
+ v_color.a *= bias;
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=`
175
+ precision mediump float;
176
+
177
+ varying vec4 v_color;
178
+ varying vec2 v_normal;
179
+ varying float v_thickness;
180
+ varying float v_feather;
181
+
182
+ const vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);
183
+
184
+ void main(void) {
185
+ // We only handle antialiasing for normal mode:
186
+ #ifdef PICKING_MODE
187
+ gl_FragColor = v_color;
188
+ #else
189
+ float dist = length(v_normal) * v_thickness;
190
+
191
+ float t = smoothstep(
192
+ v_thickness - v_feather,
193
+ v_thickness,
194
+ dist
195
+ );
196
+
197
+ gl_FragColor = mix(v_color, transparent, t);
198
+ #endif
199
+ }
200
+ `,yl=Bp,Wp=`
201
+ attribute vec4 a_id;
202
+ attribute vec4 a_color;
203
+ attribute vec2 a_normal;
204
+ attribute float a_normalCoef;
205
+ attribute vec2 a_positionStart;
206
+ attribute vec2 a_positionEnd;
207
+ attribute float a_positionCoef;
208
+ attribute float a_radius;
209
+ attribute float a_radiusCoef;
210
+
211
+ uniform mat3 u_matrix;
212
+ uniform float u_zoomRatio;
213
+ uniform float u_sizeRatio;
214
+ uniform float u_pixelRatio;
215
+ uniform float u_correctionRatio;
216
+ uniform float u_minEdgeThickness;
217
+ uniform float u_lengthToThicknessRatio;
218
+ uniform float u_feather;
219
+
220
+ varying vec4 v_color;
221
+ varying vec2 v_normal;
222
+ varying float v_thickness;
223
+ varying float v_feather;
224
+
225
+ const float bias = 255.0 / 254.0;
226
+
227
+ void main() {
228
+ float minThickness = u_minEdgeThickness;
229
+
230
+ float radius = a_radius * a_radiusCoef;
231
+ vec2 normal = a_normal * a_normalCoef;
232
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
233
+
234
+ float normalLength = length(normal);
235
+ vec2 unitNormal = normal / normalLength;
236
+
237
+ // These first computations are taken from edge.vert.glsl. Please read it to
238
+ // get better comments on what's happening:
239
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
240
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
241
+
242
+ // Here, we move the point to leave space for the arrow head:
243
+ float direction = sign(radius);
244
+ float webGLNodeRadius = direction * radius * 2.0 * u_correctionRatio / u_sizeRatio;
245
+ float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;
246
+
247
+ vec2 compensationVector = vec2(-direction * unitNormal.y, direction * unitNormal.x) * (webGLNodeRadius + webGLArrowHeadLength);
248
+
249
+ // Here is the proper position of the vertex
250
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness + compensationVector, 1)).xy, 0, 1);
251
+
252
+ v_thickness = webGLThickness / u_zoomRatio;
253
+
254
+ v_normal = unitNormal;
255
+
256
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
257
+
258
+ #ifdef PICKING_MODE
259
+ // For picking mode, we use the ID as the color:
260
+ v_color = a_id;
261
+ #else
262
+ // For normal mode, we use the color:
263
+ v_color = a_color;
264
+ #endif
265
+
266
+ v_color.a *= bias;
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=`
269
+ attribute vec4 a_id;
270
+ attribute vec4 a_color;
271
+ attribute vec2 a_normal;
272
+ attribute float a_normalCoef;
273
+ attribute vec2 a_positionStart;
274
+ attribute vec2 a_positionEnd;
275
+ attribute float a_positionCoef;
276
+
277
+ uniform mat3 u_matrix;
278
+ uniform float u_sizeRatio;
279
+ uniform float u_zoomRatio;
280
+ uniform float u_pixelRatio;
281
+ uniform float u_correctionRatio;
282
+ uniform float u_minEdgeThickness;
283
+ uniform float u_feather;
284
+
285
+ varying vec4 v_color;
286
+ varying vec2 v_normal;
287
+ varying float v_thickness;
288
+ varying float v_feather;
289
+
290
+ const float bias = 255.0 / 254.0;
291
+
292
+ void main() {
293
+ float minThickness = u_minEdgeThickness;
294
+
295
+ vec2 normal = a_normal * a_normalCoef;
296
+ vec2 position = a_positionStart * (1.0 - a_positionCoef) + a_positionEnd * a_positionCoef;
297
+
298
+ float normalLength = length(normal);
299
+ vec2 unitNormal = normal / normalLength;
300
+
301
+ // We require edges to be at least "minThickness" pixels thick *on screen*
302
+ // (so we need to compensate the size ratio):
303
+ float pixelsThickness = max(normalLength, minThickness * u_sizeRatio);
304
+
305
+ // Then, we need to retrieve the normalized thickness of the edge in the WebGL
306
+ // referential (in a ([0, 1], [0, 1]) space), using our "magic" correction
307
+ // ratio:
308
+ float webGLThickness = pixelsThickness * u_correctionRatio / u_sizeRatio;
309
+
310
+ // Here is the proper position of the vertex
311
+ gl_Position = vec4((u_matrix * vec3(position + unitNormal * webGLThickness, 1)).xy, 0, 1);
312
+
313
+ // For the fragment shader though, we need a thickness that takes the "magic"
314
+ // correction ratio into account (as in webGLThickness), but so that the
315
+ // antialiasing effect does not depend on the zoom level. So here's yet
316
+ // another thickness version:
317
+ v_thickness = webGLThickness / u_zoomRatio;
318
+
319
+ v_normal = unitNormal;
320
+
321
+ v_feather = u_feather * u_correctionRatio / u_zoomRatio / u_pixelRatio * 2.0;
322
+
323
+ #ifdef PICKING_MODE
324
+ // For picking mode, we use the ID as the color:
325
+ v_color = a_id;
326
+ #else
327
+ // For normal mode, we use the color:
328
+ v_color = a_color;
329
+ #endif
330
+
331
+ v_color.a *= bias;
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(`
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],`
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
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=bt(e[0],`
344
+ `).split(`
345
+ `),r="",i="",o=[];for(;n.length>0;){let a=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),a=!0;else if(!a)s.push(n[l]);else break;n=n.slice(l);let u=s.join(`
346
+ `),c=u.replace(this.rules.other.blockquoteSetextReplace,`
347
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
348
+ ${u}`:u,i=i?`${i}
349
+ ${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let f=d,g=n.join(`
350
+ `),m=f.raw+`
351
+ `+g.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(m);o[o.length-1]=v,r=`${r}
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
+ `+n.join(`
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(`
356
+ `,1)[0],e[1].length),d=t.split(`
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(`
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],`
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+=`
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
+ `)?"":`
371
+ `)+o.raw,s.text+=`
372
+ `+o.text,this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(o=this.tokenizer.fences(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.heading(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.hr(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.blockquote(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.list(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.html(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.def(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
373
+ `)?"":`
374
+ `)+o.raw,s.text+=`
375
+ `+o.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[o.tag]||(this.tokens.links[o.tag]={href:o.href,title:o.title},n.push(o));continue}if(o=this.tokenizer.table(e)){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.lheading(e)){e=e.substring(o.raw.length),n.push(o);continue}let a=e;if(this.options.extensions?.startBlock){let s=1/0,l=e.slice(1),u;this.options.extensions.startBlock.forEach(c=>{u=c.call({lexer:this},l),typeof u=="number"&&u>=0&&(s=Math.min(s,u))}),s<1/0&&s>=0&&(a=e.substring(0,s+1))}if(this.state.top&&(o=this.tokenizer.paragraph(a))){let s=n.at(-1);r&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
376
+ `)?"":`
377
+ `)+o.raw,s.text+=`
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
+ `)?"":`
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>
384
+ `}blockquote({tokens:t}){return`<blockquote>
385
+ ${this.parser.parse(t)}</blockquote>
386
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
387
+ `}hr(t){return`<hr>
388
+ `}list(t){let e=t.ordered,n=t.start,r="";for(let a=0;a<t.items.length;a++){let s=t.items[a];r+=this.listitem(s)}let i=e?"ol":"ul",o=e&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
389
+ `+r+"</"+i+`>
390
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
391
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
392
+ `}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let o=t.rows[i];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
393
+ <thead>
394
+ `+e+`</thead>
395
+ `+r+`</table>
396
+ `}tablerow({text:t}){return`<tr>
397
+ ${t}</tr>
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=`
401
+ :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;
405
+ --weave-row:26px;--weave-gutter:10px;
406
+ }
407
+ @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;
412
+ }
413
+ }
414
+ body{font-size:13px}
415
+ #app{height:100%;display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
416
+
417
+ /* header --------------------------------------------------------------- */
418
+ .weave-header{
419
+ display:flex;align-items:center;gap:14px;padding:0 var(--weave-gutter);
420
+ height:34px;border-bottom:1px solid var(--weave-line);background:var(--weave-panel);
421
+ }
422
+ .weave-brand{font-weight:600;letter-spacing:.01em;white-space:nowrap}
423
+ /* A button styled as a search field: the palette owns the only text input,
424
+ so this opens it rather than pretending to accept a query. */
425
+ .weave-search{
426
+ 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;
428
+ color:var(--weave-dim);background:var(--weave-bg);
429
+ border:1px solid var(--weave-line-strong);border-radius:4px;
430
+ }
431
+ .weave-search:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
432
+ .weave-search-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
433
+ .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;
436
+ }
437
+ .weave-summary{
438
+ margin-left:auto;display:flex;gap:9px;font-family:var(--weave-mono);
439
+ font-size:11.5px;color:var(--weave-dim);white-space:nowrap;
440
+ }
441
+ .weave-summary-part+.weave-summary-part::before{content:"·";margin-right:9px;color:var(--weave-faint)}
442
+ .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;
445
+ }
446
+ .weave-refresh:hover{color:var(--weave-fg);background:var(--weave-line)}
447
+
448
+ /* 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}
451
+ .weave-conn-ok .weave-conn-dot,.weave-conn-ok{color:var(--weave-ok)}
452
+ .weave-conn-warn .weave-conn-dot,.weave-conn-warn{color:var(--weave-warn)}
453
+ .weave-conn-bad .weave-conn-dot,.weave-conn-bad{color:var(--weave-bad)}
454
+
455
+ /* the grid -------------------------------------------------------------- */
456
+ /* Widths arrive as custom properties from cssvars.ts — the CSSOM path. The
457
+ fallbacks keep the layout sane for the first frame and if a write is ever
458
+ missed. */
459
+ .weave-grid{display:grid;min-height:0;overflow:hidden;background:var(--weave-line)}
460
+ .weave-grid[data-columns="3"]{
461
+ grid-template-columns:var(--weave-col-tree,22%) 1px var(--weave-col-note,46%) 1px var(--weave-col-graph,32%);
462
+ }
463
+ .weave-grid[data-columns="2"]{grid-template-columns:var(--weave-col-tree,32%) 1px var(--weave-col-note,68%)}
464
+ .weave-grid[data-columns="1"]{grid-template-columns:1fr}
465
+
466
+ .weave-col{
467
+ display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;
468
+ background:var(--weave-bg);
469
+ }
470
+ .weave-col-title{
471
+ margin:0;padding:5px var(--weave-gutter) 4px;font-size:10px;font-weight:600;
472
+ letter-spacing:.09em;text-transform:uppercase;color:var(--weave-faint);
473
+ border-bottom:1px solid var(--weave-line);
474
+ }
475
+ /* 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)}
478
+
479
+ /* dividers -------------------------------------------------------------- */
480
+ .weave-divider{
481
+ background:var(--weave-line);cursor:col-resize;position:relative;
482
+ touch-action:none;
483
+ }
484
+ /* A 1 px target is unhittable, so the hit area is widened with a pseudo
485
+ element rather than by making the visible rule thicker. */
486
+ .weave-divider::after{content:"";position:absolute;inset:0 -3px;z-index:1}
487
+ .weave-divider:hover,.weave-divider:focus-visible{background:var(--weave-accent);outline:none}
488
+
489
+ /* tree column ----------------------------------------------------------- */
490
+ /* --weave-depth is written per row by \`depthVar\`, through the same CSSOM
491
+ path as the column widths, and multiplied by a step this sheet owns — so
492
+ the tree's density stays a CSS decision. */
493
+ .weave-tree{display:flex;flex-direction:column;min-height:0;flex:1}
494
+ .weave-tree-controls{
495
+ display:flex;align-items:center;gap:6px;padding:5px var(--weave-gutter);
496
+ border-bottom:1px solid var(--weave-line);
497
+ }
498
+ .weave-filter{
499
+ flex:1;min-width:0;height:21px;padding:0 6px;font:inherit;font-size:11.5px;
500
+ color:var(--weave-fg);background:var(--weave-panel);
501
+ border:1px solid var(--weave-line-strong);border-radius:4px;
502
+ }
503
+ .weave-chip{
504
+ font:inherit;font-size:10.5px;line-height:1;white-space:nowrap;cursor:pointer;
505
+ color:var(--weave-dim);background:var(--weave-panel);padding:4px 6px;
506
+ border:1px solid var(--weave-line-strong);border-radius:4px;
507
+ }
508
+ .weave-chip:hover{color:var(--weave-fg);border-color:var(--weave-accent)}
509
+ .weave-rows{
510
+ flex:1;min-height:0;overflow:auto;margin:0;padding:3px 0;list-style:none;
511
+ }
512
+ .weave-rows:focus-visible{outline-offset:-2px}
513
+ .weave-row{
514
+ display:flex;align-items:center;gap:5px;height:var(--weave-row);
515
+ padding-right:var(--weave-gutter);
516
+ padding-left:calc(var(--weave-gutter) + var(--weave-depth,0) * 13px);
517
+ cursor:default;white-space:nowrap;
518
+ }
519
+ .weave-row:hover{background:var(--weave-line)}
520
+ .weave-row-on{background:var(--weave-line-strong);color:var(--weave-fg)}
521
+ .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}
524
+ .weave-prov-human{color:var(--weave-ok)}
525
+ .weave-prov-agent{color:var(--weave-accent)}
526
+ .weave-prov-generated{color:var(--weave-faint)}
527
+ .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)}
529
+ .weave-tree-empty{flex:1;margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim)}
530
+ .weave-tree-count{
531
+ margin:0;padding:3px var(--weave-gutter);font-size:10.5px;color:var(--weave-faint);
532
+ border-top:1px solid var(--weave-line);
533
+ }
534
+
535
+ /* 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}
541
+ .weave-note-time{color:var(--weave-faint)}
542
+ .weave-note-tags{margin:5px 0 0;display:flex;gap:5px;flex-wrap:wrap}
543
+ .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)}
548
+ .weave-note-body>*:first-child{margin-top:0}
549
+ .weave-note-body h1,.weave-note-body h2,.weave-note-body h3,
550
+ .weave-note-body h4,.weave-note-body h5,.weave-note-body h6{
551
+ margin:18px 0 6px;font-weight:600;line-height:1.3;
552
+ }
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}
556
+ .weave-note-body p,.weave-note-body ul,.weave-note-body ol,.weave-note-body blockquote{margin:0 0 10px}
557
+ .weave-note-body ul,.weave-note-body ol{padding-left:20px}
558
+ .weave-note-body li{margin:2px 0}
559
+ .weave-note-body blockquote{
560
+ padding-left:10px;border-left:2px solid var(--weave-line-strong);color:var(--weave-dim);
561
+ }
562
+ .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;
565
+ }
566
+ .weave-note-body pre{
567
+ margin:0 0 10px;padding:8px 10px;overflow:auto;
568
+ background:var(--weave-panel);border:1px solid var(--weave-line);border-radius:5px;
569
+ }
570
+ .weave-note-body pre code{padding:0;background:none;border:0}
571
+ .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}
573
+ .weave-note-body th,.weave-note-body td{padding:3px 8px;border:1px solid var(--weave-line);text-align:left}
574
+ .weave-note-body th{color:var(--weave-dim);font-weight:600}
575
+ .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. */
581
+ .weave-wiki{cursor:pointer;color:var(--weave-accent);text-decoration:none}
582
+ .weave-wiki:hover{text-decoration:underline}
583
+ .weave-wiki-ghost{
584
+ cursor:help;color:var(--weave-faint);border-bottom:1px dashed var(--weave-faint);text-decoration:none;
585
+ }
586
+ .weave-wiki-ghost:hover{text-decoration:none}
587
+
588
+ /* note editor (§11 P5) ---------------------------------------------------- */
589
+ /* A \`<textarea>\`, not CodeMirror: §0 V10 measured CM6 at 118 KB gzip, more
590
+ than the entire rest of the client. It inherits the body's type so toggling
591
+ \`⌘E\` does not reflow the column into a different shape. */
592
+ .weave-note-bar{
593
+ display:flex;align-items:center;gap:6px;flex-wrap:wrap;
594
+ padding:5px var(--weave-gutter);border-bottom:1px solid var(--weave-line);
595
+ }
596
+ .weave-note-toggle,.weave-note-save,.weave-note-open,.weave-note-action{
597
+ font:inherit;font-size:11px;padding:2px 8px;cursor:pointer;
598
+ color:var(--weave-fg);background:var(--weave-raise);
599
+ border:1px solid var(--weave-line);border-radius:4px;
600
+ }
601
+ .weave-note-toggle:hover,.weave-note-save:hover,.weave-note-open:hover,.weave-note-action:hover{
602
+ border-color:var(--weave-accent);
603
+ }
604
+ .weave-note-toggle[aria-pressed="true"]{border-color:var(--weave-accent);color:var(--weave-accent)}
605
+ .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)}
608
+ .weave-note-status-ok{color:var(--weave-ok)}
609
+ .weave-note-status-warn{color:var(--weave-warn)}
610
+ /* The prompt takes the full row rather than sitting inline: reload-or-overwrite
611
+ is a decision about the user's unsaved text, and a decision squeezed between
612
+ two buttons reads as a hint. */
613
+ .weave-note-prompt{
614
+ flex-basis:100%;display:flex;align-items:center;gap:8px;flex-wrap:wrap;
615
+ margin-top:4px;padding:5px 8px;border-radius:4px;
616
+ background:var(--weave-raise);border:1px solid var(--weave-warn);
617
+ }
618
+ .weave-note-prompt-conflict,.weave-note-prompt-collision{border-color:var(--weave-warn)}
619
+ .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)}
621
+ .weave-note-prompt-actions{margin:0;display:flex;gap:6px;flex-wrap:wrap}
622
+ .weave-note-editor{
623
+ 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;
627
+ }
628
+
629
+ /* graph column ---------------------------------------------------------- */
630
+ /* The canvas is a plain block sigma appends its own <canvas> layers into. It
631
+ must have a definite size before sigma measures it, hence \`min-height\` and
632
+ the \`1fr\` row from \`.weave-col-graph\` above — a zero-height container makes
633
+ sigma refuse to render (we pass \`allowInvalidContainer\`, so it degrades to
634
+ blank rather than throwing). */
635
+ .weave-graph{display:grid;grid-template-rows:1fr auto auto;min-height:0;overflow:hidden}
636
+ .weave-graph-canvas{min-height:120px;min-width:0;position:relative;overflow:hidden}
637
+ .weave-graph-empty{
638
+ margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim);
639
+ max-width:44ch;line-height:1.5;
640
+ }
641
+ .weave-graph-controls{
642
+ display:flex;align-items:center;gap:6px;flex-wrap:wrap;
643
+ padding:5px var(--weave-gutter);border-top:1px solid var(--weave-line);
644
+ }
645
+ .weave-depth{font:inherit;font-size:10.5px;padding:3px 4px}
646
+ .weave-graph-legend{
647
+ margin-left:auto;display:flex;gap:9px;font-size:10.5px;color:var(--weave-faint);
648
+ white-space:nowrap;
649
+ }
650
+ .weave-legend-on{color:var(--weave-accent)}
651
+ .weave-legend-near{color:var(--weave-fg)}
652
+ .weave-graph-count{
653
+ margin:0;padding:3px var(--weave-gutter);font-size:10.5px;color:var(--weave-faint);
654
+ border-top:1px solid var(--weave-line);
655
+ }
656
+
657
+ /* context rail ---------------------------------------------------------- */
658
+ /* The \`.weave-empty\` block that used to sit above went with \`EmptyState.tsx\`
659
+ in P3: every column now has its own empty state (\`treeEmptyMessage\`,
660
+ \`noteEmptyMessage\`, \`graphEmptyMessage\`, \`RAIL_EMPTY\`), each rendered as a
661
+ plain paragraph, so the shared placeholder had no callers left. */
662
+ .weave-rail{
663
+ display:flex;flex-direction:column;min-height:96px;max-height:46%;overflow:auto;
664
+ border-top:1px solid var(--weave-line);background:var(--weave-panel);
665
+ }
666
+ .weave-ctx-empty{margin:0;padding:10px var(--weave-gutter);color:var(--weave-dim);line-height:1.5}
667
+ .weave-ctx-group{padding:5px var(--weave-gutter) 2px}
668
+ .weave-ctx-heading{
669
+ margin:0 0 2px;font-size:9.5px;font-weight:600;letter-spacing:.09em;color:var(--weave-faint);
670
+ }
671
+ .weave-ctx-rows,.weave-ctx-tags{margin:0;padding:0;list-style:none}
672
+ .weave-ctx-row{display:flex}
673
+ .weave-ctx-link{
674
+ 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);
676
+ background:none;border:0;padding:2px var(--weave-gutter) 2px 0;cursor:pointer;
677
+ border-radius:3px;
678
+ }
679
+ .weave-ctx-link:hover{background:var(--weave-line)}
680
+ .weave-ctx-row.weave-row-on .weave-ctx-link{background:var(--weave-line-strong)}
681
+ .weave-ctx-tag{margin:0 0 3px}
682
+ .weave-ctx-tag .weave-ctx-rows{padding-left:12px}
683
+
684
+ /* status bar ------------------------------------------------------------ */
685
+ .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);
688
+ border-top:1px solid var(--weave-line);background:var(--weave-panel);
689
+ }
690
+ .weave-status-cwd,.weave-status-sel{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
691
+ .weave-status-cwd{max-width:38%;color:var(--weave-faint)}
692
+ .weave-status-sel{color:var(--weave-fg)}
693
+ .weave-status-stamp{margin-left:auto;color:var(--weave-faint)}
694
+
695
+ /* overlays: the ⌘K palette and the ? help sheet (P4) --------------------- */
696
+ /* The scrim is a click target that closes, and the reason both overlays sit
697
+ at the top of the stacking context rather than inside a column: a dialog
698
+ that a column's \`overflow:hidden\` can clip is a dialog that disappears at
699
+ the wrong breakpoint. */
700
+ .weave-scrim{
701
+ position:fixed;inset:0;z-index:10;display:flex;justify-content:center;
702
+ align-items:flex-start;padding:9vh 16px 16px;background:rgba(0,0,0,.45);
703
+ }
704
+ .weave-palette,.weave-help{
705
+ display:flex;flex-direction:column;width:100%;max-width:560px;max-height:72vh;
706
+ overflow:hidden;background:var(--weave-panel);color:var(--weave-fg);
707
+ border:1px solid var(--weave-line-strong);border-radius:7px;
708
+ }
709
+ .weave-palette-input{
710
+ flex:none;height:34px;padding:0 11px;font:inherit;font-size:14px;
711
+ color:var(--weave-fg);background:transparent;border:0;
712
+ border-bottom:1px solid var(--weave-line);border-radius:0;
713
+ }
714
+ .weave-palette-input:focus-visible{outline-offset:-2px}
715
+ .weave-hits{flex:1;min-height:0;overflow:auto;margin:0;padding:3px 0;list-style:none}
716
+ .weave-hit{
717
+ display:flex;align-items:baseline;gap:7px;padding:3px 11px;cursor:pointer;
718
+ min-width:0;white-space:nowrap;
719
+ }
720
+ .weave-hit-on{background:var(--weave-line-strong)}
721
+ .weave-hit-badge{
722
+ flex:none;font-size:9.5px;letter-spacing:.06em;text-transform:uppercase;color:var(--weave-faint);
723
+ min-width:56px;
724
+ }
725
+ .weave-hit-note .weave-hit-badge{color:var(--weave-accent)}
726
+ .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)}
728
+ .weave-palette-status{margin:0;padding:14px 11px;color:var(--weave-dim);line-height:1.5}
729
+ .weave-palette-foot,.weave-help-foot{
730
+ display:flex;gap:12px;margin:0;padding:4px 11px;font-size:10.5px;color:var(--weave-faint);
731
+ border-top:1px solid var(--weave-line);
732
+ }
733
+ .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)}
735
+ .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)}
737
+ .weave-key-row{display:flex;align-items:baseline;gap:9px;padding:1px 0}
738
+ .weave-key-combo{
739
+ flex:none;min-width:74px;font-family:var(--weave-mono);font-size:11px;color:var(--weave-accent);
740
+ }
741
+ .weave-key-what{flex:1;min-width:0;font-size:12px}
742
+
743
+ /* focus ----------------------------------------------------------------- */
744
+ :focus-visible{outline:2px solid var(--weave-accent);outline-offset:1px}
745
+ @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)}})();
747
+ /*! Bundled license information:
748
+
749
+ dompurify/dist/purify.es.mjs:
750
+ (*! @license DOMPurify 3.4.14 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.14/LICENSE *)
751
+ */