@openparachute/app 0.22.14 → 0.22.15-rc.2

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 (50) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/.parachute/info +1 -1
  3. package/dist/assets/{Account-BlFpLIcL.js → Account-Hp5OkH4s.js} +1 -1
  4. package/dist/assets/{Activity-04uyKSGT.js → Activity-DM07RTaL.js} +1 -1
  5. package/dist/assets/AddVault-CCUUpUpS.js +1 -0
  6. package/dist/assets/{AddVaultChooser-BQKWysH8.js → AddVaultChooser-1EvPF7Ar.js} +1 -1
  7. package/dist/assets/{AddVaultCreate-CjT_pVEv.js → AddVaultCreate-BRI7isPc.js} +1 -1
  8. package/dist/assets/Calendar-hX-e_t5t.js +1 -0
  9. package/dist/assets/{CheckEmail-DOO73-eP.js → CheckEmail-DsBGRDN5.js} +1 -1
  10. package/dist/assets/ConnectAI-DSIclnVy.js +1 -0
  11. package/dist/assets/{DayView-CIqjBQD5.js → DayView-li8WEaCe.js} +1 -1
  12. package/dist/assets/{Export-C9cVOM7Z.js → Export-CthQyoju.js} +1 -1
  13. package/dist/assets/{Import-1ndJRP3b.js → Import-D038Sg4Z.js} +1 -1
  14. package/dist/assets/NoteEditor-Cdr7U6a5.js +1 -0
  15. package/dist/assets/{NoteNew-D8MgVbk2.js → NoteNew-DA_3KP7v.js} +2 -2
  16. package/dist/assets/{NoteRenderer-CVEx6c2v.js → NoteRenderer-ChWpdbI7.js} +23 -23
  17. package/dist/assets/NoteView-DOgD2Mi_.js +3 -0
  18. package/dist/assets/OAuthCallback-CxZrvmxm.js +1 -0
  19. package/dist/assets/{PinArchiveButtons-fss0A6G3.js → PinArchiveButtons-DB8N7LBI.js} +1 -1
  20. package/dist/assets/{Settings-C8bLBNqJ.js → Settings-B9QD34GX.js} +1 -1
  21. package/dist/assets/{TagPage-ByggRkcb.js → TagPage-BpiAw1a5.js} +1 -1
  22. package/dist/assets/{TagSchemaEditor-CUHG09YZ.js → TagSchemaEditor-_n7m_7Xz.js} +1 -1
  23. package/dist/assets/{Tags-D-v1kXQE.js → Tags-DpgXCyXu.js} +1 -1
  24. package/dist/assets/{VaultGraph-C2PwotxJ.js → VaultGraph-BjX5cCDb.js} +3 -3
  25. package/dist/assets/Vaults-Col2somv.js +1 -0
  26. package/dist/assets/{ViewNew-DwZQ_Xy1.js → ViewNew-DkEvCm66.js} +1 -1
  27. package/dist/assets/ViewSurface-CfwIfZk5.js +1 -0
  28. package/dist/assets/{Welcome-Ti-1vqQ1.js → Welcome-Bhrr6Tp-.js} +1 -1
  29. package/dist/assets/{WizardShell-X-_3n8Lx.js → WizardShell-DU1MCyj6.js} +1 -1
  30. package/dist/assets/{attachment-upload-BjoNnGbm.js → attachment-upload-BPBeh3-z.js} +1 -1
  31. package/dist/assets/{history-Bxu3eq1m.js → history-DdcRLE7l.js} +1 -1
  32. package/dist/assets/index-oE_2AheL.js +66 -0
  33. package/dist/assets/{provenance-BRYF2APg.js → provenance-CPDeMpx4.js} +1 -1
  34. package/dist/assets/{react-force-graph-2d-BpJfrG8W.js → react-force-graph-2d-CHJEP3br.js} +1 -1
  35. package/dist/assets/{transcribe-default-aMtRgXlN.js → transcribe-default-DXKy7pnW.js} +1 -1
  36. package/dist/assets/{useAttachmentUploader-BTg8Q34l.js → useAttachmentUploader-CW66AUeK.js} +2 -2
  37. package/dist/index.html +1 -1
  38. package/dist/sw.js +1 -1
  39. package/meta.json +1 -1
  40. package/package.json +1 -1
  41. package/dist/assets/AddVault-HfqPTkUx.js +0 -1
  42. package/dist/assets/Calendar-CcN20GI6.js +0 -1
  43. package/dist/assets/ConnectAI-B9qWFf_f.js +0 -1
  44. package/dist/assets/NoteEditor-J2Byu7ok.js +0 -1
  45. package/dist/assets/NoteView-BnVwet5i.js +0 -3
  46. package/dist/assets/OAuthCallback-DNI4o3ND.js +0 -1
  47. package/dist/assets/Vaults-DlztTmOd.js +0 -1
  48. package/dist/assets/ViewSurface-CEipyYaB.js +0 -1
  49. package/dist/assets/index-q-OceM-D.js +0 -66
  50. package/dist/assets/url-QSQwrjSV.js +0 -1
package/dist/index.html CHANGED
@@ -22,7 +22,7 @@
22
22
  } catch (e) {}
23
23
  })();
24
24
  </script>
25
- <script type="module" crossorigin src="/assets/index-q-OceM-D.js"></script>
25
+ <script type="module" crossorigin src="/assets/index-oE_2AheL.js"></script>
26
26
  <link rel="stylesheet" crossorigin href="/assets/index-BBWRhmyM.css">
27
27
  <link rel="manifest" href="/manifest.webmanifest"></head>
28
28
  <body>
package/dist/sw.js CHANGED
@@ -1 +1 @@
1
- if(!self.define){let s,e={};const l=(l,i)=>(l=new URL(l+".js",i).href,e[l]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()}).then(()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s}));self.define=(i,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let a={};const u=s=>l(s,r),o={module:{uri:r},exports:a,require:u};e[r]=Promise.all(i.map(s=>o[s]||u(s))).then(s=>(n(...s),a))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"},{url:"index.html",revision:"b6cb2b88788ac80a4b16c6657dc3c07a"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/useAttachmentUploader-BTg8Q34l.js",revision:null},{url:"assets/url-QSQwrjSV.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-aMtRgXlN.js",revision:null},{url:"assets/react-force-graph-2d-BpJfrG8W.js",revision:null},{url:"assets/provenance-BRYF2APg.js",revision:null},{url:"assets/index-q-OceM-D.js",revision:null},{url:"assets/index-BBWRhmyM.css",revision:null},{url:"assets/history-Bxu3eq1m.js",revision:null},{url:"assets/fraunces-vietnamese-opsz-normal-Czevyj-6.woff2",revision:null},{url:"assets/fraunces-vietnamese-opsz-italic-DxWqP7Ku.woff2",revision:null},{url:"assets/fraunces-latin-opsz-normal-DihXLNYH.woff2",revision:null},{url:"assets/fraunces-latin-opsz-italic-lSdLDfvT.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-normal-CJcjJNj7.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-italic-CGbN9UgK.woff2",revision:null},{url:"assets/figtree-latin-wght-normal-D_ZTVpCC.woff2",revision:null},{url:"assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2",revision:null},{url:"assets/editor-mode-D9fveTEx.js",revision:null},{url:"assets/attachment-upload-BjoNnGbm.js",revision:null},{url:"assets/WizardShell-X-_3n8Lx.js",revision:null},{url:"assets/Welcome-Ti-1vqQ1.js",revision:null},{url:"assets/ViewSurface-CEipyYaB.js",revision:null},{url:"assets/ViewNew-DwZQ_Xy1.js",revision:null},{url:"assets/Vaults-DlztTmOd.js",revision:null},{url:"assets/VaultGraph-C2PwotxJ.js",revision:null},{url:"assets/Tags-D-v1kXQE.js",revision:null},{url:"assets/TagSchemaEditor-CUHG09YZ.js",revision:null},{url:"assets/TagPage-ByggRkcb.js",revision:null},{url:"assets/Settings-C8bLBNqJ.js",revision:null},{url:"assets/PinArchiveButtons-fss0A6G3.js",revision:null},{url:"assets/OAuthCallback-DNI4o3ND.js",revision:null},{url:"assets/NoteView-BnVwet5i.js",revision:null},{url:"assets/NoteRenderer-CVEx6c2v.js",revision:null},{url:"assets/NoteNew-D8MgVbk2.js",revision:null},{url:"assets/NoteEditor-J2Byu7ok.js",revision:null},{url:"assets/Import-1ndJRP3b.js",revision:null},{url:"assets/Export-C9cVOM7Z.js",revision:null},{url:"assets/DayView-CIqjBQD5.js",revision:null},{url:"assets/ConnectAI-B9qWFf_f.js",revision:null},{url:"assets/CheckEmail-DOO73-eP.js",revision:null},{url:"assets/Calendar-CcN20GI6.js",revision:null},{url:"assets/AddVaultCreate-CjT_pVEv.js",revision:null},{url:"assets/AddVaultChooser-BQKWysH8.js",revision:null},{url:"assets/AddVault-HfqPTkUx.js",revision:null},{url:"assets/Activity-04uyKSGT.js",revision:null},{url:"assets/Account-BlFpLIcL.js",revision:null},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//,/^\/oauth\/(?!callback)/,/^\/\.well-known\//,/^\/signup/,/^\/login/,/^\/logout/,/^\/auth\//,/^\/console/,/^\/admin/,/^\/account\//,/^\/billing/,/^\/unsubscribe/,/^\/health/,/^\/vault\//,/^\/u\//]}))});
1
+ if(!self.define){let s,e={};const l=(l,i)=>(l=new URL(l+".js",i).href,e[l]||new Promise(e=>{if("document"in self){const s=document.createElement("script");s.src=l,s.onload=e,document.head.appendChild(s)}else s=l,importScripts(l),e()}).then(()=>{let s=e[l];if(!s)throw new Error(`Module ${l} didn’t register its module`);return s}));self.define=(i,n)=>{const r=s||("document"in self?document.currentScript.src:"")||location.href;if(e[r])return;let a={};const o=s=>l(s,r),u={module:{uri:r},exports:a,require:o};e[r]=Promise.all(i.map(s=>u[s]||o(s))).then(s=>(n(...s),a))}}define(["./workbox-9c191d2f"],function(s){"use strict";self.skipWaiting(),s.clientsClaim(),s.precacheAndRoute([{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"},{url:"index.html",revision:"ef00afb12d434426d42b5ca879318ee5"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"assets/workbox-window.prod.es5-BBnX5xw4.js",revision:null},{url:"assets/useAttachmentUploader-CW66AUeK.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-DXKy7pnW.js",revision:null},{url:"assets/react-force-graph-2d-CHJEP3br.js",revision:null},{url:"assets/provenance-CPDeMpx4.js",revision:null},{url:"assets/index-oE_2AheL.js",revision:null},{url:"assets/index-BBWRhmyM.css",revision:null},{url:"assets/history-DdcRLE7l.js",revision:null},{url:"assets/fraunces-vietnamese-opsz-normal-Czevyj-6.woff2",revision:null},{url:"assets/fraunces-vietnamese-opsz-italic-DxWqP7Ku.woff2",revision:null},{url:"assets/fraunces-latin-opsz-normal-DihXLNYH.woff2",revision:null},{url:"assets/fraunces-latin-opsz-italic-lSdLDfvT.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-normal-CJcjJNj7.woff2",revision:null},{url:"assets/fraunces-latin-ext-opsz-italic-CGbN9UgK.woff2",revision:null},{url:"assets/figtree-latin-wght-normal-D_ZTVpCC.woff2",revision:null},{url:"assets/figtree-latin-ext-wght-normal-DCwSJGxG.woff2",revision:null},{url:"assets/editor-mode-D9fveTEx.js",revision:null},{url:"assets/attachment-upload-BPBeh3-z.js",revision:null},{url:"assets/WizardShell-DU1MCyj6.js",revision:null},{url:"assets/Welcome-Bhrr6Tp-.js",revision:null},{url:"assets/ViewSurface-CfwIfZk5.js",revision:null},{url:"assets/ViewNew-DkEvCm66.js",revision:null},{url:"assets/Vaults-Col2somv.js",revision:null},{url:"assets/VaultGraph-BjX5cCDb.js",revision:null},{url:"assets/Tags-DpgXCyXu.js",revision:null},{url:"assets/TagSchemaEditor-_n7m_7Xz.js",revision:null},{url:"assets/TagPage-BpiAw1a5.js",revision:null},{url:"assets/Settings-B9QD34GX.js",revision:null},{url:"assets/PinArchiveButtons-DB8N7LBI.js",revision:null},{url:"assets/OAuthCallback-CxZrvmxm.js",revision:null},{url:"assets/NoteView-DOgD2Mi_.js",revision:null},{url:"assets/NoteRenderer-ChWpdbI7.js",revision:null},{url:"assets/NoteNew-DA_3KP7v.js",revision:null},{url:"assets/NoteEditor-Cdr7U6a5.js",revision:null},{url:"assets/Import-D038Sg4Z.js",revision:null},{url:"assets/Export-CthQyoju.js",revision:null},{url:"assets/DayView-li8WEaCe.js",revision:null},{url:"assets/ConnectAI-DSIclnVy.js",revision:null},{url:"assets/CheckEmail-DsBGRDN5.js",revision:null},{url:"assets/Calendar-hX-e_t5t.js",revision:null},{url:"assets/AddVaultCreate-BRI7isPc.js",revision:null},{url:"assets/AddVaultChooser-1EvPF7Ar.js",revision:null},{url:"assets/AddVault-CCUUpUpS.js",revision:null},{url:"assets/Activity-DM07RTaL.js",revision:null},{url:"assets/Account-Hp5OkH4s.js",revision:null},{url:"apple-touch-icon-180x180.png",revision:"010679b40baa6da053a041cfc7fc7657"},{url:"favicon.ico",revision:"8b16a7348bc587d1c91324487d988e81"},{url:"icon.svg",revision:"53c7d88dbec013463a85d68375229bcb"},{url:"maskable-icon-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-192x192.png",revision:"536b2ea22e7195eefa8806a1d7d993da"},{url:"pwa-512x512.png",revision:"f748457107f68f1ca3c1c546ef9921e7"},{url:"pwa-64x64.png",revision:"6f10cd3ce8dd36cf6af65fd22310235f"},{url:"manifest.webmanifest",revision:"5171a09ae3e50605a6503e2bebd6866b"}],{}),s.cleanupOutdatedCaches(),s.registerRoute(new s.NavigationRoute(s.createHandlerBoundToURL("/index.html"),{denylist:[/^\/api\//,/^\/oauth\/(?!callback)/,/^\/\.well-known\//,/^\/signup/,/^\/login/,/^\/logout/,/^\/auth\//,/^\/console/,/^\/admin/,/^\/account\//,/^\/billing/,/^\/unsubscribe/,/^\/health/,/^\/vault\//,/^\/u\//]}))});
package/meta.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "parachute",
4
4
  "displayName": "Parachute",
5
5
  "tagline": "The Parachute app — your parachute's front door.",
6
- "version": "0.22.14",
6
+ "version": "0.22.15-rc.2",
7
7
  "path": "/surface/parachute",
8
8
  "iconUrl": "icon.svg",
9
9
  "scopes_required": ["vault:*:read", "vault:*:write"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openparachute/app",
3
- "version": "0.22.14",
3
+ "version": "0.22.15-rc.2",
4
4
  "type": "module",
5
5
  "description": "Parachute — the super-surface. A single-page app for interfacing with your Parachute: name a vault, capture and browse notes, connect your AI, and manage the cloud + hub via their APIs. Seeded from notes-ui; the calm centered arrival + warm home lead the experience.",
6
6
  "license": "AGPL-3.0-only",
@@ -1 +0,0 @@
1
- import{C as E,b as I,r,F as z,G as g,H as V,J as F,a as H,K as A,M as O,j as e,P as q,O as B}from"./index-q-OceM-D.js";import{W as L}from"./WizardShell-X-_3n8Lx.js";import{s as M}from"./url-QSQwrjSV.js";import"./history-Bxu3eq1m.js";function W(s){const o=s.trim();if(!o)return null;try{return new URL(g(o)).host}catch{return null}}function T(){const[s,o]=E(),b=I(),m=s.get("url")??"",u=s.get("add")??"",f=/^https?:\/\//i.test(u),v=m||(f?u:""),i=M(s.get("redirect")),[a,j]=r.useState(v),[y,x]=r.useState(null),[R,w]=r.useState(!1),[h,N]=r.useState(!1),S=r.useRef(null),C=r.useRef(v.length>0),U=r.useRef(!1),c=z();r.useEffect(()=>{var t;(t=S.current)==null||t.focus()},[]),r.useEffect(()=>{C.current||c.status==="found"&&c.origin&&a===""&&(j(c.origin),C.current=!0)},[c.status,c.origin,a]);const p=r.useCallback(async t=>{x(null),w(!1);let l;try{l=g(t)}catch(n){x(n.message);return}N(!0);try{const{authorizeUrl:n}=await V(l,void 0,void 0,{...i?{redirect:i}:{}});window.location.assign(n)}catch(n){n instanceof F?w(!0):x(n.message),N(!1)}},[i]);r.useEffect(()=>{if(U.current||!u)return;U.current=!0;const t=new URLSearchParams(s);if(t.delete("add"),o(t,{replace:!0}),m||!f)return;let l;try{l=g(u)}catch{return}const P=H.getState().vaults[A(l)];if(P){O(P.id,{toast:!0}),b(i??"/",{replace:!0});return}p(l)},[u,f,m,i,s,o,b,p]);function k(t){t.preventDefault(),p(a)}const d=W(a);return e.jsxs(L,{escape:{kind:"back",to:"/"},children:[e.jsx(q,{size:60,className:"mx-auto mb-6 drop-in"}),e.jsx("p",{className:"eyebrow mb-3",children:"Self-hosted"}),e.jsxs("h1",{className:"hero-title mb-4",children:["Connect your ",e.jsx("span",{className:"accent-word",children:"own"})," vault."]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-lg leading-relaxed text-fg-muted",children:"Point Parachute at a vault running on your own server."}),e.jsxs("form",{onSubmit:k,className:"mx-auto w-full max-w-sm text-left",children:[e.jsx("label",{htmlFor:"vault-url",className:"eyebrow mb-2 block",children:"Vault address"}),e.jsx("input",{id:"vault-url",ref:S,type:"url",required:!0,placeholder:"hub.your-domain.com",value:a,onChange:t=>j(t.target.value),disabled:h,className:"input input-on-bg font-mono"}),e.jsxs("p",{className:"mt-1.5 text-xs text-fg-dim",children:["A local install lives at ",e.jsx("code",{className:"note-id",children:"http://localhost:1939"}),"."]}),R?e.jsx("div",{className:"mt-3",children:e.jsx(B,{})}):null,y?e.jsx("p",{className:"mt-3 rounded-xl border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:y}):null,d?e.jsxs("div",{className:"mt-5 rounded-2xl border border-sun bg-sun-soft px-4 py-3 text-left font-round text-sm leading-relaxed text-sun-ink",children:["Next, ",e.jsx("b",{className:"font-semibold text-fg",children:d})," — your server, not ours — will ask you to sign in and approve this app. Then you land right back here."]}):null,e.jsx("button",{type:"submit",disabled:h||!a,className:"btn btn-primary btn-lg mt-5 w-full justify-center rounded-full shadow-soft",children:h?"Continuing…":d?`Continue to ${d} →`:"Continue"})]})]})}export{T as AddVault};
@@ -1 +0,0 @@
1
- import{a as S,C as k,T as j,U as N,v as A,r as u,W as T,w as _,X as K,j as e,N as C,Y as v,Z as m,_ as V,L as c,D as P,V as Y}from"./index-q-OceM-D.js";const I=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g=5;function W(){const s=S(t=>t.getActiveVault()),[d]=k(),n=d.get("month"),r=j(n)??j(N()),x=A(),l=u.useMemo(()=>T(r.year,r.month),[r.year,r.month]),$=u.useMemo(()=>{const t=l[0],a=l[l.length-1];return{from:t.toISOString(),to:new Date(a.getFullYear(),a.getMonth(),a.getDate()+1).toISOString()}},[l]),o=_({field:"created_at",...$,limit:P}),M=u.useMemo(()=>{const t=new Map;if(!o.data)return t;for(const a of o.data){const i=K(a.createdAt);i&&t.set(i,(t.get(i)??0)+1)}return t},[o.data]);if(!s)return e.jsx(C,{to:"/",replace:!0});const p=v(r.year,r.month,-1),b=v(r.year,r.month,1),y=`${p.year}-${m(p.month)}`,f=`${b.year}-${m(b.month)}`,D=N(),w=`${r.year}-${m(r.month)}`===D;return e.jsxs("div",{className:"mx-auto max-w-4xl px-4 py-6 md:px-6 md:py-10",children:[e.jsxs("header",{className:"mb-6 flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-fg-dim",children:"Calendar"}),e.jsx("h1",{className:"font-serif text-3xl tracking-tight",children:V(r.year,r.month)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsxs(c,{to:`/calendar?month=${y}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Previous month",children:["← ",y]}),w?null:e.jsx(c,{to:"/calendar",className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"This month"}),e.jsxs(c,{to:`/calendar?month=${f}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent","aria-label":"Next month",children:[f," →"]}),e.jsx(c,{to:`/today?date=${x}`,className:"rounded-lg border border-border bg-card px-3 py-1.5 text-fg-muted hover:text-accent",children:"Today"})]})]}),o.isError?e.jsx(F,{error:o.error,retry:()=>o.refetch()}):e.jsxs("div",{className:"rounded-md border border-border bg-card","aria-busy":o.isPending,children:[e.jsx("div",{className:"grid grid-cols-7 border-b border-border text-xs uppercase tracking-wider text-fg-dim",children:I.map(t=>e.jsx("div",{className:"px-2 py-2 text-center",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7",children:l.map(t=>{const a=`${t.getFullYear()}-${m(t.getMonth()+1)}-${m(t.getDate())}`,i=t.getMonth()+1===r.month,h=M.get(a)??0,E=a===x;return e.jsxs(c,{to:`/today?date=${a}`,className:`flex min-h-20 flex-col border-b border-r border-border p-1.5 text-xs hover:bg-bg/60 focus:bg-bg/60 focus:outline-none ${i?"":"opacity-40"}`,"aria-label":`${a} — ${h} notes`,children:[e.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full tabular-nums ${E?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t.getDate()}),h>0?e.jsx(R,{count:h}):e.jsx("span",{className:"sr-only",children:"no notes"})]},a)})})]}),e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:"Each dot is a note created on that day. Click any day to open /today."})]})}function R({count:s}){const d=Math.min(s,g),n=s>g?s-g:0;return e.jsxs("span",{className:"flex flex-wrap items-center gap-0.5",children:[Array.from({length:d}).map((r,x)=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-hidden":"true"},x)),n>0?e.jsxs("span",{className:"ml-0.5 text-[10px] text-fg-dim",children:["+",n]}):null]})}function F({error:s,retry:d}){const n=s instanceof Y;return e.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-6",children:[e.jsx("p",{className:"mb-2 font-medium text-red-400",children:n?"Session expired":"Could not load notes"}),e.jsx("p",{className:"mb-4 text-sm text-fg-muted",children:s.message}),n?e.jsx(c,{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"}):e.jsx("button",{type:"button",onClick:d,className:"btn btn-secondary",children:"Retry"})]})}export{W as Calendar};
@@ -1 +0,0 @@
1
- import{a as m,j as e,N as h,L as l,$ as o}from"./index-q-OceM-D.js";function u(s){return`${s.replace(/\/+$/,"")}/mcp`}function x(s){return`parachute-${s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"vault"}`}function p(s,t){return`claude mcp add --transport http ${x(s)} ${t}`}function y(){const s=m(n=>n.getActiveVault());if(!s)return e.jsx(h,{to:"/",replace:!0});const t=u(s.url),a=p(s.name,t);return e.jsxs("div",{className:"page-prose",children:[e.jsx("nav",{className:"mb-4 text-sm text-fg-dim",children:e.jsx(l,{to:"/",className:"focus-ring hover:text-accent",children:"← Home"})}),e.jsxs("header",{className:"mb-8",children:[e.jsx("p",{className:"eyebrow mb-1",children:s.name}),e.jsx("h1",{className:"page-title",children:"Connect your AI"}),e.jsx("p",{className:"mt-3 text-fg-muted",children:"Your vault speaks MCP — an open standard — so any AI can read and write it: Claude, ChatGPT, Claude Code, Cursor, or an agent you build. One memory, shared with every assistant you choose to connect."})]}),e.jsxs("section",{"aria-labelledby":"mcp-url-heading",className:"mb-8",children:[e.jsx("h2",{id:"mcp-url-heading",className:"eyebrow mb-2",children:"Your vault address"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Paste this wherever an AI asks for an MCP server. The"," ",e.jsx("code",{className:"rounded bg-bg-soft px-1 font-mono text-fg",children:"/mcp"})," suffix matters — it's the connection endpoint, not a page to open."]}),e.jsx(o,{value:t,label:"vault MCP URL"}),e.jsxs("p",{className:"mt-3 text-sm text-fg-muted",children:["It reads and writes only inside"," ",e.jsx("b",{className:"rounded-md bg-grass-soft px-2 py-0.5 font-medium text-grass-ink",children:s.name})," ","— never anywhere else. Disconnect anytime from your vault's settings."]})]}),e.jsx("h2",{className:"eyebrow mb-3",children:"Bring your AI in"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(d,{title:"Claude",initial:"C",tone:"coral",steps:g}),e.jsx(d,{title:"ChatGPT",initial:"G",tone:"grass",steps:b,note:"Exact menu names vary by ChatGPT version; the shape is the same — add an MCP server, paste the URL."})]}),e.jsxs("section",{"aria-labelledby":"other-clients-heading",className:"mt-8",children:[e.jsx("h2",{id:"other-clients-heading",className:"eyebrow mb-2",children:"Other AIs & the command line"}),e.jsx("p",{className:"mb-3 text-sm text-fg-muted",children:"That same URL works in any MCP-compatible client — Cursor, an agent you build, anywhere an AI asks for an MCP server. For Claude Code:"}),e.jsx(o,{value:a,label:"Claude Code command"})]}),e.jsx("div",{className:"mt-10 flex flex-wrap items-center gap-3 border-t border-border pt-6",children:e.jsx(l,{to:"/",className:"btn btn-primary btn-touch",children:"Done — back to your vault"})})]})}const g=[{key:"settings",body:e.jsxs(e.Fragment,{children:["Open"," ",e.jsx("a",{href:"https://claude.ai",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:"claude.ai"})," ","and go to ",e.jsx("strong",{className:"text-fg",children:"Settings → Connectors"}),"."]})},{key:"add",body:e.jsxs(e.Fragment,{children:["Choose ",e.jsx("strong",{className:"text-fg",children:"Add custom connector"}),"."]})},{key:"paste",body:"Paste your vault address above and connect."}],b=[{key:"settings",body:e.jsxs(e.Fragment,{children:["Open ChatGPT's ",e.jsx("strong",{className:"text-fg",children:"Settings"})," and find its connectors (custom connectors need a paid ChatGPT plan)."]})},{key:"add",body:"Add a custom connector / MCP server."},{key:"paste",body:"Paste the same vault address and connect."}];function d({title:s,initial:t,tone:a,steps:n,note:r}){const i=a==="coral"?"bg-coral-soft text-coral-ink":"bg-grass-soft text-grass-ink";return e.jsxs("section",{className:"tile p-5","aria-label":`Connect ${s}`,children:[e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx("span",{"aria-hidden":"true",className:`grid h-9 w-9 shrink-0 place-items-center rounded-full font-round text-sm font-semibold ${i}`,children:t}),e.jsx("h2",{className:"font-serif text-xl text-fg",children:s})]}),e.jsx("ol",{className:"list-decimal space-y-2 pl-5 text-sm text-fg-muted",children:n.map(c=>e.jsx("li",{children:c.body},c.key))}),r?e.jsx("p",{className:"mt-3 text-xs text-fg-dim",children:r}):null]})}export{y as ConnectAI};
@@ -1 +0,0 @@
1
- import{r as n,j as e,a8 as H,af as oe,V as I,a9 as le,ag as ce,a as K,ah as de,N as ue,L as $,E as me,z as fe,b as he,ai as q,aj as xe,ak as pe,al as ge,am as be,aa as ve,an as P,ao as je,ap as Ne,aq as we,A as F,ar as ye}from"./index-q-OceM-D.js";import{A as Se}from"./attachment-upload-BjoNnGbm.js";import{u as ke,C as Ce,A as Ee,a as Re}from"./useAttachmentUploader-BTg8Q34l.js";import{P as Ae,D as De}from"./PinArchiveButtons-fss0A6G3.js";import{b as Te,N as Pe}from"./NoteRenderer-CVEx6c2v.js";import{r as Ie}from"./editor-mode-D9fveTEx.js";const $e=250;function Fe({noteId:t,attachment:a}){const[r,l]=n.useState(!1),x=Ve(a);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":`Remove attachment ${x}`,className:"shrink-0 rounded border border-transparent px-1.5 py-0.5 text-fg-dim hover:border-red-500/40 hover:text-red-400",children:"✕"}),r?e.jsx(Le,{noteId:t,attachment:a,label:x,onClose:()=>l(!1)}):null]})}function Le({noteId:t,attachment:a,label:r,onClose:l}){const x=H(o=>o.push),i=oe(),[u,m]=n.useState(!1),[f,N]=n.useState(null),c=n.useRef(null);n.useEffect(()=>{const o=setTimeout(()=>m(!0),$e);return()=>clearTimeout(o)},[]),n.useEffect(()=>{var o;(o=c.current)==null||o.focus()},[]),n.useEffect(()=>{const o=k=>{k.key==="Escape"&&l()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l]);const g=n.useCallback(()=>{!u||i.isPending||(N(null),i.mutate({noteId:t,attachmentId:a.id},{onSuccess:()=>{x(`Removed ${r}`,"success"),l()},onError:o=>{if(o instanceof I){N("Session expired. Reconnect to remove attachments.");return}if(o instanceof le){x(`Already removed ${r}`,"info"),l();return}N(o instanceof Error?o.message:"Remove failed")}}))},[u,a.id,r,i,t,l,x]);return e.jsx("dialog",{open:!0,"aria-labelledby":"confirm-remove-attachment-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:o=>{o.target===o.currentTarget&&l()},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:"confirm-remove-attachment-title",className:"mb-2 font-serif text-lg text-red-400",children:"Remove attachment?"}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[e.jsx("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:r})," ","will be detached from this note. If no other note references the file, it will also be deleted from storage. Markdown referencing it will show a broken link until you update it."]}),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",{ref:c,type:"button",onClick:l,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:g,disabled:!u||i.isPending,className:"btn btn-danger-solid btn-touch",children:i.isPending?"Removing…":"Remove"})]})]})})}function Ve(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function Qe(){const{id:t}=ce(),a=K(l=>l.getActiveVault()),r=de(t);return a?e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx($,{to:t?`/n/${encodeURIComponent(t)}`:"/",className:"focus-ring hover:text-accent",children:"← Back to note"})}),r.isPending?e.jsx(Oe,{}):r.isError?e.jsx(ze,{error:r.error}):r.data?e.jsx(Be,{note:r.data}):e.jsx(_e,{id:t??""})]}):e.jsx(ue,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Be({note:t}){const a=he(),r=H(s=>s.push),l=q(s=>s.on),x=q(s=>s.setOn),i=n.useRef(K.getState().activeVaultId).current,u=n.useRef(Ie()).current,m=n.useMemo(()=>Te(t),[t]),[f,N]=n.useState(()=>S(t)),[c,g]=n.useState(()=>S(t)),[o,k]=n.useState(()=>{if(!i)return null;const s=xe(i,t.id);return!s||pe(s.body,S(t))?null:s}),[Z,L]=n.useState(""),[V,C]=n.useState(null),[B,E]=n.useState(null),[M,U]=n.useState(!1),w=n.useRef(null);n.useEffect(()=>()=>{w.current!==null&&window.clearTimeout(w.current)},[]);const[R,G]=n.useState("edit"),j=ge(t.id),A=n.useRef(t),D=n.useRef(null),O=n.useRef(null),v=ke({noteId:t.id,onInsert:s=>{D.current?D.current.insertAtCursor(s):g(d=>({...d,content:`${d.content}${s}`}))},onLinked:()=>{r("Attachment added","success")},onError:s=>r(s,"error")});n.useEffect(()=>{A.current=t},[t]);const h=c.content!==f.content||c.path!==f.path||!We(c.tags,f.tags);be(i,t.id,c,h);const y=v.uploads.some(s=>s.status==="uploading"||s.status==="linking"),T=n.useCallback(({navigateToView:s})=>{if(!h||j.isPending||y)return;const d={};c.content!==f.content&&(d.content=c.content),c.path!==f.path&&(d.path=c.path);const b=qe(f.tags,c.tags);(b.add.length||b.remove.length)&&(d.tags=b);const W=A.current.updatedAt??A.current.createdAt;W&&(d.if_updated_at=W),E(null),C(null),j.mutate(d,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,i&&P(i,t.id),s?a(`/n/${encodeURIComponent(p.id)}`,{replace:!0}):p.id!==t.id&&a(`/n/${encodeURIComponent(p.id)}/edit`,{replace:!0}),s||(U(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>U(!1),1500))},onError:p=>{p instanceof ve?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,c,h,j,a,t.id,y,i]),Q=n.useCallback(()=>{o&&g(o.body),k(null)},[o]),X=n.useCallback(()=>{i&&P(i,t.id),k(null)},[i,t.id]),ee=n.useCallback(()=>T({navigateToView:!0}),[T]),te=n.useCallback(()=>T({navigateToView:!1}),[T]),se=n.useCallback(()=>{h&&confirm("Discard all edits and revert to last saved version?")&&(g(f),C(null),E(null))},[f,h]),_=n.useCallback(()=>{h&&!confirm("Discard unsaved changes?")||(i&&P(i,t.id),a(`/n/${encodeURIComponent(t.id)}`))},[h,a,t.id,i]);n.useEffect(()=>{if(!h)return;const s=d=>{d.preventDefault(),d.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const ne=c.path!==f.path,ae=s=>{const d=ye(s);d&&(c.tags.includes(d)||(g(b=>({...b,tags:[...b.tags,d]})),L("")))},re=s=>{g(d=>({...d,tags:d.tags.filter(b=>b!==s)}))},ie=c.content,z=l?"h-[85dvh]":"h-[60dvh]";return e.jsxs("article",{children:[l?e.jsx("div",{className:"glass-panel enter-fade fixed top-4 left-4 z-30 rounded-full border border-border px-3 py-1.5 text-xs shadow-lift",style:{marginTop:"env(safe-area-inset-top)"},children:e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})}):e.jsxs("header",{className:"card mb-6 p-5 shadow-soft md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"eyebrow",children:"Editing"}),e.jsx(Y,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ae,{note:t}),e.jsx(De,{note:t}),e.jsxs("button",{type:"button",onClick:()=>{var s;(s=D.current)==null||s.focus(),x(!0)},className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(je,{width:16,height:16}),"Focus"]}),e.jsx("span",{className:"mx-1 h-5 w-px bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",onClick:se,disabled:!h||j.isPending,className:"btn btn-secondary btn-touch",children:"Revert"}),e.jsx("button",{type:"button",onClick:_,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:ee,disabled:!h||j.isPending||y,className:"btn btn-primary btn-touch",title:y?"Waiting for upload…":"Save (⌘S)","aria-label":y?"Save — waiting for upload…":"Save",children:j.isPending?"Saving…":"Save"})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ne,{tags:c.tags,input:Z,onInputChange:L,onAdd:ae,onRemove:re})}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-xs",children:"Path"}),e.jsx("input",{type:"text",value:c.path,onChange:s=>g(d=>({...d,path:s.target.value})),className:"focus-ring w-full min-w-0 truncate rounded border-0 bg-transparent font-mono text-xs text-fg-dim outline-none transition-colors hover:text-fg-muted focus:text-fg placeholder:text-fg-dim","aria-label":"Note path",placeholder:"(no path)",title:c.path||void 0})]}),ne?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null,we(c.path)?e.jsx("p",{className:"mt-1 text-xs text-danger",children:"This path is reserved for a built-in view. Notes saved here will not appear in the Views rail."}):null]}),o?e.jsxs("div",{role:"status","data-testid":"draft-offer",className:"mb-4 flex flex-wrap items-center justify-between gap-2 rounded-xl border border-accent/30 bg-accent/5 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"text-fg-muted",children:["You have an unsaved draft from ",F(o.savedAt),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:Q,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:X,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,V?e.jsx(Ue,{conflict:V,onReload:()=>{i&&P(i,t.id),window.location.reload()},onDismiss:()=>C(null)}):null,B?e.jsx("div",{className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:B}):null,u?null:e.jsx("div",{role:"tablist","aria-label":"Editor view",className:"mb-3 inline-flex rounded-lg border border-border bg-card p-0.5 text-sm lg:hidden",children:["edit","preview"].map(s=>e.jsx("button",{type:"button",role:"tab","aria-selected":R===s,onClick:()=>G(s),className:`rounded-sm px-3 py-1.5 capitalize ${R===s?"bg-accent text-on-accent":"text-fg-muted hover:text-accent"}`,children:s},s))}),e.jsxs("div",{className:`grid ${l?"min-h-[85dvh]":"min-h-[60dvh]"} gap-4 ${u?"":"lg:grid-cols-2"}`,children:[e.jsx(Se,{onDropFiles:v.start,className:`card min-h-0 ${z} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:J,children:e.jsx(Ce,{ref:D,value:c.content,onChange:s=>g(d=>({...d,content:s})),onSave:te,onCancel:_,onPasteFile:s=>(v.start(s),!0),onRequestAttachment:()=>{var s;return(s=O.current)==null?void 0:s.open()},livePreview:u})}),u?null:e.jsx("div",{className:`card min-h-0 ${z} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Pe,{note:{path:c.path,content:ie},resolve:m})})]}),e.jsx(Me,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const J=e.jsxs(e.Fragment,{children:["Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"})]});function Me({noteId:t,pickerRef:a,attachments:r,uploads:l,onPickFiles:x,onCancel:i,onDismiss:u}){return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(Ee,{ref:a,onPickFiles:x})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Max 100 MB each. ",J,"."]}),e.jsx(Re,{uploads:l,onCancel:i,onDismiss:u}),r.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:r.map(m=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-lg border border-border bg-card/50 px-3 py-1.5 font-mono text-xs",children:[e.jsx("span",{className:"truncate",title:m.path??m.id,children:m.filename??m.path??m.id}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m.mimeType?e.jsx("span",{className:"text-fg-dim",children:m.mimeType}):null,e.jsx(Fe,{noteId:t,attachment:m})]})]},m.id))}):null]})}function Ue({conflict:t,onReload:a,onDismiss:r}){return e.jsxs("div",{className:"mb-4 rounded-xl border border-warning bg-warning-soft p-4",children:[e.jsx("p",{className:"mb-1 font-medium text-warning",children:"This note was edited elsewhere."}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:["Your save was rejected to avoid overwriting the other edit.",t.currentUpdatedAt?` Latest update ${F(t.currentUpdatedAt)}.`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-touch",children:"Reload latest (discard my edits)"}),e.jsx("button",{type:"button",onClick:r,className:"btn btn-secondary btn-touch",children:"Keep editing"})]})]})}function Oe(){return e.jsxs("div",{className:"grid min-h-[60dvh] gap-4 lg:grid-cols-2","aria-busy":"true",children:[e.jsx("div",{className:"card animate-pulse"}),e.jsx("div",{className:"card animate-pulse"})]})}function _e({id:t}){return e.jsx(fe,{title:e.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:e.jsxs(e.Fragment,{children:["No note with id ",e.jsx("span",{className:"font-mono",children:t})," in this vault."]}),action:e.jsx($,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Y({isDirty:t,justSaved:a,updatedAt:r}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-accent","aria-label":"unsaved changes",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent"}),"unsaved"]}):a?e.jsx("span",{className:"text-xs text-accent","aria-label":"saved",children:"Saved ✓"}):e.jsxs("span",{className:"text-xs text-fg-dim",children:["saved ",F(r)]})}function ze({error:t}){const a=t instanceof I;return e.jsx(me,{title:a?"Session expired":"Could not load note",message:t.message,action:a?e.jsx($,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function We(t,a){if(t.length!==a.length)return!1;const r=new Set(t);for(const l of a)if(!r.has(l))return!1;return!0}function qe(t,a){const r=new Set(t),l=new Set(a),x=a.filter(u=>!r.has(u)),i=t.filter(u=>!l.has(u));return{add:x,remove:i}}export{Qe as NoteEditor};
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-BpJfrG8W.js","assets/index-q-OceM-D.js","assets/index-BBWRhmyM.css"])))=>i.map(i=>d[i]);
2
- import{a7 as k,a as w,ay as M,r as d,aP as D,j as t,ah as $,aQ as V,L as g,aR as O,aS as _,aT as z,aU as H,aV as G,ag as W,aW as K,N as Q,a2 as q,y as b,a3 as X,aX as Y,az as Z,ai as P,aY as J,aZ as ee,a_ as te,a$ as se,ao as ne,b0 as re,E as ae,z as ie,b1 as C,A,$ as oe,b2 as le,V as ce,a9 as de,b3 as ue}from"./index-q-OceM-D.js";import{P as me,D as he}from"./PinArchiveButtons-fss0A6G3.js";import{b as xe,N as fe}from"./NoteRenderer-CVEx6c2v.js";function pe(e,n){const s=k(),r=w(u=>u.activeVaultId),i=M(),[l,a]=d.useState(!1),o=n&&!ge(n)?n.path:void 0;return d.useEffect(()=>{if(a(!1),!s||!r||!e||!o)return;let u=!0;const m=()=>{u&&i.invalidateQueries({queryKey:["note",r,e]})},c=be(s,o,{onUpsert:m,onRemove:m,onStatus:x=>{u&&a(x==="open")}});return()=>{u=!1,a(!1),c()}},[s,r,e,o,i]),{isLive:l}}function ge(e){return D(e.id)}function be(e,n,s){return e.subscribe({path:n},{onSnapshot:()=>{},onUpsert:()=>s.onUpsert(),onRemove:()=>s.onRemove(),onStatus:s.onStatus})}const je=1,Ne=3,ve=1;function ye(e,n){const s=new Map,r=new Map;for(const l of n.values())for(const a of l.links??[]){if(a.sourceId===a.targetId||!n.has(a.sourceId)||!n.has(a.targetId))continue;const o=`${a.sourceId}|${a.targetId}|${a.relationship}`;s.has(o)||(s.set(o,{source:a.sourceId,target:a.targetId,relationship:a.relationship}),r.set(a.sourceId,(r.get(a.sourceId)??0)+1),r.set(a.targetId,(r.get(a.targetId)??0)+1))}return{nodes:[...n.values()].map(l=>{var a;return{id:l.id,path:l.path,tags:l.tags,summary:typeof((a=l.metadata)==null?void 0:a.summary)=="string"?l.metadata.summary:void 0,isAnchor:l.id===e,linkCount:r.get(l.id)??0}}),edges:[...s.values()]}}async function we(e,n,s,r){const i=new Map;i.set(e.id,e);let l=[e];for(let a=1;a<=n;a++){const o=new Set;for(const c of l)for(const x of c.links??[]){const f=x.sourceId===c.id?x.targetId:x.sourceId;f!==c.id&&(i.has(f)||o.add(f))}if(o.size===0)break;const u=await Promise.all([...o].map(c=>s(c).catch(()=>null)));if(r!=null&&r.cancelled)return i;const m=[];for(const c of u)c&&!i.has(c.id)&&(i.set(c.id,c),m.push(c));l=m}return i}function ke(e,n,s){const[r,i]=d.useState(null),[l,a]=d.useState(!1);return d.useEffect(()=>{if(!e||!n){i(null),a(!1);return}const o={cancelled:!1};return a(!0),we(n,s,u=>e.getNote(u,{includeLinks:!0}),o).then(u=>{o.cancelled||(i(ye(n.id,u)),a(!1))}).catch(()=>{o.cancelled||a(!1)}),()=>{o.cancelled=!0}},[e,n,s]),{data:r,isLoading:l}}const Ce=d.lazy(()=>_(()=>import("./react-force-graph-2d-BpJfrG8W.js"),__vite__mapDeps([0,1,2])));function Ie({anchor:e}){const[n,s]=d.useState(!0),[r,i]=d.useState(ve),l=k(),{data:a,isLoading:o}=ke(l,n?e:void 0,r);return t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("button",{type:"button",onClick:()=>s(u=>!u),"aria-expanded":n,className:"font-serif text-xl text-fg hover:text-accent",children:[n?"▾":"▸"," Neighborhood"]}),n&&a?t.jsxs("span",{className:"text-xs text-fg-dim",children:[a.nodes.length," ",a.nodes.length===1?"note":"notes"]}):null]}),n?t.jsx(Ee,{depth:r,onChange:i}):null]}),n?t.jsx(Se,{data:a,isLoading:o}):null]})}function Ee({depth:e,onChange:n}){const s=[];for(let r=je;r<=Ne;r++)s.push(r);return t.jsxs("fieldset",{className:"flex items-center gap-1 text-xs text-fg-dim",children:[t.jsx("legend",{className:"mr-1 inline-block",children:"Hops"}),s.map(r=>t.jsx("button",{type:"button","aria-pressed":r===e,onClick:()=>n(r),className:r===e?"rounded border border-accent bg-accent/10 px-2 py-0.5 text-accent":"rounded border border-border bg-card px-2 py-0.5 hover:text-accent",children:r},r))]})}function Se({data:e,isLoading:n}){const[s,r]=d.useState(null),i=d.useRef(null);if(d.useEffect(()=>{s&&e&&!e.nodes.some(m=>m.id===s)&&r(null)},[e,s]),!e&&n)return t.jsx(B,{});if(!e)return null;if(e.nodes.length<=1)return t.jsx("div",{className:"rounded-md border border-border bg-card p-6 text-center text-sm text-fg-dim",children:"This note has no neighbors yet."});const l=e.nodes.filter(m=>!m.isAnchor),a=s?e.nodes.find(m=>m.id===s)??null:null,o=m=>{i.current=document.activeElement??null,r(m)},u=m=>{var c,x;r(null),m!=null&&m.restoreFocus&&((x=(c=i.current)==null?void 0:c.focus)==null||x.call(c))};return t.jsxs(t.Fragment,{children:[t.jsx(Ae,{data:e,onSelect:o}),a?t.jsx(Te,{node:a,onClose:u},a.id):null,t.jsx(Re,{neighbors:l,selectedId:s,onSelect:o})]})}function Re({neighbors:e,selectedId:n,onSelect:s}){return e.length===0?null:t.jsxs("div",{className:"mt-4",children:[t.jsx("h3",{className:"eyebrow mb-2",children:"Neighbors"}),t.jsx("ul",{className:"flex flex-wrap gap-2",children:e.map(r=>{const i=O(r.path??r.id);return t.jsx("li",{children:t.jsx("button",{type:"button",onClick:()=>s(r.id),"aria-haspopup":"dialog","aria-pressed":n===r.id,"aria-label":`Preview ${i}`,className:`btn btn-sm btn-touch max-w-full ${n===r.id?"btn-primary":"btn-secondary"}`,children:t.jsx("span",{className:"truncate",children:i})})},r.id)})})]})}function Te({node:e,onClose:n}){var a;const s=$(e.id),r=d.useRef(null);d.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]);const i=V({id:e.id,path:e.path,content:(a=s.data)==null?void 0:a.content}),l=Pe(s.data);return t.jsxs("div",{role:"dialog",ref:r,"aria-label":"Note preview",tabIndex:-1,"data-testid":"neighbor-preview",onKeyDown:o=>{o.key==="Escape"&&n({restoreFocus:!0})},onBlur:o=>{o.currentTarget.contains(o.relatedTarget)||n()},className:"focus-ring card mt-3 p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h3",{className:"min-w-0 truncate font-serif text-lg text-fg",children:i}),t.jsx("button",{type:"button",onClick:()=>n({restoreFocus:!0}),"aria-label":"Close preview",className:"shrink-0 text-fg-dim hover:text-accent",children:"✕"})]}),e.tags&&e.tags.length>0?t.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:e.tags.map(o=>t.jsxs("span",{className:"chip chip-tag max-w-full break-all",children:["#",o]},o))}):null,t.jsx(Le,{isPaused:s.fetchStatus==="paused",isPending:s.isPending,isError:s.isError,snippet:l}),t.jsx("div",{className:"mt-3",children:t.jsx(g,{to:`/n/${encodeURIComponent(e.id)}`,className:"btn btn-primary btn-touch",children:"Open note"})})]})}function Le({isPaused:e,isPending:n,isError:s,snippet:r}){return e&&n?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Preview unavailable offline."}):n?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Loading preview…"}):s?t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Couldn't load preview."}):r?t.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:r}):t.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"No preview text."})}function Pe(e){if(!e)return null;const n=(e.preview??z(e.content??"")).trim();return n?n.length>200?`${n.slice(0,200).trimEnd()}…`:n:null}function B(){return t.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function Ae({data:e,onSelect:n}){const s=d.useRef(null),[r,i]=d.useState({w:600,h:384});d.useEffect(()=>{const a=s.current;if(!a)return;const o=()=>{const m=a.getBoundingClientRect();i({w:Math.max(320,Math.floor(m.width)),h:384})};o();const u=new ResizeObserver(o);return u.observe(a),()=>u.disconnect()},[]);const l=d.useMemo(()=>({nodes:e.nodes.map(a=>({...a})),links:e.edges.map(a=>({source:a.source,target:a.target,rel:a.relationship}))}),[e]);return t.jsx("div",{ref:s,"data-testid":"neighborhood-graph-canvas",className:"overflow-hidden rounded-md border border-border bg-card",children:t.jsx(d.Suspense,{fallback:t.jsx(B,{}),children:t.jsx(Ce,{graphData:l,width:r.w,height:r.h,nodeLabel:a=>Fe(a),nodeVal:a=>{const o=a;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:a=>a.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:a=>{n(a.id)}})})})}function Fe(e){const n=[e.path??e.id];return e.tags&&e.tags.length>0&&n.push(`tags: ${e.tags.join(", ")}`),e.summary&&n.push(e.summary),n.join(`
3
- `)}function $e({content:e,attachments:n,onRetry:s,retrying:r=!1}){const i={content:e,attachments:n},l=H(i);if(l==="pending"){const a=G(i);return t.jsxs("output",{"aria-live":"polite",className:"mb-4 inline-flex items-center gap-2 rounded-md border border-sky-500/30 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-300",children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 animate-pulse rounded-full bg-sky-400"}),"Transcribing…",a?t.jsxs("span",{className:"text-sky-300/80",children:["part ",Math.min(a.done+1,a.total)," of ",a.total]}):null]})}return l==="failed"?t.jsxs("output",{className:"mb-4 inline-flex flex-wrap items-center gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-1.5 text-xs text-amber-200",children:[t.jsx("span",{children:"Transcription unavailable — open the audio below and add a note by hand."}),s?t.jsx("button",{type:"button",onClick:s,disabled:r,className:"rounded border border-amber-500/40 px-2 py-0.5 font-medium text-amber-100 hover:bg-amber-500/15 disabled:opacity-50",children:r?"Retrying…":"Retry"}):null]}):l==="voice-limit"?t.jsx("output",{className:"mb-4 inline-flex items-center gap-2 rounded-md border border-border bg-bg/40 px-3 py-1.5 text-xs text-fg-muted",children:"Monthly voice limit reached — transcription resumes next month. The audio is saved below."}):null}function st(){const{id:e}=W(),n=w(r=>r.getActiveVault()),s=$(e);return pe(e,s.data),d.useEffect(()=>{n&&e&&K(n.id,e)},[n,e]),n?t.jsxs("div",{className:"page",children:[t.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:t.jsx(g,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),s.isPending?t.jsx(Ke,{}):s.data?t.jsxs(t.Fragment,{children:[s.isError?t.jsx(q,{}):null,t.jsx(Be,{note:s.data,cacheId:e})]}):s.isError?t.jsx(Ze,{error:s.error,retry:()=>s.refetch()}):t.jsx(Ye,{id:e??""})]}):t.jsx(Q,{to:"/",replace:!0})}function Be({note:e,cacheId:n}){var T,L;const s=w(h=>h.getActiveVault()),{roles:r}=X((s==null?void 0:s.id)??null),i=Y(),{mirror:l}=Z(),a=l.state==="offline",o=e.contentEvicted===!0,u=d.useMemo(()=>xe(e),[e]),m=P(h=>h.on),c=P(h=>h.setOn);d.useEffect(()=>{if(!m)return;const h=y=>{y.key==="Escape"&&c(!1)};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[m,c]);const x=e.path??e.id,f=J(e.content),p=f!==null&&!ee(f,e)?f:null,j=p!==null?{kind:"title",text:p}:e.path?te(e.path):{kind:"title",text:e.id},I=d.useMemo(()=>p!==null?{...e,content:se(e.content??"")}:e,[e,p]),E=typeof((T=e.metadata)==null?void 0:T.summary)=="string"?e.metadata.summary:null,S=d.useMemo(()=>(e.links??[]).filter(h=>h.targetId===e.id&&h.sourceId!==e.id&&h.sourceNote),[e]),R=d.useMemo(()=>{const h=new Set,y=[];for(const N of e.links??[])N.sourceId!==e.id||N.targetId===e.id||N.targetNote&&(h.has(N.targetId)||(h.add(N.targetId),y.push(N)));return y},[e]);return t.jsxs("article",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("header",{className:"mb-8 border-b border-border pb-5",children:[t.jsx("h1",{className:j.kind==="timestamp"?"page-title title-timestamp":"page-title",children:j.text}),a?t.jsx(qe,{}):null,e.tags&&e.tags.length>0?t.jsx(Ve,{tags:e.tags}):null,E?t.jsx("p",{className:"mt-3 text-fg-muted",children:E}):null,t.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[t.jsx(g,{to:`/n/${encodeURIComponent(e.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit"}),t.jsx(me,{note:e,keyboard:!0}),t.jsx(he,{note:e}),t.jsxs("button",{type:"button",onClick:()=>c(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[t.jsx(ne,{width:16,height:16}),"Focus"]}),re(e,r.view)?t.jsx(g,{to:`/views/${encodeURIComponent(e.id)}`,className:"btn btn-secondary btn-touch",children:"Open as view"}):null]}),t.jsx(_e,{value:x,isPath:!!e.path})]}),t.jsx($e,{content:e.content??"",attachments:e.attachments,onRetry:()=>i.mutate({cacheId:n??e.id,serverId:e.id}),retrying:i.isPending}),o?t.jsx(Xe,{preview:e.preview}):(L=I.content)!=null&&L.trim()?t.jsx(fe,{note:I,resolve:u}):p===null?t.jsx(Qe,{noteId:e.id}):null,e.attachments&&e.attachments.length>0?t.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[t.jsx("h2",{className:"mb-3 font-serif text-xl",children:"Attachments"}),t.jsx("div",{className:"space-y-6",children:e.attachments.map(h=>t.jsx(ze,{attachment:h},h.id))})]}):null,t.jsx(Ie,{anchor:e})]}),t.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[t.jsx(Ue,{note:e}),R.length>0?t.jsx(F,{title:"Outbound",links:R,peer:"target"}):null,S.length>0?t.jsx(F,{title:"Inbound",links:S,peer:"source"}):null]})]})}function Ue({note:e}){const n=e.createdAt,s=e.updatedAt,r=Object.entries(e.metadata??{}).filter(([i])=>i!=="summary");return t.jsxs("section",{className:"card shadow-soft p-4",children:[t.jsx("h2",{className:"eyebrow mb-2",children:"Metadata"}),t.jsxs("dl",{className:"space-y-1.5 text-sm",children:[e.path?t.jsx(v,{label:"Title",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.path})}):null,t.jsx(v,{label:"ID",value:t.jsx("span",{className:"font-mono text-xs break-all",children:e.id})}),t.jsx(v,{label:"Created",value:t.jsx("time",{title:n,children:A(n)})}),s?t.jsx(v,{label:"Updated",value:t.jsx("time",{title:s,children:A(s)})}):null,e.path?t.jsx(v,{label:"Path",value:t.jsx(oe,{value:e.path,label:"note path",className:"mt-1"})}):null,r.map(([i,l])=>t.jsx(v,{label:i,value:t.jsx("span",{className:"break-all text-fg-muted",children:String(l)})},i))]}),t.jsx(Me,{noteId:e.id}),e.path?t.jsx(De,{path:e.path}):null,t.jsx(le,{note:e,variant:"detail",className:"mt-3"})]})}function Me({noteId:e}){const n=w(i=>i.getActiveVault()),{copied:s,copy:r}=C();return n!=null&&n.name?t.jsx("button",{type:"button",onClick:()=>r(ue(n.name,e)),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy a shareable link to this note",children:s?"Copied ✓":"Copy link"}):null}function De({path:e}){const{copied:n,copy:s}=C();return t.jsx("button",{type:"button",onClick:()=>s(e),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy reference to this note",children:n?"Copied ✓":"Copy reference"})}function v({label:e,value:n}){return t.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.jsx("dt",{className:"eyebrow",children:e}),t.jsx("dd",{children:n})]})}function Ve({tags:e}){return t.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":"Tags",children:e.map(n=>t.jsxs(g,{to:`/tags/${encodeURIComponent(n)}`,className:"chip chip-tag focus-ring max-w-full break-all",children:["#",n]},n))})}function Oe(e){return t.jsxs("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[t.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),t.jsx("path",{d:"M5 15H4.5A1.5 1.5 0 0 1 3 13.5v-9A1.5 1.5 0 0 1 4.5 3h9A1.5 1.5 0 0 1 15 4.5V5"})]})}function _e({value:e,isPath:n}){const{copied:s,copy:r}=C();return t.jsxs("button",{type:"button",onClick:()=>r(e),"aria-label":n?"Copy path":"Copy note id",className:"focus-ring group mt-4 flex max-w-full items-center gap-1.5 rounded text-fg-dim transition-colors hover:text-fg-muted",children:[t.jsx(Oe,{className:"shrink-0 opacity-70 transition-opacity group-hover:opacity-100"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:e}),s?t.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:"Copied"}):null]})}function F({title:e,links:n,peer:s}){return t.jsxs("section",{className:"card shadow-soft p-4",children:[t.jsxs("h2",{className:"eyebrow mb-2 tabular-nums",children:[e," (",n.length,")"]}),t.jsx("ul",{className:"space-y-1.5",children:n.map(r=>{var o;const i=s==="source"?r.sourceNote:r.targetNote;if(!i)return null;const l=i.path??i.id,a=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return t.jsx("li",{children:t.jsxs(g,{to:`/n/${encodeURIComponent(i.id)}`,className:"block rounded px-1 py-0.5 hover:bg-bg/50",children:[t.jsx("div",{className:"truncate font-mono text-xs text-fg-muted hover:text-accent",children:l}),a?t.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:a}):null]})},`${r.sourceId}->${r.targetId}:${r.relationship}`)})})]})}function ze({attachment:e}){const n=e.filename;if(!n||!e.url)return t.jsx("figure",{className:"card shadow-soft p-3",children:t.jsx(U,{})});const s=(e.mimeType??"").toLowerCase();return t.jsxs("figure",{className:"card shadow-soft p-3",children:[t.jsxs("figcaption",{className:"mb-2 flex items-baseline justify-between gap-3",children:[t.jsx("span",{className:"truncate font-mono text-xs text-fg-muted",children:n}),typeof e.size=="number"?t.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:We(e.size)}):null]}),t.jsx(He,{attachment:e,mime:s,filename:n})]})}function U(){return t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-dim","aria-busy":"true",children:[t.jsx(b,{className:"h-4 w-32"}),t.jsx("span",{children:"Processing…"})]})}function He({attachment:e,mime:n,filename:s}){const r=k(),[i,l]=d.useState(null),[a,o]=d.useState(null),u=Ge(n,s),m=u!=="other",c=e.url;if(d.useEffect(()=>{if(!m||!c||!r)return;let f=!1,p=null;return o(null),r.fetchAttachmentBlob(c).then(j=>{f||(p=URL.createObjectURL(j),l(p))}).catch(j=>{f||o(j instanceof Error?j.message:"Failed to load attachment")}),()=>{f=!0,p&&URL.revokeObjectURL(p)}},[m,c,r]),!c)return t.jsx(U,{});if(a)return t.jsx("p",{className:"text-sm text-danger",children:a});if(m&&!i)return t.jsx(b,{className:"h-32 w-full"});const x=i??c;return u==="image"?t.jsx("img",{src:x,alt:s,className:"max-h-[32rem] rounded"}):u==="audio"?t.jsx("audio",{controls:!0,src:x,className:"w-full"}):u==="video"?t.jsx("video",{controls:!0,src:x,className:"w-full rounded"}):u==="pdf"?t.jsxs(t.Fragment,{children:[t.jsx("iframe",{src:x,title:s,className:"h-[40rem] w-full rounded border border-border"}),t.jsxs("a",{href:x,download:s,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",s]})]}):t.jsxs("a",{href:x,download:s,className:"text-sm text-accent hover:underline",children:["Download ",s]})}function Ge(e,n){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";if(e==="application/pdf")return"pdf";const s=n.toLowerCase().split(".").pop()??"";return["png","jpg","jpeg","gif","webp","svg"].includes(s)?"image":["mp3","wav","ogg","m4a","flac"].includes(s)?"audio":["mp4","webm","mov"].includes(s)?"video":s==="pdf"?"pdf":"other"}function We(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function Ke(){return t.jsxs("div",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]","aria-busy":"true",children:[t.jsxs("div",{className:"min-w-0 space-y-3",children:[t.jsx(b,{className:"h-3 w-32"}),t.jsx(b,{className:"h-8 w-2/3"}),t.jsx(b,{className:"h-4 w-full"}),t.jsx("div",{className:"mt-6 space-y-2",children:[0,1,2,3,4,5].map(e=>t.jsx(b,{className:"h-3",width:`${70+e*13%25}%`},e))})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(b,{className:"h-32"}),t.jsx(b,{className:"h-24"})]})]})}function Qe({noteId:e}){return t.jsxs("p",{className:"my-8 font-serif text-lg italic text-fg-muted",children:["Nothing here yet."," ",t.jsx(g,{to:`/n/${encodeURIComponent(e)}/edit`,className:"not-italic text-accent hover:underline",children:"Start writing →"})]})}function qe(){return t.jsx("p",{className:"mt-2",children:t.jsx("span",{className:"chip bg-bg-soft text-fg-muted",title:"Served from your offline copy",children:"Saved copy"})})}function Xe({preview:e}){return t.jsxs("div",{className:"my-8",children:[e?t.jsx("p",{className:"mb-4 text-fg-muted",children:e}):null,t.jsx("p",{className:"font-serif text-lg italic text-fg-muted",children:"Connect to load this note."})]})}function Ye({id:e}){return t.jsx(ie,{title:t.jsx("span",{className:"font-serif text-xl text-fg",children:"Note not found"}),description:t.jsxs(t.Fragment,{children:["No note with id ",t.jsx("span",{className:"font-mono",children:e})," in this vault."]}),action:t.jsx(g,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function Ze({error:e,retry:n}){const s=e instanceof ce,r=e instanceof de,i=s?"Session expired":r?"Note not found":"Could not load note",l=s?e.message:r?"Couldn't find this note. It may have been deleted, or the link may be wrong.":"Something went wrong loading this note. You can try again, or head back to your notes.";return t.jsx(ae,{title:i,message:t.jsxs(t.Fragment,{children:[l,s?null:t.jsxs("details",{className:"mt-3",children:[t.jsx("summary",{className:"cursor-pointer text-xs text-fg-dim hover:text-fg-muted",children:"Technical detail"}),t.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-xs text-fg-dim",children:e.message})]})]}),retry:s?void 0:n,action:s?t.jsx(g,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):t.jsx(g,{to:"/notes",className:"btn btn-secondary btn-touch",children:"Back to notes"})})}export{st as NoteView};
@@ -1 +0,0 @@
1
- import{C as R,b as U,a as u,r as d,b5 as z,b6 as E,b7 as I,b8 as C,k as A,b9 as H,ba as O,j as e,P as p}from"./index-q-OceM-D.js";import{W as m}from"./WizardShell-X-_3n8Lx.js";import{s as P}from"./url-QSQwrjSV.js";import"./history-Bxu3eq1m.js";function $(r){try{return new URL(r).host}catch{return"your hub"}}function W(){const[r]=R(),i=U(),h=u(s=>s.addVault),[n,l]=d.useState({kind:"working"}),f=d.useRef(!1);if(d.useEffect(()=>{if(f.current)return;f.current=!0;const s=r.get("code"),x=r.get("state"),b=r.get("error");if(b){const o=r.get("error_description");l({kind:"error",message:`Vault returned: ${b}${o?` — ${o}`:""}`});return}if(!s||!x){l({kind:"error",message:"Missing code or state in callback URL."});return}(async()=>{var o,g,v,j;try{const{pending:t,token:a}=await z(s,x),k=a.vault?`vault:${a.vault}`:void 0,N=(k?(g=(o=a.services)==null?void 0:o[k])==null?void 0:g.url:void 0)??((j=(v=a.services)==null?void 0:v.vault)==null?void 0:j.url)??t.issuerUrl,S=u.getState().activeVaultId,c=h({url:N,name:a.vault??t.issuer,issuer:t.issuer,tokenEndpoint:t.tokenEndpoint,clientId:t.clientId,scope:a.scope},E(a));a.services&&I(c,a.services);const y=C.getState();y.clearHalt(c),t.priorHaltedVaultId&&t.priorHaltedVaultId!==c&&y.clearHalt(t.priorHaltedVaultId);const V=P(t.redirect)??"/";if(c!==S){const w=u.getState().vaults[c];w&&A(H(w))}i(V,{replace:!0})}catch(t){if(t instanceof O){l({kind:"pending-approval",approveUrl:t.approveUrl});return}l({kind:"error",message:t.message})}})()},[r,i,h]),n.kind==="working")return e.jsxs(m,{escape:{kind:"none"},children:[e.jsx(p,{size:72,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-2",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:["Connecting",e.jsx("span",{className:"accent-word",children:"…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Exchanging the authorization code with your vault."})]});if(n.kind==="pending-approval"){const s=$(n.approveUrl);return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Redirected"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Approving Parachute on ",e.jsx("span",{className:"accent-word",children:s})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:"Your hub admin needs to approve this app before sign-in can complete. Open the approval page in your hub, approve, then try again."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4",children:[e.jsx("a",{href:n.approveUrl,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Open approval page →"}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"font-round text-sm font-semibold text-fg-dim hover:text-accent",children:"Retry now"})]})]})}return e.jsxs(m,{escape:{kind:"back",to:"/"},children:[e.jsx(p,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Connection failed"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Something went ",e.jsx("span",{className:"accent-word",children:"sideways."})]}),e.jsx("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:n.message}),e.jsx("button",{type:"button",onClick:()=>i("/add",{replace:!0}),className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again →"})]})}export{W as OAuthCallback};
@@ -1 +0,0 @@
1
- import{a,j as e,L as n,M as m}from"./index-q-OceM-D.js";import{v as h}from"./provenance-BRYF2APg.js";import{a as x}from"./types-BaJkUfo6.js";function f(){const l=a(s=>s.vaults),d=a(s=>s.activeVaultId),o=a(s=>s.removeVault),c=Object.values(l).sort((s,t)=>s.name.localeCompare(t.name));return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),c.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(n,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:c.map(s=>{const t=s.id===d,r=x(s.url),i=h(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[i.kind==="cloud"?"☁":"⌂"," ",i.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:s.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>m(s.id,{toast:!0}),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&o(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(n,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{f as Vaults};
@@ -1 +0,0 @@
1
- import{j as n,bL as lt,r as y,bM as O,bN as $,L as I,b2 as ot,A as ct,ay as dt,al as se,a8 as ae,v as F,bx as q,bO as _e,bP as Le,bQ as ut,bR as Be,W as mt,z as V,_ as xt,Y as Ne,a1 as ee,bS as Fe,bT as pt,bU as ht,bV as ft,bW as bt,bX as gt,bY as Ve,a as Re,a3 as yt,C as jt,bZ as vt,b_ as Nt,b$ as we,c0 as wt,b as kt,bK as R,c1 as te,ag as Ct,c2 as St,N as $t,E as Oe,c3 as Tt,c4 as Ie,c5 as Et,c6 as H,y as C,c7 as Dt,c8 as Pt,c9 as Mt,aw as At,ca as _t,cb as Lt,a5 as ke,a6 as Ce,cc as Bt}from"./index-q-OceM-D.js";import{T as Ft}from"./TagSchemaEditor-CUHG09YZ.js";const Vt="—",qe=/^https?:\/\//i;function ze(e){return typeof e=="string"&&qe.test(e)}const Se=24;function Rt(e){try{const t=new URL(e);let s=`${t.pathname}${t.search}${t.hash}`;return s==="/"&&(s=""),s.length>Se&&(s=`${s.slice(0,Se-1)}…`),{host:t.host,rest:s}}catch{return{host:e.replace(qe,""),rest:""}}}function Ot({value:e,schema:t}){if(e==null||e==="")return Vt;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 lt(e);if(ze(e)){const{host:s,rest:a}=Rt(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 z(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 It="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 qt(e){if(typeof e!="string")return"";const t=e.match(/^\d{4}-\d{2}-\d{2}/);return t?t[0]:""}function re({field:e,schema:t,value:s,onCommit:a,disabled:r=!1,options:i,includeClear:l=!1,trigger:o}){const u=z(t,i),[c,m]=y.useState(!1),p=s==null||s==="",d=(o==null?void 0:o.label)??n.jsx(Ot,{value:s,schema:t}),h=(o==null?void 0:o.ariaLabel)??`Edit ${e}`,j=(o==null?void 0:o.className)??`${It} ${p&&!(o!=null&&o.label)?"text-fg-dim":"text-fg"}`;if(u==="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:d})}const g=u==="enum"?i??((t==null?void 0:t.enum)??[]).map(v=>({value:v,label:v})):[],f=l&&!p,b=v=>{m(!1),a(v)};return n.jsxs("div",{className:"relative",children:[n.jsx("button",{type:"button",disabled:r,"aria-haspopup":u==="enum"?"menu":"dialog","aria-expanded":c,"aria-label":h,title:o!=null&&o.label?void 0:`Edit ${e}`,onClick:()=>m(v=>!v),className:j,children:d}),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:()=>m(!1)}),u==="enum"?n.jsxs("div",{role:"menu","aria-label":h,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:()=>b(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-${O(String(v.value))}`}),v.label]},v.value===null?"__clear__":String(v.value))),f?n.jsx("button",{type:"button",role:"menuitem",onClick:()=>b(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(zt,{kind:u,value:s,ariaLabel:h,onCommit:b,onCancel:()=>m(!1)})]}):null]})}function zt({kind:e,value:t,ariaLabel:s,onCommit:a,onCancel:r}){const i=e==="date"?qt(t):t==null?"":String(t),[l,o]=y.useState(i),u=()=>{const c=l.trim();if(c==="")return a(null);if(e==="number"){const m=Number(c);return Number.isFinite(m)?a(m):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(),u()):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:u,"aria-label":"Save",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"✓"}),ze(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 Gt(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 G({note:e,pinnedTag:t,archivedTag:s,variant:a="compact",overlay:r,footer:i,drag:l}){const o=$(e),u=e.updatedAt??e.createdAt,c=(e.tags??[]).includes(t),m=(e.tags??[]).includes(s),p=a==="gallery"?Gt(e):null,[d,h]=y.useState(!1),j=p&&!d,g=(l==null?void 0:l.canDrag)??!1,f=n.jsxs(I,{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 ${m?"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:p,alt:"",loading:"lazy",onError:()=>h(!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(ot,{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:ct(u)})]})]});return!r&&!i&&!g?f:n.jsxs("div",{className:g?"relative flex flex-col cursor-grab":"relative flex flex-col",...(l==null?void 0:l.sourceProps)??{},children:[f,r?n.jsx("div",{className:"absolute right-2 top-2",children:r}):null,i?n.jsx("div",{className:"mt-1",children:i}):null]})}function Ut(e,t,s){const a={...e.metadata??{}};return s===null?delete a[t]:a[t]=s,{...e,metadata:a}}function Yt(e,t,s,a){return e&&e.map(r=>r.id===t?Ut(r,s,a):r)}function Wt(e,t){const s=dt(),a=se(e);return{move:y.useCallback(async(i,l,o)=>{const u=s.getQueryData(t);s.setQueryData(t,c=>Yt(c,e,i,l));try{const c=await a.mutateAsync({metadata:{[i]:l},...o?{if_updated_at:o}:{force:!0}}),m=c==null?void 0:c.updatedAt;m&&s.setQueryData(t,p=>p==null?void 0:p.map(d=>d.id===e?{...d,updatedAt:m}:d))}catch(c){throw s.setQueryData(t,u),c}},[s,t,e,a]),isPending:a.isPending}}const Qt=1800,J="field-write-flash",Ht=700;function Jt(e){return e===null?null:typeof e=="boolean"?e?"Yes":"No":String(e)}function Xt(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(J),s.offsetWidth,s.classList.add(J),window.setTimeout(()=>s.classList.remove(J),Ht)}function U(e,t){const s=ae(c=>c.push),{move:a,isPending:r}=Wt(e.id,t),i=e.id,l=e.updatedAt,o=$(e).text;return{write:y.useCallback(async(c,m,p)=>{try{await a(c,m,l)}catch(h){const j=(p==null?void 0:p.errorPrefix)??`Couldn't update ${c} on "${o}"`;s(`${j}: ${h instanceof Error?h.message:"unknown error"}`,"error");return}const d=(p==null?void 0:p.valueLabel)??Jt(m);s(d===null?`✓ ${c} cleared`:`✓ ${c} → ${d}`,"success",{durationMs:Qt}),Xt(i)},[a,l,o,i,s]),isPending:r}}function Ge(e){if(e==null)return null;const t=typeof e;return t==="string"||t==="number"||t==="boolean"?e:null}function P({note:e,fields:t,viewResultsKey:s,omit:a}){const{write:r,isPending:i}=U(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 m;const u=Ge((m=e.metadata)==null?void 0:m[o.name]),c=z(o.schema)==="enum"&&u!==null&&u!==""?O(String(u)):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(re,{field:o.name,schema:o.schema,value:u,disabled:i,includeClear:!0,onCommit:p=>void r(o.name,p)})]},o.name)})})}function Kt(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 Zt={status:["active","incubating","dormant","paused","archived","done","shipped","dropped"],priority:["high","medium","low"]};function en(e,t){var a;const s=(a=t==null?void 0:t[e])==null?void 0:a.enum;return s&&s.length>0?s:Zt[e]??[]}function tn(e,t,s=[]){var m;const a=new Map,r=new Map,i=[];for(const p of e){const d=Kt(p,t);if(d===null){i.push(p);continue}const h=a.get(d);h?h.push(p):(a.set(d,[p]),r.set(d,(m=p.metadata)==null?void 0:m[t]))}const l=s.filter(p=>a.has(p)),o=new Set(l),u=[...a.keys()].filter(p=>!o.has(p)).sort((p,d)=>p.localeCompare(d)),c=[...l,...u].map(p=>({key:p,label:p,notes:a.get(p)??[],uncategorized:!1,value:r.get(p)}));return i.length>0&&c.push({key:"",label:`No ${t}`,notes:i,uncategorized:!0,value:null}),c}function nn(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 sn(e,t){var i;const s=new Map,a=[],r=new Map;for(const l of e){const o=nn((i=l.metadata)==null?void 0:i[t]);if(!o){a.push(l);continue}r.set(l.id,o);const u=F(o),c=s.get(u);c?c.push(l):s.set(u,[l])}return{byDay:s,undated:a,dates:r}}function an(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=F(i),o=t.get(l);o?o.push(r):t.set(l,[r])}return{byDay:t,undated:s,dates:a}}function $e(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 rn({notes:e,laneBy:t,subjectTag:s,roles:a,viewResultsKey:r,fields:i=[]}){const l=q(s??null),o=y.useMemo(()=>{var g,f,b,v;const c=tn(e,t,en(t,(g=l.data)==null?void 0:g.fields)),m=((v=(b=(f=l.data)==null?void 0:f.fields)==null?void 0:b[t])==null?void 0:v.enum)??[];if(m.length===0)return c;const p=new Map(c.filter(x=>!x.uncategorized).map(x=>[x.key,x])),d=m.map(x=>p.get(x)??{key:x,label:x,notes:[],uncategorized:!1,value:x}),h=new Set(m),j=c.filter(x=>x.uncategorized||!h.has(x.key));return[...d,...j]},[e,t,l.data]),u=_e();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(ln,{lane:c,dropRegistry:u,children:c.notes.map(m=>n.jsx(cn,{note:m,laneBy:t,lanes:o,currentLane:c,roles:a,viewResultsKey:r,fields:i,dropRegistry:u},m.id))},c.uncategorized?"__uncategorized__":c.key))})})}function ln({lane:e,dropRegistry:t,children:s}){const a=y.useCallback(l=>t.dispatch(l,e),[t,e]),{isOver:r,targetProps:i}=Le(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-${O(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:ut()?"Drop here":"No notes"}):s})]})}function Te(e,t){return e.uncategorized||t.uncategorized?e.uncategorized&&t.uncategorized:e.key===t.key}const on="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 cn({note:e,laneBy:t,lanes:s,currentLane:a,roles:r,viewResultsKey:i,fields:l,dropRegistry:o}){const{write:u,isPending:c}=U(e,i),m=y.useMemo(()=>s.filter(f=>!Te(f,a)),[s,a]),p=y.useMemo(()=>m.map(f=>({value:f.value,label:f.label,muted:f.uncategorized})),[m]),d=y.useCallback(async(f,b)=>{await u(t,f,{valueLabel:b,errorPrefix:`Couldn't move "${$(e).text}"`})},[u,t,e]),h=async f=>{const b=p.find(v=>v.value===f);await d(f,b==null?void 0:b.label)},j=Be(e.id),g=y.useCallback(f=>{c||Te(f,a)||d(f.value,f.label)},[c,a,d]);return y.useEffect(()=>o.register(e.id,g),[o,e.id,g]),n.jsx(G,{note:e,pinnedTag:r.pinned,archivedTag:r.archived,drag:j,overlay:m.length>0?n.jsx(re,{field:t,value:a.value,options:p,disabled:c,onCommit:f=>void h(f),trigger:{label:"Move",ariaLabel:`Move to another ${t}`,className:on}}):null,footer:l.length>0?n.jsx(P,{note:e,fields:l,viewResultsKey:i,omit:m.length>0?[t]:void 0}):null})}const dn=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],X=2;function un({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r=[]}){const i=y.useMemo(()=>t===null?an(e):sn(e,t),[e,t]),[l,o]=y.useState(()=>$e(i.dates.values())),[u,c]=y.useState(null),m=y.useMemo(()=>mt(l.year,l.month),[l]),p=F(),d=_e();if(i.byDay.size===0)return n.jsxs("div",{className:"space-y-4",children:[n.jsx(V,{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(Ee,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]});const h=g=>{c(null),o(g)},j=u?i.byDay.get(u)??[]:[];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:xt(l.year,l.month)}),n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("button",{type:"button",onClick:()=>h(Ne(l.year,l.month,-1)),className:"chip","aria-label":"Previous month",children:"← Prev"}),n.jsx("button",{type:"button",onClick:()=>h($e(i.dates.values())),className:"chip",children:"Latest"}),n.jsx("button",{type:"button",onClick:()=>h(Ne(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:dn.map(g=>n.jsx("div",{className:"px-2 py-2 text-center",children:g},g))}),n.jsx("div",{className:"grid grid-cols-7",children:m.map(g=>{const f=F(g),b=g.getMonth()+1===l.month,v=i.byDay.get(f)??[],x=f===p,w=f===u;return n.jsx(mn,{dayKey:f,dayNumber:g.getDate(),inMonth:b,isToday:x,isSelected:w,notes:v,onSelect:()=>c(f),dateField:t,viewResultsKey:a,dropRegistry:d},f)})})]}),u&&j.length>0?n.jsxs("section",{"aria-label":`Notes on ${ee(u)}`,className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("p",{className:"eyebrow",children:ee(u)}),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(G,{note:g,pinnedTag:s.pinned,archivedTag:s.archived,footer:r.length>0?n.jsx(P,{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(Ee,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]})}function mn({dayKey:e,dayNumber:t,inMonth:s,isToday:a,isSelected:r,notes:i,onSelect:l,dateField:o,viewResultsKey:u,dropRegistry:c}){const m=i.length>0,p=o!==null,d=y.useCallback(x=>c.dispatch(x,e),[c,e]),{isOver:h,targetProps:j}=Le(d),g=p&&s?j:{},f=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}),b=n.jsxs("span",{className:"flex flex-col gap-0.5",children:[i.slice(0,X).map(x=>o===null?n.jsx(xn,{note:x},x.id):n.jsx(pn,{note:x,dayKey:e,dateField:o,viewResultsKey:u,dropRegistry:c},x.id)),i.length>X?n.jsxs("span",{className:"text-[10px] text-fg-dim",children:["+",i.length-X," 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":""} ${p&&s&&h?"bg-accent/5 outline-2 -outline-offset-2 outline-accent/60":""}`;return m?n.jsxs("button",{type:"button",onClick:l,"aria-label":`${ee(e)} — ${i.length} notes`,className:`${v} hover:bg-bg/60 focus:bg-bg/60 focus:outline-none`,"data-day":e,...g,children:[f,b]}):n.jsxs("div",{className:v,"data-day":e,...g,children:[f,n.jsx("span",{className:"sr-only",children:"no notes"})]})}const ne="truncate rounded-md border border-border bg-card px-1.5 py-0.5 text-[10px] leading-tight text-fg shadow-sm";function xn({note:e}){return n.jsx("span",{"data-note-id":e.id,className:ne,children:$(e).text})}function pn({note:e,dayKey:t,dateField:s,viewResultsKey:a,dropRegistry:r}){const{write:i,isPending:l}=U(e,a),o=Be(e.id),u=y.useCallback(c=>{l||c===t||i(s,c,{errorPrefix:`Couldn't move "${$(e).text}"`})},[l,t,s,i,e]);return y.useEffect(()=>r.register(e.id,u),[r,e.id,u]),n.jsx("span",{"data-note-id":e.id,className:o.canDrag?`${ne} cursor-grab`:ne,...o.sourceProps,children:$(e).text})}function Ee({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(G,{note:o,pinnedTag:s.pinned,archivedTag:s.archived,footer:n.jsx(P,{note:o,fields:[i],viewResultsKey:a})},o.id))})]})}const hn="border-[color-mix(in_srgb,var(--color-accent)_40%,var(--color-border))]";function Ue({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?hn:"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 ie({label:e,value:t,icon:s,ariaLabel:a,menuLabel:r,options:i,sections:l,current:o,onSelect:u,note:c,actions:m,busy:p=!1,dirty:d=!1}){const[h,j]=y.useState(!1);y.useEffect(()=>{if(!h)return;const x=w=>{w.key==="Escape"&&j(!1)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[h]);const g=x=>{j(!1),u(x)},f=x=>{j(!1),x.onSelect()},b=x=>{const w=x.value===o;return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,onClick:()=>g(x.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 ${w?"text-fg":"text-fg-muted"}`,children:[x.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:x.glyph}):null,n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:x.hint?"shrink-0":"min-w-0 shrink truncate",children:x.label??x.value}),x.hint?n.jsx("span",{"aria-hidden":"true",className:"min-w-0 shrink truncate text-2xs text-fg-dim",children:x.hint}):null]}),w?n.jsx("span",{"aria-hidden":"true",className:"text-accent",children:"✓"}):null]},x.value)},v=l?l.reduce((x,w)=>x+w.options.length,0):(i==null?void 0:i.length)??0;return n.jsxs("div",{className:"relative",children:[n.jsx(Ue,{label:e,value:t,icon:s,ariaLabel:a,open:h,dirty:d,onClick:()=>j(x=>!x)}),h?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>j(!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}),l?l.map((x,w)=>n.jsxs("div",{className:w>0?"mt-1 border-t border-border-light pt-1":void 0,children:[x.heading?n.jsx("p",{"aria-hidden":"true",className:"px-2 pt-1 pb-0.5 text-2xs uppercase tracking-[0.08em] text-fg-dim",children:x.heading}):null,x.options.map(b)]},x.heading??w)):i==null?void 0:i.map(b),c?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:c}):null,m&&m.length>0?n.jsx("div",{className:v>0?"mt-1 border-t border-border-light pt-1":void 0,children:m.map(x=>n.jsxs("button",{type:"button",role:"menuitem",disabled:p,onClick:()=>f(x),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:[x.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:x.glyph}):null,n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-fg",children:x.label}),x.hint?n.jsx("span",{className:"block truncate text-2xs text-fg-dim",children:x.hint}):null]})]},x.key))}):null]})]}):null]})}function De(e){switch(z(e)){case"enum":case"boolean":return"●";case"date":return"📅";case"number":return"#";default:return"Aa"}}function fn({fields:e,schemaFields:t,onChange:s,dirty:a=!1}){const[r,i]=y.useState(!1);y.useEffect(()=>{if(!r)return;const d=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const l=e.map(d=>d.name),o=Object.keys(t).filter(d=>!l.includes(d));if(l.length===0&&o.length===0)return null;const u=l.length===1,c=d=>{u||s(l.filter(h=>h!==d))},m=d=>s([...l,d]),p=(d,h)=>{const j=[...l],[g]=j.splice(d,1);j.splice(d+h,0,g),s(j)};return n.jsxs("div",{className:"relative",children:[n.jsx(Ue,{label:"Fields",value:String(l.length),haspopup:"dialog",open:r,dirty:a,onClick:()=>i(d=>!d)}),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:[e.map((d,h)=>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:u,onChange:()=>c(d.name)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:De(d.schema)}),n.jsx("span",{className:"truncate",children:d.name})]}),n.jsx("button",{type:"button","aria-label":`Move ${d.name} up`,disabled:h===0,onClick:()=>p(h,-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 ${d.name} down`,disabled:h===l.length-1,onClick:()=>p(h,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:"↓"})]},d.name)),o.map(d=>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:()=>m(d)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:De(t[d])}),n.jsx("span",{className:"truncate",children:d})]})},d))]}),u?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 bn({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(G,{note:r,variant:"gallery",pinnedTag:t.pinned,archivedTag:t.archived,footer:a.length>0?n.jsx(P,{note:r,fields:a,viewResultsKey:s}):null},r.id))})}const K={list:"List",board:"Board",calendar:"Calendar",gallery:"Gallery",table:"Table"};function Pe({kind:e}){switch(e){case"board":return n.jsx(gt,{width:14,height:14});case"calendar":return n.jsx(bt,{width:14,height:14});case"gallery":return n.jsx(ft,{width:14,height:14});case"table":return n.jsx(ht,{width:14,height:14});default:return n.jsx(pt,{width:14,height:14})}}function gn({kind:e,onSwitch:t,dirty:s=!1}){return n.jsx(ie,{ariaLabel:`Lens: ${K[e]}`,menuLabel:"Lens",icon:n.jsx(Pe,{kind:e}),value:K[e],options:Fe.map(a=>({value:a,label:K[a],glyph:n.jsx(Pe,{kind:a})})),current:e,onSelect:t,dirty:s})}function yn(e,t,s){const a=e.filter(s).map(r=>r.name);return t&&!a.includes(t)&&a.unshift(t),a}const jn="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 Ye(e,t,s){return[{key:"__add_field__",label:e,hint:t,onSelect:s}]}const Me="Date fields plot on the Calendar lens (By date) — not offered here.";function Z(e,t){return{value:e,hint:t,glyph:n.jsx("span",{className:`tint-dot tint-${O(e)}`})}}function vn(e){const t=[],s=[],a=[];for(const r of e){const i=z(r.schema);i==="date"?a.push(r):i==="enum"?t.push(r):s.push(r)}return{valueBearing:t,other:s,dateFields:a}}function Nn(e){return(e.enum??[]).join(" · ")}function wn(e,t,s,a,r){if(e)return t>0?Me:void 0;if(!s)return jn;if(r)return`#${s} has no fields yet — add one to give this board its columns:`;if(!a)return Me}function kn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const{valueBearing:o,other:u,dateFields:c}=vn(t),m=new Set([...o,...u].map(f=>f.name)),p=e!==void 0&&!m.has(e)?e:void 0,d=[];p!==void 0&&d.push({options:[Z(p)]}),o.length>0&&d.push({heading:"Fields with values",options:o.map(f=>Z(f.name,Nn(f.schema)))}),u.length>0&&d.push({heading:"Other fields · one column per value",options:u.map(f=>Z(f.name))});const h=d.length>0,j=t.length===0,g=j&&!!r&&i&&!!l;return n.jsx(ie,{label:"Group by",menuLabel:"Group by",value:e??"—",sections:d,current:e,onSelect:s,note:wn(h,c.length,r,j,g),actions:g?Ye("Add a field to group by…","You name it; give it values to get columns.",l):void 0,dirty:a})}function Cn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const o=yn(t,e,c=>c.schema.type==="date"),u=o.length===0&&!!r&&i&&!!l;return n.jsx(ie,{label:"By date",menuLabel:"By date",value:e??"created",options:o.map(c=>({value:c})),current:e,onSelect:s,note:o.length===0&&u?`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:u?Ye("Add a date field…","You name it; it holds a date on each note.",l):void 0,dirty:a})}function Sn({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($n,{note:r,fields:a,roles:t,viewResultsKey:s},r.id))})]})})})}function $n({note:e,fields:t,roles:s,viewResultsKey:a}){const{write:r,isPending:i}=U(e,a),l=$(e),o=(e.tags??[]).includes(s.pinned),u=(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 ${u?"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(I,{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 m;return n.jsx("td",{className:`px-3 py-1 align-middle ${c.schema.type==="number"?"text-right":""}`,children:n.jsx(re,{field:c.name,schema:c.schema,value:Ge((m=e.metadata)==null?void 0:m[c.name]),disabled:i,includeClear:!0,onCommit:p=>void r(c.name,p)})},c.name)})]})}function We(e){return e.kind!==void 0||e.groupBy!==void 0||e.dateField!==void 0||e.fields!==void 0}function Tn(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 En(e){const t={},s=e.get("kind");s&&Fe.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 le(e,t){return We(t)?{...e,kind:t.kind??e.kind,groupBy:t.groupBy??e.groupBy,dateField:t.dateField??e.dateField,fields:t.fields??e.fields}:e}function Dn(e,t){return e===void 0||t===void 0?e===t:e.length===t.length&&e.every((s,a)=>s===t[a])}function Ae(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&&!Dn(t.fields,e.fields)&&(s.fields=t.fields),s}function Pn(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 Mn(e){var t;return(t=e.find(s=>s.schema.type==="date"))==null?void 0:t.name}function An(e,t,s,a){const r={...t,kind:s};if(s==="board"){if(!(t.groupBy??e.groupBy)){const i=Pn(a);i&&(r.groupBy=i)}}else e.groupBy===void 0&&(r.groupBy=void 0);if(s==="calendar"){if(!(t.dateField??e.dateField)){const i=Mn(a);i&&(r.dateField=i)}}else e.dateField===void 0&&(r.dateField=void 0);return r}function _n(e,t,s){const r={kind:le(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 Ln(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 Bn={type:"string"};function M(e){const t=Ve(e);return t.length===1?t[0]:null}function Fn(e,t){return e.fields&&e.fields.length>0?e.fields.map(a=>({name:a,schema:(t==null?void 0:t[a])??Bn})):M(e.query)&&t?Object.entries(t).map(([a,r])=>({name:a,schema:r})):[]}function Vn(e){const t=e?M(e.query):null,s=q(t);return y.useMemo(()=>e?Fn(e,Qe(s.data)):[],[e,s.data])}function Qe(e){return(e==null?void 0:e.fields)??null}function Rn(e){const t=e?M(e.query):null,s=q(t);return y.useMemo(()=>Qe(s.data)??{},[s.data])}function On(e){const t=e?M(e.query):null,s=q(t);return t?s.isSuccess:!0}function In(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 He(){return n.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:n.jsx(I,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})})}function ls(){const{id:e}=Ct(),t=Re(a=>a.getActiveVault()),s=St(e);return t?s.data?n.jsx(zn,{note:s.data}):n.jsxs("div",{className:"page",children:[n.jsx(He,{}),s.isPending?n.jsx(qn,{}):s.isError?n.jsx(Oe,{title:"Couldn't load this view",message:s.error instanceof Error?s.error.message:void 0,retry:()=>s.refetch()}):n.jsx(V,{title:"View not found",description:"It may have been deleted or moved."})]}):n.jsx($t,{to:"/",replace:!0})}function qn(){return n.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[n.jsx(C,{height:32,width:"40%"}),n.jsx(C,{height:20,width:"60%"}),n.jsxs("div",{className:"space-y-2 pt-4",children:[n.jsx(C,{height:56}),n.jsx(C,{height:56}),n.jsx(C,{height:56})]})]})}function zn({note:e}){const t=y.useMemo(()=>te(e),[e]);return n.jsx(Gn,{def:t,backingNote:e,nav:n.jsx(He,{})})}function Gn({def:e,backingNote:t,pageSize:s,total:a,nav:r}){var ye;const i=Re(N=>N.getActiveVault()),{roles:l}=yt((i==null?void 0:i.id)??null),o=typeof s=="number"&&s>0,[u,c]=y.useState(0),[m,p]=jt(),d=y.useMemo(()=>vt(m),[m]),h=y.useMemo(()=>Ae(e,En(m)),[e,m]),j=(N,k)=>{const T=Tn(N);for(const[L,B]of Lt(k))T.append(L,B);p(T,{replace:!0})},g=N=>j(h,N),f=N=>{j(Ae(e,N),d)},b=y.useMemo(()=>le(e,h),[e,h]),v=y.useMemo(()=>JSON.stringify({q:b.query,r:d}),[b.query,d]);y.useEffect(()=>{c(0)},[v]);const x=y.useMemo(()=>!o||!b.query?b:{...b,query:{...b.query,offset:u,limit:s+1}},[o,b,u,s]),w=Nt(x,d,{live:!o}),S=y.useMemo(()=>o&&w.data?w.data.slice(0,s):w.data,[o,w.data,s]),oe=(S==null?void 0:S.length)??0,ce=o?(((ye=w.data)==null?void 0:ye.length)??0)>s:!1,Je=we(d),Xe=o&&!ce?u+oe:void 0,Ke=Je?void 0:a,E=Vn(b),Ze=Rn(b),de=[...b.problems,...w.problems],ue=y.useMemo(()=>S?In(S,l.pinned,Ve(b.query)):{pinned:[],rest:[]},[S,l.pinned,b.query]),et=t!==null,me=(We(h)||we(d))&&et,[tt,xe]=y.useState(!1),[pe,Y]=y.useState(!1),A=wt(l.view,pe),he=se(t==null?void 0:t.id),nt=kt(),fe=ae(N=>N.push),st=y.useMemo(()=>(A.data??[]).filter(N=>N.id!==(t==null?void 0:t.id)).flatMap(N=>{const k=R(te(N).title);return N.path&&N.path!==k?[N.path,k]:[k]}),[t==null?void 0:t.id,A.data]),at=async N=>{if(t)try{const k=await he.mutateAsync({path:R(N),...t.updatedAt?{if_updated_at:t.updatedAt}:{force:!0}});fe(`Renamed view to "${te(k).title}".`,"success"),Y(!1),k.id!==t.id&&nt(`/views/${encodeURIComponent(k.id)}`,{replace:!0})}catch(k){fe(`Could not rename view: ${k.message}`,"error")}},be=()=>p(new URLSearchParams,{replace:!0}),_=y.useMemo(()=>M(b.query),[b.query]),ge=On(b),[W,Q]=y.useState(null),rt=N=>{var B,je;const k=W;if(!k)return;const T=Object.entries(N),L=k==="date"?(B=T.find(([,D])=>D.type==="date"))==null?void 0:B[0]:(je=T.find(([,D])=>{var ve;return(((ve=D.enum)==null?void 0:ve.length)??0)>0})??T.find(([,D])=>D.type!=="date"))==null?void 0:je[0];L&&f({...h,[k==="group"?"groupBy":"dateField"]:L})},it=b.kind==="board"||b.kind==="table";return n.jsxs("div",{className:it?"page page-wide":"page",children:[r,n.jsxs("article",{className:me?"pb-20":void 0,children:[n.jsx(Yn,{def:b,backingNote:t,count:Ke,onRename:t?()=>Y(!0):void 0}),n.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-2 py-1",children:[n.jsx(gn,{kind:b.kind,onSwitch:N=>f(An(e,h,N,E)),dirty:e.kind!==b.kind}),b.kind==="board"?n.jsx(kn,{value:b.groupBy,fields:E,onChange:N=>f({...h,groupBy:N}),dirty:e.groupBy!==b.groupBy,createTag:_,schemaReady:ge,onAddField:()=>Q("group")}):null,b.kind==="calendar"?n.jsx(Cn,{value:b.dateField,fields:E,onChange:N=>f({...h,dateField:N}),dirty:e.dateField!==b.dateField,createTag:_,schemaReady:ge,onAddField:()=>Q("date")}):null,n.jsx(fn,{fields:E,schemaFields:Ze,onChange:N=>f({...h,fields:N}),dirty:e.fields!==b.fields})]}),n.jsx(Xn,{def:e,refinements:d,onChange:g}),de.length>0?n.jsx(Qn,{problems:de}):null,n.jsx("div",{className:"mt-6",children:n.jsx(Hn,{def:b,data:S,isPending:w.isPending,isError:w.isError,error:w.error,retry:w.refetch,viewResultsKey:w.queryKey,fields:E,pinned:ue.pinned,rest:ue.rest,roles:l})}),o?n.jsx(Wn,{offset:u,shown:oe,total:Xe,hasPrev:u>0,hasNext:ce,onPrev:()=>c(N=>Math.max(0,N-s)),onNext:()=>c(N=>N+s)}):null,me?n.jsx(Un,{onSave:()=>xe(!0),onRevert:be}):null,tt&&t?n.jsx(ss,{note:t,def:e,draft:h,refinements:d,roles:l,onClose:()=>xe(!1),onSaved:be}):null,pe&&t?n.jsx(ns,{currentName:e.title,currentPath:t.path,existingPaths:st,isChecking:A.isPending,checkFailed:A.isError,isRenaming:he.isPending,onCancel:()=>Y(!1),onRename:at}):null,W&&_?n.jsx(Ft,{tagName:_,intent:W,onSaved:rt,onClose:()=>Q(null)}):null]})]})}function Un({onSave:e,onRevert:t}){const s=Dt(a=>a.setShown);return y.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 md:bottom-0 md: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 Yn({def:e,backingNote:t,count:s,onRename:a}){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(Tt,{kind:e.kind,hueTag:Ie(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.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:a,className:"btn btn-secondary btn-touch",children:"Rename"}),n.jsx(I,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit view note"})]}):null]})}function Wn({offset:e,shown:t,total:s,hasPrev:a,hasNext:r,onPrev:i,onNext:l}){const o=t>0?e+1:0,u=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}–${u} of ${s.toLocaleString()}`:`Showing ${o}–${u}`:""}),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 Qn({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 Hn({def:e,data:t,isPending:s,isError:a,error:r,retry:i,viewResultsKey:l,fields:o,pinned:u,rest:c,roles:m}){if(e.query===null)return n.jsx(V,{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(C,{height:56}),n.jsx(C,{height:56}),n.jsx(C,{height:56})]});if(a)return n.jsx(Oe,{title:"Couldn't run this view",message:r instanceof Error?r.message:void 0,retry:i});if(!t||u.length===0&&c.length===0)return n.jsx(V,{title:"No notes match this view yet."});const p=[...u,...c];switch(e.kind){case"board":if(e.groupBy)return n.jsx(rn,{notes:p,laneBy:e.groupBy,subjectTag:Ie(e.query),roles:m,viewResultsKey:l,fields:o});break;case"gallery":return n.jsx(bn,{notes:p,roles:m,viewResultsKey:l,fields:o});case"table":return n.jsx(Sn,{notes:p,roles:m,viewResultsKey:l,fields:o});case"calendar":return n.jsx(un,{notes:p,dateField:e.dateField||null,roles:m,viewResultsKey:l,fields:o})}return n.jsx(Jn,{pinned:u,rest:c,roles:m,viewResultsKey:l,fields:o})}function Jn({pinned:e,rest:t,roles:s,viewResultsKey:a,fields:r}){const i=l=>r.length>0?n.jsx(P,{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(ke,{"aria-label":"Pinned notes",children:e.map(l=>n.jsx(Ce,{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(ke,{"aria-label":"View results",children:t.map(l=>n.jsx(Ce,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})}):null]})}function Xn({def:e,refinements:t,onChange:s}){const a=y.useMemo(()=>Et(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(Kn,{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(H,{label:`+#${i}`,onRemove:()=>s({...t,addTags:t.addTags.filter(l=>l!==i)})},`add-${i}`)),t.search?n.jsx(H,{label:`"${t.search}"`,onRemove:()=>s({...t,search:void 0})}):null,t.sort?n.jsx(H,{label:`sorted by ${t.sort==="desc"?"newest":"oldest"}`,onRemove:()=>s({...t,sort:void 0})}):null,n.jsx(Zn,{onAdd:i=>s({...t,addTags:[...t.addTags,i]})}),n.jsx(es,{value:t.search??"",onChange:i=>s({...t,search:i||void 0})}),n.jsx(ts,{value:t.sort,onChange:i=>s({...t,sort:i})})]})}function Kn({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 Zn({onAdd:e}){const[t,s]=y.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 es({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 ts({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 ns({currentName:e,currentPath:t,existingPaths:s,isChecking:a,checkFailed:r,isRenaming:i,onCancel:l,onRename:o}){const[u,c]=y.useState(e),m=u.trim(),d=R(m)===t,h=_t(m,s,t),j=m.length>0&&!d&&!h&&!a&&!r&&!i;return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"rename-view-title",onMouseDown:g=>{g.target===g.currentTarget&&!i&&l()},children:n.jsxs("div",{className:"dialog-panel max-w-(--w-narrow)",children:[n.jsx("h2",{id:"rename-view-title",className:"mb-3 font-serif text-xl text-fg",children:"Rename view"}),n.jsxs("label",{className:"block text-sm",children:[n.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),n.jsx("input",{type:"text",value:u,autoFocus:!0,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&j&&o(m),g.key==="Escape"&&!i&&l()},"aria-label":"View name",className:"input input-on-bg"})]}),a?n.jsx("p",{className:"mt-2 text-xs text-fg-dim",children:"Checking existing views…"}):null,r?n.jsx("p",{className:"mt-2 text-xs text-danger",children:"Existing view names couldn't be checked. Close this dialog and try again."}):h?n.jsx("p",{className:"mt-2 text-xs text-danger",children:"A view with that name already exists."}):null,n.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:l,disabled:i,className:"btn btn-secondary btn-touch",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>j&&void o(m),disabled:!j,className:"btn btn-primary btn-touch",children:i?"Renaming…":"Rename"})]})]})})}function ss({note:e,def:t,draft:s,refinements:a,roles:r,onClose:i,onSaved:l}){const o=ae(x=>x.push),u=Pt(),c=Mt(e,u),[m,p]=y.useState(c),[d,h]=y.useState(`${t.title} (copy)`),[j,g]=y.useState(!1),f=se(e.id),b=At(),v=async()=>{g(!0);try{const x=Bt(t.query,a);m==="update"?(await f.mutateAsync({metadata:_n(t,s,x),...e.updatedAt?{if_updated_at:e.updatedAt}:{force:!0}}),o(`Updated "${t.title}".`,"success")):(await b.mutateAsync({content:"",path:R(d),tags:[r.view],metadata:Ln(le(t,s),x)}),o(`Saved "${d}".`,"success")),l(),i()}catch(x){o(`Could not save: ${x.message}`,"error")}finally{g(!1)}};return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-labelledby":"save-view-title",onMouseDown:x=>{x.target===x.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:m==="update",onChange:()=>p("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:m==="fork",onChange:()=>p("fork")}),"Save as new view"]})]}),m==="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:d,onChange:x=>h(x.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||m==="fork"&&!d.trim(),className:"btn btn-primary btn-touch",children:j?"Saving…":"Save"})]})]})})}export{Gn as ViewCanvas,ls as ViewSurface};