Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@openparachute/notes

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openparachute/notes - npm Package Compare versions

Comparing version
0.3.12
to
0.3.14
+1
dist/assets/Activity-0qLhISZY.js
import{u as h,a as g,r as l,j as e,N as f,L as m,b,V as y}from"./index-_ZR9kbJt.js";const p=1440*60*1e3,j=5e3;function N(n,r=30,s=new Date){const d=s.getTime()-r*p,a=[];for(const t of n){const c=t.path??t.id,o=Date.parse(t.createdAt);if(Number.isFinite(o)&&o>=d&&a.push({id:`${t.id}:created`,noteId:t.id,noteName:c,kind:"created",at:t.createdAt,preview:t.preview,tags:t.tags}),t.updatedAt){const i=Date.parse(t.updatedAt);Number.isFinite(i)&&i>=d&&Number.isFinite(o)&&i-o>j&&a.push({id:`${t.id}:updated`,noteId:t.id,noteName:c,kind:"updated",at:t.updatedAt,preview:t.preview,tags:t.tags})}}return a.sort((t,c)=>Date.parse(c.at)-Date.parse(t.at)),a}const v=["today","yesterday","thisWeek","older"],k={today:"Today",yesterday:"Yesterday",thisWeek:"This week",older:"Older"};function w(n,r=new Date){const s=Date.parse(n);if(!Number.isFinite(s))return null;const d=u(r),a=u(new Date(s)),t=Math.round((d.getTime()-a.getTime())/p);return t<0||t===0?"today":t===1?"yesterday":t<7?"thisWeek":"older"}function u(n){return new Date(n.getFullYear(),n.getMonth(),n.getDate())}function D(n,r=new Date){const s={today:[],yesterday:[],thisWeek:[],older:[]};for(const d of n){const a=w(d.at,r);a&&s[a].push(d)}return s}const x=50;function F(){const n=h(i=>i.getActiveVault()),r=g(),[s,d]=l.useState(x),a=l.useMemo(()=>r.data?N(r.data):[],[r.data]),t=l.useMemo(()=>a.slice(0,s),[a,s]),c=l.useMemo(()=>D(t),[t]),o=a.length-t.length;return n?e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-5 md:mb-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Activity"}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Recent changes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Last 30 days, newest first. Deletions aren't tracked yet."})]}),r.isPending?e.jsx(T,{}):r.isError?e.jsx(B,{error:r.error}):a.length===0?e.jsx(S,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-8",children:v.map(i=>c[i].length>0?e.jsx(E,{title:k[i],events:c[i]},i):null)}),o>0?e.jsx("div",{className:"mt-8 flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>d(i=>i+x),className:"rounded-md border border-border bg-card px-4 py-2 text-sm text-fg-muted hover:text-accent",children:["Load more (",o," remaining)"]})}):null]})]}):e.jsx(f,{to:"/",replace:!0})}function E({title:n,events:r}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[n," (",r.length,")"]}),e.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card",children:r.map(s=>e.jsx("li",{children:e.jsxs(m,{to:`/n/${encodeURIComponent(s.noteId)}`,className:"block px-4 py-3 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(A,{kind:s.kind}),e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:s.noteName})]}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:b(s.at)})]}),s.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:s.preview}):null,s.tags&&s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.tags.map(d=>e.jsxs("span",{className:"rounded-md bg-border/40 px-1.5 py-0.5 text-xs text-fg-dim",children:["#",d]},d))}):null]})},s.id))})]})}function A({kind:n}){return n==="created"?e.jsx("span",{className:"shrink-0 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs text-accent",children:"Created"}):e.jsx("span",{className:"shrink-0 rounded-md bg-border/40 px-1.5 py-0.5 text-xs text-fg-muted",children:"Edited"})}function S(){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-4 text-fg-muted",children:"No activity in the last 30 days."}),e.jsx(m,{to:"/capture",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Open capture"})]})}function T(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3,4].map(n=>e.jsx("div",{className:"h-16 animate-pulse rounded-md bg-border/30"},n))})}function B({error:n}){const r=n instanceof y;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:r?"Session expired":"Could not load activity"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:n.message}),r?e.jsx(m,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{F as Activity};
import{c as g,r as t,d as p,j as e,n as v,e as j}from"./index-_ZR9kbJt.js";function w(){const[f]=g(),u=f.get("url")??"",[r,c]=t.useState(u),[i,n]=t.useState(null),[o,d]=t.useState(!1),m=t.useRef(null),h=t.useRef(u.length>0),a=p();t.useEffect(()=>{var s;(s=m.current)==null||s.focus()},[]),t.useEffect(()=>{h.current||a.status==="found"&&a.origin&&r===""&&(c(a.origin),h.current=!0)},[a.status,a.origin,r]);async function b(s){s.preventDefault(),n(null);let x;try{x=v(r)}catch(l){n(l.message);return}d(!0);try{const{authorizeUrl:l}=await j(x);window.location.assign(l)}catch(l){n(l.message),d(!1)}}return e.jsxs("div",{className:"mx-auto max-w-xl px-6 py-16",children:[e.jsx("h1",{className:"mb-2 font-serif text-4xl tracking-tight",children:"Connect a vault"}),e.jsx("p",{className:"mb-8 text-fg-muted",children:"Paste your Parachute hub URL. You'll be taken to its consent page to authorize Parachute Notes."}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"vault-url",className:"mb-1.5 block text-sm font-medium text-fg",children:"Hub URL"}),e.jsx("input",{id:"vault-url",ref:m,type:"url",required:!0,placeholder:"http://localhost:1939",value:r,onChange:s=>c(s.target.value),disabled:o,className:"w-full rounded-md border border-border bg-card px-3 py-2 font-mono text-sm text-fg focus:border-accent focus:outline-none"}),e.jsxs("p",{className:"mt-1.5 text-xs text-fg-dim",children:["For a local install the hub lives at ",e.jsx("code",{children:"http://localhost:1939"}),". A standalone vault URL (e.g. ",e.jsx("code",{children:"https://host/vault/default"}),") also works — Notes will OAuth against whichever issuer answers."]})]}),i?e.jsx("div",{className:"rounded-md border border-red-400/30 bg-red-400/5 px-3 py-2 text-sm text-red-400",children:i}):null,e.jsx("button",{type:"submit",disabled:o||!r,className:"w-full rounded-md bg-accent px-4 py-2.5 text-sm font-medium text-white hover:bg-accent-hover disabled:cursor-not-allowed disabled:opacity-60",children:o?"Starting OAuth…":"Continue"})]})]})}export{w as AddVault};
import{u as k,c as E,a as A,r as f,j as e,N as K,L as d,V as S}from"./index-_ZR9kbJt.js";import{p as y,c as j,t as P,m as T,a as V,s as N,b as i,f as C}from"./dates-DfXc2iZW.js";const _=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x=5;function B(){const a=k(t=>t.getActiveVault()),[o]=E(),l=o.get("month"),r=y(l)??y(j()),s=A(),h=P(),v=f.useMemo(()=>T(r.year,r.month),[r.year,r.month]),$=f.useMemo(()=>{const t=new Map;if(!s.data)return t;for(const n of s.data){const c=V(n.createdAt);c&&t.set(c,(t.get(c)??0)+1)}return t},[s.data]);if(!a)return e.jsx(K,{to:"/",replace:!0});const u=N(r.year,r.month,-1),p=N(r.year,r.month,1),b=`${u.year}-${i(u.month)}`,g=`${p.year}-${i(p.month)}`,M=j(),w=`${r.year}-${i(r.month)}`===M;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Calendar"}),e.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:C(r.year,r.month)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(d,{to:`/calendar?month=${b}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous month",children:["← ",b]}),w?null:e.jsx(d,{to:"/calendar",className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"This month"}),e.jsxs(d,{to:`/calendar?month=${g}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next month",children:[g," →"]}),e.jsx(d,{to:`/today?date=${h}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"})]})]}),s.isError?e.jsx(L,{error:s.error}):e.jsxs("div",{className:"rounded-md border border-border bg-card","aria-busy":s.isPending,children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-border text-xs uppercase tracking-wider text-fg-dim",children:_.map(t=>e.jsx("div",{className:"px-2 py-2 text-center",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7",children:v.map(t=>{const n=`${t.getFullYear()}-${i(t.getMonth()+1)}-${i(t.getDate())}`,c=t.getMonth()+1===r.month,m=$.get(n)??0,D=n===h;return e.jsxs(d,{to:`/today?date=${n}`,className:`flex min-h-20 flex-col border-b border-r border-border p-1.5 text-xs hover:bg-bg/60 focus:bg-bg/60 focus:outline-none ${c?"":"opacity-40"}`,"aria-label":`${n} — ${m} notes`,children:[e.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full ${D?"bg-accent text-white":"text-fg"}`,children:t.getDate()}),m>0?e.jsx(F,{count:m}):e.jsx("span",{className:"sr-only",children:"no notes"})]},n)})})]}),e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:"Each dot is a note created on that day. Click any day to open /today."})]})}function F({count:a}){const o=Math.min(a,x),l=a>x?a-x:0;return e.jsxs("span",{className:"flex flex-wrap items-center gap-0.5",children:[Array.from({length:o}).map((r,s)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-hidden":"true"},s)),l>0?e.jsxs("span",{className:"ml-0.5 text-[10px] text-fg-dim",children:["+",l]}):null]})}function L({error:a}){const o=a instanceof S;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:o?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),o?e.jsx(d,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{B as Calendar};
import{u as Y,f as Z,g as G,h as J,r as u,i as F,k as Q,l as E,m as X,j as i,N as ee,T as te,o as H}from"./index-_ZR9kbJt.js";const re=["audio/webm;codecs=opus","audio/mp4","audio/ogg;codecs=opus"];function ne(e=re){if(typeof MediaRecorder>"u")return null;for(const r of e)if(MediaRecorder.isTypeSupported(r))return r;return null}function ae(e){return e.startsWith("audio/webm")?"webm":e.startsWith("audio/mp4")?"m4a":e.startsWith("audio/ogg")?"ogg":e.startsWith("audio/wav")?"wav":"bin"}function se(e){const r=e.now??(()=>Date.now()),s=e.MediaRecorderCtor??MediaRecorder,a=new s(e.stream,{mimeType:e.mimeType}),d=[];let n="idle",l=0,w=0;a.ondataavailable=m=>{m.data&&m.data.size>0&&d.push(m.data)};const h=()=>{for(const m of e.stream.getTracks())m.stop()};return{get state(){return n},get mimeType(){return e.mimeType},start(){if(n!=="idle")throw new Error(`Cannot start from ${n}`);a.start(),l=r(),n="recording"},pause(){n==="recording"&&(a.pause(),w+=r()-l,n="paused")},resume(){n==="paused"&&(a.resume(),l=r(),n="recording")},async stop(){if(n==="idle"||n==="stopped")throw new Error(`Cannot stop from ${n}`);n==="recording"&&(w+=r()-l);const m=new Promise(N=>{a.onstop=async()=>{const R=await ie(d);N({data:R,mimeType:e.mimeType,durationMs:w})}});return a.stop(),n="stopped",h(),m},cancel(){if(n==="recording"||n==="paused")try{a.stop()}catch{}n="stopped",d.length=0,h()}}}async function oe(e){const r=e;return typeof r.arrayBuffer=="function"?r.arrayBuffer():new Promise((s,a)=>{const d=new FileReader;d.onload=()=>s(d.result),d.onerror=()=>a(d.error??new Error("FileReader error")),d.readAsArrayBuffer(e)})}async function ie(e){if(e.length===0)return new ArrayBuffer(0);const r=await Promise.all(e.map(n=>oe(n))),s=r.reduce((n,l)=>n+l.byteLength,0),a=new Uint8Array(s);let d=0;for(const n of r)a.set(new Uint8Array(n),d),d+=n.byteLength;return a.buffer}async function ce(){var e;if(typeof navigator>"u"||!((e=navigator.mediaDevices)!=null&&e.getUserMedia)){const r=new Error("Microphone is not available in this browser.");throw r.kind="unavailable",r}try{return await navigator.mediaDevices.getUserMedia({audio:!0})}catch(r){const s=new Error(r instanceof Error?r.message:"Microphone permission denied."),a=r instanceof DOMException?r.name:"";throw s.kind=a==="NotFoundError"||a==="OverconstrainedError"?"no-device":"permission-denied",s}}function de(e,r=new Date){return`memo-${r.toISOString().replace(/[:.]/g,"-").replace(/Z$/,"")}.${ae(e)}`}function ue(e=new Date){const r=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0"),d=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`Memos/${r}/${s}-${a}/${d}-${n}-${l}`}const le=/(?:^|\s)#([a-zA-Z][\w-]*)/g;function _(e){const r=new Set;for(const s of e.matchAll(le)){const a=H(s[1]??"");a&&r.add(a)}return[...r]}function q(e){const r=Math.floor(e/1e3),s=Math.floor(r/60),a=r%60;return`${String(s).padStart(2,"0")}:${String(a).padStart(2,"0")}`}function fe(){const e=Y(t=>t.getActiveVault()),r=Z(t=>t.push),{db:s,blobStore:a,engine:d}=G(),{roles:n}=J((e==null?void 0:e.id)??null),[l,w]=u.useState(""),[h,m]=u.useState([]),[N,R]=u.useState(""),[c,g]=u.useState({kind:"idle"}),[z,C]=u.useState(0),I=u.useRef(null),x=u.useRef(null),$=u.useRef(null),A=u.useRef(!1);u.useEffect(()=>{if(c.kind!=="recording")return;const t=setInterval(()=>C(Date.now()-c.startedAt),250);return()=>clearInterval(t)},[c]),u.useEffect(()=>()=>{x.current&&URL.revokeObjectURL(x.current)},[]),u.useEffect(()=>{var t;(t=$.current)==null||t.focus()},[]);const K=u.useCallback(async()=>{if(!(c.kind==="recording"||c.kind==="requesting")){g({kind:"requesting"});try{const t=ne();if(!t){g({kind:"denied",message:"This browser can't record audio in a format we can save."});return}const o=await ce(),p=se({stream:o,mimeType:t});I.current=p,p.start(),C(0),g({kind:"recording",startedAt:Date.now()})}catch(t){const o=t,p=o.kind==="permission-denied"?"Microphone access was denied. Update your browser's site settings to record.":o.kind==="no-device"?"No microphone was found on this device.":o instanceof Error?o.message:"Microphone is not available in this browser.";g({kind:"denied",message:p})}}},[c]),B=u.useCallback(async()=>{const t=I.current;if(!(!t||c.kind!=="recording"))try{const o=await t.stop();I.current=null;const p=new Blob([o.data],{type:o.mimeType}),b=URL.createObjectURL(p);x.current&&URL.revokeObjectURL(x.current),x.current=b,g({kind:"have-audio",data:o.data,mimeType:o.mimeType,url:b,durationMs:o.durationMs})}catch(o){r(o instanceof Error?`Recording failed: ${o.message}`:"Recording failed.","error"),g({kind:"idle"})}},[c,r]);u.useEffect(()=>{if(c.kind!=="recording")return;const t=()=>{B()};return window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[c,B]);const D=u.useCallback(()=>{x.current&&(URL.revokeObjectURL(x.current),x.current=null),g({kind:"idle"}),C(0)},[]),P=u.useCallback(()=>{var t;w(""),m([]),R(""),D(),(t=$.current)==null||t.focus()},[D]),T=c.kind==="have-audio",y=l.trim().length>0,L=(y||T)&&c.kind!=="saving",U=u.useCallback(async()=>{if(!L||!s||!e)return;if(T&&!a){r("Sync queue not ready — try again in a moment.","error");return}const t=c.kind==="have-audio"?c:null;A.current=!0,g({kind:"saving"});const o=h.filter(f=>f.length>0),p=_(l),b=[];y&&b.push(n.captureText),t&&b.push(n.captureVoice);const v=Array.from(new Set([...b,...o,...p].filter(f=>f.length>0))),M=F();try{if(t){const f=new Date,S=de(t.mimeType,f),k=Q(),j=y?`${l.trim()}
_Transcript pending._
![[${S}]]
`:`_Transcript pending._
![[${S}]]
`,W=y?void 0:ue(f);if(!a)throw new Error("blob store missing");await a.put(k,t.data,t.mimeType,e.id),await E(s,{kind:"create-note",localId:M,payload:{content:j,...W?{path:W}:{},...v.length?{tags:v}:{}}},{vaultId:e.id}),await E(s,{kind:"upload-attachment",blobId:k,filename:S,mimeType:t.mimeType},{vaultId:e.id}),await E(s,{kind:"link-attachment",noteId:M,pathRef:X(k),mimeType:t.mimeType,transcribe:!0},{vaultId:e.id})}else await E(s,{kind:"create-note",localId:M,payload:{content:l,...v.length?{tags:v}:{}}},{vaultId:e.id});d==null||d.runOnce(),r(t?"Captured — syncing audio.":"Captured.","success"),P()}catch(f){r(f instanceof Error?`Capture failed: ${f.message}`:"Capture failed.","error"),A.current=!1,g(t?{kind:"have-audio",data:t.data,mimeType:t.mimeType,url:t.url,durationMs:t.durationMs}:{kind:"idle"})}},[L,s,e,a,c,T,y,h,l,n.captureText,n.captureVoice,d,r,P]),V=u.useCallback(t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),U())},[U]),O=u.useRef({db:s,activeVaultId:(e==null?void 0:e.id)??null,content:l,tags:h,roles:n});return O.current={db:s,activeVaultId:(e==null?void 0:e.id)??null,content:l,tags:h,roles:n},u.useEffect(()=>()=>{if(A.current)return;const{db:t,activeVaultId:o,content:p,tags:b,roles:v}=O.current;if(!p.trim()||!t||!o)return;const f=b.filter(j=>j.length>0),S=_(p),k=Array.from(new Set([v.captureText,...f,...S].filter(j=>j.length>0)));E(t,{kind:"create-note",localId:F(),payload:{content:p,...k.length?{tags:k}:{}}},{vaultId:o})},[]),e?i.jsxs("div",{className:"mx-auto max-w-2xl px-4 py-5 md:px-6 md:py-8",children:[i.jsxs("header",{className:"mb-5",children:[i.jsx("h1",{className:"font-serif text-2xl text-fg md:text-3xl",children:"Capture"}),i.jsxs("p",{className:"mt-1 text-xs text-fg-dim",children:["Type a thought, hold the mic to record, or both."," ",i.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"⌘"}),i.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↵"})," to send."]})]}),i.jsxs("section",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-5 md:p-6",children:[i.jsx("textarea",{ref:$,value:l,onChange:t=>w(t.target.value),onKeyDown:V,placeholder:"What are you thinking?","aria-label":"Capture content",rows:8,disabled:c.kind==="saving",className:"min-h-[30vh] w-full resize-y rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg placeholder:text-fg-dim focus:border-accent focus:outline-none disabled:opacity-60"}),c.kind==="have-audio"?i.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-accent/30 bg-accent/5 p-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("span",{className:"text-sm text-fg-muted",children:["🎙 Recorded ",q(c.durationMs)]}),i.jsx("button",{type:"button",onClick:D,className:"text-xs text-fg-dim hover:text-red-400",children:"Discard"})]}),i.jsx("audio",{controls:!0,src:c.url,className:"w-full",children:i.jsx("track",{kind:"captions"})}),i.jsx("p",{className:"text-xs text-fg-dim",children:"Transcript will be appended once your vault processes it."})]}):null,c.kind==="denied"?i.jsx("p",{className:"rounded-md border border-red-500/30 bg-red-500/5 px-3 py-2 text-xs text-red-400",children:c.message}):null,i.jsx(te,{tags:h,input:N,onInputChange:R,onAdd:t=>{const o=H(t);!o||h.includes(o)||(m(p=>[...p,o]),R(""))},onRemove:t=>m(o=>o.filter(p=>p!==t))}),i.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2",children:[i.jsx(pe,{phase:c,elapsedMs:z,onPointerDown:()=>void K()}),i.jsxs("div",{className:"flex flex-col items-end gap-1",children:[i.jsx("button",{type:"button",onClick:()=>void U(),disabled:!L,className:"min-h-11 rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:c.kind==="saving"?"Saving…":"Capture"}),i.jsx("span",{className:"text-[11px] text-fg-dim",children:T&&y?"Will save as a note with audio attached.":T?"Will save as a voice memo.":y?"Will save as a text note.":"Type or record to capture."})]})]})]})]}):i.jsx(ee,{to:"/",replace:!0})}function pe({phase:e,elapsedMs:r,onPointerDown:s}){const a=e.kind==="recording",d=e.kind==="requesting",n=a?`Recording — release to stop (${q(r)})`:d?"Requesting microphone…":"Hold to record";return i.jsxs("button",{type:"button",onPointerDown:l=>{l.preventDefault(),s()},"aria-label":n,"aria-pressed":a,disabled:e.kind==="saving",className:`flex min-h-11 items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition select-none ${a?"border-red-500/40 bg-red-500/10 text-red-400":"border-accent/30 bg-accent/10 text-accent hover:bg-accent/15"} disabled:opacity-40`,children:[i.jsx("span",{"aria-hidden":"true",className:a?"animate-pulse":"",children:"🎙"}),i.jsx("span",{children:a?`Rec ${q(r)}`:d?"Requesting…":"Hold to record"})]})}export{fe as Capture,_ as extractHashtags};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import{r as d,j as e,f as T,p as V,V as C,q as _,s as z,u as O,t as q,N as K,L as R,v as W,w as Y,x as H,b as D,T as Z,o as G}from"./index-_ZR9kbJt.js";import{u as J,A as Q,C as X,a as ee,b as te}from"./useAttachmentUploader-BdHqmISq.js";import{P as se,D as ne}from"./PinArchiveButtons-D-w7K7l4.js";import{b as re,M as ae}from"./MarkdownView-CSykIOWY.js";const oe=250;function de({noteId:t,attachment:n}){const[l,a]=d.useState(!1),o=ce(n);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":`Remove attachment ${o}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),l?e.jsx(ie,{noteId:t,attachment:n,label:o,onClose:()=>a(!1)}):null]})}function ie({noteId:t,attachment:n,label:l,onClose:a}){const o=T(i=>i.push),m=V(),[s,h]=d.useState(!1),[w,p]=d.useState(null),N=d.useRef(null);d.useEffect(()=>{const i=setTimeout(()=>h(!0),oe);return()=>clearTimeout(i)},[]),d.useEffect(()=>{var i;(i=N.current)==null||i.focus()},[]),d.useEffect(()=>{const i=g=>{g.key==="Escape"&&a()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[a]);const b=d.useCallback(()=>{!s||m.isPending||(p(null),m.mutate({noteId:t,attachmentId:n.id},{onSuccess:()=>{o(`Removed ${l}`,"success"),a()},onError:i=>{if(i instanceof C){p("Session expired. Reconnect to remove attachments.");return}if(i instanceof _){o(`Already removed ${l}`,"info"),a();return}p(i instanceof Error?i.message:"Remove failed")}}))},[s,n.id,l,m,t,a,o]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:i=>{i.target===i.currentTarget&&a()},children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[e.jsx("h2",{id:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:l})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),w?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:w}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{ref:N,type:"button",onClick:a,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:b,disabled:!s||m.isPending,className:"min-h-11 rounded-md bg-red-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-600 disabled:opacity-40",children:m.isPending?"Removing…":"Remove"})]})]})})}function ce(t){if(t.filename)return t.filename;if(t.path){const n=t.path.split("/").pop();return n||t.path}return t.id}function we(){const{id:t}=z(),n=t?decodeURIComponent(t):void 0,l=O(o=>o.getActiveVault()),a=q(n);return l?e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-5 md:px-6 md:py-8",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(R,{to:n?`/n/${encodeURIComponent(n)}`:"/",className:"hover:text-accent",children:"← Back to note"})}),a.isPending?e.jsx(xe,{}):a.isError?e.jsx(fe,{error:a.error}):a.data?e.jsx(le,{note:a.data}):e.jsx(he,{id:n??""})]}):e.jsx(K,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function le({note:t}){const n=W(),l=T(r=>r.push),a=d.useMemo(()=>re(t),[t]),[o,m]=d.useState(()=>S(t)),[s,h]=d.useState(()=>S(t)),[w,p]=d.useState(""),[N,b]=d.useState(null),[i,g]=d.useState(null),[y,L]=d.useState("edit"),v=Y(t.id),k=d.useRef(t),E=d.useRef(null),j=J({noteId:t.id,onInsert:r=>{E.current?E.current.insertAtCursor(r):h(c=>({...c,content:`${c.content}${r}`}))},onLinked:()=>{l("Attachment added","success")},onError:r=>l(r,"error")});d.useEffect(()=>{k.current=t},[t]);const u=s.content!==o.content||s.path!==o.path||!pe(s.tags,o.tags),A=d.useCallback(()=>{if(!u||v.isPending)return;const r={};s.content!==o.content&&(r.content=s.content),s.path!==o.path&&(r.path=s.path);const c=be(o.tags,s.tags);(c.add.length||c.remove.length)&&(r.tags=c);const f=k.current.updatedAt??k.current.createdAt;f&&(r.if_updated_at=f),g(null),b(null),v.mutate(r,{onSuccess:x=>{m(S(x)),h(S(x)),k.current=x,x.id!==t.id&&n(`/n/${encodeURIComponent(x.id)}/edit`,{replace:!0})},onError:x=>{x instanceof H?b(x):x instanceof C?g("Session expired. Reconnect to save."):g(x instanceof Error?x.message:"Save failed")}})},[o,s,u,v,n,t.id]),M=d.useCallback(()=>{u&&confirm("Discard all edits and revert to last saved version?")&&(h(o),b(null),g(null))},[o,u]),P=d.useCallback(()=>{u&&!confirm("Discard unsaved changes?")||n(`/n/${encodeURIComponent(t.id)}`)},[u,n,t.id]);d.useEffect(()=>{if(!u)return;const r=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",r),()=>window.removeEventListener("beforeunload",r)},[u]);const $=s.path!==o.path,B=r=>{const c=G(r);c&&(s.tags.includes(c)||(h(f=>({...f,tags:[...f.tags,c]})),p("")))},U=r=>{h(c=>({...c,tags:c.tags.filter(f=>f!==r)}))},F=s.content;return e.jsxs("article",{children:[e.jsxs("header",{className:"mb-4 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Editing"}),u?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",D(t.updatedAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{note:t}),e.jsx(ne,{note:t}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:M,disabled:!u||v.isPending,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:"Revert"}),e.jsx("button",{type:"button",onClick:P,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:A,disabled:!u||v.isPending,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",title:"Save (⌘S)",children:v.isPending?"Saving…":"Save"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx(Z,{tags:s.tags,input:w,onInputChange:p,onAdd:B,onRemove:U}),e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Path"}),e.jsx("input",{type:"text",value:s.path,onChange:r=>h(c=>({...c,path:r.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note path",placeholder:"(no path)"})]}),$?e.jsx("p",{className:"text-xs text-accent",children:"Renaming moves the note — its id may change."}):null]})]}),N?e.jsx(ue,{conflict:N,onReload:()=>{window.location.reload()},onDismiss:()=>b(null)}):null,i?e.jsx("div",{className:"mb-4 rounded-md border border-red-500/30 bg-red-500/5 p-3 text-sm text-red-400",children:i}):null,e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-md border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(r=>e.jsx("button",{type:"button",role:"tab","aria-selected":y===r,onClick:()=>L(r),className:`rounded px-3 py-1.5 capitalize ${y===r?"bg-accent text-white":"text-fg-muted hover:text-accent"}`,children:r},r))}),e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2",children:[e.jsx(Q,{onDropFiles:j.start,className:`min-w-0 rounded-md border border-border bg-card ${y==="edit"?"":"hidden lg:block"}`,hint:I,children:e.jsx(X,{ref:E,value:s.content,onChange:r=>h(c=>({...c,content:r})),onSave:A,onCancel:P,onPasteFile:r=>(j.start(r),!0)})}),e.jsx("div",{className:`min-w-0 overflow-auto rounded-md border border-border bg-card p-4 ${y==="preview"?"":"hidden lg:block"}`,children:e.jsx(ae,{content:F,resolve:a})})]}),e.jsx(me,{noteId:t.id,attachments:t.attachments??[],uploads:j.uploads,onPickFiles:j.start,onCancel:j.cancel,onDismiss:j.dismiss})]})}const I=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"underline",children:"PDF + mp4 coming"})]});function me({noteId:t,attachments:n,uploads:l,onPickFiles:a,onCancel:o,onDismiss:m}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-lg",children:"Attachments"}),e.jsx(ee,{onPickFiles:a})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",I,"."]}),e.jsx(te,{uploads:l,onCancel:o,onDismiss:m}),n.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:n.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:s.path??s.id,children:s.filename??s.path??s.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.mimeType?e.jsx("span",{className:"text-fg-dim",children:s.mimeType}):null,e.jsx(de,{noteId:t,attachment:s})]})]},s.id))}):null]})}function ue({conflict:t,onReload:n,onDismiss:l}){return e.jsxs("div",{className:"mb-4 rounded-md border border-amber-500/40 bg-amber-500/10 p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-amber-500",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${D(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:l,className:"rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Keep editing"})]})]})}function xe(){return e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"animate-pulse rounded-md border border-border bg-card"}),e.jsx("div",{className:"animate-pulse rounded-md border border-border bg-card"})]})}function he({id:t}){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-2 font-serif text-xl",children:"Note not found"}),e.jsxs("p",{className:"mb-4 text-sm text-fg-muted",children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),e.jsx(R,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to all notes"})]})}function fe({error:t}){const n=t instanceof C;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:n?"Session expired":"Could not load note"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:t.message}),n?e.jsx(R,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function pe(t,n){if(t.length!==n.length)return!1;const l=new Set(t);for(const a of n)if(!l.has(a))return!1;return!0}function be(t,n){const l=new Set(t),a=new Set(n),o=n.filter(s=>!l.has(s)),m=t.filter(s=>!a.has(s));return{add:o,remove:m}}export{we as NoteEditor};
import{u as P,v as T,f as I,y as R,z as V,r as n,j as e,N as L,V as M,L as $,T as F,o as _}from"./index-_ZR9kbJt.js";import{u as U,A as z,C as B,a as O,b as W}from"./useAttachmentUploader-BdHqmISq.js";import{b as Y,M as Z}from"./MarkdownView-CSykIOWY.js";const q={content:"",path:"",tags:[],summary:""};function K(){const w=P(t=>t.getActiveVault()),l=T(),d=I(t=>t.push),c=R(),f=V(),[a,o]=n.useState(q),[C,b]=n.useState(""),[v,x]=n.useState(null),[m,k]=n.useState([]),p=n.useRef(null),i=U({noteId:null,onInsert:t=>{p.current?p.current.insertAtCursor(t):o(s=>({...s,content:`${s.content}${t}`}))},onStaged:t=>k(s=>[...s,t]),onError:t=>d(t,"error")});if(!w)return e.jsx(L,{to:"/",replace:!0});const u=a.content.length>0||a.path.length>0||a.tags.length>0||a.summary.length>0,h=a.content.trim().length>0&&a.path.trim().length>0,j=n.useCallback(()=>{if(!h||c.isPending)return;const t={content:a.content,path:a.path.trim()};a.tags.length&&(t.tags=a.tags);const s=a.summary.trim();s&&(t.metadata={summary:s}),x(null),c.mutate(t,{onSuccess:async r=>{for(const g of m)try{await f.mutateAsync({noteId:r.id,path:g.path,mimeType:g.mimeType})}catch(y){const D=y instanceof Error?y.message:"Link failed";d(`Failed to attach ${g.filename}: ${D}`,"error")}d(`Created ${r.path??r.id}`,"success"),l(`/n/${encodeURIComponent(r.id)}`)},onError:r=>{r instanceof M?x("Session expired. Reconnect to save."):x(r instanceof Error?`${r.message} — if the path is taken, try a different one.`:"Create failed")}})},[a,h,f,c,l,d,m]),N=n.useCallback(()=>{u&&!confirm("Discard this draft?")||l("/")},[u,l]);n.useEffect(()=>{if(!u)return;const t=s=>{s.preventDefault(),s.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[u]);const A=t=>{const s=_(t);!s||a.tags.includes(s)||(o(r=>({...r,tags:[...r.tags,s]})),b(""))},E=t=>{o(s=>({...s,tags:s.tags.filter(r=>r!==t)}))},S=Y({id:"__new__",createdAt:new Date().toISOString()});return e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-5 md:px-6 md:py-8",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx($,{to:"/",className:"hover:text-accent",children:"← All notes"})}),e.jsxs("article",{children:[e.jsxs("header",{className:"mb-4 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm",children:e.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"New note"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:N,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:j,disabled:!h||c.isPending,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",title:"Create (⌘S)",children:c.isPending?"Creating…":"Create"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Path"}),e.jsx("input",{type:"text",value:a.path,onChange:t=>o(s=>({...s,path:t.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note path",placeholder:"e.g. Projects/README"})]}),e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Summary"}),e.jsx("input",{type:"text",value:a.summary,onChange:t=>o(s=>({...s,summary:t.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note summary",placeholder:"(optional one-line description)"})]}),e.jsx(F,{tags:a.tags,input:C,onInputChange:b,onAdd:A,onRemove:E})]})]}),v?e.jsx("div",{role:"alert",className:"mb-4 rounded-md border border-red-500/30 bg-red-500/5 p-3 text-sm text-red-400",children:v}):null,e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2",children:[e.jsx(z,{onDropFiles:i.start,className:"min-w-0 rounded-md border border-border bg-card",hint:"Images, audio, webm video",children:e.jsx(B,{ref:p,value:a.content,onChange:t=>o(s=>({...s,content:t})),onSave:j,onCancel:N,onPasteFile:t=>(i.start(t),!0)})}),e.jsx("div",{className:"min-w-0 overflow-auto rounded-md border border-border bg-card p-4",children:a.content.trim()?e.jsx(Z,{content:a.content,resolve:S}):e.jsx("p",{className:"text-sm text-fg-dim",children:"Preview appears here as you type."})})]}),e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-lg",children:"Attachments"}),e.jsx(O,{onPickFiles:i.start})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Attachments link to the note when you save. Max 100 MB each. Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"underline",children:"PDF + mp4 coming"}),"."]}),e.jsx(W,{uploads:i.uploads,onCancel:i.cancel,onDismiss:i.dismiss}),m.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:m.map(t=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded border border-border bg-card/50 px-3 py-1.5 font-mono text-xs text-fg-muted",children:[e.jsx("span",{className:"truncate",children:t.filename}),e.jsx("span",{className:"shrink-0 text-fg-dim",children:"staged"})]},t.path))}):null]})]})]})}export{K as NoteNew};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-jqFHZKU6.js","assets/index-_ZR9kbJt.js","assets/index-CSwzwMDF.css"])))=>i.map(i=>d[i]);
import{r as c,C as v,j as t,v as k,_ as y,s as I,u as A,t as R,D as C,N as E,L as p,V as L,b as j}from"./index-_ZR9kbJt.js";import{P as D,D as M}from"./PinArchiveButtons-D-w7K7l4.js";import{b as _,M as T}from"./MarkdownView-CSykIOWY.js";const S=1,U=3,$=1;function B(e,s){const a=new Map,n=new Map;for(const d of s.values())for(const r of d.links??[]){if(r.sourceId===r.targetId||!s.has(r.sourceId)||!s.has(r.targetId))continue;const o=`${r.sourceId}|${r.targetId}|${r.relationship}`;a.has(o)||(a.set(o,{source:r.sourceId,target:r.targetId,relationship:r.relationship}),n.set(r.sourceId,(n.get(r.sourceId)??0)+1),n.set(r.targetId,(n.get(r.targetId)??0)+1))}return{nodes:[...s.values()].map(d=>{var r;return{id:d.id,path:d.path,tags:d.tags,summary:typeof((r=d.metadata)==null?void 0:r.summary)=="string"?d.metadata.summary:void 0,isAnchor:d.id===e,linkCount:n.get(d.id)??0}}),edges:[...a.values()]}}async function P(e,s,a,n){const i=new Map;i.set(e.id,e);let d=[e];for(let r=1;r<=s;r++){const o=new Set;for(const u of d)for(const x of u.links??[]){const h=x.sourceId===u.id?x.targetId:x.sourceId;h!==u.id&&(i.has(h)||o.add(h))}if(o.size===0)break;const l=await Promise.all([...o].map(u=>a(u).catch(()=>null)));if(n!=null&&n.cancelled)return i;const m=[];for(const u of l)u&&!i.has(u.id)&&(i.set(u.id,u),m.push(u));d=m}return i}function V(e,s,a){const[n,i]=c.useState(null),[d,r]=c.useState(!1);return c.useEffect(()=>{if(!e||!s){i(null),r(!1);return}const o={cancelled:!1};return r(!0),P(s,a,l=>e.getNote(l,{includeLinks:!0}),o).then(l=>{o.cancelled||(i(B(s.id,l)),r(!1))}).catch(()=>{o.cancelled||r(!1)}),()=>{o.cancelled=!0}},[e,s,a]),{data:n,isLoading:d}}const F=c.lazy(()=>y(()=>import("./react-force-graph-2d-jqFHZKU6.js"),__vite__mapDeps([0,1,2])));function z({anchor:e}){const[s,a]=c.useState(!0),[n,i]=c.useState($),d=v(),{data:r,isLoading:o}=V(d,s?e:void 0,n);return t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>a(l=>!l),"aria-expanded":s,className:"font-serif text-xl text-fg hover:text-accent",children:[s?"▾":"▸"," Neighborhood"]}),s&&r?t.jsxs("span",{className:"text-xs text-fg-dim",children:[r.nodes.length," ",r.nodes.length===1?"note":"notes"]}):null]}),s?t.jsx(G,{depth:n,onChange:i}):null]}),s?t.jsx(O,{data:r,isLoading:o}):null]})}function G({depth:e,onChange:s}){const a=[];for(let n=S;n<=U;n++)a.push(n);return t.jsxs("fieldset",{className:"flex items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Hops"}),a.map(n=>t.jsx("button",{type:"button","aria-pressed":n===e,onClick:()=>s(n),className:n===e?"rounded border border-accent bg-accent/10 px-2 py-0.5 text-accent":"rounded border border-border bg-card px-2 py-0.5 hover:text-accent",children:n},n))]})}function O({data:e,isLoading:s}){return!e&&s?t.jsx(w,{}):e?e.nodes.length<=1?t.jsx("div",{className:"rounded-md border border-border bg-card p-6 text-center text-sm text-fg-dim",children:"This note has no neighbors yet."}):t.jsx(H,{data:e}):null}function w(){return t.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function H({data:e}){const s=k(),a=c.useRef(null),[n,i]=c.useState({w:600,h:384});c.useEffect(()=>{const r=a.current;if(!r)return;const o=()=>{const m=r.getBoundingClientRect();i({w:Math.max(320,Math.floor(m.width)),h:384})};o();const l=new ResizeObserver(o);return l.observe(r),()=>l.disconnect()},[]);const d=c.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]);return t.jsx("div",{ref:a,"data-testid":"neighborhood-graph-canvas",className:"overflow-hidden rounded-md border border-border bg-card",children:t.jsx(c.Suspense,{fallback:t.jsx(w,{}),children:t.jsx(F,{graphData:d,width:n.w,height:n.h,nodeLabel:r=>K(r),nodeVal:r=>{const o=r;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:r=>r.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:r=>{s(`/n/${encodeURIComponent(r.id)}`)}})})})}function K(e){const s=[e.path??e.id];return e.tags&&e.tags.length>0&&s.push(`tags: ${e.tags.join(", ")}`),e.summary&&s.push(e.summary),s.join(`
`)}const W="_Transcript pending._",X="_Transcription unavailable._";function q({content:e}){const s=e.includes(W),a=!s&&e.includes(X);return s?t.jsxs("output",{"aria-live":"polite",className:"mb-4 inline-flex items-center gap-2 rounded-md border border-sky-500/30 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-300",children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 animate-pulse rounded-full bg-sky-400"}),"Transcribing…"]}):a?t.jsx("output",{className:"mb-4 inline-flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-1.5 text-xs text-amber-200",children:"Transcription unavailable — open the audio below and add a note by hand."}):null}function ce(){const{id:e}=I(),s=e?decodeURIComponent(e):void 0,a=A(i=>i.getActiveVault()),n=R(s);return c.useEffect(()=>{a&&s&&C(a.id,s)},[a,s]),a?t.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-6 md:py-10",children:[t.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:t.jsx(p,{to:"/",className:"hover:text-accent",children:"← All notes"})}),n.isPending?t.jsx(ne,{}):n.isError?t.jsx(oe,{error:n.error}):n.data?t.jsx(J,{note:n.data}):t.jsx(ae,{id:s??""})]}):t.jsx(E,{to:"/",replace:!0})}function J({note:e}){var r;const s=c.useMemo(()=>_(e),[e]),a=e.path??e.id,n=typeof((r=e.metadata)==null?void 0:r.summary)=="string"?e.metadata.summary:null,i=c.useMemo(()=>(e.links??[]).filter(o=>o.targetId===e.id&&o.sourceId!==e.id&&o.sourceNote),[e]),d=c.useMemo(()=>{const o=new Set,l=[];for(const m of e.links??[])m.sourceId!==e.id||m.targetId===e.id||m.targetNote&&(o.has(m.targetId)||(o.add(m.targetId),l.push(m)));return l},[e]);return t.jsxs("article",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("header",{className:"mb-6 border-b border-border pb-4",children:[t.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:e.path?Q(e.path):e.id}),e.tags&&e.tags.length>0?t.jsx(Z,{tags:e.tags}):null,t.jsx("p",{className:"mt-2 font-mono text-xs text-fg-dim break-all",children:a}),n?t.jsx("p",{className:"mt-3 text-fg-muted",children:n}):null,t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[t.jsx(p,{to:`/n/${encodeURIComponent(e.id)}/edit`,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Edit"}),t.jsx(D,{note:e,keyboard:!0}),t.jsx(M,{note:e})]})]}),t.jsx(q,{content:e.content??""}),t.jsx(T,{content:e.content??"",resolve:s}),e.attachments&&e.attachments.length>0?t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsx("h2",{className:"mb-3 font-serif text-xl",children:"Attachments"}),t.jsx("div",{className:"space-y-6",children:e.attachments.map(o=>t.jsx(ee,{attachment:o},o.id))})]}):null,t.jsx(z,{anchor:e})]}),t.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[t.jsx(Y,{note:e}),d.length>0?t.jsx(N,{title:"Outbound",links:d,peer:"target"}):null,i.length>0?t.jsx(N,{title:"Inbound",links:i,peer:"source"}):null]})]})}function Q(e){return(e.split("/").pop()??e).replace(/\.md$/i,"")}function Y({note:e}){const s=e.createdAt,a=e.updatedAt,n=Object.entries(e.metadata??{}).filter(([i])=>i!=="summary");return t.jsxs("section",{className:"rounded-md border border-border bg-card p-4",children:[t.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Metadata"}),t.jsxs("dl",{className:"space-y-1.5 text-sm",children:[e.path?t.jsx(f,{label:"Path",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.path})}):null,t.jsx(f,{label:"ID",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.id})}),t.jsx(f,{label:"Created",value:t.jsx("time",{title:s,children:j(s)})}),a?t.jsx(f,{label:"Updated",value:t.jsx("time",{title:a,children:j(a)})}):null,n.map(([i,d])=>t.jsx(f,{label:i,value:t.jsx("span",{className:"break-all text-fg-muted",children:String(d)})},i))]})]})}function f({label:e,value:s}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("dt",{className:"text-xs uppercase tracking-wider text-fg-dim",children:e}),t.jsx("dd",{children:s})]})}function Z({tags:e}){return t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5","aria-label":"Tags",children:e.map(s=>t.jsxs(p,{to:`/?tag=${encodeURIComponent(s)}`,className:"max-w-full break-all rounded-full border border-accent/40 bg-accent/10 px-2.5 py-0.5 text-xs font-medium text-accent hover:border-accent hover:bg-accent/20",children:["#",s]},s))})}function N({title:e,links:s,peer:a}){return t.jsxs("section",{className:"rounded-md border border-border bg-card p-4",children:[t.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[e," (",s.length,")"]}),t.jsx("ul",{className:"space-y-1.5",children:s.map(n=>{var o;const i=a==="source"?n.sourceNote:n.targetNote;if(!i)return null;const d=i.path??i.id,r=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return t.jsx("li",{children:t.jsxs(p,{to:`/n/${encodeURIComponent(i.id)}`,className:"block rounded px-1 py-0.5 hover:bg-bg/50",children:[t.jsx("div",{className:"truncate font-mono text-xs text-fg-muted hover:text-accent",children:d}),r?t.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:r}):null]})},`${n.sourceId}->${n.targetId}:${n.relationship}`)})})]})}function ee({attachment:e}){const s=(e.mimeType??"").toLowerCase(),a=e.filename??e.id;return t.jsxs("figure",{className:"rounded-md border border-border bg-card p-3",children:[t.jsxs("figcaption",{className:"mb-2 flex items-baseline justify-between gap-3",children:[t.jsx("span",{className:"truncate font-mono text-xs text-fg-muted",children:a}),typeof e.size=="number"?t.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:re(e.size)}):null]}),t.jsx(te,{attachment:e,mime:s,filename:a})]})}function te({attachment:e,mime:s,filename:a}){const n=v(),[i,d]=c.useState(null),[r,o]=c.useState(null),l=se(s,a),m=l!=="other",u=e.url;if(c.useEffect(()=>{if(!m||!u||!n)return;let h=!1,b=null;return o(null),n.fetchAttachmentBlob(u).then(g=>{h||(b=URL.createObjectURL(g),d(b))}).catch(g=>{h||o(g instanceof Error?g.message:"Failed to load attachment")}),()=>{h=!0,b&&URL.revokeObjectURL(b)}},[m,u,n]),!u)return t.jsx("p",{className:"text-sm text-fg-dim",children:"(no URL)"});if(r)return t.jsx("p",{className:"text-sm text-red-400",children:r});if(m&&!i)return t.jsx("div",{className:"h-32 animate-pulse rounded bg-border/40","aria-busy":"true"});const x=i??u;return l==="image"?t.jsx("img",{src:x,alt:a,className:"max-h-[32rem] rounded"}):l==="audio"?t.jsx("audio",{controls:!0,src:x,className:"w-full"}):l==="video"?t.jsx("video",{controls:!0,src:x,className:"w-full rounded"}):l==="pdf"?t.jsxs(t.Fragment,{children:[t.jsx("iframe",{src:x,title:a,className:"h-[40rem] w-full rounded border border-border"}),t.jsxs("a",{href:x,download:a,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",a]})]}):t.jsxs("a",{href:x,download:a,className:"text-sm text-accent hover:underline",children:["Download ",a]})}function se(e,s){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e==="application/pdf")return"pdf";const a=s.toLowerCase().split(".").pop()??"";return["png","jpg","jpeg","gif","webp","svg"].includes(a)?"image":["mp3","wav","ogg","m4a","flac"].includes(a)?"audio":["mp4","webm","mov"].includes(a)?"video":a==="pdf"?"pdf":"other"}function re(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function ne(){return t.jsxs("div",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]","aria-busy":"true",children:[t.jsxs("div",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-border/40"}),t.jsx("div",{className:"h-8 w-2/3 animate-pulse rounded bg-border/60"}),t.jsx("div",{className:"h-4 w-full animate-pulse rounded bg-border/30"}),t.jsx("div",{className:"mt-6 space-y-2",children:[0,1,2,3,4,5].map(e=>t.jsx("div",{className:"h-3 animate-pulse rounded bg-border/30",style:{width:`${70+e*13%25}%`}},e))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"h-32 animate-pulse rounded bg-border/30"}),t.jsx("div",{className:"h-24 animate-pulse rounded bg-border/30"})]})]})}function ae({id:e}){return t.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"Note not found"}),t.jsxs("p",{className:"mb-4 text-sm text-fg-muted",children:["No note with id ",t.jsx("span",{className:"font-mono",children:e})," in this vault."]}),t.jsx(p,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to all notes"})]})}function oe({error:e}){const s=e instanceof L;return t.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[t.jsx("p",{className:"mb-2 font-medium text-red-400",children:s?"Session expired":"Could not load note"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),s?t.jsx(p,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{ce as NoteView};
import{c as v,v as f,u as b,r as l,G as k,H as j,I as N,J as y,P as w,j as e}from"./index-_ZR9kbJt.js";function E(){const[n]=v(),s=f(),i=b(c=>c.addVault),[r,o]=l.useState({kind:"working"}),d=l.useRef(!1);return l.useEffect(()=>{if(d.current)return;d.current=!0;const c=n.get("code"),u=n.get("state"),p=n.get("error");if(p){o({kind:"error",message:`Vault returned: ${p}`});return}if(!c||!u){o({kind:"error",message:"Missing code or state in callback URL."});return}(async()=>{var x,m;try{const{pending:t,token:a}=await k(c,u),g=((m=(x=a.services)==null?void 0:x.vault)==null?void 0:m.url)??t.issuerUrl,h=i({url:g,name:a.vault,issuer:t.issuer,tokenEndpoint:t.tokenEndpoint,clientId:t.clientId,scope:a.scope},j(a));a.services&&N(h,a.services),y.getState().clearHalt(h),s("/",{replace:!0})}catch(t){if(t instanceof w){o({kind:"pending-approval",approveUrl:t.approveUrl,cliAlternative:t.cliAlternative});return}o({kind:"error",message:t.message})}})()},[n,s,i]),r.kind==="working"?e.jsxs("div",{className:"mx-auto max-w-xl px-6 py-24 text-center",children:[e.jsx("h1",{className:"mb-3 font-serif text-3xl",children:"Connecting…"}),e.jsx("p",{className:"text-fg-muted",children:"Exchanging the authorization code with your vault."})]}):r.kind==="pending-approval"?e.jsxs("div",{className:"mx-auto max-w-xl px-6 py-24 text-center",children:[e.jsx("h1",{className:"mb-3 font-serif text-3xl",children:"Waiting for hub approval"}),e.jsxs("p",{className:"mb-8 text-fg-muted",children:["Your hub admin needs to approve this app before sign-in can complete.",r.approveUrl?" Open the approval page in your hub, approve, then try again.":null]}),r.approveUrl?e.jsx("a",{href:r.approveUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm text-white hover:bg-accent-hover",children:"Open approval page"}):null,r.cliAlternative?e.jsxs("p",{className:"mt-6 text-sm text-fg-muted",children:["Or run"," ",e.jsx("code",{className:"rounded border border-border bg-card px-1.5 py-0.5 font-mono text-xs",children:r.cliAlternative})," ","from a terminal on the hub."]}):null,e.jsx("div",{className:"mt-8",children:e.jsx("button",{type:"button",onClick:()=>s("/add",{replace:!0}),className:"text-sm text-fg-muted underline hover:text-fg",children:"Back to connect"})})]}):e.jsxs("div",{className:"mx-auto max-w-xl px-6 py-24 text-center",children:[e.jsx("h1",{className:"mb-3 font-serif text-3xl text-red-400",children:"Connection failed"}),e.jsx("p",{className:"mb-8 text-fg-muted",children:r.message}),e.jsx("button",{type:"button",onClick:()=>s("/add",{replace:!0}),className:"rounded-md bg-accent px-4 py-2 text-sm text-white hover:bg-accent-hover",children:"Try again"})]})}export{E as OAuthCallback};
import{r as c,j as t,v,f as g,E as w,V as y,u as j,h as E,w as N}from"./index-_ZR9kbJt.js";function P({note:a,className:i,label:l="Delete"}){const[r,d]=c.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(!0),className:i??"min-h-11 rounded-md border border-red-500/40 bg-transparent px-3 py-1.5 text-sm text-red-400 hover:bg-red-500/10",title:"Delete this note",children:l}),r?t.jsx(k,{note:a,onClose:()=>d(!1)}):null]})}function k({note:a,onClose:i}){const l=v(),r=g(e=>e.push),d=w(),o=a.path??a.id,[m,p]=c.useState(""),[u,b]=c.useState(null),x=c.useRef(null),s=m===o&&!d.isPending;c.useEffect(()=>{var e;(e=x.current)==null||e.focus()},[]),c.useEffect(()=>{const e=f=>{f.key==="Escape"&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);const n=c.useCallback(()=>{s&&(b(null),d.mutate(a.id,{onSuccess:()=>{r(`Deleted ${o}`,"success"),l("/")},onError:e=>{e instanceof y?b("Session expired. Reconnect to delete."):b(e instanceof Error?e.message:"Delete failed")}}))},[s,o,d,l,a.id,r]);return t.jsx("dialog",{open:!0,"aria-labelledby":"confirm-delete-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:e=>{e.target===e.currentTarget&&i()},children:t.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[t.jsx("h2",{id:"confirm-delete-title",className:"mb-2 font-serif text-xl text-red-400",children:"Delete this note?"}),t.jsx("p",{className:"mb-3 text-sm text-fg-muted",children:"This permanently removes the note, its tags, and its links. This cannot be undone."}),t.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Type"," ",t.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:o})," ","to confirm:"]}),t.jsx("input",{ref:x,type:"text",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key==="Enter"&&s&&n()},"aria-label":"Type note path to confirm",className:"mb-3 w-full rounded-md border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-red-400 focus:outline-none",placeholder:o,autoComplete:"off",spellCheck:!1}),u?t.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:u}):null,t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),t.jsx("button",{type:"button",onClick:n,disabled:!s,className:"min-h-11 rounded-md bg-red-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-600 disabled:opacity-40",children:d.isPending?"Deleting…":"Delete permanently"})]})]})})}function C({note:a,keyboard:i=!1}){var b,x;const l=j(s=>s.getActiveVault()),{roles:r}=E((l==null?void 0:l.id)??null),d=g(s=>s.push),o=N(a.id),m=((b=a.tags)==null?void 0:b.includes(r.pinned))??!1,p=((x=a.tags)==null?void 0:x.includes(r.archived))??!1,u=c.useCallback(s=>{var f;if(o.isPending)return;const n=r[s],e=((f=a.tags)==null?void 0:f.includes(n))??!1;o.mutate({tags:e?{remove:[n]}:{add:[n]}},{onSuccess:()=>{d(s==="pinned"?e?"Unpinned":"Pinned":e?"Unarchived":"Archived","success")},onError:h=>{h instanceof y?d("Session expired. Reconnect.","error"):d(h instanceof Error?h.message:"Update failed","error")}})},[o,a.tags,d,r]);return c.useEffect(()=>{if(!i)return;const s=n=>{if(n.defaultPrevented)return;const e=n.target;if(e){const f=e.tagName;if(f==="INPUT"||f==="TEXTAREA"||e.isContentEditable)return}n.metaKey||n.ctrlKey||n.altKey||(n.key==="p"||n.key==="P"?(n.preventDefault(),u("pinned")):(n.key==="a"||n.key==="A")&&(n.preventDefault(),u("archived")))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i,u]),t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>u("pinned"),disabled:o.isPending,"aria-pressed":m,title:m?`Unpin (${r.pinned})`:`Pin as #${r.pinned} (P)`,className:m?"min-h-11 rounded-md border border-accent/60 bg-accent/10 px-3 py-1.5 text-sm text-accent hover:bg-accent/20 disabled:opacity-40":"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:m?"★ Pinned":"☆ Pin"}),t.jsx("button",{type:"button",onClick:()=>u("archived"),disabled:o.isPending,"aria-pressed":p,title:p?`Unarchive (${r.archived})`:`Archive as #${r.archived} (A)`,className:p?"min-h-11 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-1.5 text-sm text-amber-500 hover:bg-amber-500/20 disabled:opacity-40":"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:p?"Archived":"Archive"})]})}export{P as D,C as P};

Sorry, the diff of this file is too big to display

import{u as N,j as e,N as y,L as w,K as T,M as S,h as E,O as A,f as C,r as n,Q as p,R as x,U as R}from"./index-_ZR9kbJt.js";function I(){const s=N(a=>a.getActiveVault());return s?e.jsxs("div",{className:"mx-auto max-w-2xl px-4 py-7 md:px-6 md:py-12",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("nav",{className:"mb-3 text-sm text-fg-dim",children:e.jsx(w,{to:"/",className:"hover:text-accent",children:"← Home"})}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Settings"}),e.jsxs("p",{className:"mt-1 text-sm text-fg-muted",children:["Configuring ",e.jsx("span",{className:"text-fg",children:s.name}),"."]})]}),e.jsx(_,{vaultId:s.id}),e.jsx(D,{vaultId:s.id}),e.jsx(L,{})]}):e.jsx(y,{to:"/",replace:!0})}function L(){const[s,a]=n.useState(!1);return n.useEffect(()=>{a(R())},[]),s?e.jsx("section",{className:"mt-6 rounded-md border border-border bg-card p-4 text-sm",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-emerald-500/20 px-2 py-0.5 text-xs font-medium text-emerald-300",children:"Installed"}),"Parachute Notes is running as an installed app on this device."]})}):null}const f={auto:{title:"Auto",help:"Show the tree only when the vault has enough folders to make it worth the space."},always:{title:"Always",help:"Always show the tree, even on a tag-flat vault."},never:{title:"Never",help:"Hide the tree. The path-prefix text input still works."}};function _({vaultId:s}){const{mode:a,setMode:o}=T(s);return e.jsxs("section",{className:"mt-6 space-y-4 rounded-xl border border-border bg-card p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Folder tree (Notes sidebar)"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Controls the collapsible folder tree on the notes list page. Auto-detect renders the tree when the vault has at least five top-level folders or twenty notes in folders."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"Path tree visibility"}),S.map(l=>e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:l,checked:a===l,onChange:()=>o(l),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg",children:f[l].title}),e.jsx("span",{className:"ml-2 text-xs text-fg-dim",children:f[l].help})]})]},l))]})]})}const h={pinned:{title:"Pinned",help:"Tag for notes you want at the top of views."},archived:{title:"Archived",help:"Tag for notes you've moved out of the way."},captureVoice:{title:"Voice capture",help:"Default tag for new voice memos."},captureText:{title:"Text capture",help:"Default tag for quick typed notes."},view:{title:"Saved view",help:"Tag the saved-view notes carry. Used to list them in the notes sidebar."}};function D({vaultId:s}){const{roles:a,setRoles:o}=E(s),l=A(),m=C(t=>t.push),u=n.useId(),[i,c]=n.useState(a);n.useEffect(()=>c(a),[a]);const g=n.useMemo(()=>{const t=(l.data??[]).map(r=>r.name);return[...new Set(t)].sort((r,d)=>r.localeCompare(d))},[l.data]),v=p.some(t=>i[t].trim()!==a[t]),j=()=>{o(i),m("Tag roles saved.","success")},b=()=>{o(null),c(x),m("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"mt-6 space-y-4 rounded-xl border border-border bg-card p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Tag roles"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Point each role at whatever tag your vault already uses. Changes apply to future notes only — existing notes keep their current tags."})]}),e.jsx("datalist",{id:u,children:g.map(t=>e.jsx("option",{value:t},t))}),e.jsx("div",{className:"space-y-3",children:p.map(t=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:h[t].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",x[t]]})]}),e.jsx("input",{type:"text",value:i[t],onChange:r=>c(d=>({...d,[t]:r.target.value})),list:u,placeholder:x[t],"aria-label":`${h[t].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg placeholder:text-fg-dim focus:border-accent focus:outline-none"}),e.jsx("span",{className:"mt-1 block text-xs text-fg-dim",children:h[t].help})]},t))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:j,disabled:!v,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:"Save"}),e.jsx("button",{type:"button",onClick:b,className:"text-sm text-fg-muted hover:text-accent",children:"Reset to defaults"})]})]})}export{I as Settings};
import{f as P,r as l,W as O,V as R,j as e,u as L,O as F,g as I,X as V,Y as z,Z as D,N as B,L as E}from"./index-_ZR9kbJt.js";const $=n=>Object.values(n).reduce((a,x)=>a+x,0);function A({mode:n,sources:a,tagOptions:x,onClose:c,onRun:d,onRunMerge:o,pending:i,offline:m}){const p=P(t=>t.push),g=l.useId(),[S,j]=l.useState(n==="rename"?a[0]??"":""),[T,h]=l.useState(null),[u,y]=l.useState(null),[b,N]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{var t,r;(t=v.current)==null||t.focus(),(r=v.current)==null||r.select()},[]),l.useEffect(()=>{const t=r=>{r.key==="Escape"&&c()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c]);const w=S.trim().replace(/^#/,""),f=!i&&!m&&!b&&w.length>0&&!(n==="rename"&&w===a[0]),C=l.useCallback(async()=>{if(f){h(null),y(null);try{const t=await d(w);if("renamed"in t)p(`Renamed on ${t.renamed} note${t.renamed===1?"":"s"}.`,"success");else{const r=$(t.merged);p(`Merged into #${t.target} on ${r} note${r===1?"":"s"}.`,"success")}c()}catch(t){if(t instanceof O&&n==="rename"&&o){y(t.target);return}t instanceof R?h("Session expired. Reconnect to retry."):h(t instanceof Error?t.message:"Operation failed.")}}},[f,w,n,c,d,o,p]),k=l.useCallback(async()=>{if(!(!u||!o)){h(null),N(!0);try{const t=await o(u),r=$(t.merged);p(`Merged into #${t.target} on ${r} note${r===1?"":"s"}.`,"success"),c()}catch(t){t instanceof R?h("Session expired. Reconnect to retry."):h(t instanceof Error?t.message:"Merge failed."),N(!1)}}},[u,c,o,p]),s=n==="rename"?"Rename tag":`Merge ${a.length} tags`;return e.jsx("dialog",{open:!0,"aria-labelledby":"tag-op-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:t=>{t.target===t.currentTarget&&c()},children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:s}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[n==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(M,{children:a[0]})," on every note that carries it. Notes that already have the new tag will end up with one copy."]}):e.jsxs(e.Fragment,{children:["Combine"," ",a.map((t,r)=>e.jsxs("span",{children:[e.jsx(M,{children:t}),r<a.length-1?", ":""]},t))," ","into one tag. The originals are removed."]})," ","Changes apply atomically on the vault."]}),e.jsxs("label",{className:"mb-3 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:n==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:v,type:"text",value:S,onChange:t=>{j(t.target.value),u&&y(null)},onKeyDown:t=>{t.key==="Enter"&&f&&C()},list:g,"aria-label":n==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-md border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-accent focus:outline-none",autoComplete:"off"}),e.jsx("datalist",{id:g,children:x.map(t=>e.jsx("option",{value:t},t))})]}),m?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,u?e.jsxs("div",{role:"alert",className:"mb-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[e.jsxs("p",{className:"mb-2 text-amber-300",children:["A tag named ",e.jsx(M,{children:u})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(M,{children:a[0]})," into ",e.jsx(M,{children:u})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void k(),disabled:b,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:b?"Merging…":`Merge into #${u}`})]}):null,T?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:T}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:c,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:!f,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:i?n==="rename"?"Renaming…":"Merging…":n==="rename"?"Rename":"Merge"})]})]})})}function M({children:n}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",n]})}function q(){const n=L(s=>s.getActiveVault()),a=F(),{isOnline:x}=I(),{isPinned:c,togglePin:d}=V((n==null?void 0:n.id)??null),[o,i]=l.useState(""),[m,p]=l.useState("count"),[g,S]=l.useState(new Set),[j,T]=l.useState(null),[h,u]=l.useState(!1),y=z(),b=D(),N=l.useMemo(()=>U(a.data??[],o,m),[a.data,o,m]),v=l.useMemo(()=>(a.data??[]).map(s=>s.name),[a.data]),w=s=>{S(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},f=()=>S(new Set);if(!n)return e.jsx(B,{to:"/",replace:!0});const C=g.size,k=!x;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:n.name}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>p(s=>s==="count"?"alpha":"count"),className:"text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",m==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:o,onChange:s=>i(s.target.value),"aria-label":"Filter tags",className:"mb-4 w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"}),C>0?e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3 rounded-md border border-accent/30 bg-accent/5 px-3 py-2 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[C," selected: ",Array.from(g).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>u(!0),disabled:C<2||k,className:"rounded-md bg-accent px-3 py-1 text-xs font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:f,className:"text-xs text-fg-muted hover:text-accent",children:"Clear"})]}):null,a.isPending?e.jsx(Z,{}):a.isError?e.jsx(W,{error:a.error}):N.length===0?e.jsx(X,{filtering:o.trim().length>0,hasAny:(a.data??[]).length>0}):e.jsx("ul",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-label":"Tag list",children:N.map(s=>e.jsx(K,{tag:s,selected:g.has(s.name),onToggle:()=>w(s.name),onRename:()=>T(s.name),pinned:c(s.name),onTogglePin:()=>d(s.name),offline:k},s.name))}),a.data&&a.data.length>0?e.jsxs("p",{className:"mt-6 text-xs text-fg-dim",children:[N.length," / ",a.data.length," tag",a.data.length===1?"":"s"]}):null,j!==null?e.jsx(A,{mode:"rename",sources:[j],tagOptions:v,onClose:()=>T(null),pending:y.isPending||b.isPending,offline:k,onRun:s=>y.mutateAsync({oldName:j,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[j],target:s})}):null,h?e.jsx(A,{mode:"merge",sources:Array.from(g),tagOptions:v,onClose:()=>u(!1),pending:b.isPending,offline:k,onRun:async s=>{const t=await b.mutateAsync({sources:Array.from(g),target:s});return f(),t}}):null]})}function K({tag:n,selected:a,onToggle:x,onRename:c,pinned:d,onTogglePin:o,offline:i}){return e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:x,"aria-label":`Select tag ${n.name}`,className:"accent-accent"}),e.jsxs(E,{to:`/?tag=${encodeURIComponent(n.name)}`,className:"flex flex-1 items-baseline gap-2 text-fg hover:text-accent focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsxs("span",{className:"font-mono",children:["#",n.name]}),e.jsx("span",{className:"text-xs text-fg-dim",children:n.count})]}),e.jsx("button",{type:"button",onClick:o,className:d?"text-xs font-medium text-accent hover:text-accent-hover":"text-xs text-fg-muted hover:text-accent","aria-label":d?`Unpin tag ${n.name}`:`Pin tag ${n.name}`,"aria-pressed":d,title:d?"Pinned to home strip — click to unpin":"Pin to home strip",children:d?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:c,disabled:i,className:"text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${n.name}`,children:"Rename"})]})}function U(n,a,x){const c=a.trim().toLowerCase(),o=[...c?n.filter(i=>i.name.toLowerCase().includes(c)):n];return x==="alpha"?o.sort((i,m)=>i.name.localeCompare(m.name)):o.sort((i,m)=>m.count-i.count||i.name.localeCompare(m.name)),o}function Z(){return e.jsx("div",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-busy":"true",children:[0,1,2,3,4].map(n=>e.jsx("div",{className:"h-10 animate-pulse bg-card/60"},n))})}function W({error:n}){const a=n instanceof R;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:a?"Session expired":"Could not load tags"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:n.message}),a?e.jsx(E,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function X({filtering:n,hasAny:a}){return n&&a?e.jsx("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:e.jsx("p",{className:"text-fg-muted",children:"No tags match your filter."})}):e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-3 text-fg-muted",children:"No tags in this vault yet."}),e.jsx(E,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create a note"})]})}export{q as Tags};
import{u as w,c as $,a as A,r as D,j as e,N as E,L as d,b as C,V as S}from"./index-_ZR9kbJt.js";import{t as V,d as N,a as g,e as K,b as f}from"./dates-DfXc2iZW.js";function F(){const a=w(i=>i.getActiveVault()),[s]=$(),t=s.get("date"),u=V(),r=t??u,x=N(r),n=A(),c=D.useMemo(()=>{const i=[],m=[];if(!n.data||!x)return{created:i,edited:m};for(const l of n.data){const b=g(l.createdAt),k=g(l.updatedAt??l.createdAt);b===r&&i.push(l),k===r&&b!==r&&m.push(l)}return{created:i,edited:m}},[n.data,x,r]);if(!a)return e.jsx(E,{to:"/",replace:!0});if(!x)return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("p",{className:"text-sm text-red-400",children:["Invalid date in URL: ",r]}),e.jsx(d,{to:"/today",className:"text-sm text-accent hover:underline",children:"Back to today"})]});const o=r===u,p=j(r,-1),h=j(r,1),v=r.slice(0,7);return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:o?"Today":"On"}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:K(r)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(d,{to:`/today?date=${p}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous day",children:["← ",p]}),o?null:e.jsx(d,{to:"/today",className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"}),e.jsxs(d,{to:`/today?date=${h}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next day",children:[h," →"]}),e.jsx(d,{to:`/calendar?month=${v}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Calendar"}),e.jsx(d,{to:"/capture",className:"rounded-md bg-accent px-3 py-1.5 font-medium text-white hover:bg-accent-hover",children:"+ Capture"})]})]}),n.isPending?e.jsx(L,{}):n.isError?e.jsx(R,{error:n.error}):c.created.length===0&&c.edited.length===0?e.jsx(P,{isToday:o,targetKey:r}):e.jsxs("div",{className:"space-y-8",children:[c.created.length>0?e.jsx(y,{title:o?"Created today":`Created on ${r}`,notes:c.created}):null,c.edited.length>0?e.jsx(y,{title:o?"Edited today":`Edited on ${r}`,notes:c.edited}):null]})]})}function j(a,s){const t=N(a);return t?(t.setDate(t.getDate()+s),`${t.getFullYear()}-${f(t.getMonth()+1)}-${f(t.getDate())}`):a}function y({title:a,notes:s}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[a," (",s.length,")"]}),e.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card",children:s.map(t=>e.jsx("li",{children:e.jsxs(d,{to:`/n/${encodeURIComponent(t.id)}`,className:"block px-4 py-3 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:t.path??t.id}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:C(t.updatedAt??t.createdAt)})]}),t.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:t.preview}):null]})},t.id))})]})}function P({isToday:a,targetKey:s}){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-4 text-fg-muted",children:a?"Nothing yet today — start capturing.":`Nothing on ${s}.`}),a?e.jsx(d,{to:"/capture",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Open capture"}):null]})}function L(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3].map(a=>e.jsx("div",{className:"h-14 animate-pulse rounded-md bg-border/30"},a))})}function R({error:a}){const s=a instanceof S;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:s?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),s?e.jsx(d,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{F as Today};

Sorry, the diff of this file is too big to display

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-jqFHZKU6.js","assets/index-_ZR9kbJt.js","assets/index-CSwzwMDF.css"])))=>i.map(i=>d[i]);
import{u as w,$ as N,r as f,j as s,N as k,L as v,v as C,V as I,_ as M}from"./index-_ZR9kbJt.js";const S={search:"",tags:[]};function T(e){const t=new Map;for(const i of e)t.set(i.id,i);const a=new Map,o=new Map;for(const i of e)for(const n of i.links??[]){if(n.sourceId===n.targetId||!t.has(n.sourceId)||!t.has(n.targetId))continue;const c=`${n.sourceId}|${n.targetId}|${n.relationship}`;a.has(c)||(a.set(c,{source:n.sourceId,target:n.targetId,relationship:n.relationship}),o.set(n.sourceId,(o.get(n.sourceId)??0)+1),o.set(n.targetId,(o.get(n.targetId)??0)+1))}return{nodes:e.map(i=>{var c;const n=i.tags??[];return{id:i.id,path:i.path,title:A(i),tags:n,topTag:n[0],degree:o.get(i.id)??0,summary:typeof((c=i.metadata)==null?void 0:c.summary)=="string"?i.metadata.summary:void 0}}),edges:[...a.values()]}}function A(e){return e.path?(e.path.split("/").pop()??e.path).replace(/\.md$/i,""):e.id}function R(e,t){const a=t.search.trim().toLowerCase();return!(a&&![e.path??"",e.title,e.id].join(" ").toLowerCase().includes(a)||t.tags.length>0&&!t.tags.some(d=>e.tags.includes(d)))}function E(e){const t=new Map;for(const a of e)for(const o of a.tags)t.set(o,(t.get(o)??0)+1);return[...t.entries()].sort((a,o)=>o[1]-a[1]||a[0].localeCompare(o[0])).map(([a])=>a)}function _(e){if(!e)return"#8a9a7a";let t=0;for(let o=0;o<e.length;o++)t=t*31+e.charCodeAt(o)&16777215;return`hsl(${t%360}, 40%, 55%)`}const $=f.lazy(()=>M(()=>import("./react-force-graph-2d-jqFHZKU6.js"),__vite__mapDeps([0,1,2]))),F=20;function O(){const e=w(c=>c.getActiveVault()),t=N(),[a,o]=f.useState(S),d=f.useMemo(()=>t.data?T(t.data):null,[t.data]),i=f.useMemo(()=>d?E(d.nodes):[],[d]),n=f.useMemo(()=>d?new Set(d.nodes.filter(c=>R(c,a)).map(c=>c.id)):new Set,[d,a]);return e?s.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[s.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:s.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[s.jsx("input",{type:"search",value:a.search,onChange:c=>o(m=>({...m,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),s.jsx(P,{allTags:i,selected:a.tags,onChange:c=>o(m=>({...m,tags:c}))}),d?s.jsxs("span",{className:"text-xs text-fg-dim",children:[n.size," / ",d.nodes.length," notes"]}):null]})}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(L,{query:t,graph:d,matched:n})})]}):s.jsx(k,{to:"/",replace:!0})}function L({query:e,graph:t,matched:a}){return e.isPending?s.jsx(j,{message:"Loading vault…"}):e.isError?s.jsx(B,{error:e.error}):!t||t.nodes.length===0?s.jsx("div",{className:"flex h-full items-center justify-center p-10",children:s.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[s.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),s.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),s.jsx(v,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create a note"})]})}):s.jsx(z,{graph:t,matched:a})}function P({allTags:e,selected:t,onChange:a}){const o=e.slice(0,F);if(o.length===0)return null;const d=i=>a(t.includes(i)?t.filter(n=>n!==i):[...t,i]);return s.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[s.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),o.map(i=>{const n=t.includes(i);return s.jsx("button",{type:"button","aria-pressed":n,onClick:()=>d(i),className:n?"max-w-full break-all rounded-full border border-accent bg-accent/10 px-2 py-0.5 text-accent":"max-w-full break-all rounded-full border border-border bg-card px-2 py-0.5 hover:text-accent",children:i},i)}),t.length>0?s.jsx("button",{type:"button",onClick:()=>a([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return s.jsx("div",{"aria-busy":"true",className:"flex h-full animate-pulse items-center justify-center bg-card/30 text-sm text-fg-dim",children:e})}function z({graph:e,matched:t}){const a=C(),o=f.useRef(null),d=f.useRef(null),[i,n]=f.useState({w:800,h:600});f.useEffect(()=>{const r=o.current;if(!r)return;const l=()=>{const u=r.getBoundingClientRect();n({w:Math.max(320,Math.floor(u.width)),h:Math.max(320,Math.floor(u.height))})};l();const h=new ResizeObserver(l);return h.observe(r),()=>h.disconnect()},[]);const c=()=>{var r,l;(l=(r=d.current)==null?void 0:r.zoomToFit)==null||l.call(r,400,40)},m=f.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),g=t.size!==e.nodes.length,y=r=>!g||t.has(r)?1:.15;return s.jsxs("div",{ref:o,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[s.jsx(f.Suspense,{fallback:s.jsx(j,{message:"Rendering graph…"}),children:s.jsx($,{ref:d,graphData:m,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>V(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const l=r,h=_(l.topTag);return g&&!t.has(l.id)?G(h):h},nodePointerAreaPaint:(r,l,h)=>{const u=r;if(u.x==null||u.y==null)return;const x=2+Math.min(u.degree,12),p=Math.max(Math.sqrt(x)*5,10);h.fillStyle=l,h.beginPath(),h.arc(u.x,u.y,p,0,2*Math.PI),h.fill()},linkColor:r=>{const l=r,h=b(l.source),u=b(l.target);return g&&(!t.has(h)||!t.has(u))?"rgba(160, 160, 160, 0.08)":"rgba(160, 160, 160, 0.35)"},linkDirectionalArrowLength:2.5,linkDirectionalArrowRelPos:1,cooldownTicks:100,onEngineStop:()=>c(),nodeCanvasObjectMode:()=>"after",nodeCanvasObject:(r,l,h)=>{const u=r;if(u.x==null||u.y==null||y(u.id)<.5)return;const p=10/h;l.font=`${p}px sans-serif`,l.fillStyle="rgba(220, 220, 220, 0.8)",l.textAlign="left",l.textBaseline="middle",l.fillText(u.title,u.x+6,u.y)},onNodeClick:r=>{a(`/n/${encodeURIComponent(r.id)}`)}})}),s.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-md border border-border bg-card/90 px-3 py-1.5 text-xs text-fg-muted shadow-sm backdrop-blur hover:text-accent",children:"Fit to screen"})]})}function V(e){const t=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&t.push(`tags: ${e.tags.join(", ")}`),e.summary&&t.push(e.summary),t.join(`
`)}function G(e){return e.startsWith("hsl(")?e.replace("hsl(","hsla(").replace(")",", 0.2)"):e}function b(e){return typeof e=="string"?e:e&&typeof e=="object"&&"id"in e?String(e.id):""}function B({error:e}){const t=e instanceof I;return s.jsx("div",{className:"flex h-full items-center justify-center p-10",children:s.jsxs("div",{className:"max-w-md rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[s.jsx("p",{className:"mb-2 font-medium text-red-400",children:t?"Session expired":"Could not load vault"}),s.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),t?s.jsx(v,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})})}export{O as VaultGraph};
import{u as a,j as e,L as c,a0 as m}from"./index-_ZR9kbJt.js";function u(){const l=a(t=>t.vaults),d=a(t=>t.activeVaultId),i=a(t=>t.removeVault),o=a(t=>t.setActiveVault),n=Object.values(l).sort((t,s)=>t.name.localeCompare(s.name));return e.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-16",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[e.jsx("h1",{className:"font-serif text-4xl tracking-tight",children:"Vaults"}),e.jsx(c,{to:"/add",className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Add vault"})]}),n.length===0?e.jsx("p",{className:"text-fg-muted",children:"No vaults connected yet."}):e.jsx("ul",{className:"space-y-3",children:n.map(t=>{const s=t.id===d,r=m(t.url);return e.jsxs("li",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:t.name}),s?e.jsx("span",{className:"rounded bg-accent/10 px-2 py-0.5 text-xs text-accent",children:"active"}):null,e.jsx("span",{className:"rounded border border-border px-2 py-0.5 text-xs text-fg-dim",children:t.scope}),r?e.jsx("span",{className:"rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-500",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate font-mono text-xs text-fg-muted",children:t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[s?null:e.jsx("button",{type:"button",onClick:()=>o(t.id),className:"text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${t.name}? The access token will be deleted.`)&&i(t.id)},className:"text-red-400 hover:text-red-300",children:"Remove"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-500",children:["Vault now serves under ",e.jsx("code",{children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(c,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},t.id)})})]})}export{u as Vaults};
+1
-0

@@ -9,3 +9,4 @@ {

"paths": ["/notes"],
"uiUrl": "/notes",
"health": "/notes/health"
}
+1
-1

@@ -22,3 +22,3 @@ <!doctype html>

</script>
<script type="module" crossorigin src="/notes/assets/index-D41hUtgX.js"></script>
<script type="module" crossorigin src="/notes/assets/index-_ZR9kbJt.js"></script>
<link rel="stylesheet" crossorigin href="/notes/assets/index-CSwzwMDF.css">

@@ -25,0 +25,0 @@ <link rel="manifest" href="/notes/manifest.webmanifest"></head>

@@ -1,1 +0,1 @@

if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,l)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let a={};const o=e=>i(e,r),t={module:{uri:r},exports:a,require:o};s[r]=Promise.all(n.map(e=>t[e]||o(e))).then(e=>(l(...e),a))}}define(["./workbox-d24cdb67"],function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.precacheAndRoute([{url:"pwa-64x64.png",revision:"52bb73fe0f7c4274aa55047dc0d5479d"},{url:"pwa-512x512.png",revision:"ebdabf19d41be24e3f47062e89399c09"},{url:"pwa-192x192.png",revision:"ec3f52a07bade7b8a295997c236dac75"},{url:"maskable-icon-512x512.png",revision:"e0d671a48eed68b28f8e7ded8a86ef88"},{url:"manifest.webmanifest",revision:"4e69789fa00f6df17850c3426d2041a9"},{url:"index.html",revision:"b1771946b77946f5d51e7b960f0707ce"},{url:"icon.svg",revision:"899549fbb9d379c3b78ab012abe72061"},{url:"favicon.ico",revision:"01d978be2c7b93a7348d91107b5bf8ad"},{url:"apple-touch-icon-180x180.png",revision:"dd71bb172b849f6328130ba825ae606d"},{url:"assets/workbox-window.prod.es5-BIl4cyR9.js",revision:null},{url:"assets/useAttachmentUploader-CafTAVak.js",revision:null},{url:"assets/react-force-graph-2d-CY0IItb_.js",revision:null},{url:"assets/index-D41hUtgX.js",revision:null},{url:"assets/index-CSwzwMDF.css",revision:null},{url:"assets/dates-DfXc2iZW.js",revision:null},{url:"assets/Vaults-BWAPyz8k.js",revision:null},{url:"assets/VaultGraph-1KwULv8z.js",revision:null},{url:"assets/Today-D47PZuKn.js",revision:null},{url:"assets/Tags-DnXib7Bo.js",revision:null},{url:"assets/Settings-D8sxVpGR.js",revision:null},{url:"assets/PinArchiveButtons-Cjsu8ZBM.js",revision:null},{url:"assets/OAuthCallback-hpIPeVmG.js",revision:null},{url:"assets/NoteView-I8Zahn0V.js",revision:null},{url:"assets/NoteNew-DgjuSEQh.js",revision:null},{url:"assets/NoteEditor-DS9ApnO9.js",revision:null},{url:"assets/MarkdownView-DksAP33z.js",revision:null},{url:"assets/Capture-BQImHZY-.js",revision:null},{url:"assets/Calendar-D_PoTDkg.js",revision:null},{url:"assets/AddVault-Cl0u33Wq.js",revision:null},{url:"assets/Activity-IRvlWG0w.js",revision:null},{url:"apple-touch-icon-180x180.png",revision:"dd71bb172b849f6328130ba825ae606d"},{url:"favicon.ico",revision:"01d978be2c7b93a7348d91107b5bf8ad"},{url:"icon.svg",revision:"899549fbb9d379c3b78ab012abe72061"},{url:"maskable-icon-512x512.png",revision:"e0d671a48eed68b28f8e7ded8a86ef88"},{url:"pwa-192x192.png",revision:"ec3f52a07bade7b8a295997c236dac75"},{url:"pwa-512x512.png",revision:"ebdabf19d41be24e3f47062e89399c09"},{url:"pwa-64x64.png",revision:"52bb73fe0f7c4274aa55047dc0d5479d"},{url:"manifest.webmanifest",revision:"4e69789fa00f6df17850c3426d2041a9"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/notes/index.html"),{denylist:[/^\/api\//,/^\/oauth\//,/^\/\.well-known\//]})),e.registerRoute(/^https:\/\/fonts\.(googleapis|gstatic)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts",plugins:[new e.ExpirationPlugin({maxEntries:30,maxAgeSeconds:2592e3}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")});
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,l)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let a={};const o=e=>i(e,r),t={module:{uri:r},exports:a,require:o};s[r]=Promise.all(n.map(e=>t[e]||o(e))).then(e=>(l(...e),a))}}define(["./workbox-d24cdb67"],function(e){"use strict";self.addEventListener("message",e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()}),e.precacheAndRoute([{url:"pwa-64x64.png",revision:"52bb73fe0f7c4274aa55047dc0d5479d"},{url:"pwa-512x512.png",revision:"ebdabf19d41be24e3f47062e89399c09"},{url:"pwa-192x192.png",revision:"ec3f52a07bade7b8a295997c236dac75"},{url:"maskable-icon-512x512.png",revision:"e0d671a48eed68b28f8e7ded8a86ef88"},{url:"manifest.webmanifest",revision:"4e69789fa00f6df17850c3426d2041a9"},{url:"index.html",revision:"78e361e09dc9fa8a8382269cf9f4f68a"},{url:"icon.svg",revision:"899549fbb9d379c3b78ab012abe72061"},{url:"favicon.ico",revision:"01d978be2c7b93a7348d91107b5bf8ad"},{url:"apple-touch-icon-180x180.png",revision:"dd71bb172b849f6328130ba825ae606d"},{url:"assets/workbox-window.prod.es5-BIl4cyR9.js",revision:null},{url:"assets/useAttachmentUploader-BdHqmISq.js",revision:null},{url:"assets/react-force-graph-2d-jqFHZKU6.js",revision:null},{url:"assets/index-_ZR9kbJt.js",revision:null},{url:"assets/index-CSwzwMDF.css",revision:null},{url:"assets/dates-DfXc2iZW.js",revision:null},{url:"assets/Vaults-D5RyJ2tX.js",revision:null},{url:"assets/VaultGraph-hiE8HUdv.js",revision:null},{url:"assets/Today-Bx3rEPyQ.js",revision:null},{url:"assets/Tags-C31aAaln.js",revision:null},{url:"assets/Settings-DQGFqD6N.js",revision:null},{url:"assets/PinArchiveButtons-D-w7K7l4.js",revision:null},{url:"assets/OAuthCallback-BGAa6vRd.js",revision:null},{url:"assets/NoteView-aYtK9I6L.js",revision:null},{url:"assets/NoteNew-5Oo2svYt.js",revision:null},{url:"assets/NoteEditor-D4npJ7AJ.js",revision:null},{url:"assets/MarkdownView-CSykIOWY.js",revision:null},{url:"assets/Capture-BQKM9uLK.js",revision:null},{url:"assets/Calendar-D5Unw04V.js",revision:null},{url:"assets/AddVault-CKKnZXZ_.js",revision:null},{url:"assets/Activity-0qLhISZY.js",revision:null},{url:"apple-touch-icon-180x180.png",revision:"dd71bb172b849f6328130ba825ae606d"},{url:"favicon.ico",revision:"01d978be2c7b93a7348d91107b5bf8ad"},{url:"icon.svg",revision:"899549fbb9d379c3b78ab012abe72061"},{url:"maskable-icon-512x512.png",revision:"e0d671a48eed68b28f8e7ded8a86ef88"},{url:"pwa-192x192.png",revision:"ec3f52a07bade7b8a295997c236dac75"},{url:"pwa-512x512.png",revision:"ebdabf19d41be24e3f47062e89399c09"},{url:"pwa-64x64.png",revision:"52bb73fe0f7c4274aa55047dc0d5479d"},{url:"manifest.webmanifest",revision:"4e69789fa00f6df17850c3426d2041a9"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/notes/index.html"),{denylist:[/^\/api\//,/^\/oauth\//,/^\/\.well-known\//]})),e.registerRoute(/^https:\/\/fonts\.(googleapis|gstatic)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts",plugins:[new e.ExpirationPlugin({maxEntries:30,maxAgeSeconds:2592e3}),new e.CacheableResponsePlugin({statuses:[0,200]})]}),"GET")});
{
"name": "@openparachute/notes",
"version": "0.3.12",
"version": "0.3.14",
"private": false,

@@ -5,0 +5,0 @@ "type": "module",

import{u as h,a as g,r as l,j as e,N as f,L as m,b,V as y}from"./index-D41hUtgX.js";const p=1440*60*1e3,j=5e3;function N(n,r=30,s=new Date){const d=s.getTime()-r*p,a=[];for(const t of n){const c=t.path??t.id,o=Date.parse(t.createdAt);if(Number.isFinite(o)&&o>=d&&a.push({id:`${t.id}:created`,noteId:t.id,noteName:c,kind:"created",at:t.createdAt,preview:t.preview,tags:t.tags}),t.updatedAt){const i=Date.parse(t.updatedAt);Number.isFinite(i)&&i>=d&&Number.isFinite(o)&&i-o>j&&a.push({id:`${t.id}:updated`,noteId:t.id,noteName:c,kind:"updated",at:t.updatedAt,preview:t.preview,tags:t.tags})}}return a.sort((t,c)=>Date.parse(c.at)-Date.parse(t.at)),a}const v=["today","yesterday","thisWeek","older"],k={today:"Today",yesterday:"Yesterday",thisWeek:"This week",older:"Older"};function w(n,r=new Date){const s=Date.parse(n);if(!Number.isFinite(s))return null;const d=u(r),a=u(new Date(s)),t=Math.round((d.getTime()-a.getTime())/p);return t<0||t===0?"today":t===1?"yesterday":t<7?"thisWeek":"older"}function u(n){return new Date(n.getFullYear(),n.getMonth(),n.getDate())}function D(n,r=new Date){const s={today:[],yesterday:[],thisWeek:[],older:[]};for(const d of n){const a=w(d.at,r);a&&s[a].push(d)}return s}const x=50;function F(){const n=h(i=>i.getActiveVault()),r=g(),[s,d]=l.useState(x),a=l.useMemo(()=>r.data?N(r.data):[],[r.data]),t=l.useMemo(()=>a.slice(0,s),[a,s]),c=l.useMemo(()=>D(t),[t]),o=a.length-t.length;return n?e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-5 md:mb-6",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Activity"}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Recent changes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Last 30 days, newest first. Deletions aren't tracked yet."})]}),r.isPending?e.jsx(T,{}):r.isError?e.jsx(B,{error:r.error}):a.length===0?e.jsx(S,{}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-8",children:v.map(i=>c[i].length>0?e.jsx(E,{title:k[i],events:c[i]},i):null)}),o>0?e.jsx("div",{className:"mt-8 flex justify-center",children:e.jsxs("button",{type:"button",onClick:()=>d(i=>i+x),className:"rounded-md border border-border bg-card px-4 py-2 text-sm text-fg-muted hover:text-accent",children:["Load more (",o," remaining)"]})}):null]})]}):e.jsx(f,{to:"/",replace:!0})}function E({title:n,events:r}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[n," (",r.length,")"]}),e.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card",children:r.map(s=>e.jsx("li",{children:e.jsxs(m,{to:`/n/${encodeURIComponent(s.noteId)}`,className:"block px-4 py-3 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(A,{kind:s.kind}),e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:s.noteName})]}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:b(s.at)})]}),s.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:s.preview}):null,s.tags&&s.tags.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:s.tags.map(d=>e.jsxs("span",{className:"rounded-md bg-border/40 px-1.5 py-0.5 text-xs text-fg-dim",children:["#",d]},d))}):null]})},s.id))})]})}function A({kind:n}){return n==="created"?e.jsx("span",{className:"shrink-0 rounded-md bg-accent/10 px-1.5 py-0.5 text-xs text-accent",children:"Created"}):e.jsx("span",{className:"shrink-0 rounded-md bg-border/40 px-1.5 py-0.5 text-xs text-fg-muted",children:"Edited"})}function S(){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-4 text-fg-muted",children:"No activity in the last 30 days."}),e.jsx(m,{to:"/capture",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Open capture"})]})}function T(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3,4].map(n=>e.jsx("div",{className:"h-16 animate-pulse rounded-md bg-border/30"},n))})}function B({error:n}){const r=n instanceof y;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:r?"Session expired":"Could not load activity"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:n.message}),r?e.jsx(m,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{F as Activity};
import{c as g,r as t,d as p,j as e,n as v,e as j}from"./index-D41hUtgX.js";function w(){const[f]=g(),u=f.get("url")??"",[r,c]=t.useState(u),[i,n]=t.useState(null),[o,d]=t.useState(!1),m=t.useRef(null),h=t.useRef(u.length>0),a=p();t.useEffect(()=>{var s;(s=m.current)==null||s.focus()},[]),t.useEffect(()=>{h.current||a.status==="found"&&a.origin&&r===""&&(c(a.origin),h.current=!0)},[a.status,a.origin,r]);async function b(s){s.preventDefault(),n(null);let x;try{x=v(r)}catch(l){n(l.message);return}d(!0);try{const{authorizeUrl:l}=await j(x);window.location.assign(l)}catch(l){n(l.message),d(!1)}}return e.jsxs("div",{className:"mx-auto max-w-xl px-6 py-16",children:[e.jsx("h1",{className:"mb-2 font-serif text-4xl tracking-tight",children:"Connect a vault"}),e.jsx("p",{className:"mb-8 text-fg-muted",children:"Paste your Parachute hub URL. You'll be taken to its consent page to authorize Parachute Notes."}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"vault-url",className:"mb-1.5 block text-sm font-medium text-fg",children:"Hub URL"}),e.jsx("input",{id:"vault-url",ref:m,type:"url",required:!0,placeholder:"http://localhost:1939",value:r,onChange:s=>c(s.target.value),disabled:o,className:"w-full rounded-md border border-border bg-card px-3 py-2 font-mono text-sm text-fg focus:border-accent focus:outline-none"}),e.jsxs("p",{className:"mt-1.5 text-xs text-fg-dim",children:["For a local install the hub lives at ",e.jsx("code",{children:"http://localhost:1939"}),". A standalone vault URL (e.g. ",e.jsx("code",{children:"https://host/vault/default"}),") also works — Notes will OAuth against whichever issuer answers."]})]}),i?e.jsx("div",{className:"rounded-md border border-red-400/30 bg-red-400/5 px-3 py-2 text-sm text-red-400",children:i}):null,e.jsx("button",{type:"submit",disabled:o||!r,className:"w-full rounded-md bg-accent px-4 py-2.5 text-sm font-medium text-white hover:bg-accent-hover disabled:cursor-not-allowed disabled:opacity-60",children:o?"Starting OAuth…":"Continue"})]})]})}export{w as AddVault};
import{u as k,c as E,a as A,r as f,j as e,N as K,L as d,V as S}from"./index-D41hUtgX.js";import{p as y,c as j,t as P,m as T,a as V,s as N,b as i,f as C}from"./dates-DfXc2iZW.js";const _=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],x=5;function B(){const a=k(t=>t.getActiveVault()),[o]=E(),l=o.get("month"),r=y(l)??y(j()),s=A(),h=P(),v=f.useMemo(()=>T(r.year,r.month),[r.year,r.month]),$=f.useMemo(()=>{const t=new Map;if(!s.data)return t;for(const n of s.data){const c=V(n.createdAt);c&&t.set(c,(t.get(c)??0)+1)}return t},[s.data]);if(!a)return e.jsx(K,{to:"/",replace:!0});const u=N(r.year,r.month,-1),p=N(r.year,r.month,1),b=`${u.year}-${i(u.month)}`,g=`${p.year}-${i(p.month)}`,M=j(),w=`${r.year}-${i(r.month)}`===M;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Calendar"}),e.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:C(r.year,r.month)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(d,{to:`/calendar?month=${b}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous month",children:["← ",b]}),w?null:e.jsx(d,{to:"/calendar",className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"This month"}),e.jsxs(d,{to:`/calendar?month=${g}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next month",children:[g," →"]}),e.jsx(d,{to:`/today?date=${h}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"})]})]}),s.isError?e.jsx(L,{error:s.error}):e.jsxs("div",{className:"rounded-md border border-border bg-card","aria-busy":s.isPending,children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-border text-xs uppercase tracking-wider text-fg-dim",children:_.map(t=>e.jsx("div",{className:"px-2 py-2 text-center",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7",children:v.map(t=>{const n=`${t.getFullYear()}-${i(t.getMonth()+1)}-${i(t.getDate())}`,c=t.getMonth()+1===r.month,m=$.get(n)??0,D=n===h;return e.jsxs(d,{to:`/today?date=${n}`,className:`flex min-h-20 flex-col border-b border-r border-border p-1.5 text-xs hover:bg-bg/60 focus:bg-bg/60 focus:outline-none ${c?"":"opacity-40"}`,"aria-label":`${n} — ${m} notes`,children:[e.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full ${D?"bg-accent text-white":"text-fg"}`,children:t.getDate()}),m>0?e.jsx(F,{count:m}):e.jsx("span",{className:"sr-only",children:"no notes"})]},n)})})]}),e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:"Each dot is a note created on that day. Click any day to open /today."})]})}function F({count:a}){const o=Math.min(a,x),l=a>x?a-x:0;return e.jsxs("span",{className:"flex flex-wrap items-center gap-0.5",children:[Array.from({length:o}).map((r,s)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-hidden":"true"},s)),l>0?e.jsxs("span",{className:"ml-0.5 text-[10px] text-fg-dim",children:["+",l]}):null]})}function L({error:a}){const o=a instanceof S;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:o?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),o?e.jsx(d,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{B as Calendar};
import{u as Y,f as Z,g as G,h as J,r as u,i as F,k as Q,l as E,m as X,j as i,N as ee,T as te,o as H}from"./index-D41hUtgX.js";const re=["audio/webm;codecs=opus","audio/mp4","audio/ogg;codecs=opus"];function ne(e=re){if(typeof MediaRecorder>"u")return null;for(const r of e)if(MediaRecorder.isTypeSupported(r))return r;return null}function ae(e){return e.startsWith("audio/webm")?"webm":e.startsWith("audio/mp4")?"m4a":e.startsWith("audio/ogg")?"ogg":e.startsWith("audio/wav")?"wav":"bin"}function se(e){const r=e.now??(()=>Date.now()),s=e.MediaRecorderCtor??MediaRecorder,a=new s(e.stream,{mimeType:e.mimeType}),d=[];let n="idle",l=0,w=0;a.ondataavailable=m=>{m.data&&m.data.size>0&&d.push(m.data)};const h=()=>{for(const m of e.stream.getTracks())m.stop()};return{get state(){return n},get mimeType(){return e.mimeType},start(){if(n!=="idle")throw new Error(`Cannot start from ${n}`);a.start(),l=r(),n="recording"},pause(){n==="recording"&&(a.pause(),w+=r()-l,n="paused")},resume(){n==="paused"&&(a.resume(),l=r(),n="recording")},async stop(){if(n==="idle"||n==="stopped")throw new Error(`Cannot stop from ${n}`);n==="recording"&&(w+=r()-l);const m=new Promise(N=>{a.onstop=async()=>{const R=await ie(d);N({data:R,mimeType:e.mimeType,durationMs:w})}});return a.stop(),n="stopped",h(),m},cancel(){if(n==="recording"||n==="paused")try{a.stop()}catch{}n="stopped",d.length=0,h()}}}async function oe(e){const r=e;return typeof r.arrayBuffer=="function"?r.arrayBuffer():new Promise((s,a)=>{const d=new FileReader;d.onload=()=>s(d.result),d.onerror=()=>a(d.error??new Error("FileReader error")),d.readAsArrayBuffer(e)})}async function ie(e){if(e.length===0)return new ArrayBuffer(0);const r=await Promise.all(e.map(n=>oe(n))),s=r.reduce((n,l)=>n+l.byteLength,0),a=new Uint8Array(s);let d=0;for(const n of r)a.set(new Uint8Array(n),d),d+=n.byteLength;return a.buffer}async function ce(){var e;if(typeof navigator>"u"||!((e=navigator.mediaDevices)!=null&&e.getUserMedia)){const r=new Error("Microphone is not available in this browser.");throw r.kind="unavailable",r}try{return await navigator.mediaDevices.getUserMedia({audio:!0})}catch(r){const s=new Error(r instanceof Error?r.message:"Microphone permission denied."),a=r instanceof DOMException?r.name:"";throw s.kind=a==="NotFoundError"||a==="OverconstrainedError"?"no-device":"permission-denied",s}}function de(e,r=new Date){return`memo-${r.toISOString().replace(/[:.]/g,"-").replace(/Z$/,"")}.${ae(e)}`}function ue(e=new Date){const r=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0"),d=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return`Memos/${r}/${s}-${a}/${d}-${n}-${l}`}const le=/(?:^|\s)#([a-zA-Z][\w-]*)/g;function _(e){const r=new Set;for(const s of e.matchAll(le)){const a=H(s[1]??"");a&&r.add(a)}return[...r]}function q(e){const r=Math.floor(e/1e3),s=Math.floor(r/60),a=r%60;return`${String(s).padStart(2,"0")}:${String(a).padStart(2,"0")}`}function fe(){const e=Y(t=>t.getActiveVault()),r=Z(t=>t.push),{db:s,blobStore:a,engine:d}=G(),{roles:n}=J((e==null?void 0:e.id)??null),[l,w]=u.useState(""),[h,m]=u.useState([]),[N,R]=u.useState(""),[c,g]=u.useState({kind:"idle"}),[z,C]=u.useState(0),I=u.useRef(null),x=u.useRef(null),$=u.useRef(null),A=u.useRef(!1);u.useEffect(()=>{if(c.kind!=="recording")return;const t=setInterval(()=>C(Date.now()-c.startedAt),250);return()=>clearInterval(t)},[c]),u.useEffect(()=>()=>{x.current&&URL.revokeObjectURL(x.current)},[]),u.useEffect(()=>{var t;(t=$.current)==null||t.focus()},[]);const K=u.useCallback(async()=>{if(!(c.kind==="recording"||c.kind==="requesting")){g({kind:"requesting"});try{const t=ne();if(!t){g({kind:"denied",message:"This browser can't record audio in a format we can save."});return}const o=await ce(),p=se({stream:o,mimeType:t});I.current=p,p.start(),C(0),g({kind:"recording",startedAt:Date.now()})}catch(t){const o=t,p=o.kind==="permission-denied"?"Microphone access was denied. Update your browser's site settings to record.":o.kind==="no-device"?"No microphone was found on this device.":o instanceof Error?o.message:"Microphone is not available in this browser.";g({kind:"denied",message:p})}}},[c]),B=u.useCallback(async()=>{const t=I.current;if(!(!t||c.kind!=="recording"))try{const o=await t.stop();I.current=null;const p=new Blob([o.data],{type:o.mimeType}),b=URL.createObjectURL(p);x.current&&URL.revokeObjectURL(x.current),x.current=b,g({kind:"have-audio",data:o.data,mimeType:o.mimeType,url:b,durationMs:o.durationMs})}catch(o){r(o instanceof Error?`Recording failed: ${o.message}`:"Recording failed.","error"),g({kind:"idle"})}},[c,r]);u.useEffect(()=>{if(c.kind!=="recording")return;const t=()=>{B()};return window.addEventListener("pointerup",t),window.addEventListener("pointercancel",t),()=>{window.removeEventListener("pointerup",t),window.removeEventListener("pointercancel",t)}},[c,B]);const D=u.useCallback(()=>{x.current&&(URL.revokeObjectURL(x.current),x.current=null),g({kind:"idle"}),C(0)},[]),P=u.useCallback(()=>{var t;w(""),m([]),R(""),D(),(t=$.current)==null||t.focus()},[D]),T=c.kind==="have-audio",y=l.trim().length>0,L=(y||T)&&c.kind!=="saving",U=u.useCallback(async()=>{if(!L||!s||!e)return;if(T&&!a){r("Sync queue not ready — try again in a moment.","error");return}const t=c.kind==="have-audio"?c:null;A.current=!0,g({kind:"saving"});const o=h.filter(f=>f.length>0),p=_(l),b=[];y&&b.push(n.captureText),t&&b.push(n.captureVoice);const v=Array.from(new Set([...b,...o,...p].filter(f=>f.length>0))),M=F();try{if(t){const f=new Date,S=de(t.mimeType,f),k=Q(),j=y?`${l.trim()}
_Transcript pending._
![[${S}]]
`:`_Transcript pending._
![[${S}]]
`,W=y?void 0:ue(f);if(!a)throw new Error("blob store missing");await a.put(k,t.data,t.mimeType,e.id),await E(s,{kind:"create-note",localId:M,payload:{content:j,...W?{path:W}:{},...v.length?{tags:v}:{}}},{vaultId:e.id}),await E(s,{kind:"upload-attachment",blobId:k,filename:S,mimeType:t.mimeType},{vaultId:e.id}),await E(s,{kind:"link-attachment",noteId:M,pathRef:X(k),mimeType:t.mimeType,transcribe:!0},{vaultId:e.id})}else await E(s,{kind:"create-note",localId:M,payload:{content:l,...v.length?{tags:v}:{}}},{vaultId:e.id});d==null||d.runOnce(),r(t?"Captured — syncing audio.":"Captured.","success"),P()}catch(f){r(f instanceof Error?`Capture failed: ${f.message}`:"Capture failed.","error"),A.current=!1,g(t?{kind:"have-audio",data:t.data,mimeType:t.mimeType,url:t.url,durationMs:t.durationMs}:{kind:"idle"})}},[L,s,e,a,c,T,y,h,l,n.captureText,n.captureVoice,d,r,P]),V=u.useCallback(t=>{(t.metaKey||t.ctrlKey)&&t.key==="Enter"&&(t.preventDefault(),U())},[U]),O=u.useRef({db:s,activeVaultId:(e==null?void 0:e.id)??null,content:l,tags:h,roles:n});return O.current={db:s,activeVaultId:(e==null?void 0:e.id)??null,content:l,tags:h,roles:n},u.useEffect(()=>()=>{if(A.current)return;const{db:t,activeVaultId:o,content:p,tags:b,roles:v}=O.current;if(!p.trim()||!t||!o)return;const f=b.filter(j=>j.length>0),S=_(p),k=Array.from(new Set([v.captureText,...f,...S].filter(j=>j.length>0)));E(t,{kind:"create-note",localId:F(),payload:{content:p,...k.length?{tags:k}:{}}},{vaultId:o})},[]),e?i.jsxs("div",{className:"mx-auto max-w-2xl px-4 py-5 md:px-6 md:py-8",children:[i.jsxs("header",{className:"mb-5",children:[i.jsx("h1",{className:"font-serif text-2xl text-fg md:text-3xl",children:"Capture"}),i.jsxs("p",{className:"mt-1 text-xs text-fg-dim",children:["Type a thought, hold the mic to record, or both."," ",i.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"⌘"}),i.jsx("kbd",{className:"rounded bg-bg/60 px-1",children:"↵"})," to send."]})]}),i.jsxs("section",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-5 md:p-6",children:[i.jsx("textarea",{ref:$,value:l,onChange:t=>w(t.target.value),onKeyDown:V,placeholder:"What are you thinking?","aria-label":"Capture content",rows:8,disabled:c.kind==="saving",className:"min-h-[30vh] w-full resize-y rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg placeholder:text-fg-dim focus:border-accent focus:outline-none disabled:opacity-60"}),c.kind==="have-audio"?i.jsxs("div",{className:"flex flex-col gap-2 rounded-md border border-accent/30 bg-accent/5 p-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("span",{className:"text-sm text-fg-muted",children:["🎙 Recorded ",q(c.durationMs)]}),i.jsx("button",{type:"button",onClick:D,className:"text-xs text-fg-dim hover:text-red-400",children:"Discard"})]}),i.jsx("audio",{controls:!0,src:c.url,className:"w-full",children:i.jsx("track",{kind:"captions"})}),i.jsx("p",{className:"text-xs text-fg-dim",children:"Transcript will be appended once your vault processes it."})]}):null,c.kind==="denied"?i.jsx("p",{className:"rounded-md border border-red-500/30 bg-red-500/5 px-3 py-2 text-xs text-red-400",children:c.message}):null,i.jsx(te,{tags:h,input:N,onInputChange:R,onAdd:t=>{const o=H(t);!o||h.includes(o)||(m(p=>[...p,o]),R(""))},onRemove:t=>m(o=>o.filter(p=>p!==t))}),i.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2",children:[i.jsx(pe,{phase:c,elapsedMs:z,onPointerDown:()=>void K()}),i.jsxs("div",{className:"flex flex-col items-end gap-1",children:[i.jsx("button",{type:"button",onClick:()=>void U(),disabled:!L,className:"min-h-11 rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:c.kind==="saving"?"Saving…":"Capture"}),i.jsx("span",{className:"text-[11px] text-fg-dim",children:T&&y?"Will save as a note with audio attached.":T?"Will save as a voice memo.":y?"Will save as a text note.":"Type or record to capture."})]})]})]})]}):i.jsx(ee,{to:"/",replace:!0})}function pe({phase:e,elapsedMs:r,onPointerDown:s}){const a=e.kind==="recording",d=e.kind==="requesting",n=a?`Recording — release to stop (${q(r)})`:d?"Requesting microphone…":"Hold to record";return i.jsxs("button",{type:"button",onPointerDown:l=>{l.preventDefault(),s()},"aria-label":n,"aria-pressed":a,disabled:e.kind==="saving",className:`flex min-h-11 items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition select-none ${a?"border-red-500/40 bg-red-500/10 text-red-400":"border-accent/30 bg-accent/10 text-accent hover:bg-accent/15"} disabled:opacity-40`,children:[i.jsx("span",{"aria-hidden":"true",className:a?"animate-pulse":"",children:"🎙"}),i.jsx("span",{children:a?`Rec ${q(r)}`:d?"Requesting…":"Hold to record"})]})}export{fe as Capture,_ as extractHashtags};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import{r as d,j as e,f as T,p as V,V as C,q as _,s as z,u as O,t as q,N as K,L as R,v as W,w as Y,x as H,b as D,T as Z,o as G}from"./index-D41hUtgX.js";import{u as J,A as Q,C as X,a as ee,b as te}from"./useAttachmentUploader-CafTAVak.js";import{P as se,D as ne}from"./PinArchiveButtons-Cjsu8ZBM.js";import{b as re,M as ae}from"./MarkdownView-DksAP33z.js";const oe=250;function de({noteId:t,attachment:n}){const[l,a]=d.useState(!1),o=ce(n);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":`Remove attachment ${o}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),l?e.jsx(ie,{noteId:t,attachment:n,label:o,onClose:()=>a(!1)}):null]})}function ie({noteId:t,attachment:n,label:l,onClose:a}){const o=T(i=>i.push),m=V(),[s,h]=d.useState(!1),[w,p]=d.useState(null),N=d.useRef(null);d.useEffect(()=>{const i=setTimeout(()=>h(!0),oe);return()=>clearTimeout(i)},[]),d.useEffect(()=>{var i;(i=N.current)==null||i.focus()},[]),d.useEffect(()=>{const i=g=>{g.key==="Escape"&&a()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[a]);const b=d.useCallback(()=>{!s||m.isPending||(p(null),m.mutate({noteId:t,attachmentId:n.id},{onSuccess:()=>{o(`Removed ${l}`,"success"),a()},onError:i=>{if(i instanceof C){p("Session expired. Reconnect to remove attachments.");return}if(i instanceof _){o(`Already removed ${l}`,"info"),a();return}p(i instanceof Error?i.message:"Remove failed")}}))},[s,n.id,l,m,t,a,o]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:i=>{i.target===i.currentTarget&&a()},children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[e.jsx("h2",{id:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:l})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),w?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:w}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{ref:N,type:"button",onClick:a,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:b,disabled:!s||m.isPending,className:"min-h-11 rounded-md bg-red-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-600 disabled:opacity-40",children:m.isPending?"Removing…":"Remove"})]})]})})}function ce(t){if(t.filename)return t.filename;if(t.path){const n=t.path.split("/").pop();return n||t.path}return t.id}function we(){const{id:t}=z(),n=t?decodeURIComponent(t):void 0,l=O(o=>o.getActiveVault()),a=q(n);return l?e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-5 md:px-6 md:py-8",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(R,{to:n?`/n/${encodeURIComponent(n)}`:"/",className:"hover:text-accent",children:"← Back to note"})}),a.isPending?e.jsx(xe,{}):a.isError?e.jsx(fe,{error:a.error}):a.data?e.jsx(le,{note:a.data}):e.jsx(he,{id:n??""})]}):e.jsx(K,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function le({note:t}){const n=W(),l=T(r=>r.push),a=d.useMemo(()=>re(t),[t]),[o,m]=d.useState(()=>S(t)),[s,h]=d.useState(()=>S(t)),[w,p]=d.useState(""),[N,b]=d.useState(null),[i,g]=d.useState(null),[y,L]=d.useState("edit"),v=Y(t.id),k=d.useRef(t),E=d.useRef(null),j=J({noteId:t.id,onInsert:r=>{E.current?E.current.insertAtCursor(r):h(c=>({...c,content:`${c.content}${r}`}))},onLinked:()=>{l("Attachment added","success")},onError:r=>l(r,"error")});d.useEffect(()=>{k.current=t},[t]);const u=s.content!==o.content||s.path!==o.path||!pe(s.tags,o.tags),A=d.useCallback(()=>{if(!u||v.isPending)return;const r={};s.content!==o.content&&(r.content=s.content),s.path!==o.path&&(r.path=s.path);const c=be(o.tags,s.tags);(c.add.length||c.remove.length)&&(r.tags=c);const f=k.current.updatedAt??k.current.createdAt;f&&(r.if_updated_at=f),g(null),b(null),v.mutate(r,{onSuccess:x=>{m(S(x)),h(S(x)),k.current=x,x.id!==t.id&&n(`/n/${encodeURIComponent(x.id)}/edit`,{replace:!0})},onError:x=>{x instanceof H?b(x):x instanceof C?g("Session expired. Reconnect to save."):g(x instanceof Error?x.message:"Save failed")}})},[o,s,u,v,n,t.id]),M=d.useCallback(()=>{u&&confirm("Discard all edits and revert to last saved version?")&&(h(o),b(null),g(null))},[o,u]),P=d.useCallback(()=>{u&&!confirm("Discard unsaved changes?")||n(`/n/${encodeURIComponent(t.id)}`)},[u,n,t.id]);d.useEffect(()=>{if(!u)return;const r=c=>{c.preventDefault(),c.returnValue=""};return window.addEventListener("beforeunload",r),()=>window.removeEventListener("beforeunload",r)},[u]);const $=s.path!==o.path,B=r=>{const c=G(r);c&&(s.tags.includes(c)||(h(f=>({...f,tags:[...f.tags,c]})),p("")))},U=r=>{h(c=>({...c,tags:c.tags.filter(f=>f!==r)}))},F=s.content;return e.jsxs("article",{children:[e.jsxs("header",{className:"mb-4 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Editing"}),u?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",D(t.updatedAt)]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{note:t}),e.jsx(ne,{note:t}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:M,disabled:!u||v.isPending,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:"Revert"}),e.jsx("button",{type:"button",onClick:P,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:A,disabled:!u||v.isPending,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",title:"Save (⌘S)",children:v.isPending?"Saving…":"Save"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsx(Z,{tags:s.tags,input:w,onInputChange:p,onAdd:B,onRemove:U}),e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Path"}),e.jsx("input",{type:"text",value:s.path,onChange:r=>h(c=>({...c,path:r.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note path",placeholder:"(no path)"})]}),$?e.jsx("p",{className:"text-xs text-accent",children:"Renaming moves the note — its id may change."}):null]})]}),N?e.jsx(ue,{conflict:N,onReload:()=>{window.location.reload()},onDismiss:()=>b(null)}):null,i?e.jsx("div",{className:"mb-4 rounded-md border border-red-500/30 bg-red-500/5 p-3 text-sm text-red-400",children:i}):null,e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-md border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(r=>e.jsx("button",{type:"button",role:"tab","aria-selected":y===r,onClick:()=>L(r),className:`rounded px-3 py-1.5 capitalize ${y===r?"bg-accent text-white":"text-fg-muted hover:text-accent"}`,children:r},r))}),e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2",children:[e.jsx(Q,{onDropFiles:j.start,className:`min-w-0 rounded-md border border-border bg-card ${y==="edit"?"":"hidden lg:block"}`,hint:I,children:e.jsx(X,{ref:E,value:s.content,onChange:r=>h(c=>({...c,content:r})),onSave:A,onCancel:P,onPasteFile:r=>(j.start(r),!0)})}),e.jsx("div",{className:`min-w-0 overflow-auto rounded-md border border-border bg-card p-4 ${y==="preview"?"":"hidden lg:block"}`,children:e.jsx(ae,{content:F,resolve:a})})]}),e.jsx(me,{noteId:t.id,attachments:t.attachments??[],uploads:j.uploads,onPickFiles:j.start,onCancel:j.cancel,onDismiss:j.dismiss})]})}const I=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"underline",children:"PDF + mp4 coming"})]});function me({noteId:t,attachments:n,uploads:l,onPickFiles:a,onCancel:o,onDismiss:m}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-lg",children:"Attachments"}),e.jsx(ee,{onPickFiles:a})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",I,"."]}),e.jsx(te,{uploads:l,onCancel:o,onDismiss:m}),n.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:n.map(s=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:s.path??s.id,children:s.filename??s.path??s.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.mimeType?e.jsx("span",{className:"text-fg-dim",children:s.mimeType}):null,e.jsx(de,{noteId:t,attachment:s})]})]},s.id))}):null]})}function ue({conflict:t,onReload:n,onDismiss:l}){return e.jsxs("div",{className:"mb-4 rounded-md border border-amber-500/40 bg-amber-500/10 p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-amber-500",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${D(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent-hover",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:l,className:"rounded-md border border-border px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Keep editing"})]})]})}function xe(){return e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"animate-pulse rounded-md border border-border bg-card"}),e.jsx("div",{className:"animate-pulse rounded-md border border-border bg-card"})]})}function he({id:t}){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-2 font-serif text-xl",children:"Note not found"}),e.jsxs("p",{className:"mb-4 text-sm text-fg-muted",children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),e.jsx(R,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to all notes"})]})}function fe({error:t}){const n=t instanceof C;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:n?"Session expired":"Could not load note"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:t.message}),n?e.jsx(R,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function pe(t,n){if(t.length!==n.length)return!1;const l=new Set(t);for(const a of n)if(!l.has(a))return!1;return!0}function be(t,n){const l=new Set(t),a=new Set(n),o=n.filter(s=>!l.has(s)),m=t.filter(s=>!a.has(s));return{add:o,remove:m}}export{we as NoteEditor};
import{u as P,v as T,f as I,y as R,z as V,r as n,j as e,N as L,V as M,L as $,T as F,o as _}from"./index-D41hUtgX.js";import{u as U,A as z,C as B,a as O,b as W}from"./useAttachmentUploader-CafTAVak.js";import{b as Y,M as Z}from"./MarkdownView-DksAP33z.js";const q={content:"",path:"",tags:[],summary:""};function K(){const w=P(t=>t.getActiveVault()),l=T(),d=I(t=>t.push),c=R(),f=V(),[a,o]=n.useState(q),[C,b]=n.useState(""),[v,x]=n.useState(null),[m,k]=n.useState([]),p=n.useRef(null),i=U({noteId:null,onInsert:t=>{p.current?p.current.insertAtCursor(t):o(s=>({...s,content:`${s.content}${t}`}))},onStaged:t=>k(s=>[...s,t]),onError:t=>d(t,"error")});if(!w)return e.jsx(L,{to:"/",replace:!0});const u=a.content.length>0||a.path.length>0||a.tags.length>0||a.summary.length>0,h=a.content.trim().length>0&&a.path.trim().length>0,j=n.useCallback(()=>{if(!h||c.isPending)return;const t={content:a.content,path:a.path.trim()};a.tags.length&&(t.tags=a.tags);const s=a.summary.trim();s&&(t.metadata={summary:s}),x(null),c.mutate(t,{onSuccess:async r=>{for(const g of m)try{await f.mutateAsync({noteId:r.id,path:g.path,mimeType:g.mimeType})}catch(y){const D=y instanceof Error?y.message:"Link failed";d(`Failed to attach ${g.filename}: ${D}`,"error")}d(`Created ${r.path??r.id}`,"success"),l(`/n/${encodeURIComponent(r.id)}`)},onError:r=>{r instanceof M?x("Session expired. Reconnect to save."):x(r instanceof Error?`${r.message} — if the path is taken, try a different one.`:"Create failed")}})},[a,h,f,c,l,d,m]),N=n.useCallback(()=>{u&&!confirm("Discard this draft?")||l("/")},[u,l]);n.useEffect(()=>{if(!u)return;const t=s=>{s.preventDefault(),s.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[u]);const A=t=>{const s=_(t);!s||a.tags.includes(s)||(o(r=>({...r,tags:[...r.tags,s]})),b(""))},E=t=>{o(s=>({...s,tags:s.tags.filter(r=>r!==t)}))},S=Y({id:"__new__",createdAt:new Date().toISOString()});return e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-5 md:px-6 md:py-8",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx($,{to:"/",className:"hover:text-accent",children:"← All notes"})}),e.jsxs("article",{children:[e.jsxs("header",{className:"mb-4 border-b border-border pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"flex items-center gap-2 text-sm",children:e.jsx("span",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"New note"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:N,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:j,disabled:!h||c.isPending,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",title:"Create (⌘S)",children:c.isPending?"Creating…":"Create"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Path"}),e.jsx("input",{type:"text",value:a.path,onChange:t=>o(s=>({...s,path:t.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 font-mono text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note path",placeholder:"e.g. Projects/README"})]}),e.jsxs("label",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("span",{className:"shrink-0 text-xs uppercase tracking-wider text-fg-dim",children:"Summary"}),e.jsx("input",{type:"text",value:a.summary,onChange:t=>o(s=>({...s,summary:t.target.value})),className:"flex-1 rounded-md border border-border bg-card px-2.5 py-1 text-sm text-fg focus:border-accent focus:outline-none","aria-label":"Note summary",placeholder:"(optional one-line description)"})]}),e.jsx(F,{tags:a.tags,input:C,onInputChange:b,onAdd:A,onRemove:E})]})]}),v?e.jsx("div",{role:"alert",className:"mb-4 rounded-md border border-red-500/30 bg-red-500/5 p-3 text-sm text-red-400",children:v}):null,e.jsxs("div",{className:"grid min-h-[60vh] gap-4 lg:grid-cols-2",children:[e.jsx(z,{onDropFiles:i.start,className:"min-w-0 rounded-md border border-border bg-card",hint:"Images, audio, webm video",children:e.jsx(B,{ref:p,value:a.content,onChange:t=>o(s=>({...s,content:t})),onSave:j,onCancel:N,onPasteFile:t=>(i.start(t),!0)})}),e.jsx("div",{className:"min-w-0 overflow-auto rounded-md border border-border bg-card p-4",children:a.content.trim()?e.jsx(Z,{content:a.content,resolve:S}):e.jsx("p",{className:"text-sm text-fg-dim",children:"Preview appears here as you type."})})]}),e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-lg",children:"Attachments"}),e.jsx(O,{onPickFiles:i.start})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Attachments link to the note when you save. Max 100 MB each. Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"underline",children:"PDF + mp4 coming"}),"."]}),e.jsx(W,{uploads:i.uploads,onCancel:i.cancel,onDismiss:i.dismiss}),m.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:m.map(t=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded border border-border bg-card/50 px-3 py-1.5 font-mono text-xs text-fg-muted",children:[e.jsx("span",{className:"truncate",children:t.filename}),e.jsx("span",{className:"shrink-0 text-fg-dim",children:"staged"})]},t.path))}):null]})]})]})}export{K as NoteNew};
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-CY0IItb_.js","assets/index-D41hUtgX.js","assets/index-CSwzwMDF.css"])))=>i.map(i=>d[i]);
import{r as c,C as v,j as t,v as k,_ as y,s as I,u as A,t as R,D as C,N as E,L as p,V as L,b as j}from"./index-D41hUtgX.js";import{P as D,D as M}from"./PinArchiveButtons-Cjsu8ZBM.js";import{b as _,M as T}from"./MarkdownView-DksAP33z.js";const S=1,U=3,$=1;function B(e,s){const a=new Map,n=new Map;for(const d of s.values())for(const r of d.links??[]){if(r.sourceId===r.targetId||!s.has(r.sourceId)||!s.has(r.targetId))continue;const o=`${r.sourceId}|${r.targetId}|${r.relationship}`;a.has(o)||(a.set(o,{source:r.sourceId,target:r.targetId,relationship:r.relationship}),n.set(r.sourceId,(n.get(r.sourceId)??0)+1),n.set(r.targetId,(n.get(r.targetId)??0)+1))}return{nodes:[...s.values()].map(d=>{var r;return{id:d.id,path:d.path,tags:d.tags,summary:typeof((r=d.metadata)==null?void 0:r.summary)=="string"?d.metadata.summary:void 0,isAnchor:d.id===e,linkCount:n.get(d.id)??0}}),edges:[...a.values()]}}async function P(e,s,a,n){const i=new Map;i.set(e.id,e);let d=[e];for(let r=1;r<=s;r++){const o=new Set;for(const u of d)for(const x of u.links??[]){const h=x.sourceId===u.id?x.targetId:x.sourceId;h!==u.id&&(i.has(h)||o.add(h))}if(o.size===0)break;const l=await Promise.all([...o].map(u=>a(u).catch(()=>null)));if(n!=null&&n.cancelled)return i;const m=[];for(const u of l)u&&!i.has(u.id)&&(i.set(u.id,u),m.push(u));d=m}return i}function V(e,s,a){const[n,i]=c.useState(null),[d,r]=c.useState(!1);return c.useEffect(()=>{if(!e||!s){i(null),r(!1);return}const o={cancelled:!1};return r(!0),P(s,a,l=>e.getNote(l,{includeLinks:!0}),o).then(l=>{o.cancelled||(i(B(s.id,l)),r(!1))}).catch(()=>{o.cancelled||r(!1)}),()=>{o.cancelled=!0}},[e,s,a]),{data:n,isLoading:d}}const F=c.lazy(()=>y(()=>import("./react-force-graph-2d-CY0IItb_.js"),__vite__mapDeps([0,1,2])));function z({anchor:e}){const[s,a]=c.useState(!0),[n,i]=c.useState($),d=v(),{data:r,isLoading:o}=V(d,s?e:void 0,n);return t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>a(l=>!l),"aria-expanded":s,className:"font-serif text-xl text-fg hover:text-accent",children:[s?"▾":"▸"," Neighborhood"]}),s&&r?t.jsxs("span",{className:"text-xs text-fg-dim",children:[r.nodes.length," ",r.nodes.length===1?"note":"notes"]}):null]}),s?t.jsx(G,{depth:n,onChange:i}):null]}),s?t.jsx(O,{data:r,isLoading:o}):null]})}function G({depth:e,onChange:s}){const a=[];for(let n=S;n<=U;n++)a.push(n);return t.jsxs("fieldset",{className:"flex items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Hops"}),a.map(n=>t.jsx("button",{type:"button","aria-pressed":n===e,onClick:()=>s(n),className:n===e?"rounded border border-accent bg-accent/10 px-2 py-0.5 text-accent":"rounded border border-border bg-card px-2 py-0.5 hover:text-accent",children:n},n))]})}function O({data:e,isLoading:s}){return!e&&s?t.jsx(w,{}):e?e.nodes.length<=1?t.jsx("div",{className:"rounded-md border border-border bg-card p-6 text-center text-sm text-fg-dim",children:"This note has no neighbors yet."}):t.jsx(H,{data:e}):null}function w(){return t.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function H({data:e}){const s=k(),a=c.useRef(null),[n,i]=c.useState({w:600,h:384});c.useEffect(()=>{const r=a.current;if(!r)return;const o=()=>{const m=r.getBoundingClientRect();i({w:Math.max(320,Math.floor(m.width)),h:384})};o();const l=new ResizeObserver(o);return l.observe(r),()=>l.disconnect()},[]);const d=c.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]);return t.jsx("div",{ref:a,"data-testid":"neighborhood-graph-canvas",className:"overflow-hidden rounded-md border border-border bg-card",children:t.jsx(c.Suspense,{fallback:t.jsx(w,{}),children:t.jsx(F,{graphData:d,width:n.w,height:n.h,nodeLabel:r=>K(r),nodeVal:r=>{const o=r;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:r=>r.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:r=>{s(`/n/${encodeURIComponent(r.id)}`)}})})})}function K(e){const s=[e.path??e.id];return e.tags&&e.tags.length>0&&s.push(`tags: ${e.tags.join(", ")}`),e.summary&&s.push(e.summary),s.join(`
`)}const W="_Transcript pending._",X="_Transcription unavailable._";function q({content:e}){const s=e.includes(W),a=!s&&e.includes(X);return s?t.jsxs("output",{"aria-live":"polite",className:"mb-4 inline-flex items-center gap-2 rounded-md border border-sky-500/30 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-300",children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 animate-pulse rounded-full bg-sky-400"}),"Transcribing…"]}):a?t.jsx("output",{className:"mb-4 inline-flex items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-1.5 text-xs text-amber-200",children:"Transcription unavailable — open the audio below and add a note by hand."}):null}function ce(){const{id:e}=I(),s=e?decodeURIComponent(e):void 0,a=A(i=>i.getActiveVault()),n=R(s);return c.useEffect(()=>{a&&s&&C(a.id,s)},[a,s]),a?t.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-6 md:py-10",children:[t.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:t.jsx(p,{to:"/",className:"hover:text-accent",children:"← All notes"})}),n.isPending?t.jsx(ne,{}):n.isError?t.jsx(oe,{error:n.error}):n.data?t.jsx(J,{note:n.data}):t.jsx(ae,{id:s??""})]}):t.jsx(E,{to:"/",replace:!0})}function J({note:e}){var r;const s=c.useMemo(()=>_(e),[e]),a=e.path??e.id,n=typeof((r=e.metadata)==null?void 0:r.summary)=="string"?e.metadata.summary:null,i=c.useMemo(()=>(e.links??[]).filter(o=>o.targetId===e.id&&o.sourceId!==e.id&&o.sourceNote),[e]),d=c.useMemo(()=>{const o=new Set,l=[];for(const m of e.links??[])m.sourceId!==e.id||m.targetId===e.id||m.targetNote&&(o.has(m.targetId)||(o.add(m.targetId),l.push(m)));return l},[e]);return t.jsxs("article",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("header",{className:"mb-6 border-b border-border pb-4",children:[t.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:e.path?Q(e.path):e.id}),e.tags&&e.tags.length>0?t.jsx(Z,{tags:e.tags}):null,t.jsx("p",{className:"mt-2 font-mono text-xs text-fg-dim break-all",children:a}),n?t.jsx("p",{className:"mt-3 text-fg-muted",children:n}):null,t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[t.jsx(p,{to:`/n/${encodeURIComponent(e.id)}/edit`,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent",children:"Edit"}),t.jsx(D,{note:e,keyboard:!0}),t.jsx(M,{note:e})]})]}),t.jsx(q,{content:e.content??""}),t.jsx(T,{content:e.content??"",resolve:s}),e.attachments&&e.attachments.length>0?t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsx("h2",{className:"mb-3 font-serif text-xl",children:"Attachments"}),t.jsx("div",{className:"space-y-6",children:e.attachments.map(o=>t.jsx(ee,{attachment:o},o.id))})]}):null,t.jsx(z,{anchor:e})]}),t.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[t.jsx(Y,{note:e}),d.length>0?t.jsx(N,{title:"Outbound",links:d,peer:"target"}):null,i.length>0?t.jsx(N,{title:"Inbound",links:i,peer:"source"}):null]})]})}function Q(e){return(e.split("/").pop()??e).replace(/\.md$/i,"")}function Y({note:e}){const s=e.createdAt,a=e.updatedAt,n=Object.entries(e.metadata??{}).filter(([i])=>i!=="summary");return t.jsxs("section",{className:"rounded-md border border-border bg-card p-4",children:[t.jsx("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Metadata"}),t.jsxs("dl",{className:"space-y-1.5 text-sm",children:[e.path?t.jsx(f,{label:"Path",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.path})}):null,t.jsx(f,{label:"ID",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.id})}),t.jsx(f,{label:"Created",value:t.jsx("time",{title:s,children:j(s)})}),a?t.jsx(f,{label:"Updated",value:t.jsx("time",{title:a,children:j(a)})}):null,n.map(([i,d])=>t.jsx(f,{label:i,value:t.jsx("span",{className:"break-all text-fg-muted",children:String(d)})},i))]})]})}function f({label:e,value:s}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("dt",{className:"text-xs uppercase tracking-wider text-fg-dim",children:e}),t.jsx("dd",{children:s})]})}function Z({tags:e}){return t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5","aria-label":"Tags",children:e.map(s=>t.jsxs(p,{to:`/?tag=${encodeURIComponent(s)}`,className:"max-w-full break-all rounded-full border border-accent/40 bg-accent/10 px-2.5 py-0.5 text-xs font-medium text-accent hover:border-accent hover:bg-accent/20",children:["#",s]},s))})}function N({title:e,links:s,peer:a}){return t.jsxs("section",{className:"rounded-md border border-border bg-card p-4",children:[t.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[e," (",s.length,")"]}),t.jsx("ul",{className:"space-y-1.5",children:s.map(n=>{var o;const i=a==="source"?n.sourceNote:n.targetNote;if(!i)return null;const d=i.path??i.id,r=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return t.jsx("li",{children:t.jsxs(p,{to:`/n/${encodeURIComponent(i.id)}`,className:"block rounded px-1 py-0.5 hover:bg-bg/50",children:[t.jsx("div",{className:"truncate font-mono text-xs text-fg-muted hover:text-accent",children:d}),r?t.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:r}):null]})},`${n.sourceId}->${n.targetId}:${n.relationship}`)})})]})}function ee({attachment:e}){const s=(e.mimeType??"").toLowerCase(),a=e.filename??e.id;return t.jsxs("figure",{className:"rounded-md border border-border bg-card p-3",children:[t.jsxs("figcaption",{className:"mb-2 flex items-baseline justify-between gap-3",children:[t.jsx("span",{className:"truncate font-mono text-xs text-fg-muted",children:a}),typeof e.size=="number"?t.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:re(e.size)}):null]}),t.jsx(te,{attachment:e,mime:s,filename:a})]})}function te({attachment:e,mime:s,filename:a}){const n=v(),[i,d]=c.useState(null),[r,o]=c.useState(null),l=se(s,a),m=l!=="other",u=e.url;if(c.useEffect(()=>{if(!m||!u||!n)return;let h=!1,b=null;return o(null),n.fetchAttachmentBlob(u).then(g=>{h||(b=URL.createObjectURL(g),d(b))}).catch(g=>{h||o(g instanceof Error?g.message:"Failed to load attachment")}),()=>{h=!0,b&&URL.revokeObjectURL(b)}},[m,u,n]),!u)return t.jsx("p",{className:"text-sm text-fg-dim",children:"(no URL)"});if(r)return t.jsx("p",{className:"text-sm text-red-400",children:r});if(m&&!i)return t.jsx("div",{className:"h-32 animate-pulse rounded bg-border/40","aria-busy":"true"});const x=i??u;return l==="image"?t.jsx("img",{src:x,alt:a,className:"max-h-[32rem] rounded"}):l==="audio"?t.jsx("audio",{controls:!0,src:x,className:"w-full"}):l==="video"?t.jsx("video",{controls:!0,src:x,className:"w-full rounded"}):l==="pdf"?t.jsxs(t.Fragment,{children:[t.jsx("iframe",{src:x,title:a,className:"h-[40rem] w-full rounded border border-border"}),t.jsxs("a",{href:x,download:a,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",a]})]}):t.jsxs("a",{href:x,download:a,className:"text-sm text-accent hover:underline",children:["Download ",a]})}function se(e,s){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e==="application/pdf")return"pdf";const a=s.toLowerCase().split(".").pop()??"";return["png","jpg","jpeg","gif","webp","svg"].includes(a)?"image":["mp3","wav","ogg","m4a","flac"].includes(a)?"audio":["mp4","webm","mov"].includes(a)?"video":a==="pdf"?"pdf":"other"}function re(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function ne(){return t.jsxs("div",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]","aria-busy":"true",children:[t.jsxs("div",{className:"min-w-0 space-y-3",children:[t.jsx("div",{className:"h-3 w-32 animate-pulse rounded bg-border/40"}),t.jsx("div",{className:"h-8 w-2/3 animate-pulse rounded bg-border/60"}),t.jsx("div",{className:"h-4 w-full animate-pulse rounded bg-border/30"}),t.jsx("div",{className:"mt-6 space-y-2",children:[0,1,2,3,4,5].map(e=>t.jsx("div",{className:"h-3 animate-pulse rounded bg-border/30",style:{width:`${70+e*13%25}%`}},e))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"h-32 animate-pulse rounded bg-border/30"}),t.jsx("div",{className:"h-24 animate-pulse rounded bg-border/30"})]})]})}function ae({id:e}){return t.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"Note not found"}),t.jsxs("p",{className:"mb-4 text-sm text-fg-muted",children:["No note with id ",t.jsx("span",{className:"font-mono",children:e})," in this vault."]}),t.jsx(p,{to:"/",className:"text-sm text-accent hover:underline",children:"Back to all notes"})]})}function oe({error:e}){const s=e instanceof L;return t.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[t.jsx("p",{className:"mb-2 font-medium text-red-400",children:s?"Session expired":"Could not load note"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),s?t.jsx(p,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{ce as NoteView};
import{c as f,v,u as k,r as o,G as j,H as b,I as y,J as E,j as e}from"./index-D41hUtgX.js";function S(){const[r]=f(),n=v(),i=k(a=>a.addVault),[u,c]=o.useState({kind:"working"}),l=o.useRef(!1);return o.useEffect(()=>{if(l.current)return;l.current=!0;const a=r.get("code"),d=r.get("state"),m=r.get("error");if(m){c({kind:"error",message:`Vault returned: ${m}`});return}if(!a||!d){c({kind:"error",message:"Missing code or state in callback URL."});return}(async()=>{var x,g;try{const{pending:t,token:s}=await j(a,d),p=((g=(x=s.services)==null?void 0:x.vault)==null?void 0:g.url)??t.issuerUrl,h=i({url:p,name:s.vault,issuer:t.issuer,tokenEndpoint:t.tokenEndpoint,clientId:t.clientId,scope:s.scope},b(s));s.services&&y(h,s.services),E.getState().clearHalt(h),n("/",{replace:!0})}catch(t){c({kind:"error",message:t.message})}})()},[r,n,i]),e.jsx("div",{className:"mx-auto max-w-xl px-6 py-24 text-center",children:u.kind==="working"?e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"mb-3 font-serif text-3xl",children:"Connecting…"}),e.jsx("p",{className:"text-fg-muted",children:"Exchanging the authorization code with your vault."})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"mb-3 font-serif text-3xl text-red-400",children:"Connection failed"}),e.jsx("p",{className:"mb-8 text-fg-muted",children:u.message}),e.jsx("button",{type:"button",onClick:()=>n("/add",{replace:!0}),className:"rounded-md bg-accent px-4 py-2 text-sm text-white hover:bg-accent-hover",children:"Try again"})]})})}export{S as OAuthCallback};
import{r as c,j as t,v,f as g,E as w,V as y,u as j,h as E,w as N}from"./index-D41hUtgX.js";function P({note:a,className:i,label:l="Delete"}){const[r,d]=c.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(!0),className:i??"min-h-11 rounded-md border border-red-500/40 bg-transparent px-3 py-1.5 text-sm text-red-400 hover:bg-red-500/10",title:"Delete this note",children:l}),r?t.jsx(k,{note:a,onClose:()=>d(!1)}):null]})}function k({note:a,onClose:i}){const l=v(),r=g(e=>e.push),d=w(),o=a.path??a.id,[m,p]=c.useState(""),[u,b]=c.useState(null),x=c.useRef(null),s=m===o&&!d.isPending;c.useEffect(()=>{var e;(e=x.current)==null||e.focus()},[]),c.useEffect(()=>{const e=f=>{f.key==="Escape"&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[i]);const n=c.useCallback(()=>{s&&(b(null),d.mutate(a.id,{onSuccess:()=>{r(`Deleted ${o}`,"success"),l("/")},onError:e=>{e instanceof y?b("Session expired. Reconnect to delete."):b(e instanceof Error?e.message:"Delete failed")}}))},[s,o,d,l,a.id,r]);return t.jsx("dialog",{open:!0,"aria-labelledby":"confirm-delete-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:e=>{e.target===e.currentTarget&&i()},children:t.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[t.jsx("h2",{id:"confirm-delete-title",className:"mb-2 font-serif text-xl text-red-400",children:"Delete this note?"}),t.jsx("p",{className:"mb-3 text-sm text-fg-muted",children:"This permanently removes the note, its tags, and its links. This cannot be undone."}),t.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Type"," ",t.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:o})," ","to confirm:"]}),t.jsx("input",{ref:x,type:"text",value:m,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key==="Enter"&&s&&n()},"aria-label":"Type note path to confirm",className:"mb-3 w-full rounded-md border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-red-400 focus:outline-none",placeholder:o,autoComplete:"off",spellCheck:!1}),u?t.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:u}):null,t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),t.jsx("button",{type:"button",onClick:n,disabled:!s,className:"min-h-11 rounded-md bg-red-500 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-600 disabled:opacity-40",children:d.isPending?"Deleting…":"Delete permanently"})]})]})})}function C({note:a,keyboard:i=!1}){var b,x;const l=j(s=>s.getActiveVault()),{roles:r}=E((l==null?void 0:l.id)??null),d=g(s=>s.push),o=N(a.id),m=((b=a.tags)==null?void 0:b.includes(r.pinned))??!1,p=((x=a.tags)==null?void 0:x.includes(r.archived))??!1,u=c.useCallback(s=>{var f;if(o.isPending)return;const n=r[s],e=((f=a.tags)==null?void 0:f.includes(n))??!1;o.mutate({tags:e?{remove:[n]}:{add:[n]}},{onSuccess:()=>{d(s==="pinned"?e?"Unpinned":"Pinned":e?"Unarchived":"Archived","success")},onError:h=>{h instanceof y?d("Session expired. Reconnect.","error"):d(h instanceof Error?h.message:"Update failed","error")}})},[o,a.tags,d,r]);return c.useEffect(()=>{if(!i)return;const s=n=>{if(n.defaultPrevented)return;const e=n.target;if(e){const f=e.tagName;if(f==="INPUT"||f==="TEXTAREA"||e.isContentEditable)return}n.metaKey||n.ctrlKey||n.altKey||(n.key==="p"||n.key==="P"?(n.preventDefault(),u("pinned")):(n.key==="a"||n.key==="A")&&(n.preventDefault(),u("archived")))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i,u]),t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>u("pinned"),disabled:o.isPending,"aria-pressed":m,title:m?`Unpin (${r.pinned})`:`Pin as #${r.pinned} (P)`,className:m?"min-h-11 rounded-md border border-accent/60 bg-accent/10 px-3 py-1.5 text-sm text-accent hover:bg-accent/20 disabled:opacity-40":"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:m?"★ Pinned":"☆ Pin"}),t.jsx("button",{type:"button",onClick:()=>u("archived"),disabled:o.isPending,"aria-pressed":p,title:p?`Unarchive (${r.archived})`:`Archive as #${r.archived} (A)`,className:p?"min-h-11 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-1.5 text-sm text-amber-500 hover:bg-amber-500/20 disabled:opacity-40":"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:p?"Archived":"Archive"})]})}export{P as D,C as P};

Sorry, the diff of this file is too big to display

import{u as N,j as e,N as y,L as w,K as T,P as S,h as E,M as A,f as C,r as n,O as p,Q as x,R}from"./index-D41hUtgX.js";function I(){const s=N(a=>a.getActiveVault());return s?e.jsxs("div",{className:"mx-auto max-w-2xl px-4 py-7 md:px-6 md:py-12",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("nav",{className:"mb-3 text-sm text-fg-dim",children:e.jsx(w,{to:"/",className:"hover:text-accent",children:"← Home"})}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Settings"}),e.jsxs("p",{className:"mt-1 text-sm text-fg-muted",children:["Configuring ",e.jsx("span",{className:"text-fg",children:s.name}),"."]})]}),e.jsx(_,{vaultId:s.id}),e.jsx(P,{vaultId:s.id}),e.jsx(L,{})]}):e.jsx(y,{to:"/",replace:!0})}function L(){const[s,a]=n.useState(!1);return n.useEffect(()=>{a(R())},[]),s?e.jsx("section",{className:"mt-6 rounded-md border border-border bg-card p-4 text-sm",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-emerald-500/20 px-2 py-0.5 text-xs font-medium text-emerald-300",children:"Installed"}),"Parachute Notes is running as an installed app on this device."]})}):null}const f={auto:{title:"Auto",help:"Show the tree only when the vault has enough folders to make it worth the space."},always:{title:"Always",help:"Always show the tree, even on a tag-flat vault."},never:{title:"Never",help:"Hide the tree. The path-prefix text input still works."}};function _({vaultId:s}){const{mode:a,setMode:o}=T(s);return e.jsxs("section",{className:"mt-6 space-y-4 rounded-xl border border-border bg-card p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Folder tree (Notes sidebar)"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Controls the collapsible folder tree on the notes list page. Auto-detect renders the tree when the vault has at least five top-level folders or twenty notes in folders."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"Path tree visibility"}),S.map(l=>e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:l,checked:a===l,onChange:()=>o(l),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-fg",children:f[l].title}),e.jsx("span",{className:"ml-2 text-xs text-fg-dim",children:f[l].help})]})]},l))]})]})}const h={pinned:{title:"Pinned",help:"Tag for notes you want at the top of views."},archived:{title:"Archived",help:"Tag for notes you've moved out of the way."},captureVoice:{title:"Voice capture",help:"Default tag for new voice memos."},captureText:{title:"Text capture",help:"Default tag for quick typed notes."},view:{title:"Saved view",help:"Tag the saved-view notes carry. Used to list them in the notes sidebar."}};function P({vaultId:s}){const{roles:a,setRoles:o}=E(s),l=A(),m=C(t=>t.push),u=n.useId(),[i,c]=n.useState(a);n.useEffect(()=>c(a),[a]);const g=n.useMemo(()=>{const t=(l.data??[]).map(r=>r.name);return[...new Set(t)].sort((r,d)=>r.localeCompare(d))},[l.data]),v=p.some(t=>i[t].trim()!==a[t]),j=()=>{o(i),m("Tag roles saved.","success")},b=()=>{o(null),c(x),m("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"mt-6 space-y-4 rounded-xl border border-border bg-card p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Tag roles"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Point each role at whatever tag your vault already uses. Changes apply to future notes only — existing notes keep their current tags."})]}),e.jsx("datalist",{id:u,children:g.map(t=>e.jsx("option",{value:t},t))}),e.jsx("div",{className:"space-y-3",children:p.map(t=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:h[t].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",x[t]]})]}),e.jsx("input",{type:"text",value:i[t],onChange:r=>c(d=>({...d,[t]:r.target.value})),list:u,placeholder:x[t],"aria-label":`${h[t].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-md border border-border bg-bg px-3 py-2 text-sm text-fg placeholder:text-fg-dim focus:border-accent focus:outline-none"}),e.jsx("span",{className:"mt-1 block text-xs text-fg-dim",children:h[t].help})]},t))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:j,disabled:!v,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:"Save"}),e.jsx("button",{type:"button",onClick:b,className:"text-sm text-fg-muted hover:text-accent",children:"Reset to defaults"})]})]})}export{I as Settings};
import{f as P,r as l,U as O,V as R,j as e,u as L,M as F,g as I,W as V,X as z,Y as D,N as U,L as E}from"./index-D41hUtgX.js";const $=n=>Object.values(n).reduce((a,x)=>a+x,0);function A({mode:n,sources:a,tagOptions:x,onClose:c,onRun:d,onRunMerge:o,pending:i,offline:m}){const p=P(t=>t.push),g=l.useId(),[S,j]=l.useState(n==="rename"?a[0]??"":""),[T,h]=l.useState(null),[u,y]=l.useState(null),[b,N]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{var t,r;(t=v.current)==null||t.focus(),(r=v.current)==null||r.select()},[]),l.useEffect(()=>{const t=r=>{r.key==="Escape"&&c()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c]);const w=S.trim().replace(/^#/,""),f=!i&&!m&&!b&&w.length>0&&!(n==="rename"&&w===a[0]),C=l.useCallback(async()=>{if(f){h(null),y(null);try{const t=await d(w);if("renamed"in t)p(`Renamed on ${t.renamed} note${t.renamed===1?"":"s"}.`,"success");else{const r=$(t.merged);p(`Merged into #${t.target} on ${r} note${r===1?"":"s"}.`,"success")}c()}catch(t){if(t instanceof O&&n==="rename"&&o){y(t.target);return}t instanceof R?h("Session expired. Reconnect to retry."):h(t instanceof Error?t.message:"Operation failed.")}}},[f,w,n,c,d,o,p]),k=l.useCallback(async()=>{if(!(!u||!o)){h(null),N(!0);try{const t=await o(u),r=$(t.merged);p(`Merged into #${t.target} on ${r} note${r===1?"":"s"}.`,"success"),c()}catch(t){t instanceof R?h("Session expired. Reconnect to retry."):h(t instanceof Error?t.message:"Merge failed."),N(!1)}}},[u,c,o,p]),s=n==="rename"?"Rename tag":`Merge ${a.length} tags`;return e.jsx("dialog",{open:!0,"aria-labelledby":"tag-op-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:t=>{t.target===t.currentTarget&&c()},children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-border bg-card p-6 shadow-xl",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:s}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[n==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(M,{children:a[0]})," on every note that carries it. Notes that already have the new tag will end up with one copy."]}):e.jsxs(e.Fragment,{children:["Combine"," ",a.map((t,r)=>e.jsxs("span",{children:[e.jsx(M,{children:t}),r<a.length-1?", ":""]},t))," ","into one tag. The originals are removed."]})," ","Changes apply atomically on the vault."]}),e.jsxs("label",{className:"mb-3 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:n==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:v,type:"text",value:S,onChange:t=>{j(t.target.value),u&&y(null)},onKeyDown:t=>{t.key==="Enter"&&f&&C()},list:g,"aria-label":n==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-md border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-accent focus:outline-none",autoComplete:"off"}),e.jsx("datalist",{id:g,children:x.map(t=>e.jsx("option",{value:t},t))})]}),m?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,u?e.jsxs("div",{role:"alert",className:"mb-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[e.jsxs("p",{className:"mb-2 text-amber-300",children:["A tag named ",e.jsx(M,{children:u})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(M,{children:a[0]})," into ",e.jsx(M,{children:u})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void k(),disabled:b,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:b?"Merging…":`Merge into #${u}`})]}):null,T?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:T}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:c,className:"min-h-11 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void C(),disabled:!f,className:"min-h-11 rounded-md bg-accent px-4 py-1.5 text-sm font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:i?n==="rename"?"Renaming…":"Merging…":n==="rename"?"Rename":"Merge"})]})]})})}function M({children:n}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",n]})}function q(){const n=L(s=>s.getActiveVault()),a=F(),{isOnline:x}=I(),{isPinned:c,togglePin:d}=V((n==null?void 0:n.id)??null),[o,i]=l.useState(""),[m,p]=l.useState("count"),[g,S]=l.useState(new Set),[j,T]=l.useState(null),[h,u]=l.useState(!1),y=z(),b=D(),N=l.useMemo(()=>K(a.data??[],o,m),[a.data,o,m]),v=l.useMemo(()=>(a.data??[]).map(s=>s.name),[a.data]),w=s=>{S(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},f=()=>S(new Set);if(!n)return e.jsx(U,{to:"/",replace:!0});const C=g.size,k=!x;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:n.name}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>p(s=>s==="count"?"alpha":"count"),className:"text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",m==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:o,onChange:s=>i(s.target.value),"aria-label":"Filter tags",className:"mb-4 w-full rounded-md border border-border bg-card px-3 py-2 text-sm text-fg focus:border-accent focus:outline-none"}),C>0?e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3 rounded-md border border-accent/30 bg-accent/5 px-3 py-2 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[C," selected: ",Array.from(g).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>u(!0),disabled:C<2||k,className:"rounded-md bg-accent px-3 py-1 text-xs font-medium text-white hover:bg-accent-hover disabled:opacity-40",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:f,className:"text-xs text-fg-muted hover:text-accent",children:"Clear"})]}):null,a.isPending?e.jsx(W,{}):a.isError?e.jsx(X,{error:a.error}):N.length===0?e.jsx(Y,{filtering:o.trim().length>0,hasAny:(a.data??[]).length>0}):e.jsx("ul",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-label":"Tag list",children:N.map(s=>e.jsx(B,{tag:s,selected:g.has(s.name),onToggle:()=>w(s.name),onRename:()=>T(s.name),pinned:c(s.name),onTogglePin:()=>d(s.name),offline:k},s.name))}),a.data&&a.data.length>0?e.jsxs("p",{className:"mt-6 text-xs text-fg-dim",children:[N.length," / ",a.data.length," tag",a.data.length===1?"":"s"]}):null,j!==null?e.jsx(A,{mode:"rename",sources:[j],tagOptions:v,onClose:()=>T(null),pending:y.isPending||b.isPending,offline:k,onRun:s=>y.mutateAsync({oldName:j,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[j],target:s})}):null,h?e.jsx(A,{mode:"merge",sources:Array.from(g),tagOptions:v,onClose:()=>u(!1),pending:b.isPending,offline:k,onRun:async s=>{const t=await b.mutateAsync({sources:Array.from(g),target:s});return f(),t}}):null]})}function B({tag:n,selected:a,onToggle:x,onRename:c,pinned:d,onTogglePin:o,offline:i}){return e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:x,"aria-label":`Select tag ${n.name}`,className:"accent-accent"}),e.jsxs(E,{to:`/?tag=${encodeURIComponent(n.name)}`,className:"flex flex-1 items-baseline gap-2 text-fg hover:text-accent focus-visible:outline-2 focus-visible:outline-accent",children:[e.jsxs("span",{className:"font-mono",children:["#",n.name]}),e.jsx("span",{className:"text-xs text-fg-dim",children:n.count})]}),e.jsx("button",{type:"button",onClick:o,className:d?"text-xs font-medium text-accent hover:text-accent-hover":"text-xs text-fg-muted hover:text-accent","aria-label":d?`Unpin tag ${n.name}`:`Pin tag ${n.name}`,"aria-pressed":d,title:d?"Pinned to home strip — click to unpin":"Pin to home strip",children:d?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:c,disabled:i,className:"text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${n.name}`,children:"Rename"})]})}function K(n,a,x){const c=a.trim().toLowerCase(),o=[...c?n.filter(i=>i.name.toLowerCase().includes(c)):n];return x==="alpha"?o.sort((i,m)=>i.name.localeCompare(m.name)):o.sort((i,m)=>m.count-i.count||i.name.localeCompare(m.name)),o}function W(){return e.jsx("div",{className:"divide-y divide-border rounded-md border border-border bg-card","aria-busy":"true",children:[0,1,2,3,4].map(n=>e.jsx("div",{className:"h-10 animate-pulse bg-card/60"},n))})}function X({error:n}){const a=n instanceof R;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:a?"Session expired":"Could not load tags"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:n.message}),a?e.jsx(E,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}function Y({filtering:n,hasAny:a}){return n&&a?e.jsx("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:e.jsx("p",{className:"text-fg-muted",children:"No tags match your filter."})}):e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-3 text-fg-muted",children:"No tags in this vault yet."}),e.jsx(E,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create a note"})]})}export{q as Tags};
import{u as w,c as $,a as A,r as D,j as e,N as E,L as d,b as C,V as S}from"./index-D41hUtgX.js";import{t as V,d as N,a as g,e as K,b as f}from"./dates-DfXc2iZW.js";function F(){const a=w(i=>i.getActiveVault()),[s]=$(),t=s.get("date"),u=V(),r=t??u,x=N(r),n=A(),c=D.useMemo(()=>{const i=[],m=[];if(!n.data||!x)return{created:i,edited:m};for(const l of n.data){const b=g(l.createdAt),k=g(l.updatedAt??l.createdAt);b===r&&i.push(l),k===r&&b!==r&&m.push(l)}return{created:i,edited:m}},[n.data,x,r]);if(!a)return e.jsx(E,{to:"/",replace:!0});if(!x)return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("p",{className:"text-sm text-red-400",children:["Invalid date in URL: ",r]}),e.jsx(d,{to:"/today",className:"text-sm text-accent hover:underline",children:"Back to today"})]});const o=r===u,p=j(r,-1),h=j(r,1),v=r.slice(0,7);return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:o?"Today":"On"}),e.jsx("h1",{className:"font-serif text-2xl tracking-tight md:text-3xl",children:K(r)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(d,{to:`/today?date=${p}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous day",children:["← ",p]}),o?null:e.jsx(d,{to:"/today",className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"}),e.jsxs(d,{to:`/today?date=${h}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next day",children:[h," →"]}),e.jsx(d,{to:`/calendar?month=${v}`,className:"rounded-md border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Calendar"}),e.jsx(d,{to:"/capture",className:"rounded-md bg-accent px-3 py-1.5 font-medium text-white hover:bg-accent-hover",children:"+ Capture"})]})]}),n.isPending?e.jsx(L,{}):n.isError?e.jsx(R,{error:n.error}):c.created.length===0&&c.edited.length===0?e.jsx(P,{isToday:o,targetKey:r}):e.jsxs("div",{className:"space-y-8",children:[c.created.length>0?e.jsx(y,{title:o?"Created today":`Created on ${r}`,notes:c.created}):null,c.edited.length>0?e.jsx(y,{title:o?"Edited today":`Edited on ${r}`,notes:c.edited}):null]})]})}function j(a,s){const t=N(a);return t?(t.setDate(t.getDate()+s),`${t.getFullYear()}-${f(t.getMonth()+1)}-${f(t.getDate())}`):a}function y({title:a,notes:s}){return e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:[a," (",s.length,")"]}),e.jsx("ol",{className:"divide-y divide-border rounded-md border border-border bg-card",children:s.map(t=>e.jsx("li",{children:e.jsxs(d,{to:`/n/${encodeURIComponent(t.id)}`,className:"block px-4 py-3 hover:bg-bg/60 focus:bg-bg/60 focus:outline-none",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("span",{className:"truncate font-mono text-sm text-fg",children:t.path??t.id}),e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:C(t.updatedAt??t.createdAt)})]}),t.preview?e.jsx("p",{className:"mt-1 truncate text-sm text-fg-muted",children:t.preview}):null]})},t.id))})]})}function P({isToday:a,targetKey:s}){return e.jsxs("div",{className:"rounded-md border border-border bg-card p-10 text-center",children:[e.jsx("p",{className:"mb-4 text-fg-muted",children:a?"Nothing yet today — start capturing.":`Nothing on ${s}.`}),a?e.jsx(d,{to:"/capture",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Open capture"}):null]})}function L(){return e.jsx("div",{className:"space-y-3","aria-busy":"true",children:[0,1,2,3].map(a=>e.jsx("div",{className:"h-14 animate-pulse rounded-md bg-border/30"},a))})}function R({error:a}){const s=a instanceof S;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:s?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:a.message}),s?e.jsx(d,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})}export{F as Today};

Sorry, the diff of this file is too big to display

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-CY0IItb_.js","assets/index-D41hUtgX.js","assets/index-CSwzwMDF.css"])))=>i.map(i=>d[i]);
import{u as w,Z as N,r as f,j as s,N as k,L as v,v as C,V as I,_ as M}from"./index-D41hUtgX.js";const S={search:"",tags:[]};function T(e){const t=new Map;for(const i of e)t.set(i.id,i);const a=new Map,o=new Map;for(const i of e)for(const n of i.links??[]){if(n.sourceId===n.targetId||!t.has(n.sourceId)||!t.has(n.targetId))continue;const c=`${n.sourceId}|${n.targetId}|${n.relationship}`;a.has(c)||(a.set(c,{source:n.sourceId,target:n.targetId,relationship:n.relationship}),o.set(n.sourceId,(o.get(n.sourceId)??0)+1),o.set(n.targetId,(o.get(n.targetId)??0)+1))}return{nodes:e.map(i=>{var c;const n=i.tags??[];return{id:i.id,path:i.path,title:A(i),tags:n,topTag:n[0],degree:o.get(i.id)??0,summary:typeof((c=i.metadata)==null?void 0:c.summary)=="string"?i.metadata.summary:void 0}}),edges:[...a.values()]}}function A(e){return e.path?(e.path.split("/").pop()??e.path).replace(/\.md$/i,""):e.id}function R(e,t){const a=t.search.trim().toLowerCase();return!(a&&![e.path??"",e.title,e.id].join(" ").toLowerCase().includes(a)||t.tags.length>0&&!t.tags.some(d=>e.tags.includes(d)))}function E(e){const t=new Map;for(const a of e)for(const o of a.tags)t.set(o,(t.get(o)??0)+1);return[...t.entries()].sort((a,o)=>o[1]-a[1]||a[0].localeCompare(o[0])).map(([a])=>a)}function _(e){if(!e)return"#8a9a7a";let t=0;for(let o=0;o<e.length;o++)t=t*31+e.charCodeAt(o)&16777215;return`hsl(${t%360}, 40%, 55%)`}const F=f.lazy(()=>M(()=>import("./react-force-graph-2d-CY0IItb_.js"),__vite__mapDeps([0,1,2]))),L=20;function O(){const e=w(c=>c.getActiveVault()),t=N(),[a,o]=f.useState(S),d=f.useMemo(()=>t.data?T(t.data):null,[t.data]),i=f.useMemo(()=>d?E(d.nodes):[],[d]),n=f.useMemo(()=>d?new Set(d.nodes.filter(c=>R(c,a)).map(c=>c.id)):new Set,[d,a]);return e?s.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[s.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:s.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[s.jsx("input",{type:"search",value:a.search,onChange:c=>o(m=>({...m,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-md border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),s.jsx($,{allTags:i,selected:a.tags,onChange:c=>o(m=>({...m,tags:c}))}),d?s.jsxs("span",{className:"text-xs text-fg-dim",children:[n.size," / ",d.nodes.length," notes"]}):null]})}),s.jsx("div",{className:"min-h-0 flex-1",children:s.jsx(P,{query:t,graph:d,matched:n})})]}):s.jsx(k,{to:"/",replace:!0})}function P({query:e,graph:t,matched:a}){return e.isPending?s.jsx(j,{message:"Loading vault…"}):e.isError?s.jsx(B,{error:e.error}):!t||t.nodes.length===0?s.jsx("div",{className:"flex h-full items-center justify-center p-10",children:s.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[s.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),s.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),s.jsx(v,{to:"/new",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Create a note"})]})}):s.jsx(z,{graph:t,matched:a})}function $({allTags:e,selected:t,onChange:a}){const o=e.slice(0,L);if(o.length===0)return null;const d=i=>a(t.includes(i)?t.filter(n=>n!==i):[...t,i]);return s.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[s.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),o.map(i=>{const n=t.includes(i);return s.jsx("button",{type:"button","aria-pressed":n,onClick:()=>d(i),className:n?"max-w-full break-all rounded-full border border-accent bg-accent/10 px-2 py-0.5 text-accent":"max-w-full break-all rounded-full border border-border bg-card px-2 py-0.5 hover:text-accent",children:i},i)}),t.length>0?s.jsx("button",{type:"button",onClick:()=>a([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return s.jsx("div",{"aria-busy":"true",className:"flex h-full animate-pulse items-center justify-center bg-card/30 text-sm text-fg-dim",children:e})}function z({graph:e,matched:t}){const a=C(),o=f.useRef(null),d=f.useRef(null),[i,n]=f.useState({w:800,h:600});f.useEffect(()=>{const r=o.current;if(!r)return;const l=()=>{const u=r.getBoundingClientRect();n({w:Math.max(320,Math.floor(u.width)),h:Math.max(320,Math.floor(u.height))})};l();const h=new ResizeObserver(l);return h.observe(r),()=>h.disconnect()},[]);const c=()=>{var r,l;(l=(r=d.current)==null?void 0:r.zoomToFit)==null||l.call(r,400,40)},m=f.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),g=t.size!==e.nodes.length,y=r=>!g||t.has(r)?1:.15;return s.jsxs("div",{ref:o,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[s.jsx(f.Suspense,{fallback:s.jsx(j,{message:"Rendering graph…"}),children:s.jsx(F,{ref:d,graphData:m,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>V(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const l=r,h=_(l.topTag);return g&&!t.has(l.id)?G(h):h},nodePointerAreaPaint:(r,l,h)=>{const u=r;if(u.x==null||u.y==null)return;const x=2+Math.min(u.degree,12),p=Math.max(Math.sqrt(x)*5,10);h.fillStyle=l,h.beginPath(),h.arc(u.x,u.y,p,0,2*Math.PI),h.fill()},linkColor:r=>{const l=r,h=b(l.source),u=b(l.target);return g&&(!t.has(h)||!t.has(u))?"rgba(160, 160, 160, 0.08)":"rgba(160, 160, 160, 0.35)"},linkDirectionalArrowLength:2.5,linkDirectionalArrowRelPos:1,cooldownTicks:100,onEngineStop:()=>c(),nodeCanvasObjectMode:()=>"after",nodeCanvasObject:(r,l,h)=>{const u=r;if(u.x==null||u.y==null||y(u.id)<.5)return;const p=10/h;l.font=`${p}px sans-serif`,l.fillStyle="rgba(220, 220, 220, 0.8)",l.textAlign="left",l.textBaseline="middle",l.fillText(u.title,u.x+6,u.y)},onNodeClick:r=>{a(`/n/${encodeURIComponent(r.id)}`)}})}),s.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-md border border-border bg-card/90 px-3 py-1.5 text-xs text-fg-muted shadow-sm backdrop-blur hover:text-accent",children:"Fit to screen"})]})}function V(e){const t=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&t.push(`tags: ${e.tags.join(", ")}`),e.summary&&t.push(e.summary),t.join(`
`)}function G(e){return e.startsWith("hsl(")?e.replace("hsl(","hsla(").replace(")",", 0.2)"):e}function b(e){return typeof e=="string"?e:e&&typeof e=="object"&&"id"in e?String(e.id):""}function B({error:e}){const t=e instanceof I;return s.jsx("div",{className:"flex h-full items-center justify-center p-10",children:s.jsxs("div",{className:"max-w-md rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[s.jsx("p",{className:"mb-2 font-medium text-red-400",children:t?"Session expired":"Could not load vault"}),s.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),t?s.jsx(v,{to:"/add",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Reconnect vault"}):null]})})}export{O as VaultGraph};
import{u as a,j as e,L as c,$ as m}from"./index-D41hUtgX.js";function u(){const l=a(t=>t.vaults),d=a(t=>t.activeVaultId),i=a(t=>t.removeVault),o=a(t=>t.setActiveVault),n=Object.values(l).sort((t,s)=>t.name.localeCompare(s.name));return e.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-16",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[e.jsx("h1",{className:"font-serif text-4xl tracking-tight",children:"Vaults"}),e.jsx(c,{to:"/add",className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent-hover",children:"Add vault"})]}),n.length===0?e.jsx("p",{className:"text-fg-muted",children:"No vaults connected yet."}):e.jsx("ul",{className:"space-y-3",children:n.map(t=>{const s=t.id===d,r=m(t.url);return e.jsxs("li",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:t.name}),s?e.jsx("span",{className:"rounded bg-accent/10 px-2 py-0.5 text-xs text-accent",children:"active"}):null,e.jsx("span",{className:"rounded border border-border px-2 py-0.5 text-xs text-fg-dim",children:t.scope}),r?e.jsx("span",{className:"rounded border border-amber-500/40 bg-amber-500/10 px-2 py-0.5 text-xs text-amber-500",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate font-mono text-xs text-fg-muted",children:t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[s?null:e.jsx("button",{type:"button",onClick:()=>o(t.id),className:"text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${t.name}? The access token will be deleted.`)&&i(t.id)},className:"text-red-400 hover:text-red-300",children:"Remove"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-500",children:["Vault now serves under ",e.jsx("code",{children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(c,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},t.id)})})]})}export{u as Vaults};

Sorry, the diff of this file is not supported yet