@openparachute/app 0.22.14-rc.2 → 0.22.14-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/.parachute/info +1 -1
  3. package/dist/assets/{Account-CoSQwMlJ.js → Account-BlFpLIcL.js} +1 -1
  4. package/dist/assets/{Activity-kaMFa3fK.js → Activity-04uyKSGT.js} +1 -1
  5. package/dist/assets/{AddVault-BdEbS-at.js → AddVault-HfqPTkUx.js} +1 -1
  6. package/dist/assets/{AddVaultChooser-DR4cyJeZ.js → AddVaultChooser-BQKWysH8.js} +1 -1
  7. package/dist/assets/{AddVaultCreate-DKSKUeG8.js → AddVaultCreate-CjT_pVEv.js} +1 -1
  8. package/dist/assets/{Calendar-_loW0paP.js → Calendar-CcN20GI6.js} +1 -1
  9. package/dist/assets/{CheckEmail-PBWODeVZ.js → CheckEmail-DOO73-eP.js} +1 -1
  10. package/dist/assets/{ConnectAI-DQ_N7ZF3.js → ConnectAI-B9qWFf_f.js} +1 -1
  11. package/dist/assets/{DayView-DtlzBMFH.js → DayView-CIqjBQD5.js} +1 -1
  12. package/dist/assets/{Export-kSyvEi0u.js → Export-C9cVOM7Z.js} +1 -1
  13. package/dist/assets/{Import-3fbKo4w8.js → Import-1ndJRP3b.js} +1 -1
  14. package/dist/assets/{NoteEditor-CpulwbX3.js → NoteEditor-J2Byu7ok.js} +1 -1
  15. package/dist/assets/{NoteNew-Cc6a1vru.js → NoteNew-D8MgVbk2.js} +1 -1
  16. package/dist/assets/{NoteRenderer-I-fX48a-.js → NoteRenderer-CVEx6c2v.js} +24 -24
  17. package/dist/assets/NoteView-BnVwet5i.js +3 -0
  18. package/dist/assets/{OAuthCallback-pBSW2lKo.js → OAuthCallback-DNI4o3ND.js} +1 -1
  19. package/dist/assets/{PinArchiveButtons-Dxqe-PNR.js → PinArchiveButtons-fss0A6G3.js} +1 -1
  20. package/dist/assets/{Settings-CPo-Wt-I.js → Settings-C8bLBNqJ.js} +1 -1
  21. package/dist/assets/{TagPage-BnEENXCy.js → TagPage-ByggRkcb.js} +1 -1
  22. package/dist/assets/{TagSchemaEditor-B-d3rSjI.js → TagSchemaEditor-CUHG09YZ.js} +1 -1
  23. package/dist/assets/{Tags-CylsLohS.js → Tags-D-v1kXQE.js} +1 -1
  24. package/dist/assets/{VaultGraph-BUmNoSkm.js → VaultGraph-C2PwotxJ.js} +3 -3
  25. package/dist/assets/{Vaults-BLhnLLYV.js → Vaults-DlztTmOd.js} +1 -1
  26. package/dist/assets/{ViewNew-AysTVG25.js → ViewNew-DwZQ_Xy1.js} +1 -1
  27. package/dist/assets/{ViewSurface-CIpzYIN8.js → ViewSurface-CEipyYaB.js} +1 -1
  28. package/dist/assets/{Welcome-Ch_SVwda.js → Welcome-Ti-1vqQ1.js} +1 -1
  29. package/dist/assets/{WizardShell-C6s4rjvR.js → WizardShell-X-_3n8Lx.js} +1 -1
  30. package/dist/assets/{attachment-upload-DgPB_hNP.js → attachment-upload-BjoNnGbm.js} +1 -1
  31. package/dist/assets/{history-D-PT8sXa.js → history-Bxu3eq1m.js} +1 -1
  32. package/dist/assets/index-q-OceM-D.js +66 -0
  33. package/dist/assets/{provenance-B3gZ95dW.js → provenance-BRYF2APg.js} +1 -1
  34. package/dist/assets/{react-force-graph-2d-QCauZ0zI.js → react-force-graph-2d-BpJfrG8W.js} +1 -1
  35. package/dist/assets/{transcribe-default-Vo4Gqy9l.js → transcribe-default-aMtRgXlN.js} +1 -1
  36. package/dist/assets/{useAttachmentUploader-DbHznJZI.js → useAttachmentUploader-BTg8Q34l.js} +1 -1
  37. package/dist/index.html +1 -1
  38. package/dist/sw.js +1 -1
  39. package/meta.json +1 -1
  40. package/package.json +3 -3
  41. package/dist/assets/NoteView-BQ3li7s2.js +0 -3
  42. package/dist/assets/index-DEEhPpPi.js +0 -66
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BpJfrG8W.js","assets/index-q-OceM-D.js","assets/index-BBWRhmyM.css"])))=>i.map(i=>d[i]);
2
+ import{a7 as k,a as w,ay as M,r as d,aP as D,j as t,ah as $,aQ as V,L as g,aR as O,aS as _,aT as z,aU as H,aV as G,ag as W,aW as K,N as Q,a2 as q,y as b,a3 as X,aX as Y,az as Z,ai as P,aY as J,aZ as ee,a_ as te,a$ as se,ao as ne,b0 as re,E as ae,z as ie,b1 as C,A,$ as oe,b2 as le,V as ce,a9 as de,b3 as ue}from"./index-q-OceM-D.js";import{P as me,D as he}from"./PinArchiveButtons-fss0A6G3.js";import{b as xe,N as fe}from"./NoteRenderer-CVEx6c2v.js";function pe(e,n){const s=k(),r=w(u=>u.activeVaultId),i=M(),[l,a]=d.useState(!1),o=n&&!ge(n)?n.path:void 0;return d.useEffect(()=>{if(a(!1),!s||!r||!e||!o)return;let u=!0;const m=()=>{u&&i.invalidateQueries({queryKey:["note",r,e]})},c=be(s,o,{onUpsert:m,onRemove:m,onStatus:x=>{u&&a(x==="open")}});return()=>{u=!1,a(!1),c()}},[s,r,e,o,i]),{isLive:l}}function ge(e){return D(e.id)}function be(e,n,s){return e.subscribe({path:n},{onSnapshot:()=>{},onUpsert:()=>s.onUpsert(),onRemove:()=>s.onRemove(),onStatus:s.onStatus})}const je=1,Ne=3,ve=1;function ye(e,n){const s=new Map,r=new Map;for(const l of n.values())for(const a of l.links??[]){if(a.sourceId===a.targetId||!n.has(a.sourceId)||!n.has(a.targetId))continue;const o=`${a.sourceId}|${a.targetId}|${a.relationship}`;s.has(o)||(s.set(o,{source:a.sourceId,target:a.targetId,relationship:a.relationship}),r.set(a.sourceId,(r.get(a.sourceId)??0)+1),r.set(a.targetId,(r.get(a.targetId)??0)+1))}return{nodes:[...n.values()].map(l=>{var a;return{id:l.id,path:l.path,tags:l.tags,summary:typeof((a=l.metadata)==null?void 0:a.summary)=="string"?l.metadata.summary:void 0,isAnchor:l.id===e,linkCount:r.get(l.id)??0}}),edges:[...s.values()]}}async function we(e,n,s,r){const i=new Map;i.set(e.id,e);let l=[e];for(let a=1;a<=n;a++){const o=new Set;for(const c of l)for(const x of c.links??[]){const f=x.sourceId===c.id?x.targetId:x.sourceId;f!==c.id&&(i.has(f)||o.add(f))}if(o.size===0)break;const u=await Promise.all([...o].map(c=>s(c).catch(()=>null)));if(r!=null&&r.cancelled)return i;const m=[];for(const c of u)c&&!i.has(c.id)&&(i.set(c.id,c),m.push(c));l=m}return i}function ke(e,n,s){const[r,i]=d.useState(null),[l,a]=d.useState(!1);return d.useEffect(()=>{if(!e||!n){i(null),a(!1);return}const o={cancelled:!1};return a(!0),we(n,s,u=>e.getNote(u,{includeLinks:!0}),o).then(u=>{o.cancelled||(i(ye(n.id,u)),a(!1))}).catch(()=>{o.cancelled||a(!1)}),()=>{o.cancelled=!0}},[e,n,s]),{data:r,isLoading:l}}const Ce=d.lazy(()=>_(()=>import("./react-force-graph-2d-BpJfrG8W.js"),__vite__mapDeps([0,1,2])));function Ie({anchor:e}){const[n,s]=d.useState(!0),[r,i]=d.useState(ve),l=k(),{data:a,isLoading:o}=ke(l,n?e:void 0,r);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:()=>s(u=>!u),"aria-expanded":n,className:"font-serif text-xl text-fg hover:text-accent",children:[n?"▾":"▸"," Neighborhood"]}),n&&a?t.jsxs("span",{className:"text-xs text-fg-dim",children:[a.nodes.length," ",a.nodes.length===1?"note":"notes"]}):null]}),n?t.jsx(Ee,{depth:r,onChange:i}):null]}),n?t.jsx(Se,{data:a,isLoading:o}):null]})}function Ee({depth:e,onChange:n}){const s=[];for(let r=je;r<=Ne;r++)s.push(r);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"}),s.map(r=>t.jsx("button",{type:"button","aria-pressed":r===e,onClick:()=>n(r),className:r===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:r},r))]})}function Se({data:e,isLoading:n}){const[s,r]=d.useState(null),i=d.useRef(null);if(d.useEffect(()=>{s&&e&&!e.nodes.some(m=>m.id===s)&&r(null)},[e,s]),!e&&n)return t.jsx(B,{});if(!e)return null;if(e.nodes.length<=1)return 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."});const l=e.nodes.filter(m=>!m.isAnchor),a=s?e.nodes.find(m=>m.id===s)??null:null,o=m=>{i.current=document.activeElement??null,r(m)},u=m=>{var c,x;r(null),m!=null&&m.restoreFocus&&((x=(c=i.current)==null?void 0:c.focus)==null||x.call(c))};return t.jsxs(t.Fragment,{children:[t.jsx(Ae,{data:e,onSelect:o}),a?t.jsx(Te,{node:a,onClose:u},a.id):null,t.jsx(Re,{neighbors:l,selectedId:s,onSelect:o})]})}function Re({neighbors:e,selectedId:n,onSelect:s}){return e.length===0?null:t.jsxs("div",{className:"mt-4",children:[t.jsx("h3",{className:"eyebrow mb-2",children:"Neighbors"}),t.jsx("ul",{className:"flex flex-wrap gap-2",children:e.map(r=>{const i=O(r.path??r.id);return t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>s(r.id),"aria-haspopup":"dialog","aria-pressed":n===r.id,"aria-label":`Preview ${i}`,className:`btn btn-sm btn-touch max-w-full ${n===r.id?"btn-primary":"btn-secondary"}`,children:t.jsx("span",{className:"truncate",children:i})})},r.id)})})]})}function Te({node:e,onClose:n}){var a;const s=$(e.id),r=d.useRef(null);d.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]);const i=V({id:e.id,path:e.path,content:(a=s.data)==null?void 0:a.content}),l=Pe(s.data);return t.jsxs("div",{role:"dialog",ref:r,"aria-label":"Note preview",tabIndex:-1,"data-testid":"neighbor-preview",onKeyDown:o=>{o.key==="Escape"&&n({restoreFocus:!0})},onBlur:o=>{o.currentTarget.contains(o.relatedTarget)||n()},className:"focus-ring card mt-3 p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h3",{className:"min-w-0 truncate font-serif text-lg text-fg",children:i}),t.jsx("button",{type:"button",onClick:()=>n({restoreFocus:!0}),"aria-label":"Close preview",className:"shrink-0 text-fg-dim hover:text-accent",children:"✕"})]}),e.tags&&e.tags.length>0?t.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.tags.map(o=>t.jsxs("span",{className:"chip chip-tag max-w-full break-all",children:["#",o]},o))}):null,t.jsx(Le,{isPaused:s.fetchStatus==="paused",isPending:s.isPending,isError:s.isError,snippet:l}),t.jsx("div",{className:"mt-3",children:t.jsx(g,{to:`/n/${encodeURIComponent(e.id)}`,className:"btn btn-primary btn-touch",children:"Open note"})})]})}function Le({isPaused:e,isPending:n,isError:s,snippet:r}){return e&&n?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Preview unavailable offline."}):n?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Loading preview…"}):s?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Couldn't load preview."}):r?t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:r}):t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"No preview text."})}function Pe(e){if(!e)return null;const n=(e.preview??z(e.content??"")).trim();return n?n.length>200?`${n.slice(0,200).trimEnd()}…`:n:null}function B(){return t.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function Ae({data:e,onSelect:n}){const s=d.useRef(null),[r,i]=d.useState({w:600,h:384});d.useEffect(()=>{const a=s.current;if(!a)return;const o=()=>{const m=a.getBoundingClientRect();i({w:Math.max(320,Math.floor(m.width)),h:384})};o();const u=new ResizeObserver(o);return u.observe(a),()=>u.disconnect()},[]);const l=d.useMemo(()=>({nodes:e.nodes.map(a=>({...a})),links:e.edges.map(a=>({source:a.source,target:a.target,rel:a.relationship}))}),[e]);return t.jsx("div",{ref:s,"data-testid":"neighborhood-graph-canvas",className:"overflow-hidden rounded-md border border-border bg-card",children:t.jsx(d.Suspense,{fallback:t.jsx(B,{}),children:t.jsx(Ce,{graphData:l,width:r.w,height:r.h,nodeLabel:a=>Fe(a),nodeVal:a=>{const o=a;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:a=>a.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:a=>{n(a.id)}})})})}function Fe(e){const n=[e.path??e.id];return e.tags&&e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
3
+ `)}function $e({content:e,attachments:n,onRetry:s,retrying:r=!1}){const i={content:e,attachments:n},l=H(i);if(l==="pending"){const a=G(i);return 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.jsxs("span",{className:"text-sky-300/80",children:["part ",Math.min(a.done+1,a.total)," of ",a.total]}):null]})}return l==="failed"?t.jsxs("output",{className:"mb-4 inline-flex flex-wrap 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:[t.jsx("span",{children:"Transcription unavailable — open the audio below and add a note by hand."}),s?t.jsx("button",{type:"button",onClick:s,disabled:r,className:"rounded border border-amber-500/40 px-2 py-0.5 font-medium text-amber-100 hover:bg-amber-500/15 disabled:opacity-50",children:r?"Retrying…":"Retry"}):null]}):l==="voice-limit"?t.jsx("output",{className:"mb-4 inline-flex items-center gap-2 rounded-md border border-border bg-bg/40 px-3 py-1.5 text-xs text-fg-muted",children:"Monthly voice limit reached — transcription resumes next month. The audio is saved below."}):null}function st(){const{id:e}=W(),n=w(r=>r.getActiveVault()),s=$(e);return pe(e,s.data),d.useEffect(()=>{n&&e&&K(n.id,e)},[n,e]),n?t.jsxs("div",{className:"page",children:[t.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:t.jsx(g,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),s.isPending?t.jsx(Ke,{}):s.data?t.jsxs(t.Fragment,{children:[s.isError?t.jsx(q,{}):null,t.jsx(Be,{note:s.data,cacheId:e})]}):s.isError?t.jsx(Ze,{error:s.error,retry:()=>s.refetch()}):t.jsx(Ye,{id:e??""})]}):t.jsx(Q,{to:"/",replace:!0})}function Be({note:e,cacheId:n}){var T,L;const s=w(h=>h.getActiveVault()),{roles:r}=X((s==null?void 0:s.id)??null),i=Y(),{mirror:l}=Z(),a=l.state==="offline",o=e.contentEvicted===!0,u=d.useMemo(()=>xe(e),[e]),m=P(h=>h.on),c=P(h=>h.setOn);d.useEffect(()=>{if(!m)return;const h=y=>{y.key==="Escape"&&c(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[m,c]);const x=e.path??e.id,f=J(e.content),p=f!==null&&!ee(f,e)?f:null,j=p!==null?{kind:"title",text:p}:e.path?te(e.path):{kind:"title",text:e.id},I=d.useMemo(()=>p!==null?{...e,content:se(e.content??"")}:e,[e,p]),E=typeof((T=e.metadata)==null?void 0:T.summary)=="string"?e.metadata.summary:null,S=d.useMemo(()=>(e.links??[]).filter(h=>h.targetId===e.id&&h.sourceId!==e.id&&h.sourceNote),[e]),R=d.useMemo(()=>{const h=new Set,y=[];for(const N of e.links??[])N.sourceId!==e.id||N.targetId===e.id||N.targetNote&&(h.has(N.targetId)||(h.add(N.targetId),y.push(N)));return y},[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-8 border-b border-border pb-5",children:[t.jsx("h1",{className:j.kind==="timestamp"?"page-title title-timestamp":"page-title",children:j.text}),a?t.jsx(qe,{}):null,e.tags&&e.tags.length>0?t.jsx(Ve,{tags:e.tags}):null,E?t.jsx("p",{className:"mt-3 text-fg-muted",children:E}):null,t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[t.jsx(g,{to:`/n/${encodeURIComponent(e.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit"}),t.jsx(me,{note:e,keyboard:!0}),t.jsx(he,{note:e}),t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[t.jsx(ne,{width:16,height:16}),"Focus"]}),re(e,r.view)?t.jsx(g,{to:`/views/${encodeURIComponent(e.id)}`,className:"btn btn-secondary btn-touch",children:"Open as view"}):null]}),t.jsx(_e,{value:x,isPath:!!e.path})]}),t.jsx($e,{content:e.content??"",attachments:e.attachments,onRetry:()=>i.mutate({cacheId:n??e.id,serverId:e.id}),retrying:i.isPending}),o?t.jsx(Xe,{preview:e.preview}):(L=I.content)!=null&&L.trim()?t.jsx(fe,{note:I,resolve:u}):p===null?t.jsx(Qe,{noteId:e.id}):null,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(h=>t.jsx(ze,{attachment:h},h.id))})]}):null,t.jsx(Ie,{anchor:e})]}),t.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[t.jsx(Ue,{note:e}),R.length>0?t.jsx(F,{title:"Outbound",links:R,peer:"target"}):null,S.length>0?t.jsx(F,{title:"Inbound",links:S,peer:"source"}):null]})]})}function Ue({note:e}){const n=e.createdAt,s=e.updatedAt,r=Object.entries(e.metadata??{}).filter(([i])=>i!=="summary");return t.jsxs("section",{className:"card shadow-soft p-4",children:[t.jsx("h2",{className:"eyebrow mb-2",children:"Metadata"}),t.jsxs("dl",{className:"space-y-1.5 text-sm",children:[e.path?t.jsx(v,{label:"Title",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.path})}):null,t.jsx(v,{label:"ID",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.id})}),t.jsx(v,{label:"Created",value:t.jsx("time",{title:n,children:A(n)})}),s?t.jsx(v,{label:"Updated",value:t.jsx("time",{title:s,children:A(s)})}):null,e.path?t.jsx(v,{label:"Path",value:t.jsx(oe,{value:e.path,label:"note path",className:"mt-1"})}):null,r.map(([i,l])=>t.jsx(v,{label:i,value:t.jsx("span",{className:"break-all text-fg-muted",children:String(l)})},i))]}),t.jsx(Me,{noteId:e.id}),e.path?t.jsx(De,{path:e.path}):null,t.jsx(le,{note:e,variant:"detail",className:"mt-3"})]})}function Me({noteId:e}){const n=w(i=>i.getActiveVault()),{copied:s,copy:r}=C();return n!=null&&n.name?t.jsx("button",{type:"button",onClick:()=>r(ue(n.name,e)),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy a shareable link to this note",children:s?"Copied ✓":"Copy link"}):null}function De({path:e}){const{copied:n,copy:s}=C();return t.jsx("button",{type:"button",onClick:()=>s(e),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy reference to this note",children:n?"Copied ✓":"Copy reference"})}function v({label:e,value:n}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("dt",{className:"eyebrow",children:e}),t.jsx("dd",{children:n})]})}function Ve({tags:e}){return t.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":"Tags",children:e.map(n=>t.jsxs(g,{to:`/tags/${encodeURIComponent(n)}`,className:"chip chip-tag focus-ring max-w-full break-all",children:["#",n]},n))})}function Oe(e){return t.jsxs("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[t.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),t.jsx("path",{d:"M5 15H4.5A1.5 1.5 0 0 1 3 13.5v-9A1.5 1.5 0 0 1 4.5 3h9A1.5 1.5 0 0 1 15 4.5V5"})]})}function _e({value:e,isPath:n}){const{copied:s,copy:r}=C();return t.jsxs("button",{type:"button",onClick:()=>r(e),"aria-label":n?"Copy path":"Copy note id",className:"focus-ring group mt-4 flex max-w-full items-center gap-1.5 rounded text-fg-dim transition-colors hover:text-fg-muted",children:[t.jsx(Oe,{className:"shrink-0 opacity-70 transition-opacity group-hover:opacity-100"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:e}),s?t.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:"Copied"}):null]})}function F({title:e,links:n,peer:s}){return t.jsxs("section",{className:"card shadow-soft p-4",children:[t.jsxs("h2",{className:"eyebrow mb-2 tabular-nums",children:[e," (",n.length,")"]}),t.jsx("ul",{className:"space-y-1.5",children:n.map(r=>{var o;const i=s==="source"?r.sourceNote:r.targetNote;if(!i)return null;const l=i.path??i.id,a=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return t.jsx("li",{children:t.jsxs(g,{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:l}),a?t.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:a}):null]})},`${r.sourceId}->${r.targetId}:${r.relationship}`)})})]})}function ze({attachment:e}){const n=e.filename;if(!n||!e.url)return t.jsx("figure",{className:"card shadow-soft p-3",children:t.jsx(U,{})});const s=(e.mimeType??"").toLowerCase();return t.jsxs("figure",{className:"card shadow-soft 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:n}),typeof e.size=="number"?t.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:We(e.size)}):null]}),t.jsx(He,{attachment:e,mime:s,filename:n})]})}function U(){return t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-dim","aria-busy":"true",children:[t.jsx(b,{className:"h-4 w-32"}),t.jsx("span",{children:"Processing…"})]})}function He({attachment:e,mime:n,filename:s}){const r=k(),[i,l]=d.useState(null),[a,o]=d.useState(null),u=Ge(n,s),m=u!=="other",c=e.url;if(d.useEffect(()=>{if(!m||!c||!r)return;let f=!1,p=null;return o(null),r.fetchAttachmentBlob(c).then(j=>{f||(p=URL.createObjectURL(j),l(p))}).catch(j=>{f||o(j instanceof Error?j.message:"Failed to load attachment")}),()=>{f=!0,p&&URL.revokeObjectURL(p)}},[m,c,r]),!c)return t.jsx(U,{});if(a)return t.jsx("p",{className:"text-sm text-danger",children:a});if(m&&!i)return t.jsx(b,{className:"h-32 w-full"});const x=i??c;return u==="image"?t.jsx("img",{src:x,alt:s,className:"max-h-[32rem] rounded"}):u==="audio"?t.jsx("audio",{controls:!0,src:x,className:"w-full"}):u==="video"?t.jsx("video",{controls:!0,src:x,className:"w-full rounded"}):u==="pdf"?t.jsxs(t.Fragment,{children:[t.jsx("iframe",{src:x,title:s,className:"h-[40rem] w-full rounded border border-border"}),t.jsxs("a",{href:x,download:s,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",s]})]}):t.jsxs("a",{href:x,download:s,className:"text-sm text-accent hover:underline",children:["Download ",s]})}function Ge(e,n){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 s=n.toLowerCase().split(".").pop()??"";return["png","jpg","jpeg","gif","webp","svg"].includes(s)?"image":["mp3","wav","ogg","m4a","flac"].includes(s)?"audio":["mp4","webm","mov"].includes(s)?"video":s==="pdf"?"pdf":"other"}function We(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 Ke(){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(b,{className:"h-3 w-32"}),t.jsx(b,{className:"h-8 w-2/3"}),t.jsx(b,{className:"h-4 w-full"}),t.jsx("div",{className:"mt-6 space-y-2",children:[0,1,2,3,4,5].map(e=>t.jsx(b,{className:"h-3",width:`${70+e*13%25}%`},e))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(b,{className:"h-32"}),t.jsx(b,{className:"h-24"})]})]})}function Qe({noteId:e}){return t.jsxs("p",{className:"my-8 font-serif text-lg italic text-fg-muted",children:["Nothing here yet."," ",t.jsx(g,{to:`/n/${encodeURIComponent(e)}/edit`,className:"not-italic text-accent hover:underline",children:"Start writing →"})]})}function qe(){return t.jsx("p",{className:"mt-2",children:t.jsx("span",{className:"chip bg-bg-soft text-fg-muted",title:"Served from your offline copy",children:"Saved copy"})})}function Xe({preview:e}){return t.jsxs("div",{className:"my-8",children:[e?t.jsx("p",{className:"mb-4 text-fg-muted",children:e}):null,t.jsx("p",{className:"font-serif text-lg italic text-fg-muted",children:"Connect to load this note."})]})}function Ye({id:e}){return t.jsx(ie,{title:t.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:t.jsxs(t.Fragment,{children:["No note with id ",t.jsx("span",{className:"font-mono",children:e})," in this vault."]}),action:t.jsx(g,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Ze({error:e,retry:n}){const s=e instanceof ce,r=e instanceof de,i=s?"Session expired":r?"Note not found":"Could not load note",l=s?e.message:r?"Couldn't find this note. It may have been deleted, or the link may be wrong.":"Something went wrong loading this note. You can try again, or head back to your notes.";return t.jsx(ae,{title:i,message:t.jsxs(t.Fragment,{children:[l,s?null:t.jsxs("details",{className:"mt-3",children:[t.jsx("summary",{className:"cursor-pointer text-xs text-fg-dim hover:text-fg-muted",children:"Technical detail"}),t.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-xs text-fg-dim",children:e.message})]})]}),retry:s?void 0:n,action:s?t.jsx(g,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):t.jsx(g,{to:"/notes",className:"btn btn-secondary btn-touch",children:"Back to notes"})})}export{st as NoteView};
@@ -1 +1 @@
1
- import{C as R,b as U,a as u,r as d,b4 as z,b5 as E,b6 as I,b7 as C,k as A,b8 as H,b9 as O,j as e,P as p}from"./index-DEEhPpPi.js";import{W as m}from"./WizardShell-C6s4rjvR.js";import{s as P}from"./url-QSQwrjSV.js";import"./history-D-PT8sXa.js";function $(r){try{return new URL(r).host}catch{return"your hub"}}function W(){const[r]=R(),i=U(),h=u(s=>s.addVault),[n,l]=d.useState({kind:"working"}),f=d.useRef(!1);if(d.useEffect(()=>{if(f.current)return;f.current=!0;const s=r.get("code"),x=r.get("state"),b=r.get("error");if(b){const o=r.get("error_description");l({kind:"error",message:`Vault returned: ${b}${o?` — ${o}`:""}`});return}if(!s||!x){l({kind:"error",message:"Missing code or state in callback URL."});return}(async()=>{var o,g,v,j;try{const{pending:t,token:a}=await z(s,x),k=a.vault?`vault:${a.vault}`:void 0,N=(k?(g=(o=a.services)==null?void 0:o[k])==null?void 0:g.url:void 0)??((j=(v=a.services)==null?void 0:v.vault)==null?void 0:j.url)??t.issuerUrl,S=u.getState().activeVaultId,c=h({url:N,name:a.vault??t.issuer,issuer:t.issuer,tokenEndpoint:t.tokenEndpoint,clientId:t.clientId,scope:a.scope},E(a));a.services&&I(c,a.services);const y=C.getState();y.clearHalt(c),t.priorHaltedVaultId&&t.priorHaltedVaultId!==c&&y.clearHalt(t.priorHaltedVaultId);const V=P(t.redirect)??"/";if(c!==S){const w=u.getState().vaults[c];w&&A(H(w))}i(V,{replace:!0})}catch(t){if(t instanceof O){l({kind:"pending-approval",approveUrl:t.approveUrl});return}l({kind:"error",message:t.message})}})()},[r,i,h]),n.kind==="working")return e.jsxs(m,{escape:{kind:"none"},children:[e.jsx(p,{size:72,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-2",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:["Connecting",e.jsx("span",{className:"accent-word",children:"…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Exchanging the authorization code with your vault."})]});if(n.kind==="pending-approval"){const s=$(n.approveUrl);return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Redirected"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Approving Parachute on ",e.jsx("span",{className:"accent-word",children:s})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:"Your hub admin needs to approve this app before sign-in can complete. Open the approval page in your hub, approve, then try again."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[e.jsx("a",{href:n.approveUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Open approval page →"}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"font-round text-sm font-semibold text-fg-dim hover:text-accent",children:"Retry now"})]})]})}return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Connection failed"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Something went ",e.jsx("span",{className:"accent-word",children:"sideways."})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:n.message}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again →"})]})}export{W as OAuthCallback};
1
+ import{C as R,b as U,a as u,r as d,b5 as z,b6 as E,b7 as I,b8 as C,k as A,b9 as H,ba as O,j as e,P as p}from"./index-q-OceM-D.js";import{W as m}from"./WizardShell-X-_3n8Lx.js";import{s as P}from"./url-QSQwrjSV.js";import"./history-Bxu3eq1m.js";function $(r){try{return new URL(r).host}catch{return"your hub"}}function W(){const[r]=R(),i=U(),h=u(s=>s.addVault),[n,l]=d.useState({kind:"working"}),f=d.useRef(!1);if(d.useEffect(()=>{if(f.current)return;f.current=!0;const s=r.get("code"),x=r.get("state"),b=r.get("error");if(b){const o=r.get("error_description");l({kind:"error",message:`Vault returned: ${b}${o?` — ${o}`:""}`});return}if(!s||!x){l({kind:"error",message:"Missing code or state in callback URL."});return}(async()=>{var o,g,v,j;try{const{pending:t,token:a}=await z(s,x),k=a.vault?`vault:${a.vault}`:void 0,N=(k?(g=(o=a.services)==null?void 0:o[k])==null?void 0:g.url:void 0)??((j=(v=a.services)==null?void 0:v.vault)==null?void 0:j.url)??t.issuerUrl,S=u.getState().activeVaultId,c=h({url:N,name:a.vault??t.issuer,issuer:t.issuer,tokenEndpoint:t.tokenEndpoint,clientId:t.clientId,scope:a.scope},E(a));a.services&&I(c,a.services);const y=C.getState();y.clearHalt(c),t.priorHaltedVaultId&&t.priorHaltedVaultId!==c&&y.clearHalt(t.priorHaltedVaultId);const V=P(t.redirect)??"/";if(c!==S){const w=u.getState().vaults[c];w&&A(H(w))}i(V,{replace:!0})}catch(t){if(t instanceof O){l({kind:"pending-approval",approveUrl:t.approveUrl});return}l({kind:"error",message:t.message})}})()},[r,i,h]),n.kind==="working")return e.jsxs(m,{escape:{kind:"none"},children:[e.jsx(p,{size:72,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-2",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:["Connecting",e.jsx("span",{className:"accent-word",children:"…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Exchanging the authorization code with your vault."})]});if(n.kind==="pending-approval"){const s=$(n.approveUrl);return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Redirected"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Approving Parachute on ",e.jsx("span",{className:"accent-word",children:s})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:"Your hub admin needs to approve this app before sign-in can complete. Open the approval page in your hub, approve, then try again."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[e.jsx("a",{href:n.approveUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Open approval page →"}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"font-round text-sm font-semibold text-fg-dim hover:text-accent",children:"Retry now"})]})]})}return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Connection failed"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Something went ",e.jsx("span",{className:"accent-word",children:"sideways."})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:n.message}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again →"})]})}export{W as OAuthCallback};
@@ -1 +1 @@
1
- import{r as l,j as t,b as v,a8 as h,b3 as j,V as y,a as w,a3 as E,al as N}from"./index-DEEhPpPi.js";function P({note:a,className:d,label:c="Delete"}){const[r,o]=l.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>o(!0),className:d??"min-h-11 rounded-lg 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:c}),r?t.jsx(k,{note:a,onClose:()=>o(!1)}):null]})}function k({note:a,onClose:d}){const c=v(),r=h(e=>e.push),o=j(),i=a.path??a.id,[f,p]=l.useState(""),[u,b]=l.useState(null),x=l.useRef(null),s=f===i&&!o.isPending;l.useEffect(()=>{var e;(e=x.current)==null||e.focus()},[]),l.useEffect(()=>{const e=m=>{m.key==="Escape"&&d()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d]);const n=l.useCallback(()=>{s&&(b(null),o.mutate(a.id,{onSuccess:()=>{r(`Deleted ${i}`,"success"),c("/",{replace:!0})},onError:e=>{e instanceof y?b("Session expired. Reconnect to delete."):b(e instanceof Error?e.message:"Delete failed")}}))},[s,i,o,c,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&&d()},children:t.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",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:i})," ","to confirm:"]}),t.jsx("input",{ref:x,type:"text",value:f,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-lg 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:i,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:d,className:"min-h-11 rounded-lg 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:"btn btn-danger-solid btn-touch",children:o.isPending?"Deleting…":"Delete permanently"})]})]})})}function C({note:a,keyboard:d=!1}){var b,x;const c=w(s=>s.getActiveVault()),{roles:r}=E((c==null?void 0:c.id)??null),o=h(s=>s.push),i=N(a.id),f=((b=a.tags)==null?void 0:b.includes(r.pinned))??!1,p=((x=a.tags)==null?void 0:x.includes(r.archived))??!1,u=l.useCallback(s=>{var m;if(i.isPending)return;const n=r[s],e=((m=a.tags)==null?void 0:m.includes(n))??!1;i.mutate({tags:e?{remove:[n]}:{add:[n]}},{onSuccess:()=>{o(s==="pinned"?e?"Unpinned":"Pinned":e?"Unarchived":"Archived","success")},onError:g=>{g instanceof y?o("Session expired. Reconnect.","error"):o(g instanceof Error?g.message:"Update failed","error")}})},[i,a.tags,o,r]);return l.useEffect(()=>{if(!d)return;const s=n=>{if(n.defaultPrevented)return;const e=n.target;if(e){const m=e.tagName;if(m==="INPUT"||m==="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)},[d,u]),t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>u("pinned"),disabled:i.isPending,"aria-pressed":f,title:f?`Unpin (${r.pinned})`:`Pin as #${r.pinned} (P)`,className:f?"min-h-11 rounded-lg 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-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:f?"★ Pinned":"☆ Pin"}),t.jsx("button",{type:"button",onClick:()=>u("archived"),disabled:i.isPending,"aria-pressed":p,title:p?`Unarchive (${r.archived})`:`Archive as #${r.archived} (A)`,className:p?"min-h-11 rounded-lg 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-lg 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};
1
+ import{r as l,j as t,b as v,a8 as h,b4 as j,V as y,a as w,a3 as E,al as N}from"./index-q-OceM-D.js";function P({note:a,className:d,label:c="Delete"}){const[r,o]=l.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>o(!0),className:d??"min-h-11 rounded-lg 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:c}),r?t.jsx(k,{note:a,onClose:()=>o(!1)}):null]})}function k({note:a,onClose:d}){const c=v(),r=h(e=>e.push),o=j(),i=a.path??a.id,[f,p]=l.useState(""),[u,b]=l.useState(null),x=l.useRef(null),s=f===i&&!o.isPending;l.useEffect(()=>{var e;(e=x.current)==null||e.focus()},[]),l.useEffect(()=>{const e=m=>{m.key==="Escape"&&d()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d]);const n=l.useCallback(()=>{s&&(b(null),o.mutate(a.id,{onSuccess:()=>{r(`Deleted ${i}`,"success"),c("/",{replace:!0})},onError:e=>{e instanceof y?b("Session expired. Reconnect to delete."):b(e instanceof Error?e.message:"Delete failed")}}))},[s,i,o,c,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&&d()},children:t.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",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:i})," ","to confirm:"]}),t.jsx("input",{ref:x,type:"text",value:f,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-lg 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:i,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:d,className:"min-h-11 rounded-lg 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:"btn btn-danger-solid btn-touch",children:o.isPending?"Deleting…":"Delete permanently"})]})]})})}function C({note:a,keyboard:d=!1}){var b,x;const c=w(s=>s.getActiveVault()),{roles:r}=E((c==null?void 0:c.id)??null),o=h(s=>s.push),i=N(a.id),f=((b=a.tags)==null?void 0:b.includes(r.pinned))??!1,p=((x=a.tags)==null?void 0:x.includes(r.archived))??!1,u=l.useCallback(s=>{var m;if(i.isPending)return;const n=r[s],e=((m=a.tags)==null?void 0:m.includes(n))??!1;i.mutate({tags:e?{remove:[n]}:{add:[n]}},{onSuccess:()=>{o(s==="pinned"?e?"Unpinned":"Pinned":e?"Unarchived":"Archived","success")},onError:g=>{g instanceof y?o("Session expired. Reconnect.","error"):o(g instanceof Error?g.message:"Update failed","error")}})},[i,a.tags,o,r]);return l.useEffect(()=>{if(!d)return;const s=n=>{if(n.defaultPrevented)return;const e=n.target;if(e){const m=e.tagName;if(m==="INPUT"||m==="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)},[d,u]),t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>u("pinned"),disabled:i.isPending,"aria-pressed":f,title:f?`Unpin (${r.pinned})`:`Pin as #${r.pinned} (P)`,className:f?"min-h-11 rounded-lg 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-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-accent disabled:opacity-40",children:f?"★ Pinned":"☆ Pin"}),t.jsx("button",{type:"button",onClick:()=>u("archived"),disabled:i.isPending,"aria-pressed":p,title:p?`Unarchive (${r.archived})`:`Archive as #${r.archived} (A)`,className:p?"min-h-11 rounded-lg 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-lg 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};
@@ -1 +1 @@
1
- import{a as T,j as e,N as C,L as v,ba as k,a8 as y,r as d,bb as E,bc as A,bd as O,be as R,bf as L,a3 as M,bg as P,bh as N,bi as g,az as $,bj as _,bk as I,A as z,bl as D,b as V,u as B,g as F,bm as G,bn as H,h as U,i as Y,bo as K}from"./index-DEEhPpPi.js";import{u as q,a as Q,b as W,c as X}from"./transcribe-default-Vo4Gqy9l.js";import{r as Z,w as J}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";function pe(){const t=T(a=>a.getActiveVault());return t?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(v,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsx("p",{className:"eyebrow mb-1",children:t.name}),e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Everything about this vault, in one calm place."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(ee,{}),e.jsx(se,{}),e.jsx(ne,{vaultId:t.id}),e.jsx(ie,{}),e.jsx(re,{}),e.jsx(de,{vaultId:t.id}),e.jsx(ue,{vaultId:t.id}),e.jsx(le,{vaultId:t.id}),e.jsx(oe,{})]})]}):e.jsx(C,{to:"/",replace:!0})}function ee(){return e.jsxs("section",{"aria-label":"Manage",children:[e.jsx("h2",{className:"eyebrow mb-3",children:"Manage"}),e.jsxs("div",{className:"card divide-y divide-border rounded-xl shadow-soft",children:[e.jsx(b,{to:"/account",title:"Account",description:"Your plan, billing, hosted vaults, and sign-in — managed in the app."}),e.jsx(te,{}),e.jsx(b,{to:"/connect",title:"Connections",description:"Connect Claude, ChatGPT, or any MCP client to this vault."}),e.jsx(b,{to:"/vaults",title:"Vaults",description:"Add a vault, switch between them, or export."})]})]})}function te(){const t=V(),a=B(r=>r.identityEpoch),[n,s]=d.useState(null),[i,u]=d.useState(!1);if(d.useEffect(()=>{let r=!0;return F().then(o=>{r&&s(o.signed_in?{identity:o.email??o.username??null,csrf:o.csrf}:null)}).catch(()=>{r&&s(null)}),()=>{r=!1}},[a]),!n)return null;const{identity:c,csrf:h}=n;async function x(){u(!0);try{await U(h)}finally{Y(),t("/",{replace:!0})}}return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-5 py-4",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"block font-medium text-fg",children:["Signed in",c?` as ${c}`:""]}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:"Signing out ends your account session on this device. Vaults already connected here stay until you remove them."})]}),e.jsx("button",{type:"button",onClick:x,disabled:i,className:"btn btn-secondary btn-touch shrink-0",children:i?"Signing out…":"Sign out"})]})}function b({to:t,href:a,title:n,description:s}){const i=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium text-fg",children:n}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:s})]}),e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-dim",children:a?"↗":"→"})]}),u="focus-ring flex items-center justify-between gap-4 px-5 py-4 transition-colors hover:bg-bg-soft first:rounded-t-xl last:rounded-b-xl";return a?e.jsx("a",{href:a,className:u,children:i}):e.jsx(v,{to:t??"/",className:u,children:i})}function se(){return e.jsxs("section",{className:"card space-y-3 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Import notes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Bring in an Obsidian vault zip or a folder of markdown files. Parsed in your browser; previewed before any note lands in the vault."})]}),e.jsx(v,{to:"/import",className:"btn btn-primary btn-touch",children:"Open importer"})]})}const ae=[{value:"keep",title:"Keep",help:"Recordings are stored with your notes; included wherever attachments are included."},{value:"until_transcribed",title:"Delete after transcribing",help:"Your words stay; the audio file is removed once the transcript lands."},{value:"never",title:"Never store",help:"Audio is removed even if transcription fails — the transcript is your only copy; failed transcriptions lose the audio."}];function ne({vaultId:t}){const a=k(),n=q(),s=Q(),{markMade:i}=W(t),{transcribeDefault:u,setTranscribeDefault:c}=X(t),h=y(r=>r.push);if((a==null?void 0:a.enabled)===!1)return null;const x=r=>{r===n.value||s.isPending||s.mutate(r,{onSuccess:()=>{i(),h("Voice recording setting saved.","success")},onError:o=>{h(o instanceof Error&&o.message?`Couldn't save: ${o.message}`:"Couldn't save the voice recording setting.","error")}})};return e.jsxs("section",{className:"card space-y-6 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Voice"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"How voice capture behaves in this vault."})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Transcribe recordings by default"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"New voice notes start with transcription on — your words are added to the note. Turn it off for a single recording right where you capture. Applies on this device."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":u,"aria-label":"Transcribe recordings by default","data-testid":"transcribe-default-toggle",onClick:()=>c(!u),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${u?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${u?"translate-x-5":"translate-x-0.5"}`})})]}),e.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Keep recordings"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"What happens to the audio file after a voice note is transcribed. Applies to this vault, from every device connected to it."})]}),n.isLoading?e.jsx("p",{className:"text-sm text-fg-dim",children:"Loading…"}):n.isError?e.jsx("p",{className:"text-sm text-fg-dim","data-testid":"retention-load-error",children:"Couldn't load this setting — check the vault connection."}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"space-y-2",disabled:!n.supported||s.isPending,children:[e.jsx("legend",{className:"sr-only",children:"Voice recording retention"}),ae.map(r=>{const o=n.value===r.value;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${o?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"audio-retention",value:r.value,checked:o,onChange:()=>x(r.value),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:r.title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r.help})]})]},r.value)})]}),n.supported?null:e.jsx("p",{className:"text-xs text-fg-dim","data-testid":"retention-unsupported",children:"This vault doesn't support changing this yet — recordings are kept. Update the vault to choose."})]})]})]})}function ie(){const[t,a]=d.useState(()=>Z()),n=s=>{a(s),J(s)};return e.jsx("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Live preview"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Formats your writing as you type — Markdown stays underneath. Turn off for the raw editor with a side-by-side preview."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Live preview",onClick:()=>n(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})})}function re(){const[t,a]=d.useState(()=>E()),n=s=>{a(s),G(s),H(s)};return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Text size"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Affects the editor and rendered notes on this device. Your markdown isn't changed."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"View text size"}),A.map(s=>{const i=t===s;return e.jsxs("label",{className:`flex items-center gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"text-size",value:s,checked:i,onChange:()=>n(s),className:"accent-accent"}),e.jsx("span",{className:"font-medium text-fg",children:O(s)})]},s)})]})]})}function le({vaultId:t}){const{db:a,mirror:n}=$(),s=y(m=>m.push),[i,u]=d.useState(null),[c,h]=d.useState(null),x=d.useCallback(async()=>{if(!a)return;const[m,l]=await Promise.all([_(a,t),I(a,t)]);u({bytes:m,count:l})},[a,t]);if(d.useEffect(()=>{x()},[x]),!n.enabled)return null;const r=async()=>{if(!c){h("sync");try{await n.syncNow(),await x(),s("Synced offline copy.","success")}catch{s("Couldn't sync the offline copy right now.","error")}finally{h(null)}}},o=async()=>{if(!c&&confirm("Clear this vault's offline copy from this device? Un-synced changes are kept.")){h("clear");try{await n.clearOffline(),await x(),s("Offline copy cleared.","success")}catch{s("Couldn't clear the offline copy.","error")}finally{h(null)}}};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft","aria-label":"Offline",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Offline"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"A copy of this vault is kept on this device so your notes open without a connection."})]}),e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Status"}),e.jsx("dd",{className:"text-fg",children:ce(n.state)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Last synced"}),e.jsx("dd",{className:"text-fg-muted",children:n.lastSyncedAt?z(new Date(n.lastSyncedAt).toISOString()):"never"})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Saved on this device"}),e.jsx("dd",{className:"text-fg-muted tabular-nums","data-testid":"offline-usage",children:i?`${i.count} note${i.count===1?"":"s"} · ${w(i.bytes)} of ${w(K)}`:"—"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[e.jsx("button",{type:"button",onClick:r,disabled:c!==null,className:"btn btn-secondary btn-touch",children:c==="sync"?"Syncing…":"Sync now"}),e.jsx("button",{type:"button",onClick:o,disabled:c!==null,className:"text-sm text-danger hover:underline disabled:opacity-60",children:c==="clear"?"Clearing…":"Clear offline copy"})]})]})}function ce(t){switch(t){case"hydrating":return"Saving your vault…";case"offline":return"Offline — showing your saved vault";case"error":return"Sync error";default:return"Saved for offline"}}function w(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function oe(){const[t,a]=d.useState(!1);return d.useEffect(()=>{a(D())},[]),t?e.jsx("section",{className:"card rounded-xl p-6 text-sm shadow-soft",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-positive-soft px-2 py-0.5 text-xs font-medium text-positive",children:"Installed"}),"Parachute is running as an installed app on this device."]})}):null}const S={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 de({vaultId:t}){const{mode:a,setMode:n}=R(t);return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",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-sm text-fg-muted",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"}),L.map(s=>{const i=a===s;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:s,checked:i,onChange:()=>n(s),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:S[s].title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:S[s].help})]})]},s)})]})]})}const j={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 that view notes carry. Used to list them in the Views band."}};function ue({vaultId:t}){const{roles:a,setRoles:n}=M(t),s=P(),i=y(l=>l.push),u=d.useId(),[c,h]=d.useState(a);d.useEffect(()=>h(a),[a]);const x=d.useMemo(()=>{const l=(s.data??[]).map(f=>f.name);return[...new Set(l)].sort((f,p)=>f.localeCompare(p))},[s.data]),r=N.some(l=>c[l].trim()!==a[l]),o=()=>{n(c),i("Tag roles saved.","success")},m=()=>{n(null),h(g),i("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft",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-sm text-fg-muted",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:x.map(l=>e.jsx("option",{value:l},l))}),e.jsx("div",{className:"space-y-4",children:N.map(l=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1.5 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-fg",children:j[l].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",g[l]]})]}),e.jsx("input",{type:"text",value:c[l],onChange:f=>h(p=>({...p,[l]:f.target.value})),list:u,placeholder:g[l],"aria-label":`${j[l].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"input input-on-bg"}),e.jsx("span",{className:"mt-1.5 block text-xs text-fg-dim",children:j[l].help})]},l))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 pt-1",children:[e.jsx("button",{type:"button",onClick:o,disabled:!r,className:"btn btn-primary btn-lg",children:"Save"}),e.jsx("button",{type:"button",onClick:m,className:"btn btn-ghost",children:"Reset to defaults"})]})]})}export{pe as Settings};
1
+ import{a as T,j as e,N as C,L as v,bb as k,a8 as y,r as d,bc as E,bd as A,be as O,bf as R,bg as L,a3 as M,bh as P,bi as N,bj as g,az as $,bk as _,bl as I,A as z,bm as D,b as V,u as B,g as F,bn as G,bo as H,h as U,i as Y,bp as K}from"./index-q-OceM-D.js";import{u as q,a as Q,b as W,c as X}from"./transcribe-default-aMtRgXlN.js";import{r as Z,w as J}from"./editor-mode-D9fveTEx.js";import"./types-BaJkUfo6.js";function pe(){const t=T(a=>a.getActiveVault());return t?e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(v,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsx("p",{className:"eyebrow mb-1",children:t.name}),e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Everything about this vault, in one calm place."})]}),e.jsxs("div",{className:"space-y-8",children:[e.jsx(ee,{}),e.jsx(se,{}),e.jsx(ne,{vaultId:t.id}),e.jsx(ie,{}),e.jsx(re,{}),e.jsx(de,{vaultId:t.id}),e.jsx(ue,{vaultId:t.id}),e.jsx(le,{vaultId:t.id}),e.jsx(oe,{})]})]}):e.jsx(C,{to:"/",replace:!0})}function ee(){return e.jsxs("section",{"aria-label":"Manage",children:[e.jsx("h2",{className:"eyebrow mb-3",children:"Manage"}),e.jsxs("div",{className:"card divide-y divide-border rounded-xl shadow-soft",children:[e.jsx(b,{to:"/account",title:"Account",description:"Your plan, billing, hosted vaults, and sign-in — managed in the app."}),e.jsx(te,{}),e.jsx(b,{to:"/connect",title:"Connections",description:"Connect Claude, ChatGPT, or any MCP client to this vault."}),e.jsx(b,{to:"/vaults",title:"Vaults",description:"Add a vault, switch between them, or export."})]})]})}function te(){const t=V(),a=B(r=>r.identityEpoch),[n,s]=d.useState(null),[i,u]=d.useState(!1);if(d.useEffect(()=>{let r=!0;return F().then(o=>{r&&s(o.signed_in?{identity:o.email??o.username??null,csrf:o.csrf}:null)}).catch(()=>{r&&s(null)}),()=>{r=!1}},[a]),!n)return null;const{identity:c,csrf:h}=n;async function x(){u(!0);try{await U(h)}finally{Y(),t("/",{replace:!0})}}return e.jsxs("div",{className:"flex items-center justify-between gap-4 px-5 py-4",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"block font-medium text-fg",children:["Signed in",c?` as ${c}`:""]}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:"Signing out ends your account session on this device. Vaults already connected here stay until you remove them."})]}),e.jsx("button",{type:"button",onClick:x,disabled:i,className:"btn btn-secondary btn-touch shrink-0",children:i?"Signing out…":"Sign out"})]})}function b({to:t,href:a,title:n,description:s}){const i=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block font-medium text-fg",children:n}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:s})]}),e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-dim",children:a?"↗":"→"})]}),u="focus-ring flex items-center justify-between gap-4 px-5 py-4 transition-colors hover:bg-bg-soft first:rounded-t-xl last:rounded-b-xl";return a?e.jsx("a",{href:a,className:u,children:i}):e.jsx(v,{to:t??"/",className:u,children:i})}function se(){return e.jsxs("section",{className:"card space-y-3 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Import notes"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Bring in an Obsidian vault zip or a folder of markdown files. Parsed in your browser; previewed before any note lands in the vault."})]}),e.jsx(v,{to:"/import",className:"btn btn-primary btn-touch",children:"Open importer"})]})}const ae=[{value:"keep",title:"Keep",help:"Recordings are stored with your notes; included wherever attachments are included."},{value:"until_transcribed",title:"Delete after transcribing",help:"Your words stay; the audio file is removed once the transcript lands."},{value:"never",title:"Never store",help:"Audio is removed even if transcription fails — the transcript is your only copy; failed transcriptions lose the audio."}];function ne({vaultId:t}){const a=k(),n=q(),s=Q(),{markMade:i}=W(t),{transcribeDefault:u,setTranscribeDefault:c}=X(t),h=y(r=>r.push);if((a==null?void 0:a.enabled)===!1)return null;const x=r=>{r===n.value||s.isPending||s.mutate(r,{onSuccess:()=>{i(),h("Voice recording setting saved.","success")},onError:o=>{h(o instanceof Error&&o.message?`Couldn't save: ${o.message}`:"Couldn't save the voice recording setting.","error")}})};return e.jsxs("section",{className:"card space-y-6 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Voice"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"How voice capture behaves in this vault."})]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Transcribe recordings by default"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"New voice notes start with transcription on — your words are added to the note. Turn it off for a single recording right where you capture. Applies on this device."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":u,"aria-label":"Transcribe recordings by default","data-testid":"transcribe-default-toggle",onClick:()=>c(!u),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${u?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${u?"translate-x-5":"translate-x-0.5"}`})})]}),e.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-fg",children:"Keep recordings"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"What happens to the audio file after a voice note is transcribed. Applies to this vault, from every device connected to it."})]}),n.isLoading?e.jsx("p",{className:"text-sm text-fg-dim",children:"Loading…"}):n.isError?e.jsx("p",{className:"text-sm text-fg-dim","data-testid":"retention-load-error",children:"Couldn't load this setting — check the vault connection."}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"space-y-2",disabled:!n.supported||s.isPending,children:[e.jsx("legend",{className:"sr-only",children:"Voice recording retention"}),ae.map(r=>{const o=n.value===r.value;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${o?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"audio-retention",value:r.value,checked:o,onChange:()=>x(r.value),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:r.title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:r.help})]})]},r.value)})]}),n.supported?null:e.jsx("p",{className:"text-xs text-fg-dim","data-testid":"retention-unsupported",children:"This vault doesn't support changing this yet — recordings are kept. Update the vault to choose."})]})]})]})}function ie(){const[t,a]=d.useState(()=>Z()),n=s=>{a(s),J(s)};return e.jsx("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Live preview"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Formats your writing as you type — Markdown stays underneath. Turn off for the raw editor with a side-by-side preview."})]}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Live preview",onClick:()=>n(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})})}function re(){const[t,a]=d.useState(()=>E()),n=s=>{a(s),G(s),H(s)};return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Text size"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"Affects the editor and rendered notes on this device. Your markdown isn't changed."})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"sr-only",children:"View text size"}),A.map(s=>{const i=t===s;return e.jsxs("label",{className:`flex items-center gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"text-size",value:s,checked:i,onChange:()=>n(s),className:"accent-accent"}),e.jsx("span",{className:"font-medium text-fg",children:O(s)})]},s)})]})]})}function le({vaultId:t}){const{db:a,mirror:n}=$(),s=y(m=>m.push),[i,u]=d.useState(null),[c,h]=d.useState(null),x=d.useCallback(async()=>{if(!a)return;const[m,l]=await Promise.all([_(a,t),I(a,t)]);u({bytes:m,count:l})},[a,t]);if(d.useEffect(()=>{x()},[x]),!n.enabled)return null;const r=async()=>{if(!c){h("sync");try{await n.syncNow(),await x(),s("Synced offline copy.","success")}catch{s("Couldn't sync the offline copy right now.","error")}finally{h(null)}}},o=async()=>{if(!c&&confirm("Clear this vault's offline copy from this device? Un-synced changes are kept.")){h("clear");try{await n.clearOffline(),await x(),s("Offline copy cleared.","success")}catch{s("Couldn't clear the offline copy.","error")}finally{h(null)}}};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft","aria-label":"Offline",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-serif text-xl text-fg",children:"Offline"}),e.jsx("p",{className:"mt-1 text-sm text-fg-muted",children:"A copy of this vault is kept on this device so your notes open without a connection."})]}),e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Status"}),e.jsx("dd",{className:"text-fg",children:ce(n.state)})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Last synced"}),e.jsx("dd",{className:"text-fg-muted",children:n.lastSyncedAt?z(new Date(n.lastSyncedAt).toISOString()):"never"})]}),e.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[e.jsx("dt",{className:"text-fg-muted",children:"Saved on this device"}),e.jsx("dd",{className:"text-fg-muted tabular-nums","data-testid":"offline-usage",children:i?`${i.count} note${i.count===1?"":"s"} · ${w(i.bytes)} of ${w(K)}`:"—"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-1",children:[e.jsx("button",{type:"button",onClick:r,disabled:c!==null,className:"btn btn-secondary btn-touch",children:c==="sync"?"Syncing…":"Sync now"}),e.jsx("button",{type:"button",onClick:o,disabled:c!==null,className:"text-sm text-danger hover:underline disabled:opacity-60",children:c==="clear"?"Clearing…":"Clear offline copy"})]})]})}function ce(t){switch(t){case"hydrating":return"Saving your vault…";case"offline":return"Offline — showing your saved vault";case"error":return"Sync error";default:return"Saved for offline"}}function w(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function oe(){const[t,a]=d.useState(!1);return d.useEffect(()=>{a(D())},[]),t?e.jsx("section",{className:"card rounded-xl p-6 text-sm shadow-soft",children:e.jsxs("p",{className:"text-fg-muted",children:[e.jsx("span",{className:"mr-2 inline-block rounded-full bg-positive-soft px-2 py-0.5 text-xs font-medium text-positive",children:"Installed"}),"Parachute is running as an installed app on this device."]})}):null}const S={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 de({vaultId:t}){const{mode:a,setMode:n}=R(t);return e.jsxs("section",{className:"card space-y-4 rounded-xl p-6 shadow-soft",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-sm text-fg-muted",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"}),L.map(s=>{const i=a===s;return e.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 transition-colors ${i?"border-accent bg-accent/5":"border-border hover:border-accent/40"}`,children:[e.jsx("input",{type:"radio",name:"path-tree-mode",value:s,checked:i,onChange:()=>n(s),className:"mt-1 accent-accent"}),e.jsxs("span",{children:[e.jsx("span",{className:"block font-medium text-fg",children:S[s].title}),e.jsx("span",{className:"mt-0.5 block text-sm text-fg-muted",children:S[s].help})]})]},s)})]})]})}const j={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 that view notes carry. Used to list them in the Views band."}};function ue({vaultId:t}){const{roles:a,setRoles:n}=M(t),s=P(),i=y(l=>l.push),u=d.useId(),[c,h]=d.useState(a);d.useEffect(()=>h(a),[a]);const x=d.useMemo(()=>{const l=(s.data??[]).map(f=>f.name);return[...new Set(l)].sort((f,p)=>f.localeCompare(p))},[s.data]),r=N.some(l=>c[l].trim()!==a[l]),o=()=>{n(c),i("Tag roles saved.","success")},m=()=>{n(null),h(g),i("Tag roles reset to defaults.","success")};return e.jsxs("section",{className:"card space-y-5 rounded-xl p-6 shadow-soft",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-sm text-fg-muted",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:x.map(l=>e.jsx("option",{value:l},l))}),e.jsx("div",{className:"space-y-4",children:N.map(l=>e.jsxs("label",{className:"block text-sm",children:[e.jsxs("span",{className:"mb-1.5 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-fg",children:j[l].title}),e.jsxs("span",{className:"text-xs text-fg-dim",children:["default: #",g[l]]})]}),e.jsx("input",{type:"text",value:c[l],onChange:f=>h(p=>({...p,[l]:f.target.value})),list:u,placeholder:g[l],"aria-label":`${j[l].title} tag role`,spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"input input-on-bg"}),e.jsx("span",{className:"mt-1.5 block text-xs text-fg-dim",children:j[l].help})]},l))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 pt-1",children:[e.jsx("button",{type:"button",onClick:o,disabled:!r,className:"btn btn-primary btn-lg",children:"Save"}),e.jsx("button",{type:"button",onClick:m,className:"btn btn-ghost",children:"Reset to defaults"})]})]})}export{pe as Settings};
@@ -1 +1 @@
1
- import{bv as o,ag as x,a as l,bw as h,j as e,N as c,L as g,y as r,a3 as j,r as f}from"./index-DEEhPpPi.js";import{ViewCanvas as m}from"./ViewSurface-CIpzYIN8.js";import"./TagSchemaEditor-B-d3rSjI.js";function v(t,s,a){const i=s!=null&&s.fields?Object.keys(s.fields).length:0,n={tag:t};return t!==a.archived&&(n.exclude_tags=[a.archived]),n.sort="desc",n.limit=o,{noteId:`derived:tag:${t}`,title:t,kind:i>=1?"table":"list",query:n,problems:[]}}function u(){return e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(g,{to:"/tags",className:"focus-ring hover:text-accent",children:"← Tags"})})}function N(){const{name:t}=x(),s=l(i=>i.getActiveVault()),a=h(t??null);return s?t?a.isPending?e.jsxs("div",{className:"page",children:[e.jsx(u,{}),e.jsx(T,{})]}):e.jsx(p,{name:t,tag:a.data??null}):e.jsx(c,{to:"/tags",replace:!0}):e.jsx(c,{to:"/",replace:!0})}function p({name:t,tag:s}){const a=l(d=>d.getActiveVault()),{roles:i}=j((a==null?void 0:a.id)??null),n=f.useMemo(()=>v(t,s,i),[t,s,i]);return e.jsx(m,{def:n,backingNote:null,pageSize:o,total:s==null?void 0:s.count,nav:e.jsx(u,{})})}function T(){return e.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[e.jsx(r,{height:32,width:"40%"}),e.jsx(r,{height:20,width:"60%"}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(r,{height:56}),e.jsx(r,{height:56}),e.jsx(r,{height:56})]})]})}export{N as TagPage};
1
+ import{bw as o,ag as x,a as l,bx as h,j as e,N as c,L as g,y as r,a3 as j,r as f}from"./index-q-OceM-D.js";import{ViewCanvas as m}from"./ViewSurface-CEipyYaB.js";import"./TagSchemaEditor-CUHG09YZ.js";function v(t,s,a){const i=s!=null&&s.fields?Object.keys(s.fields).length:0,n={tag:t};return t!==a.archived&&(n.exclude_tags=[a.archived]),n.sort="desc",n.limit=o,{noteId:`derived:tag:${t}`,title:t,kind:i>=1?"table":"list",query:n,problems:[]}}function u(){return e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(g,{to:"/tags",className:"focus-ring hover:text-accent",children:"← Tags"})})}function N(){const{name:t}=x(),s=l(i=>i.getActiveVault()),a=h(t??null);return s?t?a.isPending?e.jsxs("div",{className:"page",children:[e.jsx(u,{}),e.jsx(T,{})]}):e.jsx(p,{name:t,tag:a.data??null}):e.jsx(c,{to:"/tags",replace:!0}):e.jsx(c,{to:"/",replace:!0})}function p({name:t,tag:s}){const a=l(d=>d.getActiveVault()),{roles:i}=j((a==null?void 0:a.id)??null),n=f.useMemo(()=>v(t,s,i),[t,s,i]);return e.jsx(m,{def:n,backingNote:null,pageSize:o,total:s==null?void 0:s.count,nav:e.jsx(u,{})})}function T(){return e.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[e.jsx(r,{height:32,width:"40%"}),e.jsx(r,{height:20,width:"60%"}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(r,{height:56}),e.jsx(r,{height:56}),e.jsx(r,{height:56})]})]})}export{N as TagPage};
@@ -1 +1 @@
1
- import{bw as V,cc as _,r as u,j as e,V as K}from"./index-DEEhPpPi.js";const q=["string","number","boolean","date"];let C=0;function g(){return C+=1,`row-${C}`}function z(s){return s?Object.entries(s).map(([n,l])=>{var i;return{rowId:g(),name:n,type:l.type||"string",values:((i=l.enum)==null?void 0:i.join(", "))??""}}):[]}function L(s){return s==="date"?{rowId:g(),name:"",type:"date"}:{rowId:g(),name:"",type:"string",values:""}}function B({tagName:s,intent:n,onSaved:l,onClose:i}){var I;const a=V(s),d=_(),[j,v]=u.useState(""),[f,x]=u.useState([]),[N,w]=u.useState(""),[k,T]=u.useState(!1),[E,p]=u.useState(null);u.useEffect(()=>{if(k||a.isPending)return;const t=a.data;let r=[];t&&(v(t.description??""),r=z(t.fields),w((t.parent_names??[]).join(", ")));const m=n==="date"?r.some(c=>c.type==="date"):r.length>0;n&&!m&&(r=[...r,L(n)]),x(r),T(!0)},[k,a.isPending,a.data,n]);const h=((I=a.data)==null?void 0:I.fields)??null,P=!M(h,S(f)),b=(t,r)=>{x(m=>m.map(c=>c.rowId===t?{...c,...r}:c))},D=()=>{x(t=>[...t,{rowId:g(),name:"",type:"string"}])},R=t=>{x(r=>r.filter(m=>m.rowId!==t))},A=async()=>{p(null);const t=f.map(o=>({...o,name:o.name.trim()}));if(t.filter(o=>o.name.length===0).length>0){p("Field names can't be blank. Remove the empty row or fill it in.");return}const m=new Set;for(const o of t){if(m.has(o.name)){p(`Duplicate field name "${o.name}". Each field needs a unique key.`);return}m.add(o.name)}const c=t.length>0?S(t):null,$=h!=null&&Object.keys(h).some(o=>!t.find(O=>O.name===o)),F=N.split(",").map(o=>o.trim()).filter(o=>o.length>0),y={description:j.trim()||null,parent_names:F.length>0?F:null};try{$?(await d.mutateAsync({name:s,payload:{...y,fields:null}}),c&&await d.mutateAsync({name:s,payload:{...y,fields:c}})):await d.mutateAsync({name:s,payload:{...y,fields:c}}),l==null||l(c??{}),i()}catch(o){if(o instanceof K){p("Session expired. Reconnect to save.");return}p(o instanceof Error?o.message:"Save failed")}};return e.jsx("dialog",{open:!0,"aria-modal":"true","aria-label":`Edit schema for #${s}`,className:"fixed inset-0 z-50 m-0 h-dvh w-screen max-h-none max-w-none overflow-y-auto bg-black/60 p-4 md:p-8",onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),i())},children:e.jsxs("div",{className:"mx-auto max-w-xl rounded-2xl border border-border bg-card p-5 text-fg shadow-lift md:p-6",children:[e.jsxs("header",{className:"mb-4 flex items-baseline justify-between gap-3",children:[e.jsxs("h2",{className:"font-serif text-lg",children:["Schema for ",e.jsxs("span",{className:"font-mono",children:["#",s]})]}),e.jsx("button",{type:"button",onClick:i,className:"text-sm text-fg-muted hover:text-accent","aria-label":"Close schema editor",children:"Close"})]}),a.isPending?e.jsx("p",{className:"text-sm text-fg-dim","aria-busy":"true",children:"Loading schema…"}):a.isError?e.jsxs("p",{role:"alert",className:"text-sm text-red-400",children:["Could not load schema: ",a.error.message]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"A meta tag gives every note carrying it a shared shape — fields it can carry, and where it sits in your tag hierarchy."}),n?e.jsx("p",{className:"mb-4 rounded-md border border-accent/30 bg-accent/5 p-3 text-sm text-fg-muted",children:n==="group"?"Name a field to organize by, then give it a set of values — each value becomes a column on your board.":"Name a date field — the calendar plots notes on the day it holds, and lets you drag them between days."}):null,e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Description"}),e.jsx("input",{type:"text",value:j,onChange:t=>v(t.target.value),placeholder:"What does this tag mean? Who uses it?","aria-label":"Tag description",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("fieldset",{className:"mb-4",children:[e.jsx("legend",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Fields"}),e.jsxs("p",{className:"mb-2 text-xs text-fg-dim",children:["Each field is a key and a type — e.g."," ",e.jsx("span",{className:"font-mono",children:"status — string"}),","," ",e.jsx("span",{className:"font-mono",children:"meeting_date — date"}),"."]}),f.length===0?e.jsx("p",{className:"mb-2 text-xs text-fg-dim",children:"No fields declared yet. Add one to give notes carrying this tag a structured shape."}):e.jsx("ul",{className:"mb-2 space-y-2.5","aria-label":"Schema fields",children:f.map(t=>e.jsxs("li",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t.name,onChange:r=>b(t.rowId,{name:r.target.value}),placeholder:"field_name","aria-label":"Field name",className:"flex-1 rounded-lg border border-border bg-bg px-2 py-1 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("select",{value:t.type,onChange:r=>b(t.rowId,{type:r.target.value}),"aria-label":`Type for ${t.name||"new field"}`,className:"rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none",children:q.map(r=>e.jsx("option",{value:r,children:r},r))}),e.jsx("button",{type:"button",onClick:()=>R(t.rowId),"aria-label":`Remove field ${t.name||"new"}`,className:"text-fg-dim hover:text-red-400",children:"×"})]}),t.type==="string"?e.jsxs("div",{className:"pl-1",children:[e.jsx("input",{type:"text",value:t.values??"",onChange:r=>b(t.rowId,{values:r.target.value}),placeholder:"e.g. To do, In progress, Done","aria-label":`Values for ${t.name||"new field"}`,className:"w-full rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-2xs text-fg-dim",children:"Optional — comma-separated values become columns on a board."})]}):null]},t.rowId))}),e.jsx("button",{type:"button",onClick:D,className:"text-xs text-accent hover:text-accent-hover",children:"+ Add field"})]}),e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Parent tags"}),e.jsx("input",{type:"text",value:N,onChange:t=>w(t.target.value),placeholder:"comma-separated (e.g. project, area)","aria-label":"Parent tags",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Vault treats parents as a hierarchical relationship — children inherit semantics. Comma-separated; leave blank for a top-level tag."})]}),P?e.jsxs("div",{role:"alert",className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-300",children:[e.jsx("strong",{className:"block font-medium",children:"Heads up."})," Editing this tag's schema doesn't retroactively update notes already tagged with"," ",e.jsxs("span",{className:"font-mono",children:["#",s]}),". The new schema applies to notes you create or update from here on. Existing notes keep their current shape until you edit them."]}):null,E?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:E}):null,e.jsxs("footer",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"rounded-lg 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:d.isPending,className:"rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:d.isPending?"Saving…":"Save schema"})]})]})]})})}function W(s){if(!s)return[];const n=new Set,l=[];for(const i of s.split(/[,\n]/)){const a=i.trim();a&&!n.has(a)&&(n.add(a),l.push(a))}return l}function S(s){const n={};for(const l of s){const i=l.name.trim();if(!i)continue;const a={type:l.type};if(l.type==="string"){const d=W(l.values);d.length>0&&(a.enum=d)}n[i]=a}return n}function H(s,n){const l=s??[],i=n??[];return l.length!==i.length?!1:l.every((a,d)=>a===i[d])}function M(s,n){const l=s?Object.keys(s):[],i=n?Object.keys(n):[];if(l.length!==i.length)return!1;for(const a of l)if(!n||!n[a]||s[a].type!==n[a].type||!H(s[a].enum,n[a].enum))return!1;return!0}export{B as T};
1
+ import{bx as V,cd as _,r as u,j as e,V as K}from"./index-q-OceM-D.js";const q=["string","number","boolean","date"];let C=0;function g(){return C+=1,`row-${C}`}function z(s){return s?Object.entries(s).map(([n,l])=>{var i;return{rowId:g(),name:n,type:l.type||"string",values:((i=l.enum)==null?void 0:i.join(", "))??""}}):[]}function L(s){return s==="date"?{rowId:g(),name:"",type:"date"}:{rowId:g(),name:"",type:"string",values:""}}function B({tagName:s,intent:n,onSaved:l,onClose:i}){var I;const a=V(s),d=_(),[j,v]=u.useState(""),[f,x]=u.useState([]),[N,w]=u.useState(""),[k,T]=u.useState(!1),[E,p]=u.useState(null);u.useEffect(()=>{if(k||a.isPending)return;const t=a.data;let r=[];t&&(v(t.description??""),r=z(t.fields),w((t.parent_names??[]).join(", ")));const m=n==="date"?r.some(c=>c.type==="date"):r.length>0;n&&!m&&(r=[...r,L(n)]),x(r),T(!0)},[k,a.isPending,a.data,n]);const h=((I=a.data)==null?void 0:I.fields)??null,P=!M(h,S(f)),b=(t,r)=>{x(m=>m.map(c=>c.rowId===t?{...c,...r}:c))},D=()=>{x(t=>[...t,{rowId:g(),name:"",type:"string"}])},R=t=>{x(r=>r.filter(m=>m.rowId!==t))},A=async()=>{p(null);const t=f.map(o=>({...o,name:o.name.trim()}));if(t.filter(o=>o.name.length===0).length>0){p("Field names can't be blank. Remove the empty row or fill it in.");return}const m=new Set;for(const o of t){if(m.has(o.name)){p(`Duplicate field name "${o.name}". Each field needs a unique key.`);return}m.add(o.name)}const c=t.length>0?S(t):null,$=h!=null&&Object.keys(h).some(o=>!t.find(O=>O.name===o)),F=N.split(",").map(o=>o.trim()).filter(o=>o.length>0),y={description:j.trim()||null,parent_names:F.length>0?F:null};try{$?(await d.mutateAsync({name:s,payload:{...y,fields:null}}),c&&await d.mutateAsync({name:s,payload:{...y,fields:c}})):await d.mutateAsync({name:s,payload:{...y,fields:c}}),l==null||l(c??{}),i()}catch(o){if(o instanceof K){p("Session expired. Reconnect to save.");return}p(o instanceof Error?o.message:"Save failed")}};return e.jsx("dialog",{open:!0,"aria-modal":"true","aria-label":`Edit schema for #${s}`,className:"fixed inset-0 z-50 m-0 h-dvh w-screen max-h-none max-w-none overflow-y-auto bg-black/60 p-4 md:p-8",onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),i())},children:e.jsxs("div",{className:"mx-auto max-w-xl rounded-2xl border border-border bg-card p-5 text-fg shadow-lift md:p-6",children:[e.jsxs("header",{className:"mb-4 flex items-baseline justify-between gap-3",children:[e.jsxs("h2",{className:"font-serif text-lg",children:["Schema for ",e.jsxs("span",{className:"font-mono",children:["#",s]})]}),e.jsx("button",{type:"button",onClick:i,className:"text-sm text-fg-muted hover:text-accent","aria-label":"Close schema editor",children:"Close"})]}),a.isPending?e.jsx("p",{className:"text-sm text-fg-dim","aria-busy":"true",children:"Loading schema…"}):a.isError?e.jsxs("p",{role:"alert",className:"text-sm text-red-400",children:["Could not load schema: ",a.error.message]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"A meta tag gives every note carrying it a shared shape — fields it can carry, and where it sits in your tag hierarchy."}),n?e.jsx("p",{className:"mb-4 rounded-md border border-accent/30 bg-accent/5 p-3 text-sm text-fg-muted",children:n==="group"?"Name a field to organize by, then give it a set of values — each value becomes a column on your board.":"Name a date field — the calendar plots notes on the day it holds, and lets you drag them between days."}):null,e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Description"}),e.jsx("input",{type:"text",value:j,onChange:t=>v(t.target.value),placeholder:"What does this tag mean? Who uses it?","aria-label":"Tag description",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("fieldset",{className:"mb-4",children:[e.jsx("legend",{className:"mb-2 text-xs uppercase tracking-wider text-fg-dim",children:"Fields"}),e.jsxs("p",{className:"mb-2 text-xs text-fg-dim",children:["Each field is a key and a type — e.g."," ",e.jsx("span",{className:"font-mono",children:"status — string"}),","," ",e.jsx("span",{className:"font-mono",children:"meeting_date — date"}),"."]}),f.length===0?e.jsx("p",{className:"mb-2 text-xs text-fg-dim",children:"No fields declared yet. Add one to give notes carrying this tag a structured shape."}):e.jsx("ul",{className:"mb-2 space-y-2.5","aria-label":"Schema fields",children:f.map(t=>e.jsxs("li",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:t.name,onChange:r=>b(t.rowId,{name:r.target.value}),placeholder:"field_name","aria-label":"Field name",className:"flex-1 rounded-lg border border-border bg-bg px-2 py-1 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("select",{value:t.type,onChange:r=>b(t.rowId,{type:r.target.value}),"aria-label":`Type for ${t.name||"new field"}`,className:"rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none",children:q.map(r=>e.jsx("option",{value:r,children:r},r))}),e.jsx("button",{type:"button",onClick:()=>R(t.rowId),"aria-label":`Remove field ${t.name||"new"}`,className:"text-fg-dim hover:text-red-400",children:"×"})]}),t.type==="string"?e.jsxs("div",{className:"pl-1",children:[e.jsx("input",{type:"text",value:t.values??"",onChange:r=>b(t.rowId,{values:r.target.value}),placeholder:"e.g. To do, In progress, Done","aria-label":`Values for ${t.name||"new field"}`,className:"w-full rounded-lg border border-border bg-bg px-2 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-2xs text-fg-dim",children:"Optional — comma-separated values become columns on a board."})]}):null]},t.rowId))}),e.jsx("button",{type:"button",onClick:D,className:"text-xs text-accent hover:text-accent-hover",children:"+ Add field"})]}),e.jsxs("label",{className:"mb-4 block",children:[e.jsx("span",{className:"mb-1 block text-xs uppercase tracking-wider text-fg-dim",children:"Parent tags"}),e.jsx("input",{type:"text",value:N,onChange:t=>w(t.target.value),placeholder:"comma-separated (e.g. project, area)","aria-label":"Parent tags",className:"w-full rounded-lg border border-border bg-bg px-2.5 py-1.5 font-mono text-xs text-fg focus:border-accent focus:outline-none"}),e.jsx("p",{className:"mt-1 text-xs text-fg-dim",children:"Vault treats parents as a hierarchical relationship — children inherit semantics. Comma-separated; leave blank for a top-level tag."})]}),P?e.jsxs("div",{role:"alert",className:"mb-4 rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-xs text-amber-300",children:[e.jsx("strong",{className:"block font-medium",children:"Heads up."})," Editing this tag's schema doesn't retroactively update notes already tagged with"," ",e.jsxs("span",{className:"font-mono",children:["#",s]}),". The new schema applies to notes you create or update from here on. Existing notes keep their current shape until you edit them."]}):null,E?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:E}):null,e.jsxs("footer",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"rounded-lg 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:d.isPending,className:"rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:d.isPending?"Saving…":"Save schema"})]})]})]})})}function W(s){if(!s)return[];const n=new Set,l=[];for(const i of s.split(/[,\n]/)){const a=i.trim();a&&!n.has(a)&&(n.add(a),l.push(a))}return l}function S(s){const n={};for(const l of s){const i=l.name.trim();if(!i)continue;const a={type:l.type};if(l.type==="string"){const d=W(l.values);d.length>0&&(a.enum=d)}n[i]=a}return n}function H(s,n){const l=s??[],i=n??[];return l.length!==i.length?!1:l.every((a,d)=>a===i[d])}function M(s,n){const l=s?Object.keys(s):[],i=n?Object.keys(n):[];if(l.length!==i.length)return!1;for(const a of l)if(!n||!n[a]||s[a].type!==n[a].type||!H(s[a].enum,n[a].enum))return!1;return!0}export{B as T};
@@ -1 +1 @@
1
- import{a8 as z,r,ab as F,V as R,j as e,a as D,br as I,az as V,bs as B,bt as K,bu as U,N as W,y as Z,E as _,L as P,z as A}from"./index-DEEhPpPi.js";import{T as q}from"./TagSchemaEditor-B-d3rSjI.js";const O=t=>Object.values(t).reduce((n,g)=>n+g,0);function L({mode:t,sources:n,tagOptions:g,onClose:i,onRun:y,onRunMerge:l,pending:o,offline:c}){const m=z(a=>a.push),d=r.useId(),[p,h]=r.useState(t==="rename"?n[0]??"":""),[f,u]=r.useState(null),[x,v]=r.useState(null),[w,S]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{var a,s;(a=b.current)==null||a.focus(),(s=b.current)==null||s.select()},[]),r.useEffect(()=>{const a=s=>{s.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const j=p.trim().replace(/^#/,""),N=!o&&!c&&!w&&j.length>0&&!(t==="rename"&&j===n[0]),T=r.useCallback(async()=>{if(N){u(null),v(null);try{const a=await y(j);if("renamed"in a)m(`Renamed on ${a.renamed} note${a.renamed===1?"":"s"}.`,"success");else{const s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success")}i()}catch(a){if(a instanceof F&&t==="rename"&&l){v(a.target);return}a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Operation failed.")}}},[N,j,t,i,y,l,m]),E=r.useCallback(async()=>{if(!(!x||!l)){u(null),S(!0);try{const a=await l(x),s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success"),i()}catch(a){a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Merge failed."),S(!1)}}},[x,i,l,m]),k=t==="rename"?"Rename tag":`Merge ${n.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:a=>{a.target===a.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:k}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[t==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(C,{children:n[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"," ",n.map((a,s)=>e.jsxs("span",{children:[e.jsx(C,{children:a}),s<n.length-1?", ":""]},a))," ","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:t==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:b,type:"text",value:p,onChange:a=>{h(a.target.value),x&&v(null)},onKeyDown:a=>{a.key==="Enter"&&N&&T()},list:d,"aria-label":t==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-lg 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:d,children:g.map(a=>e.jsx("option",{value:a},a))})]}),c?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,x?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(C,{children:x})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(C,{children:n[0]})," into ",e.jsx(C,{children:x})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:w,className:"rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:w?"Merging…":`Merge into #${x}`})]}):null,f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-lg 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 T(),disabled:!N,className:"min-h-11 rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:o?t==="rename"?"Renaming…":"Merging…":t==="rename"?"Rename":"Merge"})]})]})})}function C({children:t}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",t]})}function te(){const t=D(s=>s.getActiveVault()),n=I(),{isOnline:g}=V(),{isPinned:i,togglePin:y}=B((t==null?void 0:t.id)??null),[l,o]=r.useState(""),[c,m]=r.useState("count"),[d,p]=r.useState(new Set),[h,f]=r.useState(null),[u,x]=r.useState(!1),[v,w]=r.useState(null),S=K(),b=U(),j=r.useMemo(()=>H(n.data??[],l,c),[n.data,l,c]),N=r.useMemo(()=>(n.data??[]).map(s=>s.name),[n.data]),T=s=>{p(M=>{const $=new Set(M);return $.has(s)?$.delete(s):$.add(s),$})},E=()=>p(new Set);if(!t)return e.jsx(W,{to:"/",replace:!0});const k=d.size,a=!g;return e.jsxs("div",{className:"page",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:"eyebrow",children:t.name}),e.jsx("h1",{className:"page-title",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>m(s=>s==="count"?"alpha":"count"),className:"focus-ring text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",c==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:l,onChange:s=>o(s.target.value),"aria-label":"Filter tags",className:"input mb-6"}),k>0?e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-3 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[k," selected: ",Array.from(d).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>x(!0),disabled:k<2||a,className:"btn btn-primary btn-sm",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:E,className:"btn btn-ghost btn-sm",children:"Clear"})]}):null,n.isPending?e.jsx(J,{}):n.isError?e.jsx(Q,{error:n.error}):j.length===0?e.jsx(X,{filtering:l.trim().length>0,hasAny:(n.data??[]).length>0}):e.jsx("ul",{className:"card shadow-soft divide-y divide-border rounded-xl","aria-label":"Tag list",children:j.map(s=>e.jsx(G,{tag:s,selected:d.has(s.name),onToggle:()=>T(s.name),onRename:()=>f(s.name),onEditSchema:()=>w(s.name),pinned:i(s.name),onTogglePin:()=>y(s.name),offline:a},s.name))}),n.data&&n.data.length>0?e.jsxs("p",{className:"mt-6 text-xs tabular-nums text-fg-dim",children:[j.length," / ",n.data.length," tag",n.data.length===1?"":"s"]}):null,h!==null?e.jsx(L,{mode:"rename",sources:[h],tagOptions:N,onClose:()=>f(null),pending:S.isPending||b.isPending,offline:a,onRun:s=>S.mutateAsync({oldName:h,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[h],target:s})}):null,u?e.jsx(L,{mode:"merge",sources:Array.from(d),tagOptions:N,onClose:()=>x(!1),pending:b.isPending,offline:a,onRun:async s=>{const M=await b.mutateAsync({sources:Array.from(d),target:s});return E(),M}}):null,v!==null?e.jsx(q,{tagName:v,onClose:()=>w(null)}):null]})}function G({tag:t,selected:n,onToggle:g,onRename:i,onEditSchema:y,pinned:l,onTogglePin:o,offline:c}){const m=t.fields?Object.keys(t.fields):[],d=t.parent_names??[],p=!!t.description||m.length>0||d.length>0;return e.jsxs("li",{className:"px-4 py-3 text-sm transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:g,"aria-label":`Select tag ${t.name}`,className:"accent-accent"}),e.jsxs(P,{to:`/tags/${encodeURIComponent(t.name)}`,className:"chip chip-tag focus-ring shrink-0 max-w-full break-all",children:[e.jsxs("span",{className:"font-mono",children:["#",t.name]}),e.jsx("span",{className:"tabular-nums opacity-70",children:t.count??0})]}),e.jsxs("div",{className:"-my-3 ml-auto flex shrink-0 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:o,className:l?"focus-ring flex min-h-11 items-center text-xs font-medium text-accent hover:text-accent-hover":"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent","aria-label":l?`Unpin tag ${t.name}`:`Pin tag ${t.name}`,"aria-pressed":l,title:l?"Pinned to home strip — click to unpin":"Pin to home strip",children:l?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:y,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Edit schema for tag ${t.name}`,children:p?"Schema":"+ Schema"}),e.jsx("button",{type:"button",onClick:i,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${t.name}`,children:"Rename"})]})]}),p?e.jsxs("dl",{className:"ml-8 mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-fg-dim","aria-label":`Schema for ${t.name}`,children:[t.description?e.jsxs("div",{className:"flex w-full items-baseline gap-1.5",children:[e.jsx("dt",{className:"sr-only",children:"Description"}),e.jsx("dd",{className:"italic",children:t.description})]}):null,m.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Fields"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:m.map(h=>{var f,u;return`${h}: ${((u=(f=t.fields)==null?void 0:f[h])==null?void 0:u.type)??"?"}`}).join(", ")})]}):null,d.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Parents"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:d.join(", ")})]}):null]}):null]})}function H(t,n,g){const i=n.trim().toLowerCase(),l=[...i?t.filter(o=>o.name.toLowerCase().includes(i)):t];return g==="alpha"?l.sort((o,c)=>o.name.localeCompare(c.name)):l.sort((o,c)=>(c.count??0)-(o.count??0)||o.name.localeCompare(c.name)),l}function J(){return e.jsx("div",{className:"space-y-2","aria-busy":"true",children:[0,1,2,3,4].map(t=>e.jsx(Z,{className:"h-12 rounded-xl"},t))})}function Q({error:t}){const n=t instanceof R;return e.jsx(_,{title:n?"Session expired":"Could not load tags",message:t.message,action:n?e.jsx(P,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function X({filtering:t,hasAny:n}){return t&&n?e.jsx(A,{title:"No tags match your filter."}):e.jsx(A,{title:"No tags in this vault yet.",action:e.jsx(P,{to:"/new",className:"btn btn-primary",children:"Create a note"})})}export{te as Tags};
1
+ import{a8 as z,r,ab as F,V as R,j as e,a as D,bs as I,az as V,bt as B,bu as K,bv as U,N as W,y as Z,E as _,L as P,z as A}from"./index-q-OceM-D.js";import{T as q}from"./TagSchemaEditor-CUHG09YZ.js";const O=t=>Object.values(t).reduce((n,g)=>n+g,0);function L({mode:t,sources:n,tagOptions:g,onClose:i,onRun:y,onRunMerge:l,pending:o,offline:c}){const m=z(a=>a.push),d=r.useId(),[p,h]=r.useState(t==="rename"?n[0]??"":""),[f,u]=r.useState(null),[x,v]=r.useState(null),[w,S]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{var a,s;(a=b.current)==null||a.focus(),(s=b.current)==null||s.select()},[]),r.useEffect(()=>{const a=s=>{s.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const j=p.trim().replace(/^#/,""),N=!o&&!c&&!w&&j.length>0&&!(t==="rename"&&j===n[0]),T=r.useCallback(async()=>{if(N){u(null),v(null);try{const a=await y(j);if("renamed"in a)m(`Renamed on ${a.renamed} note${a.renamed===1?"":"s"}.`,"success");else{const s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success")}i()}catch(a){if(a instanceof F&&t==="rename"&&l){v(a.target);return}a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Operation failed.")}}},[N,j,t,i,y,l,m]),E=r.useCallback(async()=>{if(!(!x||!l)){u(null),S(!0);try{const a=await l(x),s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success"),i()}catch(a){a instanceof R?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Merge failed."),S(!1)}}},[x,i,l,m]),k=t==="rename"?"Rename tag":`Merge ${n.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:a=>{a.target===a.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:k}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[t==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(C,{children:n[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"," ",n.map((a,s)=>e.jsxs("span",{children:[e.jsx(C,{children:a}),s<n.length-1?", ":""]},a))," ","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:t==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:b,type:"text",value:p,onChange:a=>{h(a.target.value),x&&v(null)},onKeyDown:a=>{a.key==="Enter"&&N&&T()},list:d,"aria-label":t==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-lg 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:d,children:g.map(a=>e.jsx("option",{value:a},a))})]}),c?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,x?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(C,{children:x})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(C,{children:n[0]})," into ",e.jsx(C,{children:x})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:w,className:"rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:w?"Merging…":`Merge into #${x}`})]}):null,f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-lg 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 T(),disabled:!N,className:"min-h-11 rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:o?t==="rename"?"Renaming…":"Merging…":t==="rename"?"Rename":"Merge"})]})]})})}function C({children:t}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",t]})}function te(){const t=D(s=>s.getActiveVault()),n=I(),{isOnline:g}=V(),{isPinned:i,togglePin:y}=B((t==null?void 0:t.id)??null),[l,o]=r.useState(""),[c,m]=r.useState("count"),[d,p]=r.useState(new Set),[h,f]=r.useState(null),[u,x]=r.useState(!1),[v,w]=r.useState(null),S=K(),b=U(),j=r.useMemo(()=>H(n.data??[],l,c),[n.data,l,c]),N=r.useMemo(()=>(n.data??[]).map(s=>s.name),[n.data]),T=s=>{p(M=>{const $=new Set(M);return $.has(s)?$.delete(s):$.add(s),$})},E=()=>p(new Set);if(!t)return e.jsx(W,{to:"/",replace:!0});const k=d.size,a=!g;return e.jsxs("div",{className:"page",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:"eyebrow",children:t.name}),e.jsx("h1",{className:"page-title",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>m(s=>s==="count"?"alpha":"count"),className:"focus-ring text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",c==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:l,onChange:s=>o(s.target.value),"aria-label":"Filter tags",className:"input mb-6"}),k>0?e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-3 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[k," selected: ",Array.from(d).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>x(!0),disabled:k<2||a,className:"btn btn-primary btn-sm",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:E,className:"btn btn-ghost btn-sm",children:"Clear"})]}):null,n.isPending?e.jsx(J,{}):n.isError?e.jsx(Q,{error:n.error}):j.length===0?e.jsx(X,{filtering:l.trim().length>0,hasAny:(n.data??[]).length>0}):e.jsx("ul",{className:"card shadow-soft divide-y divide-border rounded-xl","aria-label":"Tag list",children:j.map(s=>e.jsx(G,{tag:s,selected:d.has(s.name),onToggle:()=>T(s.name),onRename:()=>f(s.name),onEditSchema:()=>w(s.name),pinned:i(s.name),onTogglePin:()=>y(s.name),offline:a},s.name))}),n.data&&n.data.length>0?e.jsxs("p",{className:"mt-6 text-xs tabular-nums text-fg-dim",children:[j.length," / ",n.data.length," tag",n.data.length===1?"":"s"]}):null,h!==null?e.jsx(L,{mode:"rename",sources:[h],tagOptions:N,onClose:()=>f(null),pending:S.isPending||b.isPending,offline:a,onRun:s=>S.mutateAsync({oldName:h,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[h],target:s})}):null,u?e.jsx(L,{mode:"merge",sources:Array.from(d),tagOptions:N,onClose:()=>x(!1),pending:b.isPending,offline:a,onRun:async s=>{const M=await b.mutateAsync({sources:Array.from(d),target:s});return E(),M}}):null,v!==null?e.jsx(q,{tagName:v,onClose:()=>w(null)}):null]})}function G({tag:t,selected:n,onToggle:g,onRename:i,onEditSchema:y,pinned:l,onTogglePin:o,offline:c}){const m=t.fields?Object.keys(t.fields):[],d=t.parent_names??[],p=!!t.description||m.length>0||d.length>0;return e.jsxs("li",{className:"px-4 py-3 text-sm transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:g,"aria-label":`Select tag ${t.name}`,className:"accent-accent"}),e.jsxs(P,{to:`/tags/${encodeURIComponent(t.name)}`,className:"chip chip-tag focus-ring shrink-0 max-w-full break-all",children:[e.jsxs("span",{className:"font-mono",children:["#",t.name]}),e.jsx("span",{className:"tabular-nums opacity-70",children:t.count??0})]}),e.jsxs("div",{className:"-my-3 ml-auto flex shrink-0 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:o,className:l?"focus-ring flex min-h-11 items-center text-xs font-medium text-accent hover:text-accent-hover":"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent","aria-label":l?`Unpin tag ${t.name}`:`Pin tag ${t.name}`,"aria-pressed":l,title:l?"Pinned to home strip — click to unpin":"Pin to home strip",children:l?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:y,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Edit schema for tag ${t.name}`,children:p?"Schema":"+ Schema"}),e.jsx("button",{type:"button",onClick:i,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${t.name}`,children:"Rename"})]})]}),p?e.jsxs("dl",{className:"ml-8 mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-fg-dim","aria-label":`Schema for ${t.name}`,children:[t.description?e.jsxs("div",{className:"flex w-full items-baseline gap-1.5",children:[e.jsx("dt",{className:"sr-only",children:"Description"}),e.jsx("dd",{className:"italic",children:t.description})]}):null,m.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Fields"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:m.map(h=>{var f,u;return`${h}: ${((u=(f=t.fields)==null?void 0:f[h])==null?void 0:u.type)??"?"}`}).join(", ")})]}):null,d.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Parents"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:d.join(", ")})]}):null]}):null]})}function H(t,n,g){const i=n.trim().toLowerCase(),l=[...i?t.filter(o=>o.name.toLowerCase().includes(i)):t];return g==="alpha"?l.sort((o,c)=>o.name.localeCompare(c.name)):l.sort((o,c)=>(c.count??0)-(o.count??0)||o.name.localeCompare(c.name)),l}function J(){return e.jsx("div",{className:"space-y-2","aria-busy":"true",children:[0,1,2,3,4].map(t=>e.jsx(Z,{className:"h-12 rounded-xl"},t))})}function Q({error:t}){const n=t instanceof R;return e.jsx(_,{title:n?"Session expired":"Could not load tags",message:t.message,action:n?e.jsx(P,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function X({filtering:t,hasAny:n}){return t&&n?e.jsx(A,{title:"No tags match your filter."}):e.jsx(A,{title:"No tags in this vault yet.",action:e.jsx(P,{to:"/new",className:"btn btn-primary",children:"Create a note"})})}export{te as Tags};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-QCauZ0zI.js","assets/index-DEEhPpPi.js","assets/index-BBWRhmyM.css"])))=>i.map(i=>d[i]);
2
- import{a as N,bx as k,r as u,by as w,bz as S,bA as C,bB as M,j as t,N as T,L as v,b as R,bC as A,V as E,aS as z}from"./index-DEEhPpPi.js";const P=u.lazy(()=>z(()=>import("./react-force-graph-2d-QCauZ0zI.js"),__vite__mapDeps([0,1,2]))),_=20;function O(){const e=N(c=>c.getActiveVault()),n=k(),[d,m]=u.useState(w),o=u.useMemo(()=>n.data?S(n.data):null,[n.data]),i=u.useMemo(()=>o?C(o.nodes):[],[o]),x=u.useMemo(()=>o?new Set(o.nodes.filter(c=>M(c,d)).map(c=>c.id)):new Set,[o,d]);return e?t.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[t.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:t.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[t.jsx("input",{type:"search",value:d.search,onChange:c=>m(h=>({...h,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),t.jsx(V,{allTags:i,selected:d.tags,onChange:c=>m(h=>({...h,tags:c}))}),o?t.jsxs("span",{className:"text-xs text-fg-dim",children:[x.size," / ",o.nodes.length," notes"]}):null]})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(F,{query:n,graph:o,matched:x})})]}):t.jsx(T,{to:"/",replace:!0})}function F({query:e,graph:n,matched:d}){return e.isPending?t.jsx(j,{message:"Loading vault…"}):e.isError?t.jsx(B,{error:e.error}):!n||n.nodes.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),t.jsx(v,{to:"/new",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Create a note"})]})}):t.jsx(I,{graph:n,matched:d})}function V({allTags:e,selected:n,onChange:d}){const m=e.slice(0,_);if(m.length===0)return null;const o=i=>d(n.includes(i)?n.filter(x=>x!==i):[...n,i]);return t.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),m.map(i=>{const x=n.includes(i);return t.jsx("button",{type:"button","aria-pressed":x,onClick:()=>o(i),className:x?"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)}),n.length>0?t.jsx("button",{type:"button",onClick:()=>d([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return t.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 I({graph:e,matched:n}){const d=R(),m=u.useRef(null),o=u.useRef(null),[i,x]=u.useState({w:800,h:600});u.useEffect(()=>{const r=m.current;if(!r)return;const s=()=>{const a=r.getBoundingClientRect();x({w:Math.max(320,Math.floor(a.width)),h:Math.max(320,Math.floor(a.height))})};s();const l=new ResizeObserver(s);return l.observe(r),()=>l.disconnect()},[]);const c=()=>{var r,s;(s=(r=o.current)==null?void 0:r.zoomToFit)==null||s.call(r,400,40)},h=u.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),f=n.size!==e.nodes.length,y=r=>!f||n.has(r)?1:.15;return t.jsxs("div",{ref:m,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[t.jsx(u.Suspense,{fallback:t.jsx(j,{message:"Rendering graph…"}),children:t.jsx(P,{ref:o,graphData:h,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>L(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const s=r,l=A(s.topTag);return f&&!n.has(s.id)?G(l):l},nodePointerAreaPaint:(r,s,l)=>{const a=r;if(a.x==null||a.y==null)return;const g=2+Math.min(a.degree,12),b=Math.max(Math.sqrt(g)*5,10);l.fillStyle=s,l.beginPath(),l.arc(a.x,a.y,b,0,2*Math.PI),l.fill()},linkColor:r=>{const s=r,l=p(s.source),a=p(s.target);return f&&(!n.has(l)||!n.has(a))?"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,s,l)=>{const a=r;if(a.x==null||a.y==null||y(a.id)<.5)return;const b=10/l;s.font=`${b}px sans-serif`,s.fillStyle="rgba(220, 220, 220, 0.8)",s.textAlign="left",s.textBaseline="middle",s.fillText(a.title,a.x+6,a.y)},onNodeClick:r=>{d(`/n/${encodeURIComponent(r.id)}`)}})}),t.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-lg 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 L(e){const n=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
3
- `)}function G(e){return e.startsWith("hsl(")?e.replace("hsl(","hsla(").replace(")",", 0.2)"):e}function p(e){return typeof e=="string"?e:e&&typeof e=="object"&&"id"in e?String(e.id):""}function B({error:e}){const n=e instanceof E;return t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-md 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:n?"Session expired":"Could not load vault"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),n?t.jsx(v,{to:"/add",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Reconnect vault"}):null]})})}export{O as VaultGraph};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BpJfrG8W.js","assets/index-q-OceM-D.js","assets/index-BBWRhmyM.css"])))=>i.map(i=>d[i]);
2
+ import{a as N,by as k,r as u,bz as w,bA as S,bB as C,bC as M,j as t,N as T,L as v,b as R,bD as A,V as E,aS as z}from"./index-q-OceM-D.js";const P=u.lazy(()=>z(()=>import("./react-force-graph-2d-BpJfrG8W.js"),__vite__mapDeps([0,1,2]))),_=20;function O(){const e=N(c=>c.getActiveVault()),n=k(),[d,x]=u.useState(w),o=u.useMemo(()=>n.data?S(n.data):null,[n.data]),i=u.useMemo(()=>o?C(o.nodes):[],[o]),m=u.useMemo(()=>o?new Set(o.nodes.filter(c=>M(c,d)).map(c=>c.id)):new Set,[o,d]);return e?t.jsxs("div",{className:"flex h-[calc(100dvh-5rem)] flex-col",children:[t.jsx("div",{className:"border-b border-border bg-card/40 px-6 py-3",children:t.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-4",children:[t.jsx("input",{type:"search",value:d.search,onChange:c=>x(h=>({...h,search:c.target.value})),placeholder:"Search nodes…","aria-label":"Search graph nodes",className:"min-w-48 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"}),t.jsx(V,{allTags:i,selected:d.tags,onChange:c=>x(h=>({...h,tags:c}))}),o?t.jsxs("span",{className:"text-xs text-fg-dim",children:[m.size," / ",o.nodes.length," notes"]}):null]})}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(F,{query:n,graph:o,matched:m})})]}):t.jsx(T,{to:"/",replace:!0})}function F({query:e,graph:n,matched:d}){return e.isPending?t.jsx(j,{message:"Loading vault…"}):e.isError?t.jsx(G,{error:e.error}):!n||n.nodes.length===0?t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-sm rounded-md border border-border bg-card p-8 text-center",children:[t.jsx("p",{className:"mb-2 font-serif text-xl",children:"No notes yet"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:"This vault is empty. Start by creating the first note."}),t.jsx(v,{to:"/new",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Create a note"})]})}):t.jsx(I,{graph:n,matched:d})}function V({allTags:e,selected:n,onChange:d}){const x=e.slice(0,_);if(x.length===0)return null;const o=i=>d(n.includes(i)?n.filter(m=>m!==i):[...n,i]);return t.jsxs("fieldset",{"aria-label":"Filter by tag",className:"flex flex-wrap items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Tags"}),x.map(i=>{const m=n.includes(i);return t.jsx("button",{type:"button","aria-pressed":m,onClick:()=>o(i),className:m?"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)}),n.length>0?t.jsx("button",{type:"button",onClick:()=>d([]),className:"ml-1 text-xs text-fg-dim hover:text-accent",children:"Clear"}):null]})}function j({message:e}){return t.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 I({graph:e,matched:n}){const d=R(),x=u.useRef(null),o=u.useRef(null),[i,m]=u.useState({w:800,h:600});u.useEffect(()=>{const r=x.current;if(!r)return;const s=()=>{const a=r.getBoundingClientRect();m({w:Math.max(320,Math.floor(a.width)),h:Math.max(320,Math.floor(a.height))})};s();const l=new ResizeObserver(s);return l.observe(r),()=>l.disconnect()},[]);const c=()=>{var r,s;(s=(r=o.current)==null?void 0:r.zoomToFit)==null||s.call(r,400,40)},h=u.useMemo(()=>({nodes:e.nodes.map(r=>({...r})),links:e.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[e]),f=n.size!==e.nodes.length,y=r=>!f||n.has(r)?1:.15;return t.jsxs("div",{ref:x,"data-testid":"vault-graph-canvas",className:"relative h-full w-full touch-none",children:[t.jsx(u.Suspense,{fallback:t.jsx(j,{message:"Rendering graph…"}),children:t.jsx(P,{ref:o,graphData:h,width:i.w,height:i.h,backgroundColor:"rgba(0,0,0,0)",nodeLabel:r=>L(r),nodeRelSize:5,nodeVal:r=>2+Math.min(r.degree,12),nodeColor:r=>{const s=r,l=A(s.topTag);return f&&!n.has(s.id)?D(l):l},nodePointerAreaPaint:(r,s,l)=>{const a=r;if(a.x==null||a.y==null)return;const g=2+Math.min(a.degree,12),b=Math.max(Math.sqrt(g)*5,10);l.fillStyle=s,l.beginPath(),l.arc(a.x,a.y,b,0,2*Math.PI),l.fill()},linkColor:r=>{const s=r,l=p(s.source),a=p(s.target);return f&&(!n.has(l)||!n.has(a))?"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,s,l)=>{const a=r;if(a.x==null||a.y==null||y(a.id)<.5)return;const b=10/l;s.font=`${b}px sans-serif`,s.fillStyle="rgba(220, 220, 220, 0.8)",s.textAlign="left",s.textBaseline="middle",s.fillText(a.title,a.x+6,a.y)},onNodeClick:r=>{d(`/n/${encodeURIComponent(r.id)}`)}})}),t.jsx("button",{type:"button",onClick:c,className:"absolute right-3 bottom-3 rounded-lg 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 L(e){const n=[e.path??e.id,`${e.degree} link${e.degree===1?"":"s"}`];return e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
3
+ `)}function D(e){return e.startsWith("hsl(")?e.replace("hsl(","hsla(").replace(")",", 0.2)"):e}function p(e){return typeof e=="string"?e:e&&typeof e=="object"&&"id"in e?String(e.id):""}function G({error:e}){const n=e instanceof E;return t.jsx("div",{className:"flex h-full items-center justify-center p-10",children:t.jsxs("div",{className:"max-w-md 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:n?"Session expired":"Could not load vault"}),t.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:e.message}),n?t.jsx(v,{to:"/add",className:"inline-block rounded-lg bg-accent px-4 py-2 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover",children:"Reconnect vault"}):null]})})}export{O as VaultGraph};
@@ -1 +1 @@
1
- import{a,j as e,L as n,M as m}from"./index-DEEhPpPi.js";import{v as h}from"./provenance-B3gZ95dW.js";import{a as x}from"./types-BaJkUfo6.js";function f(){const l=a(s=>s.vaults),d=a(s=>s.activeVaultId),o=a(s=>s.removeVault),c=Object.values(l).sort((s,t)=>s.name.localeCompare(t.name));return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),c.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:c.map(s=>{const t=s.id===d,r=x(s.url),i=h(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",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:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[i.kind==="cloud"?"☁":"⌂"," ",i.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:s.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>m(s.id,{toast:!0}),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&o(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(n,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{f as Vaults};
1
+ import{a,j as e,L as n,M as m}from"./index-q-OceM-D.js";import{v as h}from"./provenance-BRYF2APg.js";import{a as x}from"./types-BaJkUfo6.js";function f(){const l=a(s=>s.vaults),d=a(s=>s.activeVaultId),o=a(s=>s.removeVault),c=Object.values(l).sort((s,t)=>s.name.localeCompare(t.name));return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),c.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:c.map(s=>{const t=s.id===d,r=x(s.url),i=h(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",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:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[i.kind==="cloud"?"☁":"⌂"," ",i.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:s.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>m(s.id,{toast:!0}),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&o(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(n,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{f as Vaults};
@@ -1 +1 @@
1
- import{a as g,a3 as h,aw as v,a8 as N,b as w,r,bJ as y,ab as j,j as e,N as b}from"./index-DEEhPpPi.js";function k(){const a=g(t=>t.getActiveVault()),{roles:c}=h((a==null?void 0:a.id)??null),l=v(),o=N(t=>t.push),p=w(),[i,x]=r.useState("New view"),[s,u]=r.useState(!1),[d,f]=r.useState(null),m=r.useCallback(async()=>{const t=i.trim()||"New view";u(!0);try{const n=await l.mutateAsync({content:"",path:y(t),tags:[c.view],metadata:{kind:"list",query:"{}"}});f(n.id)}catch(n){n instanceof j?o("A note already exists at that path — try a different name.","error"):o(`Could not create the view: ${n.message}`,"error")}finally{u(!1)}},[i,l,c.view,o]);return a?d?e.jsx(b,{to:`/views/${encodeURIComponent(d)}`,replace:!0}):e.jsxs("div",{className:"page-prose",children:[e.jsx("h1",{className:"page-title mb-2",children:"New view"}),e.jsx("p",{className:"mb-6 text-fg-muted",children:"A view is a note that describes a query — refine and save it from the view itself once it's open."}),e.jsxs("label",{className:"mb-4 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:t=>x(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!s&&m()},autoFocus:!0,className:"w-full rounded-lg border border-border bg-bg/40 px-3 py-2 text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>p(-1),className:"btn btn-secondary btn-touch",disabled:s,children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void m(),disabled:s,className:"btn btn-primary btn-touch",children:s?"Creating…":"Create view"})]})]}):e.jsx(b,{to:"/",replace:!0})}export{k as ViewNew};
1
+ import{a as g,a3 as h,aw as v,a8 as N,b as w,r,bK as y,ab as j,j as e,N as b}from"./index-q-OceM-D.js";function k(){const a=g(t=>t.getActiveVault()),{roles:c}=h((a==null?void 0:a.id)??null),l=v(),o=N(t=>t.push),p=w(),[i,x]=r.useState("New view"),[s,u]=r.useState(!1),[d,f]=r.useState(null),m=r.useCallback(async()=>{const t=i.trim()||"New view";u(!0);try{const n=await l.mutateAsync({content:"",path:y(t),tags:[c.view],metadata:{kind:"list",query:"{}"}});f(n.id)}catch(n){n instanceof j?o("A note already exists at that path — try a different name.","error"):o(`Could not create the view: ${n.message}`,"error")}finally{u(!1)}},[i,l,c.view,o]);return a?d?e.jsx(b,{to:`/views/${encodeURIComponent(d)}`,replace:!0}):e.jsxs("div",{className:"page-prose",children:[e.jsx("h1",{className:"page-title mb-2",children:"New view"}),e.jsx("p",{className:"mb-6 text-fg-muted",children:"A view is a note that describes a query — refine and save it from the view itself once it's open."}),e.jsxs("label",{className:"mb-4 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),e.jsx("input",{type:"text",value:i,onChange:t=>x(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!s&&m()},autoFocus:!0,className:"w-full rounded-lg border border-border bg-bg/40 px-3 py-2 text-fg focus:border-accent focus:outline-none"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>p(-1),className:"btn btn-secondary btn-touch",disabled:s,children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void m(),disabled:s,className:"btn btn-primary btn-touch",children:s?"Creating…":"Create view"})]})]}):e.jsx(b,{to:"/",replace:!0})}export{k as ViewNew};