ocean-brain 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/server/client/dist/assets/{Calendar-BytW4PeT.js → Calendar-DbPut8EU.js} +1 -1
  3. package/server/client/dist/assets/{Callout-9sJgGNRb.js → Callout-DfX-gIUB.js} +1 -1
  4. package/server/client/dist/assets/{Graph-o5u-NzrA.js → Graph-yHE9m5fy.js} +1 -1
  5. package/server/client/dist/assets/{Image-DxWhlIDG.js → Image-DK0lnaK2.js} +1 -1
  6. package/server/client/dist/assets/{Image.es-B0LL3pb7.js → Image.es-CtMc7BW4.js} +1 -1
  7. package/server/client/dist/assets/{Note-CYoYzZNu.js → Note-BECn-AoI.js} +2 -2
  8. package/server/client/dist/assets/{Plus.es-DpxzgRtY.js → Plus.es-BGVIIQtM.js} +1 -1
  9. package/server/client/dist/assets/{Reminders-DAepTZg1.js → Reminders-CvEJf0eQ.js} +1 -1
  10. package/server/client/dist/assets/{Search-6KH7An44.js → Search-CKZhztuV.js} +1 -1
  11. package/server/client/dist/assets/{SurfaceCard-EMs50xSF.js → SurfaceCard-Bnfo5EOl.js} +1 -1
  12. package/server/client/dist/assets/Tag-C4oAwjs0.js +1 -0
  13. package/server/client/dist/assets/{TagNotes-BTbu-f6v.js → TagNotes-Rl1ZSJP6.js} +1 -1
  14. package/server/client/dist/assets/{Trash.es-C5x35NKF.js → Trash.es-BcwUz2yM.js} +1 -1
  15. package/server/client/dist/assets/ViewNotes-B9Yc0A87.js +1 -0
  16. package/server/client/dist/assets/ViewSectionTableRenderer-C5yJBO7C.js +102 -0
  17. package/server/client/dist/assets/Views-Bqq0pUEE.js +1 -0
  18. package/server/client/dist/assets/{image.api-DRhRQ0Gf.js → image.api-CuGTgzyQ.js} +1 -1
  19. package/server/client/dist/assets/{index-DYlYUrjH.js → index-B43ulIPo.js} +40 -40
  20. package/server/client/dist/assets/{index-DswSFFMb.js → index-BQDR6hIA.js} +1 -1
  21. package/server/client/dist/assets/{index-Cd81UxEh.css → index-CDjYEIVf.css} +1 -1
  22. package/server/client/dist/assets/manage-image-Bs4Kmevx.js +1 -0
  23. package/server/client/dist/assets/{manage-image-detail-CJkfybR9.js → manage-image-detail-WARala-v.js} +1 -1
  24. package/server/client/dist/assets/{mcp-piouFDNm.js → mcp-C0Z3vKBa.js} +1 -1
  25. package/server/client/dist/assets/{note-core-Z6kqulGB.js → note-core-DMZcZ4yV.js} +53 -53
  26. package/server/client/dist/assets/{note-vendor-i1M2FSI2.js → note-vendor-uuJO2MTD.js} +1 -1
  27. package/server/client/dist/assets/{placeholder-DGz3CHej.js → placeholder-D080guzn.js} +3 -3
  28. package/server/client/dist/assets/{properties-CM4khczg.js → properties-DbnmfbT5.js} +1 -1
  29. package/server/client/dist/assets/trash-D5ZiZfTk.js +1 -0
  30. package/server/client/dist/assets/{useReminderMutate-DHjDDHKg.js → useReminderMutate-h7d_S_X2.js} +2 -2
  31. package/server/client/dist/index.html +4 -4
  32. package/server/dist/features/note/services/markdown-intent-write.js +17 -0
  33. package/server/dist/features/note/services/markdown-intent-write.js.map +1 -1
  34. package/server/dist/features/note/services/markdown-patch.js.map +1 -1
  35. package/server/dist/features/view/graphql/view.type-defs.js +22 -0
  36. package/server/dist/features/view/graphql/view.type-defs.js.map +1 -1
  37. package/server/dist/features/view/services/workspace.js +77 -16
  38. package/server/dist/features/view/services/workspace.js.map +1 -1
  39. package/server/dist/modules/blocknote.js +320 -5
  40. package/server/dist/modules/blocknote.js.map +1 -1
  41. package/server/prisma/schema.prisma +1 -0
  42. package/server/client/dist/assets/Tag-C89j8x56.js +0 -1
  43. package/server/client/dist/assets/ViewNotes-DPEuki3y.js +0 -1
  44. package/server/client/dist/assets/Views-BGkuNhVd.js +0 -1
  45. package/server/client/dist/assets/manage-image-C6sHhWnI.js +0 -1
  46. package/server/client/dist/assets/trash-C2lItz-b.js +0 -1
  47. package/server/client/dist/assets/view-dashboard-C17WsdL7.js +0 -99
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocean-brain",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{T as b,L as te,N as se,c as q,d as f,s as re,a as ae,M as S,b as ne,S as oe,e as F,B as O,f as ie,g as ce,u as H,q as z,h as K,P as le,i as de,j as ue,C as me}from"./index-DYlYUrjH.js";import{a as d}from"./graph-vendor-CUxe67Lr.js";import{C as he}from"./Callout-9sJgGNRb.js";import"./note-core-Z6kqulGB.js";const ge=({day:r,cellClassName:t,dayNumberClassName:s,isCurrentMonth:i,items:o,overflowCount:c,onOpenOverflow:m})=>e.jsxs("div",{className:`min-h-[196px] rounded-[16px] border p-2.5 ${t}`.trim(),children:[e.jsx("div",{className:"mb-2.5 flex justify-end",children:e.jsx(b,{as:"span",variant:"label",className:`flex h-7 w-7 items-center justify-center rounded-[10px] ${s}`.trim(),children:r})}),i&&o.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,c>0?e.jsxs("button",{type:"button",onClick:m,className:"focus-ring-soft w-full rounded-[10px] border border-dashed border-border-subtle/70 bg-subtle/70 py-1 text-center text-micro font-semibold text-fg-tertiary outline-none transition-colors hover:border-border-secondary/70 hover:bg-hover-subtle hover:text-fg-secondary",children:["+",c," more"]}):null]}):null]}),V=({params:r,toneClassName:t="",header:s,title:i,meta:o,titleClassName:c=""})=>e.jsx(te,{to:se,params:r,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:q("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-hover-subtle",t),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(b,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:q("line-clamp-1",c),children:i}),o?e.jsx(b,{as:"div",variant:"micro",weight:"medium",tone:"tertiary",className:"mt-0.5",children:o}):null]})]})}),xe=({note:r,type:t})=>e.jsx(V,{params:{id:r.id},header:e.jsx(re,{size:12}),title:r.title,meta:f(Number(t==="create"?r.createdAt:r.updatedAt)).format("HH:mm")}),pe=({reminder:r})=>e.jsx(V,{params:{id:String(r.note?.id??r.noteId)},header:e.jsx(ae,{size:12}),title:r.content||r.note?.title||"No title",titleClassName:r.completed?"line-through":"",meta:f(Number(r.reminderDate)).format("HH:mm")}),L=3,Q=(r,t)=>r.map(s=>s.type==="note"?e.jsx(xe,{note:s.item,type:t},`note-${s.item.id}`):e.jsx(pe,{reminder:s.item},`reminder-${s.item.id}`)),ye=({year:r,month:t,day:s,isCurrentMonth:i,isSunday:o,isToday:c,isPast:m,notes:h,reminders:g,type:N})=>{const[M,v]=d.useState(!1),p=d.useMemo(()=>{const a=h.map(u=>({type:"note",item:u})),l=g.map(u=>({type:"reminder",item:u}));return m?[...a,...l]:[...l,...a]},[m,h,g]),D=p.length>L,w=d.useMemo(()=>Q(p.slice(0,L),N),[p,N]),$=d.useMemo(()=>Q(p,N),[p,N]),k=d.useCallback(()=>v(!0),[]),C=d.useCallback(()=>v(!1),[]),E=()=>i?c?"border-border-secondary/70 bg-[color:color-mix(in_srgb,var(--surface)_88%,var(--accent-soft-primary)_12%)]":"bg-surface border-border-subtle":"bg-muted/18 border-border-subtle/70",I=()=>c?"bg-cta text-fg-on-filled font-semibold":i?o?"text-fg-weekend font-bold":"text-fg-secondary font-bold":"text-fg-disabled opacity-55";return e.jsxs(e.Fragment,{children:[e.jsx(ge,{day:s,cellClassName:E(),dayNumberClassName:I(),isCurrentMonth:i,items:w,overflowCount:D?p.length-L:0,onOpenOverflow:k}),D&&e.jsxs(S,{isOpen:M,onClose:C,variant:"inspect",children:[e.jsx(S.Header,{title:`${r}/${String(t).padStart(2,"0")}/${String(s).padStart(2,"0")}`,onClose:C}),e.jsxs(S.Body,{children:[e.jsxs(S.Description,{className:"sr-only",children:["View all notes and reminders scheduled for day ",s,"."]}),e.jsx("div",{className:"flex max-h-[60vh] flex-col gap-2 overflow-y-auto",children:$})]})]})]})},fe=d.memo(ye),be=["January","February","March","April","May","June","July","August","September","October","November","December"],je=({month:r,year:t,type:s,onPrevMonth:i,onNextMonth:o,onToday:c,onTypeChange:m})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(b,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:be[r-1]}),e.jsx(b,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:t})]}),e.jsx(b,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(b,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Note date"}),e.jsxs(oe,{value:s,onValueChange:g=>m(g),variant:"ghost",size:"sm",children:[e.jsx(F,{value:"create",children:"Created"}),e.jsx(F,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(O,{variant:"ghost",size:"sm",onClick:c,children:"Today"}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:i,children:e.jsx(ie,{width:18,height:18})}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:o,children:e.jsx(ce,{width:18,height:18})})]})]})})]}),Ne=`
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{T as b,L as te,N as se,c as q,d as f,s as re,a as ae,M as S,b as ne,S as oe,e as F,B as O,f as ie,g as ce,u as H,q as z,h as K,P as le,i as de,j as ue,C as me}from"./index-B43ulIPo.js";import{a as d}from"./graph-vendor-CUxe67Lr.js";import{C as he}from"./Callout-DfX-gIUB.js";import"./note-core-DMZcZ4yV.js";const ge=({day:r,cellClassName:t,dayNumberClassName:s,isCurrentMonth:i,items:o,overflowCount:c,onOpenOverflow:m})=>e.jsxs("div",{className:`min-h-[196px] rounded-[16px] border p-2.5 ${t}`.trim(),children:[e.jsx("div",{className:"mb-2.5 flex justify-end",children:e.jsx(b,{as:"span",variant:"label",className:`flex h-7 w-7 items-center justify-center rounded-[10px] ${s}`.trim(),children:r})}),i&&o.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[o,c>0?e.jsxs("button",{type:"button",onClick:m,className:"focus-ring-soft w-full rounded-[10px] border border-dashed border-border-subtle/70 bg-subtle/70 py-1 text-center text-micro font-semibold text-fg-tertiary outline-none transition-colors hover:border-border-secondary/70 hover:bg-hover-subtle hover:text-fg-secondary",children:["+",c," more"]}):null]}):null]}),V=({params:r,toneClassName:t="",header:s,title:i,meta:o,titleClassName:c=""})=>e.jsx(te,{to:se,params:r,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:q("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-hover-subtle",t),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(b,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:q("line-clamp-1",c),children:i}),o?e.jsx(b,{as:"div",variant:"micro",weight:"medium",tone:"tertiary",className:"mt-0.5",children:o}):null]})]})}),xe=({note:r,type:t})=>e.jsx(V,{params:{id:r.id},header:e.jsx(re,{size:12}),title:r.title,meta:f(Number(t==="create"?r.createdAt:r.updatedAt)).format("HH:mm")}),pe=({reminder:r})=>e.jsx(V,{params:{id:String(r.note?.id??r.noteId)},header:e.jsx(ae,{size:12}),title:r.content||r.note?.title||"No title",titleClassName:r.completed?"line-through":"",meta:f(Number(r.reminderDate)).format("HH:mm")}),L=3,Q=(r,t)=>r.map(s=>s.type==="note"?e.jsx(xe,{note:s.item,type:t},`note-${s.item.id}`):e.jsx(pe,{reminder:s.item},`reminder-${s.item.id}`)),ye=({year:r,month:t,day:s,isCurrentMonth:i,isSunday:o,isToday:c,isPast:m,notes:h,reminders:g,type:N})=>{const[M,v]=d.useState(!1),p=d.useMemo(()=>{const a=h.map(u=>({type:"note",item:u})),l=g.map(u=>({type:"reminder",item:u}));return m?[...a,...l]:[...l,...a]},[m,h,g]),D=p.length>L,w=d.useMemo(()=>Q(p.slice(0,L),N),[p,N]),$=d.useMemo(()=>Q(p,N),[p,N]),k=d.useCallback(()=>v(!0),[]),C=d.useCallback(()=>v(!1),[]),E=()=>i?c?"border-border-secondary/70 bg-[color:color-mix(in_srgb,var(--surface)_88%,var(--accent-soft-primary)_12%)]":"bg-surface border-border-subtle":"bg-muted/18 border-border-subtle/70",I=()=>c?"bg-cta text-fg-on-filled font-semibold":i?o?"text-fg-weekend font-bold":"text-fg-secondary font-bold":"text-fg-disabled opacity-55";return e.jsxs(e.Fragment,{children:[e.jsx(ge,{day:s,cellClassName:E(),dayNumberClassName:I(),isCurrentMonth:i,items:w,overflowCount:D?p.length-L:0,onOpenOverflow:k}),D&&e.jsxs(S,{isOpen:M,onClose:C,variant:"inspect",children:[e.jsx(S.Header,{title:`${r}/${String(t).padStart(2,"0")}/${String(s).padStart(2,"0")}`,onClose:C}),e.jsxs(S.Body,{children:[e.jsxs(S.Description,{className:"sr-only",children:["View all notes and reminders scheduled for day ",s,"."]}),e.jsx("div",{className:"flex max-h-[60vh] flex-col gap-2 overflow-y-auto",children:$})]})]})]})},fe=d.memo(ye),be=["January","February","March","April","May","June","July","August","September","October","November","December"],je=({month:r,year:t,type:s,onPrevMonth:i,onNextMonth:o,onToday:c,onTypeChange:m})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(b,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:be[r-1]}),e.jsx(b,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:t})]}),e.jsx(b,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(b,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Note date"}),e.jsxs(oe,{value:s,onValueChange:g=>m(g),variant:"ghost",size:"sm",children:[e.jsx(F,{value:"create",children:"Created"}),e.jsx(F,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(O,{variant:"ghost",size:"sm",onClick:c,children:"Today"}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:i,children:e.jsx(ie,{width:18,height:18})}),e.jsx(O,{variant:"ghost",size:"icon-sm",onClick:o,children:e.jsx(ce,{width:18,height:18})})]})]})})]}),Ne=`
2
2
  query NotesInDateRange($dateRange: DateRangeInput) {
3
3
  notesInDateRange(dateRange: $dateRange) {
4
4
  id
@@ -1 +1 @@
1
- import{j as n}from"./note-vendor-i1M2FSI2.js";import{p as m,T as d}from"./index-DYlYUrjH.js";import{a as e}from"./graph-vendor-CUxe67Lr.js";const p=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z"}))]]),g=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z"}))]]),l=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:p}));l.displayName="InfoIcon";const E=l,c=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:g}));c.displayName="WarningCircleIcon";const i=c,f=({children:a,className:t="",tone:r="info"})=>{const o=r==="danger"?i:E,Z=r==="danger"?"border-border-error/70 bg-accent-soft-danger/60":"border-border-subtle bg-hover-subtle/50",s=r==="danger"?"text-fg-error":"text-fg-tertiary",A=r==="danger"?"error":"secondary";return n.jsxs("div",{className:`flex items-center gap-2.5 rounded-[12px] border px-4 py-3 ${Z} ${t}`,children:[n.jsx(o,{className:`h-4 w-4 shrink-0 ${s}`}),n.jsx(d,{as:"div",variant:"meta",weight:"medium",tone:A,children:a})]})};export{f as C,i as m};
1
+ import{j as n}from"./note-vendor-uuJO2MTD.js";import{p as m,T as d}from"./index-B43ulIPo.js";import{a as e}from"./graph-vendor-CUxe67Lr.js";const p=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z"}))]]),g=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z"}))]]),l=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:p}));l.displayName="InfoIcon";const E=l,c=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:g}));c.displayName="WarningCircleIcon";const i=c,f=({children:a,className:t="",tone:r="info"})=>{const o=r==="danger"?i:E,Z=r==="danger"?"border-border-error/70 bg-accent-soft-danger/60":"border-border-subtle bg-hover-subtle/50",s=r==="danger"?"text-fg-error":"text-fg-tertiary",A=r==="danger"?"error":"secondary";return n.jsxs("div",{className:`flex items-center gap-2.5 rounded-[12px] border px-4 py-3 ${Z} ${t}`,children:[n.jsx(o,{className:`h-4 w-4 shrink-0 ${s}`}),n.jsx(d,{as:"div",variant:"meta",weight:"medium",tone:A,children:a})]})};export{f as C,i as m};
@@ -1 +1 @@
1
- import{j as t}from"./note-vendor-i1M2FSI2.js";import{a0 as _,P as C,a3 as U,i as G,a4 as Y,a5 as J,a6 as X,a7 as ee,q as ne,N as te,G as re,T as N,a8 as oe}from"./index-DYlYUrjH.js";import{a as i,F as se}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const ae=s=>{let a=0;for(let r=0;r<s.length;r++)a+=s.charCodeAt(r);return a},ie={background:"#f4f6f8",nodeHub:"#2c2f36",nodeSelected:"#111318",nodeConnected:"#636b76",nodeDefault:["#d6dbe1","#c8ced6","#b7bec7","#a7afb9"],nodeDimmed:["rgba(214,219,225,0.28)","rgba(200,206,214,0.24)","rgba(183,190,199,0.24)","rgba(167,175,185,0.2)"],nodeHubDimmed:"rgba(44,47,54,0.16)",nodeStroke:"#eef1f4",nodeSelectedStroke:"#a6b0bc",labelBackground:"rgba(246,248,250,0.92)",labelText:"#222831",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(99, 107, 117, 0.34)",linkConnected:"#68717c",linkDimmed:"rgba(127, 136, 146, 0.12)",legendHub:"#2c2f36"},le={background:"#121316",nodeHub:"#d6dce3",nodeSelected:"#eef1f5",nodeConnected:"#9099a4",nodeDefault:["#343a43","#2d333c","#262c35","#20262f"],nodeDimmed:["rgba(52,58,67,0.28)","rgba(45,51,60,0.24)","rgba(38,44,53,0.22)","rgba(32,38,47,0.2)"],nodeHubDimmed:"rgba(214,220,227,0.16)",nodeStroke:"#171c23",nodeSelectedStroke:"#7f8a97",labelBackground:"rgba(16,18,22,0.9)",labelText:"#eef2f6",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(118, 127, 138, 0.42)",linkConnected:"#a2abb6",linkDimmed:"rgba(118, 127, 138, 0.1)",legendHub:"#d6dce3"};function D(s){return s==="dark"?le:ie}function de(s,a){const r=D(s),{connections:g,colorIndex:y,selectedNodeId:d,nodeId:b,isConnected:c}=a,h=d===b;return d!==null&&!h&&!c?g>3?r.nodeHubDimmed:r.nodeDimmed[y%r.nodeDimmed.length]:h?r.nodeSelected:c?r.nodeConnected:g>3?r.nodeHub:r.nodeDefault[y%r.nodeDefault.length]}function ce(s,a){const r=D(s);return a.selectedNodeId!==null&&!a.isConnected?r.linkDimmed:a.isConnected?r.linkConnected:r.linkIdle}function ue(s,a){const r=D(s);return`${a.emphasize?"700":"400"} ${a.fontSize}px ${r.labelFontFamily}`}function z(s){return s<=1?3.5:s<=3?4.5:s<=6?5.5:Math.min(7,5.5+Math.sqrt(s)*.5)}const fe=t.jsx(C,{title:"Knowledge Graph",description:t.jsx(G,{width:184,height:16,className:"rounded-full"}),children:t.jsx("div",{className:"flex h-[600px] items-center justify-center",children:t.jsx(G,{width:"100%",height:"100%"})})});function he(){const s=Y(),a=i.useRef(null),r=i.useRef(null),[g,y]=i.useState({width:800,height:600}),[d,b]=i.useState(null),{theme:c}=J(e=>e),h=D(c),v=i.useRef(h);v.current=h;const{data:w}=X({queryKey:ne.notes.graph(),queryFn:async()=>{const e=await ee();if(e.type==="error")throw e;return e.noteGraph}}),l=i.useMemo(()=>{if(w.nodes.length===0)return null;const e=w.nodes.filter(o=>o.connections>0);if(e.length===0)return null;const n=new Set(e.map(o=>o.id));return{nodes:e,links:w.links.filter(o=>n.has(o.source)&&n.has(o.target))}},[w]);i.useEffect(()=>{if(!l)return;const e=()=>{if(!a.current)return;const n=a.current.getBoundingClientRect();y({width:n.width,height:Math.max(600,window.innerHeight-150)})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l]),i.useEffect(()=>{if(!l||!r.current)return;const e=window.setTimeout(()=>{r.current?.zoomToFit(400,50)},500);return()=>window.clearTimeout(e)},[l]);const R=i.useRef(d);R.current=d;const B=i.useCallback(e=>{if(R.current===e.id){s({to:te,params:{id:e.id}});return}b(e.id)},[s]),L=i.useCallback(()=>{b(null)},[]),K=i.useCallback(e=>{a.current&&(a.current.style.cursor=e?"pointer":"default")},[]),I=i.useRef(!1),q=i.useCallback(()=>{I.current||(I.current=!0,r.current?.enableZoomInteraction(!1))},[]),A=i.useCallback(()=>{I.current=!1,r.current?.enableZoomInteraction(!0)},[]),H=i.useRef(new Map),O=i.useMemo(()=>{const e=new Map;if(l)for(const n of l.links)e.has(n.source)||e.set(n.source,new Set),e.has(n.target)||e.set(n.target,new Set),e.get(n.source)?.add(n.target),e.get(n.target)?.add(n.source);return e},[l]);H.current=O;const Z=i.useCallback((e,n,o)=>{const u=v.current,f=d,p=H.current,m=z(e.connections),x=e.x||0,S=e.y||0,k=f===e.id,T=f?p.get(f)?.has(e.id)??!1:!1,V=f!==null&&!k&&!T,W=ae(e.id);if(n.beginPath(),n.arc(x,S,m,0,Math.PI*2),n.fillStyle=de(c,{connections:e.connections,colorIndex:W,selectedNodeId:f,nodeId:e.id,isConnected:T}),n.fill(),V)return;n.strokeStyle=u.nodeStroke,n.lineWidth=(k?2:1)/o,n.stroke(),k&&(n.beginPath(),n.arc(x,S,m+2/o,0,Math.PI*2),n.strokeStyle=u.nodeSelectedStroke,n.lineWidth=1.5/o,n.stroke());const Q=T&&e.connections>=4;if(k||Q||o>2.5){const P=e.title||"Untitled",E=Math.max(10/o,2.5);n.font=ue(c,{fontSize:E,emphasize:k}),n.textAlign="center",n.textBaseline="top";const M=n.measureText(P).width,j=2/o,F=S+m+3/o;n.fillStyle=u.labelBackground,n.fillRect(x-M/2-j,F,M+j*2,E+j*2),n.fillStyle=u.labelText,n.fillText(P,x,F+j)}},[d,c]),$=i.useCallback((e,n,o)=>{const u=d,f=e.source,p=e.target,m=u?f.id===u||p.id===u:!1;n.beginPath(),n.moveTo(f.x||0,f.y||0),n.lineTo(p.x||0,p.y||0),n.strokeStyle=ce(c,{selectedNodeId:u,isConnected:m}),n.lineWidth=m?2/o:.5/o,n.stroke()},[d,c]);return l?t.jsx(C,{title:"Knowledge Graph",description:`${l.nodes.length} linked notes, ${l.links.length} connections`,children:t.jsxs("div",{ref:a,className:"surface-base graph-canvas relative overflow-hidden",style:{"--graph-bg":h.background},children:[d&&(()=>{const e=l.nodes.find(n=>n.id===d);return e?t.jsxs("div",{className:"surface-floating absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-2",children:[t.jsx(N,{as:"span",variant:"meta",weight:"semibold",truncate:!0,className:"max-w-48",children:e.title}),t.jsxs(N,{as:"span",variant:"label",tone:"tertiary",children:[e.connections," links"]}),t.jsx("button",{type:"button",onClick:()=>b(null),className:"focus-ring-soft ml-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-[8px] text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default","aria-label":"Deselect node",children:t.jsx(oe,{className:"h-3.5 w-3.5"})})]}):null})(),t.jsxs("div",{className:"surface-floating absolute top-3 right-3 z-10 flex flex-col gap-1.5 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.legendHub}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Hub notes (4+ connections)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.nodeConnected}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Connected notes"})]})]}),t.jsx(se,{ref:r,graphData:l,width:g.width,height:g.height,nodeId:"id",nodeLabel:"",nodeCanvasObject:Z,nodePointerAreaPaint:(e,n,o)=>{o.beginPath(),o.arc(e.x||0,e.y||0,Math.max(z(e.connections)+4,10),0,2*Math.PI),o.fillStyle=n,o.fill()},linkCanvasObject:$,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:0,onNodeClick:B,onNodeHover:K,onBackgroundClick:L,onNodeDrag:q,onNodeDragEnd:A,warmupTicks:30,cooldownTicks:80,d3AlphaDecay:.05,d3VelocityDecay:.3,enableZoomInteraction:!0,enablePanInteraction:!0,minZoom:.3,maxZoom:5})]})}):t.jsx(C,{title:"Knowledge Graph",description:"0 linked notes, 0 connections",children:t.jsx(re,{title:"No constellations yet",description:"Link your notes together and watch your own starry sky unfold"})})}function ke(){return t.jsx(_,{fallback:fe,errorTitle:"Failed to load graph",errorDescription:"Retry loading your linked note constellation",renderError:({error:s,retry:a})=>t.jsx(C,{title:"Knowledge Graph",children:t.jsx(U,{title:"Failed to load graph",description:"Retry loading your linked note constellation",error:s,onRetry:a})}),children:t.jsx(he,{})})}export{ke as default};
1
+ import{j as t}from"./note-vendor-uuJO2MTD.js";import{a0 as _,P as C,a3 as U,i as G,a4 as J,a5 as Y,a6 as X,a7 as ee,q as ne,N as te,J as re,T as N,a8 as oe}from"./index-B43ulIPo.js";import{a as i,F as se}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const ae=s=>{let a=0;for(let r=0;r<s.length;r++)a+=s.charCodeAt(r);return a},ie={background:"#f4f6f8",nodeHub:"#2c2f36",nodeSelected:"#111318",nodeConnected:"#636b76",nodeDefault:["#d6dbe1","#c8ced6","#b7bec7","#a7afb9"],nodeDimmed:["rgba(214,219,225,0.28)","rgba(200,206,214,0.24)","rgba(183,190,199,0.24)","rgba(167,175,185,0.2)"],nodeHubDimmed:"rgba(44,47,54,0.16)",nodeStroke:"#eef1f4",nodeSelectedStroke:"#a6b0bc",labelBackground:"rgba(246,248,250,0.92)",labelText:"#222831",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(99, 107, 117, 0.34)",linkConnected:"#68717c",linkDimmed:"rgba(127, 136, 146, 0.12)",legendHub:"#2c2f36"},le={background:"#121316",nodeHub:"#d6dce3",nodeSelected:"#eef1f5",nodeConnected:"#9099a4",nodeDefault:["#343a43","#2d333c","#262c35","#20262f"],nodeDimmed:["rgba(52,58,67,0.28)","rgba(45,51,60,0.24)","rgba(38,44,53,0.22)","rgba(32,38,47,0.2)"],nodeHubDimmed:"rgba(214,220,227,0.16)",nodeStroke:"#171c23",nodeSelectedStroke:"#7f8a97",labelBackground:"rgba(16,18,22,0.9)",labelText:"#eef2f6",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(118, 127, 138, 0.42)",linkConnected:"#a2abb6",linkDimmed:"rgba(118, 127, 138, 0.1)",legendHub:"#d6dce3"};function D(s){return s==="dark"?le:ie}function de(s,a){const r=D(s),{connections:g,colorIndex:y,selectedNodeId:d,nodeId:b,isConnected:c}=a,h=d===b;return d!==null&&!h&&!c?g>3?r.nodeHubDimmed:r.nodeDimmed[y%r.nodeDimmed.length]:h?r.nodeSelected:c?r.nodeConnected:g>3?r.nodeHub:r.nodeDefault[y%r.nodeDefault.length]}function ce(s,a){const r=D(s);return a.selectedNodeId!==null&&!a.isConnected?r.linkDimmed:a.isConnected?r.linkConnected:r.linkIdle}function ue(s,a){const r=D(s);return`${a.emphasize?"700":"400"} ${a.fontSize}px ${r.labelFontFamily}`}function z(s){return s<=1?3.5:s<=3?4.5:s<=6?5.5:Math.min(7,5.5+Math.sqrt(s)*.5)}const fe=t.jsx(C,{title:"Knowledge Graph",description:t.jsx(G,{width:184,height:16,className:"rounded-full"}),children:t.jsx("div",{className:"flex h-[600px] items-center justify-center",children:t.jsx(G,{width:"100%",height:"100%"})})});function he(){const s=J(),a=i.useRef(null),r=i.useRef(null),[g,y]=i.useState({width:800,height:600}),[d,b]=i.useState(null),{theme:c}=Y(e=>e),h=D(c),v=i.useRef(h);v.current=h;const{data:w}=X({queryKey:ne.notes.graph(),queryFn:async()=>{const e=await ee();if(e.type==="error")throw e;return e.noteGraph}}),l=i.useMemo(()=>{if(w.nodes.length===0)return null;const e=w.nodes.filter(o=>o.connections>0);if(e.length===0)return null;const n=new Set(e.map(o=>o.id));return{nodes:e,links:w.links.filter(o=>n.has(o.source)&&n.has(o.target))}},[w]);i.useEffect(()=>{if(!l)return;const e=()=>{if(!a.current)return;const n=a.current.getBoundingClientRect();y({width:n.width,height:Math.max(600,window.innerHeight-150)})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l]),i.useEffect(()=>{if(!l||!r.current)return;const e=window.setTimeout(()=>{r.current?.zoomToFit(400,50)},500);return()=>window.clearTimeout(e)},[l]);const R=i.useRef(d);R.current=d;const B=i.useCallback(e=>{if(R.current===e.id){s({to:te,params:{id:e.id}});return}b(e.id)},[s]),L=i.useCallback(()=>{b(null)},[]),K=i.useCallback(e=>{a.current&&(a.current.style.cursor=e?"pointer":"default")},[]),I=i.useRef(!1),q=i.useCallback(()=>{I.current||(I.current=!0,r.current?.enableZoomInteraction(!1))},[]),A=i.useCallback(()=>{I.current=!1,r.current?.enableZoomInteraction(!0)},[]),H=i.useRef(new Map),O=i.useMemo(()=>{const e=new Map;if(l)for(const n of l.links)e.has(n.source)||e.set(n.source,new Set),e.has(n.target)||e.set(n.target,new Set),e.get(n.source)?.add(n.target),e.get(n.target)?.add(n.source);return e},[l]);H.current=O;const Z=i.useCallback((e,n,o)=>{const u=v.current,f=d,p=H.current,m=z(e.connections),x=e.x||0,S=e.y||0,k=f===e.id,T=f?p.get(f)?.has(e.id)??!1:!1,V=f!==null&&!k&&!T,W=ae(e.id);if(n.beginPath(),n.arc(x,S,m,0,Math.PI*2),n.fillStyle=de(c,{connections:e.connections,colorIndex:W,selectedNodeId:f,nodeId:e.id,isConnected:T}),n.fill(),V)return;n.strokeStyle=u.nodeStroke,n.lineWidth=(k?2:1)/o,n.stroke(),k&&(n.beginPath(),n.arc(x,S,m+2/o,0,Math.PI*2),n.strokeStyle=u.nodeSelectedStroke,n.lineWidth=1.5/o,n.stroke());const Q=T&&e.connections>=4;if(k||Q||o>2.5){const P=e.title||"Untitled",E=Math.max(10/o,2.5);n.font=ue(c,{fontSize:E,emphasize:k}),n.textAlign="center",n.textBaseline="top";const M=n.measureText(P).width,j=2/o,F=S+m+3/o;n.fillStyle=u.labelBackground,n.fillRect(x-M/2-j,F,M+j*2,E+j*2),n.fillStyle=u.labelText,n.fillText(P,x,F+j)}},[d,c]),$=i.useCallback((e,n,o)=>{const u=d,f=e.source,p=e.target,m=u?f.id===u||p.id===u:!1;n.beginPath(),n.moveTo(f.x||0,f.y||0),n.lineTo(p.x||0,p.y||0),n.strokeStyle=ce(c,{selectedNodeId:u,isConnected:m}),n.lineWidth=m?2/o:.5/o,n.stroke()},[d,c]);return l?t.jsx(C,{title:"Knowledge Graph",description:`${l.nodes.length} linked notes, ${l.links.length} connections`,children:t.jsxs("div",{ref:a,className:"surface-base graph-canvas relative overflow-hidden",style:{"--graph-bg":h.background},children:[d&&(()=>{const e=l.nodes.find(n=>n.id===d);return e?t.jsxs("div",{className:"surface-floating absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-2",children:[t.jsx(N,{as:"span",variant:"meta",weight:"semibold",truncate:!0,className:"max-w-48",children:e.title}),t.jsxs(N,{as:"span",variant:"label",tone:"tertiary",children:[e.connections," links"]}),t.jsx("button",{type:"button",onClick:()=>b(null),className:"focus-ring-soft ml-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-[8px] text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default","aria-label":"Deselect node",children:t.jsx(oe,{className:"h-3.5 w-3.5"})})]}):null})(),t.jsxs("div",{className:"surface-floating absolute top-3 right-3 z-10 flex flex-col gap-1.5 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.legendHub}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Hub notes (4+ connections)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.nodeConnected}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Connected notes"})]})]}),t.jsx(se,{ref:r,graphData:l,width:g.width,height:g.height,nodeId:"id",nodeLabel:"",nodeCanvasObject:Z,nodePointerAreaPaint:(e,n,o)=>{o.beginPath(),o.arc(e.x||0,e.y||0,Math.max(z(e.connections)+4,10),0,2*Math.PI),o.fillStyle=n,o.fill()},linkCanvasObject:$,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:0,onNodeClick:B,onNodeHover:K,onBackgroundClick:L,onNodeDrag:q,onNodeDragEnd:A,warmupTicks:30,cooldownTicks:80,d3AlphaDecay:.05,d3VelocityDecay:.3,enableZoomInteraction:!0,enablePanInteraction:!0,minZoom:.3,maxZoom:5})]})}):t.jsx(C,{title:"Knowledge Graph",description:"0 linked notes, 0 connections",children:t.jsx(re,{title:"No constellations yet",description:"Link your notes together and watch your own starry sky unfold"})})}function ke(){return t.jsx(_,{fallback:fe,errorTitle:"Failed to load graph",errorDescription:"Retry loading your linked note constellation",renderError:({error:s,retry:a})=>t.jsx(C,{title:"Knowledge Graph",children:t.jsx(U,{title:"Failed to load graph",description:"Retry loading your linked note constellation",error:s,onRetry:a})}),children:t.jsx(he,{})})}export{ke as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{a as g}from"./graph-vendor-CUxe67Lr.js";function u({src:r,alt:n,loading:t="lazy",className:i}){const s=g.useRef(null);return g.useEffect(()=>{if(!s.current||t!=="lazy"||!r)return;const a=new IntersectionObserver(([c])=>{if(c.isIntersecting){const A=c.target;A.src=A.dataset.src,a.unobserve(A)}});return a.observe(s.current),()=>{a.disconnect()}},[t,r]),e.jsx(e.Fragment,{children:t!=="lazy"?e.jsx("img",{src:r,alt:n,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()}):e.jsx("img",{ref:s,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2O4evXqfwAIgQN/QHwrfwAAAABJRU5ErkJggg==",alt:n,"data-src":r,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()})})}export{u as I};
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{a as g}from"./graph-vendor-CUxe67Lr.js";function u({src:r,alt:n,loading:t="lazy",className:i}){const s=g.useRef(null);return g.useEffect(()=>{if(!s.current||t!=="lazy"||!r)return;const a=new IntersectionObserver(([c])=>{if(c.isIntersecting){const A=c.target;A.src=A.dataset.src,a.unobserve(A)}});return a.observe(s.current),()=>{a.disconnect()}},[t,r]),e.jsx(e.Fragment,{children:t!=="lazy"?e.jsx("img",{src:r,alt:n,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()}):e.jsx("img",{ref:s,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2O4evXqfwAIgQN/QHwrfwAAAABJRU5ErkJggg==",alt:n,"data-src":r,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()})})}export{u as I};
@@ -1 +1 @@
1
- import{a}from"./graph-vendor-CUxe67Lr.js";import{p as m}from"./index-DYlYUrjH.js";const n=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M144,96a16,16,0,1,1,16,16A16,16,0,0,1,144,96Zm92-40V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56ZM44,60v79.72l33.86-33.86a20,20,0,0,1,28.28,0L147.31,147l17.18-17.17a20,20,0,0,1,28.28,0L212,149.09V60Zm0,136H162.34L92,125.66l-48,48Zm168,0V183l-33.37-33.37L164.28,164l32,32Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,56V178.06l-39.72-39.72a8,8,0,0,0-11.31,0L147.31,164,97.66,114.34a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM156,88a12,12,0,1,1-12,12A12,12,0,0,1,156,88Zm60,112H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0h0L165,181.66a8,8,0,0,0,11.32-11.32l-17.66-17.65L173,138.34a8,8,0,0,1,11.31,0L216,170.07V200Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM40,54H216a2,2,0,0,1,2,2V163.57L188.53,134.1a14,14,0,0,0-19.8,0l-21.42,21.42L101.9,110.1a14,14,0,0,0-19.8,0L38,154.2V56A2,2,0,0,1,40,54ZM38,200V171.17l52.58-52.58a2,2,0,0,1,2.84,0L176.83,202H40A2,2,0,0,1,38,200Zm178,2H193.8l-38-38,21.41-21.42a2,2,0,0,1,2.83,0l38,38V200A2,2,0,0,1,216,202ZM146,100a10,10,0,1,1,10,10A10,10,0,0,1,146,100Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM40,52H216a4,4,0,0,1,4,4V168.4l-32.89-32.89a12,12,0,0,0-17,0l-22.83,22.83-46.82-46.83a12,12,0,0,0-17,0L36,159V56A4,4,0,0,1,40,52ZM36,200V170.34l53.17-53.17a4,4,0,0,1,5.66,0L181.66,204H40A4,4,0,0,1,36,200Zm180,4H193l-40-40,22.83-22.83a4,4,0,0,1,5.66,0L220,179.71V200A4,4,0,0,1,216,204ZM148,100a8,8,0,1,1,8,8A8,8,0,0,1,148,100Z"}))]]),e=a.forwardRef((l,t)=>a.createElement(m,{ref:t,...l,weights:n}));e.displayName="ImageIcon";const Z=e;export{Z as I};
1
+ import{a}from"./graph-vendor-CUxe67Lr.js";import{p as m}from"./index-B43ulIPo.js";const n=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M144,96a16,16,0,1,1,16,16A16,16,0,0,1,144,96Zm92-40V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56ZM44,60v79.72l33.86-33.86a20,20,0,0,1,28.28,0L147.31,147l17.18-17.17a20,20,0,0,1,28.28,0L212,149.09V60Zm0,136H162.34L92,125.66l-48,48Zm168,0V183l-33.37-33.37L164.28,164l32,32Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,56V178.06l-39.72-39.72a8,8,0,0,0-11.31,0L147.31,164,97.66,114.34a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM156,88a12,12,0,1,1-12,12A12,12,0,0,1,156,88Zm60,112H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0h0L165,181.66a8,8,0,0,0,11.32-11.32l-17.66-17.65L173,138.34a8,8,0,0,1,11.31,0L216,170.07V200Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM40,54H216a2,2,0,0,1,2,2V163.57L188.53,134.1a14,14,0,0,0-19.8,0l-21.42,21.42L101.9,110.1a14,14,0,0,0-19.8,0L38,154.2V56A2,2,0,0,1,40,54ZM38,200V171.17l52.58-52.58a2,2,0,0,1,2.84,0L176.83,202H40A2,2,0,0,1,38,200Zm178,2H193.8l-38-38,21.41-21.42a2,2,0,0,1,2.83,0l38,38V200A2,2,0,0,1,216,202ZM146,100a10,10,0,1,1,10,10A10,10,0,0,1,146,100Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM40,52H216a4,4,0,0,1,4,4V168.4l-32.89-32.89a12,12,0,0,0-17,0l-22.83,22.83-46.82-46.83a12,12,0,0,0-17,0L36,159V56A4,4,0,0,1,40,52ZM36,200V170.34l53.17-53.17a4,4,0,0,1,5.66,0L181.66,204H40A4,4,0,0,1,36,200Zm180,4H193l-40-40,22.83-22.83a4,4,0,0,1,5.66,0L220,179.71V200A4,4,0,0,1,216,204ZM148,100a8,8,0,1,1,8,8A8,8,0,0,1,148,100Z"}))]]),e=a.forwardRef((l,t)=>a.createElement(m,{ref:t,...l,weights:n}));e.displayName="ImageIcon";const Z=e;export{Z as I};
@@ -1,4 +1,4 @@
1
- import{j as e,i as qe,k as na,U as dt,y as ut,v as ra,X as sa,F as oa}from"./note-vendor-i1M2FSI2.js";import{af as la,p as Qe,T as h,c as q,M as H,r as me,B as R,w as we,u as _e,ag as ia,q as T,ah as ca,ai as da,aj as ua,d as W,X as Ye,a6 as pt,ak as pa,l as Ee,I as $e,m as ma,n as fa,o as Me,$ as mt,D as ft,k as ht,g as ha,al as xa,a as ga,am as xt,an as ya,ao as gt,a4 as yt,N as ve,ad as va,x as ba,ap as wa,a5 as ja,aq as Ie,ar as ye,a0 as Ue,P as Ge,a3 as Ze,as as Na,at as Ca,au as ka,av as Aa,aw as tt,ax as Sa,i as ie,L as Ke,j as Ra,ay as Ta,az as Ea,aA as at,F as Ma,aB as Ha,S as nt,e as He,a8 as Da,aC as Fa,aD as La,aE as Va,aF as Pa,aG as Oa,aH as Ba,aI as rt,aJ as _a,aK as $a}from"./index-DYlYUrjH.js";import{a as n}from"./graph-vendor-CUxe67Lr.js";import{C as st,m as Ia}from"./Callout-9sJgGNRb.js";import{S as Ua}from"./SurfaceCard-EMs50xSF.js";import{u as Za,R as Ka}from"./useReminderMutate-DHjDDHKg.js";import{n as ze}from"./Plus.es-DpxzgRtY.js";import{u as za}from"./image.api-DRhRQ0Gf.js";import{A as qa,G as Qa,a3 as vt,a4 as Ya}from"./note-core-Z6kqulGB.js";function Ga(t,a){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const r=!!(t.condition??!0),l=t.blockerFn;return{shouldBlockFn:async()=>r&&l!==void 0?await l():r,enableBeforeUnload:r,withResolver:l===void 0}}function Wa(t,a){const{shouldBlockFn:r,enableBeforeUnload:l=!0,disabled:s=!1,withResolver:d=!1}=Ga(t),i=la(),{history:u}=i,[c,x]=n.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return n.useEffect(()=>{const m=async N=>{function j(M){const C=i.parseLocation(M),b=i.getMatchedRoutes(C.pathname);return b.foundRoute===void 0?{routeId:"__notFound__",fullPath:C.pathname,pathname:C.pathname,params:b.routeParams,search:i.options.parseSearch(M.search)}:{routeId:b.foundRoute.id,fullPath:b.foundRoute.fullPath,pathname:C.pathname,params:b.routeParams,search:i.options.parseSearch(M.search)}}const y=j(N.currentLocation),S=j(N.nextLocation);if(y.routeId==="__notFound__"&&S.routeId!=="__notFound__")return!1;const f=await r({action:N.action,current:y,next:S});if(!d)return f;if(!f)return!1;const V=await new Promise(M=>{x({status:"blocked",current:y,next:S,action:N.action,proceed:()=>M(!1),reset:()=>M(!0)})});return x({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),V};return s?void 0:u.block({blockerFn:m,enableBeforeUnload:l})},[r,l,s,d,u,i]),c}const Ja=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z"}))]]),Xa=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),en=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),n.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),bt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:Ja}));bt.displayName="CopyIcon";const tn=bt,wt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:Xa}));wt.displayName="FileIcon";const an=wt,jt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:en}));jt.displayName="LinkSimpleIcon";const Nt=jt;function Ct({icon:t,title:a,className:r}){return e.jsxs("div",{className:q("flex items-center gap-2",r),children:[e.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:t}),e.jsx(h,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:a})]})}function We({title:t,icon:a,action:r,titleButtonProps:l,ariaLabel:s,className:d,children:i}){const u=i!=null&&i!==!1,c=r!=null&&r!==!1,x=e.jsx(Ct,{icon:a,title:t,className:"text-fg-tertiary"});return e.jsxs("section",{className:q("surface-base mb-5 p-4",d),"aria-label":s??t,children:[e.jsxs("div",{className:q("relative",c&&"pr-44 sm:pr-48",u&&"mb-3"),children:[l?e.jsx("button",{...l,type:"button",className:q("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",l.className),children:x}):x,c&&e.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:r})]}),i]})}function ue({title:t,description:a,selected:r=!1,onClick:l,children:s}){return e.jsxs("button",{type:"button","aria-pressed":r,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${r?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:l,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:r?"default":"secondary",children:t}),e.jsx(h,{as:"div",variant:"meta",weight:"medium",tone:r?"secondary":"tertiary",className:"mt-1",children:a})]}),s?e.jsx("div",{className:"shrink-0",children:s}):null]})}const nn=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function rn({isOpen:t,onClose:a,onSave:r,currentLayout:l="wide"}){const[s,d]=n.useState(l);n.useEffect(()=>{t&&d(l)},[t,l]);const i=()=>{r(s),a()};return e.jsxs(H,{isOpen:t,onClose:a,variant:"compact",children:[e.jsx(H.Header,{title:"Layout Settings",onClose:a}),e.jsx(H.Body,{children:e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),e.jsx("div",{className:"flex flex-col gap-2",children:nn.map(u=>e.jsx(ue,{title:u.label,description:u.description,selected:s===u.value,onClick:()=>d(u.value)},u.value))})]})})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:i,children:"Apply"})]})})]})}const kt=t=>t==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:t==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},sn=({isDeleted:t,isConflict:a,source:r})=>{const l=kt(r);return t?`This note was moved to trash ${l.place}`:a?`Save paused: note changed ${l.place}`:`This note changed ${l.place}`},on=({isDeleted:t,isConflict:a,hasDraft:r,source:l})=>{const s=kt(l);return t?`${s.actor} moved this note to trash. Open trash to review or restore it.`:a&&r?`Your draft is saved locally. Reload the latest note, overwrite ${s.target}, or clone your draft into a new note.`:a?`The layout change is paused because the note changed ${s.place}. Reload the latest note or overwrite only the layout.`:`${s.actor} changed this note while it was open here. Reload the latest version before continuing.`};function ln({isOpen:t,isDeleted:a,isConflict:r,hasDraft:l,source:s,isReloading:d,onReload:i,onOverwrite:u,onCloneDraft:c,onOpenTrash:x}){return e.jsxs(H,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(H.Header,{title:sn({isDeleted:a,isConflict:r,source:s})}),e.jsx(H.Body,{children:e.jsx(h,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:on({isDeleted:a,isConflict:r,hasDraft:l,source:s})})}),e.jsx(H.Footer,{children:e.jsx(me,{children:a?e.jsx(R,{type:"button",variant:"primary",size:"sm",onClick:x,children:"Open trash"}):r?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:i,children:"Reload latest"}),l&&e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(R,{type:"button",variant:"danger",size:"sm",onClick:u,children:"Overwrite"})]}):e.jsx(R,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:i,children:"Reload latest"})})})]})}const ot=(t,a)=>t||(a==="mobile"?"Mobile browser":a==="mcp"?"MCP":"Web browser");function cn({isOpen:t,noteId:a,onClose:r,onRestored:l}){const s=Ye(),d=we(),[i,u]=n.useState(null),c=n.useRef(null),x=_e({queryKey:T.notes.snapshots(a),queryFn:async()=>{const f=await ia(a);if(f.type==="error")throw f;return f.noteSnapshots},enabled:t}),m=ca({mutationFn:da,onSuccess:async f=>{if(f.type==="error"){s(f.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:T.notes.detail(a),exact:!0}),d.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagNameListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.pinned(),exact:!0}),d.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.graph(),exact:!0}),d.invalidateQueries({queryKey:T.notes.snapshots(a),exact:!1}),d.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),s("Previous version restored."),l?.(f.restoreNoteSnapshot),u(null),r()}}),N=x.data?.find(f=>f.id===i)??null,j=_e({queryKey:T.notes.snapshotDetail(i??"pending"),queryFn:async()=>{if(!i)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await ua(i);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!i}),y=j.data?.contentAsMarkdown.trim()??"";n.useEffect(()=>{i&&c.current?.focus()},[i]);const S=()=>{u(null),r()};return e.jsxs(H,{isOpen:t,onClose:S,variant:"inspect",children:[e.jsx(H.Header,{title:N?"Snapshot Content":"Restore Previous Version",onClose:S}),e.jsx(H.Description,{className:"sr-only",children:N?"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(H.Body,{children:N?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:N.title}),e.jsxs(h,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ot(N.meta.label,N.meta.entrypoint)," ","edit - ",W(N.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),j.isLoading?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):j.isError?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):y?e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:y}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),x.isLoading&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!x.isLoading&&x.data?.length===0&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!x.isLoading&&x.data&&x.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:x.data.map(f=>e.jsx(Ua,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(h,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ot(f.meta.label,f.meta.entrypoint)," ","edit"]}),e.jsx(h,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),e.jsx(h,{as:"p",variant:"label",tone:"tertiary",children:W(f.createdAt).format("YYYY-MM-DD HH:mm:ss")}),f.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(R,{variant:"subtle",size:"sm",onClick:()=>u(f.id),children:"View content"}),e.jsx(R,{size:"sm",isLoading:m.isPending,onClick:()=>m.mutate(f.id),children:"Restore"})]})]})},f.id))})]})}),N&&e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{ref:c,variant:"subtle",onClick:()=>u(null),children:"Back"}),e.jsx(R,{disabled:!j.data||j.isError,isLoading:m.isPending,onClick:()=>m.mutate(N.id),children:"Restore this version"})]})})]})}const dn=t=>{const{data:a}=pt({queryKey:T.notes.backReferences(t.noteId),async queryFn(){const r=await pa(t.noteId);if(r.type==="error")throw r;return r.backReferences}});return t.render(a)};let un="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pn=(t=21)=>{let a="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)a+=un[r[t]&63];return a};const lt={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function mn({isOpen:t,onClose:a,onSave:r,reminder:l,mode:s}){const[d,i]=n.useState(new Date),[u,c]=n.useState("medium"),[x,m]=n.useState("");n.useEffect(()=>{t&&s==="edit"&&l?(i(new Date(Number(l.reminderDate))),c(l.priority||"medium"),m(l.content||"")):t&&s==="create"&&(i(new Date),c("medium"),m(""))},[t,s,l]);const N=()=>{r(d,u,x||void 0),a()},j=y=>u===y?lt[y].active:lt[y].inactive;return e.jsxs(H,{isOpen:t,onClose:a,variant:"form",children:[e.jsx(H.Header,{title:s==="create"?"Create Reminder":"Edit Reminder",onClose:a}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Date & Time"}),e.jsx($e,{type:"datetime-local",size:"sm",value:W(d).format("YYYY-MM-DDTHH:mm"),onChange:y=>i(new Date(y.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Content"}),e.jsx(ma,{size:"sm",placeholder:"Enter reminder content (optional)",value:x,onChange:y=>m(y.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Priority"}),e.jsxs(fa,{type:"single",variant:"quiet",value:u,onValueChange:y=>y&&c(y),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(Me,{value:"low",className:`flex-1 rounded-[10px] border ${j("low")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),e.jsx(Me,{value:"medium",className:`flex-1 rounded-[10px] border ${j("medium")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),e.jsx(Me,{value:"high",className:`flex-1 rounded-[10px] border ${j("high")}`,children:e.jsx(h,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:N,children:s==="create"?"Create":"Save"})]})})]})}function fn({noteId:t}){const[a,r]=n.useState(!1),[l,s]=n.useState(!1),[d,i]=n.useState("create"),[u,c]=n.useState(void 0),{onCreate:x,onUpdate:m,onDelete:N}=Za(),j=()=>{i("create"),c(void 0),s(!0)},y=C=>{i("edit"),c(C),s(!0)},S=(C,b,v)=>{d==="create"?x(t,C,b,()=>{s(!1)},v):d==="edit"&&u&&m(u.id,t,{reminderDate:C,priority:b,content:v},()=>{s(!1)})},f=C=>{m(C.id,t,{completed:!C.completed})},F=C=>{const b=W(Number(C)),v=W();return b.isSame(v,"day")?`Today at ${b.format("HH:mm")}`:b.isSame(v.add(1,"day"),"day")?`Tomorrow at ${b.format("HH:mm")}`:b.format("YYYY-MM-DD HH:mm")},V=C=>{const b=W(Number(C)),v=W(),P=b.diff(v,"hour");return P<=6?"high":P<=24?"medium":"low"},M=C=>{const b=W(Number(C)),v=W(),P=b.diff(v,"hour"),_=b.diff(v,"minute")%60;return P<0||_<0?"Overdue":P===0?`${_}m remaining`:`${P}h ${_}m remaining`};return e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"Reminders",icon:e.jsx(ga,{className:"h-3.5 w-3.5"}),action:e.jsxs(e.Fragment,{children:[!a&&e.jsxs(R,{size:"sm",variant:"ghost",onClick:j,children:[e.jsx(ze,{className:"w-3 h-3"}),e.jsx(h,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),e.jsxs(R,{type:"button",size:"sm",variant:"ghost","aria-label":a?"Expand reminders":"Collapse reminders","aria-expanded":!a,onClick:()=>r(!a),children:[a?e.jsx(ha,{className:"h-3.5 w-3.5"}):e.jsx(xa,{className:"h-3.5 w-3.5"}),a?"Expand":"Collapse"]})]}),children:!a&&e.jsx(Ka,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:C,totalCount:b})=>e.jsx("div",{className:"flex flex-col gap-2",children:C.length===0?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:b===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:C.map(v=>{const P=v.priority||V(v.reminderDate),_=M(v.reminderDate),D=_==="Overdue";return e.jsxs("div",{className:q("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(mt,{checked:v.completed,onChange:()=>f(v),size:"sm"}),e.jsx(h,{as:"div",variant:"body",weight:"medium",className:q("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||F(v.reminderDate)}),e.jsxs("div",{className:q("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&e.jsx(h,{as:"span",variant:"meta",tone:"secondary",children:F(v.reminderDate)}),!v.completed&&e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:D||P==="high"?"error":"tertiary",className:q(v.content&&'before:content-["·"] before:mr-1'),children:_})]}),e.jsx(ft,{button:e.jsx(ht,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>y(v)},{name:"Delete",onClick:()=>N(v.id,t)}]})]},v.id)})})})})}),e.jsx(mn,{isOpen:l,onClose:()=>s(!1),onSave:S,reminder:u,mode:d})]})}const hn=({editor:t})=>e.jsx(qe,{triggerCharacter:"/",getItems:async a=>qa([...na(t).filter(r=>r.title!=="Audio"&&r.title!=="Video"&&r.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{t.insertBlocks([{type:"tableOfContents"}],t.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:e.jsx(xt,{})}],a)}),xn=(t,a)=>a?t.filter(r=>r.id!==a):t,gn=({currentNoteId:t,onClick:a})=>e.jsx(qe,{triggerCharacter:"[",getItems:async r=>{const l=await ya({query:r,limit:5});return l.type==="error"?[]:xn(l.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>a({type:"reference",props:{id:d.id,title:d.title}})}))}}),yn="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",vn={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},bn={idle:"Copy",copied:"Copied",failed:"Copy failed"},wn=({getText:t,resetDelayMs:a=2e3})=>{const[r,l]=n.useState("idle"),s=n.useRef(null),d=n.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),i=n.useCallback(()=>{d(),s.current=setTimeout(()=>{l("idle"),s.current=null},a)},[d,a]);n.useEffect(()=>d,[d]);const u=m=>{m.stopPropagation()},c=m=>{m.preventDefault(),m.stopPropagation()},x=async m=>{u(m);try{await navigator.clipboard.writeText(t()),l("copied")}catch{l("failed")}i()};return e.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:c,children:e.jsxs("button",{type:"button",className:q(yn,vn[r]),contentEditable:!1,onClick:x,children:[e.jsx(tn,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:bn[r]})]})})},jn=({contentRef:t})=>{const a=n.useRef(null),r=n.useCallback(l=>{a.current=l,t(l)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:r})}),e.jsx(wn,{getText:()=>a.current?.textContent?.trimEnd()??""})]})},Nn="_Reference_102im_1",Cn={Reference:Nn},kn=gt.bind(Cn),An={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function Sn(t){const a=yt(),r=()=>{t.editor.blur(),a({to:ve,params:{id:t.inlineContent.props.id}})},l=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:kn("Reference"),onMouseDown:l,onClick:s=>{l(s),r()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(l(s),r())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const Rn=dt(An,{render:t=>e.jsx(Sn,{...t})}),Tn=()=>{const t=ra(),[a,r]=n.useState([]),l={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};n.useEffect(()=>{const i=()=>{const c=t.document,x=[],m=N=>{for(const j of N){if(j.type==="heading"){const y=j,S=y.props.level||1,f=y.content?.map(F=>F.text||"").join("")||"";f.trim()&&x.push({id:j.id,level:S,text:f})}j.children&&Array.isArray(j.children)&&m(j.children)}};m(c),r(x)};i();const u=t.onChange?.(i);return()=>{u&&u()}},[t]);const s=i=>{t.setTextCursorPosition(i);const u=document.querySelector(`[data-id="${i}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"center"})},d=e.jsx(Ct,{icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return a.length===0?e.jsxs("div",{className:"surface-base w-full p-4",children:[d,e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):e.jsxs("div",{className:"surface-base w-full p-4",children:[e.jsx("div",{className:"mb-2",children:d}),e.jsx("nav",{className:"space-y-0.5",children:a.map(i=>{const u=i.level===1;return e.jsxs("button",{type:"button",onClick:()=>s(i.id),className:q("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",l[i.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",u?"text-fg-default":"text-fg-secondary"),children:[e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",i.level]}),e.jsx(h,{as:"span",variant:"body",weight:u?"semibold":"medium",className:"line-clamp-2 text-current",children:i.text})]},i.id)})})]})},En=ut({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(Tn,{})})(),Mn="_Tag_1gb8h_1",Hn={Tag:Mn},Dn=gt.bind(Hn),Fn={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Ln(t){const a=yt(),r=()=>{t.editor.blur(),a({to:va,params:{id:t.inlineContent.props.id},search:{page:1}})},l=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Dn("Tag"),onMouseDown:l,onClick:s=>{l(s),r()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(l(s),r())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const Vn=dt(Fn,{render:t=>e.jsx(Ln,{...t})}),Pn=t=>t,On=t=>t,Bn=Pn({tag:Vn,reference:Rn}),_n=On({tableOfContents:En}),se=vt.codeBlock,it=ut(se.config,{meta:se.implementation.meta,parse:se.implementation.parse,parseContent:se.implementation.parseContent,runsBefore:se.implementation.runsBefore,render:jn})(),$n={...it,extensions:se.extensions,implementation:{...it.implementation,toExternalHTML:se.implementation.toExternalHTML}},In=Qa.create({inlineContentSpecs:{...Ya,...Bn},blockSpecs:{...vt,codeBlock:$n,..._n}}),Un=(t,a)=>a.some(r=>r.name===`@${t}`),Zn=({onClick:t})=>e.jsx(qe,{triggerCharacter:"@",getItems:async a=>{const r=await ba({query:a,limit:5});if(r.type==="error")return[];const{tags:l}=r.allTags,s=Un(a,l),d=[{title:"Add a new tag",onItemClick:async()=>{const i=await wa({name:"@"+a});if(i.type==="error")return;const{id:u,name:c}=i.createTag;t({type:"tag",props:{id:u,tag:c}})}}];return l.length===0?d:l.map(i=>({title:i.name,onItemClick:()=>t({type:"tag",props:{id:i.id,tag:i.name}})})).concat(a&&!s?d:[])}}),Kn=new Set(["tableOfContents"]),zn="OCEAN_BRAIN_TAG_",qn="_TOKEN",Qn=t=>`${zn}${t}${qn}`,Yn=t=>!Array.isArray(t)&&t?.type==="tableContent",Gn=(t,a)=>Array.isArray(t)?t.map(a):Yn(t)?{...t,rows:t.rows?.map(r=>({...r,cells:r.cells?.map(l=>({...l,content:l.content?.map(a)}))}))}:t,At=(t,a)=>t.filter(r=>!Kn.has(r.type)).map(r=>({...r,content:a(r.content),children:r.children?.length?At(r.children,a):[]}));function Wn(t){const a=new Map;let r=0;return{blocks:At(t,s=>Gn(s,d=>{if(d.type==="reference")return{type:"text",text:`[[${d.props?.title||d.props?.id||""}]]`,styles:{}};if(d.type==="tag"){const i=d.props?.tag||"",u=Qn(r);return r+=1,a.set(u,i),{type:"text",text:u,styles:{}}}return d})),placeholderToTag:a}}function Jn(t,a){let r=t;for(const[l,s]of a.entries())r=r.split(l).join(`[${s}]`);return r}async function Xn(t){return new Promise((a,r)=>{const l=new FileReader;l.readAsDataURL(t),l.onload=()=>a(l.result),l.onerror=s=>r(s)})}const er=n.forwardRef(({content:t,currentNoteId:a,editable:r,onChange:l},s)=>{const{theme:d}=ja(u=>u),i=sa({schema:In,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async u=>za({base64:await Xn(u)})},[]);return n.useImperativeHandle(s,()=>({getContent:()=>JSON.stringify(i.document),getMarkdown:()=>{const u=Wn(i.document),c=i.blocksToMarkdownLossy(u.blocks);return Jn(c,u.placeholderToTag)},getHtml:()=>i.blocksToHTMLLossy(i.document)})),e.jsxs(oa,{slashMenu:!1,theme:d,editor:i,editable:r,onChange:l,children:[e.jsx(hn,{editor:i}),e.jsx(gn,{currentNoteId:a,onClick:u=>{i.insertInlineContent([u," "])}}),e.jsx(Zn,{onClick:u=>{i.insertInlineContent([u," "])}})]})}),Je=t=>`ocean-brain.note-draft.${t}`,tr=t=>{if(typeof window>"u")return null;try{const a=window.localStorage.getItem(Je(t));if(!a)return null;const r=JSON.parse(a);return typeof r.title!="string"||typeof r.content!="string"||typeof r.baseUpdatedAt!="string"?null:{title:r.title,content:r.content,baseUpdatedAt:r.baseUpdatedAt,createdAt:typeof r.createdAt=="number"?r.createdAt:Date.now(),...r.layout==="narrow"||r.layout==="wide"||r.layout==="full"?{layout:r.layout}:{}}}catch{return null}},De=(t,a)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(t),JSON.stringify(a))}catch{}},Fe=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(t))}catch{}},ar=1e3,nr="NOTE_UPDATE_CONFLICT";function rr({noteId:t,initialContent:a,initialUpdatedAt:r,editSessionIdRef:l,getContent:s,onSaved:d,onConflict:i,onError:u}){const c=we(),x=n.useRef(null),m=n.useRef(null),N=n.useRef(!1),j=n.useRef(null),y=n.useRef(!1),S=n.useRef(r),f=n.useRef(!1),F=n.useRef(!0),V=n.useRef(d),M=n.useRef(i),C=n.useRef(u),[b,v]=n.useState("saved"),[P,_]=n.useState(null),D=n.useCallback(()=>{x.current!==null&&(window.clearTimeout(x.current),x.current=null)},[]),O=n.useCallback(A=>{F.current&&v(A)},[]),J=n.useCallback(A=>{S.current=A},[]),Y=n.useCallback((A,B={})=>({title:A,content:s()??a,createdAt:Date.now(),baseUpdatedAt:S.current,...B.layout?{layout:B.layout}:{}}),[s,a]),ne=n.useCallback(()=>{m.current&&De(t,m.current)},[t]),G=n.useCallback(A=>{f.current=!0,O("conflict"),M.current(A??S.current)},[O]),Q=n.useCallback(async({ignoreConflict:A=!1,silent:B=!1}={})=>{if(N.current)return y.current=!0,j.current??"idle";const $=m.current;if(!$)return y.current=!1,"idle";m.current=null,y.current=!1,D(),N.current=!0,B||O("saving");const U=(async()=>{let Z;try{Z=await Ie({id:t,title:$.title,content:$.content,...$.layout?{layout:$.layout}:{},editSessionId:l.current,...A?{force:!0}:{expectedUpdatedAt:$.baseUpdatedAt}})}catch{Z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(N.current=!1,j.current=null,Z.type==="error"){m.current||(m.current=$),ne();const X=Z.errors[0];if(X.code===nr&&!A){const k=X.details?.extensions?.currentUpdatedAt;return f.current=!0,!B&&F.current&&(O("conflict"),M.current(k??S.current)),"conflict"}return!B&&F.current&&(O("error"),C.current(X.message)),"error"}f.current=!1,S.current=Z.updateNote.updatedAt;const K=!B&&F.current,re=T.notes.detail(t);await c.cancelQueries({queryKey:re,exact:!0}),K&&V.current(Z.updateNote.updatedAt),c.setQueryData(re,X=>X&&{...X,title:Z.updateNote.title,content:$.content,...$.layout?{layout:$.layout}:{},updatedAt:Z.updateNote.updatedAt}),ye({noteId:t,updatedAt:Z.updateNote.updatedAt,editSessionId:l.current});const I=m.current;return I?.baseUpdatedAt===$.baseUpdatedAt?(m.current={...I,baseUpdatedAt:Z.updateNote.updatedAt},ne()):I||Fe(t),K&&(m.current?v("pending"):(v("saved"),c.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.graph(),exact:!0}))),m.current||y.current?Q({silent:B}):"saved"})();return j.current=U,U},[D,l,t,ne,c,O]),p=n.useCallback((A,B={})=>{if(m.current=A,De(t,A),f.current){O("conflict");return}if(O("pending"),D(),B.immediate){Q();return}x.current=window.setTimeout(()=>{Q()},ar)},[D,Q,t,O]),E=n.useCallback(A=>{if(m.current=A,De(t,A),_(null),A.baseUpdatedAt!==S.current){G(S.current);return}p(A)},[t,p,G]),w=n.useCallback(()=>{D(),m.current=null,j.current=null,y.current=!1,f.current=!1,Fe(t),_(null),v("saved")},[D,t]),L=n.useCallback(()=>{D(),j.current=null,y.current=!1,f.current=!1,O(m.current?"pending":"saved")},[D,O]),je=n.useCallback(()=>{Fe(t),_(null)},[t]),oe=n.useCallback(()=>m.current,[]),Ne=n.useCallback(A=>{D(),G(A)},[D,G]);return n.useEffect(()=>{M.current=i,C.current=u,V.current=d},[i,u,d]),n.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),n.useEffect(()=>{m.current||N.current||f.current||(S.current=r,v("saved"))},[r]),n.useEffect(()=>{m.current=null,N.current=!1,j.current=null,y.current=!1,f.current=!1,S.current=r,_(tr(t)),v("saved")},[t]),n.useEffect(()=>{const A=B=>{!m.current&&!N.current&&!f.current||(B.preventDefault(),B.returnValue="")};return window.addEventListener("beforeunload",A),()=>{window.removeEventListener("beforeunload",A)}},[]),n.useEffect(()=>()=>{D(),m.current&&!f.current&&Q({silent:!0})},[D,Q]),{saveStatus:b,localDraft:P,serverUpdatedAtRef:S,hasUnsavedChanges:b!=="saved",buildDraft:Y,queueSave:p,flushPendingSave:Q,restoreLocalDraft:E,discardLocalDraft:je,clearDrafts:w,resolveConflict:L,pauseForConflict:Ne,getPendingDraft:oe,setServerUpdatedAt:J}}const sr=/[:{}[\],&*#?|<>=!%@`-]/,or=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",lr=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),ge=t=>t?sr.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',be=t=>{if(!t)return;const a=Number(t);return Number.isFinite(a)?new Date(a).toISOString():t},Le=(t,a)=>`${or(t)}.${a}`,ir=({id:t,title:a,createdAt:r,updatedAt:l})=>{const s=["---",`title: ${ge(a)}`,`note_id: ${ge(t)}`],d=be(r),i=be(l);return d&&s.push(`created_at: ${ge(d)}`),i&&s.push(`updated_at: ${ge(i)}`),s.push("source: ocean-brain","---"),s.join(`
1
+ import{j as e,i as qe,k as na,U as dt,y as ut,v as ra,X as sa,F as oa}from"./note-vendor-uuJO2MTD.js";import{af as la,p as Qe,T as x,c as q,M as H,x as me,B as R,k as we,u as _e,ag as ia,q as T,ah as ca,ai as da,aj as ua,d as W,m as Ye,a6 as pt,ak as pa,n as Ee,I as $e,w as ma,o as fa,r as Me,v as mt,D as ft,l as ht,g as ha,al as xa,a as ga,am as xt,an as ya,ao as gt,a4 as yt,N as ve,ad as va,z as ba,ap as wa,a5 as ja,aq as Ie,ar as ye,a0 as Ue,P as Ge,a3 as Ze,as as Na,at as Ca,au as ka,av as Aa,aw as tt,ax as Sa,i as ie,L as Ke,j as Ra,ay as Ta,az as Ea,aA as at,H as Ma,aB as Ha,S as nt,e as He,a8 as Da,aC as La,aD as Va,aE as Fa,aF as Pa,aG as Oa,aH as Ba,aI as rt,aJ as _a,aK as $a}from"./index-B43ulIPo.js";import{a as n}from"./graph-vendor-CUxe67Lr.js";import{C as st,m as Ia}from"./Callout-DfX-gIUB.js";import{S as Ua}from"./SurfaceCard-Bnfo5EOl.js";import{u as Za,R as Ka}from"./useReminderMutate-h7d_S_X2.js";import{n as ze}from"./Plus.es-BGVIIQtM.js";import{u as za}from"./image.api-CuGTgzyQ.js";import{A as qa,G as Qa,a3 as vt,a4 as Ya}from"./note-core-DMZcZ4yV.js";function Ga(t,a){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const r=!!(t.condition??!0),l=t.blockerFn;return{shouldBlockFn:async()=>r&&l!==void 0?await l():r,enableBeforeUnload:r,withResolver:l===void 0}}function Wa(t,a){const{shouldBlockFn:r,enableBeforeUnload:l=!0,disabled:s=!1,withResolver:d=!1}=Ga(t),i=la(),{history:u}=i,[c,h]=n.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return n.useEffect(()=>{const m=async N=>{function j(M){const C=i.parseLocation(M),b=i.getMatchedRoutes(C.pathname);return b.foundRoute===void 0?{routeId:"__notFound__",fullPath:C.pathname,pathname:C.pathname,params:b.routeParams,search:i.options.parseSearch(M.search)}:{routeId:b.foundRoute.id,fullPath:b.foundRoute.fullPath,pathname:C.pathname,params:b.routeParams,search:i.options.parseSearch(M.search)}}const y=j(N.currentLocation),S=j(N.nextLocation);if(y.routeId==="__notFound__"&&S.routeId!=="__notFound__")return!1;const f=await r({action:N.action,current:y,next:S});if(!d)return f;if(!f)return!1;const F=await new Promise(M=>{h({status:"blocked",current:y,next:S,action:N.action,proceed:()=>M(!1),reset:()=>M(!0)})});return h({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),F};return s?void 0:u.block({blockerFn:m,enableBeforeUnload:l})},[r,l,s,d,u,i]),c}const Ja=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z"}))]]),Xa=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),en=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),n.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),bt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:Ja}));bt.displayName="CopyIcon";const tn=bt,wt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:Xa}));wt.displayName="FileIcon";const an=wt,jt=n.forwardRef((t,a)=>n.createElement(Qe,{ref:a,...t,weights:en}));jt.displayName="LinkSimpleIcon";const Nt=jt;function Ct({icon:t,title:a,className:r}){return e.jsxs("div",{className:q("flex items-center gap-2",r),children:[e.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:t}),e.jsx(x,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:a})]})}function We({title:t,icon:a,action:r,titleButtonProps:l,ariaLabel:s,className:d,children:i}){const u=i!=null&&i!==!1,c=r!=null&&r!==!1,h=e.jsx(Ct,{icon:a,title:t,className:"text-fg-tertiary"});return e.jsxs("section",{className:q("surface-base mb-5 p-4",d),"aria-label":s??t,children:[e.jsxs("div",{className:q("relative",c&&"pr-44 sm:pr-48",u&&"mb-3"),children:[l?e.jsx("button",{...l,type:"button",className:q("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",l.className),children:h}):h,c&&e.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:r})]}),i]})}function ue({title:t,description:a,selected:r=!1,onClick:l,children:s}){return e.jsxs("button",{type:"button","aria-pressed":r,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${r?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:l,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:r?"default":"secondary",children:t}),e.jsx(x,{as:"div",variant:"meta",weight:"medium",tone:r?"secondary":"tertiary",className:"mt-1",children:a})]}),s?e.jsx("div",{className:"shrink-0",children:s}):null]})}const nn=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function rn({isOpen:t,onClose:a,onSave:r,currentLayout:l="wide"}){const[s,d]=n.useState(l);n.useEffect(()=>{t&&d(l)},[t,l]);const i=()=>{r(s),a()};return e.jsxs(H,{isOpen:t,onClose:a,variant:"compact",children:[e.jsx(H.Header,{title:"Layout Settings",onClose:a}),e.jsx(H.Body,{children:e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),e.jsx("div",{className:"flex flex-col gap-2",children:nn.map(u=>e.jsx(ue,{title:u.label,description:u.description,selected:s===u.value,onClick:()=>d(u.value)},u.value))})]})})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:i,children:"Apply"})]})})]})}const kt=t=>t==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:t==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},sn=({isDeleted:t,isConflict:a,source:r})=>{const l=kt(r);return t?`This note was moved to trash ${l.place}`:a?`Save paused: note changed ${l.place}`:`This note changed ${l.place}`},on=({isDeleted:t,isConflict:a,hasDraft:r,source:l})=>{const s=kt(l);return t?`${s.actor} moved this note to trash. Open trash to review or restore it.`:a&&r?`Your draft is saved locally. Reload the latest note, overwrite ${s.target}, or clone your draft into a new note.`:a?`The layout change is paused because the note changed ${s.place}. Reload the latest note or overwrite only the layout.`:`${s.actor} changed this note while it was open here. Reload the latest version before continuing.`};function ln({isOpen:t,isDeleted:a,isConflict:r,hasDraft:l,source:s,isReloading:d,onReload:i,onOverwrite:u,onCloneDraft:c,onOpenTrash:h}){return e.jsxs(H,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(H.Header,{title:sn({isDeleted:a,isConflict:r,source:s})}),e.jsx(H.Body,{children:e.jsx(x,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:on({isDeleted:a,isConflict:r,hasDraft:l,source:s})})}),e.jsx(H.Footer,{children:e.jsx(me,{children:a?e.jsx(R,{type:"button",variant:"primary",size:"sm",onClick:h,children:"Open trash"}):r?e.jsxs(e.Fragment,{children:[e.jsx(R,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:i,children:"Reload latest"}),l&&e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(R,{type:"button",variant:"danger",size:"sm",onClick:u,children:"Overwrite"})]}):e.jsx(R,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:i,children:"Reload latest"})})})]})}const ot=(t,a)=>t||(a==="mobile"?"Mobile browser":a==="mcp"?"MCP":"Web browser");function cn({isOpen:t,noteId:a,onClose:r,onRestored:l}){const s=Ye(),d=we(),[i,u]=n.useState(null),c=n.useRef(null),h=_e({queryKey:T.notes.snapshots(a),queryFn:async()=>{const f=await ia(a);if(f.type==="error")throw f;return f.noteSnapshots},enabled:t}),m=ca({mutationFn:da,onSuccess:async f=>{if(f.type==="error"){s(f.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:T.notes.detail(a),exact:!0}),d.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.tagNameListAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.pinned(),exact:!0}),d.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),d.invalidateQueries({queryKey:T.notes.graph(),exact:!0}),d.invalidateQueries({queryKey:T.notes.snapshots(a),exact:!1}),d.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),s("Previous version restored."),l?.(f.restoreNoteSnapshot),u(null),r()}}),N=h.data?.find(f=>f.id===i)??null,j=_e({queryKey:T.notes.snapshotDetail(i??"pending"),queryFn:async()=>{if(!i)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await ua(i);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!i}),y=j.data?.contentAsMarkdown.trim()??"";n.useEffect(()=>{i&&c.current?.focus()},[i]);const S=()=>{u(null),r()};return e.jsxs(H,{isOpen:t,onClose:S,variant:"inspect",children:[e.jsx(H.Header,{title:N?"Snapshot Content":"Restore Previous Version",onClose:S}),e.jsx(H.Description,{className:"sr-only",children:N?"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(H.Body,{children:N?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(x,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:N.title}),e.jsxs(x,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ot(N.meta.label,N.meta.entrypoint)," ","edit - ",W(N.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),j.isLoading?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):j.isError?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):y?e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:y}):e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(x,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),h.isLoading&&e.jsx(x,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!h.isLoading&&h.data?.length===0&&e.jsx(x,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!h.isLoading&&h.data&&h.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:h.data.map(f=>e.jsx(Ua,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(x,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",ot(f.meta.label,f.meta.entrypoint)," ","edit"]}),e.jsx(x,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),e.jsx(x,{as:"p",variant:"label",tone:"tertiary",children:W(f.createdAt).format("YYYY-MM-DD HH:mm:ss")}),f.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(R,{variant:"subtle",size:"sm",onClick:()=>u(f.id),children:"View content"}),e.jsx(R,{size:"sm",isLoading:m.isPending,onClick:()=>m.mutate(f.id),children:"Restore"})]})]})},f.id))})]})}),N&&e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{ref:c,variant:"subtle",onClick:()=>u(null),children:"Back"}),e.jsx(R,{disabled:!j.data||j.isError,isLoading:m.isPending,onClick:()=>m.mutate(N.id),children:"Restore this version"})]})})]})}const dn=t=>{const{data:a}=pt({queryKey:T.notes.backReferences(t.noteId),async queryFn(){const r=await pa(t.noteId);if(r.type==="error")throw r;return r.backReferences}});return t.render(a)};let un="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pn=(t=21)=>{let a="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)a+=un[r[t]&63];return a};const lt={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function mn({isOpen:t,onClose:a,onSave:r,reminder:l,mode:s}){const[d,i]=n.useState(new Date),[u,c]=n.useState("medium"),[h,m]=n.useState("");n.useEffect(()=>{t&&s==="edit"&&l?(i(new Date(Number(l.reminderDate))),c(l.priority||"medium"),m(l.content||"")):t&&s==="create"&&(i(new Date),c("medium"),m(""))},[t,s,l]);const N=()=>{r(d,u,h||void 0),a()},j=y=>u===y?lt[y].active:lt[y].inactive;return e.jsxs(H,{isOpen:t,onClose:a,variant:"form",children:[e.jsx(H.Header,{title:s==="create"?"Create Reminder":"Edit Reminder",onClose:a}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Date & Time"}),e.jsx($e,{type:"datetime-local",size:"sm",value:W(d).format("YYYY-MM-DDTHH:mm"),onChange:y=>i(new Date(y.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Content"}),e.jsx(ma,{size:"sm",placeholder:"Enter reminder content (optional)",value:h,onChange:y=>m(y.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Ee,{children:"Priority"}),e.jsxs(fa,{type:"single",variant:"quiet",value:u,onValueChange:y=>y&&c(y),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(Me,{value:"low",className:`flex-1 rounded-[10px] border ${j("low")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),e.jsx(Me,{value:"medium",className:`flex-1 rounded-[10px] border ${j("medium")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),e.jsx(Me,{value:"high",className:`flex-1 rounded-[10px] border ${j("high")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:N,children:s==="create"?"Create":"Save"})]})})]})}function fn({noteId:t}){const[a,r]=n.useState(!1),[l,s]=n.useState(!1),[d,i]=n.useState("create"),[u,c]=n.useState(void 0),{onCreate:h,onUpdate:m,onDelete:N}=Za(),j=()=>{i("create"),c(void 0),s(!0)},y=C=>{i("edit"),c(C),s(!0)},S=(C,b,v)=>{d==="create"?h(t,C,b,()=>{s(!1)},v):d==="edit"&&u&&m(u.id,t,{reminderDate:C,priority:b,content:v},()=>{s(!1)})},f=C=>{m(C.id,t,{completed:!C.completed})},L=C=>{const b=W(Number(C)),v=W();return b.isSame(v,"day")?`Today at ${b.format("HH:mm")}`:b.isSame(v.add(1,"day"),"day")?`Tomorrow at ${b.format("HH:mm")}`:b.format("YYYY-MM-DD HH:mm")},F=C=>{const b=W(Number(C)),v=W(),P=b.diff(v,"hour");return P<=6?"high":P<=24?"medium":"low"},M=C=>{const b=W(Number(C)),v=W(),P=b.diff(v,"hour"),_=b.diff(v,"minute")%60;return P<0||_<0?"Overdue":P===0?`${_}m remaining`:`${P}h ${_}m remaining`};return e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"Reminders",icon:e.jsx(ga,{className:"h-3.5 w-3.5"}),action:e.jsxs(e.Fragment,{children:[!a&&e.jsxs(R,{size:"sm",variant:"ghost",onClick:j,children:[e.jsx(ze,{className:"w-3 h-3"}),e.jsx(x,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),e.jsxs(R,{type:"button",size:"sm",variant:"ghost","aria-label":a?"Expand reminders":"Collapse reminders","aria-expanded":!a,onClick:()=>r(!a),children:[a?e.jsx(ha,{className:"h-3.5 w-3.5"}):e.jsx(xa,{className:"h-3.5 w-3.5"}),a?"Expand":"Collapse"]})]}),children:!a&&e.jsx(Ka,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:C,totalCount:b})=>e.jsx("div",{className:"flex flex-col gap-2",children:C.length===0?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:b===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:C.map(v=>{const P=v.priority||F(v.reminderDate),_=M(v.reminderDate),D=_==="Overdue";return e.jsxs("div",{className:q("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(mt,{checked:v.completed,onChange:()=>f(v),size:"sm"}),e.jsx(x,{as:"div",variant:"body",weight:"medium",className:q("truncate flex-1 min-w-0",v.completed&&"line-through opacity-40"),children:v.content||L(v.reminderDate)}),e.jsxs("div",{className:q("shrink-0 flex items-center gap-1",v.completed&&"opacity-40"),children:[v.content&&e.jsx(x,{as:"span",variant:"meta",tone:"secondary",children:L(v.reminderDate)}),!v.completed&&e.jsx(x,{as:"span",variant:"label",weight:"medium",tone:D||P==="high"?"error":"tertiary",className:q(v.content&&'before:content-["·"] before:mr-1'),children:_})]}),e.jsx(ft,{button:e.jsx(ht,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>y(v)},{name:"Delete",onClick:()=>N(v.id,t)}]})]},v.id)})})})})}),e.jsx(mn,{isOpen:l,onClose:()=>s(!1),onSave:S,reminder:u,mode:d})]})}const hn=({editor:t})=>e.jsx(qe,{triggerCharacter:"/",getItems:async a=>qa([...na(t).filter(r=>r.title!=="Audio"&&r.title!=="Video"&&r.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{t.insertBlocks([{type:"tableOfContents"}],t.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:e.jsx(xt,{})}],a)}),xn=(t,a)=>a?t.filter(r=>r.id!==a):t,gn=({currentNoteId:t,onClick:a})=>e.jsx(qe,{triggerCharacter:"[",getItems:async r=>{const l=await ya({query:r,limit:5});return l.type==="error"?[]:xn(l.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>a({type:"reference",props:{id:d.id,title:d.title}})}))}}),yn="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",vn={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},bn={idle:"Copy",copied:"Copied",failed:"Copy failed"},wn=({getText:t,resetDelayMs:a=2e3})=>{const[r,l]=n.useState("idle"),s=n.useRef(null),d=n.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),i=n.useCallback(()=>{d(),s.current=setTimeout(()=>{l("idle"),s.current=null},a)},[d,a]);n.useEffect(()=>d,[d]);const u=m=>{m.stopPropagation()},c=m=>{m.preventDefault(),m.stopPropagation()},h=async m=>{u(m);try{await navigator.clipboard.writeText(t()),l("copied")}catch{l("failed")}i()};return e.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:c,children:e.jsxs("button",{type:"button",className:q(yn,vn[r]),contentEditable:!1,onClick:h,children:[e.jsx(tn,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:bn[r]})]})})},jn=({contentRef:t})=>{const a=n.useRef(null),r=n.useCallback(l=>{a.current=l,t(l)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:r})}),e.jsx(wn,{getText:()=>a.current?.textContent?.trimEnd()??""})]})},Nn="_Reference_102im_1",Cn={Reference:Nn},kn=gt.bind(Cn),An={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function Sn(t){const a=yt(),r=()=>{t.editor.blur(),a({to:ve,params:{id:t.inlineContent.props.id}})},l=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:kn("Reference"),onMouseDown:l,onClick:s=>{l(s),r()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(l(s),r())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const Rn=dt(An,{render:t=>e.jsx(Sn,{...t})}),Tn=()=>{const t=ra(),[a,r]=n.useState([]),l={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};n.useEffect(()=>{const i=()=>{const c=t.document,h=[],m=N=>{for(const j of N){if(j.type==="heading"){const y=j,S=y.props.level||1,f=y.content?.map(L=>L.text||"").join("")||"";f.trim()&&h.push({id:j.id,level:S,text:f})}j.children&&Array.isArray(j.children)&&m(j.children)}};m(c),r(h)};i();const u=t.onChange?.(i);return()=>{u&&u()}},[t]);const s=i=>{t.setTextCursorPosition(i);const u=document.querySelector(`[data-id="${i}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"center"})},d=e.jsx(Ct,{icon:e.jsx(xt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return a.length===0?e.jsxs("div",{className:"surface-base w-full p-4",children:[d,e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):e.jsxs("div",{className:"surface-base w-full p-4",children:[e.jsx("div",{className:"mb-2",children:d}),e.jsx("nav",{className:"space-y-0.5",children:a.map(i=>{const u=i.level===1;return e.jsxs("button",{type:"button",onClick:()=>s(i.id),className:q("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",l[i.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",u?"text-fg-default":"text-fg-secondary"),children:[e.jsxs(x,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",i.level]}),e.jsx(x,{as:"span",variant:"body",weight:u?"semibold":"medium",className:"line-clamp-2 text-current",children:i.text})]},i.id)})})]})},En=ut({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(Tn,{})})(),Mn="_Tag_1gb8h_1",Hn={Tag:Mn},Dn=gt.bind(Hn),Ln={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Vn(t){const a=yt(),r=()=>{t.editor.blur(),a({to:va,params:{id:t.inlineContent.props.id},search:{page:1}})},l=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Dn("Tag"),onMouseDown:l,onClick:s=>{l(s),r()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(l(s),r())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const Fn=dt(Ln,{render:t=>e.jsx(Vn,{...t})}),Pn=t=>t,On=t=>t,Bn=Pn({tag:Fn,reference:Rn}),_n=On({tableOfContents:En}),se=vt.codeBlock,it=ut(se.config,{meta:se.implementation.meta,parse:se.implementation.parse,parseContent:se.implementation.parseContent,runsBefore:se.implementation.runsBefore,render:jn})(),$n={...it,extensions:se.extensions,implementation:{...it.implementation,toExternalHTML:se.implementation.toExternalHTML}},In=Qa.create({inlineContentSpecs:{...Ya,...Bn},blockSpecs:{...vt,codeBlock:$n,..._n}}),Un=(t,a)=>a.some(r=>r.name===`@${t}`),Zn=({onClick:t})=>e.jsx(qe,{triggerCharacter:"@",getItems:async a=>{const r=await ba({query:a,limit:5});if(r.type==="error")return[];const{tags:l}=r.allTags,s=Un(a,l),d=[{title:"Add a new tag",onItemClick:async()=>{const i=await wa({name:"@"+a});if(i.type==="error")return;const{id:u,name:c}=i.createTag;t({type:"tag",props:{id:u,tag:c}})}}];return l.length===0?d:l.map(i=>({title:i.name,onItemClick:()=>t({type:"tag",props:{id:i.id,tag:i.name}})})).concat(a&&!s?d:[])}}),Kn=new Set(["tableOfContents"]),zn="OCEAN_BRAIN_TAG_",qn="_TOKEN",Qn=t=>`${zn}${t}${qn}`,Yn=t=>!Array.isArray(t)&&t?.type==="tableContent",Gn=(t,a)=>Array.isArray(t)?t.map(a):Yn(t)?{...t,rows:t.rows?.map(r=>({...r,cells:r.cells?.map(l=>({...l,content:l.content?.map(a)}))}))}:t,At=(t,a)=>t.filter(r=>!Kn.has(r.type)).map(r=>({...r,content:a(r.content),children:r.children?.length?At(r.children,a):[]}));function Wn(t){const a=new Map;let r=0;return{blocks:At(t,s=>Gn(s,d=>{if(d.type==="reference")return{type:"text",text:`[[${d.props?.title||d.props?.id||""}]]`,styles:{}};if(d.type==="tag"){const i=d.props?.tag||"",u=Qn(r);return r+=1,a.set(u,i),{type:"text",text:u,styles:{}}}return d})),placeholderToTag:a}}function Jn(t,a){let r=t;for(const[l,s]of a.entries())r=r.split(l).join(`[${s}]`);return r}async function Xn(t){return new Promise((a,r)=>{const l=new FileReader;l.readAsDataURL(t),l.onload=()=>a(l.result),l.onerror=s=>r(s)})}const er=n.forwardRef(({content:t,currentNoteId:a,editable:r,onChange:l},s)=>{const{theme:d}=ja(u=>u),i=sa({schema:In,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async u=>za({base64:await Xn(u)})},[]);return n.useImperativeHandle(s,()=>({getContent:()=>JSON.stringify(i.document),getMarkdown:()=>{const u=Wn(i.document),c=i.blocksToMarkdownLossy(u.blocks);return Jn(c,u.placeholderToTag)},getHtml:()=>i.blocksToHTMLLossy(i.document)})),e.jsxs(oa,{slashMenu:!1,theme:d,editor:i,editable:r,onChange:l,children:[e.jsx(hn,{editor:i}),e.jsx(gn,{currentNoteId:a,onClick:u=>{i.insertInlineContent([u," "])}}),e.jsx(Zn,{onClick:u=>{i.insertInlineContent([u," "])}})]})}),Je=t=>`ocean-brain.note-draft.${t}`,tr=t=>{if(typeof window>"u")return null;try{const a=window.localStorage.getItem(Je(t));if(!a)return null;const r=JSON.parse(a);return typeof r.title!="string"||typeof r.content!="string"||typeof r.baseUpdatedAt!="string"?null:{title:r.title,content:r.content,baseUpdatedAt:r.baseUpdatedAt,createdAt:typeof r.createdAt=="number"?r.createdAt:Date.now(),...r.layout==="narrow"||r.layout==="wide"||r.layout==="full"?{layout:r.layout}:{}}}catch{return null}},De=(t,a)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(t),JSON.stringify(a))}catch{}},Le=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(t))}catch{}},ar=1e3,nr="NOTE_UPDATE_CONFLICT";function rr({noteId:t,initialContent:a,initialUpdatedAt:r,editSessionIdRef:l,getContent:s,onSaved:d,onConflict:i,onError:u}){const c=we(),h=n.useRef(null),m=n.useRef(null),N=n.useRef(!1),j=n.useRef(null),y=n.useRef(!1),S=n.useRef(r),f=n.useRef(!1),L=n.useRef(!0),F=n.useRef(d),M=n.useRef(i),C=n.useRef(u),[b,v]=n.useState("saved"),[P,_]=n.useState(null),D=n.useCallback(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),O=n.useCallback(A=>{L.current&&v(A)},[]),J=n.useCallback(A=>{S.current=A},[]),Y=n.useCallback((A,B={})=>({title:A,content:s()??a,createdAt:Date.now(),baseUpdatedAt:S.current,...B.layout?{layout:B.layout}:{}}),[s,a]),ne=n.useCallback(()=>{m.current&&De(t,m.current)},[t]),G=n.useCallback(A=>{f.current=!0,O("conflict"),M.current(A??S.current)},[O]),Q=n.useCallback(async({ignoreConflict:A=!1,silent:B=!1}={})=>{if(N.current)return y.current=!0,j.current??"idle";const $=m.current;if(!$)return y.current=!1,"idle";m.current=null,y.current=!1,D(),N.current=!0,B||O("saving");const U=(async()=>{let Z;try{Z=await Ie({id:t,title:$.title,content:$.content,...$.layout?{layout:$.layout}:{},editSessionId:l.current,...A?{force:!0}:{expectedUpdatedAt:$.baseUpdatedAt}})}catch{Z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(N.current=!1,j.current=null,Z.type==="error"){m.current||(m.current=$),ne();const X=Z.errors[0];if(X.code===nr&&!A){const k=X.details?.extensions?.currentUpdatedAt;return f.current=!0,!B&&L.current&&(O("conflict"),M.current(k??S.current)),"conflict"}return!B&&L.current&&(O("error"),C.current(X.message)),"error"}f.current=!1,S.current=Z.updateNote.updatedAt;const K=!B&&L.current,re=T.notes.detail(t);await c.cancelQueries({queryKey:re,exact:!0}),K&&F.current(Z.updateNote.updatedAt),c.setQueryData(re,X=>X&&{...X,title:Z.updateNote.title,content:$.content,...$.layout?{layout:$.layout}:{},updatedAt:Z.updateNote.updatedAt}),ye({noteId:t,updatedAt:Z.updateNote.updatedAt,editSessionId:l.current});const I=m.current;return I?.baseUpdatedAt===$.baseUpdatedAt?(m.current={...I,baseUpdatedAt:Z.updateNote.updatedAt},ne()):I||Le(t),K&&(m.current?v("pending"):(v("saved"),c.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.graph(),exact:!0}))),m.current||y.current?Q({silent:B}):"saved"})();return j.current=U,U},[D,l,t,ne,c,O]),p=n.useCallback((A,B={})=>{if(m.current=A,De(t,A),f.current){O("conflict");return}if(O("pending"),D(),B.immediate){Q();return}h.current=window.setTimeout(()=>{Q()},ar)},[D,Q,t,O]),E=n.useCallback(A=>{if(m.current=A,De(t,A),_(null),A.baseUpdatedAt!==S.current){G(S.current);return}p(A)},[t,p,G]),w=n.useCallback(()=>{D(),m.current=null,j.current=null,y.current=!1,f.current=!1,Le(t),_(null),v("saved")},[D,t]),V=n.useCallback(()=>{D(),j.current=null,y.current=!1,f.current=!1,O(m.current?"pending":"saved")},[D,O]),je=n.useCallback(()=>{Le(t),_(null)},[t]),oe=n.useCallback(()=>m.current,[]),Ne=n.useCallback(A=>{D(),G(A)},[D,G]);return n.useEffect(()=>{M.current=i,C.current=u,F.current=d},[i,u,d]),n.useEffect(()=>(L.current=!0,()=>{L.current=!1}),[]),n.useEffect(()=>{m.current||N.current||f.current||(S.current=r,v("saved"))},[r]),n.useEffect(()=>{m.current=null,N.current=!1,j.current=null,y.current=!1,f.current=!1,S.current=r,_(tr(t)),v("saved")},[t]),n.useEffect(()=>{const A=B=>{!m.current&&!N.current&&!f.current||(B.preventDefault(),B.returnValue="")};return window.addEventListener("beforeunload",A),()=>{window.removeEventListener("beforeunload",A)}},[]),n.useEffect(()=>()=>{D(),m.current&&!f.current&&Q({silent:!0})},[D,Q]),{saveStatus:b,localDraft:P,serverUpdatedAtRef:S,hasUnsavedChanges:b!=="saved",buildDraft:Y,queueSave:p,flushPendingSave:Q,restoreLocalDraft:E,discardLocalDraft:je,clearDrafts:w,resolveConflict:V,pauseForConflict:Ne,getPendingDraft:oe,setServerUpdatedAt:J}}const sr=/[:{}[\],&*#?|<>=!%@`-]/,or=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",lr=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),ge=t=>t?sr.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',be=t=>{if(!t)return;const a=Number(t);return Number.isFinite(a)?new Date(a).toISOString():t},Ve=(t,a)=>`${or(t)}.${a}`,ir=({id:t,title:a,createdAt:r,updatedAt:l})=>{const s=["---",`title: ${ge(a)}`,`note_id: ${ge(t)}`],d=be(r),i=be(l);return d&&s.push(`created_at: ${ge(d)}`),i&&s.push(`updated_at: ${ge(i)}`),s.push("source: ocean-brain","---"),s.join(`
2
2
  `)},cr=(t,a,r=!1)=>r?`${ir(a)}
3
3
 
4
4
  ${t}`:t,dr=(t,a,{includeMetadata:r=!1,mode:l="fragment"}={})=>{const s=r?`<!--
@@ -18,4 +18,4 @@ updated_at: ${be(a.updatedAt)??""}
18
18
  <body>
19
19
  ${s}${t}
20
20
  </body>
21
- </html>`},Ve=(t,a,r)=>{const l=new Blob([t],{type:r}),s=URL.createObjectURL(l),d=document.createElement("a");d.href=s,d.download=a,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(s)},St=Ra(ve),pe=t=>{const a=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(a)?a:null},Pe=t=>{const a=pe(t);return W(a??Number(t)).format("YYYY-MM-DD HH:mm:ss")},ur=(t,a)=>Ta(pe(t),a),Oe=()=>pn(),pr="NOTE_UPDATE_CONFLICT",mr=2200,fr=t=>t?.extensions?.currentUpdatedAt,ct=(t,a)=>{const r=pe(t),l=pe(a);return r===null||l===null?t===a?0:1:r-l},hr=t=>{const a=t.trim();if(!a)return null;try{const r=new URL(a);return r.protocol==="http:"||r.protocol==="https:"?r.toString():null}catch{return null}},xr={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},gr=e.jsx(Ge,{title:"Loading note",variant:"none",children:e.jsxs("main",{className:"mx-auto max-w-[896px]",children:[e.jsx(ie,{className:"mb-8",height:"66px"}),e.jsx(ie,{className:"ml-12 mb-8",height:"150px"}),e.jsx(ie,{className:"mb-5",height:"80px"}),e.jsx(ie,{height:"80px"})]})}),yr=t=>({id:t?.key??"",key:t?.key??"",name:t?.name??"",value:t?.value??"",valueType:t?.valueType??"text",persistedKey:t?.key}),vr=t=>{if(Array.isArray(t))return t;const a=t?.keys;return Array.isArray(a)?a:[]},Be=(t=[])=>t.map(yr),Rt=(t,a)=>{const r=[],l=new Set(a);for(const s of t){const d=s.key.trim();if(!d)continue;const i=s.value.trim(),u=!!s.persistedKey&&(s.valueType==="number"||s.valueType==="date"||s.valueType==="select"||s.valueType==="url");if(!i&&u){l.add(s.persistedKey);continue}!i&&s.valueType!=="text"&&s.valueType!=="boolean"||r.push({key:d,name:s.name.trim()||d,value:s.valueType==="boolean"?i||"false":i,valueType:s.valueType})}return{set:r.sort((s,d)=>s.key.localeCompare(d.key)),deleteKeys:Array.from(l).sort()}},le=(t,a=[])=>JSON.stringify(Rt(t,a)),br=({noteId:t,properties:a=[],expectedUpdatedAt:r,editSessionId:l,disabled:s,onSaved:d})=>{const i=Ye(),u=we(),[c,x]=n.useState(()=>Be(a)),[m,N]=n.useState([]),[j,y]=n.useState("idle"),S=n.useRef(c),f=n.useRef(m),F=n.useRef(r),V=n.useRef(le(c)),M=n.useRef(null),C=n.useRef(!1),b=n.useRef(!1),v=_e({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const p=await Ma({limit:50});if(p.type==="error")throw p;return p.notePropertyKeys.keys}});n.useEffect(()=>{const p=Be(a);x(p),N([]),V.current=le(p),y("idle")},[a]),n.useEffect(()=>{S.current=c},[c]),n.useEffect(()=>{f.current=m},[m]),n.useEffect(()=>{F.current=r},[r]);const P=vr(v.data),_=P.filter(p=>!c.some(E=>E.key===p.key)),D=P.length>0,O=n.useCallback(async()=>{const p=le(S.current,f.current);if(s||p===V.current)return;if(C.current){b.current=!0;return}const E=Rt(S.current,f.current);if(!(E.set.length===0&&E.deleteKeys.length===0)){C.current=!0,b.current=!1,y("saving");try{const w=await Ha({id:t,set:E.set,deleteKeys:E.deleteKeys,editSessionId:l,expectedUpdatedAt:F.current});if(w.type==="error"){y("error"),i(w.errors[0]?.message??"Failed to save properties.");return}F.current=w.updateNoteProperties.updatedAt,V.current=le(Be(w.updateNoteProperties.properties??[])),d(w.updateNoteProperties),u.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),y("saved")}catch{y("error"),i("Failed to save properties.")}finally{C.current=!1,b.current&&(b.current=!1,O())}}},[s,l,t,d,u,i]);n.useEffect(()=>{if(M.current&&clearTimeout(M.current),!(s||le(c,m)===V.current))return M.current=setTimeout(()=>{O()},500),()=>{M.current&&clearTimeout(M.current)}},[m,s,c,O]);const J=p=>{x(E=>[...E,{id:p.key,key:p.key,name:p.name,value:"",valueType:p.valueType,persistedKey:void 0}]),N(E=>E.filter(w=>w!==p.key))},Y=(p,E)=>{x(w=>w.map(L=>L.id===p?{...L,...E}:L))},ne=p=>{p.persistedKey&&N(E=>[...new Set([...E,p.persistedKey])]),x(E=>E.filter(w=>w.id!==p.id))},G=le(c,m)!==V.current,Q=s||!G&&j==="idle"?null:j==="saving"?"Saving...":j==="error"?"Save failed":G?"Waiting...":"Saved";return e.jsxs(We,{title:"Properties",icon:e.jsx($a,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:e.jsxs(e.Fragment,{children:[Q&&e.jsx(h,{as:"span",variant:"micro",tone:j==="error"?"error":"tertiary",className:"px-1",children:Q}),D&&e.jsx(R,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(Ke,{to:rt,search:{page:1},children:[e.jsx(_a,{className:"h-3 w-3"}),"Manage"]})})]}),children:[s&&e.jsx(h,{as:"p",variant:"label",tone:"tertiary",className:"mb-3",children:"Finish the current note save or resolve conflicts before editing properties."}),c.length===0?e.jsx(h,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):e.jsx("div",{className:"divide-y divide-border-subtle",children:c.map(p=>{const E=p.valueType==="url"?hr(p.value):null;return e.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[e.jsx(h,{as:"span",variant:"label",tone:"secondary",className:"truncate",children:p.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:p.key})]}),p.valueType==="boolean"?e.jsxs(nt,{size:"sm",variant:"ghost",value:p.value||"false",disabled:s,onValueChange:w=>Y(p.id,{value:w}),children:[e.jsx(He,{value:"false",children:"False"}),e.jsx(He,{value:"true",children:"True"})]}):p.valueType==="select"?e.jsx(nt,{size:"sm",variant:"ghost",value:p.value,placeholder:"Select option",disabled:s,onValueChange:w=>Y(p.id,{value:w}),children:(P.find(w=>w.key===p.key)?.options??[]).map(w=>e.jsx(He,{value:w.value,children:w.label},w.id))}):p.valueType==="url"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx($e,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:p.value,disabled:s,onChange:w=>Y(p.id,{value:w.target.value})}),E?e.jsx(R,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${p.name}`,className:"shrink-0 text-fg-tertiary",children:e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",title:E,children:e.jsx(Nt,{className:"h-4 w-4"})})}):null]}):e.jsx($e,{size:"sm",variant:"ghost",type:p.valueType==="date"?"date":p.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:p.value,disabled:s,onChange:w=>Y(p.id,{value:w.target.value})}),e.jsx(R,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${p.name}`,disabled:s,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>ne(p),children:e.jsx(Da,{className:"h-4 w-4"})})]},p.id)})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:v.isLoading?e.jsx(R,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):_.length>0?e.jsxs(Fa,{children:[e.jsx(La,{asChild:!0,children:e.jsxs(R,{type:"button",size:"sm",variant:"ghost",disabled:s,children:[e.jsx(ze,{className:"h-4 w-4"}),"Add property"]})}),e.jsxs(Va,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[e.jsx(Pa,{children:e.jsx(h,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),e.jsx(Oa,{}),_.map(p=>e.jsxs(Ba,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>J(p),children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[e.jsx(h,{as:"span",variant:"label",weight:"medium",className:"truncate",children:p.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:p.valueType})]}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:p.key})]},p.key))]})]}):D?e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):e.jsxs(Ke,{to:rt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(ze,{className:"h-4 w-4"}),"Create property definition"]})})]})};function wr({id:t}){const a=Ye(),r=St.useNavigate(),l=we(),s=n.useRef(null),d=n.useRef(null),i=n.useRef(Oe()),u=pt({queryKey:T.notes.detail(t),queryFn:async()=>{const o=await Na(t);if(o.type==="error")throw o;return o.note},gcTime:0}),c=u.data,[x,m]=n.useState(c.title),[N,j]=n.useState(()=>Pe(c.updatedAt)),[y,S]=n.useState(c.updatedAt),[f,F]=n.useState(()=>Date.now()),[V,M]=n.useState(c.pinned),[C,b]=n.useState(c.layout||"wide"),[v,P]=n.useState(!1),[_,D]=n.useState(!1),[O,J]=n.useState(!1),[Y,ne]=n.useState("markdown"),[G,Q]=n.useState(!1),[p,E]=n.useState("fragment"),[w,L]=n.useState(null),[je,oe]=n.useState(null),[Ne,A]=n.useState(0),[B,$]=n.useState(!1),U=n.useRef(c.updatedAt),Z=n.useRef(t),K=n.useRef(null),re=n.useRef(!1),I=n.useCallback(o=>{j(Pe(o)),S(o),F(Date.now())},[]),X=rr({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:i,getContent:()=>s.current?.getContent(),onSaved:o=>{K.current=null,U.current=o,I(o),$(!0)},onConflict:o=>{L({type:"updated",updatedAt:o,source:"unknown"}),a("This note changed elsewhere. Choose how to resolve the draft.")},onError:a}),{saveStatus:k,localDraft:ee,serverUpdatedAtRef:te,hasUnsavedChanges:ce,buildDraft:fe,queueSave:he,flushPendingSave:xe,restoreLocalDraft:Tt,discardLocalDraft:Et,clearDrafts:Ce,resolveConflict:Mt,pauseForConflict:de,getPendingDraft:ke,setServerUpdatedAt:ae}=X,Ht=n.useCallback(async()=>{if(re.current)return re.current=!1,!1;if(k==="conflict")return a("Resolve the note conflict before leaving."),!0;const o=await xe();return o==="error"?(a("Save failed. Stay on this note and try again."),!0):o==="conflict"},[xe,k,a]);Wa({disabled:k==="saved",enableBeforeUnload:!1,shouldBlockFn:Ht}),n.useEffect(()=>{if(ce){c.updatedAt!==te.current&&ct(c.updatedAt,te.current)>0&&de(c.updatedAt);return}const o=U.current;if(!(c.updatedAt!==o&&ct(c.updatedAt,o)<0)&&(M(c.pinned),b(c.layout||"wide"),ae(c.updatedAt),m(c.title),I(c.updatedAt),o!==c.updatedAt)){const g=s.current?.getContent();U.current=c.updatedAt,(g===void 0||g!==c.content)&&(oe(null),A(z=>z+1))}},[ce,c.layout,c.pinned,c.title,c.updatedAt,de,te,ae,I]),n.useEffect(()=>{Z.current!==t&&(Z.current=t,i.current=Oe(),U.current=c.updatedAt,K.current=null,L(null),oe(null),A(o=>o+1),$(!1))},[t,c.updatedAt]),n.useEffect(()=>{if(k!=="saved")return;const o=window.setTimeout(()=>{F(Date.now())},Ca(pe(y),f));return()=>window.clearTimeout(o)},[y,f,k]),n.useEffect(()=>{if(!B)return;const o=window.setTimeout(()=>{$(!1)},mr);return()=>window.clearTimeout(o)},[B]),n.useEffect(()=>{w?.type!=="updated"||k==="conflict"||w.updatedAt!==c.updatedAt||(U.current=c.updatedAt,ae(c.updatedAt),I(c.updatedAt),L(null))},[w,c.updatedAt,k,ae,I]),n.useEffect(()=>ka(o=>{if(o.noteId===t&&!(o.source==="web"&&o.editSessionId===i.current)){if(o.type==="mcp.note.updated"||o.type==="web.note.updated"){if(o.updatedAt===c.updatedAt||o.updatedAt===te.current)return;if(ce){de(o.updatedAt),L({type:"updated",updatedAt:o.updatedAt,source:o.source});return}L({type:"updated",updatedAt:o.updatedAt,source:o.source});return}o.type==="mcp.note.deleted"&&L({type:"deleted",source:o.source})}}),[ce,t,c.updatedAt,de,te]);const{onCreate:Dt,onDelete:Ft,onPinned:Lt,deleteWarningDialog:Vt}=Aa(),Pt=()=>{he(fe(x))},Ot=o=>{m(o),he(fe(o))},Xe=()=>{he(fe(x),{immediate:!0})},Bt=async o=>{if(ce){b(o),he(fe(x,{layout:o}),{immediate:!0}),a("Layout will be saved with your draft.");return}const g=await Ie({id:t,layout:o,editSessionId:i.current,expectedUpdatedAt:te.current});if(g.type==="error"){g.errors[0].code===pr&&(K.current=o,b(o),de(fr(g.errors[0].details)??te.current)),a(g.errors[0].message);return}K.current=null,await l.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=g.updateNote.updatedAt,ae(g.updateNote.updatedAt),l.setQueryData(T.notes.detail(t),z=>z&&{...z,layout:o,updatedAt:g.updateNote.updatedAt}),ye({noteId:t,updatedAt:g.updateNote.updatedAt,editSessionId:i.current}),I(g.updateNote.updatedAt),b(o),a("Layout has been updated.")},_t=()=>({id:t,title:x,createdAt:c.createdAt,updatedAt:te.current||c.updatedAt}),$t=async()=>{const o=s.current?.getMarkdown();if(o===void 0){a("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(o),a("Copied note as Markdown.")}catch{a("Failed to copy Markdown.")}},It=()=>{const o=s.current?.getMarkdown();if(o===void 0){a("Markdown is not ready yet.");return}try{Ve(o,Le(x,"md"),"text/markdown;charset=utf-8"),a("Downloaded note as Markdown.")}catch{a("Failed to download Markdown.")}},Ut=()=>{const o=_t();try{if(Y==="markdown"){const g=s.current?.getMarkdown();if(g===void 0){a("Markdown is not ready yet.");return}Ve(cr(g,o,G),Le(x,"md"),"text/markdown;charset=utf-8")}else{const g=s.current?.getHtml();if(g===void 0){a("HTML is not ready yet.");return}Ve(dr(g,o,{includeMetadata:G,mode:p}),Le(x,"html"),"text/html;charset=utf-8")}J(!1),a("Downloaded note.")}catch{a("Failed to download note.")}},Zt=async()=>{const o=await u.refetch();if(o.error||!o.data){a("Failed to reload the latest note state.");return}Ce(),K.current=null,U.current=o.data.updatedAt,ae(o.data.updatedAt),m(o.data.title),b(o.data.layout||"wide"),I(o.data.updatedAt),oe(null),A(g=>g+1),L(null)},Kt=async()=>{if(ke()){K.current=null,L(null),await xe({ignoreConflict:!0});return}const g=K.current;if(g){const z=await Ie({id:t,layout:g,editSessionId:i.current,force:!0});if(z.type==="error"){a(z.errors[0].message);return}K.current=null,await l.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=z.updateNote.updatedAt,Mt(),L(null),ae(z.updateNote.updatedAt),l.setQueryData(T.notes.detail(t),Te=>Te&&{...Te,layout:g,updatedAt:z.updateNote.updatedAt}),ye({noteId:t,updatedAt:z.updateNote.updatedAt,editSessionId:i.current}),I(z.updateNote.updatedAt),b(g);return}L(null),await xe({ignoreConflict:!0})},et=async()=>{const o=ke();if(!o)return;const g=await Ea({title:at(o.title||"untitled"),content:at(o.content),layout:o.layout??C});if(g.type==="error"){a(g.errors[0].message);return}re.current=!0,K.current=null,L(null),Ce(),Promise.resolve(r({to:ve,params:{id:g.createNote.id}})).finally(()=>{re.current=!1})},zt=()=>{ee&&(m(ee.title),ee.layout&&b(ee.layout),oe(ee.content),A(o=>o+1),Tt(ee))},qt=()=>{Et()},Qt=ee?W(ee.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Ae=k==="saved"&&B,Yt=ur(y,f),Gt=Pe(c.createdAt),Wt=k==="pending"?"Saving...":k==="saving"?"Saving now...":k==="error"?"Save failed. Try again.":k==="conflict"?"Save paused: changed elsewhere":`Saved ${Yt}`,Jt=q("inline-flex items-center gap-2 transition-colors",k==="saved"&&!Ae&&"text-fg-secondary",Ae&&"text-accent-success",(k==="pending"||k==="saving")&&"text-fg-default",(k==="error"||k==="conflict")&&"text-fg-error"),Se=q("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(k==="pending"||k==="saving")&&"save-progress-ring-active",k==="saved"&&Ae&&"save-progress-ring-complete",(k==="error"||k==="conflict")&&"save-progress-ring-error"),Xt=k==="saving"?e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):k==="pending"?e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):k==="error"||k==="conflict"?e.jsx(Ia,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),ea=e.jsxs(h,{as:"span",variant:"label",weight:"medium",className:Jt,role:"status","aria-live":"polite",title:N,children:[Xt,Wt]}),Re=k==="conflict"&&w?.type==="updated",ta=Re?ke():null,aa=w!==null&&!(w.type==="updated"&&!Re&&w.updatedAt===c.updatedAt);return e.jsx(Ge,{title:x,variant:"none",children:e.jsxs("main",{className:q("mx-auto",xr[C]),children:[e.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),e.jsx("input",{ref:d,placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:x,onChange:o=>Ot(o.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(ft,{button:e.jsx(ht,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:$t},{name:"Download Markdown",onClick:It},{name:"Download in another format",onClick:()=>J(!0)},{type:"separator",key:"export-separator"},{name:V?"Unpin":"Pin",onClick:()=>Lt(t,V,()=>{M(o=>!o)})},{name:"Change layout",onClick:()=>P(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>Dt(d.current?.value||"untitled",s.current?.getContent()||"",C)},{name:"Restore previous version",onClick:()=>D(!0)},{type:"separator"},{name:"Delete",onClick:()=>Ft(t,()=>{r({to:tt,search:{page:1}})})}]}),e.jsx(R,{size:"sm",variant:"subtle",isLoading:k==="saving",disabled:k==="conflict",onClick:Xe,children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[V&&e.jsxs(h,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(Sa,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),V&&e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),ea,e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsxs(h,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",Gt]})]})]})}),ee&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["A draft from ",Qt," is saved only in this browser."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(R,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:zt,children:"Restore draft"}),e.jsx(R,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:qt,children:"Discard"})]})]})}),k==="error"&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(R,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Xe,children:"Retry save"}),e.jsx(R,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{et()},children:"Save as new note"})]})]})}),e.jsx(br,{noteId:t,properties:c.properties,expectedUpdatedAt:te.current,editSessionId:i.current,disabled:k!=="saved",onSaved:o=>{U.current=o.updatedAt,ae(o.updatedAt),I(o.updatedAt),$(!0),l.setQueryData(T.notes.detail(t),g=>g&&{...g,updatedAt:o.updatedAt,properties:o.properties}),ye({noteId:t,updatedAt:o.updatedAt,editSessionId:i.current})}}),e.jsx(er,{ref:s,content:je??c.content,currentNoteId:t,onChange:Pt},`${t}:${Ne}`),e.jsx(Ue,{fallback:e.jsx(ie,{className:"mb-5",height:"80px"}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:o,retry:g})=>e.jsx(Ze,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:o,onRetry:g,showBackAction:!1,showHomeAction:!1}),children:e.jsx(fn,{noteId:t})}),e.jsx(Ue,{fallback:e.jsx(ie,{height:"80px"}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:o,retry:g})=>e.jsx(Ze,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:o,onRetry:g,showBackAction:!1,showHomeAction:!1}),children:e.jsx(dn,{noteId:t,render:o=>o&&o.length>0&&e.jsx(We,{icon:e.jsx(Nt,{className:"h-3.5 w-3.5"}),title:"Back References",children:e.jsx("ul",{className:"flex flex-col",children:o.map(g=>e.jsx("li",{children:e.jsxs(Ke,{to:ve,params:{id:g.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(an,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(h,{as:"span",variant:"body",weight:"medium",className:"text-current",children:g.title})]})},g.id))})})})}),e.jsx(rn,{isOpen:v,onClose:()=>P(!1),onSave:Bt,currentLayout:C}),e.jsx(ln,{isOpen:aa,isDeleted:w?.type==="deleted",isConflict:Re,hasDraft:ta!==null,source:w?.source??"unknown",isReloading:u.isRefetching,onReload:Zt,onOverwrite:()=>{Kt()},onCloneDraft:()=>{et()},onOpenTrash:()=>r({to:tt,search:{page:1}})}),e.jsxs(H,{isOpen:O,onClose:()=>J(!1),variant:"compact",children:[e.jsx(H.Header,{title:"Download in another format",onClose:()=>J(!1)}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Format"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Markdown",description:"Good for GitHub, static blogs, and other note apps.",selected:Y==="markdown",onClick:()=>ne("markdown")}),e.jsx(ue,{title:"HTML",description:"Good for web documents or CMS editors.",selected:Y==="html",onClick:()=>ne("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(mt,{size:"sm",checked:G,onChange:o=>Q(o.target.checked),className:"mt-0.5","aria-label":"Include metadata"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(h,{as:"span",variant:"body",weight:"semibold",children:"Include metadata"}),e.jsx(h,{as:"span",variant:"label",tone:"tertiary",children:"Add the title, note id, timestamps, and Ocean Brain source information."})]})]}),Y==="html"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"HTML style"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Content only",description:"Save only the note body HTML.",selected:p==="fragment",onClick:()=>E("fragment")}),e.jsx(ue,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:p==="standalone",onClick:()=>E("standalone")})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>J(!1),children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:Ut,children:"Download"})]})})]}),e.jsx(cn,{isOpen:_,noteId:t,onClose:()=>D(!1),onRestored:o=>{i.current=Oe(),Ce(),K.current=null,U.current=o.updatedAt,L(null),ae(o.updatedAt),I(o.updatedAt)}}),Vt]})})}function Mr(){const{id:t}=St.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Ue,{fallback:gr,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:a,retry:r})=>e.jsx(Ge,{title:"Note",variant:"none",children:e.jsx(Ze,{title:"Failed to load note",description:"Retry loading the note editor.",error:a,onRetry:r})}),children:e.jsx(wr,{id:t},t)})}export{wr as NoteContent,Mr as default};
21
+ </html>`},Fe=(t,a,r)=>{const l=new Blob([t],{type:r}),s=URL.createObjectURL(l),d=document.createElement("a");d.href=s,d.download=a,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(s)},St=Ra(ve),pe=t=>{const a=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(a)?a:null},Pe=t=>{const a=pe(t);return W(a??Number(t)).format("YYYY-MM-DD HH:mm:ss")},ur=(t,a)=>Ta(pe(t),a),Oe=()=>pn(),pr="NOTE_UPDATE_CONFLICT",mr=2200,fr=t=>t?.extensions?.currentUpdatedAt,ct=(t,a)=>{const r=pe(t),l=pe(a);return r===null||l===null?t===a?0:1:r-l},hr=t=>{const a=t.trim();if(!a)return null;try{const r=new URL(a);return r.protocol==="http:"||r.protocol==="https:"?r.toString():null}catch{return null}},xr={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},gr=e.jsx(Ge,{title:"Loading note",variant:"none",children:e.jsxs("main",{className:"mx-auto max-w-[896px]",children:[e.jsx(ie,{className:"mb-8",height:"66px"}),e.jsx(ie,{className:"ml-12 mb-8",height:"150px"}),e.jsx(ie,{className:"mb-5",height:"80px"}),e.jsx(ie,{height:"80px"})]})}),yr=t=>({id:t?.key??"",key:t?.key??"",name:t?.name??"",value:t?.value??"",valueType:t?.valueType??"text",persistedKey:t?.key}),vr=t=>{if(Array.isArray(t))return t;const a=t?.keys;return Array.isArray(a)?a:[]},Be=(t=[])=>t.map(yr),Rt=(t,a)=>{const r=[],l=new Set(a);for(const s of t){const d=s.key.trim();if(!d)continue;const i=s.value.trim(),u=!!s.persistedKey&&(s.valueType==="number"||s.valueType==="date"||s.valueType==="select"||s.valueType==="url");if(!i&&u){l.add(s.persistedKey);continue}!i&&s.valueType!=="text"&&s.valueType!=="boolean"||r.push({key:d,name:s.name.trim()||d,value:s.valueType==="boolean"?i||"false":i,valueType:s.valueType})}return{set:r.sort((s,d)=>s.key.localeCompare(d.key)),deleteKeys:Array.from(l).sort()}},le=(t,a=[])=>JSON.stringify(Rt(t,a)),br=({noteId:t,properties:a=[],expectedUpdatedAt:r,editSessionId:l,disabled:s,onSaved:d})=>{const i=Ye(),u=we(),[c,h]=n.useState(()=>Be(a)),[m,N]=n.useState([]),[j,y]=n.useState("idle"),S=n.useRef(c),f=n.useRef(m),L=n.useRef(r),F=n.useRef(le(c)),M=n.useRef(null),C=n.useRef(!1),b=n.useRef(!1),v=_e({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const p=await Ma({limit:50});if(p.type==="error")throw p;return p.notePropertyKeys.keys}});n.useEffect(()=>{const p=Be(a);h(p),N([]),F.current=le(p),y("idle")},[a]),n.useEffect(()=>{S.current=c},[c]),n.useEffect(()=>{f.current=m},[m]),n.useEffect(()=>{L.current=r},[r]);const P=vr(v.data),_=P.filter(p=>!c.some(E=>E.key===p.key)),D=P.length>0,O=n.useCallback(async()=>{const p=le(S.current,f.current);if(s||p===F.current)return;if(C.current){b.current=!0;return}const E=Rt(S.current,f.current);if(!(E.set.length===0&&E.deleteKeys.length===0)){C.current=!0,b.current=!1,y("saving");try{const w=await Ha({id:t,set:E.set,deleteKeys:E.deleteKeys,editSessionId:l,expectedUpdatedAt:L.current});if(w.type==="error"){y("error"),i(w.errors[0]?.message??"Failed to save properties.");return}L.current=w.updateNoteProperties.updatedAt,F.current=le(Be(w.updateNoteProperties.properties??[])),d(w.updateNoteProperties),u.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),y("saved")}catch{y("error"),i("Failed to save properties.")}finally{C.current=!1,b.current&&(b.current=!1,O())}}},[s,l,t,d,u,i]);n.useEffect(()=>{if(M.current&&clearTimeout(M.current),!(s||le(c,m)===F.current))return M.current=setTimeout(()=>{O()},500),()=>{M.current&&clearTimeout(M.current)}},[m,s,c,O]);const J=p=>{h(E=>[...E,{id:p.key,key:p.key,name:p.name,value:"",valueType:p.valueType,persistedKey:void 0}]),N(E=>E.filter(w=>w!==p.key))},Y=(p,E)=>{h(w=>w.map(V=>V.id===p?{...V,...E}:V))},ne=p=>{p.persistedKey&&N(E=>[...new Set([...E,p.persistedKey])]),h(E=>E.filter(w=>w.id!==p.id))},G=le(c,m)!==F.current,Q=s||!G&&j==="idle"?null:j==="saving"?"Saving...":j==="error"?"Save failed":G?"Waiting...":"Saved";return e.jsxs(We,{title:"Properties",icon:e.jsx($a,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:e.jsxs(e.Fragment,{children:[Q&&e.jsx(x,{as:"span",variant:"micro",tone:j==="error"?"error":"tertiary",className:"px-1",children:Q}),D&&e.jsx(R,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(Ke,{to:rt,search:{page:1},children:[e.jsx(_a,{className:"h-3 w-3"}),"Manage"]})})]}),children:[c.length===0?e.jsx(x,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):e.jsx("div",{className:"divide-y divide-border-subtle",children:c.map(p=>{const E=p.valueType==="url"?hr(p.value):null;return e.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[e.jsx(x,{as:"span",variant:"label",tone:"secondary",className:"truncate",children:p.name}),e.jsx(x,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:p.key})]}),p.valueType==="boolean"?e.jsxs(nt,{size:"sm",variant:"ghost",value:p.value||"false",disabled:s,onValueChange:w=>Y(p.id,{value:w}),children:[e.jsx(He,{value:"false",children:"False"}),e.jsx(He,{value:"true",children:"True"})]}):p.valueType==="select"?e.jsx(nt,{size:"sm",variant:"ghost",value:p.value,placeholder:"Select option",disabled:s,onValueChange:w=>Y(p.id,{value:w}),children:(P.find(w=>w.key===p.key)?.options??[]).map(w=>e.jsx(He,{value:w.value,children:w.label},w.id))}):p.valueType==="url"?e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx($e,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:p.value,disabled:s,onChange:w=>Y(p.id,{value:w.target.value})}),E?e.jsx(R,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${p.name}`,className:"shrink-0 text-fg-tertiary",children:e.jsx("a",{href:E,target:"_blank",rel:"noopener noreferrer",title:E,children:e.jsx(Nt,{className:"h-4 w-4"})})}):null]}):e.jsx($e,{size:"sm",variant:"ghost",type:p.valueType==="date"?"date":p.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:p.value,disabled:s,onChange:w=>Y(p.id,{value:w.target.value})}),e.jsx(R,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${p.name}`,disabled:s,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>ne(p),children:e.jsx(Da,{className:"h-4 w-4"})})]},p.id)})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:v.isLoading?e.jsx(R,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):_.length>0?e.jsxs(La,{children:[e.jsx(Va,{asChild:!0,children:e.jsxs(R,{type:"button",size:"sm",variant:"ghost",disabled:s,children:[e.jsx(ze,{className:"h-4 w-4"}),"Add property"]})}),e.jsxs(Fa,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[e.jsx(Pa,{children:e.jsx(x,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),e.jsx(Oa,{}),_.map(p=>e.jsxs(Ba,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>J(p),children:[e.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[e.jsx(x,{as:"span",variant:"label",weight:"medium",className:"truncate",children:p.name}),e.jsx(x,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:p.valueType})]}),e.jsx(x,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:p.key})]},p.key))]})]}):D?e.jsx(x,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):e.jsxs(Ke,{to:rt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(ze,{className:"h-4 w-4"}),"Create property definition"]})})]})};function wr({id:t}){const a=Ye(),r=St.useNavigate(),l=we(),s=n.useRef(null),d=n.useRef(null),i=n.useRef(Oe()),u=pt({queryKey:T.notes.detail(t),queryFn:async()=>{const o=await Na(t);if(o.type==="error")throw o;return o.note},gcTime:0}),c=u.data,[h,m]=n.useState(c.title),[N,j]=n.useState(()=>Pe(c.updatedAt)),[y,S]=n.useState(c.updatedAt),[f,L]=n.useState(()=>Date.now()),[F,M]=n.useState(c.pinned),[C,b]=n.useState(c.layout||"wide"),[v,P]=n.useState(!1),[_,D]=n.useState(!1),[O,J]=n.useState(!1),[Y,ne]=n.useState("markdown"),[G,Q]=n.useState(!1),[p,E]=n.useState("fragment"),[w,V]=n.useState(null),[je,oe]=n.useState(null),[Ne,A]=n.useState(0),[B,$]=n.useState(!1),U=n.useRef(c.updatedAt),Z=n.useRef(t),K=n.useRef(null),re=n.useRef(!1),I=n.useCallback(o=>{j(Pe(o)),S(o),L(Date.now())},[]),X=rr({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:i,getContent:()=>s.current?.getContent(),onSaved:o=>{K.current=null,U.current=o,I(o),$(!0)},onConflict:o=>{V({type:"updated",updatedAt:o,source:"unknown"}),a("This note changed elsewhere. Choose how to resolve the draft.")},onError:a}),{saveStatus:k,localDraft:ee,serverUpdatedAtRef:te,hasUnsavedChanges:ce,buildDraft:fe,queueSave:he,flushPendingSave:xe,restoreLocalDraft:Tt,discardLocalDraft:Et,clearDrafts:Ce,resolveConflict:Mt,pauseForConflict:de,getPendingDraft:ke,setServerUpdatedAt:ae}=X,Ht=n.useCallback(async()=>{if(re.current)return re.current=!1,!1;if(k==="conflict")return a("Resolve the note conflict before leaving."),!0;const o=await xe();return o==="error"?(a("Save failed. Stay on this note and try again."),!0):o==="conflict"},[xe,k,a]);Wa({disabled:k==="saved",enableBeforeUnload:!1,shouldBlockFn:Ht}),n.useEffect(()=>{if(ce){c.updatedAt!==te.current&&ct(c.updatedAt,te.current)>0&&de(c.updatedAt);return}const o=U.current;if(!(c.updatedAt!==o&&ct(c.updatedAt,o)<0)&&(M(c.pinned),b(c.layout||"wide"),ae(c.updatedAt),m(c.title),I(c.updatedAt),o!==c.updatedAt)){const g=s.current?.getContent();U.current=c.updatedAt,(g===void 0||g!==c.content)&&(oe(null),A(z=>z+1))}},[ce,c.layout,c.pinned,c.title,c.updatedAt,de,te,ae,I]),n.useEffect(()=>{Z.current!==t&&(Z.current=t,i.current=Oe(),U.current=c.updatedAt,K.current=null,V(null),oe(null),A(o=>o+1),$(!1))},[t,c.updatedAt]),n.useEffect(()=>{if(k!=="saved")return;const o=window.setTimeout(()=>{L(Date.now())},Ca(pe(y),f));return()=>window.clearTimeout(o)},[y,f,k]),n.useEffect(()=>{if(!B)return;const o=window.setTimeout(()=>{$(!1)},mr);return()=>window.clearTimeout(o)},[B]),n.useEffect(()=>{w?.type!=="updated"||k==="conflict"||w.updatedAt!==c.updatedAt||(U.current=c.updatedAt,ae(c.updatedAt),I(c.updatedAt),V(null))},[w,c.updatedAt,k,ae,I]),n.useEffect(()=>ka(o=>{if(o.noteId===t&&!(o.source==="web"&&o.editSessionId===i.current)){if(o.type==="mcp.note.updated"||o.type==="web.note.updated"){if(o.updatedAt===c.updatedAt||o.updatedAt===te.current)return;if(ce){de(o.updatedAt),V({type:"updated",updatedAt:o.updatedAt,source:o.source});return}V({type:"updated",updatedAt:o.updatedAt,source:o.source});return}o.type==="mcp.note.deleted"&&V({type:"deleted",source:o.source})}}),[ce,t,c.updatedAt,de,te]);const{onCreate:Dt,onDelete:Lt,onPinned:Vt,deleteWarningDialog:Ft}=Aa(),Pt=()=>{he(fe(h))},Ot=o=>{m(o),he(fe(o))},Xe=()=>{he(fe(h),{immediate:!0})},Bt=async o=>{if(ce){b(o),he(fe(h,{layout:o}),{immediate:!0}),a("Layout will be saved with your draft.");return}const g=await Ie({id:t,layout:o,editSessionId:i.current,expectedUpdatedAt:te.current});if(g.type==="error"){g.errors[0].code===pr&&(K.current=o,b(o),de(fr(g.errors[0].details)??te.current)),a(g.errors[0].message);return}K.current=null,await l.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=g.updateNote.updatedAt,ae(g.updateNote.updatedAt),l.setQueryData(T.notes.detail(t),z=>z&&{...z,layout:o,updatedAt:g.updateNote.updatedAt}),ye({noteId:t,updatedAt:g.updateNote.updatedAt,editSessionId:i.current}),I(g.updateNote.updatedAt),b(o),a("Layout has been updated.")},_t=()=>({id:t,title:h,createdAt:c.createdAt,updatedAt:te.current||c.updatedAt}),$t=async()=>{const o=s.current?.getMarkdown();if(o===void 0){a("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(o),a("Copied note as Markdown.")}catch{a("Failed to copy Markdown.")}},It=()=>{const o=s.current?.getMarkdown();if(o===void 0){a("Markdown is not ready yet.");return}try{Fe(o,Ve(h,"md"),"text/markdown;charset=utf-8"),a("Downloaded note as Markdown.")}catch{a("Failed to download Markdown.")}},Ut=()=>{const o=_t();try{if(Y==="markdown"){const g=s.current?.getMarkdown();if(g===void 0){a("Markdown is not ready yet.");return}Fe(cr(g,o,G),Ve(h,"md"),"text/markdown;charset=utf-8")}else{const g=s.current?.getHtml();if(g===void 0){a("HTML is not ready yet.");return}Fe(dr(g,o,{includeMetadata:G,mode:p}),Ve(h,"html"),"text/html;charset=utf-8")}J(!1),a("Downloaded note.")}catch{a("Failed to download note.")}},Zt=async()=>{const o=await u.refetch();if(o.error||!o.data){a("Failed to reload the latest note state.");return}Ce(),K.current=null,U.current=o.data.updatedAt,ae(o.data.updatedAt),m(o.data.title),b(o.data.layout||"wide"),I(o.data.updatedAt),oe(null),A(g=>g+1),V(null)},Kt=async()=>{if(ke()){K.current=null,V(null),await xe({ignoreConflict:!0});return}const g=K.current;if(g){const z=await Ie({id:t,layout:g,editSessionId:i.current,force:!0});if(z.type==="error"){a(z.errors[0].message);return}K.current=null,await l.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=z.updateNote.updatedAt,Mt(),V(null),ae(z.updateNote.updatedAt),l.setQueryData(T.notes.detail(t),Te=>Te&&{...Te,layout:g,updatedAt:z.updateNote.updatedAt}),ye({noteId:t,updatedAt:z.updateNote.updatedAt,editSessionId:i.current}),I(z.updateNote.updatedAt),b(g);return}V(null),await xe({ignoreConflict:!0})},et=async()=>{const o=ke();if(!o)return;const g=await Ea({title:at(o.title||"untitled"),content:at(o.content),layout:o.layout??C});if(g.type==="error"){a(g.errors[0].message);return}re.current=!0,K.current=null,V(null),Ce(),Promise.resolve(r({to:ve,params:{id:g.createNote.id}})).finally(()=>{re.current=!1})},zt=()=>{ee&&(m(ee.title),ee.layout&&b(ee.layout),oe(ee.content),A(o=>o+1),Tt(ee))},qt=()=>{Et()},Qt=ee?W(ee.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Ae=k==="saved"&&B,Yt=ur(y,f),Gt=Pe(c.createdAt),Wt=k==="pending"?"Saving...":k==="saving"?"Saving now...":k==="error"?"Save failed. Try again.":k==="conflict"?"Save paused: changed elsewhere":`Saved ${Yt}`,Jt=q("inline-flex items-center gap-2 transition-colors",k==="saved"&&!Ae&&"text-fg-secondary",Ae&&"text-accent-success",(k==="pending"||k==="saving")&&"text-fg-default",(k==="error"||k==="conflict")&&"text-fg-error"),Se=q("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(k==="pending"||k==="saving")&&"save-progress-ring-active",k==="saved"&&Ae&&"save-progress-ring-complete",(k==="error"||k==="conflict")&&"save-progress-ring-error"),Xt=k==="saving"?e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):k==="pending"?e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):k==="error"||k==="conflict"?e.jsx(Ia,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Se,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),ea=e.jsxs(x,{as:"span",variant:"label",weight:"medium",className:Jt,role:"status","aria-live":"polite",title:N,children:[Xt,Wt]}),Re=k==="conflict"&&w?.type==="updated",ta=Re?ke():null,aa=w!==null&&!(w.type==="updated"&&!Re&&w.updatedAt===c.updatedAt);return e.jsx(Ge,{title:h,variant:"none",children:e.jsxs("main",{className:q("mx-auto",xr[C]),children:[e.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx(x,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),e.jsx("input",{ref:d,placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:h,onChange:o=>Ot(o.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(ft,{button:e.jsx(ht,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:$t},{name:"Download Markdown",onClick:It},{name:"Download in another format",onClick:()=>J(!0)},{type:"separator",key:"export-separator"},{name:F?"Unpin":"Pin",onClick:()=>Vt(t,F,()=>{M(o=>!o)})},{name:"Change layout",onClick:()=>P(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>Dt(d.current?.value||"untitled",s.current?.getContent()||"",C)},{name:"Restore previous version",onClick:()=>D(!0)},{type:"separator"},{name:"Delete",onClick:()=>Lt(t,()=>{r({to:tt,search:{page:1}})})}]}),e.jsx(R,{size:"sm",variant:"subtle",isLoading:k==="saving",disabled:k==="conflict",onClick:Xe,children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[F&&e.jsxs(x,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(Sa,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),F&&e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),ea,e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsxs(x,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",Gt]})]})]})}),ee&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["A draft from ",Qt," is saved only in this browser."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(R,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:zt,children:"Restore draft"}),e.jsx(R,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:qt,children:"Discard"})]})]})}),k==="error"&&e.jsx(st,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(R,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Xe,children:"Retry save"}),e.jsx(R,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{et()},children:"Save as new note"})]})]})}),e.jsx(br,{noteId:t,properties:c.properties,expectedUpdatedAt:te.current,editSessionId:i.current,disabled:k!=="saved",onSaved:o=>{U.current=o.updatedAt,ae(o.updatedAt),I(o.updatedAt),$(!0),l.setQueryData(T.notes.detail(t),g=>g&&{...g,updatedAt:o.updatedAt,properties:o.properties}),ye({noteId:t,updatedAt:o.updatedAt,editSessionId:i.current})}}),e.jsx(er,{ref:s,content:je??c.content,currentNoteId:t,onChange:Pt},`${t}:${Ne}`),e.jsx(Ue,{fallback:e.jsx(ie,{className:"mb-5",height:"80px"}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:o,retry:g})=>e.jsx(Ze,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:o,onRetry:g,showBackAction:!1,showHomeAction:!1}),children:e.jsx(fn,{noteId:t})}),e.jsx(Ue,{fallback:e.jsx(ie,{height:"80px"}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:o,retry:g})=>e.jsx(Ze,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:o,onRetry:g,showBackAction:!1,showHomeAction:!1}),children:e.jsx(dn,{noteId:t,render:o=>o&&o.length>0&&e.jsx(We,{icon:e.jsx(Nt,{className:"h-3.5 w-3.5"}),title:"Back References",children:e.jsx("ul",{className:"flex flex-col",children:o.map(g=>e.jsx("li",{children:e.jsxs(Ke,{to:ve,params:{id:g.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(an,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(x,{as:"span",variant:"body",weight:"medium",className:"text-current",children:g.title})]})},g.id))})})})}),e.jsx(rn,{isOpen:v,onClose:()=>P(!1),onSave:Bt,currentLayout:C}),e.jsx(ln,{isOpen:aa,isDeleted:w?.type==="deleted",isConflict:Re,hasDraft:ta!==null,source:w?.source??"unknown",isReloading:u.isRefetching,onReload:Zt,onOverwrite:()=>{Kt()},onCloneDraft:()=>{et()},onOpenTrash:()=>r({to:tt,search:{page:1}})}),e.jsxs(H,{isOpen:O,onClose:()=>J(!1),variant:"compact",children:[e.jsx(H.Header,{title:"Download in another format",onClose:()=>J(!1)}),e.jsx(H.Body,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Format"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Markdown",description:"Good for GitHub, static blogs, and other note apps.",selected:Y==="markdown",onClick:()=>ne("markdown")}),e.jsx(ue,{title:"HTML",description:"Good for web documents or CMS editors.",selected:Y==="html",onClick:()=>ne("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(mt,{size:"sm",checked:G,onChange:o=>Q(o.target.checked),className:"mt-0.5","aria-label":"Include metadata"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(x,{as:"span",variant:"body",weight:"semibold",children:"Include metadata"}),e.jsx(x,{as:"span",variant:"label",tone:"tertiary",children:"Add the title, note id, timestamps, and Ocean Brain source information."})]})]}),Y==="html"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"HTML style"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ue,{title:"Content only",description:"Save only the note body HTML.",selected:p==="fragment",onClick:()=>E("fragment")}),e.jsx(ue,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:p==="standalone",onClick:()=>E("standalone")})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(me,{children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>J(!1),children:"Cancel"}),e.jsx(R,{variant:"primary",size:"sm",onClick:Ut,children:"Download"})]})})]}),e.jsx(cn,{isOpen:_,noteId:t,onClose:()=>D(!1),onRestored:o=>{i.current=Oe(),Ce(),K.current=null,U.current=o.updatedAt,V(null),ae(o.updatedAt),I(o.updatedAt)}}),Ft]})})}function Mr(){const{id:t}=St.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Ue,{fallback:gr,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:a,retry:r})=>e.jsx(Ge,{title:"Note",variant:"none",children:e.jsx(Ze,{title:"Failed to load note",description:"Retry loading the note editor.",error:a,onRetry:r})}),children:e.jsx(wr,{id:t},t)})}export{wr as NoteContent,Mr as default};
@@ -1 +1 @@
1
- import{a as e}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-DYlYUrjH.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
1
+ import{a as e}from"./graph-vendor-CUxe67Lr.js";import{p as l}from"./index-B43ulIPo.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{$ as k,T as h,L as H,N as M,D as E,k as L,d as x,a0 as S,P as w,G as O,a1 as C,i as o,j as U,a2 as I}from"./index-DYlYUrjH.js";import"./graph-vendor-CUxe67Lr.js";import{u as P,R as Y}from"./useReminderMutate-DHjDDHKg.js";import"./note-core-Z6kqulGB.js";const u={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:g}){const f=y=>{const r=x(Number(y)),m=x();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=x(Number(y)),m=x(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=u[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",j=t.content?.trim()||t.note?.title||"Untitled reminder",R=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=f(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:j}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:M,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:R})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(E,{button:e.jsx(L,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>g(t.id,c)}]})})]})}const v=U(I),A=[{label:"High",className:u.high},{label:"Medium",className:u.medium},{label:"Low",className:u.low}];function Q(){const t=v.useNavigate(),{page:l}=v.useSearch(),{onUpdate:g,onDelete:f}=P(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(S,{fallback:e.jsx(w,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(Y,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(O,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:g,onDelete:f},n.id))}),s&&a<s&&e.jsx(C,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:j=>({...j,page:n})})}})]})})}})})}export{Q as default};
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{v as k,T as h,L as H,N as M,D as E,l as L,d as x,a0 as S,P as v,J as O,a1 as C,i as o,j as U,a2 as I}from"./index-B43ulIPo.js";import"./graph-vendor-CUxe67Lr.js";import{u as P,R as Y}from"./useReminderMutate-h7d_S_X2.js";import"./note-core-DMZcZ4yV.js";const u={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:g}){const f=y=>{const r=x(Number(y)),m=x();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=x(Number(y)),m=x(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=u[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",j=t.content?.trim()||t.note?.title||"Untitled reminder",R=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=f(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:j}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:M,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:R})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(E,{button:e.jsx(L,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>g(t.id,c)}]})})]})}const w=U(I),A=[{label:"High",className:u.high},{label:"Medium",className:u.medium},{label:"Low",className:u.low}];function Q(){const t=w.useNavigate(),{page:l}=w.useSearch(),{onUpdate:g,onDelete:f}=P(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(S,{fallback:e.jsx(v,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(Y,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(v,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(O,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(v,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:g,onDelete:f},n.id))}),s&&a<s&&e.jsx(C,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:j=>({...j,page:n})})}})]})})}})})}export{Q as default};
@@ -1 +1 @@
1
- import{j as e}from"./note-vendor-i1M2FSI2.js";import{P as m,G as f,a0 as N,a9 as b,T as h,L as w,N as S,a1 as k,j as E,aa as $,i as d}from"./index-DYlYUrjH.js";import{a as R}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const L=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=L(r),n=new RegExp(`(${a})`,"gi"),c=new RegExp(`^${a}$`,"i"),l=t.split(n);return e.jsx("span",{children:l.map((i,o)=>c.test(i)?e.jsx("mark",{children:i},o):e.jsx(R.Fragment,{children:i},o))})},j=E($),v=180,x=t=>t.replace(/\s+/g," ").trim(),T=(t,s)=>{const r=x(t),a=x(s).toLowerCase();if(!a)return r;const n=r.toLowerCase().indexOf(a);if(n===-1)return r.length>v?`${r.slice(0,v-1).trimEnd()}…`:r;const c=Math.max(0,n-56),l=Math.min(r.length,n+a.length+84);let i=r.slice(c,l).trim();return c>0&&(i=`…${i}`),l<r.length&&(i=`${i}…`),i},A=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",B=(t,s)=>t==="heading"?`Heading ${typeof s?.level=="number"?s.level:1}`:t==="bulletListItem"?"Bullet":t==="numberedListItem"?"Numbered":t==="checkListItem"?"Checklist":t==="quote"?"Quote":t==="codeBlock"?"Code":"Content",y=(t,s)=>{Array.isArray(t)&&t.forEach(r=>{if(!r||typeof r!="object")return;const a=typeof r.type=="string"?r.type:void 0,n=typeof r.props=="object"&&r.props?r.props:void 0,c=x(A(r.content));c&&s.push({label:B(a,n),text:c});const l=r.children;Array.isArray(l)&&y(l,s)})},C=(t,s)=>{try{const r=JSON.parse(t),a=[];if(y(r,a),a.length===0)return[];const n=x(s).toLowerCase(),c=n?a.filter(i=>i.text.toLowerCase().includes(n)):a;return(c.length>0?c:a).slice(0,2).map(i=>({...i,text:T(i.text,s)}))}catch{return[]}},P=t=>t===1?"1 result":`${t} results`,M=()=>"Open the note to inspect matching content.",z=(t,s)=>`${P(s)} for "${t}"`,I=()=>e.jsx(m,{title:"Search",variant:"default",description:e.jsx(d,{width:208,height:16,className:"rounded-full"}),children:e.jsx("main",{className:"flex flex-col gap-3",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(d,{width:"34%",height:18,className:"rounded-full"}),e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{width:84,height:12,className:"rounded-full"}),e.jsx(d,{width:"100%",height:14,className:"mt-2 rounded-full"}),e.jsx(d,{width:"82%",height:14,className:"mt-1.5 rounded-full"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-2",children:[e.jsx(d,{width:72,height:12,className:"rounded-full"}),e.jsx(d,{width:"94%",height:14,className:"mt-2 rounded-full"})]})]})})]},s))})});function F(){const t=j.useNavigate(),{page:s,query:r}=j.useSearch(),a=r.trim(),n=10;return a?e.jsx(N,{fallback:e.jsx(I,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${a}".`,resetKeys:[a,s],children:e.jsx(b,{searchParams:{query:a,limit:n,offset:(s-1)*n,fields:["content"]},render:({notes:c,totalCount:l})=>e.jsx(m,{title:"Search",description:z(a,l),variant:"default",children:e.jsxs("main",{className:"flex flex-col gap-4",children:[c.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:c.map(i=>{const o=C(i.content,a);return e.jsxs("article",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(h,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",children:e.jsx(w,{to:S,params:{id:i.id},className:"transition-colors hover:text-fg-default/85",children:e.jsx(g,{match:a,children:i.title||"Untitled"})})}),o.length>0?e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((u,p)=>e.jsxs("div",{className:p>0?"border-t border-border-subtle pt-2":void 0,children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"wider",transform:"uppercase",tone:"tertiary",children:u.label}),e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-1 leading-[1.65]",children:e.jsx(g,{match:a,children:u.text})})]},`${i.id}:${u.label}:${p}`))})}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"leading-[1.65]",children:M()})]},i.id)})}):e.jsx(f,{title:"No results found",description:"Try searching for a different word or phrase"}),l>n&&e.jsx(k,{page:s,last:Math.ceil(l/n),onChange:i=>{t({search:o=>({...o,page:i})})}})]})})})}):e.jsx(m,{title:"Search",description:"Search note titles and matching sections across your workspace",variant:"default",children:e.jsx("main",{children:e.jsx(f,{title:"Start searching",description:"Enter a keyword to look through note titles and matching content"})})})}export{F as default};
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{P as m,J as f,a0 as N,a9 as b,T as h,L as w,N as S,a1 as k,j as E,aa as $,i as d}from"./index-B43ulIPo.js";import{a as R}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const L=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=L(r),n=new RegExp(`(${a})`,"gi"),c=new RegExp(`^${a}$`,"i"),l=t.split(n);return e.jsx("span",{children:l.map((i,o)=>c.test(i)?e.jsx("mark",{children:i},o):e.jsx(R.Fragment,{children:i},o))})},j=E($),v=180,x=t=>t.replace(/\s+/g," ").trim(),T=(t,s)=>{const r=x(t),a=x(s).toLowerCase();if(!a)return r;const n=r.toLowerCase().indexOf(a);if(n===-1)return r.length>v?`${r.slice(0,v-1).trimEnd()}…`:r;const c=Math.max(0,n-56),l=Math.min(r.length,n+a.length+84);let i=r.slice(c,l).trim();return c>0&&(i=`…${i}`),l<r.length&&(i=`${i}…`),i},A=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",B=(t,s)=>t==="heading"?`Heading ${typeof s?.level=="number"?s.level:1}`:t==="bulletListItem"?"Bullet":t==="numberedListItem"?"Numbered":t==="checkListItem"?"Checklist":t==="quote"?"Quote":t==="codeBlock"?"Code":"Content",y=(t,s)=>{Array.isArray(t)&&t.forEach(r=>{if(!r||typeof r!="object")return;const a=typeof r.type=="string"?r.type:void 0,n=typeof r.props=="object"&&r.props?r.props:void 0,c=x(A(r.content));c&&s.push({label:B(a,n),text:c});const l=r.children;Array.isArray(l)&&y(l,s)})},C=(t,s)=>{try{const r=JSON.parse(t),a=[];if(y(r,a),a.length===0)return[];const n=x(s).toLowerCase(),c=n?a.filter(i=>i.text.toLowerCase().includes(n)):a;return(c.length>0?c:a).slice(0,2).map(i=>({...i,text:T(i.text,s)}))}catch{return[]}},P=t=>t===1?"1 result":`${t} results`,M=()=>"Open the note to inspect matching content.",z=(t,s)=>`${P(s)} for "${t}"`,I=()=>e.jsx(m,{title:"Search",variant:"default",description:e.jsx(d,{width:208,height:16,className:"rounded-full"}),children:e.jsx("main",{className:"flex flex-col gap-3",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(d,{width:"34%",height:18,className:"rounded-full"}),e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{width:84,height:12,className:"rounded-full"}),e.jsx(d,{width:"100%",height:14,className:"mt-2 rounded-full"}),e.jsx(d,{width:"82%",height:14,className:"mt-1.5 rounded-full"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-2",children:[e.jsx(d,{width:72,height:12,className:"rounded-full"}),e.jsx(d,{width:"94%",height:14,className:"mt-2 rounded-full"})]})]})})]},s))})});function F(){const t=j.useNavigate(),{page:s,query:r}=j.useSearch(),a=r.trim(),n=10;return a?e.jsx(N,{fallback:e.jsx(I,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${a}".`,resetKeys:[a,s],children:e.jsx(b,{searchParams:{query:a,limit:n,offset:(s-1)*n,fields:["content"]},render:({notes:c,totalCount:l})=>e.jsx(m,{title:"Search",description:z(a,l),variant:"default",children:e.jsxs("main",{className:"flex flex-col gap-4",children:[c.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:c.map(i=>{const o=C(i.content,a);return e.jsxs("article",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(h,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",children:e.jsx(w,{to:S,params:{id:i.id},className:"transition-colors hover:text-fg-default/85",children:e.jsx(g,{match:a,children:i.title||"Untitled"})})}),o.length>0?e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((u,p)=>e.jsxs("div",{className:p>0?"border-t border-border-subtle pt-2":void 0,children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"wider",transform:"uppercase",tone:"tertiary",children:u.label}),e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-1 leading-[1.65]",children:e.jsx(g,{match:a,children:u.text})})]},`${i.id}:${u.label}:${p}`))})}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"leading-[1.65]",children:M()})]},i.id)})}):e.jsx(f,{title:"No results found",description:"Try searching for a different word or phrase"}),l>n&&e.jsx(k,{page:s,last:Math.ceil(l/n),onChange:i=>{t({search:o=>({...o,page:i})})}})]})})})}):e.jsx(m,{title:"Search",description:"Search note titles and matching sections across your workspace",variant:"default",children:e.jsx("main",{children:e.jsx(f,{title:"Start searching",description:"Enter a keyword to look through note titles and matching content"})})})}export{F as default};
@@ -1 +1 @@
1
- import{j as f}from"./note-vendor-i1M2FSI2.js";import{b7 as o}from"./index-DYlYUrjH.js";const n=o("surface-base",{variants:{tone:{default:"",elevated:"surface-elevated"},padding:{default:"p-4",compact:"px-3 py-2.5",roomy:"p-6",flush:"overflow-hidden"}},defaultVariants:{tone:"default",padding:"default"}});function i({children:a,className:e,flush:t=!1,padding:d="default",tone:s="default"}){const r=t?"flush":d;return f.jsx("div",{className:n({tone:s,padding:r,className:e}),children:a})}export{i as S};
1
+ import{j as f}from"./note-vendor-uuJO2MTD.js";import{b7 as o}from"./index-B43ulIPo.js";const n=o("surface-base",{variants:{tone:{default:"",elevated:"surface-elevated"},padding:{default:"p-4",compact:"px-3 py-2.5",roomy:"p-6",flush:"overflow-hidden"}},defaultVariants:{tone:"default",padding:"default"}});function i({children:a,className:e,flush:t=!1,padding:d="default",tone:s="default"}){const r=t?"flush":d;return f.jsx("div",{className:n({tone:s,padding:r,className:e}),children:a})}export{i as S};
@@ -0,0 +1 @@
1
+ import{j as e}from"./note-vendor-uuJO2MTD.js";import{a6 as g,z as p,q as m,a0 as u,ab as f,P as d,ac as h,L as j,ad as y,T as o,a1 as T,J as w,i as s,j as b,ae as v}from"./index-B43ulIPo.js";import"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const N=r=>{const{data:i}=g({queryKey:m.tags.list(r.searchParams),async queryFn(){const a=await p({offset:r.searchParams.offset,limit:r.searchParams.limit});if(a.type==="error")throw a;return a.allTags}});return r.render(i)},E=f,c=b(v);function k(){const r=c.useNavigate(),{page:i}=c.useSearch(),a=E;return e.jsx("div",{children:e.jsx(u,{fallback:e.jsx(d,{title:"Tags",heading:e.jsx(s,{width:120,height:24,className:"rounded-full"}),description:e.jsx(s,{width:188,height:16,className:"rounded-full"}),children:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(s,{width:"90px",height:"36px"}),e.jsx(s,{width:"120px",height:"36px"}),e.jsx(s,{width:"80px",height:"36px"}),e.jsx(s,{width:"100px",height:"36px"}),e.jsx(s,{width:"110px",height:"36px"}),e.jsx(s,{width:"70px",height:"36px"})]})}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[i,a],children:e.jsx(N,{searchParams:{offset:(i-1)*a,limit:a},render:({tags:l,totalCount:n})=>e.jsx(d,{title:"Tags",heading:n>0?`Tags (${n})`:void 0,description:"Browse the tags you added with @ across your notes",children:e.jsx(h,{fallback:e.jsx(w,{title:"No tags yet",description:"Add @tags inside notes and they will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:l.map(t=>e.jsxs(j,{to:y,params:{id:t.id},search:{page:1},className:"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-hover-subtle px-3 py-1.5 text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover hover:text-fg-default",children:[e.jsx(o,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:t.name}),e.jsx(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:t.referenceCount})]},t.id))}),e.jsx(h,{fallback:null,children:n&&a<n&&e.jsx(T,{page:i,last:Math.ceil(n/a),onChange:t=>{r({search:x=>({...x,page:t})})}})})]})})})})})})}export{k as default};