mirror of
https://github.com/samvallad33/vestige.git
synced 2026-05-29 19:35:15 +02:00
9 lines
12 KiB
JavaScript
9 lines
12 KiB
JavaScript
|
|
import"../chunks/Bzak7iHL.js";import{o as we,a as Ne}from"../chunks/CNjeV5xa.js";import{p as Me,s as A,c as le,aB as ve,d as y,e as p,t as L,g as e,f as Ee,u as de,r as v,a as Se,h as d,n as me}from"../chunks/CvjSAYrz.js";import{s as K,d as Ie,a as xe}from"../chunks/FzvEaXMa.js";import{i as ue}from"../chunks/ciN1mm2W.js";import{a as E,c as Fe,b as oe,f as X}from"../chunks/BsvCUYx-.js";import{s as o,r as ge}from"../chunks/CNfQDikv.js";import{b as Ge,a as Pe}from"../chunks/CVpUe0w3.js";import{a as he}from"../chunks/DNjM5a-l.js";import{e as ke}from"../chunks/CtkE7HV2.js";import{e as fe,i as ye}from"../chunks/DTnG8poT.js";import{p as W}from"../chunks/B_YDQCB6.js";import{N as Ce}from"../chunks/DzfRjky4.js";const Re=.93,Te=.05,be="#8B95A5",Le="#818cf8",Oe=140,pe=8,De=4,Ke=12;function je(s){return!Number.isFinite(s)||s<=0?0:s*Re}function Ue(s){return Number.isFinite(s)?s>=Te:!1}function Ae(s){return!Number.isFinite(s)||s<pe?1:2}function _e(s,f,u,x,N=0){if(!Number.isFinite(u)||u<=0)return[];const M=Oe*x,b=[];for(let S=0;S<u;S++){const F=N+S/u*Math.PI*2;b.push({x:s+Math.cos(F)*M,y:f+Math.sin(F)*M})}return b}function qe(s,f,u,x=0){const N=Math.min(u,pe),M=Math.max(0,u-pe);return[..._e(s,f,N,1,x),..._e(s,f,M,2,x)]}function Ye(s,f){if(!Number.isFinite(f)||f<=0||!Number.isFinite(s)||s<0)return 0;const u=1-s/f*.35,x=Ae(s)===1?1:.75;return Math.min(1,u*x)}function ze(s){if(!Number.isFinite(s)||s<0)return 0;const f=Math.floor(s),u=f*De;return Ae(f)===1?u:u+Ke}function Ve(s,f){return f?Le:s?Ce[s]??be:be}function He(s,f){if(!s||s.length===0)return[];const u=[];for(const x of s){if(x===f)break;if(x.type!=="ActivationSpread")continue;const N=x.data;if(typeof N.source_id!="string"||!Array.isArray(N.target_ids))continue;const M=N.target_ids.filter(b=>typeof b=="string");M.length!==0&&u.push({source_id:N.source_id,target_ids:M})}return u.reverse()}var Qe=oe('<circle fill="none" stroke="#818cf8" stroke-width="1.5"></circle>'),We=oe('<line stroke="#818cf8" stroke-width="1.2" stroke-linecap="round"></line>'),Xe=oe('<text text-anchor="middle" fill="#e0e0ff" font-size="11" font-family="var(--font-mono)"> </text>'),Je=oe('<g><circle filter="url(#act-glow-strong)"></circle><circle filter="url(#act-glow)"></circle><circle fill="#ffffff"></circle><!></g>'),Ze=oe('<svg class="w-full h-full block" aria-label="Spreading activation visualization"><defs><filter id="act-glow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="4" result="blur"></feGaussianBlur><feMerge><feMergeNode in="blur"></feMergeNode><feMergeNode in="SourceGraphic"></feMergeNode></feMerge></filter><filter id="act-glow-strong" x="-100%" y="-100%" width="300%" height="300%"><feGaussianBlur stdDeviation="8" result="blur"></feGaussianBlur><feMerge><feMergeNode in="blur"></feMergeNode><feMergeNode in="SourceGraphic"></feMergeNode></feMerge></filter><radialGradient id="ripple-grad" cx="50%" cy="50%" r="50%"><stop offset="70%" stop-color="#818cf8" stop-opacity="0"></stop><stop offset="100%" stop-color="#818cf8" stop-opacity="0.7"></stop></radialGradient></defs><!><!><!></svg>');function $e(s,f){Me(f,!0);let u=W(f,"width",3,900),x=W(f,"height",3,560),N=W(f,"source",3,null),M=W(f,"neighbours",19,()=>[]),b=W(f,"liveBurstKey",3,0),S=W(f,"liveBurst",3,null);const F=22,J=14;let B=A(le([])),G=A(le([])),T=A(le([])),U=0,O=null,ne=null,Z=0;function $(n,t,c,_){U+=1;const i=U,l=b()>0&&e(B).length>0?40:0,m=c+(Math.random()-.5)*l,g=_+(Math.random()-.5)*l;d(T,[...e(T),{burstId:i,x:m,y:g,radius:F,opacity:.75},{burstId:i,x:m,y:g,radius:F,opacity:.5}],!0);const V={id:`${n.id}::${i}`,label:n.label,nodeType:"source",x:m,y:g,activation:1,isSource:!0,sourceBurstId:i},H=[],k=[],C=U*.37%(Math.PI*2),re=qe(m,g,t.length,C);t.forEach((D,ie)=>{const se=re[ie];se&&(H.push({id:`${D.id}::${i}`,label:D.label,nodeType:D.nodeType,x:se.x,y:se.y,activation:Ye(ie,t.length),isSource:!1,sourceBurstId:i}),k.push({burstId:i,sourceNodeId:V.id,targetNodeId:`${D.id}::${i}`,drawProgress:0,staggerDelay:ze(ie),framesElapsed:0}))}),d(B,[...e(B),V,...H],!0),d(G,[...e(G),...k],!0)}function q(){let n=[];for(const i of e(
|
||
|
|
query or switch on live mode to watch the engine fire its own
|
||
|
|
bursts.</p></div></div>`),it=X(`<div class="flex items-center justify-center h-[560px] text-dim"><div class="text-center max-w-md px-6"><div class="text-3xl opacity-20 mb-3">◎</div> <p class="text-sm text-bright mb-1">Waiting for activation</p> <p class="text-xs text-muted">Seed a burst with the search bar above, or enable live mode to
|
||
|
|
overlay bursts from the cognitive engine as they happen.</p></div></div>`),st=X('<div class="p-3 glass rounded-xl !border-synapse/20"><div class="text-[10px] text-synapse-glow mb-1 uppercase tracking-wider">Seed</div> <p class="text-sm text-text"> </p> <div class="flex gap-2 mt-1.5 text-[10px] text-muted"><span> </span> <span> </span></div></div>'),at=X(`<div class="p-6 max-w-6xl mx-auto space-y-6"><header class="space-y-2"><h1 class="text-xl text-bright font-semibold">Spreading Activation</h1> <p class="text-xs text-muted">Collins & Loftus 1975 — activation spreads from a seed memory to
|
||
|
|
neighbours along semantic edges, decaying by 0.93 per animation frame
|
||
|
|
until it drops below 0.05. Search seeds a focused burst; live mode
|
||
|
|
overlays every spread event fired by the cognitive engine in real time.</p></header> <div class="space-y-3"><span class="text-xs text-dim font-medium">Seed Memory</span> <div class="flex gap-2"><input type="text" placeholder="Search for a memory to activate..." class="flex-1 px-4 py-2.5 bg-white/[0.03] border border-synapse/10 rounded-xl text-text text-sm
|
||
|
|
placeholder:text-muted focus:outline-none focus:border-synapse/40 transition backdrop-blur-sm"/> <button class="px-4 py-2.5 bg-synapse/20 border border-synapse/40 text-synapse-glow text-sm rounded-xl hover:bg-synapse/30 transition disabled:opacity-50"> </button></div></div> <div class="flex items-center justify-between text-xs"><label class="flex items-center gap-2 text-dim cursor-pointer select-none"><input type="checkbox" class="accent-synapse-glow"/> <span>Live mode — overlay bursts from cognitive engine events</span></label> <span class="text-muted">Live bursts fired: <span class="text-synapse-glow"> </span></span></div> <div class="glass rounded-2xl overflow-hidden !border-synapse/15 bg-deep/40" style="min-height: 560px;"><!></div> <!></div>`);function yt(s,f){Me(f,!0);let u=A(""),x=A(!1),N=A(!1),M=A(null),b=A(null),S=A(le([])),F=A(!0),J=A(0),B=A(null),G=A(0);const T=new Map;function U(r){T.set(r.id,r)}function O(r){return{id:r.id,label:ne(r.content,r.id),nodeType:r.nodeType}}function ne(r,a){if(r&&r.trim().length>0){const h=r.trim();return h.length>60?h.slice(0,60)+"…":h}return a.slice(0,8)}function Z(r){const a=T.get(r);return a?O(a):{id:r,label:r.slice(0,8),nodeType:"note"}}async function $(){const r=e(u).trim();if(!r){d(M,null);return}d(x,!0),d(N,!0),d(M,null),d(b,null),d(S,[],!0);try{const a=await he.search(r,1);if(!a.results||a.results.length===0)return;const h=a.results[0];U(h),d(b,O(h),!0);const w=await he.explore(h.id,"associations",void 0,15),I=(w==null?void 0:w.results)??(w==null?void 0:w.nodes)??(w==null?void 0:w.associations)??[],R=[];for(const Q of I){if(!Q||typeof Q!="object"||!("id"in Q))continue;const ae=Q;U(ae),R.push(O(ae))}d(S,R,!0)}catch(a){d(M,a instanceof Error?a.message:String(a),!0),d(b,null),d(S,[],!0)}finally{d(x,!1)}}let q=null,Y=null,ce=!1;we(()=>{q=ke.subscribe(r=>{if(!r||r.length===0)return;if(!ce){Y=r[0],ce=!0;return}if(!e(F)){Y=r[0];return}const a=He(r,Y);if(Y=r[0],a.length!==0)for(const h of a){const w=Z(h.source_id),I=h.target_ids.map(R=>Z(R));d(J,e(J)+1),d(B,{source:w,neighbours:I},!0),d(G,e(G)+1)}})}),Ne(()=>{q&&q()});var ee=at(),P=y(p(ee),2),te=y(p(P),2),j=p(te);ge(j);var z=y(j,2),n=p(z,!0);v(z),v(te),v(P);var t=y(P,2),c=p(t),_=p(c);ge(_),me(2),v(c);var i=y(c,2),l=y(p(i)),m=p(l,!0);v(l),v(i),v(t);var g=y(t,2),V=p(g);{var H=r=>{var a=et();E(r,a)},k=r=>{var a=tt(),h=p(a),w=y(p(h),4),I=p(w,!0);v(w),v(h),v(a),L(()=>K(I,e(M))),E(r,a)},C=r=>{var a=rt(),h=p(a),w=y(p(h),4),I=y(p(w)),R=p(I);v(I),me(),v(w),v(h),v(a),L(()=>K(R,`"${e(u)??""}"`)),E(r,a)},re=r=>{var a=it();E(r,a)},D=r=>{$e(r,{width:1040,height:560,get source(){return e(b)},get neighbours(){return e(S)},get liveBurstKey(){return e(J)},get liveBurst(){return e(B)}})};ue(V,r=>{e(x)?r(H):e(M)?r(k,1):!e(b)&&e(N)?r(C,2):e(b)?r(D,!1):r(re,3)})}v(g);var ie=y(g,2);{var se=r=>{var a=st(),h=y(p(a),2),w=p(h,!0);v(h);var I=y(h,2),R=p(I),Q=p(R,!0);v(R);var ae=y(R,2),Be=p(ae);v(ae),v(I),v(a),L(()=>{K(w,e(b).label),K(Q,e(b).nodeType),K(Be,`${e(S).length??""} neighbours`)}),E(r,a)};ue(ie,r=>{e(b)&&r(se)})}v(ee),L(()=>{z.disabled=e(x),K(n,e(x)?"Activating…":"Activate"),K(m,e(G))}),xe("keydown",j,r=>r.key==="Enter"&&$()),Ge(j,()=>e(u),r=>d(u,r)),xe("click",z,$),Pe(_,()=>e(F),r=>d(F,r)),E(s,ee),Se()}Ie(["keydown","click"]);export{yt as component};
|