@augmentd-labs/canvas-web 2.26.33 → 2.26.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/CalendarApplet-gN_A0sQe.js +2 -0
- package/dist/assets/{DocumentBodyEditor-DRFQgBNB.js → DocumentBodyEditor-CVO5KPCs.js} +1 -1
- package/dist/assets/{DocumentIcon-ByDAILhm.js → DocumentIcon-9i1uCMQa.js} +1 -1
- package/dist/assets/{EditorOverlay-DpQKmxkR.js → EditorOverlay-D5t3xg4w.js} +1 -1
- package/dist/assets/{FileForm-B6eFRKG-.js → FileForm-C35drQ_R.js} +1 -1
- package/dist/assets/{FiltersApplet-Bh-Ti230.js → FiltersApplet-NltVCRY8.js} +1 -1
- package/dist/assets/{HomeFab-DjDhl9Kx.js → HomeFab-Cc33x4F2.js} +1 -1
- package/dist/assets/{IdentityFields-CEDxU-Hd.js → IdentityFields-DZRqtnIG.js} +1 -1
- package/dist/assets/{LensApplet-CTRYyg4u.js → LensApplet-D-E4YyKz.js} +1 -1
- package/dist/assets/{LinkToCard-VXpoeMDH.js → LinkToCard-BQ1yoFDr.js} +1 -1
- package/dist/assets/{MarkdownEditor-Dnyez7VT.js → MarkdownEditor-DbpRWbO6.js} +2 -2
- package/dist/assets/{MessageComposerDialog-BKGlI7jO.js → MessageComposerDialog-CdPp-3GR.js} +1 -1
- package/dist/assets/{NextShell-BvKyH2Oj.js → NextShell-BfQHKEKO.js} +1 -1
- package/dist/assets/{NotesApplet-DShxjAo_.js → NotesApplet-DZ7lSkfC.js} +1 -1
- package/dist/assets/ObjectPropertiesCard-BTTwYnN9.js +8 -0
- package/dist/assets/{ObjectPropertiesCard-JArcZXXv.css → ObjectPropertiesCard-Docu7O5V.css} +1 -1
- package/dist/assets/{PathPickerField-B58yeJGw.js → PathPickerField-B4yFUjgD.js} +1 -1
- package/dist/assets/{PickDocumentsCard-B72XNYh3.js → PickDocumentsCard-CFDQL70e.js} +1 -1
- package/dist/assets/{SketchApplet-BHee4eKG.js → SketchApplet-14xrogy3.js} +1 -1
- package/dist/assets/{SketchEditor-Knj-HA0P.js → SketchEditor-B2LYe_MO.js} +1 -1
- package/dist/assets/{TerminalApplet-Djk4l1Jm.js → TerminalApplet-BNeLmNFF.js} +1 -1
- package/dist/assets/{TextDocumentEditor-rgHsbLCL.js → TextDocumentEditor-CU5ersd_.js} +1 -1
- package/dist/assets/{TodosApplet-DZVcRHmh.js → TodosApplet-ASG9wXjL.js} +1 -1
- package/dist/assets/{TodosWidget-CX4lgk-9.js → TodosWidget-CYK5RbYD.js} +1 -1
- package/dist/assets/{UploadProgressList-CHQ-Kn-e.js → UploadProgressList-Ci1akl_D.js} +1 -1
- package/dist/assets/{_agentId_-D9i9ZJWV.js → _agentId_-BuZ9wBek.js} +0 -0
- package/dist/assets/{_contextId_-C6KmQgsY.js → _contextId_-DURo7ANU.js} +1 -1
- package/dist/assets/{_workspaceName_-DOmVjYen.js → _workspaceName_-JpQwQGvI.js} +1 -1
- package/dist/assets/{about-BzJi5UDC.js → about-BpN8_1bC.js} +1 -1
- package/dist/assets/{add-DJ45m1Gq.js → add-B7zdhw47.js} +1 -1
- package/dist/assets/{agents-mnY8dZIT.js → agents-ChD6m_5J.js} +1 -1
- package/dist/assets/{agents-DEJU4O1Z.js → agents-DxqAi3vk.js} +1 -1
- package/dist/assets/{alert-dialog-CShuAcnP.js → alert-dialog-CFeuDt0T.js} +1 -1
- package/dist/assets/{api-tokens-CmHhwd58.js → api-tokens-drrVuCYc.js} +1 -1
- package/dist/assets/{appearance-CRoFdA6E.js → appearance-DEL04cKR.js} +1 -1
- package/dist/assets/{applet-target-Bl9Je1N-.js → applet-target-I8w6EPj0.js} +1 -1
- package/dist/assets/{apps-4xGIx_KA.js → apps-BYrwwspU.js} +1 -1
- package/dist/assets/{auth-_bmIEN02.js → auth-PqttD05H.js} +1 -1
- package/dist/assets/backend-sync-progress-tUU2XWtW.js +7 -0
- package/dist/assets/{button-Bum-POPT.js → button-SeUZ_Pvi.js} +1 -1
- package/dist/assets/{content-app-view-3BCpYf7m.js → content-app-view-Dcknmau8.js} +1 -1
- package/dist/assets/{context-BGgz0Y_q.js → context-DZ1Hn7tt.js} +1 -1
- package/dist/assets/{contexts-Dtl9oERX.js → contexts-DDJagU4j.js} +1 -1
- package/dist/assets/{contexts-CwGdjtXy2.js → contexts-Df-cWUlj2.js} +1 -1
- package/dist/assets/date-time-picker-txVhlNO0.js +1 -0
- package/dist/assets/{devices-CmVlYbam.js → devices-BwU9M8-W.js} +1 -1
- package/dist/assets/{document-Ds_P5v-f.js → document-CTvT2Qa5.js} +1 -1
- package/dist/assets/document-list-CQ1_7Sja.js +2 -0
- package/dist/assets/{embedding-2EjzoVFT.js → embedding-BvXcVfij.js} +1 -1
- package/dist/assets/{embedding-BqI3l5RB.js → embedding-D-I_ygUZ.js} +1 -1
- package/dist/assets/{form-panel-DZj3WZ3z.js → form-panel-3p-ncEVK.js} +1 -1
- package/dist/assets/{home-DB-ohpoi.js → home-Bg5pLpIh.js} +1 -1
- package/dist/assets/index-C51Jk0Xq.css +2 -0
- package/dist/assets/index-VAgMESOp.js +16 -0
- package/dist/assets/{inferd-config-editor-CyDCQJRs.js → inferd-config-editor-B8x_XPOt.js} +1 -1
- package/dist/assets/{key-bindings-BYwqkLkk.js → key-bindings--OI4Iz7e.js} +1 -1
- package/dist/assets/{label-DJc8-3CQ.js → label-BSTdjCWU.js} +1 -1
- package/dist/assets/{lazy-editor-Bdm5JEXv.js → lazy-editor-BUFAkTGl.js} +2 -2
- package/dist/assets/{logs-DUeiDqCX.js → logs-DjG8_wJ2.js} +1 -1
- package/dist/assets/{offline-yfQ63Zr7.js → offline-sNCjxnp-.js} +1 -1
- package/dist/assets/{page-header-BoCaZiqu.js → page-header-DrDt1sQ2.js} +1 -1
- package/dist/assets/{public-share-D2S8DEsv.js → public-share-D5yz-Pmo.js} +1 -1
- package/dist/assets/{query-debug-CZacGe0M.js → query-debug-CQ0I3cXX.js} +1 -1
- package/dist/assets/registry-DQPkddij.js +2 -0
- package/dist/assets/{remotes-BjjlqN_M.js → remotes-RPGcw6fH.js} +1 -1
- package/dist/assets/{roles-CuqCEPC7.js → roles-DoR2drD1.js} +1 -1
- package/dist/assets/{roles-BHJYWaBs.js → roles-p2cRajz-.js} +1 -1
- package/dist/assets/{settings-BjieBx_W.js → settings-B6TQfRMQ.js} +1 -1
- package/dist/assets/{settings-DAwqsOhZ.js → settings-BQmgBTa-.js} +1 -1
- package/dist/assets/settings-BgqCRJzb.js +16 -0
- package/dist/assets/{settings-BGCP2DRw.js → settings-CljJz3ui.js} +1 -1
- package/dist/assets/{share-target-BhCMpdxU.js → share-target-BZmiLt2r.js} +1 -1
- package/dist/assets/{shared-C-uHNNY8.js → shared-BnpwVpxG.js} +1 -1
- package/dist/assets/{shared-Dnd9GFGT.js → shared-qweQ1MKt.js} +1 -1
- package/dist/assets/sketch-lazy-BbNgGbR3.js +2 -0
- package/dist/assets/{subtree-transfer-dialog-BN9xBB9n.js → subtree-transfer-dialog-DQM5zfx2.js} +1 -1
- package/dist/assets/{text-documents-CFW8MWES.js → text-documents-BaXhu3ra.js} +1 -1
- package/dist/assets/ui-CDoK3F3U.js +41 -0
- package/dist/assets/{use-applet-docs-DBshA7yq.js → use-applet-docs-B2dk__vk.js} +1 -1
- package/dist/assets/{use-applet-target-DmIdCxa_.js → use-applet-target-ffIGaAqT.js} +1 -1
- package/dist/assets/{use-canvas-pins-D-zi5fqQ.js → use-canvas-pins-DkWN9oEd.js} +1 -1
- package/dist/assets/{use-menu-CaiLyPdw.js → use-menu-DIP1zh7I.js} +1 -1
- package/dist/assets/use-settings-back-DGmLAD63.js +1 -0
- package/dist/assets/{use-sortable-data-W2inLcb5.js → use-sortable-data-BBKmqs79.js} +1 -1
- package/dist/assets/{use-workspace-identity-KxY9injc.js → use-workspace-identity-B8gOMGj4.js} +1 -1
- package/dist/assets/{useAddTarget-D4ra50Am.js → useAddTarget-B3b6TyZr.js} +1 -1
- package/dist/assets/{useAgentModels-CTCpJy1M.js → useAgentModels-Bda5ilvQ.js} +1 -1
- package/dist/assets/{useDocumentThumbnail-Bs2Ju0eb.js → useDocumentThumbnail-wW0lSOEy.js} +1 -1
- package/dist/assets/{useEditNoteFields-CKYMBf8V.js → useEditNoteFields-DXLTFEqL.js} +1 -1
- package/dist/assets/{users-DInwKAxz.js → users-DuVk-TEd.js} +1 -1
- package/dist/assets/{workspace-46EFyEKZ.js → workspace-BJELPCNs.js} +1 -1
- package/dist/assets/{workspace-area-menu-DtsodEXC.js → workspace-area-menu-BFw2yUHk.js} +1 -1
- package/dist/assets/{workspace-content-gate-CGZmT2kw.js → workspace-content-gate-NLuRPvbm.js} +1 -1
- package/dist/assets/{workspace-import-form-Bu1nlv8u.js → workspace-import-form-Bb6z42nw.js} +1 -1
- package/dist/assets/{workspaces-BzAZpTMK.js → workspaces-BK7Rj72s.js} +1 -1
- package/dist/assets/{workspaces-p959p9BR.js → workspaces-CqHYstZv.js} +1 -1
- package/dist/index.html +37 -37
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/CalendarApplet-CG6XE01c.js +0 -1
- package/dist/assets/ObjectPropertiesCard-CFZ_LqzX.js +0 -8
- package/dist/assets/backend-sync-progress-BJsLP7o5.js +0 -7
- package/dist/assets/date-time-picker-Bzu8H_Oa.js +0 -1
- package/dist/assets/document-list-CwStaizB.js +0 -2
- package/dist/assets/index-BG5J93SO.js +0 -16
- package/dist/assets/index-XDD8pFI_.css +0 -2
- package/dist/assets/registry-CtnhH0si.js +0 -2
- package/dist/assets/settings-Id06aU1g.js +0 -16
- package/dist/assets/sketch-lazy-BOFTGGTA.js +0 -2
- package/dist/assets/ui-76Hw0NU_.js +0 -41
- package/dist/assets/use-settings-back-DE0SPb7h.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ct as i,Er as a,G as o,L as s,Lt as c,Pt as l,Rt as u,St as d,Vr as f,Wt as p,X as m,Xr as h,bn as g,ct as _,hn as v,it as y,mt as b,ni as x,qr as S,tt as C,yn as w}from"./ui-76Hw0NU_.js";import{t as T}from"./utils-2pl1SbIp.js";import{An as E,Cn as D,Hn as O,K as k}from"./workspace-46EFyEKZ.js";import{t as ee}from"./TodosWidget-CX4lgk-9.js";import{d as te,o as ne,u as re}from"./ObjectPropertiesCard-CFZ_LqzX.js";import{h as ie,s as ae,t as oe,u as se}from"./document-list-CwStaizB.js";import{n as ce,r as le}from"./use-toolbox-Ck_cLGgf.js";import{t as ue}from"./useToastHelpers-CRrpIIdY.js";import{n as A}from"./color-DFEH4BfK.js";import{t as de}from"./DocumentIcon-ByDAILhm.js";import{r as fe}from"./workspace-BydSRtST.js";import{t as j}from"./registry-CtnhH0si.js";import{t as pe}from"./FileForm-B6eFRKG-.js";import{t as me}from"./applet-target-Bl9Je1N-.js";var M=e(n(),1);function he(e){let{pathname:t}=r(),n=le()?.setAgentView,i=JSON.stringify(e);(0,M.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function ge(e,t,n,r){return structuredClone({...e,query:fe(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function _e({target:e,children:t}){let[n,r]=(0,M.useState)([]),i=(0,M.useRef)(!1),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),{showErrorToast:d}=ue();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(se,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(pe,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function P({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:a=!0,urlType:s,urlDisplay:l,contextPath:d,treeName:f,workspaceId:p,workspaceLabel:h,workspaceIcon:_,documentSchema:v,documents:y,isLoading:S,totalCount:C,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:O,onRemoveDocument:k,onDeleteDocument:ee,onDestroyDocument:ae,onRemoveDocuments:se,onDeleteDocuments:le,onDestroyDocuments:ue,onCopyDocuments:A,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:j,onSelectionChange:pe,pastedDocumentIds:me,onPurgeDocuments:he,disablePurgeDocuments:ge,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:I,onSaveAsCanvas:L,onShareCanvas:R,onUnshareCanvas:z,onDeleteCanvas:B,isSharingCanvas:V,isDeletingCanvas:H,isCanvasShared:U,isCanvasLocked:W,backendSearchQueries:G,onBackendSearch:K,onRemoveBackendQuery:q,serverSort:ve,onServerSortChange:ye,scope:be,onScopeChange:xe,canSaveChanges:Se,isSavingChanges:J,onSaveChanges:Y,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,linkTree:Ee,children:X,contentBanner:De,folders:Oe,onOpenFolder:ke}){let Ae=s===`canvas`,Z=ie(),{state:je,toggleView:Me,hasActiveFilters:Ne,openAddPicker:Pe}=ce(),Q=ne(),[Fe,$]=(0,M.useState)(``),Ie=JSON.stringify([p,f,d,v]),[Le,Re]=(0,M.useState)(Ie);Le!==Ie&&(Re(Ie),$(``));let ze=(0,N.jsxs)(N.Fragment,{children:[t,L&&(0,N.jsx)(`button`,{type:`button`,onClick:L,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(x,{className:`h-4 w-4`})})]});return(0,N.jsxs)(_e,{target:j&&p?{mode:`workspace`,workspaceName:p,path:d,treeName:f||`context`,treeType:D(f)}:null,children:[e&&!Z&&(0,N.jsx)(te,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${a&&!Z?` is-framed`:``}`,children:[(0,N.jsx)(re,{workspaceIcon:_,workspace:h||p||l.split(`://`)[0]||`Workspace`,actions:Z&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${s.endsWith(`-layer`)?`:layer`:``}`:s.replace(`-layer`,``),path:d,accentColor:r,onBack:Q.location?Q.location.section===`view`?Q.close:()=>Q.update?.({section:`view`}):n,section:Q.location?`document/${Q.location.documentId}/${Q.location.section}`:void 0,onSection:Q.location?()=>Q.update?.({section:`view`}):void 0,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,onFilter:()=>Me(`tools`),filtersActive:Ne,filtersOpen:je.t1Open&&je.t1View===`tools`,onAdd:e=>Pe({modal:e.shiftKey,fresh:!0}),search:K||!X?{workspaceId:p,queries:G||[],onSearch:K??$,localOnly:!K,onRemoveQuery:q,scope:be,onScopeChange:xe}:void 0,onDraftChange:X?void 0:$}),Ae&&P?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[P.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,N.jsx)(g,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||l.split(`://`)[1]||`Canvas`}),P.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Se&&Y&&(0,N.jsxs)(`button`,{type:`button`,onClick:Y,disabled:J,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(i,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:J?`Saving...`:`Save filters`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,"aria-pressed":!!F,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:F?`Unpin from home`:`Pin to home`,children:[F?(0,N.jsx)(u,{className:`w-3 h-3`}):(0,N.jsx)(c,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:U?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(b,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:V?`Sharing...`:U?`Copy link`:`Share`})]}),U&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:z,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),B&&(0,N.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||W&&!U,title:W&&!U?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Deleting…`:`Delete`})]})]})}):null,X&&(L||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[De,X||(0,N.jsx)(oe,{readingPane:!0,externalSearchQuery:Fe,toolbarActions:ze,documents:v?y.filter(e=>e.schema===v):y,isLoading:S,folders:v?void 0:Oe,onOpenFolder:ke,contextPath:d,treeName:f,workspaceId:p,totalCount:C,viewMode:v?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:O,onRemoveDocument:k,onDeleteDocument:ee,onDestroyDocument:ae,onRemoveDocuments:se,onDeleteDocuments:le,onDestroyDocuments:ue,onCopyDocuments:A,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:j,onSelectionChange:pe,pastedDocumentIds:me,onPurgeDocuments:v?void 0:he,disablePurgeDocuments:ge,backendSearchQueries:G,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:q,scope:be,onScopeChange:xe,canSaveChanges:!Ae&&Se,isSavingChanges:J,onSaveChanges:Y,linkTree:Ee},v??`documents`)]})]})]})}var F=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function I(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var L={id:`default`,name:`All`,kind:`documents`};function R(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function z(e){let t=e?.views;if(!Array.isArray(t))return[L];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(F.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[L]}var B={todos:v,"todo-app":v,notes:C,"notes-app":C,calendar:S,filters:_,sketch:h,terminal:y,lens:d};function V({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:o,accentColor:c,onOpenToSide:u}){let[d,f]=(0,M.useState)(null),[m,h]=(0,M.useState)(``),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(null),[b,x]=(0,M.useState)(null),S=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=S.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,M.useEffect)(()=>{S.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let C=()=>{y(null),x(null)},E=()=>{if(v&&b&&v!==b.id){let t=e.find(e=>e.id===v),n=e.filter(e=>e.id!==v),i=n.findIndex(e=>e.id===b.id);t&&i>=0&&(n.splice(b.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}C()},D=()=>{if(!d)return;let t=m.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?F.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:R()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),h(a)},k=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[L],n===t?i[0]?.id??L.id:void 0)};return(0,N.jsxs)(`div`,{className:T(`relative flex h-full min-w-0 items-end`,o),children:[(0,N.jsx)(`div`,{ref:S,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let o=r.id===t,l=r.kind===`columns`?a:r.kind===`app`&&r.app?B[r.app]:w;return d===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:m,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&f(null)},className:T(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,o?T(`z-[2] bg-background font-medium`,c?A(c):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:o?c:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(r.id),h(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,y(r.id)},onDragOver:e=>{if(!v||v===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;x(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),E()},onDragEnd:C,className:T(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,o?T(`z-[2] bg-background font-medium`,c?A(c):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:o?c:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(l,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),u&&(0,N.jsx)(p,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),u(r.id)}}),!i&&e.length>1&&(0,N.jsx)(s,{className:T(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,o?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),k(r.id)}})]},r.id)})}),!i&&(g?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(w,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(a,{className:`h-3 w-3`}),` Board`]}),F.map(e=>{let t=B[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(s,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(l,{className:`h-3.5 w-3.5`})}))]})}var H=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function U(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function W({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,M.useState)(null),[c,u]=(0,M.useState)(!1),[d,p]=(0,M.useState)({}),[m,h]=(0,M.useState)({}),g=(0,M.useRef)(null),[_,v]=(0,M.useState)(!1),y=(0,M.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,M.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(()=>y());return t.observe(e),()=>t.disconnect()},[y]);let b=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),h(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},x=e=>{h(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},S=e=>{let t=d[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},C=H.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:g,onScroll:y,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let a=(d[t.id]??t.filter??``).toLowerCase(),c=e.filter(e=>U(e,t.schemas)).filter(e=>{if(!a)return!0;let t=E(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=m[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!i&&(0,N.jsx)(`div`,{onPointerDown:e=>b(e,t.id),onDoubleClick:()=>x(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!i&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(s,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>p(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:i,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[c.map(e=>{let t=E(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(de,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),c.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&C.length>0||_)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!i&&C.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(l,{className:`h-3.5 w-3.5`})}),c&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{u(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>u(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),_&&(0,N.jsx)(f,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(ae,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function G(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r}\0${i??``}`,[o,s]=(0,M.useState)(0),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{let o=!1;return k(e,n,t,{limit:200,allOf:[r],...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,M.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,M.useCallback)(()=>s(e=>e+1),[])}}function K({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=G(e,t,n,O,`tasks`),[o,s]=(0,M.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(ee,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}function q({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:D(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=j.find(e=>e.id===i);return(0,N.jsx)(me,{target:r,children:e===`todos`?(0,N.jsx)(K,{...n}):a?(0,N.jsx)(a.Component,{}):null})}export{I as a,ge as c,L as i,he as l,W as n,z as o,V as r,P as s,q as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ct as i,Er as a,G as o,Jr as s,L as c,Lt as l,Pt as u,Rt as d,St as f,Vr as p,Wt as m,X as h,Zr as g,bn as _,ct as v,hn as y,it as b,mt as x,ri as S,tt as C,yn as w}from"./ui-CDoK3F3U.js";import{t as T}from"./utils-2pl1SbIp.js";import{An as E,Cn as D,Hn as O,K as k}from"./workspace-BJELPCNs.js";import{t as ee}from"./TodosWidget-CYK5RbYD.js";import{d as te,o as ne,u as re}from"./ObjectPropertiesCard-BTTwYnN9.js";import{h as ie,s as ae,t as oe,u as se}from"./document-list-CQ1_7Sja.js";import{n as ce,r as le}from"./use-toolbox-Ck_cLGgf.js";import{t as ue}from"./useToastHelpers-CRrpIIdY.js";import{n as A}from"./color-DFEH4BfK.js";import{t as de}from"./DocumentIcon-9i1uCMQa.js";import{r as fe}from"./workspace-BydSRtST.js";import{t as j}from"./registry-DQPkddij.js";import{t as pe}from"./FileForm-C35drQ_R.js";import{t as me}from"./applet-target-I8w6EPj0.js";var M=e(n(),1);function he(e){let{pathname:t}=r(),n=le()?.setAgentView,i=JSON.stringify(e);(0,M.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function ge(e,t,n,r){return structuredClone({...e,query:fe(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function _e({target:e,children:t}){let[n,r]=(0,M.useState)([]),i=(0,M.useRef)(!1),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),{showErrorToast:d}=ue();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(se,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(pe,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function P({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:a=!0,urlType:s,urlDisplay:c,contextPath:u,treeName:f,workspaceId:p,workspaceLabel:m,workspaceIcon:g,documentSchema:v,documents:y,isLoading:b,totalCount:C,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:O,onRemoveDocument:k,onDeleteDocument:ee,onDestroyDocument:ae,onRemoveDocuments:se,onDeleteDocuments:le,onDestroyDocuments:ue,onCopyDocuments:A,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:j,onSelectionChange:pe,pastedDocumentIds:me,onPurgeDocuments:he,disablePurgeDocuments:ge,canvasInfo:P,isCanvasPinned:F,onTogglePinCanvas:I,onSaveAsCanvas:L,onShareCanvas:R,onUnshareCanvas:z,onDeleteCanvas:B,isSharingCanvas:V,isDeletingCanvas:H,isCanvasShared:U,isCanvasLocked:W,backendSearchQueries:G,onBackendSearch:K,onRemoveBackendQuery:q,serverSort:ve,onServerSortChange:ye,scope:be,onScopeChange:xe,canSaveChanges:Se,isSavingChanges:J,onSaveChanges:Y,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,linkTree:Ee,children:X,contentBanner:De,folders:Oe,onOpenFolder:ke}){let Ae=s===`canvas`,Z=ie(),{state:je,toggleView:Me,hasActiveFilters:Ne,openAddPicker:Pe}=ce(),Q=ne(),[Fe,$]=(0,M.useState)(``),Ie=JSON.stringify([p,f,u,v]),[Le,Re]=(0,M.useState)(Ie);Le!==Ie&&(Re(Ie),$(``));let ze=(0,N.jsxs)(N.Fragment,{children:[t,L&&(0,N.jsx)(`button`,{type:`button`,onClick:L,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(S,{className:`h-4 w-4`})})]});return(0,N.jsxs)(_e,{target:j&&p?{mode:`workspace`,workspaceName:p,path:u,treeName:f||`context`,treeType:D(f)}:null,children:[e&&!Z&&(0,N.jsx)(te,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${a&&!Z?` is-framed`:``}`,children:[(0,N.jsx)(re,{workspaceIcon:g,workspace:m||p||c.split(`://`)[0]||`Workspace`,actions:Z&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${s.endsWith(`-layer`)?`:layer`:``}`:s.replace(`-layer`,``),path:u,accentColor:r,onBack:Q.location?Q.location.section===`view`?Q.close:()=>Q.update?.({section:`view`}):n,section:Q.location?`document/${Q.location.documentId}/${Q.location.section}`:void 0,onSection:Q.location?()=>Q.update?.({section:`view`}):void 0,onBrowseWorkspaces:Ce,onBrowseTree:we,onNavigatePath:Te,onFilter:()=>Me(`tools`),filtersActive:Ne,filtersOpen:je.t1Open&&je.t1View===`tools`,onAdd:e=>Pe({modal:e.shiftKey,fresh:!0}),search:K||!X?{workspaceId:p,queries:G||[],onSearch:K??$,localOnly:!K,onRemoveQuery:q,scope:be,onScopeChange:xe}:void 0,onDraftChange:X?void 0:$}),Ae&&P?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[P.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:P.color}}),(0,N.jsx)(_,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:P.label||c.split(`://`)[1]||`Canvas`}),P.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:P.description})]}),Se&&Y&&(0,N.jsxs)(`button`,{type:`button`,onClick:Y,disabled:J,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(i,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:J?`Saving...`:`Save filters`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,"aria-pressed":!!F,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:F?`Unpin from home`:`Pin to home`,children:[F?(0,N.jsx)(d,{className:`w-3 h-3`}):(0,N.jsx)(l,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:F?`Unpin`:`Pin`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:U?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(x,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:V?`Sharing...`:U?`Copy link`:`Share`})]}),U&&z&&(0,N.jsxs)(`button`,{type:`button`,onClick:z,disabled:V||H,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),B&&(0,N.jsxs)(`button`,{type:`button`,onClick:B,disabled:H||W&&!U,title:W&&!U?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(h,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:H?`Deleting…`:`Delete`})]})]})}):null,X&&(L||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[De,X||(0,N.jsx)(oe,{readingPane:!0,externalSearchQuery:Fe,toolbarActions:ze,documents:v?y.filter(e=>e.schema===v):y,isLoading:b,folders:v?void 0:Oe,onOpenFolder:ke,contextPath:u,treeName:f,workspaceId:p,totalCount:C,viewMode:v?`card`:`table`,allowViewToggle:!0,currentPage:w,pageSize:T,onPageChange:E,onPageSizeChange:O,onRemoveDocument:k,onDeleteDocument:ee,onDestroyDocument:ae,onRemoveDocuments:se,onDeleteDocuments:le,onDestroyDocuments:ue,onCopyDocuments:A,onCutDocuments:de,onPasteDocuments:fe,onImportDocuments:j,onSelectionChange:pe,pastedDocumentIds:me,onPurgeDocuments:v?void 0:he,disablePurgeDocuments:ge,backendSearchQueries:G,onBackendSearch:K,serverSort:ve,onServerSortChange:ye,onRemoveBackendQuery:q,scope:be,onScopeChange:xe,canSaveChanges:!Ae&&Se,isSavingChanges:J,onSaveChanges:Y,linkTree:Ee},v??`documents`)]})]})]})}var F=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function I(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var L={id:`default`,name:`All`,kind:`documents`};function R(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function z(e){let t=e?.views;if(!Array.isArray(t))return[L];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(F.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[L]}var B={todos:y,"todo-app":y,notes:C,"notes-app":C,calendar:s,filters:v,sketch:g,terminal:b,lens:f};function V({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:o,accentColor:s,onOpenToSide:l}){let[d,f]=(0,M.useState)(null),[p,h]=(0,M.useState)(``),[g,_]=(0,M.useState)(!1),[v,y]=(0,M.useState)(null),[b,x]=(0,M.useState)(null),S=(0,M.useRef)(null);(0,M.useEffect)(()=>{let e=S.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,M.useEffect)(()=>{S.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let C=()=>{y(null),x(null)},E=()=>{if(v&&b&&v!==b.id){let t=e.find(e=>e.id===v),n=e.filter(e=>e.id!==v),i=n.findIndex(e=>e.id===b.id);t&&i>=0&&(n.splice(b.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}C()},D=()=>{if(!d)return;let t=p.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},O=(t,n)=>{_(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?F.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:R()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),h(a)},k=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[L],n===t?i[0]?.id??L.id:void 0)};return(0,N.jsxs)(`div`,{className:T(`relative flex h-full min-w-0 items-end`,o),children:[(0,N.jsx)(`div`,{ref:S,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let o=r.id===t,u=r.kind===`columns`?a:r.kind===`app`&&r.app?B[r.app]:w;return d===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:p,onChange:e=>h(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&D(),e.key===`Escape`&&f(null)},className:T(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,o?T(`z-[2] bg-background font-medium`,s?A(s):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:o?s:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(r.id),h(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,y(r.id)},onDragOver:e=>{if(!v||v===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;x(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),E()},onDragEnd:C,className:T(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,o?T(`z-[2] bg-background font-medium`,s?A(s):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,v===r.id&&`opacity-50`),style:{backgroundColor:o?s:void 0,boxShadow:b?.id===r.id?`inset ${b.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),l&&(0,N.jsx)(m,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),l(r.id)}}),!i&&e.length>1&&(0,N.jsx)(c,{className:T(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,o?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),k(r.id)}})]},r.id)})}),!i&&(g?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(w,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(a,{className:`h-3 w-3`}),` Board`]}),F.map(e=>{let t=B[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>O(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(c,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>_(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var H=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function U(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function W({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,M.useState)(null),[s,l]=(0,M.useState)(!1),[d,f]=(0,M.useState)({}),[m,h]=(0,M.useState)({}),g=(0,M.useRef)(null),[_,v]=(0,M.useState)(!1),y=(0,M.useCallback)(()=>{let e=g.current;e&&v(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,M.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(()=>y());return t.observe(e),()=>t.disconnect()},[y]);let b=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),h(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},x=e=>{h(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},S=e=>{let t=d[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},C=H.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:g,onScroll:y,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let a=(d[t.id]??t.filter??``).toLowerCase(),s=e.filter(e=>U(e,t.schemas)).filter(e=>{if(!a)return!0;let t=E(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=m[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!i&&(0,N.jsx)(`div`,{onPointerDown:e=>b(e,t.id),onDoubleClick:()=>x(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!i&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>f(n=>({...n,[t.id]:e.target.value})),onBlur:()=>S(t.id),onKeyDown:e=>{e.key===`Enter`&&S(t.id)},placeholder:`Filter…`,readOnly:i,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[s.map(e=>{let t=E(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(de,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),s.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&C.length>0||_)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!i&&C.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}),s&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),C.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),_&&(0,N.jsx)(p,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(ae,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function G(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r}\0${i??``}`,[o,s]=(0,M.useState)(0),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{let o=!1;return k(e,n,t,{limit:200,allOf:[r],...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,M.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,M.useCallback)(()=>s(e=>e+1),[])}}function K({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=G(e,t,n,O,`tasks`),[o,s]=(0,M.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(ee,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}function q({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:D(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=j.find(e=>e.id===i);return(0,N.jsx)(me,{target:r,children:e===`todos`?(0,N.jsx)(K,{...n}):a?(0,N.jsx)(a.Component,{}):null})}export{I as a,ge as c,L as i,he as l,W as n,z as o,V as r,P as s,q as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,t}from"./api-CA6WiiYM.js";import{Dn as n,En as r}from"./workspace-
|
|
1
|
+
import{c as e,t}from"./api-CA6WiiYM.js";import{Dn as n,En as r}from"./workspace-BJELPCNs.js";var i=`contexts:deleted`;function a(e,t){return e.id===t.id?t.ownerId===void 0?e.isShared!==!0&&e.type!==`shared`:e.userId===t.ownerId:!1}async function o(){try{let n=await t.get(e.contexts);return Array.isArray(n)?n:(console.warn(`listContexts: response.payload is not an array:`,n),[])}catch(e){throw console.error(`Failed to list contexts:`,e),e}}function s(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}ownerId=${encodeURIComponent(t)}`:e}async function c(n,r){try{let i=s(`${e.contexts}/${n}`,r),a=await t.get(i);if(a&&a)return a;throw Error(`Context data not found in API response`)}catch(e){throw console.error(`Failed to get context ${n}:`,e),e}}async function l(n){try{let r=await t.post(e.contexts,n);if(r&&r&&r.context)return r.context;throw Error(`Created context data not found in API response`)}catch(e){throw console.error(`Failed to create context:`,e),e}}async function u(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to patch context ${n}:`,e),e}}async function d(n,r,i){try{let a=s(`${e.contexts}/${n}`,i),o=await t.put(a,r);if(o?.context)return o.context;throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context ${n}:`,e),e}}async function f(n,r,i,a){try{let o=s(`${e.contexts}/${n}/url`,i),c=await t.post(o,{url:r,...a?{treeName:a}:{}});if(c&&c&&c.url)return{url:c.url,treeId:c.treeId};throw Error(`Updated context data not found in API response`)}catch(e){throw console.error(`Failed to update context URL for ${n}:`,e),e}}async function p(n,r){try{let a=s(`${e.contexts}/${n}`,r);await t.delete(a),window.dispatchEvent(new CustomEvent(i,{detail:{id:n,ownerId:r}}))}catch(e){throw console.error(`Failed to delete context ${n}:`,e),e}}async function m(i,a=[],o=[],s={},c){try{if(s.ids?.length===0)return Object.assign([],{count:0,totalCount:0});if(n(s.sortBy)){let e=await r(s,async e=>{let t=await m(i,a,o,{...s,...e,sortBy:void 0,order:`asc`},c);return{payload:t,count:t.count,totalCount:t.totalCount}});return Object.assign(e.payload,{count:e.count,totalCount:e.totalCount})}let l=new URLSearchParams;s.geoSelection&&(l.set(`geoSelection`,JSON.stringify(s.geoSelection)),l.set(`includeUnlocated`,String(s.includeUnlocated===!0))),s.ids?.forEach(e=>l.append(`ids`,String(e))),a.forEach(e=>l.append(`allOf`,e)),o.forEach(e=>l.append(`filters`,e)),(s.anyOf||[]).filter(Boolean).forEach(e=>l.append(`anyOf`,e)),(s.noneOf||[]).filter(Boolean).forEach(e=>l.append(`noneOf`,e)),s.sortBy&&l.append(`sortBy`,s.sortBy),s.order&&l.append(`order`,s.order),s.applyContextSpec===!1&&l.append(`applyContextSpec`,`false`),c&&l.append(`ownerId`,c),s.includeServerContext!==void 0&&l.append(`includeServerContext`,s.includeServerContext.toString()),s.includeClientContext!==void 0&&l.append(`includeClientContext`,s.includeClientContext.toString()),s.limit!==void 0&&l.append(`limit`,s.limit.toString()),s.offset!==void 0&&l.append(`offset`,s.offset.toString()),s.page!==void 0&&l.append(`page`,s.page.toString()),(s.queries&&s.queries.length?s.queries:s.q?[s.q]:[]).map(e=>e.trim()).filter(Boolean).forEach(e=>l.append(`q`,e));let u=`${e.contexts}/${i}/documents${l.toString()?`?`+l.toString():``}`,d=await t.getEnvelope(u,{signal:s.signal}),f=d.payload;if(Array.isArray(f)){let e=f;return e.count=d.count??void 0,e.totalCount=d.totalCount??void 0,e}return console.warn(`getContextDocuments: payload is not an array:`,f),[]}catch(e){throw console.error(`Failed to get context documents for ${i}:`,e),e}}async function h(n){let r=await t.get(`${e.contexts}/${n}/shares`);return Array.isArray(r)?r:[]}async function g(n,r,i){try{return{message:(await t.post(`${e.contexts}/${n}/shares`,{userEmail:r,accessLevel:i})).message||`Context access granted`}}catch(e){throw console.error(`Failed to grant context access:`,e),e}}async function _(n,r){try{return{message:(await t.delete(`${e.contexts}/${n}/shares/${encodeURIComponent(r)}`)).message||`Context access revoked`}}catch(e){throw console.error(`Failed to revoke context access:`,e),e}}async function v(n,r){try{let i=s(`${e.contexts}/${n}/tree`,r),a=await t.get(i);if(a)return a;throw Error(`Context tree data not found in API response`)}catch(e){throw console.error(`Failed to get context tree for ${n}:`,e),e}}async function y(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents/remove${o.toString()?`?${o.toString()}`:``}`;return{message:await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})||`Documents removed from context`}}catch(e){throw console.error(`Failed to remove documents from context ${n}:`,e),e}}async function b(n,r,i,a){try{let a=Array.isArray(r)?r:[r],o=new URLSearchParams,c=`${e.contexts}/${n}/documents${o.toString()?`?${o.toString()}`:``}`;return await t.delete(s(c,i),{body:JSON.stringify(a),headers:{"Content-Type":`application/json`}})}catch(e){throw console.error(`Failed to delete documents from context ${n}:`,e),e}}async function x(n,r,i,a){try{let o=Array.isArray(i)?i:[i];return await t.post(s(`${e.contexts}/${n}/documents`,a),{documentIds:o,context:r}),!0}catch(e){throw console.error(`Failed to paste documents to context path ${r}:`,e),e}}async function S(n,r,i=!0){return await t.post(`${e.contexts}/${n}/tree/paths`,{path:r,autoCreateLayers:i})??!0}async function C(n,r,i=!1){let a=new URLSearchParams({path:r,recursive:i.toString()});return await t.delete(`${e.contexts}/${n}/tree/paths?${a}`)??!0}async function w(n,r,i){return await t.patch(`${e.contexts}/${n}/tree/paths`,{path:r,...i})??!0}async function T(n,r,i,a=!1,o={}){return await t.post(`${e.contexts}/${n}/tree/paths/move`,{from:r,to:i,recursive:a,...o.mergeDown?{mergeDown:!0}:{}})??!0}async function E(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/merge-down`,{path:r})}async function D(n,r){return await t.post(`${e.contexts}/${n}/tree/paths/subtract-down`,{path:r})}async function O(n,r,i,a=!1){return await t.post(`${e.contexts}/${n}/tree/paths/copy`,{from:r,to:i,recursive:a})??!0}async function k(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/merge`,{layerId:r,targetLayers:i})}async function A(n,r,i){return await t.post(`${e.contexts}/${n}/tree/layers/subtract`,{layerId:r,targetLayers:i})}async function j(n,r,i){try{let a=Array.isArray(i)?i:[i];return await t.post(`${e.workspaces}/${n}/documents`,{documents:a,treeType:`context`,context:r}),!0}catch(e){throw console.error(`Failed to import documents to context path ${r}:`,e),e}}async function M(n,r,i=[]){try{let a=Array.isArray(r)?r:[r],o=await t.post(`${e.contexts}/${n}/documents`,{documents:a,features:i});return Array.isArray(o)?o:[]}catch(e){throw console.error(`Failed to insert documents into context ${n}:`,e),e}}export{D as C,i as D,f as E,a as O,A as S,w as T,x as _,c as a,y as b,g as c,M as d,h as f,T as g,E as h,b as i,j as l,k as m,l as n,m as o,o as p,p as r,v as s,O as t,S as u,u as v,d as w,_ as x,C as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{i as r}from"./auth-Bx9fAZmz.js";import{n as i}from"./page-header-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{i as r}from"./auth-Bx9fAZmz.js";import{n as i}from"./page-header-DrDt1sQ2.js";var a=e(n(),1),o=t();function s(){let e=r()?.userType===`admin`;return(0,a.useEffect)(()=>{},[e]),e?(0,o.jsxs)(`div`,{className:`space-y-6`,children:[(0,o.jsx)(i,{title:`All Contexts`,description:`Manage all contexts across all users`}),(0,o.jsx)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:(0,o.jsxs)(`div`,{className:`text-center`,children:[(0,o.jsx)(`h2`,{className:`text-2xl font-semibold mb-2`,children:`Coming Soon`}),(0,o.jsx)(`p`,{className:`text-muted-foreground max-w-md`,children:`Global context management is currently under development. Check back later for updates.`})]})})]}):(0,o.jsx)(`div`,{className:`text-center space-y-4`,children:(0,o.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Pt as i,Y as a,at as o,mt as s,yr as c}from"./ui-76Hw0NU_.js";import{t as l}from"./button-Bum-POPT.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./socket-CtH3EU9m.js";import{n as ee}from"./use-toast-BlLDqSUO.js";import{Nt as te}from"./workspace-46EFyEKZ.js";import{a as ne,c as re,i as f,n as ie,o as ae,r as oe,s as se,t as ce}from"./alert-dialog-CShuAcnP.js";import{O as le,n as ue,p as de,r as p}from"./context-BGgz0Y_q.js";import{t as m}from"./PathPickerField-B58yeJGw.js";import{a as h,c as g,i as fe,n as _,o as pe,r as me,s as he,t as ge}from"./use-sortable-data-W2inLcb5.js";import{n as _e}from"./page-header-BoCaZiqu.js";import{t as ve}from"./form-panel-DZj3WZ3z.js";import{t as ye}from"./use-create-panel-DhSNIGtr.js";var v=e(n(),1);function y(e,t=`An error occurred`){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let n=e;return n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||t}return t}function be(e,t,n=`An error occurred`){return console.error(t,e),y(e,n)}var b=t();function x(){let e=r(),[t,n]=(0,v.useState)([]),[y,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(`context`),[M,N]=(0,v.useState)(`/`),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(`/`),[B,V]=(0,v.useState)(``),[H,U]=(0,v.useState)(!1),[W,G]=ye(),[K,q]=(0,v.useState)(null),[J,Y]=(0,v.useState)(null),{showToast:X}=ee();(0,v.useEffect)(()=>{d.isConnected()||(console.log(`Socket not connected, attempting to connect...`),d.reconnect())},[]);let Z=(0,v.useCallback)(async()=>{try{C(!0);let[e,t]=await Promise.all([de(),te()]),r=e?.filter(e=>e&&typeof e==`object`&&e.id&&e.userId)||[];n(r);let i=t||[];if(x(i),i.length>0){let e=i.some(e=>e.id===B);(!B||!e)&&V(i[0].id)}else V(``);T(null)}catch(e){console.error(`Data fetch error:`,e),n([]),x([]);let t=`Failed to fetch data`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch data`}T(t),X({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[B,X]);(0,v.useEffect)(()=>{Z()},[Z]),(0,v.useEffect)(()=>{let e=()=>d.emit(`subscribe`,{channel:`context`}),t=()=>d.emit(`unsubscribe`,{channel:`context`}),r=d.on(`connect`,e);console.log(`Subscribing to context events`),e();let i=e=>{let t=e;if(console.log(`Received context created:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:created event:`,t);return}n(e=>e.some(e=>e&&e.id===t.id&&e.userId===t.userId)?(console.log(`Context ${t.id} already exists, skipping duplicate add`),e):[...e,t])},a=e=>{let t=e;if(console.log(`Received context update:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:updated event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},o=e=>{let t=e;console.log(`Received context deletion:`,t);let r=t?.contextId??t?.id;if(!r){console.error(`Invalid context deletion data received:`,t);return}n(e=>e.filter(e=>e&&e.id!==r))},s=e=>{let t=e;if(console.log(`Received context URL change:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:url:changed event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},c=[[`context:created`,i],[`context.created`,i],[`context:updated`,a],[`context.updated`,a],[`context:deleted`,o],[`context.deleted`,o],[`context:url:changed`,s],[`context.url.set`,s],[`context:url:set`,s]];return c.forEach(([e,t])=>d.on(e,t)),()=>{console.log(`Unsubscribing from context events`),t(),r?.(),c.forEach(([e,t])=>d.off(e,t))}},[]);let xe=async t=>{if(t.preventDefault(),!M.trim()||!B||!E.trim()){X({title:`Missing Fields`,description:`Context ID, Context URL and Workspace are required.`,variant:`destructive`});return}U(!0);try{let t={id:E,name:O.trim()||void 0,url:M,description:P.trim()||void 0,metadata:{ui:{color:I}},workspaceId:B,baseUrl:R||void 0,treeType:A},n=await ue(t);D(``),k(``),N(`/`),F(``),L(null),z(`/`),await Z(),X({title:`Success`,description:`Context created successfully`}),G(!1),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e(`/contexts/${n.id}`)}catch(e){let t=be(e,`Context creation error:`,`Failed to create context`);X({title:`Error`,description:t,variant:`destructive`})}finally{U(!1)}},Se=async e=>{let n=t.find(t=>t.id===e);if(n&&n.url&&(n.url.endsWith(`/default`)||n.url.includes(`://default`))){X({title:`Error`,description:`Cannot delete the default context`,variant:`destructive`});return}Y(e)},Ce=async()=>{if(J)try{await p(J),n(e=>e.filter(e=>!le(e,{id:J}))),X({title:`Success`,description:`Context deleted successfully`})}catch(e){console.error(`Context deletion error:`,e);let t=`Failed to delete context`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to delete context`}X({title:`Error`,description:t,variant:`destructive`})}finally{Y(null)}},we=t=>{let n=t.isShared||t.type===`shared`;e(n?`/contexts/${t.id}?ownerId=${encodeURIComponent(t.userId)}`:`/contexts/${t.id}`)},Te=e=>{q(e)},Ee=async e=>{if(e.preventDefault(),K)try{n(e=>e.map(e=>e.id===K.id&&e.userId===K.userId?K:e)),X({title:`Success`,description:`Context updated successfully (mock update)`}),q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update context`;X({title:`Error`,description:t,variant:`destructive`})}},De=(0,v.useMemo)(()=>({type:e=>e.isShared||e.type===`shared`?`shared`:`owned`,id:e=>e.id??``,owner:e=>e.isShared||e.type===`shared`?e.ownerEmail||e.userId||``:`you`,url:e=>e.url??``,workspaceId:e=>e.workspaceId??``,baseUrl:e=>e.baseUrl??``,path:e=>e.path??``,locked:e=>+!!e.locked,created:e=>Date.parse(e.createdAt)||0,updated:e=>Date.parse(e.updatedAt)||0}),[]),{sorted:Oe,sort:Q,toggleSort:$}=ge(t.filter(e=>e!=null),De);return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(_e,{title:`Contexts`,description:`Create and manage contexts in your workspaces. View contexts shared with you.`,actions:!W&&(0,b.jsxs)(l,{onClick:()=>G(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create context`,title:`Create context`,children:[(0,b.jsx)(i,{className:`h-4 w-4 sm:mr-2`}),(0,b.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Context`})]})}),W&&(0,b.jsx)(ve,{title:`Create New Context`,onClose:()=>G(!1),children:(0,b.jsxs)(`form`,{onSubmit:xe,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`workspace`,className:`block text-sm font-medium mb-1`,children:`Workspace`}),(0,b.jsxs)(`select`,{id:`workspace`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:B,onChange:e=>V(e.target.value),disabled:H||y.length===0,children:[y.length===0&&(0,b.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),y.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label||e.name},`${e.owner}-${e.id}`))]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`newContextId`,className:`block text-sm font-medium mb-1`,children:`Context ID`}),(0,b.jsx)(u,{id:`newContextId`,value:E,onChange:e=>D(e.target.value),placeholder:`e.g., my-new-context`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`url`,value:M,onChange:N,placeholder:`e.g., /project/path/resource`,disabled:H,pickerTitle:`Context URL path…`,onPickTarget:(e,t)=>{N(e),j(t.treeType);let n=y.find(e=>e.name===t.workspaceName||e.id===t.workspaceName);n&&V(n.id)}})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`baseUrl`,className:`block text-sm font-medium mb-1`,children:`Base URL (Optional)`}),(0,b.jsx)(m,{id:`baseUrl`,value:R,onChange:z,format:`path`,placeholder:`e.g., /base/path`,disabled:H,pickerTitle:`Base path…`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`description`,className:`block text-sm font-medium mb-1`,children:`Description (Optional)`}),(0,b.jsx)(u,{id:`description`,value:P,onChange:e=>F(e.target.value),placeholder:`Description`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextColor`,className:`block text-sm font-medium mb-1`,children:`Color (Optional)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{id:`contextColor`,type:`color`,value:I||`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:H}),(0,b.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:H||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Uses the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextName`,className:`block text-sm font-medium mb-1`,children:`Name (Optional)`}),(0,b.jsx)(u,{id:`contextName`,value:O,onChange:e=>k(e.target.value),placeholder:`My Context`,disabled:H})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`treeType`,className:`block text-sm font-medium mb-1`,children:`Tree`}),(0,b.jsxs)(`select`,{id:`treeType`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:A,onChange:e=>j(e.target.value),disabled:H,children:[(0,b.jsx)(`option`,{value:`context`,children:`Context tree`}),(0,b.jsx)(`option`,{value:`directory`,children:`Directory tree`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Which workspace tree this context navigates.`})]})]}),(0,b.jsxs)(l,{type:`submit`,disabled:H||!M.trim()||!B||!E.trim(),children:[(0,b.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create Context`]})]})}),(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Contexts & Shared Contexts`}),S&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading contexts...`}),w&&(0,b.jsx)(`div`,{className:`text-center text-destructive`,children:(0,b.jsx)(`p`,{children:w})}),!S&&!w&&t.length===0&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No contexts found. Create one above.`}),t.length>0&&(0,b.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,b.jsxs)(me,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(_,{label:`Type`,sortKey:`type`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`ID`,sortKey:`id`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Owner`,sortKey:`owner`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Context URL`,sortKey:`url`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Workspace ID`,sortKey:`workspaceId`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Base URL`,sortKey:`baseUrl`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Path`,sortKey:`path`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Locked`,sortKey:`locked`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Created`,sortKey:`created`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Updated`,sortKey:`updated`,sort:Q,onSort:$}),(0,b.jsx)(pe,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:Oe.map(e=>{if(!e)return console.warn(`Found null/undefined context in contexts array, skipping`),null;let t=e.createdAt?new Date(e.createdAt).toLocaleDateString():`-`,n=e.updatedAt?new Date(e.updatedAt).toLocaleDateString():`-`,r=e.isShared||e.type===`shared`,i=r?e.ownerEmail||e.userId||`-`:`You`,u=r&&e.sharedVia?typeof e.sharedVia==`string`?e.sharedVia:e.sharedVia.accessLevel||`-`:`-`;return(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{children:r?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-info`,title:`Shared with you (${u})`,children:[(0,b.jsx)(s,{className:`h-4 w-4`}),(0,b.jsx)(`span`,{className:`text-xs`,children:`Shared`})]}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Owned`})}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.id||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,title:r?`Owned by: ${i}`:`You are the owner`,children:i}),(0,b.jsx)(h,{className:`font-mono text-sm max-w-xs truncate`,title:e.url||`-`,children:e.url||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.workspaceId||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.baseUrl||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.path||`-`}),(0,b.jsx)(h,{children:e.locked?`Yes`:`No`}),(0,b.jsx)(h,{children:t}),(0,b.jsx)(h,{children:n}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Te(e),title:`Edit Context`,children:(0,b.jsx)(o,{className:`h-4 w-4`})}),(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>we(e),title:r?`Open Shared Context`:`Open Context Details`,children:(0,b.jsx)(c,{className:`h-4 w-4`})}),!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Se(e.id),disabled:!!(e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))),className:`text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-50 disabled:cursor-not-allowed`,title:e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))?`Cannot delete default context`:`Delete Context`,children:(0,b.jsx)(a,{className:`h-4 w-4`})})]})})]},`${e.userId}-${e.id}`)})})]})})]}),K&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit Context`}),(0,b.jsxs)(`form`,{onSubmit:Ee,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-id`,className:`block text-sm font-medium mb-1`,children:`Context ID (read-only)`}),(0,b.jsx)(u,{id:`edit-context-id`,value:K.id,disabled:!0,className:`bg-muted`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`edit-context-url`,value:K.url,onChange:e=>q(t=>t?{...t,url:e}:null),placeholder:`workspace://path or /path`,pickerTitle:`Context URL path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Use format: workspace://path or /path for current workspace`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-base-url`,className:`block text-sm font-medium mb-1`,children:`Base URL (optional)`}),(0,b.jsx)(m,{id:`edit-base-url`,value:K.baseUrl||``,onChange:e=>q(t=>t?{...t,baseUrl:e||null}:null),format:`path`,placeholder:`/base/path`,pickerTitle:`Base path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restricts context navigation to this base path`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(l,{type:`submit`,children:`Save Changes`}),(0,b.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>q(null),children:`Cancel`})]})]})]}),(0,b.jsx)(ce,{open:J!==null,onOpenChange:e=>!e&&Y(null),children:(0,b.jsxs)(f,{children:[(0,b.jsxs)(se,{children:[(0,b.jsx)(re,{children:`Delete Context`}),(0,b.jsx)(ne,{children:`Are you sure you want to delete this context? This action cannot be undone.`})]}),(0,b.jsxs)(ae,{children:[(0,b.jsx)(oe,{children:`Cancel`}),(0,b.jsx)(ie,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})})]})}export{x as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Pt as i,Y as a,at as o,mt as s,yr as c}from"./ui-CDoK3F3U.js";import{t as l}from"./button-SeUZ_Pvi.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./socket-CtH3EU9m.js";import{n as ee}from"./use-toast-BlLDqSUO.js";import{Nt as te}from"./workspace-BJELPCNs.js";import{a as ne,c as re,i as f,n as ie,o as ae,r as oe,s as se,t as ce}from"./alert-dialog-CFeuDt0T.js";import{O as le,n as ue,p as de,r as p}from"./context-DZ1Hn7tt.js";import{t as m}from"./PathPickerField-B4yFUjgD.js";import{a as h,c as g,i as fe,n as _,o as pe,r as me,s as he,t as ge}from"./use-sortable-data-BBKmqs79.js";import{n as _e}from"./page-header-DrDt1sQ2.js";import{t as ve}from"./form-panel-3p-ncEVK.js";import{t as ye}from"./use-create-panel-DhSNIGtr.js";var v=e(n(),1);function y(e,t=`An error occurred`){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let n=e;return n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||t}return t}function be(e,t,n=`An error occurred`){return console.error(t,e),y(e,n)}var b=t();function x(){let e=r(),[t,n]=(0,v.useState)([]),[y,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(`context`),[M,N]=(0,v.useState)(`/`),[P,F]=(0,v.useState)(``),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(`/`),[B,V]=(0,v.useState)(``),[H,U]=(0,v.useState)(!1),[W,G]=ye(),[K,q]=(0,v.useState)(null),[J,Y]=(0,v.useState)(null),{showToast:X}=ee();(0,v.useEffect)(()=>{d.isConnected()||(console.log(`Socket not connected, attempting to connect...`),d.reconnect())},[]);let Z=(0,v.useCallback)(async()=>{try{C(!0);let[e,t]=await Promise.all([de(),te()]),r=e?.filter(e=>e&&typeof e==`object`&&e.id&&e.userId)||[];n(r);let i=t||[];if(x(i),i.length>0){let e=i.some(e=>e.id===B);(!B||!e)&&V(i[0].id)}else V(``);T(null)}catch(e){console.error(`Data fetch error:`,e),n([]),x([]);let t=`Failed to fetch data`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch data`}T(t),X({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[B,X]);(0,v.useEffect)(()=>{Z()},[Z]),(0,v.useEffect)(()=>{let e=()=>d.emit(`subscribe`,{channel:`context`}),t=()=>d.emit(`unsubscribe`,{channel:`context`}),r=d.on(`connect`,e);console.log(`Subscribing to context events`),e();let i=e=>{let t=e;if(console.log(`Received context created:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:created event:`,t);return}n(e=>e.some(e=>e&&e.id===t.id&&e.userId===t.userId)?(console.log(`Context ${t.id} already exists, skipping duplicate add`),e):[...e,t])},a=e=>{let t=e;if(console.log(`Received context update:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:updated event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},o=e=>{let t=e;console.log(`Received context deletion:`,t);let r=t?.contextId??t?.id;if(!r){console.error(`Invalid context deletion data received:`,t);return}n(e=>e.filter(e=>e&&e.id!==r))},s=e=>{let t=e;if(console.log(`Received context URL change:`,t),!t||!t.id||!t.userId){console.error(`Invalid context data received in context:url:changed event:`,t);return}n(e=>e.map(e=>e&&e.id===t.id&&e.userId===t.userId?{...e,...t}:e))},c=[[`context:created`,i],[`context.created`,i],[`context:updated`,a],[`context.updated`,a],[`context:deleted`,o],[`context.deleted`,o],[`context:url:changed`,s],[`context.url.set`,s],[`context:url:set`,s]];return c.forEach(([e,t])=>d.on(e,t)),()=>{console.log(`Unsubscribing from context events`),t(),r?.(),c.forEach(([e,t])=>d.off(e,t))}},[]);let xe=async t=>{if(t.preventDefault(),!M.trim()||!B||!E.trim()){X({title:`Missing Fields`,description:`Context ID, Context URL and Workspace are required.`,variant:`destructive`});return}U(!0);try{let t={id:E,name:O.trim()||void 0,url:M,description:P.trim()||void 0,metadata:{ui:{color:I}},workspaceId:B,baseUrl:R||void 0,treeType:A},n=await ue(t);D(``),k(``),N(`/`),F(``),L(null),z(`/`),await Z(),X({title:`Success`,description:`Context created successfully`}),G(!1),window.dispatchEvent(new CustomEvent(`contexts:refresh`)),e(`/contexts/${n.id}`)}catch(e){let t=be(e,`Context creation error:`,`Failed to create context`);X({title:`Error`,description:t,variant:`destructive`})}finally{U(!1)}},Se=async e=>{let n=t.find(t=>t.id===e);if(n&&n.url&&(n.url.endsWith(`/default`)||n.url.includes(`://default`))){X({title:`Error`,description:`Cannot delete the default context`,variant:`destructive`});return}Y(e)},Ce=async()=>{if(J)try{await p(J),n(e=>e.filter(e=>!le(e,{id:J}))),X({title:`Success`,description:`Context deleted successfully`})}catch(e){console.error(`Context deletion error:`,e);let t=`Failed to delete context`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to delete context`}X({title:`Error`,description:t,variant:`destructive`})}finally{Y(null)}},we=t=>{let n=t.isShared||t.type===`shared`;e(n?`/contexts/${t.id}?ownerId=${encodeURIComponent(t.userId)}`:`/contexts/${t.id}`)},Te=e=>{q(e)},Ee=async e=>{if(e.preventDefault(),K)try{n(e=>e.map(e=>e.id===K.id&&e.userId===K.userId?K:e)),X({title:`Success`,description:`Context updated successfully (mock update)`}),q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update context`;X({title:`Error`,description:t,variant:`destructive`})}},De=(0,v.useMemo)(()=>({type:e=>e.isShared||e.type===`shared`?`shared`:`owned`,id:e=>e.id??``,owner:e=>e.isShared||e.type===`shared`?e.ownerEmail||e.userId||``:`you`,url:e=>e.url??``,workspaceId:e=>e.workspaceId??``,baseUrl:e=>e.baseUrl??``,path:e=>e.path??``,locked:e=>+!!e.locked,created:e=>Date.parse(e.createdAt)||0,updated:e=>Date.parse(e.updatedAt)||0}),[]),{sorted:Oe,sort:Q,toggleSort:$}=ge(t.filter(e=>e!=null),De);return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsx)(_e,{title:`Contexts`,description:`Create and manage contexts in your workspaces. View contexts shared with you.`,actions:!W&&(0,b.jsxs)(l,{onClick:()=>G(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create context`,title:`Create context`,children:[(0,b.jsx)(i,{className:`h-4 w-4 sm:mr-2`}),(0,b.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Context`})]})}),W&&(0,b.jsx)(ve,{title:`Create New Context`,onClose:()=>G(!1),children:(0,b.jsxs)(`form`,{onSubmit:xe,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`workspace`,className:`block text-sm font-medium mb-1`,children:`Workspace`}),(0,b.jsxs)(`select`,{id:`workspace`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:B,onChange:e=>V(e.target.value),disabled:H||y.length===0,children:[y.length===0&&(0,b.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),y.map(e=>(0,b.jsx)(`option`,{value:e.id,children:e.label||e.name},`${e.owner}-${e.id}`))]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`newContextId`,className:`block text-sm font-medium mb-1`,children:`Context ID`}),(0,b.jsx)(u,{id:`newContextId`,value:E,onChange:e=>D(e.target.value),placeholder:`e.g., my-new-context`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`url`,value:M,onChange:N,placeholder:`e.g., /project/path/resource`,disabled:H,pickerTitle:`Context URL path…`,onPickTarget:(e,t)=>{N(e),j(t.treeType);let n=y.find(e=>e.name===t.workspaceName||e.id===t.workspaceName);n&&V(n.id)}})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`baseUrl`,className:`block text-sm font-medium mb-1`,children:`Base URL (Optional)`}),(0,b.jsx)(m,{id:`baseUrl`,value:R,onChange:z,format:`path`,placeholder:`e.g., /base/path`,disabled:H,pickerTitle:`Base path…`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`description`,className:`block text-sm font-medium mb-1`,children:`Description (Optional)`}),(0,b.jsx)(u,{id:`description`,value:P,onChange:e=>F(e.target.value),placeholder:`Description`,disabled:H})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextColor`,className:`block text-sm font-medium mb-1`,children:`Color (Optional)`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(u,{id:`contextColor`,type:`color`,value:I||`#808080`,onChange:e=>L(e.target.value),className:`h-10 w-16 p-1`,disabled:H}),(0,b.jsx)(l,{type:`button`,variant:`outline`,size:`sm`,disabled:H||I===null,onClick:()=>L(null),children:`Use inherited color`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:I===null?`Uses the tree folder or workspace color.`:`Applies only to this context.`})]}),(0,b.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`contextName`,className:`block text-sm font-medium mb-1`,children:`Name (Optional)`}),(0,b.jsx)(u,{id:`contextName`,value:O,onChange:e=>k(e.target.value),placeholder:`My Context`,disabled:H})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`treeType`,className:`block text-sm font-medium mb-1`,children:`Tree`}),(0,b.jsxs)(`select`,{id:`treeType`,className:`w-full px-3 py-2 border border-border rounded-md shadow-elevation-1 focus:outline-none focus:ring-primary focus:border-primary`,value:A,onChange:e=>j(e.target.value),disabled:H,children:[(0,b.jsx)(`option`,{value:`context`,children:`Context tree`}),(0,b.jsx)(`option`,{value:`directory`,children:`Directory tree`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Which workspace tree this context navigates.`})]})]}),(0,b.jsxs)(l,{type:`submit`,disabled:H||!M.trim()||!B||!E.trim(),children:[(0,b.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create Context`]})]})}),(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Contexts & Shared Contexts`}),S&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading contexts...`}),w&&(0,b.jsx)(`div`,{className:`text-center text-destructive`,children:(0,b.jsx)(`p`,{children:w})}),!S&&!w&&t.length===0&&(0,b.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No contexts found. Create one above.`}),t.length>0&&(0,b.jsx)(`div`,{className:`border rounded-lg overflow-hidden`,children:(0,b.jsxs)(me,{children:[(0,b.jsx)(he,{children:(0,b.jsxs)(g,{children:[(0,b.jsx)(_,{label:`Type`,sortKey:`type`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`ID`,sortKey:`id`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Owner`,sortKey:`owner`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Context URL`,sortKey:`url`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Workspace ID`,sortKey:`workspaceId`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Base URL`,sortKey:`baseUrl`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Path`,sortKey:`path`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Locked`,sortKey:`locked`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Created`,sortKey:`created`,sort:Q,onSort:$}),(0,b.jsx)(_,{label:`Updated`,sortKey:`updated`,sort:Q,onSort:$}),(0,b.jsx)(pe,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:Oe.map(e=>{if(!e)return console.warn(`Found null/undefined context in contexts array, skipping`),null;let t=e.createdAt?new Date(e.createdAt).toLocaleDateString():`-`,n=e.updatedAt?new Date(e.updatedAt).toLocaleDateString():`-`,r=e.isShared||e.type===`shared`,i=r?e.ownerEmail||e.userId||`-`:`You`,u=r&&e.sharedVia?typeof e.sharedVia==`string`?e.sharedVia:e.sharedVia.accessLevel||`-`:`-`;return(0,b.jsxs)(g,{children:[(0,b.jsx)(h,{children:r?(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-info`,title:`Shared with you (${u})`,children:[(0,b.jsx)(s,{className:`h-4 w-4`}),(0,b.jsx)(`span`,{className:`text-xs`,children:`Shared`})]}):(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Owned`})}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.id||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,title:r?`Owned by: ${i}`:`You are the owner`,children:i}),(0,b.jsx)(h,{className:`font-mono text-sm max-w-xs truncate`,title:e.url||`-`,children:e.url||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.workspaceId||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.baseUrl||`-`}),(0,b.jsx)(h,{className:`font-mono text-sm`,children:e.path||`-`}),(0,b.jsx)(h,{children:e.locked?`Yes`:`No`}),(0,b.jsx)(h,{children:t}),(0,b.jsx)(h,{children:n}),(0,b.jsx)(h,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Te(e),title:`Edit Context`,children:(0,b.jsx)(o,{className:`h-4 w-4`})}),(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>we(e),title:r?`Open Shared Context`:`Open Context Details`,children:(0,b.jsx)(c,{className:`h-4 w-4`})}),!r&&(0,b.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>Se(e.id),disabled:!!(e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))),className:`text-destructive hover:bg-destructive/10 hover:text-destructive disabled:opacity-50 disabled:cursor-not-allowed`,title:e.url&&(e.url.endsWith(`/default`)||e.url.includes(`://default`))?`Cannot delete default context`:`Delete Context`,children:(0,b.jsx)(a,{className:`h-4 w-4`})})]})})]},`${e.userId}-${e.id}`)})})]})})]}),K&&(0,b.jsxs)(`div`,{className:`space-y-4`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Edit Context`}),(0,b.jsxs)(`form`,{onSubmit:Ee,className:`space-y-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-id`,className:`block text-sm font-medium mb-1`,children:`Context ID (read-only)`}),(0,b.jsx)(u,{id:`edit-context-id`,value:K.id,disabled:!0,className:`bg-muted`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-context-url`,className:`block text-sm font-medium mb-1`,children:`Context URL`}),(0,b.jsx)(m,{id:`edit-context-url`,value:K.url,onChange:e=>q(t=>t?{...t,url:e}:null),placeholder:`workspace://path or /path`,pickerTitle:`Context URL path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Use format: workspace://path or /path for current workspace`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{htmlFor:`edit-base-url`,className:`block text-sm font-medium mb-1`,children:`Base URL (optional)`}),(0,b.jsx)(m,{id:`edit-base-url`,value:K.baseUrl||``,onChange:e=>q(t=>t?{...t,baseUrl:e||null}:null),format:`path`,placeholder:`/base/path`,pickerTitle:`Base path…`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Restricts context navigation to this base path`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(l,{type:`submit`,children:`Save Changes`}),(0,b.jsx)(l,{type:`button`,variant:`outline`,onClick:()=>q(null),children:`Cancel`})]})]})]}),(0,b.jsx)(ce,{open:J!==null,onOpenChange:e=>!e&&Y(null),children:(0,b.jsxs)(f,{children:[(0,b.jsxs)(se,{children:[(0,b.jsx)(re,{children:`Delete Context`}),(0,b.jsx)(ne,{children:`Are you sure you want to delete this context? This action cannot be undone.`})]}),(0,b.jsxs)(ae,{children:[(0,b.jsx)(oe,{children:`Cancel`}),(0,b.jsx)(ie,{onClick:Ce,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:`Delete`})]})]})})]})}export{x as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{yt as r}from"./react-BHzhHVTZ.js";import{Hr as i,Jr as a,L as o,Vr as s,Yr as c}from"./ui-CDoK3F3U.js";import{t as l}from"./utils-2pl1SbIp.js";import{Hn as u}from"./workspace-BJELPCNs.js";import{n as d}from"./tags-YamdPoBK.js";import{o as f}from"./useAddTarget-B3b6TyZr.js";import{r as p}from"./relation-events-CKio19hE.js";var m=e(n(),1),h=`2.1`,g=[`pending`,`in-progress`,`completed`,`cancelled`],_={pending:`Pending`,"in-progress":`In progress`,completed:`Completed`,cancelled:`Cancelled`};function v(e){return String(e).padStart(2,`0`)}function y(e){return`${e.getFullYear()}-${v(e.getMonth()+1)}-${v(e.getDate())}T${v(e.getHours())}:${v(e.getMinutes())}`}function b(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:y(t)}function x(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function S(){let e=new Date;return e.setHours(23,59,0,0),y(e)}function C(e){let t=x(e.due);return{title:e.title.trim(),...e.description.trim()?{description:e.description.trim()}:{},status:e.status,completed:e.status===`completed`,...t?{dueDate:t}:{},...e.priority===``?{}:{priority:Number(e.priority)}}}function w(){let[e,t]=(0,m.useState)(``),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(`pending`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(S()),[g,_]=(0,m.useState)([]),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(!1),w=p(),T=e.trim().length>0&&!b;async function E(t){x(!0);try{let r=await w.capture(),a=v.trim(),s={schema:u,schemaVersion:h,data:C({title:e,description:n,status:i,priority:o,due:c}),...a?{comment:a}:{},metadata:{features:d(g),...r?{geo:r}:{}}};return await f(t,[s])}finally{x(!1)}}return{title:e,setTitle:t,description:n,setDescription:r,status:i,setStatus:a,priority:o,setPriority:s,due:c,setDue:l,tags:g,setTags:_,comment:v,setComment:y,saving:b,canSave:T,save:E,geotag:w}}var T=e(r(),1),E=t(),D=15,O=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function k(e){return String(e).padStart(2,`0`)}function A(e){let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e||``);return t?{date:`${t[1]}-${t[2]}-${t[3]}`,time:`${t[4]}:${t[5]}`}:null}function j(e){return`${e.getFullYear()}-${k(e.getMonth()+1)}-${k(e.getDate())}`}function M(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r)}function N(){let e=new Date;return e.setSeconds(0,0),e.setMinutes(Math.ceil(e.getMinutes()/D)*D),`${k(e.getHours())}:${k(e.getMinutes())}`}function P(){let e=[];for(let t=0;t<1440;t+=D)e.push(`${k(Math.floor(t/60))}:${k(t%60)}`);return e}var F=P();function I(e){let t=new Date(e.getFullYear(),e.getMonth(),1),n=(t.getDay()+6)%7,r=new Date(t);return r.setDate(t.getDate()-n),Array.from({length:42},(e,t)=>{let n=new Date(r);return n.setDate(r.getDate()+t),n})}function L(e){let[t,n]=e.split(`:`).map(Number);return new Date(2e3,0,1,t,n).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function R(e){let t=A(e);if(!t)return``;let[n,r,i]=t.date.split(`-`).map(Number),[a,o]=t.time.split(`:`).map(Number);return new Date(n,r-1,i,a,o).toLocaleString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}function z({value:e,onChange:t,id:n,placeholder:r=`Pick a date & time`,clearable:i=!0,disabled:a=!1,compact:s=!1,className:u=``}){let[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(null),h=A(e),g=h?R(e):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:p,id:n,type:`button`,disabled:a,onClick:()=>f(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":d,className:l(`inline-flex w-full items-center gap-2 rounded-md border border-input bg-transparent text-left shadow-elevation-1 transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,s?`h-6 px-1.5 text-[11px]`:`h-9 px-3 py-1 text-sm`,!h&&`text-muted-foreground`,u),children:[(0,E.jsx)(c,{className:l(`shrink-0 text-muted-foreground`,s?`h-3 w-3`:`h-4 w-4`)}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:g||r}),i&&h&&(0,E.jsx)(`span`,{role:`button`,tabIndex:-1,"aria-label":`Clear date`,title:`Clear`,onClick:e=>{e.stopPropagation(),t(``)},className:`shrink-0 rounded p-0.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(o,{className:s?`h-2.5 w-2.5`:`h-3.5 w-3.5`})})]}),d&&(0,E.jsx)(V,{anchorRef:p,value:e,onChange:t,onClose:()=>f(!1)})]})}function B({value:e,onChange:t,id:n,placeholder:r=`Pick a date`,min:i,disabled:o=!1,className:s=``}){let[c,u]=(0,m.useState)(!1),d=(0,m.useRef)(null),f=/^\d{4}-\d{2}-\d{2}$/.test(e),p=f?M(e).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`,year:`numeric`}):``;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`button`,{ref:d,id:n,type:`button`,disabled:o,onClick:()=>u(e=>!e),"aria-haspopup":`dialog`,"aria-expanded":c,className:l(`inline-flex h-8 w-full items-center gap-2 rounded-md border border-input bg-transparent px-2 text-left text-sm transition-colors`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,!f&&`text-muted-foreground`,s),children:[(0,E.jsx)(a,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,E.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:p||r})]}),c&&(0,E.jsx)(V,{anchorRef:d,value:f?`${e}T00:00`:``,min:i,dateOnly:!0,onChange:e=>{t(e.slice(0,10)),u(!1)},onClose:()=>u(!1)})]})}function V({anchorRef:e,value:t,min:n,dateOnly:r=!1,onChange:a,onClose:o}){let c=A(t),u=c?.date??j(new Date),d=c?.time??null,[f,p]=(0,m.useState)(()=>{let e=M(u);return new Date(e.getFullYear(),e.getMonth(),1)}),h=(0,m.useRef)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null);(0,m.useLayoutEffect)(()=>{let t=h.current,n=e.current;if(!t||!n)return;let r=()=>{let e=n.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),a=e.bottom+4,o=a+i+8<=window.innerHeight,s=e.top-i-4>=8,c=o?a:s?e.top-i-4:Math.max(8,window.innerHeight-i-8),l=Math.max(8,Math.min(e.left,window.innerWidth-r-8));v({x:l,y:c})};r();let i=new ResizeObserver(r);return i.observe(t),window.addEventListener(`resize`,r),window.addEventListener(`scroll`,r,!0),()=>{i.disconnect(),window.removeEventListener(`resize`,r),window.removeEventListener(`scroll`,r,!0)}},[e]),(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),o())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o]);let y=(0,m.useMemo)(()=>!d||F.includes(d)?F:[...F,d].sort(),[d]);(0,m.useEffect)(()=>{let e=g.current,t=e?.querySelector(`[data-selected="true"]`);e&&t&&(e.scrollTop=t.offsetTop-e.clientHeight/2+t.clientHeight/2)},[]);let b=(e,t)=>a(`${e}T${t}`),x=e=>{let t=r?`00:00`:d??N();b(j(e),t),e.getMonth()!==f.getMonth()&&p(new Date(e.getFullYear(),e.getMonth(),1))},S=e=>{b(u,e),o()},C=e=>{let t=new Date;t.setDate(t.getDate()+e);let n=r?`00:00`:d??N();b(j(t),n),p(new Date(t.getFullYear(),t.getMonth(),1))},w=j(new Date),D=I(f);return(0,T.createPortal)((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:o}),(0,E.jsxs)(`div`,{ref:h,role:`dialog`,"aria-label":`Choose date and time`,className:`fixed z-50 flex max-w-[95vw] gap-2 rounded-md border bg-popover p-2 text-popover-foreground shadow-elevation-4`,style:{left:_?.x??-9999,top:_?.y??-9999,visibility:_?`visible`:`hidden`},children:[(0,E.jsxs)(`div`,{className:`w-[236px]`,children:[(0,E.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()-1,1)),"aria-label":`Previous month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(i,{className:`h-4 w-4`})}),(0,E.jsx)(`span`,{className:`text-xs font-medium`,children:f.toLocaleDateString(void 0,{month:`long`,year:`numeric`})}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>p(new Date(f.getFullYear(),f.getMonth()+1,1)),"aria-label":`Next month`,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,E.jsx)(s,{className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5 px-0.5 pb-1 text-center text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:O.map(e=>(0,E.jsx)(`span`,{children:e},e))}),(0,E.jsx)(`div`,{className:`grid grid-cols-7 gap-0.5`,children:D.map(e=>{let t=j(e),r=e.getMonth()!==f.getMonth(),i=t===u&&!!c;return(0,E.jsx)(`button`,{type:`button`,disabled:!!n&&t<n,onClick:()=>x(e),"aria-pressed":i,className:l(`h-7 rounded text-xs tabular-nums transition-colors disabled:cursor-not-allowed disabled:opacity-30`,r?`text-muted-foreground/40`:`text-foreground`,i?`bg-primary text-primary-foreground`:`hover:bg-muted`,!i&&t===w&&`font-semibold ring-1 ring-inset ring-border`),children:e.getDate()},t)})}),(0,E.jsx)(`div`,{className:`mt-1.5 flex gap-1`,children:[[`Today`,0],[`Tomorrow`,1],[`Next week`,7]].map(([e,t])=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>C(t),className:`flex-1 rounded border border-border px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:e},e))})]}),!r&&(0,E.jsxs)(`div`,{className:`flex w-[104px] flex-col`,children:[(0,E.jsx)(`input`,{type:`time`,step:900,value:d??``,onChange:e=>{e.target.value&&b(u,e.target.value.slice(0,5))},"aria-label":`Time`,className:`mb-1 h-7 w-full rounded border border-input bg-transparent px-1.5 text-xs tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`}),(0,E.jsx)(`div`,{ref:g,className:`max-h-[236px] flex-1 overflow-y-auto pr-0.5`,children:y.map(e=>{let t=e===d;return(0,E.jsx)(`button`,{type:`button`,"data-selected":t,onClick:()=>S(e),"aria-pressed":t,className:l(`block w-full rounded px-2 py-1 text-left text-xs tabular-nums transition-colors`,t?`bg-primary text-primary-foreground`:`hover:bg-muted`),children:L(e)},e)})})]})]})]}),document.body)}export{C as a,S as c,_ as i,w as l,z as n,b as o,g as r,x as s,B as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Bt as r,L as i,Wr as a,Xt as o,dt as s,kt as c,vn as l}from"./ui-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Bt as r,L as i,Wr as a,Xt as o,dt as s,kt as c,vn as l}from"./ui-CDoK3F3U.js";import{t as u}from"./button-SeUZ_Pvi.js";import{t as d}from"./input-BOtCd4HP.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{n as p}from"./page-header-DrDt1sQ2.js";import{t as m}from"./use-settings-back-DGmLAD63.js";import{i as h,n as g,o as _}from"./devices-CAa1bRxk.js";var v=e(n(),1),y=t();function b({device:e,onUpdated:t,onRemoved:n}){let[c,l]=(0,v.useState)(!1),[p,m]=(0,v.useState)(e.name),[g,b]=(0,v.useState)(e.description??``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(!1),{showToast:D}=f(),O=async()=>{E(!0);try{await h(e.deviceId),n(e.deviceId),D({title:`Revoked`,description:`${e.name} can no longer sign in; a running mirror stops on its next request.`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to revoke device`,variant:`destructive`}),w(!1)}finally{E(!1)}},k=async()=>{let n=p.trim();if(n){if(n===e.name&&g.trim()===(e.description??``)){l(!1);return}S(!0);try{let r=await _(e.deviceId,{name:n,description:g.trim()||void 0});t({...e,...r}),l(!1),D({title:`Saved`,description:`Device updated`})}catch(e){D({title:`Error`,description:e instanceof Error?e.message:`Failed to update device`,variant:`destructive`})}finally{S(!1)}}},A=()=>{m(e.name),b(e.description??``),l(!1)},j=e=>e?new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):`—`;return(0,y.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-start gap-3 min-w-0`,children:[(0,y.jsx)(o,{className:`h-4 w-4 text-muted-foreground mt-0.5 shrink-0`}),(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[c?(0,y.jsxs)(`div`,{className:`space-y-2 mb-2`,children:[(0,y.jsx)(d,{value:p,onChange:e=>m(e.target.value),className:`h-7 text-sm`,placeholder:`Device name`,autoFocus:!0,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}}),(0,y.jsx)(d,{value:g,onChange:e=>b(e.target.value),className:`h-7 text-xs`,placeholder:`Description (optional)`,disabled:x,onKeyDown:e=>{e.key===`Enter`&&k(),e.key===`Escape`&&A()}})]}):(0,y.jsxs)(`div`,{className:`mb-1`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.description&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] font-mono text-muted-foreground`,children:[(0,y.jsx)(`span`,{title:`Device ID`,children:e.deviceId}),e.platform&&(0,y.jsx)(`span`,{children:e.platform}),e.arch&&(0,y.jsx)(`span`,{children:e.arch}),e.type&&(0,y.jsx)(`span`,{className:`capitalize`,children:e.type})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 text-[11px] text-muted-foreground`,children:[e.createdAt&&(0,y.jsxs)(`span`,{children:[`registered `,j(e.createdAt)]}),e.updatedAt&&e.updatedAt!==e.createdAt&&(0,y.jsxs)(`span`,{children:[`updated `,j(e.updatedAt)]}),e.lastSeen&&(0,y.jsxs)(`span`,{children:[`seen `,j(e.lastSeen)]})]})]})]}),(0,y.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:C?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`destructive`,size:`sm`,onClick:O,disabled:T,children:T?`Revoking…`:`Confirm revoke`}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!1),disabled:T,children:(0,y.jsx)(i,{className:`h-3.5 w-3.5`})})]}):c?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:k,disabled:x||!p.trim(),children:(0,y.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:A,disabled:x,children:(0,y.jsx)(i,{className:`h-3.5 w-3.5`})})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>l(!0),title:`Edit name / description`,children:(0,y.jsx)(r,{className:`h-3.5 w-3.5`})}),(0,y.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(!0),title:`Revoke this device: its tokens stop working and its mirrors stop syncing`,children:(0,y.jsx)(s,{className:`h-3.5 w-3.5`})})]})})]})})}function x(){let[e,t]=(0,v.useState)([]),[n,r]=(0,v.useState)(!0),{showToast:i}=f(),a=async()=>{r(!0);try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}};(0,v.useEffect)(()=>{(async()=>{try{t(await g())}catch(e){i({title:`Error`,description:e instanceof Error?e.message:`Failed to load devices`,variant:`destructive`})}finally{r(!1)}})()},[i]);let s=e=>t(t=>t.map(t=>t.deviceId===e.deviceId?e:t)),d=e=>t(t=>t.filter(t=>t.deviceId!==e));return(0,y.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,y.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6 pb-12 space-y-6`,children:[(0,y.jsx)(p,{compact:!0,title:`Devices`,onBack:m(),description:`All devices registered to your account. Link them to individual workspaces in Workspace › Settings › Devices.`,actions:(0,y.jsxs)(u,{type:`button`,variant:`outline`,size:`sm`,onClick:a,disabled:n,children:[(0,y.jsx)(c,{className:`mr-2 h-3.5 w-3.5 ${n?`animate-spin`:``}`}),`Refresh`]})}),n?(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Loading…`]}):e.length===0?(0,y.jsxs)(`div`,{className:`rounded-lg border p-6 text-center text-sm text-muted-foreground space-y-2`,children:[(0,y.jsx)(o,{className:`h-8 w-8 mx-auto text-muted-foreground/40`}),(0,y.jsx)(`p`,{children:`No devices registered yet.`}),(0,y.jsxs)(`p`,{className:`text-xs`,children:[`Devices register themselves automatically on first connection via`,` `,(0,y.jsx)(`span`,{className:`font-mono`,children:`POST /auth/devices/register`}),`.`]})]}):(0,y.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,y.jsx)(b,{device:e,onUpdated:s,onRemoved:d},e.deviceId))}),e.length>0&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-dashed p-3 text-xs text-muted-foreground`,children:[(0,y.jsx)(l,{className:`h-3.5 w-3.5 shrink-0`}),`To link a device to a workspace, go to Workspace › Settings › Devices.`]})]})})}export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./button-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as i,h as a}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as o}from"./button-SeUZ_Pvi.js";import{An as s,nt as c,tt as l}from"./workspace-BJELPCNs.js";import{t as u,u as d}from"./ObjectPropertiesCard-BTTwYnN9.js";import{t as f}from"./url-params-n7kU_WZ-.js";import{i as p}from"./use-menu-DIP1zh7I.js";import{t as m}from"./workspace-content-gate-NLuRPvbm.js";import{t as h}from"./use-workspace-identity-B8gOMGj4.js";var g=e(n(),1),_=t();function v(){let{workspaceName:e}=r();return e?(0,_.jsx)(m,{workspaceName:e,children:(0,_.jsx)(y,{})}):(0,_.jsx)(`p`,{role:`alert`,className:`p-6`,children:`Workspace not specified.`})}function y(){let{workspaceName:e=``,documentId:t=``,algo:n=``,checksum:m=``}=r(),v=i(),y=a(),{goBack:b,openM1Drawer:x,openM2Drawer:S}=p(),C=h(e),w=!!n&&!!m,T=w?`${n}/${m}`:t,E=JSON.stringify([e,t,n,m]),D=Number(t),O=/^\d+$/.test(t)&&Number.isSafeInteger(D)&&D>0,k=w||O,[A,j]=(0,g.useState)(0),[M,N]=(0,g.useState)(null),P=M?.identity===E?M:null,F=k&&(!P||P.revision!==A);(0,g.useEffect)(()=>{let t=!1;if(k)return(w?c(e,n,m):l(e,D)).then(e=>{t||N({identity:E,revision:A,document:e||null,missing:!e,error:``})}).catch(e=>{t||N({identity:E,revision:A,document:null,missing:e?.statusCode===404,error:e instanceof Error?e.message:`Unable to retrieve this document.`})}),()=>{t=!0}},[e,D,E,A,k,w,n,m]);let I={workspace:C?.label||e,workspaceIcon:C?.icon,path:`/`,tree:`context`,document:P?.document?s(P.document).title:`Document ${T}`,onBack:b,onBrowseWorkspaces:()=>x(`workspaces`),onBrowseTree:()=>S(`workspaces`,`detail`,e),onNavigatePath:t=>v(f(e,t,`context`))},L=y.hash.slice(1),R=[`view`,`location`,`metadata`,`json`,`synapses`,`backends`].includes(L)?L:`view`;return(0,_.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[!P?.document&&(0,_.jsx)(d,{...I}),P?.document?(0,_.jsx)(u,{document:P.document,workspaceId:e,onChanged:()=>j(e=>e+1),navigation:I,initialTab:R,onTabChange:e=>v(`${y.pathname}${y.search}#${e}`,{replace:!0}),tabActions:(0,_.jsx)(o,{variant:`ghost`,disabled:F,onClick:()=>j(e=>e+1),children:`Refresh`})},E):F?(0,_.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading document…`}):(0,_.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-6 text-sm`,children:[(0,_.jsx)(`p`,{className:`font-medium`,children:P?.missing?`Document ${T} not found`:`Unable to load document`}),k&&(0,_.jsx)(o,{variant:`outline`,onClick:()=>j(e=>e+1),children:`Retry`}),(0,_.jsx)(`p`,{className:`text-muted-foreground`,children:k?P?.missing?`This record is no longer available in this workspace. Subtree exports skip missing records and report their IDs.`:P?.error:`Document ID must be a positive integer.`})]})]})}export{v as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/subtree-transfer-dialog-DQM5zfx2.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/react-BHzhHVTZ.js","assets/ui-CDoK3F3U.js","assets/button-SeUZ_Pvi.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CFeuDt0T.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{l as n,u as r}from"./code-editor-BOIngd5F.js";import{vt as i,yt as a}from"./react-BHzhHVTZ.js";import{t as o}from"./preload-helper-Czpn1I53.js";import{g as s}from"./chunk-62JRHF6Z-vspAGgtK.js";import{$ as c,Ar as l,Bn as u,Br as d,Bt as f,Cr as p,Ct as m,Hr as h,It as g,Jr as _,Jt as v,Kn as y,Kr as b,L as x,Lt as S,Pt as C,Qn as w,Qt as ee,Rt as T,Tr as te,Tt as ne,Un as re,Vr as E,Vt as D,W as ie,Wt as ae,X as oe,_n as se,_r as O,an as ce,ar as le,ci as k,cn as ue,cr as de,fi as fe,fr as pe,gr as me,hi as he,lr as ge,mr as _e,ot as ve,pn as ye,rt as be,st as xe,tt as A,vn as Se,vr as Ce,xn as we,xt as Te,yn as Ee,yt as De,zn as j,zr as Oe}from"./ui-CDoK3F3U.js";import{t as ke}from"./utils-2pl1SbIp.js";import{t as M}from"./button-SeUZ_Pvi.js";import{t as Ae}from"./socket-CtH3EU9m.js";import{n as je}from"./use-toast-BlLDqSUO.js";import{c as Me,d as Ne,f as Pe,h as Fe,l as Ie,p as Le,t as Re,u as ze}from"./LinkToCard-BQ1yoFDr.js";import{An as N,At as Be,Bt as Ve,Cn as P,Dn as He,Dt as Ue,Ft as F,It as We,Jt as Ge,Mn as Ke,N as qe,O as Je,Pt as Ye,Q as Xe,Rt as Ze,Tn as Qe,Un as $e,Ut as et,Yt as tt,a as nt,bn as rt,c as it,cn as at,g as ot,hn as I,ht as st,jn as ct,ln as lt,m as ut,mn as dt,mt as ft,o as pt,p as L,pn as mt,r as R,rt as z,tt as B,ut as ht,vn as gt,wn as _t,yt as vt,zt as yt}from"./workspace-BJELPCNs.js";import{a as bt,b as xt,c as St,f as Ct,l as wt,o as Tt,s as V,t as Et,v as Dt}from"./ObjectPropertiesCard-BTTwYnN9.js";import{i as Ot,n as kt,s as At}from"./document-open-mode-DoImW-xs.js";import{t as jt}from"./use-mobile-Db-vWu9Y.js";import{c as Mt,s as Nt}from"./IdentityFields-DZRqtnIG.js";import{i as Pt}from"./public-share-D5yz-Pmo.js";import{o as Ft,s as It}from"./text-documents-BaXhu3ra.js";import{t as H}from"./useDocumentThumbnail-wW0lSOEy.js";import{t as Lt}from"./markdown-view-BBBZtNSR.js";import{n as Rt}from"./tags-YamdPoBK.js";import{r as zt}from"./use-toolbox-Ck_cLGgf.js";import{C as Bt,S as Vt,T as Ht,g as Ut,h as Wt,m as Gt,t as Kt,u as qt,y as Jt}from"./context-DZ1Hn7tt.js";import{n as Yt}from"./relation-events-CKio19hE.js";import{n as Xt,t as Zt}from"./PickDocumentsCard-CFDQL70e.js";import{t as U}from"./useEscapeClose-DR_xKT_k.js";import{t as Qt}from"./useToastHelpers-CRrpIIdY.js";import{u as $t}from"./layer-style-Byl5LNFR.js";import{t as W}from"./DocumentIcon-9i1uCMQa.js";import{n as en,t as tn}from"./LinkToSidePanel-eCy3nW4R.js";import{C as nn,W as rn,c as an,d as on,i as sn,k as cn,s as ln,t as un,z as dn}from"./backend-sync-progress-tUU2XWtW.js";import{t as fn}from"./workspace-access-C9nZlBBZ.js";import{t as pn}from"./search-COMZIxA7.js";import{a as G,c as mn,i as hn,n as gn,o as _n,r as vn,s as yn,t as bn}from"./use-sortable-data-BBKmqs79.js";import{n as xn}from"./workspace-BydSRtST.js";var K=e(r(),1),Sn=(0,K.createContext)(null),Cn=()=>(0,K.useContext)(Sn),wn=`canvas:readerWidth`,q=320,Tn=1600;function En(){try{let e=Number(sessionStorage.getItem(wn));return Number.isFinite(e)&&e>=q&&e<=Tn?e:null}catch{return null}}var Dn=En(),On=new Set;function kn(e){return On.add(e),()=>{On.delete(e)}}function An(e){Dn=e===null?null:Math.round(Math.max(q,Math.min(Tn,e)));try{Dn===null?sessionStorage.removeItem(wn):sessionStorage.setItem(wn,String(Dn))}catch{}On.forEach(e=>e())}function jn(){return(0,K.useSyncExternalStore)(kn,()=>Dn,()=>null)}function Mn(e,t){let[n,r]=(0,K.useState)(null),i=t?.id??null,a=`${e}:${i}`,[o,s]=(0,K.useState)(a);a!==o&&(s(a),r(null));let c=(0,K.useRef)(a),l=(0,K.useRef)(0);(0,K.useEffect)(()=>(c.current=a,l.current++,()=>{c.current=``}),[a]);let u=n?.id??i,d=(0,K.useCallback)(t=>{if(!e||u==null||c.current!==a)return;let n=++l.current;if(t){r(t);return}B(e,u).then(e=>{c.current===a&&l.current===n&&e&&r(e)}).catch(()=>{})},[e,u,a]);return{document:n??t,refresh:d}}var J=n();function Nn(e){return e.schema===`data/schema/note`?A:e.schema===`data/schema/tab`?se:e.schema===`data/schema/file`?le:e.schema===`data/schema/message/email`?ue:ge}function Pn({entry:e,onClose:t,frame:n}={}){let r=Tt(),i=e??r.entry,a=t??r.close,{document:o,refresh:s}=Mn(i?.workspaceId,i?.document??null);if(!i||!o)return!e&&(r.loading||r.error)?(0,J.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden rounded-(--card-radius) border bg-card`,children:[(0,J.jsxs)(`div`,{className:`flex h-[calc(3rem-1px)] shrink-0 items-center justify-between border-b-[3px] bg-muted pl-4 pr-2`,children:[(0,J.jsx)(`span`,{className:`text-sm`,children:`Document`}),(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`flex h-8 w-8 items-center justify-center rounded hover:bg-accent`,"aria-label":`Close`,children:(0,J.jsx)(x,{className:`h-4 w-4`})})]}),(0,J.jsxs)(`div`,{className:`p-4 text-sm`,role:r.error?`alert`:`status`,children:[r.error||`Loading document…`,r.error&&(0,J.jsx)(`button`,{type:`button`,className:`ml-2 underline`,onClick:r.retry,children:`Retry`})]})]}):null;let{workspaceId:c}=i,l=t=>{s(t),t&&t.id!==i.document.id&&!e&&r.replace?.(t,c)};return(0,J.jsx)(Xt,{title:N(o).title,icon:Nn(o),onClose:a,onSave:async e=>(await yt(c,e.path,[o.id],e.treeName,e.treeType),[o.id]),canSave:!0,successMessage:`Linked`,lockedWorkspaceName:c,relationSubjectId:o.id,frame:n,fillParent:!0,fullWidthContent:Ct(o)===Dt,maximized:e?void 0:r.location?.maximized,onMaximizedChange:e?void 0:e=>r.update?.({maximized:e}),children:t=>(0,J.jsx)(`div`,{className:`document-side-content h-full min-h-0 min-w-0 w-full`,children:(0,J.jsx)(Et,{document:o,workspaceId:c,onChanged:l,compact:!0,tabActions:t,initialTab:e?void 0:r.location?.section,onTabChange:e?void 0:e=>r.update?.({section:e})},`${c}:${o.id}`)})})}var Fn=320,In=1600;function Ln({edge:e}){let t=jn(),n=(0,K.useRef)(null),r=e===`left`?-1:1;return(0,J.jsx)(`div`,{role:`separator`,"aria-label":`Resize document reader`,"aria-orientation":`vertical`,"aria-valuemin":Fn,"aria-valuemax":In,"aria-valuenow":t??420,tabIndex:0,title:`Drag to resize; arrow keys adjust width; double-click to reset`,className:`absolute inset-y-0 ${e===`left`?`left-0`:`right-0`} z-20 hidden w-2 touch-none cursor-col-resize select-none hover:bg-primary/20 focus-visible:bg-primary/20 focus-visible:outline-none md:block`,onPointerDown:t=>{if(t.button!==0)return;t.preventDefault(),t.stopPropagation();let r=t.currentTarget.closest(`[data-reader-pane]`),i=e===`left`?(r.parentElement?.clientWidth??window.innerWidth)-248:window.innerWidth;n.current={x:t.clientX,width:r.getBoundingClientRect().width,max:Math.max(Fn,i)},t.currentTarget.setPointerCapture(t.pointerId)},onPointerMove:e=>{n.current&&An(Math.min(n.current.max,n.current.width+r*(e.clientX-n.current.x)))},onPointerUp:e=>{n.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{n.current=null},onLostPointerCapture:()=>{n.current=null},onDoubleClick:()=>An(null),onKeyDown:e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault(),e.stopPropagation();let t=e.currentTarget.closest(`[data-reader-pane]`);e.key===`Home`?An(null):An(t.getBoundingClientRect().width+(e.key===`ArrowRight`?1:-1)*r*(e.shiftKey?64:16))}})}function Rn(e){let t=Cn(),n=Ot(),r=jt(),i=Tt();return!e.enabled||!e.workspaceId||r||t?.compact||i.location?e.children:(0,J.jsx)(zn,{...e,workspaceId:e.workspaceId,autoOpen:n},`${e.scope}:${n}`)}function zn({workspaceId:e,scope:t,documents:n,loading:r,children:i,autoOpen:a}){let o=jn(),[s,c]=(0,K.useState)(a),l=`canvas:readerSelection:${t}`,[u,d]=(0,K.useState)(()=>{try{return Number(sessionStorage.getItem(l))||null}catch{return null}}),f=!s||r?null:n.find(e=>e.id===u)??n[0]??null,p=(0,K.useCallback)((t,n)=>{if(n===e){c(!0),d(t.id);try{sessionStorage.setItem(l,String(t.id))}catch{}}},[e,l]),m=(0,K.useMemo)(()=>({entry:f?{document:f,workspaceId:e}:null,alwaysOn:!0,open:p,preview:p,replace:p,close:()=>c(!1)}),[f,e,p]);return(0,J.jsx)(bt.Provider,{value:m,children:(0,J.jsxs)(`div`,{"data-always-reader":!0,className:`flex h-full min-h-0 min-w-0 flex-1 gap-shell`,children:[(0,J.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto`,children:i}),s&&(0,J.jsxs)(`aside`,{"data-reader-pane":!0,"aria-label":`Document reading pane`,style:{width:o?`${o}px`:`50vw`,maxWidth:`calc(100% - 240px)`},className:`relative flex min-h-0 min-w-0 shrink-0 overflow-hidden border-l bg-card`,children:[(0,J.jsx)(Ln,{edge:`left`}),f?(0,J.jsx)(Pn,{},`${e}:${f.id}`):(0,J.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,role:`status`,children:r?`Loading documents…`:`No documents in this list`})]})]})})}async function Bn(e,t,n){let r={successful:[],failed:[],pending:[]},i=[...new Set(e)],a=0;n.onProgress(0,i.length);for(let e of i){if(n.shouldStop())break;try{let n=await t([e]);r.successful.push(...n.successful),r.failed.push(...n.failed)}catch(t){r.failed.push({id:e,reason:t instanceof Error?t.message:String(t)}),a++,n.onProgress(a,i.length);break}a++,n.onProgress(a,i.length)}return r.pending=i.slice(a),r}function Vn(e){let t=[],n=!1;return{text:e.replace(/"[^"]*"|(^|\s)@id:([^\s]*)/g,(e,r,i)=>{if(i===void 0)return e;let a=i.replace(/^#/,``),o=Number(a);return!/^\d+$/.test(a)||!Number.isInteger(o)||o<=0||o>4294967295?n=!0:t.push(o),r}).trim(),ids:t,invalid:n}}function Hn(){let e,t,n=!1,r=()=>{clearTimeout(e),e=void 0,t=void 0};return{cancel:r,start(i,a,o){r(),n=!1,t={x:i,y:a},e=setTimeout(()=>{e=void 0,n=!0,o()},500)},move(e,n){t&&Math.hypot(e-t.x,n-t.y)>10&&r()},consumeClick(){let e=n;return n=!1,e},contextMenu(){let e=n;return t&&(n=!0),r(),e},reset(){r(),n=!1}}}function Un(){let[e]=(0,K.useState)(Hn);return(0,K.useEffect)(()=>e.cancel,[e]),{onPointerDown:t=>{if(e.reset(),t.pointerType!==`touch`||!t.isPrimary)return;let n=t.target;if(!t.currentTarget.contains(n)||n.closest(`button, input, textarea, select, a, [contenteditable="true"], [role="dialog"]`))return;let{clientX:r,clientY:i}=t;e.start(r,i,()=>{n.dispatchEvent(new window.MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,clientX:r,clientY:i}))})},onPointerMove:t=>e.move(t.clientX,t.clientY),onPointerUp:e.cancel,onPointerCancel:e.cancel,onPointerLeave:e.cancel,onDragStartCapture:t=>{e.cancel(),e.consumeClick()&&t.preventDefault()},onContextMenuCapture:t=>{t.isTrusted&&e.contextMenu()&&(t.preventDefault(),t.stopPropagation())},onClickCapture:t=>{e.consumeClick()&&(t.preventDefault(),t.stopPropagation())}}}function Wn(e,t,n,r,i=!1){let a=e.indexOf(n);if(a<0)return new Set(r);let o=t===null?-1:e.indexOf(t),s=o<0?a:o,c=i?new Set(r):new Set;for(let t of e.slice(Math.min(s,a),Math.max(s,a)+1))c.add(t);return c}var Y=e=>typeof e==`string`?e:``,X=e=>e&&typeof e==`object`?e:{},Z=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\r/g,`\\r`).replace(/\n/g,`\\n`).replace(/\t/g,`\\t`);function Gn(e){let t=e.data||{},n=e.schema===`data/schema/message/email`,r=!n&&e.schema.startsWith(`data/schema/message`),i=Y(t.platform),a=Y(X(t.channel).id)||Y(t.channel),o=[],s=(t,n,r)=>o.push({id:t,label:n,rule:{id:``,description:n,enabled:!0,when:{event:`document.inserted`,schema:e.schema,...r},then:[{action:`link`,paths:[]}]}}),c=i?{platform:{equals:i}}:{};if(n){let e=Y(X(t.from).address)||Y(t.from);e&&s(`sender`,`Mail from ${e}`,{from:{equals:e}}),t.subject&&s(`subject`,`Subject matches regex`,{subject:{regex:Z(t.subject)}})}else if(r){let e=Y(X(t.sender).id)||Y(X(t.sender).username)||Y(X(t.sender).name)||Y(t.sender),n=Y(X(t.sender).name)||Y(X(t.sender).username)||e;e&&s(`sender`,`Messages from ${n}`,{...c,sender:{equals:e}})}let l=Y(t.body)||Y(t.text)||Y(t.content)||Y(t.bodyHtml)||Y(t.bodyPreview);if((n||r||l)&&s(`body`,n?`Email body matches regex`:`Text matches regex`,{...c,body:{regex:Z(l.slice(0,160))}}),r){let n=Y(t.threadId)||([`slack`,`teams`].includes(i)?Y(X(e.metadata).remoteId):``);n&&a&&s(`thread`,`Messages in this thread`,{...c,channel:{equals:a},thread:{equals:n}}),a&&s(`channel`,i===`whatsapp`?`Messages in this conversation`:`Messages in this channel`,{...c,channel:{equals:a}})}return t.url&&s(`url`,`URL matches regex`,{url:{regex:Z(t.url)}}),s(`schema`,`All items of this type`,{}),o}var Kn=e(a(),1);function qn({label:e,onClose:t,children:n}){return U(t),(0,Kn.createPortal)((0,J.jsx)(`div`,{className:`fixed inset-0 z-dialog flex items-center justify-center bg-scrim p-4`,onClick:t,children:(0,J.jsx)(`section`,{"data-dialog-surface":!0,role:`dialog`,"aria-modal":`true`,"aria-label":e,className:`h-[86dvh] max-h-full min-h-0 w-full max-w-3xl overflow-y-auto rounded-(--panel-radius) border bg-popover text-popover-foreground shadow-elevation-4`,onClick:e=>e.stopPropagation(),children:n})}),window.document.body)}function Jn({workspaceId:e,document:t,onClose:n}){let[r,i]=(0,K.useState)(null),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``);U(n),(0,K.useEffect)(()=>{let n=!1;return(async()=>{let r=await Xe(e);if(!fn(r))throw Error(`Only workspace administrators can create rules.`);let a=await B(e,t.id);n||i(a)})().catch(e=>{n||o(e instanceof Error?e.message:`Could not load document`)}),()=>{n=!0}},[e,t.id]);let l=(0,K.useMemo)(()=>r?Gn(r):[],[r]),u=l.find(e=>e.id===s)||l[0],d=(0,K.useMemo)(()=>u?{kind:`document`,rule:u.rule}:null,[u]);return(0,J.jsx)(qn,{label:`Create rule`,onClose:n,children:(0,J.jsxs)(`div`,{className:`p-5`,children:[(0,J.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{id:`document-rule-title`,className:`text-lg font-semibold`,children:`Create rule`}),(0,J.jsx)(`p`,{className:`truncate text-sm text-muted-foreground`,children:N(t).title})]}),(0,J.jsx)(`button`,{type:`button`,"aria-label":`Close`,onClick:n,className:`rounded-md p-2 hover:bg-accent`,children:(0,J.jsx)(x,{className:`h-4 w-4`})})]}),a?(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{className:`mb-4 block space-y-2 text-sm font-medium`,children:[(0,J.jsx)(`span`,{children:`Start with`}),(0,J.jsx)(`select`,{className:`h-10 w-full rounded-md border bg-background px-3`,value:u?.id,onChange:e=>c(e.target.value),children:l.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(on,{workspaceId:e,prefill:d,createOnly:!0,onCreated:n,onCancel:n})]}):(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading document…`})]})})}function Yn(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Xn(e,t){return e.left<t.left+t.width&&e.left+e.width>t.left&&e.top<t.top+t.height&&e.top+e.height>t.top}function Zn(e,t,n,r){let i=new Set(r?n:[]);for(let n of t)Xn(e,n.bounds)&&i.add(n.id);return i}var Qn=`[data-document-id], button, a, input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="dialog"], [role="menu"], [draggable="true"], thead, [data-selection-ignore]`;function $n(e,t){let n=e.ownerDocument.defaultView,r=null,i=null,a=0,o=0,s=!1,c=!1,l=``,u=()=>{let t=e.getBoundingClientRect();return{left:t.left+e.clientLeft,top:t.top+e.clientTop,width:e.clientWidth,height:e.clientHeight}},d=t=>{let n=u();return{x:Math.max(0,Math.min(n.width,t.x-n.left))+e.scrollLeft,y:Math.max(0,Math.min(n.height,t.y-n.top))+e.scrollTop}},f=()=>{if(!r?.active||!i)return;let n=Yn(r.start,d(r.client));Object.assign(i.style,{left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`});let a=u(),o=Array.from(e.querySelectorAll(`[data-document-id]`)).filter(e=>e.getClientRects().length>0).map(t=>{let n=t.getBoundingClientRect();return{id:Number(t.dataset.documentId),bounds:{left:n.left-a.left+e.scrollLeft,top:n.top-a.top+e.scrollTop,width:n.width,height:n.height}}});t.onSelectionChange(Zn(n,o,r.initial,r.additive))},p=(e,t,n)=>{let r=Math.min(40,n/4);return e<t+r?-18*Math.min(1,(t+r-e)/r):e>t+n-r?18*Math.min(1,(e-t-n+r)/r):0},m=t=>{if(!r?.active)return;let i=u(),c=o?Math.min(2,(t-o)/(1e3/60)):1;o=t;let{scrollTop:l,scrollLeft:d}=e;e.scrollTop+=p(r.client.y,i.top,i.height)*c,e.scrollLeft+=p(r.client.x,i.left,i.width)*c,(s||e.scrollTop!==l||e.scrollLeft!==d)&&(f(),s=!1),a=n.requestAnimationFrame(m)},h=(s=!1)=>{if(!r)return;let u=r;r=null,n.cancelAnimationFrame(a),a=0,o=0,i?.remove(),i=null,u.active&&(e.style.userSelect=l,c=!0,s&&t.onSelectionChange(u.initial)),e.hasPointerCapture(u.pointerId)&&e.releasePointerCapture(u.pointerId)},g=n=>{if(c=!1,r||n.button!==0||!n.isPrimary||n.pointerType===`touch`)return;let i=n.target;if(!e.contains(i)||i.closest(Qn))return;let a=u();if(n.clientX<a.left||n.clientX>=a.left+a.width||n.clientY<a.top||n.clientY>=a.top+a.height)return;let o={x:n.clientX,y:n.clientY};r={pointerId:n.pointerId,start:d(o),clientStart:o,client:o,initial:new Set(t.getSelection()),additive:n.ctrlKey||n.metaKey||n.shiftKey,active:!1},n.preventDefault(),e.focus({preventScroll:!0}),e.setPointerCapture(n.pointerId)},_=t=>{if(!(!r||t.pointerId!==r.pointerId)){if(!(t.buttons&1)){h();return}if(r.client={x:t.clientX,y:t.clientY},!r.active){if(Math.hypot(t.clientX-r.clientStart.x,t.clientY-r.clientStart.y)<4)return;r.active=!0,l=e.style.userSelect,e.style.userSelect=`none`,n.getSelection()?.removeAllRanges(),i=e.ownerDocument.createElement(`div`),i.setAttribute(`aria-hidden`,`true`),i.dataset.selectionRectangle=``,i.className=`pointer-events-none absolute z-20 border border-info bg-info/15`,e.append(i),a=n.requestAnimationFrame(m)}s=!0,t.preventDefault()}},v=e=>{!r||e.pointerId!==r.pointerId||(r.client={x:e.clientX,y:e.clientY},r.active?f():r.additive||t.onSelectionChange(new Set),h())},y=()=>h(!0),b=e=>{e.pointerId===r?.pointerId&&y()},x=e=>{r&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y())},S=e=>{c&&(c=!1,e.preventDefault(),e.stopImmediatePropagation())},C=()=>{s=!0};return e.addEventListener(`pointerdown`,g),e.addEventListener(`pointermove`,_),e.addEventListener(`pointerup`,v),e.addEventListener(`pointercancel`,b),e.addEventListener(`lostpointercapture`,b),e.addEventListener(`click`,S,!0),e.addEventListener(`scroll`,C,!0),n.addEventListener(`keydown`,x,!0),n.addEventListener(`blur`,y),()=>{h(),e.removeEventListener(`pointerdown`,g),e.removeEventListener(`pointermove`,_),e.removeEventListener(`pointerup`,v),e.removeEventListener(`pointercancel`,b),e.removeEventListener(`lostpointercapture`,b),e.removeEventListener(`click`,S,!0),e.removeEventListener(`scroll`,C,!0),n.removeEventListener(`keydown`,x,!0),n.removeEventListener(`blur`,y)}}function er({scope:e,selected:t,onSelectionChange:n,onContextMenu:r,children:i}){let a=(0,K.useRef)(null),o=(0,K.useRef)({selected:t,onSelectionChange:n});return(0,K.useLayoutEffect)(()=>{o.current={selected:t,onSelectionChange:n}},[t,n]),(0,K.useLayoutEffect)(()=>{if(a.current)return $n(a.current,{getSelection:()=>o.current.selected,onSelectionChange:e=>o.current.onSelectionChange(e)})},[e]),(0,J.jsx)(`div`,{ref:a,tabIndex:-1,"data-document-selection-area":``,onContextMenu:r,className:`relative isolate min-h-0 min-w-0 flex-1 overflow-auto p-2 outline-none`,children:i})}function tr(e){let t=2166136261;for(let e of localStorage.getItem(`authToken`)||``)t=Math.imul(t^e.charCodeAt(0),16777619);return`canvas:workspace-copy:${t>>>0}:${e}`}function nr({workspaceId:e,ids:t,onClose:n,modal:r=!1}){let{showProgress:i}=je();U(n,r);let[a]=(0,K.useState)(()=>{try{return tr(e)}catch{return``}}),[o,s]=(0,K.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(a)||`null`);return e&&Array.isArray(e.ids)&&e.target&&e.index<e.ids.length?e:null}catch{return null}}),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(``),f=(0,K.useRef)(!1),p=(0,K.useRef)(!1);(0,K.useEffect)(()=>(f.current=!1,()=>{f.current=!0}),[]);let m=e=>{try{e.index>=e.ids.length?localStorage.removeItem(a):localStorage.setItem(a,JSON.stringify(e))}catch{}f.current||s(e)},h=async t=>{if(p.current)return;p.current=!0,l(!0),d(``);let n=t,r=()=>`${n.index} / ${n.ids.length} document(s) → ${n.target.workspaceName}`,a=i({title:`Copying to workspace…`,description:r()});m(n);try{for(;n.index<n.ids.length&&!f.current;){if(!navigator.onLine)throw Error(`Offline. Your copy is saved; resume when connected.`);await L(e,n.ids[n.index],{destination:n.target.workspaceName,context:n.paths,treeType:n.target.treeType,treeNameOrTreeId:n.target.treeName,operationId:`${n.id}:${n.index}`}),n={...n,index:n.index+1},m(n),a.update({title:`Copying to workspace…`,description:r()})}a.done({title:n.index>=n.ids.length?`Copy complete`:`Copy paused`,description:r()}),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`))}catch(e){a.fail({title:`Copy incomplete`,description:`${r()}. ${e instanceof Error?e.message:`Copy failed`}`,variant:`destructive`}),f.current||d(`Document ${n.ids[n.index]}: ${e instanceof Error?e.message:`Copy failed`}. Resume to retry.`)}finally{p.current=!1,f.current||l(!1)}},g=()=>{f.current=!0,n()},_=o!=null&&o.index>=o.ids.length,v=r?`h-full min-h-0 w-full`:tn,y=(0,J.jsx)(J.Fragment,{children:o?(0,J.jsxs)(`section`,{role:`dialog`,"aria-label":`Copy to workspace`,className:`${v} flex flex-col rounded-(--panel-radius) border bg-card p-4 shadow-elevation-4`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Copy to workspace`}),(0,J.jsxs)(`p`,{className:`mt-3 break-words text-sm`,children:[o.target.workspaceName,`: `,o.paths.join(`, `)]}),(0,J.jsxs)(`p`,{role:`status`,className:`mt-3 text-sm`,children:[o.index,` of `,o.ids.length,` copied`,_?`.`:c?`…`:` — paused.`]}),u&&(0,J.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-destructive`,children:u}),(0,J.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Files go to workspace:data. Destination rules handle storage placement. Relationships and sharing permissions are not copied. Source documents stay unchanged.`}),!_&&(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`Closing lets the current item finish and pauses the rest. Reopen Copy to workspace to resume, including after reconnecting.`}),(0,J.jsxs)(`div`,{className:`mt-auto flex flex-wrap justify-end gap-2 pt-4`,children:[!_&&!c&&(0,J.jsx)(M,{variant:`ghost`,onClick:()=>{try{localStorage.removeItem(a)}catch{}s(null),d(``)},children:`Discard remaining`}),!_&&!c&&(0,J.jsx)(M,{onClick:()=>void h(o),children:`Resume copy`}),(0,J.jsx)(M,{variant:_?`default`:`outline`,onClick:g,children:_?`Done`:c?`Pause & close`:`Close`})]})]}):(0,J.jsx)(Re,{title:`Copy to workspace…`,confirmLabel:`Copy documents`,excludeWorkspace:e,documentCount:t.length,sizeClassName:v,onClose:g,onConfirm:(e,n)=>h({ids:t,target:n,paths:e,index:0,id:crypto.randomUUID()})})});return r?(0,J.jsx)(qn,{label:`Copy to workspace`,onClose:g,children:y}):(0,J.jsx)(en,{onClose:g,children:y})}function rr(e,t,n){return{...t.length?{features:[...new Set([...e.features??e.metadata?.features??[],...Rt(e.data?.tags??[]),...Rt(t)])]}:{},...n?{geo:n}:{}}}function ir(e,t,n,r){return{id:e.id,schema:e.schema,schemaVersion:e.schemaVersion,metadata:rr(e,t,n),...r===void 0?{}:{comment:r.trim()}}}function ar({workspaceId:e,documentIds:t,onClose:n}){let[r,i]=(0,K.useState)([]),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(`keep`),[l,u]=(0,K.useState)(``),d=(r.length>0||!!a||s!==`keep`)&&(s!==`replace`||l.trim().length>0),[f,p]=(0,K.useState)(t),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``);return U(n,!m),(0,Kn.createPortal)((0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-scrim p-4`,children:(0,J.jsxs)(`section`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`bulk-edit-title`,className:`max-h-viewport-modal overflow-y-auto w-full max-w-md space-y-4 rounded-(--panel-radius) border bg-background p-5 shadow-elevation-4`,children:[(0,J.jsxs)(`h2`,{id:`bulk-edit-title`,className:`font-semibold`,children:[`Bulk Edit · `,f.length,` documents`]}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add tags to all selected documents. Choosing a location replaces their existing geotags; leaving it unset keeps them.`}),(0,J.jsxs)(`fieldset`,{disabled:m,className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Add tags`}),(0,J.jsx)(Nt,{tags:r,onChange:i,suggestions:[]})]}),(0,J.jsx)(V,{value:a,onChange:o,idPrefix:`bulk-geo`}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`label`,{htmlFor:`bulk-comment-mode`,className:`text-sm font-medium`,children:`Comment`}),(0,J.jsxs)(`select`,{id:`bulk-comment-mode`,value:s,onChange:e=>c(e.target.value),className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm`,children:[(0,J.jsx)(`option`,{value:`keep`,children:`Keep existing comments`}),(0,J.jsx)(`option`,{value:`replace`,children:`Replace comments`}),(0,J.jsx)(`option`,{value:`clear`,children:`Clear comments`})]}),s===`replace`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`label`,{htmlFor:`bulk-comment`,className:`sr-only`,children:`New comment for all selected documents`}),(0,J.jsx)(`textarea`,{id:`bulk-comment`,rows:3,value:l,onChange:e=>u(e.target.value),placeholder:`Comment for all selected documents…`,className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This replaces the comment on every selected document.`})]}),s===`clear`&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This removes the comment from every selected document.`})]})]}),g&&(0,J.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:g}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(M,{variant:`outline`,onClick:n,disabled:m,children:`Cancel`}),(0,J.jsx)(M,{onClick:async()=>{if(m||!d)return;h(!0),_(``);let t=[];for(let n of f)try{let t=await B(e,n);await gt(e,ir(t,r,a,s===`keep`?void 0:s===`clear`?``:l))}catch{t.push(n)}window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),h(!1),t.length?(p(t),_(`${f.length-t.length} saved; ${t.length} could not be updated. Retry applies only to those documents.`)):n()},disabled:m||!d,children:m?`Saving…`:g?`Retry failed`:`Apply to all`})]})]})}),window.document.body)}var or=e=>`/${e}`.replace(/\/+/g,`/`).replace(/\/$/,``)||`/`;function sr(e,t,n,r){return typeof e.sourcePath==`string`&&!!t&&e.sourceWorkspaceId===t&&!!n&&e.sourceTreeName===n&&or(e.sourcePath)===or(r)}var cr=i();function lr(e){let{id:t,...n}=e;return n}function ur(e){let t=kt(),n=(0,K.useContext)(bt),{document:r,workspaceId:i,isOpen:a,onClose:o,initialEdit:s,initialTab:c}=e,l=(t===`side`||n?.alwaysOn===!0)&&!!n&&!!i&&!s&&!c;return(0,K.useLayoutEffect)(()=>{!l||!a||!r||!i||!n||((n.preview??n.open)(r,i),o())},[l,a,r,i,n,o]),l?null:(0,J.jsx)(dr,{...e})}function dr({document:e,isOpen:t,onClose:n,workspaceId:r,initialTab:i,initialEdit:a}){let[o,s]=(0,K.useState)(!1),c=zt(),{document:l,refresh:u}=Mn(r,e);if(U(()=>o?s(!1):n(),t&&!!l),!t||!l)return null;let d=!!(c?.state.t1Open||c?.state.t2Open);return(0,Kn.createPortal)((0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:ke(`fixed inset-0 z-50 flex items-center justify-center bg-scrim`,o?`p-0`:`p-4 max-md:p-2`,o&&d&&`md:right-[min(436px,90vw)]`),onClick:n,children:(0,J.jsxs)(`div`,{className:ke(`flex w-full flex-col border bg-background max-md:h-full max-md:max-w-none`,o?`h-full max-w-none rounded-none md:rounded-(--panel-radius) md:m-2 md:h-[calc(var(--viewport-h)-1rem)]`:`h-viewport-card max-w-3xl rounded-(--panel-radius)`),onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4 pb-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h2`,{className:`truncate text-lg font-bold`,children:N(l).title}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`ID: `,l.id,` · `,l.schema]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(()=>{let e=ct(l);return e?(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`rounded-sm p-2 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Open original: ${e}`,"aria-label":`Open original`,children:(0,J.jsx)(_e,{className:`h-4 w-4`})}):null})(),(0,J.jsx)(`button`,{onClick:()=>s(!o),className:`hidden rounded-sm p-2 hover:bg-muted md:block`,title:o?`Restore`:`Fullscreen`,"aria-label":o?`Restore`:`Fullscreen`,children:o?(0,J.jsx)(ee,{className:`h-4 w-4`}):(0,J.jsx)(ce,{className:`h-4 w-4`})}),(0,J.jsx)(`button`,{onClick:n,className:`rounded-sm p-2 hover:bg-muted`,title:`Close`,children:`✕`})]})]}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(Mt.Provider,{value:()=>s(e=>!e),children:(0,J.jsx)(Et,{document:l,workspaceId:r??``,initialTab:i,initialEdit:a,onChanged:u})})})]})}),window.document.body)}var fr=xn,pr={alphabetical:`Alphabetical`,type:`Type`,"crud:created":`Created`,"crud:updated":`Updated`,content:`Content`};function mr(e){return pr[e]??e}function hr(e){let[t,n]=(0,K.useState)([]);return(0,K.useEffect)(()=>{let t=!1;return Be(e).then(e=>{t||n(e)}).catch(()=>{t||n([])}),()=>{t=!0}},[e]),(0,K.useMemo)(()=>[...new Set([`alphabetical`,`type`,`crud:created`,`crud:updated`,`content`,...t.filter(e=>e!==`crud:deleted`)])].map(e=>({value:e,label:mr(e)})),[t])}function gr({workspaceId:e,value:t,onChange:n}){let r=hr(e);return(0,J.jsxs)(`div`,{className:`canvas-no-drag flex items-center gap-1`,children:[(0,J.jsxs)(`select`,{value:t.sortBy,onChange:e=>n({...t,sortBy:e.target.value,order:[`alphabetical`,`type`].includes(e.target.value)?`asc`:t.order}),className:`h-7 rounded-md border bg-background px-1.5 text-xs`,title:`Sort by`,"aria-label":`Sort by`,children:[t.sortBy!==`crud:deleted`&&!r.some(e=>e.value===t.sortBy)&&(0,J.jsx)(`option`,{value:t.sortBy,children:mr(t.sortBy)}),r.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>n({...t,order:t.order===`asc`?`desc`:`asc`}),title:t.order===`asc`?`Ascending`:`Descending`,"aria-label":t.order===`asc`?`Ascending`:`Descending`,className:`flex h-7 w-7 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent hover:text-foreground touch-target`,children:t.order===`asc`?(0,J.jsx)(k,{className:`h-3.5 w-3.5`}):(0,J.jsx)(he,{className:`h-3.5 w-3.5`})})]})}function _r(e,t){let n=t?.replace(/^t:/,``)||`crud:created`,r=(n===`crud:created`?[e.createdAt]:n===`crud:updated`?[e.updatedAt]:(e.timelines??[]).filter(e=>(e.timeline||e.name)===n).map(e=>e.start)).map(e=>Date.parse(e??``)).filter(Number.isFinite);if(r.length)return Math.min(...r);let i=n===`content`?Date.parse(e.createdAt??``):NaN;return Number.isFinite(i)?i:null}var Q={today:8,yesterday:7,thisWeek:6,lastWeek:5,thisMonth:4,lastMonth:3,thisYear:2,year:1,unknown:0},$=e=>e*1e6;function vr(){try{let e=new Intl.Locale(navigator.language),t=(typeof e.getWeekInfo==`function`?e.getWeekInfo():e.weekInfo)?.firstDay;if(typeof t==`number`&&t>=1&&t<=7)return t}catch{}return 1}function yr(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function br(e,t){let n=((e.getDay()===0?7:e.getDay())-t+7)%7,r=yr(e);return r.setDate(r.getDate()-n),r}var xr=864e5;function Sr(e){let t=vr(),n=yr(e),r=br(e,t);return{today:n.getTime(),yesterday:n.getTime()-xr,weekStart:r.getTime(),lastWeekStart:r.getTime()-7*xr,year:e.getFullYear(),month:e.getFullYear()*12+e.getMonth()}}function Cr(e,t){if(e===null||!Number.isFinite(e))return{key:`unknown`,label:`Unknown date`,rank:$(Q.unknown)};if(e>=t.today)return{key:`today`,label:`Today`,rank:$(Q.today)};if(e>=t.yesterday)return{key:`yesterday`,label:`Yesterday`,rank:$(Q.yesterday)};if(e>=t.weekStart)return{key:`this-week`,label:`Earlier this week`,rank:$(Q.thisWeek)};if(e>=t.lastWeekStart)return{key:`last-week`,label:`Last week`,rank:$(Q.lastWeek)};let n=new Date(e),r=n.getFullYear()*12+n.getMonth();if(r===t.month)return{key:`this-month`,label:`Earlier this month`,rank:$(Q.thisMonth)};if(r===t.month-1)return{key:`last-month`,label:`Last month`,rank:$(Q.lastMonth)};if(n.getFullYear()===t.year)return{key:`this-year`,label:`Earlier this year`,rank:$(Q.thisYear)};let i=n.getFullYear();return{key:`year-${i}`,label:String(i),rank:$(Q.year)+i}}function wr(e,t,n=`desc`,r=new Date){let i=Sr(r),a=new Map;for(let n of e){let e=Cr(t(n),i),r=a.get(e.key);r?r.items.push(n):a.set(e.key,{...e,items:[n]})}let o=[...a.values()].sort((e,t)=>n===`asc`?e.rank-t.rank:t.rank-e.rank),s=o.filter(e=>e.key===`unknown`);return s.length?[...o.filter(e=>e.key!==`unknown`),...s]:o}function Tr(){let{showProgress:e}=je();return(0,K.useCallback)(async(t,n,r,i)=>{let a=e({title:t,description:n});try{let e=await i();if(e===!1)throw Error(`The operation could not be completed.`);return a.done({title:r,description:n}),e}catch(e){throw a.fail({title:`Operation failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`}),e}},[e])}var Er=[`tree.path.inserted`,`tree.path.moved`,`tree.path.removed`,`tree.path.copied`,`tree.path.locked`,`tree.path.unlocked`,`tree.layer.updated`,`tree.layer.converted`,`tree.recalculated`,`tree.created`,`tree.deleted`,`tree.renamed`,`context.path.changed`,`backend.tree.changed`,`backend.changed`,`backend.resync.changed`,`dataBackends.changed`,`services.changed`,`connect`],Dr=new Map;function Or(e,t,n){st(e,t),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:t,cacheInvalidated:!0}})),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e,treeName:t,path:n}}))}function kr(e,t){let n=Dr.get(e);if(!n){let t=new Set([e]),r=new Set,i,a=Er.map(n=>{let a=(a={})=>{if(n===`backend.resync.changed`&&a.resyncing!==!1)return;let o=typeof a.workspaceId==`string`?a.workspaceId:null,s=typeof a.workspaceName==`string`?a.workspaceName:null;if(o&&!t.has(o)||!o&&s&&s!==e)return;let c=typeof a.treeName==`string`?a.treeName:void 0;n===`tree.renamed`?c=void 0:n===`context.path.changed`?c??=`context`:[`backend.tree.changed`,`backend.changed`,`backend.resync.changed`,`dataBackends.changed`,`services.changed`,`connect`].includes(n)&&(c??=`backends`),r.add(c),!i&&(i=setTimeout(()=>{i=void 0;let t=r.has(void 0)?[void 0]:[...r];r.clear();for(let n of t)st(e,n),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:n,cacheInvalidated:!0}}))},200))};return Ae.on(n,a),[n,a]});n={users:0,workspaceIds:t,stop:()=>{clearTimeout(i);for(let t of r)st(e,t);a.forEach(([e,t])=>Ae.off(e,t))}},Dr.set(e,n)}n.users++,t&&n.workspaceIds.add(t);let r=n;return()=>{--r.users===0&&(r.stop(),Dr.delete(e))}}function Ar({contextId:e,workspaceId:t,treeName:n,onRefresh:r}){let i=Tr(),{showProgress:a}=je(),s=n||`context`,c=s===`directory`,[l,u]=(0,K.useState)([]);(0,K.useEffect)(()=>{let e=!1,n=()=>{t&&cn(t).then(t=>{e||u(t)}).catch(()=>{})};return n(),window.addEventListener(`focus`,n),()=>{e=!0,window.removeEventListener(`focus`,n)}},[t,s]);let d=(0,K.useCallback)(e=>{if(s===`backends`)return[e];let t=`${c?`dir`:`ctx`}:${e}`;return[...new Set(l.filter(e=>e.enabled!==!1).flatMap(e=>{let n=e.when.pathExact||e.when.path,r=(Array.isArray(n)?n:[n]).filter(e=>typeof e==`string`&&e.startsWith(`backends:`));return e.then.flatMap(e=>e.action!==`link`||!Array.isArray(e.paths)?[]:e.paths.flatMap(n=>{if(typeof n!=`string`)return[];let i=n===t?``:e.recursive&&t.startsWith(n+`/`)?t.slice(n.length):null;return i===null?[]:r.map(e=>e.slice(9)+i)}))}))]},[l,s,c]),f=(0,K.useCallback)((e=150)=>{r&&setTimeout(r,e),t&&setTimeout(()=>window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:t}})),e)},[r,t]),p=(0,K.useCallback)(async(n,r=!0)=>{let i;if(e)i=await qt(e,n,r);else if(t)i=await ft(t,n,r,s);else return!1;let a=$t(n);if(i&&a)try{e?await Ht(e,n,a):t&&await rt(t,n,a,s)}catch{}return f(),i},[e,t,s,f]),m=(0,K.useCallback)(async(n,r=!1,a=!1,o=!1)=>i(o?`Destroying…`:a?`Purging…`:`Removing…`,n,o?`Destroyed`:a?`Purged`:`Removed`,async()=>{try{return e?await Jt(e,n,r):t?await Ge(t,n,r,s,a,o):!1}finally{f()}}),[e,t,s,f,i]),h=(0,K.useCallback)(async(n,r)=>{let i;if(e){let t=n.split(`/`);t[t.length-1]=r,i=await Ut(e,n,t.join(`/`),!1)}else if(t)i=await rt(t,n,{name:r},s);else return!1;return f(),i},[e,t,s,f]),g=(0,K.useCallback)(async(n,r,a=!1,o=s,c=s,l={})=>i(`Moving…`,`${n} → ${r}`,`Moved`,async()=>{let i;if(e)i=await Ut(e,n,r,a,l);else if(t)i=await Ze(t,n,r,a,o,c,l);else return!1;return f(),i}),[e,t,s,f,i]),_=(0,K.useCallback)(async n=>{let r;if(e)r=await Wt(e,n);else if(t)r=await F(t,n,s);else return null;return f(),r},[e,t,s,f]),v=(0,K.useCallback)(async n=>{let r;if(e)r=await Bt(e,n);else if(t)r=await at(t,n,s);else return null;return f(),r},[e,t,s,f]),y=(0,K.useCallback)(async(n,r,a=!1,o=s,c=s)=>i(`Copying…`,`${n} → ${r}`,`Copied`,async()=>{let i;if(e)i=await Kt(e,n,r,a);else if(t)i=await ut(t,n,r,a,o,c);else return!1;return f(),i}),[e,t,s,f,i]),b=(0,K.useCallback)(async(n,r)=>e?await Ht(e,n,r):t?await rt(t,n,r,s):!1,[e,t,s]),x=(0,K.useCallback)(async(n,r)=>{let i;if(e)i=await Gt(e,n,r);else if(t)i=await We(t,n,r,s);else return null;return f(),i},[e,t,s,f]),S=(0,K.useCallback)(async(n,r)=>{let i;if(e)i=await Vt(e,n,r);else if(t)i=await lt(t,n,r,s);else return null;return f(),i},[e,t,s,f]),C=(0,K.useCallback)(async e=>{if(!t)return!1;let n=await Ye(t,e,t,s);return f(300),n},[t,s,f]),w=(0,K.useCallback)(async(e,n)=>{if(!t)return!1;try{await dt(t,e,n??t,s)}catch(e){if(!(e instanceof Error)||!/still locked by/i.test(e.message))throw e}return f(300),!0},[t,s,f]),ee=(0,K.useCallback)(async e=>{if(!t)return!1;let n=await Je(t,e,s);return f(),n},[t,s,f]),T=(0,K.useCallback)(async e=>{if(!t)return!1;let n=await vt(t).catch(()=>[]),r=d(e);for(let e of r){let r=nt(e,n);if(!r)continue;let i=n.find(e=>e.driver===r.driver&&e.address===r.address),o=r.driver===`imap`?i?.containers?.find(t=>t.treePath===e):void 0;if(r.driver===`imap`&&e!==i?.treePath&&!o)throw Error(`Select a subscribed mailbox folder to refresh`);await un(a,t,r.driver,r.address,void 0,o?.name)}return f(300),r.length>0},[t,f,a,d]),te=(0,K.useCallback)(async(e,n)=>{if(!t)return!1;let r=await vt(t).catch(()=>[]),i=pt(e,r);if(!i)return!1;let a=i.key?`${i.key}/${n}`:n;return await R(t,i.driver,i.address,[a]),f(200),!0},[t,f]),ne=(0,K.useCallback)(async(e,n)=>{if(!t)return!1;let r=await vt(t).catch(()=>[]),i=pt(e,r);return!i||!i.key?!1:(await tt(t,i.driver,i.address,i.key,n),f(200),!0)},[t,f]),re=(0,K.useCallback)(async e=>t?i(`Deleting folder…`,e,`Folder deleted`,async()=>{let n=await vt(t),r=it(e,n);if(!r)throw Error(`This folder is not on a writable backend, or is a backend root.`);try{return await et(t,r.driver,r.address,r.key),!0}finally{f(200)}}):!1,[t,f,i]),E=(0,K.useCallback)(async(e,n)=>{if(!t)return;let{showSubtreeTransfer:r}=await o(async()=>{let{showSubtreeTransfer:e}=await import(`./subtree-transfer-dialog-DQM5zfx2.js`);return{showSubtreeTransfer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]));r({mode:e,path:n,workspaceId:t,treeName:s,onImported:()=>{Or(t,s),f()}})},[t,s,f]),D=(0,K.useCallback)(async(e,n)=>{if(!t)return;let r=await o(()=>Promise.resolve().then(()=>Mr),void 0);if(e===`import`)r.showDocumentImport(async e=>{if((await ht(t,n,e,s,P(s))).length!==e.length)throw Error(`Some documents could not be imported`);return Or(t,s),f(),!0});else{let e=[];for(let r=0;;){let i=await z(t,n,[],{treeName:s,treeType:P(s),limit:500,offset:r,order:`asc`}),a=i.payload||[];if(e.push(...a),r+=a.length,!a.length||r>=(i.totalCount??i.count??1/0))break}r.showDocumentExport(e)}},[t,s,f]);return{onImportDocuments:t&&s!==`backends`?e=>D(`import`,e):void 0,onExportDocuments:t?e=>D(`export`,e):void 0,onInsertPath:p,onRemovePath:m,onRenamePath:h,onMovePath:g,onCopyPath:y,onExportSubtree:t?e=>E(`export`,e):void 0,onImportSubtree:t&&s!==`backends`?e=>E(`import`,e):void 0,onUpdateNode:b,onMergeLayer:x,onSubtractLayer:S,onMergeDown:c?void 0:_,onSubtractDown:c?void 0:v,onLockLayer:t?C:void 0,onUnlockLayer:t?w:void 0,onDestroyLayer:t&&!c?ee:void 0,canResyncBackend:e=>d(e).length>0,onResyncBackend:t?T:void 0,onCreateBackendFolder:t?te:void 0,onRenameBackendFolder:t?ne:void 0,onDeleteBackendFolder:t?re:void 0}}function jr({x:e,y:t,workspaceName:n,treeName:r,path:i,onClose:a,onOpen:o,onOpenToSide:c,pastedDocumentIds:d,onPasteDocuments:f}){let p=s(),m=Ar({workspaceId:n,treeName:r}),h=r===`backends`,g=h?pt(i):null,[_,v]=(0,K.useState)([]);(0,K.useEffect)(()=>{if(!h)return;let e=!1;return vt(n).then(t=>{e||v(t)}).catch(()=>{}),()=>{e=!0}},[n,h]);let y=h?it(i,_):null,b=i.split(`/`).filter(Boolean).pop()||i,[x,ee]=(0,K.useState)(void 0);(0,K.useEffect)(()=>{let e=!1;return Ue(n).then(t=>{e||ee(t.find(e=>e.tree===r&&e.path===i)??null)}).catch(()=>{e||ee(null)}),()=>{e=!0}},[n,r,i]);let re=async e=>{a();try{await e()}catch(e){alert(e instanceof Error?e.message:String(e))}},E=(e,t,n,r=!1)=>(0,J.jsxs)(`button`,{type:`button`,className:ke(`flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent rounded-sm text-left`,r&&`text-destructive hover:bg-destructive/10`),onClick:()=>re(n),children:[e,t]}),ie=(0,J.jsx)(`div`,{className:`my-1 h-px bg-border`}),ae=e=>{let t=h?(()=>{let t=rn(i);return{kind:e,storeTo:t?.backend||``,storeFolder:t?.rel||``}})():{kind:e,path:`dir:${i}`,storeFolder:e===`download`?`Downloads`:nn(i)};p(`/workspaces/${n}/settings/hooks?${dn(t).toString()}`)},se=(e,t=``)=>{let n=prompt(e,t)?.trim();return n&&n!==t&&!n.includes(`/`)?n:null},O=an(r,i);return O?(0,J.jsxs)(Fe,{x:e,y:t,onClose:a,className:`min-w-44 rounded-md border bg-popover p-1 shadow-elevation-3`,children:[E((0,J.jsx)(oe,{className:`h-3 w-3`}),`Open Trash`,()=>o(i)),O.backend&&E((0,J.jsx)(ne,{className:`h-3 w-3`}),`Restore original paths`,()=>ln(n,i)),O.backend&&E((0,J.jsx)(oe,{className:`h-3 w-3`}),`Empty Trash`,()=>sn(n,i),!0)]}):(0,J.jsxs)(Fe,{x:e,y:t,onClose:a,className:`min-w-[11rem] rounded-md border bg-popover p-1 shadow-elevation-3`,children:[E((0,J.jsx)(w,{className:`w-3 h-3`}),`Open`,()=>o(i)),c&&E((0,J.jsx)(pe,{className:`w-3 h-3`}),`Open to the side`,()=>c(i)),ie,h?g&&(0,J.jsxs)(J.Fragment,{children:[E((0,J.jsx)(C,{className:`w-3 h-3`}),`New folder here`,async()=>{let e=se(`New folder name:`);e&&await m.onCreateBackendFolder?.(i,e)}),g.key&&E((0,J.jsx)(D,{className:`w-3 h-3`}),`Rename folder`,async()=>{let e=se(`New folder name:`,b);e&&await m.onRenameBackendFolder?.(i,e)}),E((0,J.jsx)(u,{className:`w-3 h-3`}),`Create storage rule…`,()=>ae(`store`))]}):(0,J.jsxs)(J.Fragment,{children:[E((0,J.jsx)(C,{className:`w-3 h-3`}),`New folder here`,async()=>{let e=se(`New folder name:`);e&&await m.onInsertPath(`${i===`/`?``:i}/${e}`)}),E((0,J.jsx)(D,{className:`w-3 h-3`}),`Rename`,async()=>{let e=se(`New name:`,b);e&&await m.onRenamePath(i,e)}),E((0,J.jsx)(u,{className:`w-3 h-3`}),`Create rule…`,()=>ae(`store`)),E((0,J.jsx)(Ce,{className:`w-3 h-3`}),`Create download rule…`,()=>ae(`download`))]}),x!==void 0&&E(x?(0,J.jsx)(T,{className:`w-3 h-3`}):(0,J.jsx)(S,{className:`w-3 h-3`}),x?`Unpin`:`Pin`,async()=>{x?await I(n,x.id):await Ve(n,i,r),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:n}}))}),ie,m.onImportDocuments&&E((0,J.jsx)(C,{className:`w-3 h-3`}),`Import documents…`,()=>m.onImportDocuments(i)),m.onExportDocuments&&E((0,J.jsx)(Ce,{className:`w-3 h-3`}),`Export documents…`,()=>m.onExportDocuments(i)),E((0,J.jsx)(te,{className:`w-3 h-3`}),`Copy path`,()=>navigator.clipboard?.writeText(i)),!h&&f&&d&&d.length>0&&E((0,J.jsx)(l,{className:`w-3 h-3`}),`Paste ${d.length} document(s)`,()=>f(i,d)),h?y&&(0,J.jsxs)(J.Fragment,{children:[ie,E((0,J.jsx)(oe,{className:`w-3 h-3`}),`Delete from backend`,async()=>{confirm(`Delete folder "${b}" and its contents from the backend?`)&&await m.onDeleteBackendFolder?.(i)},!0)]}):(0,J.jsxs)(J.Fragment,{children:[ie,E((0,J.jsx)(oe,{className:`w-3 h-3`}),`Remove`,async()=>{confirm(`Remove "${i}" and all children?`)&&await m.onRemovePath(i,!0)},!0)]})]})}var Mr=t({DocumentList:()=>ii,default:()=>ii,showDocumentExport:()=>oi,showDocumentImport:()=>ai});function Nr({isOpen:e,onClose:t,documents:n,selectedDocuments:r}){let[i,a]=(0,K.useState)(`idle`);if(!e)return null;let o=()=>{a(`idle`),t()},s=r.size>0?n.filter(e=>r.has(e.id)):n,c=s.map(lr),l=JSON.stringify(c,null,2),u=async()=>{try{await navigator.clipboard.writeText(l),a(`copied`),setTimeout(()=>a(`idle`),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e),a(`error`),setTimeout(()=>a(`idle`),2e3)}};return(0,J.jsx)(qn,{label:`Export Documents`,onClose:o,children:(0,J.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col p-4 sm:p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Export Documents`}),(0,J.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Exporting `,s.length,` document`,s.length===1?``:`s`,i===`copied`&&(0,J.jsx)(`span`,{className:`text-success ml-2`,children:`✓ Copied to clipboard!`}),i===`error`&&(0,J.jsx)(`span`,{className:`text-destructive ml-2`,children:`✗ Failed to copy`})]})]}),(0,J.jsx)(`button`,{onClick:o,className:`p-2 hover:bg-muted rounded-sm`,title:`Close`,children:`✕`})]}),(0,J.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold`,children:`JSON Data (Press Ctrl+A to select all, Ctrl+C to copy)`}),(0,J.jsxs)(M,{onClick:u,size:`sm`,className:`flex items-center gap-2`,children:[(0,J.jsx)(te,{className:`h-4 w-4`}),`Copy to Clipboard`]})]}),(0,J.jsx)(`textarea`,{className:`w-full min-h-24 flex-1 p-4 bg-muted border rounded-lg text-sm font-mono resize-none focus:outline-none focus:ring-2 focus:ring-primary`,value:l,readOnly:!0,autoFocus:!0,onKeyDown:e=>{if(e.ctrlKey||e.metaKey){if(e.key===`a`){e.preventDefault();let t=window.getSelection(),n=document.createRange();n.selectNodeContents(e.currentTarget),t?.removeAllRanges(),t?.addRange(n)}else e.key===`c`&&u()}},onFocus:e=>e.target.select()})]})}),(0,J.jsxs)(`div`,{className:`mt-8 pt-4 border-t flex justify-end gap-2`,children:[(0,J.jsx)(M,{variant:`outline`,onClick:()=>{let e=URL.createObjectURL(new Blob([l],{type:`application/json`})),t=window.document.createElement(`a`);t.href=e,t.download=`canvas-documents.json`,t.click(),setTimeout(()=>URL.revokeObjectURL(e),1e3)},children:`Download JSON`}),(0,J.jsx)(M,{onClick:o,children:`Close`})]})]})})}function Pr({isOpen:e,onClose:t,onImport:n}){let[r,i]=(0,K.useState)(``),[a,o]=(0,K.useState)(!1),[s,c]=(0,K.useState)(null);if(!e)return null;let l=async()=>{if(c(null),!r.trim()){c(`Please enter JSON data`);return}try{let e=JSON.parse(r),a=Array.isArray(e)?e:[e];for(let e of a)if(!e||typeof e!=`object`||!e.schema||!e.data){c(`Each document must have "schema" and "data" fields`);return}o(!0),await n(a)?(i(``),t()):c(`Failed to import documents`)}catch(e){c(e instanceof Error?e.message:`Import failed`)}finally{o(!1)}},u=()=>{i(``),c(null),t()};return(0,Kn.createPortal)((0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 bg-scrim flex items-center justify-center z-50 p-4 max-md:p-2`,children:(0,J.jsx)(`div`,{className:`bg-background border rounded-(--panel-radius) max-w-3xl w-full max-h-viewport-card overflow-y-auto max-md:h-full max-md:max-h-none max-md:max-w-none`,children:(0,J.jsxs)(`div`,{className:`p-6`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Import Documents`}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:`Paste JSON data or choose a document export file`})]}),(0,J.jsx)(`button`,{onClick:u,className:`p-2 hover:bg-muted rounded-sm`,title:`Close`,children:`✕`})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`block text-sm font-medium mb-2`,children:`JSON Data (single document or array of documents)`}),(0,J.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),className:`w-full h-64 p-3 border rounded-lg font-mono text-sm`,placeholder:`[{"schema": "data/schema/tab", "schemaVersion": "2.0", "data": {...}, "metadata": {...}}]`,disabled:a,autoFocus:!0})]}),s&&(0,J.jsx)(`div`,{className:`text-sm text-destructive bg-destructive/10 p-3 rounded-lg border`,children:s}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:`Format:`}),` Each document must have "schema", "schemaVersion", "data", and "metadata" fields.`]}),(0,J.jsxs)(`p`,{children:[(0,J.jsx)(`strong`,{children:`Example schemas:`}),` "data/schema/tab", "data/schema/file", etc.`]})]})]}),(0,J.jsxs)(`label`,{className:`mt-4 block text-sm`,children:[`Import JSON file`,(0,J.jsx)(`input`,{type:`file`,accept:`.json,application/json`,disabled:a,className:`mt-2 block w-full text-sm`,onChange:e=>{let t=e.target.files?.[0];t&&t.text().then(e=>{i(e),c(null)}).catch(e=>c(String(e)))}})]}),(0,J.jsxs)(`div`,{className:`mt-8 pt-4 border-t flex justify-between`,children:[(0,J.jsx)(M,{variant:`outline`,onClick:u,disabled:a,children:`Cancel`}),(0,J.jsx)(M,{onClick:l,disabled:a||!r.trim(),children:a?`Importing...`:`Import Documents`})]})]})})}),window.document.body)}function Fr({document:e}){let{replicating:t,label:n}=_t(e);return t?(0,J.jsxs)(`span`,{role:`status`,className:`inline-flex shrink-0 items-center gap-1 rounded-full border bg-muted/60 px-2 py-0.5 text-[11px] font-normal text-muted-foreground`,children:[(0,J.jsx)(ye,{className:`h-3 w-3 animate-spin`}),n]}):null}function Ir(e){return e.clientX||e.clientY?{x:e.clientX,y:e.clientY}:Ie(e.currentTarget,`inside`)}function Lr({documentId:e,onOpenActions:t,className:n}){return t?(0,J.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),t(n.currentTarget,e)},className:`rounded-sm p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground ${n??``}`,title:`Actions`,"aria-label":`Document actions`,"aria-haspopup":`menu`,children:(0,J.jsx)(O,{className:`h-4 w-4`})}):null}function Rr(e,t,n){e.target===e.currentTarget&&(e.key===`Enter`?(e.preventDefault(),t()):e.key===` `&&n&&(e.preventDefault(),n()))}function zr({document:e}){let t=ct(e);return t?(0,J.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open original in browser`,"aria-label":`Open original in browser`,className:`shrink-0 rounded p-1 text-muted-foreground hover:text-foreground`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,J.jsx)(_e,{className:`h-3.5 w-3.5`})}):null}function Br({document:e,isSelected:t,workspaceId:n,onSelect:r,onRightClick:i,onOpenActions:a,onDragStart:o}){let s=Tt(),c=s.alwaysOn&&s.entry?.workspaceId===n&&s.entry?.document.id===e.id,l=Un(),[u,d]=(0,K.useState)(!1),{replicating:f}=_t(e),p=N(e),m=Hr(e),h=m||Wr(e),{blobUrl:g}=H(n??``,e.id,128,{enabled:h,blobFallback:m,version:e.checksumArray?.[0]??null}),_=t=>{o?.(t,e.id)},v=e=>new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),y=(()=>{let t=e.checksumArray?.[0];if(t){let[e,n]=t.split(`/`);if(n)return{algo:e,hash:n.substring(0,8)+`...`}}return null})(),b=n=>{let i=n.ctrlKey||n.metaKey;if(n.shiftKey&&r){n.preventDefault(),r(e.id,!0,i,!0);return}r&&(i?r(e.id,!t,i):r(e.id,!0,i)),i||d(!0)},x=e=>{e.shiftKey&&e.preventDefault()},S=n=>{n.preventDefault(),n.stopPropagation(),r&&!t&&r(e.id,!0,!1),i?.(n,e.id)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(mn,{tabIndex:0,"data-document-id":e.id,"data-reading":c||void 0,"aria-selected":!!t,onKeyDown:n=>Rr(n,()=>d(!0),()=>r?.(e.id,!t,!0)),className:`data-[reading=true]:bg-accent data-[reading=true]:text-accent-foreground cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring transition-opacity ${f?`opacity-60`:``} ${t?`bg-info-subtle hover:bg-info-subtle`:`hover:bg-muted/50`}`,onClick:b,onMouseDown:x,...l,onContextMenu:S,draggable:!0,onDragStart:_,children:[(0,J.jsx)(G,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,J.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer accent-primary align-middle`,checked:!!t,onClick:t=>{t.stopPropagation(),r?.(e.id,t.currentTarget.checked,!0,t.shiftKey)},onChange:()=>{}})}),(0,J.jsx)(G,{className:`w-12`,children:g?(0,J.jsx)(`img`,{src:g,alt:``,className:`h-8 w-8 rounded-md border object-cover`}):(0,J.jsx)(W,{document:e,chip:!0})}),(0,J.jsx)(G,{className:`font-medium w-full max-w-0 md:w-auto md:max-w-xs`,children:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`truncate`,title:p.title,children:p.title}),(0,J.jsx)(zr,{document:e}),(0,J.jsx)(Fr,{document:e})]}),p.subtitle&&(0,J.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:p.subtitle,children:p.subtitle})]})}),(0,J.jsx)(G,{className:`hidden md:table-cell`,children:(0,J.jsx)(`span`,{className:`px-2 py-1 text-xs bg-muted rounded border`,children:p.schemaLabel})}),(0,J.jsx)(G,{className:`hidden text-xs text-muted-foreground lg:table-cell`,children:e.id}),(0,J.jsx)(G,{className:`hidden text-xs text-muted-foreground lg:table-cell`,children:y&&(0,J.jsx)(`span`,{className:`font-mono`,title:`${y.algo} checksum`,children:y.hash})}),(0,J.jsx)(G,{className:`hidden text-xs text-muted-foreground sm:table-cell`,children:v(e.createdAt)}),(0,J.jsx)(G,{className:`w-12 text-right`,children:(0,J.jsx)(Lr,{documentId:e.id,onOpenActions:a})})]}),(0,J.jsx)(ur,{document:e,isOpen:u,onClose:()=>d(!1),workspaceId:n})]})}function Vr({document:e,isSelected:t,workspaceId:n,onSelect:r,onRightClick:i,onOpenActions:a,onDragStart:o}){let s=Tt(),c=s.alwaysOn&&s.entry?.workspaceId===n&&s.entry?.document.id===e.id,l=Un(),[u,d]=(0,K.useState)(!1),f=e.schema===`data/schema/tab`,{replicating:p}=_t(e),m=N(e),h=Hr(e),_=Ur(e),v=h||Wr(e)||_,{blobUrl:y,loading:x}=H(n??``,e.id,512,{enabled:v,blobFallback:h,version:e.checksumArray?.[0]??null}),S=t=>{o?.(t,e.id)},C=e=>new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),w=(()=>{let t=e.checksumArray?.[0];if(t){let[e,n]=t.split(`/`);if(n)return{algo:e,hash:n.substring(0,8)+`...`}}return null})(),ee=n=>{let i=n.ctrlKey||n.metaKey;if(n.shiftKey&&r){n.preventDefault(),r(e.id,!0,i,!0);return}r&&(i?r(e.id,!t,i):r(e.id,!0,i)),i||d(!0)},T=e=>{e.shiftKey&&e.preventDefault()},te=n=>{n.preventDefault(),n.stopPropagation(),r&&!t&&r(e.id,!0,!1),i?.(n,e.id)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{tabIndex:0,"data-document-id":e.id,"data-reading":c||void 0,"aria-selected":!!t,onKeyDown:n=>Rr(n,()=>d(!0),()=>r?.(e.id,!t,!0)),className:`data-[reading=true]:bg-accent data-[reading=true]:border-primary border rounded-(--card-radius) p-4 transition cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring ${p?`opacity-60`:``} ${t?`bg-info-subtle border-info ring-1 ring-info`:``} ${f&&!t?`hover:bg-info-subtle hover:border-info`:t?``:`hover:bg-accent/50`}`,onClick:ee,onMouseDown:T,...l,onContextMenu:te,draggable:!0,onDragStart:S,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[v&&(0,J.jsxs)(`div`,{className:`relative h-32 w-40 max-w-[40%] sm:h-40 sm:w-56 shrink-0 overflow-hidden rounded-md border bg-muted/40`,children:[y?(0,J.jsx)(`img`,{src:y,alt:m.title,loading:`lazy`,className:`h-full w-full object-cover`}):_&&n&&!x?(0,J.jsx)(Gr,{workspaceId:n,documentId:e.id,fallback:(0,J.jsx)(W,{document:e})}):x?(0,J.jsx)(`div`,{className:`h-full w-full animate-pulse bg-muted/60`}):(0,J.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,J.jsx)(W,{document:e})}),_&&(0,J.jsx)(g,{className:`pointer-events-none absolute bottom-2 right-2 h-5 w-5 rounded bg-scrim text-scrim-foreground`})]}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 overflow-hidden`,children:[(0,J.jsx)(W,{document:e,chip:!0}),(0,J.jsx)(`h4`,{className:`font-medium truncate min-w-0 flex-1 max-w-[640px]`,title:m.title,children:m.title}),(0,J.jsx)(zr,{document:e}),(0,J.jsx)(`span`,{className:`ml-auto px-2 py-0.5 text-xs bg-muted text-muted-foreground rounded border flex-shrink-0`,children:m.schemaLabel}),(0,J.jsx)(Fr,{document:e})]}),m.subtitle&&(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2 truncate`,title:m.subtitle,children:m.subtitle}),m.preview&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground mb-3 line-clamp-2 break-all overflow-hidden`,children:m.preview}),(0,J.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-muted-foreground overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:`ID:`}),(0,J.jsx)(`span`,{className:`font-mono truncate max-w-[60px]`,title:`ID: ${e.id}`,children:e.id})]}),w&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,J.jsx)(j,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,title:`${w.algo} checksum`,children:w.hash})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,J.jsx)(b,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{title:`Created: ${C(e.createdAt)}`,children:C(e.createdAt)})]})]})]}),(0,J.jsx)(Lr,{documentId:e.id,onOpenActions:a,className:`-mr-1 -mt-1 p-2`})]})}),(0,J.jsx)(ur,{document:e,isOpen:u,onClose:()=>d(!1),workspaceId:n})]})}function Hr(e){return(e.schema===`data/schema/file`||e.schema===`data/schema/drawing`)&&String(e.metadata?.contentType||``).startsWith(`image/`)}function Ur(e){return e.schema===`data/schema/file`&&String(e.metadata?.contentType||``).startsWith(`video/`)}function Wr(e){return e.schema===`data/schema/file`&&String(e.metadata?.contentType||``)===`application/pdf`}function Gr({workspaceId:e,documentId:t,fallback:n}){let{src:r,error:i}=It(e,t),[a,o]=(0,K.useState)(!1);return i||a?(0,J.jsx)(J.Fragment,{children:n}):r?(0,J.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,J.jsx)(`video`,{src:r,preload:`metadata`,muted:!0,playsInline:!0,onError:()=>o(!0),className:`block h-full w-full object-cover`}),(0,J.jsx)(`span`,{className:`pointer-events-none absolute bottom-2 right-2 rounded-sm bg-scrim p-1 text-scrim-foreground`,children:(0,J.jsx)(g,{className:`h-3.5 w-3.5`})})]}):(0,J.jsx)(`div`,{className:`aspect-video w-full animate-pulse bg-muted/60`})}function Kr({document:e,workspaceId:t,markdown:n}){let r=(0,K.useRef)(null),[i,a]=(0,K.useState)(()=>typeof IntersectionObserver>`u`);(0,K.useEffect)(()=>{let e=r.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(a(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},[]);let{text:o,loading:s,error:c}=Ft(t,e.id,{mode:`text`,enabled:i,maxTextLength:8e3});return(0,J.jsx)(`div`,{ref:r,className:`relative h-48 w-full overflow-hidden bg-card text-card-foreground`,children:o!=null&&!c?(0,J.jsxs)(`div`,{className:`pointer-events-none p-3 pt-7 text-xs leading-relaxed`,"aria-hidden":`true`,children:[o.length===0?(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Empty file`}):n?(0,J.jsx)(Lt,{content:o,preview:!0,className:`text-xs [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_table]:table-fixed [&_table]:w-full`}):(0,J.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono`,children:o}),(0,J.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-8 bg-gradient-to-t from-card to-transparent`})]}):(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center`,children:[(0,J.jsx)(W,{document:e,size:10,chip:!0}),i&&s&&(0,J.jsx)(`span`,{className:`sr-only`,children:`Loading text preview`})]})})}function qr({document:e,isSelected:t,workspaceId:n,onSelect:r,onOpenToSide:i,onRightClick:a,onOpenActions:o,onDragStart:s}){let[c,l]=(0,K.useState)(null),u=e.metadata?.dimensions,d=c??(u?.width&&u?.height?Math.max(.2,Math.min(5,u.width/u.height)):1),f=Tt(),p=f.alwaysOn&&f.entry?.workspaceId===n&&f.entry?.document.id===e.id,m=Un(),[h,_]=(0,K.useState)(!1),v=Hr(e),y=Ur(e),b=v||Wr(e)||y,x=N(e),S=$e(String(e.metadata?.contentType||``).split(`;`)[0].trim().toLowerCase(),e.metadata?.filename||Ke(e)),C=e.schema===`data/schema/file`&&(S===`markdown`||S===`text`)&&(e.metadata?.size??e.data?.size??0)<=1048576,w=!b&&e.schema!==`data/schema/file`&&!!(x.preview||x.subtitle),{replicating:ee}=_t(e),{blobUrl:T,loading:te}=H(n??``,e.id,768,{enabled:b,blobFallback:v,version:e.checksumArray?.[0]??null}),ne=n=>{let i=n.ctrlKey||n.metaKey;if(n.shiftKey&&r){n.preventDefault(),r(e.id,!0,i,!0);return}r&&r(e.id,!i||!t,i),i||_(!0)},re=n=>{n.preventDefault(),n.stopPropagation(),r&&!t&&r(e.id,!0,!1),a?.(n,e.id)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{tabIndex:0,"data-document-id":e.id,style:{flexGrow:d,flexBasis:`${d*220}px`,"--tile-ratio":d},"data-reading":p||void 0,"aria-selected":!!t,onKeyDown:n=>Rr(n,()=>_(!0),()=>r?.(e.id,!t,!0)),className:`document-tile data-[reading=true]:bg-accent data-[reading=true]:border-primary group relative mb-3 flex break-inside-avoid flex-col overflow-hidden rounded-(--card-radius) border transition cursor-pointer outline-none hover:shadow-elevation-2 focus-visible:ring-2 focus-visible:ring-ring ${ee?`opacity-60`:``} ${t?`ring-2 ring-info border-info`:``}`,onClick:ne,onMouseDown:e=>{e.shiftKey&&e.preventDefault()},...m,onContextMenu:re,draggable:!0,onDragStart:t=>s?.(t,e.id),title:x.title,children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`absolute left-2 top-2 z-10 h-4 w-4 cursor-pointer accent-primary ${t?``:`reveal-on-hover`}`,checked:t,onClick:t=>{t.stopPropagation(),r?.(e.id,t.currentTarget.checked,!0,t.shiftKey)},onChange:()=>{}}),(0,J.jsxs)(`div`,{className:`document-tile-media relative w-full bg-muted/40 ${b&&T||w||C&&n||y&&n?``:`aspect-square`}`,children:[b&&te&&(0,J.jsx)(`div`,{className:`absolute inset-0 animate-pulse bg-muted/60`}),b&&T?(0,J.jsx)(`img`,{src:T,alt:x.title,loading:`lazy`,className:`block h-auto w-full`,onLoad:e=>{let t=e.currentTarget;t.naturalHeight&&l(t.naturalWidth/t.naturalHeight)}}):y&&n&&!te?(0,J.jsx)(Gr,{workspaceId:n,documentId:e.id,fallback:(0,J.jsx)(`div`,{className:`flex aspect-square w-full items-center justify-center`,children:(0,J.jsx)(W,{document:e,size:10,chip:!0})})}):C&&n?(0,J.jsx)(Kr,{document:e,workspaceId:n,markdown:S===`markdown`},`${n}:${e.id}:${e.checksumArray?.[0]??``}`):w?(0,J.jsxs)(`div`,{className:`flex min-h-28 w-full flex-col gap-1.5 overflow-hidden bg-card p-3 pt-7 text-left`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(W,{document:e}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-[10px] uppercase tracking-wide text-muted-foreground`,children:x.schemaLabel}),(0,J.jsx)(zr,{document:e})]}),(0,J.jsx)(`div`,{className:`line-clamp-2 text-sm font-semibold leading-snug`,children:x.title}),x.subtitle&&(0,J.jsx)(`div`,{className:`truncate text-[11px] text-info`,children:x.subtitle}),(0,J.jsx)(`p`,{className:`line-clamp-[8] text-xs leading-relaxed text-muted-foreground`,children:x.preview})]}):(0,J.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,J.jsx)(W,{document:e,size:10,chip:!0})}),y&&T&&(0,J.jsx)(g,{className:`pointer-events-none absolute bottom-2 right-2 h-5 w-5 rounded bg-scrim text-scrim-foreground`}),(0,J.jsxs)(`div`,{className:`absolute right-2 top-2 flex gap-1 reveal-on-hover`,children:[i&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e)},className:`rounded-sm bg-scrim p-1 text-scrim-foreground`,title:`Open to the side`,children:(0,J.jsx)(ae,{className:`h-3.5 w-3.5`})}),o&&(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),o(t.currentTarget,e.id)},className:`rounded-sm bg-scrim p-1 text-scrim-foreground`,title:`Actions`,"aria-label":`Document actions`,"aria-haspopup":`menu`,children:(0,J.jsx)(O,{className:`h-3.5 w-3.5`})})]})]}),!w&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t bg-card px-2 py-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-xs font-medium`,title:x.title,children:x.title}),(0,J.jsx)(zr,{document:e})]})]}),(0,J.jsx)(ur,{document:e,isOpen:h,onClose:()=>_(!1),workspaceId:n})]})}function Jr(e,t,n,r,i){let[a,o]=(0,K.useState)(!1),s=e=>Array.from(e.dataTransfer.types).includes(`application/json`);return{over:a,onDragOver:e=>{!t||!s(e)||(e.preventDefault(),e.dataTransfer.dropEffect=`link`,a||o(!0))},onDragLeave:()=>o(!1),onDrop:async a=>{if(o(!1),!t||!s(a))return;a.preventDefault(),a.stopPropagation();let c=null;try{c=JSON.parse(a.dataTransfer.getData(`application/json`))}catch{c=null}if(!(c?.type!==`document`||!Array.isArray(c.documentIds)||c.documentIds.length===0)&&!sr(c,i,r,e.path))try{await t(e.path,c.documentIds,{move:!1,sourcePath:c.sourcePath??n,sourceTreeName:c.sourceTreeName??r})}catch{}}}}function Yr(e,t,n){e.stopPropagation(),!(t.isParent||!n)&&(e.preventDefault(),n(t.path,e))}function Xr({folder:e,className:t=`h-4 w-4`}){if(e.isParent)return(0,J.jsx)(p,{className:`${t} text-muted-foreground`});let n=e.color?{color:e.color}:void 0;return(0,J.jsx)(y,{className:`${t} ${e.color?``:`text-warning`}`,style:n})}var Zr=e=>e.isParent?`Parent folder`:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name;function Qr({folder:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o}){let s=Jr(e,r,i,a,o);return(0,J.jsxs)(`button`,{type:`button`,title:Zr(e),onClick:()=>t?.(e.path),onContextMenu:t=>Yr(t,e,n),onDragOver:s.onDragOver,onDragLeave:s.onDragLeave,onDrop:s.onDrop,className:`folder-surface group flex min-w-0 max-w-full items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm transition-colors hover:bg-accent ${s.over?`ring-2 ring-info border-info bg-accent`:``} ${e.isParent?`text-muted-foreground`:``}`,children:[(0,J.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,J.jsx)(Xr,{folder:e,className:`h-4 w-4 group-hover:hidden`}),e.isParent?(0,J.jsx)(p,{className:`hidden h-4 w-4 group-hover:block`}):(0,J.jsx)(w,{className:`hidden h-4 w-4 group-hover:block`,style:e.color?{color:e.color}:void 0})]}),(0,J.jsx)(`span`,{className:`truncate`,children:e.isParent?`..`:e.label||e.name}),!e.isParent&&!!e.childCount&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-muted-foreground`,children:e.childCount})]})}function $r({folder:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o}){let s=Jr(e,r,i,a,o),c=e.color?{color:e.color}:void 0;return(0,J.jsxs)(`button`,{type:`button`,title:Zr(e),onClick:()=>t?.(e.path),onContextMenu:t=>Yr(t,e,n),onDragOver:s.onDragOver,onDragLeave:s.onDragLeave,onDrop:s.onDrop,className:`folder-surface group flex min-w-0 flex-col items-center gap-1.5 rounded-(--card-radius) border px-2 py-3 text-sm transition hover:bg-accent hover:shadow-elevation-2 ${s.over?`ring-2 ring-info border-info bg-accent`:``} ${e.isParent?`text-muted-foreground`:``}`,children:[(0,J.jsx)(`span`,{className:`relative flex h-14 w-14 items-center justify-center`,children:e.isParent?(0,J.jsx)(p,{className:`h-10 w-10`,strokeWidth:1.5}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y,{className:`h-14 w-14 group-hover:hidden ${e.color?``:`text-warning`}`,strokeWidth:1.25,fill:`currentColor`,fillOpacity:.18,style:c}),(0,J.jsx)(w,{className:`hidden h-14 w-14 group-hover:block ${e.color?``:`text-warning`}`,strokeWidth:1.25,fill:`currentColor`,fillOpacity:.18,style:c})]})}),(0,J.jsx)(`span`,{className:`w-full truncate text-center font-medium`,children:e.isParent?`..`:e.label||e.name}),!e.isParent&&!!e.childCount&&(0,J.jsxs)(`span`,{className:`text-[11px] tabular-nums text-muted-foreground`,children:[e.childCount,` subfolder`,e.childCount===1?``:`s`]})]})}function ei({folders:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o}){return e.length===0?null:(0,J.jsx)(`div`,{className:`mb-4 grid grid-cols-[repeat(auto-fill,minmax(120px,1fr))] gap-3 pr-2`,onContextMenu:e=>e.stopPropagation(),children:e.map(e=>(0,J.jsx)($r,{folder:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o},e.path))})}function ti({folders:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o}){return e.length===0?null:(0,J.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-2 pr-2`,onContextMenu:e=>e.stopPropagation(),children:e.map(e=>(0,J.jsx)(Qr,{folder:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o},e.path))})}function ni({folder:e,onOpen:t,onMenu:n,onPasteDocuments:r,contextPath:i,treeName:a,workspaceId:o}){let s=Jr(e,r,i,a,o);return(0,J.jsxs)(mn,{"data-selection-ignore":``,className:`cursor-pointer ${s.over?`bg-accent ring-1 ring-inset ring-info`:``} ${e.isParent?`text-muted-foreground`:``}`,onClick:()=>t?.(e.path),onContextMenu:t=>Yr(t,e,n),onDragOver:s.onDragOver,onDragLeave:s.onDragLeave,onDrop:s.onDrop,title:Zr(e),children:[(0,J.jsx)(G,{className:`w-10`}),(0,J.jsx)(G,{className:`w-12`,children:(0,J.jsx)(Xr,{folder:e})}),(0,J.jsx)(G,{className:`w-full max-w-0 md:w-auto md:max-w-none`,children:(0,J.jsx)(`span`,{className:`block truncate font-medium`,children:e.isParent?`..`:e.label||e.name})}),(0,J.jsx)(G,{className:`hidden md:table-cell text-xs text-muted-foreground`,children:e.isParent?``:`Folder`}),(0,J.jsx)(G,{className:`hidden lg:table-cell`}),(0,J.jsx)(G,{className:`hidden lg:table-cell`}),(0,J.jsx)(G,{className:`hidden sm:table-cell text-xs text-muted-foreground`,children:!e.isParent&&e.childCount?`${e.childCount} subfolder${e.childCount===1?``:`s`}`:``}),(0,J.jsx)(G,{className:`w-12 md:w-auto`})]})}function ri({label:e,count:t,collapsed:n,allSelected:r,someSelected:i,onToggle:a,onSelectAll:o}){return(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-1 mb-2 flex items-center gap-2 bg-background/95 px-1 py-1.5 backdrop-blur-sm`,children:[(0,J.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 cursor-pointer accent-primary ${r||i?``:`reveal-on-hover`}`,checked:r,ref:e=>{e&&(e.indeterminate=i&&!r)},onChange:e=>o(e.target.checked),title:`Select everything in "${e}"`,onClick:e=>e.stopPropagation()}),(0,J.jsxs)(`button`,{type:`button`,onClick:a,"aria-expanded":!n,className:`flex min-w-0 items-center gap-1.5 text-left text-muted-foreground transition-colors hover:text-foreground`,children:[(0,J.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${n?``:`rotate-90`}`}),(0,J.jsx)(`span`,{className:`truncate text-xs font-semibold uppercase tracking-wide`,children:e}),(0,J.jsx)(`span`,{className:`shrink-0 text-xs font-normal tabular-nums opacity-70`,children:t})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function ii({readingPane:e=!1,externalSearchQuery:t,toolbarActions:n,documents:r,isLoading:i,contextPath:a,treeName:o,workspaceId:s,totalCount:p,onRemoveDocument:g,onDeleteDocument:y,onDestroyDocument:b,onRemoveDocuments:S,onDeleteDocuments:w,onDestroyDocuments:ee,onCopyDocuments:T,onCutDocuments:ne,onPasteDocuments:D,onImportDocuments:O,onSelectionChange:ce,pastedDocumentIds:k,viewMode:ue=`card`,allowViewToggle:he=!1,activeContextUrl:ge,currentContextUrl:ye,currentPage:A=1,pageSize:j=50,onPageChange:ke,onPageSizeChange:Ae,onPurgeDocuments:Fe,disablePurgeDocuments:Be=!1,backendSearchQueries:Ve=[],onBackendSearch:P,onRemoveBackendQuery:Ue,serverSort:F,onServerSortChange:We,scope:Ge=`path`,onScopeChange:Je,canSaveChanges:Ye=!1,isSavingChanges:Xe=!1,onSaveChanges:Ze,linkTree:$e,folders:et,onOpenFolder:tt}){let nt=Cn(),rt=At(),[it,at]=(0,K.useState)(()=>{if(!he)return ue;try{let e=localStorage.getItem(`doclist:view`);if(e===`card`||e===`table`||e===`tile`)return e}catch{}return ue}),I=he?nt?.documentLayout??it:ue,st=(0,K.useCallback)(e=>{nt?.selectDocumentLayout(e),at(e);try{localStorage.setItem(`doclist:view`,e)}catch{}},[nt]),[ct,lt]=(0,K.useState)(()=>{try{return localStorage.getItem(`doclist:groupdates`)!==`off`}catch{return!0}}),ut=(0,K.useCallback)(()=>{lt(e=>{let t=!e;try{localStorage.setItem(`doclist:groupdates`,t?`on`:`off`)}catch{}return t})},[]),[dt,ft]=(0,K.useState)(new Set),pt=(0,K.useCallback)(e=>{ft(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[L,R]=(0,K.useState)(new Set),[z,B]=(0,K.useState)(null),[ht,gt]=(0,K.useState)(null),_t=zt(),vt=!!(_t&&s),yt=(0,K.useCallback)((e,t=!1)=>{if(!_t||!s)return;let n=e.map(e=>r.find(t=>t.id===e)).filter(e=>!!e);n.length!==0&&_t.openAddRelated({workspaceName:s,documents:n},t)},[_t,s,r]),[bt,Ct]=(0,K.useState)(!1),[V,Et]=(0,K.useState)(null),[Dt,Ot]=(0,K.useState)(!1),[kt,jt]=(0,K.useState)(null),[Mt,Nt]=(0,K.useState)(!1),Ft=(0,K.useRef)(!1),It=(0,K.useRef)(!1),H=o===`backends`&&Ge===`path`?rn(a):null;(0,K.useEffect)(()=>()=>{Ft.current=!0},[]);let[Lt,Rt]=(0,K.useState)(!1),[Bt,Vt]=(0,K.useState)(null),[Ht,Ut]=(0,K.useState)(!1),[Wt,Gt]=(0,K.useState)(null),Kt=Pt()==null&&!!s,[qt,Jt]=(0,K.useState)(null),[Xt,U]=(0,K.useState)(null),$t=!!($e&&D),en=!!s,{showSuccessToast:tn,showErrorToast:nn}=Qt(),{showProgress:an}=je(),on=Tt(),sn=s?e=>on.open(e,s):void 0,cn=Ge===`workspace`,ln=cn?void 0:g,un=cn?void 0:S,[dn,fn]=(0,K.useState)(!1),[G,xn]=(0,K.useState)(!1),[Sn,wn]=(0,K.useState)(``),q=t??Sn,Tn=t!==void 0,[En,Dn]=(0,K.useState)(!1),On=Ve.length>0,kn=(0,K.useRef)(null),An=(0,K.useCallback)(()=>{wn(``),kn.current&&(kn.current.value=``)},[]);(0,K.useEffect)(()=>{if(!he||window.matchMedia(`(max-width: 767px)`).matches)return;let e=kn.current;if(!e)return;let t=setTimeout(()=>{let t=window.document.activeElement;t&&t!==window.document.body||e.focus()},60);return()=>clearTimeout(t)},[he]);let jn=JSON.stringify([s,o,a]),[Mn,Nn]=(0,K.useState)(jn);jn!==Mn&&(Nn(jn),R(new Set),Et(null),gt(null),B(null)),(0,K.useEffect)(()=>{ce?.(Array.from(L))},[L,ce]);let Pn=(0,K.useCallback)(()=>{if(!P)return;let e=q.trim();e&&(P(e),An())},[P,q,An]),Fn=(0,K.useCallback)(()=>{An(),Ue&&Ve.length>0&&Ue(-1)},[Ue,Ve.length,An]),In=(0,K.useCallback)((e,t)=>{let n;L.has(t)&&L.size>1?n=Array.from(L):(n=[t],R(new Set([t])));let r={type:`document`,documentIds:n,sourcePath:Ge===`path`?a:void 0,sourceTreeName:o,sourceWorkspaceId:s};e.dataTransfer.setData(`application/json`,JSON.stringify(r)),e.dataTransfer.effectAllowed=`copyMove`,e.dataTransfer.setDragImage(e.currentTarget,0,0)},[L,a,o,s,Ge]),Ln=(0,K.useCallback)(async e=>{if(!D)return;let t=e.dataTransfer.getData(`application/json`);if(!t)return;let n=null;try{n=JSON.parse(t)}catch{return}n?.type!==`document`||!Array.isArray(n.documentIds)||n.documentIds.length===0||(e.preventDefault(),e.stopPropagation(),Dn(!1),!sr(n,s,o,a)&&(await D(a,n.documentIds,{move:e.shiftKey,sourcePath:n.sourcePath,sourceTreeName:n.sourceTreeName}),R(new Set)))},[a,o,s,D]),zn=(0,K.useCallback)(e=>{D&&Array.from(e.dataTransfer.types).includes(`application/json`)&&(e.preventDefault(),e.dataTransfer.dropEffect=e.shiftKey?`move`:`copy`,Dn(!0))},[D]),Hn=(0,K.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Dn(!1)},[]),Un=(0,K.useMemo)(()=>({keys:[{name:`data.title`,weight:.4},{name:`data.name`,weight:.4},{name:`locations.url`,weight:.4},{name:`data.url`,weight:.3},{name:`data.content`,weight:.2},{name:`data.description`,weight:.2}],threshold:.4,location:0,distance:100,minMatchCharLength:1,includeScore:!0,includeMatches:!0,ignoreLocation:!0}),[]),Y=(0,K.useMemo)(()=>r.length===0?null:new pn(r,Un),[r,Un]),X=(0,K.useDeferredValue)(q),Z=(0,K.useMemo)(()=>{if(!X.trim())return r;let{text:e,ids:t,invalid:n}=Vn(X);if(n)return[];let i=e&&Y?Y.search(e).map(e=>e.item):r;return t.length?i.filter(e=>t.every(t=>e.id===t)):i},[r,X,Y]),Gn=(0,K.useMemo)(()=>{if(!et||et.length===0||X.trim())return[];let e=F?.order===`desc`?-1:1;return[...et].sort((t,n)=>Number(!!n.isParent)-Number(!!t.isParent)||(t.label||t.name).localeCompare(n.label||n.name,void 0,{numeric:!0,sensitivity:`base`})*e)},[et,X,F?.order]),Yn=Gn.length>0,[Xn,Zn]=(0,K.useState)(null),Qn=(0,K.useMemo)(()=>s&&o&&tt?(e,t)=>Zn({x:t.clientX,y:t.clientY,path:e}):void 0,[s,o,tt]),$n={folders:Gn,onOpen:tt,onMenu:Qn,onPasteDocuments:D,contextPath:a,treeName:o,workspaceId:s},tr=(0,K.useMemo)(()=>({title:e=>N(e).title?.toLowerCase()??``,schema:e=>N(e).schemaLabel??``,type:Qe,id:e=>e.id,created:e=>Date.parse(e.createdAt)||0}),[]),{sorted:rr,sort:ir,toggleSort:or}=bn(Z,tr),cr=(0,K.useCallback)(e=>_r(e,F?.sortBy),[F?.sortBy]),lr=(0,K.useMemo)(()=>wr(Z,cr,F?.order===`asc`?`asc`:`desc`),[Z,cr,F?.order]),dr=ct&&!He(F?.sortBy)&&lr.length>1,fr=(0,K.useCallback)((e,t)=>{R(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},[]),pr=(0,K.useMemo)(()=>(I===`table`?rr:dr?lr.filter(e=>!dt.has(e.key)).flatMap(e=>e.items):Z).map(e=>e.id),[I,rr,dr,lr,dt,Z]),mr=(0,K.useRef)(null),hr=JSON.stringify([s,a,o,A]),Q=(0,K.useCallback)(e=>{mr.current=null,R(t=>t.size===e.size&&[...t].every(t=>e.has(t))?t:e)},[]),$=(0,K.useCallback)((e,t,n,r=!1)=>{let i=mr.current,a=i?.scope===hr&&pr.includes(i.id)?i.id:null;(!r||a===null)&&(mr.current={scope:hr,id:e}),R(i=>{if(r)return Wn(pr,a,e,i,n);let o=n?new Set(i):new Set;return t?o.add(e):o.delete(e),o})},[hr,pr]),vr=(0,K.useCallback)((e,t)=>{let n;L.has(e)?n=Array.from(L):(n=[e],R(new Set([e]))),B({anchor:t,ids:n})},[L]),yr=(0,K.useCallback)((e,t)=>{vr(t,Ie(e))},[vr]),br=(0,K.useCallback)((e,t)=>{e.target.closest?.(`[role="dialog"]`)||(e.preventDefault(),e.stopPropagation(),vr(t,Ir(e)))},[vr]),xr=(0,K.useCallback)(async(e,t)=>{if(t.length!==0&&e.targetIds.length!==0){Ct(!0);try{for(let n of t)await ot(s,n,e.predicate,e.targetIds,e.direction);let n=t.length*e.targetIds.length;tn(`Created ${n} relation${n===1?``:`s`}`),Yt(),gt(null)}catch(e){nn(e instanceof Error?e.message:`Failed to create relations`)}finally{Ct(!1)}}},[s,tn,nn]),Sr=(0,K.useCallback)(async(e,t,n)=>{if(D){for(let r of e)await D(r,t,{move:!1,targetTreeName:n?.treeName,targetTreeType:n?.treeType});R(new Set)}},[D]),Cr=(0,K.useCallback)(async(e,t,n)=>{if(!s||!V||It.current)return;It.current=!0,Ft.current=!1,Nt(!1),Ot(!0);let i=an({title:t===`delete`?`Deleting…`:t===`move`?`Moving…`:`Copying…`,description:`${V.ids.length} document(s) · ${e.join(`, `)}`});try{let a=r=>mt(s,r,{to:e,mode:t,keepDocument:n.keepDocument,...t===`delete`&&H?{deleteFrom:{backend:H.backend,folder:H.rel}}:{},folder:n.folder,filename:n.filename,onConflict:n.onConflict}),o=t===`delete`?await Bn(V.ids,a,{shouldStop:()=>Ft.current,onProgress:(t,n)=>{jt({completed:t,total:n}),i.update({title:`Deleting…`,description:`${t} / ${n} document(s) · ${e.join(`, `)}`})}}):{...await a(V.ids),pending:[]},c=o.successful.filter(e=>e.transfers?.every(e=>e.state===`unchanged`)).length,l=o.successful.filter(e=>e.transfers?.some(e=>e.state===`pending`)).length,u=o.successful.length-c-l,d=o.failed.length,f=t===`delete`?`Deleted from`:t===`move`?`Moved to`:`Copied to`,p=e.join(`, `),m=[c?`${c} already there`:null,l?`${l} queued for backend sync`:null,d?`${d} skipped`:null,o.pending.length?`${o.pending.length} not processed`:null].filter(Boolean).join(` · `),h=`${f} ${p}: ${u} document${u===1?``:`s`}${m?` · ${m}`:``}`;d>0?(i.fail({title:`Operation incomplete`,description:`${h}. ${wt(o.failed,new Map(r.map(e=>[e.id,N(e).title])))}`,variant:`destructive`}),console.warn(`Backend transfer skipped documents:`,o.failed)):i.done({title:o.pending.length?`Operation stopped`:l?`Transfer queued`:`Operation complete`,description:h}),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`));let g=[...o.failed.map(e=>e.id),...o.pending];Et(g.length?{ids:g,mode:t}:null),R(new Set(g))}catch(e){i.fail({title:`Operation failed`,description:e instanceof Error?e.message:String(e),variant:`destructive`})}finally{It.current=!1,Ot(!1),jt(null)}},[s,V,H,r,an]),Tr=(0,K.useCallback)(()=>{L.size===Z.length?R(new Set):R(new Set(Z.map(e=>e.id)))},[L.size,Z]),Er=(0,K.useCallback)(async e=>{try{await navigator.clipboard.writeText(e)}catch{let t=window.document.createElement(`textarea`);t.value=e,window.document.body.appendChild(t),t.select(),window.document.execCommand(`copy`),window.document.body.removeChild(t)}},[]),Dr=e=>{if(e.length===0)return[];let t=e.length,n=t>1?` (${t})`:``,i=t===1?r.find(t=>t.id===e[0]):void 0,a=()=>R(new Set),c=e.some(e=>r.find(t=>t.id===e)?.locations?.some(e=>e.status==null||e.status===`available`)),l=[],d=e=>{e&&l.push(e)};if(i){let e=i.schema===`data/schema/tab`?i.data.url:null;d({id:`view`,group:`open`,label:`View details`,icon:pe,run:()=>U({document:i})}),d(Kt&&{id:`edit`,group:`open`,label:`Edit`,icon:f,run:()=>U({document:i,edit:!0})}),d(Kt&&i.schema===`data/schema/file`&&{id:`rename`,group:`open`,label:`Rename…`,icon:f,run:()=>U({document:i,edit:!0})});let t=i.data?.url||i.data?.uri;d(Kt&&s&&i.schema!==`data/schema/file`&&typeof t==`string`&&/^https?:\/\//i.test(t)&&{id:`download-link`,group:`open`,label:`Download to workspace`,icon:Ce,run:async()=>{let e=an({title:`Downloading file…`});try{await qe(s,i.id),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`)),e.done({title:`File saved to workspace`})}catch(t){e.fail({title:`Download failed`,description:t instanceof Error?t.message:String(t),variant:`destructive`})}}}),d(e&&{id:`open-url`,group:`open`,label:`Open URL`,icon:_e,run:()=>{window.open(e,`_blank`,`noopener,noreferrer`)}}),d(sn&&{id:`open-side`,group:`open`,label:`Open to the side`,icon:ae,run:()=>sn(i)})}return d(T&&{id:`copy`,group:`clipboard`,label:`Copy${n}`,icon:te,shortcut:`Mod+C`,run:()=>T(e)}),d(ne&&{id:`cut`,group:`clipboard`,label:`Cut${n}`,icon:Te,shortcut:`Mod+X`,run:()=>ne(e)}),d(i&&{id:`copy-id`,group:`clipboard`,label:`Copy ID`,icon:se,run:()=>Er(String(i.id))}),d(i&&Kt&&{id:`create-rule`,group:`organize`,label:`Create rule…`,icon:xe,run:()=>Jt(i)}),d($t&&{id:`link-to`,group:`organize`,label:`Link to…${n}`,icon:Se,run:()=>gt(e)}),d(vt&&{id:`add-related`,group:`organize`,label:`Add related document…${n}`,icon:C,run:t=>yt(e,t?.shiftKey)}),d(Kt&&{id:`bulk-edit`,group:`organize`,label:`Bulk edit…${n}`,icon:f,run:()=>Gt(e)}),d(Kt&&{id:`copy-workspace`,group:`organize`,label:`Copy to workspace…`,icon:te,run:t=>{Ut(!!t?.shiftKey),Vt(e)}}),d({id:`export`,group:`organize`,label:`Export…${n}`,icon:Ce,run:()=>fn(!0)}),d(o!==`backends`&&(ln||un)&&{id:`remove`,group:`remove`,label:`Remove (unlink) from folder${n}`,icon:v,shortcut:`Delete`,hint:`Unlinks from this folder; the document stays in the index`,run:()=>{t===1&&ln?ln(e[0]):un?.(e),a()}}),d(o!==`backends`&&(y||w)&&{id:`delete`,group:`remove`,label:`Delete from index${n}`,icon:oe,destructive:!0,hint:`Removes the document from the index entirely; file data stays on its backend(s)`,run:()=>{t===1&&y?y(e[0]):w?.(e),a()}}),c&&en?(d({id:`backend-copy`,group:`backends`,groupLabel:`Backends`,label:`Copy to backend…${n}`,icon:u,hint:`Copy the file data to another storage backend (keeps the existing copies)`,run:()=>Et({ids:e,mode:`copy`})}),d({id:`backend-move`,group:`backends`,label:`Move to backend…${n}`,icon:fe,hint:`Move the file data to another storage backend (source released once the copy is durable)`,run:()=>Et({ids:e,mode:`move`})}),d({id:`backend-delete`,group:`backends`,label:`Delete from backend…${n}`,icon:oe,destructive:!0,hint:`Delete the file data from selected backends (copies elsewhere are kept)`,run:()=>Et({ids:e,mode:`delete`})})):c&&(b||ee)&&d({id:`destroy`,group:`backends`,label:`Delete from backend(s)${n}`,icon:oe,destructive:!0,hint:`Deletes the document and its file data from the storage backend(s)`,run:()=>{t===1&&b?b(e[0]):ee?.(e),a()}}),l},Or=()=>{let e=[],t=t=>{t&&e.push(t)},n=k??[];return t(D&&n.length>0&&{id:`paste`,group:`clipboard`,label:`Paste (${n.length})`,icon:l,shortcut:`Mod+V`,run:async()=>{try{await D(a,n)}catch(e){console.error(`Failed to paste documents:`,e)}}}),t(Z.length>0&&{id:`select-all`,group:`select`,label:q?`Select all matches (${Z.length})`:`Select all on this page`,icon:ve,shortcut:`Mod+A`,run:()=>R(new Set(Z.map(e=>e.id)))}),t(L.size>0&&{id:`select-none`,group:`select`,label:`Clear selection`,icon:be,run:()=>R(new Set)}),t(D&&{id:`add-existing`,group:`add`,label:`Add existing documents…`,icon:de,hint:`Browse and add existing documents to this folder`,run:()=>Rt(!0)}),t(O&&{id:`import`,group:`add`,label:`Import…`,icon:ie,run:()=>xn(!0)}),t(r.length>0&&{id:`export-all`,group:`add`,label:`Export all…`,icon:Ce,run:()=>{R(new Set),fn(!0)}}),t(Fe&&p>0&&{id:`purge`,group:`purge`,label:`Purge all (${p})`,icon:oe,destructive:!0,disabled:Be||!!q,hint:q?`Purge is disabled while local search is active`:Be?`Purge requires loaded server results with no browser-only or live selection`:`Delete all documents matching the current server-side filters across all pages`,run:Fe}),e},kr=!!(We&&F&&s),Ar=z?z.ids?Dr(z.ids):Or():[],Mr=z?.ids?.length===1?r.find(e=>e.id===z.ids[0]):void 0,Fr=Mr?(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(W,{document:Mr,chip:!0}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`div`,{className:`truncate text-base font-semibold`,children:N(Mr).title}),(0,J.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[`ID: `,Mr.id,` · `,Mr.schema]})]})]}):(0,J.jsx)(`div`,{className:`truncate text-base font-semibold`,children:z?.ids?`${z.ids.length} documents`:`This folder`}),Lr=e=>{B({anchor:Ie(e.currentTarget),ids:L.size>0?Array.from(L):null})},Rr=e=>{e.target.closest?.(`[role="dialog"]`)||(e.preventDefault(),e.stopPropagation(),R(new Set),B({anchor:Ir(e),ids:null}))},zr=e=>{if(e.defaultPrevented||Le(e.target))return;let t=e.target.closest?.(`[data-document-id]`)??null;if(Pe(e)){e.preventDefault(),t?vr(Number(t.dataset.documentId),Ie(t,`inside`)):B({anchor:Ie(e.target,`inside`),ids:L.size>0?Array.from(L):null});return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){let n=Array.from(e.currentTarget.querySelectorAll(`[data-document-id]`));if(n.length===0)return;let r=t?n.indexOf(t):-1,i=n[e.key===`ArrowDown`?Math.min(r+1,n.length-1):Math.max(r-1,0)];e.preventDefault(),i.focus({preventScroll:!0}),i.scrollIntoView({block:`nearest`}),e.shiftKey&&$(Number(i.dataset.documentId),!0,!1,!0);return}if(e.key===`Escape`&&L.size>0){e.preventDefault(),R(new Set);return}ze(e,[...Dr(Array.from(L)),...Or()])},Hr=(0,K.useCallback)(async e=>{if(!O)return!1;try{return await O(e,a)}catch(e){return console.error(`Failed to import documents:`,e),!1}},[O,a]),Ur=e=>dr?lr.map(t=>{let n=dt.has(t.key),r=t.items.map(e=>e.id),i=r.reduce((e,t)=>e+ +!!L.has(t),0);return(0,J.jsxs)(`section`,{className:`group mb-4`,children:[(0,J.jsx)(ri,{label:t.label,count:t.items.length,collapsed:n,allSelected:i===r.length,someSelected:i>0,onToggle:()=>pt(t.key),onSelectAll:e=>fr(r,e)}),!n&&e(t.items)]},t.key)}):e(Z);return i?(0,J.jsx)(Rn,{enabled:e,workspaceId:s,scope:JSON.stringify([s,o,a]),documents:[],loading:!0,children:(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,J.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading documents...`})]})})}):(0,J.jsx)(Rn,{enabled:e,workspaceId:s,scope:JSON.stringify([s,o,a]),documents:I===`table`?rr:Z,loading:!1,children:(0,J.jsxs)(`div`,{tabIndex:-1,onKeyDown:zr,className:`flex-1 flex flex-col min-h-0 min-w-0 p-4 rounded-(--card-radius) outline-none transition-colors ${En?`ring-2 ring-inset ring-primary bg-primary/5`:``}`,onDragOver:zn,onDragLeave:Hn,onDrop:Ln,children:[(0,J.jsxs)(`div`,{className:`border-b pb-3 mb-4 flex-shrink-0`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-sm text-muted-foreground`,children:`Documents`}),(0,J.jsx)(`p`,{className:`shrink-0 text-sm font-medium`,children:q?`${Z.length} of ${r.length}`:`${p.toLocaleString()} document${p===1?``:`s`}`})]}),(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs text-muted-foreground`,children:[(0,J.jsxs)(`p`,{hidden:Tn,className:`min-w-0 truncate`,children:[`Context: `,(0,J.jsx)(`span`,{className:`font-mono`,children:a}),ge&&ye&&ge!==ye&&(0,J.jsx)(`span`,{className:`text-warning ml-2`,children:`(not yet active)`})]}),(0,J.jsxs)(`p`,{className:`shrink-0`,children:[L.size>0&&(0,J.jsxs)(`span`,{className:`text-info`,children:[L.size,` selected`]}),L.size>0&&(q||p>j)&&(0,J.jsx)(`span`,{className:`mx-1`,children:`·`}),q?`on this page`:p>j?`Showing ${Math.min((A-1)*j+1,p)}–${Math.min(A*j,p)}`:null]})]})]}),!Tn&&(0,J.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`relative flex flex-wrap items-center gap-2`,children:[!Tn&&Je&&(0,J.jsxs)(`div`,{className:`flex shrink-0 rounded-md border border-input overflow-hidden text-xs font-medium`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>Je(`path`),className:`px-2.5 py-2 transition-colors ${Ge===`path`?`bg-primary text-primary-foreground`:`bg-background text-muted-foreground hover:text-foreground hover:bg-muted`}`,title:`List documents in the selected path`,children:`This path`}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>Je(`workspace`),className:`px-2.5 py-2 border-l border-input transition-colors flex items-center gap-1 ${Ge===`workspace`?`bg-primary text-primary-foreground`:`bg-background text-muted-foreground hover:text-foreground hover:bg-muted`}`,title:`List every document in the workspace (staging excluded)`,children:[(0,J.jsx)(re,{className:`h-3.5 w-3.5`}),`Whole workspace`]})]}),!Tn&&(0,J.jsxs)(`div`,{className:`relative flex-1 min-w-[12rem]`,children:[(0,J.jsx)(De,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,J.jsx)(`input`,{ref:kn,type:`text`,placeholder:P?On?`Refine: add another query (Enter)…`:`Search documents (Enter for server search)…`:`Search documents...`,title:`Search text or an exact document ID, e.g. @id:101140. Press Enter to search the server.`,defaultValue:``,onChange:e=>wn(e.target.value),onFocus:e=>{let t=e.currentTarget;window.matchMedia(`(max-width: 767px)`).matches&&setTimeout(()=>t.scrollIntoView({block:`center`,behavior:`smooth`}),250)},onKeyDown:e=>{e.key===`Enter`&&P&&(e.preventDefault(),Pn())},className:`w-full pl-10 pr-9 py-2 border border-input rounded-md bg-background text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent`}),P&&s&&(0,J.jsx)(xt,{workspaceId:s,inputRef:kn,onChange:wn}),(q||On)&&(0,J.jsx)(`button`,{onClick:Fn,className:`absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground hover:text-foreground`,title:`Clear search`,children:(0,J.jsx)(x,{className:`h-4 w-4`})})]}),!Tn&&P&&q.trim()&&!Ve.includes(q.trim())&&(0,J.jsxs)(M,{size:`sm`,variant:`default`,onClick:Pn,className:`shrink-0`,title:On?`Refine: narrow the current results by this query`:`Run full-text search on the server`,children:[(0,J.jsx)(De,{className:`h-3.5 w-3.5 mr-1`}),On?`Refine`:`Search server`]})]}),!Tn&&On&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`Server search:`}),Ve.map((e,t)=>(0,J.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground/70 font-medium uppercase text-[10px]`,children:`then`}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded bg-muted text-foreground border`,children:[(0,J.jsxs)(`span`,{className:`font-mono`,children:[`"`,e,`"`]}),Ue&&(0,J.jsx)(`button`,{onClick:()=>Ue(t),className:`text-muted-foreground hover:text-foreground`,title:`Remove this query`,children:(0,J.jsx)(x,{className:`h-3 w-3`})})]})]},`${e}-${t}`)),Ue&&Ve.length>1&&(0,J.jsx)(`button`,{onClick:()=>Ue(-1),className:`ml-1 text-muted-foreground hover:text-foreground underline`,title:`Clear all queries`,children:`clear all`})]})]}),(0,J.jsx)(`div`,{className:`document-toolbar mt-3`,children:(0,J.jsxs)(`div`,{className:`document-toolbar-row`,children:[(0,J.jsxs)(`div`,{className:`document-toolbar-controls`,children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,role:`group`,"aria-label":`Document layout`,children:[he&&(0,J.jsx)(`div`,{className:`flex shrink-0 items-center rounded-md border p-0.5 touch-target`,children:[[`table`,c,`Table view`],[`tile`,we,`Tile view`],[`card`,Ee,`Card view`]].map(([e,t,n])=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>st(e),title:n,"aria-pressed":I===e,className:`rounded-sm p-1.5 transition-colors focus-ring ${I===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:(0,J.jsx)(t,{className:`h-4 w-4`})},e))}),he&&I!==`table`&&!He(F?.sortBy)&&(0,J.jsx)(`button`,{type:`button`,onClick:ut,title:ct?`Grouping by date — click for a flat list`:`Group by date (Today, Yesterday, …)`,"aria-pressed":ct,className:`touch-target shrink-0 rounded-md border p-1.5 transition-colors focus-ring ${ct?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-accent/50`}`,children:(0,J.jsx)(_,{className:`h-4 w-4`})})]}),ke&&p>0&&(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`document-toolbar-label`,children:`Show:`}),(0,J.jsxs)(`select`,{value:j,onChange:e=>Ae?.(Number(e.target.value)),className:`h-control-sm rounded-(--input-radius) border-(length:--input-border-width) border-input bg-background px-2 text-sm focus-ring`,"aria-label":`Documents per page`,children:[(0,J.jsx)(`option`,{value:25,children:`25`}),(0,J.jsx)(`option`,{value:50,children:`50`}),(0,J.jsx)(`option`,{value:100,children:`100`}),(0,J.jsx)(`option`,{value:200,children:`200`})]}),(0,J.jsx)(`span`,{className:`document-toolbar-label`,children:`per page`})]})]}),(0,J.jsxs)(`div`,{className:`document-toolbar-secondary`,children:[kr&&(0,J.jsxs)(`div`,{className:`document-toolbar-sort flex min-w-0 items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`document-toolbar-label`,children:`Sort`}),(0,J.jsx)(gr,{workspaceId:s,value:F,onChange:We})]}),(0,J.jsxs)(`div`,{className:`document-toolbar-actions`,children:[(r.length>0||O||D)&&(0,J.jsxs)(`div`,{className:`contents`,children:[(0,J.jsxs)(M,{variant:`outline`,size:`sm`,onClick:Lr,"aria-haspopup":`menu`,"aria-label":L.size>0?`Actions (${L.size} selected)`:`Actions`,className:`document-toolbar-action-button flex items-center gap-1.5 touch-target`,title:`Actions (${Ne(`Shift+F10`)} or right-click)`,children:[(0,J.jsx)(me,{className:`h-4 w-4`}),(0,J.jsxs)(`span`,{className:`document-toolbar-action-label`,children:[`Actions`,L.size>0?` (${L.size} selected)`:``]})]}),L.size>0&&(0,J.jsxs)(M,{variant:`ghost`,size:`sm`,onClick:()=>R(new Set),"aria-label":`Clear selection`,className:`document-toolbar-action-button touch-target`,title:`Clear selection (Esc)`,children:[(0,J.jsx)(x,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{className:`document-toolbar-action-label`,children:`Clear`})]}),k&&k.length>0&&D&&(0,J.jsxs)(M,{variant:`outline`,size:`sm`,onClick:()=>D(a,k),className:`flex items-center gap-1.5`,title:`Paste into this folder (${Ne(`Mod+V`)})`,children:[(0,J.jsx)(l,{className:`h-4 w-4`}),`Paste (`,k.length,`)`]})]}),Ye&&Ze&&(0,J.jsx)(M,{size:`sm`,variant:`outline`,onClick:Ze,disabled:Xe,className:`w-control-sm shrink-0 px-0 touch-target`,"aria-label":Xe?`Saving filters`:`Save current query and filters`,title:`Save current query and filters`,children:(0,J.jsx)(m,{className:`h-3.5 w-3.5`})}),n]})]})]})}),ke&&p>j&&(0,J.jsxs)(`div`,{className:`document-pagination mt-3 flex min-w-0 flex-wrap items-center justify-end gap-2 border-t pt-3 max-sm:gap-0.5`,children:[(0,J.jsxs)(`span`,{className:`text-sm text-muted-foreground max-md:hidden`,children:[`Showing `,Math.min((A-1)*j+1,p),` - `,Math.min(A*j,p),` of `,p]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 max-sm:gap-0.5`,children:[(0,J.jsx)(M,{variant:`outline`,size:`sm`,"aria-label":`First page`,onClick:()=>ke(1),disabled:A===1,className:`p-1 touch-target`,children:(0,J.jsx)(d,{className:`h-4 w-4`})}),(0,J.jsx)(M,{variant:`outline`,size:`sm`,"aria-label":`Previous page`,onClick:()=>ke(A-1),disabled:A===1,className:`p-1 touch-target`,children:(0,J.jsx)(h,{className:`h-4 w-4`})}),(0,J.jsxs)(`span`,{className:`whitespace-nowrap px-3 py-1 text-sm font-medium max-sm:px-1 max-sm:text-xs`,children:[(0,J.jsx)(`span`,{className:`max-sm:sr-only`,children:`Page `}),A,(0,J.jsx)(`span`,{className:`max-sm:hidden`,children:` of `}),(0,J.jsx)(`span`,{className:`sm:hidden`,children:`/`}),Math.ceil(p/j)]}),(0,J.jsx)(M,{variant:`outline`,size:`sm`,"aria-label":`Next page`,onClick:()=>ke(A+1),disabled:A>=Math.ceil(p/j),className:`p-1 touch-target`,children:(0,J.jsx)(E,{className:`h-4 w-4`})}),(0,J.jsx)(M,{variant:`outline`,size:`sm`,"aria-label":`Last page`,onClick:()=>ke(Math.ceil(p/j)),disabled:A>=Math.ceil(p/j),className:`p-1 touch-target`,children:(0,J.jsx)(Oe,{className:`h-4 w-4`})})]})]})]}),(0,J.jsx)(er,{scope:JSON.stringify([hr,I,pr]),selected:L,onSelectionChange:Q,onContextMenu:Rr,children:Z.length===0&&!Yn?(0,J.jsx)(`div`,{className:`min-h-full flex items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,J.jsx)(le,{className:`h-12 w-12 text-muted-foreground/50 mx-auto`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:q?`No documents match your search`:`No documents found in this context`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q?(0,J.jsxs)(J.Fragment,{children:[`Search: `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[`"`,q,`"`]})]}):(0,J.jsxs)(J.Fragment,{children:[`Path: `,(0,J.jsx)(`span`,{className:`font-mono`,children:a})]})}),!Tn&&q&&(0,J.jsx)(`button`,{onClick:An,className:`text-xs text-primary hover:text-primary/80 underline mt-1`,children:`Clear search`}),!q&&k&&k.length>0&&(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Right-click or press `,Ne(`Mod+V`),` to paste `,k.length,` document(s)`]})]})}):I===`tile`?(0,J.jsxs)(`div`,{children:[(0,J.jsx)(ei,{...$n}),Z.length===0&&(0,J.jsx)(`p`,{className:`py-6 text-center text-xs text-muted-foreground`,children:`No documents in this folder`}),Ur(e=>(0,J.jsx)(`div`,{className:`document-tiles pr-2`,"data-tile-style":rt,children:e.map(e=>(0,J.jsx)(qr,{document:e,isSelected:L.has(e.id),workspaceId:s,onSelect:$,onOpenToSide:sn,onRightClick:br,onOpenActions:yr,onDragStart:In},e.id))}))]}):I===`table`?(0,J.jsx)(`div`,{children:(0,J.jsxs)(vn,{children:[(0,J.jsx)(yn,{children:(0,J.jsxs)(mn,{children:[(0,J.jsx)(_n,{className:`w-10`,children:(0,J.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer accent-primary align-middle`,checked:Z.length>0&&L.size===Z.length,ref:e=>{e&&(e.indeterminate=L.size>0&&L.size<Z.length)},onChange:Tr,title:`Select all on this page`})}),(0,J.jsx)(gn,{label:(0,J.jsx)(`span`,{className:`max-md:sr-only`,children:`Type`}),sortKey:`type`,sort:ir,onSort:or,className:`w-12`}),(0,J.jsx)(gn,{label:`Title`,sortKey:`title`,sort:ir,onSort:or,className:`w-full max-w-0 md:w-auto md:max-w-none`}),(0,J.jsx)(gn,{label:`Schema`,sortKey:`schema`,sort:ir,onSort:or,className:`hidden md:table-cell`}),(0,J.jsx)(gn,{label:`ID`,sortKey:`id`,sort:ir,onSort:or,className:`hidden lg:table-cell`}),(0,J.jsx)(_n,{className:`hidden lg:table-cell`,children:`Checksum`}),(0,J.jsx)(gn,{label:`Created`,sortKey:`created`,sort:ir,onSort:or,className:`hidden sm:table-cell`}),(0,J.jsx)(_n,{className:`w-12 md:w-auto`,children:(0,J.jsx)(`span`,{className:`max-md:sr-only`,children:`Actions`})})]})}),(0,J.jsxs)(hn,{children:[Gn.map(e=>(0,J.jsx)(ni,{folder:e,onOpen:tt,onMenu:Qn,onPasteDocuments:D,contextPath:a,treeName:o,workspaceId:s},e.path)),rr.map(e=>(0,J.jsx)(Br,{document:e,isSelected:L.has(e.id),workspaceId:s,onSelect:$,onOpenToSide:sn,onRightClick:br,onOpenActions:yr,onDragStart:In},e.id))]})]})}):(0,J.jsxs)(`div`,{children:[(0,J.jsx)(ti,{...$n}),Z.length===0&&(0,J.jsx)(`p`,{className:`py-6 text-center text-xs text-muted-foreground`,children:`No documents in this folder`}),Ur(e=>(0,J.jsx)(`div`,{className:`space-y-3 pr-2`,children:e.map(e=>(0,J.jsx)(`div`,{children:(0,J.jsx)(Vr,{document:e,isSelected:L.has(e.id),workspaceId:s,onSelect:$,onOpenToSide:sn,onRightClick:br,onOpenActions:yr,onDragStart:In})},e.id))}))]})}),z&&(0,J.jsx)(Me,{anchor:z.anchor,items:Ar,onClose:()=>B(null),label:z.ids?`Document actions`:`Folder actions`,header:Fr}),(0,J.jsx)(Nr,{isOpen:dn,onClose:()=>fn(!1),documents:r,selectedDocuments:L}),(0,J.jsx)(Pr,{isOpen:G,onClose:()=>xn(!1),onImport:Hr}),Bt&&s&&(0,J.jsx)(nr,{modal:Ht,workspaceId:s,ids:Bt,onClose:()=>Vt(null)}),ht&&$e&&(0,J.jsx)(qn,{label:`Link to`,onClose:()=>gt(null),children:(0,J.jsx)(Re,{sizeClassName:`h-full w-full rounded-none border-0 bg-popover text-popover-foreground shadow-none`,documentCount:ht.length,fixedWorkspaceName:s,tabs:[`context`,`directory`,`relations`],saving:bt,relationExcludeIds:new Set(ht),onConfirm:(e,t)=>Sr(e,ht,t),onConfirmRelation:e=>xr(e,ht),onClose:()=>gt(null)})}),V&&s&&(0,Kn.createPortal)((0,J.jsx)(`div`,{className:`fixed inset-0 z-picker flex items-center justify-center bg-scrim p-4 max-md:p-2`,children:(0,J.jsx)(St,{workspaceId:s,documentCount:V.ids.length,initialMode:V.mode,defaultFilename:V.ids.length===1?Ke(r.find(e=>e.id===V.ids[0])??{}):``,saving:Dt,progress:kt,stopping:Mt,onStop:()=>{Ft.current=!0,Nt(!0)},deleteFrom:H?{backend:H.backend,folder:H.rel}:void 0,onConfirm:Cr,onClose:()=>{Dt||Et(null)}})}),window.document.body),Lt&&D&&(0,Kn.createPortal)((0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`fixed inset-0 z-picker-scrim bg-scrim animate-fade-in md:hidden`,onClick:()=>Rt(!1),"aria-hidden":!0}),(0,J.jsx)(`div`,{className:`fixed inset-y-0 right-0 z-picker flex items-stretch py-2 pr-2 max-md:bottom-2 max-md:left-2 max-md:top-2 max-md:py-0 max-md:pr-0 max-md:animate-fade-in`,children:(0,J.jsx)(Zt,{sizeClassName:`h-full w-[420px] max-w-full max-md:w-full max-md:shadow-elevation-5`,fixedWorkspaceName:s,onConfirm:async e=>{await D(a,e),Rt(!1)},onClose:()=>Rt(!1)})})]}),window.document.body),qt&&s&&(0,J.jsx)(Jn,{workspaceId:s,document:qt,onClose:()=>Jt(null)},`${s}:${qt.id}`),Wt&&s&&(0,J.jsx)(ar,{workspaceId:s,documentIds:Wt,onClose:()=>Gt(null)}),(0,J.jsx)(ur,{document:Xt?.document??null,isOpen:!!Xt,onClose:()=>U(null),workspaceId:s,initialEdit:Xt?.edit}),Xn&&s&&o&&tt&&(0,J.jsx)(jr,{x:Xn.x,y:Xn.y,workspaceName:s,treeName:o,path:Xn.path,onClose:()=>Zn(null),onOpen:tt,onOpenToSide:e=>window.dispatchEvent(new CustomEvent(`workspace:open-to-side`,{detail:{workspaceName:s,treeName:o,path:e}})),pastedDocumentIds:k,onPasteDocuments:D?(e,t)=>D(e,t):void 0})]})})}function ai(e){let t=window.document.createElement(`div`);window.document.body.appendChild(t);let n=(0,cr.createRoot)(t);n.render((0,J.jsx)(Pr,{isOpen:!0,onClose:()=>{n.unmount(),t.remove()},onImport:e}))}function oi(e){let t=window.document.createElement(`div`);window.document.body.appendChild(t);let n=(0,cr.createRoot)(t);n.render((0,J.jsx)(Nr,{isOpen:!0,onClose:()=>{n.unmount(),t.remove()},documents:e,selectedDocuments:new Set}))}export{gr as a,sr as c,Un as d,Ln as f,Cn as h,kr as i,ar as l,jn as m,Ar as n,fr as o,Pn as p,Or as r,ur as s,ii as t,qn as u};
|