(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{70843:function(e,n,t){"use strict";t.r(n),t.d(n,{Graph:function(){return et},GraphPage:function(){return $n},default:function(){return Yn},getThemeColor:function(){return rt},hexToRGBA:function(){return it},normalizeLinkEnds:function(){return tt}});var r=t(87757),i=t.n(r),o=t(92137),l=t(87329),s=t(96156),c=t(34699),a=t(85893),u=t(67294),d=t(9008);function h(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function g(e){for(var n=1;n2&&void 0!==arguments[2]?arguments[2]:{},i=p(e,null!==(t=r.storage)&&void 0!==t?t:localStorage),o=i.get(),l=void 0!==o?o:n,s=null!=o&&"object"===typeof o&&!1===Array.isArray(o)?g(g({},n),o):l;s!==o&&i.update(s);var c=(0,u.useState)(s),a=c[0],d=c[1];(0,u.useEffect)((function(){a!==s&&d(s)}),[e]);var h=function(e){e instanceof Function?d((function(n){var t=e(n);return i.update(t),t})):(d(e),i.update(e))};return[a,h]}function p(e,n){return{get:function(){var t=n.getItem(e);if(t&&"undefined"!==t)return JSON.parse(t)},update:function(t){n.setItem(e,JSON.stringify(t))},remove:function(){n.removeItem(e)}}}var x=t(54533),j=t(81253),b=t(94096),v=t(48420),y=t(47516),m=t(35255),C=t(56884),O=function(e){var n=e.setJustification,t=e.setIndent,r=e.setFont,i=e.justification;return(0,a.jsxs)(b.k,{py:3,alignItems:"center",justifyContent:"space-between",pr:4,children:[(0,a.jsxs)(b.k,{children:[(0,a.jsx)(v.h,{variant:"ghost",icon:(0,a.jsx)(m.w,{}),"aria-label":"Previous node"}),(0,a.jsx)(v.h,{variant:"ghost",icon:(0,a.jsx)(C.X,{}),"aria-label":"Previous node"})]}),(0,a.jsxs)(b.k,{children:[(0,a.jsx)(v.h,{variant:"ghost","aria-label":"Justify content",icon:[(0,a.jsx)(y.v9V,{},"justify"),(0,a.jsx)(y.YSr,{},"left"),(0,a.jsx)(y.RXA,{},"right"),(0,a.jsx)(y.tr_,{},"center")][i],onClick:function(){return n((function(e){return(e+1)%4}))}}),(0,a.jsx)(v.h,{variant:"ghost","aria-label":"Indent Text",icon:(0,a.jsx)(y.WHD,{}),onClick:function(){t((function(e){return e?0:1}))}}),(0,a.jsx)(v.h,{variant:"ghost","aria-label":"Change font",icon:(0,a.jsx)(y.TlM,{}),onClick:function(){r((function(e){return"sans serif"===e?"serif":"sans serif"}))}})]})]})},w=t(48017),k=t(18835),S=t.n(k),P=t(13816),N=t.n(P),I=t(42728),L=t.n(I),D=t(77890),z=t.n(D),E=t(94986),Z=t.n(E),T=t(88541),B=t.n(T),R=t(71167),F=t.n(R),H=(t(74477),t(27431)),A=t.n(H),V=t(40980),W=t(64115),M=t(45170),X=t(67273),_=t(29356),q={".katex":{overflowX:"scroll"},h1:{color:"black",lineHeight:"1.2",fontSize:"20",fontWeight:"bold",marginBottom:3},h2:{fontSize:"18",marginBottom:2,color:"black"},h3:{fontSize:"16",fontWeight:"600 !important",marginBottom:".5em",color:"black"},h4:{fontSize:"14",fontWeight:"500 !important",marginBottom:".25em",fontStyle:"italic",color:"black"},ol:{paddingLeft:"5"},ul:{paddingLeft:"5"},p:{fontSize:"14",fontWeight:"500 !important",paddingBottom:".5em"},div:{hyphens:"auto !important"},".title":{textAlign:"center",marginBottom:".2em"},".subtitle":{textAlign:"center",fontSize:"medium",fontWeight:"bold",marginTop:0},".todo":{fontFamily:"monospace",color:"red"},".equationContainer":{display:"table",textAlign:"center",width:"100%"},".equation":{verticalAlign:"middle"},".equation-label":{display:"tableCell",textAlign:"right",verticalAlign:"middle"},".inlinetask":{padding:"10px",border:"2px solid gray",margin:"10px",background:"#ffffcc"},"#org-div-home-and-up":{textAlign:"right",fontSize:"70 % ",whiteSpace:"nowrap"},textarea:{overflowX:"auto"},".linenr":{fontSize:"smaller"},".code-highlighted":{backgroundColor:"#ffff00"},".org-info-js_info-navigation":{borderStyle:"none"},"#org-info-js_console-label":{fontSize:"10px",fontWeight:"bold",whiteSpace:"nowrap"},".org-info-js_search-highlight":{backgroundColor:"#ffff00",color:"#000000",fontWeight:"bold"},".org-svg":{width:"90%"},".done":{fontFamily:"monospace",color:"green"},".priority":{fontFamily:"monospace",color:"orange"},".tag":{backgroundColor:"#eee",fontFamily:"monospace",padding:"2px",fontSize:"80%",fontWeight:"normal"},".timestamp":{color:"#bebebe"},".timestamp-kwd":{color:"#5f9ea0"},".org-right":{marginLeft:"auto",marginRight:"0px",textAlign:"right"},".org-left":{marginLeft:"0px",marginRight:"auto",textAlign:"left"},".org-center":{marginLeft:"auto",marginRight:"auto",textAlign:"center"},".underline":{textDecoration:"underline"},"#postamble p":{fontSize:"90%",margin:".2em"},"#preamble p":{fontSize:"90%",margin:".2em"},"p.verse":{marginLeft:"3%"},pre:{border:"1px solid #e6e6e6",borderRadius:"3px",backgroundColor:"#f2f2f2",padding:"8pt",fontFamily:"monospace",overflow:"auto",margin:"1.2em"},"pre.src":{position:"relative",overflow:"auto"},"pre.src:before":{display:"none",position:"absolute",top:"-8px",right:"12px",padding:"3px",color:"#555",backgroundColor:"#f2f2f299"},"caption.t-above":{captionSide:"top"},"caption.t-bottom":{captionSide:"bottom"},"th.org-right":{textAlign:"center"},"th.org-left":{textAlign:"center"},"th.org-center":{textAlign:"center"},"td.org-right":{textAlign:"right"},"td.org-left":{textAlign:"left"},"td.org-center":{textAlign:"center"},".footpara":{display:"inline"},".footdef":{marginBottom:"1em"},".figure":{padding:"1em"},".figure p":{textAlign:"center"}},U=q;function Q(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function G(e){for(var n=1;n1,animateOpacity:!0,children:(0,a.jsx)(w.xu,{paddingTop:2,children:(0,a.jsx)(nn,{label:"Label Appearance Scale",value:5*n.labelScale,onChange:function(e){return t(Cn(Cn({},n),{},{labelScale:e/5}))}})})})]})]})})};function wn(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function kn(e){for(var n=1;n2&&void 0!==arguments[2]?arguments[2]:2e3,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:200;if("color"!==e){var o=se.current,s=de.current,c=he.current,a=null!==(t=ie.current[n])&&void 0!==t?t:[],u=Object.fromEntries([n].concat((0,l.Z)(a.flatMap((function(e){return[e.source,e.target]})))).map((function(e){return[e,{}]})));if("zoom"===e)return s.nodeIds.length&&x({nodeIds:[]}),void setTimeout((function(){return o.zoomToFit(r,i,(function(e){return u[e.id]}))}),50);if(!s.nodeIds.length)return x({nodeIds:[n]}),void setTimeout((function(){o.centerAt(0,0,10),o.zoomToFit(1,i)}),50);if("add"!==c.localSame)return x({nodeIds:[n]}),void setTimeout((function(){o.centerAt(0,0,10),o.zoomToFit(1,i)}),50);if(!s.nodeIds.includes(n)||!s.nodeIds.some((function(e){return u[e]})))return x({nodeIds:[n]}),void setTimeout((function(){o.centerAt(0,0,10),o.zoomToFit(1,i)}),50);x((function(e){return Qn(Qn({},e),{},{nodeIds:[].concat((0,l.Z)(e.nodeIds),[n])})})),setTimeout((function(){o.centerAt(0,0,10),o.zoomToFit(1,i)}),50)}};return(0,u.useEffect)((function(){fe.current=new qn.Z("ws://localhost:35903"),fe.current.addEventListener("open",(function(){console.log("Connection with Emacs established")})),fe.current.addEventListener("message",(function(e){var n=he.current,t=JSON.parse(e.data);switch(t.type){case"graphdata":return function(e){var n,t,r,i=re.current;le.current=null!==(n=e.tags)&&void 0!==n?n:[];var o=null!==(t=e.nodes)&&void 0!==t?t:[],a=null!==(r=e.links)&&void 0!==r?r:[],u=o.reduce((function(e,n){var t;return Qn(Qn({},e),{},(0,s.Z)({},n.file,[].concat((0,l.Z)(null!==(t=e[n.file])&&void 0!==t?t:[]),[n])))}),{}),d=Object.keys(u).flatMap((function(e){var n,t=null!==(n=u[e])&&void 0!==n?n:[],r=t.find((function(e){return 0===e.level})),i=t.filter((function(e){return 0!==e.level}));return r?i.map((function(e){var n=t.filter((function(n){var t;return!(n.level>=e.level||n.pos>=e.pos||null===(t=e.olp)||void 0===t||!t.includes(n.title))})).reduce((function(e,n){return n.level>e.level&&(e=n),e}),r);return{source:e.id,target:(null===n||void 0===n?void 0:n.id)||r.id,type:"heading"}})):[]})),h=Object.keys(u).flatMap((function(e){var n,t=null!==(n=u[e])&&void 0!==n?n:[],r=t.find((function(e){return 0===e.level})),i=t.filter((function(e){return 0!==e.level}));return r?i.map((function(e){return{source:e.id,target:r.id,type:"parent"}})):[]}));re.current=Object.fromEntries(o.map((function(e){return[e.id,e]})));var g=[].concat((0,l.Z)(a),(0,l.Z)(d),(0,l.Z)(h)),f=[],p=g.map((function(e){var n=e.source,t=e.target;return re.current[n]?re.current[t]?e:(f.push({id:t,tags:["bad"],properties:{FILELESS:"yes",bad:"yes"},file:"",title:t,level:0,pos:0,olp:null}),Qn(Qn({},e),{},{type:"bad"})):(f.push({id:n,tags:["bad"],properties:{FILELESS:"yes",bad:"yes"},file:"",title:n,level:0,pos:0,olp:null}),Qn(Qn({},e),{},{type:"bad"}))}));re.current=Qn(Qn({},re.current),Object.fromEntries(f.map((function(e){return[e.id,e]})))),ie.current=p.reduce((function(e,n){var t,r,i;return Qn(Qn({},e),{},(i={},(0,s.Z)(i,n.source,[].concat((0,l.Z)(null!==(t=e[n.source])&&void 0!==t?t:[]),[n])),(0,s.Z)(i,n.target,[].concat((0,l.Z)(null!==(r=e[n.target])&&void 0!==r?r:[]),[n])),i))}),{});var x=[].concat((0,l.Z)(o),f);oe.current=x.reduce((function(e,n){var t,r=null===(t=n.properties)||void 0===t?void 0:t.ROAM_REFS;if(null===r||void 0===r||!r.includes("cite"))return e;var i=r.replaceAll(/cite:(.*)/g,"$1");return i?Qn(Qn({},e),{},(0,s.Z)({},i,n)):e}),{});var j={nodes:x,links:p},b=ce.current;if(0===b.nodes.length){var v=JSON.parse(JSON.stringify(j));return ce.current=v,void Z(v)}var y=[].concat((0,l.Z)(b.nodes.flatMap((function(e){var n,t=null!==(n=re.current[null===e||void 0===e?void 0:e.id])&&void 0!==n&&n;return t?[Qn(Qn({},e),t)]:[]}))),(0,l.Z)(Object.keys(re.current).filter((function(e){return!i[e]})).map((function(e){return re.current[e]})))),m=y.reduce((function(e,n,t){var r=null===n||void 0===n?void 0:n.id;return Qn(Qn({},e),{},(0,s.Z)({},r,t))}),{}),C=p.map((function(e){var n=tt(e),t=(0,c.Z)(n,2),r=t[0],i=t[1];return Qn(Qn({},e),{},{source:y[m[r]],target:y[m[i]]})}));Z({nodes:y,links:C})}(t.data);case"theme":return ae(t.data);case"command":switch(t.data.commandName){case"local":var r=A.zoomSpeed,i=A.zoomPadding;pe("local",t.data.id,r,i),R(t.data.id);break;case"zoom":var o,a,u=(null===t||void 0===t||null===(o=t.data)||void 0===o?void 0:o.speed)||n.zoomSpeed,d=(null===t||void 0===t||null===(a=t.data)||void 0===a?void 0:a.padding)||n.zoomPadding;pe("zoom",t.data.id,u,d),R(t.data.id);break;case"follow":pe(n.follow,t.data.id,n.zoomSpeed,n.zoomPadding),R(t.data.id);break;default:return console.error("unknown message type",t.type)}}}))}),[]),(0,u.useEffect)((function(){var e=se.current;!e||p.nodeIds.length>1||(p.nodeIds.length||!m.gravityOn?setTimeout((function(){e.zoomToFit(5,200)}),50):e.zoomToFit())}),[p.nodeIds]),E?(0,a.jsxs)(w.xu,{display:"flex",alignItems:"flex-start",flexDirection:"row",height:"100%",overflow:"hidden",children:[(0,a.jsxs)(w.xu,{display:"flex",justifyContent:"space-between",flexDirection:"row",height:"100%",width:"100%",children:[(0,a.jsx)(En,Qn(Qn({},{physics:m,setPhysics:C,threeDim:t,setThreeDim:r,filter:S,setFilter:P,visuals:L,setVisuals:D,mouse:X,setMouse:q,behavior:A,setBehavior:V,tagColors:d,setTagColors:h}),{},{tags:le.current})),(0,a.jsx)(b.k,{height:"100%",flexDirection:"column",marginLeft:"auto",children:!ee&&(0,a.jsx)(v.h,{icon:(0,a.jsx)(ue.U,{}),"aria-label":"Open org-viewer",zIndex:2,onClick:ne,variant:"ghost",marginTop:10,mr:8})})]}),(0,a.jsxs)(b.k,{position:"absolute",alignItems:"top",overflow:"hidden",children:[(0,a.jsx)(et,Qn({ref:se,nodeById:re.current,linksByNodeId:ie.current,webSocket:fe.current},{physics:m,graphData:E,threeDim:t,emacsNodeId:B,filter:S,visuals:L,behavior:A,mouse:X,scope:p,setScope:x,tagColors:d,setPreviewNode:G,sidebarHighlightedNode:K})),(0,a.jsx)(ge,Qn(Qn({},{isOpen:ee,onOpen:ne,onClose:te,previewNode:Q,setPreviewNode:G,setSidebarHighlightedNode:Y}),{},{nodeById:re.current,linksByNodeId:ie.current,nodeByCite:oe.current}))]})]}):null}var et=(0,u.forwardRef)((function(e,n){var t=e.physics,r=e.graphData,d=e.threeDim,h=e.linksByNodeId,g=e.filter,f=e.emacsNodeId,p=e.nodeById,j=e.visuals,b=e.behavior,v=e.mouse,y=e.scope,m=e.setScope,C=e.webSocket,O=e.tagColors,k=e.setPreviewNode,S=e.sidebarHighlightedNode,P=(0,fe.iP)(),N=(0,c.Z)(P,2),I=(N[0],N[1]),L=(0,u.useState)(null),D=L[0],z=L[1],E=(0,u.useState)(null),Z=E[0],T=E[1],B=(0,u.useState)([0,0]),R=B[0],F=B[1],H=(0,V.useTheme)(),A=(0,u.useContext)(_.N).emacsTheme,W=function(e,n){"replace"!==n?y.nodeIds.includes(e.id)||m((function(n){return Qn(Qn({},n),{},{nodeIds:[].concat((0,l.Z)(n.nodeIds),[e.id])})})):m({nodeIds:[e.id]})},M=(0,xe.q)(),X=function(e,n,t){switch(e){case v.local:W(n,b.localSame);break;case v.follow:Vn(n,C);break;case v.context:!function(e,n){F([n.pageX,n.pageY]),T(e),M.onOpen()}(n,t);case v.preview:k(n)}},q=(0,u.useRef)(null);(0,u.useEffect)((function(){f&&z(p[f])}),[f]);var U=(0,u.useRef)({}),Q=(0,u.useRef)({}),G=(0,u.useMemo)((function(){var e;Q.current={};var n=null===r||void 0===r||null===(e=r.nodes)||void 0===e?void 0:e.filter((function(e){var n=e;return g.tagsBlacklist.length&&g.tagsBlacklist.some((function(e){return n.tags.indexOf(e)>-1}))||g.tagsWhitelist.length>0&&!g.tagsWhitelist.some((function(e){return n.tags.indexOf(e)>-1}))||g.filelessCites&&n.properties.FILELESS?(Q.current=Qn(Qn({},Q.current),{},(0,s.Z)({},n.id,n)),!1):!g.bad||!n.properties.bad||(Q.current=Qn(Qn({},Q.current),{},(0,s.Z)({},n.id,n)),!1)})).filter((function(e){var n,t=(null!==(n=h[null===e||void 0===e?void 0:e.id])&&void 0!==n?n:[]).filter((function(e){return!Q.current[e.source]&&!Q.current[e.target]}));return!g.orphans||(g.parent?0!==t.length:0!==t.length&&t.some((function(e){return!["parent","heading"].includes(e.type)})))})),t=n.map((function(e){return e.id})),i=r.links.filter((function(e){var n=tt(e),r=(0,c.Z)(n,2),i=r[0],o=r[1];if(!t.includes(i)||!t.includes(o))return!1;var l=e;return g.parent?"heading"===g.parent?"parent"!==l.type:"heading"!==l.type:!["parent","heading"].includes(l.type)}));return U.current=i.reduce((function(e,n){var t,r,i,o=n,a=tt(o),u=(0,c.Z)(a,2),d=u[0],h=u[1];return Qn(Qn({},e),{},(i={},(0,s.Z)(i,d,[].concat((0,l.Z)(null!==(t=e[d])&&void 0!==t?t:[]),[o])),(0,s.Z)(i,h,[].concat((0,l.Z)(null!==(r=e[h])&&void 0!==r?r:[]),[o])),i))}),{}),{nodes:n,links:i}}),[g,r]),J=(0,u.useState)({nodes:[],links:[]}),K=J[0],Y=J[1];(0,u.useEffect)((function(){if(y.nodeIds.length){var e=y.nodeIds.length>1?K.nodes:[],n=e.map((function(e){return e.id})),t=function(e,n){var t=[e[0]],r=[],i=[e[0]];return Array.from({length:n},(function(){t.forEach((function(e){var n;(null!==(n=U.current[e])&&void 0!==n?n:[]).forEach((function(e){var n=tt(e),t=(0,c.Z)(n,2),o=t[0],l=t[1];i.includes(o)?i.includes(l)||r.push(l):r.push(o)}))})),t=r,r.forEach((function(e){return e&&i.push(e)})),r=[]})),i}(y.nodeIds,1),r=G.nodes.filter((function(r){var i;return e.length?!n.includes(r.id)&&(null!==(i=U.current[r.id])&&void 0!==i?i:[]).some((function(e){return y.nodeIds.includes(e.source)||y.nodeIds.includes(e.target)})):t.includes(r.id)})).map((function(e){return Qn(Qn({},e),{},{x:0,y:0,vy:0,vx:0})})),i=[].concat((0,l.Z)(e),(0,l.Z)(r)),o=i.map((function(e){return e.id})),s=y.nodeIds.length>1?K.links:[],a=G.links.filter((function(e){var t=tt(e),r=(0,c.Z)(t,2),i=r[0],l=r[1];return!(s.length&&n.includes(l)&&n.includes(i))&&(o.includes(i)&&o.includes(l))})).map((function(e){var n=tt(e),t=(0,c.Z)(n,2);return{source:t[0],target:t[1]}})),u=[].concat((0,l.Z)(s),(0,l.Z)(a));Y({nodes:i,links:u})}}),[g,y,r]),(0,u.useEffect)((function(){(0,o.Z)(i().mark((function e(){var r,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.current,e.next=3,Gn;case 3:o=e.sent,!t.gravityOn||y.nodeIds.length&&!t.gravityLocal?(r.d3Force("x",null),r.d3Force("y",null),d&&r.d3Force("z",null)):(r.d3Force("x",o.forceX().strength(t.gravity)),r.d3Force("y",o.forceY().strength(t.gravity)),d&&r.d3Force("z",o.forceZ().strength(t.gravity))),t.centering?r.d3Force("center",o.forceCenter().strength(t.centeringStrength)):r.d3Force("center",null),t.linkStrength&&r.d3Force("link").strength(t.linkStrength),t.linkIts&&r.d3Force("link").iterations(t.linkIts),t.charge&&r.d3Force("charge").strength(t.charge),r.d3Force("collide",t.collision?o.forceCollide().radius(t.collisionStrength):null);case 10:case"end":return e.stop()}}),e)})))()}),[t,d,y]),(0,u.useEffect)((function(){var e;null===(e=n.current)||void 0===e||e.d3ReheatSimulation()}),[t,y.nodeIds.length]);var $=(0,u.useRef)(0),ee=(0,u.useState)(1),ne=ee[0],te=ee[1],re=(0,pe._7)((function(e){return te(e)}),{duration:j.animationSpeed,algorithm:Oe[j.algorithmName]}),ie=(0,c.Z)(re,2),oe=ie[0],le=ie[1],se=(0,pe._7)((function(e){return te(Math.min(ne,-1*(e-1)))}),{duration:j.animationSpeed,algorithm:Oe[j.algorithmName]}),ce=(0,c.Z)(se,2),ae=ce[0],ue=ce[1];(0,u.useEffect)((function(){console.log("aaa"),null!==S&&void 0!==S&&S.id?z(S):z(null)}),[S]);var de=(0,u.useMemo)((function(){if(!q.current)return{};var e=U.current[q.current.id];return e?Object.fromEntries([q.current.id].concat((0,l.Z)(e.flatMap((function(e){return[e.source,e.target]})))).map((function(e){return[e,{}]}))):{}}),[JSON.stringify(q.current),JSON.stringify(U.current)]),he=(0,u.useRef)(null);(0,u.useEffect)((function(){if(q.current=D,D&&(he.current=D),!j.highlightAnim)return te(D?1:0);D?oe():(le(),ne>.5?ae():te(0))}),[D]);var ge=(0,u.useMemo)((function(){return Object.fromEntries(Ie.map((function(e){var n=rt(e,H),t=Ie.map((function(e){return[e,x.Z(n,rt(e,H))]}));return[e,Object.fromEntries(t)]})))}),[A]),je=(0,u.useMemo)((function(){var e,n,t,r=null!==(e=U.current[null===(n=he.current)||void 0===n?void 0:n.id])&&void 0!==e?e:[];return Object.fromEntries([null===(t=he.current)||void 0===t?void 0:t.id].concat((0,l.Z)(r.flatMap((function(e){return tt(e)})))).map((function(e){return[e,{}]})))}),[JSON.stringify(D),he.current,U.current]),be=function(e){var n,t,r,i,o,l=null!==(n=null===(t=U.current[e])||void 0===t?void 0:t.length)&&void 0!==n?n:0;return j.nodeColorScheme[(r=l,i=0,o=j.nodeColorScheme.length-1,Math.min(Math.max(r,i),o))]},ve=function(e,n){return U.current[e].length>U.current[n].length?be(e):be(n)},ye=(0,u.useMemo)((function(){return rt(j.labelTextColor,H)}),[j.labelTextColor,A]),me=(0,u.useMemo)((function(){return rt(j.labelBackgroundColor,H)}),[j.labelBackgroundColor,A]),Ce=function(e){var n,t=null!==(n=U.current[e.id])&&void 0!==n?n:[],r=t.length?t.filter((function(e){return"parent"===e.type})).length:0,i=3+t.length*j.nodeSizeLinks-(g.parent?0:r);return 1===j.highlightNodeSize?i:i*(de[e.id]||je[e.id]?1+ne*(j.highlightNodeSize-1):1)},we=(0,u.useState)(!1),ke=we[0],Se=we[1],Pe=(0,u.useState)(1),Ne=Pe[0],Le=Pe[1],De={graphData:y.nodeIds.length?K:G,height:I,backgroundColor:H.colors.gray[j.backgroundColor],warmupTicks:1===y.nodeIds.length?100:y.nodeIds.length>1?20:0,onZoom:function(e){var n=e.k;e.x,e.y;return Le(n)},nodeLabel:function(e){return e.title},nodeColor:function(e){return function(e,n){var t=de[e.id]||je[e.id];if(j.emacsNodeColor&&e.id===f)return rt(j.emacsNodeColor,n);if(O&&e.tags.some((function(e){return O[e]}))){var r=O[e.tags.filter((function(e){return O[e]}))[0]];return ge[r][j.backgroundColor](j.highlightFade*ne)}return j.citeNodeColor&&e.properties.ROAM_REFS&&e.properties.FILELESS?t?rt(j.citeNodeColor,n):ge[j.citeNodeColor][j.backgroundColor](j.highlightFade*ne):j.refNodeColor&&e.properties.ROAM_REFS?t?rt(j.refNodeColor,n):ge[j.refNodeColor][j.backgroundColor](j.highlightFade*ne):t?j.nodeHighlight?ge[be(e.id)][j.nodeHighlight](ne):rt(be(e.id),n):ge[be(e.id)][j.backgroundColor](j.highlightFade*ne)}(e,H)},nodeRelSize:j.nodeRel,nodeVal:function(e){return Ce(e)/Math.pow(Ne,j.nodeZoomSize)},nodeCanvasObject:function(e,n,t){if(e&&!ke&&j.labels){var r=je[e.id];if(!(t<=j.labelScale||1===j.labels)||de[e.id]||r){var i=e.title,o=i.substring(0,j.labelLength),s=j.labelFontSize/(.75*Math.min(Math.max(.5,t),3)),c=[1.1*n.measureText(o).width,s].map((function(e){return e+.5*s})),a=Math.min(3*(t-j.labelScale)/j.labelScale,1),u=function(){return 1===j.labels||t<=j.labelScale?ne:de[e.id]||je[e.id]?Math.max(a,ne):1*a*(-1*(j.highlightFade*ne-1))},d=8*Math.cbrt(Ce(e)*j.nodeRel);if(j.labelBackgroundColor&&j.labelBackgroundOpacity){var h=u()*j.labelBackgroundOpacity,g=it(me,h);n.fillStyle=g,n.fillRect.apply(n,[e.x-c[0]/2,e.y-c[1]/2+d].concat((0,l.Z)(c)))}var f=u();n.textAlign="center",n.textBaseline="middle";var p=it(ye,f);n.fillStyle=p,n.font="".concat(s,"px Sans-Serif");var x=_n()(o,{width:j.labelWordWrap}).split("\n");(i.length>j.labelLength?[].concat((0,l.Z)(x.slice(0,-1)),["".concat(x.slice(-1),"...")]):x).forEach((function(t,r){n.fillText(t,e.x,e.y+d+j.labelLineSpace*s*r)}))}}},nodeCanvasObjectMode:function(){return"after"},linkDirectionalParticles:j.particles?j.particlesNumber:void 0,linkDirectionalArrowLength:j.arrows?j.arrowsLength:void 0,linkDirectionalArrowRelPos:j.arrowsPos,linkDirectionalArrowColor:j.arrowsColor?function(){return rt(j.arrowsColor,H)}:void 0,linkColor:function(e){var n,t="object"===typeof e.source?e.source.id:e.source,r="object"===typeof e.target?e.target.id:e.target,i=nt(e,q.current),o=nt(e,he.current),l=i||o,s=e;return j.refLinkColor&&"ref"===s.type?l&&(j.refLinkHighlightColor||j.linkHighlight)?ge[j.refLinkColor][j.refLinkHighlightColor||j.linkHighlight](ne):ge[j.refLinkColor][j.backgroundColor](j.highlightFade*ne):j.citeLinkColor&&null!==(n=s.type)&&void 0!==n&&n.includes("cite")?l&&(j.citeLinkHighlightColor||j.linkHighlight)?ge[j.citeLinkColor][j.citeLinkHighlightColor||j.linkHighlight](ne):ge[j.citeLinkColor][j.backgroundColor](j.highlightFade*ne):function(e,n,t,r){if(!j.linkHighlight&&!j.linkColorScheme&&!t)return rt(ve(e,n),r);if(!t&&!j.linkColorScheme){var i=ve(e,n);return ge[i][j.backgroundColor](j.highlightFade*ne)}return t?j.linkHighlight||j.linkColorScheme?j.linkHighlight?j.linkColorScheme?ge[j.linkColorScheme][j.linkHighlight](ne):ge[ve(e,n)][j.linkHighlight](ne):rt(j.linkColorScheme,r):rt(ve(e,n),r):ge[j.linkColorScheme][j.backgroundColor](j.highlightFade*ne)}(t,r,l,H)},linkWidth:function(e){if(1===j.highlightLinkSize)return j.linkWidth;var n=nt(e,q.current),t=nt(e,he.current);return n||t?j.linkWidth*(1+ne*(j.highlightLinkSize-1)):j.linkWidth},linkDirectionalParticleWidth:j.particlesWidth,d3AlphaDecay:t.alphaDecay,d3AlphaMin:t.alphaMin,d3VelocityDecay:t.velocityDecay,onNodeClick:function(e,n){var t=e;M.onClose();var r=n.timeStamp-$.current<200;if($.current=n.timeStamp,r)return X("double",t,n);var i=$.current;return setTimeout((function(){if($.current===i)return X("click",t,n)}),200)},onBackgroundClick:function(){M.onClose(),z(null),0!==y.nodeIds.length&&m((function(e){return Qn(Qn({},e),{},{nodeIds:[]})}))},onNodeHover:function(e){j.highlight&&(D||(ue(),te(0)),z(e))},onNodeRightClick:function(e,n){X("right",e,n)},onNodeDrag:function(e){M.onClose(),z(e),Se(!0)},onNodeDragEnd:function(){z(null),Se(!1)}};return(0,a.jsxs)(w.xu,{overflow:"hidden",children:[M.isOpen&&(0,a.jsx)(Wn,{scope:y,node:Z,nodeType:null===Z||void 0===Z?void 0:Z.id,background:!1,coordinates:R,handleLocal:W,menuClose:M.onClose.bind(M),webSocket:C,setPreviewNode:k}),d?(0,a.jsx)(Kn,Qn(Qn({ref:n},De),{},{nodeThreeObjectExtend:!0,backgroundColor:H.colors.white,nodeOpacity:j.nodeOpacity,nodeResolution:j.nodeResolution,linkOpacity:j.linkOpacity,nodeThreeObject:function(e){if(j.labels&&(!(j.labels<3)||de[e.id])){var n=new Mn.Z(e.title.substring(0,40));return n.color=rt(j.labelTextColor,H),n.backgroundColor=rt(j.labelBackgroundColor,H),n.padding=2,n.textHeight=8,n}}})):(0,a.jsx)(Jn,Qn(Qn({ref:n},De),{},{linkLineDash:function(e){var n,t=e;return j.citeDashes&&null!==(n=t.type)&&void 0!==n&&n.includes("cite")?[j.citeDashLength,j.citeGapLength]:j.refDashes&&"ref"==t.type?[j.refDashLength,j.refGapLength]:null}}))]})}));function nt(e,n){var t,r;return(null===(t=e.source)||void 0===t?void 0:t.id)===(null===n||void 0===n?void 0:n.id)||(null===(r=e.target)||void 0===r?void 0:r.id)===(null===n||void 0===n?void 0:n.id)}function tt(e){return["object"===typeof e.source?e.source.id:e.source,"object"===typeof e.target?e.target.id:e.target]}function rt(e,n){return e.split(".").reduce((function(e,n){return e[n]}),n.colors)}function it(e,n){return"rgba("+(e=e.replace("#","")).match(new RegExp("(.{"+e.length/3+"})","g")).map((function(n){return parseInt(e.length%2?n+n:n,16)})).concat(isFinite(n)?n:1).join(",")+")"}},45301:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return t(70843)}])}},function(e){e.O(0,[774,737,874,573,446,599,888,179],(function(){return n=45301,e(e.s=n);var n}));var n=e.O();_N_E=n}]);