shieldcortex 3.4.18 → 3.4.19

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 (41) hide show
  1. package/dashboard/.next/standalone/dashboard/.next/BUILD_ID +1 -1
  2. package/dashboard/.next/standalone/dashboard/.next/build-manifest.json +2 -2
  3. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.html +2 -2
  4. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.rsc +1 -1
  5. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/dashboard/.next/standalone/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  11. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.html +1 -1
  12. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.rsc +2 -2
  13. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  14. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  15. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  16. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  17. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  18. package/dashboard/.next/standalone/dashboard/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  19. package/dashboard/.next/standalone/dashboard/.next/server/app/index.html +1 -1
  20. package/dashboard/.next/standalone/dashboard/.next/server/app/index.rsc +3 -3
  21. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  22. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_full.segment.rsc +3 -3
  23. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_head.segment.rsc +1 -1
  24. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_index.segment.rsc +2 -2
  25. package/dashboard/.next/standalone/dashboard/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  26. package/dashboard/.next/standalone/dashboard/.next/server/app/page/react-loadable-manifest.json +1 -1
  27. package/dashboard/.next/standalone/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  28. package/dashboard/.next/standalone/dashboard/.next/server/chunks/ssr/dashboard_3051539d._.js +1 -1
  29. package/dashboard/.next/standalone/dashboard/.next/server/pages/404.html +1 -1
  30. package/dashboard/.next/standalone/dashboard/.next/server/pages/500.html +2 -2
  31. package/dashboard/.next/standalone/dashboard/.next/static/chunks/1149b3b44ee773af.css +1 -0
  32. package/dashboard/.next/standalone/dashboard/.next/static/chunks/1f5ebabd3b48455f.js +9 -0
  33. package/dashboard/.next/standalone/dashboard/.next/static/chunks/35cfd40af157bddc.js +3 -0
  34. package/dashboard/.next/standalone/dashboard/.next/static/chunks/{ba0a82824f2d743e.js → c8f1a389f6fb4d08.js} +1 -1
  35. package/package.json +1 -1
  36. package/dashboard/.next/standalone/dashboard/.next/static/chunks/0990d325463921e6.css +0 -1
  37. package/dashboard/.next/standalone/dashboard/.next/static/chunks/5f8dc35fbc5e6446.js +0 -9
  38. package/dashboard/.next/standalone/dashboard/.next/static/chunks/9232a2d99b47b21f.js +0 -3
  39. /package/dashboard/.next/standalone/dashboard/.next/static/{6CcZ7pEGzKu1lSJdZYC_7 → w5g2QLCHvT4o8-6fmh6hX}/_buildManifest.js +0 -0
  40. /package/dashboard/.next/standalone/dashboard/.next/static/{6CcZ7pEGzKu1lSJdZYC_7 → w5g2QLCHvT4o8-6fmh6hX}/_clientMiddlewareManifest.json +0 -0
  41. /package/dashboard/.next/standalone/dashboard/.next/static/{6CcZ7pEGzKu1lSJdZYC_7 → w5g2QLCHvT4o8-6fmh6hX}/_ssgManifest.js +0 -0
@@ -1,3 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,68595,e=>{"use strict";var t=e.i(22534),s=e.i(27493),a=e.i(4),l=e.i(13132),r=e.i(6847),i=e.i(17278),n=e.i(24929);let c=(0,n.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),o=(0,n.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);var d=e.i(22934);let x=(0,n.default)("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),h=(0,n.default)("list-tree",[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]]);var m=e.i(13808),u=e.i(88969);let p=t.default.env.NEXT_PUBLIC_API_URL||"http://localhost:3001",f={tool:"#22d3ee",person:"#34d399",concept:"#f59e0b",language:"#a78bfa",file:"#64748b",service:"#f472b6",pattern:"#fb923c"},b={uses:"#22d3ee",implements:"#34d399",depends_on:"#f59e0b",related_to:"#475569",part_of:"#a78bfa",created_by:"#f472b6",extends:"#fb923c",replaces:"#ef4444",fixes:"#10b981",configures:"#6366f1",prefers:"#f59e0b",avoids:"#ef4444"},y={uses:"uses",implements:"implements",depends_on:"depends on",related_to:"related to",extends:"extends",replaces:"replaces",fixes:"fixes",configures:"configures",prefers:"prefers",avoids:"avoids"},g="#94a3b8",j=(0,l.default)(()=>e.A(23531),{loadableGenerated:{modules:[23272]},ssr:!1});function v(e,t,s,a){return{x:e+Math.cos(a)*s,y:t+Math.sin(a)*s}}function N(){let e=(0,a.useRef)(null),t=(0,a.useRef)(void 0),l=(0,a.useRef)(null),[n,N]=(0,a.useState)({width:800,height:600}),[k,w]=(0,a.useState)(null),[$,M]=(0,a.useState)([]),[C,_]=(0,a.useState)(null),[S,T]=(0,a.useState)([]),[P,R]=(0,a.useState)(!0),[X,Y]=(0,a.useState)(null),[z,F]=(0,a.useState)(""),[L,E]=(0,a.useState)([]),[A,D]=(0,a.useState)(!1),[I,W]=(0,a.useState)("outline"),[B,G]=(0,a.useState)({scale:1,offsetX:0,offsetY:0}),U=(0,a.useRef)(null),O=(0,a.useRef)(null),[Q,q]=(0,a.useState)([]);(0,a.useEffect)(()=>{let t=e.current;if(!t)return;let s=()=>N({width:t.clientWidth,height:t.clientHeight});s();let a=new ResizeObserver(s);return a.observe(t),()=>a.disconnect()},[]);let H=(0,a.useCallback)(e=>{w(t=>(null!==t&&t!==e&&M(e=>[...e,t]),e))},[]);(0,a.useEffect)(()=>{(0,u.authFetch)(`${p}/api/graph/entities?limit=30`).then(e=>e.json()).then(e=>{let t=e.entities||[];q(t),t.length>0&&H(t[0].id),R(!1)}).catch(e=>{Y(e.message),R(!1)})},[]),(0,a.useEffect)(()=>{null!==k&&(R(!0),Promise.all([(0,u.authFetch)(`${p}/api/graph/entities/${k}/neighbourhood`).then(e=>e.json()),(0,u.authFetch)(`${p}/api/graph/entities/${k}/memories`).then(e=>e.json())]).then(([e,t])=>{_(e),T(t.memories||[]),R(!1),Y(null)}).catch(e=>{Y(e.message),R(!1)}))},[k]),(0,a.useEffect)(()=>{if(!C||!t.current)return;let e=setTimeout(()=>{t.current?.zoomToFit(400,60)},500);return()=>clearTimeout(e)},[C]),(0,a.useEffect)(()=>{G({scale:1,offsetX:0,offsetY:0}),l.current=null},[I,k]);let K=(0,a.useCallback)(()=>{M(e=>0===e.length?e:(w(e[e.length-1]),e.slice(0,-1)))},[]),V=(0,a.useCallback)(e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),s=e.clientX-t.left,a=e.clientY-t.top;G(t=>{let l=e.deltaY<0?1.12:.9,r=Math.min(2.6,Math.max(.65,t.scale*l));if(1e-4>Math.abs(r-t.scale))return t;let i=s-(s-t.offsetX)*r/t.scale,n=a-(a-t.offsetY)*r/t.scale;return{scale:r,offsetX:i,offsetY:n}})},[]),Z=(0,a.useCallback)(e=>{l.current={startX:e.clientX,startY:e.clientY,offsetX:B.offsetX,offsetY:B.offsetY}},[B.offsetX,B.offsetY]),J=(0,a.useCallback)(e=>{let t=l.current;t&&G(s=>({...s,offsetX:t.offsetX+(e.clientX-t.startX),offsetY:t.offsetY+(e.clientY-t.startY)}))},[]),ee=(0,a.useCallback)(()=>{l.current=null},[]);(0,a.useEffect)(()=>z.trim()?(O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{(0,u.authFetch)(`${p}/api/graph/search?q=${encodeURIComponent(z)}&limit=8`).then(e=>e.json()).then(e=>E(e.entities||[])).catch(()=>{})},200),()=>{O.current&&clearTimeout(O.current)}):void E([]),[z]);let et=(0,a.useMemo)(()=>{if(!C)return{nodes:[],links:[]};let e=C.neighbours.map(e=>{let t=C.triples.filter(t=>t.subject_id===e.id||t.object_id===e.id),s=t.filter(e=>"related_to"!==e.predicate),a=s[0]?.predicate??t[0]?.predicate??"related_to",l=10*e.memoryCount+50*s.length+t.length;return{entity:e,strongestPredicate:a,hasMeaningfulLink:s.length>0,score:l}}),t=[...e.filter(e=>e.hasMeaningfulLink).sort((e,t)=>t.score-e.score).slice(0,10),...e.filter(e=>!e.hasMeaningfulLink).sort((e,t)=>t.score-e.score).slice(0,6)],s=new Set(t.map(e=>e.entity.id)),a=[C.focal,...C.neighbours.filter(e=>s.has(e.id))],l=Math.max(1,...a.map(e=>e.memoryCount)),r=new Set(a.map(e=>e.id)),i=new Map;i.set(C.focal.id,{id:C.focal.id,name:C.focal.name,entityType:C.focal.type,memoryCount:C.focal.memoryCount,isFocal:!0,val:28,x:0,y:0,fx:0,fy:0,labelDirection:"center"});let n=(e,t,s)=>{let a=e.entity.memoryCount/l;i.set(e.entity.id,{id:e.entity.id,name:e.entity.name,entityType:e.entity.type,memoryCount:e.entity.memoryCount,isFocal:!1,val:7+14*Math.pow(a,.6),x:t,y:s,fx:t,fy:s,labelDirection:40>Math.abs(t)?"center":t>0?"right":"left"})};if("fractal"===I){let e=[...t.reduce((e,t)=>{let s=t.hasMeaningfulLink?t.strongestPredicate:`ambient:${t.entity.type}`;return e.has(s)||e.set(s,[]),e.get(s).push(t),e},new Map).entries()].sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0]));e.forEach(([,t],s)=>{let a=-Math.PI/2+s/Math.max(e.length,1)*Math.PI*2;t.sort((e,t)=>t.score-e.score).forEach((e,t)=>{let s=a+(0===t?0:.18*Math.ceil(t/2)*(t%2==0?-1:1)),l=165+78*t,r=(t%3==0?1:-1)*(12+4*t);n(e,Math.cos(s)*l+Math.cos(s+Math.PI/2)*r,Math.sin(s)*l+Math.sin(s+Math.PI/2)*r)})})}else{let e=t.filter(e=>e.hasMeaningfulLink),s=t.filter(e=>!e.hasMeaningfulLink),a=(e,t,s)=>{e.forEach((a,l)=>{let r=1===e.length?-Math.PI/2:-Math.PI/2+l/e.length*Math.PI*2;n(a,Math.cos(r)*t,Math.sin(r)*s)})};a(e,250,180),a(s,360,255)}let c=[...i.values()],o=C.triples.filter(e=>r.has(e.subject_id)&&r.has(e.object_id)).filter(e=>"related_to"!==e.predicate||e.subject_id===C.focal.id||e.object_id===C.focal.id).map(e=>({source:e.subject_id,target:e.object_id,predicate:e.predicate})),d=new Set;return{nodes:c,links:o.filter(e=>{let t=`${e.source}-${e.target}`,s=`${e.target}-${e.source}`;return!(d.has(t)||d.has(s))&&(d.add(t),!0)})}},[I,C]);(0,a.useEffect)(()=>{let e=t.current;e&&0!==et.nodes.length&&(e.d3Force("charge")?.strength(0),e.d3Force("center",null),e.d3Force("link")?.distance(e=>"related_to"===e.predicate?160:120))},[et]);let es=(0,a.useCallback)((e,t,s)=>{let a=e.x,l=e.y;if(null==a||null==l)return;let r=f[e.entityType]||g,i=Math.max(4,e.val);e.isFocal&&(t.beginPath(),t.arc(a,l,i+6,0,2*Math.PI),t.fillStyle=r+"20",t.fill()),t.beginPath(),t.arc(a,l,i,0,2*Math.PI),t.fillStyle=e.isFocal?r:r+"cc",t.fill(),e.isFocal&&(t.lineWidth=3,t.strokeStyle="#ffffff",t.stroke());let n=e.isFocal?40:22,c=e.name.length>n?e.name.slice(0,n)+"…":e.name,o=e.isFocal?Math.max(14,16/s):Math.max(11,13/s);t.font=`${e.isFocal?"bold ":""}${o}px Sans-Serif`;let d=e.labelDirection??"center",x="left"===d,h="right"===d,m=x?a-i-10:h?a+i+10:a,u="center"===d?l+i+6:l-o/2;t.textAlign=x?"right":h?"left":"center",t.textBaseline="center"===d?"top":"middle";let p=t.measureText(c).width,b="center"===d?u-3:u-o/2-3;if(t.fillStyle="rgba(2, 6, 23, 0.9)",t.beginPath(),t.roundRect(x?m-p-3:h?m-3:m-p/2-3,b,p+6,o+6,3),t.fill(),t.fillStyle=e.isFocal?"#ffffff":"#cbd5e1",t.fillText(c,m,u),e.memoryCount>1){let n=`${e.memoryCount}`,c=Math.max(8,10/s);t.font=`${c}px Sans-Serif`;let o=t.measureText(n).width+6,d=a+i-2,x=l-i-2;t.fillStyle=r,t.beginPath(),t.roundRect(d-o/2,x-c/2-2,o,c+4,4),t.fill(),t.fillStyle="#020617",t.textAlign="center",t.textBaseline="middle",t.fillText(n,d,x)}},[]),ea=(0,a.useCallback)((e,t,s)=>{let a=e.source,l=e.target;if(!a?.x||!l?.x)return;let r="related_to"===e.predicate,i="fractal"===I,n=(a.x+l.x)/2,c=(a.y+l.y)/2,o=.14*!!i;if(t.beginPath(),t.moveTo(a.x,a.y),i?t.quadraticCurveTo(n+n*o,c+c*o,l.x,l.y):t.lineTo(l.x,l.y),t.strokeStyle=b[e.predicate]||"#475569",t.lineWidth=r?i?.7:.8:i?1.7:2,t.globalAlpha=r?i?.12:.2:i?.62:.7,t.stroke(),t.globalAlpha=1,!r&&s>.8){let a=y[e.predicate]||e.predicate,l=Math.max(8,10/s);t.font=`${l}px Sans-Serif`,t.textAlign="center",t.textBaseline="middle";let r=t.measureText(a).width;t.fillStyle="rgba(2, 6, 23, 0.85)",t.beginPath(),t.roundRect(n-r/2-2,c-l/2-1,r+4,l+2,2),t.fill(),t.fillStyle=b[e.predicate]||"#94a3b8",t.globalAlpha=.8,t.fillText(a,n,c),t.globalAlpha=1}},[I]),el=(0,a.useCallback)(e=>`${e.name}
2
- ${e.entityType} \u00b7 ${e.memoryCount} memories
3
- Click to explore`,[]),er=(0,a.useCallback)(e=>{e.isFocal||H(e.id)},[H]),ei=C?.focal,en=C?.neighbours||[],ec=(0,a.useMemo)(()=>C?C.triples.map(e=>{let t=e.subject_id===C.focal.id,s=t?e.object_id:e.subject_id,a=C.neighbours.find(e=>e.id===s);return a?{key:e.id,direction:t?"out":"in",predicate:e.predicate,sentence:t?`${C.focal.name} ${y[e.predicate]||e.predicate} ${a.name}`:`${a.name} ${y[e.predicate]||e.predicate} ${C.focal.name}`,neighbour:a}:null}).filter(e=>!!e).sort((e,t)=>"related_to"===e.predicate&&"related_to"!==t.predicate?1:"related_to"!==e.predicate&&"related_to"===t.predicate?-1:t.neighbour.memoryCount-e.neighbour.memoryCount):[],[C]),eo=(0,a.useMemo)(()=>{if(!C||n.width<=0||n.height<=0)return null;let e=Math.max(n.width,900),t=Math.max(n.height,620),s=.5*e,a=.72*t,l=C.neighbours.map(e=>{let t=C.triples.filter(t=>t.subject_id===e.id||t.object_id===e.id),s=t.filter(e=>"related_to"!==e.predicate),a=s[0]?.predicate??t[0]?.predicate??e.type,l=10*e.memoryCount+48*s.length+t.length;return{entity:e,strongestPredicate:a,score:l}}).sort((e,t)=>t.score-e.score).slice(0,16),r=[...l.reduce((e,t)=>{let s=t.strongestPredicate;return e.has(s)||e.set(s,[]),e.get(s).push(t),e},new Map).entries()].sort((e,t)=>t[1].length-e[1].length||e[0].localeCompare(t[0])).slice(0,6),i=Math.max(1,C.focal.memoryCount,...l.map(e=>e.entity.memoryCount)),c=r.map(([e,t],l)=>{let n=b[e]||f[t[0]?.entity.type||"tool"]||g,c=1===r.length?-Math.PI/2:-(.88*Math.PI)+l/(r.length-1)*(.76*Math.PI),o=210+18*t.length,d=Math.min(.24,.1+.015*t.length),x=v(s,a,44,c-.08),h=v(s,a,44,c+.08),m=v(s,a,.62*o,c-d),u=v(s,a,.62*o,c+d),p=v(s,a,o,c),j=v(s,a,.42*o,c),N=v(s,a,.35*o,c),k=t.map((e,t)=>{let l=e.entity.memoryCount/i,r=c+(0===t?0:.13*Math.ceil(t/2)*(t%2==0?-1:1)),n=v(s,a,118+50*t,r),o=v(0,0,8+3*t,r+Math.PI/2);return{id:e.entity.id,name:e.entity.name,entityType:e.entity.type,memoryCount:e.entity.memoryCount,x:n.x+o.x,y:n.y+o.y,radius:8+12*Math.pow(l,.55)}}),w=k.map((t,s)=>{let a=v(N.x,N.y,18+8*s,c+(0===s?0:s%2==0?-.18:.18));return{key:`${e}-${t.id}`,path:`M ${N.x} ${N.y} Q ${a.x} ${a.y} ${t.x} ${t.y}`}});return{key:e,label:y[e]||e.replace(/_/g," "),color:n,petalPath:`M ${x.x} ${x.y} Q ${m.x} ${m.y} ${p.x} ${p.y} Q ${u.x} ${u.y} ${h.x} ${h.y} Q ${s} ${a} ${x.x} ${x.y} Z`,stemPath:`M ${s} ${a} Q ${j.x} ${j.y} ${p.x} ${p.y}`,labelX:p.x,labelY:p.y-10,nodeStems:w,nodes:k}}),o=new Map;c.forEach(e=>{e.nodes.forEach(e=>o.set(e.id,e))});let d=new Set(o.keys()),x=C.triples.filter(e=>d.has(e.subject_id)&&d.has(e.object_id)&&e.subject_id!==C.focal.id&&e.object_id!==C.focal.id&&"related_to"!==e.predicate).slice(0,10).map(e=>{let t=o.get(e.subject_id),l=o.get(e.object_id),r=v(s,a,Math.max(Math.hypot(t.x-s,t.y-a),Math.hypot(l.x-s,l.y-a))+55,Math.atan2((t.y+l.y)/2-a,(t.x+l.x)/2-s));return{key:`${e.id}`,color:b[e.predicate]||g,path:`M ${t.x} ${t.y} Q ${r.x} ${r.y} ${l.x} ${l.y}`}});return{width:e,height:t,centerX:s,centerY:a,focalRadius:30,focalGlowRadius:46,branches:c,crossLinks:x}},[n.height,n.width,C]);if(!P&&0===Q.length&&!k)return(0,s.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-center max-w-md",children:[(0,s.jsx)("div",{className:"text-slate-600 text-4xl mb-4",children:"🕸"}),(0,s.jsx)("h3",{className:"text-lg font-medium text-slate-300 mb-2",children:"No knowledge graph yet"}),(0,s.jsx)("p",{className:"text-sm text-slate-500",children:"As memories are created, ShieldCortex automatically extracts entities and relationships. The graph will appear here once entities are detected."})]})});let ed=(()=>{if(!C)return[];let e=new Map;for(let t of C.triples){let s=t.subject_id===C.focal.id,a=s?t.object_id:t.subject_id,l=C.neighbours.find(e=>e.id===a);if(!l)continue;let r=`${t.predicate}-${s?"out":"in"}`;e.has(r)||e.set(r,{predicate:t.predicate,neighbours:[],direction:s?"out":"in"});let i=e.get(r);i.neighbours.find(e=>e.id===l.id)||i.neighbours.push(l)}return[...e.values()].sort((e,t)=>"related_to"===e.predicate&&"related_to"!==t.predicate?1:"related_to"!==e.predicate&&"related_to"===t.predicate?-1:t.neighbours.length-e.neighbours.length)})();return(0,s.jsxs)("div",{className:"w-full h-full flex flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-slate-800 bg-slate-900/50 shrink-0",children:[(0,s.jsx)("button",{onClick:K,disabled:0===$.length,className:"p-1.5 rounded text-slate-400 hover:text-white hover:bg-slate-800 disabled:opacity-30 disabled:cursor-default transition-colors",title:"Go back",children:(0,s.jsx)(c,{size:16})}),ei&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-sm min-w-0",children:[(0,s.jsx)("div",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:f[ei.type]||g}}),(0,s.jsx)("span",{className:"font-semibold text-white truncate",children:ei.name}),(0,s.jsx)("span",{className:"text-slate-500 shrink-0",children:ei.type}),(0,s.jsx)("span",{className:"text-slate-600 shrink-0",children:"·"}),(0,s.jsxs)("span",{className:"text-slate-500 shrink-0",children:[ei.memoryCount," memories"]}),C&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-slate-600 shrink-0",children:"·"}),(0,s.jsxs)("span",{className:"text-slate-500 shrink-0",children:[en.length," connections"]})]})]}),(0,s.jsx)("div",{className:"flex-1"}),(0,s.jsxs)("div",{className:"flex items-center rounded-lg border border-slate-700 bg-slate-900/80 p-0.5",children:[(0,s.jsxs)("button",{onClick:()=>W("outline"),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${"outline"===I?"bg-cyan-500/15 text-cyan-300":"text-slate-400 hover:text-slate-200"}`,title:"Readable relationship outline",children:[(0,s.jsx)(h,{size:12}),"Read"]}),(0,s.jsxs)("button",{onClick:()=>W("map"),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${"map"===I?"bg-cyan-500/15 text-cyan-300":"text-slate-400 hover:text-slate-200"}`,title:"Graph canvas",children:[(0,s.jsx)(x,{size:12}),"Map"]}),(0,s.jsxs)("button",{onClick:()=>W("fractal"),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${"fractal"===I?"bg-cyan-500/15 text-cyan-300":"text-slate-400 hover:text-slate-200"}`,title:"Fractal bloom layout",children:[(0,s.jsx)(m.Sparkles,{size:12}),"Bloom"]})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>{D(!A),setTimeout(()=>U.current?.focus(),100)},className:"p-1.5 rounded text-slate-400 hover:text-white hover:bg-slate-800 transition-colors",title:"Search entities",children:(0,s.jsx)(r.Search,{size:16})}),A&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-72 bg-slate-800 border border-slate-700 rounded-lg shadow-xl z-30",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(r.Search,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),(0,s.jsx)("input",{ref:U,type:"text",placeholder:"Search entities...",value:z,onChange:e=>F(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(D(!1),F(""))},className:"w-full pl-8 pr-8 py-2 text-sm bg-transparent border-b border-slate-700 text-white placeholder:text-slate-500 focus:outline-none"}),z&&(0,s.jsx)("button",{onClick:()=>F(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white",children:(0,s.jsx)(i.X,{size:12})})]}),(0,s.jsx)("div",{className:"max-h-64 overflow-y-auto",children:L.length>0?L.map(e=>(0,s.jsxs)("button",{onClick:()=>{H(e.id),D(!1),F("")},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-slate-300 hover:bg-slate-700 transition-colors",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:f[e.type]||g}}),(0,s.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-slate-500 shrink-0",children:e.type}),(0,s.jsx)("span",{className:"text-xs text-slate-600 shrink-0",children:e.memoryCount})]},e.id)):z.trim()?(0,s.jsx)("div",{className:"px-3 py-4 text-xs text-slate-500 text-center",children:"No entities found"}):(0,s.jsx)("div",{className:"px-3 py-2 text-xs text-slate-600",children:"Type to search..."})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 text-xs text-slate-600",title:"Graph shows all projects",children:[(0,s.jsx)(o,{size:11}),(0,s.jsx)("span",{children:"Workspace-wide"})]})]}),(0,s.jsxs)("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[(0,s.jsxs)("div",{className:"w-[240px] shrink-0 border-r border-slate-800 bg-slate-900/30 flex flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-3 border-b border-slate-800",children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-slate-600 mb-2",children:"Top Entities"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:Q.slice(0,12).map(e=>(0,s.jsxs)("button",{onClick:()=>H(e.id),className:`flex items-center gap-1 px-2 py-0.5 text-xs rounded-full border transition-colors ${k===e.id?"border-transparent text-white":"border-slate-700 text-slate-500 hover:text-slate-300 hover:border-slate-600"}`,style:k===e.id?{backgroundColor:(f[e.type]||g)+"40",color:f[e.type]}:{},children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:f[e.type]||g}}),e.name]},e.id))})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto",children:ed.length>0?ed.map(e=>(0,s.jsxs)("div",{className:"border-b border-slate-800/50",children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider font-medium",style:{color:b[e.predicate]||"#94a3b8"},children:["out"===e.direction?"":"← ",y[e.predicate]||e.predicate,"out"===e.direction?" →":"",(0,s.jsxs)("span",{className:"text-slate-600 ml-1",children:["(",e.neighbours.length,")"]})]}),e.neighbours.map(e=>(0,s.jsxs)("button",{onClick:()=>H(e.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-slate-400 hover:text-white hover:bg-slate-800/50 transition-colors",children:[(0,s.jsx)("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:f[e.type]||g}}),(0,s.jsx)("span",{className:"truncate flex-1 text-left",children:e.name}),(0,s.jsx)("span",{className:"text-slate-600 tabular-nums shrink-0",children:e.memoryCount}),(0,s.jsx)(d.ChevronRight,{size:10,className:"text-slate-700 shrink-0"})]},e.id))]},`${e.predicate}-${e.direction}`)):P?(0,s.jsx)("div",{className:"p-4 text-xs text-slate-500 text-center animate-pulse",children:"Loading..."}):(0,s.jsx)("div",{className:"p-4 text-xs text-slate-500 text-center",children:"No connections"})}),S.length>0&&(0,s.jsxs)("div",{className:"border-t border-slate-800 max-h-[200px] overflow-y-auto",children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-slate-600 sticky top-0 bg-slate-900/80 backdrop-blur-sm",children:["Memories (",S.length,")"]}),S.slice(0,15).map(e=>(0,s.jsxs)("div",{className:"px-3 py-1.5 border-b border-slate-800/30",children:[(0,s.jsx)("div",{className:"text-xs text-slate-300 truncate",children:e.title}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[(0,s.jsx)("span",{className:"text-[10px] text-slate-500",children:e.category}),(0,s.jsx)("span",{className:"text-[10px] text-slate-600 ml-auto",children:new Date(e.created_at).toLocaleDateString()})]})]},e.id))]})]}),"outline"===I?(0,s.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto bg-slate-950/20",children:[P&&(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsx)("div",{className:"text-slate-400 animate-pulse text-sm",children:"Loading..."})}),X&&(0,s.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,s.jsxs)("div",{className:"text-red-400 text-sm",children:["Error: ",X]})}),!P&&!X&&ei&&(0,s.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-4 p-4",children:[(0,s.jsxs)("div",{className:"grid gap-4 lg:grid-cols-[1.15fr_0.85fr]",children:[(0,s.jsx)("section",{className:"rounded-2xl border border-slate-800 bg-slate-900/40 p-4",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.28em] text-slate-600",children:"Focused Entity"}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,s.jsx)("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:f[ei.type]||g}}),(0,s.jsx)("h2",{className:"text-2xl font-semibold text-white",children:ei.name}),(0,s.jsx)("span",{className:"rounded-full border border-slate-700 px-2 py-0.5 text-xs text-slate-400",children:ei.type})]}),ei.aliases.length>0&&(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-1",children:ei.aliases.slice(0,8).map(e=>(0,s.jsx)("span",{className:"rounded-full bg-slate-800 px-2 py-0.5 text-[11px] text-slate-300",children:e},e))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-right",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-slate-800 bg-slate-950/50 px-3 py-2",children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-600",children:"Memories"}),(0,s.jsx)("div",{className:"mt-1 text-xl font-semibold text-white",children:ei.memoryCount})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-slate-800 bg-slate-950/50 px-3 py-2",children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-600",children:"Direct Links"}),(0,s.jsx)("div",{className:"mt-1 text-xl font-semibold text-white",children:ec.length})]})]})]})}),(0,s.jsxs)("section",{className:"rounded-2xl border border-slate-800 bg-slate-900/40 p-4",children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.28em] text-slate-600",children:"How To Read This"}),(0,s.jsxs)("div",{className:"mt-3 space-y-3 text-sm text-slate-300",children:[(0,s.jsx)("p",{children:"This view turns the graph into readable statements and evidence instead of relying on overlapping labels."}),(0,s.jsxs)("p",{children:["Click any related entity to recenter the graph. Use ",(0,s.jsx)("span",{className:"font-medium text-cyan-300",children:"Map"})," when you want spatial context, and ",(0,s.jsx)("span",{className:"font-medium text-cyan-300",children:"Read"})," when you want meaning."]})]})]})]}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[1.15fr_0.85fr]",children:[(0,s.jsxs)("section",{className:"rounded-2xl border border-slate-800 bg-slate-900/30 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.28em] text-slate-600",children:"Relationship Outline"}),(0,s.jsx)("div",{className:"mt-1 text-sm text-slate-400",children:"Readable connections grouped by meaning instead of force layout."})]}),(0,s.jsxs)("div",{className:"text-xs text-slate-500",children:[ec.length," statements"]})]}),(0,s.jsx)("div",{className:"mt-4 space-y-4",children:ed.length>0?ed.map(e=>{let t=ec.filter(t=>t.predicate===e.predicate&&t.direction===e.direction);return(0,s.jsxs)("div",{className:"rounded-xl border border-slate-800 bg-slate-950/40",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-slate-800 px-4 py-3",children:[(0,s.jsx)("div",{className:"text-sm font-medium",style:{color:b[e.predicate]||"#94a3b8"},children:"out"===e.direction?`${ei.name} ${y[e.predicate]||e.predicate}...`:`... ${y[e.predicate]||e.predicate} ${ei.name}`}),(0,s.jsx)("div",{className:"text-xs text-slate-500",children:t.length})]}),(0,s.jsx)("div",{className:"divide-y divide-slate-800/80",children:t.map(e=>(0,s.jsxs)("button",{onClick:()=>H(e.neighbour.id),className:"flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-slate-900/60",children:[(0,s.jsx)("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:f[e.neighbour.type]||g}}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"truncate text-sm text-white",children:e.sentence}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-[11px] text-slate-500",children:[(0,s.jsx)("span",{children:e.neighbour.type}),(0,s.jsx)("span",{children:"·"}),(0,s.jsxs)("span",{children:[e.neighbour.memoryCount," memories"]})]})]}),(0,s.jsx)(d.ChevronRight,{size:14,className:"shrink-0 text-slate-600"})]},e.key))})]},`${e.predicate}-${e.direction}`)}):(0,s.jsx)("div",{className:"rounded-xl border border-dashed border-slate-800 px-4 py-8 text-center text-sm text-slate-500",children:"No direct relationships for this entity yet."})})]}),(0,s.jsxs)("section",{className:"rounded-2xl border border-slate-800 bg-slate-900/30 p-4",children:[(0,s.jsx)("div",{className:"text-[10px] uppercase tracking-[0.28em] text-slate-600",children:"Evidence Memories"}),(0,s.jsx)("div",{className:"mt-1 text-sm text-slate-400",children:"The actual memories backing this node and its relationships."}),(0,s.jsx)("div",{className:"mt-4 space-y-3",children:S.length>0?S.map(e=>(0,s.jsxs)("div",{className:"rounded-xl border border-slate-800 bg-slate-950/50 px-4 py-3",children:[(0,s.jsx)("div",{className:"truncate text-sm font-medium text-white",children:e.title}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-slate-500",children:[(0,s.jsx)("span",{className:"rounded-full border border-slate-800 px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:e.category}),(0,s.jsx)("span",{children:new Date(e.created_at).toLocaleDateString()}),(0,s.jsxs)("span",{className:"ml-auto",children:["salience ",Math.round(100*e.salience),"%"]})]})]},e.id)):(0,s.jsx)("div",{className:"rounded-xl border border-dashed border-slate-800 px-4 py-8 text-center text-sm text-slate-500",children:"No linked memories found."})})]})]})]})]}):"fractal"===I?(0,s.jsxs)("div",{ref:e,className:"relative flex-1 min-h-0 overflow-hidden bg-[radial-gradient(circle_at_center,rgba(34,211,238,0.08),rgba(2,6,23,0.02)_28%,rgba(2,6,23,0)_56%)]",children:[(0,s.jsxs)("div",{className:"absolute right-4 top-4 z-20 flex items-center gap-2",children:[(0,s.jsx)("div",{className:"rounded-full border border-slate-800 bg-slate-950/70 px-3 py-1 text-[11px] text-slate-400",children:"Wheel to zoom • drag to pan"}),(0,s.jsx)("button",{onClick:()=>G({scale:1,offsetX:0,offsetY:0}),className:"rounded-full border border-slate-700 bg-slate-950/70 px-3 py-1 text-[11px] text-slate-300 transition-colors hover:border-slate-600 hover:text-white",children:"Reset view"})]}),P&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsx)("div",{className:"text-slate-400 animate-pulse text-sm",children:"Loading..."})}),X&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsxs)("div",{className:"text-red-400 text-sm",children:["Error: ",X]})}),!P&&!X&&eo&&ei&&(0,s.jsxs)("svg",{width:n.width,height:n.height,viewBox:`0 0 ${eo.width} ${eo.height}`,className:`h-full w-full ${l.current?"cursor-grabbing":"cursor-grab"}`,onWheel:V,onMouseDown:Z,onMouseMove:J,onMouseUp:ee,onMouseLeave:ee,children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("filter",{id:"bloom-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:[(0,s.jsx)("feGaussianBlur",{stdDeviation:"14",result:"blur"}),(0,s.jsx)("feColorMatrix",{in:"blur",type:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -8"})]})}),(0,s.jsxs)("g",{transform:`translate(${B.offsetX} ${B.offsetY}) scale(${B.scale})`,children:[eo.branches.map((e,t)=>(0,s.jsxs)("g",{children:[(0,s.jsx)("path",{d:e.petalPath,fill:`${e.color}0a`,stroke:"none"}),(0,s.jsx)("path",{d:e.stemPath,fill:"none",stroke:`${e.color}66`,strokeWidth:2,strokeLinecap:"round"}),e.nodeStems.map(t=>(0,s.jsx)("path",{d:t.path,fill:"none",stroke:`${e.color}52`,strokeWidth:1.2,strokeLinecap:"round"},t.key)),(0,s.jsx)("circle",{cx:e.labelX,cy:e.labelY+8,r:22,fill:`${e.color}0d`}),(0,s.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:"middle",className:"fill-slate-400 text-[11px] uppercase tracking-[0.22em]",children:e.label}),(0,s.jsx)("animateTransform",{attributeName:"transform",type:"rotate",values:`0 ${eo.centerX} ${eo.centerY}; ${t%2==0?1.2:-1.2} ${eo.centerX} ${eo.centerY}; 0 ${eo.centerX} ${eo.centerY}`,dur:`${16+2*t}s`,begin:`${-1.4*t}s`,repeatCount:"indefinite"})]},e.key)),eo.crossLinks.map(e=>(0,s.jsx)("path",{d:e.path,fill:"none",stroke:`${e.color}66`,strokeWidth:1.3,strokeDasharray:"5 6",opacity:.65},e.key)),(0,s.jsx)("circle",{cx:eo.centerX,cy:eo.centerY,r:eo.focalGlowRadius,fill:f[ei.type]||g,opacity:.14,filter:"url(#bloom-glow)"}),(0,s.jsx)("circle",{cx:eo.centerX,cy:eo.centerY,r:eo.focalRadius+8,fill:"none",stroke:`${f[ei.type]||g}55`,strokeWidth:1.5}),(0,s.jsx)("circle",{cx:eo.centerX,cy:eo.centerY,r:eo.focalRadius,fill:f[ei.type]||g,stroke:"#ffffff",strokeWidth:2.5}),(0,s.jsx)("text",{x:eo.centerX,y:eo.centerY+eo.focalRadius+26,textAnchor:"middle",className:"fill-white text-[16px] font-semibold",children:ei.name}),eo.branches.flatMap(e=>e.nodes).map((e,t)=>(0,s.jsxs)("g",{onClick:()=>H(e.id),className:"cursor-pointer",children:[(0,s.jsx)("animateTransform",{attributeName:"transform",type:"translate",values:`0 0; ${e.id%7-3} ${(e.id%5-2)*1.4}; 0 0`,dur:`${6+t%5}s`,begin:`${-(t%6*.8)}s`,repeatCount:"indefinite"}),(0,s.jsx)("circle",{cx:e.x,cy:e.y,r:e.radius+5,fill:f[e.entityType]||g,opacity:.1}),(0,s.jsx)("circle",{cx:e.x,cy:e.y,r:e.radius,fill:f[e.entityType]||g,opacity:.95}),(0,s.jsx)("rect",{x:e.x-14,y:e.y-e.radius-18,rx:8,width:28,height:16,fill:`${f[e.entityType]||g}dd`}),(0,s.jsx)("text",{x:e.x,y:e.y-e.radius-7,textAnchor:"middle",className:"fill-slate-950 text-[10px] font-semibold",children:e.memoryCount}),(0,s.jsx)("text",{x:e.x,y:e.y+e.radius+18,textAnchor:"middle",className:"fill-slate-200 text-[12px]",children:e.name})]},e.id))]})]})]}):(0,s.jsxs)("div",{ref:e,className:"flex-1 min-h-0 relative",children:[P&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsx)("div",{className:"text-slate-400 animate-pulse text-sm",children:"Loading..."})}),X&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,s.jsxs)("div",{className:"text-red-400 text-sm",children:["Error: ",X]})}),!P&&!X&&et.nodes.length>0&&n.width>0&&(0,s.jsx)(j,{ref:t,graphData:et,width:n.width,height:n.height,backgroundColor:"rgba(0,0,0,0)",nodeCanvasObject:es,nodeLabel:el,onNodeClick:er,linkCanvasObject:ea,linkDirectionalArrowLength:6,linkDirectionalArrowRelPos:.85,d3AlphaDecay:.05,d3VelocityDecay:.3,warmupTicks:80,cooldownTicks:150})]})]})]})}e.s(["default",()=>N],68595)},13213,e=>{e.n(e.i(68595))},23531,e=>{e.v(t=>Promise.all(["static/chunks/da64d159c042f5ae.js"].map(t=>e.l(t))).then(()=>t(23272)))}]);