ocean-brain 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +5 -3
  2. package/dist/index.js +12 -4
  3. package/package.json +10 -8
  4. package/server/client/dist/assets/{Calendar-CaeK7gTz.js → Calendar-DH3eSSRs.js} +1 -1
  5. package/server/client/dist/assets/{Note-CGI-Y1__.js → Note-CpzLtGVM.js} +1 -1
  6. package/server/client/dist/assets/{Search-DAYHxAml.js → Search-D9detGWk.js} +1 -1
  7. package/server/client/dist/assets/{Tag-CG8b0l1j.js → Tag-Bquqtx23.js} +1 -1
  8. package/server/client/dist/assets/{TagNotes-COyaVsdn.js → TagNotes-CbjfxqAN.js} +1 -1
  9. package/server/client/dist/assets/{Views-BPxlw3vk.js → Views-L4eC96Lx.js} +1 -1
  10. package/server/client/dist/assets/{app-BezcjTfd.js → app-BFM2V_Rx.js} +2 -2
  11. package/server/client/dist/assets/{index-CzZFedXj.js → index-CJPl3MJE.js} +1 -1
  12. package/server/client/dist/assets/{manage-image-detail-9hRTiAsR.js → manage-image-detail-BIDHUR5-.js} +1 -1
  13. package/server/client/dist/assets/mcp-D8footel.js +5 -0
  14. package/server/client/dist/assets/{note-core-DUTqUh5N.js → note-core-YhYEmI_R.js} +1 -1
  15. package/server/client/dist/assets/note-runtime-B3ats-dC.js +153 -0
  16. package/server/client/dist/assets/{note-ui-BaqzP-YU.js → note-ui-BtzPk8gA.js} +1 -1
  17. package/server/client/dist/assets/{placeholder-CZoqs4S3.js → placeholder-DKgxoe_f.js} +1 -1
  18. package/server/client/dist/assets/route-preload.js +2 -2
  19. package/server/client/dist/index.html +1 -1
  20. package/server/dist/app.js +91 -8
  21. package/server/dist/features/auth/http/api.js +9 -8
  22. package/server/dist/features/auth/http/pages.js +27 -28
  23. package/server/dist/features/auth/service.js +7 -27
  24. package/server/dist/features/cache/graphql/cache.type-defs.js +1 -1
  25. package/server/dist/features/image/http/upload.js +2 -2
  26. package/server/dist/features/mcp-admin/http/handlers.js +9 -9
  27. package/server/dist/features/note/http/mcp.js +17 -17
  28. package/server/dist/features/search/http/handlers.js +10 -10
  29. package/server/dist/features/search/search-manager.js +34 -6
  30. package/server/dist/features/tag/http/mcp.js +2 -2
  31. package/server/dist/modules/auth-guard.js +36 -53
  32. package/server/dist/modules/blocknote.js +16 -9
  33. package/server/dist/modules/error-handler.js +17 -20
  34. package/server/dist/modules/mcp-auth.js +50 -56
  35. package/server/dist/modules/rate-limit.js +23 -23
  36. package/server/dist/modules/server-events-handler.js +15 -13
  37. package/server/dist/modules/session-store.js +6 -8
  38. package/server/dist/paths.js +2 -1
  39. package/server/dist/routes/api.js +105 -71
  40. package/server/dist/routes/auth-pages.js +21 -11
  41. package/server/dist/routes/client.js +60 -72
  42. package/server/dist/routes/graphql.js +31 -26
  43. package/server/dist/routes/mcp.js +25 -35
  44. package/server/dist/server.js +14 -16
  45. package/server/client/dist/assets/mcp-ugdCKa6H.js +0 -4
  46. package/server/client/dist/assets/note-runtime-zN5ddTba.js +0 -168
  47. package/server/dist/modules/logger.js +0 -53
  48. package/server/dist/modules/use-async.js +0 -10
@@ -1 +1 @@
1
- import{r as h,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{f as Lt,u as Se,g as de,K as Pe,P as ut,D as Ae,h as Me,j as _t,k as qt,l as Ut,m as mt,C as Ve,n as Wt,o as pt,M as Gt,r as Yt,S as ht,p as Qt,q as bt,t as Ht,v as Zt,w as Xt,x as Jt,y as ea,z as Ie,A as ta,B as aa,E as sa,G as Ke,H as ra,I as na,J as ia,L as la}from"./app-BezcjTfd.js";import{d as se,a as be,k as oa,h as Fe,m as xt,M as yt,u as da}from"./useNoteMutate-BjvZUmtX.js";import{a2 as ca,a3 as Be,a4 as ua,a5 as ma,a6 as pa,A as ha,q as _,T as o,B as K,M as Y,u as gt,W as ba,e as ft,l as xe,c as ie,D as Ee,O as Ne,N as Oe,a7 as xa,k as ya,L as W,I as Ce,a as Le,b as oe,K as _e,x as ee,y as I,d as ga,a8 as fa,P as va,E as qe,h as ja}from"./time-PxWila4-.js";import{f as wa}from"./tag.api-DEUROVKQ.js";import{S as ke}from"./SurfaceCard-D5QxOte_.js";import{N as Re,V as Na}from"./url-DKUMNVCI.js";import{V as G}from"./ViewChip-BVkZAXyx.js";import{e as Ca,g as ka,t as ye,d as Ta,b as Da,c as Sa,C as Pa,a as Aa}from"./calendar-data-wB0ifXdo.js";import{s as Ma}from"./FileText.es-DPIwDCEe.js";import{s as Va}from"./ArrowRight.es-BlNsZQFs.js";import{s as Fa}from"./CheckCircle.es-Dqr3WImn.js";import{n as Te}from"./Plus.es-Dy6onD-Z.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-hVj6vAYJ.js";var Ea=class extends ca{constructor(t,a){super(t,a)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Be()})}getOptimisticResult(t){return t.behavior=Be(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,a){const{state:s}=t,i=super.createResult(t,a),{isFetching:n,isRefetching:c,isError:b,isRefetchError:d}=i,j=s.fetchMeta?.fetchMore?.direction,k=b&&j==="forward",A=n&&j==="forward",x=b&&j==="backward",E=n&&j==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ma(a,s.data),hasPreviousPage:ua(a,s.data),isFetchNextPageError:k,isFetchingNextPage:A,isFetchPreviousPageError:x,isFetchingPreviousPage:E,isRefetchError:d&&!k&&!x,isRefetching:c&&!A&&!E}}};function Oa(t,a){return pa(t,Ea)}const Ra=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),vt=h.forwardRef((t,a)=>h.createElement(ha,{ref:a,...t,weights:Ra}));vt.displayName="CircleIcon";const za=vt,Ue=2,$a=(t,a)=>t.displayOptions.calendarDateField==="property"?a?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",Ia=t=>{const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!a)return null;const s=Number(a[1]),i=Number(a[2]),n=Number(a[3]),c=new Date(Date.UTC(s,i-1,n));return c.getUTCFullYear()!==s||c.getUTCMonth()!==i-1||c.getUTCDate()!==n?null:`${s}-${i}-${n}`},Ka=t=>{const a=ye(t);if(!Number.isFinite(a))return null;const s=se(a);return`${s.year()}-${s.month()+1}-${s.date()}`},Ba=(t,a)=>t.isCurrentMonth?a?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",La=t=>t.isToday?"bg-cta font-semibold text-fg-on-filled":t.isCurrentMonth?t.isSunday?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";function _a({section:t,calendarDateProperty:a,navigationState:s,onNavigationStateChange:i}){const n=se(),c=s.calendar?.year??n.year(),b=s.calendar?.month??n.month()+1,d=se(new Date(c,b-1,1)).format("MMMM YYYY"),j=t.displayOptions.calendarDateField,k=j==="property",A=$a(t,a),x=k?Ca(c,b):ka(c,b),[E,p]=h.useState(),{data:m,isPending:v,isError:D,refetch:P}=be({queryKey:_.views.sectionCalendar(t.id,{year:c,month:b,dateField:j,propertyKey:t.displayOptions.calendarDatePropertyKey}),async queryFn(){const u=await Lt(t.id,x);if(u.type==="error")throw u;return u.viewSectionCalendarNotes}}),M=h.useMemo(()=>{const u=new Map;for(const C of m??[]){const y=k?Ia(C.calendarDate):Ka(C.calendarDate);if(!y)continue;const T=u.get(y)??[];T.push(C),u.set(y,T)}for(const C of u.values())C.sort((y,T)=>(k?y.calendarDate.localeCompare(T.calendarDate):ye(y.calendarDate)-ye(T.calendarDate))||y.id.localeCompare(T.id));return Ta(c,b).map(C=>({...C,notes:u.get(C.key)??[]}))},[m,k,b,c]),w=M.find(u=>u.key===E),R=w?se(new Date(w.year,w.month-1,w.day)).format("dddd, MMMM D"):"Day notes",f=(u,C)=>{const y=u===n.year()&&C===n.month()+1;p(void 0),i(T=>({...T,calendar:y?void 0:{year:u,month:C}}))},S=u=>{const C=new Date(c,b-1+u,1);f(C.getFullYear(),C.getMonth()+1)},z=m?.length??0;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h3",variant:"subheading",weight:"semibold",tracking:"tight",children:d}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Notes placed by ",A.toLowerCase()]})]}),e.jsx(Da,{onToday:()=>f(n.year(),n.month()+1),onPrevMonth:()=>S(-1),onNextMonth:()=>S(1)})]}),D?e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this calendar"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:["Retry to refresh notes for ",d,"."]}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>{P()},children:"Retry"})})]}):e.jsx("div",{className:"min-w-0 px-4 py-3.5",children:e.jsx(Sa,{isLoading:v,ariaLabel:`${d} note calendar`,children:M.map(u=>{const C=u.key===E,y=u.notes.slice(0,Ue).map(T=>({key:`note-${T.id}`,type:"note",title:T.title||"Untitled"}));return e.jsx(Pa,{day:u.day,dateLabel:se(new Date(u.year,u.month-1,u.day)).format("dddd, MMMM D, YYYY"),cellClassName:Ba(u,C),dayNumberClassName:La(u),isCurrentMonth:u.isCurrentMonth,isToday:u.isToday,isSelected:C,noteCount:u.notes.length,reminderCount:0,previewItems:y,overflowCount:Math.max(0,u.notes.length-Ue),density:"compact",showReminderSummary:!1,onSelect:()=>p(u.key)},u.key)})})}),e.jsx("div",{className:"mt-auto border-t border-border-subtle/75 px-4 py-3",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:v?"Loading calendar notes...":D?`Calendar notes for ${d} are unavailable`:z===0?`No matching notes in ${d}`:`${z} matching note${z===1?"":"s"} in ${d}`})}),e.jsxs(Y,{isOpen:!!w,onClose:()=>p(void 0),variant:"inspect",children:[e.jsx(Y.Header,{title:R,onClose:()=>p(void 0)}),e.jsxs(Y.Body,{children:[e.jsxs(Y.Description,{className:"sr-only",children:["View matching notes placed on ",R," by ",A.toLowerCase(),"."]}),e.jsxs(o,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:[w?.notes.length??0," matching"," ",(w?.notes.length??0)===1?"note":"notes"]}),e.jsx("div",{className:"flex flex-col gap-1",children:w?.notes.map(u=>e.jsx(Aa,{params:{id:u.id},header:e.jsx(Ma,{size:12}),title:u.title||"Untitled",meta:k?void 0:se(ye(u.calendarDate)).format("HH:mm")},u.id))})]})]})]})}const ge=6,De=["title","tags","properties","createdAt","updatedAt"],jt="createdAt",qa={activeTabId:null,tabs:[]},Ua=t=>{const a=t.trim();return a?a.startsWith("@")?a:a.startsWith("#")?"":`@${a}`:""},wt=(t,a,s)=>{if(a===s)return t;const i=t.findIndex(d=>d.id===a),n=t.findIndex(d=>d.id===s);if(i<0||n<0)return t;const c=[...t],[b]=c.splice(i,1);return c.splice(n,0,b),c},Nt=(t,a,s)=>{const i=t.findIndex(c=>c.id===a),n=i+(s==="previous"?-1:1);return i>=0&&n>=0&&n<t.length?t[n]?.id:void 0},We=t=>{const a=t.flatMap(s=>typeof s=="string"?s.split(","):[]);return Array.from(new Set(a.map(Ua).filter(Boolean)))},Wa=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(a=>a.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,Ga=(t,a)=>t.tabs.some(s=>s.id===a)?{...t,activeTabId:a}:t,Ct=(t,a,s)=>({...t,tabs:wt(t.tabs,a,s)}),kt=(t,a,s,i)=>({...t,tabs:t.tabs.map(n=>n.id===a?{...n,sections:wt(n.sections,s,i)}:n)}),Ya=(t,a,s)=>{const i=Nt(t.tabs,a,s);return i?Ct(t,a,i):t},Qa=(t,a,s,i)=>{const n=t.tabs.find(b=>b.id===a)?.sections??[],c=Nt(n,s,i);return c?kt(t,a,s,c):t},Ge=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",Ha=t=>t==="or"?"OR":"AND",Tt=t=>{switch(t){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},Za=t=>{switch(t){case"table":return"Table";case"board":return"Board";case"calendar":return"Calendar";default:return"List"}},Dt=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},fe=t=>{const a=new Set(De),s=(t??[]).filter(n=>a.has(n)),i=Array.from(new Set(s));return i.length===0?[...De]:i.includes("title")?i:["title",...i]},ze=t=>Array.from(new Set((t??[]).map(a=>a.trim()).filter(Boolean))).slice(0,ge),St=t=>t==="updatedAt"||t==="property"?t:jt,Pt=t=>{const a=St(t?.calendarDateField);return{tableColumns:fe(t?.tableColumns),tablePropertyKeys:ze(t?.tablePropertyKeys),boardGroupByPropertyKey:t?.boardGroupByPropertyKey?.trim()||null,calendarDateField:a,calendarDatePropertyKey:a==="property"&&t?.calendarDatePropertyKey?.trim()||null}},Xa=t=>{const a=Tt(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${a}`:`${t.name} ${a} ${t.value??""}`.trim()},Ja=(t,a={})=>{const s={...t,...a};return{title:s.title,displayType:s.displayType,displayOptions:Pt(s.displayOptions),tagNames:s.tagNames,mode:s.mode,propertyFilters:s.propertyFilters.map(i=>({key:i.key,valueType:i.valueType,operator:i.operator,value:i.value})),sortBy:s.sortBy,sortOrder:s.sortOrder,limit:s.limit}},At="view-board-column:unassigned",es=t=>t===null?At:`view-board-column:value:${encodeURIComponent(t)}`,ts=t=>[...[...t].sort((a,s)=>a.order-s.order||a.label.localeCompare(s.label)).map(a=>({id:es(a.value),label:a.label,value:a.value,color:a.color??null})),{id:At,label:"Unassigned",value:null,color:null}];function as({note:t,column:a,columns:s,isMoving:i,onMove:n}){const{attributes:c,listeners:b,setNodeRef:d,setActivatorNodeRef:j,transform:k,isDragging:A}=Ut({id:`view-board-note:${t.id}`,data:{note:t,sourceValue:a.value},disabled:i});return e.jsx("article",{ref:d,style:{transform:Ve.Translate.toString(k)},className:ie("group rounded-[14px] border border-border-subtle bg-elevated px-3 py-2.5 transition-[opacity,background-color,border-color] hover:border-border-secondary/80 hover:bg-hover-subtle/35",(A||i)&&"opacity-55",A&&"z-20 border-accent-primary/45 bg-elevated ring-2 ring-accent-primary/10"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",ref:j,"aria-label":`Drag ${t.title||"Untitled"} to another column`,...c,...b,className:"focus-ring-soft mt-0.5 hidden size-7 shrink-0 touch-none items-center justify-center rounded-[9px] text-fg-tertiary outline-none hover:bg-hover-subtle hover:text-fg-default sm:inline-flex",children:e.jsx(mt,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"leading-[1.4]",children:e.jsx(Ee,{to:Re,params:{id:t.id},className:"line-clamp-2 transition-colors hover:text-fg-default/80",children:t.title||"Untitled"})}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:["Updated ",Ne(Number(t.updatedAt))]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:`Move ${t.title||"Untitled"}`,size:"sm"}),items:s.filter(x=>x.value!==a.value).map(x=>({name:`Move to ${x.label}`,onClick:()=>n(t,a.value,x.value)}))})]})})}function ss({section:t,groupProperty:a,column:s,columns:i,index:n,scrollRootRef:c,movingNoteIds:b,onMove:d,pageCount:j,onPageCountChange:k}){const A=h.useRef(null),[x,E]=h.useState(n<4),{isOver:p,setNodeRef:m}=_t({id:s.id,data:{optionValue:s.value}});h.useEffect(()=>{if(x||!A.current)return;if(typeof IntersectionObserver>"u"){E(!0);return}const y=new IntersectionObserver(T=>{T.some(Q=>Q.isIntersecting)&&(E(!0),y.disconnect())},{root:c.current,rootMargin:"0px 320px",threshold:.01});return y.observe(A.current),()=>y.disconnect()},[c,x]);const{data:v,isPending:D,isError:P,refetch:M,fetchNextPage:w,hasNextPage:R,isFetchingNextPage:f,isFetchNextPageError:S}=Oa({queryKey:_.views.sectionBoardColumnPages(t.id,a.key,s.value,t.limit),enabled:x,initialPageParam:0,async queryFn({pageParam:y}){const T=await qt(t.id,{optionValue:s.value,limit:t.limit,offset:y});if(T.type==="error")throw T;return T.viewSectionBoardColumn},getNextPageParam(y,T){return T.reduce((te,H)=>te+H.notes.length,0)<y.totalCount?T.length*t.limit:void 0}}),z=h.useMemo(()=>Array.from(new Map((v?.pages??[]).flatMap(y=>y.notes).map(y=>[y.id,y])).values()),[v?.pages]),u=v?.pages[0]?.totalCount;h.useEffect(()=>{!x||!v||v.pages.length>=j||!R||f||S||w()},[v,w,R,S,f,j,x]),h.useEffect(()=>{if(u===void 0)return;const y=Math.max(1,Math.ceil(u/t.limit));j>y&&k(y)},[k,j,t.limit,u]);const C=y=>{A.current=y,m(y)};return e.jsxs("section",{ref:C,"aria-label":`${s.label} column`,className:ie("flex min-h-[248px] w-[17rem] shrink-0 flex-col rounded-[18px] border bg-subtle/30 transition-[border-color,background-color] sm:w-[18rem]",p?"border-accent-primary/50 bg-accent-primary/6":"border-border-subtle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border-subtle/75 px-3.5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-full border border-black/5",style:{backgroundColor:s.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx(o,{as:"h3",variant:"label",weight:"semibold",className:"truncate",children:s.label})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary","aria-label":u===void 0?"Card count loading":`${u} cards`,className:"inline-flex min-w-6 justify-center rounded-full bg-elevated px-2 py-0.5 tabular-nums",children:u??"–"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-2.5",children:[x?D&&!v?e.jsxs(e.Fragment,{children:[e.jsx(xe,{height:"76px",className:"rounded-[14px]"}),e.jsx(xe,{height:"76px",className:"rounded-[14px]"})]}):P?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-border-subtle bg-elevated/60 p-3",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Failed to load this column."}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2",onClick:()=>{M()},children:"Retry"})]}):z.length===0?e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-center",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Drop a note here"})}):z.map(y=>e.jsx(as,{note:y,column:s,columns:i,isMoving:b.has(y.id),onMove:d},y.id)):e.jsx("button",{type:"button",className:"focus-ring-soft flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-sm text-fg-tertiary outline-none hover:bg-elevated",onClick:()=>E(!0),children:"Load cards"}),R?e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"mt-auto w-full",disabled:f,onClick:()=>{S||k(j+1),w()},children:f?"Loading...":S?"Retry loading cards":`Load more (${Math.max(0,(u??0)-z.length)})`}):null]})]})}function rs({section:t,groupProperty:a,navigationState:s={},onNavigationStateChange:i=()=>{}}){const n=gt(),c=ft(),b=h.useRef(null),[d,j]=h.useState(()=>new Set),k=h.useMemo(()=>ts(a.options),[a.options]),A=Se(de(ut,{activationConstraint:{distance:6}}),de(Pe)),x=h.useCallback(async(p,m,v)=>{if(m===v||d.has(p.id))return;j(M=>new Set(M).add(p.id));const D=_.views.sectionBoardAll(t.id),P=n.getQueriesData({queryKey:D});for(const[M,w]of P){if(!w||!Array.isArray(w.pages))continue;const R=M[3];if(R?.groupPropertyKey!==a.key)continue;const f=R.optionValue===m,S=R.optionValue===v,z=R.pageSize??t.limit;let u=w.pages.flatMap(y=>y.notes).filter(y=>y.id!==p.id);S&&(u=[p,...u]);const C=Math.max(0,(w.pages[0]?.totalCount??0)-(f?1:0)+(S?1:0));n.setQueryData(M,{...w,pages:w.pages.map((y,T)=>({totalCount:C,notes:u.slice(T*z,(T+1)*z)}))})}try{const M=await ba({id:p.id,expectedUpdatedAt:p.updatedAt,...v===null?{deleteKeys:[a.key]}:{set:[{key:a.key,name:a.name,value:v,valueType:"select"}]}});if(M.type==="error"){for(const[w,R]of P)n.setQueryData(w,R);c(M.errors[0]?.message??"Failed to move this note.");return}await Promise.all([oa(n),n.invalidateQueries({queryKey:_.notes.propertyKeysAll(),exact:!1})])}catch{for(const[M,w]of P)n.setQueryData(M,w);c("Failed to move this note.")}finally{j(M=>{const w=new Set(M);return w.delete(p.id),w})}},[a.key,a.name,d,n,t.id,t.limit,c]),E=({active:p,over:m})=>{const v=p.data.current?.note,D=p.data.current?.sourceValue,P=m?.data.current?.optionValue;!v||D===void 0||P===void 0||x(v,D,P)};return e.jsx(Ae,{sensors:A,collisionDetection:Me,onDragEnd:E,children:e.jsx("div",{ref:b,"data-scroll-restoration-id":`view-board-${t.id}`,className:"overflow-x-auto overscroll-x-contain px-3 py-3.5 [scrollbar-gutter:stable] sm:px-4","aria-label":`Board grouped by ${a.name}`,children:e.jsx("div",{className:"flex min-w-max items-stretch gap-3 pb-1",children:k.map((p,m)=>e.jsx(ss,{section:t,groupProperty:a,column:p,columns:k,index:m,scrollRootRef:b,movingNoteIds:d,pageCount:s.columns?.[p.id]??1,onPageCountChange:v=>i(D=>({...D,columns:{...D.columns,[p.id]:v}})),onMove:(v,D,P)=>{x(v,D,P)}},p.id))})})})}const ns="group flex min-h-[72px] items-center justify-between gap-3 px-4 py-3 transition-colors hover:bg-hover-subtle",is=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,ls=t=>{const a=t.tags.slice(0,2),s=t.tags.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0&&e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})},os=t=>{const a=t.properties??[],s=a.slice(0,2),i=a.length-s.length;return s.length===0?null:e.jsxs(e.Fragment,{children:[s.map(n=>e.jsxs(G,{size:"compact",truncateContent:!1,className:"max-w-[220px] gap-1.5 border-border-subtle bg-subtle/55 text-fg-secondary",children:[n.valueType==="select"?e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:n.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}):null,e.jsx("span",{className:"max-w-[72px] shrink truncate text-fg-tertiary",children:n.name}),e.jsx("span",{className:"min-w-0 truncate",children:is(n)||"—"})]},n.key)),i>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",i," properties"]}):null]})};function ds({notes:t,isPending:a,isError:s,onRetry:i}){return a?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[72px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):s?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:t.map(n=>e.jsxs(Ee,{to:Re,params:{id:n.id},className:ns,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"line-clamp-1",children:n.title||"Untitled"})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[os(n),ls(n),e.jsxs(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"sm:hidden",children:["Updated ",Ne(Number(n.updatedAt))]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pl-2",children:[e.jsx(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"hidden sm:inline",children:Ne(Number(n.updatedAt))}),e.jsx(Va,{className:"size-4 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]})]},n.id))})}const cs={title:300,tags:200,createdAt:148,updatedAt:148},us={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},ms="flex h-[24px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",Mt="text-xs leading-5 text-fg-tertiary",ps=t=>se(Number(t)).format("MMM D, YYYY"),hs=t=>t==="text"||t==="url"?220:t==="date"?168:156,Vt=t=>t.kind==="property"?hs(t.valueType):cs[t.key],bs=(t,a,s)=>{const i=new Map(s.map(d=>[d.key,d])),n=new Map(a.flatMap(d=>d.properties??[]).map(d=>[d.key,d])),c=ze(t.displayOptions.tablePropertyKeys),b=Array.from(new Set([...t.propertyFilters.map(d=>d.key),...a.flatMap(d=>(d.properties??[]).map(j=>j.key))])).slice(0,3);return(c.length>0?c:b).flatMap(d=>{const j=i.get(d),k=n.get(d);return!j&&!k?[]:[{kind:"property",key:d,name:j?.name??k?.name??d,valueType:j?.valueType??k?.valueType??"text"}]})},xs=(t,a,s)=>{const i=bs(t,a,s);return fe(t.displayOptions.tableColumns).reduce((n,c)=>(c==="properties"?n.push(...i):n.push({kind:"base",key:c}),n),[])},ys=t=>t.reduce((a,s)=>a+Vt(s),0),gs=t=>{if(t.tags.length===0)return e.jsx("span",{className:Mt,children:"—"});const a=t.tags.slice(0,3),s=t.tags.length-a.length;return e.jsxs("div",{className:ms,children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]}):null]})},fs=t=>{if(!t)return e.jsx("span",{className:Mt,children:"—"});if(t.valueType==="select")return e.jsx(G,{size:"compact",className:"max-w-full border-border-subtle bg-subtle/65 text-fg-secondary",truncateContent:!1,children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:t.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:t.option?.label??t.value})]})});if(t.valueType==="boolean"){const a=t.value==="true",s=a?Fa:za;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-fg-secondary",children:[e.jsx(s,{className:"size-3.5 text-fg-tertiary",weight:a?"fill":"regular"}),a?"True":"False"]})}return e.jsx("span",{className:ie("block truncate text-sm text-fg-secondary",t.valueType==="number"&&"tabular-nums"),title:t.value,children:t.value||"—"})};function vs({section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:c,isSortPending:b,activeSortBy:d=t.sortBy,activeSortOrder:j=t.sortOrder,availableProperties:k=[],surface:A="flush"}){const x=xs(t,a,k),E=ys(x),p=A==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",m=A==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",v=A==="card"?"bg-elevated":"bg-transparent",D=A==="card"?"bg-subtle/65":"bg-subtle/45",P=A==="card"?"bg-elevated":"bg-transparent",M=A==="card"?"var(--elevated)":"var(--surface)",w=f=>{if(f.kind==="property")return e.jsxs("th",{className:"px-3 py-2 text-left",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",className:"truncate",title:f.name,children:f.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5 capitalize",children:f.valueType})]},`property:${f.key}`);const S=us[f.key],z=Dt(f.key),u=S?d===S:!1,C=f.key==="title";return e.jsx("th",{"aria-sort":u?j==="asc"?"ascending":"descending":void 0,className:ie("px-3 py-2.5 text-xs font-semibold text-fg-tertiary",C&&"lg:sticky lg:left-0 lg:z-20"),style:C?{background:`linear-gradient(var(--subtle), var(--subtle)), ${M}`}:void 0,children:S?e.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:b,onClick:()=>c(S),children:[e.jsx("span",{children:z}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:u?j==="asc"?"↑":"↓":"↕"})]}):z},f.key)},R=(f,S)=>{if(S.kind==="property")return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:fs(f.properties?.find(z=>z.key===S.key))},`property:${S.key}`);switch(S.key){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:gs(f)},S.key);case"createdAt":case"updatedAt":{const z=S.key==="createdAt"?f.createdAt:f.updatedAt;return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",title:se(Number(z)).format("MMM D, YYYY h:mm A"),children:ps(z)})},S.key)}default:return e.jsxs("td",{className:"relative px-3 py-2.5 align-middle lg:sticky lg:left-0 lg:z-10",style:{background:M},children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-hover-subtle opacity-0 transition-opacity group-hover:opacity-100"}),e.jsxs("div",{className:"relative z-10 flex min-w-0 items-center gap-2",children:[f.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",className:"min-w-0 line-clamp-1",children:e.jsx(Ee,{to:Re,params:{id:f.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/80",children:f.title||"Untitled"})})]})]},S.key)}};return s?e.jsxs("div",{className:m,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`})]}):i?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Retry"})})]}):a.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:p,"data-scroll-restoration-id":`view-table-${t.id}`,"aria-label":"Scrollable view table",children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:E},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:x.map(f=>e.jsx("col",{style:{width:`${Vt(f)/E*100}%`}},f.kind==="property"?`property:${f.key}`:f.key))}),e.jsx("thead",{className:D,children:e.jsx("tr",{className:"border-b border-border-subtle",children:x.map(w)})}),e.jsx("tbody",{className:P,children:a.map(f=>e.jsx("tr",{className:"group h-12 border-b border-border-subtle/70 last:border-b-0",children:x.map(S=>R(f,S))},f.id))})]})})}const Ye=({displayName:t,onRetry:a})=>e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsxs(o,{as:"p",variant:"body",weight:"semibold",children:["Failed to load ",t," properties"]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to check the configured property without changing this view."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:a,children:"Retry"})})]});function js({section:t,notes:a,isPending:s,isError:i,onRetry:n,onEdit:c,onSortChange:b,isSortPending:d,activeSortBy:j=t.sortBy,activeSortOrder:k=t.sortOrder,availableProperties:A=[],isPropertiesLoading:x=!1,isPropertiesError:E=!1,onRetryProperties:p=()=>{},navigationState:m={},onNavigationStateChange:v=()=>{}}){if(t.displayType==="board"){const D=A.find(P=>P.key===t.displayOptions.boardGroupByPropertyKey&&P.valueType==="select");return!D&&x?e.jsxs("div",{className:"flex gap-3 overflow-hidden px-4 py-3.5",children:[e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"})]}):!D&&E?e.jsx(Ye,{displayName:"board",onRetry:p}):!D||D.options.length===0?e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Board grouping is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing select property with options to restore this board."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit board"})})]}):e.jsx(rs,{section:t,groupProperty:D,navigationState:m,onNavigationStateChange:v})}if(t.displayType==="table")return e.jsx(vs,{section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:b,isSortPending:d,activeSortBy:j,activeSortOrder:k,availableProperties:A});if(t.displayType==="calendar"){const D=t.displayOptions.calendarDateField==="property"?A.find(P=>P.key===t.displayOptions.calendarDatePropertyKey&&P.valueType==="date"):void 0;return t.displayOptions.calendarDateField==="property"&&!D?x?e.jsx("div",{className:"m-4 h-[320px] animate-pulse rounded-[18px] bg-subtle/50"}):E?e.jsx(Ye,{displayName:"calendar",onRetry:p}):e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Calendar date property is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing date property to restore this calendar."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit calendar"})})]}):e.jsx(_a,{section:t,calendarDateProperty:D,navigationState:m,onNavigationStateChange:v})}return e.jsx(ds,{notes:a,isPending:s,isError:i,onRetry:n})}function ws({section:t,onEdit:a,onDuplicate:s,onDelete:i,onMoveUp:n,onMoveDown:c,dragHandle:b,availableProperties:d=[],isPropertiesLoading:j=!1,isPropertiesError:k=!1,onRetryProperties:A=()=>{},navigationState:x={},onNavigationStateChange:E=()=>{}}){const p=t.displayType==="board",m=t.displayType==="calendar",v=x.page??1,D=(v-1)*t.limit,P=x.sort?.by??t.sortBy,M=x.sort?.order??t.sortOrder,{data:w,isPending:R,isError:f,isPlaceholderData:S,refetch:z}=be({queryKey:_.views.sectionNotes(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:M}),enabled:!p&&!m,placeholderData:xa,async queryFn(){const V=await Wt(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:M});if(V.type==="error")throw V;return V.viewSectionNotes}}),u=w?.notes??[],C=w?.totalCount??0,y=Math.max(1,Math.ceil(C/t.limit)),T=Ha(t.mode),Q=t.tagNames.length>0||t.propertyFilters.length>0,te=p?d.find(V=>V.key===t.displayOptions.boardGroupByPropertyKey):null,H=m?d.find(V=>V.key===t.displayOptions.calendarDatePropertyKey):null,ae=t.displayOptions.calendarDateField==="property"?H?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",re=V=>{const q=P===V?M==="asc"?"desc":"asc":V==="title"?"asc":"desc";E(ce=>({...ce,page:1,sort:{by:V,order:q}}))};return h.useEffect(()=>{p||m||R||f||S||!w||v<=y||E(V=>({...V,page:y}))},[w,p,m,f,R,S,y,E,v]),e.jsxs(ke,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[b&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:b}),e.jsx("div",{className:"min-w-0",children:e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx("span",{className:"truncate",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Za(t.displayType)}),p&&t.displayOptions.boardGroupByPropertyKey?e.jsxs(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:["Grouped by ",te?.name??t.displayOptions.boardGroupByPropertyKey]}):null,m?e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:ae}):null,t.tagNames.map((V,q)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[q>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:T}),e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:V})]},V)),t.propertyFilters.map(V=>e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Xa(V)},`${V.key}-${V.operator}-${V.value??""}`)),!Q&&e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"Section actions"}),items:[...n?[{name:"Move up",onClick:n}]:[],...c?[{name:"Move down",onClick:c}]:[],...n||c?[{type:"separator"}]:[],{name:"Edit section",onClick:a},{name:"Duplicate section",onClick:s},{type:"separator"},{name:"Delete section",onClick:i}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(js,{section:t,notes:u,isPending:R,isError:f,onRetry:()=>{z()},onEdit:a,onSortChange:re,isSortPending:S,activeSortBy:P,activeSortOrder:M,availableProperties:d,isPropertiesLoading:j,isPropertiesError:k,onRetryProperties:A,navigationState:x,onNavigationStateChange:E})}),m?null:e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:p?`${t.limit} cards per column load`:R||S?"Loading notes...":C===0?"No matching notes":`Showing ${D+1}–${Math.min(D+u.length,C)} of ${C} notes`}),!p&&y>1?e.jsx(ya,{page:Math.min(v,y),last:y,className:"!mt-0 shrink-0 sm:justify-end",onChange:V=>E(q=>({...q,page:V}))}):null]})]})}const ve="__choose_property__",je="__choose_board_group__",Ns=["title","tags","properties","createdAt","updatedAt"],Qe=t=>String(t?.limit??5),He=t=>t?.displayType??"list",Ze=t=>fe(t?.displayOptions?.tableColumns??De),Xe=t=>ze(t?.displayOptions?.tablePropertyKeys),Je=t=>t?.displayOptions?.boardGroupByPropertyKey??"",et=t=>St(t?.displayOptions?.calendarDateField??jt),tt=t=>t?.displayOptions?.calendarDatePropertyKey??"",at=t=>t?.mode??"and",st=t=>t?t.tagNames.join(", "):"",rt=t=>t?.title??"",nt=t=>t?.sortBy??"updatedAt",it=t=>t?.sortOrder??"desc",Ft=t=>`property-filter-${Date.now()}-${t}`,lt=t=>(t?.propertyFilters??[]).map((a,s)=>({id:Ft(s),key:a.key,operator:a.operator,value:a.value??""})),ot=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],dt=t=>t?"equals":"exists",Cs=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",we=t=>t!=="exists"&&t!=="notExists",Et=t=>t==="contains"||t==="notContains",ks=(t,a)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Et(a)?"url":"text",Ts=(t,a)=>{if(t.valueType==="url")return Et(a)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Ds({open:t,mode:a,initialSection:s=null,availableTags:i,availableProperties:n,isTagsLoading:c=!1,isPropertiesLoading:b=!1,onClose:d,onSubmit:j}){const[k,A]=h.useState(rt(s)),[x,E]=h.useState(He(s)),[p,m]=h.useState(Ze(s)),[v,D]=h.useState(Xe(s)),[P,M]=h.useState(Je(s)),[w,R]=h.useState(et(s)),[f,S]=h.useState(tt(s)),[z,u]=h.useState(st(s)),[C,y]=h.useState(at(s)),[T,Q]=h.useState(nt(s)),[te,H]=h.useState(it(s)),[ae,re]=h.useState(Qe(s)),[V,q]=h.useState(lt(s)),[ce,ue]=h.useState((s?.tagNames.length??0)>0),[me,$]=h.useState(""),Z=h.useMemo(()=>new Map(n.map(r=>[r.key,r])),[n]);h.useEffect(()=>{t&&(A(rt(s)),E(He(s)),m(Ze(s)),D(Xe(s)),M(Je(s)),R(et(s)),S(tt(s)),u(st(s)),y(at(s)),Q(nt(s)),H(it(s)),re(Qe(s)),q(lt(s)),ue((s?.tagNames.length??0)>0),$(""))},[s,t]);const X=We([z]),le=ce||X.length>0,l=X.length===0&&V.length===0,g=n.filter(r=>r.valueType==="select"&&r.options.length>0),O=n.filter(r=>r.valueType==="date"),L=w==="property"&&!!f&&!O.some(r=>r.key===f),pe=r=>{r!=="title"&&(m(N=>{if(N.includes(r)){const B=N.filter(F=>F!==r);return B.length>0?B:N}return fe([...N,r])}),$(""))},Ot=r=>{D(N=>N.includes(r)?N.filter(B=>B!==r):N.length>=ge?N:[...N,r])},Rt=r=>{const N=X.includes(r)?X.filter(B=>B!==r):[...X,r];u(N.join(", ")),$("")},zt=()=>{ue(!0),$("")},$t=()=>{u(""),y("and"),ue(!1),$("")},It=()=>{if(n.length===0){$("Create a shared property before adding a filter.");return}q(r=>[...r,{id:Ft(r.length),key:"",operator:"exists",value:""}]),$("")},he=(r,N)=>{q(B=>B.map(F=>{if(F.id!==r)return F;const J={...F,...N},ne=Z.get(J.key);return ot(ne).includes(J.operator)||(J.operator=dt(ne)),"key"in N&&(J.value=Cs(ne),J.operator=dt(ne)),J})),$("")},Kt=r=>{q(N=>N.filter(B=>B.id!==r)),$("")};return e.jsxs(Y,{isOpen:t,onClose:d,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(Y.Header,{title:a==="create"?"Create section":"Edit section",onClose:d}),e.jsx(Y.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const N=We([z]);if(le&&N.length===0){$("Choose at least one tag, or remove this tag filter.");return}if(V.find(U=>!U.key||!Z.has(U.key))){$("Choose a property for every filter.");return}const F=Z.get(P);if(x==="board"&&(!F||F.valueType!=="select"||F.options.length===0)){$("Choose a select property with at least one option for the board columns.");return}if(x==="board"&&V.some(U=>U.key===P)){$("Use different properties for the board columns and the section filter.");return}const J=Z.get(f);if(x==="calendar"&&w==="property"&&(!J||J.valueType!=="date")){$("Choose a date property for the calendar.");return}const ne=V.map(U=>{const $e=Z.get(U.key);return{key:$e?.key??U.key,valueType:$e?.valueType??"text",operator:U.operator,value:we(U.operator)?U.value:null}});if(ne.some(U=>we(U.operator)&&!U.value?.trim())){$("Fill every filter value, or switch it to is set / is empty.");return}j({title:k,displayType:x,displayOptions:Pt({tableColumns:p,tablePropertyKeys:v,boardGroupByPropertyKey:P,calendarDateField:w,calendarDatePropertyKey:f}),tagNames:N,mode:C,propertyFilters:ne,sortBy:T,sortOrder:te,limit:Number(ae)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(Ce,{id:"view-section-title",value:k,onChange:r=>A(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Display"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same note set as a list, table, property board, or calendar."})]}),e.jsxs(Le,{type:"single",value:x,onValueChange:r=>{(r==="list"||r==="table"||r==="board"||r==="calendar")&&(E(r),r==="board"&&!g.some(N=>N.key===P)&&M(g[0]?.key??""),$(""))},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(oe,{value:"table","aria-label":"Show as table",children:"Table"}),e.jsx(oe,{value:"board","aria-label":"Show as board",children:"Board"}),e.jsx(oe,{value:"calendar","aria-label":"Show as calendar",children:"Calendar"})]}),x==="table"?e.jsxs("div",{className:"border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(W,{size:"sm",children:"Table columns"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:p.includes("properties")&&v.length===0?"Properties automatic":`${p.length-(p.includes("properties")?1:0)+(p.includes("properties")?v.length:0)} shown`})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:Ns.map(r=>{const N=Dt(r);return e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:p.includes(r),disabled:r==="title","aria-label":`Show ${N} column`,onChange:()=>pe(r)}),e.jsx(o,{as:"span",variant:"label",tone:"secondary",children:N})]},r)})}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."}),p.includes("properties")?e.jsxs("div",{className:"mt-3 border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Property columns"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Select up to ",ge," properties to compare."]})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:v.length>0?`${v.length} selected`:"Automatic"})]}),n.length>0?e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:n.map(r=>{const N=v.includes(r.key),B=v.length>=ge;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:N,disabled:!N&&B,"aria-label":`Show ${r.name} property column`,onChange:()=>Ot(r.key)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"secondary",truncate:!0,children:r.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",children:r.valueType})]})]},r.key)})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-3",children:"Shared properties will appear here after you create them."}),v.length===0&&n.length>0?e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Automatic mode shows up to three properties relevant to the current notes."}):null]}):null]}):null,x==="board"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-board-group-label",htmlFor:"view-section-board-group",size:"sm",children:"Board columns"}),e.jsxs(ee,{id:"view-section-board-group",value:P||je,"aria-labelledby":"view-section-board-group-label",className:"w-full",onValueChange:r=>{r!==je&&(M(r),$(""))},children:[e.jsx(I,{value:je,disabled:!0,children:"Choose a select property"}),g.map(r=>e.jsxs(I,{value:r.key,children:[r.name," · ",r.options.length," columns"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Moving a card changes this property. Notes without a value stay in Unassigned."}),g.length===0&&!b?e.jsx(o,{as:"p",variant:"meta",className:"text-fg-error",children:"Create a shared select property with options before using a board."}):null]})}):null,x==="calendar"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-calendar-date-label",htmlFor:"view-section-calendar-date",size:"sm",children:"Place notes by"}),e.jsxs(ee,{id:"view-section-calendar-date",value:w==="property"&&f?`property:${f}`:w,"aria-labelledby":"view-section-calendar-date-label",className:"w-full",onValueChange:r=>{if(r==="createdAt"||r==="updatedAt"){R(r),S(""),$("");return}if(r.startsWith("property:")){const N=r.slice(9),B=Z.get(N);B?.valueType==="date"&&(R("property"),S(B.key),$(""))}},children:[e.jsx(I,{value:"createdAt",children:"Created date"}),e.jsx(I,{value:"updatedAt",children:"Updated date"}),L?e.jsxs(I,{value:`property:${f}`,disabled:!0,children:[f," · unavailable"]}):null,O.map(r=>e.jsxs(I,{value:`property:${r.key}`,children:[r.name," · date property"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"The calendar loads every matching note in the visible month. Date properties use their saved day; reminders are not included."})]})}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{type:"button",variant:"subtle",size:"sm",onClick:It,children:"Add property filter"}),!le&&e.jsx(K,{type:"button",variant:"subtle",size:"sm",onClick:zt,children:"Add tag filter"})]})]}),V.length===0&&!le?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:l?"All notes":"No filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,V.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:V.map(r=>{const N=Z.get(r.key),B=ot(N);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(ee,{value:r.key||ve,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:F=>{F!==ve&&he(r.id,{key:F})},children:[e.jsx(I,{value:ve,disabled:!0,children:"Choose property"}),n.map(F=>e.jsx(I,{value:F.key,children:F.name},F.key))]}),e.jsx(ee,{value:r.operator,disabled:!N,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:F=>he(r.id,{operator:F}),children:B.map(F=>e.jsx(I,{value:F,children:Tt(F)},F))}),we(r.operator)&&N?N.valueType==="select"?e.jsx(ee,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:N.options.map(F=>e.jsx(I,{value:F.value,children:F.label},F.value))}):N.valueType==="boolean"?e.jsxs(ee,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:[e.jsx(I,{value:"true",children:"True"}),e.jsx(I,{value:"false",children:"False"})]}):e.jsx(Ce,{type:ks(N,r.operator),value:r.value,onChange:F=>he(r.id,{value:F.target.value}),placeholder:Ts(N,r.operator),"aria-label":"Property filter value"}):e.jsx(o,{as:"span",variant:"label",tone:"tertiary",children:N?"No value needed":"Choose a property first"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Kt(r.id),children:"Remove"})]},r.id)})}):null,le?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:$t,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(ga,{id:"view-section-tags",value:z,onChange:r=>{u(r.target.value),$("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),X.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{size:"sm",children:"Tag match"}),e.jsxs(Le,{type:"single",value:C,onValueChange:r=>{(r==="and"||r==="or")&&y(r)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"and","aria-label":Ge("and"),children:"AND"}),e.jsx(oe,{value:"or","aria-label":Ge("or"),children:"OR"})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(W,{size:"sm",children:"Existing tags"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:c?"Loading...":`${i.length} available`})]}),i.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(r=>{const N=X.includes(r.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${N?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,"aria-pressed":N,onClick:()=>Rt(r.name),children:r.name},r.id)})})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(o,{as:"p",variant:"meta",tone:me?"default":"tertiary",className:me?"text-fg-error":void 0,children:me||(b||c?"Loading filter options...":`${n.length} properties · ${i.length} tags available`)})]}),x==="calendar"?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Month view"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Calendar sections use month navigation instead of row sorting or pagination."})]}):e.jsxs("details",{className:"group pb-1",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(o,{as:"span",variant:"label",tone:"default",children:"Sort and page size"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"col-start-1 row-start-2",children:x==="board"?"Controls how many cards each board column loads at a time.":"Controls how many matching notes appear on each section page."}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",className:"col-start-2 row-span-2 row-start-1 whitespace-nowrap",children:x==="board"?`${ae} per column`:`${ae} notes`})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(ee,{id:"view-section-sort-by",value:T,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>Q(r),children:[e.jsx(I,{value:"updatedAt",children:"Updated time"}),e.jsx(I,{value:"createdAt",children:"Created time"}),e.jsx(I,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(ee,{id:"view-section-sort-order",value:te,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>H(r),children:[e.jsx(I,{value:"desc",children:"Descending"}),e.jsx(I,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:x==="board"?"Cards per load":"Rows per page"}),e.jsxs(ee,{id:"view-section-limit",value:ae,"aria-labelledby":"view-section-limit-label",onValueChange:re,children:[e.jsxs(I,{value:"3",children:["3 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"5",children:["5 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"8",children:["8 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"10",children:["10 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"12",children:["12 ",x==="board"?"cards":"rows"]})]})]})]})]})]})}),e.jsx(Y.Footer,{children:e.jsxs(yt,{children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:d,children:"Cancel"}),e.jsx(K,{type:"submit",size:"sm",form:"view-section-form",children:a==="create"?"Create section":"Save section"})]})})]})}const Ss="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",Ps="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function As({tab:t,isActive:a,onSelect:s}){const{attributes:i,listeners:n,setNodeRef:c,setActivatorNodeRef:b,transform:d,transition:j,isDragging:k}=bt({id:t.id});return e.jsx("div",{ref:c,style:{transform:Ve.Translate.toString(d),transition:j,opacity:k?.6:1},className:ie(Ss,a?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:b,...i,...n,role:"tab","aria-selected":a,title:`${t.title}. Drag to reorder.`,className:ie(Ps,a?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",k?"cursor-grabbing":"cursor-pointer"),onClick:s,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:t.sections.length})]})})}function Ms({tabs:t,activeTabId:a,onSelectTab:s,onReorderTabs:i,onCreateTab:n}){const c=Se(de(Gt,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(Ae,{sensors:c,collisionDetection:Me,modifiers:[Yt],autoScroll:!1,onDragEnd:b=>{i(b)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ht,{items:t.map(b=>b.id),strategy:Qt,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:t.map(b=>e.jsx(As,{tab:b,isActive:b.id===a,onSelect:()=>{s(b)}},b.id))})}),e.jsxs(K,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:n,children:[e.jsx(Te,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function Vs({open:t,mode:a,initialTitle:s="",onClose:i,onSubmit:n}){const[c,b]=h.useState(s);return h.useEffect(()=>{t&&b(s)},[s,t]),e.jsxs(Y,{isOpen:t,onClose:i,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(Y.Header,{title:a==="create"?"Create view tab":"Rename view tab",onClose:i}),e.jsx(Y.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:d=>{d.preventDefault(),n(c)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(Ce,{id:"view-tab-title",value:c,onChange:d=>b(d.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(Y.Footer,{children:e.jsxs(yt,{children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),e.jsx(K,{type:"submit",size:"sm",form:"view-tab-form",children:a==="create"?"Create tab":"Save tab"})]})})]})}const ct=ja(Na),Fs="Save reusable note queries with tags, shared properties, and sorting.",Es="focus-ring-soft hidden h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default sm:inline-flex touch-none",Os=({section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:x})=>{const{attributes:E,listeners:p,setNodeRef:m,setActivatorNodeRef:v,transform:D,transition:P,isDragging:M}=bt({id:t.id}),w=h.useCallback(R=>x(t.id,R),[x,t.id]);return e.jsx("div",{ref:m,style:{transform:Ve.Translate.toString(D),transition:P,opacity:M?.6:1},children:e.jsx(ws,{section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:w,dragHandle:e.jsx("button",{type:"button",ref:v,"aria-label":`Reorder section ${t.title}`,...E,...p,className:ie(Es,M?"cursor-grabbing":"cursor-grab"),children:e.jsx(mt,{className:"size-4"})})})})};function Zs(){const t=da(),a=ft(),s=gt(),i=ct.useSearch(),n=ct.useNavigate(),[c,b]=h.useState(null),[d,j]=h.useState(null),{data:k,isPending:A,isError:x,refetch:E}=be({queryKey:_.views.workspace(),async queryFn(){const l=await Ht();if(l.type==="error")throw l;return l.viewWorkspace}}),p=k??qa,m=p.tabs.find(l=>l.id===i.tab)??Wa(p),v=m?p.tabs.findIndex(l=>l.id===m.id):-1,{data:D,isPending:P}=be({queryKey:_.tags.list({limit:200}),async queryFn(){const l=await wa({limit:200});if(l.type==="error")throw l;return l.allTags}}),M=Se(de(ut,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt})),w=D?.tags??[],{data:R,isPending:f,isError:S,refetch:z}=be({queryKey:_.notes.propertyKeysCatalog(),async queryFn(){const l=await fa();if(l.type==="error")throw l;return l.notePropertyKeys}}),u=R?.keys??[],C=l=>{s.setQueryData(_.views.workspace(),l)},y=h.useCallback((l,g)=>{n({search:O=>({...O,state:Zt(O.state,l,g)}),replace:!0,resetScroll:!1})},[n]),T=async()=>{await s.invalidateQueries({queryKey:_.views.all(),exact:!1})},Q=async(l,g)=>{C(g);const O=await ia(g.tabs.map(L=>L.id));if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},te=async({active:l,over:g})=>{if(!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=Ct(O,String(l.id),String(g.id));await Q(O,L)},H=async l=>{if(!m)return;const g=s.getQueryData(_.views.workspace())??p,O=Ya(g,m.id,l);O!==g&&await Q(g,O)},ae=async l=>{const g=s.getQueryData(_.views.workspace())??p,O=i,L=Ga(g,l.id);C(L),await n({search:{tab:l.id,state:void 0},resetScroll:!1});const pe=await Ie(l.id);if(pe.type==="error"){C(g),await n({search:O,replace:!0,resetScroll:!1}),a(pe.errors[0].message);return}C(pe.setActiveViewTab)},re=async(l,g)=>{if(!m)return;C(g);const O=await la(m.id,g.tabs.find(L=>L.id===m.id)?.sections.map(L=>L.id)??[]);if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},V=async({active:l,over:g})=>{if(!m||!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=kt(O,m.id,String(l.id),String(g.id));await re(O,L)},q=async(l,g)=>{if(!m)return;const O=s.getQueryData(_.views.workspace())??p,L=Qa(O,m.id,l,g);L!==O&&await re(O,L)},ce=async l=>{const g=await ta(l);if(g.type==="error"){a(g.errors[0].message);return}const O=await Ie(g.createViewTab.id);O.type==="success"?C(O.setActiveViewTab):a(O.errors[0].message),await T(),await n({search:{tab:g.createViewTab.id,state:void 0},resetScroll:!1}),b(null)},ue=async l=>{if(!m)return;const g=await aa(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),b(null)},me=async()=>{if(!m||!await t("Delete this view tab and all of its sections?"))return;const l=await sa(m.id);if(l.type==="error"){a(l.errors[0].message);return}await T(),await n({search:{tab:void 0,state:void 0},replace:!0,resetScroll:!1})},$=async l=>{if(!m)return;const g=await Ke(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),j(null)},Z=async l=>{if(!m||!d||d.mode!=="edit")return;const g=await ra(d.section.id,l);if(g.type==="error"){a(g.errors[0].message);return}y(d.section.id,{}),await T(),j(null)},X=async l=>{const g=await Ke(l.tabId,{...Ja(l),title:`${l.title} copy`});if(g.type==="error"){a(g.errors[0].message);return}await T(),a("Section duplicated.")},le=async l=>{if(!m||!await t("Delete this section from the current view tab?"))return;const g=await na(l);if(g.type==="error"){a(g.errors[0].message);return}y(l,{}),await T()};return e.jsxs(e.Fragment,{children:[e.jsx(va,{title:"Views",description:Fs,children:A&&!k?e.jsx(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(xe,{height:20,width:180,className:"rounded-full"}),e.jsx(xe,{height:16,width:260,className:"rounded-full"}),e.jsx(xe,{height:44,width:140,className:"rounded-[12px]"})]})}):x?e.jsxs(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E()},children:"Retry"})})]}):p.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(qe,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{type:"button",onClick:()=>b({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Ms,{tabs:p.tabs,activeTabId:m?.id??null,onSelectTab:ae,onReorderTabs:te,onCreateTab:()=>b({mode:"create"})}),m&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:m.title}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:m.sections.length>0?`${m.sections.length} section${m.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs(K,{type:"button",size:"sm",onClick:()=>j({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Add section"]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"View tab actions"}),items:[...v>0?[{name:"Move tab left",onClick:()=>{H("previous")}}]:[],...v>=0&&v<p.tabs.length-1?[{name:"Move tab right",onClick:()=>{H("next")}}]:[],...p.tabs.length>1?[{type:"separator"}]:[],{name:"Rename tab",onClick:()=>b({mode:"edit",tab:m})},{type:"separator"},{name:"Delete tab",onClick:()=>{me()}}]})]})]}),m.sections.length===0?e.jsx(qe,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(Ae,{sensors:M,collisionDetection:Me,modifiers:[Xt],onDragEnd:V,children:e.jsx(ht,{items:m.sections.map(l=>l.id),strategy:Jt,children:e.jsx("div",{className:"flex flex-col gap-4",children:m.sections.map((l,g)=>e.jsx(Os,{section:l,availableProperties:u,isPropertiesLoading:f,isPropertiesError:S,onRetryProperties:()=>{z()},navigationState:ea(i.state,l.id),onNavigationStateChange:y,onEdit:()=>j({mode:"edit",section:l}),onDuplicate:()=>{X(l)},onDelete:()=>{le(l.id)},onMoveUp:g>0?()=>{q(l.id,"previous")}:void 0,onMoveDown:g<m.sections.length-1?()=>{q(l.id,"next")}:void 0},l.id))})})})})]})]})}),e.jsx(Vs,{open:c!==null,mode:c?.mode??"create",initialTitle:c?.mode==="edit"?c.tab.title:"",onClose:()=>b(null),onSubmit:l=>{if(c?.mode==="edit"){ue(l);return}ce(l)}}),e.jsx(Ds,{open:d!==null,mode:d?.mode??"create",initialSection:d?.mode==="edit"?d.section:null,availableTags:w,availableProperties:u,isTagsLoading:P,isPropertiesLoading:f,onClose:()=>j(null),onSubmit:l=>{if(d?.mode==="edit"){Z(l);return}$(l)}})]})}export{Zs as default};
1
+ import{r as h,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{f as Lt,u as Se,g as de,K as Pe,P as ut,D as Ae,h as Me,j as _t,k as qt,l as Ut,m as mt,C as Ve,n as Wt,o as pt,M as Gt,r as Yt,S as ht,p as Qt,q as bt,t as Ht,v as Zt,w as Xt,x as Jt,y as ea,z as Ie,A as ta,B as aa,E as sa,G as Ke,H as ra,I as na,J as ia,L as la}from"./app-BFM2V_Rx.js";import{d as se,a as be,k as oa,h as Fe,m as xt,M as yt,u as da}from"./useNoteMutate-BjvZUmtX.js";import{a2 as ca,a3 as Be,a4 as ua,a5 as ma,a6 as pa,A as ha,q as _,T as o,B as K,M as Y,u as gt,W as ba,e as ft,l as xe,c as ie,D as Ee,O as Ne,N as Oe,a7 as xa,k as ya,L as W,I as Ce,a as Le,b as oe,K as _e,x as ee,y as I,d as ga,a8 as fa,P as va,E as qe,h as ja}from"./time-PxWila4-.js";import{f as wa}from"./tag.api-DEUROVKQ.js";import{S as ke}from"./SurfaceCard-D5QxOte_.js";import{N as Re,V as Na}from"./url-DKUMNVCI.js";import{V as G}from"./ViewChip-BVkZAXyx.js";import{e as Ca,g as ka,t as ye,d as Ta,b as Da,c as Sa,C as Pa,a as Aa}from"./calendar-data-wB0ifXdo.js";import{s as Ma}from"./FileText.es-DPIwDCEe.js";import{s as Va}from"./ArrowRight.es-BlNsZQFs.js";import{s as Fa}from"./CheckCircle.es-Dqr3WImn.js";import{n as Te}from"./Plus.es-Dy6onD-Z.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-hVj6vAYJ.js";var Ea=class extends ca{constructor(t,a){super(t,a)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Be()})}getOptimisticResult(t){return t.behavior=Be(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,a){const{state:s}=t,i=super.createResult(t,a),{isFetching:n,isRefetching:c,isError:b,isRefetchError:d}=i,j=s.fetchMeta?.fetchMore?.direction,k=b&&j==="forward",A=n&&j==="forward",x=b&&j==="backward",E=n&&j==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ma(a,s.data),hasPreviousPage:ua(a,s.data),isFetchNextPageError:k,isFetchingNextPage:A,isFetchPreviousPageError:x,isFetchingPreviousPage:E,isRefetchError:d&&!k&&!x,isRefetching:c&&!A&&!E}}};function Oa(t,a){return pa(t,Ea)}const Ra=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),vt=h.forwardRef((t,a)=>h.createElement(ha,{ref:a,...t,weights:Ra}));vt.displayName="CircleIcon";const za=vt,Ue=2,$a=(t,a)=>t.displayOptions.calendarDateField==="property"?a?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",Ia=t=>{const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!a)return null;const s=Number(a[1]),i=Number(a[2]),n=Number(a[3]),c=new Date(Date.UTC(s,i-1,n));return c.getUTCFullYear()!==s||c.getUTCMonth()!==i-1||c.getUTCDate()!==n?null:`${s}-${i}-${n}`},Ka=t=>{const a=ye(t);if(!Number.isFinite(a))return null;const s=se(a);return`${s.year()}-${s.month()+1}-${s.date()}`},Ba=(t,a)=>t.isCurrentMonth?a?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",La=t=>t.isToday?"bg-cta font-semibold text-fg-on-filled":t.isCurrentMonth?t.isSunday?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";function _a({section:t,calendarDateProperty:a,navigationState:s,onNavigationStateChange:i}){const n=se(),c=s.calendar?.year??n.year(),b=s.calendar?.month??n.month()+1,d=se(new Date(c,b-1,1)).format("MMMM YYYY"),j=t.displayOptions.calendarDateField,k=j==="property",A=$a(t,a),x=k?Ca(c,b):ka(c,b),[E,p]=h.useState(),{data:m,isPending:v,isError:D,refetch:P}=be({queryKey:_.views.sectionCalendar(t.id,{year:c,month:b,dateField:j,propertyKey:t.displayOptions.calendarDatePropertyKey}),async queryFn(){const u=await Lt(t.id,x);if(u.type==="error")throw u;return u.viewSectionCalendarNotes}}),M=h.useMemo(()=>{const u=new Map;for(const C of m??[]){const y=k?Ia(C.calendarDate):Ka(C.calendarDate);if(!y)continue;const T=u.get(y)??[];T.push(C),u.set(y,T)}for(const C of u.values())C.sort((y,T)=>(k?y.calendarDate.localeCompare(T.calendarDate):ye(y.calendarDate)-ye(T.calendarDate))||y.id.localeCompare(T.id));return Ta(c,b).map(C=>({...C,notes:u.get(C.key)??[]}))},[m,k,b,c]),w=M.find(u=>u.key===E),R=w?se(new Date(w.year,w.month-1,w.day)).format("dddd, MMMM D"):"Day notes",f=(u,C)=>{const y=u===n.year()&&C===n.month()+1;p(void 0),i(T=>({...T,calendar:y?void 0:{year:u,month:C}}))},S=u=>{const C=new Date(c,b-1+u,1);f(C.getFullYear(),C.getMonth()+1)},z=m?.length??0;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h3",variant:"subheading",weight:"semibold",tracking:"tight",children:d}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Notes placed by ",A.toLowerCase()]})]}),e.jsx(Da,{onToday:()=>f(n.year(),n.month()+1),onPrevMonth:()=>S(-1),onNextMonth:()=>S(1)})]}),D?e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this calendar"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:["Retry to refresh notes for ",d,"."]}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>{P()},children:"Retry"})})]}):e.jsx("div",{className:"min-w-0 px-4 py-3.5",children:e.jsx(Sa,{isLoading:v,ariaLabel:`${d} note calendar`,children:M.map(u=>{const C=u.key===E,y=u.notes.slice(0,Ue).map(T=>({key:`note-${T.id}`,type:"note",title:T.title||"Untitled"}));return e.jsx(Pa,{day:u.day,dateLabel:se(new Date(u.year,u.month-1,u.day)).format("dddd, MMMM D, YYYY"),cellClassName:Ba(u,C),dayNumberClassName:La(u),isCurrentMonth:u.isCurrentMonth,isToday:u.isToday,isSelected:C,noteCount:u.notes.length,reminderCount:0,previewItems:y,overflowCount:Math.max(0,u.notes.length-Ue),density:"compact",showReminderSummary:!1,onSelect:()=>p(u.key)},u.key)})})}),e.jsx("div",{className:"mt-auto border-t border-border-subtle/75 px-4 py-3",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:v?"Loading calendar notes...":D?`Calendar notes for ${d} are unavailable`:z===0?`No matching notes in ${d}`:`${z} matching note${z===1?"":"s"} in ${d}`})}),e.jsxs(Y,{isOpen:!!w,onClose:()=>p(void 0),variant:"inspect",children:[e.jsx(Y.Header,{title:R,onClose:()=>p(void 0)}),e.jsxs(Y.Body,{children:[e.jsxs(Y.Description,{className:"sr-only",children:["View matching notes placed on ",R," by ",A.toLowerCase(),"."]}),e.jsxs(o,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:[w?.notes.length??0," matching"," ",(w?.notes.length??0)===1?"note":"notes"]}),e.jsx("div",{className:"flex flex-col gap-1",children:w?.notes.map(u=>e.jsx(Aa,{params:{id:u.id},header:e.jsx(Ma,{size:12}),title:u.title||"Untitled",meta:k?void 0:se(ye(u.calendarDate)).format("HH:mm")},u.id))})]})]})]})}const ge=6,De=["title","tags","properties","createdAt","updatedAt"],jt="createdAt",qa={activeTabId:null,tabs:[]},Ua=t=>{const a=t.trim();return a?a.startsWith("@")?a:a.startsWith("#")?"":`@${a}`:""},wt=(t,a,s)=>{if(a===s)return t;const i=t.findIndex(d=>d.id===a),n=t.findIndex(d=>d.id===s);if(i<0||n<0)return t;const c=[...t],[b]=c.splice(i,1);return c.splice(n,0,b),c},Nt=(t,a,s)=>{const i=t.findIndex(c=>c.id===a),n=i+(s==="previous"?-1:1);return i>=0&&n>=0&&n<t.length?t[n]?.id:void 0},We=t=>{const a=t.flatMap(s=>typeof s=="string"?s.split(","):[]);return Array.from(new Set(a.map(Ua).filter(Boolean)))},Wa=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(a=>a.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,Ga=(t,a)=>t.tabs.some(s=>s.id===a)?{...t,activeTabId:a}:t,Ct=(t,a,s)=>({...t,tabs:wt(t.tabs,a,s)}),kt=(t,a,s,i)=>({...t,tabs:t.tabs.map(n=>n.id===a?{...n,sections:wt(n.sections,s,i)}:n)}),Ya=(t,a,s)=>{const i=Nt(t.tabs,a,s);return i?Ct(t,a,i):t},Qa=(t,a,s,i)=>{const n=t.tabs.find(b=>b.id===a)?.sections??[],c=Nt(n,s,i);return c?kt(t,a,s,c):t},Ge=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",Ha=t=>t==="or"?"OR":"AND",Tt=t=>{switch(t){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},Za=t=>{switch(t){case"table":return"Table";case"board":return"Board";case"calendar":return"Calendar";default:return"List"}},Dt=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},fe=t=>{const a=new Set(De),s=(t??[]).filter(n=>a.has(n)),i=Array.from(new Set(s));return i.length===0?[...De]:i.includes("title")?i:["title",...i]},ze=t=>Array.from(new Set((t??[]).map(a=>a.trim()).filter(Boolean))).slice(0,ge),St=t=>t==="updatedAt"||t==="property"?t:jt,Pt=t=>{const a=St(t?.calendarDateField);return{tableColumns:fe(t?.tableColumns),tablePropertyKeys:ze(t?.tablePropertyKeys),boardGroupByPropertyKey:t?.boardGroupByPropertyKey?.trim()||null,calendarDateField:a,calendarDatePropertyKey:a==="property"&&t?.calendarDatePropertyKey?.trim()||null}},Xa=t=>{const a=Tt(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${a}`:`${t.name} ${a} ${t.value??""}`.trim()},Ja=(t,a={})=>{const s={...t,...a};return{title:s.title,displayType:s.displayType,displayOptions:Pt(s.displayOptions),tagNames:s.tagNames,mode:s.mode,propertyFilters:s.propertyFilters.map(i=>({key:i.key,valueType:i.valueType,operator:i.operator,value:i.value})),sortBy:s.sortBy,sortOrder:s.sortOrder,limit:s.limit}},At="view-board-column:unassigned",es=t=>t===null?At:`view-board-column:value:${encodeURIComponent(t)}`,ts=t=>[...[...t].sort((a,s)=>a.order-s.order||a.label.localeCompare(s.label)).map(a=>({id:es(a.value),label:a.label,value:a.value,color:a.color??null})),{id:At,label:"Unassigned",value:null,color:null}];function as({note:t,column:a,columns:s,isMoving:i,onMove:n}){const{attributes:c,listeners:b,setNodeRef:d,setActivatorNodeRef:j,transform:k,isDragging:A}=Ut({id:`view-board-note:${t.id}`,data:{note:t,sourceValue:a.value},disabled:i});return e.jsx("article",{ref:d,style:{transform:Ve.Translate.toString(k)},className:ie("group rounded-[14px] border border-border-subtle bg-elevated px-3 py-2.5 transition-[opacity,background-color,border-color] hover:border-border-secondary/80 hover:bg-hover-subtle/35",(A||i)&&"opacity-55",A&&"z-20 border-accent-primary/45 bg-elevated ring-2 ring-accent-primary/10"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",ref:j,"aria-label":`Drag ${t.title||"Untitled"} to another column`,...c,...b,className:"focus-ring-soft mt-0.5 hidden size-7 shrink-0 touch-none items-center justify-center rounded-[9px] text-fg-tertiary outline-none hover:bg-hover-subtle hover:text-fg-default sm:inline-flex",children:e.jsx(mt,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"leading-[1.4]",children:e.jsx(Ee,{to:Re,params:{id:t.id},className:"line-clamp-2 transition-colors hover:text-fg-default/80",children:t.title||"Untitled"})}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:["Updated ",Ne(Number(t.updatedAt))]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:`Move ${t.title||"Untitled"}`,size:"sm"}),items:s.filter(x=>x.value!==a.value).map(x=>({name:`Move to ${x.label}`,onClick:()=>n(t,a.value,x.value)}))})]})})}function ss({section:t,groupProperty:a,column:s,columns:i,index:n,scrollRootRef:c,movingNoteIds:b,onMove:d,pageCount:j,onPageCountChange:k}){const A=h.useRef(null),[x,E]=h.useState(n<4),{isOver:p,setNodeRef:m}=_t({id:s.id,data:{optionValue:s.value}});h.useEffect(()=>{if(x||!A.current)return;if(typeof IntersectionObserver>"u"){E(!0);return}const y=new IntersectionObserver(T=>{T.some(Q=>Q.isIntersecting)&&(E(!0),y.disconnect())},{root:c.current,rootMargin:"0px 320px",threshold:.01});return y.observe(A.current),()=>y.disconnect()},[c,x]);const{data:v,isPending:D,isError:P,refetch:M,fetchNextPage:w,hasNextPage:R,isFetchingNextPage:f,isFetchNextPageError:S}=Oa({queryKey:_.views.sectionBoardColumnPages(t.id,a.key,s.value,t.limit),enabled:x,initialPageParam:0,async queryFn({pageParam:y}){const T=await qt(t.id,{optionValue:s.value,limit:t.limit,offset:y});if(T.type==="error")throw T;return T.viewSectionBoardColumn},getNextPageParam(y,T){return T.reduce((te,H)=>te+H.notes.length,0)<y.totalCount?T.length*t.limit:void 0}}),z=h.useMemo(()=>Array.from(new Map((v?.pages??[]).flatMap(y=>y.notes).map(y=>[y.id,y])).values()),[v?.pages]),u=v?.pages[0]?.totalCount;h.useEffect(()=>{!x||!v||v.pages.length>=j||!R||f||S||w()},[v,w,R,S,f,j,x]),h.useEffect(()=>{if(u===void 0)return;const y=Math.max(1,Math.ceil(u/t.limit));j>y&&k(y)},[k,j,t.limit,u]);const C=y=>{A.current=y,m(y)};return e.jsxs("section",{ref:C,"aria-label":`${s.label} column`,className:ie("flex min-h-[248px] w-[17rem] shrink-0 flex-col rounded-[18px] border bg-subtle/30 transition-[border-color,background-color] sm:w-[18rem]",p?"border-accent-primary/50 bg-accent-primary/6":"border-border-subtle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border-subtle/75 px-3.5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-full border border-black/5",style:{backgroundColor:s.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx(o,{as:"h3",variant:"label",weight:"semibold",className:"truncate",children:s.label})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary","aria-label":u===void 0?"Card count loading":`${u} cards`,className:"inline-flex min-w-6 justify-center rounded-full bg-elevated px-2 py-0.5 tabular-nums",children:u??"–"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-2.5",children:[x?D&&!v?e.jsxs(e.Fragment,{children:[e.jsx(xe,{height:"76px",className:"rounded-[14px]"}),e.jsx(xe,{height:"76px",className:"rounded-[14px]"})]}):P?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-border-subtle bg-elevated/60 p-3",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Failed to load this column."}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"mt-2",onClick:()=>{M()},children:"Retry"})]}):z.length===0?e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-center",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Drop a note here"})}):z.map(y=>e.jsx(as,{note:y,column:s,columns:i,isMoving:b.has(y.id),onMove:d},y.id)):e.jsx("button",{type:"button",className:"focus-ring-soft flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-sm text-fg-tertiary outline-none hover:bg-elevated",onClick:()=>E(!0),children:"Load cards"}),R?e.jsx(K,{type:"button",variant:"ghost",size:"sm",className:"mt-auto w-full",disabled:f,onClick:()=>{S||k(j+1),w()},children:f?"Loading...":S?"Retry loading cards":`Load more (${Math.max(0,(u??0)-z.length)})`}):null]})]})}function rs({section:t,groupProperty:a,navigationState:s={},onNavigationStateChange:i=()=>{}}){const n=gt(),c=ft(),b=h.useRef(null),[d,j]=h.useState(()=>new Set),k=h.useMemo(()=>ts(a.options),[a.options]),A=Se(de(ut,{activationConstraint:{distance:6}}),de(Pe)),x=h.useCallback(async(p,m,v)=>{if(m===v||d.has(p.id))return;j(M=>new Set(M).add(p.id));const D=_.views.sectionBoardAll(t.id),P=n.getQueriesData({queryKey:D});for(const[M,w]of P){if(!w||!Array.isArray(w.pages))continue;const R=M[3];if(R?.groupPropertyKey!==a.key)continue;const f=R.optionValue===m,S=R.optionValue===v,z=R.pageSize??t.limit;let u=w.pages.flatMap(y=>y.notes).filter(y=>y.id!==p.id);S&&(u=[p,...u]);const C=Math.max(0,(w.pages[0]?.totalCount??0)-(f?1:0)+(S?1:0));n.setQueryData(M,{...w,pages:w.pages.map((y,T)=>({totalCount:C,notes:u.slice(T*z,(T+1)*z)}))})}try{const M=await ba({id:p.id,expectedUpdatedAt:p.updatedAt,...v===null?{deleteKeys:[a.key]}:{set:[{key:a.key,name:a.name,value:v,valueType:"select"}]}});if(M.type==="error"){for(const[w,R]of P)n.setQueryData(w,R);c(M.errors[0]?.message??"Failed to move this note.");return}await Promise.all([oa(n),n.invalidateQueries({queryKey:_.notes.propertyKeysAll(),exact:!1})])}catch{for(const[M,w]of P)n.setQueryData(M,w);c("Failed to move this note.")}finally{j(M=>{const w=new Set(M);return w.delete(p.id),w})}},[a.key,a.name,d,n,t.id,t.limit,c]),E=({active:p,over:m})=>{const v=p.data.current?.note,D=p.data.current?.sourceValue,P=m?.data.current?.optionValue;!v||D===void 0||P===void 0||x(v,D,P)};return e.jsx(Ae,{sensors:A,collisionDetection:Me,onDragEnd:E,children:e.jsx("div",{ref:b,"data-scroll-restoration-id":`view-board-${t.id}`,className:"overflow-x-auto overscroll-x-contain px-3 py-3.5 [scrollbar-gutter:stable] sm:px-4","aria-label":`Board grouped by ${a.name}`,children:e.jsx("div",{className:"flex min-w-max items-stretch gap-3 pb-1",children:k.map((p,m)=>e.jsx(ss,{section:t,groupProperty:a,column:p,columns:k,index:m,scrollRootRef:b,movingNoteIds:d,pageCount:s.columns?.[p.id]??1,onPageCountChange:v=>i(D=>({...D,columns:{...D.columns,[p.id]:v}})),onMove:(v,D,P)=>{x(v,D,P)}},p.id))})})})}const ns="group flex min-h-[72px] items-center justify-between gap-3 px-4 py-3 transition-colors hover:bg-hover-subtle",is=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,ls=t=>{const a=t.tags.slice(0,2),s=t.tags.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0&&e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})},os=t=>{const a=t.properties??[],s=a.slice(0,2),i=a.length-s.length;return s.length===0?null:e.jsxs(e.Fragment,{children:[s.map(n=>e.jsxs(G,{size:"compact",truncateContent:!1,className:"max-w-[220px] gap-1.5 border-border-subtle bg-subtle/55 text-fg-secondary",children:[n.valueType==="select"?e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:n.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}):null,e.jsx("span",{className:"max-w-[72px] shrink truncate text-fg-tertiary",children:n.name}),e.jsx("span",{className:"min-w-0 truncate",children:is(n)||"—"})]},n.key)),i>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",i," properties"]}):null]})};function ds({notes:t,isPending:a,isError:s,onRetry:i}){return a?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[72px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):s?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:t.map(n=>e.jsxs(Ee,{to:Re,params:{id:n.id},className:ns,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"line-clamp-1",children:n.title||"Untitled"})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[os(n),ls(n),e.jsxs(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"sm:hidden",children:["Updated ",Ne(Number(n.updatedAt))]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pl-2",children:[e.jsx(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"hidden sm:inline",children:Ne(Number(n.updatedAt))}),e.jsx(Va,{className:"size-4 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]})]},n.id))})}const cs={title:300,tags:200,createdAt:148,updatedAt:148},us={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},ms="flex h-[24px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",Mt="text-xs leading-5 text-fg-tertiary",ps=t=>se(Number(t)).format("MMM D, YYYY"),hs=t=>t==="text"||t==="url"?220:t==="date"?168:156,Vt=t=>t.kind==="property"?hs(t.valueType):cs[t.key],bs=(t,a,s)=>{const i=new Map(s.map(d=>[d.key,d])),n=new Map(a.flatMap(d=>d.properties??[]).map(d=>[d.key,d])),c=ze(t.displayOptions.tablePropertyKeys),b=Array.from(new Set([...t.propertyFilters.map(d=>d.key),...a.flatMap(d=>(d.properties??[]).map(j=>j.key))])).slice(0,3);return(c.length>0?c:b).flatMap(d=>{const j=i.get(d),k=n.get(d);return!j&&!k?[]:[{kind:"property",key:d,name:j?.name??k?.name??d,valueType:j?.valueType??k?.valueType??"text"}]})},xs=(t,a,s)=>{const i=bs(t,a,s);return fe(t.displayOptions.tableColumns).reduce((n,c)=>(c==="properties"?n.push(...i):n.push({kind:"base",key:c}),n),[])},ys=t=>t.reduce((a,s)=>a+Vt(s),0),gs=t=>{if(t.tags.length===0)return e.jsx("span",{className:Mt,children:"—"});const a=t.tags.slice(0,3),s=t.tags.length-a.length;return e.jsxs("div",{className:ms,children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]}):null]})},fs=t=>{if(!t)return e.jsx("span",{className:Mt,children:"—"});if(t.valueType==="select")return e.jsx(G,{size:"compact",className:"max-w-full border-border-subtle bg-subtle/65 text-fg-secondary",truncateContent:!1,children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:t.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:t.option?.label??t.value})]})});if(t.valueType==="boolean"){const a=t.value==="true",s=a?Fa:za;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-fg-secondary",children:[e.jsx(s,{className:"size-3.5 text-fg-tertiary",weight:a?"fill":"regular"}),a?"True":"False"]})}return e.jsx("span",{className:ie("block truncate text-sm text-fg-secondary",t.valueType==="number"&&"tabular-nums"),title:t.value,children:t.value||"—"})};function vs({section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:c,isSortPending:b,activeSortBy:d=t.sortBy,activeSortOrder:j=t.sortOrder,availableProperties:k=[],surface:A="flush"}){const x=xs(t,a,k),E=ys(x),p=A==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",m=A==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",v=A==="card"?"bg-elevated":"bg-transparent",D=A==="card"?"bg-subtle/65":"bg-subtle/45",P=A==="card"?"bg-elevated":"bg-transparent",M=A==="card"?"var(--elevated)":"var(--surface)",w=f=>{if(f.kind==="property")return e.jsxs("th",{className:"px-3 py-2 text-left",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",className:"truncate",title:f.name,children:f.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5 capitalize",children:f.valueType})]},`property:${f.key}`);const S=us[f.key],z=Dt(f.key),u=S?d===S:!1,C=f.key==="title";return e.jsx("th",{"aria-sort":u?j==="asc"?"ascending":"descending":void 0,className:ie("px-3 py-2.5 text-xs font-semibold text-fg-tertiary",C&&"lg:sticky lg:left-0 lg:z-20"),style:C?{background:`linear-gradient(var(--subtle), var(--subtle)), ${M}`}:void 0,children:S?e.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:b,onClick:()=>c(S),children:[e.jsx("span",{children:z}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:u?j==="asc"?"↑":"↓":"↕"})]}):z},f.key)},R=(f,S)=>{if(S.kind==="property")return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:fs(f.properties?.find(z=>z.key===S.key))},`property:${S.key}`);switch(S.key){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:gs(f)},S.key);case"createdAt":case"updatedAt":{const z=S.key==="createdAt"?f.createdAt:f.updatedAt;return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",title:se(Number(z)).format("MMM D, YYYY h:mm A"),children:ps(z)})},S.key)}default:return e.jsxs("td",{className:"relative px-3 py-2.5 align-middle lg:sticky lg:left-0 lg:z-10",style:{background:M},children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-hover-subtle opacity-0 transition-opacity group-hover:opacity-100"}),e.jsxs("div",{className:"relative z-10 flex min-w-0 items-center gap-2",children:[f.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",className:"min-w-0 line-clamp-1",children:e.jsx(Ee,{to:Re,params:{id:f.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/80",children:f.title||"Untitled"})})]})]},S.key)}};return s?e.jsxs("div",{className:m,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`})]}):i?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Retry"})})]}):a.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:p,"data-scroll-restoration-id":`view-table-${t.id}`,"aria-label":"Scrollable view table",children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:E},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:x.map(f=>e.jsx("col",{style:{width:`${Vt(f)/E*100}%`}},f.kind==="property"?`property:${f.key}`:f.key))}),e.jsx("thead",{className:D,children:e.jsx("tr",{className:"border-b border-border-subtle",children:x.map(w)})}),e.jsx("tbody",{className:P,children:a.map(f=>e.jsx("tr",{className:"group h-12 border-b border-border-subtle/70 last:border-b-0",children:x.map(S=>R(f,S))},f.id))})]})})}const Ye=({displayName:t,onRetry:a})=>e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsxs(o,{as:"p",variant:"body",weight:"semibold",children:["Failed to load ",t," properties"]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to check the configured property without changing this view."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:a,children:"Retry"})})]});function js({section:t,notes:a,isPending:s,isError:i,onRetry:n,onEdit:c,onSortChange:b,isSortPending:d,activeSortBy:j=t.sortBy,activeSortOrder:k=t.sortOrder,availableProperties:A=[],isPropertiesLoading:x=!1,isPropertiesError:E=!1,onRetryProperties:p=()=>{},navigationState:m={},onNavigationStateChange:v=()=>{}}){if(t.displayType==="board"){const D=A.find(P=>P.key===t.displayOptions.boardGroupByPropertyKey&&P.valueType==="select");return!D&&x?e.jsxs("div",{className:"flex gap-3 overflow-hidden px-4 py-3.5",children:[e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"})]}):!D&&E?e.jsx(Ye,{displayName:"board",onRetry:p}):!D||D.options.length===0?e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Board grouping is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing select property with options to restore this board."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit board"})})]}):e.jsx(rs,{section:t,groupProperty:D,navigationState:m,onNavigationStateChange:v})}if(t.displayType==="table")return e.jsx(vs,{section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:b,isSortPending:d,activeSortBy:j,activeSortOrder:k,availableProperties:A});if(t.displayType==="calendar"){const D=t.displayOptions.calendarDateField==="property"?A.find(P=>P.key===t.displayOptions.calendarDatePropertyKey&&P.valueType==="date"):void 0;return t.displayOptions.calendarDateField==="property"&&!D?x?e.jsx("div",{className:"m-4 h-[320px] animate-pulse rounded-[18px] bg-subtle/50"}):E?e.jsx(Ye,{displayName:"calendar",onRetry:p}):e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Calendar date property is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing date property to restore this calendar."}),e.jsx("div",{className:"mt-3",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit calendar"})})]}):e.jsx(_a,{section:t,calendarDateProperty:D,navigationState:m,onNavigationStateChange:v})}return e.jsx(ds,{notes:a,isPending:s,isError:i,onRetry:n})}function ws({section:t,onEdit:a,onDuplicate:s,onDelete:i,onMoveUp:n,onMoveDown:c,dragHandle:b,availableProperties:d=[],isPropertiesLoading:j=!1,isPropertiesError:k=!1,onRetryProperties:A=()=>{},navigationState:x={},onNavigationStateChange:E=()=>{}}){const p=t.displayType==="board",m=t.displayType==="calendar",v=x.page??1,D=(v-1)*t.limit,P=x.sort?.by??t.sortBy,M=x.sort?.order??t.sortOrder,{data:w,isPending:R,isError:f,isPlaceholderData:S,refetch:z}=be({queryKey:_.views.sectionNotes(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:M}),enabled:!p&&!m,placeholderData:xa,async queryFn(){const V=await Wt(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:M});if(V.type==="error")throw V;return V.viewSectionNotes}}),u=w?.notes??[],C=w?.totalCount??0,y=Math.max(1,Math.ceil(C/t.limit)),T=Ha(t.mode),Q=t.tagNames.length>0||t.propertyFilters.length>0,te=p?d.find(V=>V.key===t.displayOptions.boardGroupByPropertyKey):null,H=m?d.find(V=>V.key===t.displayOptions.calendarDatePropertyKey):null,ae=t.displayOptions.calendarDateField==="property"?H?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",re=V=>{const q=P===V?M==="asc"?"desc":"asc":V==="title"?"asc":"desc";E(ce=>({...ce,page:1,sort:{by:V,order:q}}))};return h.useEffect(()=>{p||m||R||f||S||!w||v<=y||E(V=>({...V,page:y}))},[w,p,m,f,R,S,y,E,v]),e.jsxs(ke,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[b&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:b}),e.jsx("div",{className:"min-w-0",children:e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx("span",{className:"truncate",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Za(t.displayType)}),p&&t.displayOptions.boardGroupByPropertyKey?e.jsxs(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:["Grouped by ",te?.name??t.displayOptions.boardGroupByPropertyKey]}):null,m?e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:ae}):null,t.tagNames.map((V,q)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[q>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:T}),e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:V})]},V)),t.propertyFilters.map(V=>e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Xa(V)},`${V.key}-${V.operator}-${V.value??""}`)),!Q&&e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"Section actions"}),items:[...n?[{name:"Move up",onClick:n}]:[],...c?[{name:"Move down",onClick:c}]:[],...n||c?[{type:"separator"}]:[],{name:"Edit section",onClick:a},{name:"Duplicate section",onClick:s},{type:"separator"},{name:"Delete section",onClick:i}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(js,{section:t,notes:u,isPending:R,isError:f,onRetry:()=>{z()},onEdit:a,onSortChange:re,isSortPending:S,activeSortBy:P,activeSortOrder:M,availableProperties:d,isPropertiesLoading:j,isPropertiesError:k,onRetryProperties:A,navigationState:x,onNavigationStateChange:E})}),m?null:e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:p?`${t.limit} cards per column load`:R||S?"Loading notes...":C===0?"No matching notes":`Showing ${D+1}–${Math.min(D+u.length,C)} of ${C} notes`}),!p&&y>1?e.jsx(ya,{page:Math.min(v,y),last:y,className:"!mt-0 shrink-0 sm:justify-end",onChange:V=>E(q=>({...q,page:V}))}):null]})]})}const ve="__choose_property__",je="__choose_board_group__",Ns=["title","tags","properties","createdAt","updatedAt"],Qe=t=>String(t?.limit??5),He=t=>t?.displayType??"list",Ze=t=>fe(t?.displayOptions?.tableColumns??De),Xe=t=>ze(t?.displayOptions?.tablePropertyKeys),Je=t=>t?.displayOptions?.boardGroupByPropertyKey??"",et=t=>St(t?.displayOptions?.calendarDateField??jt),tt=t=>t?.displayOptions?.calendarDatePropertyKey??"",at=t=>t?.mode??"and",st=t=>t?t.tagNames.join(", "):"",rt=t=>t?.title??"",nt=t=>t?.sortBy??"updatedAt",it=t=>t?.sortOrder??"desc",Ft=t=>`property-filter-${Date.now()}-${t}`,lt=t=>(t?.propertyFilters??[]).map((a,s)=>({id:Ft(s),key:a.key,operator:a.operator,value:a.value??""})),ot=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],dt=t=>t?"equals":"exists",Cs=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",we=t=>t!=="exists"&&t!=="notExists",Et=t=>t==="contains"||t==="notContains",ks=(t,a)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Et(a)?"url":"text",Ts=(t,a)=>{if(t.valueType==="url")return Et(a)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Ds({open:t,mode:a,initialSection:s=null,availableTags:i,availableProperties:n,isTagsLoading:c=!1,isPropertiesLoading:b=!1,onClose:d,onSubmit:j}){const[k,A]=h.useState(rt(s)),[x,E]=h.useState(He(s)),[p,m]=h.useState(Ze(s)),[v,D]=h.useState(Xe(s)),[P,M]=h.useState(Je(s)),[w,R]=h.useState(et(s)),[f,S]=h.useState(tt(s)),[z,u]=h.useState(st(s)),[C,y]=h.useState(at(s)),[T,Q]=h.useState(nt(s)),[te,H]=h.useState(it(s)),[ae,re]=h.useState(Qe(s)),[V,q]=h.useState(lt(s)),[ce,ue]=h.useState((s?.tagNames.length??0)>0),[me,$]=h.useState(""),Z=h.useMemo(()=>new Map(n.map(r=>[r.key,r])),[n]);h.useEffect(()=>{t&&(A(rt(s)),E(He(s)),m(Ze(s)),D(Xe(s)),M(Je(s)),R(et(s)),S(tt(s)),u(st(s)),y(at(s)),Q(nt(s)),H(it(s)),re(Qe(s)),q(lt(s)),ue((s?.tagNames.length??0)>0),$(""))},[s,t]);const X=We([z]),le=ce||X.length>0,l=X.length===0&&V.length===0,g=n.filter(r=>r.valueType==="select"&&r.options.length>0),O=n.filter(r=>r.valueType==="date"),L=w==="property"&&!!f&&!O.some(r=>r.key===f),pe=r=>{r!=="title"&&(m(N=>{if(N.includes(r)){const B=N.filter(F=>F!==r);return B.length>0?B:N}return fe([...N,r])}),$(""))},Ot=r=>{D(N=>N.includes(r)?N.filter(B=>B!==r):N.length>=ge?N:[...N,r])},Rt=r=>{const N=X.includes(r)?X.filter(B=>B!==r):[...X,r];u(N.join(", ")),$("")},zt=()=>{ue(!0),$("")},$t=()=>{u(""),y("and"),ue(!1),$("")},It=()=>{if(n.length===0){$("Create a shared property before adding a filter.");return}q(r=>[...r,{id:Ft(r.length),key:"",operator:"exists",value:""}]),$("")},he=(r,N)=>{q(B=>B.map(F=>{if(F.id!==r)return F;const J={...F,...N},ne=Z.get(J.key);return ot(ne).includes(J.operator)||(J.operator=dt(ne)),"key"in N&&(J.value=Cs(ne),J.operator=dt(ne)),J})),$("")},Kt=r=>{q(N=>N.filter(B=>B.id!==r)),$("")};return e.jsxs(Y,{isOpen:t,onClose:d,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(Y.Header,{title:a==="create"?"Create section":"Edit section",onClose:d}),e.jsx(Y.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const N=We([z]);if(le&&N.length===0){$("Choose at least one tag, or remove this tag filter.");return}if(V.find(U=>!U.key||!Z.has(U.key))){$("Choose a property for every filter.");return}const F=Z.get(P);if(x==="board"&&(!F||F.valueType!=="select"||F.options.length===0)){$("Choose a select property with at least one option for the board columns.");return}if(x==="board"&&V.some(U=>U.key===P)){$("Use different properties for the board columns and the section filter.");return}const J=Z.get(f);if(x==="calendar"&&w==="property"&&(!J||J.valueType!=="date")){$("Choose a date property for the calendar.");return}const ne=V.map(U=>{const $e=Z.get(U.key);return{key:$e?.key??U.key,valueType:$e?.valueType??"text",operator:U.operator,value:we(U.operator)?U.value:null}});if(ne.some(U=>we(U.operator)&&!U.value?.trim())){$("Fill every filter value, or switch it to is set / is empty.");return}j({title:k,displayType:x,displayOptions:Pt({tableColumns:p,tablePropertyKeys:v,boardGroupByPropertyKey:P,calendarDateField:w,calendarDatePropertyKey:f}),tagNames:N,mode:C,propertyFilters:ne,sortBy:T,sortOrder:te,limit:Number(ae)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(Ce,{id:"view-section-title",value:k,onChange:r=>A(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Display"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same note set as a list, table, property board, or calendar."})]}),e.jsxs(Le,{type:"single",value:x,onValueChange:r=>{(r==="list"||r==="table"||r==="board"||r==="calendar")&&(E(r),r==="board"&&!g.some(N=>N.key===P)&&M(g[0]?.key??""),$(""))},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(oe,{value:"table","aria-label":"Show as table",children:"Table"}),e.jsx(oe,{value:"board","aria-label":"Show as board",children:"Board"}),e.jsx(oe,{value:"calendar","aria-label":"Show as calendar",children:"Calendar"})]}),x==="table"?e.jsxs("div",{className:"border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(W,{size:"sm",children:"Table columns"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:p.includes("properties")&&v.length===0?"Properties automatic":`${p.length-(p.includes("properties")?1:0)+(p.includes("properties")?v.length:0)} shown`})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:Ns.map(r=>{const N=Dt(r);return e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:p.includes(r),disabled:r==="title","aria-label":`Show ${N} column`,onChange:()=>pe(r)}),e.jsx(o,{as:"span",variant:"label",tone:"secondary",children:N})]},r)})}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."}),p.includes("properties")?e.jsxs("div",{className:"mt-3 border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Property columns"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Select up to ",ge," properties to compare."]})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:v.length>0?`${v.length} selected`:"Automatic"})]}),n.length>0?e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:n.map(r=>{const N=v.includes(r.key),B=v.length>=ge;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:N,disabled:!N&&B,"aria-label":`Show ${r.name} property column`,onChange:()=>Ot(r.key)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"secondary",truncate:!0,children:r.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",children:r.valueType})]})]},r.key)})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-3",children:"Shared properties will appear here after you create them."}),v.length===0&&n.length>0?e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Automatic mode shows up to three properties relevant to the current notes."}):null]}):null]}):null,x==="board"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-board-group-label",htmlFor:"view-section-board-group",size:"sm",children:"Board columns"}),e.jsxs(ee,{id:"view-section-board-group",value:P||je,"aria-labelledby":"view-section-board-group-label",className:"w-full",onValueChange:r=>{r!==je&&(M(r),$(""))},children:[e.jsx(I,{value:je,disabled:!0,children:"Choose a select property"}),g.map(r=>e.jsxs(I,{value:r.key,children:[r.name," · ",r.options.length," columns"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Moving a card changes this property. Notes without a value stay in Unassigned."}),g.length===0&&!b?e.jsx(o,{as:"p",variant:"meta",className:"text-fg-error",children:"Create a shared select property with options before using a board."}):null]})}):null,x==="calendar"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-calendar-date-label",htmlFor:"view-section-calendar-date",size:"sm",children:"Place notes by"}),e.jsxs(ee,{id:"view-section-calendar-date",value:w==="property"&&f?`property:${f}`:w,"aria-labelledby":"view-section-calendar-date-label",className:"w-full",onValueChange:r=>{if(r==="createdAt"||r==="updatedAt"){R(r),S(""),$("");return}if(r.startsWith("property:")){const N=r.slice(9),B=Z.get(N);B?.valueType==="date"&&(R("property"),S(B.key),$(""))}},children:[e.jsx(I,{value:"createdAt",children:"Created date"}),e.jsx(I,{value:"updatedAt",children:"Updated date"}),L?e.jsxs(I,{value:`property:${f}`,disabled:!0,children:[f," · unavailable"]}):null,O.map(r=>e.jsxs(I,{value:`property:${r.key}`,children:[r.name," · date property"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"The calendar loads every matching note in the visible month. Date properties use their saved day; reminders are not included."})]})}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(K,{type:"button",variant:"subtle",size:"sm",onClick:It,children:"Add property filter"}),!le&&e.jsx(K,{type:"button",variant:"subtle",size:"sm",onClick:zt,children:"Add tag filter"})]})]}),V.length===0&&!le?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:l?"All notes":"No filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,V.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:V.map(r=>{const N=Z.get(r.key),B=ot(N);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(ee,{value:r.key||ve,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:F=>{F!==ve&&he(r.id,{key:F})},children:[e.jsx(I,{value:ve,disabled:!0,children:"Choose property"}),n.map(F=>e.jsx(I,{value:F.key,children:F.name},F.key))]}),e.jsx(ee,{value:r.operator,disabled:!N,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:F=>he(r.id,{operator:F}),children:B.map(F=>e.jsx(I,{value:F,children:Tt(F)},F))}),we(r.operator)&&N?N.valueType==="select"?e.jsx(ee,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:N.options.map(F=>e.jsx(I,{value:F.value,children:F.label},F.value))}):N.valueType==="boolean"?e.jsxs(ee,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:[e.jsx(I,{value:"true",children:"True"}),e.jsx(I,{value:"false",children:"False"})]}):e.jsx(Ce,{type:ks(N,r.operator),value:r.value,onChange:F=>he(r.id,{value:F.target.value}),placeholder:Ts(N,r.operator),"aria-label":"Property filter value"}):e.jsx(o,{as:"span",variant:"label",tone:"tertiary",children:N?"No value needed":"Choose a property first"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>Kt(r.id),children:"Remove"})]},r.id)})}):null,le?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:$t,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(ga,{id:"view-section-tags",value:z,onChange:r=>{u(r.target.value),$("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),X.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{size:"sm",children:"Tag match"}),e.jsxs(Le,{type:"single",value:C,onValueChange:r=>{(r==="and"||r==="or")&&y(r)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"and","aria-label":Ge("and"),children:"AND"}),e.jsx(oe,{value:"or","aria-label":Ge("or"),children:"OR"})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(W,{size:"sm",children:"Existing tags"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:c?"Loading...":`${i.length} available`})]}),i.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(r=>{const N=X.includes(r.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${N?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,"aria-pressed":N,onClick:()=>Rt(r.name),children:r.name},r.id)})})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(o,{as:"p",variant:"meta",tone:me?"default":"tertiary",className:me?"text-fg-error":void 0,children:me||(b||c?"Loading filter options...":`${n.length} properties · ${i.length} tags available`)})]}),x==="calendar"?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Month view"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Calendar sections use month navigation instead of row sorting or pagination."})]}):e.jsxs("details",{className:"group pb-1",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(o,{as:"span",variant:"label",tone:"default",children:"Sort and page size"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"col-start-1 row-start-2",children:x==="board"?"Controls how many cards each board column loads at a time.":"Controls how many matching notes appear on each section page."}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",className:"col-start-2 row-span-2 row-start-1 whitespace-nowrap",children:x==="board"?`${ae} per column`:`${ae} notes`})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(ee,{id:"view-section-sort-by",value:T,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>Q(r),children:[e.jsx(I,{value:"updatedAt",children:"Updated time"}),e.jsx(I,{value:"createdAt",children:"Created time"}),e.jsx(I,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(ee,{id:"view-section-sort-order",value:te,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>H(r),children:[e.jsx(I,{value:"desc",children:"Descending"}),e.jsx(I,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:x==="board"?"Cards per load":"Rows per page"}),e.jsxs(ee,{id:"view-section-limit",value:ae,"aria-labelledby":"view-section-limit-label",onValueChange:re,children:[e.jsxs(I,{value:"3",children:["3 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"5",children:["5 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"8",children:["8 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"10",children:["10 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"12",children:["12 ",x==="board"?"cards":"rows"]})]})]})]})]})]})}),e.jsx(Y.Footer,{children:e.jsxs(yt,{children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:d,children:"Cancel"}),e.jsx(K,{type:"submit",size:"sm",form:"view-section-form",children:a==="create"?"Create section":"Save section"})]})})]})}const Ss="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",Ps="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function As({tab:t,isActive:a,onSelect:s}){const{attributes:i,listeners:n,setNodeRef:c,setActivatorNodeRef:b,transform:d,transition:j,isDragging:k}=bt({id:t.id});return e.jsx("div",{ref:c,style:{transform:Ve.Translate.toString(d),transition:j,opacity:k?.6:1},className:ie(Ss,a?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:b,...i,...n,role:"tab","aria-selected":a,title:`${t.title}. Drag to reorder.`,className:ie(Ps,a?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",k?"cursor-grabbing":"cursor-pointer"),onClick:s,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:t.sections.length})]})})}function Ms({tabs:t,activeTabId:a,onSelectTab:s,onReorderTabs:i,onCreateTab:n}){const c=Se(de(Gt,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(Ae,{sensors:c,collisionDetection:Me,modifiers:[Yt],autoScroll:!1,onDragEnd:b=>{i(b)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ht,{items:t.map(b=>b.id),strategy:Qt,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:t.map(b=>e.jsx(As,{tab:b,isActive:b.id===a,onSelect:()=>{s(b)}},b.id))})}),e.jsxs(K,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:n,children:[e.jsx(Te,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function Vs({open:t,mode:a,initialTitle:s="",onClose:i,onSubmit:n}){const[c,b]=h.useState(s);return h.useEffect(()=>{t&&b(s)},[s,t]),e.jsxs(Y,{isOpen:t,onClose:i,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(Y.Header,{title:a==="create"?"Create view tab":"Rename view tab",onClose:i}),e.jsx(Y.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:d=>{d.preventDefault(),n(c)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(Ce,{id:"view-tab-title",value:c,onChange:d=>b(d.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(Y.Footer,{children:e.jsxs(yt,{children:[e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),e.jsx(K,{type:"submit",size:"sm",form:"view-tab-form",children:a==="create"?"Create tab":"Save tab"})]})})]})}const ct=ja(Na),Fs="Save reusable note queries with tags, shared properties, and sorting.",Es="focus-ring-soft hidden h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default sm:inline-flex touch-none",Os=({section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:x})=>{const{attributes:E,listeners:p,setNodeRef:m,setActivatorNodeRef:v,transform:D,transition:P,isDragging:M}=bt({id:t.id}),w=h.useCallback(R=>x(t.id,R),[x,t.id]);return e.jsx("div",{ref:m,style:{transform:Ve.Translate.toString(D),transition:P,opacity:M?.6:1},children:e.jsx(ws,{section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:w,dragHandle:e.jsx("button",{type:"button",ref:v,"aria-label":`Reorder section ${t.title}`,...E,...p,className:ie(Es,M?"cursor-grabbing":"cursor-grab"),children:e.jsx(mt,{className:"size-4"})})})})};function Zs(){const t=da(),a=ft(),s=gt(),i=ct.useSearch(),n=ct.useNavigate(),[c,b]=h.useState(null),[d,j]=h.useState(null),{data:k,isPending:A,isError:x,refetch:E}=be({queryKey:_.views.workspace(),async queryFn(){const l=await Ht();if(l.type==="error")throw l;return l.viewWorkspace}}),p=k??qa,m=p.tabs.find(l=>l.id===i.tab)??Wa(p),v=m?p.tabs.findIndex(l=>l.id===m.id):-1,{data:D,isPending:P}=be({queryKey:_.tags.list({limit:200}),async queryFn(){const l=await wa({limit:200});if(l.type==="error")throw l;return l.allTags}}),M=Se(de(ut,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt})),w=D?.tags??[],{data:R,isPending:f,isError:S,refetch:z}=be({queryKey:_.notes.propertyKeysCatalog(),async queryFn(){const l=await fa();if(l.type==="error")throw l;return l.notePropertyKeys}}),u=R?.keys??[],C=l=>{s.setQueryData(_.views.workspace(),l)},y=h.useCallback((l,g)=>{n({search:O=>({...O,state:Zt(O.state,l,g)}),replace:!0,resetScroll:!1})},[n]),T=async()=>{await s.invalidateQueries({queryKey:_.views.all(),exact:!1})},Q=async(l,g)=>{C(g);const O=await ia(g.tabs.map(L=>L.id));if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},te=async({active:l,over:g})=>{if(!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=Ct(O,String(l.id),String(g.id));await Q(O,L)},H=async l=>{if(!m)return;const g=s.getQueryData(_.views.workspace())??p,O=Ya(g,m.id,l);O!==g&&await Q(g,O)},ae=async l=>{const g=s.getQueryData(_.views.workspace())??p,O=i,L=Ga(g,l.id);C(L),await n({search:{tab:l.id,state:void 0},resetScroll:!1});const pe=await Ie(l.id);if(pe.type==="error"){C(g),await n({search:O,replace:!0,resetScroll:!1}),a(pe.errors[0].message);return}C(pe.setActiveViewTab)},re=async(l,g)=>{if(!m)return;C(g);const O=await la(m.id,g.tabs.find(L=>L.id===m.id)?.sections.map(L=>L.id)??[]);if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},V=async({active:l,over:g})=>{if(!m||!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=kt(O,m.id,String(l.id),String(g.id));await re(O,L)},q=async(l,g)=>{if(!m)return;const O=s.getQueryData(_.views.workspace())??p,L=Qa(O,m.id,l,g);L!==O&&await re(O,L)},ce=async l=>{const g=await ta(l);if(g.type==="error"){a(g.errors[0].message);return}const O=await Ie(g.createViewTab.id);O.type==="success"?C(O.setActiveViewTab):a(O.errors[0].message),await T(),await n({search:{tab:g.createViewTab.id,state:void 0},resetScroll:!1}),b(null)},ue=async l=>{if(!m)return;const g=await aa(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),b(null)},me=async()=>{if(!m||!await t("Delete this view tab and all of its sections?"))return;const l=await sa(m.id);if(l.type==="error"){a(l.errors[0].message);return}await T(),await n({search:{tab:void 0,state:void 0},replace:!0,resetScroll:!1})},$=async l=>{if(!m)return;const g=await Ke(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),j(null)},Z=async l=>{if(!m||!d||d.mode!=="edit")return;const g=await ra(d.section.id,l);if(g.type==="error"){a(g.errors[0].message);return}y(d.section.id,{}),await T(),j(null)},X=async l=>{const g=await Ke(l.tabId,{...Ja(l),title:`${l.title} copy`});if(g.type==="error"){a(g.errors[0].message);return}await T(),a("Section duplicated.")},le=async l=>{if(!m||!await t("Delete this section from the current view tab?"))return;const g=await na(l);if(g.type==="error"){a(g.errors[0].message);return}y(l,{}),await T()};return e.jsxs(e.Fragment,{children:[e.jsx(va,{title:"Views",description:Fs,children:A&&!k?e.jsx(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(xe,{height:20,width:180,className:"rounded-full"}),e.jsx(xe,{height:16,width:260,className:"rounded-full"}),e.jsx(xe,{height:44,width:140,className:"rounded-[12px]"})]})}):x?e.jsxs(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E()},children:"Retry"})})]}):p.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(qe,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(K,{type:"button",onClick:()=>b({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Ms,{tabs:p.tabs,activeTabId:m?.id??null,onSelectTab:ae,onReorderTabs:te,onCreateTab:()=>b({mode:"create"})}),m&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:m.title}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:m.sections.length>0?`${m.sections.length} section${m.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs(K,{type:"button",size:"sm",onClick:()=>j({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Add section"]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"View tab actions"}),items:[...v>0?[{name:"Move tab left",onClick:()=>{H("previous")}}]:[],...v>=0&&v<p.tabs.length-1?[{name:"Move tab right",onClick:()=>{H("next")}}]:[],...p.tabs.length>1?[{type:"separator"}]:[],{name:"Rename tab",onClick:()=>b({mode:"edit",tab:m})},{type:"separator"},{name:"Delete tab",onClick:()=>{me()}}]})]})]}),m.sections.length===0?e.jsx(qe,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(Ae,{sensors:M,collisionDetection:Me,modifiers:[Xt],onDragEnd:V,children:e.jsx(ht,{items:m.sections.map(l=>l.id),strategy:Jt,children:e.jsx("div",{className:"flex flex-col gap-4",children:m.sections.map((l,g)=>e.jsx(Os,{section:l,availableProperties:u,isPropertiesLoading:f,isPropertiesError:S,onRetryProperties:()=>{z()},navigationState:ea(i.state,l.id),onNavigationStateChange:y,onEdit:()=>j({mode:"edit",section:l}),onDuplicate:()=>{X(l)},onDelete:()=>{le(l.id)},onMoveUp:g>0?()=>{q(l.id,"previous")}:void 0,onMoveDown:g<m.sections.length-1?()=>{q(l.id,"next")}:void 0},l.id))})})})})]})]})}),e.jsx(Vs,{open:c!==null,mode:c?.mode??"create",initialTitle:c?.mode==="edit"?c.tab.title:"",onClose:()=>b(null),onSubmit:l=>{if(c?.mode==="edit"){ue(l);return}ce(l)}}),e.jsx(Ds,{open:d!==null,mode:d?.mode??"create",initialSection:d?.mode==="edit"?d.section:null,availableTags:w,availableProperties:u,isTagsLoading:P,isPropertiesLoading:f,onClose:()=>j(null),onSubmit:l=>{if(d?.mode==="edit"){Z(l);return}$(l)}})]})}export{Zs as default};