@openparachute/app 0.22.15-rc.8 → 0.22.15-rc.9
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.
- package/dist/.parachute/info +1 -1
- package/dist/assets/{Account-nwhgv70-.js → Account-BlF_EcRI.js} +1 -1
- package/dist/assets/{Activity-nrXpsQcr.js → Activity-CNQH3ItP.js} +1 -1
- package/dist/assets/{AddVault-Ber89Wqa.js → AddVault-hGHUTnPD.js} +1 -1
- package/dist/assets/{AddVaultChooser-DanK5s3b.js → AddVaultChooser-BlNP3fXL.js} +1 -1
- package/dist/assets/{AddVaultCreate-9M159HyG.js → AddVaultCreate-BE4IlqS6.js} +1 -1
- package/dist/assets/{AttachmentDropZone-DCx4BmUB.js → AttachmentDropZone-EkT_RjLH.js} +1 -1
- package/dist/assets/{Calendar-IN2_LWdR.js → Calendar-DPtYgRuV.js} +1 -1
- package/dist/assets/{CheckEmail-TDlZFsMB.js → CheckEmail-9wbGxeLW.js} +1 -1
- package/dist/assets/{CodeMirrorEditor-BFbrH8SS.js → CodeMirrorEditor-D8LwdUtK.js} +1 -1
- package/dist/assets/{ConnectAI-CgmKvizd.js → ConnectAI-CYN2YQRa.js} +1 -1
- package/dist/assets/{DayView-BJNKXaVZ.js → DayView-CuHuewG-.js} +1 -1
- package/dist/assets/{Export-wDmogiyF.js → Export-CL1BgnGi.js} +1 -1
- package/dist/assets/{Import-CXf9uGsq.js → Import-wcBU0sNv.js} +1 -1
- package/dist/assets/NoteEditor-CQhyIljD.js +1 -0
- package/dist/assets/{NoteNew-Cj3YJXU6.js → NoteNew-CTbXeJiZ.js} +1 -1
- package/dist/assets/NoteView-DCYmDxdI.js +9 -0
- package/dist/assets/{OAuthCallback-I9Prty3a.js → OAuthCallback-kN--pM00.js} +1 -1
- package/dist/assets/{PinArchiveButtons-PVL_MlIF.js → PinArchiveButtons-DQvu374I.js} +1 -1
- package/dist/assets/{Settings-yCqoLy9Q.js → Settings-CgJB1fI_.js} +1 -1
- package/dist/assets/{TagPage-M-1Z3Lf7.js → TagPage-Dpar99IQ.js} +1 -1
- package/dist/assets/{TagSchemaEditor-BK0vcpyB.js → TagSchemaEditor-CORGT8cE.js} +1 -1
- package/dist/assets/{Tags-Bof4tsk7.js → Tags-CbXlWv7c.js} +1 -1
- package/dist/assets/{VaultGraph-WE9ZHl_X.js → VaultGraph-DZsVI2L4.js} +2 -2
- package/dist/assets/{Vaults-DvoRumEG.js → Vaults-BuG0aIzf.js} +1 -1
- package/dist/assets/{ViewNew-CAfjs7mP.js → ViewNew-0mojnm9U.js} +1 -1
- package/dist/assets/{ViewSurface-wMkEz45K.js → ViewSurface-DDF7E9EA.js} +1 -1
- package/dist/assets/{Welcome-BA0CZ6MF.js → Welcome-D7Q2yTT6.js} +1 -1
- package/dist/assets/{WizardShell-CA6wAaXi.js → WizardShell-CgBMpM5E.js} +1 -1
- package/dist/assets/{attachment-upload-eLoB3B2Y.js → attachment-upload-Dh8mYgHN.js} +1 -1
- package/dist/assets/{history-BQ4lTS0J.js → history-BROjFTSH.js} +1 -1
- package/dist/assets/{index-N8p5fKHh.js → index-BPGR62yM.js} +15 -15
- package/dist/assets/{provenance-CD9K2aIh.js → provenance-Duy77fE7.js} +1 -1
- package/dist/assets/{react-force-graph-2d-CzhNMQ2p.js → react-force-graph-2d-B20jUNAB.js} +1 -1
- package/dist/assets/{transcribe-default-LQWMPSGB.js → transcribe-default-GimGXEzW.js} +1 -1
- package/dist/assets/{useAttachmentUploader-FuXMSo6s.js → useAttachmentUploader-BSMLFZyP.js} +2 -2
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/meta.json +1 -1
- package/package.json +1 -1
- package/dist/assets/NoteEditor-Bysn6eCI.js +0 -1
- package/dist/assets/NoteView-2aKk-OPF.js +0 -9
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-
|
|
25
|
+
<script type="module" crossorigin src="/assets/index-BPGR62yM.js"></script>
|
|
26
26
|
<link rel="stylesheet" crossorigin href="/assets/index-eHCCOf4I.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
|
|
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:"fa614ddf4d6b7e710561b38a2f6b5a5e"},{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-BSMLFZyP.js",revision:null},{url:"assets/types-BaJkUfo6.js",revision:null},{url:"assets/transcribe-default-GimGXEzW.js",revision:null},{url:"assets/react-force-graph-2d-B20jUNAB.js",revision:null},{url:"assets/provenance-Duy77fE7.js",revision:null},{url:"assets/index-eHCCOf4I.css",revision:null},{url:"assets/index-BPGR62yM.js",revision:null},{url:"assets/history-BROjFTSH.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-Dh8mYgHN.js",revision:null},{url:"assets/WizardShell-CgBMpM5E.js",revision:null},{url:"assets/Welcome-D7Q2yTT6.js",revision:null},{url:"assets/ViewSurface-DDF7E9EA.js",revision:null},{url:"assets/ViewNew-0mojnm9U.js",revision:null},{url:"assets/Vaults-BuG0aIzf.js",revision:null},{url:"assets/VaultGraph-DZsVI2L4.js",revision:null},{url:"assets/Tags-CbXlWv7c.js",revision:null},{url:"assets/TagSchemaEditor-CORGT8cE.js",revision:null},{url:"assets/TagPage-Dpar99IQ.js",revision:null},{url:"assets/Settings-CgJB1fI_.js",revision:null},{url:"assets/PinArchiveButtons-DQvu374I.js",revision:null},{url:"assets/OAuthCallback-kN--pM00.js",revision:null},{url:"assets/NoteView-DCYmDxdI.js",revision:null},{url:"assets/NoteNew-CTbXeJiZ.js",revision:null},{url:"assets/NoteEditor-CQhyIljD.js",revision:null},{url:"assets/Import-wcBU0sNv.js",revision:null},{url:"assets/Export-CL1BgnGi.js",revision:null},{url:"assets/DayView-CuHuewG-.js",revision:null},{url:"assets/ConnectAI-CYN2YQRa.js",revision:null},{url:"assets/CodeMirrorEditor-D8LwdUtK.js",revision:null},{url:"assets/CheckEmail-9wbGxeLW.js",revision:null},{url:"assets/Calendar-DPtYgRuV.js",revision:null},{url:"assets/AttachmentDropZone-EkT_RjLH.js",revision:null},{url:"assets/AddVaultCreate-BE4IlqS6.js",revision:null},{url:"assets/AddVaultChooser-BlNP3fXL.js",revision:null},{url:"assets/AddVault-hGHUTnPD.js",revision:null},{url:"assets/Activity-CNQH3ItP.js",revision:null},{url:"assets/Account-BlF_EcRI.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.
|
|
6
|
+
"version": "0.22.15-rc.9",
|
|
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.
|
|
3
|
+
"version": "0.22.15-rc.9",
|
|
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 J,ar as le,V as I,al as de,as as ue,b as Z,at as me,N as fe,L as $,J as he,K as xe,e as pe,au as Y,av as ge,aw as be,ax as ve,ay as je,am as Ne,az as P,aA as we,aB as ye,aC as Se,M as F,aD as ke}from"./index-N8p5fKHh.js";import{A as Ce}from"./AttachmentDropZone-DCx4BmUB.js";import{b as Ee,u as Re,N as Ae,A as De,a as Te}from"./useAttachmentUploader-FuXMSo6s.js";import{C as Pe}from"./CodeMirrorEditor-BFbrH8SS.js";import{P as Ie,D as $e}from"./PinArchiveButtons-PVL_MlIF.js";import{r as Fe}from"./editor-mode-D9fveTEx.js";import"./attachment-upload-eLoB3B2Y.js";const Le=250;function Ve({noteId:t,attachment:a}){const[r,i]=n.useState(!1),x=Me(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(Be,{noteId:t,attachment:a,label:x,onClose:()=>i(!1)}):null]})}function Be({noteId:t,attachment:a,label:r,onClose:i}){const x=J(c=>c.push),d=le(),[u,m]=n.useState(!1),[f,N]=n.useState(null),l=n.useRef(null);n.useEffect(()=>{const c=setTimeout(()=>m(!0),Le);return()=>clearTimeout(c)},[]),n.useEffect(()=>{var c;(c=l.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||d.isPending||(N(null),d.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 de){x(`Already removed ${r}`,"info"),i();return}N(c instanceof Error?c.message:"Remove failed")}}))},[u,a.id,r,d,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:l,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||d.isPending,className:"btn btn-danger-solid btn-touch",children:d.isPending?"Removing…":"Remove"})]})]})})}function Me(t){if(t.filename)return t.filename;if(t.path){const a=t.path.split("/").pop();return a||t.path}return t.id}function tt(){const{id:t}=ue(),a=Z(i=>i.getActiveVault()),r=me(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(ze,{}):r.isError?e.jsx(qe,{error:r.error}):r.data?e.jsx(Ue,{note:r.data}):e.jsx(We,{id:t??""})]}):e.jsx(fe,{to:"/",replace:!0})}function S(t){return{content:t.content??"",path:t.path??"",tags:[...t.tags??[]]}}function Ue({note:t}){const a=pe(),r=J(s=>s.push),i=Y(s=>s.on),x=Y(s=>s.setOn),d=n.useRef(Z.getState().activeVaultId).current,u=n.useRef(Fe()).current,m=n.useMemo(()=>Ee(t),[t]),[f,N]=n.useState(()=>S(t)),[l,g]=n.useState(()=>S(t)),[c,k]=n.useState(()=>{if(!d)return null;const s=ge(d,t.id);return!s||be(s.body,S(t))?null:s}),[Q,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,X]=n.useState("edit"),j=ve(t.id),A=n.useRef(t),D=n.useRef(null),O=n.useRef(null),v=Re({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=l.content!==f.content||l.path!==f.path||!Ke(l.tags,f.tags),_=je(d,t.id,l,h),y=v.uploads.some(s=>s.status==="uploading"||s.status==="linking"),T=n.useCallback(({navigateToView:s})=>{if(!h||j.isPending||y)return;const o={};l.content!==f.content&&(o.content=l.content),l.path!==f.path&&(o.path=l.path);const b=Ye(f.tags,l.tags);(b.add.length||b.remove.length)&&(o.tags=b);const K=A.current.updatedAt??A.current.createdAt;K&&(o.if_updated_at=K),E(null),C(null),j.mutate(o,{onSuccess:p=>{N(S(p)),g(S(p)),A.current=p,d&&P(d,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 Ne?C(p):p instanceof I?E("Session expired. Reconnect to save."):E(p instanceof Error?p.message:"Save failed")}})},[f,l,h,j,a,t.id,y,d]),ee=n.useCallback(()=>{c&&g(c.body),k(null)},[c]),te=n.useCallback(()=>{d&&P(d,t.id),k(null)},[d,t.id]),se=n.useCallback(()=>T({navigateToView:!0}),[T]),ne=n.useCallback(()=>T({navigateToView:!1}),[T]),ae=n.useCallback(()=>{h&&confirm("Discard all edits and revert to last saved version?")&&(g(f),C(null),E(null))},[f,h]),z=n.useCallback(()=>{h&&!confirm("Discard unsaved changes?")||(_.discard(),a(`/n/${encodeURIComponent(t.id)}`))},[_,h,a,t.id]);n.useEffect(()=>{if(!h)return;const s=o=>{o.preventDefault(),o.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[h]);const W=n.useRef(i);n.useEffect(()=>{var o;const s=i&&!W.current;W.current=i,s&&((o=D.current)==null||o.focus())},[i]);const re=l.path!==f.path,ie=s=>{const o=ke(s);o&&(l.tags.includes(o)||(g(b=>({...b,tags:[...b.tags,o]})),L("")))},oe=s=>{g(o=>({...o,tags:o.tags.filter(b=>b!==s)}))},ce=l.content,q=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(H,{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(H,{isDirty:h,justSaved:M,updatedAt:t.updatedAt})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ie,{note:t}),e.jsx($e,{note:t}),e.jsxs("button",{type:"button",onClick:()=>x(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(we,{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:ae,disabled:!h||j.isPending,className:"btn btn-secondary btn-touch",children:"Revert"}),e.jsx("button",{type:"button",onClick:z,className:"btn btn-secondary btn-touch",children:"Cancel"}),e.jsx("button",{type:"button",onClick:se,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(ye,{tags:l.tags,input:Q,onInputChange:L,onAdd:ie,onRemove:oe})}),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:l.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:l.path||void 0})]}),re?e.jsx("p",{className:"mt-1 text-xs text-accent",children:"Renaming moves the note — its id may change."}):null,Se(l.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:ee,className:"focus-ring font-medium text-accent hover:underline",children:"Restore"}),e.jsx("button",{type:"button",onClick:te,className:"focus-ring text-fg-dim hover:text-danger",children:"Discard"})]})]}):null,V?e.jsx(_e,{conflict:V,onReload:()=>{d&&P(d,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:()=>X(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(Ce,{onDropFiles:v.start,className:`card min-h-0 ${q} min-w-0 ${u||R==="edit"?"":"hidden lg:block"}`,hint:G,children:e.jsx(Pe,{ref:D,value:l.content,onChange:s=>g(o=>({...o,content:s})),onSave:ne,onCancel:z,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 ${q} min-w-0 overflow-auto p-4 ${R==="preview"?"":"hidden lg:block"}`,children:e.jsx(Ae,{note:{path:l.path,content:ce},resolve:m})})]}),e.jsx(Oe,{noteId:t.id,pickerRef:O,attachments:t.attachments??[],uploads:v.uploads,onPickFiles:v.start,onCancel:v.cancel,onDismiss:v.dismiss})]})}const G=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 Oe({noteId:t,pickerRef:a,attachments:r,uploads:i,onPickFiles:x,onCancel:d,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(De,{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. ",G,"."]}),e.jsx(Te,{uploads:i,onCancel:d,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(Ve,{noteId:t,attachment:m})]})]},m.id))}):null]})}function _e({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 ze(){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 We({id:t}){return e.jsx(xe,{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 H({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 qe({error:t}){const a=t instanceof I;return e.jsx(he,{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 Ke(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 Ye(t,a){const r=new Set(t),i=new Set(a),x=a.filter(u=>!r.has(u)),d=t.filter(u=>!i.has(u));return{add:x,remove:d}}export{tt as NoteEditor};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-CzhNMQ2p.js","assets/index-N8p5fKHh.js","assets/index-eHCCOf4I.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{aj as A,b as I,aK as L,r as h,a$ as _,j as e,at as H,b0 as q,L as j,b1 as Q,b2 as z,b3 as G,b4 as F,b5 as M,am as W,b6 as J,b7 as V,b8 as X,b9 as Y,as as Z,ba as ee,bb as te,N as se,bc as ne,ae,H as N,af as re,bd as ie,aL as oe,au as B,be as le,bf as ce,bg as de,bh as ue,aA as he,bi as me,J as pe,K as xe,ak as fe,bj as $,M as D,ab as be,bk as ge,V as je,al as ye,bl as ve,bm as Ne}from"./index-N8p5fKHh.js";import{b as we,A as ke,a as Ce,N as Se,u as Ie}from"./useAttachmentUploader-FuXMSo6s.js";import{P as Re,D as Ee}from"./PinArchiveButtons-PVL_MlIF.js";import"./attachment-upload-eLoB3B2Y.js";function Te(t,s){const n=A(),a=I(c=>c.activeVaultId),i=L(),[l,r]=h.useState(!1),o=s&&!Ae(s)?s.path:void 0;return h.useEffect(()=>{if(r(!1),!n||!a||!t||!o)return;let c=!0;const u=()=>{c&&i.invalidateQueries({queryKey:["note",a,t]})},m=Pe(n,o,{onUpsert:u,onRemove:u,onStatus:p=>{c&&r(p==="open")}});return()=>{c=!1,r(!1),m()}},[n,a,t,o,i]),{isLive:l}}function Ae(t){return _(t.id)}function Pe(t,s,n){return t.subscribe({path:s},{onSnapshot:()=>{},onUpsert:()=>n.onUpsert(),onRemove:()=>n.onRemove(),onStatus:n.onStatus})}const Le=1,$e=3,Fe=1;function Me(t,s){const n=new Map,a=new Map;for(const l of s.values())for(const r of l.links??[]){if(r.sourceId===r.targetId||!s.has(r.sourceId)||!s.has(r.targetId))continue;const o=`${r.sourceId}|${r.targetId}|${r.relationship}`;n.has(o)||(n.set(o,{source:r.sourceId,target:r.targetId,relationship:r.relationship}),a.set(r.sourceId,(a.get(r.sourceId)??0)+1),a.set(r.targetId,(a.get(r.targetId)??0)+1))}return{nodes:[...s.values()].map(l=>{var r;return{id:l.id,path:l.path,tags:l.tags,summary:typeof((r=l.metadata)==null?void 0:r.summary)=="string"?l.metadata.summary:void 0,isAnchor:l.id===t,linkCount:a.get(l.id)??0}}),edges:[...n.values()]}}async function Ve(t,s,n,a){const i=new Map;i.set(t.id,t);let l=[t];for(let r=1;r<=s;r++){const o=new Set;for(const m of l)for(const p of m.links??[]){const f=p.sourceId===m.id?p.targetId:p.sourceId;f!==m.id&&(i.has(f)||o.add(f))}if(o.size===0)break;const c=await Promise.all([...o].map(m=>n(m).catch(()=>null)));if(a!=null&&a.cancelled)return i;const u=[];for(const m of c)m&&!i.has(m.id)&&(i.set(m.id,m),u.push(m));l=u}return i}function Be(t,s,n){const[a,i]=h.useState(null),[l,r]=h.useState(!1);return h.useEffect(()=>{if(!t||!s){i(null),r(!1);return}const o={cancelled:!1};return r(!0),Ve(s,n,c=>t.getNote(c,{includeLinks:!0}),o).then(c=>{o.cancelled||(i(Me(s.id,c)),r(!1))}).catch(()=>{o.cancelled||r(!1)}),()=>{o.cancelled=!0}},[t,s,n]),{data:a,isLoading:l}}const De=h.lazy(()=>z(()=>import("./react-force-graph-2d-CzhNMQ2p.js"),__vite__mapDeps([0,1,2])));function Oe({anchor:t}){const[s,n]=h.useState(!0),[a,i]=h.useState(Fe),l=A(),{data:r,isLoading:o}=Be(l,s?t:void 0,a);return e.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[e.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(c=>!c),"aria-expanded":s,className:"font-serif text-xl text-fg hover:text-accent",children:[s?"▾":"▸"," Neighborhood"]}),s&&r?e.jsxs("span",{className:"text-xs text-fg-dim",children:[r.nodes.length," ",r.nodes.length===1?"note":"notes"]}):null]}),s?e.jsx(Ue,{depth:a,onChange:i}):null]}),s?e.jsx(_e,{data:r,isLoading:o}):null]})}function Ue({depth:t,onChange:s}){const n=[];for(let a=Le;a<=$e;a++)n.push(a);return e.jsxs("fieldset",{className:"flex items-center gap-1 text-xs text-fg-dim",children:[e.jsx("legend",{className:"mr-1 inline-block",children:"Hops"}),n.map(a=>e.jsx("button",{type:"button","aria-pressed":a===t,onClick:()=>s(a),className:a===t?"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:a},a))]})}function _e({data:t,isLoading:s}){const[n,a]=h.useState(null),i=h.useRef(null);if(h.useEffect(()=>{n&&t&&!t.nodes.some(u=>u.id===n)&&a(null)},[t,n]),!t&&s)return e.jsx(K,{});if(!t)return null;if(t.nodes.length<=1)return e.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=t.nodes.filter(u=>!u.isAnchor),r=n?t.nodes.find(u=>u.id===n)??null:null,o=u=>{i.current=document.activeElement??null,a(u)},c=u=>{var m,p;a(null),u!=null&&u.restoreFocus&&((p=(m=i.current)==null?void 0:m.focus)==null||p.call(m))};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{data:t,onSelect:o}),r?e.jsx(Ke,{node:r,onClose:c},r.id):null,e.jsx(He,{neighbors:l,selectedId:n,onSelect:o})]})}function He({neighbors:t,selectedId:s,onSelect:n}){return t.length===0?null:e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"eyebrow mb-2",children:"Neighbors"}),e.jsx("ul",{className:"flex flex-wrap gap-2",children:t.map(a=>{const i=Q(a.path??a.id);return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>n(a.id),"aria-haspopup":"dialog","aria-pressed":s===a.id,"aria-label":`Preview ${i}`,className:`btn btn-sm btn-touch max-w-full ${s===a.id?"btn-primary":"btn-secondary"}`,children:e.jsx("span",{className:"truncate",children:i})})},a.id)})})]})}function Ke({node:t,onClose:s}){var r;const n=H(t.id),a=h.useRef(null);h.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]);const i=q({id:t.id,path:t.path,content:(r=n.data)==null?void 0:r.content}),l=Qe(n.data);return e.jsxs("div",{role:"dialog",ref:a,"aria-label":"Note preview",tabIndex:-1,"data-testid":"neighbor-preview",onKeyDown:o=>{o.key==="Escape"&&s({restoreFocus:!0})},onBlur:o=>{o.currentTarget.contains(o.relatedTarget)||s()},className:"focus-ring card mt-3 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h3",{className:"min-w-0 truncate font-serif text-lg text-fg",children:i}),e.jsx("button",{type:"button",onClick:()=>s({restoreFocus:!0}),"aria-label":"Close preview",className:"shrink-0 text-fg-dim hover:text-accent",children:"✕"})]}),t.tags&&t.tags.length>0?e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:t.tags.map(o=>e.jsxs("span",{className:"chip chip-tag max-w-full break-all",children:["#",o]},o))}):null,e.jsx(qe,{isPaused:n.fetchStatus==="paused",isPending:n.isPending,isError:n.isError,snippet:l}),e.jsx("div",{className:"mt-3",children:e.jsx(j,{to:`/n/${encodeURIComponent(t.id)}`,className:"btn btn-primary btn-touch",children:"Open note"})})]})}function qe({isPaused:t,isPending:s,isError:n,snippet:a}){return t&&s?e.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Preview unavailable offline."}):s?e.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Loading preview…"}):n?e.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"Couldn't load preview."}):a?e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:a}):e.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"No preview text."})}function Qe(t){if(!t)return null;const s=(t.preview??G(t.content??"")).trim();return s?s.length>200?`${s.slice(0,200).trimEnd()}…`:s:null}function K(){return e.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function ze({data:t,onSelect:s}){const n=h.useRef(null),[a,i]=h.useState({w:600,h:384});h.useEffect(()=>{const r=n.current;if(!r)return;const o=()=>{const u=r.getBoundingClientRect();i({w:Math.max(320,Math.floor(u.width)),h:384})};o();const c=new ResizeObserver(o);return c.observe(r),()=>c.disconnect()},[]);const l=h.useMemo(()=>({nodes:t.nodes.map(r=>({...r})),links:t.edges.map(r=>({source:r.source,target:r.target,rel:r.relationship}))}),[t]);return e.jsx("div",{ref:n,"data-testid":"neighborhood-graph-canvas",className:"overflow-hidden rounded-md border border-border bg-card",children:e.jsx(h.Suspense,{fallback:e.jsx(K,{}),children:e.jsx(De,{graphData:l,width:a.w,height:a.h,nodeLabel:r=>Ge(r),nodeVal:r=>{const o=r;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:r=>r.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:r=>{s(r.id)}})})})}function Ge(t){const s=[t.path??t.id];return t.tags&&t.tags.length>0&&s.push(`tags: ${t.tags.join(", ")}`),t.summary&&s.push(t.summary),s.join(`
|
|
3
|
-
`)}function We({note:t}){const[s,n]=h.useState(!1),a=I(i=>i.activeVaultId);return e.jsxs("section",{className:"mt-6 border-t border-border pt-4",children:[e.jsx("button",{type:"button",className:"btn btn-secondary","aria-expanded":s,onClick:()=>n(!s),children:"Version history"}),s&&a?e.jsx(Je,{note:t,vaultId:a},`${a}:${t.id}`):null]})}function Je({note:t,vaultId:s}){var E,T;const n=A(),a=L(),[i,l]=h.useState(0),[r,o]=h.useState(null),[c,u]=h.useState(null),[m,p]=h.useState(!1),[f,g]=h.useState(null),b=F({queryKey:["history",s,t.id,i],queryFn:()=>n.listHistory(t.id,i),enabled:!!n,retry:!1}),x=F({queryKey:["historyVersion",s,t.id,r],queryFn:()=>n.readHistory(t.id,V(r)),enabled:!!n&&!!r,retry:!1}),y=M({networkMode:"always",retry:!1,mutationFn:()=>n.getNote(t.id),onSuccess:d=>{u(d),p(!1),g(null)}}),w=M({networkMode:"always",retry:!1,mutationFn:()=>{if(!J.isOnline())throw new Error("Connect to the vault before restoring.");if(!n||!r||!(c!=null&&c.updatedAt))throw new Error("Read the current note before restoring.");return n.restoreHistory(t.id,V(r),c.updatedAt)},onSuccess:d=>{a.invalidateQueries({queryKey:["note",s]});for(const v of["history","notes","notesForDateViews","viewList","tags","vaultInfo"])a.invalidateQueries({queryKey:[v,s]});u(d),p(!1),g("Version restored. The change you replaced is retained in history under the vault’s retention policy.")},onError:d=>{p(!1),u(null),g(d instanceof W?"The server refused this restore. The note may have changed or the selected history may be unavailable. Read the current note again and review the comparison.":`Restore could not be confirmed. Read the current note again before retrying. ${d.message}`)}}),P=d=>{o(d),u(null),p(!1),g(null),y.mutate()},k=w.isPending||y.isPending,R=!!x.data&&!x.isFetching&&!x.isError&&!y.isError&&x.data.content!==null&&x.data.encoding!=="overflow"&&!!(c!=null&&c.updatedAt)&&!k;return e.jsxs("div",{className:"mt-4 space-y-4","aria-label":"Note version history",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"History contains retained snapshots, not every keystroke. Older versions may have been pruned. Imported snapshots are labeled separately. Recovery needs a connection to the vault."}),n?null:e.jsx("p",{role:"alert",children:"Connect to this vault to read history."}),b.fetchStatus==="paused"?e.jsx("p",{role:"alert",children:"Connect to this vault to read history. Offline copies do not include version history."}):null,b.isPending&&n&&b.fetchStatus!=="paused"?e.jsx("output",{children:"Loading history…"}):null,b.isError?e.jsxs("div",{role:"alert",children:[e.jsx("p",{children:"History is unavailable. This server may not support it, the note may be unavailable, or your connection/access may need attention. This is not an empty-history result."}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>b.refetch(),children:"Retry history"})]}):null,((E=b.data)==null?void 0:E.versions.length)===0?e.jsx("p",{children:"No retained versions on this page. Earlier edits may predate history capture or have been pruned."}):null,e.jsx("ul",{className:"space-y-2",children:(T=b.data)==null?void 0:T.versions.map((d,v)=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-secondary text-left",disabled:w.isPending,onClick:()=>P(d),children:[d.origin==="git-import"?`Imported snapshot ${d.import_ix}`:`Version ${d.version_ix}`," ","· ",d.superseded_at," · ",d.op]})},`${d.origin??"native"}:${d.import_ix??d.version_ix}:${v}`))}),b.data?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:i===0||k,onClick:()=>l(Math.max(0,i-50)),children:"Newer"}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:i+50>=b.data.total||k,onClick:()=>l(i+50),children:"Older"})]}):null,r?e.jsxs("div",{className:"space-y-3",children:[x.isPending||y.isPending?e.jsx("output",{children:"Loading comparison…"}):null,x.isError?e.jsx("p",{role:"alert",children:"This version could not be read. It may have been pruned, exceed history limits, or have damaged stored content. Choose another version."}):null,y.isError?e.jsx("p",{role:"alert",children:"The current note could not be read. Restore is disabled."}):null,x.data&&c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(O,{title:"Selected version",content:x.data.content,metadata:x.data.metadata,extension:x.data.extension}),e.jsx(O,{title:"Current note when reviewed",content:c.content,metadata:c.metadata,extension:c.extension})]}),x.data.content===null?e.jsx("p",{role:"alert",children:"This version records a change but has no recoverable content. It cannot be restored."}):null,t.updatedAt!==c.updatedAt?e.jsx("output",{children:"The displayed note has changed since this comparison. Refresh the comparison before deciding."}):null,e.jsx("p",{className:"text-sm text-fg-muted",children:"Restore replaces content, metadata and file type. It keeps the current path and tags. It creates a new recoverable change; it does not erase history."})]}):null,e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:k,onClick:()=>{u(null),p(!1),y.mutate()},children:"Read current note again"}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:!R,onClick:()=>p(!0),children:"Restore selected version…"}),m?e.jsxs("div",{className:"rounded border border-border p-4",children:[e.jsx("p",{children:"Replace the current note with this version? A newer edit will stop the restore."}),e.jsx("button",{type:"button",className:"btn btn-primary",disabled:!R,onClick:()=>w.mutate(),children:"Confirm restore"}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:w.isPending,onClick:()=>p(!1),children:"Cancel"})]}):null]}):null,f?e.jsx("output",{children:f}):null]})}function O({title:t,content:s,metadata:n,extension:a}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold",children:t}),e.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap rounded border border-border p-3 text-sm",children:s??"Content unavailable"}),e.jsxs("details",{children:[e.jsx("summary",{children:"Metadata and file type"}),e.jsx("pre",{className:"overflow-auto text-sm",children:JSON.stringify({extension:a,metadata:n},null,2)})]})]})}function Xe({content:t,attachments:s,onRetry:n,retrying:a=!1}){const i={content:t,attachments:s},l=X(i);if(l==="pending"){const r=Y(i);return e.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:[e.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 animate-pulse rounded-full bg-sky-400"}),"Transcribing…",r?e.jsxs("span",{className:"text-sky-300/80",children:["part ",Math.min(r.done+1,r.total)," of ",r.total]}):null]})}return l==="failed"?e.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:[e.jsx("span",{children:"Transcription unavailable — open the audio below and add a note by hand."}),n?e.jsx("button",{type:"button",onClick:n,disabled:a,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:a?"Retrying…":"Retry"}):null]}):l==="voice-limit"?e.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 wt(){const{id:t}=Z(),s=I(i=>i.getActiveVault()),n=ee(),a=H(t);return Te(t,a.data),h.useEffect(()=>{s&&t&&te(s.id,t)},[s,t]),s?e.jsxs("div",{className:"page",children:[e.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:e.jsx(j,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),a.isPending?e.jsx(mt,{}):a.data?e.jsxs(e.Fragment,{children:[a.isError?e.jsx(ae,{}):null,e.jsx(Ye,{note:a.data,cacheId:t})]}):a.isError?e.jsx(gt,{error:a.error,retry:()=>a.refetch()}):e.jsx(bt,{id:t??""})]}):e.jsx(se,{to:ne("/",`${n.pathname}${n.search}`),replace:!0})}function Ye({note:t,cacheId:s}){var E,T;const n=I(d=>d.getActiveVault()),{roles:a}=re((n==null?void 0:n.id)??null),i=ie(),{mirror:l,isOnline:r}=oe(),o=Ze(t,s),c=l.state==="offline",u=t.contentEvicted===!0,m=h.useMemo(()=>we(t),[t]),p=B(d=>d.on),f=B(d=>d.setOn);h.useEffect(()=>{if(!p)return;const d=v=>{v.key==="Escape"&&f(!1)};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[p,f]);const g=t.path??t.id,b=le(t.content),x=b!==null&&!ce(b,t)?b:null,y=x!==null?{kind:"title",text:x}:t.path?de(t.path):{kind:"title",text:t.id},w=h.useMemo(()=>x!==null?{...t,content:ue(t.content??"")}:t,[t,x]),P=typeof((E=t.metadata)==null?void 0:E.summary)=="string"?t.metadata.summary:null,k=h.useMemo(()=>(t.links??[]).filter(d=>d.targetId===t.id&&d.sourceId!==t.id&&d.sourceNote),[t]),R=h.useMemo(()=>{const d=new Set,v=[];for(const C of t.links??[])C.sourceId!==t.id||C.targetId===t.id||C.targetNote&&(d.has(C.targetId)||(d.add(C.targetId),v.push(C)));return v},[t]);return e.jsxs("article",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("header",{className:"mb-8 border-b border-border pb-5",children:[e.jsx("h1",{className:y.kind==="timestamp"?"page-title title-timestamp":"page-title",children:y.text}),c?e.jsx(xt,{}):null,t.tags&&t.tags.length>0?e.jsx(at,{tags:t.tags}):null,P?e.jsx("p",{className:"mt-3 text-fg-muted",children:P}):null,e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(j,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit"}),r&&!u&&!_(t.id)?e.jsx(ke,{label:"Attach file",className:"btn btn-secondary btn-touch",onPickFiles:o.start}):null,e.jsx(Re,{note:t,keyboard:!0}),e.jsx(Ee,{note:t}),e.jsxs("button",{type:"button",onClick:()=>f(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(he,{width:16,height:16}),"Focus"]}),me(t,a.view)?e.jsx(j,{to:`/views/${encodeURIComponent(t.id)}`,className:"btn btn-secondary btn-touch",children:"Open as view"}):null]}),o.uploads.length>0?e.jsx("div",{className:"mt-3",children:e.jsx(Ce,{uploads:o.uploads,onCancel:o.cancel,onDismiss:o.dismiss})}):null,e.jsx(it,{value:g,isPath:!!t.path}),e.jsx(We,{note:t})]}),e.jsx(Xe,{content:t.content??"",attachments:t.attachments,onRetry:()=>i.mutate({cacheId:s??t.id,serverId:t.id}),retrying:i.isPending}),u?e.jsx(ft,{preview:t.preview}):(T=w.content)!=null&&T.trim()?e.jsx(Se,{note:w,resolve:m}):x===null?e.jsx(pt,{noteId:t.id}):null,t.attachments&&t.attachments.length>0?e.jsxs("section",{className:"mt-10 border-t border-border pt-6",children:[e.jsx("h2",{className:"mb-3 font-serif text-xl",children:"Attachments"}),e.jsx("div",{className:"space-y-6",children:t.attachments.map(d=>e.jsx(lt,{attachment:d},d.id))})]}):null,e.jsx(Oe,{anchor:t})]}),e.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[e.jsx(tt,{note:t}),R.length>0?e.jsx(U,{title:"Outbound",links:R,peer:"target"}):null,k.length>0?e.jsx(U,{title:"Inbound",links:k,peer:"source"}):null]})]})}function Ze(t,s){const n=A(),a=I(o=>o.activeVaultId),i=L(),l=fe(o=>o.push),r=Ie({noteId:t.id,onInsert:()=>{},onLinked:async o=>{const c=["note",a,s??t.id],u=i.getQueryData(c)??t;try{if(!n)throw new Error("No active vault");const m={append:et(u.content)+o};await n.updateNote(t.id,m),l("Attachment added","success")}catch{l("Attached, but couldn't add it to the note text.","error")}await i.invalidateQueries({queryKey:c,exact:!0}),i.invalidateQueries({queryKey:["notes",a]})},onError:o=>l(o,"error")});return{...r,uploads:r.uploads.filter(o=>o.status!=="done")}}function et(t){return t===""||t!=null&&t.endsWith(`
|
|
4
|
-
|
|
5
|
-
`)?"":t!=null&&t.endsWith(`
|
|
6
|
-
`)?`
|
|
7
|
-
`:`
|
|
8
|
-
|
|
9
|
-
`}function tt({note:t}){const s=t.createdAt,n=t.updatedAt,a=Object.entries(t.metadata??{}).filter(([i])=>i!=="summary");return e.jsxs("section",{className:"card shadow-soft p-4",children:[e.jsx("h2",{className:"eyebrow mb-2",children:"Metadata"}),e.jsxs("dl",{className:"space-y-1.5 text-sm",children:[t.path?e.jsx(S,{label:"Title",value:e.jsx("span",{className:"font-mono text-xs break-all",children:t.path})}):null,e.jsx(S,{label:"ID",value:e.jsx("span",{className:"font-mono text-xs break-all",children:t.id})}),e.jsx(S,{label:"Created",value:e.jsx("time",{title:s,children:D(s)})}),n?e.jsx(S,{label:"Updated",value:e.jsx("time",{title:n,children:D(n)})}):null,t.path?e.jsx(S,{label:"Path",value:e.jsx(be,{value:t.path,label:"note path",className:"mt-1"})}):null,a.map(([i,l])=>e.jsx(S,{label:i,value:e.jsx("span",{className:"break-all text-fg-muted",children:String(l)})},i))]}),e.jsx(st,{noteId:t.id}),t.path?e.jsx(nt,{path:t.path}):null,e.jsx(ge,{note:t,variant:"detail",className:"mt-3"})]})}function st({noteId:t}){const s=I(l=>l.getActiveVault()),{copied:n,copy:a}=$(),i=s?ve(s):"";return i?e.jsx("button",{type:"button",onClick:()=>a(Ne(i,t)),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy a shareable link to this note",children:n?"Copied ✓":"Copy link"}):null}function nt({path:t}){const{copied:s,copy:n}=$();return e.jsx("button",{type:"button",onClick:()=>n(t),className:"btn btn-secondary btn-touch mt-3 w-full","aria-label":"Copy reference to this note",children:s?"Copied ✓":"Copy reference"})}function S({label:t,value:s}){return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("dt",{className:"eyebrow",children:t}),e.jsx("dd",{children:s})]})}function at({tags:t}){return e.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":"Tags",children:t.map(s=>e.jsxs(j,{to:`/tags/${encodeURIComponent(s)}`,className:"chip chip-tag focus-ring max-w-full break-all",children:["#",s]},s))})}function rt(t){return e.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",...t,children:[e.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),e.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 it({value:t,isPath:s}){const{copied:n,copy:a}=$();return e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-label":s?"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:[e.jsx(rt,{className:"shrink-0 opacity-70 transition-opacity group-hover:opacity-100"}),e.jsx("span",{className:"min-w-0 truncate font-mono text-xs",children:t}),n?e.jsx("span",{className:"shrink-0 text-xs text-fg-muted",children:"Copied"}):null]})}function U({title:t,links:s,peer:n}){return e.jsxs("section",{className:"card shadow-soft p-4",children:[e.jsxs("h2",{className:"eyebrow mb-2 tabular-nums",children:[t," (",s.length,")"]}),e.jsx("ul",{className:"space-y-1.5",children:s.map(a=>{var o;const i=n==="source"?a.sourceNote:a.targetNote;if(!i)return null;const l=i.path??i.id,r=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return e.jsx("li",{children:e.jsxs(j,{to:`/n/${encodeURIComponent(i.id)}`,className:"block rounded px-1 py-0.5 hover:bg-bg/50",children:[e.jsx("div",{className:"truncate font-mono text-xs text-fg-muted hover:text-accent",children:l}),r?e.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:r}):null]})},`${a.sourceId}->${a.targetId}:${a.relationship}`)})})]})}function ot(t){var n;const s=(n=t.path)==null?void 0:n.replace(/^\/+/,"");return{filename:t.filename??(s?s.split("/").pop():void 0),url:t.url??(s?`/api/storage/${s}`:void 0)}}function lt({attachment:t}){const{filename:s,url:n}=ot(t);if(!s||!n)return e.jsx("figure",{className:"card shadow-soft p-3",children:e.jsx(ct,{})});const a=(t.mimeType??"").toLowerCase();return e.jsxs("figure",{className:"card shadow-soft p-3",children:[e.jsxs("figcaption",{className:"mb-2 flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"truncate font-mono text-xs text-fg-muted",children:s}),typeof t.size=="number"?e.jsx("span",{className:"shrink-0 text-xs text-fg-dim",children:ht(t.size)}):null]}),e.jsx(dt,{url:n,mime:a,filename:s})]})}function ct(){return e.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-dim","aria-busy":"true",children:[e.jsx(N,{className:"h-4 w-32"}),e.jsx("span",{children:"Processing…"})]})}function dt({url:t,mime:s,filename:n}){const a=A(),[i,l]=h.useState(null),[r,o]=h.useState(null),c=ut(s,n),u=c!=="other";if(h.useEffect(()=>{if(!u||!a)return;let p=!1,f=null;return o(null),a.fetchAttachmentBlob(t).then(g=>{p||(f=URL.createObjectURL(g),l(f))}).catch(g=>{p||o(g instanceof Error?g.message:"Failed to load attachment")}),()=>{p=!0,f&&URL.revokeObjectURL(f)}},[u,t,a]),r)return e.jsx("p",{className:"text-sm text-danger",children:r});if(u&&!i)return e.jsx(N,{className:"h-32 w-full"});const m=i??t;return c==="image"?e.jsx("img",{src:m,alt:n,className:"max-h-[32rem] rounded"}):c==="audio"?e.jsx("audio",{controls:!0,src:m,className:"w-full"}):c==="video"?e.jsx("video",{controls:!0,src:m,className:"w-full rounded"}):c==="pdf"?e.jsxs(e.Fragment,{children:[e.jsx("iframe",{src:m,title:n,className:"h-[40rem] w-full rounded border border-border"}),e.jsxs("a",{href:m,download:n,className:"mt-2 inline-block text-sm text-accent hover:underline",children:["Download ",n]})]}):e.jsxs("a",{href:m,download:n,className:"text-sm text-accent hover:underline",children:["Download ",n]})}function ut(t,s){if(t.startsWith("image/"))return"image";if(t.startsWith("audio/"))return"audio";if(t.startsWith("video/"))return"video";if(t==="application/pdf")return"pdf";const n=s.toLowerCase().split(".").pop()??"";return["png","jpg","jpeg","gif","webp","svg"].includes(n)?"image":["mp3","wav","ogg","m4a","flac"].includes(n)?"audio":["mp4","webm","mov"].includes(n)?"video":n==="pdf"?"pdf":"other"}function ht(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function mt(){return e.jsxs("div",{className:"grid gap-10 lg:grid-cols-[minmax(0,1fr)_18rem]","aria-busy":"true",children:[e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(N,{className:"h-3 w-32"}),e.jsx(N,{className:"h-8 w-2/3"}),e.jsx(N,{className:"h-4 w-full"}),e.jsx("div",{className:"mt-6 space-y-2",children:[0,1,2,3,4,5].map(t=>e.jsx(N,{className:"h-3",width:`${70+t*13%25}%`},t))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{className:"h-32"}),e.jsx(N,{className:"h-24"})]})]})}function pt({noteId:t}){return e.jsxs("p",{className:"my-8 font-serif text-lg italic text-fg-muted",children:["Nothing here yet."," ",e.jsx(j,{to:`/n/${encodeURIComponent(t)}/edit`,className:"not-italic text-accent hover:underline",children:"Start writing →"})]})}function xt(){return e.jsx("p",{className:"mt-2",children:e.jsx("span",{className:"chip bg-bg-soft text-fg-muted",title:"Served from your offline copy",children:"Saved copy"})})}function ft({preview:t}){return e.jsxs("div",{className:"my-8",children:[t?e.jsx("p",{className:"mb-4 text-fg-muted",children:t}):null,e.jsx("p",{className:"font-serif text-lg italic text-fg-muted",children:"Connect to load this note."})]})}function bt({id:t}){return e.jsx(xe,{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(j,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function gt({error:t,retry:s}){const n=t instanceof je,a=t instanceof ye,i=n?"Session expired":a?"Note not found":"Could not load note",l=n?t.message:a?"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 e.jsx(pe,{title:i,message:e.jsxs(e.Fragment,{children:[l,n?null:e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-fg-dim hover:text-fg-muted",children:"Technical detail"}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words font-mono text-xs text-fg-dim",children:t.message})]})]}),retry:n?void 0:s,action:n?e.jsx(j,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):e.jsx(j,{to:"/notes",className:"btn btn-secondary btn-touch",children:"Back to notes"})})}export{wt as NoteView};
|