ocean-brain 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/client/dist/_redirects +1 -0
- package/server/client/dist/assets/{Calendar-B2_OJcHD.js → Calendar-BuHuea3u.js} +1 -1
- package/server/client/dist/assets/{Callout-BvXAlA5k.js → Callout-B-Y15DKd.js} +1 -1
- package/server/client/dist/assets/{Graph-DO35UCPM.js → Graph-BddGuIWA.js} +1 -1
- package/server/client/dist/assets/{Image.es-DLqLiGdW.js → Image.es-DWOPKZ3F.js} +1 -1
- package/server/client/dist/assets/Note-Dl6-yoQO.js +22 -0
- package/server/client/dist/assets/{Plus.es-I7xuoJ9B.js → Plus.es-2XIq0eEW.js} +1 -1
- package/server/client/dist/assets/{Reminders-B0LJeSlu.js → Reminders-06CF__C2.js} +1 -1
- package/server/client/dist/assets/{Search-xbDSlNOT.js → Search-DtLyJR_o.js} +1 -1
- package/server/client/dist/assets/{SurfaceCard-Brd1cMxi.js → SurfaceCard-C7ZAzggM.js} +1 -1
- package/server/client/dist/assets/{Tag-2PlhkjwY.js → Tag-KGPO2bT9.js} +1 -1
- package/server/client/dist/assets/{TagNotes-1yUBLqhX.js → TagNotes-CkmcnqM6.js} +1 -1
- package/server/client/dist/assets/{Trash.es-B-7U25B6.js → Trash.es-CerlaxH9.js} +1 -1
- package/server/client/dist/assets/{ViewNotes-D4X-MCTk.js → ViewNotes-Khdg4Ynn.js} +1 -1
- package/server/client/dist/assets/{ViewSectionTableRenderer-FuqBpQts.js → ViewSectionTableRenderer-BMlCUDvj.js} +1 -1
- package/server/client/dist/assets/{Views-CBEimWY8.js → Views-BLUk_24_.js} +1 -1
- package/server/client/dist/assets/image.api-C6RG15TF.js +17 -0
- package/server/client/dist/assets/{index-BFkZTZ6v.css → index-Biw4vuiN.css} +1 -1
- package/server/client/dist/assets/{index-sGhvnErO.js → index-CbhzIgIR.js} +1 -1
- package/server/client/dist/assets/{index-BgnmVjeF.js → index-_FcT3AuV.js} +44 -44
- package/server/client/dist/assets/{manage-image-detail-ejAh3nCL.js → manage-image-detail-CImm-cQJ.js} +1 -1
- package/server/client/dist/assets/{manage-image-B4UZ-ZQx.js → manage-image-mHebal-S.js} +1 -1
- package/server/client/dist/assets/{mcp-aIwuouT9.js → mcp-CHthNSpj.js} +1 -1
- package/server/client/dist/assets/{placeholder-B_9Hnm7h.js → placeholder-BMXsrVZ1.js} +4 -4
- package/server/client/dist/assets/{properties-D8oLyTCD.js → properties-DRB3IoO1.js} +1 -1
- package/server/client/dist/assets/{trash-w7Hhxckg.js → trash-Dw2FQsut.js} +1 -1
- package/server/client/dist/assets/{useReminderMutate--RlAj_Gg.js → useReminderMutate-C3GYwXa0.js} +1 -1
- package/server/client/dist/index.html +2 -2
- package/server/client/dist/assets/Note-AaTlS352.js +0 -22
- package/server/client/dist/assets/Note-W4f6H9K0.css +0 -1
- package/server/client/dist/assets/image.api-BtadKO98.js +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as D,T as r,t as F,L as p,N as _,ad as R,a_ as Z,aP as E,f as q,a0 as B,j as G,aZ as L,y as z,k as H,a6 as b,q as x,a$ as O,ah as v,b0 as K,b1 as P,B as w,i as l,m as Q}from"./index-BgnmVjeF.js";import{a as U,d as $}from"./image.api-BtadKO98.js";import{a as t}from"./graph-vendor-CUxe67Lr.js";import{I as V}from"./Image-DK0lnaK2.js";import{S as g}from"./SurfaceCard-Brd1cMxi.js";import{c as W,n as J}from"./Trash.es-B-7U25B6.js";import{I as X}from"./Image.es-DLqLiGdW.js";import"./note-core-DMZcZ4yV.js";const Y=new Map([["bold",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,36c-20.09,0-37.92,7.93-50,21.56C115.92,43.93,98.09,36,78,36a66.08,66.08,0,0,0-66,66c0,72.34,105.81,130.14,110.31,132.57a12,12,0,0,0,11.38,0C138.19,232.14,244,174.34,244,102A66.08,66.08,0,0,0,178,36Zm-5.49,142.36A328.69,328.69,0,0,1,128,210.16a328.69,328.69,0,0,1-44.51-31.8C61.82,159.77,36,131.42,36,102A42,42,0,0,1,78,60c17.8,0,32.7,9.4,38.89,24.54a12,12,0,0,0,22.22,0C145.3,69.4,160.2,60,178,60a42,42,0,0,1,42,42C220,131.42,194.18,159.77,172.51,178.36Z"}))],["duotone",t.createElement(t.Fragment,null,t.createElement("path",{d:"M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z",opacity:"0.2"}),t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["fill",t.createElement(t.Fragment,null,t.createElement("path",{d:"M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0C119.79,228.66,16,172,16,102A62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z"}))],["light",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60c0,29.2,18.2,59.59,54.1,90.31a334.68,334.68,0,0,0,53.06,37,6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42ZM128,217.11C111.59,207.64,30,157.72,30,102A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48C226,157.72,144.41,207.64,128,217.11Z"}))],["regular",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["thin",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58c0,28.59,18,58.47,53.4,88.79a333.81,333.81,0,0,0,52.7,36.73,4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44ZM128,219.42c-14-8-100-59.35-100-117.42A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50C228,160,142,211.46,128,219.42Z"}))]]),A=t.forwardRef((a,n)=>t.createElement(D,{ref:n,...a,weights:Y}));A.displayName="HeartIcon";const ee=A;function ae({name:a}){return e.jsx(r,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",children:a})}function se({id:a,title:n,tags:i,createdAt:u,updatedAt:d}){const o=new Date(Number(u)),m=F(Number(d));return e.jsx("div",{className:"border-b-2 border-dashed border-border-subtle last:border-b-0",children:e.jsxs("div",{className:"py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"label",weight:"medium",tone:"tertiary",children:m}),e.jsxs(r,{variant:"label",tone:"placeholder",children:["(",o.toDateString(),")"]})]}),e.jsx(r,{as:"div",variant:"body",weight:"bold",tracking:"tight",children:e.jsx(p,{className:"transition-colors hover:text-accent-primary",to:_,params:{id:a},children:n||"Untitled"})}),i&&i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(c=>e.jsx(p,{to:R,params:{id:c.id},search:{page:1},children:e.jsx(ae,{name:c.name})},c.id))})]})})}const I=G(L),j=352,te="mb-4 inline-flex items-center gap-1 text-fg-secondary transition-colors hover:text-fg-default",T="flex items-center justify-center bg-muted/25 p-3",re="h-full w-full rounded-[12px] object-contain",M="mb-3 flex flex-wrap items-start justify-between gap-3 border-b border-border-subtle pb-3",S="space-y-1",ne=a=>a===1?"1 reference":`${a} references`,C=(a,n)=>typeof a=="object"&&a!==null&&"errors"in a&&Array.isArray(a.errors)&&typeof a.errors[0]?.message=="string"?a.errors[0].message:a instanceof Error&&a.message?a.message:n,ie=()=>e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(l,{width:"100%",height:j-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsx(l,{width:96,height:14,className:"rounded-full"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"}),e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(l,{width:140,height:18}),e.jsx(l,{width:220,height:14,className:"rounded-full"})]}),e.jsx(l,{width:84,height:14,className:"rounded-full"})]}),e.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:3},(a,n)=>e.jsx(l,{height:72,className:"rounded-[16px]"},n))})]})})]}),le=({id:a})=>{const n=z(),i=Q(),u=I.useNavigate(),d=H(),{data:o}=b({queryKey:x.images.detail(a),queryFn:async()=>{const s=await U(a);if(s.type==="error")throw s;return s.image}}),{data:m}=b({queryKey:x.images.notes(a),queryFn:async()=>{const s=await O(o.url);if(s.type==="error")throw s;return s.imageNotes}}),c=m.length,y=ne(c),h=c===0,f=v({mutationFn:async()=>{const s=await $(a);if(s.type==="error")throw s;if(!s.deleteImage)throw new Error("Failed to delete image");return s.deleteImage},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.images.listAll(),exact:!1}),i("Image deleted"),u({to:E,search:{page:1}})},onError:s=>{i(C(s,"Failed to delete image"))}}),N=v({mutationFn:async()=>{const s=await K("heroBanner",o.url);if(s.type==="error")throw s},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.ui.heroBanner(),exact:!0}),i("Hero banner updated")},onError:s=>{i(C(s,"Failed to update hero banner"))}}),k=async()=>{!h||f.isPending||await n("Delete this image? It is not referenced by any notes.")&&f.mutate()};return e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(V,{className:re,src:o.url,alt:`Image ${o.id}`})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:14,className:"text-fg-tertiary"}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),e.jsx(r,{as:"p",variant:"meta",tone:"tertiary",children:h?"Delete is available because no notes reference this image":"Remove this image from notes before deleting it"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{content:h?"Delete this image":"Cannot delete while referenced by notes",side:"bottom",children:e.jsxs(w,{variant:"soft-danger",size:"sm",className:"flex-1",disabled:!h,isLoading:f.isPending,onClick:k,children:[e.jsx(J,{size:16}),"Delete"]})}),e.jsxs(w,{variant:"primary",size:"sm",className:"flex-1",isLoading:N.isPending,onClick:()=>N.mutate(),children:[e.jsx(ee,{size:16}),"Set hero banner"]})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(r,{as:"h2",variant:"subheading",weight:"medium",tracking:"tight",children:"Referenced Notes"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"Notes currently using this image"})]}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),c>0?e.jsx("ul",{className:"flex flex-col",children:m.map(s=>e.jsx("li",{children:e.jsx(se,{...s})},s.id))}):e.jsxs("div",{className:"flex items-start gap-3 py-1",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-muted/25 text-fg-disabled",children:e.jsx(X,{size:18})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(r,{as:"p",variant:"body",weight:"medium",tone:"secondary",children:"No notes reference this image"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"This image can be deleted or reused in another note"})]})]})]})})]})},pe=()=>{const{id:a}=I.useParams();return e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:e.jsx("title",{children:"Image Detail | Ocean Brain"})}),e.jsxs(p,{to:E,search:{page:1},className:te,children:[e.jsx(q,{size:16}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:"Back to Images"})]}),e.jsx(r,{as:"h1",variant:"heading",weight:"bold",tracking:"tighter",className:"sr-only",children:"Image Detail"}),e.jsx(B,{fallback:e.jsx(ie,{}),errorTitle:"Failed to load image detail",errorDescription:"Retry loading the image preview and its referenced notes",resetKeys:[a],children:e.jsx(le,{id:a})})]})};export{pe as default};
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as D,T as r,t as F,L as p,N as _,ad as R,aZ as Z,aO as E,f as q,a0 as B,j as G,aY as L,y as O,k as z,a6 as b,q as x,a_ as H,ah as v,a$ as K,b0 as P,B as w,i as l,m as Q}from"./index-_FcT3AuV.js";import{a as U,d as $}from"./image.api-C6RG15TF.js";import{a as t}from"./graph-vendor-CUxe67Lr.js";import{I as V}from"./Image-DK0lnaK2.js";import{S as g}from"./SurfaceCard-C7ZAzggM.js";import{c as W,n as Y}from"./Trash.es-CerlaxH9.js";import{I as J}from"./Image.es-DWOPKZ3F.js";import"./note-core-DMZcZ4yV.js";const X=new Map([["bold",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,36c-20.09,0-37.92,7.93-50,21.56C115.92,43.93,98.09,36,78,36a66.08,66.08,0,0,0-66,66c0,72.34,105.81,130.14,110.31,132.57a12,12,0,0,0,11.38,0C138.19,232.14,244,174.34,244,102A66.08,66.08,0,0,0,178,36Zm-5.49,142.36A328.69,328.69,0,0,1,128,210.16a328.69,328.69,0,0,1-44.51-31.8C61.82,159.77,36,131.42,36,102A42,42,0,0,1,78,60c17.8,0,32.7,9.4,38.89,24.54a12,12,0,0,0,22.22,0C145.3,69.4,160.2,60,178,60a42,42,0,0,1,42,42C220,131.42,194.18,159.77,172.51,178.36Z"}))],["duotone",t.createElement(t.Fragment,null,t.createElement("path",{d:"M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z",opacity:"0.2"}),t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["fill",t.createElement(t.Fragment,null,t.createElement("path",{d:"M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0C119.79,228.66,16,172,16,102A62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z"}))],["light",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60c0,29.2,18.2,59.59,54.1,90.31a334.68,334.68,0,0,0,53.06,37,6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42ZM128,217.11C111.59,207.64,30,157.72,30,102A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48C226,157.72,144.41,207.64,128,217.11Z"}))],["regular",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,70,103.79,126.66,108.21,129a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40ZM128,214.8C109.74,204.16,32,155.69,32,102A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46C224,155.61,146.24,204.15,128,214.8Z"}))],["thin",t.createElement(t.Fragment,null,t.createElement("path",{d:"M178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58c0,28.59,18,58.47,53.4,88.79a333.81,333.81,0,0,0,52.7,36.73,4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44ZM128,219.42c-14-8-100-59.35-100-117.42A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50C228,160,142,211.46,128,219.42Z"}))]]),A=t.forwardRef((a,n)=>t.createElement(D,{ref:n,...a,weights:X}));A.displayName="HeartIcon";const ee=A;function ae({name:a}){return e.jsx(r,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",children:a})}function se({id:a,title:n,tags:i,createdAt:u,updatedAt:d}){const o=new Date(Number(u)),m=F(Number(d));return e.jsx("div",{className:"border-b-2 border-dashed border-border-subtle last:border-b-0",children:e.jsxs("div",{className:"py-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{variant:"label",weight:"medium",tone:"tertiary",children:m}),e.jsxs(r,{variant:"label",tone:"placeholder",children:["(",o.toDateString(),")"]})]}),e.jsx(r,{as:"div",variant:"body",weight:"bold",tracking:"tight",children:e.jsx(p,{className:"transition-colors hover:text-accent-primary",to:_,params:{id:a},children:n||"Untitled"})}),i&&i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(c=>e.jsx(p,{to:R,params:{id:c.id},search:{page:1},children:e.jsx(ae,{name:c.name})},c.id))})]})})}const I=G(L),j=352,te="mb-4 inline-flex items-center gap-1 text-fg-secondary transition-colors hover:text-fg-default",T="flex items-center justify-center bg-muted/25 p-3",re="h-full w-full rounded-[12px] object-contain",M="mb-3 flex flex-wrap items-start justify-between gap-3 border-b border-border-subtle pb-3",S="space-y-1",ne=a=>a===1?"1 reference":`${a} references`,C=(a,n)=>typeof a=="object"&&a!==null&&"errors"in a&&Array.isArray(a.errors)&&typeof a.errors[0]?.message=="string"?a.errors[0].message:a instanceof Error&&a.message?a.message:n,ie=()=>e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(l,{width:"100%",height:j-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsx(l,{width:96,height:14,className:"rounded-full"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"}),e.jsx(l,{height:32,className:"flex-1 rounded-[12px]"})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(l,{width:140,height:18}),e.jsx(l,{width:220,height:14,className:"rounded-full"})]}),e.jsx(l,{width:84,height:14,className:"rounded-full"})]}),e.jsx("div",{className:"flex flex-col gap-3",children:Array.from({length:3},(a,n)=>e.jsx(l,{height:72,className:"rounded-[16px]"},n))})]})})]}),le=({id:a})=>{const n=O(),i=Q(),u=I.useNavigate(),d=z(),{data:o}=b({queryKey:x.images.detail(a),queryFn:async()=>{const s=await U(a);if(s.type==="error")throw s;return s.image}}),{data:m}=b({queryKey:x.images.notes(a),queryFn:async()=>{const s=await H(o.url);if(s.type==="error")throw s;return s.imageNotes}}),c=m.length,y=ne(c),h=c===0,f=v({mutationFn:async()=>{const s=await $(a);if(s.type==="error")throw s;if(!s.deleteImage)throw new Error("Failed to delete image");return s.deleteImage},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.images.listAll(),exact:!1}),i("Image deleted"),u({to:E,search:{page:1}})},onError:s=>{i(C(s,"Failed to delete image"))}}),N=v({mutationFn:async()=>{const s=await K("heroBanner",o.url);if(s.type==="error")throw s},onSuccess:async()=>{await d.invalidateQueries({queryKey:x.ui.heroBanner(),exact:!0}),i("Hero banner updated")},onError:s=>{i(C(s,"Failed to update hero banner"))}}),k=async()=>{!h||f.isPending||await n("Delete this image? It is not referenced by any notes.")&&f.mutate()};return e.jsxs("div",{className:"flex flex-col gap-6 lg:flex-row",children:[e.jsx("div",{className:"w-full lg:w-[400px] lg:flex-shrink-0",children:e.jsxs(g,{flush:!0,children:[e.jsx("div",{className:T,style:{height:j},children:e.jsx(V,{className:re,src:o.url,alt:`Image ${o.id}`})}),e.jsxs("div",{className:"flex flex-col gap-4 border-t border-border-subtle p-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:14,className:"text-fg-tertiary"}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),e.jsx(r,{as:"p",variant:"meta",tone:"tertiary",children:h?"Delete is available because no notes reference this image":"Remove this image from notes before deleting it"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{content:h?"Delete this image":"Cannot delete while referenced by notes",side:"bottom",children:e.jsxs(w,{variant:"soft-danger",size:"sm",className:"flex-1",disabled:!h,isLoading:f.isPending,onClick:k,children:[e.jsx(Y,{size:16}),"Delete"]})}),e.jsxs(w,{variant:"primary",size:"sm",className:"flex-1",isLoading:N.isPending,onClick:()=>N.mutate(),children:[e.jsx(ee,{size:16}),"Set hero banner"]})]})]})]})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs(g,{children:[e.jsxs("div",{className:M,children:[e.jsxs("div",{className:S,children:[e.jsx(r,{as:"h2",variant:"subheading",weight:"medium",tracking:"tight",children:"Referenced Notes"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"Notes currently using this image"})]}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:y})]}),c>0?e.jsx("ul",{className:"flex flex-col",children:m.map(s=>e.jsx("li",{children:e.jsx(se,{...s})},s.id))}):e.jsxs("div",{className:"flex items-start gap-3 py-1",children:[e.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-[10px] bg-muted/25 text-fg-disabled",children:e.jsx(J,{size:18})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(r,{as:"p",variant:"body",weight:"medium",tone:"secondary",children:"No notes reference this image"}),e.jsx(r,{as:"p",variant:"meta",tone:"secondary",children:"This image can be deleted or reused in another note"})]})]})]})})]})},pe=()=>{const{id:a}=I.useParams();return e.jsxs(e.Fragment,{children:[e.jsx(Z,{children:e.jsx("title",{children:"Image Detail | Ocean Brain"})}),e.jsxs(p,{to:E,search:{page:1},className:te,children:[e.jsx(q,{size:16}),e.jsx(r,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:"Back to Images"})]}),e.jsx(r,{as:"h1",variant:"heading",weight:"bold",tracking:"tighter",className:"sr-only",children:"Image Detail"}),e.jsx(B,{fallback:e.jsx(ie,{}),errorTitle:"Failed to load image detail",errorDescription:"Retry loading the image preview and its referenced notes",resetKeys:[a],children:e.jsx(le,{id:a})})]})};export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{a6 as L,q as T,y as G,k as S,ah as C,a0 as F,P as N,J as k,L as q,
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{a6 as L,q as T,y as G,k as S,ah as C,a0 as F,P as N,J as k,L as q,aY as B,T as O,B as D,a1 as z,i as h,j as K,aO as Q}from"./index-_FcT3AuV.js";import{f as U,d as W}from"./image.api-C6RG15TF.js";import{a as x}from"./graph-vendor-CUxe67Lr.js";import{I as H}from"./Image-DK0lnaK2.js";import{S as M}from"./SurfaceCard-C7ZAzggM.js";import{c as $,n as J}from"./Trash.es-CerlaxH9.js";import"./note-core-DMZcZ4yV.js";const V=n=>{const{data:a}=L({queryKey:T.images.list(n.searchParams),async queryFn(){const s=await U({offset:n.searchParams.offset,limit:n.searchParams.limit});if(s.type==="error")throw s;return s.allImages}});return n.render(a)},b=16;function X(n,a,s){return Math.max(Math.floor((Math.max(n,0)+s)/(a+s)),1)}function _(n,a,s){return n*a+(n-1)*s}function Y({minItemWidth:n,gap:a,rows:s,fallback:l,override:g}){const[i,w]=x.useState(null),[v,p]=x.useState(l??s),r=x.useRef(null),o=x.useCallback(t=>{w(t)},[]),d=g==null,y=d?v:g;return x.useLayoutEffect(()=>{if(!d){r.current=null;return}if(!i){r.current=null,p(c=>c===(l??s)?c:l??s);return}let t=null;const I=()=>{const c=i.offsetWidth,E=X(c,n,a),u=r.current;let j=E;if(u!==null&&u!==E)if(E>u){const f=_(u+1,n,a);c<f+b&&(j=u)}else{const f=_(u,n,a);c>f-b&&(j=u)}r.current=j;const A=Math.max(j*s,s);p(f=>f===A?f:A)},m=()=>{t===null&&(t=window.requestAnimationFrame(()=>{t=null,I()}))};if(m(),typeof ResizeObserver<"u"){const c=new ResizeObserver(()=>{m()});return c.observe(i),()=>{c.disconnect(),t!==null&&window.cancelAnimationFrame(t)}}return window.addEventListener("resize",m),window.addEventListener("orientationchange",m),()=>{window.removeEventListener("resize",m),window.removeEventListener("orientationchange",m),t!==null&&window.cancelAnimationFrame(t)}},[i,l,a,d,n,s]),{containerRef:o,limit:y,isAutoLimit:d}}const Z=240,ee=20,te=4,R=192,P=K(Q),de=()=>{const n=G(),a=S(),s=P.useNavigate(),{page:l}=P.useSearch(),{containerRef:g,limit:i}=Y({minItemWidth:Z,gap:ee,rows:te}),w=C({mutationFn:W,onSuccess:r=>{if(r.type==="error")throw r;a.invalidateQueries({queryKey:T.images.listAll(),exact:!1})}}),v=async r=>{await n("Delete this image? It is not referenced by any notes.")&&w.mutate(r)},p=r=>r===1?"1 reference":`${r} references`;return e.jsx("div",{ref:g,children:e.jsx(F,{fallback:e.jsx(N,{title:"Images",variant:"default",heading:e.jsx(h,{width:136,height:24,className:"rounded-full"}),description:e.jsx(h,{width:232,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"flex flex-col gap-4",children:e.jsx("div",{className:"grid-auto-cards grid gap-4",children:Array.from({length:3},(r,o)=>e.jsxs(M,{flush:!0,children:[e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(h,{width:"100%",height:R-24,className:"rounded-[12px]"})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsx(h,{width:92,height:14,className:"rounded-full"}),e.jsx(h,{width:32,height:32,className:"rounded-[12px]"})]})]},o))})})}),errorTitle:"Failed to load images",errorDescription:"Retry loading uploaded image metadata",resetKeys:[l,i],children:e.jsx(V,{searchParams:{offset:(l-1)*i,limit:i},render:({images:r,totalCount:o})=>{const d=o>0?`Images (${o})`:void 0,y="Review and manage the images you uploaded inside notes";return r.length===0?e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsx(k,{title:"There are no images",description:"Upload an image in any note and it will appear here"})}):e.jsx(N,{title:"Images",variant:"default",heading:d,description:y,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-4",children:r.map(t=>e.jsxs(M,{flush:!0,children:[e.jsx(q,{to:B,params:{id:t.id},className:"focus-ring-soft block overflow-hidden rounded-t-[18px] outline-none",children:e.jsx("div",{className:"flex items-center justify-center bg-muted/25 p-3",style:{height:R},children:e.jsx(H,{className:"h-full w-full rounded-[12px] object-contain transition-transform duration-200 hover:scale-[1.02]",src:t.url,alt:t.id})})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border-subtle px-3 py-2.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-fg-secondary",children:[e.jsx($,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(O,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:"truncate",children:p(t.referenceCount)})]}),e.jsx(D,{variant:"ghost",size:"icon-sm",disabled:t.referenceCount>0,onClick:()=>v(t.id),children:e.jsx(J,{className:"h-4 w-4"})})]})]},t.id))}),o&&i<o&&e.jsx(z,{page:l,last:Math.ceil(o/i),onChange:t=>{s({search:I=>({...I,page:t})})}})]})})}})})})};export{de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{aR as r,k as Q,u as B,ah as p,P as E,T as t,aS as G,B as M,n as w,w as J,I as K,o as O,r as T,m as U}from"./index-_FcT3AuV.js";import{a as h}from"./graph-vendor-CUxe67Lr.js";import{S as x}from"./SurfaceCard-C7ZAzggM.js";import"./note-core-DMZcZ4yV.js";const D=async()=>{const{data:s}=await r.get("/api/mcp-admin/status");return s},z=async s=>{const{data:n}=await r.post("/api/mcp-admin/enabled",{enabled:s});return n},V=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/rotate");return s},H=async()=>{const{data:s}=await r.post("/api/mcp-admin/token/revoke");return s},o=["mcp-admin","status"],W=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token-file","/path/to/token.txt"]}}},null,2),X=s=>JSON.stringify({mcpServers:{"ocean-brain":{command:"npx",args:["-y","ocean-brain","mcp","--server",s,"--token","your-token-here"]}}},null,2),se=()=>{const s=U(),n=Q(),[c,S]=h.useState(()=>window.location.origin),[v,g]=h.useState(""),[k,P]=h.useState("token-file"),{data:y,isLoading:A}=B({queryKey:o,queryFn:D}),b=p({mutationFn:z,onSuccess:a=>{n.setQueryData(o,a),s(a.enabled?"MCP access enabled.":"MCP access disabled.")}}),j=p({mutationFn:V,onSuccess:async({token:a})=>{g(a),s("A new MCP token has been issued."),await n.invalidateQueries({queryKey:o})}}),f=p({mutationFn:H,onSuccess:a=>{g(""),n.setQueryData(o,a),s("The active MCP token has been revoked.")}}),l=y?.enabled??!1,d=y?.hasActiveToken??!1,I=!A&&!b.isPending,i="space-y-1",N="space-y-4.5",F="inline-flex items-center gap-3 rounded-[14px] border border-border-subtle bg-muted px-3 py-2",L="rounded-full border border-border-subtle bg-hover-subtle px-2.5 py-1",R="space-y-3 rounded-[16px] border border-border-subtle bg-surface px-4 py-3",q="overflow-x-auto rounded-[14px] border border-border-subtle bg-surface px-4 py-3 text-xs text-fg-secondary",u={variant:"subheading",weight:"medium",tracking:"tight"},C="font-medium text-fg-tertiary",m=k==="token-file"?{title:"Token file",description:"Recommended. Keeps the token out of config.",snippet:W(c)}:{title:"Inline token",description:"Useful for quick local testing.",snippet:X(c)};return e.jsx(E,{title:"MCP",variant:"default",description:"Manage MCP access, tokens, and connection details",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"MCP Access"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Allow or block MCP requests at the server level."})]}),e.jsxs("div",{className:F,children:[e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:l?"Enabled":"Disabled"}),e.jsx(G,{"aria-label":"Allow MCP access",checked:l,disabled:!I,onCheckedChange:()=>{b.mutate(!l)}})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Token Management"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",className:"max-w-[64ch]",children:"Ocean Brain supports one active MCP token at a time. Rotating immediately invalidates the previous one."})]}),e.jsx(t,{as:"span",variant:"meta",weight:"medium",tone:d?"secondary":"tertiary",className:L,children:d?"1 active token":"No active token"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(M,{onClick:()=>j.mutate(void 0),isLoading:j.isPending,children:"Rotate token"}),e.jsx(M,{variant:"soft-danger",onClick:()=>f.mutate(),isLoading:f.isPending,disabled:!d,children:"Revoke token"})]}),v&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(w,{htmlFor:"issued-mcp-token",className:C,children:"Issued token"}),e.jsx(J,{id:"issued-mcp-token",rows:3,readOnly:!0,value:v})]})]})}),e.jsx(x,{tone:"elevated",children:e.jsxs("div",{className:N,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"h2",...u,children:"Connection Guide"}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:"Connect your MCP client with either a token file or an inline token."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"mcp-server-url",className:C,children:"Server URL"}),e.jsx(K,{id:"mcp-server-url",value:c,onChange:a=>S(a.target.value)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(O,{type:"single",variant:"pills",size:"sm",value:k,onValueChange:a=>{(a==="token-file"||a==="inline-token")&&P(a)},children:[e.jsx(T,{value:"token-file",children:"Token file"}),e.jsx(T,{value:"inline-token",children:"Inline token"})]}),e.jsxs("div",{className:R,children:[e.jsxs("div",{className:i,children:[e.jsx(t,{as:"p",variant:"meta",weight:"semibold",children:m.title}),e.jsx(t,{as:"p",variant:"meta",tone:"secondary",children:m.description})]}),e.jsx("pre",{className:q,children:m.snippet})]})]})]})})]})})};export{se as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as J,h as
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as J,h as P,k as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,am as te,b5 as j,b6 as N,B as C,a8 as se,M as m,n as b,I as w,x as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,m as oe}from"./index-_FcT3AuV.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-C7ZAzggM.js";import{n as de}from"./Plus.es-2XIq0eEW.js";import"./note-core-DMZcZ4yV.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),k=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));k.displayName="CaretUpIcon";const he=k,O=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(O),pe=`query FetchPlaceholders(
|
|
2
2
|
$searchFilter: SearchFilterInput,
|
|
3
3
|
$pagination: PaginationInput
|
|
4
4
|
) {
|
|
@@ -12,7 +12,7 @@ __PLACEHOLDER_FIELDS__ }
|
|
|
12
12
|
}
|
|
13
13
|
}`,xe=l=>{const c=l&&l.length>0?l.filter(r=>ue.has(r)):O;return Array.from(new Set(c)).map(r=>" "+r).join(`
|
|
14
14
|
`)+`
|
|
15
|
-
`},ge=async({limit:l=25,offset:c=0,query:h="",fields:r}={})=>{const g=xe(r),i=pe.replace("__PLACEHOLDER_FIELDS__",g);return
|
|
15
|
+
`},ge=async({limit:l=25,offset:c=0,query:h="",fields:r}={})=>{const g=xe(r),i=pe.replace("__PLACEHOLDER_FIELDS__",g);return P(i,{searchFilter:{query:h},pagination:{limit:l,offset:c}})},ye=l=>P(`mutation CreatePlaceholder(
|
|
16
16
|
$name: String!,
|
|
17
17
|
$template: String!,
|
|
18
18
|
$replacement: String!
|
|
@@ -29,6 +29,6 @@ __PLACEHOLDER_FIELDS__ }
|
|
|
29
29
|
createdAt
|
|
30
30
|
updatedAt
|
|
31
31
|
}
|
|
32
|
-
}`,l),fe=l=>
|
|
32
|
+
}`,l),fe=l=>P(`mutation DeletePlaceholder($id: ID!) {
|
|
33
33
|
deletePlaceholder(id: $id)
|
|
34
|
-
}`,{id:l}),I=ce(ie),
|
|
34
|
+
}`,{id:l}),I=ce(ie),Ee=()=>{const l=oe(),c=V(),h=I.useNavigate(),{page:r}=I.useSearch(),[g,i]=a.useState(!1),[y,H]=a.useState(!0),[n,u]=a.useState({name:"",template:"",replacement:""}),o=25,T=v.placeholders.list({limit:o,offset:(r-1)*o}),[E]=a.useState(W),{data:d,isLoading:p}=ee({queryKey:T,queryFn:async()=>{const t=await ge({offset:(r-1)*o,limit:o});if(t.type==="error")throw t;return t.allPlaceholders}}),F=M({mutationFn:ye,onSuccess:async()=>{l("Placeholder added successfully"),i(!1),u({name:"",template:"",replacement:""}),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),q=M({mutationFn:fe,onSuccess:async()=>{l("Placeholder deleted successfully"),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),B=E.length,x=d?.totalCount??0,Z=d?.placeholders??[],f="font-medium text-fg-tertiary",L="leading-[1.2]",A="break-all leading-[1.2]",S="leading-[1.2]",_="flex flex-col gap-px",R="space-y-px",Q="focus-ring-soft inline-flex items-center gap-2 rounded-[12px] border border-transparent px-2.5 py-1.5 text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",K="relative",U="absolute right-2 top-2",G="focus-ring-soft surface-base group flex flex-col items-center justify-center gap-0.5 px-4 py-4 text-center text-fg-secondary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",X="inline-flex h-[34px] w-[34px] items-center justify-center rounded-full border border-border-subtle bg-surface text-current transition-colors group-hover:border-border-secondary/70",z=x>0?`Placeholders (${x})`:void 0;return e.jsxs(ae,{title:"Placeholders",variant:"default",heading:p?e.jsx($,{width:244,height:24,className:"rounded-full"}):z,description:p?e.jsx($,{width:260,height:16,className:"rounded-full"}):"Create tokens that get replaced with values when you clone a note",children:[e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("section",{className:"space-y-3 border-b border-border-subtle/80 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"System placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Built-in tokens for date and time that are always available when cloning notes"})]}),e.jsxs("button",{type:"button",onClick:()=>H(!y),className:Q,children:[e.jsxs(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:[B," items"]}),y?e.jsx(he,{className:"h-4 w-4"}):e.jsx(te,{className:"h-4 w-4"})]})]}),y&&e.jsx("div",{className:"grid-auto-cards grid gap-5",children:E.map(t=>e.jsx(D,{children:e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:L,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Current value: ",t.replacement]})]})]})},t.name))})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"Custom placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Custom tokens you define once and reuse whenever you clone a note"})]}),!p&&e.jsx(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:x===1?"1 item":`${x} items`})]}),!p&&e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[Z.map(t=>e.jsxs(D,{className:K,children:[e.jsx(C,{variant:"ghost",size:"icon-sm",className:U,onClick:()=>q.mutate(t.id.toString()),children:e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:`min-w-0 pr-8 ${L}`,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Replaces with: ",t.replacement]})]})]})]},t.id)),e.jsxs("button",{type:"button",onClick:()=>i(!0),className:G,children:[e.jsx("span",{className:X,children:e.jsx(de,{className:"h-4.5 w-4.5"})}),e.jsx(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:"text-current",children:"New custom"})]})]})]})]}),e.jsxs(m,{isOpen:g,onClose:()=>i(!1),variant:"form",children:[e.jsx(m.Header,{title:"Add Placeholder",onClose:()=>i(!1)}),e.jsxs(m.Body,{children:[e.jsx(m.Description,{className:"mb-4",children:"Create a token that swaps in a value when you clone a note"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name",className:f,children:"Name"}),e.jsx(w,{id:"name",type:"text",value:n.name,onChange:t=>u({...n,name:t.target.value}),placeholder:"Description of this placeholder"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"A readable label so you can find this placeholder later"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"template",className:f,children:"Placeholder"}),e.jsx(w,{id:"template",type:"text",value:n.template,onChange:t=>u({...n,template:t.target.value}),placeholder:"note_app"}),e.jsxs(s,{as:"p",variant:"meta",tone:"secondary",children:["Use it in a note as ",j,"your_placeholder",N]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"replacement",className:f,children:"Replacement"}),e.jsx(w,{id:"replacement",type:"text",value:n.replacement,onChange:t=>u({...n,replacement:t.target.value}),placeholder:"Ocean Brain"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"This value is inserted when the placeholder is replaced during cloning"})]})]})]}),e.jsx(m.Footer,{children:e.jsxs(le,{children:[e.jsx(C,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),e.jsx(C,{variant:"primary",isLoading:F.isPending,onClick:()=>{if(!n.name||!n.template||!n.replacement){l("All fields are required");return}F.mutate({name:n.name,template:n.template,replacement:n.replacement})},children:"Add"})]})})]}),e.jsx(ne,{fallback:null,children:d?.totalCount&&o<d.totalCount&&e.jsx(re,{page:r,last:Math.ceil(d.totalCount/o),onChange:t=>{h({search:Y=>({...Y,page:t})})}})})]})};export{Ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{k as oe,u as de,H as ce,q as x,ah as M,b2 as ue,b3 as me,b4 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,x as q,m as ve,j as ye,aJ as ge}from"./index-BgnmVjeF.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[k,Q]=p.useState(""),[I,A]=p.useState(""),[y,H]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,$]=p.useState(null),[O,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{Q(""),A(""),H("text"),j([{label:"",value:""}])},ae=a=>{$(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{$(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:k,name:I||k,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:O||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),J=B.find(a=>!Ce(a)),U=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!U&&!Y&&!K&&!J,le=!!i&&O.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=U?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:J?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:k,onChange:a=>Q(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:I,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>H(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:O,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{k as oe,u as de,H as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,x as q,m as ve,j as ye,aI as ge}from"./index-_FcT3AuV.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[k,I]=p.useState(""),[Q,A]=p.useState(""),[y,H]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,$]=p.useState(null),[O,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),H("text"),j([{label:"",value:""}])},ae=a=>{$(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{$(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:k,name:Q||k,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:O||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&O.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:k,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>H(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:O,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-uuJO2MTD.js";import{a0 as M,j as Q,
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{a0 as M,j as Q,aw as F,k as L,y as _,a6 as I,aT as K,q as i,ah as E,aU as B,N as O,aV as W,P as N,J as H,T as d,ax as U,B as j,a1 as V,aW as Y,i as l,m as $,d as z,al as G,u as J,aX as X,M as y}from"./index-_FcT3AuV.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-C7ZAzggM.js";import"./note-core-DMZcZ4yV.js";const m=25,v=Q(F),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>z(a).format("YYYY-MM-DD HH:mm"),Z=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=J({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await X(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&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:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{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 deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(j,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(N,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{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 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=L(),c=$(),r=_(),[f,h]=k.useState(null),[x,b]=k.useState(null),{data:u}=I({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await K({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),w=E({mutationFn:B,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:O,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=E({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;b(null),p.mutate(t)},q=async t=>{const n=await G(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){b({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,A=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(N,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(H,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(N,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{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 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(U,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(j,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(j,{variant:"subtle",size:"sm",isLoading:w.isPending&&w.variables===t.id,onClick:()=>w.mutate(t.id),children:"Restore"}),e.jsx(j,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>q(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx(V,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(Z,{note:A,onClose:()=>h(null)}),e.jsx(Y,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>b(null),onConfirm:D})]})},oe=()=>{const{page:a}=v.useSearch();return e.jsx(M,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{oe as default};
|
package/server/client/dist/assets/{useReminderMutate--RlAj_Gg.js → useReminderMutate-C3GYwXa0.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as y}from"./note-vendor-uuJO2MTD.js";import{h as u,a6 as f,q as n,k as R,m as $}from"./index-
|
|
1
|
+
import{j as y}from"./note-vendor-uuJO2MTD.js";import{h as u,a6 as f,q as n,k as R,m as $}from"./index-_FcT3AuV.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
|
|
2
2
|
query FetchNoteReminders($noteId: ID!, $pagination: PaginationInput) {
|
|
3
3
|
noteReminders(noteId: $noteId, pagination: $pagination) {
|
|
4
4
|
totalCount
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<link rel="icon" type="image/png" href="/icon.png" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Ocean Brain</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-_FcT3AuV.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/graph-vendor-CUxe67Lr.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/note-core-DMZcZ4yV.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/note-vendor-uuJO2MTD.js">
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Biw4vuiN.css">
|
|
14
14
|
</head>
|
|
15
15
|
|
|
16
16
|
<body>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{j as e,i as qe,k as ra,U as dt,y as ut,v as na,X as sa,F as oa}from"./note-vendor-uuJO2MTD.js";import{af as la,p as Qe,T as h,c as q,M as H,x as fe,B as S,k as je,u as ye,ag as ia,q as T,ah as ca,ai as da,aj as ua,ak as pa,d as G,m as Ye,a6 as pt,al as fa,n as Me,I as $e,w as ma,o as ha,r as De,v as ft,D as mt,l as ht,g as xa,am as ga,a as ya,an as xt,ao as va,ap as gt,a4 as yt,N as be,ad as ba,z as wa,aq as ja,a5 as Na,ar as Ie,as as ve,a0 as Ue,P as We,a3 as Ze,at as Ca,au as ka,av as Aa,aw as Sa,ax as tt,ay as Ra,i as ie,L as Ke,j as Ta,az as Ea,aA as Ma,aB as at,H as Da,aC as Ha,S as rt,e as He,a8 as La,aD as Fa,aE as Va,aF as Pa,aG as Oa,aH as _a,aI as Ba,aJ as nt,aK as $a,aL as Ia}from"./index-BgnmVjeF.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{C as st,m as Ua}from"./Callout-BvXAlA5k.js";import{S as Za}from"./SurfaceCard-Brd1cMxi.js";import{u as Ka,R as za}from"./useReminderMutate--RlAj_Gg.js";import{n as ze}from"./Plus.es-I7xuoJ9B.js";import{u as qa}from"./image.api-BtadKO98.js";import{A as Qa,G as Ya,a3 as vt,a4 as Wa}from"./note-core-DMZcZ4yV.js";function Ga(t,r){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 n=!!(t.condition??!0),i=t.blockerFn;return{shouldBlockFn:async()=>n&&i!==void 0?await i():n,enableBeforeUnload:n,withResolver:i===void 0}}function Ja(t,r){const{shouldBlockFn:n,enableBeforeUnload:i=!0,disabled:s=!1,withResolver:d=!1}=Ga(t),o=la(),{history:p}=o,[c,g]=a.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return a.useEffect(()=>{const m=async C=>{function j(M){const u=o.parseLocation(M),y=o.getMatchedRoutes(u.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:u.pathname,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:u.pathname,params:y.routeParams,search:o.options.parseSearch(M.search)}}const x=j(C.currentLocation),A=j(C.nextLocation);if(x.routeId==="__notFound__"&&A.routeId!=="__notFound__")return!1;const k=await n({action:C.action,current:x,next:A});if(!d)return k;if(!k)return!1;const F=await new Promise(M=>{g({status:"blocked",current:x,next:A,action:C.action,proceed:()=>M(!1),reset:()=>M(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),F};return s?void 0:p.block({blockerFn:m,enableBeforeUnload:i})},[n,i,s,d,p,o]),c}const Xa=new Map([["bold",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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"}))]]),er=new Map([["bold",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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"}))]]),tr=new Map([["bold",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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"}),a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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",a.createElement(a.Fragment,null,a.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=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:Xa}));bt.displayName="CopyIcon";const ar=bt,wt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:er}));wt.displayName="FileIcon";const rr=wt,jt=a.forwardRef((t,r)=>a.createElement(Qe,{ref:r,...t,weights:tr}));jt.displayName="LinkSimpleIcon";const Nt=jt;function Ct({icon:t,title:r,className:n}){return e.jsxs("div",{className:q("flex items-center gap-2",n),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:r})]})}function Ge({title:t,icon:r,action:n,titleButtonProps:i,ariaLabel:s,className:d,children:o}){const p=o!=null&&o!==!1,c=n!=null&&n!==!1,g=e.jsx(Ct,{icon:r,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",p&&"mb-3"),children:[i?e.jsx("button",{...i,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",i.className),children:g}):g,c&&e.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:n})]}),o]})}function ue({title:t,description:r,selected:n=!1,onClick:i,children:s}){return e.jsxs("button",{type:"button","aria-pressed":n,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${n?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:i,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"div",variant:"body",weight:"semibold",tone:n?"default":"secondary",children:t}),e.jsx(h,{as:"div",variant:"meta",weight:"medium",tone:n?"secondary":"tertiary",className:"mt-1",children:r})]}),s?e.jsx("div",{className:"shrink-0",children:s}):null]})}const nr=[{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 sr({isOpen:t,onClose:r,onSave:n,currentLayout:i="wide"}){const[s,d]=a.useState(i);a.useEffect(()=>{t&&d(i)},[t,i]);const o=()=>{n(s),r()};return e.jsxs(H,{isOpen:t,onClose:r,variant:"compact",children:[e.jsx(H.Header,{title:"Layout Settings",onClose:r}),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:nr.map(p=>e.jsx(ue,{title:p.label,description:p.description,selected:s===p.value,onClick:()=>d(p.value)},p.value))})]})})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:o,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"},or=({isDeleted:t,isConflict:r,source:n})=>{const i=kt(n);return t?`This note was moved to trash ${i.place}`:r?`Save paused: note changed ${i.place}`:`This note changed ${i.place}`},lr=({isDeleted:t,isConflict:r,hasDraft:n,source:i})=>{const s=kt(i);return t?`${s.actor} moved this note to trash. Open trash to review or restore it.`:r&&n?`Your draft is saved locally. Reload the latest note, overwrite ${s.target}, or clone your draft into a new note.`:r?`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 ir({isOpen:t,isDeleted:r,isConflict:n,hasDraft:i,source:s,isReloading:d,onReload:o,onOverwrite:p,onCloneDraft:c,onOpenTrash:g}){return e.jsxs(H,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(H.Header,{title:or({isDeleted:r,isConflict:n,source:s})}),e.jsx(H.Body,{children:e.jsx(h,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:lr({isDeleted:r,isConflict:n,hasDraft:i,source:s})})}),e.jsx(H.Footer,{children:e.jsx(fe,{children:r?e.jsx(S,{type:"button",variant:"primary",size:"sm",onClick:g,children:"Open trash"}):n?e.jsxs(e.Fragment,{children:[e.jsx(S,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:o,children:"Reload latest"}),i&&e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(S,{type:"button",variant:"danger",size:"sm",onClick:p,children:"Overwrite"})]}):e.jsx(S,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:o,children:"Reload latest"})})})]})}const ot=(t,r)=>t||(r==="mobile"?"Mobile browser":r==="mcp"?"MCP":"Web browser");function cr({isOpen:t,noteId:r,onClose:n,onRestored:i}){const s=Ye(),d=je(),[o,p]=a.useState(null),[c,g]=a.useState("diff"),m=a.useRef(null),C=ye({queryKey:T.notes.snapshots(r),queryFn:async()=>{const u=await ia(r);if(u.type==="error")throw u;return u.noteSnapshots},enabled:t}),j=ca({mutationFn:da,onSuccess:async u=>{if(u.type==="error"){s(u.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:T.notes.detail(r),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(r),exact:!1}),d.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),s("Previous version restored."),i?.(u.restoreNoteSnapshot),p(null),n()}}),x=C.data?.find(u=>u.id===o)??null,A=ye({queryKey:[...T.notes.snapshotDetail(o??"pending"),"diff"],queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await ua(o,"current");if(u.type==="error")throw u;if(!u.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return u.noteSnapshotDiff},enabled:!!o&&c==="diff"}),k=ye({queryKey:T.notes.snapshotDetail(o??"pending"),queryFn:async()=>{if(!o)throw new Error("SNAPSHOT_NOT_SELECTED");const u=await pa(o);if(u.type==="error")throw u;if(!u.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return u.noteSnapshot},enabled:!!o&&c==="content"}),D=k.data?.contentAsMarkdown.trim()??"";a.useEffect(()=>{o&&m.current?.focus()},[o]);const F=(u,y)=>{g(y),p(u)},M=()=>{p(null),g("diff"),n()};return e.jsxs(H,{isOpen:t,onClose:M,variant:"inspect",children:[e.jsx(H.Header,{title:x?c==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:M}),e.jsx(H.Description,{className:"sr-only",children:x?c==="diff"?"Review the markdown diff between this snapshot and the current note.":"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(H.Body,{children:x?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:x.title}),e.jsxs(h,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",ot(x.meta.label,x.meta.entrypoint)," ","edit - ",G(x.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{variant:c==="diff"?"primary":"subtle",size:"sm",onClick:()=>g("diff"),children:"Show diff"}),e.jsx(S,{variant:c==="content"?"primary":"subtle",size:"sm",onClick:()=>g("content"),children:"View content"})]}),c==="diff"?A.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 diff..."}):A.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 diff could not be loaded."}):A.data?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(h,{as:"p",variant:"meta",tone:"secondary",children:"Changes from this snapshot to the current note. Red lines were in the snapshot; green lines are in the current note."}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-0 py-3 text-xs leading-5 text-fg-secondary",children:A.data.diff.markdown.split(`
|
|
2
|
-
`).map((u,y)=>{const v=u.startsWith("+")&&!u.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":u.startsWith("-")&&!u.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":u.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return e.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${v}`,children:u||" "},`${y}-${u}`)})})]}):null:k.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..."}):k.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."}):D?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:D}):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."}),C.isLoading&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!C.isLoading&&C.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."}),!C.isLoading&&C.data&&C.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:C.data.map(u=>e.jsx(Za,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3",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(u.meta.label,u.meta.entrypoint)," ","edit"]}),e.jsx(h,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:u.title}),e.jsx(h,{as:"p",variant:"label",tone:"tertiary",children:G(u.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(S,{variant:"subtle",size:"sm",onClick:()=>F(u.id,"diff"),children:"Compare"}),e.jsx(S,{size:"sm",isLoading:j.isPending,onClick:()=>j.mutate(u.id),children:"Restore"})]})]}),u.contentPreview&&e.jsx("div",{className:"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:u.contentPreview})})]})},u.id))})]})}),x&&e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{ref:m,variant:"subtle",onClick:()=>{p(null),g("diff")},children:"Back"}),e.jsx(S,{isLoading:j.isPending,onClick:()=>j.mutate(x.id),children:"Restore this version"})]})})]})}const dr=t=>{const{data:r}=pt({queryKey:T.notes.backReferences(t.noteId),async queryFn(){const n=await fa(t.noteId);if(n.type==="error")throw n;return n.backReferences}});return t.render(r)};let ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pr=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)r+=ur[n[t]&63];return r};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 fr({isOpen:t,onClose:r,onSave:n,reminder:i,mode:s}){const[d,o]=a.useState(new Date),[p,c]=a.useState("medium"),[g,m]=a.useState("");a.useEffect(()=>{t&&s==="edit"&&i?(o(new Date(Number(i.reminderDate))),c(i.priority||"medium"),m(i.content||"")):t&&s==="create"&&(o(new Date),c("medium"),m(""))},[t,s,i]);const C=()=>{n(d,p,g||void 0),r()},j=x=>p===x?lt[x].active:lt[x].inactive;return e.jsxs(H,{isOpen:t,onClose:r,variant:"form",children:[e.jsx(H.Header,{title:s==="create"?"Create Reminder":"Edit Reminder",onClose:r}),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(Me,{children:"Date & Time"}),e.jsx($e,{type:"datetime-local",size:"sm",value:G(d).format("YYYY-MM-DDTHH:mm"),onChange:x=>o(new Date(x.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Content"}),e.jsx(ma,{size:"sm",placeholder:"Enter reminder content (optional)",value:g,onChange:x=>m(x.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Me,{children:"Priority"}),e.jsxs(ha,{type:"single",variant:"quiet",value:p,onValueChange:x=>x&&c(x),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(De,{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(De,{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(De,{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(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:C,children:s==="create"?"Create":"Save"})]})})]})}function mr({noteId:t}){const[r,n]=a.useState(!1),[i,s]=a.useState(!1),[d,o]=a.useState("create"),[p,c]=a.useState(void 0),{onCreate:g,onUpdate:m,onDelete:C}=Ka(),j=()=>{o("create"),c(void 0),s(!0)},x=u=>{o("edit"),c(u),s(!0)},A=(u,y,v)=>{d==="create"?g(t,u,y,()=>{s(!1)},v):d==="edit"&&p&&m(p.id,t,{reminderDate:u,priority:y,content:v},()=>{s(!1)})},k=u=>{m(u.id,t,{completed:!u.completed})},D=u=>{const y=G(Number(u)),v=G();return y.isSame(v,"day")?`Today at ${y.format("HH:mm")}`:y.isSame(v.add(1,"day"),"day")?`Tomorrow at ${y.format("HH:mm")}`:y.format("YYYY-MM-DD HH:mm")},F=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour");return P<=6?"high":P<=24?"medium":"low"},M=u=>{const y=G(Number(u)),v=G(),P=y.diff(v,"hour"),B=y.diff(v,"minute")%60;return P<0||B<0?"Overdue":P===0?`${B}m remaining`:`${P}h ${B}m remaining`};return e.jsxs(e.Fragment,{children:[e.jsx(Ge,{title:"Reminders",icon:e.jsx(ya,{className:"h-3.5 w-3.5"}),action:e.jsxs(e.Fragment,{children:[!r&&e.jsxs(S,{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(S,{type:"button",size:"sm",variant:"ghost","aria-label":r?"Expand reminders":"Collapse reminders","aria-expanded":!r,onClick:()=>n(!r),children:[r?e.jsx(xa,{className:"h-3.5 w-3.5"}):e.jsx(ga,{className:"h-3.5 w-3.5"}),r?"Expand":"Collapse"]})]}),children:!r&&e.jsx(za,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:u,totalCount:y})=>e.jsx("div",{className:"flex flex-col gap-2",children:u.length===0?e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:y===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:u.map(v=>{const P=v.priority||F(v.reminderDate),B=M(v.reminderDate),L=B==="Overdue";return e.jsxs("div",{className:q("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(ft,{checked:v.completed,onChange:()=>k(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||D(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:D(v.reminderDate)}),!v.completed&&e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:L||P==="high"?"error":"tertiary",className:q(v.content&&'before:content-["·"] before:mr-1'),children:B})]}),e.jsx(mt,{button:e.jsx(ht,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>x(v)},{name:"Delete",onClick:()=>C(v.id,t)}]})]},v.id)})})})})}),e.jsx(fr,{isOpen:i,onClose:()=>s(!1),onSave:A,reminder:p,mode:d})]})}const hr=({editor:t})=>e.jsx(qe,{triggerCharacter:"/",getItems:async r=>Qa([...ra(t).filter(n=>n.title!=="Audio"&&n.title!=="Video"&&n.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,{})}],r)}),xr=(t,r)=>r?t.filter(n=>n.id!==r):t,gr=({currentNoteId:t,onClick:r})=>e.jsx(qe,{triggerCharacter:"[",getItems:async n=>{const i=await va({query:n,limit:5});return i.type==="error"?[]:xr(i.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>r({type:"reference",props:{id:d.id,title:d.title}})}))}}),yr="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",vr={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"},br={idle:"Copy",copied:"Copied",failed:"Copy failed"},wr=({getText:t,resetDelayMs:r=2e3})=>{const[n,i]=a.useState("idle"),s=a.useRef(null),d=a.useCallback(()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),o=a.useCallback(()=>{d(),s.current=setTimeout(()=>{i("idle"),s.current=null},r)},[d,r]);a.useEffect(()=>d,[d]);const p=m=>{m.stopPropagation()},c=m=>{m.preventDefault(),m.stopPropagation()},g=async m=>{p(m);try{await navigator.clipboard.writeText(t()),i("copied")}catch{i("failed")}o()};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(yr,vr[n]),contentEditable:!1,onClick:g,children:[e.jsx(ar,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:br[n]})]})})},jr=({contentRef:t})=>{const r=a.useRef(null),n=a.useCallback(i=>{r.current=i,t(i)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:n})}),e.jsx(wr,{getText:()=>r.current?.textContent?.trimEnd()??""})]})},Nr="_Reference_102im_1",Cr={Reference:Nr},kr=gt.bind(Cr),Ar={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function Sr(t){const r=yt(),n=()=>{t.editor.blur(),r({to:be,params:{id:t.inlineContent.props.id}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:kr("Reference"),onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const Rr=dt(Ar,{render:t=>e.jsx(Sr,{...t})}),Tr=()=>{const t=na(),[r,n]=a.useState([]),i={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};a.useEffect(()=>{const o=()=>{const c=t.document,g=[],m=C=>{for(const j of C){if(j.type==="heading"){const x=j,A=x.props.level||1,k=x.content?.map(D=>D.text||"").join("")||"";k.trim()&&g.push({id:j.id,level:A,text:k})}j.children&&Array.isArray(j.children)&&m(j.children)}};m(c),n(g)};o();const p=t.onChange?.(o);return()=>{p&&p()}},[t]);const s=o=>{t.setTextCursorPosition(o);const p=document.querySelector(`[data-id="${o}"]`);p&&p.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 r.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:r.map(o=>{const p=o.level===1;return e.jsxs("button",{type:"button",onClick:()=>s(o.id),className:q("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",i[o.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",p?"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",o.level]}),e.jsx(h,{as:"span",variant:"body",weight:p?"semibold":"medium",className:"line-clamp-2 text-current",children:o.text})]},o.id)})})]})},Er=ut({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(Tr,{})})(),Mr="_Tag_1gb8h_1",Dr={Tag:Mr},Hr=gt.bind(Dr),Lr={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function Fr(t){const r=yt(),n=()=>{t.editor.blur(),r({to:ba,params:{id:t.inlineContent.props.id},search:{page:1}})},i=s=>{s.preventDefault(),s.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Hr("Tag"),onMouseDown:i,onClick:s=>{i(s),n()},onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(i(s),n())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const Vr=dt(Lr,{render:t=>e.jsx(Fr,{...t})}),Pr=t=>t,Or=t=>t,_r=Pr({tag:Vr,reference:Rr}),Br=Or({tableOfContents:Er}),se=vt.codeBlock,it=ut(se.config,{meta:se.implementation.meta,parse:se.implementation.parse,parseContent:se.implementation.parseContent,runsBefore:se.implementation.runsBefore,render:jr})(),$r={...it,extensions:se.extensions,implementation:{...it.implementation,toExternalHTML:se.implementation.toExternalHTML}},Ir=Ya.create({inlineContentSpecs:{...Wa,..._r},blockSpecs:{...vt,codeBlock:$r,...Br}}),Ur=(t,r)=>r.some(n=>n.name===`@${t}`),Zr=({onClick:t})=>e.jsx(qe,{triggerCharacter:"@",getItems:async r=>{const n=await wa({query:r,limit:5});if(n.type==="error")return[];const{tags:i}=n.allTags,s=Ur(r,i),d=[{title:"Add a new tag",onItemClick:async()=>{const o=await ja({name:"@"+r});if(o.type==="error")return;const{id:p,name:c}=o.createTag;t({type:"tag",props:{id:p,tag:c}})}}];return i.length===0?d:i.map(o=>({title:o.name,onItemClick:()=>t({type:"tag",props:{id:o.id,tag:o.name}})})).concat(r&&!s?d:[])}}),Kr=new Set(["tableOfContents"]),zr="OCEAN_BRAIN_TAG_",qr="_TOKEN",Qr=t=>`${zr}${t}${qr}`,Yr=t=>!Array.isArray(t)&&t?.type==="tableContent",Wr=(t,r)=>Array.isArray(t)?t.map(r):Yr(t)?{...t,rows:t.rows?.map(n=>({...n,cells:n.cells?.map(i=>({...i,content:i.content?.map(r)}))}))}:t,At=(t,r)=>t.filter(n=>!Kr.has(n.type)).map(n=>({...n,content:r(n.content),children:n.children?.length?At(n.children,r):[]}));function Gr(t){const r=new Map;let n=0;return{blocks:At(t,s=>Wr(s,d=>{if(d.type==="reference"){const o=String(d.props?.id||""),p=String(d.props?.title||d.props?.id||"");return{type:"text",text:o?`[[${p}]](note:${o})`:`[[${p}]]`,styles:{}}}if(d.type==="tag"){const o=d.props?.tag||"",p=Qr(n);return n+=1,r.set(p,o),{type:"text",text:p,styles:{}}}return d})),placeholderToTag:r}}function Jr(t,r){let n=t;for(const[i,s]of r.entries())n=n.split(i).join(`[${s}]`);return n}async function Xr(t){return new Promise((r,n)=>{const i=new FileReader;i.readAsDataURL(t),i.onload=()=>r(i.result),i.onerror=s=>n(s)})}const en=a.forwardRef(({content:t,currentNoteId:r,editable:n,onChange:i},s)=>{const{theme:d}=Na(p=>p),o=sa({schema:Ir,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async p=>qa({base64:await Xr(p)})},[]);return a.useImperativeHandle(s,()=>({getContent:()=>JSON.stringify(o.document),getMarkdown:()=>{const p=Gr(o.document),c=o.blocksToMarkdownLossy(p.blocks);return Jr(c,p.placeholderToTag)},getHtml:()=>o.blocksToHTMLLossy(o.document)})),e.jsxs(oa,{slashMenu:!1,theme:d,editor:o,editable:n,onChange:i,children:[e.jsx(hr,{editor:o}),e.jsx(gr,{currentNoteId:r,onClick:p=>{o.insertInlineContent([p," "])}}),e.jsx(Zr,{onClick:p=>{o.insertInlineContent([p," "])}})]})}),Je=t=>`ocean-brain.note-draft.${t}`,tn=t=>{if(typeof window>"u")return null;try{const r=window.localStorage.getItem(Je(t));if(!r)return null;const n=JSON.parse(r);return typeof n.title!="string"||typeof n.content!="string"||typeof n.baseUpdatedAt!="string"?null:{title:n.title,content:n.content,baseUpdatedAt:n.baseUpdatedAt,createdAt:typeof n.createdAt=="number"?n.createdAt:Date.now(),...n.layout==="narrow"||n.layout==="wide"||n.layout==="full"?{layout:n.layout}:{}}}catch{return null}},Le=(t,r)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(t),JSON.stringify(r))}catch{}},Fe=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(t))}catch{}},an=1e3,rn="NOTE_UPDATE_CONFLICT";function nn({noteId:t,initialContent:r,initialUpdatedAt:n,editSessionIdRef:i,getContent:s,onSaved:d,onConflict:o,onError:p}){const c=je(),g=a.useRef(null),m=a.useRef(null),C=a.useRef(!1),j=a.useRef(null),x=a.useRef(!1),A=a.useRef(n),k=a.useRef(!1),D=a.useRef(!0),F=a.useRef(d),M=a.useRef(o),u=a.useRef(p),[y,v]=a.useState("saved"),[P,B]=a.useState(null),L=a.useCallback(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),O=a.useCallback(R=>{D.current&&v(R)},[]),J=a.useCallback(R=>{A.current=R},[]),Y=a.useCallback((R,_={})=>({title:R,content:s()??r,createdAt:Date.now(),baseUpdatedAt:A.current,..._.layout?{layout:_.layout}:{}}),[s,r]),re=a.useCallback(()=>{m.current&&Le(t,m.current)},[t]),W=a.useCallback(R=>{k.current=!0,O("conflict"),M.current(R??A.current)},[O]),Q=a.useCallback(async({ignoreConflict:R=!1,silent:_=!1}={})=>{if(C.current)return x.current=!0,j.current??"idle";const $=m.current;if(!$)return x.current=!1,"idle";m.current=null,x.current=!1,L(),C.current=!0,_||O("saving");const U=(async()=>{let Z;try{Z=await Ie({id:t,title:$.title,content:$.content,...$.layout?{layout:$.layout}:{},editSessionId:i.current,...R?{force:!0}:{expectedUpdatedAt:$.baseUpdatedAt}})}catch{Z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(C.current=!1,j.current=null,Z.type==="error"){m.current||(m.current=$),re();const X=Z.errors[0];if(X.code===rn&&!R){const N=X.details?.extensions?.currentUpdatedAt;return k.current=!0,!_&&D.current&&(O("conflict"),M.current(N??A.current)),"conflict"}return!_&&D.current&&(O("error"),u.current(X.message)),"error"}k.current=!1,A.current=Z.updateNote.updatedAt;const K=!_&&D.current,ne=T.notes.detail(t);await c.cancelQueries({queryKey:ne,exact:!0}),K&&F.current(Z.updateNote.updatedAt),c.setQueryData(ne,X=>X&&{...X,title:Z.updateNote.title,content:$.content,...$.layout?{layout:$.layout}:{},updatedAt:Z.updateNote.updatedAt}),ve({noteId:t,updatedAt:Z.updateNote.updatedAt,editSessionId:i.current});const I=m.current;return I?.baseUpdatedAt===$.baseUpdatedAt?(m.current={...I,baseUpdatedAt:Z.updateNote.updatedAt},re()):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||x.current?Q({silent:_}):"saved"})();return j.current=U,U},[L,i,t,re,c,O]),f=a.useCallback((R,_={})=>{if(m.current=R,Le(t,R),k.current){O("conflict");return}if(O("pending"),L(),_.immediate){Q();return}g.current=window.setTimeout(()=>{Q()},an)},[L,Q,t,O]),E=a.useCallback(R=>{if(m.current=R,Le(t,R),B(null),R.baseUpdatedAt!==A.current){W(A.current);return}f(R)},[t,f,W]),w=a.useCallback(()=>{L(),m.current=null,j.current=null,x.current=!1,k.current=!1,Fe(t),B(null),v("saved")},[L,t]),V=a.useCallback(()=>{L(),j.current=null,x.current=!1,k.current=!1,O(m.current?"pending":"saved")},[L,O]),Ne=a.useCallback(()=>{Fe(t),B(null)},[t]),oe=a.useCallback(()=>m.current,[]),Ce=a.useCallback(R=>{L(),W(R)},[L,W]);return a.useEffect(()=>{M.current=o,u.current=p,F.current=d},[o,p,d]),a.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),a.useEffect(()=>{m.current||C.current||k.current||(A.current=n,v("saved"))},[n]),a.useEffect(()=>{m.current=null,C.current=!1,j.current=null,x.current=!1,k.current=!1,A.current=n,B(tn(t)),v("saved")},[t]),a.useEffect(()=>{const R=_=>{!m.current&&!C.current&&!k.current||(_.preventDefault(),_.returnValue="")};return window.addEventListener("beforeunload",R),()=>{window.removeEventListener("beforeunload",R)}},[]),a.useEffect(()=>()=>{L(),m.current&&!k.current&&Q({silent:!0})},[L,Q]),{saveStatus:y,localDraft:P,serverUpdatedAtRef:A,hasUnsavedChanges:y!=="saved",buildDraft:Y,queueSave:f,flushPendingSave:Q,restoreLocalDraft:E,discardLocalDraft:Ne,clearDrafts:w,resolveConflict:V,pauseForConflict:Ce,getPendingDraft:oe,setServerUpdatedAt:J}}const sn=/[:{}[\],&*#?|<>=!%@`-]/,on=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",ln=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ge=t=>t?sn.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',we=t=>{if(!t)return;const r=Number(t);return Number.isFinite(r)?new Date(r).toISOString():t},Ve=(t,r)=>`${on(t)}.${r}`,cn=({id:t,title:r,createdAt:n,updatedAt:i})=>{const s=["---",`title: ${ge(r)}`,`note_id: ${ge(t)}`],d=we(n),o=we(i);return d&&s.push(`created_at: ${ge(d)}`),o&&s.push(`updated_at: ${ge(o)}`),s.push("source: ocean-brain","---"),s.join(`
|
|
3
|
-
`)},dn=(t,r,n=!1)=>n?`${cn(r)}
|
|
4
|
-
|
|
5
|
-
${t}`:t,un=(t,r,{includeMetadata:n=!1,mode:i="fragment"}={})=>{const s=n?`<!--
|
|
6
|
-
source: ocean-brain
|
|
7
|
-
note_id: ${r.id}
|
|
8
|
-
title: ${r.title}
|
|
9
|
-
created_at: ${we(r.createdAt)??""}
|
|
10
|
-
updated_at: ${we(r.updatedAt)??""}
|
|
11
|
-
-->
|
|
12
|
-
`:"";return i==="fragment"?`${s}${t}`:`<!doctype html>
|
|
13
|
-
<html lang="ko">
|
|
14
|
-
<head>
|
|
15
|
-
<meta charset="utf-8" />
|
|
16
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
17
|
-
<title>${ln(r.title)}</title>
|
|
18
|
-
</head>
|
|
19
|
-
<body>
|
|
20
|
-
${s}${t}
|
|
21
|
-
</body>
|
|
22
|
-
</html>`},Pe=(t,r,n)=>{const i=new Blob([t],{type:n}),s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=r,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(s)},St=Ta(be),pe=t=>{const r=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(r)?r:null},Oe=t=>{const r=pe(t);return G(r??Number(t)).format("YYYY-MM-DD HH:mm:ss")},pn=(t,r)=>Ea(pe(t),r),_e=()=>pr(),fn="NOTE_UPDATE_CONFLICT",mn=2200,hn=t=>t?.extensions?.currentUpdatedAt,ct=(t,r)=>{const n=pe(t),i=pe(r);return n===null||i===null?t===r?0:1:n-i},xn=t=>{const r=t.trim();if(!r)return null;try{const n=new URL(r);return n.protocol==="http:"||n.protocol==="https:"?n.toString():null}catch{return null}},gn={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},yn=e.jsx(We,{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"})]})}),vn=t=>({id:t?.key??"",key:t?.key??"",name:t?.name??"",value:t?.value??"",valueType:t?.valueType??"text",persistedKey:t?.key}),bn=t=>{if(Array.isArray(t))return t;const r=t?.keys;return Array.isArray(r)?r:[]},Be=(t=[])=>t.map(vn),Rt=(t,r)=>{const n=[],i=new Set(r);for(const s of t){const d=s.key.trim();if(!d)continue;const o=s.value.trim(),p=!!s.persistedKey&&(s.valueType==="number"||s.valueType==="date"||s.valueType==="select"||s.valueType==="url");if(!o&&p){i.add(s.persistedKey);continue}!o&&s.valueType!=="text"&&s.valueType!=="boolean"||n.push({key:d,name:s.name.trim()||d,value:s.valueType==="boolean"?o||"false":o,valueType:s.valueType})}return{set:n.sort((s,d)=>s.key.localeCompare(d.key)),deleteKeys:Array.from(i).sort()}},le=(t,r=[])=>JSON.stringify(Rt(t,r)),wn=({noteId:t,properties:r=[],expectedUpdatedAt:n,editSessionId:i,disabled:s,onSaved:d})=>{const o=Ye(),p=je(),[c,g]=a.useState(()=>Be(r)),[m,C]=a.useState([]),[j,x]=a.useState("idle"),A=a.useRef(c),k=a.useRef(m),D=a.useRef(n),F=a.useRef(le(c)),M=a.useRef(null),u=a.useRef(!1),y=a.useRef(!1),v=ye({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const f=await Da({limit:50});if(f.type==="error")throw f;return f.notePropertyKeys.keys}});a.useEffect(()=>{const f=Be(r);g(f),C([]),F.current=le(f),x("idle")},[r]),a.useEffect(()=>{A.current=c},[c]),a.useEffect(()=>{k.current=m},[m]),a.useEffect(()=>{D.current=n},[n]);const P=bn(v.data),B=P.filter(f=>!c.some(E=>E.key===f.key)),L=P.length>0,O=a.useCallback(async()=>{const f=le(A.current,k.current);if(s||f===F.current)return;if(u.current){y.current=!0;return}const E=Rt(A.current,k.current);if(!(E.set.length===0&&E.deleteKeys.length===0)){u.current=!0,y.current=!1,x("saving");try{const w=await Ha({id:t,set:E.set,deleteKeys:E.deleteKeys,editSessionId:i,expectedUpdatedAt:D.current});if(w.type==="error"){x("error"),o(w.errors[0]?.message??"Failed to save properties.");return}D.current=w.updateNoteProperties.updatedAt,F.current=le(Be(w.updateNoteProperties.properties??[])),d(w.updateNoteProperties),p.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),x("saved")}catch{x("error"),o("Failed to save properties.")}finally{u.current=!1,y.current&&(y.current=!1,O())}}},[s,i,t,d,p,o]);a.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=f=>{g(E=>[...E,{id:f.key,key:f.key,name:f.name,value:"",valueType:f.valueType,persistedKey:void 0}]),C(E=>E.filter(w=>w!==f.key))},Y=(f,E)=>{g(w=>w.map(V=>V.id===f?{...V,...E}:V))},re=f=>{f.persistedKey&&C(E=>[...new Set([...E,f.persistedKey])]),g(E=>E.filter(w=>w.id!==f.id))},W=le(c,m)!==F.current,Q=s||!W&&j==="idle"?null:j==="saving"?"Saving...":j==="error"?"Save failed":W?"Waiting...":"Saved";return e.jsxs(Ge,{title:"Properties",icon:e.jsx(Ia,{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}),L&&e.jsx(S,{asChild:!0,size:"sm",variant:"ghost",children:e.jsxs(Ke,{to:nt,search:{page:1},children:[e.jsx($a,{className:"h-3 w-3"}),"Manage"]})})]}),children:[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(f=>{const E=f.valueType==="url"?xn(f.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:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:f.key})]}),f.valueType==="boolean"?e.jsxs(rt,{size:"sm",variant:"ghost",value:f.value||"false",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:[e.jsx(He,{value:"false",children:"False"}),e.jsx(He,{value:"true",children:"True"})]}):f.valueType==="select"?e.jsx(rt,{size:"sm",variant:"ghost",value:f.value,placeholder:"Select option",disabled:s,onValueChange:w=>Y(f.id,{value:w}),children:(P.find(w=>w.key===f.key)?.options??[]).map(w=>e.jsx(He,{value:w.value,children:w.label},w.id))}):f.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:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),E?e.jsx(S,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${f.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:f.valueType==="date"?"date":f.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:f.value,disabled:s,onChange:w=>Y(f.id,{value:w.target.value})}),e.jsx(S,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${f.name}`,disabled:s,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>re(f),children:e.jsx(La,{className:"h-4 w-4"})})]},f.id)})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:v.isLoading?e.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):B.length>0?e.jsxs(Fa,{children:[e.jsx(Va,{asChild:!0,children:e.jsxs(S,{type:"button",size:"sm",variant:"ghost",disabled:s,children:[e.jsx(ze,{className:"h-4 w-4"}),"Add property"]})}),e.jsxs(Pa,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[e.jsx(Oa,{children:e.jsx(h,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),e.jsx(_a,{}),B.map(f=>e.jsxs(Ba,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>J(f),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:f.name}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:f.valueType})]}),e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:f.key})]},f.key))]})]}):L?e.jsx(h,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):e.jsxs(Ke,{to:nt,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 jn({id:t}){const r=Ye(),n=St.useNavigate(),i=je(),s=a.useRef(null),d=a.useRef(null),o=a.useRef(_e()),p=pt({queryKey:T.notes.detail(t),queryFn:async()=>{const l=await Ca(t);if(l.type==="error")throw l;return l.note},gcTime:0}),c=p.data,[g,m]=a.useState(c.title),[C,j]=a.useState(()=>Oe(c.updatedAt)),[x,A]=a.useState(c.updatedAt),[k,D]=a.useState(()=>Date.now()),[F,M]=a.useState(c.pinned),[u,y]=a.useState(c.layout||"wide"),[v,P]=a.useState(!1),[B,L]=a.useState(!1),[O,J]=a.useState(!1),[Y,re]=a.useState("markdown"),[W,Q]=a.useState(!1),[f,E]=a.useState("fragment"),[w,V]=a.useState(null),[Ne,oe]=a.useState(null),[Ce,R]=a.useState(0),[_,$]=a.useState(!1),U=a.useRef(c.updatedAt),Z=a.useRef(t),K=a.useRef(null),ne=a.useRef(!1),I=a.useCallback(l=>{j(Oe(l)),A(l),D(Date.now())},[]),X=nn({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:o,getContent:()=>s.current?.getContent(),onSaved:l=>{K.current=null,U.current=l,I(l),$(!0)},onConflict:l=>{V({type:"updated",updatedAt:l,source:"unknown"}),r("This note changed elsewhere. Choose how to resolve the draft.")},onError:r}),{saveStatus:N,localDraft:ee,serverUpdatedAtRef:te,hasUnsavedChanges:ce,buildDraft:me,queueSave:he,flushPendingSave:xe,restoreLocalDraft:Tt,discardLocalDraft:Et,clearDrafts:ke,resolveConflict:Mt,pauseForConflict:de,getPendingDraft:Ae,setServerUpdatedAt:ae}=X,Dt=a.useCallback(async()=>{if(ne.current)return ne.current=!1,!1;if(N==="conflict")return r("Resolve the note conflict before leaving."),!0;const l=await xe();return l==="error"?(r("Save failed. Stay on this note and try again."),!0):l==="conflict"},[xe,N,r]);Ja({disabled:N==="saved",enableBeforeUnload:!1,shouldBlockFn:Dt}),a.useEffect(()=>{if(ce){c.updatedAt!==te.current&&ct(c.updatedAt,te.current)>0&&de(c.updatedAt);return}const l=U.current;if(!(c.updatedAt!==l&&ct(c.updatedAt,l)<0)&&(M(c.pinned),y(c.layout||"wide"),ae(c.updatedAt),m(c.title),I(c.updatedAt),l!==c.updatedAt)){const b=s.current?.getContent();U.current=c.updatedAt,(b===void 0||b!==c.content)&&(oe(null),R(z=>z+1))}},[ce,c.layout,c.pinned,c.title,c.updatedAt,de,te,ae,I]),a.useEffect(()=>{Z.current!==t&&(Z.current=t,o.current=_e(),U.current=c.updatedAt,K.current=null,V(null),oe(null),R(l=>l+1),$(!1))},[t,c.updatedAt]),a.useEffect(()=>{if(N!=="saved")return;const l=window.setTimeout(()=>{D(Date.now())},ka(pe(x),k));return()=>window.clearTimeout(l)},[x,k,N]),a.useEffect(()=>{if(!_)return;const l=window.setTimeout(()=>{$(!1)},mn);return()=>window.clearTimeout(l)},[_]),a.useEffect(()=>{w?.type!=="updated"||N==="conflict"||w.updatedAt!==c.updatedAt||(U.current=c.updatedAt,ae(c.updatedAt),I(c.updatedAt),V(null))},[w,c.updatedAt,N,ae,I]),a.useEffect(()=>Aa(l=>{if(l.noteId===t&&!(l.source==="web"&&l.editSessionId===o.current)){if(l.type==="mcp.note.updated"||l.type==="web.note.updated"){if(l.updatedAt===c.updatedAt||l.updatedAt===te.current)return;if(ce){de(l.updatedAt),V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}V({type:"updated",updatedAt:l.updatedAt,source:l.source});return}l.type==="mcp.note.deleted"&&V({type:"deleted",source:l.source})}}),[ce,t,c.updatedAt,de,te]);const{onCreate:Ht,onDelete:Lt,onPinned:Ft,deleteWarningDialog:Vt}=Sa(),Pt=()=>{he(me(g))},Ot=l=>{m(l),he(me(l))},Xe=()=>{he(me(g),{immediate:!0})},_t=async l=>{if(ce){y(l),he(me(g,{layout:l}),{immediate:!0}),r("Layout will be saved with your draft.");return}const b=await Ie({id:t,layout:l,editSessionId:o.current,expectedUpdatedAt:te.current});if(b.type==="error"){b.errors[0].code===fn&&(K.current=l,y(l),de(hn(b.errors[0].details)??te.current)),r(b.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=b.updateNote.updatedAt,ae(b.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),z=>z&&{...z,layout:l,updatedAt:b.updateNote.updatedAt}),ve({noteId:t,updatedAt:b.updateNote.updatedAt,editSessionId:o.current}),I(b.updateNote.updatedAt),y(l),r("Layout has been updated.")},Bt=()=>({id:t,title:g,createdAt:c.createdAt,updatedAt:te.current||c.updatedAt}),$t=async()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(l),r("Copied note as Markdown.")}catch{r("Failed to copy Markdown.")}},It=()=>{const l=s.current?.getMarkdown();if(l===void 0){r("Markdown is not ready yet.");return}try{Pe(l,Ve(g,"md"),"text/markdown;charset=utf-8"),r("Downloaded note as Markdown.")}catch{r("Failed to download Markdown.")}},Ut=()=>{const l=Bt();try{if(Y==="markdown"){const b=s.current?.getMarkdown();if(b===void 0){r("Markdown is not ready yet.");return}Pe(dn(b,l,W),Ve(g,"md"),"text/markdown;charset=utf-8")}else{const b=s.current?.getHtml();if(b===void 0){r("HTML is not ready yet.");return}Pe(un(b,l,{includeMetadata:W,mode:f}),Ve(g,"html"),"text/html;charset=utf-8")}J(!1),r("Downloaded note.")}catch{r("Failed to download note.")}},Zt=async()=>{const l=await p.refetch();if(l.error||!l.data){r("Failed to reload the latest note state.");return}ke(),K.current=null,U.current=l.data.updatedAt,ae(l.data.updatedAt),m(l.data.title),y(l.data.layout||"wide"),I(l.data.updatedAt),oe(null),R(b=>b+1),V(null)},Kt=async()=>{if(Ae()){K.current=null,V(null),await xe({ignoreConflict:!0});return}const b=K.current;if(b){const z=await Ie({id:t,layout:b,editSessionId:o.current,force:!0});if(z.type==="error"){r(z.errors[0].message);return}K.current=null,await i.cancelQueries({queryKey:T.notes.detail(t),exact:!0}),U.current=z.updateNote.updatedAt,Mt(),V(null),ae(z.updateNote.updatedAt),i.setQueryData(T.notes.detail(t),Ee=>Ee&&{...Ee,layout:b,updatedAt:z.updateNote.updatedAt}),ve({noteId:t,updatedAt:z.updateNote.updatedAt,editSessionId:o.current}),I(z.updateNote.updatedAt),y(b);return}V(null),await xe({ignoreConflict:!0})},et=async()=>{const l=Ae();if(!l)return;const b=await Ma({title:at(l.title||"untitled"),content:at(l.content),layout:l.layout??u});if(b.type==="error"){r(b.errors[0].message);return}ne.current=!0,K.current=null,V(null),ke(),Promise.resolve(n({to:be,params:{id:b.createNote.id}})).finally(()=>{ne.current=!1})},zt=()=>{ee&&(m(ee.title),ee.layout&&y(ee.layout),oe(ee.content),R(l=>l+1),Tt(ee))},qt=()=>{Et()},Qt=ee?G(ee.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Se=N==="saved"&&_,Yt=pn(x,k),Wt=Oe(c.createdAt),Gt=N==="pending"?"Saving...":N==="saving"?"Saving now...":N==="error"?"Save failed. Try again.":N==="conflict"?"Save paused: changed elsewhere":`Saved ${Yt}`,Jt=q("inline-flex items-center gap-2 transition-colors",N==="saved"&&!Se&&"text-fg-secondary",Se&&"text-accent-success",(N==="pending"||N==="saving")&&"text-fg-default",(N==="error"||N==="conflict")&&"text-fg-error"),Re=q("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(N==="pending"||N==="saving")&&"save-progress-ring-active",N==="saved"&&Se&&"save-progress-ring-complete",(N==="error"||N==="conflict")&&"save-progress-ring-error"),Xt=N==="saving"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="pending"?e.jsx("span",{className:Re,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="error"||N==="conflict"?e.jsx(Ua,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Re,"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:C,children:[Xt,Gt]}),Te=N==="conflict"&&w?.type==="updated",ta=Te?Ae():null,aa=w!==null&&!(w.type==="updated"&&!Te&&w.updatedAt===c.updatedAt);return e.jsx(We,{title:g,variant:"none",children:e.jsxs("main",{className:q("mx-auto",gn[u]),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:g,onChange:l=>Ot(l.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(mt,{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:()=>Ft(t,F,()=>{M(l=>!l)})},{name:"Change layout",onClick:()=>P(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>Ht(d.current?.value||"untitled",s.current?.getContent()||"",u)},{name:"Restore previous version",onClick:()=>L(!0)},{type:"separator"},{name:"Delete",onClick:()=>Lt(t,()=>{n({to:tt,search:{page:1}})})}]}),e.jsx(S,{size:"sm",variant:"subtle",isLoading:N==="saving",disabled:N==="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(h,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(Ra,{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(h,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",Wt]})]})]})}),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(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:zt,children:"Restore draft"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:qt,children:"Discard"})]})]})}),N==="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(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Xe,children:"Retry save"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{et()},children:"Save as new note"})]})]})}),e.jsx(wn,{noteId:t,properties:c.properties,expectedUpdatedAt:te.current,editSessionId:o.current,disabled:N!=="saved",onSaved:l=>{U.current=l.updatedAt,ae(l.updatedAt),I(l.updatedAt),$(!0),i.setQueryData(T.notes.detail(t),b=>b&&{...b,updatedAt:l.updatedAt,properties:l.properties}),ve({noteId:t,updatedAt:l.updatedAt,editSessionId:o.current})}}),e.jsx(en,{ref:s,content:Ne??c.content,currentNoteId:t,onChange:Pt},`${t}:${Ce}`),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:l,retry:b})=>e.jsx(Ze,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(mr,{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:l,retry:b})=>e.jsx(Ze,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:l,onRetry:b,showBackAction:!1,showHomeAction:!1}),children:e.jsx(dr,{noteId:t,render:l=>l&&l.length>0&&e.jsx(Ge,{icon:e.jsx(Nt,{className:"h-3.5 w-3.5"}),title:"Back References",children:e.jsx("ul",{className:"flex flex-col",children:l.map(b=>e.jsx("li",{children:e.jsxs(Ke,{to:be,params:{id:b.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(rr,{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:b.title})]})},b.id))})})})}),e.jsx(sr,{isOpen:v,onClose:()=>P(!1),onSave:_t,currentLayout:u}),e.jsx(ir,{isOpen:aa,isDeleted:w?.type==="deleted",isConflict:Te,hasDraft:ta!==null,source:w?.source??"unknown",isReloading:p.isRefetching,onReload:Zt,onOverwrite:()=>{Kt()},onCloneDraft:()=>{et()},onOpenTrash:()=>n({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:()=>re("markdown")}),e.jsx(ue,{title:"HTML",description:"Good for web documents or CMS editors.",selected:Y==="html",onClick:()=>re("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(ft,{size:"sm",checked:W,onChange:l=>Q(l.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:f==="fragment",onClick:()=>E("fragment")}),e.jsx(ue,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:f==="standalone",onClick:()=>E("standalone")})]})]})]})}),e.jsx(H.Footer,{children:e.jsxs(fe,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>J(!1),children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:Ut,children:"Download"})]})})]}),e.jsx(cr,{isOpen:B,noteId:t,onClose:()=>L(!1),onRestored:l=>{o.current=_e(),ke(),K.current=null,U.current=l.updatedAt,V(null),ae(l.updatedAt),I(l.updatedAt)}}),Vt]})})}function Dn(){const{id:t}=St.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Ue,{fallback:yn,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:r,retry:n})=>e.jsx(We,{title:"Note",variant:"none",children:e.jsx(Ze,{title:"Failed to load note",description:"Retry loading the note editor.",error:r,onRetry:n})}),children:e.jsx(jn,{id:t},t)})}export{jn as NoteContent,Dn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
._Reference_102im_1{display:inline-flex;align-items:center;cursor:pointer;font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:8px;background:color-mix(in srgb,var(--elevated) 72%,var(--hover-subtle));border:1px solid var(--border-subtle);color:var(--fg-secondary);transition:background-color .15s ease,border-color .15s ease,color .15s ease}._Reference_102im_1:hover{background:var(--elevated);border-color:var(--border-secondary);color:var(--fg-default)}._Reference_102im_1:focus-visible{outline:2px solid var(--border-focus);outline-offset:2px}html.dark ._Reference_102im_1{background:color-mix(in srgb,var(--elevated) 82%,var(--hover-subtle))}._Tag_1gb8h_1{display:inline-flex;align-items:center;cursor:pointer;font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:8px;background:var(--emphasis);border:1px solid var(--border-subtle);color:var(--fg-secondary);transition:background-color .15s ease,border-color .15s ease,color .15s ease}._Tag_1gb8h_1:hover{background:var(--hover-subtle);border-color:var(--border-secondary);color:var(--fg-default)}._Tag_1gb8h_1:focus-visible{outline:2px solid var(--border-focus);outline-offset:2px}html.dark ._Tag_1gb8h_1{background:var(--emphasis)}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import{h as t,aS as n}from"./index-BgnmVjeF.js";function o({limit:a=50,offset:e=0}={}){return t(`query FetchImages($pagination: PaginationInput) {
|
|
2
|
-
allImages(pagination: $pagination) {
|
|
3
|
-
totalCount
|
|
4
|
-
images {
|
|
5
|
-
id
|
|
6
|
-
url
|
|
7
|
-
referenceCount
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}`,{pagination:{limit:a,offset:e}})}function u(a){return t(`query FetchImage($id: ID!) {
|
|
11
|
-
image(id: $id) {
|
|
12
|
-
id
|
|
13
|
-
url
|
|
14
|
-
}
|
|
15
|
-
}`,{id:a})}function g(a){return t(`mutation DeleteImage($id: ID!) {
|
|
16
|
-
deleteImage(id: $id)
|
|
17
|
-
}`,{id:a})}async function m({base64:a,externalSrc:e}){if(a){const{data:i}=await n.post("/api/image",{image:a});return i.url}if(e){const{data:i}=await n.post("/api/image-from-src",{src:e});return i.url}throw new Error("No file or src provided")}export{u as a,g as d,o as f,m as u};
|