ocean-brain 0.8.0 → 0.8.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 +3 -2
- package/server/client/dist/assets/{ArrowRight.es-C4zlc54Z.js → ArrowRight.es-CbA8ey6a.js} +1 -1
- package/server/client/dist/assets/{Calendar-COrN6Hjv.js → Calendar-CgWgr1BV.js} +1 -1
- package/server/client/dist/assets/{Callout-BK0K9E74.js → Callout-DKruIT0f.js} +1 -1
- package/server/client/dist/assets/{Copy.es-zm8f_XXX.js → Copy.es-DFbgpaNJ.js} +1 -1
- package/server/client/dist/assets/{Graph-BH1fzhue.js → Graph-kCltGRlY.js} +1 -1
- package/server/client/dist/assets/{Image-KXuHOG4b.js → Image-7W0DZwMo.js} +1 -1
- package/server/client/dist/assets/{Image.es-BKahRbIm.js → Image.es-5pXLx9TU.js} +1 -1
- package/server/client/dist/assets/Note-BW6Np_5g.js +20 -0
- package/server/client/dist/assets/{Plus.es-BqeC8T8h.js → Plus.es-B0sg64VJ.js} +1 -1
- package/server/client/dist/assets/{Reminders-BYG5rz1M.js → Reminders-C10fHQcl.js} +1 -1
- package/server/client/dist/assets/{Search-DBWsIMDP.js → Search-tf2nV4v0.js} +1 -1
- package/server/client/dist/assets/{SurfaceCard-CNSQfYfM.js → SurfaceCard-pydtvHfu.js} +1 -1
- package/server/client/dist/assets/{Tag-5aCfSO8Y.js → Tag-uCoYbISy.js} +1 -1
- package/server/client/dist/assets/{TagNotes-BPZjN-6l.js → TagNotes-CqOcQiRw.js} +1 -1
- package/server/client/dist/assets/{Trash.es-CRQkTnXZ.js → Trash.es-w32Goxfa.js} +1 -1
- package/server/client/dist/assets/{ViewNotes-DGLNF96x.js → ViewNotes-slPXXoOY.js} +1 -1
- package/server/client/dist/assets/{ViewSectionDialog-CzskgmMF.js → ViewSectionDialog-brTrsF6G.js} +1 -1
- package/server/client/dist/assets/{Views-DR5jT23G.js → Views-B_wsb-XJ.js} +1 -1
- package/server/client/dist/assets/{graph-vendor-UTvF2NS_.js → graph-vendor-BAF95C0g.js} +1 -1
- package/server/client/dist/assets/{image.api-8dlMwzMd.js → image.api-CYsjXiMr.js} +1 -1
- package/server/client/dist/assets/{index-VHp17GQX.js → index-BR05aSXr.js} +4 -4
- package/server/client/dist/assets/{index-DGIAh3ZY.js → index-D83QbOcw.js} +1 -1
- package/server/client/dist/assets/{index-BEUqDuAZ.css → index-DPI6YoDt.css} +1 -1
- package/server/client/dist/assets/{manage-image-RqtWKas2.js → manage-image-BYIhWu56.js} +1 -1
- package/server/client/dist/assets/{manage-image-detail-BTSIbLlQ.js → manage-image-detail-6KgmQvbN.js} +1 -1
- package/server/client/dist/assets/{mcp-EDurbggR.js → mcp-Dd98N9Hq.js} +2 -2
- package/server/client/dist/assets/{mcp-admin-adapter-DmGUo5G8.js → mcp-admin-adapter-DOgBsYpl.js} +1 -1
- package/server/client/dist/assets/note-core-CMGUaW1v.js +176 -0
- package/server/client/dist/assets/note-vendor-Hoz9Q4-4.js +54 -0
- package/server/client/dist/assets/{placeholder-DeKgSBnC.js → placeholder-siHGg9aK.js} +4 -4
- package/server/client/dist/assets/{properties-BjrZvOYn.js → properties-CyVRKgcT.js} +1 -1
- package/server/client/dist/assets/{tag.api-Dl8DQd0m.js → tag.api-CwmC8crB.js} +1 -1
- package/server/client/dist/assets/{trash-C5ntddLu.js → trash-wojQBK9Z.js} +1 -1
- package/server/client/dist/assets/{useReminderMutate-CoXXqJY2.js → useReminderMutate-DuVKxpBh.js} +1 -1
- package/server/client/dist/index.html +5 -5
- package/server/dist/app.js +0 -1
- package/server/dist/features/auth/http/api.js +0 -1
- package/server/dist/features/auth/http/login-page.js +272 -5
- package/server/dist/features/auth/http/pages.js +20 -3
- package/server/dist/features/auth/service.js +3 -2
- package/server/dist/features/cache/graphql/cache.field.resolver.js +0 -1
- package/server/dist/features/cache/graphql/cache.mutation.resolver.js +0 -1
- package/server/dist/features/cache/graphql/cache.query.resolver.js +0 -1
- package/server/dist/features/cache/graphql/cache.resolver.js +0 -1
- package/server/dist/features/cache/graphql/cache.type-defs.js +0 -1
- package/server/dist/features/cache/graphql/index.js +0 -1
- package/server/dist/features/image/graphql/image.field.resolver.js +0 -1
- package/server/dist/features/image/graphql/image.mutation.resolver.js +0 -1
- package/server/dist/features/image/graphql/image.query.resolver.js +0 -1
- package/server/dist/features/image/graphql/image.resolver.js +0 -1
- package/server/dist/features/image/graphql/image.type-defs.js +0 -1
- package/server/dist/features/image/graphql/index.js +0 -1
- package/server/dist/features/image/http/upload.js +0 -1
- package/server/dist/features/image/services/delete.js +0 -1
- package/server/dist/features/image/services/upload.js +0 -1
- package/server/dist/features/image/services/validation.js +0 -1
- package/server/dist/features/mcp-admin/http/handlers.js +0 -1
- package/server/dist/features/mcp-admin/service.js +0 -1
- package/server/dist/features/note/graphql/index.js +0 -1
- package/server/dist/features/note/graphql/note.field.resolver.js +0 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js +0 -1
- package/server/dist/features/note/graphql/note.query.resolver.js +0 -1
- package/server/dist/features/note/graphql/note.resolver.js +0 -1
- package/server/dist/features/note/graphql/note.type-defs.js +0 -1
- package/server/dist/features/note/http/mcp.js +0 -1
- package/server/dist/features/note/services/authoring.js +0 -1
- package/server/dist/features/note/services/cleanup.js +0 -1
- package/server/dist/features/note/services/content-blocks.js +0 -1
- package/server/dist/features/note/services/markdown-intent-write.js +0 -1
- package/server/dist/features/note/services/markdown-patch.js +0 -1
- package/server/dist/features/note/services/properties.js +0 -1
- package/server/dist/features/note/services/search-backfill.js +0 -1
- package/server/dist/features/note/services/search.js +0 -1
- package/server/dist/features/note/services/snapshot.js +0 -1
- package/server/dist/features/note/services/tag-filter.js +0 -1
- package/server/dist/features/note/services/trash.js +0 -1
- package/server/dist/features/note/services/write-conflict.js +0 -1
- package/server/dist/features/note/services/write.js +0 -1
- package/server/dist/features/placeholder/graphql/index.js +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.field.resolver.js +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.mutation.resolver.js +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.query.resolver.js +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.resolver.js +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.type-defs.js +0 -1
- package/server/dist/features/reminder/graphql/index.js +0 -1
- package/server/dist/features/reminder/graphql/reminder.field.resolver.js +0 -1
- package/server/dist/features/reminder/graphql/reminder.mutation.resolver.js +0 -1
- package/server/dist/features/reminder/graphql/reminder.query.resolver.js +0 -1
- package/server/dist/features/reminder/graphql/reminder.resolver.js +0 -1
- package/server/dist/features/reminder/graphql/reminder.type-defs.js +0 -1
- package/server/dist/features/tag/graphql/index.js +0 -1
- package/server/dist/features/tag/graphql/tag.field.resolver.js +0 -1
- package/server/dist/features/tag/graphql/tag.mutation.resolver.js +0 -1
- package/server/dist/features/tag/graphql/tag.query.resolver.js +0 -1
- package/server/dist/features/tag/graphql/tag.resolver.js +0 -1
- package/server/dist/features/tag/graphql/tag.type-defs.js +0 -1
- package/server/dist/features/tag/http/mcp.js +0 -1
- package/server/dist/features/tag/services/organization.js +0 -1
- package/server/dist/features/view/graphql/index.js +0 -1
- package/server/dist/features/view/graphql/view.mutation.resolver.js +0 -1
- package/server/dist/features/view/graphql/view.query.resolver.js +0 -1
- package/server/dist/features/view/graphql/view.resolver.js +0 -1
- package/server/dist/features/view/graphql/view.type-defs.js +0 -1
- package/server/dist/features/view/services/workspace.js +0 -1
- package/server/dist/main.js +0 -1
- package/server/dist/models.js +0 -1
- package/server/dist/modules/app-version.js +0 -1
- package/server/dist/modules/auth-guard.js +0 -1
- package/server/dist/modules/auth-mode.js +0 -1
- package/server/dist/modules/auth-redirect.js +0 -1
- package/server/dist/modules/blocknote-markdown-editor.js +53 -0
- package/server/dist/modules/blocknote-tree.js +0 -1
- package/server/dist/modules/blocknote.js +10 -4
- package/server/dist/modules/data-maintenance.js +0 -1
- package/server/dist/modules/error-handler.js +0 -1
- package/server/dist/modules/graphql.js +0 -1
- package/server/dist/modules/logger.js +0 -1
- package/server/dist/modules/mcp-auth.js +0 -1
- package/server/dist/modules/mcp-token.js +0 -1
- package/server/dist/modules/prisma-runtime.js +0 -1
- package/server/dist/modules/rate-limit.js +0 -1
- package/server/dist/modules/recovery-retention.js +0 -1
- package/server/dist/modules/server-events-handler.js +0 -1
- package/server/dist/modules/server-events.js +0 -1
- package/server/dist/modules/session-store.js +0 -1
- package/server/dist/modules/use-async.js +0 -1
- package/server/dist/paths.js +0 -1
- package/server/dist/routes/api.js +0 -1
- package/server/dist/routes/auth-pages.js +0 -1
- package/server/dist/routes/client.js +0 -1
- package/server/dist/routes/graphql.js +0 -1
- package/server/dist/routes/index.js +0 -1
- package/server/dist/routes/mcp.js +0 -1
- package/server/dist/schema/index.js +0 -1
- package/server/dist/start.js +0 -1
- package/server/dist/types/index.js +0 -1
- package/server/dist/types/input.js +0 -1
- package/server/client/dist/assets/Note-C143cKKw.js +0 -12
- package/server/client/dist/assets/note-core-BklwyZHk.js +0 -180
- package/server/client/dist/assets/note-vendor-DkYKUmLo.js +0 -54
- package/server/client/dist/fonts/Pretendard-Bold.woff +0 -0
- package/server/client/dist/fonts/Pretendard-Regular.woff +0 -0
- package/server/dist/app.js.map +0 -1
- package/server/dist/features/auth/http/api.js.map +0 -1
- package/server/dist/features/auth/http/login-page.js.map +0 -1
- package/server/dist/features/auth/http/pages.js.map +0 -1
- package/server/dist/features/auth/service.js.map +0 -1
- package/server/dist/features/cache/graphql/cache.field.resolver.js.map +0 -1
- package/server/dist/features/cache/graphql/cache.mutation.resolver.js.map +0 -1
- package/server/dist/features/cache/graphql/cache.query.resolver.js.map +0 -1
- package/server/dist/features/cache/graphql/cache.resolver.js.map +0 -1
- package/server/dist/features/cache/graphql/cache.type-defs.js.map +0 -1
- package/server/dist/features/cache/graphql/index.js.map +0 -1
- package/server/dist/features/image/graphql/image.field.resolver.js.map +0 -1
- package/server/dist/features/image/graphql/image.mutation.resolver.js.map +0 -1
- package/server/dist/features/image/graphql/image.query.resolver.js.map +0 -1
- package/server/dist/features/image/graphql/image.resolver.js.map +0 -1
- package/server/dist/features/image/graphql/image.type-defs.js.map +0 -1
- package/server/dist/features/image/graphql/index.js.map +0 -1
- package/server/dist/features/image/http/upload.js.map +0 -1
- package/server/dist/features/image/services/delete.js.map +0 -1
- package/server/dist/features/image/services/upload.js.map +0 -1
- package/server/dist/features/image/services/validation.js.map +0 -1
- package/server/dist/features/mcp-admin/http/handlers.js.map +0 -1
- package/server/dist/features/mcp-admin/service.js.map +0 -1
- package/server/dist/features/note/graphql/index.js.map +0 -1
- package/server/dist/features/note/graphql/note.field.resolver.js.map +0 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js.map +0 -1
- package/server/dist/features/note/graphql/note.query.resolver.js.map +0 -1
- package/server/dist/features/note/graphql/note.resolver.js.map +0 -1
- package/server/dist/features/note/graphql/note.type-defs.js.map +0 -1
- package/server/dist/features/note/http/mcp.js.map +0 -1
- package/server/dist/features/note/services/authoring.js.map +0 -1
- package/server/dist/features/note/services/cleanup.js.map +0 -1
- package/server/dist/features/note/services/content-blocks.js.map +0 -1
- package/server/dist/features/note/services/markdown-intent-write.js.map +0 -1
- package/server/dist/features/note/services/markdown-patch.js.map +0 -1
- package/server/dist/features/note/services/properties.js.map +0 -1
- package/server/dist/features/note/services/search-backfill.js.map +0 -1
- package/server/dist/features/note/services/search.js.map +0 -1
- package/server/dist/features/note/services/snapshot.js.map +0 -1
- package/server/dist/features/note/services/tag-filter.js.map +0 -1
- package/server/dist/features/note/services/trash.js.map +0 -1
- package/server/dist/features/note/services/write-conflict.js.map +0 -1
- package/server/dist/features/note/services/write.js.map +0 -1
- package/server/dist/features/placeholder/graphql/index.js.map +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.field.resolver.js.map +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.mutation.resolver.js.map +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.query.resolver.js.map +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.resolver.js.map +0 -1
- package/server/dist/features/placeholder/graphql/placeholder.type-defs.js.map +0 -1
- package/server/dist/features/reminder/graphql/index.js.map +0 -1
- package/server/dist/features/reminder/graphql/reminder.field.resolver.js.map +0 -1
- package/server/dist/features/reminder/graphql/reminder.mutation.resolver.js.map +0 -1
- package/server/dist/features/reminder/graphql/reminder.query.resolver.js.map +0 -1
- package/server/dist/features/reminder/graphql/reminder.resolver.js.map +0 -1
- package/server/dist/features/reminder/graphql/reminder.type-defs.js.map +0 -1
- package/server/dist/features/tag/graphql/index.js.map +0 -1
- package/server/dist/features/tag/graphql/tag.field.resolver.js.map +0 -1
- package/server/dist/features/tag/graphql/tag.mutation.resolver.js.map +0 -1
- package/server/dist/features/tag/graphql/tag.query.resolver.js.map +0 -1
- package/server/dist/features/tag/graphql/tag.resolver.js.map +0 -1
- package/server/dist/features/tag/graphql/tag.type-defs.js.map +0 -1
- package/server/dist/features/tag/http/mcp.js.map +0 -1
- package/server/dist/features/tag/services/organization.js.map +0 -1
- package/server/dist/features/view/graphql/index.js.map +0 -1
- package/server/dist/features/view/graphql/view.mutation.resolver.js.map +0 -1
- package/server/dist/features/view/graphql/view.query.resolver.js.map +0 -1
- package/server/dist/features/view/graphql/view.resolver.js.map +0 -1
- package/server/dist/features/view/graphql/view.type-defs.js.map +0 -1
- package/server/dist/features/view/services/workspace.js.map +0 -1
- package/server/dist/main.js.map +0 -1
- package/server/dist/models.js.map +0 -1
- package/server/dist/modules/app-version.js.map +0 -1
- package/server/dist/modules/auth-guard.js.map +0 -1
- package/server/dist/modules/auth-mode.js.map +0 -1
- package/server/dist/modules/auth-redirect.js.map +0 -1
- package/server/dist/modules/blocknote-tree.js.map +0 -1
- package/server/dist/modules/blocknote.js.map +0 -1
- package/server/dist/modules/data-maintenance.js.map +0 -1
- package/server/dist/modules/error-handler.js.map +0 -1
- package/server/dist/modules/graphql.js.map +0 -1
- package/server/dist/modules/logger.js.map +0 -1
- package/server/dist/modules/mcp-auth.js.map +0 -1
- package/server/dist/modules/mcp-token.js.map +0 -1
- package/server/dist/modules/prisma-runtime.js.map +0 -1
- package/server/dist/modules/rate-limit.js.map +0 -1
- package/server/dist/modules/recovery-retention.js.map +0 -1
- package/server/dist/modules/server-events-handler.js.map +0 -1
- package/server/dist/modules/server-events.js.map +0 -1
- package/server/dist/modules/session-store.js.map +0 -1
- package/server/dist/modules/use-async.js.map +0 -1
- package/server/dist/paths.js.map +0 -1
- package/server/dist/routes/api.js.map +0 -1
- package/server/dist/routes/auth-pages.js.map +0 -1
- package/server/dist/routes/client.js.map +0 -1
- package/server/dist/routes/graphql.js.map +0 -1
- package/server/dist/routes/index.js.map +0 -1
- package/server/dist/routes/mcp.js.map +0 -1
- package/server/dist/schema/index.js.map +0 -1
- package/server/dist/start.js.map +0 -1
- package/server/dist/types/index.js.map +0 -1
- package/server/dist/types/input.js.map +0 -1
package/server/dist/paths.js
CHANGED
package/server/dist/start.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=input.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{j as t,i as Ue,k as ia,U as st,y as ot,v as ca,X as da,F as ua}from"./note-vendor-DkYKUmLo.js";import{aj as pa,a7 as lt,T as y,c as Y,a5 as it,ak as fa,q as T,M as L,F as ue,B as S,al as ct,X as dt,am as ma,m as pe,k as ve,u as he,an as ha,ao as xa,ap as ga,aq as ya,ar as va,d as J,E as ke,I as Le,as as ba,at as wa,au as Ee,D as ut,l as pt,g as ja,av as Na,a as Ca,aw as ft,ax as Aa,ay as mt,N as ge,ah as Sa,$ as ka,az as Be,aA as xe,Y as Fe,P as He,a4 as _e,aB as Ea,aC as Ra,aD as Ta,aE as Ma,aF as Qe,aG as Da,i as ne,L as Ie,j as Pa,aH as Oa,aI as La,aJ as qe,O as Ba,aK as Fa,S as Ge,e as Re,a2 as _a,aL as Ia,aM as $a,aN as Ua,aO as Ha,aP as Va,aQ as za,aR as We,aS as Ka,aT as Za}from"./index-VHp17GQX.js";import{a as o}from"./graph-vendor-UTvF2NS_.js";import{c as Ya,C as Je,m as Qa}from"./Callout-BK0K9E74.js";import{S as qa}from"./SurfaceCard-CNSQfYfM.js";import{u as Ga,R as Wa}from"./useReminderMutate-CoXXqJY2.js";import{n as $e}from"./Plus.es-BqeC8T8h.js";import{u as Ja}from"./image.api-8dlMwzMd.js";import{A as Xa,G as en,a3 as ce,a4 as tn}from"./note-core-BklwyZHk.js";import{s as an}from"./Copy.es-zm8f_XXX.js";import{f as nn,c as rn}from"./tag.api-Dl8DQd0m.js";function sn(e,a){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const n=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>n&&s!==void 0?await s():n,enableBeforeUnload:n,withResolver:s===void 0}}function on(e,a){const{shouldBlockFn:n,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:c=!1}=sn(e),i=pa(),{history:d}=i,[l,m]=o.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return o.useEffect(()=>{const p=async g=>{function v(M){const f=i.parseLocation(M),w=i.getMatchedRoutes(f.pathname);return w.foundRoute===void 0?{routeId:"__notFound__",fullPath:f.pathname,pathname:f.pathname,params:w.routeParams,search:i.options.parseSearch(M.search)}:{routeId:w.foundRoute.id,fullPath:w.foundRoute.fullPath,pathname:f.pathname,params:w.routeParams,search:i.options.parseSearch(M.search)}}const h=v(g.currentLocation),A=v(g.nextLocation);if(h.routeId==="__notFound__"&&A.routeId!=="__notFound__")return!1;const C=await n({action:g.action,current:h,next:A});if(!c)return C;if(!C)return!1;const _=await new Promise(M=>{m({status:"blocked",current:h,next:A,action:g.action,proceed:()=>M(!1),reset:()=>M(!0)})});return m({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),_};return r?void 0:d.block({blockerFn:p,enableBeforeUnload:s})},[n,s,r,c,d,i]),l}const ln=new Map([["bold",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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"}))]]),cn=new Map([["bold",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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"}),o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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",o.createElement(o.Fragment,null,o.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"}))]]),ht=o.forwardRef((e,a)=>o.createElement(lt,{ref:a,...e,weights:ln}));ht.displayName="FileIcon";const dn=ht,xt=o.forwardRef((e,a)=>o.createElement(lt,{ref:a,...e,weights:cn}));xt.displayName="LinkSimpleIcon";const gt=xt;function yt({icon:e,title:a,className:n}){return t.jsxs("div",{className:Y("flex items-center gap-2",n),children:[t.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:e}),t.jsx(y,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:a})]})}function Ve({title:e,icon:a,action:n,titleButtonProps:s,ariaLabel:r,className:c,children:i}){const d=i!=null&&i!==!1,l=n!=null&&n!==!1,m=t.jsx(yt,{icon:a,title:e,className:"text-fg-tertiary"});return t.jsxs("section",{className:Y("surface-base p-4",c),"aria-label":r??e,children:[t.jsxs("div",{className:Y("relative",l&&"pr-44 sm:pr-48",d&&"mb-3"),children:[s?t.jsx("button",{...s,type:"button",className:Y("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",s.className),children:m}):m,l&&t.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:n})]}),i]})}function un({title:e,description:a,selected:n=!1,onClick:s,children:r}){return t.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:s,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(y,{as:"div",variant:"body",weight:"semibold",tone:n?"default":"secondary",children:e}),t.jsx(y,{as:"div",variant:"meta",weight:"medium",tone:n?"secondary":"tertiary",className:"mt-1",children:a})]}),r?t.jsx("div",{className:"shrink-0",children:r}):null]})}const pn=e=>{const{data:a}=it({queryKey:T.notes.backReferences(e.noteId),async queryFn(){const n=await fa(e.noteId);if(n.type==="error")throw n;return n.backReferences}});return e.render(a)},fn=[{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 mn({isOpen:e,onClose:a,onSave:n,currentLayout:s="wide"}){const[r,c]=o.useState(s);o.useEffect(()=>{e&&c(s)},[e,s]);const i=()=>{n(r),a()};return t.jsxs(L,{isOpen:e,onClose:a,variant:"compact",children:[t.jsx(L.Header,{title:"Layout Settings",onClose:a}),t.jsx(L.Body,{children:t.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(y,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),t.jsx("div",{className:"flex flex-col gap-2",children:fn.map(d=>t.jsx(un,{title:d.label,description:d.description,selected:r===d.value,onClick:()=>c(d.value)},d.value))})]})})}),t.jsx(L.Footer,{children:t.jsxs(ue,{children:[t.jsx(S,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),t.jsx(S,{variant:"primary",size:"sm",onClick:i,children:"Apply"})]})})]})}const hn=/[:{}[\],&*#?|<>=!%@`-]/,xn="/assets/images/",vt="<!-- Local Ocean Brain image omitted from document-only export. -->",gn=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",me=e=>e?hn.test(e)||/^\s|\s$/.test(e)?JSON.stringify(e):e:'""',ye=e=>{if(!e)return;const a=Number(e);return Number.isFinite(a)?new Date(a).toISOString():e},ze=()=>typeof window>"u"||!window.location?.origin?"http://localhost":window.location.origin,be=(e,a=ze())=>{try{const n=new URL(e,a);return n.origin===a&&n.pathname.startsWith(xn)}catch{return!1}},bt=(e,a=ze())=>{const n=new URL(e,a);return`${n.pathname}${n.search}`},wt=e=>e.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase()??"",yn=e=>e.trim().replace(/[\\/:*?"<>|]/g,"-").split("").map(s=>s.charCodeAt(0)<32?"-":s).join("").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"image",vn=e=>{const a=e.lastIndexOf(".");return a<=0||a===e.length-1?{baseName:e,extension:""}:{baseName:e.slice(0,a),extension:e.slice(a)}},jt=(e,a,n)=>{const r=new URL(e,ze()).pathname.split("/").filter(Boolean),c=decodeURIComponent(r[r.length-1]??""),i=`image-${a+1}`,{baseName:d,extension:l}=vn(yn(c||i));let m=`${d}${l}`,p=2;for(;n.has(m);)m=`${d}-${p}${l}`,p+=1;return n.add(m),`assets/${m}`},bn=(e,a)=>{let n=null;for(let s=a;s<e.length;s+=1){const r=e[s];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'"){n=r;continue}if(r===">")return s}return-1},wn=(e,a)=>{let n=a;for(;n<e.length;){const s=e.toLowerCase().indexOf("<img",n);if(s===-1)return-1;const r=e[s+4],c=s===0?-1:e.lastIndexOf("<",s-1),i=s===0?-1:e.lastIndexOf(">",s-1);if(c<=i&&(!r||/[\s/>]/.test(r)))return s;n=s+4}return-1},jn=(e,a,n,s)=>{let r=a;for(;r<n;){for(;r<n&&/[\s/]/.test(e[r]);)r+=1;const c=r;for(;r<n&&/[^\s=/>]/.test(e[r]);)r+=1;const i=e.slice(c,r).toLowerCase();for(;r<n&&/\s/.test(e[r]);)r+=1;if(e[r]!=="=")continue;for(r+=1;r<n&&/\s/.test(e[r]);)r+=1;const d=e[r];if(d==='"'||d==="'"){const m=r+1,p=e.indexOf(d,m);if(p===-1||p>n)return;if(r=p+1,i===s)return{end:p,start:m,value:e.slice(m,p)};continue}const l=r;for(;r<n&&/[^\s>]/.test(e[r]);)r+=1;if(i===s)return{end:r,start:l,value:e.slice(l,r)}}},Nt=e=>{const a=[];let n=0;for(;n<e.length;){const s=wn(e,n);if(s===-1)break;const r=bn(e,s+4);if(r===-1)break;const c=jn(e,s+4,r,"src");c&&a.push({end:r+1,source:c,start:s}),n=r+1}return a},Ct=(e,a)=>{let n=e;for(const s of[...a].sort((r,c)=>c.start-r.start))n=`${n.slice(0,s.start)}${s.value}${n.slice(s.end)}`;return n},At=(e,a)=>{let n=e;for(const s of[...a].sort((r,c)=>c.start-r.start))n=`${n.slice(0,s.start)}${s.value}${n.slice(s.end)}`;return n},St=e=>{const a=/!\[[^\]\n]*\]\([^)]+?\)/g,n=[];for(const s of e.matchAll(a)){if(s.index===void 0)continue;const r=s[0],c=r.indexOf("("),i=r.lastIndexOf(")");if(c<0||i<0||i<=c)continue;let d=c+1;for(;d<i&&/\s/.test(r[d]);)d+=1;if(d>=i)continue;let l=d,m=d,p=d;if(r[d]==="<"){const g=r.indexOf(">",d+1);if(g===-1||g>i)continue;l=g+1,m=d+1,p=g}else{for(;l<i&&!/\s/.test(r[l]);)l+=1;m=d,p=l}n.push({end:s.index+r.length,source:{end:s.index+l,start:s.index+d,value:r.slice(m,p)},start:s.index})}return n},Nn=(e,a)=>`${gn(e)}.${a}`,Cn=({id:e,title:a,createdAt:n,updatedAt:s})=>{const r=["---",`title: ${me(a)}`,`note_id: ${me(e)}`],c=ye(n),i=ye(s);return c&&r.push(`created_at: ${me(c)}`),i&&r.push(`updated_at: ${me(i)}`),r.push("source: ocean-brain","---"),r.join(`
|
|
2
|
-
`)},kt=(e,a,n=!1)=>n?`${Cn(a)}
|
|
3
|
-
|
|
4
|
-
${e}`:e,An=(e,a,{includeMetadata:n=!1}={})=>{const s=kt(e,a,n),r=St(s).filter(c=>be(c.source.value)).map(c=>({end:c.end,start:c.start,value:vt}));return At(s,r)},Et=(e,a,{includeMetadata:n=!1}={})=>`${n?`<!--
|
|
5
|
-
source: ocean-brain
|
|
6
|
-
note_id: ${a.id}
|
|
7
|
-
title: ${a.title}
|
|
8
|
-
created_at: ${ye(a.createdAt)??""}
|
|
9
|
-
updated_at: ${ye(a.updatedAt)??""}
|
|
10
|
-
-->
|
|
11
|
-
`:""}${e}`,Sn=(e,a,{includeMetadata:n=!1}={})=>{const s=Et(e,a,{includeMetadata:n}),r=Nt(s).filter(c=>be(c.source.value)).map(c=>({end:c.end,start:c.start,value:vt}));return Ct(s,r)},kn=async(e,a,{fetchImpl:n=fetch,includeMetadata:s=!1}={})=>{const r=new ct,c=Et(e,a,{includeMetadata:s}),i=Nt(c),d=[],l=new Set,m=new Map;for(const{source:p}of i){if(!be(p.value))continue;const g=bt(p.value);let v=m.get(g);if(!v){v=jt(g,m.size,l),m.set(g,v);const h=await n(g,{credentials:"same-origin"});if(!h.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!wt(h).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(v,new Uint8Array(await h.arrayBuffer()))}d.push({end:p.end,start:p.start,value:`./${v}`})}return r.file("note.html",Ct(c,d)),r.generateAsync({type:"blob"})},En=async(e,a,{fetchImpl:n=fetch,includeMetadata:s=!1}={})=>{const r=new ct,c=kt(e,a,s),i=St(c),d=[],l=new Set,m=new Map;for(const{source:p}of i){if(!be(p.value))continue;const g=bt(p.value);let v=m.get(g);if(!v){v=jt(g,m.size,l),m.set(g,v);const h=await n(g,{credentials:"same-origin"});if(!h.ok)throw new Error(`Failed to fetch image asset: ${g}`);if(!wt(h).startsWith("image/"))throw new Error(`Image asset did not return image content: ${g}`);r.file(v,new Uint8Array(await h.arrayBuffer()))}d.push({end:p.end,start:p.start,value:`./${v}`})}return r.file("note.md",At(c,d)),r.generateAsync({type:"blob"})},Rn=(e,a)=>{const n=URL.createObjectURL(e),s=document.createElement("a");s.href=n,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(n)},Rt={html:{extension:"html",getContent:e=>e.getHtml(),createDocumentBlob:(e,a)=>new Blob([Sn(e,a.metadata,{includeMetadata:a.includeMetadata})],{type:"text/html;charset=utf-8"}),createZipBlob:(e,a)=>kn(e,a.metadata,{fetchImpl:a.fetchImpl,includeMetadata:a.includeMetadata})},markdown:{extension:"md",getContent:e=>e.getMarkdown(),createDocumentBlob:(e,a)=>new Blob([An(e,a.metadata,{includeMetadata:a.includeMetadata})],{type:"text/markdown;charset=utf-8"}),createZipBlob:(e,a)=>En(e,a.metadata,{fetchImpl:a.fetchImpl,includeMetadata:a.includeMetadata})}},Tt=(e,a)=>a?"zip":Rt[e].extension,Tn=async e=>{const a=Rt[e.format],n=a.getContent(e.source);if(n===void 0)return{type:"not-ready",format:e.format};const s=Tt(e.format,e.includeAssets);return{type:"success",blob:e.includeAssets?await a.createZipBlob(n,e):a.createDocumentBlob(n,e),filename:Nn(e.metadata.title,s)}},Mn=e=>e==="markdown"?"Markdown is not ready yet.":"HTML is not ready yet.",Xe=({checked:e,description:a,id:n,label:s,onChange:r})=>{const c=`${n}-label`;return t.jsxs("div",{className:"flex min-h-6 items-center gap-2",children:[t.jsx(dt,{id:n,size:"sm",checked:e,onChange:i=>r(i.target.checked),"aria-labelledby":c}),t.jsx("label",{id:c,htmlFor:n,className:"min-w-0 cursor-pointer",children:t.jsx(y,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"block",children:s})}),t.jsx(ma,{content:t.jsx("span",{className:"block max-w-[240px] leading-4",children:a}),side:"top",children:t.jsx("button",{type:"button",className:"focus-ring-soft inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-secondary","aria-label":`${s} help`,children:t.jsx(Ya,{className:"h-3.5 w-3.5"})})})]})};function Dn({isOpen:e,metadata:a,getHtml:n,getMarkdown:s,onClose:r}){const c=pe(),[i,d]=o.useState("html"),[l,m]=o.useState(!0),[p,g]=o.useState(!1),[v,h]=o.useState(!1),A=Tt(i,l),C=async()=>{h(!0);try{const k=await Tn({format:i,includeAssets:l,includeMetadata:p,metadata:a,source:{getHtml:n,getMarkdown:s}});if(k.type==="not-ready"){c(Mn(k.format));return}Rn(k.blob,k.filename),r(),c("Downloaded note.")}catch{c("Failed to download note.")}finally{h(!1)}};return t.jsxs(L,{isOpen:e,onClose:r,variant:"compact",children:[t.jsx(L.Header,{title:"Download document",onClose:r}),t.jsx(L.Body,{children:t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsxs("div",{className:"flex flex-col gap-3",role:"radiogroup","aria-label":"Format",children:[t.jsx(y,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Format"}),t.jsxs("div",{className:"flex flex-wrap gap-4",children:[t.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[t.jsx("input",{type:"radio",name:"note-export-format",value:"html",checked:i==="html",onChange:()=>d("html"),className:"h-4 w-4 accent-cta"}),t.jsx(y,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".html"})]}),t.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[t.jsx("input",{type:"radio",name:"note-export-format",value:"markdown",checked:i==="markdown",onChange:()=>d("markdown"),className:"h-4 w-4 accent-cta"}),t.jsx(y,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".md"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-3",role:"group","aria-label":"Options",children:[t.jsx(y,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Options"}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Xe,{id:"note-export-include-assets",label:"Include local image assets",checked:l,onChange:m,description:"Bundle uploaded Ocean Brain images with the document. Without assets, local images are omitted."}),t.jsx(Xe,{id:"note-export-include-metadata",label:"Include metadata",checked:p,onChange:g,description:"Add the note title, note id, timestamps, and Ocean Brain source information."})]})]})]})}),t.jsx(L.Footer,{children:t.jsxs(ue,{children:[t.jsx(S,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),t.jsx(S,{variant:"primary",size:"sm",onClick:C,disabled:v,children:v?"Downloading...":`Download .${A}`})]})})]})}const Mt=e=>e==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:e==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},Pn=({isDeleted:e,isConflict:a,source:n})=>{const s=Mt(n);return e?`This note was moved to trash ${s.place}`:a?`Save paused: note changed ${s.place}`:`This note changed ${s.place}`},On=({isDeleted:e,isConflict:a,hasDraft:n,source:s})=>{const r=Mt(s);return e?`${r.actor} moved this note to trash. Open trash to review or restore it.`:a&&n?`Your draft is saved locally. Reload the latest note, overwrite ${r.target}, or clone your draft into a new note.`:a?`The layout change is paused because the note changed ${r.place}. Reload the latest note or overwrite only the layout.`:`${r.actor} changed this note while it was open here. Reload the latest version before continuing.`};function Ln({isOpen:e,isDeleted:a,isConflict:n,hasDraft:s,source:r,isReloading:c,onReload:i,onOverwrite:d,onCloneDraft:l,onOpenTrash:m}){return t.jsxs(L,{isOpen:e,onClose:()=>{},variant:"inspect",children:[t.jsx(L.Header,{title:Pn({isDeleted:a,isConflict:n,source:r})}),t.jsx(L.Body,{children:t.jsx(y,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:On({isDeleted:a,isConflict:n,hasDraft:s,source:r})})}),t.jsx(L.Footer,{children:t.jsx(ue,{children:a?t.jsx(S,{type:"button",variant:"primary",size:"sm",onClick:m,children:"Open trash"}):n?t.jsxs(t.Fragment,{children:[t.jsx(S,{type:"button",variant:"subtle",size:"sm",isLoading:c,onClick:i,children:"Reload latest"}),s&&t.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"Clone draft"}),t.jsx(S,{type:"button",variant:"danger",size:"sm",onClick:d,children:"Overwrite"})]}):t.jsx(S,{type:"button",variant:"primary",size:"sm",isLoading:c,onClick:i,children:"Reload latest"})})})]})}const et=(e,a)=>e||(a==="mobile"?"Mobile browser":a==="mcp"?"MCP":"Web browser");function Bn({isOpen:e,noteId:a,onClose:n,onRestored:s}){const r=pe(),c=ve(),[i,d]=o.useState(null),[l,m]=o.useState("diff"),p=o.useRef(null),g=he({queryKey:T.notes.snapshots(a),queryFn:async()=>{const f=await ha(a);if(f.type==="error")throw f;return f.noteSnapshots},enabled:e}),v=xa({mutationFn:ga,onSuccess:async f=>{if(f.type==="error"){r(f.errors[0].message);return}await Promise.all([c.invalidateQueries({queryKey:T.notes.detail(a),exact:!0}),c.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.tagNameListAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.pinned(),exact:!0}),c.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:T.notes.graph(),exact:!0}),c.invalidateQueries({queryKey:T.notes.snapshots(a),exact:!1}),c.invalidateQueries({queryKey:T.views.sectionNotesAll(),exact:!1}),c.invalidateQueries({queryKey:T.tags.all(),exact:!1})]),r("Previous version restored."),s?.(f.restoreNoteSnapshot),d(null),n()}}),h=g.data?.find(f=>f.id===i)??null,A=he({queryKey:[...T.notes.snapshotDetail(i??"pending"),"diff"],queryFn:async()=>{if(!i)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await ya(i,"current");if(f.type==="error")throw f;if(!f.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return f.noteSnapshotDiff},enabled:!!i&&l==="diff"}),C=he({queryKey:T.notes.snapshotDetail(i??"pending"),queryFn:async()=>{if(!i)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await va(i);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!i&&l==="content"}),k=C.data?.contentAsMarkdown.trim()??"";o.useEffect(()=>{i&&p.current?.focus()},[i]);const _=(f,w)=>{m(w),d(f)},M=()=>{d(null),m("diff"),n()};return t.jsxs(L,{isOpen:e,onClose:M,variant:"inspect",children:[t.jsx(L.Header,{title:h?l==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:M}),t.jsx(L.Description,{className:"sr-only",children:h?l==="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."}),t.jsx(L.Body,{children:h?t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx(y,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:h.title}),t.jsxs(y,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",et(h.meta.label,h.meta.entrypoint)," ","edit - ",J(h.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(S,{variant:l==="diff"?"primary":"subtle",size:"sm",onClick:()=>m("diff"),children:"Show diff"}),t.jsx(S,{variant:l==="content"?"primary":"subtle",size:"sm",onClick:()=>m("content"),children:"View content"})]}),l==="diff"?A.isLoading?t.jsx(y,{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?t.jsx(y,{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?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(y,{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."}),t.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(`
|
|
12
|
-
`).map((f,w)=>{const b=f.startsWith("+")&&!f.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":f.startsWith("-")&&!f.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":f.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return t.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${b}`,children:f||" "},`${w}-${f}`)})})]}):null:C.isLoading?t.jsx(y,{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..."}):C.isError?t.jsx(y,{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."}):k?t.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:k}):t.jsx(y,{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."})]}):t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx(y,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),g.isLoading&&t.jsx(y,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!g.isLoading&&g.data?.length===0&&t.jsx(y,{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."}),!g.isLoading&&g.data&&g.data.length>0&&t.jsx("div",{className:"flex flex-col gap-2",children:g.data.map(f=>t.jsx(qa,{padding:"compact",children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs(y,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",et(f.meta.label,f.meta.entrypoint)," ","edit"]}),t.jsx(y,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),t.jsx(y,{as:"p",variant:"label",tone:"tertiary",children:J(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),t.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[t.jsx(S,{variant:"subtle",size:"sm",onClick:()=>_(f.id,"diff"),children:"Compare"}),t.jsx(S,{size:"sm",isLoading:v.isPending,onClick:()=>v.mutate(f.id),children:"Restore"})]})]}),f.contentPreview&&t.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:t.jsx(y,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]})},f.id))})]})}),h&&t.jsx(L.Footer,{children:t.jsxs(ue,{children:[t.jsx(S,{ref:p,variant:"subtle",onClick:()=>{d(null),m("diff")},children:"Back"}),t.jsx(S,{isLoading:v.isPending,onClick:()=>v.mutate(h.id),children:"Restore this version"})]})})]})}let Fn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",_n=(e=21)=>{let a="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)a+=Fn[n[e]&63];return a};const tt={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 In({isOpen:e,onClose:a,onSave:n,reminder:s,mode:r}){const[c,i]=o.useState(new Date),[d,l]=o.useState("medium"),[m,p]=o.useState("");o.useEffect(()=>{e&&r==="edit"&&s?(i(new Date(Number(s.reminderDate))),l(s.priority||"medium"),p(s.content||"")):e&&r==="create"&&(i(new Date),l("medium"),p(""))},[e,r,s]);const g=()=>{n(c,d,m||void 0),a()},v=h=>d===h?tt[h].active:tt[h].inactive;return t.jsxs(L,{isOpen:e,onClose:a,variant:"form",children:[t.jsx(L.Header,{title:r==="create"?"Create Reminder":"Edit Reminder",onClose:a}),t.jsx(L.Body,{children:t.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(ke,{children:"Date & Time"}),t.jsx(Le,{type:"datetime-local",size:"sm",value:J(c).format("YYYY-MM-DDTHH:mm"),onChange:h=>i(new Date(h.target.value))})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(ke,{children:"Content"}),t.jsx(ba,{size:"sm",placeholder:"Enter reminder content (optional)",value:m,onChange:h=>p(h.target.value)})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(ke,{children:"Priority"}),t.jsxs(wa,{type:"single",variant:"quiet",value:d,onValueChange:h=>h&&l(h),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[t.jsx(Ee,{value:"low",className:`flex-1 rounded-[10px] border ${v("low")}`,children:t.jsx(y,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),t.jsx(Ee,{value:"medium",className:`flex-1 rounded-[10px] border ${v("medium")}`,children:t.jsx(y,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),t.jsx(Ee,{value:"high",className:`flex-1 rounded-[10px] border ${v("high")}`,children:t.jsx(y,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),t.jsx(L.Footer,{children:t.jsxs(ue,{children:[t.jsx(S,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),t.jsx(S,{variant:"primary",size:"sm",onClick:g,children:r==="create"?"Create":"Save"})]})})]})}function $n({noteId:e}){const[a,n]=o.useState(!1),[s,r]=o.useState(!1),[c,i]=o.useState("create"),[d,l]=o.useState(void 0),{onCreate:m,onUpdate:p,onDelete:g}=Ga(),v=()=>{i("create"),l(void 0),r(!0)},h=f=>{i("edit"),l(f),r(!0)},A=(f,w,b)=>{c==="create"?m(e,f,w,()=>{r(!1)},b):c==="edit"&&d&&p(d.id,e,{reminderDate:f,priority:w,content:b},()=>{r(!1)})},C=f=>{p(f.id,e,{completed:!f.completed})},k=f=>{const w=J(Number(f)),b=J();return w.isSame(b,"day")?`Today at ${w.format("HH:mm")}`:w.isSame(b.add(1,"day"),"day")?`Tomorrow at ${w.format("HH:mm")}`:w.format("YYYY-MM-DD HH:mm")},_=f=>{const w=J(Number(f)),b=J(),$=w.diff(b,"hour");return $<=6?"high":$<=24?"medium":"low"},M=f=>{const w=J(Number(f)),b=J(),$=w.diff(b,"hour"),H=w.diff(b,"minute")%60;return $<0||H<0?"Overdue":$===0?`${H}m remaining`:`${$}h ${H}m remaining`};return t.jsxs(t.Fragment,{children:[t.jsx(Ve,{title:"Reminders",icon:t.jsx(Ca,{className:"h-3.5 w-3.5"}),action:t.jsxs(t.Fragment,{children:[!a&&t.jsxs(S,{size:"sm",variant:"ghost",onClick:v,children:[t.jsx($e,{className:"w-3 h-3"}),t.jsx(y,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),t.jsxs(S,{type:"button",size:"sm",variant:"ghost","aria-label":a?"Expand reminders":"Collapse reminders","aria-expanded":!a,onClick:()=>n(!a),children:[a?t.jsx(ja,{className:"h-3.5 w-3.5"}):t.jsx(Na,{className:"h-3.5 w-3.5"}),a?"Expand":"Collapse"]})]}),children:!a&&t.jsx(Wa,{noteId:e,searchParams:{offset:0,limit:9999},render:({reminders:f,totalCount:w})=>t.jsx("div",{className:"flex flex-col gap-2",children:f.length===0?t.jsx(y,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:w===0?"No reminders yet":"All reminders complete"}):t.jsx("div",{className:"flex flex-col",children:f.map(b=>{const $=b.priority||_(b.reminderDate),H=M(b.reminderDate),B=H==="Overdue";return t.jsxs("div",{className:Y("flex items-center gap-2.5 px-2 py-1.5"),children:[t.jsx(dt,{checked:b.completed,onChange:()=>C(b),size:"sm","aria-label":`Reminder: ${b.content||k(b.reminderDate)}`}),t.jsx(y,{as:"div",variant:"body",weight:"medium",className:Y("truncate flex-1 min-w-0",b.completed&&"line-through opacity-40"),children:b.content||k(b.reminderDate)}),t.jsxs("div",{className:Y("shrink-0 flex items-center gap-1",b.completed&&"opacity-40"),children:[b.content&&t.jsx(y,{as:"span",variant:"meta",tone:"secondary",children:k(b.reminderDate)}),!b.completed&&t.jsx(y,{as:"span",variant:"label",weight:"medium",tone:B||$==="high"?"error":"tertiary",className:Y(b.content&&'before:content-["·"] before:mr-1'),children:H})]}),t.jsx(ut,{button:t.jsx(pt,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>h(b)},{name:"Delete",onClick:()=>g(b.id,e)}]})]},b.id)})})})})}),t.jsx(In,{isOpen:s,onClose:()=>r(!1),onSave:A,reminder:d,mode:c})]})}const Un=({editor:e})=>t.jsx(Ue,{triggerCharacter:"/",getItems:async a=>Xa([...ia(e).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:()=>{e.insertBlocks([{type:"tableOfContents"}],e.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:t.jsx(ft,{})}],a)}),Hn=(e,a)=>a?e.filter(n=>n.id!==a):e,Vn=({currentNoteId:e,onClick:a})=>t.jsx(Ue,{triggerCharacter:"[",getItems:async n=>{const s=await Aa({query:n,limit:5});return s.type==="error"?[]:Hn(s.allNotes.notes,e).map(c=>({title:c.title,onItemClick:()=>a({type:"reference",props:{id:c.id,title:c.title}})}))}}),Dt=["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/avif"],zn=new Set(Dt),at="Unsupported image type. Use PNG, JPEG, GIF, WebP, BMP, or AVIF.",Kn="Failed to upload image.",Zn=e=>zn.has(e),Yn="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",Qn={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"},qn={idle:"Copy",copied:"Copied",failed:"Copy failed"},Gn=({getText:e,resetDelayMs:a=2e3})=>{const[n,s]=o.useState("idle"),r=o.useRef(null),c=o.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),i=o.useCallback(()=>{c(),r.current=setTimeout(()=>{s("idle"),r.current=null},a)},[c,a]);o.useEffect(()=>c,[c]);const d=p=>{p.stopPropagation()},l=p=>{p.preventDefault(),p.stopPropagation()},m=async p=>{d(p);try{await navigator.clipboard.writeText(e()),s("copied")}catch{s("failed")}i()};return t.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:l,children:t.jsxs("button",{type:"button",className:Y(Yn,Qn[n]),contentEditable:!1,onClick:m,children:[t.jsx(an,{className:"h-3.5 w-3.5"}),t.jsx("span",{"aria-live":"polite",children:qn[n]})]})})},Wn=({contentRef:e})=>{const a=o.useRef(null),n=o.useCallback(s=>{a.current=s,e(s)},[e]);return t.jsxs(t.Fragment,{children:[t.jsx("pre",{children:t.jsx("code",{ref:n})}),t.jsx(Gn,{getText:()=>a.current?.textContent?.trimEnd()??""})]})},Jn="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-[color-mix(in_srgb,var(--elevated)_72%,var(--hover-subtle))] px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-elevated hover:text-fg-default dark:bg-[color-mix(in_srgb,var(--elevated)_82%,var(--hover-subtle))]",Xn={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function er(e){const a=mt(),n=()=>{e.editor.blur(),a({to:ge,params:{id:e.inlineContent.props.id}})},s=r=>{r.preventDefault(),r.stopPropagation()};return t.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Jn,onMouseDown:s,onClick:r=>{s(r),n()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),n())},children:t.jsxs("span",{children:["[",e.inlineContent.props.title,"]"]})})}const tr=st(Xn,{render:e=>t.jsx(er,{...e})}),ar=()=>{const e=ca(),[a,n]=o.useState([]),s={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};o.useEffect(()=>{const i=()=>{const l=e.document,m=[],p=g=>{for(const v of g){if(v.type==="heading"){const h=v,A=h.props.level||1,C=h.content?.map(k=>k.text||"").join("")||"";C.trim()&&m.push({id:v.id,level:A,text:C})}v.children&&Array.isArray(v.children)&&p(v.children)}};p(l),n(m)};i();const d=e.onChange?.(i);return()=>{d&&d()}},[e]);const r=i=>{e.setTextCursorPosition(i);const d=document.querySelector(`[data-id="${i}"]`);if(d){const l=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;d.scrollIntoView({behavior:l?"auto":"smooth",block:"center"})}},c=t.jsx(yt,{icon:t.jsx(ft,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return a.length===0?t.jsxs("div",{className:"surface-base w-full p-4",children:[c,t.jsx(y,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):t.jsxs("div",{className:"surface-base w-full p-4",children:[t.jsx("div",{className:"mb-2",children:c}),t.jsx("nav",{className:"space-y-0.5",children:a.map(i=>{const d=i.level===1;return t.jsxs("button",{type:"button",onClick:()=>r(i.id),className:Y("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",s[i.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",d?"text-fg-default":"text-fg-secondary"),children:[t.jsxs(y,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",i.level]}),t.jsx(y,{as:"span",variant:"body",weight:d?"semibold":"medium",className:"line-clamp-2 text-current",children:i.text})]},i.id)})})]})},nr=ot({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>t.jsx(ar,{})})(),rr="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-emphasis px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover-subtle hover:text-fg-default dark:bg-emphasis",sr={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function or(e){const a=mt(),n=()=>{e.editor.blur(),a({to:Sa,params:{id:e.inlineContent.props.id},search:{page:1}})},s=r=>{r.preventDefault(),r.stopPropagation()};return t.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:rr,onMouseDown:s,onClick:r=>{s(r),n()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),n())},children:t.jsx("span",{children:e.inlineContent.props.tag})})}const lr=st(sr,{render:e=>t.jsx(or,{...e})}),ir=e=>e,cr=e=>e,dr=ir({tag:lr,reference:tr}),ur=cr({tableOfContents:nr}),re=ce.codeBlock,nt=ot(re.config,{meta:re.implementation.meta,parse:re.implementation.parse,parseContent:re.implementation.parseContent,runsBefore:re.implementation.runsBefore,render:Wn})(),pr={...nt,extensions:re.extensions,implementation:{...nt.implementation,toExternalHTML:re.implementation.toExternalHTML}},fr={...ce.image,implementation:{...ce.image.implementation,meta:{...ce.image.implementation.meta,fileBlockAccept:[...Dt]}}},mr=en.create({inlineContentSpecs:{...tn,...dr},blockSpecs:{...ce,image:fr,codeBlock:pr,...ur}}),hr=(e,a)=>a.some(n=>n.name===`@${e}`),xr=({onClick:e})=>t.jsx(Ue,{triggerCharacter:"@",getItems:async a=>{const n=await nn({query:a,limit:5});if(n.type==="error")return[];const{tags:s}=n.allTags,r=hr(a,s),c=[{title:"Add a new tag",onItemClick:async()=>{const i=await rn({name:"@"+a});if(i.type==="error")return;const{id:d,name:l}=i.createTag;e({type:"tag",props:{id:d,tag:l}})}}];return s.length===0?c:s.map(i=>({title:i.name,onItemClick:()=>e({type:"tag",props:{id:i.id,tag:i.name}})})).concat(a&&!r?c:[])}}),gr=new Set(["tableOfContents"]),yr="OCEAN_BRAIN_TAG_",vr="_TOKEN",br=e=>`${yr}${e}${vr}`,wr=e=>!Array.isArray(e)&&e?.type==="tableContent",jr=(e,a)=>Array.isArray(e)?e.map(a):wr(e)?{...e,rows:e.rows?.map(n=>({...n,cells:n.cells?.map(s=>({...s,content:s.content?.map(a)}))}))}:e,Pt=(e,a)=>e.filter(n=>!gr.has(n.type)).map(n=>({...n,content:a(n.content),children:n.children?.length?Pt(n.children,a):[]}));function Nr(e){const a=new Map;let n=0;return{blocks:Pt(e,r=>jr(r,c=>{if(c.type==="reference"){const i=String(c.props?.id||""),d=String(c.props?.title||c.props?.id||"");return{type:"text",text:i?`[[${d}]](note:${i})`:`[[${d}]]`,styles:{}}}if(c.type==="tag"){const i=c.props?.tag||"",d=br(n);return n+=1,a.set(d,i),{type:"text",text:d,styles:{}}}return c})),placeholderToTag:a}}function Cr(e,a){let n=e;for(const[s,r]of a.entries())n=n.split(s).join(`[${r}]`);return n}async function Ar(e){return new Promise((a,n)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>a(s.result),s.onerror=r=>n(r)})}const Sr=o.forwardRef(({content:e,currentNoteId:a,editable:n,onChange:s},r)=>{const{theme:c}=ka(l=>l),i=pe(),d=da({schema:mr,initialContent:e&&JSON.parse(e)||void 0,uploadFile:async(l,m)=>{const p=()=>{m&&d.getBlock(m)&&d.removeBlocks([m])};if(!Zn(l.type))throw p(),i(at),new Error(at);try{return await Ja({base64:await Ar(l)})}catch(g){throw p(),i(Kn),g}}},[i]);return o.useImperativeHandle(r,()=>({getContent:()=>JSON.stringify(d.document),getMarkdown:()=>{const l=Nr(d.document),m=d.blocksToMarkdownLossy(l.blocks);return Cr(m,l.placeholderToTag)},getHtml:()=>d.blocksToHTMLLossy(d.document)})),t.jsxs(ua,{slashMenu:!1,theme:c,editor:d,editable:n,onChange:s,children:[t.jsx(Un,{editor:d}),t.jsx(Vn,{currentNoteId:a,onClick:l=>{d.insertInlineContent([l," "])}}),t.jsx(xr,{onClick:l=>{d.insertInlineContent([l," "])}})]})}),Ke=e=>`ocean-brain.note-draft.${e}`,kr=e=>{if(typeof window>"u")return null;try{const a=window.localStorage.getItem(Ke(e));if(!a)return null;const n=JSON.parse(a);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}},Te=(e,a)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ke(e),JSON.stringify(a))}catch{}},Me=e=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Ke(e))}catch{}},Er=1e3,Rr="NOTE_UPDATE_CONFLICT";function Tr({noteId:e,initialContent:a,initialUpdatedAt:n,editSessionIdRef:s,getContent:r,onSaved:c,onConflict:i,onError:d}){const l=ve(),m=o.useRef(null),p=o.useRef(null),g=o.useRef(!1),v=o.useRef(null),h=o.useRef(!1),A=o.useRef(n),C=o.useRef(!1),k=o.useRef(!0),_=o.useRef(c),M=o.useRef(i),f=o.useRef(d),[w,b]=o.useState("saved"),[$,H]=o.useState(null),B=o.useCallback(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),U=o.useCallback(E=>{k.current&&b(E)},[]),se=o.useCallback(E=>{A.current=E},[]),V=o.useCallback((E,P={})=>({title:E,content:r()??a,createdAt:Date.now(),baseUpdatedAt:A.current,...P.layout?{layout:P.layout}:{}}),[r,a]),I=o.useCallback(()=>{p.current&&Te(e,p.current)},[e]),X=o.useCallback(E=>{C.current=!0,U("conflict"),M.current(E??A.current)},[U]),z=o.useCallback(async({ignoreConflict:E=!1,silent:P=!1}={})=>{if(g.current)return h.current=!0,v.current??"idle";const K=p.current;if(!K)return h.current=!1,"idle";p.current=null,h.current=!1,B(),g.current=!0,P||U("saving");const N=(async()=>{let F;try{F=await Be({id:e,title:K.title,content:K.content,...K.layout?{layout:K.layout}:{},editSessionId:s.current,...E?{force:!0}:{expectedUpdatedAt:K.baseUpdatedAt}})}catch{F={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(g.current=!1,v.current=null,F.type==="error"){p.current||(p.current=K),I();const W=F.errors[0];if(W.code===Rr&&!E){const oe=W.details?.extensions?.currentUpdatedAt;return C.current=!0,!P&&k.current&&(U("conflict"),M.current(oe??A.current)),"conflict"}return!P&&k.current&&(U("error"),f.current(W.message)),"error"}C.current=!1,A.current=F.updateNote.updatedAt;const G=!P&&k.current,te=T.notes.detail(e);await l.cancelQueries({queryKey:te,exact:!0}),G&&_.current(F.updateNote.updatedAt),l.setQueryData(te,W=>W&&{...W,title:F.updateNote.title,content:K.content,...K.layout?{layout:K.layout}:{},updatedAt:F.updateNote.updatedAt}),xe({noteId:e,updatedAt:F.updateNote.updatedAt,editSessionId:s.current});const ae=p.current;return ae?.baseUpdatedAt===K.baseUpdatedAt?(p.current={...ae,baseUpdatedAt:F.updateNote.updatedAt},I()):ae||Me(e),G&&(p.current?b("pending"):(b("saved"),l.invalidateQueries({queryKey:T.notes.listAll(),exact:!1}),l.invalidateQueries({queryKey:T.notes.tagListAll(),exact:!1}),l.invalidateQueries({queryKey:T.notes.backReferencesAll(),exact:!1}),l.invalidateQueries({queryKey:T.notes.graph(),exact:!0}))),p.current||h.current?z({silent:P}):"saved"})();return v.current=N,N},[B,s,e,I,l,U]),x=o.useCallback((E,P={})=>{if(p.current=E,Te(e,E),C.current){U("conflict");return}if(U("pending"),B(),P.immediate){z();return}m.current=window.setTimeout(()=>{z()},Er)},[B,z,e,U]),R=o.useCallback(E=>{if(p.current=E,Te(e,E),H(null),E.baseUpdatedAt!==A.current){X(A.current);return}x(E)},[e,x,X]),O=o.useCallback(()=>{B(),p.current=null,v.current=null,h.current=!1,C.current=!1,Me(e),H(null),b("saved")},[B,e]),D=o.useCallback(()=>{B(),v.current=null,h.current=!1,C.current=!1,U(p.current?"pending":"saved")},[B,U]),Q=o.useCallback(()=>{Me(e),H(null)},[e]),fe=o.useCallback(()=>p.current,[]),q=o.useCallback(E=>{B(),X(E)},[B,X]);return o.useEffect(()=>{M.current=i,f.current=d,_.current=c},[i,d,c]),o.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]),o.useEffect(()=>{p.current||g.current||C.current||(A.current=n,b("saved"))},[n]),o.useEffect(()=>{p.current=null,g.current=!1,v.current=null,h.current=!1,C.current=!1,A.current=n,H(kr(e)),b("saved")},[e]),o.useEffect(()=>{const E=P=>{!p.current&&!g.current&&!C.current||(P.preventDefault(),P.returnValue="")};return window.addEventListener("beforeunload",E),()=>{window.removeEventListener("beforeunload",E)}},[]),o.useEffect(()=>()=>{B(),p.current&&!C.current&&z({silent:!0})},[B,z]),{saveStatus:w,localDraft:$,serverUpdatedAtRef:A,hasUnsavedChanges:w!=="saved",buildDraft:V,queueSave:x,flushPendingSave:z,restoreLocalDraft:R,discardLocalDraft:Q,clearDrafts:O,resolveConflict:D,pauseForConflict:q,getPendingDraft:fe,setServerUpdatedAt:se}}const Ot=Pa(ge),de=e=>{const a=/^\d+$/.test(e)?Number(e):Date.parse(e);return Number.isFinite(a)?a:null},De=e=>{const a=de(e);return J(a??Number(e)).format("YYYY-MM-DD HH:mm:ss")},Mr=(e,a)=>Oa(de(e),a),Pe=()=>_n(),Dr="NOTE_UPDATE_CONFLICT",Pr=2200,Or=e=>e?.extensions?.currentUpdatedAt,rt=(e,a)=>{const n=de(e),s=de(a);return n===null||s===null?e===a?0:1:n-s},Lr=e=>{const a=e.trim();if(!a)return null;try{const n=new URL(a);return n.protocol==="http:"||n.protocol==="https:"?n.toString():null}catch{return null}},Br={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},Fr=t.jsx(He,{title:"Loading note",variant:"none",children:t.jsxs("main",{className:"mx-auto max-w-[896px]",children:[t.jsx(ne,{className:"mb-8",height:123}),t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsx(ne,{height:135}),t.jsx(ne,{className:"ml-12",height:320}),t.jsx(ne,{height:107}),t.jsx(ne,{height:100})]})]})}),_r=e=>({id:e?.key??"",key:e?.key??"",name:e?.name??"",value:e?.value??"",valueType:e?.valueType??"text",persistedKey:e?.key}),Ir=e=>{if(Array.isArray(e))return e;const a=e?.keys;return Array.isArray(a)?a:[]},Oe=(e=[])=>e.map(_r),Lt=(e,a)=>{const n=[],s=new Set(a);for(const r of e){const c=r.key.trim();if(!c)continue;const i=r.value.trim(),d=!!r.persistedKey&&(r.valueType==="number"||r.valueType==="date"||r.valueType==="select"||r.valueType==="url");if(!i&&d){s.add(r.persistedKey);continue}!i&&r.valueType!=="text"&&r.valueType!=="boolean"||n.push({key:c,name:r.name.trim()||c,value:r.valueType==="boolean"?i||"false":i,valueType:r.valueType})}return{set:n.sort((r,c)=>r.key.localeCompare(c.key)),deleteKeys:Array.from(s).sort()}},le=(e,a=[])=>JSON.stringify(Lt(e,a)),$r=({noteId:e,properties:a=[],expectedUpdatedAt:n,editSessionId:s,disabled:r,onSaved:c})=>{const i=pe(),d=ve(),[l,m]=o.useState(()=>Oe(a)),[p,g]=o.useState([]),[v,h]=o.useState("idle"),A=o.useRef(l),C=o.useRef(p),k=o.useRef(n),_=o.useRef(le(l)),M=o.useRef(null),f=o.useRef(!1),w=o.useRef(!1),b=he({queryKey:T.notes.propertyKeys({limit:50}),queryFn:async()=>{const x=await Ba({limit:50});if(x.type==="error")throw x;return x.notePropertyKeys.keys}});o.useEffect(()=>{const x=Oe(a);m(x),g([]),_.current=le(x),h("idle")},[a]),o.useEffect(()=>{A.current=l},[l]),o.useEffect(()=>{C.current=p},[p]),o.useEffect(()=>{k.current=n},[n]);const $=Ir(b.data),H=$.filter(x=>!l.some(R=>R.key===x.key)),B=$.length>0,U=o.useCallback(async()=>{const x=le(A.current,C.current);if(r||x===_.current)return;if(f.current){w.current=!0;return}const R=Lt(A.current,C.current);if(!(R.set.length===0&&R.deleteKeys.length===0)){f.current=!0,w.current=!1,h("saving");try{const O=await Fa({id:e,set:R.set,deleteKeys:R.deleteKeys,editSessionId:s,expectedUpdatedAt:k.current});if(O.type==="error"){h("error"),i(O.errors[0]?.message??"Failed to save properties.");return}k.current=O.updateNoteProperties.updatedAt,_.current=le(Oe(O.updateNoteProperties.properties??[])),c(O.updateNoteProperties),d.invalidateQueries({queryKey:T.notes.propertyKeysAll(),exact:!1}),h("saved")}catch{h("error"),i("Failed to save properties.")}finally{f.current=!1,w.current&&(w.current=!1,U())}}},[r,s,e,c,d,i]);o.useEffect(()=>{if(M.current&&clearTimeout(M.current),!(r||le(l,p)===_.current))return M.current=setTimeout(()=>{U()},500),()=>{M.current&&clearTimeout(M.current)}},[p,r,l,U]);const se=x=>{m(R=>[...R,{id:x.key,key:x.key,name:x.name,value:"",valueType:x.valueType,persistedKey:void 0}]),g(R=>R.filter(O=>O!==x.key))},V=(x,R)=>{m(O=>O.map(D=>D.id===x?{...D,...R}:D))},I=x=>{x.persistedKey&&g(R=>[...new Set([...R,x.persistedKey])]),m(R=>R.filter(O=>O.id!==x.id))},X=le(l,p)!==_.current,z=r||!X&&v==="idle"?null:v==="saving"?"Saving...":v==="error"?"Save failed":X?"Waiting...":"Saved";return t.jsxs(Ve,{title:"Properties",icon:t.jsx(Za,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:t.jsxs(t.Fragment,{children:[z&&t.jsx(y,{as:"span",variant:"micro",tone:v==="error"?"error":"tertiary",className:"px-1",children:z}),B&&t.jsx(S,{asChild:!0,size:"sm",variant:"ghost",children:t.jsxs(Ie,{to:We,search:{page:1},children:[t.jsx(Ka,{className:"h-3 w-3"}),"Manage"]})})]}),children:[l.length===0?t.jsx(y,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):t.jsx("div",{className:"divide-y divide-border-subtle",children:l.map(x=>{const R=`note-property-${x.id}-label`,O=x.valueType==="url"?Lr(x.value):null;return t.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[t.jsx(y,{id:R,as:"span",variant:"label",tone:"secondary",className:"truncate",children:x.name}),t.jsx(y,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:x.key})]}),x.valueType==="boolean"?t.jsxs(Ge,{size:"sm",variant:"ghost",value:x.value||"false",disabled:r,"aria-labelledby":R,onValueChange:D=>V(x.id,{value:D}),children:[t.jsx(Re,{value:"false",children:"False"}),t.jsx(Re,{value:"true",children:"True"})]}):x.valueType==="select"?t.jsx(Ge,{size:"sm",variant:"ghost",value:x.value,placeholder:"Select option",disabled:r,"aria-labelledby":R,onValueChange:D=>V(x.id,{value:D}),children:($.find(D=>D.key===x.key)?.options??[]).map(D=>t.jsx(Re,{value:D.value,children:D.label},D.id))}):x.valueType==="url"?t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx(Le,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:x.value,disabled:r,onChange:D=>V(x.id,{value:D.target.value})}),O?t.jsx(S,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${x.name}`,className:"shrink-0 text-fg-tertiary",children:t.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",title:O,children:t.jsx(gt,{className:"h-4 w-4"})})}):null]}):t.jsx(Le,{size:"sm",variant:"ghost",type:x.valueType==="date"?"date":x.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:x.value,disabled:r,onChange:D=>V(x.id,{value:D.target.value})}),t.jsx(S,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${x.name}`,disabled:r,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>I(x),children:t.jsx(_a,{className:"h-4 w-4"})})]},x.id)})}),t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:b.isLoading?t.jsx(S,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):H.length>0?t.jsxs(Ia,{children:[t.jsx($a,{asChild:!0,children:t.jsxs(S,{type:"button",size:"sm",variant:"ghost",disabled:r,children:[t.jsx($e,{className:"h-4 w-4"}),"Add property"]})}),t.jsxs(Ua,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[t.jsx(Ha,{children:t.jsx(y,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),t.jsx(Va,{}),H.map(x=>t.jsxs(za,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>se(x),children:[t.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[t.jsx(y,{as:"span",variant:"label",weight:"medium",className:"truncate",children:x.name}),t.jsx(y,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:x.valueType})]}),t.jsx(y,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:x.key})]},x.key))]})]}):B?t.jsx(y,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):t.jsxs(Ie,{to:We,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:[t.jsx($e,{className:"h-4 w-4"}),"Create property definition"]})})]})};function Ur({id:e}){const a=pe(),n=Ot.useNavigate(),s=ve(),r=o.useRef(null),c=o.useRef(null),i=o.useRef(Pe()),d=it({queryKey:T.notes.detail(e),queryFn:async()=>{const u=await Ea(e);if(u.type==="error")throw u;return u.note},gcTime:0}),l=d.data,[m,p]=o.useState(l.title),[g,v]=o.useState(()=>De(l.updatedAt)),[h,A]=o.useState(l.updatedAt),[C,k]=o.useState(()=>Date.now()),[_,M]=o.useState(l.pinned),[f,w]=o.useState(l.layout||"wide"),[b,$]=o.useState(!1),[H,B]=o.useState(!1),[U,se]=o.useState(!1),[V,I]=o.useState(null),[X,z]=o.useState(null),[x,R]=o.useState(0),[O,D]=o.useState(!1),Q=o.useRef(l.updatedAt),fe=o.useRef(e),q=o.useRef(null),E=o.useRef(!1),P=o.useCallback(u=>{v(De(u)),A(u),k(Date.now())},[]),K=Tr({noteId:e,initialContent:l.content,initialUpdatedAt:l.updatedAt,editSessionIdRef:i,getContent:()=>r.current?.getContent(),onSaved:u=>{q.current=null,Q.current=u,P(u),D(!0)},onConflict:u=>{I({type:"updated",updatedAt:u,source:"unknown"}),a("This note changed elsewhere. Choose how to resolve the draft.")},onError:a}),{saveStatus:N,localDraft:F,serverUpdatedAtRef:G,hasUnsavedChanges:te,buildDraft:ae,queueSave:W,flushPendingSave:oe,restoreLocalDraft:Bt,discardLocalDraft:Ft,clearDrafts:we,resolveConflict:_t,pauseForConflict:ie,getPendingDraft:je,setServerUpdatedAt:ee}=K,It=o.useCallback(async()=>{if(E.current)return E.current=!1,!1;if(N==="conflict")return a("Resolve the note conflict before leaving."),!0;const u=await oe();return u==="error"?(a("Save failed. Stay on this note and try again."),!0):u==="conflict"},[oe,N,a]);on({disabled:N==="saved",enableBeforeUnload:!1,shouldBlockFn:It}),o.useEffect(()=>{if(te){l.updatedAt!==G.current&&rt(l.updatedAt,G.current)>0&&ie(l.updatedAt);return}const u=Q.current;if(!(l.updatedAt!==u&&rt(l.updatedAt,u)<0)&&(M(l.pinned),w(l.layout||"wide"),ee(l.updatedAt),p(l.title),P(l.updatedAt),u!==l.updatedAt)){const j=r.current?.getContent();Q.current=l.updatedAt,(j===void 0||j!==l.content)&&(z(null),R(Z=>Z+1))}},[te,l.layout,l.pinned,l.title,l.updatedAt,ie,G,ee,P]),o.useEffect(()=>{fe.current!==e&&(fe.current=e,i.current=Pe(),Q.current=l.updatedAt,q.current=null,I(null),z(null),R(u=>u+1),D(!1))},[e,l.updatedAt]),o.useEffect(()=>{if(N!=="saved")return;const u=window.setTimeout(()=>{k(Date.now())},Ra(de(h),C));return()=>window.clearTimeout(u)},[h,C,N]),o.useEffect(()=>{if(!O)return;const u=window.setTimeout(()=>{D(!1)},Pr);return()=>window.clearTimeout(u)},[O]),o.useEffect(()=>{V?.type!=="updated"||N==="conflict"||V.updatedAt!==l.updatedAt||(Q.current=l.updatedAt,ee(l.updatedAt),P(l.updatedAt),I(null))},[V,l.updatedAt,N,ee,P]),o.useEffect(()=>Ta(u=>{if(u.noteId===e&&!(u.source==="web"&&u.editSessionId===i.current)){if(u.type==="mcp.note.updated"||u.type==="web.note.updated"){if(u.updatedAt===l.updatedAt||u.updatedAt===G.current)return;if(te){ie(u.updatedAt),I({type:"updated",updatedAt:u.updatedAt,source:u.source});return}I({type:"updated",updatedAt:u.updatedAt,source:u.source});return}u.type==="mcp.note.deleted"&&I({type:"deleted",source:u.source})}}),[te,e,l.updatedAt,ie,G]);const{onCreate:$t,onDelete:Ut,onPinned:Ht,deleteWarningDialog:Vt}=Ma(),zt=()=>{W(ae(m))},Kt=u=>{p(u),W(ae(u))},Ze=()=>{W(ae(m),{immediate:!0})},Zt=async u=>{if(te){w(u),W(ae(m,{layout:u}),{immediate:!0}),a("Layout will be saved with your draft.");return}const j=await Be({id:e,layout:u,editSessionId:i.current,expectedUpdatedAt:G.current});if(j.type==="error"){j.errors[0].code===Dr&&(q.current=u,w(u),ie(Or(j.errors[0].details)??G.current)),a(j.errors[0].message);return}q.current=null,await s.cancelQueries({queryKey:T.notes.detail(e),exact:!0}),Q.current=j.updateNote.updatedAt,ee(j.updateNote.updatedAt),s.setQueryData(T.notes.detail(e),Z=>Z&&{...Z,layout:u,updatedAt:j.updateNote.updatedAt}),xe({noteId:e,updatedAt:j.updateNote.updatedAt,editSessionId:i.current}),P(j.updateNote.updatedAt),w(u),a("Layout has been updated.")},Yt=()=>({id:e,title:m,createdAt:l.createdAt,updatedAt:G.current||l.updatedAt}),Qt=async()=>{const u=r.current?.getMarkdown();if(u===void 0){a("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(u),a("Copied note as Markdown.")}catch{a("Failed to copy Markdown.")}},qt=async()=>{const u=await d.refetch();if(u.error||!u.data){a("Failed to reload the latest note state.");return}we(),q.current=null,Q.current=u.data.updatedAt,ee(u.data.updatedAt),p(u.data.title),w(u.data.layout||"wide"),P(u.data.updatedAt),z(null),R(j=>j+1),I(null)},Gt=async()=>{if(je()){q.current=null,I(null),await oe({ignoreConflict:!0});return}const j=q.current;if(j){const Z=await Be({id:e,layout:j,editSessionId:i.current,force:!0});if(Z.type==="error"){a(Z.errors[0].message);return}q.current=null,await s.cancelQueries({queryKey:T.notes.detail(e),exact:!0}),Q.current=Z.updateNote.updatedAt,_t(),I(null),ee(Z.updateNote.updatedAt),s.setQueryData(T.notes.detail(e),Se=>Se&&{...Se,layout:j,updatedAt:Z.updateNote.updatedAt}),xe({noteId:e,updatedAt:Z.updateNote.updatedAt,editSessionId:i.current}),P(Z.updateNote.updatedAt),w(j);return}I(null),await oe({ignoreConflict:!0})},Ye=async()=>{const u=je();if(!u)return;const j=await La({title:qe(u.title||"untitled"),content:qe(u.content),layout:u.layout??f});if(j.type==="error"){a(j.errors[0].message);return}E.current=!0,q.current=null,I(null),we(),Promise.resolve(n({to:ge,params:{id:j.createNote.id}})).finally(()=>{E.current=!1})},Wt=()=>{F&&(p(F.title),F.layout&&w(F.layout),z(F.content),R(u=>u+1),Bt(F))},Jt=()=>{Ft()},Xt=F?J(F.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Ne=N==="saved"&&O,ea=Mr(h,C),ta=De(l.createdAt),aa=N==="pending"?"Saving...":N==="saving"?"Saving now...":N==="error"?"Save failed. Try again.":N==="conflict"?"Save paused: changed elsewhere":`Saved ${ea}`,na=Y("inline-flex items-center gap-2 transition-colors",N==="saved"&&!Ne&&"text-fg-secondary",Ne&&"text-accent-success",(N==="pending"||N==="saving")&&"text-fg-default",(N==="error"||N==="conflict")&&"text-fg-error"),Ce=Y("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"&&Ne&&"save-progress-ring-complete",(N==="error"||N==="conflict")&&"save-progress-ring-error"),ra=N==="saving"?t.jsx("span",{className:Ce,"aria-hidden":!0,children:t.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="pending"?t.jsx("span",{className:Ce,"aria-hidden":!0,children:t.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):N==="error"||N==="conflict"?t.jsx(Qa,{className:"h-3.5 w-3.5",weight:"fill"}):t.jsx("span",{className:Ce,"aria-hidden":!0,children:t.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),sa=t.jsxs(y,{as:"span",variant:"label",weight:"medium",className:na,role:"status","aria-live":"polite",title:g,children:[ra,aa]}),Ae=N==="conflict"&&V?.type==="updated",oa=Ae?je():null,la=V!==null&&!(V.type==="updated"&&!Ae&&V.updatedAt===l.updatedAt);return t.jsx(He,{title:m,variant:"none",children:t.jsxs("main",{className:Y("mx-auto",Br[f]),children:[t.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:t.jsxs("div",{className:"flex flex-col gap-3.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-5",children:[t.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[t.jsx(y,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),t.jsx("input",{ref:c,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:m,onChange:u=>Kt(u.target.value)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(ut,{button:t.jsx(pt,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:Qt},{name:"Download document",onClick:()=>se(!0)},{type:"separator",key:"export-separator"},{name:_?"Unpin":"Pin",onClick:()=>Ht(e,_,()=>{M(u=>!u)})},{name:"Change layout",onClick:()=>$(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>$t(c.current?.value||"untitled",r.current?.getContent()||"",f)},{name:"Restore previous version",onClick:()=>B(!0)},{type:"separator"},{name:"Delete",onClick:()=>Ut(e,()=>{n({to:Qe,search:{page:1}})})}]}),t.jsx(S,{size:"sm",variant:"subtle",isLoading:N==="saving",disabled:N==="conflict",onClick:Ze,children:"Save"})]})]}),t.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:[_&&t.jsxs(y,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[t.jsx(Da,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),_&&t.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),sa,t.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),t.jsxs(y,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",ta]})]})]})}),F&&t.jsx(Je,{tone:"danger",className:"mb-6",children:t.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("span",{children:["A draft from ",Xt," is saved only in this browser."]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Wt,children:"Restore draft"}),t.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:Jt,children:"Discard"})]})]})}),N==="error"&&t.jsx(Je,{tone:"danger",className:"mb-6",children:t.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Ze,children:"Retry save"}),t.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{Ye()},children:"Save as new note"})]})]})}),t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsx($r,{noteId:e,properties:l.properties,expectedUpdatedAt:G.current,editSessionId:i.current,disabled:N!=="saved",onSaved:u=>{Q.current=u.updatedAt,ee(u.updatedAt),P(u.updatedAt),D(!0),s.setQueryData(T.notes.detail(e),j=>j&&{...j,updatedAt:u.updatedAt,properties:u.properties}),xe({noteId:e,updatedAt:u.updatedAt,editSessionId:i.current})}}),t.jsx(Sr,{ref:r,content:X??l.content,currentNoteId:e,onChange:zt},`${e}:${x}`),t.jsx(Fe,{fallback:t.jsx(ne,{height:107}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:u,retry:j})=>t.jsx(_e,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:u,onRetry:j,showBackAction:!1,showHomeAction:!1}),children:t.jsx($n,{noteId:e})}),t.jsx(Fe,{fallback:t.jsx(ne,{height:100}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:u,retry:j})=>t.jsx(_e,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:u,onRetry:j,showBackAction:!1,showHomeAction:!1}),children:t.jsx(pn,{noteId:e,render:u=>u&&u.length>0&&t.jsx(Ve,{icon:t.jsx(gt,{className:"h-3.5 w-3.5"}),title:"Back References",children:t.jsx("ul",{className:"flex flex-col",children:u.map(j=>t.jsx("li",{children:t.jsxs(Ie,{to:ge,params:{id:j.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:[t.jsx(dn,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),t.jsx(y,{as:"span",variant:"body",weight:"medium",className:"text-current",children:j.title})]})},j.id))})})})})]}),t.jsx(mn,{isOpen:b,onClose:()=>$(!1),onSave:Zt,currentLayout:f}),t.jsx(Ln,{isOpen:la,isDeleted:V?.type==="deleted",isConflict:Ae,hasDraft:oa!==null,source:V?.source??"unknown",isReloading:d.isRefetching,onReload:qt,onOverwrite:()=>{Gt()},onCloneDraft:()=>{Ye()},onOpenTrash:()=>n({to:Qe,search:{page:1}})}),t.jsx(Dn,{isOpen:U,metadata:Yt(),getHtml:()=>r.current?.getHtml(),getMarkdown:()=>r.current?.getMarkdown(),onClose:()=>se(!1)}),t.jsx(Bn,{isOpen:H,noteId:e,onClose:()=>B(!1),onRestored:u=>{i.current=Pe(),we(),q.current=null,Q.current=u.updatedAt,I(null),ee(u.updatedAt),P(u.updatedAt)}}),Vt]})})}function Xr(){const{id:e}=Ot.useParams();if(!e)throw new Error("Note id is required.");return t.jsx(Fe,{fallback:Fr,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[e],renderError:({error:a,retry:n})=>t.jsx(He,{title:"Note",variant:"none",children:t.jsx(_e,{title:"Failed to load note",description:"Retry loading the note editor.",error:a,onRetry:n})}),children:t.jsx(Ur,{id:e},e)})}export{Ur as NoteContent,Xr as default};
|