@openparachute/app 0.22.5

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 (64) hide show
  1. package/CHANGELOG.md +3473 -0
  2. package/LICENSE +661 -0
  3. package/README.md +68 -0
  4. package/dist/.parachute/info +8 -0
  5. package/dist/apple-touch-icon-180x180.png +0 -0
  6. package/dist/assets/Account-BhmA30V5.js +1 -0
  7. package/dist/assets/Activity-BgJa7Woi.js +1 -0
  8. package/dist/assets/AddVault-BWa_-QjM.js +1 -0
  9. package/dist/assets/AddVaultChooser-B3ElIlza.js +1 -0
  10. package/dist/assets/AddVaultCreate-DKJfYFJ1.js +1 -0
  11. package/dist/assets/Calendar-DUwSvnCY.js +1 -0
  12. package/dist/assets/CheckEmail-BQYQLTLL.js +1 -0
  13. package/dist/assets/ConnectAI-DCtARp-w.js +1 -0
  14. package/dist/assets/DayView-nficJMEc.js +1 -0
  15. package/dist/assets/Export-DNAoKjAn.js +1 -0
  16. package/dist/assets/Import-CoFeXNMx.js +20 -0
  17. package/dist/assets/NoteEditor-DtrdRbqx.js +1 -0
  18. package/dist/assets/NoteNew-C0DMe5Q8.js +8 -0
  19. package/dist/assets/NoteRenderer-Dl9X9uRt.js +37 -0
  20. package/dist/assets/NoteView-B2QH25fP.js +3 -0
  21. package/dist/assets/OAuthCallback-Dj26N8oJ.js +1 -0
  22. package/dist/assets/PinArchiveButtons-BXZFiW-i.js +1 -0
  23. package/dist/assets/Settings-BuXl91ig.js +1 -0
  24. package/dist/assets/TagPage-q7PgbEHn.js +1 -0
  25. package/dist/assets/TagSchemaEditor-DIHppYmj.js +1 -0
  26. package/dist/assets/Tags-BqJ9vWM5.js +1 -0
  27. package/dist/assets/VaultGraph-CaiNmEtX.js +3 -0
  28. package/dist/assets/Vaults-CTsUsDH8.js +1 -0
  29. package/dist/assets/ViewNew-BegTqdOq.js +1 -0
  30. package/dist/assets/ViewSurface-ClCtZW0N.js +1 -0
  31. package/dist/assets/Welcome-CN4Zh9jP.js +1 -0
  32. package/dist/assets/WizardShell-ZqrzQKxp.js +1 -0
  33. package/dist/assets/attachment-upload-l7qA8_xw.js +2 -0
  34. package/dist/assets/editor-mode-D9fveTEx.js +1 -0
  35. package/dist/assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
  36. package/dist/assets/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
  37. package/dist/assets/fraunces-latin-ext-opsz-italic-CGbN9UgK.woff2 +0 -0
  38. package/dist/assets/fraunces-latin-ext-opsz-normal-CJcjJNj7.woff2 +0 -0
  39. package/dist/assets/fraunces-latin-opsz-italic-lSdLDfvT.woff2 +0 -0
  40. package/dist/assets/fraunces-latin-opsz-normal-DihXLNYH.woff2 +0 -0
  41. package/dist/assets/fraunces-vietnamese-opsz-italic-DxWqP7Ku.woff2 +0 -0
  42. package/dist/assets/fraunces-vietnamese-opsz-normal-Czevyj-6.woff2 +0 -0
  43. package/dist/assets/history-ByMClxJV.js +1 -0
  44. package/dist/assets/index-CaleIHD8.css +1 -0
  45. package/dist/assets/index-Dwo2xe8_.js +66 -0
  46. package/dist/assets/provenance-B6WFYTWW.js +1 -0
  47. package/dist/assets/react-force-graph-2d-BMU3lxLC.js +44 -0
  48. package/dist/assets/transcribe-default-LVAxyzpn.js +1 -0
  49. package/dist/assets/types-BaJkUfo6.js +1 -0
  50. package/dist/assets/url-QSQwrjSV.js +1 -0
  51. package/dist/assets/useAttachmentUploader-C3UnTg01.js +30 -0
  52. package/dist/assets/workbox-window.prod.es5-BBnX5xw4.js +2 -0
  53. package/dist/favicon.ico +0 -0
  54. package/dist/icon.svg +21 -0
  55. package/dist/index.html +31 -0
  56. package/dist/manifest.webmanifest +1 -0
  57. package/dist/maskable-icon-512x512.png +0 -0
  58. package/dist/pwa-192x192.png +0 -0
  59. package/dist/pwa-512x512.png +0 -0
  60. package/dist/pwa-64x64.png +0 -0
  61. package/dist/sw.js +1 -0
  62. package/dist/workbox-9c191d2f.js +1 -0
  63. package/meta.json +20 -0
  64. package/package.json +83 -0
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BMU3lxLC.js","assets/index-Dwo2xe8_.js","assets/index-CaleIHD8.css"])))=>i.map(i=>d[i]);
2
+ import{a5 as w,a as k,av as M,r as d,aM as U,j as t,af as A,aN as $,L as p,aO as D,aP as V,aQ as O,aR as _,aS as H,ae as z,aT as G,N as W,a0 as K,v as j,a1 as Q,aU as Y,aw as q,ag as L,aV as X,aW as Z,aX as J,am as ee,aY as te,E as se,w as ne,aZ as F,x as T,Y as re,a_ as ae,V as ie,a7 as oe}from"./index-Dwo2xe8_.js";import{P as le,D as ce}from"./PinArchiveButtons-BXZFiW-i.js";import{b as de,N as ue}from"./NoteRenderer-Dl9X9uRt.js";function me(e,n){const s=w(),r=k(u=>u.activeVaultId),i=M(),[l,a]=d.useState(!1),o=n&&!xe(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=he(s,o,{onUpsert:m,onRemove:m,onStatus:h=>{u&&a(h==="open")}});return()=>{u=!1,a(!1),c()}},[s,r,e,o,i]),{isLive:l}}function xe(e){return U(e.id)}function he(e,n,s){return e.subscribe({path:n},{onSnapshot:()=>{},onUpsert:()=>s.onUpsert(),onRemove:()=>s.onRemove(),onStatus:s.onStatus})}const fe=1,pe=3,ge=1;function be(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 je(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 h of c.links??[]){const f=h.sourceId===c.id?h.targetId:h.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 Ne(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),je(n,s,u=>e.getNote(u,{includeLinks:!0}),o).then(u=>{o.cancelled||(i(be(n.id,u)),a(!1))}).catch(()=>{o.cancelled||a(!1)}),()=>{o.cancelled=!0}},[e,n,s]),{data:r,isLoading:l}}const ve=d.lazy(()=>V(()=>import("./react-force-graph-2d-BMU3lxLC.js"),__vite__mapDeps([0,1,2])));function ye({anchor:e}){const[n,s]=d.useState(!0),[r,i]=d.useState(ge),l=w(),{data:a,isLoading:o}=Ne(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(we,{depth:r,onChange:i}):null]}),n?t.jsx(ke,{data:a,isLoading:o}):null]})}function we({depth:e,onChange:n}){const s=[];for(let r=fe;r<=pe;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 ke({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,h;r(null),m!=null&&m.restoreFocus&&((h=(c=i.current)==null?void 0:c.focus)==null||h.call(c))};return t.jsxs(t.Fragment,{children:[t.jsx(Re,{data:e,onSelect:o}),a?t.jsx(Ie,{node:a,onClose:u},a.id):null,t.jsx(Ce,{neighbors:l,selectedId:s,onSelect:o})]})}function Ce({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=D(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 Ie({node:e,onClose:n}){var a;const s=A(e.id),r=d.useRef(null);d.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]);const i=$({id:e.id,path:e.path,content:(a=s.data)==null?void 0:a.content}),l=Se(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(Ee,{isPaused:s.fetchStatus==="paused",isPending:s.isPending,isError:s.isError,snippet:l}),t.jsx("div",{className:"mt-3",children:t.jsx(p,{to:`/n/${encodeURIComponent(e.id)}`,className:"btn btn-primary btn-touch",children:"Open note"})})]})}function Ee({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 Se(e){if(!e)return null;const n=(e.preview??O(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 Re({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(ve,{graphData:l,width:r.w,height:r.h,nodeLabel:a=>Le(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 Le(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 Te({content:e,attachments:n,onRetry:s,retrying:r=!1}){const i={content:e,attachments:n},l=_(i);if(l==="pending"){const a=H(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 Xe(){const{id:e}=z(),n=k(r=>r.getActiveVault()),s=A(e);return me(e,s.data),d.useEffect(()=>{n&&e&&G(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(p,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),s.isPending?t.jsx(_e,{}):s.data?t.jsxs(t.Fragment,{children:[s.isError?t.jsx(K,{}):null,t.jsx(Pe,{note:s.data,cacheId:e})]}):s.isError?t.jsx(Ke,{error:s.error,retry:()=>s.refetch()}):t.jsx(We,{id:e??""})]}):t.jsx(W,{to:"/",replace:!0})}function Pe({note:e,cacheId:n}){var S,R;const s=k(x=>x.getActiveVault()),{roles:r}=Q((s==null?void 0:s.id)??null),i=Y(),{mirror:l}=q(),a=l.state==="offline",o=e.contentEvicted===!0,u=d.useMemo(()=>de(e),[e]),m=L(x=>x.on),c=L(x=>x.setOn);d.useEffect(()=>{if(!m)return;const x=y=>{y.key==="Escape"&&c(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[m,c]);const h=e.path??e.id,f=X(e.content),g=f!==null?{kind:"title",text:f}:e.path?Z(e.path):{kind:"title",text:e.id},b=d.useMemo(()=>f!==null?{...e,content:J(e.content??"")}:e,[e,f]),C=typeof((S=e.metadata)==null?void 0:S.summary)=="string"?e.metadata.summary:null,I=d.useMemo(()=>(e.links??[]).filter(x=>x.targetId===e.id&&x.sourceId!==e.id&&x.sourceNote),[e]),E=d.useMemo(()=>{const x=new Set,y=[];for(const N of e.links??[])N.sourceId!==e.id||N.targetId===e.id||N.targetNote&&(x.has(N.targetId)||(x.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:g.kind==="timestamp"?"page-title title-timestamp":"page-title",children:g.text}),a?t.jsx(ze,{}):null,e.tags&&e.tags.length>0?t.jsx(Be,{tags:e.tags}):null,C?t.jsx("p",{className:"mt-3 text-fg-muted",children:C}):null,t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[t.jsx(p,{to:`/n/${encodeURIComponent(e.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit"}),t.jsx(le,{note:e,keyboard:!0}),t.jsx(ce,{note:e}),t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[t.jsx(ee,{width:16,height:16}),"Focus"]}),te(e,r.view)?t.jsx(p,{to:`/views/${encodeURIComponent(e.id)}`,className:"btn btn-secondary btn-touch",children:"Open as view"}):null]}),t.jsx(Ue,{value:h,isPath:!!e.path})]}),t.jsx(Te,{content:e.content??"",attachments:e.attachments,onRetry:()=>i.mutate({cacheId:n??e.id,serverId:e.id}),retrying:i.isPending}),o?t.jsx(Ge,{preview:e.preview}):(R=b.content)!=null&&R.trim()?t.jsx(ue,{note:b,resolve:u}):f===null?t.jsx(He,{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(x=>t.jsx($e,{attachment:x},x.id))})]}):null,t.jsx(ye,{anchor:e})]}),t.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[t.jsx(Ae,{note:e}),E.length>0?t.jsx(P,{title:"Outbound",links:E,peer:"target"}):null,I.length>0?t.jsx(P,{title:"Inbound",links:I,peer:"source"}):null]})]})}function Ae({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:T(n)})}),s?t.jsx(v,{label:"Updated",value:t.jsx("time",{title:s,children:T(s)})}):null,e.path?t.jsx(v,{label:"Path",value:t.jsx(re,{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))]}),e.path?t.jsx(Fe,{path:e.path}):null,t.jsx(ae,{note:e,variant:"detail",className:"mt-3"})]})}function Fe({path:e}){const{copied:n,copy:s}=F();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 Be({tags:e}){return t.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":"Tags",children:e.map(n=>t.jsxs(p,{to:`/tags/${encodeURIComponent(n)}`,className:"chip chip-tag focus-ring max-w-full break-all",children:["#",n]},n))})}function Me(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 Ue({value:e,isPath:n}){const{copied:s,copy:r}=F();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(Me,{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 P({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(p,{to:`/n/${encodeURIComponent(i.id)}`,className:"block rounded px-1 py-0.5 hover:bg-bg/50",children:[t.jsx("div",{className:"truncate font-mono text-xs text-fg-muted hover:text-accent",children: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 $e({attachment:e}){const n=(e.mimeType??"").toLowerCase(),s=e.filename??e.id;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:s}),typeof e.size=="number"?t.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:Oe(e.size)}):null]}),t.jsx(De,{attachment:e,mime:n,filename:s})]})}function De({attachment:e,mime:n,filename:s}){const r=w(),[i,l]=d.useState(null),[a,o]=d.useState(null),u=Ve(n,s),m=u!=="other",c=e.url;if(d.useEffect(()=>{if(!m||!c||!r)return;let f=!1,g=null;return o(null),r.fetchAttachmentBlob(c).then(b=>{f||(g=URL.createObjectURL(b),l(g))}).catch(b=>{f||o(b instanceof Error?b.message:"Failed to load attachment")}),()=>{f=!0,g&&URL.revokeObjectURL(g)}},[m,c,r]),!c)return t.jsx("p",{className:"text-sm text-fg-dim",children:"(no URL)"});if(a)return t.jsx("p",{className:"text-sm text-danger",children:a});if(m&&!i)return t.jsx(j,{className:"h-32 w-full"});const h=i??c;return u==="image"?t.jsx("img",{src:h,alt:s,className:"max-h-[32rem] rounded"}):u==="audio"?t.jsx("audio",{controls:!0,src:h,className:"w-full"}):u==="video"?t.jsx("video",{controls:!0,src:h,className:"w-full rounded"}):u==="pdf"?t.jsxs(t.Fragment,{children:[t.jsx("iframe",{src:h,title:s,className:"h-[40rem] w-full rounded border border-border"}),t.jsxs("a",{href:h,download:s,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",s]})]}):t.jsxs("a",{href:h,download:s,className:"text-sm text-accent hover:underline",children:["Download ",s]})}function Ve(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 Oe(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 _e(){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(j,{className:"h-3 w-32"}),t.jsx(j,{className:"h-8 w-2/3"}),t.jsx(j,{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(j,{className:"h-3",width:`${70+e*13%25}%`},e))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(j,{className:"h-32"}),t.jsx(j,{className:"h-24"})]})]})}function He({noteId:e}){return t.jsxs("p",{className:"my-8 font-serif text-lg italic text-fg-muted",children:["Nothing here yet."," ",t.jsx(p,{to:`/n/${encodeURIComponent(e)}/edit`,className:"not-italic text-accent hover:underline",children:"Start writing →"})]})}function ze(){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 Ge({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 We({id:e}){return t.jsx(ne,{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(p,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Ke({error:e,retry:n}){const s=e instanceof ie,r=e instanceof oe,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(se,{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(p,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):t.jsx(p,{to:"/notes",className:"btn btn-secondary btn-touch",children:"Back to notes"})})}export{Xe as NoteView};
@@ -0,0 +1 @@
1
+ import{y as R,b as U,a as u,r as d,b0 as z,b1 as E,b2 as I,b3 as A,k as C,b4 as H,b5 as O,j as e,P as p}from"./index-Dwo2xe8_.js";import{W as m}from"./WizardShell-ZqrzQKxp.js";import{s as P}from"./url-QSQwrjSV.js";import"./history-ByMClxJV.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),y=a.vault?`vault:${a.vault}`:void 0,N=(y?(g=(o=a.services)==null?void 0:o[y])==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 k=A.getState();k.clearHalt(c),t.priorHaltedVaultId&&t.priorHaltedVaultId!==c&&k.clearHalt(t.priorHaltedVaultId);const V=P(t.redirect)??"/";if(c!==S){const w=u.getState().vaults[c];w&&C(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};
@@ -0,0 +1 @@
1
+ import{r as l,j as t,b as v,a6 as h,a$ as j,V as y,a as w,a1 as E,aj as N}from"./index-Dwo2xe8_.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};
@@ -0,0 +1 @@
1
+ import{a as T,j as e,N as C,L as j,b6 as k,a6 as y,r as d,b7 as E,b8 as A,b9 as O,ba as R,bb as L,a1 as M,bc as P,bd as N,be as g,aw as $,bf as _,bg as I,x as D,bh as z,b as V,u as B,g as F,bi as G,bj as H,h as U,i as Y,bk as K}from"./index-Dwo2xe8_.js";import{u as q,a as Q,b as W,c as X}from"./transcribe-default-LVAxyzpn.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(j,{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(j,{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(j,{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 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 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?D(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(z())},[]),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 v={pinned:{title:"Pinned",help:"Tag for notes you want at the top of views."},archived:{title:"Archived",help:"Tag for notes you've moved out of the way."},captureVoice:{title:"Voice capture",help:"Default tag for new voice memos."},captureText:{title:"Text capture",help:"Default tag for quick typed notes."},view:{title:"Saved view",help:"Tag the saved-view notes carry. Used to list them in the notes sidebar."}};function 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:v[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":`${v[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:v[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};
@@ -0,0 +1 @@
1
+ import{br as o,ae as x,a as l,bs as h,j as e,N as c,L as j,v as r,a1 as g,r as f}from"./index-Dwo2xe8_.js";import{ViewCanvas as m}from"./ViewSurface-ClCtZW0N.js";import"./TagSchemaEditor-DIHppYmj.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(j,{to:"/tags",className:"focus-ring hover:text-accent",children:"← Tags"})})}function y(){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}=g((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{y as TagPage};
@@ -0,0 +1 @@
1
+ import{bs as V,c1 as _,r as u,j as e,V as K}from"./index-Dwo2xe8_.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};
@@ -0,0 +1 @@
1
+ import{a6 as F,r,a9 as D,V as R,j as e,a as I,bn as V,aw as z,bo as B,bp as K,bq as U,N as q,v as W,E as Z,L as P,w as A}from"./index-Dwo2xe8_.js";import{T as _}from"./TagSchemaEditor-DIHppYmj.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=F(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 D&&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=I(s=>s.getActiveVault()),n=V(),{isOnline:g}=z(),{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(q,{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(_,{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(W,{className:"h-12 rounded-xl"},t))})}function Q({error:t}){const n=t instanceof R;return e.jsx(Z,{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};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BMU3lxLC.js","assets/index-Dwo2xe8_.js","assets/index-CaleIHD8.css"])))=>i.map(i=>d[i]);
2
+ import{a as N,bt as k,r as u,bu as w,bv as S,bw as C,bx as M,j as t,N as T,L as v,b as R,by as E,V as A,aP as P}from"./index-Dwo2xe8_.js";const _=u.lazy(()=>P(()=>import("./react-force-graph-2d-BMU3lxLC.js"),__vite__mapDeps([0,1,2]))),z=20;function $(){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(D,{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,z);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(_,{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=E(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 D({error:e}){const n=e instanceof A;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{$ as VaultGraph};
@@ -0,0 +1 @@
1
+ import{a,j as e,L as n,G as m}from"./index-Dwo2xe8_.js";import{v as h}from"./provenance-B6WFYTWW.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};
@@ -0,0 +1 @@
1
+ import{a as g,a1 as h,at as v,a6 as N,b as w,r,bF as y,a9 as j,j as e,N as b}from"./index-Dwo2xe8_.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};
@@ -0,0 +1 @@
1
+ import{j as n,bG as Ke,r as x,bH as V,bI as C,L as O,a_ as Ze,x as et,av as tt,aj as we,a6 as ke,Q as B,bs as I,R as nt,w as R,X as st,U as fe,$ as J,bJ as Se,bK as at,bL as rt,bM as it,bN as lt,bO as ot,bP as Ce,a as De,a1 as ct,y as dt,bQ as ut,bR as mt,bS as pe,ae as ft,bT as pt,N as xt,E as Te,bU as ht,bV as $e,bW as bt,v as k,bX as gt,bY as yt,bZ as vt,at as jt,b_ as Nt,b$ as wt,a3 as xe,a4 as he,c0 as kt,bF as St}from"./index-Dwo2xe8_.js";import{T as Ct}from"./TagSchemaEditor-DIHppYmj.js";const Dt="—",Ee=/^https?:\/\//i;function Me(e){return typeof e=="string"&&Ee.test(e)}const be=24;function Tt(e){try{const t=new URL(e);let s=`${t.pathname}${t.search}${t.hash}`;return s==="/"&&(s=""),s.length>be&&(s=`${s.slice(0,be-1)}…`),{host:t.host,rest:s}}catch{return{host:e.replace(Ee,""),rest:""}}}function $t({value:e,schema:t}){if(e==null||e==="")return Dt;if(typeof e=="boolean")return e?n.jsx("span",{className:"text-grass",children:"✓"}):n.jsx("span",{className:"text-fg-dim",children:"✕"});if((t==null?void 0:t.type)==="date"&&typeof e=="string")return Ke(e);if(Me(e)){const{host:s,rest:a}=Tt(e);return n.jsxs("span",{className:"min-w-0 truncate text-accent underline underline-offset-2",title:e,children:[s,a?n.jsx("span",{className:"opacity-70",children:a}):null]})}return typeof e=="number"?n.jsx("span",{className:"tabular-nums",children:String(e)}):String(e)}function Pe(e,t){if(t&&t.length>0||e!=null&&e.enum&&e.enum.length>0)return"enum";switch(e==null?void 0:e.type){case"date":return"date";case"boolean":return"boolean";case"number":return"number";default:return"string"}}const Et="focus-ring inline-flex max-w-[9rem] items-center rounded px-1 py-0.5 text-[0.6875rem] hover:text-accent disabled:opacity-50";function Mt(e){if(typeof e!="string")return"";const t=e.match(/^\d{4}-\d{2}-\d{2}/);return t?t[0]:""}function K({field:e,schema:t,value:s,onCommit:a,disabled:r=!1,options:i,includeClear:l=!1,trigger:o}){const d=Pe(t,i),[c,p]=x.useState(!1),f=s==null||s==="",u=(o==null?void 0:o.label)??n.jsx($t,{value:s,schema:t}),b=(o==null?void 0:o.ariaLabel)??`Edit ${e}`,j=(o==null?void 0:o.className)??`${Et} ${f&&!(o!=null&&o.label)?"text-fg-dim":"text-fg"}`;if(d==="boolean"){const v=(o==null?void 0:o.ariaLabel)??`Edit ${e} (${s===!0?"checked":"unchecked"})`;return n.jsx("button",{type:"button",disabled:r,"aria-label":v,onClick:()=>a(s!==!0),className:j,children:u})}const g=d==="enum"?i??((t==null?void 0:t.enum)??[]).map(v=>({value:v,label:v})):[],m=l&&!f,h=v=>{p(!1),a(v)};return n.jsxs("div",{className:"relative",children:[n.jsx("button",{type:"button",disabled:r,"aria-haspopup":d==="enum"?"menu":"dialog","aria-expanded":c,"aria-label":b,title:o!=null&&o.label?void 0:`Edit ${e}`,onClick:()=>p(v=>!v),className:j,children:u}),c?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"fixed inset-0 z-10 cursor-default",onClick:()=>p(!1)}),d==="enum"?n.jsxs("div",{role:"menu","aria-label":b,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] flex-col gap-0.5 p-1 shadow-lg",children:[g.map(v=>n.jsxs("button",{type:"button",role:"menuitem",onClick:()=>h(v.value),className:`focus-ring flex items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${v.muted?"text-fg-dim":"text-fg"}`,children:[v.value===null||v.value===void 0||v.value===""?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${V(String(v.value))}`}),v.label]},v.value===null?"__clear__":String(v.value))),m?n.jsx("button",{type:"button",role:"menuitem",onClick:()=>h(null),className:"focus-ring rounded px-2 py-1.5 text-left text-sm text-fg-dim hover:bg-bg-soft",children:"Clear"}):null]}):n.jsx(Pt,{kind:d,value:s,ariaLabel:b,onCommit:h,onCancel:()=>p(!1)})]}):null]})}function Pt({kind:e,value:t,ariaLabel:s,onCommit:a,onCancel:r}){const i=e==="date"?Mt(t):t==null?"":String(t),[l,o]=x.useState(i),d=()=>{const c=l.trim();if(c==="")return a(null);if(e==="number"){const p=Number(c);return Number.isFinite(p)?a(p):r()}a(c)};return n.jsxs("div",{role:"dialog","aria-label":s,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] items-center gap-1 p-1 shadow-lg",children:[n.jsx("input",{autoFocus:!0,type:e==="date"?"date":e==="number"?"number":"text",value:l,"aria-label":s,onChange:c=>o(c.target.value),onKeyDown:c=>{c.key==="Enter"?(c.preventDefault(),d()):c.key==="Escape"&&(c.preventDefault(),r())},className:"w-full rounded border border-border bg-bg/40 px-1.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),n.jsx("button",{type:"button",onClick:d,"aria-label":"Save",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"✓"}),Me(t)?n.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer","aria-label":"Open link",title:"Open link",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"↗"}):null]})}function _t(e){for(const t of e.attachments??[]){const s=typeof t.url=="string"?t.url:null;if(typeof t.mimeType=="string"&&t.mimeType.startsWith("image/")&&s&&/^https?:\/\//i.test(s))return s}return null}function q({note:e,pinnedTag:t,archivedTag:s,variant:a="compact",overlay:r,footer:i,drag:l}){const o=C(e),d=e.updatedAt??e.createdAt,c=(e.tags??[]).includes(t),p=(e.tags??[]).includes(s),f=a==="gallery"?_t(e):null,[u,b]=x.useState(!1),j=f&&!u,g=(l==null?void 0:l.canDrag)??!1,m=n.jsxs(O,{to:`/n/${encodeURIComponent(e.id)}`,draggable:g?!1:void 0,"data-note-id":e.id,className:`focus-ring card group flex flex-col overflow-hidden rounded-xl shadow-sm transition hover:border-accent hover:shadow-md ${p?"opacity-60 italic":""}`,children:[a==="gallery"?n.jsx("div",{className:"aspect-[3/2] w-full overflow-hidden bg-bg-soft",children:j?n.jsx("img",{src:f,alt:"",loading:"lazy",onError:()=>b(!0),className:"h-full w-full object-cover"}):n.jsx("div",{"aria-hidden":"true",className:"flex h-full w-full items-end p-3 text-fg-dim",children:n.jsx("span",{className:"line-clamp-3 text-sm text-fg-muted",children:e.preview??""})})}):null,n.jsxs("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[c?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:o.kind==="timestamp"?"min-w-0 truncate text-sm title-timestamp":"min-w-0 truncate text-sm font-medium text-fg",children:o.text})]}),n.jsx(Ze,{note:e})]}),e.preview&&!(a==="gallery"&&!j)?n.jsx("p",{className:"line-clamp-2 text-xs text-fg-muted",children:e.preview}):null,n.jsx("span",{className:"mt-auto pt-1 text-[0.6875rem] tabular-nums text-fg-dim",children:et(d)})]})]});return!r&&!i&&!g?m:n.jsxs("div",{className:g?"relative flex flex-col cursor-grab":"relative flex flex-col",...(l==null?void 0:l.sourceProps)??{},children:[m,r?n.jsx("div",{className:"absolute right-2 top-2",children:r}):null,i?n.jsx("div",{className:"mt-1",children:i}):null]})}function Lt(e,t,s){const a={...e.metadata??{}};return s===null?delete a[t]:a[t]=s,{...e,metadata:a}}function At(e,t,s,a){return e&&e.map(r=>r.id===t?Lt(r,s,a):r)}function Ft(e,t){const s=tt(),a=we(e);return{move:x.useCallback(async(i,l,o)=>{const d=s.getQueryData(t);s.setQueryData(t,c=>At(c,e,i,l));try{const c=await a.mutateAsync({metadata:{[i]:l},...o?{if_updated_at:o}:{force:!0}}),p=c==null?void 0:c.updatedAt;p&&s.setQueryData(t,f=>f==null?void 0:f.map(u=>u.id===e?{...u,updatedAt:p}:u))}catch(c){throw s.setQueryData(t,d),c}},[s,t,e,a]),isPending:a.isPending}}const Bt=1800,Y="field-write-flash",Rt=700;function Vt(e){return e===null?null:typeof e=="boolean"?e?"Yes":"No":String(e)}function Ot(e){if(typeof document>"u")return;const t=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&");for(const s of document.querySelectorAll(`[data-note-id="${t}"]`))s.classList.remove(Y),s.offsetWidth,s.classList.add(Y),window.setTimeout(()=>s.classList.remove(Y),Rt)}function z(e,t){const s=ke(c=>c.push),{move:a,isPending:r}=Ft(e.id,t),i=e.id,l=e.updatedAt,o=C(e).text;return{write:x.useCallback(async(c,p,f)=>{try{await a(c,p,l)}catch(b){const j=(f==null?void 0:f.errorPrefix)??`Couldn't update ${c} on "${o}"`;s(`${j}: ${b instanceof Error?b.message:"unknown error"}`,"error");return}const u=(f==null?void 0:f.valueLabel)??Vt(p);s(u===null?`✓ ${c} cleared`:`✓ ${c} → ${u}`,"success",{durationMs:Bt}),Ot(i)},[a,l,o,i,s]),isPending:r}}function _e(e){if(e==null)return null;const t=typeof e;return t==="string"||t==="number"||t==="boolean"?e:null}function M({note:e,fields:t,viewResultsKey:s,omit:a}){const{write:r,isPending:i}=z(e,s),l=a&&a.length>0?t.filter(o=>!a.includes(o.name)):t;return l.length===0?null:n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pt-0.5",children:l.map(o=>{var p;const d=_e((p=e.metadata)==null?void 0:p[o.name]),c=Pe(o.schema)==="enum"&&d!==null&&d!==""?V(String(d)):null;return n.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border py-0.5 pl-2 pr-1 text-[0.6875rem] leading-none ${c?`chip-tinted tint-${c}`:"border-border bg-bg-soft/60"}`,children:[c?n.jsx("span",{"aria-hidden":"true",className:"tint-dot"}):null,n.jsx("span",{className:"text-fg-dim",children:o.name}),n.jsx(K,{field:o.name,schema:o.schema,value:d,disabled:i,includeClear:!0,onCommit:f=>void r(o.name,f)})]},o.name)})})}const Z="application/x-parachute-note";function Le(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(pointer: fine)").matches}function It(e,t){e.setData(Z,t),e.effectAllowed="move"}function F(e){return e?Array.from(e.types??[]).includes(Z):!1}function qt(e){if(!e)return null;const t=e.getData(Z);return t===""?null:t}function Ae(e){const[t]=x.useState(Le),s=x.useRef(!1),a=x.useCallback(l=>{l.dataTransfer&&(It(l.dataTransfer,e),s.current=!0)},[e]),r=x.useCallback(()=>{window.setTimeout(()=>{s.current=!1},0)},[]),i=x.useCallback(l=>{s.current&&(l.preventDefault(),l.stopPropagation(),s.current=!1)},[]);return t?{canDrag:!0,sourceProps:{draggable:!0,onDragStart:a,onDragEnd:r,onClickCapture:i}}:{canDrag:!1,sourceProps:{}}}function Fe(e){const[t,s]=x.useState(!1),a=x.useRef(0),r=x.useCallback(d=>{F(d.dataTransfer)&&(d.preventDefault(),a.current+=1,s(!0))},[]),i=x.useCallback(d=>{F(d.dataTransfer)&&(d.preventDefault(),d.dataTransfer&&(d.dataTransfer.dropEffect="move"))},[]),l=x.useCallback(d=>{F(d.dataTransfer)&&(a.current=Math.max(0,a.current-1),a.current===0&&s(!1))},[]),o=x.useCallback(d=>{if(!F(d.dataTransfer))return;d.preventDefault(),a.current=0,s(!1);const c=qt(d.dataTransfer);c&&e(c)},[e]);return{isOver:t,targetProps:{onDragEnter:r,onDragOver:i,onDragLeave:l,onDrop:o}}}function Be(){const e=x.useRef(new Map),t=x.useCallback((a,r)=>(e.current.set(a,r),()=>{e.current.get(a)===r&&e.current.delete(a)}),[]),s=x.useCallback((a,r)=>{var i;(i=e.current.get(a))==null||i(r)},[]);return{register:t,dispatch:s}}function zt(e,t){var a;const s=(a=e.metadata)==null?void 0:a[t];if(s==null)return null;if(typeof s=="string"){const r=s.trim();return r===""?null:r}return typeof s=="number"||typeof s=="boolean"?String(s):null}const Gt={status:["active","incubating","dormant","paused","archived","done","shipped","dropped"],priority:["high","medium","low"]};function Ut(e,t){var a;const s=(a=t==null?void 0:t[e])==null?void 0:a.enum;return s&&s.length>0?s:Gt[e]??[]}function Yt(e,t,s=[]){var p;const a=new Map,r=new Map,i=[];for(const f of e){const u=zt(f,t);if(u===null){i.push(f);continue}const b=a.get(u);b?b.push(f):(a.set(u,[f]),r.set(u,(p=f.metadata)==null?void 0:p[t]))}const l=s.filter(f=>a.has(f)),o=new Set(l),d=[...a.keys()].filter(f=>!o.has(f)).sort((f,u)=>f.localeCompare(u)),c=[...l,...d].map(f=>({key:f,label:f,notes:a.get(f)??[],uncategorized:!1,value:r.get(f)}));return i.length>0&&c.push({key:"",label:`No ${t}`,notes:i,uncategorized:!0,value:null}),c}function Qt(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const s=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(s){const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return Number.isNaN(r.getTime())?null:r}const a=new Date(t);return Number.isNaN(a.getTime())?null:a}function Ht(e,t){var i;const s=new Map,a=[],r=new Map;for(const l of e){const o=Qt((i=l.metadata)==null?void 0:i[t]);if(!o){a.push(l);continue}r.set(l.id,o);const d=B(o),c=s.get(d);c?c.push(l):s.set(d,[l])}return{byDay:s,undated:a,dates:r}}function Wt(e){const t=new Map,s=[],a=new Map;for(const r of e){const i=r.createdAt?new Date(r.createdAt):null;if(!i||Number.isNaN(i.getTime())){s.push(r);continue}a.set(r.id,i);const l=B(i),o=t.get(l);o?o.push(r):t.set(l,[r])}return{byDay:t,undated:s,dates:a}}function ge(e,t=new Date){let s=null;for(const r of e)(!s||r.getTime()>s.getTime())&&(s=r);const a=s??t;return{year:a.getFullYear(),month:a.getMonth()+1}}function Jt({notes:e,laneBy:t,subjectTag:s,roles:a,viewResultsKey:r,fields:i=[]}){const l=I(s??null),o=x.useMemo(()=>{var g,m,h,v;const c=Yt(e,t,Ut(t,(g=l.data)==null?void 0:g.fields)),p=((v=(h=(m=l.data)==null?void 0:m.fields)==null?void 0:h[t])==null?void 0:v.enum)??[];if(p.length===0)return c;const f=new Map(c.filter(y=>!y.uncategorized).map(y=>[y.key,y])),u=p.map(y=>f.get(y)??{key:y,label:y,notes:[],uncategorized:!1,value:y}),b=new Set(p),j=c.filter(y=>y.uncategorized||!b.has(y.key));return[...u,...j]},[e,t,l.data]),d=Be();return n.jsx("div",{className:"overflow-x-auto pb-2",children:n.jsx("div",{className:"flex items-start gap-4",children:o.map(c=>n.jsx(Xt,{lane:c,dropRegistry:d,children:c.notes.map(p=>n.jsx(Zt,{note:p,laneBy:t,lanes:o,currentLane:c,roles:a,viewResultsKey:r,fields:i,dropRegistry:d},p.id))},c.uncategorized?"__uncategorized__":c.key))})})}function Xt({lane:e,dropRegistry:t,children:s}){const a=x.useCallback(l=>t.dispatch(l,e),[t,e]),{isOver:r,targetProps:i}=Fe(a);return n.jsxs("section",{"aria-label":e.label,className:`flex w-72 shrink-0 flex-col gap-2 rounded-2xl border border-border-light bg-bg-soft p-2 ${r?"outline-2 outline-offset-2 outline-accent/50":""}`,...i,children:[n.jsxs("header",{className:"flex items-baseline justify-between gap-2 px-1.5 pt-1",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.uncategorized?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${V(e.key)}`}),n.jsx("span",{className:`min-w-0 truncate text-sm font-semibold ${e.uncategorized?"text-fg-dim":"text-fg"}`,children:e.label})]}),n.jsx("span",{className:"shrink-0 rounded-full bg-bg px-2 text-xs tabular-nums text-fg-dim",children:e.notes.length})]}),n.jsx("div",{className:"flex flex-col gap-2",children:e.notes.length===0?n.jsx("p",{className:"py-4 text-center text-xs italic text-fg-dim",children:Le()?"Drop here":"No notes"}):s})]})}function ye(e,t){return e.uncategorized||t.uncategorized?e.uncategorized&&t.uncategorized:e.key===t.key}const Kt="focus-ring rounded-full border border-border bg-bg-soft/90 px-2 py-0.5 text-[0.6875rem] font-medium text-fg-dim backdrop-blur transition-colors hover:text-accent disabled:opacity-50";function Zt({note:e,laneBy:t,lanes:s,currentLane:a,roles:r,viewResultsKey:i,fields:l,dropRegistry:o}){const{write:d,isPending:c}=z(e,i),p=x.useMemo(()=>s.filter(m=>!ye(m,a)),[s,a]),f=x.useMemo(()=>p.map(m=>({value:m.value,label:m.label,muted:m.uncategorized})),[p]),u=x.useCallback(async(m,h)=>{await d(t,m,{valueLabel:h,errorPrefix:`Couldn't move "${C(e).text}"`})},[d,t,e]),b=async m=>{const h=f.find(v=>v.value===m);await u(m,h==null?void 0:h.label)},j=Ae(e.id),g=x.useCallback(m=>{c||ye(m,a)||u(m.value,m.label)},[c,a,u]);return x.useEffect(()=>o.register(e.id,g),[o,e.id,g]),n.jsx(q,{note:e,pinnedTag:r.pinned,archivedTag:r.archived,drag:j,overlay:p.length>0?n.jsx(K,{field:t,value:a.value,options:f,disabled:c,onCommit:m=>void b(m),trigger:{label:"Move",ariaLabel:`Move to another ${t}`,className:Kt}}):null,footer:l.length>0?n.jsx(M,{note:e,fields:l,viewResultsKey:i,omit:p.length>0?[t]:void 0}):null})}const en=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Q=2;function tn({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r=[]}){const i=x.useMemo(()=>t===null?Wt(e):Ht(e,t),[e,t]),[l,o]=x.useState(()=>ge(i.dates.values())),[d,c]=x.useState(null),p=x.useMemo(()=>nt(l.year,l.month),[l]),f=B(),u=Be();if(i.byDay.size===0)return n.jsxs("div",{className:"space-y-4",children:[n.jsx(R,{title:"Nothing on the calendar yet",description:t===null?void 0:`Give a note a ${t} date below and it lands on the grid.`}),t===null?null:n.jsx(ve,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]});const b=g=>{c(null),o(g)},j=d?i.byDay.get(d)??[]:[];return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[n.jsx("h2",{className:"font-serif text-2xl tracking-tight text-fg",children:st(l.year,l.month)}),n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("button",{type:"button",onClick:()=>b(fe(l.year,l.month,-1)),className:"chip","aria-label":"Previous month",children:"← Prev"}),n.jsx("button",{type:"button",onClick:()=>b(ge(i.dates.values())),className:"chip",children:"Latest"}),n.jsx("button",{type:"button",onClick:()=>b(fe(l.year,l.month,1)),className:"chip","aria-label":"Next month",children:"Next →"})]})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-card",children:[n.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-bg-soft text-2xs uppercase tracking-wider text-fg-dim",children:en.map(g=>n.jsx("div",{className:"px-2 py-2 text-center",children:g},g))}),n.jsx("div",{className:"grid grid-cols-7",children:p.map(g=>{const m=B(g),h=g.getMonth()+1===l.month,v=i.byDay.get(m)??[],y=m===f,w=m===d;return n.jsx(nn,{dayKey:m,dayNumber:g.getDate(),inMonth:h,isToday:y,isSelected:w,notes:v,onSelect:()=>c(m),dateField:t,viewResultsKey:a,dropRegistry:u},m)})})]}),d&&j.length>0?n.jsxs("section",{"aria-label":`Notes on ${J(d)}`,className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("p",{className:"eyebrow",children:J(d)}),n.jsx("button",{type:"button",onClick:()=>c(null),className:"text-xs text-fg-dim hover:text-accent focus-ring rounded",children:"Clear"})]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:j.map(g=>n.jsx(q,{note:g,pinnedTag:s.pinned,archivedTag:s.archived,footer:r.length>0?n.jsx(M,{note:g,fields:r,viewResultsKey:a}):null},g.id))})]}):null,t===null?n.jsx("p",{className:"text-xs text-fg-dim",children:"Showing by created date — set a date field to schedule."}):n.jsx(ve,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]})}function nn({dayKey:e,dayNumber:t,inMonth:s,isToday:a,isSelected:r,notes:i,onSelect:l,dateField:o,viewResultsKey:d,dropRegistry:c}){const p=i.length>0,f=o!==null,u=x.useCallback(y=>c.dispatch(y,e),[c,e]),{isOver:b,targetProps:j}=Fe(u),g=f&&s?j:{},m=n.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-serif tabular-nums ${a?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t}),h=n.jsxs("span",{className:"flex flex-col gap-0.5",children:[i.slice(0,Q).map(y=>o===null?n.jsx(sn,{note:y},y.id):n.jsx(an,{note:y,dayKey:e,dateField:o,viewResultsKey:d,dropRegistry:c},y.id)),i.length>Q?n.jsxs("span",{className:"text-[10px] text-fg-dim",children:["+",i.length-Q," more"]}):null]}),v=`flex min-h-24 flex-col border-b border-r border-border p-1.5 text-left text-xs ${s?"":"opacity-40"} ${r?"bg-accent/5":""} ${f&&s&&b?"bg-accent/5 outline-2 -outline-offset-2 outline-accent/60":""}`;return p?n.jsxs("button",{type:"button",onClick:l,"aria-label":`${J(e)} — ${i.length} notes`,className:`${v} hover:bg-bg/60 focus:bg-bg/60 focus:outline-none`,"data-day":e,...g,children:[m,h]}):n.jsxs("div",{className:v,"data-day":e,...g,children:[m,n.jsx("span",{className:"sr-only",children:"no notes"})]})}const X="truncate rounded-md border border-border bg-card px-1.5 py-0.5 text-[10px] leading-tight text-fg shadow-sm";function sn({note:e}){return n.jsx("span",{"data-note-id":e.id,className:X,children:C(e).text})}function an({note:e,dayKey:t,dateField:s,viewResultsKey:a,dropRegistry:r}){const{write:i,isPending:l}=z(e,a),o=Ae(e.id),d=x.useCallback(c=>{l||c===t||i(s,c,{errorPrefix:`Couldn't move "${C(e).text}"`})},[l,t,s,i,e]);return x.useEffect(()=>r.register(e.id,d),[r,e.id,d]),n.jsx("span",{"data-note-id":e.id,className:o.canDrag?`${X} cursor-grab`:X,...o.sourceProps,children:C(e).text})}function ve({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r}){if(e.length===0)return null;const i=r.find(o=>o.name===t)??{name:t,schema:{type:"date"}},l=/date/i.test(t)?t:`${t} date`;return n.jsxs("section",{"aria-label":`Not on the calendar — no ${l}`,className:"space-y-2",children:[n.jsx("p",{className:"eyebrow",children:"Not on the calendar yet"}),n.jsxs("p",{className:"text-xs text-fg-dim",children:[e.length," ",e.length===1?"note has":"notes have"," no ",l," — set one to place ",e.length===1?"it":"them","."]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:e.map(o=>n.jsx(q,{note:o,pinnedTag:s.pinned,archivedTag:s.archived,footer:n.jsx(M,{note:o,fields:[i],viewResultsKey:a})},o.id))})]})}const rn="border-[color-mix(in_srgb,var(--color-accent)_40%,var(--color-border))]";function Re({label:e,value:t,icon:s,ariaLabel:a,haspopup:r="menu",open:i,dirty:l=!1,onClick:o}){return n.jsxs("button",{type:"button","aria-haspopup":r,"aria-expanded":i,"aria-label":a,onClick:o,className:`focus-ring inline-flex min-h-8 items-center gap-1.5 rounded-full border bg-card px-3 py-1 transition-colors duration-(--dur-quick) ease-out hover:border-accent/50 ${l?rn:"border-border"}`,children:[s?n.jsx("span",{"aria-hidden":"true",className:"flex-none text-fg-muted",children:s}):null,e?n.jsx("span",{className:"text-2xs uppercase tracking-[0.08em] text-fg-dim",children:e}):null,n.jsx("span",{className:"text-xs font-medium text-fg",children:t}),n.jsx("span",{"aria-hidden":"true",className:"text-2xs text-fg-dim",children:"▾"})]})}function ee({label:e,value:t,icon:s,ariaLabel:a,menuLabel:r,options:i,current:l,onSelect:o,note:d,actions:c,busy:p=!1,dirty:f=!1}){const[u,b]=x.useState(!1);x.useEffect(()=>{if(!u)return;const m=h=>{h.key==="Escape"&&b(!1)};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[u]);const j=m=>{b(!1),o(m)},g=m=>{b(!1),m.onSelect()};return n.jsxs("div",{className:"relative",children:[n.jsx(Re,{label:e,value:t,icon:s,ariaLabel:a,open:u,dirty:f,onClick:()=>b(m=>!m)}),u?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>b(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"menu","aria-label":r,className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-56 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{"aria-hidden":"true",className:"eyebrow px-2 pt-1.5 pb-1",children:r}),i.map(m=>{const h=m.value===l;return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":h,onClick:()=>j(m.value),className:`focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${h?"text-fg":"text-fg-muted"}`,children:[m.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:m.glyph}):null,n.jsx("span",{className:"min-w-0 flex-1 truncate",children:m.label??m.value}),h?n.jsx("span",{"aria-hidden":"true",className:"text-accent",children:"✓"}):null]},m.value)}),d?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:d}):null,c&&c.length>0?n.jsx("div",{className:i.length>0?"mt-1 border-t border-border-light pt-1":void 0,children:c.map(m=>n.jsxs("button",{type:"button",role:"menuitem",disabled:p,onClick:()=>g(m),className:"focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm text-fg-muted hover:bg-bg-soft disabled:opacity-50",children:[m.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:m.glyph}):null,n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-fg",children:m.label}),m.hint?n.jsx("span",{className:"block truncate text-2xs text-fg-dim",children:m.hint}):null]})]},m.key))}):null]})]}):null]})}function ln({fields:e,schemaFieldNames:t,onChange:s,dirty:a=!1}){const[r,i]=x.useState(!1);x.useEffect(()=>{if(!r)return;const u=b=>{b.key==="Escape"&&i(!1)};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);const l=e.map(u=>u.name),o=t.filter(u=>!l.includes(u));if(l.length===0&&o.length===0)return null;const d=l.length===1,c=u=>{d||s(l.filter(b=>b!==u))},p=u=>s([...l,u]),f=(u,b)=>{const j=[...l],[g]=j.splice(u,1);j.splice(u+b,0,g),s(j)};return n.jsxs("div",{className:"relative",children:[n.jsx(Re,{label:"Fields",value:String(l.length),haspopup:"dialog",open:r,dirty:a,onClick:()=>i(u=>!u)}),r?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>i(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"dialog","aria-label":"Fields",className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-60 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{className:"eyebrow px-2 pt-1.5 pb-1",children:"Fields"}),n.jsxs("ul",{className:"flex flex-col gap-0.5",children:[l.map((u,b)=>n.jsxs("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:[n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:d,onChange:()=>c(u)}),n.jsx("span",{className:"truncate",children:u})]}),n.jsx("button",{type:"button","aria-label":`Move ${u} up`,disabled:b===0,onClick:()=>f(b,-1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↑"}),n.jsx("button",{type:"button","aria-label":`Move ${u} down`,disabled:b===l.length-1,onClick:()=>f(b,1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↓"})]},u)),o.map(u=>n.jsx("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:!1,onChange:()=>p(u)}),n.jsx("span",{className:"truncate",children:u})]})},u))]}),d?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:"Views show at least one field."}):null]})]}):null]})}function on({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{"aria-label":"Gallery",className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,13rem),1fr))] gap-4",children:e.map(r=>n.jsx(q,{note:r,variant:"gallery",pinnedTag:t.pinned,archivedTag:t.archived,footer:a.length>0?n.jsx(M,{note:r,fields:a,viewResultsKey:s}):null},r.id))})}const H={list:"List",board:"Board",calendar:"Calendar",gallery:"Gallery",table:"Table"};function je({kind:e}){switch(e){case"board":return n.jsx(ot,{width:14,height:14});case"calendar":return n.jsx(lt,{width:14,height:14});case"gallery":return n.jsx(it,{width:14,height:14});case"table":return n.jsx(rt,{width:14,height:14});default:return n.jsx(at,{width:14,height:14})}}function cn({kind:e,onSwitch:t,dirty:s=!1}){return n.jsx(ee,{ariaLabel:`Lens: ${H[e]}`,menuLabel:"Lens",icon:n.jsx(je,{kind:e}),value:H[e],options:Se.map(a=>({value:a,label:H[a],glyph:n.jsx(je,{kind:a})})),current:e,onSelect:t,dirty:s})}function Ve(e,t,s){const a=e.filter(s).map(r=>r.name);return t&&!a.includes(t)&&a.unshift(t),a}const dn="This view isn't scoped to one tag, so there's no schema to add a field to — add a single tag to the query, or open a tag's view.";function Oe(e,t,s){return[{key:"__add_field__",label:e,hint:t,onSelect:s}]}function un({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const o=Ve(t,e,()=>!0),d=o.length===0&&!!r&&i&&!!l;return n.jsx(ee,{label:"Group by",menuLabel:"Group by",value:e??"—",options:o.map(c=>({value:c,glyph:n.jsx("span",{className:`tint-dot tint-${V(c)}`})})),current:e,onSelect:s,note:o.length>0?void 0:r?d?`#${r} has no fields yet — add one to give this board its columns:`:void 0:dn,actions:d?Oe("Add a field to group by…","You name it; give it values to get columns.",l):void 0,dirty:a})}function mn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const o=Ve(t,e,c=>c.schema.type==="date"),d=o.length===0&&!!r&&i&&!!l;return n.jsx(ee,{label:"By date",menuLabel:"By date",value:e??"created",options:o.map(c=>({value:c})),current:e,onSelect:s,note:o.length===0&&d?`Showing by created date. #${r} has no date field — add one to plot and drag by it:`:e===void 0?"Showing by created date":void 0,actions:d?Oe("Add a date field…","You name it; it holds a date on each note.",l):void 0,dirty:a})}function fn({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card shadow-sm",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[36rem] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-border text-left",children:[n.jsx("th",{scope:"col",className:"sticky left-0 z-[1] bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim",children:"Note"}),a.map(r=>n.jsx("th",{scope:"col",className:`whitespace-nowrap bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim ${r.schema.type==="number"?"text-right":""}`,children:r.name},r.name))]})}),n.jsx("tbody",{children:e.map(r=>n.jsx(pn,{note:r,fields:a,roles:t,viewResultsKey:s},r.id))})]})})})}function pn({note:e,fields:t,roles:s,viewResultsKey:a}){const{write:r,isPending:i}=z(e,a),l=C(e),o=(e.tags??[]).includes(s.pinned),d=(e.tags??[]).includes(s.archived);return n.jsxs("tr",{"data-note-id":e.id,className:`group border-b border-border-light last:border-b-0 hover:bg-bg-soft/60 ${d?"opacity-60 italic":""}`,children:[n.jsx("th",{scope:"row",className:"group-hover:after:opacity-100 sticky left-0 z-[1] bg-card px-3 py-1.5 text-left font-normal after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:bg-bg-soft/60 after:opacity-0",children:n.jsxs(O,{to:`/n/${encodeURIComponent(e.id)}`,className:"focus-ring inline-flex max-w-[16rem] items-baseline gap-1.5 hover:text-accent",children:[o?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:l.kind==="timestamp"?"min-w-0 truncate title-timestamp":"min-w-0 truncate font-medium text-fg",children:l.text})]})}),t.map(c=>{var p;return n.jsx("td",{className:`px-3 py-1 align-middle ${c.schema.type==="number"?"text-right":""}`,children:n.jsx(K,{field:c.name,schema:c.schema,value:_e((p=e.metadata)==null?void 0:p[c.name]),disabled:i,includeClear:!0,onCommit:f=>void r(c.name,f)})},c.name)})]})}function Ie(e){return e.kind!==void 0||e.groupBy!==void 0||e.dateField!==void 0||e.fields!==void 0}function xn(e){const t=new URLSearchParams;return e.kind&&t.set("kind",e.kind),e.groupBy&&t.set("group",e.groupBy),e.dateField&&t.set("date",e.dateField),e.fields&&e.fields.length>0&&t.set("fields",e.fields.join(",")),t}function hn(e){const t={},s=e.get("kind");s&&Se.includes(s)&&(t.kind=s);const a=e.get("group");a&&(t.groupBy=a);const r=e.get("date");r&&(t.dateField=r);const i=e.get("fields");if(i){const l=i.split(",").map(o=>o.trim()).filter(Boolean);l.length>0&&(t.fields=l)}return t}function te(e,t){return Ie(t)?{...e,kind:t.kind??e.kind,groupBy:t.groupBy??e.groupBy,dateField:t.dateField??e.dateField,fields:t.fields??e.fields}:e}function bn(e,t){return e===void 0||t===void 0?e===t:e.length===t.length&&e.every((s,a)=>s===t[a])}function Ne(e,t){const s={};return t.kind!==void 0&&t.kind!==e.kind&&(s.kind=t.kind),t.groupBy!==void 0&&t.groupBy!==e.groupBy&&(s.groupBy=t.groupBy),t.dateField!==void 0&&t.dateField!==e.dateField&&(s.dateField=t.dateField),t.fields!==void 0&&!bn(t.fields,e.fields)&&(s.fields=t.fields),s}function gn(e){var t;return(t=e.find(s=>{var a;return(((a=s.schema.enum)==null?void 0:a.length)??0)>0}))==null?void 0:t.name}function yn(e){var t;return(t=e.find(s=>s.schema.type==="date"))==null?void 0:t.name}function vn(e,t,s,a){const r={...t,kind:s};if(s==="board"){if(!(t.groupBy??e.groupBy)){const i=gn(a);i&&(r.groupBy=i)}}else e.groupBy===void 0&&(r.groupBy=void 0);if(s==="calendar"){if(!(t.dateField??e.dateField)){const i=yn(a);i&&(r.dateField=i)}}else e.dateField===void 0&&(r.dateField=void 0);return r}function jn(e,t,s){const r={kind:te(e,t).kind};return s!==null&&(r.query=JSON.stringify(s)),t.groupBy!==void 0&&(r.group_by=t.groupBy),t.dateField!==void 0&&(r.date_field=t.dateField),t.fields!==void 0&&(r.fields=JSON.stringify(t.fields)),r}function Nn(e,t){const s={kind:e.kind};return t!==null&&(s.query=JSON.stringify(t)),e.groupBy!==void 0&&(s.group_by=e.groupBy),e.dateField!==void 0&&(s.date_field=e.dateField),e.fields!==void 0&&(s.fields=JSON.stringify(e.fields)),s}const wn={type:"string"};function P(e){const t=Ce(e);return t.length===1?t[0]:null}function kn(e,t){return e.fields&&e.fields.length>0?e.fields.map(a=>({name:a,schema:(t==null?void 0:t[a])??wn})):P(e.query)&&t?Object.entries(t).map(([a,r])=>({name:a,schema:r})):[]}function Sn(e){const t=e?P(e.query):null,s=I(t);return x.useMemo(()=>e?kn(e,qe(s.data)):[],[e,s.data])}function qe(e){return(e==null?void 0:e.fields)??null}function Cn(e){const t=e?P(e.query):null,s=I(t);return x.useMemo(()=>Object.keys(qe(s.data)??{}),[s.data])}function Dn(e){const t=e?P(e.query):null,s=I(t);return t?s.isSuccess:!0}function Tn(e,t,s=[]){if(s.includes(t))return{pinned:[],rest:e};const a=[],r=[];for(const i of e)(i.tags??[]).includes(t)?a.push(i):r.push(i);return{pinned:a,rest:r}}function ze(){return n.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:n.jsx(O,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})})}function Qn(){const{id:e}=ft(),t=De(a=>a.getActiveVault()),s=pt(e);return t?s.data?n.jsx(En,{note:s.data}):n.jsxs("div",{className:"page",children:[n.jsx(ze,{}),s.isPending?n.jsx($n,{}):s.isError?n.jsx(Te,{title:"Couldn't load this view",message:s.error instanceof Error?s.error.message:void 0,retry:()=>s.refetch()}):n.jsx(R,{title:"View not found",description:"It may have been deleted or moved."})]}):n.jsx(xt,{to:"/",replace:!0})}function $n(){return n.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[n.jsx(k,{height:32,width:"40%"}),n.jsx(k,{height:20,width:"60%"}),n.jsxs("div",{className:"space-y-2 pt-4",children:[n.jsx(k,{height:56}),n.jsx(k,{height:56}),n.jsx(k,{height:56})]})]})}function En({note:e}){const t=x.useMemo(()=>Nt(e),[e]);return n.jsx(Mn,{def:t,backingNote:e,nav:n.jsx(ze,{})})}function Mn({def:e,backingNote:t,pageSize:s,total:a,nav:r}){var de;const i=De(N=>N.getActiveVault()),{roles:l}=ct((i==null?void 0:i.id)??null),o=typeof s=="number"&&s>0,[d,c]=x.useState(0),[p,f]=dt(),u=x.useMemo(()=>ut(p),[p]),b=x.useMemo(()=>Ne(e,hn(p)),[e,p]),j=(N,$)=>{const D=xn(N);for(const[L,A]of wt($))D.append(L,A);f(D,{replace:!0})},g=N=>j(b,N),m=N=>{j(Ne(e,N),u)},h=x.useMemo(()=>te(e,b),[e,b]),v=x.useMemo(()=>JSON.stringify({q:h.query,r:u}),[h.query,u]);x.useEffect(()=>{c(0)},[v]);const y=x.useMemo(()=>!o||!h.query?h:{...h,query:{...h.query,offset:d,limit:s+1}},[o,h,d,s]),w=mt(y,u,{live:!o}),S=x.useMemo(()=>o&&w.data?w.data.slice(0,s):w.data,[o,w.data,s]),ne=(S==null?void 0:S.length)??0,se=o?(((de=w.data)==null?void 0:de.length)??0)>s:!1,Ge=pe(u),Ue=o&&!se?d+ne:void 0,Ye=Ge?void 0:a,T=Sn(h),Qe=Cn(h),ae=[...h.problems,...w.problems],re=x.useMemo(()=>S?Tn(S,l.pinned,Ce(h.query)):{pinned:[],rest:[]},[S,l.pinned,h.query]),He=t!==null,ie=(Ie(b)||pe(u))&&He,[We,le]=x.useState(!1),oe=()=>f(new URLSearchParams,{replace:!0}),_=x.useMemo(()=>P(h.query),[h.query]),ce=Dn(h),[G,U]=x.useState(null),Je=N=>{var A,ue;const $=G;if(!$)return;const D=Object.entries(N),L=$==="date"?(A=D.find(([,E])=>E.type==="date"))==null?void 0:A[0]:(ue=D.find(([,E])=>{var me;return(((me=E.enum)==null?void 0:me.length)??0)>0})??D.find(([,E])=>E.type!=="date"))==null?void 0:ue[0];L&&m({...b,[$==="group"?"groupBy":"dateField"]:L})},Xe=h.kind==="board"||h.kind==="table";return n.jsxs("div",{className:Xe?"page page-wide":"page",children:[r,n.jsxs("article",{className:ie?"pb-20":void 0,children:[n.jsx(_n,{def:h,backingNote:t,count:Ye}),n.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-2 py-1",children:[n.jsx(cn,{kind:h.kind,onSwitch:N=>m(vn(e,b,N,T)),dirty:e.kind!==h.kind}),h.kind==="board"?n.jsx(un,{value:h.groupBy,fields:T,onChange:N=>m({...b,groupBy:N}),dirty:e.groupBy!==h.groupBy,createTag:_,schemaReady:ce,onAddField:()=>U("group")}):null,h.kind==="calendar"?n.jsx(mn,{value:h.dateField,fields:T,onChange:N=>m({...b,dateField:N}),dirty:e.dateField!==h.dateField,createTag:_,schemaReady:ce,onAddField:()=>U("date")}):null,n.jsx(ln,{fields:T,schemaFieldNames:Qe,onChange:N=>m({...b,fields:N}),dirty:e.fields!==h.fields})]}),n.jsx(Rn,{def:e,refinements:u,onChange:g}),ae.length>0?n.jsx(An,{problems:ae}):null,n.jsx("div",{className:"mt-6",children:n.jsx(Fn,{def:h,data:S,isPending:w.isPending,isError:w.isError,error:w.error,retry:w.refetch,viewResultsKey:w.queryKey,fields:T,pinned:re.pinned,rest:re.rest,roles:l})}),o?n.jsx(Ln,{offset:d,shown:ne,total:Ue,hasPrev:d>0,hasNext:se,onPrev:()=>c(N=>Math.max(0,N-s)),onNext:()=>c(N=>N+s)}):null,ie?n.jsx(Pn,{onSave:()=>le(!0),onRevert:oe}):null,We&&t?n.jsx(zn,{note:t,def:e,draft:b,refinements:u,roles:l,onClose:()=>le(!1),onSaved:oe}):null,G&&_?n.jsx(Ct,{tagName:_,intent:G,onSaved:Je,onClose:()=>U(null)}):null]})]})}function Pn({onSave:e,onRevert:t}){const s=gt(a=>a.setShown);return x.useEffect(()=>(s(!0),()=>s(!1)),[s]),n.jsx("div",{"aria-label":"View modified",className:"glass-panel fixed inset-x-0 bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-20 border-t border-border lg:bottom-0 lg:pb-[env(safe-area-inset-bottom)]",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-(--w-page) items-center justify-between gap-3 px-5 py-2.5 md:px-10",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx("span",{"aria-hidden":"true",className:"view-modified-pulse h-2 w-2 shrink-0 rounded-full bg-accent"}),n.jsxs("p",{className:"min-w-0 text-sm text-fg-muted",children:[n.jsx("span",{className:"font-medium text-fg",children:"View modified"})," — you're exploring. Save to keep this layout."]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:t,className:"btn btn-secondary btn-touch",children:"Revert"}),n.jsx("button",{type:"button",onClick:e,className:"btn btn-primary btn-touch",children:"Save"})]})]})})}function _n({def:e,backingNote:t,count:s}){return n.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 border-b border-border pb-5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx(ht,{kind:e.kind,hueTag:$e(e.query)}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"page-title truncate",children:e.title}),typeof s=="number"?n.jsx("p",{className:"text-sm text-fg-dim",children:s===1?"1 note":`${s.toLocaleString()} notes`}):null]})]}),t?n.jsx(O,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit view note"}):null]})}function Ln({offset:e,shown:t,total:s,hasPrev:a,hasNext:r,onPrev:i,onNext:l}){const o=t>0?e+1:0,d=e+t;return!a&&!r?null:n.jsxs("div",{className:"mt-6 flex items-center justify-between text-fg-dim text-sm",children:[n.jsx("span",{children:t>0?typeof s=="number"?`Showing ${o}–${d} of ${s.toLocaleString()}`:`Showing ${o}–${d}`:""}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"button",disabled:!a,onClick:i,className:"btn btn-secondary btn-touch",children:"Previous"}),n.jsx("button",{type:"button",disabled:!r,onClick:l,className:"btn btn-secondary btn-touch",children:"Next"})]})]})}function An({problems:e}){return n.jsx("output",{"aria-live":"polite",className:"mt-4 block rounded-lg border border-[--color-warning] bg-[--color-warning-soft] p-3 text-sm text-fg",children:n.jsx("ul",{className:"list-disc space-y-1 pl-5",children:e.map((t,s)=>n.jsx("li",{children:t.message},`${t.code}-${s}`))})})}function Fn({def:e,data:t,isPending:s,isError:a,error:r,retry:i,viewResultsKey:l,fields:o,pinned:d,rest:c,roles:p}){if(e.query===null)return n.jsx(R,{title:"Nothing is being shown",description:"Fix the view's query to see results."});if(s)return n.jsxs("div",{className:"space-y-2","aria-busy":"true",children:[n.jsx(k,{height:56}),n.jsx(k,{height:56}),n.jsx(k,{height:56})]});if(a)return n.jsx(Te,{title:"Couldn't run this view",message:r instanceof Error?r.message:void 0,retry:i});if(!t||d.length===0&&c.length===0)return n.jsx(R,{title:"No notes match this view yet."});const f=[...d,...c];switch(e.kind){case"board":if(e.groupBy)return n.jsx(Jt,{notes:f,laneBy:e.groupBy,subjectTag:$e(e.query),roles:p,viewResultsKey:l,fields:o});break;case"gallery":return n.jsx(on,{notes:f,roles:p,viewResultsKey:l,fields:o});case"table":return n.jsx(fn,{notes:f,roles:p,viewResultsKey:l,fields:o});case"calendar":return n.jsx(tn,{notes:f,dateField:e.dateField||null,roles:p,viewResultsKey:l,fields:o})}return n.jsx(Bn,{pinned:d,rest:c,roles:p,viewResultsKey:l,fields:o})}function Bn({pinned:e,rest:t,roles:s,viewResultsKey:a,fields:r}){const i=l=>r.length>0?n.jsx(M,{note:l,fields:r,viewResultsKey:a}):null;return n.jsxs("div",{className:"space-y-6",children:[e.length>0?n.jsxs("section",{"aria-label":"Pinned",children:[n.jsx("p",{className:"eyebrow mb-2",children:"Pinned"}),n.jsx(xe,{"aria-label":"Pinned notes",children:e.map(l=>n.jsx(he,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})]}):null,t.length>0?n.jsx("section",{"aria-label":"Results",children:n.jsx(xe,{"aria-label":"View results",children:t.map(l=>n.jsx(he,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})}):null]})}function Rn({def:e,refinements:t,onChange:s}){const a=x.useMemo(()=>bt(e.query),[e.query]),r=i=>{const l=t.removeExcludes.includes(i);s({...t,removeExcludes:l?t.removeExcludes.filter(o=>o!==i):[...t.removeExcludes,i]})};return n.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[a.map(i=>n.jsx(Vn,{chip:i,toggled:i.kind==="exclude"&&!!i.value&&t.removeExcludes.includes(i.value),onToggle:i.kind==="exclude"&&i.value?()=>r(i.value):void 0},`${i.kind}-${i.value??i.label}`)),t.addTags.map(i=>n.jsx(W,{label:`+#${i}`,onRemove:()=>s({...t,addTags:t.addTags.filter(l=>l!==i)})},`add-${i}`)),t.search?n.jsx(W,{label:`"${t.search}"`,onRemove:()=>s({...t,search:void 0})}):null,t.sort?n.jsx(W,{label:`sorted by ${t.sort==="desc"?"newest":"oldest"}`,onRemove:()=>s({...t,sort:void 0})}):null,n.jsx(On,{onAdd:i=>s({...t,addTags:[...t.addTags,i]})}),n.jsx(In,{value:t.search??"",onChange:i=>s({...t,search:i||void 0})}),n.jsx(qn,{value:t.sort,onChange:i=>s({...t,sort:i})})]})}function Vn({chip:e,toggled:t,onToggle:s}){return s?n.jsx("button",{type:"button",onClick:s,"aria-pressed":!t,title:t?"Excluded again — tap to peek":"Tap to peek at these too",className:`chip ${t?"opacity-50 line-through":""}`,children:e.label}):n.jsx("span",{className:"chip",children:e.label})}function W({label:e,onRemove:t}){return n.jsxs("span",{className:"chip chip-tag-active",children:[e,n.jsx("button",{type:"button",onClick:t,"aria-label":`Remove refinement ${e}`,className:"focus-ring ml-1 rounded-full",children:"×"})]})}function On({onAdd:e}){const[t,s]=x.useState(""),a=()=>{const r=t.trim().replace(/^#/,"");r&&(e(r),s(""))};return n.jsx("input",{type:"text",value:t,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),a())},placeholder:"+ tag","aria-label":"Add a tag filter",className:"w-24 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function In({value:e,onChange:t}){return n.jsx("input",{type:"search",value:e,onChange:s=>t(s.target.value),placeholder:"Search…","aria-label":"Search within this view",className:"w-32 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function qn({value:e,onChange:t}){return n.jsx("button",{type:"button",onClick:()=>t(e==="desc"?"asc":e==="asc"?void 0:"desc"),className:"chip","aria-label":"Cycle sort order",children:e==="desc"?"Newest first":e==="asc"?"Oldest first":"Sort"})}function zn({note:e,def:t,draft:s,refinements:a,roles:r,onClose:i,onSaved:l}){const o=ke(y=>y.push),d=yt(),c=vt(e,d),[p,f]=x.useState(c),[u,b]=x.useState(`${t.title} (copy)`),[j,g]=x.useState(!1),m=we(e.id),h=jt(),v=async()=>{g(!0);try{const y=kt(t.query,a);p==="update"?(await m.mutateAsync({metadata:jn(t,s,y),...e.updatedAt?{if_updated_at:e.updatedAt}:{force:!0}}),o(`Updated "${t.title}".`,"success")):(await h.mutateAsync({content:"",path:St(u),tags:[r.view],metadata:Nn(te(t,s),y)}),o(`Saved "${u}".`,"success")),l(),i()}catch(y){o(`Could not save: ${y.message}`,"error")}finally{g(!1)}};return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-labelledby":"save-view-title",onMouseDown:y=>{y.target===y.currentTarget&&i()},children:n.jsxs("div",{className:"dialog-panel max-w-md",children:[n.jsx("h2",{id:"save-view-title",className:"mb-3 font-serif text-xl text-fg",children:"Save this view"}),n.jsxs("div",{className:"mb-4 space-y-2",children:[n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:p==="update",onChange:()=>f("update")}),"Update this view"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:p==="fork",onChange:()=>f("fork")}),"Save as new view"]})]}),p==="fork"?n.jsxs("label",{className:"mb-4 block text-sm",children:[n.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),n.jsx("input",{type:"text",value:u,onChange:y=>b(y.target.value),className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}):null,n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary btn-touch",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>void v(),disabled:j||p==="fork"&&!u.trim(),className:"btn btn-primary btn-touch",children:j?"Saving…":"Save"})]})]})})}export{Mn as ViewCanvas,Qn as ViewSurface};
@@ -0,0 +1 @@
1
+ import{b as w,y,r as i,g as N,l as v,bz as S,o as j,k,j as e,N as b,P as h,L as C}from"./index-Dwo2xe8_.js";import{W as p}from"./WizardShell-ZqrzQKxp.js";import{f as z}from"./provenance-B6WFYTWW.js";import"./history-ByMClxJV.js";function K(){const r=w(),[a]=y(),[t,n]=i.useState({kind:"checking"}),[l,f]=i.useState(0),d=i.useRef(null),m=i.useRef(null),x=a.get("new")==="1";if(i.useEffect(()=>{if(x)return;const s=`${l}|${a.toString()}`;if(d.current===s)return;d.current=s,n(c=>c.kind==="checking"?c:{kind:"checking"});const o=a.get("pick")==="1";(async()=>{let c;try{c=await N()}catch{n({kind:"redirect"});return}if(!c.signed_in){n({kind:"redirect"});return}try{const{vaults:u}=await v();if(o&&u.length>0){n({kind:"picker",email:c.email,vaults:u});return}const g=S(u);g.kind==="first-vault"?n({kind:"first-vault"}):g.kind==="welcome-back"?n({kind:"welcome-back",email:c.email,vault:g.vault}):n({kind:"picker",email:c.email,vaults:g.vaults})}catch(u){n({kind:"net-error",message:u instanceof Error?u.message:"Unknown error"})}})()},[l,a,x]),i.useEffect(()=>{if(t.kind!=="welcome-back"||t.error||m.current===t.vault.name)return;m.current=t.vault.name;const s=t.vault.name;(async()=>{try{await j(s),k(s),r("/",{replace:!0})}catch(o){m.current=null,n(c=>c.kind==="welcome-back"&&c.vault.name===s?{...c,error:o instanceof Error?o.message:"Couldn't open your vault."}:c)}})()},[t,r]),x)return e.jsx(b,{to:"/add-vault/create",replace:!0});switch(t.kind){case"checking":return e.jsx(E,{});case"redirect":return e.jsx(b,{to:a.get("link")==="expired"?"/?link=expired":"/",replace:!0});case"first-vault":return e.jsx(b,{to:"/add-vault/create?first=1",replace:!0});case"net-error":return e.jsx(O,{message:t.message,onRetry:()=>{n({kind:"checking"}),f(s=>s+1)}});case"welcome-back":return e.jsx(V,{email:t.email,vaultName:t.vault.name,error:t.error,onRetry:()=>n(s=>s.kind==="welcome-back"?{...s,error:void 0}:s)});case"picker":return e.jsx(W,{email:t.email,vaults:t.vaults,onOpenVault:async s=>{await j(s.name),k(s.name),r("/")},onCreateNew:()=>{r("/add-vault/create")}});default:return null}}function E(){return e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{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:["Signing you ",e.jsx("span",{className:"accent-word",children:"in…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Checking your vaults…"})]})}function O({message:r,onRetry:a}){return e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Almost there"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.8rem, 4vw, 2.2rem)"},children:["You're signed in — we just couldn't fetch your ",e.jsx("span",{className:"accent-word",children:"vaults."})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:r}),e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]})}function V({email:r,vaultName:a,error:t,onRetry:n}){return t?e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Couldn't open ",e.jsxs("span",{className:"accent-word",children:[a,"."]})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:t}),e.jsx("button",{type:"button",onClick:n,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]}):e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{size:76,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"Welcome back"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.1rem)"},children:["Opening ",e.jsxs("span",{className:"accent-word",children:[a,"…"]})]}),e.jsxs("output",{"aria-live":"polite",className:"mx-auto max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," — opening ",a,"…"]})]})}function R({vault:r,busy:a,onOpen:t}){const n=z(r.usage),l=r.url?r.url.replace(/^https?:\/\//,""):"";return e.jsxs("li",{className:"card flex items-center gap-4 rounded-2xl p-4 shadow-soft",children:[e.jsx("span",{"aria-hidden":"true",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-grass-soft text-base",children:"🌱"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:r.name}),e.jsx("span",{className:"chip",children:"☁ Cloud"})]}),l?e.jsx("p",{className:"mt-0.5 truncate note-id",children:l}):null,n?e.jsx("p",{className:"mt-0.5 font-round text-xs text-fg-muted",children:n}):null]}),e.jsx("button",{type:"button",onClick:t,disabled:a,className:"btn btn-primary btn-touch shrink-0 rounded-full",children:a?"Opening…":"Open →"})]})}function W({email:r,vaults:a,onOpenVault:t,onCreateNew:n}){const[l,f]=i.useState(null),[d,m]=i.useState(null);async function x(s){if(!l){f(s.name),m(null);try{await t(s)}catch(o){f(null),m(o instanceof Error?o.message:"Couldn't open that vault.")}}}return e.jsxs(p,{wide:!0,escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Which vault"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.4rem)"},children:["Which vault ",e.jsx("span",{className:"accent-word",children:"today?"})]}),e.jsxs("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," · ",a.length," vault",a.length===1?"":"s"," on Cloud"]}),e.jsx("ul",{className:"mx-auto flex max-w-md flex-col gap-3",children:a.map(s=>e.jsx(R,{vault:s,busy:l===s.name,onOpen:()=>x(s)},s.name))}),d?e.jsx("p",{className:"mx-auto mt-6 max-w-sm rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:d}):null,e.jsxs("p",{className:"mt-8 font-round text-sm text-fg-muted",children:[e.jsx("button",{type:"button",onClick:n,className:"font-semibold text-accent hover:underline",children:"+ Create a new vault"})," ","·"," ",e.jsx(C,{to:"/add",className:"font-semibold hover:underline",style:{color:"var(--color-sky)"},children:"Connect a self-hosted vault"})]})]})}export{K as Welcome};
@@ -0,0 +1 @@
1
+ import{j as e,bE as d}from"./index-Dwo2xe8_.js";import{u as x}from"./history-ByMClxJV.js";function f({children:s,wide:t=!1,escape:l,progress:n}){const a=l!==void 0&&l.kind!=="none",c=x(a?l.to:"/"),i=a?e.jsx("button",{type:"button",onClick:c,className:"focus-ring font-round text-sm text-fg-dim hover:text-accent",children:l.label??(l.kind==="back"?"← Back":"Maybe later")}):null;return e.jsxs("div",{className:"relative flex min-h-[calc(100dvh-4rem)] flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 pt-6 sm:px-10",children:[e.jsx(d,{}),(l==null?void 0:l.kind)==="back"?i:null]}),n?e.jsx(m,{labels:n.labels,current:n.current}):null,e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-10 text-center",children:e.jsxs("div",{className:`mx-auto w-full ${t?"max-w-2xl":"max-w-md"}`,children:[s,(l==null?void 0:l.kind)==="maybe-later"?e.jsx("p",{className:"mt-6",children:i}):null]})})]})}function m({labels:s,current:t}){return e.jsx("ol",{"aria-label":`Step ${t+1} of ${s.length}: ${s[t]??""}`,className:"mt-5 flex items-center justify-center gap-2",children:s.map((l,n)=>e.jsx("li",{"aria-current":n===t?"step":void 0,className:n===t?"h-1.5 w-7 rounded-full bg-accent":n<t?"h-1.5 w-1.5 rounded-full bg-sage":"h-1.5 w-1.5 rounded-full bg-border",children:e.jsx("span",{className:"sr-only",children:l})},l))})}export{f as W};
@@ -0,0 +1,2 @@
1
+ import{r as n,j as i,aK as h,aL as v}from"./index-Dwo2xe8_.js";function E({onDropFiles:e,children:t,className:a,hint:s}){const[c,u]=n.useState(!1),o=n.useRef(0),d=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current+=1,u(!0))},[]),m=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),o.current=Math.max(0,o.current-1),o.current===0&&u(!1))},[]),p=n.useCallback(r=>{l(r.dataTransfer)&&(r.preventDefault(),r.dataTransfer.dropEffect="copy")},[]),x=n.useCallback(r=>{if(!l(r.dataTransfer))return;r.preventDefault(),u(!1),o.current=0;const f=Array.from(r.dataTransfer.files);f.length>0&&e(f)},[e]);return i.jsxs("div",{className:`relative ${a??""}`,onDragEnter:d,onDragLeave:m,onDragOver:p,onDrop:x,children:[t,c?i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-20 flex items-center justify-center rounded-md border-2 border-dashed border-accent bg-accent/10 text-sm text-accent",children:i.jsxs("div",{className:"rounded-md bg-bg/80 px-4 py-2 font-medium shadow",children:["Drop to attach",s?i.jsxs("span",{className:"ml-2 text-fg-dim",children:["— ",s]}):null]})}):null]})}function l(e){if(!e)return!1;const t=e.types;for(let a=0;a<t.length;a++)if(t[a]==="Files")return!0;return!1}function $(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}function g(e){return`${(e/(1024*1024)).toFixed(1)} MB`}function T(e){if(e.size>h)return`${e.name} is too large (${g(e.size)}). Max: 100 MB.`;const t=$(e.name);return v.has(t)?null:`${e.name}: .${t||"?"} is not in the vault allowlist.`}function D(e,t,a={}){const s=`/api/storage/${e.path}`,c=a.newline===!1?"":`
2
+ `;return e.mimeType.startsWith("image/")?`![${t}](${s})${c}`:`[${t}](${s})${c}`}export{E as A,$ as f,D as m,T as v};
@@ -0,0 +1 @@
1
+ const e="notes:livePreview";function r(){try{return localStorage.getItem(e)!=="off"}catch{return!0}}function o(t){try{t?localStorage.removeItem(e):localStorage.setItem(e,"off")}catch{}}export{r,o as w};
@@ -0,0 +1 @@
1
+ import{b as a,r as i}from"./index-Dwo2xe8_.js";function n(s){const t=a();return i.useCallback(()=>{var e;(((e=window.history.state)==null?void 0:e.idx)??0)>0?t(-1):t(s)},[t,s])}export{n as u};