@openparachute/app 0.22.15-rc.4 → 0.22.15-rc.6
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/CHANGELOG.md +9 -0
- package/dist/.parachute/info +1 -1
- package/dist/assets/Account-K_xK2X9B.js +1 -0
- package/dist/assets/{Activity-K74lz7be.js → Activity-BL33NLB_.js} +1 -1
- package/dist/assets/AddVault-CTe-mwRH.js +1 -0
- package/dist/assets/{AddVaultChooser-BeAu_6Sf.js → AddVaultChooser-BPJV1MeI.js} +1 -1
- package/dist/assets/AddVaultCreate-DI73o6uE.js +1 -0
- package/dist/assets/{Calendar-BdnpLRbx.js → Calendar-CaIuHTLe.js} +1 -1
- package/dist/assets/CheckEmail-CqFmFCks.js +1 -0
- package/dist/assets/ConnectAI-DHagDo44.js +1 -0
- package/dist/assets/{DayView-RBUIG0ht.js → DayView-GOUuDzfi.js} +1 -1
- package/dist/assets/Export-YCQBcJkP.js +1 -0
- package/dist/assets/{Import-C1CAy6gk.js → Import-kCFoVM-8.js} +1 -1
- package/dist/assets/{NoteEditor-BiF7u2II.js → NoteEditor-BcJb5-4o.js} +1 -1
- package/dist/assets/{NoteNew-EDC5DN9z.js → NoteNew-BHjrbBq2.js} +2 -2
- package/dist/assets/{NoteRenderer-CVHb_hev.js → NoteRenderer-CN_XExeX.js} +1 -1
- package/dist/assets/NoteView-DtbLplBa.js +3 -0
- package/dist/assets/{OAuthCallback-DZfGvDHw.js → OAuthCallback-BPLeIM87.js} +1 -1
- package/dist/assets/{PinArchiveButtons-CFvL4XBO.js → PinArchiveButtons-z6H_YGSc.js} +1 -1
- package/dist/assets/{Settings-CN7EqJHc.js → Settings-Ck3g9l6D.js} +1 -1
- package/dist/assets/{TagPage-B1FYKxLN.js → TagPage-oQqARXqf.js} +1 -1
- package/dist/assets/{TagSchemaEditor-CMCwC2U0.js → TagSchemaEditor-D_LYDGRK.js} +1 -1
- package/dist/assets/Tags-CyP_yKov.js +1 -0
- package/dist/assets/{VaultGraph-3A0kx4wI.js → VaultGraph-Di0B4NaD.js} +2 -2
- package/dist/assets/Vaults-BMJUdDaM.js +1 -0
- package/dist/assets/{ViewNew-KOli1zPy.js → ViewNew-Um87-wU2.js} +1 -1
- package/dist/assets/ViewSurface-D8xrFE_I.js +1 -0
- package/dist/assets/Welcome-Cb7SFRmw.js +1 -0
- package/dist/assets/{WizardShell-dR1ElLgB.js → WizardShell-CDZWRkFh.js} +1 -1
- package/dist/assets/{attachment-upload-Dt0I8iWK.js → attachment-upload-B0biPzAc.js} +2 -2
- package/dist/assets/history-B2ZH4y8B.js +1 -0
- package/dist/assets/index-CkXqzhj_.js +66 -0
- package/dist/assets/{provenance-Hx5MxK3k.js → provenance-DnIXLZVC.js} +1 -1
- package/dist/assets/{react-force-graph-2d-B2Gxxhfm.js → react-force-graph-2d-C179xgl7.js} +1 -1
- package/dist/assets/{transcribe-default-DKody_lk.js → transcribe-default-Z7qqgq1r.js} +1 -1
- package/dist/assets/{useAttachmentUploader-CwUuyNf7.js → useAttachmentUploader-DNhr7cOE.js} +1 -1
- 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/Account-D0h6O8Fw.js +0 -1
- package/dist/assets/AddVault-DRwBvbhl.js +0 -1
- package/dist/assets/AddVaultCreate-BCV0cbE-.js +0 -1
- package/dist/assets/CheckEmail-DDbWzG2r.js +0 -1
- package/dist/assets/ConnectAI-Dcn5RhIk.js +0 -1
- package/dist/assets/Export-Bs1BQGwv.js +0 -1
- package/dist/assets/NoteView-3dqZLg5S.js +0 -3
- package/dist/assets/Tags-DcbmSGY5.js +0 -1
- package/dist/assets/Vaults-DM198kBa.js +0 -1
- package/dist/assets/ViewSurface-D0oPkxKC.js +0 -1
- package/dist/assets/Welcome-DhYNT96e.js +0 -1
- package/dist/assets/history-CFoof_sA.js +0 -1
- package/dist/assets/index-GcTfNe1b.js +0 -66
- package/dist/assets/mcp-address-C02VbHLL.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-force-graph-2d-B2Gxxhfm.js","assets/index-GcTfNe1b.js","assets/index-D-RN2HHm.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{ah as T,u as R,aI as D,r as d,b0 as q,j as e,ar as U,b1 as K,L as y,b2 as G,b3 as z,b4 as Q,b5 as A,b6 as F,ak as W,b7 as J,b8 as $,b9 as X,ba as Y,aq as Z,bb as ee,bc as te,N as se,bd as ne,ac as re,G as N,ad as ae,be as ie,aJ as oe,as as M,bf as le,bg as ce,bh as de,bi as ue,ay as he,bj as me,H as xe,J as pe,bk as L,K as V,a9 as fe,bl as be,V as ge,aj as je,bm as ye,bn as ve}from"./index-GcTfNe1b.js";import{P as Ne,D as we}from"./PinArchiveButtons-CFvL4XBO.js";import{b as ke,N as Ce}from"./NoteRenderer-CVHb_hev.js";function Se(t,s){const n=T(),r=R(c=>c.activeVaultId),i=D(),[l,a]=d.useState(!1),o=s&&!Ie(s)?s.path:void 0;return d.useEffect(()=>{if(a(!1),!n||!r||!t||!o)return;let c=!0;const u=()=>{c&&i.invalidateQueries({queryKey:["note",r,t]})},h=Re(n,o,{onUpsert:u,onRemove:u,onStatus:m=>{c&&a(m==="open")}});return()=>{c=!1,a(!1),h()}},[n,r,t,o,i]),{isLive:l}}function Ie(t){return q(t.id)}function Re(t,s,n){return t.subscribe({path:s},{onSnapshot:()=>{},onUpsert:()=>n.onUpsert(),onRemove:()=>n.onRemove(),onStatus:n.onStatus})}const Ee=1,Te=3,Pe=1;function Le(t,s){const n=new Map,r=new Map;for(const l of s.values())for(const a of l.links??[]){if(a.sourceId===a.targetId||!s.has(a.sourceId)||!s.has(a.targetId))continue;const o=`${a.sourceId}|${a.targetId}|${a.relationship}`;n.has(o)||(n.set(o,{source:a.sourceId,target:a.targetId,relationship:a.relationship}),r.set(a.sourceId,(r.get(a.sourceId)??0)+1),r.set(a.targetId,(r.get(a.targetId)??0)+1))}return{nodes:[...s.values()].map(l=>{var a;return{id:l.id,path:l.path,tags:l.tags,summary:typeof((a=l.metadata)==null?void 0:a.summary)=="string"?l.metadata.summary:void 0,isAnchor:l.id===t,linkCount:r.get(l.id)??0}}),edges:[...n.values()]}}async function Ae(t,s,n,r){const i=new Map;i.set(t.id,t);let l=[t];for(let a=1;a<=s;a++){const o=new Set;for(const h of l)for(const m of h.links??[]){const j=m.sourceId===h.id?m.targetId:m.sourceId;j!==h.id&&(i.has(j)||o.add(j))}if(o.size===0)break;const c=await Promise.all([...o].map(h=>n(h).catch(()=>null)));if(r!=null&&r.cancelled)return i;const u=[];for(const h of c)h&&!i.has(h.id)&&(i.set(h.id,h),u.push(h));l=u}return i}function Fe(t,s,n){const[r,i]=d.useState(null),[l,a]=d.useState(!1);return d.useEffect(()=>{if(!t||!s){i(null),a(!1);return}const o={cancelled:!1};return a(!0),Ae(s,n,c=>t.getNote(c,{includeLinks:!0}),o).then(c=>{o.cancelled||(i(Le(s.id,c)),a(!1))}).catch(()=>{o.cancelled||a(!1)}),()=>{o.cancelled=!0}},[t,s,n]),{data:r,isLoading:l}}const $e=d.lazy(()=>z(()=>import("./react-force-graph-2d-B2Gxxhfm.js"),__vite__mapDeps([0,1,2])));function Me({anchor:t}){const[s,n]=d.useState(!0),[r,i]=d.useState(Pe),l=T(),{data:a,isLoading:o}=Fe(l,s?t:void 0,r);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&&a?e.jsxs("span",{className:"text-xs text-fg-dim",children:[a.nodes.length," ",a.nodes.length===1?"note":"notes"]}):null]}),s?e.jsx(Ve,{depth:r,onChange:i}):null]}),s?e.jsx(Be,{data:a,isLoading:o}):null]})}function Ve({depth:t,onChange:s}){const n=[];for(let r=Ee;r<=Te;r++)n.push(r);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(r=>e.jsx("button",{type:"button","aria-pressed":r===t,onClick:()=>s(r),className:r===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:r},r))]})}function Be({data:t,isLoading:s}){const[n,r]=d.useState(null),i=d.useRef(null);if(d.useEffect(()=>{n&&t&&!t.nodes.some(u=>u.id===n)&&r(null)},[t,n]),!t&&s)return e.jsx(_,{});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),a=n?t.nodes.find(u=>u.id===n)??null:null,o=u=>{i.current=document.activeElement??null,r(u)},c=u=>{var h,m;r(null),u!=null&&u.restoreFocus&&((m=(h=i.current)==null?void 0:h.focus)==null||m.call(h))};return e.jsxs(e.Fragment,{children:[e.jsx(He,{data:t,onSelect:o}),a?e.jsx(De,{node:a,onClose:c},a.id):null,e.jsx(Oe,{neighbors:l,selectedId:n,onSelect:o})]})}function Oe({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(r=>{const i=G(r.path??r.id);return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>n(r.id),"aria-haspopup":"dialog","aria-pressed":s===r.id,"aria-label":`Preview ${i}`,className:`btn btn-sm btn-touch max-w-full ${s===r.id?"btn-primary":"btn-secondary"}`,children:e.jsx("span",{className:"truncate",children:i})})},r.id)})})]})}function De({node:t,onClose:s}){var a;const n=U(t.id),r=d.useRef(null);d.useEffect(()=>{var o;(o=r.current)==null||o.focus()},[]);const i=K({id:t.id,path:t.path,content:(a=n.data)==null?void 0:a.content}),l=_e(n.data);return e.jsxs("div",{role:"dialog",ref:r,"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(Ue,{isPaused:n.fetchStatus==="paused",isPending:n.isPending,isError:n.isError,snippet:l}),e.jsx("div",{className:"mt-3",children:e.jsx(y,{to:`/n/${encodeURIComponent(t.id)}`,className:"btn btn-primary btn-touch",children:"Open note"})})]})}function Ue({isPaused:t,isPending:s,isError:n,snippet:r}){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."}):r?e.jsx("p",{className:"mt-2 text-sm text-fg-muted",children:r}):e.jsx("p",{className:"mt-2 text-sm text-fg-dim",children:"No preview text."})}function _e(t){if(!t)return null;const s=(t.preview??Q(t.content??"")).trim();return s?s.length>200?`${s.slice(0,200).trimEnd()}…`:s:null}function _(){return e.jsx("div",{"aria-busy":"true",className:"h-[24rem] w-full animate-pulse rounded-md border border-border bg-card"})}function He({data:t,onSelect:s}){const n=d.useRef(null),[r,i]=d.useState({w:600,h:384});d.useEffect(()=>{const a=n.current;if(!a)return;const o=()=>{const u=a.getBoundingClientRect();i({w:Math.max(320,Math.floor(u.width)),h:384})};o();const c=new ResizeObserver(o);return c.observe(a),()=>c.disconnect()},[]);const l=d.useMemo(()=>({nodes:t.nodes.map(a=>({...a})),links:t.edges.map(a=>({source:a.source,target:a.target,rel:a.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(d.Suspense,{fallback:e.jsx(_,{}),children:e.jsx($e,{graphData:l,width:r.w,height:r.h,nodeLabel:a=>qe(a),nodeVal:a=>{const o=a;return o.isAnchor?8:3+Math.min(o.linkCount,8)},nodeColor:a=>a.isAnchor?"#c9b170":"#8a9a7a",linkColor:()=>"rgba(160, 160, 160, 0.4)",linkDirectionalArrowLength:3,linkDirectionalArrowRelPos:1,cooldownTicks:80,onNodeClick:a=>{s(a.id)}})})})}function qe(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 Ke({note:t}){const[s,n]=d.useState(!1),r=R(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&&r?e.jsx(Ge,{note:t,vaultId:r},`${r}:${t.id}`):null]})}function Ge({note:t,vaultId:s}){var p,C;const n=T(),r=D(),[i,l]=d.useState(0),[a,o]=d.useState(null),[c,u]=d.useState(null),[h,m]=d.useState(!1),[j,b]=d.useState(null),f=A({queryKey:["history",s,t.id,i],queryFn:()=>n.listHistory(t.id,i),enabled:!!n,retry:!1}),g=A({queryKey:["historyVersion",s,t.id,a],queryFn:()=>n.readHistory(t.id,$(a)),enabled:!!n&&!!a,retry:!1}),v=F({networkMode:"always",retry:!1,mutationFn:()=>n.getNote(t.id),onSuccess:x=>{u(x),m(!1),b(null)}}),w=F({networkMode:"always",retry:!1,mutationFn:()=>{if(!J.isOnline())throw new Error("Connect to the vault before restoring.");if(!n||!a||!(c!=null&&c.updatedAt))throw new Error("Read the current note before restoring.");return n.restoreHistory(t.id,$(a),c.updatedAt)},onSuccess:x=>{r.invalidateQueries({queryKey:["note",s]});for(const P of["history","notes","notesForDateViews","viewList","tags","vaultInfo"])r.invalidateQueries({queryKey:[P,s]});u(x),m(!1),b("Version restored. The change you replaced is retained in history under the vault’s retention policy.")},onError:x=>{m(!1),u(null),b(x 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. ${x.message}`)}}),E=x=>{o(x),u(null),m(!1),b(null),v.mutate()},k=w.isPending||v.isPending,I=!!g.data&&!g.isFetching&&!g.isError&&!v.isError&&g.data.content!==null&&g.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."}),f.fetchStatus==="paused"?e.jsx("p",{role:"alert",children:"Connect to this vault to read history. Offline copies do not include version history."}):null,f.isPending&&n&&f.fetchStatus!=="paused"?e.jsx("output",{children:"Loading history…"}):null,f.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:()=>f.refetch(),children:"Retry history"})]}):null,((p=f.data)==null?void 0:p.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:(C=f.data)==null?void 0:C.versions.map((x,P)=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-secondary text-left",disabled:w.isPending,onClick:()=>E(x),children:[x.origin==="git-import"?`Imported snapshot ${x.import_ix}`:`Version ${x.version_ix}`," ","· ",x.superseded_at," · ",x.op]})},`${x.origin??"native"}:${x.import_ix??x.version_ix}:${P}`))}),f.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>=f.data.total||k,onClick:()=>l(i+50),children:"Older"})]}):null,a?e.jsxs("div",{className:"space-y-3",children:[g.isPending||v.isPending?e.jsx("output",{children:"Loading comparison…"}):null,g.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,v.isError?e.jsx("p",{role:"alert",children:"The current note could not be read. Restore is disabled."}):null,g.data&&c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(B,{title:"Selected version",content:g.data.content,metadata:g.data.metadata,extension:g.data.extension}),e.jsx(B,{title:"Current note when reviewed",content:c.content,metadata:c.metadata,extension:c.extension})]}),g.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),m(!1),v.mutate()},children:"Read current note again"}),e.jsx("button",{type:"button",className:"btn btn-secondary",disabled:!I,onClick:()=>m(!0),children:"Restore selected version…"}),h?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:!I,onClick:()=>w.mutate(),children:"Confirm restore"}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:w.isPending,onClick:()=>m(!1),children:"Cancel"})]}):null]}):null,j?e.jsx("output",{children:j}):null]})}function B({title:t,content:s,metadata:n,extension:r}){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:r,metadata:n},null,2)})]})]})}function ze({content:t,attachments:s,onRetry:n,retrying:r=!1}){const i={content:t,attachments:s},l=X(i);if(l==="pending"){const a=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…",a?e.jsxs("span",{className:"text-sky-300/80",children:["part ",Math.min(a.done+1,a.total)," of ",a.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:r,className:"rounded border border-amber-500/40 px-2 py-0.5 font-medium text-amber-100 hover:bg-amber-500/15 disabled:opacity-50",children:r?"Retrying…":"Retry"}):null]}):l==="voice-limit"?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 xt(){const{id:t}=Z(),s=R(i=>i.getActiveVault()),n=ee(),r=U(t);return Se(t,r.data),d.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(y,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})}),r.isPending?e.jsx(at,{}):r.data?e.jsxs(e.Fragment,{children:[r.isError?e.jsx(re,{}):null,e.jsx(Qe,{note:r.data,cacheId:t})]}):r.isError?e.jsx(dt,{error:r.error,retry:()=>r.refetch()}):e.jsx(ct,{id:t??""})]}):e.jsx(se,{to:ne("/",`${n.pathname}${n.search}`),replace:!0})}function Qe({note:t,cacheId:s}){var k,I;const n=R(p=>p.getActiveVault()),{roles:r}=ae((n==null?void 0:n.id)??null),i=ie(),{mirror:l}=oe(),a=l.state==="offline",o=t.contentEvicted===!0,c=d.useMemo(()=>ke(t),[t]),u=M(p=>p.on),h=M(p=>p.setOn);d.useEffect(()=>{if(!u)return;const p=C=>{C.key==="Escape"&&h(!1)};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[u,h]);const m=t.path??t.id,j=le(t.content),b=j!==null&&!ce(j,t)?j:null,f=b!==null?{kind:"title",text:b}:t.path?de(t.path):{kind:"title",text:t.id},g=d.useMemo(()=>b!==null?{...t,content:ue(t.content??"")}:t,[t,b]),v=typeof((k=t.metadata)==null?void 0:k.summary)=="string"?t.metadata.summary:null,w=d.useMemo(()=>(t.links??[]).filter(p=>p.targetId===t.id&&p.sourceId!==t.id&&p.sourceNote),[t]),E=d.useMemo(()=>{const p=new Set,C=[];for(const x of t.links??[])x.sourceId!==t.id||x.targetId===t.id||x.targetNote&&(p.has(x.targetId)||(p.add(x.targetId),C.push(x)));return C},[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:f.kind==="timestamp"?"page-title title-timestamp":"page-title",children:f.text}),a?e.jsx(ot,{}):null,t.tags&&t.tags.length>0?e.jsx(Ye,{tags:t.tags}):null,v?e.jsx("p",{className:"mt-3 text-fg-muted",children:v}):null,e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsx(y,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit"}),e.jsx(Ne,{note:t,keyboard:!0}),e.jsx(we,{note:t}),e.jsxs("button",{type:"button",onClick:()=>h(!0),className:"btn btn-ghost btn-touch",title:"Focus (⌘.)",children:[e.jsx(he,{width:16,height:16}),"Focus"]}),me(t,r.view)?e.jsx(y,{to:`/views/${encodeURIComponent(t.id)}`,className:"btn btn-secondary btn-touch",children:"Open as view"}):null]}),e.jsx(et,{value:m,isPath:!!t.path}),e.jsx(Ke,{note:t})]}),e.jsx(ze,{content:t.content??"",attachments:t.attachments,onRetry:()=>i.mutate({cacheId:s??t.id,serverId:t.id}),retrying:i.isPending}),o?e.jsx(lt,{preview:t.preview}):(I=g.content)!=null&&I.trim()?e.jsx(Ce,{note:g,resolve:c}):b===null?e.jsx(it,{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(p=>e.jsx(tt,{attachment:p},p.id))})]}):null,e.jsx(Me,{anchor:t})]}),e.jsxs("aside",{className:"space-y-6 text-sm lg:sticky lg:top-24 lg:self-start",children:[e.jsx(We,{note:t}),E.length>0?e.jsx(O,{title:"Outbound",links:E,peer:"target"}):null,w.length>0?e.jsx(O,{title:"Inbound",links:w,peer:"source"}):null]})]})}function We({note:t}){const s=t.createdAt,n=t.updatedAt,r=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:V(s)})}),n?e.jsx(S,{label:"Updated",value:e.jsx("time",{title:n,children:V(n)})}):null,t.path?e.jsx(S,{label:"Path",value:e.jsx(fe,{value:t.path,label:"note path",className:"mt-1"})}):null,r.map(([i,l])=>e.jsx(S,{label:i,value:e.jsx("span",{className:"break-all text-fg-muted",children:String(l)})},i))]}),e.jsx(Je,{noteId:t.id}),t.path?e.jsx(Xe,{path:t.path}):null,e.jsx(be,{note:t,variant:"detail",className:"mt-3"})]})}function Je({noteId:t}){const s=R(l=>l.getActiveVault()),{copied:n,copy:r}=L(),i=s?ye(s):"";return i?e.jsx("button",{type:"button",onClick:()=>r(ve(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 Xe({path:t}){const{copied:s,copy:n}=L();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 Ye({tags:t}){return e.jsx("div",{className:"mt-2 flex flex-wrap gap-1","aria-label":"Tags",children:t.map(s=>e.jsxs(y,{to:`/tags/${encodeURIComponent(s)}`,className:"chip chip-tag focus-ring max-w-full break-all",children:["#",s]},s))})}function Ze(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 et({value:t,isPath:s}){const{copied:n,copy:r}=L();return e.jsxs("button",{type:"button",onClick:()=>r(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(Ze,{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 O({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(r=>{var o;const i=n==="source"?r.sourceNote:r.targetNote;if(!i)return null;const l=i.path??i.id,a=typeof((o=i.metadata)==null?void 0:o.summary)=="string"?i.metadata.summary:null;return e.jsx("li",{children:e.jsxs(y,{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}),a?e.jsx("div",{className:"mt-0.5 line-clamp-2 text-xs text-fg-dim",children:a}):null]})},`${r.sourceId}->${r.targetId}:${r.relationship}`)})})]})}function tt({attachment:t}){const s=t.filename;if(!s||!t.url)return e.jsx("figure",{className:"card shadow-soft p-3",children:e.jsx(H,{})});const n=(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:rt(t.size)}):null]}),e.jsx(st,{attachment:t,mime:n,filename:s})]})}function H(){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 st({attachment:t,mime:s,filename:n}){const r=T(),[i,l]=d.useState(null),[a,o]=d.useState(null),c=nt(s,n),u=c!=="other",h=t.url;if(d.useEffect(()=>{if(!u||!h||!r)return;let j=!1,b=null;return o(null),r.fetchAttachmentBlob(h).then(f=>{j||(b=URL.createObjectURL(f),l(b))}).catch(f=>{j||o(f instanceof Error?f.message:"Failed to load attachment")}),()=>{j=!0,b&&URL.revokeObjectURL(b)}},[u,h,r]),!h)return e.jsx(H,{});if(a)return e.jsx("p",{className:"text-sm text-danger",children:a});if(u&&!i)return e.jsx(N,{className:"h-32 w-full"});const m=i??h;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 nt(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 rt(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 at(){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 it({noteId:t}){return e.jsxs("p",{className:"my-8 font-serif text-lg italic text-fg-muted",children:["Nothing here yet."," ",e.jsx(y,{to:`/n/${encodeURIComponent(t)}/edit`,className:"not-italic text-accent hover:underline",children:"Start writing →"})]})}function ot(){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 lt({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 ct({id:t}){return e.jsx(pe,{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(y,{to:"/notes",className:"text-sm text-accent hover:underline",children:"Back to all notes"})})}function dt({error:t,retry:s}){const n=t instanceof ge,r=t instanceof je,i=n?"Session expired":r?"Note not found":"Could not load note",l=n?t.message:r?"Couldn't find this note. It may have been deleted, or the link may be wrong.":"Something went wrong loading this note. You can try again, or head back to your notes.";return e.jsx(xe,{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(y,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):e.jsx(y,{to:"/notes",className:"btn btn-secondary btn-touch",children:"Back to notes"})})}export{xt as NoteView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ai as F,r,al as D,V as M,j as e,u as I,bQ as V,aJ as z,bR as B,bS as J,bT as K,N as U,G,H,L as P,J as A}from"./index-GcTfNe1b.js";import{T as Q}from"./TagSchemaEditor-CMCwC2U0.js";const O=t=>Object.values(t).reduce((n,g)=>n+g,0);function L({mode:t,sources:n,tagOptions:g,onClose:i,onRun:y,onRunMerge:l,pending:o,offline:c}){const m=F(a=>a.push),d=r.useId(),[p,h]=r.useState(t==="rename"?n[0]??"":""),[f,u]=r.useState(null),[x,v]=r.useState(null),[w,S]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{var a,s;(a=b.current)==null||a.focus(),(s=b.current)==null||s.select()},[]),r.useEffect(()=>{const a=s=>{s.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const j=p.trim().replace(/^#/,""),N=!o&&!c&&!w&&j.length>0&&!(t==="rename"&&j===n[0]),T=r.useCallback(async()=>{if(N){u(null),v(null);try{const a=await y(j);if("renamed"in a)m(`Renamed on ${a.renamed} note${a.renamed===1?"":"s"}.`,"success");else{const s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success")}i()}catch(a){if(a instanceof D&&t==="rename"&&l){v(a.target);return}a instanceof M?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Operation failed.")}}},[N,j,t,i,y,l,m]),E=r.useCallback(async()=>{if(!(!x||!l)){u(null),S(!0);try{const a=await l(x),s=O(a.merged);m(`Merged into #${a.target} on ${s} note${s===1?"":"s"}.`,"success"),i()}catch(a){a instanceof M?u("Session expired. Reconnect to retry."):u(a instanceof Error?a.message:"Merge failed."),S(!1)}}},[x,i,l,m]),k=t==="rename"?"Rename tag":`Merge ${n.length} tags`;return e.jsx("dialog",{open:!0,"aria-labelledby":"tag-op-title",className:"fixed inset-0 z-40 m-0 flex h-full max-h-full w-full max-w-full items-center justify-center bg-black/60 p-4",onMouseDown:a=>{a.target===a.currentTarget&&i()},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-6 shadow-lift",children:[e.jsx("h2",{id:"tag-op-title",className:"mb-2 font-serif text-xl text-fg",children:k}),e.jsxs("p",{className:"mb-3 text-sm text-fg-muted",children:[t==="rename"?e.jsxs(e.Fragment,{children:["Rename ",e.jsx(C,{children:n[0]})," on every note that carries it. Notes that already have the new tag will end up with one copy."]}):e.jsxs(e.Fragment,{children:["Combine"," ",n.map((a,s)=>e.jsxs("span",{children:[e.jsx(C,{children:a}),s<n.length-1?", ":""]},a))," ","into one tag. The originals are removed."]})," ","Changes apply atomically on the vault."]}),e.jsxs("label",{className:"mb-3 block text-sm",children:[e.jsx("span",{className:"mb-1 block text-fg-muted",children:t==="rename"?"New tag name":"Target tag"}),e.jsx("input",{ref:b,type:"text",value:p,onChange:a=>{h(a.target.value),x&&v(null)},onKeyDown:a=>{a.key==="Enter"&&N&&T()},list:d,"aria-label":t==="rename"?"New tag name":"Merge target tag",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 font-mono text-sm text-fg focus:border-accent focus:outline-none",autoComplete:"off"}),e.jsx("datalist",{id:d,children:g.map(a=>e.jsx("option",{value:a},a))})]}),c?e.jsx("p",{className:"mb-3 text-sm text-amber-300",children:"Offline — tag operations need a live vault connection."}):null,x?e.jsxs("div",{role:"alert",className:"mb-3 rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[e.jsxs("p",{className:"mb-2 text-amber-300",children:["A tag named ",e.jsx(C,{children:x})," already exists."]}),e.jsxs("p",{className:"mb-3 text-fg-muted",children:["Merge ",e.jsx(C,{children:n[0]})," into ",e.jsx(C,{children:x})," instead? Notes that carry both end up with one copy."]}),e.jsx("button",{type:"button",onClick:()=>void E(),disabled:w,className:"rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:w?"Merging…":`Merge into #${x}`})]}):null,f?e.jsx("p",{role:"alert",className:"mb-3 text-sm text-red-400",children:f}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:i,className:"min-h-11 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-fg-muted hover:text-fg",children:"Cancel"}),e.jsx("button",{type:"button",onClick:()=>void T(),disabled:!N,className:"min-h-11 rounded-lg bg-accent px-4 py-1.5 text-sm font-medium text-(--color-on-accent) hover:bg-accent-hover disabled:opacity-40",children:o?t==="rename"?"Renaming…":"Merging…":t==="rename"?"Rename":"Merge"})]})]})})}function C({children:t}){return e.jsxs("span",{className:"rounded bg-bg/60 px-1 py-0.5 font-mono text-xs text-fg",children:["#",t]})}function te(){const t=I(s=>s.getActiveVault()),n=V(),{isOnline:g}=z(),{isPinned:i,togglePin:y}=B((t==null?void 0:t.id)??null),[l,o]=r.useState(""),[c,m]=r.useState("count"),[d,p]=r.useState(new Set),[h,f]=r.useState(null),[u,x]=r.useState(!1),[v,w]=r.useState(null),S=J(),b=K(),j=r.useMemo(()=>Z(n.data??[],l,c),[n.data,l,c]),N=r.useMemo(()=>(n.data??[]).map(s=>s.name),[n.data]),T=s=>{p($=>{const R=new Set($);return R.has(s)?R.delete(s):R.add(s),R})},E=()=>p(new Set);if(!t)return e.jsx(U,{to:"/",replace:!0});const k=d.size,a=!g;return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"mb-5 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-3 md:mb-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow",children:t.name}),e.jsx("h1",{className:"page-title",children:"Tags"})]}),e.jsxs("button",{type:"button",onClick:()=>m(s=>s==="count"?"alpha":"count"),className:"focus-ring text-sm text-fg-muted hover:text-accent","aria-label":"Toggle tag sort",children:["Sort: ",c==="count"?"most used":"A–Z"]})]}),e.jsx("input",{type:"search",placeholder:"Filter tags…",value:l,onChange:s=>o(s.target.value),"aria-label":"Filter tags",className:"input mb-6"}),k>0?e.jsxs("div",{className:"mb-6 flex flex-wrap items-center gap-3 rounded-xl border border-accent/30 bg-accent/5 px-4 py-3 text-sm","aria-label":"Tag selection actions",children:[e.jsxs("span",{className:"text-fg-muted",children:[k," selected: ",Array.from(d).join(", ")]}),e.jsx("button",{type:"button",onClick:()=>x(!0),disabled:k<2||a,className:"btn btn-primary btn-sm",children:"Merge into…"}),e.jsx("button",{type:"button",onClick:E,className:"btn btn-ghost btn-sm",children:"Clear"})]}):null,n.isPending?e.jsx(_,{}):n.isError?e.jsx(q,{error:n.error}):j.length===0?e.jsx(X,{filtering:l.trim().length>0,hasAny:(n.data??[]).length>0}):e.jsx("ul",{className:"card shadow-soft divide-y divide-border rounded-xl","aria-label":"Tag list",children:j.map(s=>e.jsx(W,{tag:s,selected:d.has(s.name),onToggle:()=>T(s.name),onRename:()=>f(s.name),onEditSchema:()=>w(s.name),pinned:i(s.name),onTogglePin:()=>y(s.name),offline:a},s.name))}),n.data&&n.data.length>0?e.jsxs("p",{className:"mt-6 text-xs tabular-nums text-fg-dim",children:[j.length," / ",n.data.length," tag",n.data.length===1?"":"s"]}):null,h!==null?e.jsx(L,{mode:"rename",sources:[h],tagOptions:N,onClose:()=>f(null),pending:S.isPending||b.isPending,offline:a,onRun:s=>S.mutateAsync({oldName:h,newName:s}),onRunMerge:s=>b.mutateAsync({sources:[h],target:s})}):null,u?e.jsx(L,{mode:"merge",sources:Array.from(d),tagOptions:N,onClose:()=>x(!1),pending:b.isPending,offline:a,onRun:async s=>{const $=await b.mutateAsync({sources:Array.from(d),target:s});return E(),$}}):null,v!==null?e.jsx(Q,{tagName:v,onClose:()=>w(null)}):null]})}function W({tag:t,selected:n,onToggle:g,onRename:i,onEditSchema:y,pinned:l,onTogglePin:o,offline:c}){const m=t.fields?Object.keys(t.fields):[],d=t.parent_names??[],p=!!t.description||m.length>0||d.length>0;return e.jsxs("li",{className:"px-4 py-3 text-sm transition-colors hover:bg-bg-soft",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:g,"aria-label":`Select tag ${t.name}`,className:"accent-accent"}),e.jsxs(P,{to:`/tags/${encodeURIComponent(t.name)}`,className:"chip chip-tag focus-ring shrink-0 max-w-full break-all",children:[e.jsxs("span",{className:"font-mono",children:["#",t.name]}),e.jsx("span",{className:"tabular-nums opacity-70",children:t.count??0})]}),e.jsxs("div",{className:"-my-3 ml-auto flex shrink-0 items-center gap-4",children:[e.jsx("button",{type:"button",onClick:o,className:l?"focus-ring flex min-h-11 items-center text-xs font-medium text-accent hover:text-accent-hover":"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent","aria-label":l?`Unpin tag ${t.name}`:`Pin tag ${t.name}`,"aria-pressed":l,title:l?"Pinned to home strip — click to unpin":"Pin to home strip",children:l?"★ Pinned":"☆ Pin"}),e.jsx("button",{type:"button",onClick:y,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Edit schema for tag ${t.name}`,children:p?"Schema":"+ Schema"}),e.jsx("button",{type:"button",onClick:i,disabled:c,className:"focus-ring flex min-h-11 items-center text-xs text-fg-muted hover:text-accent disabled:opacity-40","aria-label":`Rename tag ${t.name}`,children:"Rename"})]})]}),p?e.jsxs("dl",{className:"ml-8 mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-xs text-fg-dim","aria-label":`Schema for ${t.name}`,children:[t.description?e.jsxs("div",{className:"flex w-full items-baseline gap-1.5",children:[e.jsx("dt",{className:"sr-only",children:"Description"}),e.jsx("dd",{className:"italic",children:t.description})]}):null,m.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Fields"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:m.map(h=>{var f,u;return`${h}: ${((u=(f=t.fields)==null?void 0:f[h])==null?void 0:u.type)??"?"}`}).join(", ")})]}):null,d.length>0?e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("dt",{className:"uppercase tracking-wider",children:"Parents"}),e.jsx("dd",{className:"font-mono text-fg-muted",children:d.join(", ")})]}):null]}):null]})}function Z(t,n,g){const i=n.trim().toLowerCase(),l=[...i?t.filter(o=>o.name.toLowerCase().includes(i)):t];return g==="alpha"?l.sort((o,c)=>o.name.localeCompare(c.name)):l.sort((o,c)=>(c.count??0)-(o.count??0)||o.name.localeCompare(c.name)),l}function _(){return e.jsx("div",{className:"space-y-2","aria-busy":"true",children:[0,1,2,3,4].map(t=>e.jsx(G,{className:"h-12 rounded-xl"},t))})}function q({error:t}){const n=t instanceof M;return e.jsx(H,{title:n?"Session expired":"Could not load tags",message:t.message,action:n?e.jsx(P,{to:"/add",className:"btn btn-primary",children:"Reconnect vault"}):void 0})}function X({filtering:t,hasAny:n}){return t&&n?e.jsx(A,{title:"No tags match your filter."}):e.jsx(A,{title:"No tags in this vault yet.",action:e.jsx(P,{to:"/new",className:"btn btn-primary",children:"Create a note"})})}export{te as Tags};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as h,u as n,j as e,L as c,c0 as x,bm as p}from"./index-GcTfNe1b.js";import{v}from"./provenance-Hx5MxK3k.js";import{a as f,s as g}from"./mcp-address-C02VbHLL.js";import{a as j}from"./types-BaJkUfo6.js";function V(){const i=h(),o=n(s=>s.vaults),d=n(s=>s.activeVaultId),m=n(s=>s.removeVault),a=Object.values(o).sort((s,t)=>s.name.localeCompare(t.name)),u=f(a);return e.jsxs("div",{className:"page-prose",children:[e.jsxs("header",{className:"mb-8 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"page-title",children:"Vaults"}),e.jsx("p",{className:"mt-2 text-fg-muted",children:"Every vault you've connected, in one place."})]}),e.jsx(c,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}),a.length===0?e.jsxs("div",{className:"card rounded-xl p-8 text-center shadow-soft",children:[e.jsx("p",{className:"mb-1 font-serif text-lg text-fg",children:"No vaults connected yet."}),e.jsx("p",{className:"mb-5 text-sm text-fg-muted",children:"Open one you already have, create a new one, or connect a self-hosted vault."}),e.jsx(c,{to:"/add-vault",className:"btn btn-primary btn-touch",children:"Add vault"})]}):e.jsx("ul",{className:"space-y-3",children:a.map(s=>{const t=s.id===d,r=j(s.url),l=v(s);return e.jsxs("li",{className:"card rounded-xl p-5 shadow-soft",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:s.name}),t?e.jsx("span",{className:"chip chip-tag-active",children:"active"}):null,e.jsxs("span",{className:"chip",children:[l.kind==="cloud"?"☁":"⌂"," ",l.label]}),r?e.jsx("span",{className:"chip border-warning/40 bg-warning-soft text-warning",children:"needs reconnect"}):null]}),e.jsx("p",{className:"mt-1 truncate note-id",children:g(s,u)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-4 text-sm",children:[t?null:e.jsx("button",{type:"button",onClick:()=>i(`${x()}/v/${encodeURIComponent(p(s))}`),className:"focus-ring text-fg-muted hover:text-accent",children:"Make active"}),e.jsx("button",{type:"button",onClick:()=>{confirm(`Remove ${s.name} from this device? Your notes stay in the vault — only this device's stored access is removed. You can add it again anytime.`)&&m(s.id)},className:"focus-ring text-danger hover:text-danger-hover",children:"Remove from this device"})]})]}),r?e.jsxs("p",{className:"mt-3 rounded-xl border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning",children:["Vault now serves under ",e.jsx("code",{className:"font-mono",children:"/vault/<name>/"}),". This stored URL is from the older scheme and won't reach the new endpoints. Remove this entry and"," ",e.jsx(c,{to:"/add",className:"underline",children:"add it again"})," ","— discovery will pick the right URL automatically."]}):null]},s.id)})})]})}export{V as Vaults};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as n,c7 as lt,r as y,c8 as O,c9 as $,L as I,bl as ot,K as ct,aI as dt,av as se,ai as ae,C as F,bV as q,ca as Le,cb as _e,cc as ut,cd as Be,a4 as mt,J as V,a8 as xt,a6 as Ne,ab as ee,ce as Fe,cf as pt,cg as ht,ch as ft,ci as gt,cj as bt,ck as Ve,u as Re,ad as yt,M as jt,cl as vt,cm as Nt,cn as we,co as wt,b as kt,c6 as R,cp as te,aq as Ct,cq as St,N as $t,H as Oe,cr as Tt,cs as Ie,ct as Et,cu as W,G as C,cv as Dt,cw as Pt,cx as Mt,aG as At,cy as Lt,cz as _t,af as ke,ag as Ce,cA as Bt}from"./index-GcTfNe1b.js";import{T as Ft}from"./TagSchemaEditor-CMCwC2U0.js";const Vt="—",qe=/^https?:\/\//i;function ze(e){return typeof e=="string"&&qe.test(e)}const Se=24;function Rt(e){try{const t=new URL(e);let s=`${t.pathname}${t.search}${t.hash}`;return s==="/"&&(s=""),s.length>Se&&(s=`${s.slice(0,Se-1)}…`),{host:t.host,rest:s}}catch{return{host:e.replace(qe,""),rest:""}}}function Ot({value:e,schema:t}){if(e==null||e==="")return Vt;if(typeof e=="boolean")return e?n.jsx("span",{className:"text-grass",children:"✓"}):n.jsx("span",{className:"text-fg-dim",children:"✕"});if((t==null?void 0:t.type)==="date"&&typeof e=="string")return lt(e);if(ze(e)){const{host:s,rest:a}=Rt(e);return n.jsxs("span",{className:"min-w-0 truncate text-accent underline underline-offset-2",title:e,children:[s,a?n.jsx("span",{className:"opacity-70",children:a}):null]})}return typeof e=="number"?n.jsx("span",{className:"tabular-nums",children:String(e)}):String(e)}function z(e,t){if(t&&t.length>0||e!=null&&e.enum&&e.enum.length>0)return"enum";switch(e==null?void 0:e.type){case"date":return"date";case"boolean":return"boolean";case"number":return"number";default:return"string"}}const It="focus-ring inline-flex max-w-[9rem] items-center rounded px-1 py-0.5 text-[0.6875rem] hover:text-accent disabled:opacity-50";function qt(e){if(typeof e!="string")return"";const t=e.match(/^\d{4}-\d{2}-\d{2}/);return t?t[0]:""}function re({field:e,schema:t,value:s,onCommit:a,disabled:r=!1,options:i,includeClear:l=!1,trigger:o}){const u=z(t,i),[c,m]=y.useState(!1),p=s==null||s==="",d=(o==null?void 0:o.label)??n.jsx(Ot,{value:s,schema:t}),h=(o==null?void 0:o.ariaLabel)??`Edit ${e}`,j=(o==null?void 0:o.className)??`${It} ${p&&!(o!=null&&o.label)?"text-fg-dim":"text-fg"}`;if(u==="boolean"){const v=(o==null?void 0:o.ariaLabel)??`Edit ${e} (${s===!0?"checked":"unchecked"})`;return n.jsx("button",{type:"button",disabled:r,"aria-label":v,onClick:()=>a(s!==!0),className:j,children:d})}const b=u==="enum"?i??((t==null?void 0:t.enum)??[]).map(v=>({value:v,label:v})):[],f=l&&!p,g=v=>{m(!1),a(v)};return n.jsxs("div",{className:"relative",children:[n.jsx("button",{type:"button",disabled:r,"aria-haspopup":u==="enum"?"menu":"dialog","aria-expanded":c,"aria-label":h,title:o!=null&&o.label?void 0:`Edit ${e}`,onClick:()=>m(v=>!v),className:j,children:d}),c?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"fixed inset-0 z-10 cursor-default",onClick:()=>m(!1)}),u==="enum"?n.jsxs("div",{role:"menu","aria-label":h,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] flex-col gap-0.5 p-1 shadow-lg",children:[b.map(v=>n.jsxs("button",{type:"button",role:"menuitem",onClick:()=>g(v.value),className:`focus-ring flex items-center gap-1.5 rounded px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${v.muted?"text-fg-dim":"text-fg"}`,children:[v.value===null||v.value===void 0||v.value===""?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${O(String(v.value))}`}),v.label]},v.value===null?"__clear__":String(v.value))),f?n.jsx("button",{type:"button",role:"menuitem",onClick:()=>g(null),className:"focus-ring rounded px-2 py-1.5 text-left text-sm text-fg-dim hover:bg-bg-soft",children:"Clear"}):null]}):n.jsx(zt,{kind:u,value:s,ariaLabel:h,onCommit:g,onCancel:()=>m(!1)})]}):null]})}function zt({kind:e,value:t,ariaLabel:s,onCommit:a,onCancel:r}){const i=e==="date"?qt(t):t==null?"":String(t),[l,o]=y.useState(i),u=()=>{const c=l.trim();if(c==="")return a(null);if(e==="number"){const m=Number(c);return Number.isFinite(m)?a(m):r()}a(c)};return n.jsxs("div",{role:"dialog","aria-label":s,className:"card absolute right-0 z-20 mt-1 flex min-w-[10rem] items-center gap-1 p-1 shadow-lg",children:[n.jsx("input",{autoFocus:!0,type:e==="date"?"date":e==="number"?"number":"text",value:l,"aria-label":s,onChange:c=>o(c.target.value),onKeyDown:c=>{c.key==="Enter"?(c.preventDefault(),u()):c.key==="Escape"&&(c.preventDefault(),r())},className:"w-full rounded border border-border bg-bg/40 px-1.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"}),n.jsx("button",{type:"button",onClick:u,"aria-label":"Save",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"✓"}),ze(t)?n.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer","aria-label":"Open link",title:"Open link",className:"focus-ring rounded px-1.5 py-1 text-xs text-accent hover:bg-bg-soft",children:"↗"}):null]})}function Gt(e){for(const t of e.attachments??[]){const s=typeof t.url=="string"?t.url:null;if(typeof t.mimeType=="string"&&t.mimeType.startsWith("image/")&&s&&/^https?:\/\//i.test(s))return s}return null}function G({note:e,pinnedTag:t,archivedTag:s,variant:a="compact",overlay:r,footer:i,drag:l}){const o=$(e),u=e.updatedAt??e.createdAt,c=(e.tags??[]).includes(t),m=(e.tags??[]).includes(s),p=a==="gallery"?Gt(e):null,[d,h]=y.useState(!1),j=p&&!d,b=(l==null?void 0:l.canDrag)??!1,f=n.jsxs(I,{to:`/n/${encodeURIComponent(e.id)}`,draggable:b?!1:void 0,"data-note-id":e.id,className:`focus-ring card group flex flex-col overflow-hidden rounded-xl shadow-sm transition hover:border-accent hover:shadow-md ${m?"opacity-60 italic":""}`,children:[a==="gallery"?n.jsx("div",{className:"aspect-[3/2] w-full overflow-hidden bg-bg-soft",children:j?n.jsx("img",{src:p,alt:"",loading:"lazy",onError:()=>h(!0),className:"h-full w-full object-cover"}):n.jsx("div",{"aria-hidden":"true",className:"flex h-full w-full items-end p-3 text-fg-dim",children:n.jsx("span",{className:"line-clamp-3 text-sm text-fg-muted",children:e.preview??""})})}):null,n.jsxs("div",{className:"flex flex-1 flex-col gap-1 p-3",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsxs("span",{className:"flex min-w-0 items-baseline gap-1.5",children:[c?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:o.kind==="timestamp"?"min-w-0 truncate text-sm title-timestamp":"min-w-0 truncate text-sm font-medium text-fg",children:o.text})]}),n.jsx(ot,{note:e})]}),e.preview&&!(a==="gallery"&&!j)?n.jsx("p",{className:"line-clamp-2 text-xs text-fg-muted",children:e.preview}):null,n.jsx("span",{className:"mt-auto pt-1 text-[0.6875rem] tabular-nums text-fg-dim",children:ct(u)})]})]});return!r&&!i&&!b?f:n.jsxs("div",{className:b?"relative flex flex-col cursor-grab":"relative flex flex-col",...(l==null?void 0:l.sourceProps)??{},children:[f,r?n.jsx("div",{className:"absolute right-2 top-2",children:r}):null,i?n.jsx("div",{className:"mt-1",children:i}):null]})}function Ut(e,t,s){const a={...e.metadata??{}};return s===null?delete a[t]:a[t]=s,{...e,metadata:a}}function Yt(e,t,s,a){return e&&e.map(r=>r.id===t?Ut(r,s,a):r)}function Ht(e,t){const s=dt(),a=se(e);return{move:y.useCallback(async(i,l,o)=>{const u=s.getQueryData(t);s.setQueryData(t,c=>Yt(c,e,i,l));try{const c=await a.mutateAsync({metadata:{[i]:l},...o?{if_updated_at:o}:{force:!0}}),m=c==null?void 0:c.updatedAt;m&&s.setQueryData(t,p=>p==null?void 0:p.map(d=>d.id===e?{...d,updatedAt:m}:d))}catch(c){throw s.setQueryData(t,u),c}},[s,t,e,a]),isPending:a.isPending}}const Qt=1800,J="field-write-flash",Wt=700;function Jt(e){return e===null?null:typeof e=="boolean"?e?"Yes":"No":String(e)}function Xt(e){if(typeof document>"u")return;const t=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&");for(const s of document.querySelectorAll(`[data-note-id="${t}"]`))s.classList.remove(J),s.offsetWidth,s.classList.add(J),window.setTimeout(()=>s.classList.remove(J),Wt)}function U(e,t){const s=ae(c=>c.push),{move:a,isPending:r}=Ht(e.id,t),i=e.id,l=e.updatedAt,o=$(e).text;return{write:y.useCallback(async(c,m,p)=>{try{await a(c,m,l)}catch(h){const j=(p==null?void 0:p.errorPrefix)??`Couldn't update ${c} on "${o}"`;s(`${j}: ${h instanceof Error?h.message:"unknown error"}`,"error");return}const d=(p==null?void 0:p.valueLabel)??Jt(m);s(d===null?`✓ ${c} cleared`:`✓ ${c} → ${d}`,"success",{durationMs:Qt}),Xt(i)},[a,l,o,i,s]),isPending:r}}function Ge(e){if(e==null)return null;const t=typeof e;return t==="string"||t==="number"||t==="boolean"?e:null}function P({note:e,fields:t,viewResultsKey:s,omit:a}){const{write:r,isPending:i}=U(e,s),l=a&&a.length>0?t.filter(o=>!a.includes(o.name)):t;return l.length===0?null:n.jsx("div",{className:"flex flex-wrap items-center gap-1.5 px-3 pb-2.5 pt-0.5",children:l.map(o=>{var m;const u=Ge((m=e.metadata)==null?void 0:m[o.name]),c=z(o.schema)==="enum"&&u!==null&&u!==""?O(String(u)):null;return n.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full border py-0.5 pl-2 pr-1 text-[0.6875rem] leading-none ${c?`chip-tinted tint-${c}`:"border-border bg-bg-soft/60"}`,children:[c?n.jsx("span",{"aria-hidden":"true",className:"tint-dot"}):null,n.jsx("span",{className:"text-fg-dim",children:o.name}),n.jsx(re,{field:o.name,schema:o.schema,value:u,disabled:i,includeClear:!0,onCommit:p=>void r(o.name,p)})]},o.name)})})}function Kt(e,t){var a;const s=(a=e.metadata)==null?void 0:a[t];if(s==null)return null;if(typeof s=="string"){const r=s.trim();return r===""?null:r}return typeof s=="number"||typeof s=="boolean"?String(s):null}const Zt={status:["active","incubating","dormant","paused","archived","done","shipped","dropped"],priority:["high","medium","low"]};function en(e,t){var a;const s=(a=t==null?void 0:t[e])==null?void 0:a.enum;return s&&s.length>0?s:Zt[e]??[]}function tn(e,t,s=[]){var m;const a=new Map,r=new Map,i=[];for(const p of e){const d=Kt(p,t);if(d===null){i.push(p);continue}const h=a.get(d);h?h.push(p):(a.set(d,[p]),r.set(d,(m=p.metadata)==null?void 0:m[t]))}const l=s.filter(p=>a.has(p)),o=new Set(l),u=[...a.keys()].filter(p=>!o.has(p)).sort((p,d)=>p.localeCompare(d)),c=[...l,...u].map(p=>({key:p,label:p,notes:a.get(p)??[],uncategorized:!1,value:r.get(p)}));return i.length>0&&c.push({key:"",label:`No ${t}`,notes:i,uncategorized:!0,value:null}),c}function nn(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const s=t.match(/^(\d{4})-(\d{2})-(\d{2})/);if(s){const r=new Date(Number(s[1]),Number(s[2])-1,Number(s[3]));return Number.isNaN(r.getTime())?null:r}const a=new Date(t);return Number.isNaN(a.getTime())?null:a}function sn(e,t){var i;const s=new Map,a=[],r=new Map;for(const l of e){const o=nn((i=l.metadata)==null?void 0:i[t]);if(!o){a.push(l);continue}r.set(l.id,o);const u=F(o),c=s.get(u);c?c.push(l):s.set(u,[l])}return{byDay:s,undated:a,dates:r}}function an(e){const t=new Map,s=[],a=new Map;for(const r of e){const i=r.createdAt?new Date(r.createdAt):null;if(!i||Number.isNaN(i.getTime())){s.push(r);continue}a.set(r.id,i);const l=F(i),o=t.get(l);o?o.push(r):t.set(l,[r])}return{byDay:t,undated:s,dates:a}}function $e(e,t=new Date){let s=null;for(const r of e)(!s||r.getTime()>s.getTime())&&(s=r);const a=s??t;return{year:a.getFullYear(),month:a.getMonth()+1}}function rn({notes:e,laneBy:t,subjectTag:s,roles:a,viewResultsKey:r,fields:i=[]}){const l=q(s??null),o=y.useMemo(()=>{var b,f,g,v;const c=tn(e,t,en(t,(b=l.data)==null?void 0:b.fields)),m=((v=(g=(f=l.data)==null?void 0:f.fields)==null?void 0:g[t])==null?void 0:v.enum)??[];if(m.length===0)return c;const p=new Map(c.filter(x=>!x.uncategorized).map(x=>[x.key,x])),d=m.map(x=>p.get(x)??{key:x,label:x,notes:[],uncategorized:!1,value:x}),h=new Set(m),j=c.filter(x=>x.uncategorized||!h.has(x.key));return[...d,...j]},[e,t,l.data]),u=Le();return n.jsx("div",{className:"overflow-x-auto pb-2",children:n.jsx("div",{className:"flex items-start gap-4",children:o.map(c=>n.jsx(ln,{lane:c,dropRegistry:u,children:c.notes.map(m=>n.jsx(cn,{note:m,laneBy:t,lanes:o,currentLane:c,roles:a,viewResultsKey:r,fields:i,dropRegistry:u},m.id))},c.uncategorized?"__uncategorized__":c.key))})})}function ln({lane:e,dropRegistry:t,children:s}){const a=y.useCallback(l=>t.dispatch(l,e),[t,e]),{isOver:r,targetProps:i}=_e(a);return n.jsxs("section",{"aria-label":e.label,className:`flex w-72 shrink-0 flex-col gap-2 rounded-2xl border border-border-light bg-bg-soft p-2 ${r?"outline-2 outline-offset-2 outline-accent/50":""}`,...i,children:[n.jsxs("header",{className:"flex items-baseline justify-between gap-2 px-1.5 pt-1",children:[n.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[e.uncategorized?null:n.jsx("span",{"aria-hidden":"true",className:`tint-dot tint-${O(e.key)}`}),n.jsx("span",{className:`min-w-0 truncate text-sm font-semibold ${e.uncategorized?"text-fg-dim":"text-fg"}`,children:e.label})]}),n.jsx("span",{className:"shrink-0 rounded-full bg-bg px-2 text-xs tabular-nums text-fg-dim",children:e.notes.length})]}),n.jsx("div",{className:"flex flex-col gap-2",children:e.notes.length===0?n.jsx("p",{className:"py-4 text-center text-xs italic text-fg-dim",children:ut()?"Drop here":"No notes"}):s})]})}function Te(e,t){return e.uncategorized||t.uncategorized?e.uncategorized&&t.uncategorized:e.key===t.key}const on="focus-ring rounded-full border border-border bg-bg-soft/90 px-2 py-0.5 text-[0.6875rem] font-medium text-fg-dim backdrop-blur transition-colors hover:text-accent disabled:opacity-50";function cn({note:e,laneBy:t,lanes:s,currentLane:a,roles:r,viewResultsKey:i,fields:l,dropRegistry:o}){const{write:u,isPending:c}=U(e,i),m=y.useMemo(()=>s.filter(f=>!Te(f,a)),[s,a]),p=y.useMemo(()=>m.map(f=>({value:f.value,label:f.label,muted:f.uncategorized})),[m]),d=y.useCallback(async(f,g)=>{await u(t,f,{valueLabel:g,errorPrefix:`Couldn't move "${$(e).text}"`})},[u,t,e]),h=async f=>{const g=p.find(v=>v.value===f);await d(f,g==null?void 0:g.label)},j=Be(e.id),b=y.useCallback(f=>{c||Te(f,a)||d(f.value,f.label)},[c,a,d]);return y.useEffect(()=>o.register(e.id,b),[o,e.id,b]),n.jsx(G,{note:e,pinnedTag:r.pinned,archivedTag:r.archived,drag:j,overlay:m.length>0?n.jsx(re,{field:t,value:a.value,options:p,disabled:c,onCommit:f=>void h(f),trigger:{label:"Move",ariaLabel:`Move to another ${t}`,className:on}}):null,footer:l.length>0?n.jsx(P,{note:e,fields:l,viewResultsKey:i,omit:m.length>0?[t]:void 0}):null})}const dn=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],X=2;function un({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r=[]}){const i=y.useMemo(()=>t===null?an(e):sn(e,t),[e,t]),[l,o]=y.useState(()=>$e(i.dates.values())),[u,c]=y.useState(null),m=y.useMemo(()=>mt(l.year,l.month),[l]),p=F(),d=Le();if(i.byDay.size===0)return n.jsxs("div",{className:"space-y-4",children:[n.jsx(V,{title:"Nothing on the calendar yet",description:t===null?void 0:`Give a note a ${t} date below and it lands on the grid.`}),t===null?null:n.jsx(Ee,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]});const h=b=>{c(null),o(b)},j=u?i.byDay.get(u)??[]:[];return n.jsxs("div",{className:"space-y-3",children:[n.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[n.jsx("h2",{className:"font-serif text-2xl tracking-tight text-fg",children:xt(l.year,l.month)}),n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("button",{type:"button",onClick:()=>h(Ne(l.year,l.month,-1)),className:"chip","aria-label":"Previous month",children:"← Prev"}),n.jsx("button",{type:"button",onClick:()=>h($e(i.dates.values())),className:"chip",children:"Latest"}),n.jsx("button",{type:"button",onClick:()=>h(Ne(l.year,l.month,1)),className:"chip","aria-label":"Next month",children:"Next →"})]})]}),n.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-card",children:[n.jsx("div",{className:"grid grid-cols-7 border-b border-border bg-bg-soft text-2xs uppercase tracking-wider text-fg-dim",children:dn.map(b=>n.jsx("div",{className:"px-2 py-2 text-center",children:b},b))}),n.jsx("div",{className:"grid grid-cols-7",children:m.map(b=>{const f=F(b),g=b.getMonth()+1===l.month,v=i.byDay.get(f)??[],x=f===p,w=f===u;return n.jsx(mn,{dayKey:f,dayNumber:b.getDate(),inMonth:g,isToday:x,isSelected:w,notes:v,onSelect:()=>c(f),dateField:t,viewResultsKey:a,dropRegistry:d},f)})})]}),u&&j.length>0?n.jsxs("section",{"aria-label":`Notes on ${ee(u)}`,className:"space-y-2",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("p",{className:"eyebrow",children:ee(u)}),n.jsx("button",{type:"button",onClick:()=>c(null),className:"text-xs text-fg-dim hover:text-accent focus-ring rounded",children:"Clear"})]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:j.map(b=>n.jsx(G,{note:b,pinnedTag:s.pinned,archivedTag:s.archived,footer:r.length>0?n.jsx(P,{note:b,fields:r,viewResultsKey:a}):null},b.id))})]}):null,t===null?n.jsx("p",{className:"text-xs text-fg-dim",children:"Showing by created date — set a date field to schedule."}):n.jsx(Ee,{notes:i.undated,dateField:t,roles:s,viewResultsKey:a,fields:r})]})}function mn({dayKey:e,dayNumber:t,inMonth:s,isToday:a,isSelected:r,notes:i,onSelect:l,dateField:o,viewResultsKey:u,dropRegistry:c}){const m=i.length>0,p=o!==null,d=y.useCallback(x=>c.dispatch(x,e),[c,e]),{isOver:h,targetProps:j}=_e(d),b=p&&s?j:{},f=n.jsx("span",{className:`mb-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-serif tabular-nums ${a?"bg-accent text-(--color-on-accent)":"text-fg"}`,children:t}),g=n.jsxs("span",{className:"flex flex-col gap-0.5",children:[i.slice(0,X).map(x=>o===null?n.jsx(xn,{note:x},x.id):n.jsx(pn,{note:x,dayKey:e,dateField:o,viewResultsKey:u,dropRegistry:c},x.id)),i.length>X?n.jsxs("span",{className:"text-[10px] text-fg-dim",children:["+",i.length-X," more"]}):null]}),v=`flex min-h-24 flex-col border-b border-r border-border p-1.5 text-left text-xs ${s?"":"opacity-40"} ${r?"bg-accent/5":""} ${p&&s&&h?"bg-accent/5 outline-2 -outline-offset-2 outline-accent/60":""}`;return m?n.jsxs("button",{type:"button",onClick:l,"aria-label":`${ee(e)} — ${i.length} notes`,className:`${v} hover:bg-bg/60 focus:bg-bg/60 focus:outline-none`,"data-day":e,...b,children:[f,g]}):n.jsxs("div",{className:v,"data-day":e,...b,children:[f,n.jsx("span",{className:"sr-only",children:"no notes"})]})}const ne="truncate rounded-md border border-border bg-card px-1.5 py-0.5 text-[10px] leading-tight text-fg shadow-sm";function xn({note:e}){return n.jsx("span",{"data-note-id":e.id,className:ne,children:$(e).text})}function pn({note:e,dayKey:t,dateField:s,viewResultsKey:a,dropRegistry:r}){const{write:i,isPending:l}=U(e,a),o=Be(e.id),u=y.useCallback(c=>{l||c===t||i(s,c,{errorPrefix:`Couldn't move "${$(e).text}"`})},[l,t,s,i,e]);return y.useEffect(()=>r.register(e.id,u),[r,e.id,u]),n.jsx("span",{"data-note-id":e.id,className:o.canDrag?`${ne} cursor-grab`:ne,...o.sourceProps,children:$(e).text})}function Ee({notes:e,dateField:t,roles:s,viewResultsKey:a,fields:r}){if(e.length===0)return null;const i=r.find(o=>o.name===t)??{name:t,schema:{type:"date"}},l=/date/i.test(t)?t:`${t} date`;return n.jsxs("section",{"aria-label":`Not on the calendar — no ${l}`,className:"space-y-2",children:[n.jsx("p",{className:"eyebrow",children:"Not on the calendar yet"}),n.jsxs("p",{className:"text-xs text-fg-dim",children:[e.length," ",e.length===1?"note has":"notes have"," no ",l," — set one to place ",e.length===1?"it":"them","."]}),n.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,16rem),1fr))] gap-2",children:e.map(o=>n.jsx(G,{note:o,pinnedTag:s.pinned,archivedTag:s.archived,footer:n.jsx(P,{note:o,fields:[i],viewResultsKey:a})},o.id))})]})}const hn="border-[color-mix(in_srgb,var(--color-accent)_40%,var(--color-border))]";function Ue({label:e,value:t,icon:s,ariaLabel:a,haspopup:r="menu",open:i,dirty:l=!1,onClick:o}){return n.jsxs("button",{type:"button","aria-haspopup":r,"aria-expanded":i,"aria-label":a,onClick:o,className:`focus-ring inline-flex min-h-8 items-center gap-1.5 rounded-full border bg-card px-3 py-1 transition-colors duration-(--dur-quick) ease-out hover:border-accent/50 ${l?hn:"border-border"}`,children:[s?n.jsx("span",{"aria-hidden":"true",className:"flex-none text-fg-muted",children:s}):null,e?n.jsx("span",{className:"text-2xs uppercase tracking-[0.08em] text-fg-dim",children:e}):null,n.jsx("span",{className:"text-xs font-medium text-fg",children:t}),n.jsx("span",{"aria-hidden":"true",className:"text-2xs text-fg-dim",children:"▾"})]})}function ie({label:e,value:t,icon:s,ariaLabel:a,menuLabel:r,options:i,sections:l,current:o,onSelect:u,note:c,actions:m,busy:p=!1,dirty:d=!1}){const[h,j]=y.useState(!1);y.useEffect(()=>{if(!h)return;const x=w=>{w.key==="Escape"&&j(!1)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[h]);const b=x=>{j(!1),u(x)},f=x=>{j(!1),x.onSelect()},g=x=>{const w=x.value===o;return n.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":w,onClick:()=>b(x.value),className:`focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm hover:bg-bg-soft ${w?"text-fg":"text-fg-muted"}`,children:[x.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:x.glyph}):null,n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:x.hint?"shrink-0":"min-w-0 shrink truncate",children:x.label??x.value}),x.hint?n.jsx("span",{"aria-hidden":"true",className:"min-w-0 shrink truncate text-2xs text-fg-dim",children:x.hint}):null]}),w?n.jsx("span",{"aria-hidden":"true",className:"text-accent",children:"✓"}):null]},x.value)},v=l?l.reduce((x,w)=>x+w.options.length,0):(i==null?void 0:i.length)??0;return n.jsxs("div",{className:"relative",children:[n.jsx(Ue,{label:e,value:t,icon:s,ariaLabel:a,open:h,dirty:d,onClick:()=>j(x=>!x)}),h?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>j(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"menu","aria-label":r,className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-56 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{"aria-hidden":"true",className:"eyebrow px-2 pt-1.5 pb-1",children:r}),l?l.map((x,w)=>n.jsxs("div",{className:w>0?"mt-1 border-t border-border-light pt-1":void 0,children:[x.heading?n.jsx("p",{"aria-hidden":"true",className:"px-2 pt-1 pb-0.5 text-2xs uppercase tracking-[0.08em] text-fg-dim",children:x.heading}):null,x.options.map(g)]},x.heading??w)):i==null?void 0:i.map(g),c?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:c}):null,m&&m.length>0?n.jsx("div",{className:v>0?"mt-1 border-t border-border-light pt-1":void 0,children:m.map(x=>n.jsxs("button",{type:"button",role:"menuitem",disabled:p,onClick:()=>f(x),className:"focus-ring flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-sm text-fg-muted hover:bg-bg-soft disabled:opacity-50",children:[x.glyph?n.jsx("span",{"aria-hidden":"true",className:"flex-none",children:x.glyph}):null,n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block truncate text-fg",children:x.label}),x.hint?n.jsx("span",{className:"block truncate text-2xs text-fg-dim",children:x.hint}):null]})]},x.key))}):null]})]}):null]})}function De(e){switch(z(e)){case"enum":case"boolean":return"●";case"date":return"📅";case"number":return"#";default:return"Aa"}}function fn({fields:e,schemaFields:t,onChange:s,dirty:a=!1}){const[r,i]=y.useState(!1);y.useEffect(()=>{if(!r)return;const d=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const l=e.map(d=>d.name),o=Object.keys(t).filter(d=>!l.includes(d));if(l.length===0&&o.length===0)return null;const u=l.length===1,c=d=>{u||s(l.filter(h=>h!==d))},m=d=>s([...l,d]),p=(d,h)=>{const j=[...l],[b]=j.splice(d,1);j.splice(d+h,0,b),s(j)};return n.jsxs("div",{className:"relative",children:[n.jsx(Ue,{label:"Fields",value:String(l.length),haspopup:"dialog",open:r,dirty:a,onClick:()=>i(d=>!d)}),r?n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,onClick:()=>i(!1),className:"enter-fade fixed inset-0 z-30 cursor-default bg-black/40 sm:bg-transparent"}),n.jsxs("div",{role:"dialog","aria-label":"Fields",className:"card enter-rise fixed inset-x-0 bottom-0 z-40 max-h-[70dvh] overflow-y-auto rounded-b-none p-1.5 pb-[calc(0.375rem+env(safe-area-inset-bottom))] shadow-lift sm:absolute sm:top-full sm:right-auto sm:bottom-auto sm:mt-1 sm:max-h-80 sm:w-60 sm:rounded-b-[var(--radius-2xl)] sm:pb-1.5",children:[n.jsx("p",{className:"eyebrow px-2 pt-1.5 pb-1",children:"Fields"}),n.jsxs("ul",{className:"flex flex-col gap-0.5",children:[e.map((d,h)=>n.jsxs("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:[n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:u,onChange:()=>c(d.name)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:De(d.schema)}),n.jsx("span",{className:"truncate",children:d.name})]}),n.jsx("button",{type:"button","aria-label":`Move ${d.name} up`,disabled:h===0,onClick:()=>p(h,-1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↑"}),n.jsx("button",{type:"button","aria-label":`Move ${d.name} down`,disabled:h===l.length-1,onClick:()=>p(h,1),className:"focus-ring rounded px-1.5 py-0.5 text-sm text-fg-muted hover:bg-bg-soft hover:text-fg disabled:opacity-30",children:"↓"})]},d.name)),o.map(d=>n.jsx("li",{className:"flex items-center gap-1 rounded-lg px-2 py-1 hover:bg-bg-soft",children:n.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-sm text-fg-muted",children:[n.jsx("input",{type:"checkbox",checked:!1,onChange:()=>m(d)}),n.jsx("span",{"aria-hidden":"true",className:"w-4 flex-none text-center text-2xs text-fg-dim",children:De(t[d])}),n.jsx("span",{className:"truncate",children:d})]})},d))]}),u?n.jsx("p",{className:"px-2 pt-1.5 pb-1 text-xs text-fg-dim",children:"Views show at least one field."}):null]})]}):null]})}function gn({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{"aria-label":"Gallery",className:"grid grid-cols-[repeat(auto-fill,minmax(min(100%,13rem),1fr))] gap-4",children:e.map(r=>n.jsx(G,{note:r,variant:"gallery",pinnedTag:t.pinned,archivedTag:t.archived,footer:a.length>0?n.jsx(P,{note:r,fields:a,viewResultsKey:s}):null},r.id))})}const K={list:"List",board:"Board",calendar:"Calendar",gallery:"Gallery",table:"Table"};function Pe({kind:e}){switch(e){case"board":return n.jsx(bt,{width:14,height:14});case"calendar":return n.jsx(gt,{width:14,height:14});case"gallery":return n.jsx(ft,{width:14,height:14});case"table":return n.jsx(ht,{width:14,height:14});default:return n.jsx(pt,{width:14,height:14})}}function bn({kind:e,onSwitch:t,dirty:s=!1}){return n.jsx(ie,{ariaLabel:`Lens: ${K[e]}`,menuLabel:"Lens",icon:n.jsx(Pe,{kind:e}),value:K[e],options:Fe.map(a=>({value:a,label:K[a],glyph:n.jsx(Pe,{kind:a})})),current:e,onSelect:t,dirty:s})}function yn(e,t,s){const a=e.filter(s).map(r=>r.name);return t&&!a.includes(t)&&a.unshift(t),a}const jn="This view isn't scoped to one tag, so there's no schema to add a field to — add a single tag to the query, or open a tag's view.";function Ye(e,t,s){return[{key:"__add_field__",label:e,hint:t,onSelect:s}]}const Me="Date fields plot on the Calendar lens (By date) — not offered here.";function Z(e,t){return{value:e,hint:t,glyph:n.jsx("span",{className:`tint-dot tint-${O(e)}`})}}function vn(e){const t=[],s=[],a=[];for(const r of e){const i=z(r.schema);i==="date"?a.push(r):i==="enum"?t.push(r):s.push(r)}return{valueBearing:t,other:s,dateFields:a}}function Nn(e){return(e.enum??[]).join(" · ")}function wn(e,t,s,a,r){if(e)return t>0?Me:void 0;if(!s)return jn;if(r)return`#${s} has no fields yet — add one to give this board its columns:`;if(!a)return Me}function kn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const{valueBearing:o,other:u,dateFields:c}=vn(t),m=new Set([...o,...u].map(f=>f.name)),p=e!==void 0&&!m.has(e)?e:void 0,d=[];p!==void 0&&d.push({options:[Z(p)]}),o.length>0&&d.push({heading:"Fields with values",options:o.map(f=>Z(f.name,Nn(f.schema)))}),u.length>0&&d.push({heading:"Other fields · one column per value",options:u.map(f=>Z(f.name))});const h=d.length>0,j=t.length===0,b=j&&!!r&&i&&!!l;return n.jsx(ie,{label:"Group by",menuLabel:"Group by",value:e??"—",sections:d,current:e,onSelect:s,note:wn(h,c.length,r,j,b),actions:b?Ye("Add a field to group by…","You name it; give it values to get columns.",l):void 0,dirty:a})}function Cn({value:e,fields:t,onChange:s,dirty:a=!1,createTag:r=null,schemaReady:i=!0,onAddField:l}){const o=yn(t,e,c=>c.schema.type==="date"),u=o.length===0&&!!r&&i&&!!l;return n.jsx(ie,{label:"By date",menuLabel:"By date",value:e??"created",options:o.map(c=>({value:c})),current:e,onSelect:s,note:o.length===0&&u?`Showing by created date. #${r} has no date field — add one to plot and drag by it:`:e===void 0?"Showing by created date":void 0,actions:u?Ye("Add a date field…","You name it; it holds a date on each note.",l):void 0,dirty:a})}function Sn({notes:e,roles:t,viewResultsKey:s,fields:a=[]}){return n.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card shadow-sm",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full min-w-[36rem] border-collapse text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-border text-left",children:[n.jsx("th",{scope:"col",className:"sticky left-0 z-[1] bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim",children:"Note"}),a.map(r=>n.jsx("th",{scope:"col",className:`whitespace-nowrap bg-bg-soft px-3 py-2 text-2xs font-semibold uppercase tracking-[0.08em] text-fg-dim ${r.schema.type==="number"?"text-right":""}`,children:r.name},r.name))]})}),n.jsx("tbody",{children:e.map(r=>n.jsx($n,{note:r,fields:a,roles:t,viewResultsKey:s},r.id))})]})})})}function $n({note:e,fields:t,roles:s,viewResultsKey:a}){const{write:r,isPending:i}=U(e,a),l=$(e),o=(e.tags??[]).includes(s.pinned),u=(e.tags??[]).includes(s.archived);return n.jsxs("tr",{"data-note-id":e.id,className:`group border-b border-border-light last:border-b-0 hover:bg-bg-soft/60 ${u?"opacity-60 italic":""}`,children:[n.jsx("th",{scope:"row",className:"group-hover:after:opacity-100 sticky left-0 z-[1] bg-card px-3 py-1.5 text-left font-normal after:pointer-events-none after:absolute after:inset-0 after:-z-10 after:bg-bg-soft/60 after:opacity-0",children:n.jsxs(I,{to:`/n/${encodeURIComponent(e.id)}`,className:"focus-ring inline-flex max-w-[16rem] items-baseline gap-1.5 hover:text-accent",children:[o?n.jsx("span",{className:"shrink-0 text-accent","aria-label":"pinned",title:"pinned",children:"★"}):null,n.jsx("span",{className:l.kind==="timestamp"?"min-w-0 truncate title-timestamp":"min-w-0 truncate font-medium text-fg",children:l.text})]})}),t.map(c=>{var m;return n.jsx("td",{className:`px-3 py-1 align-middle ${c.schema.type==="number"?"text-right":""}`,children:n.jsx(re,{field:c.name,schema:c.schema,value:Ge((m=e.metadata)==null?void 0:m[c.name]),disabled:i,includeClear:!0,onCommit:p=>void r(c.name,p)})},c.name)})]})}function He(e){return e.kind!==void 0||e.groupBy!==void 0||e.dateField!==void 0||e.fields!==void 0}function Tn(e){const t=new URLSearchParams;return e.kind&&t.set("kind",e.kind),e.groupBy&&t.set("group",e.groupBy),e.dateField&&t.set("date",e.dateField),e.fields&&e.fields.length>0&&t.set("fields",e.fields.join(",")),t}function En(e){const t={},s=e.get("kind");s&&Fe.includes(s)&&(t.kind=s);const a=e.get("group");a&&(t.groupBy=a);const r=e.get("date");r&&(t.dateField=r);const i=e.get("fields");if(i){const l=i.split(",").map(o=>o.trim()).filter(Boolean);l.length>0&&(t.fields=l)}return t}function le(e,t){return He(t)?{...e,kind:t.kind??e.kind,groupBy:t.groupBy??e.groupBy,dateField:t.dateField??e.dateField,fields:t.fields??e.fields}:e}function Dn(e,t){return e===void 0||t===void 0?e===t:e.length===t.length&&e.every((s,a)=>s===t[a])}function Ae(e,t){const s={};return t.kind!==void 0&&t.kind!==e.kind&&(s.kind=t.kind),t.groupBy!==void 0&&t.groupBy!==e.groupBy&&(s.groupBy=t.groupBy),t.dateField!==void 0&&t.dateField!==e.dateField&&(s.dateField=t.dateField),t.fields!==void 0&&!Dn(t.fields,e.fields)&&(s.fields=t.fields),s}function Pn(e){var t;return(t=e.find(s=>{var a;return(((a=s.schema.enum)==null?void 0:a.length)??0)>0}))==null?void 0:t.name}function Mn(e){var t;return(t=e.find(s=>s.schema.type==="date"))==null?void 0:t.name}function An(e,t,s,a){const r={...t,kind:s};if(s==="board"){if(!(t.groupBy??e.groupBy)){const i=Pn(a);i&&(r.groupBy=i)}}else e.groupBy===void 0&&(r.groupBy=void 0);if(s==="calendar"){if(!(t.dateField??e.dateField)){const i=Mn(a);i&&(r.dateField=i)}}else e.dateField===void 0&&(r.dateField=void 0);return r}function Ln(e,t,s){const r={kind:le(e,t).kind};return s!==null&&(r.query=JSON.stringify(s)),t.groupBy!==void 0&&(r.group_by=t.groupBy),t.dateField!==void 0&&(r.date_field=t.dateField),t.fields!==void 0&&(r.fields=JSON.stringify(t.fields)),r}function _n(e,t){const s={kind:e.kind};return t!==null&&(s.query=JSON.stringify(t)),e.groupBy!==void 0&&(s.group_by=e.groupBy),e.dateField!==void 0&&(s.date_field=e.dateField),e.fields!==void 0&&(s.fields=JSON.stringify(e.fields)),s}const Bn={type:"string"};function M(e){const t=Ve(e);return t.length===1?t[0]:null}function Fn(e,t){return e.fields&&e.fields.length>0?e.fields.map(a=>({name:a,schema:(t==null?void 0:t[a])??Bn})):M(e.query)&&t?Object.entries(t).map(([a,r])=>({name:a,schema:r})):[]}function Vn(e){const t=e?M(e.query):null,s=q(t);return y.useMemo(()=>e?Fn(e,Qe(s.data)):[],[e,s.data])}function Qe(e){return(e==null?void 0:e.fields)??null}function Rn(e){const t=e?M(e.query):null,s=q(t);return y.useMemo(()=>Qe(s.data)??{},[s.data])}function On(e){const t=e?M(e.query):null,s=q(t);return t?s.isSuccess:!0}function In(e,t,s=[]){if(s.includes(t))return{pinned:[],rest:e};const a=[],r=[];for(const i of e)(i.tags??[]).includes(t)?a.push(i):r.push(i);return{pinned:a,rest:r}}function We(){return n.jsx("nav",{className:"mb-6 text-sm text-fg-dim",children:n.jsx(I,{to:"/notes",className:"focus-ring hover:text-accent",children:"← All notes"})})}function ls(){const{id:e}=Ct(),t=Re(a=>a.getActiveVault()),s=St(e);return t?s.data?n.jsx(zn,{note:s.data}):n.jsxs("div",{className:"page",children:[n.jsx(We,{}),s.isPending?n.jsx(qn,{}):s.isError?n.jsx(Oe,{title:"Couldn't load this view",message:s.error instanceof Error?s.error.message:void 0,retry:()=>s.refetch()}):n.jsx(V,{title:"View not found",description:"It may have been deleted or moved."})]}):n.jsx($t,{to:"/",replace:!0})}function qn(){return n.jsxs("div",{className:"space-y-4","aria-busy":"true",children:[n.jsx(C,{height:32,width:"40%"}),n.jsx(C,{height:20,width:"60%"}),n.jsxs("div",{className:"space-y-2 pt-4",children:[n.jsx(C,{height:56}),n.jsx(C,{height:56}),n.jsx(C,{height:56})]})]})}function zn({note:e}){const t=y.useMemo(()=>te(e),[e]);return n.jsx(Gn,{def:t,backingNote:e,nav:n.jsx(We,{})})}function Gn({def:e,backingNote:t,pageSize:s,total:a,nav:r}){var ye;const i=Re(N=>N.getActiveVault()),{roles:l}=yt((i==null?void 0:i.id)??null),o=typeof s=="number"&&s>0,[u,c]=y.useState(0),[m,p]=jt(),d=y.useMemo(()=>vt(m),[m]),h=y.useMemo(()=>Ae(e,En(m)),[e,m]),j=(N,k)=>{const T=Tn(N);for(const[_,B]of _t(k))T.append(_,B);p(T,{replace:!0})},b=N=>j(h,N),f=N=>{j(Ae(e,N),d)},g=y.useMemo(()=>le(e,h),[e,h]),v=y.useMemo(()=>JSON.stringify({q:g.query,r:d}),[g.query,d]);y.useEffect(()=>{c(0)},[v]);const x=y.useMemo(()=>!o||!g.query?g:{...g,query:{...g.query,offset:u,limit:s+1}},[o,g,u,s]),w=Nt(x,d,{live:!o}),S=y.useMemo(()=>o&&w.data?w.data.slice(0,s):w.data,[o,w.data,s]),oe=(S==null?void 0:S.length)??0,ce=o?(((ye=w.data)==null?void 0:ye.length)??0)>s:!1,Je=we(d),Xe=o&&!ce?u+oe:void 0,Ke=Je?void 0:a,E=Vn(g),Ze=Rn(g),de=[...g.problems,...w.problems],ue=y.useMemo(()=>S?In(S,l.pinned,Ve(g.query)):{pinned:[],rest:[]},[S,l.pinned,g.query]),et=t!==null,me=(He(h)||we(d))&&et,[tt,xe]=y.useState(!1),[pe,Y]=y.useState(!1),A=wt(l.view,pe),he=se(t==null?void 0:t.id),nt=kt(),fe=ae(N=>N.push),st=y.useMemo(()=>(A.data??[]).filter(N=>N.id!==(t==null?void 0:t.id)).flatMap(N=>{const k=R(te(N).title);return N.path&&N.path!==k?[N.path,k]:[k]}),[t==null?void 0:t.id,A.data]),at=async N=>{if(t)try{const k=await he.mutateAsync({path:R(N),...t.updatedAt?{if_updated_at:t.updatedAt}:{force:!0}});fe(`Renamed view to "${te(k).title}".`,"success"),Y(!1),k.id!==t.id&&nt(`/views/${encodeURIComponent(k.id)}`,{replace:!0})}catch(k){fe(`Could not rename view: ${k.message}`,"error")}},ge=()=>p(new URLSearchParams,{replace:!0}),L=y.useMemo(()=>M(g.query),[g.query]),be=On(g),[H,Q]=y.useState(null),rt=N=>{var B,je;const k=H;if(!k)return;const T=Object.entries(N),_=k==="date"?(B=T.find(([,D])=>D.type==="date"))==null?void 0:B[0]:(je=T.find(([,D])=>{var ve;return(((ve=D.enum)==null?void 0:ve.length)??0)>0})??T.find(([,D])=>D.type!=="date"))==null?void 0:je[0];_&&f({...h,[k==="group"?"groupBy":"dateField"]:_})},it=g.kind==="board"||g.kind==="table";return n.jsxs("div",{className:it?"page page-wide":"page",children:[r,n.jsxs("article",{className:me?"pb-20":void 0,children:[n.jsx(Yn,{def:g,backingNote:t,count:Ke,onRename:t?()=>Y(!0):void 0}),n.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-x-2 gap-y-2 py-1",children:[n.jsx(bn,{kind:g.kind,onSwitch:N=>f(An(e,h,N,E)),dirty:e.kind!==g.kind}),g.kind==="board"?n.jsx(kn,{value:g.groupBy,fields:E,onChange:N=>f({...h,groupBy:N}),dirty:e.groupBy!==g.groupBy,createTag:L,schemaReady:be,onAddField:()=>Q("group")}):null,g.kind==="calendar"?n.jsx(Cn,{value:g.dateField,fields:E,onChange:N=>f({...h,dateField:N}),dirty:e.dateField!==g.dateField,createTag:L,schemaReady:be,onAddField:()=>Q("date")}):null,n.jsx(fn,{fields:E,schemaFields:Ze,onChange:N=>f({...h,fields:N}),dirty:e.fields!==g.fields})]}),n.jsx(Xn,{def:e,refinements:d,onChange:b}),de.length>0?n.jsx(Qn,{problems:de}):null,n.jsx("div",{className:"mt-6",children:n.jsx(Wn,{def:g,data:S,isPending:w.isPending,isError:w.isError,error:w.error,retry:w.refetch,viewResultsKey:w.queryKey,fields:E,pinned:ue.pinned,rest:ue.rest,roles:l})}),o?n.jsx(Hn,{offset:u,shown:oe,total:Xe,hasPrev:u>0,hasNext:ce,onPrev:()=>c(N=>Math.max(0,N-s)),onNext:()=>c(N=>N+s)}):null,me?n.jsx(Un,{onSave:()=>xe(!0),onRevert:ge}):null,tt&&t?n.jsx(ss,{note:t,def:e,draft:h,refinements:d,roles:l,onClose:()=>xe(!1),onSaved:ge}):null,pe&&t?n.jsx(ns,{currentName:e.title,currentPath:t.path,existingPaths:st,isChecking:A.isPending,checkFailed:A.isError,isRenaming:he.isPending,onCancel:()=>Y(!1),onRename:at}):null,H&&L?n.jsx(Ft,{tagName:L,intent:H,onSaved:rt,onClose:()=>Q(null)}):null]})]})}function Un({onSave:e,onRevert:t}){const s=Dt(a=>a.setShown);return y.useEffect(()=>(s(!0),()=>s(!1)),[s]),n.jsx("div",{"aria-label":"View modified",className:"glass-panel fixed inset-x-0 bottom-[calc(3.5rem+env(safe-area-inset-bottom))] z-20 border-t border-border md:bottom-0 md:pb-[env(safe-area-inset-bottom)]",children:n.jsxs("div",{className:"mx-auto flex w-full max-w-(--w-page) items-center justify-between gap-3 px-5 py-2.5 md:px-10",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx("span",{"aria-hidden":"true",className:"view-modified-pulse h-2 w-2 shrink-0 rounded-full bg-accent"}),n.jsxs("p",{className:"min-w-0 text-sm text-fg-muted",children:[n.jsx("span",{className:"font-medium text-fg",children:"View modified"})," — you're exploring. Save to keep this layout."]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:t,className:"btn btn-secondary btn-touch",children:"Revert"}),n.jsx("button",{type:"button",onClick:e,className:"btn btn-primary btn-touch",children:"Save"})]})]})})}function Yn({def:e,backingNote:t,count:s,onRename:a}){return n.jsxs("header",{className:"mb-4 flex flex-wrap items-center justify-between gap-3 border-b border-border pb-5",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[n.jsx(Tt,{kind:e.kind,hueTag:Ie(e.query)}),n.jsxs("div",{className:"min-w-0",children:[n.jsx("h1",{className:"page-title truncate",children:e.title}),typeof s=="number"?n.jsx("p",{className:"text-sm text-fg-dim",children:s===1?"1 note":`${s.toLocaleString()} notes`}):null]})]}),t?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:a,className:"btn btn-secondary btn-touch",children:"Rename"}),n.jsx(I,{to:`/n/${encodeURIComponent(t.id)}/edit`,className:"btn btn-secondary btn-touch",children:"Edit view note"})]}):null]})}function Hn({offset:e,shown:t,total:s,hasPrev:a,hasNext:r,onPrev:i,onNext:l}){const o=t>0?e+1:0,u=e+t;return!a&&!r?null:n.jsxs("div",{className:"mt-6 flex items-center justify-between text-fg-dim text-sm",children:[n.jsx("span",{children:t>0?typeof s=="number"?`Showing ${o}–${u} of ${s.toLocaleString()}`:`Showing ${o}–${u}`:""}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{type:"button",disabled:!a,onClick:i,className:"btn btn-secondary btn-touch",children:"Previous"}),n.jsx("button",{type:"button",disabled:!r,onClick:l,className:"btn btn-secondary btn-touch",children:"Next"})]})]})}function Qn({problems:e}){return n.jsx("output",{"aria-live":"polite",className:"mt-4 block rounded-lg border border-(--color-warning) bg-(--color-warning-soft) p-3 text-sm text-fg",children:n.jsx("ul",{className:"list-disc space-y-1 pl-5",children:e.map((t,s)=>n.jsx("li",{children:t.message},`${t.code}-${s}`))})})}function Wn({def:e,data:t,isPending:s,isError:a,error:r,retry:i,viewResultsKey:l,fields:o,pinned:u,rest:c,roles:m}){if(e.query===null)return n.jsx(V,{title:"Nothing is being shown",description:"Fix the view's query to see results."});if(s)return n.jsxs("div",{className:"space-y-2","aria-busy":"true",children:[n.jsx(C,{height:56}),n.jsx(C,{height:56}),n.jsx(C,{height:56})]});if(a)return n.jsx(Oe,{title:"Couldn't run this view",message:r instanceof Error?r.message:void 0,retry:i});if(!t||u.length===0&&c.length===0)return n.jsx(V,{title:"No notes match this view yet."});const p=[...u,...c];switch(e.kind){case"board":if(e.groupBy)return n.jsx(rn,{notes:p,laneBy:e.groupBy,subjectTag:Ie(e.query),roles:m,viewResultsKey:l,fields:o});break;case"gallery":return n.jsx(gn,{notes:p,roles:m,viewResultsKey:l,fields:o});case"table":return n.jsx(Sn,{notes:p,roles:m,viewResultsKey:l,fields:o});case"calendar":return n.jsx(un,{notes:p,dateField:e.dateField||null,roles:m,viewResultsKey:l,fields:o})}return n.jsx(Jn,{pinned:u,rest:c,roles:m,viewResultsKey:l,fields:o})}function Jn({pinned:e,rest:t,roles:s,viewResultsKey:a,fields:r}){const i=l=>r.length>0?n.jsx(P,{note:l,fields:r,viewResultsKey:a}):null;return n.jsxs("div",{className:"space-y-6",children:[e.length>0?n.jsxs("section",{"aria-label":"Pinned",children:[n.jsx("p",{className:"eyebrow mb-2",children:"Pinned"}),n.jsx(ke,{"aria-label":"Pinned notes",children:e.map(l=>n.jsx(Ce,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})]}):null,t.length>0?n.jsx("section",{"aria-label":"Results",children:n.jsx(ke,{"aria-label":"View results",children:t.map(l=>n.jsx(Ce,{note:l,pinnedTag:s.pinned,archivedTag:s.archived,footer:i(l)},l.id))})}):null]})}function Xn({def:e,refinements:t,onChange:s}){const a=y.useMemo(()=>Et(e.query),[e.query]),r=i=>{const l=t.removeExcludes.includes(i);s({...t,removeExcludes:l?t.removeExcludes.filter(o=>o!==i):[...t.removeExcludes,i]})};return n.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[a.map(i=>n.jsx(Kn,{chip:i,toggled:i.kind==="exclude"&&!!i.value&&t.removeExcludes.includes(i.value),onToggle:i.kind==="exclude"&&i.value?()=>r(i.value):void 0},`${i.kind}-${i.value??i.label}`)),t.addTags.map(i=>n.jsx(W,{label:`+#${i}`,onRemove:()=>s({...t,addTags:t.addTags.filter(l=>l!==i)})},`add-${i}`)),t.search?n.jsx(W,{label:`"${t.search}"`,onRemove:()=>s({...t,search:void 0})}):null,t.sort?n.jsx(W,{label:`sorted by ${t.sort==="desc"?"newest":"oldest"}`,onRemove:()=>s({...t,sort:void 0})}):null,n.jsx(Zn,{onAdd:i=>s({...t,addTags:[...t.addTags,i]})}),n.jsx(es,{value:t.search??"",onChange:i=>s({...t,search:i||void 0})}),n.jsx(ts,{value:t.sort,onChange:i=>s({...t,sort:i})})]})}function Kn({chip:e,toggled:t,onToggle:s}){return s?n.jsx("button",{type:"button",onClick:s,"aria-pressed":!t,title:t?"Excluded again — tap to peek":"Tap to peek at these too",className:`chip ${t?"opacity-50 line-through":""}`,children:e.label}):n.jsx("span",{className:"chip",children:e.label})}function Zn({onAdd:e}){const[t,s]=y.useState(""),a=()=>{const r=t.trim().replace(/^#/,"");r&&(e(r),s(""))};return n.jsx("input",{type:"text",value:t,onChange:r=>s(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),a())},placeholder:"+ tag","aria-label":"Add a tag filter",className:"w-24 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function es({value:e,onChange:t}){return n.jsx("input",{type:"search",value:e,onChange:s=>t(s.target.value),placeholder:"Search…","aria-label":"Search within this view",className:"w-32 rounded-full border border-border bg-bg/40 px-2.5 py-1 text-xs text-fg focus:border-accent focus:outline-none"})}function ts({value:e,onChange:t}){return n.jsx("button",{type:"button",onClick:()=>t(e==="desc"?"asc":e==="asc"?void 0:"desc"),className:"chip","aria-label":"Cycle sort order",children:e==="desc"?"Newest first":e==="asc"?"Oldest first":"Sort"})}function ns({currentName:e,currentPath:t,existingPaths:s,isChecking:a,checkFailed:r,isRenaming:i,onCancel:l,onRename:o}){const[u,c]=y.useState(e),m=u.trim(),d=R(m)===t,h=Lt(m,s,t),j=m.length>0&&!d&&!h&&!a&&!r&&!i;return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"rename-view-title",onMouseDown:b=>{b.target===b.currentTarget&&!i&&l()},children:n.jsxs("div",{className:"dialog-panel max-w-(--w-narrow)",children:[n.jsx("h2",{id:"rename-view-title",className:"mb-3 font-serif text-xl text-fg",children:"Rename view"}),n.jsxs("label",{className:"block text-sm",children:[n.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),n.jsx("input",{type:"text",value:u,autoFocus:!0,onChange:b=>c(b.target.value),onKeyDown:b=>{b.key==="Enter"&&j&&o(m),b.key==="Escape"&&!i&&l()},"aria-label":"View name",className:"input input-on-bg"})]}),a?n.jsx("p",{className:"mt-2 text-xs text-fg-dim",children:"Checking existing views…"}):null,r?n.jsx("p",{className:"mt-2 text-xs text-danger",children:"Existing view names couldn't be checked. Close this dialog and try again."}):h?n.jsx("p",{className:"mt-2 text-xs text-danger",children:"A view with that name already exists."}):null,n.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:l,disabled:i,className:"btn btn-secondary btn-touch",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>j&&void o(m),disabled:!j,className:"btn btn-primary btn-touch",children:i?"Renaming…":"Rename"})]})]})})}function ss({note:e,def:t,draft:s,refinements:a,roles:r,onClose:i,onSaved:l}){const o=ae(x=>x.push),u=Pt(),c=Mt(e,u),[m,p]=y.useState(c),[d,h]=y.useState(`${t.title} (copy)`),[j,b]=y.useState(!1),f=se(e.id),g=At(),v=async()=>{b(!0);try{const x=Bt(t.query,a);m==="update"?(await f.mutateAsync({metadata:Ln(t,s,x),...e.updatedAt?{if_updated_at:e.updatedAt}:{force:!0}}),o(`Updated "${t.title}".`,"success")):(await g.mutateAsync({content:"",path:R(d),tags:[r.view],metadata:_n(le(t,s),x)}),o(`Saved "${d}".`,"success")),l(),i()}catch(x){o(`Could not save: ${x.message}`,"error")}finally{b(!1)}};return n.jsx("div",{className:"dialog-overlay",role:"dialog","aria-labelledby":"save-view-title",onMouseDown:x=>{x.target===x.currentTarget&&i()},children:n.jsxs("div",{className:"dialog-panel max-w-md",children:[n.jsx("h2",{id:"save-view-title",className:"mb-3 font-serif text-xl text-fg",children:"Save this view"}),n.jsxs("div",{className:"mb-4 space-y-2",children:[n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:m==="update",onChange:()=>p("update")}),"Update this view"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"radio",name:"save-mode",checked:m==="fork",onChange:()=>p("fork")}),"Save as new view"]})]}),m==="fork"?n.jsxs("label",{className:"mb-4 block text-sm",children:[n.jsx("span",{className:"mb-1 block text-fg-muted",children:"Name"}),n.jsx("input",{type:"text",value:d,onChange:x=>h(x.target.value),className:"w-full rounded-lg border border-border bg-bg/40 px-2.5 py-1.5 text-sm text-fg focus:border-accent focus:outline-none"})]}):null,n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary btn-touch",children:"Cancel"}),n.jsx("button",{type:"button",onClick:()=>void v(),disabled:j||m==="fork"&&!d.trim(),className:"btn btn-primary btn-touch",children:j?"Saving…":"Save"})]})]})})}export{Gn as ViewCanvas,ls as ViewSurface};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as w,M as N,r as i,g as y,l as v,c1 as S,q as j,w as k,j as e,N as b,_ as h,L as C}from"./index-GcTfNe1b.js";import{W as p}from"./WizardShell-dR1ElLgB.js";import{f as z}from"./provenance-Hx5MxK3k.js";import"./history-CFoof_sA.js";function K(){const r=w(),[a]=N(),[t,n]=i.useState({kind:"checking"}),[l,f]=i.useState(0),d=i.useRef(null),m=i.useRef(null),x=a.get("new")==="1";if(i.useEffect(()=>{if(x)return;const s=`${l}|${a.toString()}`;if(d.current===s)return;d.current=s,n(c=>c.kind==="checking"?c:{kind:"checking"});const o=a.get("pick")==="1";(async()=>{let c;try{c=await y()}catch{n({kind:"redirect"});return}if(!c.signed_in){n({kind:"redirect"});return}try{const{vaults:u}=await v();if(o&&u.length>0){n({kind:"picker",email:c.email,vaults:u});return}const g=S(u);g.kind==="first-vault"?n({kind:"first-vault"}):g.kind==="welcome-back"?n({kind:"welcome-back",email:c.email,vault:g.vault}):n({kind:"picker",email:c.email,vaults:g.vaults})}catch(u){n({kind:"net-error",message:u instanceof Error?u.message:"Unknown error"})}})()},[l,a,x]),i.useEffect(()=>{if(t.kind!=="welcome-back"||t.error||m.current===t.vault.name)return;m.current=t.vault.name;const s=t.vault.name;(async()=>{try{await j(s),k(s),r("/",{replace:!0})}catch(o){m.current=null,n(c=>c.kind==="welcome-back"&&c.vault.name===s?{...c,error:o instanceof Error?o.message:"Couldn't open your vault."}:c)}})()},[t,r]),x)return e.jsx(b,{to:"/add-vault/create",replace:!0});switch(t.kind){case"checking":return e.jsx(E,{});case"redirect":return e.jsx(b,{to:a.get("link")==="expired"?"/?link=expired":"/",replace:!0});case"first-vault":return e.jsx(b,{to:"/add-vault/create?first=1",replace:!0});case"net-error":return e.jsx(O,{message:t.message,onRetry:()=>{n({kind:"checking"}),f(s=>s+1)}});case"welcome-back":return e.jsx(V,{email:t.email,vaultName:t.vault.name,error:t.error,onRetry:()=>n(s=>s.kind==="welcome-back"?{...s,error:void 0}:s)});case"picker":return e.jsx(W,{email:t.email,vaults:t.vaults,onOpenVault:async s=>{await j(s.name),k(s.name),r("/")},onCreateNew:()=>{r("/add-vault/create")}});default:return null}}function E(){return e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{size:72,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-2",style:{fontSize:"clamp(1.8rem, 4vw, 2.3rem)"},children:["Signing you ",e.jsx("span",{className:"accent-word",children:"in…"})]}),e.jsx("output",{"aria-live":"polite",className:"font-round text-sm text-fg-muted",children:"Checking your vaults…"})]})}function O({message:r,onRetry:a}){return e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Almost there"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.8rem, 4vw, 2.2rem)"},children:["You're signed in — we just couldn't fetch your ",e.jsx("span",{className:"accent-word",children:"vaults."})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:r}),e.jsx("button",{type:"button",onClick:a,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]})}function V({email:r,vaultName:a,error:t,onRetry:n}){return t?e.jsxs(p,{escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:60,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"One moment"}),e.jsxs("h1",{className:"hero-title mb-4",style:{fontSize:"clamp(1.6rem, 3.5vw, 2.1rem)"},children:["Couldn't open ",e.jsxs("span",{className:"accent-word",children:[a,"."]})]}),e.jsx("p",{className:"mx-auto mb-6 max-w-sm text-fg-muted",children:t}),e.jsx("button",{type:"button",onClick:n,className:"btn btn-primary btn-lg justify-center rounded-full px-6 shadow-soft",children:"Try again"})]}):e.jsxs(p,{escape:{kind:"none"},children:[e.jsx(h,{size:76,className:"mx-auto mb-4 animate-pulse"}),e.jsx("p",{className:"eyebrow mb-3",children:"Welcome back"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.1rem)"},children:["Opening ",e.jsxs("span",{className:"accent-word",children:[a,"…"]})]}),e.jsxs("output",{"aria-live":"polite",className:"mx-auto max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," — opening ",a,"…"]})]})}function R({vault:r,busy:a,onOpen:t}){const n=z(r.usage),l=r.url?r.url.replace(/^https?:\/\//,""):"";return e.jsxs("li",{className:"card flex items-center gap-4 rounded-2xl p-4 shadow-soft",children:[e.jsx("span",{"aria-hidden":"true",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-grass-soft text-base",children:"🌱"}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-serif text-lg text-fg",children:r.name}),e.jsx("span",{className:"chip",children:"☁ Cloud"})]}),l?e.jsx("p",{className:"mt-0.5 truncate note-id",children:l}):null,n?e.jsx("p",{className:"mt-0.5 font-round text-xs text-fg-muted",children:n}):null]}),e.jsx("button",{type:"button",onClick:t,disabled:a,className:"btn btn-primary btn-touch shrink-0 rounded-full",children:a?"Opening…":"Open →"})]})}function W({email:r,vaults:a,onOpenVault:t,onCreateNew:n}){const[l,f]=i.useState(null),[d,m]=i.useState(null);async function x(s){if(!l){f(s.name),m(null);try{await t(s)}catch(o){f(null),m(o instanceof Error?o.message:"Couldn't open that vault.")}}}return e.jsxs(p,{wide:!0,escape:{kind:"back",to:"/"},children:[e.jsx(h,{size:56,className:"mx-auto mb-6"}),e.jsx("p",{className:"eyebrow mb-3",children:"Which vault"}),e.jsxs("h1",{className:"hero-title mb-3",style:{fontSize:"clamp(1.8rem, 4vw, 2.4rem)"},children:["Which vault ",e.jsx("span",{className:"accent-word",children:"today?"})]}),e.jsxs("p",{className:"mx-auto mb-8 max-w-sm text-fg-muted",children:["Signed in as ",r??"you"," · ",a.length," vault",a.length===1?"":"s"," on Cloud"]}),e.jsx("ul",{className:"mx-auto flex max-w-md flex-col gap-3",children:a.map(s=>e.jsx(R,{vault:s,busy:l===s.name,onOpen:()=>x(s)},s.name))}),d?e.jsx("p",{className:"mx-auto mt-6 max-w-sm rounded-lg border border-danger-border bg-danger-soft px-3 py-2 text-sm text-danger",children:d}):null,e.jsxs("p",{className:"mt-8 font-round text-sm text-fg-muted",children:[e.jsx("button",{type:"button",onClick:n,className:"font-semibold text-accent hover:underline",children:"+ Create a new vault"})," ","·"," ",e.jsx(C,{to:"/add",className:"font-semibold hover:underline",style:{color:"var(--color-sky)"},children:"Connect a self-hosted vault"})]})]})}export{K as Welcome};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a,r as i}from"./index-GcTfNe1b.js";function n(s){const t=a();return i.useCallback(()=>{var e;(((e=window.history.state)==null?void 0:e.idx)??0)>0?t(-1):t(s)},[t,s])}export{n as u};
|