@openparachute/app 0.22.15-rc.7 → 0.22.15-rc.8

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 (43) hide show
  1. package/dist/.parachute/info +1 -1
  2. package/dist/assets/{Account-DVrOc5d2.js → Account-nwhgv70-.js} +1 -1
  3. package/dist/assets/{Activity-0hs_ikJM.js → Activity-nrXpsQcr.js} +1 -1
  4. package/dist/assets/{AddVault-BB-AFOmL.js → AddVault-Ber89Wqa.js} +1 -1
  5. package/dist/assets/{AddVaultChooser-n8eLZ11X.js → AddVaultChooser-DanK5s3b.js} +1 -1
  6. package/dist/assets/{AddVaultCreate-BVyIpnXh.js → AddVaultCreate-9M159HyG.js} +1 -1
  7. package/dist/assets/{AttachmentDropZone-TqaFTJWk.js → AttachmentDropZone-DCx4BmUB.js} +1 -1
  8. package/dist/assets/{Calendar-BFFWBFvP.js → Calendar-IN2_LWdR.js} +1 -1
  9. package/dist/assets/{CheckEmail-PgQKYluA.js → CheckEmail-TDlZFsMB.js} +1 -1
  10. package/dist/assets/{CodeMirrorEditor-DxXQL_Yv.js → CodeMirrorEditor-BFbrH8SS.js} +1 -1
  11. package/dist/assets/{ConnectAI-DvGvVaFL.js → ConnectAI-CgmKvizd.js} +1 -1
  12. package/dist/assets/{DayView-DckpX5OB.js → DayView-BJNKXaVZ.js} +1 -1
  13. package/dist/assets/{Export-nog6GkVZ.js → Export-wDmogiyF.js} +1 -1
  14. package/dist/assets/{Import-kMnqJ0Zy.js → Import-CXf9uGsq.js} +1 -1
  15. package/dist/assets/NoteEditor-Bysn6eCI.js +1 -0
  16. package/dist/assets/NoteNew-Cj3YJXU6.js +8 -0
  17. package/dist/assets/{NoteView-BkwjWffV.js → NoteView-2aKk-OPF.js} +2 -2
  18. package/dist/assets/{OAuthCallback-Bqwbh5dE.js → OAuthCallback-I9Prty3a.js} +1 -1
  19. package/dist/assets/{PinArchiveButtons-6XVGmX0l.js → PinArchiveButtons-PVL_MlIF.js} +1 -1
  20. package/dist/assets/{Settings-B44TjE-J.js → Settings-yCqoLy9Q.js} +1 -1
  21. package/dist/assets/{TagPage-BvHAtmih.js → TagPage-M-1Z3Lf7.js} +1 -1
  22. package/dist/assets/{TagSchemaEditor-Bv9OJXDP.js → TagSchemaEditor-BK0vcpyB.js} +1 -1
  23. package/dist/assets/{Tags-XxPefjNE.js → Tags-Bof4tsk7.js} +1 -1
  24. package/dist/assets/{VaultGraph-B8m-aKEP.js → VaultGraph-WE9ZHl_X.js} +2 -2
  25. package/dist/assets/{Vaults-PLbdO3kQ.js → Vaults-DvoRumEG.js} +1 -1
  26. package/dist/assets/{ViewNew-WUgtqEUn.js → ViewNew-CAfjs7mP.js} +1 -1
  27. package/dist/assets/{ViewSurface-B3tMmOMq.js → ViewSurface-wMkEz45K.js} +1 -1
  28. package/dist/assets/{Welcome-Bncj2rBF.js → Welcome-BA0CZ6MF.js} +1 -1
  29. package/dist/assets/{WizardShell-Cp46Sjm6.js → WizardShell-CA6wAaXi.js} +1 -1
  30. package/dist/assets/{attachment-upload-DML2Fh0E.js → attachment-upload-eLoB3B2Y.js} +1 -1
  31. package/dist/assets/{history-DeQhlq0x.js → history-BQ4lTS0J.js} +1 -1
  32. package/dist/assets/index-N8p5fKHh.js +66 -0
  33. package/dist/assets/{provenance-D_yuCkJz.js → provenance-CD9K2aIh.js} +1 -1
  34. package/dist/assets/{react-force-graph-2d-iGY_edo3.js → react-force-graph-2d-CzhNMQ2p.js} +1 -1
  35. package/dist/assets/{transcribe-default-Cz5r46Dt.js → transcribe-default-LQWMPSGB.js} +1 -1
  36. package/dist/assets/{useAttachmentUploader-CR8KEhCu.js → useAttachmentUploader-FuXMSo6s.js} +1 -1
  37. package/dist/index.html +1 -1
  38. package/dist/sw.js +1 -1
  39. package/meta.json +1 -1
  40. package/package.json +1 -1
  41. package/dist/assets/NoteEditor-DJJzL6og.js +0 -1
  42. package/dist/assets/NoteNew-CNO1wteU.js +0 -8
  43. package/dist/assets/index-BwG_4Oup.js +0 -66
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 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:"80e75420db71c514bcc292ccc0cd842a"},{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-CR8KEhCu.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-Cz5r46Dt.js",revision:null},{url:"assets/react-force-graph-2d-iGY_edo3.js",revision:null},{url:"assets/provenance-D_yuCkJz.js",revision:null},{url:"assets/index-eHCCOf4I.css",revision:null},{url:"assets/index-BwG_4Oup.js",revision:null},{url:"assets/history-DeQhlq0x.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-DML2Fh0E.js",revision:null},{url:"assets/WizardShell-Cp46Sjm6.js",revision:null},{url:"assets/Welcome-Bncj2rBF.js",revision:null},{url:"assets/ViewSurface-B3tMmOMq.js",revision:null},{url:"assets/ViewNew-WUgtqEUn.js",revision:null},{url:"assets/Vaults-PLbdO3kQ.js",revision:null},{url:"assets/VaultGraph-B8m-aKEP.js",revision:null},{url:"assets/Tags-XxPefjNE.js",revision:null},{url:"assets/TagSchemaEditor-Bv9OJXDP.js",revision:null},{url:"assets/TagPage-BvHAtmih.js",revision:null},{url:"assets/Settings-B44TjE-J.js",revision:null},{url:"assets/PinArchiveButtons-6XVGmX0l.js",revision:null},{url:"assets/OAuthCallback-Bqwbh5dE.js",revision:null},{url:"assets/NoteView-BkwjWffV.js",revision:null},{url:"assets/NoteNew-CNO1wteU.js",revision:null},{url:"assets/NoteEditor-DJJzL6og.js",revision:null},{url:"assets/Import-kMnqJ0Zy.js",revision:null},{url:"assets/Export-nog6GkVZ.js",revision:null},{url:"assets/DayView-DckpX5OB.js",revision:null},{url:"assets/ConnectAI-DvGvVaFL.js",revision:null},{url:"assets/CodeMirrorEditor-DxXQL_Yv.js",revision:null},{url:"assets/CheckEmail-PgQKYluA.js",revision:null},{url:"assets/Calendar-BFFWBFvP.js",revision:null},{url:"assets/AttachmentDropZone-TqaFTJWk.js",revision:null},{url:"assets/AddVaultCreate-BVyIpnXh.js",revision:null},{url:"assets/AddVaultChooser-n8eLZ11X.js",revision:null},{url:"assets/AddVault-BB-AFOmL.js",revision:null},{url:"assets/Activity-0hs_ikJM.js",revision:null},{url:"assets/Account-DVrOc5d2.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:"e54f96331fb6ea3da3e8cdd4d6cd11f2"},{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-FuXMSo6s.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-LQWMPSGB.js",revision:null},{url:"assets/react-force-graph-2d-CzhNMQ2p.js",revision:null},{url:"assets/provenance-CD9K2aIh.js",revision:null},{url:"assets/index-eHCCOf4I.css",revision:null},{url:"assets/index-N8p5fKHh.js",revision:null},{url:"assets/history-BQ4lTS0J.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-eLoB3B2Y.js",revision:null},{url:"assets/WizardShell-CA6wAaXi.js",revision:null},{url:"assets/Welcome-BA0CZ6MF.js",revision:null},{url:"assets/ViewSurface-wMkEz45K.js",revision:null},{url:"assets/ViewNew-CAfjs7mP.js",revision:null},{url:"assets/Vaults-DvoRumEG.js",revision:null},{url:"assets/VaultGraph-WE9ZHl_X.js",revision:null},{url:"assets/Tags-Bof4tsk7.js",revision:null},{url:"assets/TagSchemaEditor-BK0vcpyB.js",revision:null},{url:"assets/TagPage-M-1Z3Lf7.js",revision:null},{url:"assets/Settings-yCqoLy9Q.js",revision:null},{url:"assets/PinArchiveButtons-PVL_MlIF.js",revision:null},{url:"assets/OAuthCallback-I9Prty3a.js",revision:null},{url:"assets/NoteView-2aKk-OPF.js",revision:null},{url:"assets/NoteNew-Cj3YJXU6.js",revision:null},{url:"assets/NoteEditor-Bysn6eCI.js",revision:null},{url:"assets/Import-CXf9uGsq.js",revision:null},{url:"assets/Export-wDmogiyF.js",revision:null},{url:"assets/DayView-BJNKXaVZ.js",revision:null},{url:"assets/ConnectAI-CgmKvizd.js",revision:null},{url:"assets/CodeMirrorEditor-BFbrH8SS.js",revision:null},{url:"assets/CheckEmail-TDlZFsMB.js",revision:null},{url:"assets/Calendar-IN2_LWdR.js",revision:null},{url:"assets/AttachmentDropZone-DCx4BmUB.js",revision:null},{url:"assets/AddVaultCreate-9M159HyG.js",revision:null},{url:"assets/AddVaultChooser-DanK5s3b.js",revision:null},{url:"assets/AddVault-Ber89Wqa.js",revision:null},{url:"assets/Activity-nrXpsQcr.js",revision:null},{url:"assets/Account-nwhgv70-.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.15-rc.7",
6
+ "version": "0.22.15-rc.8",
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.15-rc.7",
3
+ "version": "0.22.15-rc.8",
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{r as n,j as e,ak as H,ar as le,V as I,al as ce,as as de,b as J,at as ue,N as me,L as $,J as fe,K as he,e as xe,au as K,av as pe,aw as ge,ax as be,ay as ve,am as je,az as P,aA as Ne,aB as we,aC as ye,M as F,aD as Se}from"./index-BwG_4Oup.js";import{A as ke}from"./AttachmentDropZone-TqaFTJWk.js";import{b as Ce,u as Ee,N as Re,A as Ae,a as De}from"./useAttachmentUploader-CR8KEhCu.js";import{C as Te}from"./CodeMirrorEditor-DxXQL_Yv.js";import{P as Pe,D as Ie}from"./PinArchiveButtons-6XVGmX0l.js";import{r as $e}from"./editor-mode-D9fveTEx.js";import"./attachment-upload-DML2Fh0E.js";const Fe=250;function Le({noteId:t,attachment:a}){const[r,i]=n.useState(!1),x=Be(a);return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>i(!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(Ve,{noteId:t,attachment:a,label:x,onClose:()=>i(!1)}):null]})}function Ve({noteId:t,attachment:a,label:r,onClose:i}){const x=H(c=>c.push),l=le(),[u,m]=n.useState(!1),[f,N]=n.useState(null),d=n.useRef(null);n.useEffect(()=>{const c=setTimeout(()=>m(!0),Fe);return()=>clearTimeout(c)},[]),n.useEffect(()=>{var c;(c=d.current)==null||c.focus()},[]),n.useEffect(()=>{const c=k=>{k.key==="Escape"&&i()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[i]);const g=n.useCallback(()=>{!u||l.isPending||(N(null),l.mutate({noteId:t,attachmentId:a.id},{onSuccess:()=>{x(`Removed ${r}`,"success"),i()},onError:c=>{if(c instanceof I){N("Session expired. Reconnect to remove attachments.");return}if(c instanceof ce){x(`Already removed ${r}`,"info"),i();return}N(c instanceof Error?c.message:"Remove failed")}}))},[u,a.id,r,l,t,i,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:c=>{c.target===c.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"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:d,type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:g,disabled:!u||l.isPending,className:"btn btn-danger-solid btn-touch",children:l.isPending?"Removing…":"Remove"})]})]})})}function Be(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function et(){const{id:t}=de(),a=J(i=>i.getActiveVault()),r=ue(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(_e,{}):r.isError?e.jsx(We,{error:r.error}):r.data?e.jsx(Me,{note:r.data}):e.jsx(ze,{id:t??""})]}):e.jsx(me,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Me({note:t}){const a=xe(),r=H(s=>s.push),i=K(s=>s.on),x=K(s=>s.setOn),l=n.useRef(J.getState().activeVaultId).current,u=n.useRef($e()).current,m=n.useMemo(()=>Ce(t),[t]),[f,N]=n.useState(()=>S(t)),[d,g]=n.useState(()=>S(t)),[c,k]=n.useState(()=>{if(!l)return null;const s=pe(l,t.id);return!s||ge(s.body,S(t))?null:s}),[G,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,Q]=n.useState("edit"),j=be(t.id),A=n.useRef(t),D=n.useRef(null),O=n.useRef(null),v=Ee({noteId:t.id,onInsert:s=>{D.current?D.current.insertAtCursor(s):g(o=>({...o,content:`${o.content}${s}`}))},onLinked:()=>{r("Attachment added","success")},onError:s=>r(s,"error")});n.useEffect(()=>{A.current=t},[t]);const h=d.content!==f.content||d.path!==f.path||!qe(d.tags,f.tags);ve(l,t.id,d,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 o={};d.content!==f.content&&(o.content=d.content),d.path!==f.path&&(o.path=d.path);const b=Ke(f.tags,d.tags);(b.add.length||b.remove.length)&&(o.tags=b);const q=A.current.updatedAt??A.current.createdAt;q&&(o.if_updated_at=q),E(null),C(null),j.mutate(o,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,l&&P(l,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 je?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,d,h,j,a,t.id,y,l]),X=n.useCallback(()=>{c&&g(c.body),k(null)},[c]),ee=n.useCallback(()=>{l&&P(l,t.id),k(null)},[l,t.id]),te=n.useCallback(()=>T({navigateToView:!0}),[T]),se=n.useCallback(()=>T({navigateToView:!1}),[T]),ne=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?")||(l&&P(l,t.id),a(`/n/${encodeURIComponent(t.id)}`))},[h,a,t.id,l]);n.useEffect(()=>{if(!h)return;const s=o=>{o.preventDefault(),o.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const z=n.useRef(i);n.useEffect(()=>{var o;const s=i&&!z.current;z.current=i,s&&((o=D.current)==null||o.focus())},[i]);const ae=d.path!==f.path,re=s=>{const o=Se(s);o&&(d.tags.includes(o)||(g(b=>({...b,tags:[...b.tags,o]})),L("")))},ie=s=>{g(o=>({...o,tags:o.tags.filter(b=>b!==s)}))},oe=d.content,W=i?"h-[85dvh]":"h-[60dvh]";return e.jsxs("article",{children:[i?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(Pe,{note:t}),e.jsx(Ie,{note:t}),e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(Ne,{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:ne,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:te,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(we,{tags:d.tags,input:G,onInputChange:L,onAdd:re,onRemove:ie})}),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:d.path,onChange:s=>g(o=>({...o,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:d.path||void 0})]}),ae?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null,ye(d.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]}),c?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(c.savedAt),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:X,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:ee,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,V?e.jsx(Oe,{conflict:V,onReload:()=>{l&&P(l,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:()=>Q(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 ${i?"min-h-[85dvh]":"min-h-[60dvh]"} gap-4 ${u?"":"lg:grid-cols-2"}`,children:[e.jsx(ke,{onDropFiles:v.start,className:`card min-h-0 ${W} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:Z,children:e.jsx(Te,{ref:D,value:d.content,onChange:s=>g(o=>({...o,content:s})),onSave:se,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 ${W} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Re,{note:{path:d.path,content:oe},resolve:m})})]}),e.jsx(Ue,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const Z=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 Ue({noteId:t,pickerRef:a,attachments:r,uploads:i,onPickFiles:x,onCancel:l,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(Ae,{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. ",Z,"."]}),e.jsx(De,{uploads:i,onCancel:l,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(Le,{noteId:t,attachment:m})]})]},m.id))}):null]})}function Oe({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 _e(){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 ze({id:t}){return e.jsx(he,{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 We({error:t}){const a=t instanceof I;return e.jsx(fe,{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 qe(t,a){if(t.length!==a.length)return!1;const r=new Set(t);for(const i of a)if(!r.has(i))return!1;return!0}function Ke(t,a){const r=new Set(t),i=new Set(a),x=a.filter(u=>!r.has(u)),l=t.filter(u=>!i.has(u));return{add:x,remove:l}}export{et as NoteEditor};
@@ -1,8 +0,0 @@
1
- import{aE as Le,r,aF as Ue,aG as Fe,aH as ge,b as Ve,e as qe,ak as Oe,aI as Be,aJ as Ge,aK as He,aL as We,af as Ye,aj as Ke,aM as Qe,av as Ze,aN as ze,P as Je,ay as Xe,j as e,N as et,aO as tt,aP as st,aQ as xe,V as nt,az as W,aR as at,aS as rt,aT as ot,aU as it,aV as ee,aW as ct,aX as lt,aY as D,L as dt,aB as ut,M as mt,aZ as pt,a_ as ht,aD as ft}from"./index-BwG_4Oup.js";import{A as gt}from"./AttachmentDropZone-TqaFTJWk.js";import{u as xt,b as bt,N as vt,A as yt,a as jt}from"./useAttachmentUploader-CR8KEhCu.js";import{C as kt}from"./CodeMirrorEditor-DxXQL_Yv.js";import{l as be,u as wt,a as Nt,b as Rt}from"./transcribe-default-Cz5r46Dt.js";import{r as St}from"./editor-mode-D9fveTEx.js";import{v as Tt}from"./attachment-upload-DML2Fh0E.js";import"./types-BaJkUfo6.js";const Ct=30*6e4,At=20*1024*1024,Et=1e4;function It(t){const i=t.segmentMs??Ct,c=t.setTimer??((m,C)=>setTimeout(m,C)),x=t.clearTimer??(m=>clearTimeout(m)),j=t.makeRecorder??(m=>Le({...m,releaseStreamOnStop:!1})),f=[];let a=null,d=null,p="idle",b=0,h=0,v=!1;const u=()=>{for(const m of t.stream.getTracks())m.stop()},g=()=>{d!==null&&(x(d),d=null)},n=()=>{d=c(()=>{d=null,o()},i)},R=()=>{h+=1;const m=h;a=j({stream:t.stream,mimeType:t.mimeType,releaseStreamOnStop:!1,now:t.now,MediaRecorderCtor:t.MediaRecorderCtor,dataIntervalMs:Et,onData:C=>{m===h&&C>=At&&o()}}),a.start(),b+=1,n()},o=()=>{var m;p!=="recording"||!a||v||(v=!0,g(),f.push(a.stop()),R(),(m=t.onRoll)==null||m.call(t,b),v=!1)};return{get state(){return p},get activePart(){return b},start(){if(p!=="idle")throw new Error(`Cannot start from ${p}`);p="recording",R()},async stop(){if(p!=="recording"||!a)throw new Error(`Cannot stop from ${p}`);p="stopped",g(),f.push(a.stop()),a=null;const m=await Promise.all(f);return u(),m},cancel(){g(),a&&a.cancel(),a=null,p="stopped",u()}}}function Pt(){const[t,i]=r.useState({kind:"idle"}),[c,x]=r.useState(0),[j,f]=r.useState(0),a=r.useRef(null),d=r.useRef(null);r.useEffect(()=>{if(t.kind!=="recording")return;const u=setInterval(()=>x(Date.now()-t.startedAt),250);return()=>clearInterval(u)},[t]),r.useEffect(()=>()=>{d.current&&URL.revokeObjectURL(d.current),a.current&&a.current.state==="recording"&&a.current.cancel()},[]);const p=r.useCallback(async()=>{if(!(t.kind==="recording"||t.kind==="requesting")){i({kind:"requesting"});try{const u=Ue();if(!u){i({kind:"denied",message:"This browser can't record audio in a format we can save."});return}const g=await Fe(),n=It({stream:g,mimeType:u,onRoll:R=>f(R)});a.current=n,n.start(),x(0),f(n.activePart),i({kind:"recording",startedAt:Date.now()})}catch(u){const g=u,n=g.kind==="permission-denied"?"Microphone access was denied. Update your browser's site settings to record.":g.kind==="no-device"?"No microphone was found on this device.":g instanceof Error?g.message:"Microphone is not available in this browser.";i({kind:"denied",message:n})}}},[t]),b=r.useCallback(async()=>{var g;const u=a.current;if(!(!u||t.kind!=="recording"))try{const n=await u.stop();a.current=null,f(0);const R=((g=n[0])==null?void 0:g.mimeType)??"",o=n.reduce((q,Y)=>q+Y.durationMs,0),m=n[0],C=m?URL.createObjectURL(new Blob([m.data],{type:m.mimeType})):"";d.current&&URL.revokeObjectURL(d.current),d.current=C||null,i({kind:"have-audio",segments:n,mimeType:R,url:C,durationMs:o})}catch(n){console.warn(n instanceof Error?`Recording failed: ${n.message}`:"Recording failed."),f(0),i({kind:"idle"})}},[t]),h=r.useCallback(()=>{d.current&&(URL.revokeObjectURL(d.current),d.current=null),i({kind:"idle"}),x(0),f(0)},[]),v=r.useCallback(()=>{h()},[h]);return{phase:t,elapsedMs:c,parts:j,startRecording:p,stopRecording:b,discardAudio:h,reset:v}}function Mt(t){const{segments:i,mimeType:c,recordedAt:x,willTranscribe:j}=t,f=i.length>1,a=t.typedText.trim(),d=i.map((v,u)=>({filename:f?ge(c,x,u+1):ge(c,x),transcribe:j,...j&&f?{segment_index:u}:{}})),p=j?f?i.map((v,u)=>`_Transcript pending (part ${u+1})._`).join(`
2
-
3
- `):"_Transcript pending._":"",b=d.map(v=>`![[${v.filename}]]`).join(`
4
-
5
- `),h=[];return a&&h.push(a),p&&h.push(p),h.push(b),{body:`${h.join(`
6
-
7
- `)}
8
- `,segments:d}}const ve={content:"",path:"",tags:[]};function Ht(){const t=Ve(s=>s.getActiveVault()),i=qe(),c=Oe(s=>s.push),x=Be(),j=Ge(),f=He(),{db:a,blobStore:d,engine:p}=We(),{roles:b,tagNewNotes:h}=Ye((t==null?void 0:t.id)??null),v=Ke(),u=r.useRef(Qe()),g=r.useRef(St()).current,n=r.useRef((t==null?void 0:t.id)??null).current,R=r.useRef(null),[o,m]=r.useState(()=>{if(n){const s=Ze(n,D);if(s)return R.current=s.savedAt,s.body}return{...ve,path:u.current}}),[C,q]=r.useState(()=>R.current),[Y,se]=r.useState(""),[ne,E]=r.useState(null),[O,je]=r.useState([]),[ke,ae]=r.useState(!1),K=r.useRef(null),re=r.useRef(null),y=Pt(),$=ze(),S=$.capability,we=y.phase.kind==="requesting"||y.phase.kind==="recording"||y.phase.kind==="have-audio",Ne=(S==null?void 0:S.enabled)===!1&&!we,Q=typeof(S==null?void 0:S.minutes_remaining)=="number"?S.minutes_remaining:void 0,Z=Q!==void 0&&Q<=0,[z,oe]=r.useState(()=>n?be(n):!0),Re=(S==null?void 0:S.enabled)!==!1,ie=r.useRef(y.phase.kind);r.useEffect(()=>{const s=ie.current,l=y.phase.kind;ie.current=l,l==="idle"&&s!=="idle"&&n&&oe(be(n))},[y.phase.kind,n]);const[Se]=Je(),ce=Se.has("voice"),le=r.useRef(!1);r.useEffect(()=>{var s;!ce||le.current||$.settled&&((s=$.capability)==null?void 0:s.enabled)!==!1&&(le.current=!0,y.startRecording())},[ce,$.settled,$.capability,y.startRecording]);const I=xt({noteId:null,onInsert:s=>{K.current?K.current.insertAtCursor(s):m(l=>({...l,content:`${l.content}${s}`}))},onStaged:s=>je(l=>[...l,s]),onError:s=>c(s,"error")}),Te=o.content.trim().length>0||o.tags.length>0||o.path.trim().length>0&&o.path!==u.current;if(Xe(n,D,o,Te),!t)return e.jsx(et,{to:"/",replace:!0});const P=y.phase.kind==="have-audio",Ce=o.content.trim().length>0,B=o.content.length>0||o.path!==u.current||o.tags.length>0||P,Ae=h?P?b.captureVoice:b.captureText:null,de=tt(o.tags,o.content,Ae),L=o.path.trim().length>0&&(Ce||P),M=x.isPending||ke,ue=r.useCallback(()=>{var k;if(!L||M)return;const s=h?b.captureText:null,l=st({content:o.content,path:o.path,tags:o.tags,inboxTag:s});v&&s&&((k=l.tags)!=null&&k.includes(s))&&xe(t.id,v,s),E(null),x.mutate(l,{onSuccess:async T=>{for(const U of O)try{await j.mutateAsync({noteId:T.id,path:U.path,mimeType:U.mimeType})}catch(G){const _=G instanceof Error?G.message:"Link failed";c(`Failed to attach ${U.filename}: ${_}`,"error")}n&&W(n,D),c(`Created ${T.path??T.id}`,"success"),i(`/n/${encodeURIComponent(T.id)}`,{replace:!0})},onError:T=>{T instanceof nt?E("Session expired. Reconnect to save."):E(T instanceof Error?`${T.message} — if the path is taken, try a different one.`:"Create failed")}})},[t,n,v,o,L,j,x,i,M,c,b.captureText,O,h]),me=r.useCallback(async()=>{if(!L||M||y.phase.kind!=="have-audio")return;if(!a||!d){c("Sync queue not ready — try again in a moment.","error");return}E(null);const s=y.phase,l=s.segments,k=s.mimeType,T=o.path.trim(),U=o.tags,G=at(o.content),_=h?b.captureVoice:null,J=rt([...U,...G],_),_e=new Date,F=ot(),De=!Z&&z,X=Mt({segments:l,mimeType:k,typedText:o.content,recordedAt:_e,willTranscribe:De});for(let w=0;w<l.length;w++){const A=Tt(new File([l[w].data],X.segments[w].filename,{type:k}));if(A){c(A,"error"),E(A);return}}ae(!0),v&&_&&J.includes(_)&&xe(t.id,v,_);const fe={content:X.body,path:T,metadata:ht("voice"),...J.length?{tags:J}:{}};try{const w=X.segments.map((N,V)=>({segment:N,data:l[V].data,blobId:it()})),A=[];try{for(const N of w)await d.put(N.blobId,N.data,k,t.id),A.push(N.blobId)}catch(N){throw(await Promise.allSettled(A.map(H=>d.delete(H)))).forEach((H,$e)=>{H.status==="rejected"&&console.warn(`Could not roll back staged voice blob ${A[$e]}; it may need cleanup.`,H.reason)}),N}await ee(a,{kind:"create-note",localId:F,payload:fe},{vaultId:t.id});for(const{segment:N,blobId:V}of w)await ee(a,{kind:"upload-attachment",blobId:V,filename:N.filename,mimeType:k},{vaultId:t.id}),await ee(a,{kind:"link-attachment",noteId:F,pathRef:ct(V),mimeType:k,transcribe:N.transcribe,...N.segment_index!==void 0?{segment_index:N.segment_index}:{}},{vaultId:t.id});p==null||p.runOnce(),f.setQueryData(["note",t.id,F],lt(fe,F)),n&&W(n,D),c("Captured — syncing audio.","success"),y.discardAudio(),i(`/n/${encodeURIComponent(F)}`,{replace:!0})}catch(w){c(w instanceof Error?`Capture failed: ${w.message}`:"Capture failed.","error"),E(w instanceof Error?w.message:"Capture failed")}finally{ae(!1)}},[t,n,d,v,a,o,p,L,i,Z,M,c,f,b.captureVoice,h,z,y]),pe=r.useCallback(()=>{P?me():ue()},[P,ue,me]),he=r.useCallback(()=>{B&&!confirm("Discard this draft?")||(n&&W(n,D),y.discardAudio(),i("/"))},[n,B,i,y]),Ee=r.useCallback(()=>{n&&W(n,D),m({...ve,path:u.current}),y.discardAudio(),q(null)},[n,y]);r.useEffect(()=>{if(!B)return;const s=l=>{l.preventDefault(),l.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[B]);const Ie=s=>{const l=ft(s);!l||o.tags.includes(l)||(m(k=>({...k,tags:[...k.tags,l]})),se(""))},Pe=s=>{m(l=>({...l,tags:l.tags.filter(k=>k!==s)}))},Me=bt({id:"__new__",createdAt:new Date().toISOString()});return e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(dt,{to:"/notes",className:"hover:text-accent",children:"← All notes"})}),e.jsxs("article",{children:[e.jsxs("header",{className:"composer mb-6 p-5 md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{className:"eyebrow",children:"New note"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:he,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:pe,disabled:!L||M,className:"btn btn-primary btn-touch",title:"Create (⌘S)",children:M?"Creating…":"Create"})]})]}),e.jsx("input",{type:"text",value:o.path,onChange:s=>m(l=>({...l,path:s.target.value})),className:o.path===u.current?"mt-4 w-full border-0 bg-transparent font-sans text-sm text-fg-dim outline-none placeholder:text-fg-dim":"mt-4 w-full border-0 bg-transparent font-serif text-2xl text-fg outline-none placeholder:text-fg-dim md:text-3xl","aria-label":"Note path",placeholder:"Name your note — or just start writing"}),e.jsxs("div",{className:"mt-4",children:[e.jsx(ut,{tags:o.tags,input:Y,onInputChange:se,onAdd:Ie,onRemove:Pe}),de?e.jsxs("p",{className:"mt-1.5 text-xs text-fg-dim","data-testid":"inbox-tag-hint",children:["No tags yet, so this note will be saved with #",de,"."]}):null]})]}),C?e.jsxs("div",{role:"status","data-testid":"draft-restored",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:["Unsaved draft restored from ",mt(C),"."]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:Ee,className:"text-fg-dim hover:text-danger",children:"Discard draft"}),e.jsx("button",{type:"button",onClick:()=>q(null),"aria-label":"Dismiss draft-restored notice",className:"text-fg-dim hover:text-accent",children:"✕"})]})]}):null,ne?e.jsx("div",{role:"alert",className:"mb-4 rounded-xl border border-danger-border bg-danger-soft p-3 text-sm text-danger",children:ne}):null,Ne?e.jsx(pt,{capability:S}):e.jsxs(e.Fragment,{children:[e.jsx($t,{voice:y,minutesRemaining:Q,outOfMinutes:Z,transcribe:z,onTranscribeChange:oe,showTranscribeToggle:Re}),e.jsx(_t,{vaultId:t.id,captureEngaged:P})]}),e.jsxs("div",{className:`grid min-h-[60dvh] gap-4 ${g?"":"lg:grid-cols-2"}`,children:[e.jsx(gt,{onDropFiles:I.start,className:"card min-h-0 h-[60dvh] min-w-0",hint:"Images, audio, webm video",children:e.jsx(kt,{ref:K,value:o.content,onChange:s=>m(l=>({...l,content:s})),onSave:pe,onCancel:he,placeholder:"Start writing…",onPasteFile:s=>(I.start(s),!0),onRequestAttachment:()=>{var s;return(s=re.current)==null?void 0:s.open()},livePreview:g})}),g?null:e.jsx("div",{className:"card min-w-0 overflow-auto p-4 lg:h-[60dvh] lg:min-h-0",children:o.content.trim()?e.jsx(vt,{note:{path:o.path,content:o.content},resolve:Me}):e.jsx("p",{className:"text-sm text-fg-dim",children:"Preview appears here as you type."})})]}),e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-xl",children:"Attachments"}),e.jsx(yt,{ref:re,onPickFiles:I.start})]}),e.jsxs("p",{className:"mb-3 text-xs text-fg-dim",children:["Drop or paste files into the editor. Attachments link to the note when you save. Max 100 MB each. Images, audio, webm video."," ",e.jsx("a",{href:"https://github.com/ParachuteComputer/parachute-vault/issues/127",target:"_blank",rel:"noreferrer",className:"text-accent hover:underline",children:"PDF + mp4 coming"}),"."]}),e.jsx(jt,{uploads:I.uploads,onCancel:I.cancel,onDismiss:I.dismiss}),O.length>0?e.jsx("ul",{className:"mt-3 space-y-1 text-sm",children:O.map(s=>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 text-fg-muted",children:[e.jsx("span",{className:"truncate",children:s.filename}),e.jsx("span",{className:"shrink-0 text-fg-dim",children:"staged"})]},s.path))}):null]})]})]})}function _t({vaultId:t,captureEngaged:i}){const c=wt(),x=Nt(),{made:j,markMade:f}=Rt(t),[a,d]=r.useState(null);if(!(i&&!j&&c.supported&&c.value==="keep"))return null;const b=h=>{d(null),x.mutate(h,{onSuccess:()=>f(),onError:()=>d("Couldn't save that choice — this recording is kept (the vault default). We'll ask again next time; you can also set it in Settings.")})};return e.jsxs("div",{"data-testid":"retention-choice",className:"mb-4 flex flex-col gap-2 rounded-xl border border-border bg-card/60 p-3",children:[e.jsx("p",{className:"text-xs text-fg-muted",children:"First voice note here — should this vault keep your audio files after transcribing?"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>b("keep"),disabled:x.isPending,className:"btn btn-secondary btn-touch",children:"Keep my recordings"}),e.jsx("button",{type:"button",onClick:()=>b("until_transcribed"),disabled:x.isPending,className:"btn btn-secondary btn-touch",children:"Just keep the words"}),e.jsx("span",{className:"text-xs text-fg-dim",children:"(audio deleted after transcribing)"})]}),e.jsx("p",{className:"text-xs text-fg-dim",children:"Either way your capture saves now. Change this anytime in Settings."}),a?e.jsx("p",{className:"text-xs text-danger","data-testid":"retention-choice-error",children:a}):null]})}const Dt=30;function ye({checked:t,disabled:i,onChange:c}){return e.jsxs("div",{className:"flex basis-full items-center gap-3",children:[e.jsx("span",{className:"text-xs text-fg-dim",children:"Transcribe this recording"}),e.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Transcribe this recording","data-testid":"transcribe-toggle",disabled:i,onClick:()=>c(!t),className:`relative h-7 w-12 shrink-0 rounded-full transition-colors disabled:opacity-40 ${t?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0 h-6 w-6 rounded-full bg-card shadow-sm transition-transform ${t?"translate-x-5":"translate-x-0.5"}`})})]})}function $t({voice:t,minutesRemaining:i,outOfMinutes:c,transcribe:x,onTranscribeChange:j,showTranscribeToggle:f}){const{phase:a,elapsedMs:d,parts:p,startRecording:b,stopRecording:h,discardAudio:v}=t,u=a.kind==="recording",g=a.kind==="requesting",n=!c&&x,R=typeof i=="number"&&i<=Dt;return a.kind==="have-audio"?e.jsxs("div",{className:"mb-4 flex flex-col gap-2 rounded-xl border border-accent/30 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("span",{className:"text-sm text-fg-muted",children:["🎙 Recorded ",te(a.durationMs),a.segments.length>1?` · ${a.segments.length} parts`:""]}),e.jsx("button",{type:"button",onClick:v,className:"text-xs text-fg-dim hover:text-danger",children:"Discard"})]}),e.jsx("audio",{controls:!0,src:a.url,className:"w-full",children:e.jsx("track",{kind:"captions"})}),f?e.jsx(ye,{checked:n,disabled:c,onChange:j}):null,e.jsx("p",{className:"text-xs text-fg-dim",children:c?"Saved as audio-only — you're out of transcription minutes this month.":n?"Transcript will be appended once your vault processes it. Save to commit.":"Saved as audio-only — transcription is off for this recording."})]}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-border bg-card/60 p-3",children:[e.jsx("div",{className:"text-xs text-fg-dim",children:u?p>1?`Recording — tap Stop to finish. (part ${p})`:"Recording — tap Stop to finish.":g?"Requesting microphone…":c?"You're out of transcription minutes this month — this saves as audio-only.":n?"Add a voice memo to this note. Audio gets transcribed and appended.":"Add a voice memo to this note. Saved as audio-only — transcription is off for this recording."}),u?e.jsxs("button",{type:"button",onClick:()=>void h(),"aria-label":`Recording — ${te(d)} — stop`,"aria-pressed":"true",className:"flex min-h-11 items-center gap-2 rounded-full border border-danger-border bg-danger-soft px-4 py-2 text-sm font-medium text-danger",children:[e.jsx("span",{"aria-hidden":"true",className:"animate-pulse",children:"🎙"}),e.jsxs("span",{children:["Stop ",te(d)]})]}):e.jsxs("button",{type:"button",onClick:()=>void b(),"aria-label":"Record voice memo",disabled:g,className:"flex min-h-11 items-center gap-2 rounded-full border border-accent/30 bg-accent/10 px-4 py-2 text-sm font-medium text-accent hover:bg-accent/15 disabled:opacity-40",children:[e.jsx("span",{"aria-hidden":"true",children:"🎙"}),e.jsx("span",{children:g?"Requesting…":"Record"})]}),f?e.jsx(ye,{checked:n,disabled:c,onChange:j}):null,R&&!c?e.jsxs("p",{className:"basis-full text-xs text-fg-dim","data-testid":"voice-minutes-left",children:["About ",Math.round(i)," min of transcription left this month."]}):null,a.kind==="denied"?e.jsx("p",{className:"basis-full rounded-xl border border-danger-border bg-danger-soft px-3 py-2 text-xs text-danger",children:a.message}):null]})}function te(t){const i=Math.floor(t/1e3),c=Math.floor(i/60),x=i%60;return`${String(c).padStart(2,"0")}:${String(x).padStart(2,"0")}`}export{Ht as NoteNew};