import"../chunks/Bzak7iHL.js";import{o as Pt}from"../chunks/CNjeV5xa.js";import{m as Kt,ab as qt,aO as Ht,b as Wt,p as Rt,h as C,e as i,t as S,g as t,d as o,r as n,a as Tt,u as y,s as q,f as U,c as Ct,a2 as Xt,i as Zt,n as Gt}from"../chunks/CvjSAYrz.js";import{s as _,d as Ut,a as kt}from"../chunks/FzvEaXMa.js";import{i as R}from"../chunks/ciN1mm2W.js";import{B as Vt}from"../chunks/DE4u6cUg.js";import{e as V,i as rt}from"../chunks/DTnG8poT.js";import{a as x,c as Nt,b as yt,f as h}from"../chunks/BsvCUYx-.js";import{s as Yt}from"../chunks/Bhad70Ss.js";import{b as Jt}from"../chunks/CVpUe0w3.js";import{g as Qt}from"../chunks/S0ILvWpb.js";import{b as te}from"../chunks/DJWRm1Ki.js";import{a as Ft}from"../chunks/DNjM5a-l.js";import{N as ee}from"../chunks/DzfRjky4.js";import{s as p}from"../chunks/CNfQDikv.js";import{p as ae}from"../chunks/B_YDQCB6.js";const re=Symbol("NaN");function se(a,F,m){Kt&&qt();var v=new Vt(a),T=!Ht();Wt(()=>{var w=F();w!==w&&(w=re),T&&w!==null&&typeof w=="object"&&(w={}),v.ensure(w,m)})}function Mt(a){return a==null||!Number.isFinite(a)||a<0?0:a>1?1:a}function ne(a){return{novelty:Mt(a==null?void 0:a.novelty),arousal:Mt(a==null?void 0:a.arousal),reward:Mt(a==null?void 0:a.reward),attention:Mt(a==null?void 0:a.attention)}}const It={sm:80,md:180,lg:320};function $t(a){return a&&(a==="sm"||a==="md"||a==="lg")?It[a]:It.md}const gt=[{key:"novelty",angle:-Math.PI/2},{key:"arousal",angle:0},{key:"reward",angle:Math.PI/2},{key:"attention",angle:Math.PI}];function oe(a){const F=$t(a);let m;switch(a){case"lg":m=44;break;case"sm":m=4;break;default:m=28}return Math.max(0,F/2-m)}var ie=yt(''),le=yt(''),de=yt(''),ce=yt(' ',1),ve=yt('');function Et(a,F){Rt(F,!0);let m=ae(F,"size",3,"md"),v=y(()=>$t(m())),T=y(()=>m()!=="sm"),w=y(()=>oe(m())),Y=y(()=>t(v)/2),J=y(()=>t(v)/2);const St={novelty:"Novelty",arousal:"Arousal",reward:"Reward",attention:"Attention"};let N=y(()=>ne({novelty:F.novelty,arousal:F.arousal,reward:F.reward,attention:F.attention}));function H(d,l){const r=d*t(w);return[t(Y)+Math.cos(l)*r,t(J)+Math.sin(l)*r]}const st=[.25,.5,.75,1];function nt(d){return gt.map(({angle:r})=>H(d,r)).map((r,c)=>`${c===0?"M":"L"}${r[0].toFixed(2)},${r[1].toFixed(2)}`).join(" ")+" Z"}let $=q(0);Pt(()=>{const l=performance.now();let r=0;const c=b=>{const g=Math.min(1,(b-l)/600);C($,1-Math.pow(1-g,3)),g<1&&(r=requestAnimationFrame(c))};return r=requestAnimationFrame(c),()=>cancelAnimationFrame(r)});let ot=y(()=>{const d=t($);return gt.map(({key:r,angle:c})=>H(t(N)[r]*d,c)).map((r,c)=>`${c===0?"M":"L"}${r[0].toFixed(2)},${r[1].toFixed(2)}`).join(" ")+" Z"});function _t(d){const l=t(w)+(m()==="lg"?18:12),r=t(Y)+Math.cos(d)*l,c=t(J)+Math.sin(d)*l;let b="middle";return Math.abs(Math.cos(d))>.5&&(b=Math.cos(d)>0?"start":"end"),{x:r,y:c,anchor:b}}var P=ve(),it=i(P);V(it,17,()=>st,rt,(d,l)=>{var r=ie();S(c=>{p(r,"d",c),p(r,"stroke-opacity",t(l)===1?.45:.18),p(r,"stroke-width",t(l)===1?1:.75)},[()=>nt(t(l))]),x(d,r)});var ht=o(it);V(ht,17,()=>gt,rt,(d,l)=>{const r=y(()=>{const[b,g]=H(1,t(l).angle);return{x:b,y:g}});var c=le();S(()=>{p(c,"x1",t(Y)),p(c,"y1",t(J)),p(c,"x2",t(r).x),p(c,"y2",t(r).y)}),x(d,c)});var W=o(ht),Q=o(W);{var wt=d=>{var l=Nt(),r=U(l);V(r,17,()=>gt,rt,(c,b)=>{const g=y(()=>{const[I,dt]=H(t(N)[t(b).key]*t($),t(b).angle);return{px:I,py:dt}});var j=de();S(()=>{p(j,"cx",t(g).px),p(j,"cy",t(g).py),p(j,"r",m()==="lg"?3:2.25)}),x(c,j)}),x(d,l)};R(Q,d=>{m()!=="sm"&&d(wt)})}var lt=o(Q);{var tt=d=>{var l=Nt(),r=U(l);V(r,17,()=>gt,rt,(c,b)=>{const g=y(()=>_t(t(b).angle));var j=ce(),I=U(j),dt=i(I);n(I);var L=o(I),ct=i(L,!0);n(L),S(At=>{p(I,"x",t(g).x),p(I,"y",t(g).y),p(I,"text-anchor",t(g).anchor),p(I,"font-size",m()==="lg"?12:10),_(dt,`${At??""}%`),p(L,"x",t(g).x),p(L,"y",t(g).y+(m()==="lg"?14:11)),p(L,"text-anchor",t(g).anchor),p(L,"font-size",m()==="lg"?10:8.5),_(ct,St[t(b).key])},[()=>(t(N)[t(b).key]*100).toFixed(0)]),x(c,j)}),x(d,l)};R(lt,d=>{t(T)&&d(tt)})}n(P),S((d,l,r,c)=>{p(P,"width",t(v)),p(P,"height",t(v)),p(P,"viewBox",`0 0 ${t(v)??""} ${t(v)??""}`),p(P,"aria-label",`Importance radar: novelty ${d??""}%, arousal ${l??""}%, reward ${r??""}%, attention ${c??""}%`),p(W,"d",t(ot)),p(W,"stroke-width",m()==="sm"?1:1.5)},[()=>(t(N).novelty*100).toFixed(0),()=>(t(N).arousal*100).toFixed(0),()=>(t(N).reward*100).toFixed(0),()=>(t(N).attention*100).toFixed(0)]),x(a,P),Tt()}var pe=h(' '),xe=h('Driven by ',1),me=h('
✓ Save

'),ue=h('Weakest channel: ',1),fe=h('
⨯ Skip

'),ge=h('
Composite
%
',1),ye=h(`

Type some content above to score its importance.

Composite = 0.25·novelty + 0.30·arousal + 0.25·reward + 0.20·attention. Threshold for save: 60%.

`),_e=h('
'),he=h('
'),we=h('

No memories yet.

'),be=h('· ',1),ke=h(' '),Me=h('
'),Se=h(``),Ae=h('
'),Fe=h(`

Importance Radar

4-channel importance model: Novelty · Arousal · Reward · Attention

Test Importance

Paste any content below. Vestige scores it across 4 channels and decides whether it is worth saving.

⌘/Ctrl + Enter

Top Important Memories This Week

Ranked by retention × reviews ÷ age. Click any card to open it.

`);function He(a,F){Rt(F,!0);let m=q(""),v=q(null),T=q(!1),w=q(null),Y=q(0);async function J(){const e=t(m).trim();if(!(!e||t(T))){C(T,!0),C(w,null);try{C(v,await Ft.importance(e),!0),Xt(Y)}catch(s){C(w,s instanceof Error?s.message:String(s),!0),C(v,null)}finally{C(T,!1)}}}function St(e){(e.metaKey||e.ctrlKey)&&e.key==="Enter"&&(e.preventDefault(),J())}const N={novelty:.25,arousal:.3,reward:.25,attention:.2},H={novelty:{high:"new information not already in your graph",low:"overlaps heavily with what you already know"},arousal:{high:"emotionally salient — decisions, bugs, or discoveries stick",low:"neutral tone, no strong affect signal"},reward:{high:"high reward value — preferences, wins, or solutions you will revisit",low:"low reward value — transient or incidental detail"},attention:{high:"strong attentional markers (imperatives, questions, urgency)",low:"passive phrasing, no clear attentional hook"}};let st=y(()=>t(v)?Object.keys(N).map(s=>({key:s,contribution:t(v).channels[s]*N[s]})).sort((s,u)=>u.contribution-s.contribution)[0]:null),nt=y(()=>t(v)?Object.keys(N).slice().sort((e,s)=>t(v).channels[e]-t(v).channels[s])[0]:null),$=q(Ct([])),ot=q(!0),_t=Ct({});function P(e){const s=Math.max(1,(Date.now()-new Date(e.createdAt).getTime())/864e5),u=e.reviewCount??0,f=1/Math.pow(s,.5);return e.retentionStrength*Math.log1p(u+1)*f}async function it(){C(ot,!0);try{const s=(await Ft.memories.list({limit:"20"})).memories.slice().sort((u,f)=>P(f)-P(u)).slice(0,20);C($,s,!0),t($).forEach(async u=>{try{const f=await Ft.importance(u.content);_t[u.id]=f.channels}catch{}})}catch{C($,[],!0)}finally{C(ot,!1)}}Pt(it);function ht(e){Qt(`${te}/memories`)}var W=Fe(),Q=o(i(W),2),wt=o(i(Q),2),lt=i(wt),tt=i(lt);Zt(tt);var d=o(tt,2),l=i(d),r=i(l,!0);n(l);var c=o(l,4);{var b=e=>{var s=pe(),u=i(s,!0);n(s),S(()=>_(u,t(w))),x(e,s)};R(c,e=>{t(w)&&e(b)})}n(d),n(lt);var g=o(lt,2),j=i(g);{var I=e=>{var s=ge(),u=U(s),f=o(i(u),2),z=i(f,!0);Gt(),n(f),n(u);var X=o(u,2);se(X,()=>t(Y),A=>{Et(A,{get novelty(){return t(v).channels.novelty},get arousal(){return t(v).channels.arousal},get reward(){return t(v).channels.reward},get attention(){return t(v).channels.attention},size:"lg"})});var vt=o(X,2);{var pt=A=>{var B=me(),D=o(i(B),2),Z=i(D),xt=o(Z);{var mt=k=>{var G=xe(),O=o(U(G)),ut=i(O,!0);n(O);var et=o(O);S(()=>{_(ut,t(st).key),_(et,` — ${H[t(st).key].high??""}.`)}),x(k,G)};R(xt,k=>{t(st)&&k(mt)})}n(D),n(B),S(k=>_(Z,`Composite ${k??""}% > 60% threshold. `),[()=>(t(v).composite*100).toFixed(0)]),x(A,B)},bt=A=>{var B=fe(),D=o(i(B),2),Z=i(D),xt=o(Z);{var mt=k=>{var G=ue(),O=o(U(G)),ut=i(O,!0);n(O);var et=o(O);S(()=>{_(ut,t(nt)),_(et,` — ${H[t(nt)].low??""}.`)}),x(k,G)};R(xt,k=>{t(nt)&&k(mt)})}n(D),n(B),S(k=>_(Z,`Composite ${k??""}% < 60% threshold. `),[()=>(t(v).composite*100).toFixed(0)]),x(A,B)};R(vt,A=>{t(v).composite>.6?A(pt):A(bt,!1)})}S(A=>_(z,A),[()=>(t(v).composite*100).toFixed(0)]),x(e,s)},dt=e=>{var s=ye();x(e,s)};R(j,e=>{t(v)?e(I):e(dt,!1)})}n(g),n(wt),n(Q);var L=o(Q,2),ct=i(L),At=o(i(ct),2);n(ct);var jt=o(ct,2);{var Lt=e=>{var s=he();V(s,20,()=>Array(6),rt,(u,f)=>{var z=_e();x(u,z)}),n(s),x(e,s)},Bt=e=>{var s=we();x(e,s)},Dt=e=>{var s=Ae();V(s,21,()=>t($),u=>u.id,(u,f)=>{const z=y(()=>_t[t(f).id]);var X=Se(),vt=i(X),pt=i(vt),bt=i(pt),A=o(bt,2),B=i(A,!0);n(A);var D=o(A,4),Z=i(D);n(D);var xt=o(D,2);{var mt=E=>{var K=be(),at=o(U(K),2),ft=i(at);n(at),S(()=>_(ft,`${t(f).reviewCount??""} reviews`)),x(E,K)};R(xt,E=>{t(f).reviewCount&&E(mt)})}n(pt);var k=o(pt,2),G=i(k,!0);n(k);var O=o(k,2);{var ut=E=>{var K=Me();V(K,21,()=>t(f).tags.slice(0,4),rt,(at,ft)=>{var M=ke(),zt=i(M,!0);n(M),S(()=>_(zt,t(ft))),x(at,M)}),n(K),x(E,K)};R(O,E=>{t(f).tags.length>0&&E(ut)})}n(vt);var et=o(vt,2),Ot=i(et);{let E=y(()=>{var M;return((M=t(z))==null?void 0:M.novelty)??0}),K=y(()=>{var M;return((M=t(z))==null?void 0:M.arousal)??0}),at=y(()=>{var M;return((M=t(z))==null?void 0:M.reward)??0}),ft=y(()=>{var M;return((M=t(z))==null?void 0:M.attention)??0});Et(Ot,{get novelty(){return t(E)},get arousal(){return t(K)},get reward(){return t(at)},get attention(){return t(ft)},size:"sm"})}n(et),n(X),S(E=>{Yt(bt,`background: ${(ee[t(f).nodeType]||"#8B95A5")??""}`),_(B,t(f).nodeType),_(Z,`${E??""}% retention`),_(G,t(f).content)},[()=>(t(f).retentionStrength*100).toFixed(0)]),kt("click",X,()=>ht(t(f).id)),x(u,X)}),n(s),x(e,s)};R(jt,e=>{t(ot)?e(Lt):t($).length===0?e(Bt,1):e(Dt,!1)})}n(L),n(W),S(e=>{l.disabled=e,_(r,t(T)?"Scoring…":"Score Importance")},[()=>t(T)||!t(m).trim()]),kt("keydown",tt,St),Jt(tt,()=>t(m),e=>C(m,e)),kt("click",l,J),kt("click",At,it),x(a,W),Tt()}Ut(["keydown","click"]);export{He as component};