@augmentd-labs/canvas-web 2.26.34 → 2.26.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/assets/CalendarApplet-CI650A38.js +2 -0
  2. package/dist/assets/{DocumentBodyEditor-DRFQgBNB.js → DocumentBodyEditor-CVO5KPCs.js} +1 -1
  3. package/dist/assets/{DocumentIcon-ByDAILhm.js → DocumentIcon-9i1uCMQa.js} +1 -1
  4. package/dist/assets/{EditorOverlay-DpQKmxkR.js → EditorOverlay-D5t3xg4w.js} +1 -1
  5. package/dist/assets/{FileForm-B6eFRKG-.js → FileForm-C35drQ_R.js} +1 -1
  6. package/dist/assets/{FiltersApplet-B3UrkkQk.js → FiltersApplet-Ia3RTHqt.js} +1 -1
  7. package/dist/assets/{HomeFab-D83jf0To.js → HomeFab-CXuEjvlA.js} +1 -1
  8. package/dist/assets/{IdentityFields-CEDxU-Hd.js → IdentityFields-DZRqtnIG.js} +1 -1
  9. package/dist/assets/{LensApplet-BvgmmKLC.js → LensApplet-DxqrTTvu.js} +1 -1
  10. package/dist/assets/{LinkToCard-VXpoeMDH.js → LinkToCard-BQ1yoFDr.js} +1 -1
  11. package/dist/assets/{MarkdownEditor-Dnyez7VT.js → MarkdownEditor-DbpRWbO6.js} +2 -2
  12. package/dist/assets/{MessageComposerDialog-BKGlI7jO.js → MessageComposerDialog-CdPp-3GR.js} +1 -1
  13. package/dist/assets/{NextShell-BvKyH2Oj.js → NextShell-BfQHKEKO.js} +1 -1
  14. package/dist/assets/{NotesApplet-BJwWkYe_.js → NotesApplet-ALnJx1R5.js} +1 -1
  15. package/dist/assets/{ObjectPropertiesCard-B9gkyowI.js → ObjectPropertiesCard-BTTwYnN9.js} +4 -4
  16. package/dist/assets/{PathPickerField-B58yeJGw.js → PathPickerField-B4yFUjgD.js} +1 -1
  17. package/dist/assets/{PickDocumentsCard-B72XNYh3.js → PickDocumentsCard-CFDQL70e.js} +1 -1
  18. package/dist/assets/{SketchApplet-BHee4eKG.js → SketchApplet-14xrogy3.js} +1 -1
  19. package/dist/assets/{SketchEditor-Knj-HA0P.js → SketchEditor-B2LYe_MO.js} +1 -1
  20. package/dist/assets/{TerminalApplet-Djk4l1Jm.js → TerminalApplet-BNeLmNFF.js} +1 -1
  21. package/dist/assets/{TextDocumentEditor-rgHsbLCL.js → TextDocumentEditor-CU5ersd_.js} +1 -1
  22. package/dist/assets/{TodosApplet-DZVcRHmh.js → TodosApplet-ASG9wXjL.js} +1 -1
  23. package/dist/assets/{TodosWidget-DdN3vJfS.js → TodosWidget-CYK5RbYD.js} +1 -1
  24. package/dist/assets/{UploadProgressList-CHQ-Kn-e.js → UploadProgressList-Ci1akl_D.js} +1 -1
  25. package/dist/assets/{_agentId_-Ctolhe8r.js → _agentId_-DiuSEd4O.js} +0 -0
  26. package/dist/assets/{_contextId_-Cj78rDep.js → _contextId_-Bovrvd2T.js} +1 -1
  27. package/dist/assets/{_workspaceName_-CU9Y7Zvt.js → _workspaceName_-DXYHTbna.js} +1 -1
  28. package/dist/assets/{about-OY_bpfUf.js → about-CIz-eZ-8.js} +1 -1
  29. package/dist/assets/{add-D7ysLgO3.js → add-Cf7qavr8.js} +1 -1
  30. package/dist/assets/{agents-DEJU4O1Z.js → agents-DxqAi3vk.js} +1 -1
  31. package/dist/assets/{agents-DgJX7Rbh.js → agents-t82sp0lw.js} +1 -1
  32. package/dist/assets/{alert-dialog-CShuAcnP.js → alert-dialog-CFeuDt0T.js} +1 -1
  33. package/dist/assets/{api-tokens-CmHhwd58.js → api-tokens-drrVuCYc.js} +1 -1
  34. package/dist/assets/{appearance-D3YShC7g.js → appearance-Ba1GYZ_J.js} +1 -1
  35. package/dist/assets/{applet-target-Bl9Je1N-.js → applet-target-I8w6EPj0.js} +1 -1
  36. package/dist/assets/{apps-CJ5g43ts.js → apps-uPsYOOCl.js} +1 -1
  37. package/dist/assets/{auth-_bmIEN02.js → auth-PqttD05H.js} +1 -1
  38. package/dist/assets/backend-sync-progress-tUU2XWtW.js +7 -0
  39. package/dist/assets/{button-Bum-POPT.js → button-SeUZ_Pvi.js} +1 -1
  40. package/dist/assets/{content-app-view-CH0wMWqu.js → content-app-view-DfmmWQ_z.js} +1 -1
  41. package/dist/assets/{context-BGgz0Y_q.js → context-DZ1Hn7tt.js} +1 -1
  42. package/dist/assets/{contexts-Dtl9oERX.js → contexts-DDJagU4j.js} +1 -1
  43. package/dist/assets/{contexts-CwGdjtXy2.js → contexts-Df-cWUlj2.js} +1 -1
  44. package/dist/assets/date-time-picker-txVhlNO0.js +1 -0
  45. package/dist/assets/{devices-CmVlYbam.js → devices-BwU9M8-W.js} +1 -1
  46. package/dist/assets/{document-CdrNjy0Z.js → document-CTvT2Qa5.js} +1 -1
  47. package/dist/assets/document-list-CQ1_7Sja.js +2 -0
  48. package/dist/assets/{embedding-2EjzoVFT.js → embedding-BvXcVfij.js} +1 -1
  49. package/dist/assets/{embedding-BqI3l5RB.js → embedding-D-I_ygUZ.js} +1 -1
  50. package/dist/assets/{form-panel-DZj3WZ3z.js → form-panel-3p-ncEVK.js} +1 -1
  51. package/dist/assets/{home-BYUM64nU.js → home-CsrwkvZX.js} +1 -1
  52. package/dist/assets/index-C51Jk0Xq.css +2 -0
  53. package/dist/assets/index-DRHEGJ8I.js +16 -0
  54. package/dist/assets/{inferd-config-editor-CyDCQJRs.js → inferd-config-editor-B8x_XPOt.js} +1 -1
  55. package/dist/assets/{key-bindings-BhC3zpgE.js → key-bindings-CnvBrNMZ.js} +1 -1
  56. package/dist/assets/{label-DJc8-3CQ.js → label-BSTdjCWU.js} +1 -1
  57. package/dist/assets/{lazy-editor-Bdm5JEXv.js → lazy-editor-BUFAkTGl.js} +2 -2
  58. package/dist/assets/{logs-DUeiDqCX.js → logs-DjG8_wJ2.js} +1 -1
  59. package/dist/assets/{offline-yfQ63Zr7.js → offline-sNCjxnp-.js} +1 -1
  60. package/dist/assets/{page-header-BoCaZiqu.js → page-header-DrDt1sQ2.js} +1 -1
  61. package/dist/assets/{public-share-D2S8DEsv.js → public-share-D5yz-Pmo.js} +1 -1
  62. package/dist/assets/{query-debug-CZacGe0M.js → query-debug-CQ0I3cXX.js} +1 -1
  63. package/dist/assets/registry-9MElXU-U.js +2 -0
  64. package/dist/assets/{remotes-BjjlqN_M.js → remotes-RPGcw6fH.js} +1 -1
  65. package/dist/assets/{roles-CuqCEPC7.js → roles-DoR2drD1.js} +1 -1
  66. package/dist/assets/{roles-BHJYWaBs.js → roles-p2cRajz-.js} +1 -1
  67. package/dist/assets/{settings-_xaqx07q.js → settings-B9-XHGdl.js} +1 -1
  68. package/dist/assets/{settings-e2lvFtNs.js → settings-CUxtVfMx.js} +1 -1
  69. package/dist/assets/{settings-j7fHuCH-.js → settings-Dkb35vRa.js} +1 -1
  70. package/dist/assets/settings-DxEF5yL8.js +16 -0
  71. package/dist/assets/{share-target-BNWYelcQ.js → share-target-DJICHfZZ.js} +1 -1
  72. package/dist/assets/{shared-C-uHNNY8.js → shared-BnpwVpxG.js} +1 -1
  73. package/dist/assets/{shared-td0TEahe.js → shared-DmdHUnl7.js} +1 -1
  74. package/dist/assets/sketch-lazy-BbNgGbR3.js +2 -0
  75. package/dist/assets/{subtree-transfer-dialog-BN9xBB9n.js → subtree-transfer-dialog-DQM5zfx2.js} +1 -1
  76. package/dist/assets/{text-documents-CFW8MWES.js → text-documents-BaXhu3ra.js} +1 -1
  77. package/dist/assets/ui-CDoK3F3U.js +41 -0
  78. package/dist/assets/{use-applet-docs-DBshA7yq.js → use-applet-docs-B2dk__vk.js} +1 -1
  79. package/dist/assets/{use-applet-target-DmIdCxa_.js → use-applet-target-ffIGaAqT.js} +1 -1
  80. package/dist/assets/{use-canvas-pins-BfT9xMi5.js → use-canvas-pins-DkWN9oEd.js} +1 -1
  81. package/dist/assets/{use-menu-CaiLyPdw.js → use-menu-DIP1zh7I.js} +1 -1
  82. package/dist/assets/use-settings-back-DGmLAD63.js +1 -0
  83. package/dist/assets/{use-sortable-data-W2inLcb5.js → use-sortable-data-BBKmqs79.js} +1 -1
  84. package/dist/assets/{use-workspace-identity-KxY9injc.js → use-workspace-identity-B8gOMGj4.js} +1 -1
  85. package/dist/assets/{useAddTarget-D4ra50Am.js → useAddTarget-B3b6TyZr.js} +1 -1
  86. package/dist/assets/{useAgentModels-C9Qu2rhq.js → useAgentModels-BjT4oN4e.js} +1 -1
  87. package/dist/assets/{useDocumentThumbnail-Bs2Ju0eb.js → useDocumentThumbnail-wW0lSOEy.js} +1 -1
  88. package/dist/assets/{useEditNoteFields-CKYMBf8V.js → useEditNoteFields-DXLTFEqL.js} +1 -1
  89. package/dist/assets/{users-DInwKAxz.js → users-DuVk-TEd.js} +1 -1
  90. package/dist/assets/{workspace-46EFyEKZ.js → workspace-BJELPCNs.js} +1 -1
  91. package/dist/assets/{workspace-area-menu-DEyR7-bZ.js → workspace-area-menu-BFw2yUHk.js} +1 -1
  92. package/dist/assets/{workspace-content-gate-CGZmT2kw.js → workspace-content-gate-NLuRPvbm.js} +1 -1
  93. package/dist/assets/{workspace-import-form-Bu1nlv8u.js → workspace-import-form-Bb6z42nw.js} +1 -1
  94. package/dist/assets/{workspaces-p959p9BR.js → workspaces-CqHYstZv.js} +1 -1
  95. package/dist/assets/{workspaces-BryjR7k9.js → workspaces-DpVuDD1E.js} +1 -1
  96. package/dist/index.html +36 -36
  97. package/dist/sw.js +1 -1
  98. package/package.json +2 -2
  99. package/dist/assets/CalendarApplet-CVcB6nT5.js +0 -1
  100. package/dist/assets/backend-sync-progress-BJsLP7o5.js +0 -7
  101. package/dist/assets/date-time-picker-Bzu8H_Oa.js +0 -1
  102. package/dist/assets/document-list-BX13fcRu.js +0 -2
  103. package/dist/assets/index-CJapDuPp.js +0 -16
  104. package/dist/assets/index-lwdPSalm.css +0 -2
  105. package/dist/assets/registry-C7aVPPMW.js +0 -2
  106. package/dist/assets/settings-HUPOeACw.js +0 -16
  107. package/dist/assets/sketch-lazy-BOFTGGTA.js +0 -2
  108. package/dist/assets/ui-76Hw0NU_.js +0 -41
  109. 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{_t as r,yt as i}from"./react-BHzhHVTZ.js";import{Bn as a,L as o,Lt as s,Ur as ee,Vr as c,Wn as l,Zn as u,mt as d,qn as f,vn as p,wr as m,yt as h}from"./ui-76Hw0NU_.js";import{t as g}from"./utils-2pl1SbIp.js";import{t as _}from"./button-Bum-POPT.js";import{An as v,Dt as y,G as b,K as x,Nt as te,Sn as S,Z as C,ht as w,mt as ne,rt as re}from"./workspace-46EFyEKZ.js";import{t as T}from"./useEscapeClose-DR_xKT_k.js";import{t as ie}from"./useToastHelpers-CRrpIIdY.js";import{s as E}from"./layer-style-Byl5LNFR.js";import{i as D}from"./color-DFEH4BfK.js";import{t as ae}from"./DocumentIcon-ByDAILhm.js";var O=e(n(),1),k=t();function A({className:e=`h-5 w-5`,...t}){return(0,k.jsxs)(`svg`,{className:`animate-spin ${e}`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...t,children:[(0,k.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,k.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}var j=e(i(),1);function M(e){let[t,n]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!e)return;let t=!1;return C(e).then(r=>{t||n({workspaceId:e,predicates:r,error:!1})},()=>{t||n({workspaceId:e,predicates:[],error:!0})}),()=>{t=!0}},[e]);let r=t?.workspaceId===e?t:null;return{predicates:r?.predicates??[],error:r?.error??!1,loading:!!e&&!r}}function N({x:e,y:t,onClose:n,className:r,children:i}){let a=(0,O.useRef)(null),[o,s]=(0,O.useState)({x:e,y:t});return T(n),(0,O.useLayoutEffect)(()=>{let n=a.current;if(!n)return;let{width:r,height:i}=n.getBoundingClientRect();s({x:Math.max(8,Math.min(e,window.innerWidth-r-8)),y:Math.max(8,Math.min(t,window.innerHeight-i-8))})},[e,t]),(0,j.createPortal)((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`fixed inset-0 z-menu-scrim`,onClick:n,onContextMenu:e=>{e.preventDefault(),n()}}),(0,k.jsx)(`div`,{ref:a,style:{left:o.x,top:o.y},className:g(`fixed z-menu max-h-viewport-modal overflow-y-auto`,r,`bg-popover text-popover-foreground`),children:i})]}),document.body)}var P=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),F={Delete:`Del`,Backspace:`⌫`,Enter:`↵`,ArrowUp:`↑`,ArrowDown:`↓`};function I(e){let t=e.split(`+`),n=t.pop()||``,r=F[n]||(n.length===1?n.toUpperCase():n);if(P){let e={Mod:`⌘`,Shift:`⇧`,Alt:`⌥`,Ctrl:`⌃`};return[...[`Ctrl`,`Alt`,`Shift`,`Mod`].filter(e=>t.includes(e)).map(t=>e[t]),r].join(``)}return[...t.map(e=>e===`Mod`?`Ctrl`:e),r].join(`+`)}function L(e,t){let n=t.split(`+`),r=n.pop()||``;return(P?e.metaKey:e.ctrlKey)!==n.includes(`Mod`)||e.shiftKey!==n.includes(`Shift`)||e.altKey!==n.includes(`Alt`)||P&&e.ctrlKey!==n.includes(`Ctrl`)?!1:r.length===1?e.key.toLowerCase()===r.toLowerCase():e.key===r}function R(e){if(e?.closest?.(`input, textarea, select, [contenteditable="true"], [role="dialog"], [role="menu"]`))return!0;let t=typeof window<`u`?window.getSelection():null;return!!t&&!t.isCollapsed&&t.toString().length>0}function z(e,t){if(e.defaultPrevented||e.nativeEvent.isComposing||R(e.target))return!1;let n=t.find(t=>t.shortcut&&!t.disabled&&L(e,t.shortcut));return n?(e.preventDefault(),e.stopPropagation(),n.run({shiftKey:e.shiftKey}),!0):!1}function B(e){return e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey}function oe(){return typeof window<`u`&&window.matchMedia(`(max-width: 767px)`).matches}function V(e,t=`below`){let n=e.getBoundingClientRect();return t===`below`?{x:n.left,y:n.bottom+4}:{x:n.left+Math.min(24,n.width/2),y:n.top+Math.min(24,n.height/2)}}function H(e){let t=[];for(let n of e){let e=t[t.length-1];e&&(e[0].group??``)===(n.group??``)?e.push(n):t.push([n])}return t}function se(e,t,n){t(),setTimeout(()=>{e.run({shiftKey:n})},0)}function ce({anchor:e,items:t,onClose:n,label:r}){let i=(0,O.useRef)(null);return(0,O.useEffect)(()=>{let e=document.activeElement;return i.current?.querySelector(`[role="menuitem"]:not([aria-disabled="true"])`)?.focus(),()=>{e?.isConnected&&e.focus({preventScroll:!0})}},[]),(0,k.jsx)(N,{x:e.x,y:e.y,onClose:n,className:`min-w-[200px] rounded-lg border bg-popover text-popover-foreground py-1 shadow-elevation-3`,children:(0,k.jsx)(`div`,{ref:i,role:`menu`,"aria-label":r,onKeyDown:e=>{let t=Array.from(i.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)??[]);if(t.length===0)return;let r=t.indexOf(document.activeElement),a=e=>t[(e+t.length)%t.length]?.focus();switch(e.key){case`ArrowDown`:e.preventDefault(),a(r+1);return;case`ArrowUp`:e.preventDefault(),a(r<0?-1:r-1);return;case`Home`:e.preventDefault(),a(0);return;case`End`:e.preventDefault(),a(-1);return;case`Tab`:e.preventDefault(),n();return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let n=e.key.toLowerCase(),i=[...t.slice(r+1),...t.slice(0,r+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(n));i&&(e.preventDefault(),i.focus())}},onContextMenu:e=>e.preventDefault(),children:H(t).map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`div`,{role:`separator`,className:`my-1 h-px bg-border`}),e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let t=e.icon;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":e.disabled||void 0,title:e.hint,onClick:t=>{e.disabled||se(e,n,t.shiftKey)},className:g(`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm outline-none`,e.disabled?`cursor-default opacity-50`:e.destructive?`text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground`:`hover:bg-muted focus:bg-muted`),children:[t?(0,k.jsx)(t,{className:`h-3.5 w-3.5 shrink-0`}):(0,k.jsx)(`span`,{className:`w-3.5 shrink-0`}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.shortcut&&(0,k.jsx)(`kbd`,{className:`ml-4 shrink-0 font-sans text-[11px] text-muted-foreground`,children:I(e.shortcut)})]},e.id)})]},`${e[0].group??``}:${t}`))})})}function U({items:e,onClose:t,header:n}){T(t);let r=`flex w-full items-center gap-3 rounded-xl border bg-card px-4 py-3.5 text-base font-medium transition-transform active:scale-[.98]`;return(0,j.createPortal)((0,k.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-fullscreen flex flex-col bg-popover text-popover-foreground animate-in slide-in-from-bottom-10 fade-in duration-normal`,onClick:t,onContextMenu:e=>e.preventDefault(),children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b p-4`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm p-2 hover:bg-muted`,title:`Close`,"aria-label":`Close`,children:(0,k.jsx)(o,{className:`h-5 w-5`})})]}),(0,k.jsx)(`div`,{className:`min-h-4 flex-1`}),(0,k.jsxs)(`div`,{className:`max-h-[75vh] shrink-0 space-y-2 overflow-y-auto px-4 pt-2`,style:{paddingBottom:`calc(var(--safe-bottom) + 1.25rem)`},onClick:e=>e.stopPropagation(),children:[H(e).map((e,n)=>(0,k.jsxs)(`div`,{className:g(`space-y-2`,n>0&&`pt-2`),children:[e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let n=e.icon;return(0,k.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:n=>se(e,t,n.shiftKey),className:g(r,e.destructive&&`border-destructive/30 text-destructive`,e.disabled&&`opacity-50`),children:[n&&(0,k.jsx)(n,{className:g(`h-5 w-5 shrink-0`,!e.destructive&&`text-muted-foreground`)}),e.label]},e.id)})]},`${e[0].group??``}:${n}`)),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`${r} justify-center bg-muted`,children:`Cancel`})]})]}),window.document.body)}function le({anchor:e,items:t,onClose:n,label:r,header:i}){return t.length===0?null:oe()?(0,k.jsx)(U,{items:t,onClose:n,header:i??(r&&(0,k.jsx)(`div`,{className:`truncate text-base font-semibold`,children:r}))}):(0,k.jsx)(ce,{anchor:e,items:t,onClose:n,label:r})}function ue({items:e,onNavigate:t,disabled:n,className:r,label:i=`Tree path`}){let a=(0,O.useRef)(null),o=e[e.length-1]?.path;return(0,O.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[o]),(0,k.jsx)(`nav`,{"aria-label":i,className:g(`min-w-0 flex-1`,r),children:(0,k.jsx)(`ol`,{ref:a,className:`flex min-w-0 items-center gap-1 overflow-x-auto py-0.5 text-sm`,children:e.map((r,i)=>{let a=i===e.length-1,o=g(`block max-w-56 truncate rounded px-1.5 py-1`,a?`font-medium text-foreground`:`text-muted-foreground`);return(0,k.jsxs)(`li`,{className:`flex shrink-0 items-center gap-1`,children:[i>0&&(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`/`}),t&&!a?(0,k.jsx)(`button`,{type:`button`,title:r.path===`/`?`${r.label} (root)`:r.path,disabled:n,onClick:()=>t(r.path),className:g(o,`hover:bg-accent hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`),children:r.label}):(0,k.jsx)(`span`,{title:r.path===`/`?r.label:r.path,"aria-current":a?`location`:void 0,className:o,children:r.label})]},r.path)})})})}function W(e,t){let n=e.split(`/`).filter(Boolean);return[{label:t,path:`/`},...n.map((e,t)=>({label:e,path:`/${n.slice(0,t+1).join(`/`)}`}))]}var de={context:(0,k.jsx)(l,{className:`h-3.5 w-3.5`}),directory:(0,k.jsx)(f,{className:`h-3.5 w-3.5`}),backends:(0,k.jsx)(a,{className:`h-3.5 w-3.5`}),relations:(0,k.jsx)(d,{className:`h-3.5 w-3.5`})},fe={context:`Context tree`,directory:`Directory tree`,backends:`Backends tree`,relations:`Relations`};function pe(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function me(e,t){let n=(0,O.useRef)(null),r=(0,O.useRef)(!1),i=()=>{n.current&&=(clearTimeout(n.current),null)},a=e=>t=>{if(r.current){r.current=!1;return}t.detail>1||e()};return t?{guardClick:a,handlers:{onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),t({clientX:n.clientX,clientY:n.clientY,path:e})},onPointerDown:a=>{if(a.pointerType!==`touch`)return;let{clientX:o,clientY:s}=a;i(),n.current=setTimeout(()=>{r.current=!0,t({clientX:o,clientY:s,path:e})},500)},onPointerUp:i,onPointerLeave:i,onPointerMove:i}}:{handlers:{},guardClick:a}}function he(e,t,n){let r=pe(t,e.name);return r.toLowerCase().includes(n)||(e.label||``).toLowerCase().includes(n)?!0:e.children?.some(e=>he(e,r,n))??!1}var G=200;function ge({onConfirm:e,onCancel:t,busy:n}){let[r,i]=(0,O.useState)(``);return(0,k.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 text-sm shadow-elevation-1`,children:[(0,k.jsx)(m,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`&&r.trim()&&e(r.trim()),n.key===`Escape`&&t()},onBlur:()=>{n||t()},placeholder:`New folder name…`,autoFocus:!0,disabled:n,className:`w-full flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),n&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Creating…`})]})}function _e({node:e,parentPath:t,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:l,onCreateConfirm:u,onCreateCancel:d,creating:f}){let p=pe(t,e.name),m=!!e.children?.length,[h,_]=(0,O.useState)(!1),{handlers:v,guardClick:y}=me(p,s);if(n&&!he(e,t,n))return null;let b=l===p,x=h||n.length>0||b,te=i.has(p),S=e.type===`canvas`,C=E(e);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,te?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:y(()=>a(p)),onDoubleClick:e=>{e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.target.closest(`button,input,textarea,select,a,[contenteditable="true"]`)||(e.preventDefault(),e.stopPropagation(),m?_(e=>!e):o?.(p))},title:p,...v,children:[(0,k.jsx)(`button`,{type:`button`,"aria-label":`${x?`Collapse`:`Expand`} ${e.label||e.name}`,"aria-expanded":m?x:void 0,disabled:!m,className:g(`shrink-0 text-muted-foreground hover:text-foreground`,!m&&`invisible`),onClick:e=>{e.stopPropagation(),e.detail<=1&&_(e=>!e)},children:x?(0,k.jsx)(ee,{className:`w-4 h-4`}):(0,k.jsx)(c,{className:`w-4 h-4`})}),(0,k.jsx)(r,{icon:C.icon||(S?`ph:squares-four-fill`:`ph:folder-fill`),width:16,height:16,color:D(C.color),className:g(`shrink-0`,!D(C.color)&&(S?`text-primary`:`text-muted-foreground`))}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,title:e.description||void 0,children:e.label||e.name})]}),x&&m||b?(0,k.jsxs)(`div`,{className:`ml-[22px] mt-1.5 space-y-1.5`,children:[b&&u&&d&&(0,k.jsx)(ge,{busy:f,onConfirm:e=>{_(!0),u(p,e)},onCancel:d}),x&&e.children?.map(e=>(0,k.jsx)(_e,{node:e,parentPath:p,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:l,onCreateConfirm:u,onCreateCancel:d,creating:f},e.id||e.name))]}):null]})}function ve({workspaces:e,loading:t,onPick:n}){return t&&e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`No workspaces found`}):(0,k.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>{let t=D(e.color);return(0,k.jsxs)(`div`,{onClick:()=>n(e.name),className:`group relative flex cursor-pointer items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 shadow-elevation-1 transition-all hover:bg-accent/50 hover:shadow`,style:{borderRight:`6px solid ${t||`transparent`}`},children:[(0,k.jsx)(r,{icon:e.icon||`ph:stack-fill`,width:18,height:18,color:t,className:g(`shrink-0`,!t&&`text-muted-foreground`)}),(0,k.jsx)(`span`,{className:`flex-1 truncate text-sm font-medium`,children:e.label||e.name}),(0,k.jsx)(c,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.id||e.name)})})}function ye({workspaceName:e,treeTab:t,onTreeTabChange:n,selectedDocIds:r,onToggleDoc:i,onNavigate:a,excludeDocumentIds:s}){let[l,u]=(0,O.useState)(`folder`),[d,f]=(0,O.useState)(``),p=d.trim().toLowerCase(),[m,_]=(0,O.useState)(`/`),[y,te]=(0,O.useState)(null),[C,w]=(0,O.useState)(!1),[ne,T]=(0,O.useState)([]),[ie,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(``),[j,M]=(0,O.useState)(``),[N,P]=(0,O.useState)(t),F=n?t:N,I=e=>{_(`/`),u(`folder`),A(``),M(``),a?.(`/`),n?n(e):P(e)},[L,R]=(0,O.useState)(F);F!==L&&(R(F),_(`/`),u(`folder`)),(0,O.useEffect)(()=>{let e=setTimeout(()=>M(D.trim()),300);return()=>clearTimeout(e)},[D]),(0,O.useEffect)(()=>{let t=!1;async function n(){w(!0);try{let n=await b(e,F);t||te(n)}catch{t||te(null)}finally{t||w(!1)}}return n(),()=>{t=!0}},[e,F]),(0,O.useEffect)(()=>{if(l!==`documents`)return;let t=!1,n=F===`directory`?`directory`:S,r=F===`context`?`context`:`directory`;async function i(){E(!0);try{let i=j?await re(e,m,[],{treeName:n,treeType:r,q:j,limit:G}):await x(e,m,n,{limit:G});t||T(i.payload||[])}catch{t||T([])}finally{t||E(!1)}}return i(),()=>{t=!0}},[e,F,m,l,j]);let z=e=>{_(e),a?.(e)},B=s?.size?ne.filter(e=>!s.has(e.id)):ne;return l===`folder`?(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[!n&&(0,k.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-input p-0.5`,children:[`context`,`directory`].map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>I(e),className:g(`flex flex-1 items-center justify-center gap-1.5 rounded px-2 py-1 text-xs transition-colors`,F===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),title:`Browse the ${fe[e].toLowerCase()}`,children:[de[e],(0,k.jsx)(`span`,{className:`font-mono`,children:e===`directory`?`dir://`:`ctx://`})]},e))}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Step 1 of 2 · Pick a folder`}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>u(`documents`),className:`inline-flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90`,children:[`Next `,(0,k.jsx)(c,{className:`h-3.5 w-3.5`})]})]}),(0,k.jsx)(ue,{items:W(m,e),onNavigate:z,label:`Folder path`}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Filter folders…`,value:d,onChange:e=>f(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-3 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,children:C?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,m===`/`?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:()=>z(`/`),onDoubleClick:()=>{z(`/`),u(`documents`)},title:`/`,children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsx)(`div`,{className:`ml-[22px] space-y-1.5`,children:y?.children?.length?y.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:p,selected:new Set([m]),onToggle:z,onActivate:e=>{z(e),u(`documents`)}},e.id||e.name)):(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})})]})})]}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>u(`folder`),className:`inline-flex min-w-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:`Back to folders`,children:[(0,k.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 rotate-180`}),(0,k.jsx)(`span`,{children:`Folders`})]}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:`Step 2 of 2 · Pick a document`})]}),(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`[`,F,`]`]}),(0,k.jsx)(ue,{items:W(m,e),onNavigate:z,label:`Document folder path`})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search documents in this folder…`,value:D,onChange:e=>A(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-7 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`}),D&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>A(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear document search`,children:(0,k.jsx)(o,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto p-3`,children:ie?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading documents…`}):B.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:j?`No documents match “${j}” here.`:`No documents in this folder.`}):B.map(e=>{let t=v(e),n=r.has(e.id);return(0,k.jsxs)(`div`,{onClick:()=>i(e.id),className:g(`flex min-h-9 items-center gap-2 rounded-md px-3 py-1.5 cursor-pointer transition-all select-none text-sm`,n?`bg-primary/[0.08] hover:bg-primary/[0.12]`:`hover:bg-primary/[0.04]`),children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>i(e.id),className:`shrink-0`,onClick:e=>e.stopPropagation()}),(0,k.jsx)(ae,{document:e,size:3.5}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:t.title})]},e.id)})})]})}function be({onClose:e,onConfirm:t,documentCount:n,fixedWorkspaceName:r,excludeWorkspace:i,multiple:a=!0,saving:l=!1,savingContent:d,sizeClassName:f,tabs:m=[`context`,`directory`],initialTab:v,title:x,confirmLabel:C,backendFolderCreation:re,onConfirmRelation:E,relationWorkspaceName:D,relationPredicates:ae,relationExcludeIds:j}){let[N,P]=(0,O.useState)(r?`tree`:`workspace`),[F,I]=(0,O.useState)([]),[L,R]=(0,O.useState)(!r),[z,B]=(0,O.useState)(r??null),oe=v&&m.includes(v)?v:m.includes(`context`)||m.includes(`directory`)?`pins`:m[0]??`context`,[V,H]=(0,O.useState)(oe),se=M(m.includes(`relations`)&&!ae?D??z:null),U=ae??se.predicates,[le,ue]=(0,O.useState)(``),W=U.includes(le)?le:U[0]??``,[pe,he]=(0,O.useState)(`out`),[G,be]=(0,O.useState)(new Set),[xe,Se]=(0,O.useState)(null),[K,Ce]=(0,O.useState)(`context`),[we,Te]=(0,O.useState)(!1),Ee=V===`pins`?K:V;(0,O.useEffect)(()=>{if(!z)return;let e=!1;return y(z).then(t=>{e||Se(t)}).catch(()=>{e||Te(!0)}),()=>{e=!0}},[z]);let q=V===`relations`,[De,Oe]=(0,O.useState)(null),[ke,Ae]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(new Set),[je,Me]=(0,O.useState)(``),Ne=je.trim().toLowerCase(),{showErrorToast:Pe}=ie(),[X,Fe]=(0,O.useState)(null),[Ie,Z]=(0,O.useState)(null),[Q,Le]=(0,O.useState)(!1);T(e,!l&&!Q);let Re=me(`/`,e=>Fe(e)),ze=e=>!l&&(V===`backends`?re?.canCreate(e)===!0:V!==`pins`&&V!==`relations`),Be=async(e,t)=>{let n=t.trim().replace(/^\/+|\/+$/g,``);if(!(!n||!z||Q||!ze(e))){Le(!0);try{let t=`${e===`/`?``:e}/${n}`,r=V===`context`?S:V;V===`backends`?await re.create(e,n):await ne(z,t,!0,r),w(z,r),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:z,treeName:r,cacheInvalidated:!0}}));let i=await b(z,V);Oe(i),Y(e=>a?new Set([...e,t]):new Set([t])),Me(``),Z(null)}catch(e){Pe(e instanceof Error?e.message:`Failed to create folder`)}finally{Le(!1)}}},[Ve,He]=(0,O.useState)(r);r!==Ve&&(He(r),r||R(!0)),(0,O.useEffect)(()=>{r||te().then(e=>I(e.filter(e=>e.id!==i&&e.name!==i))).catch(()=>I([])).finally(()=>R(!1))},[r,i]),(0,O.useEffect)(()=>{if(!z||V===`relations`||V===`pins`)return;let e=!1,t=0;async function n(n=!1){let r=++t;n||Ae(!0);try{let n=await b(z,V);!e&&r===t&&Oe(n)}catch{!e&&r===t&&!n&&Oe(null)}finally{!e&&r===t&&Ae(!1)}}let r=e=>{let t=e.detail;t?.workspaceName&&t.workspaceName!==z||t?.treeName&&t.treeName!==V||(t?.cacheInvalidated||w(z,V),n(!0))};return window.addEventListener(`workspace:tree:refresh`,r),n(),()=>{e=!0,window.removeEventListener(`workspace:tree:refresh`,r)}},[z,V]);let Ue=e=>{e!==z&&(Se(null),Te(!1)),H(oe),B(e),Y(new Set),be(new Set),P(`tree`)},We=e=>{be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ge=e=>{if(!a){Y(new Set([e]));return}Y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ke=q?!!W&&G.size>0&&!!E:J.size>0,qe=async()=>{if(!(!z||l||!Ke)){if(q){await E?.({predicate:W,direction:pe,targetIds:Array.from(G)},{workspaceName:D??z});return}await t(Array.from(J),{workspaceName:z,treeName:Ee===`context`?S:Ee,treeType:Ee===`context`?`context`:`directory`})}},$=n??1;return l&&d?(0,k.jsx)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,f||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:d}):(0,k.jsxs)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,f||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:[(0,k.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,k.jsx)(p,{className:`h-4 w-4`}),x??(N===`workspace`?`Link to…`:q?`Relate ${$} document${$===1?``:`s`} to…`:`Link ${$} document${$===1?``:`s`} to…`)]}),(0,k.jsx)(`button`,{type:`button`,onClick:e,disabled:l||Q,className:`text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40`,"aria-label":`Close`,children:(0,k.jsx)(o,{className:`h-4 w-4`})})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,k.jsxs)(`div`,{className:`grid h-full w-[200%] grid-cols-2 transition-transform duration-normal`,style:{transform:N===`workspace`?`translateX(0)`:`translateX(-50%)`},children:[(0,k.jsx)(`div`,{className:`flex min-w-0 flex-col overflow-y-auto p-2`,children:(0,k.jsx)(ve,{workspaces:F,loading:L,onPick:Ue})}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 pt-2`,children:[!r&&(0,k.jsx)(`button`,{type:`button`,disabled:Q,onClick:()=>P(`workspace`),className:`mr-1 rounded p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground touch-target`,"aria-label":`Back to workspaces`,children:(0,k.jsx)(c,{className:`h-4 w-4 rotate-180`})}),(m.includes(`context`)||m.includes(`directory`))&&(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{H(`pins`),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 border-b-2 px-3 py-2 text-xs`,V===`pins`?`border-primary`:`border-transparent text-muted-foreground`),children:[(0,k.jsx)(s,{className:`h-3.5 w-3.5`}),`Pins`]}),m.map(e=>(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{H(e),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-xs font-medium transition-colors`,V===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[de[e],fe[e]]},e))]}),!q&&(0,k.jsx)(`div`,{className:`shrink-0 border-b p-2`,children:(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search paths…`,value:je,onChange:e=>Me(e.target.value),className:`w-full rounded-md border border-input bg-background py-2 pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})}),q&&(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-primary/[0.04] px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`relation-predicate`,className:`shrink-0 text-xs text-muted-foreground`,children:`Predicate`}),(0,k.jsx)(`select`,{id:`relation-predicate`,value:W,onChange:e=>ue(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-ring`,children:U.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]}),(0,k.jsx)(`div`,{className:`flex items-center gap-1`,children:[{dir:`out`,label:`This → picked`,hint:`the ${$===1?`document`:`documents`} you started from ${W} the picked one(s)`},{dir:`in`,label:`Picked → this`,hint:`the picked document(s) ${W} the ${$===1?`one`:`ones`} you started from`}].map(({dir:e,label:t,hint:n})=>(0,k.jsx)(`button`,{type:`button`,title:n,onClick:()=>he(e),className:g(`flex-1 rounded-md border px-2 py-1.5 text-xs transition-colors`,pe===e?`border-primary bg-primary text-primary-foreground`:`border-input hover:bg-accent`),children:t},e))})]}),!q&&a&&(0,k.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1.5 overflow-x-auto border-b bg-primary/[0.04] px-3`,children:[!J.size&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Selected folders appear here`}),Array.from(J).map(e=>(0,k.jsxs)(`span`,{className:`inline-flex max-w-full shrink-0 items-center gap-1 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground`,children:[(0,k.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ge(e),className:`shrink-0 rounded-full hover:bg-primary-foreground/20`,"aria-label":`Remove ${e}`,children:(0,k.jsx)(o,{className:`h-3 w-3`})})]},e))]}),q&&(D??z)&&(0,k.jsx)(ye,{workspaceName:D??z,treeTab:`context`,selectedDocIds:G,onToggleDoc:We,excludeDocumentIds:j}),V===`pins`&&(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3 space-y-2`,children:[!xe&&!we&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading pins…`}),we&&(0,k.jsx)(`p`,{className:`text-xs text-destructive`,children:`Could not load pins. You can still browse the trees.`}),!we&&xe?.length===0&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No pinned paths yet. Choose a path from a tree.`}),xe?.filter(e=>e.resolvable!==!1&&m.includes(e.tree===`context`?`context`:e.tree)&&`${e.label??e.name??``} ${e.path}`.toLowerCase().includes(Ne)).map(e=>{let t=e.tree===`context`?`context`:e.tree;return(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":K===t&&J.has(e.path),className:g(`w-full rounded-md border p-3 text-left text-sm hover:bg-muted`,K===t&&J.has(e.path)&&`border-primary bg-primary/10`),onClick:()=>{K===t?Ge(e.path):(Ce(t),Y(new Set([e.path])))},children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(s,{className:`h-3.5 w-3.5`}),e.label||e.name||e.path]}),(0,k.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[t,` · `,e.path]})]},e.id)})]}),(0,k.jsx)(`div`,{className:g(`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,(q||V===`pins`)&&`hidden`),children:ke?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,J.has(`/`)?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:Re.guardClick(()=>Ge(`/`)),title:`/`,...ze(`/`)?Re.handlers:{},children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsxs)(`div`,{className:`ml-[22px] space-y-1.5`,children:[Ie===`/`&&(0,k.jsx)(ge,{busy:Q,onConfirm:e=>Be(`/`,e),onCancel:()=>Z(null)}),De?.children?.length?De.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:Ne,selected:J,onToggle:Ge,onRowMenu:e=>{ze(e.path)&&Fe(e)},createParent:Ie,onCreateConfirm:Be,onCreateCancel:()=>Z(null),creating:Q},e.id||e.name)):Ie===`/`?null:(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})]})]})})]})]})}),N===`tree`&&(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t px-4 py-3`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q?`${G.size} document${G.size===1?``:`s`} selected`:`${J.size} path${J.size===1?``:`s`} selected`}),(0,k.jsx)(_,{size:`sm`,onClick:qe,disabled:!Ke||l||Q,children:l?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{className:`mr-1.5 h-3.5 w-3.5`}),q?`Relating…`:`Linking…`]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(p,{className:`mr-1 h-3.5 w-3.5`}),q?`Relate`:C??`Link`]})})]}),X&&(0,k.jsx)(ce,{anchor:{x:X.clientX,y:X.clientY},onClose:()=>Fe(null),items:[{id:`new-folder`,label:`New folder in ${X.path}`,icon:u,run:()=>Z(X.path)}]})]})}export{A as _,fe as a,le as c,I as d,B as f,M as g,N as h,de as i,V as l,L as m,ye as n,W as o,R as p,ve as r,ue as s,be as t,z as u};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r,yt as i}from"./react-BHzhHVTZ.js";import{Bn as a,L as o,Lt as s,Ur as ee,Vr as c,Wn as l,Zn as u,mt as d,qn as f,vn as p,wr as m,yt as h}from"./ui-CDoK3F3U.js";import{t as g}from"./utils-2pl1SbIp.js";import{t as _}from"./button-SeUZ_Pvi.js";import{An as v,Dt as y,G as b,K as x,Nt as te,Sn as S,Z as C,ht as w,mt as ne,rt as re}from"./workspace-BJELPCNs.js";import{t as T}from"./useEscapeClose-DR_xKT_k.js";import{t as ie}from"./useToastHelpers-CRrpIIdY.js";import{s as E}from"./layer-style-Byl5LNFR.js";import{i as D}from"./color-DFEH4BfK.js";import{t as ae}from"./DocumentIcon-9i1uCMQa.js";var O=e(n(),1),k=t();function A({className:e=`h-5 w-5`,...t}){return(0,k.jsxs)(`svg`,{className:`animate-spin ${e}`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,...t,children:[(0,k.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,k.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]})}var j=e(i(),1);function M(e){let[t,n]=(0,O.useState)(null);(0,O.useEffect)(()=>{if(!e)return;let t=!1;return C(e).then(r=>{t||n({workspaceId:e,predicates:r,error:!1})},()=>{t||n({workspaceId:e,predicates:[],error:!0})}),()=>{t=!0}},[e]);let r=t?.workspaceId===e?t:null;return{predicates:r?.predicates??[],error:r?.error??!1,loading:!!e&&!r}}function N({x:e,y:t,onClose:n,className:r,children:i}){let a=(0,O.useRef)(null),[o,s]=(0,O.useState)({x:e,y:t});return T(n),(0,O.useLayoutEffect)(()=>{let n=a.current;if(!n)return;let{width:r,height:i}=n.getBoundingClientRect();s({x:Math.max(8,Math.min(e,window.innerWidth-r-8)),y:Math.max(8,Math.min(t,window.innerHeight-i-8))})},[e,t]),(0,j.createPortal)((0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`fixed inset-0 z-menu-scrim`,onClick:n,onContextMenu:e=>{e.preventDefault(),n()}}),(0,k.jsx)(`div`,{ref:a,style:{left:o.x,top:o.y},className:g(`fixed z-menu max-h-viewport-modal overflow-y-auto`,r,`bg-popover text-popover-foreground`),children:i})]}),document.body)}var P=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent),F={Delete:`Del`,Backspace:`⌫`,Enter:`↵`,ArrowUp:`↑`,ArrowDown:`↓`};function I(e){let t=e.split(`+`),n=t.pop()||``,r=F[n]||(n.length===1?n.toUpperCase():n);if(P){let e={Mod:`⌘`,Shift:`⇧`,Alt:`⌥`,Ctrl:`⌃`};return[...[`Ctrl`,`Alt`,`Shift`,`Mod`].filter(e=>t.includes(e)).map(t=>e[t]),r].join(``)}return[...t.map(e=>e===`Mod`?`Ctrl`:e),r].join(`+`)}function L(e,t){let n=t.split(`+`),r=n.pop()||``;return(P?e.metaKey:e.ctrlKey)!==n.includes(`Mod`)||e.shiftKey!==n.includes(`Shift`)||e.altKey!==n.includes(`Alt`)||P&&e.ctrlKey!==n.includes(`Ctrl`)?!1:r.length===1?e.key.toLowerCase()===r.toLowerCase():e.key===r}function R(e){if(e?.closest?.(`input, textarea, select, [contenteditable="true"], [role="dialog"], [role="menu"]`))return!0;let t=typeof window<`u`?window.getSelection():null;return!!t&&!t.isCollapsed&&t.toString().length>0}function z(e,t){if(e.defaultPrevented||e.nativeEvent.isComposing||R(e.target))return!1;let n=t.find(t=>t.shortcut&&!t.disabled&&L(e,t.shortcut));return n?(e.preventDefault(),e.stopPropagation(),n.run({shiftKey:e.shiftKey}),!0):!1}function B(e){return e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey}function oe(){return typeof window<`u`&&window.matchMedia(`(max-width: 767px)`).matches}function V(e,t=`below`){let n=e.getBoundingClientRect();return t===`below`?{x:n.left,y:n.bottom+4}:{x:n.left+Math.min(24,n.width/2),y:n.top+Math.min(24,n.height/2)}}function H(e){let t=[];for(let n of e){let e=t[t.length-1];e&&(e[0].group??``)===(n.group??``)?e.push(n):t.push([n])}return t}function se(e,t,n){t(),setTimeout(()=>{e.run({shiftKey:n})},0)}function ce({anchor:e,items:t,onClose:n,label:r}){let i=(0,O.useRef)(null);return(0,O.useEffect)(()=>{let e=document.activeElement;return i.current?.querySelector(`[role="menuitem"]:not([aria-disabled="true"])`)?.focus(),()=>{e?.isConnected&&e.focus({preventScroll:!0})}},[]),(0,k.jsx)(N,{x:e.x,y:e.y,onClose:n,className:`min-w-[200px] rounded-lg border bg-popover text-popover-foreground py-1 shadow-elevation-3`,children:(0,k.jsx)(`div`,{ref:i,role:`menu`,"aria-label":r,onKeyDown:e=>{let t=Array.from(i.current?.querySelectorAll(`[role="menuitem"]:not([aria-disabled="true"])`)??[]);if(t.length===0)return;let r=t.indexOf(document.activeElement),a=e=>t[(e+t.length)%t.length]?.focus();switch(e.key){case`ArrowDown`:e.preventDefault(),a(r+1);return;case`ArrowUp`:e.preventDefault(),a(r<0?-1:r-1);return;case`Home`:e.preventDefault(),a(0);return;case`End`:e.preventDefault(),a(-1);return;case`Tab`:e.preventDefault(),n();return}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let n=e.key.toLowerCase(),i=[...t.slice(r+1),...t.slice(0,r+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(n));i&&(e.preventDefault(),i.focus())}},onContextMenu:e=>e.preventDefault(),children:H(t).map((e,t)=>(0,k.jsxs)(O.Fragment,{children:[t>0&&(0,k.jsx)(`div`,{role:`separator`,className:`my-1 h-px bg-border`}),e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let t=e.icon;return(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,"aria-disabled":e.disabled||void 0,title:e.hint,onClick:t=>{e.disabled||se(e,n,t.shiftKey)},className:g(`flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm outline-none`,e.disabled?`cursor-default opacity-50`:e.destructive?`text-destructive hover:bg-destructive hover:text-destructive-foreground focus:bg-destructive focus:text-destructive-foreground`:`hover:bg-muted focus:bg-muted`),children:[t?(0,k.jsx)(t,{className:`h-3.5 w-3.5 shrink-0`}):(0,k.jsx)(`span`,{className:`w-3.5 shrink-0`}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.shortcut&&(0,k.jsx)(`kbd`,{className:`ml-4 shrink-0 font-sans text-[11px] text-muted-foreground`,children:I(e.shortcut)})]},e.id)})]},`${e[0].group??``}:${t}`))})})}function U({items:e,onClose:t,header:n}){T(t);let r=`flex w-full items-center gap-3 rounded-xl border bg-card px-4 py-3.5 text-base font-medium transition-transform active:scale-[.98]`;return(0,j.createPortal)((0,k.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-fullscreen flex flex-col bg-popover text-popover-foreground animate-in slide-in-from-bottom-10 fade-in duration-normal`,onClick:t,onContextMenu:e=>e.preventDefault(),children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b p-4`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-sm p-2 hover:bg-muted`,title:`Close`,"aria-label":`Close`,children:(0,k.jsx)(o,{className:`h-5 w-5`})})]}),(0,k.jsx)(`div`,{className:`min-h-4 flex-1`}),(0,k.jsxs)(`div`,{className:`max-h-[75vh] shrink-0 space-y-2 overflow-y-auto px-4 pt-2`,style:{paddingBottom:`calc(var(--safe-bottom) + 1.25rem)`},onClick:e=>e.stopPropagation(),children:[H(e).map((e,n)=>(0,k.jsxs)(`div`,{className:g(`space-y-2`,n>0&&`pt-2`),children:[e[0].groupLabel&&(0,k.jsx)(`div`,{className:`px-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:e[0].groupLabel}),e.map(e=>{let n=e.icon;return(0,k.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:n=>se(e,t,n.shiftKey),className:g(r,e.destructive&&`border-destructive/30 text-destructive`,e.disabled&&`opacity-50`),children:[n&&(0,k.jsx)(n,{className:g(`h-5 w-5 shrink-0`,!e.destructive&&`text-muted-foreground`)}),e.label]},e.id)})]},`${e[0].group??``}:${n}`)),(0,k.jsx)(`button`,{type:`button`,onClick:t,className:`${r} justify-center bg-muted`,children:`Cancel`})]})]}),window.document.body)}function le({anchor:e,items:t,onClose:n,label:r,header:i}){return t.length===0?null:oe()?(0,k.jsx)(U,{items:t,onClose:n,header:i??(r&&(0,k.jsx)(`div`,{className:`truncate text-base font-semibold`,children:r}))}):(0,k.jsx)(ce,{anchor:e,items:t,onClose:n,label:r})}function ue({items:e,onNavigate:t,disabled:n,className:r,label:i=`Tree path`}){let a=(0,O.useRef)(null),o=e[e.length-1]?.path;return(0,O.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[o]),(0,k.jsx)(`nav`,{"aria-label":i,className:g(`min-w-0 flex-1`,r),children:(0,k.jsx)(`ol`,{ref:a,className:`flex min-w-0 items-center gap-1 overflow-x-auto py-0.5 text-sm`,children:e.map((r,i)=>{let a=i===e.length-1,o=g(`block max-w-56 truncate rounded px-1.5 py-1`,a?`font-medium text-foreground`:`text-muted-foreground`);return(0,k.jsxs)(`li`,{className:`flex shrink-0 items-center gap-1`,children:[i>0&&(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`text-muted-foreground/60`,children:`/`}),t&&!a?(0,k.jsx)(`button`,{type:`button`,title:r.path===`/`?`${r.label} (root)`:r.path,disabled:n,onClick:()=>t(r.path),className:g(o,`hover:bg-accent hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50`),children:r.label}):(0,k.jsx)(`span`,{title:r.path===`/`?r.label:r.path,"aria-current":a?`location`:void 0,className:o,children:r.label})]},r.path)})})})}function W(e,t){let n=e.split(`/`).filter(Boolean);return[{label:t,path:`/`},...n.map((e,t)=>({label:e,path:`/${n.slice(0,t+1).join(`/`)}`}))]}var de={context:(0,k.jsx)(l,{className:`h-3.5 w-3.5`}),directory:(0,k.jsx)(f,{className:`h-3.5 w-3.5`}),backends:(0,k.jsx)(a,{className:`h-3.5 w-3.5`}),relations:(0,k.jsx)(d,{className:`h-3.5 w-3.5`})},fe={context:`Context tree`,directory:`Directory tree`,backends:`Backends tree`,relations:`Relations`};function pe(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function me(e,t){let n=(0,O.useRef)(null),r=(0,O.useRef)(!1),i=()=>{n.current&&=(clearTimeout(n.current),null)},a=e=>t=>{if(r.current){r.current=!1;return}t.detail>1||e()};return t?{guardClick:a,handlers:{onContextMenu:n=>{n.preventDefault(),n.stopPropagation(),t({clientX:n.clientX,clientY:n.clientY,path:e})},onPointerDown:a=>{if(a.pointerType!==`touch`)return;let{clientX:o,clientY:s}=a;i(),n.current=setTimeout(()=>{r.current=!0,t({clientX:o,clientY:s,path:e})},500)},onPointerUp:i,onPointerLeave:i,onPointerMove:i}}:{handlers:{},guardClick:a}}function he(e,t,n){let r=pe(t,e.name);return r.toLowerCase().includes(n)||(e.label||``).toLowerCase().includes(n)?!0:e.children?.some(e=>he(e,r,n))??!1}var G=200;function ge({onConfirm:e,onCancel:t,busy:n}){let[r,i]=(0,O.useState)(``);return(0,k.jsxs)(`div`,{className:`flex min-h-11 items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 text-sm shadow-elevation-1`,children:[(0,k.jsx)(m,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`&&r.trim()&&e(r.trim()),n.key===`Escape`&&t()},onBlur:()=>{n||t()},placeholder:`New folder name…`,autoFocus:!0,disabled:n,className:`w-full flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`}),n&&(0,k.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Creating…`})]})}function _e({node:e,parentPath:t,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:l,onCreateConfirm:u,onCreateCancel:d,creating:f}){let p=pe(t,e.name),m=!!e.children?.length,[h,_]=(0,O.useState)(!1),{handlers:v,guardClick:y}=me(p,s);if(n&&!he(e,t,n))return null;let b=l===p,x=h||n.length>0||b,te=i.has(p),S=e.type===`canvas`,C=E(e);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,te?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:y(()=>a(p)),onDoubleClick:e=>{e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||e.target.closest(`button,input,textarea,select,a,[contenteditable="true"]`)||(e.preventDefault(),e.stopPropagation(),m?_(e=>!e):o?.(p))},title:p,...v,children:[(0,k.jsx)(`button`,{type:`button`,"aria-label":`${x?`Collapse`:`Expand`} ${e.label||e.name}`,"aria-expanded":m?x:void 0,disabled:!m,className:g(`shrink-0 text-muted-foreground hover:text-foreground`,!m&&`invisible`),onClick:e=>{e.stopPropagation(),e.detail<=1&&_(e=>!e)},children:x?(0,k.jsx)(ee,{className:`w-4 h-4`}):(0,k.jsx)(c,{className:`w-4 h-4`})}),(0,k.jsx)(r,{icon:C.icon||(S?`ph:squares-four-fill`:`ph:folder-fill`),width:16,height:16,color:D(C.color),className:g(`shrink-0`,!D(C.color)&&(S?`text-primary`:`text-muted-foreground`))}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,title:e.description||void 0,children:e.label||e.name})]}),x&&m||b?(0,k.jsxs)(`div`,{className:`ml-[22px] mt-1.5 space-y-1.5`,children:[b&&u&&d&&(0,k.jsx)(ge,{busy:f,onConfirm:e=>{_(!0),u(p,e)},onCancel:d}),x&&e.children?.map(e=>(0,k.jsx)(_e,{node:e,parentPath:p,query:n,selected:i,onToggle:a,onActivate:o,onRowMenu:s,createParent:l,onCreateConfirm:u,onCreateCancel:d,creating:f},e.id||e.name))]}):null]})}function ve({workspaces:e,loading:t,onPick:n}){return t&&e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):e.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`No workspaces found`}):(0,k.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>{let t=D(e.color);return(0,k.jsxs)(`div`,{onClick:()=>n(e.name),className:`group relative flex cursor-pointer items-center gap-2 rounded-(--card-radius) bg-card px-3 py-2.5 shadow-elevation-1 transition-all hover:bg-accent/50 hover:shadow`,style:{borderRight:`6px solid ${t||`transparent`}`},children:[(0,k.jsx)(r,{icon:e.icon||`ph:stack-fill`,width:18,height:18,color:t,className:g(`shrink-0`,!t&&`text-muted-foreground`)}),(0,k.jsx)(`span`,{className:`flex-1 truncate text-sm font-medium`,children:e.label||e.name}),(0,k.jsx)(c,{className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.id||e.name)})})}function ye({workspaceName:e,treeTab:t,onTreeTabChange:n,selectedDocIds:r,onToggleDoc:i,onNavigate:a,excludeDocumentIds:s}){let[l,u]=(0,O.useState)(`folder`),[d,f]=(0,O.useState)(``),p=d.trim().toLowerCase(),[m,_]=(0,O.useState)(`/`),[y,te]=(0,O.useState)(null),[C,w]=(0,O.useState)(!1),[ne,T]=(0,O.useState)([]),[ie,E]=(0,O.useState)(!1),[D,A]=(0,O.useState)(``),[j,M]=(0,O.useState)(``),[N,P]=(0,O.useState)(t),F=n?t:N,I=e=>{_(`/`),u(`folder`),A(``),M(``),a?.(`/`),n?n(e):P(e)},[L,R]=(0,O.useState)(F);F!==L&&(R(F),_(`/`),u(`folder`)),(0,O.useEffect)(()=>{let e=setTimeout(()=>M(D.trim()),300);return()=>clearTimeout(e)},[D]),(0,O.useEffect)(()=>{let t=!1;async function n(){w(!0);try{let n=await b(e,F);t||te(n)}catch{t||te(null)}finally{t||w(!1)}}return n(),()=>{t=!0}},[e,F]),(0,O.useEffect)(()=>{if(l!==`documents`)return;let t=!1,n=F===`directory`?`directory`:S,r=F===`context`?`context`:`directory`;async function i(){E(!0);try{let i=j?await re(e,m,[],{treeName:n,treeType:r,q:j,limit:G}):await x(e,m,n,{limit:G});t||T(i.payload||[])}catch{t||T([])}finally{t||E(!1)}}return i(),()=>{t=!0}},[e,F,m,l,j]);let z=e=>{_(e),a?.(e)},B=s?.size?ne.filter(e=>!s.has(e.id)):ne;return l===`folder`?(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[!n&&(0,k.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-input p-0.5`,children:[`context`,`directory`].map(e=>(0,k.jsxs)(`button`,{type:`button`,onClick:()=>I(e),className:g(`flex flex-1 items-center justify-center gap-1.5 rounded px-2 py-1 text-xs transition-colors`,F===e?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),title:`Browse the ${fe[e].toLowerCase()}`,children:[de[e],(0,k.jsx)(`span`,{className:`font-mono`,children:e===`directory`?`dir://`:`ctx://`})]},e))}),(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Step 1 of 2 · Pick a folder`}),(0,k.jsxs)(`button`,{type:`button`,onClick:()=>u(`documents`),className:`inline-flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90`,children:[`Next `,(0,k.jsx)(c,{className:`h-3.5 w-3.5`})]})]}),(0,k.jsx)(ue,{items:W(m,e),onNavigate:z,label:`Folder path`}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Filter folders…`,value:d,onChange:e=>f(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-3 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,children:C?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,m===`/`?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:()=>z(`/`),onDoubleClick:()=>{z(`/`),u(`documents`)},title:`/`,children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsx)(`div`,{className:`ml-[22px] space-y-1.5`,children:y?.children?.length?y.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:p,selected:new Set([m]),onToggle:z,onActivate:e=>{z(e),u(`documents`)}},e.id||e.name)):(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})})]})})]}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-muted/30 px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(`button`,{type:`button`,onClick:()=>u(`folder`),className:`inline-flex min-w-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:`Back to folders`,children:[(0,k.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 rotate-180`}),(0,k.jsx)(`span`,{children:`Folders`})]}),(0,k.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-muted-foreground`,children:`Step 2 of 2 · Pick a document`})]}),(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[`[`,F,`]`]}),(0,k.jsx)(ue,{items:W(m,e),onNavigate:z,label:`Document folder path`})]}),(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search documents in this folder…`,value:D,onChange:e=>A(e.target.value),className:`w-full rounded-md border border-input bg-background py-1.5 pl-8 pr-7 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`}),D&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>A(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":`Clear document search`,children:(0,k.jsx)(o,{className:`h-3.5 w-3.5`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto p-3`,children:ie?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading documents…`}):B.length===0?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:j?`No documents match “${j}” here.`:`No documents in this folder.`}):B.map(e=>{let t=v(e),n=r.has(e.id);return(0,k.jsxs)(`div`,{onClick:()=>i(e.id),className:g(`flex min-h-9 items-center gap-2 rounded-md px-3 py-1.5 cursor-pointer transition-all select-none text-sm`,n?`bg-primary/[0.08] hover:bg-primary/[0.12]`:`hover:bg-primary/[0.04]`),children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>i(e.id),className:`shrink-0`,onClick:e=>e.stopPropagation()}),(0,k.jsx)(ae,{document:e,size:3.5}),(0,k.jsx)(`span`,{className:`flex-1 truncate`,children:t.title})]},e.id)})})]})}function be({onClose:e,onConfirm:t,documentCount:n,fixedWorkspaceName:r,excludeWorkspace:i,multiple:a=!0,saving:l=!1,savingContent:d,sizeClassName:f,tabs:m=[`context`,`directory`],initialTab:v,title:x,confirmLabel:C,backendFolderCreation:re,onConfirmRelation:E,relationWorkspaceName:D,relationPredicates:ae,relationExcludeIds:j}){let[N,P]=(0,O.useState)(r?`tree`:`workspace`),[F,I]=(0,O.useState)([]),[L,R]=(0,O.useState)(!r),[z,B]=(0,O.useState)(r??null),oe=v&&m.includes(v)?v:m.includes(`context`)||m.includes(`directory`)?`pins`:m[0]??`context`,[V,H]=(0,O.useState)(oe),se=M(m.includes(`relations`)&&!ae?D??z:null),U=ae??se.predicates,[le,ue]=(0,O.useState)(``),W=U.includes(le)?le:U[0]??``,[pe,he]=(0,O.useState)(`out`),[G,be]=(0,O.useState)(new Set),[xe,Se]=(0,O.useState)(null),[K,Ce]=(0,O.useState)(`context`),[we,Te]=(0,O.useState)(!1),Ee=V===`pins`?K:V;(0,O.useEffect)(()=>{if(!z)return;let e=!1;return y(z).then(t=>{e||Se(t)}).catch(()=>{e||Te(!0)}),()=>{e=!0}},[z]);let q=V===`relations`,[De,Oe]=(0,O.useState)(null),[ke,Ae]=(0,O.useState)(!1),[J,Y]=(0,O.useState)(new Set),[je,Me]=(0,O.useState)(``),Ne=je.trim().toLowerCase(),{showErrorToast:Pe}=ie(),[X,Fe]=(0,O.useState)(null),[Ie,Z]=(0,O.useState)(null),[Q,Le]=(0,O.useState)(!1);T(e,!l&&!Q);let Re=me(`/`,e=>Fe(e)),ze=e=>!l&&(V===`backends`?re?.canCreate(e)===!0:V!==`pins`&&V!==`relations`),Be=async(e,t)=>{let n=t.trim().replace(/^\/+|\/+$/g,``);if(!(!n||!z||Q||!ze(e))){Le(!0);try{let t=`${e===`/`?``:e}/${n}`,r=V===`context`?S:V;V===`backends`?await re.create(e,n):await ne(z,t,!0,r),w(z,r),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:z,treeName:r,cacheInvalidated:!0}}));let i=await b(z,V);Oe(i),Y(e=>a?new Set([...e,t]):new Set([t])),Me(``),Z(null)}catch(e){Pe(e instanceof Error?e.message:`Failed to create folder`)}finally{Le(!1)}}},[Ve,He]=(0,O.useState)(r);r!==Ve&&(He(r),r||R(!0)),(0,O.useEffect)(()=>{r||te().then(e=>I(e.filter(e=>e.id!==i&&e.name!==i))).catch(()=>I([])).finally(()=>R(!1))},[r,i]),(0,O.useEffect)(()=>{if(!z||V===`relations`||V===`pins`)return;let e=!1,t=0;async function n(n=!1){let r=++t;n||Ae(!0);try{let n=await b(z,V);!e&&r===t&&Oe(n)}catch{!e&&r===t&&!n&&Oe(null)}finally{!e&&r===t&&Ae(!1)}}let r=e=>{let t=e.detail;t?.workspaceName&&t.workspaceName!==z||t?.treeName&&t.treeName!==V||(t?.cacheInvalidated||w(z,V),n(!0))};return window.addEventListener(`workspace:tree:refresh`,r),n(),()=>{e=!0,window.removeEventListener(`workspace:tree:refresh`,r)}},[z,V]);let Ue=e=>{e!==z&&(Se(null),Te(!1)),H(oe),B(e),Y(new Set),be(new Set),P(`tree`)},We=e=>{be(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ge=e=>{if(!a){Y(new Set([e]));return}Y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ke=q?!!W&&G.size>0&&!!E:J.size>0,qe=async()=>{if(!(!z||l||!Ke)){if(q){await E?.({predicate:W,direction:pe,targetIds:Array.from(G)},{workspaceName:D??z});return}await t(Array.from(J),{workspaceName:z,treeName:Ee===`context`?S:Ee,treeType:Ee===`context`?`context`:`directory`})}},$=n??1;return l&&d?(0,k.jsx)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,f||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:d}):(0,k.jsxs)(`div`,{className:g(`flex flex-col overflow-hidden rounded-(--panel-radius) border bg-card shadow-elevation-4`,f||`h-viewport-card max-h-full w-[min(380px,90vw)] max-md:h-full max-md:w-full max-md:shadow-elevation-5`),children:[(0,k.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,k.jsx)(p,{className:`h-4 w-4`}),x??(N===`workspace`?`Link to…`:q?`Relate ${$} document${$===1?``:`s`} to…`:`Link ${$} document${$===1?``:`s`} to…`)]}),(0,k.jsx)(`button`,{type:`button`,onClick:e,disabled:l||Q,className:`text-muted-foreground transition-colors hover:text-foreground disabled:opacity-40`,"aria-label":`Close`,children:(0,k.jsx)(o,{className:`h-4 w-4`})})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,k.jsxs)(`div`,{className:`grid h-full w-[200%] grid-cols-2 transition-transform duration-normal`,style:{transform:N===`workspace`?`translateX(0)`:`translateX(-50%)`},children:[(0,k.jsx)(`div`,{className:`flex min-w-0 flex-col overflow-y-auto p-2`,children:(0,k.jsx)(ve,{workspaces:F,loading:L,onPick:Ue})}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-x-auto border-b px-2 pt-2`,children:[!r&&(0,k.jsx)(`button`,{type:`button`,disabled:Q,onClick:()=>P(`workspace`),className:`mr-1 rounded p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground touch-target`,"aria-label":`Back to workspaces`,children:(0,k.jsx)(c,{className:`h-4 w-4 rotate-180`})}),(m.includes(`context`)||m.includes(`directory`))&&(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{H(`pins`),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 border-b-2 px-3 py-2 text-xs`,V===`pins`?`border-primary`:`border-transparent text-muted-foreground`),children:[(0,k.jsx)(s,{className:`h-3.5 w-3.5`}),`Pins`]}),m.map(e=>(0,k.jsxs)(`button`,{type:`button`,disabled:Q,onClick:()=>{H(e),Y(new Set),Z(null)},className:g(`flex shrink-0 items-center gap-1.5 rounded-t-md border-b-2 px-3 py-2 text-xs font-medium transition-colors`,V===e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[de[e],fe[e]]},e))]}),!q&&(0,k.jsx)(`div`,{className:`shrink-0 border-b p-2`,children:(0,k.jsxs)(`div`,{className:`relative`,children:[(0,k.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search paths…`,value:je,onChange:e=>Me(e.target.value),className:`w-full rounded-md border border-input bg-background py-2 pl-9 pr-3 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})]})}),q&&(0,k.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b bg-primary/[0.04] px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`label`,{htmlFor:`relation-predicate`,className:`shrink-0 text-xs text-muted-foreground`,children:`Predicate`}),(0,k.jsx)(`select`,{id:`relation-predicate`,value:W,onChange:e=>ue(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-background px-2 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-ring`,children:U.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]}),(0,k.jsx)(`div`,{className:`flex items-center gap-1`,children:[{dir:`out`,label:`This → picked`,hint:`the ${$===1?`document`:`documents`} you started from ${W} the picked one(s)`},{dir:`in`,label:`Picked → this`,hint:`the picked document(s) ${W} the ${$===1?`one`:`ones`} you started from`}].map(({dir:e,label:t,hint:n})=>(0,k.jsx)(`button`,{type:`button`,title:n,onClick:()=>he(e),className:g(`flex-1 rounded-md border px-2 py-1.5 text-xs transition-colors`,pe===e?`border-primary bg-primary text-primary-foreground`:`border-input hover:bg-accent`),children:t},e))})]}),!q&&a&&(0,k.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-1.5 overflow-x-auto border-b bg-primary/[0.04] px-3`,children:[!J.size&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Selected folders appear here`}),Array.from(J).map(e=>(0,k.jsxs)(`span`,{className:`inline-flex max-w-full shrink-0 items-center gap-1 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground`,children:[(0,k.jsx)(`span`,{className:`truncate`,title:e,children:e}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ge(e),className:`shrink-0 rounded-full hover:bg-primary-foreground/20`,"aria-label":`Remove ${e}`,children:(0,k.jsx)(o,{className:`h-3 w-3`})})]},e))]}),q&&(D??z)&&(0,k.jsx)(ye,{workspaceName:D??z,treeTab:`context`,selectedDocIds:G,onToggleDoc:We,excludeDocumentIds:j}),V===`pins`&&(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3 space-y-2`,children:[!xe&&!we&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading pins…`}),we&&(0,k.jsx)(`p`,{className:`text-xs text-destructive`,children:`Could not load pins. You can still browse the trees.`}),!we&&xe?.length===0&&(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No pinned paths yet. Choose a path from a tree.`}),xe?.filter(e=>e.resolvable!==!1&&m.includes(e.tree===`context`?`context`:e.tree)&&`${e.label??e.name??``} ${e.path}`.toLowerCase().includes(Ne)).map(e=>{let t=e.tree===`context`?`context`:e.tree;return(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":K===t&&J.has(e.path),className:g(`w-full rounded-md border p-3 text-left text-sm hover:bg-muted`,K===t&&J.has(e.path)&&`border-primary bg-primary/10`),onClick:()=>{K===t?Ge(e.path):(Ce(t),Y(new Set([e.path])))},children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(s,{className:`h-3.5 w-3.5`}),e.label||e.name||e.path]}),(0,k.jsxs)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:[t,` · `,e.path]})]},e.id)})]}),(0,k.jsx)(`div`,{className:g(`min-h-0 flex-1 space-y-1.5 overflow-y-auto p-3`,(q||V===`pins`)&&`hidden`),children:ke?(0,k.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground`,children:`Loading…`}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:g(`group relative flex min-h-11 items-center gap-2 rounded-md px-3 py-2.5 cursor-pointer transition-all select-none text-sm shadow-elevation-1 hover:shadow`,`before:absolute before:left-0 before:top-0 before:bottom-0 before:w-1.5 before:transition-colors`,J.has(`/`)?`bg-primary/[0.08] hover:bg-primary/[0.12] before:bg-primary`:`bg-card hover:bg-primary/[0.04] before:bg-transparent`),onClick:Re.guardClick(()=>Ge(`/`)),title:`/`,...ze(`/`)?Re.handlers:{},children:[(0,k.jsx)(ee,{className:`w-4 h-4 shrink-0 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`flex-1 truncate font-medium`,children:`/`})]}),(0,k.jsxs)(`div`,{className:`ml-[22px] space-y-1.5`,children:[Ie===`/`&&(0,k.jsx)(ge,{busy:Q,onConfirm:e=>Be(`/`,e),onCancel:()=>Z(null)}),De?.children?.length?De.children.map(e=>(0,k.jsx)(_e,{node:e,parentPath:`/`,query:Ne,selected:J,onToggle:Ge,onRowMenu:e=>{ze(e.path)&&Fe(e)},createParent:Ie,onCreateConfirm:Be,onCreateCancel:()=>Z(null),creating:Q},e.id||e.name)):Ie===`/`?null:(0,k.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Empty tree`})]})]})})]})]})}),N===`tree`&&(0,k.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t px-4 py-3`,children:[(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q?`${G.size} document${G.size===1?``:`s`} selected`:`${J.size} path${J.size===1?``:`s`} selected`}),(0,k.jsx)(_,{size:`sm`,onClick:qe,disabled:!Ke||l||Q,children:l?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{className:`mr-1.5 h-3.5 w-3.5`}),q?`Relating…`:`Linking…`]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(p,{className:`mr-1 h-3.5 w-3.5`}),q?`Relate`:C??`Link`]})})]}),X&&(0,k.jsx)(ce,{anchor:{x:X.clientX,y:X.clientY},onClose:()=>Fe(null),items:[{id:`new-folder`,label:`New folder in ${X.path}`,icon:u,run:()=>Z(X.path)}]})]})}export{A as _,fe as a,le as c,I as d,B as f,M as g,N as h,de as i,V as l,L as m,ye as n,W as o,R as p,ve as r,ue as s,be as t,z as u};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{l as r,u as i}from"./code-editor-BOIngd5F.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,F as d,G as f,H as p,I as m,J as h,K as g,L as _,M as v,N as y,O as b,P as ee,Q as x,R as S,S as te,T as ne,U as C,V as re,W as ie,X as w,Y as T,Z as ae,_ as oe,at as se,b as ce,c as le,d as E,et as ue,f as de,g as fe,h as pe,it as me,j as he,k as ge,l as _e,m as D,nt as ve,ot as O,p as k,q as ye,rt as A,tt as be,v as xe,w as Se,x as Ce,y as we,z as Te}from"./react-BHzhHVTZ.js";import{Dn as Ee,Dr as De,Ln as Oe,Rn as ke,Yt as Ae,_n as je,et as Me,gn as Ne,mn as Pe,ri as Fe}from"./ui-76Hw0NU_.js";import{t as Ie}from"./utils-2pl1SbIp.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./punycode.es6-ZbLrB_Dn.js";import{t as Ue}from"./use-theme-DaxpiICf.js";var We=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ge=e(i(),1),Ke=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},qe=/^\s*>\s$/,Je=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return We(`blockquote`,{...S(this.options.HTMLAttributes,e),children:We(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
1
+ import{o as e,r as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{l as r,u as i}from"./code-editor-BOIngd5F.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,F as d,G as f,H as p,I as m,J as h,K as g,L as _,M as v,N as y,O as b,P as ee,Q as x,R as S,S as te,T as ne,U as C,V as re,W as ie,X as w,Y as T,Z as ae,_ as oe,at as se,b as ce,c as le,d as E,et as ue,f as de,g as fe,h as pe,it as me,j as he,k as ge,l as _e,m as D,nt as ve,ot as O,p as k,q as ye,rt as A,tt as be,v as xe,w as Se,x as Ce,y as we,z as Te}from"./react-BHzhHVTZ.js";import{Dn as Ee,Dr as De,Ln as Oe,Rn as ke,Yt as Ae,_n as je,et as Me,gn as Ne,ii as Pe,mn as Fe}from"./ui-CDoK3F3U.js";import{t as Ie}from"./utils-2pl1SbIp.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,t as He}from"./punycode.es6-ZbLrB_Dn.js";import{t as Ue}from"./use-theme-DaxpiICf.js";var We=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},Ge=e(i(),1),Ke=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new O(n,0,0);return e.replace(l,i.after(),r),e.setSelection(x.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},qe=/^\s*>\s$/,Je=D.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return We(`blockquote`,{...S(this.options.HTMLAttributes,e),children:We(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(`
2
2
  `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
3
3
  `))}),n.join(`
4
4
  >
@@ -88,6 +88,6 @@ ${t.innerHTML}
88
88
  `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let r=e.split(`
89
89
  `),[i,a]=vp(r);if(i.length===0)return;let o=xp(i,i[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,typeMarker:i[0]?.type,items:o,raw:r.slice(0,a).join(`
90
90
  `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Cp,this.editor.getAttributes(wp)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new h({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=bp(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=C({find:Tp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=C({find:Tp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(wp)}),joinPredicate:e,editor:this.editor})),[t]}}),Op=/^\s*(\[([( |x])?\])\s$/,kp=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,Ap=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},jp=D.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,S(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>{let n=`- [${e.attrs?.checked?`x`:` `}] `;return re(e,t,n)},addExtensions(){return this.options.nested?[If(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),s=document.createElement(`span`),c=document.createElement(`input`),l=document.createElement(`div`);s.style.cssText=kp;let u=e=>{let t=Ap(e,e.attrs.checked,this.options.a11y);c.setAttribute(`aria-label`,t),s.textContent=t};u(e),a.contentEditable=`false`,c.type=`checkbox`,c.addEventListener(`mousedown`,e=>e.preventDefault()),c.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,c.checked=e.attrs.checked,a.append(c,s),i.append(a,l),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let d=new Set(Object.keys(t));return{dom:i,contentDOM:l,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,c.checked=e.attrs.checked,u(e);let t=r.extensionManager.attributes,n=o(e,t),a=new Set(Object.keys(n)),s=this.options.HTMLAttributes;return d.forEach(e=>{a.has(e)||(e in s?i.setAttribute(e,s[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in s?i.setAttribute(e,s[e]):i.removeAttribute(e):i.setAttribute(e,t)}),d=a,!0}}}},addInputRules(){return[C({find:Op,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Mp=D.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,S(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
91
- `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=s(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=s(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});E.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Mf.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(tp.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(up.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Dp.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(jp.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Mp.configure(this.options.taskList)),e}});function Np(e){return e.storage.markdown?.getMarkdown()??``}var $=r(),Pp=`canvas.ui.markdown.theme`;function Fp(){try{let e=localStorage.getItem(Pp);return e===`light`||e===`dark`?e:null}catch{return null}}function Ip({active:e,onClick:t,title:n,children:r}){return(0,$.jsx)(`button`,{type:`button`,title:n,"aria-label":n,onClick:t,className:Ie(`flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,e&&`bg-muted text-foreground`),children:r})}function Lp({editor:e,scheme:t,toggleScheme:n}){return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-input px-1 py-1`,children:[(0,$.jsx)(Ip,{title:`Bold`,active:e.isActive(`bold`),onClick:()=>e.chain().focus().toggleBold().run(),children:(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Italic`,active:e.isActive(`italic`),onClick:()=>e.chain().focus().toggleItalic().run(),children:(0,$.jsx)(Ee,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Code`,active:e.isActive(`code`),onClick:()=>e.chain().focus().toggleCode().run(),children:(0,$.jsx)(De,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Heading 1`,active:e.isActive(`heading`,{level:1}),onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),children:(0,$.jsx)(ke,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Heading 2`,active:e.isActive(`heading`,{level:2}),onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Bullet list`,active:e.isActive(`bulletList`),onClick:()=>e.chain().focus().toggleBulletList().run(),children:(0,$.jsx)(Pe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Numbered list`,active:e.isActive(`orderedList`),onClick:()=>e.chain().focus().toggleOrderedList().run(),children:(0,$.jsx)(Ne,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Link`,active:e.isActive(`link`),onClick:()=>{let t=e.getAttributes(`link`).href,n=window.prompt(`Link URL`,t??`https://`);if(n!==null){if(n===``){e.chain().focus().extendMarkRange(`link`).unsetLink().run();return}e.chain().focus().extendMarkRange(`link`).setLink({href:n}).run()}},children:(0,$.jsx)(je,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(Ip,{title:`Switch editor to ${t===`dark`?`light`:`dark`} theme`,onClick:n,children:t===`dark`?(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})}function Rp({value:e,onChange:t,placeholder:n,fill:r=!1,format:i=`markdown`,editable:a=!0}){let o=e=>i===`html`?e.getHTML():Np(e),{resolvedScheme:s}=Ue(),[c,l]=(0,Ge.useState)(Fp),u=c??s,d=()=>{let e=u===`dark`?`light`:`dark`;l(e);try{localStorage.setItem(Pp,e)}catch{}},f=_e({extensions:[ao.configure({link:{openOnClick:!1,autolink:!0}}),Of.configure({table:{resizable:!1}}),Mp,jp.configure({nested:!0}),yu.configure({html:i===`html`,transformPastedText:!0})],content:e,editorProps:{attributes:{class:`canvas-no-drag markdown-body md-editor-content min-h-[8rem] px-3 py-2 text-sm outline-none`,"data-placeholder":n??``}},onUpdate:({editor:e})=>{t(o(e),e.getText({blockSeparator:`
91
+ `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=s(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=s(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});E.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Mf.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(tp.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(up.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Dp.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(jp.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Mp.configure(this.options.taskList)),e}});function Np(e){return e.storage.markdown?.getMarkdown()??``}var $=r(),Pp=`canvas.ui.markdown.theme`;function Fp(){try{let e=localStorage.getItem(Pp);return e===`light`||e===`dark`?e:null}catch{return null}}function Ip({active:e,onClick:t,title:n,children:r}){return(0,$.jsx)(`button`,{type:`button`,title:n,"aria-label":n,onClick:t,className:Ie(`flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground`,e&&`bg-muted text-foreground`),children:r})}function Lp({editor:e,scheme:t,toggleScheme:n}){return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-0.5 border-b border-input px-1 py-1`,children:[(0,$.jsx)(Ip,{title:`Bold`,active:e.isActive(`bold`),onClick:()=>e.chain().focus().toggleBold().run(),children:(0,$.jsx)(Pe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Italic`,active:e.isActive(`italic`),onClick:()=>e.chain().focus().toggleItalic().run(),children:(0,$.jsx)(Ee,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Code`,active:e.isActive(`code`),onClick:()=>e.chain().focus().toggleCode().run(),children:(0,$.jsx)(De,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Heading 1`,active:e.isActive(`heading`,{level:1}),onClick:()=>e.chain().focus().toggleHeading({level:1}).run(),children:(0,$.jsx)(ke,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Heading 2`,active:e.isActive(`heading`,{level:2}),onClick:()=>e.chain().focus().toggleHeading({level:2}).run(),children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Bullet list`,active:e.isActive(`bulletList`),onClick:()=>e.chain().focus().toggleBulletList().run(),children:(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(Ip,{title:`Numbered list`,active:e.isActive(`orderedList`),onClick:()=>e.chain().focus().toggleOrderedList().run(),children:(0,$.jsx)(Ne,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`mx-1 h-4 w-px bg-input`}),(0,$.jsx)(Ip,{title:`Link`,active:e.isActive(`link`),onClick:()=>{let t=e.getAttributes(`link`).href,n=window.prompt(`Link URL`,t??`https://`);if(n!==null){if(n===``){e.chain().focus().extendMarkRange(`link`).unsetLink().run();return}e.chain().focus().extendMarkRange(`link`).setLink({href:n}).run()}},children:(0,$.jsx)(je,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:`flex-1`}),(0,$.jsx)(Ip,{title:`Switch editor to ${t===`dark`?`light`:`dark`} theme`,onClick:n,children:t===`dark`?(0,$.jsx)(Me,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})}function Rp({value:e,onChange:t,placeholder:n,fill:r=!1,format:i=`markdown`,editable:a=!0}){let o=e=>i===`html`?e.getHTML():Np(e),{resolvedScheme:s}=Ue(),[c,l]=(0,Ge.useState)(Fp),u=c??s,d=()=>{let e=u===`dark`?`light`:`dark`;l(e);try{localStorage.setItem(Pp,e)}catch{}},f=_e({extensions:[ao.configure({link:{openOnClick:!1,autolink:!0}}),Of.configure({table:{resizable:!1}}),Mp,jp.configure({nested:!0}),yu.configure({html:i===`html`,transformPastedText:!0})],content:e,editorProps:{attributes:{class:`canvas-no-drag markdown-body md-editor-content min-h-[8rem] px-3 py-2 text-sm outline-none`,"data-placeholder":n??``}},onUpdate:({editor:e})=>{t(o(e),e.getText({blockSeparator:`
92
92
 
93
93
  `}))}});return(0,Ge.useEffect)(()=>{!f||f.isDestroyed||e!==o(f)&&!(i===`html`&&!e&&f.isEmpty)&&f.commands.setContent(e||``,{emitUpdate:!1})},[e,f]),(0,Ge.useEffect)(()=>{f&&!f.isDestroyed&&f.isEditable!==a&&f.setEditable(a)},[f,a]),f?(0,$.jsxs)(`div`,{"data-scheme":u,className:Ie(`md-editor rounded-md border border-input bg-background text-foreground focus-within:ring-1 focus-within:ring-ring`,r&&`flex h-full min-h-0 flex-col`),children:[(0,$.jsx)(Lp,{editor:f,scheme:u,toggleScheme:d}),(0,$.jsx)(`div`,{className:Ie(`overflow-y-auto flex flex-col [&>div]:flex-1 [&_.ProseMirror]:h-full`,r?`min-h-0 flex-1`:`resize-y min-h-[8rem] max-h-[70vh]`),onClick:()=>f.chain().focus().run(),children:(0,$.jsx)(le,{editor:f})})]}):null}export{Rp as MarkdownEditor};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-Bum-POPT.js";import{t as i}from"./input-BOtCd4HP.js";import{c as a,t as o}from"./api-CA6WiiYM.js";import{t as s}from"./markdown-it-DRESbtwK.js";import{t as c}from"./lazy-editor-Bdm5JEXv.js";var l=t();function u({tabs:e,active:t,onChange:n,className:r=``,iconOnly:i=!1}){return(0,l.jsx)(`div`,{className:`flex gap-1 border-b overflow-x-auto ${r}`,children:e.map(e=>{let r=e.icon;return(0,l.jsxs)(`button`,{onClick:()=>n(e.id),title:e.label,className:`${i&&r?`px-3`:`px-4`} py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap inline-flex items-center gap-1.5 ${t===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[r&&(0,l.jsx)(r,{className:`h-3.5 w-3.5`}),(!i||!r)&&e.label]},e.id)})})}var d=e(n(),1),f=e=>`${a.workspaces}/${encodeURIComponent(e)}/messages`,p=e=>o.get(`${f(e)}/accounts`),m=(e,t)=>o.get(`${f(e)}/reply-target/${t}`),h=(e,t)=>o.post(`${f(e)}/send`,t),g=(e,t)=>o.get(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),_=(e,t)=>o.get(`${f(e)}/outbox/${encodeURIComponent(t)}`),v=(e,t)=>o.delete(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),y=(e,t)=>o.get(`${f(e)}/thread/${t}`),b=new s({html:!1});function x(e){let t=e=>{let n=[];return e.map(e=>{if(e.children)return t(e.children);switch(e.type){case`strong_open`:case`strong_close`:return`*`;case`em_open`:case`em_close`:return`_`;case`s_open`:case`s_close`:return`~`;case`code_inline`:return`\`${e.content}\``;case`fence`:case`code_block`:return`\`\`\`\n${e.content}\`\`\`\n`;case`text`:return e.content;case`softbreak`:case`hardbreak`:return`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-SeUZ_Pvi.js";import{t as i}from"./input-BOtCd4HP.js";import{c as a,t as o}from"./api-CA6WiiYM.js";import{t as s}from"./markdown-it-DRESbtwK.js";import{t as c}from"./lazy-editor-BUFAkTGl.js";var l=t();function u({tabs:e,active:t,onChange:n,className:r=``,iconOnly:i=!1}){return(0,l.jsx)(`div`,{className:`flex gap-1 border-b overflow-x-auto ${r}`,children:e.map(e=>{let r=e.icon;return(0,l.jsxs)(`button`,{onClick:()=>n(e.id),title:e.label,className:`${i&&r?`px-3`:`px-4`} py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap inline-flex items-center gap-1.5 ${t===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[r&&(0,l.jsx)(r,{className:`h-3.5 w-3.5`}),(!i||!r)&&e.label]},e.id)})})}var d=e(n(),1),f=e=>`${a.workspaces}/${encodeURIComponent(e)}/messages`,p=e=>o.get(`${f(e)}/accounts`),m=(e,t)=>o.get(`${f(e)}/reply-target/${t}`),h=(e,t)=>o.post(`${f(e)}/send`,t),g=(e,t)=>o.get(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),_=(e,t)=>o.get(`${f(e)}/outbox/${encodeURIComponent(t)}`),v=(e,t)=>o.delete(`${f(e)}/whatsapp/${encodeURIComponent(t)}/connection`),y=(e,t)=>o.get(`${f(e)}/thread/${t}`),b=new s({html:!1});function x(e){let t=e=>{let n=[];return e.map(e=>{if(e.children)return t(e.children);switch(e.type){case`strong_open`:case`strong_close`:return`*`;case`em_open`:case`em_close`:return`_`;case`s_open`:case`s_close`:return`~`;case`code_inline`:return`\`${e.content}\``;case`fence`:case`code_block`:return`\`\`\`\n${e.content}\`\`\`\n`;case`text`:return e.content;case`softbreak`:case`hardbreak`:return`
2
2
  `;case`paragraph_close`:case`heading_close`:return`
3
3
 
4
4
  `;case`list_item_open`:return`- `;case`link_open`:return n.push(String(e.attrGet(`href`)||``)),``;case`link_close`:return` (${n.pop()||``})`;case`image`:return e.content;default:return``}}).join(``)};return t(b.parse(e,{})).trim()}function S(e,t,n=!1){let r=2166136261;try{for(let e of localStorage.getItem(`authToken`)||``)r=Math.imul(r^e.charCodeAt(0),16777619)}catch{}return`canvas:message-draft:${r>>>0}:${e}:${t||`new`}${n?`:fwd`:``}`}var C={reply:`Reply`,replyAll:`Reply all`,forward:`Forward`};function w({workspaceId:e,replyToDocumentId:t,mode:n=`reply`,originalSubject:a,initialAccount:o,testEmail:s=!1,onClose:u}){let f=!!t&&n===`forward`,g=s?`${S(e)}:smtp-test:${o?.address}`:S(e,t,f),v=()=>({requestId:crypto.randomUUID(),text:s?`This is a test email sent from Canvas to check the SMTP configuration.`:``,replyToDocumentId:t,...o,...s?{subject:`Canvas SMTP test`}:{},...f?{forward:!0}:t?{replyAll:n===`replyAll`,quote:!0}:{}}),[y,b]=(0,d.useState)(()=>{try{let e=localStorage.getItem(g);if(e){let r=JSON.parse(e),i=r.draft||r;if(f||!t||r.attempted)return i;let a=n===`replyAll`;return{...i,replyAll:a,...!!i.replyAll===a?{}:{to:void 0,cc:void 0}}}}catch{}return v()}),[w,T]=(0,d.useState)(null),[E,D]=(0,d.useState)([]),[O,k]=(0,d.useState)(navigator.onLine);(0,d.useEffect)(()=>{let e=()=>k(navigator.onLine);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]);let A=(0,d.useRef)(!1),[j,M]=(0,d.useState)(!1),[N,P]=(0,d.useState)(!1),[F,I]=(0,d.useState)(()=>{try{return JSON.parse(localStorage.getItem(g)||`{}`).attempted===!0}catch{return!1}}),[L,R]=(0,d.useState)(``),[z,B]=(0,d.useState)(null);(0,d.useEffect)(()=>{let n=!0;return Promise.all([p(e),t?m(e,t):Promise.resolve(null)]).then(([e,r])=>{n&&(T(r),D(e.filter(e=>e.canSend&&(!r||e.driver===r.driver&&e.address===r.address))),t&&!r&&R(`This message has no supported reply account.`),r&&b(e=>{let t=e.replyAll?r.allRecipients:r.recipients;return{...e,driver:r.driver,address:r.address,...!f&&t&&!F?{to:e.to?.some(e=>e.trim())?e.to:t.to,cc:e.cc?.some(e=>e.trim())?e.cc:t.cc}:{}}}))}).catch(e=>{n&&R(e.message)}),()=>{n=!1}},[e,t,f,F]),(0,d.useEffect)(()=>{try{z?.status===`accepted`?localStorage.removeItem(g):localStorage.setItem(g,JSON.stringify({draft:y,attempted:F}))}catch{}},[g,y,F,z]);let V=E.find(e=>e.driver===y.driver&&e.address===y.address),H=V?.driver===`imap`,U=V?.driver===`whatsapp`,W=!!y.images?.length,G=!!y.text.trim(),K=e=>b(t=>({...t,...e})),q=async()=>{P(!0),R(``),I(!0);let t=H?G?y:{...y,html:void 0}:{...y,text:U?x(y.text):y.text,html:void 0,quote:void 0,forward:void 0};try{let n=F?await _(e,y.requestId).catch(n=>{if(n.statusCode===404)return h(e,t);throw n}):await h(e,t);if(B(n),n.status===`accepted`){try{localStorage.removeItem(g)}catch{}window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e}}))}}catch(e){let t=e;R(t.message),!F&&t.statusCode&&t.statusCode>=400&&t.statusCode<500&&t.statusCode!==409&&I(!1)}finally{P(!1)}},J=async e=>{if(X||A.current)return;let t=e.filter(e=>[`image/png`,`image/jpeg`,`image/webp`,`image/gif`].includes(e.type));if(t.length){if((y.images?.length||0)+t.length>(U?1:8)){R(U?`One picture per WhatsApp reply.`:`Up to 8 pictures per email.`);return}if((y.images||[]).reduce((e,t)=>e+t.base64.length*3/4,0)+t.reduce((e,t)=>e+t.size,0)>8388608){R(`Pictures must total at most 8 MB.`);return}A.current=!0,M(!0);try{let e=await Promise.all(t.map(e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(Error(`Could not read picture`)),r.onload=()=>t({name:e.name,mimeType:e.type,base64:String(r.result).split(`,`)[1]}),r.readAsDataURL(e)})));b(t=>({...t,images:[...t.images||[],...e]})),R(``)}catch(e){R(e instanceof Error?e.message:`Could not read picture`)}finally{A.current=!1,M(!1)}}},Y=y.replyAll?w?.allRecipients:w?.recipients,X=N||F||j,Z=s?`Send test email`:t?f?C.forward:C[y.replyAll?`replyAll`:`reply`]:`New message`,Q=t&&a?`${f?`Fwd`:`Re`}: ${a.replace(f?/^(fwd?|fw):\s*/i:/^re:\s*/i,``)}`:``;return(0,l.jsxs)(`section`,{onPasteCapture:e=>{if(!(H||U))return;let t=Array.from(e.clipboardData.files);t.some(e=>e.type.startsWith(`image/`))&&(e.preventDefault(),e.stopPropagation(),J(t))},className:`max-h-[70dvh] overflow-y-auto rounded-md border bg-card p-3 space-y-3`,"aria-label":t?`${Z} to message`:`New message`,children:[(0,l.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,l.jsx)(`strong`,{className:`text-sm`,children:Z}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,onClick:u,children:`Close`})]}),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Send from`,(0,l.jsxs)(`select`,{"aria-label":`Sending account`,className:`w-full rounded border bg-background p-2`,value:V?`${V.driver}:${V.address}`:``,disabled:X||!!t||!!o,onChange:e=>{let t=E.find(t=>`${t.driver}:${t.address}`===e.target.value);t&&K({driver:t.driver,address:t.address,to:[],cc:[],bcc:[],subject:void 0,target:void 0,images:void 0,replyAll:!1})},children:[(0,l.jsx)(`option`,{value:``,children:`Select an enabled sending account`}),E.map(e=>(0,l.jsxs)(`option`,{value:`${e.driver}:${e.address}`,children:[e.driver,` · `,e.from||e.address]},`${e.driver}:${e.address}`))]})]}),s&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Uses the saved SMTP settings. Enter a recipient you control, then click Send. This sends a real email; provider acceptance does not guarantee inbox delivery.`}),!E.length&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable sending in the account’s workspace settings. Your draft stays on this device.`}),H?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`To `,t&&!f?`(leave blank to reply to the sender)`:``,(0,l.jsx)(i,{"aria-label":`To`,disabled:X,value:y.to?.join(`, `)||``,onChange:e=>K({to:[e.target.value]})})]}),t&&!f&&!y.to?.some(e=>e.trim())&&Y&&(0,l.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Reply to: `,Y.to.join(`, `),Y.cc.length?` · Cc: ${Y.cc.join(`, `)}`:``]}),[`cc`,`bcc`].map(e=>(0,l.jsxs)(`label`,{className:`block text-xs`,children:[e===`cc`?`Cc`:`Bcc`,(0,l.jsx)(i,{"aria-label":e===`cc`?`Cc`:`Bcc`,disabled:X,value:y[e]?.join(`, `)||``,onChange:t=>K({[e]:[t.target.value]})})]},e)),(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Subject`,(0,l.jsx)(i,{"aria-label":`Subject`,disabled:X,value:y.subject||``,placeholder:Q,onChange:e=>K({subject:e.target.value||void 0})})]}),t&&!f&&(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-xs`,children:[(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.replyAll||!1,onChange:e=>{let t=e.target.checked?w?.allRecipients:w?.recipients;K({replyAll:e.target.checked,...t?{to:t.to,cc:t.cc}:{}})}}),`Reply all`]}),(0,l.jsxs)(`label`,{className:`flex gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,disabled:X,checked:y.quote||!1,onChange:e=>K({quote:e.target.checked})}),`Quote original message`]})]}),f&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The original message and its attachments are included below your note.`}),(0,l.jsx)(c,{format:`html`,editable:!X,value:y.html||``,placeholder:f?`Add a note (optional)…`:`Write a message…`,onChange:(e,t)=>K({html:e,text:t.slice(0,32e3)})})]}):(0,l.jsxs)(l.Fragment,{children:[!t&&(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Conversation (configured channel name or ID)`,(0,l.jsx)(i,{"aria-label":`Conversation`,disabled:X,value:y.target||``,onChange:e=>K({target:e.target.value})})]}),U?(0,l.jsx)(c,{format:`markdown`,editable:!X,value:y.text,placeholder:`Write a message…`,onChange:e=>K({text:e.slice(0,32e3)})}):(0,l.jsx)(`textarea`,{"aria-label":`Message text`,className:`w-full rounded border bg-background p-2 text-sm`,rows:5,maxLength:32e3,disabled:X,value:y.text,onChange:e=>K({text:e.target.value}),placeholder:`Write a message…`})]}),(H||U)&&(0,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.jsxs)(`label`,{className:`block text-xs`,children:[`Paste a picture into the reply, or attach one`,(0,l.jsx)(`input`,{"aria-label":`Attach pictures`,className:`block`,type:`file`,accept:`image/png,image/jpeg,image/webp,image/gif`,multiple:!U,disabled:X,onChange:e=>{J(Array.from(e.target.files||[])),e.target.value=``}})]}),y.images?.map((e,t)=>(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`img`,{className:`h-20 w-20 rounded object-contain`,src:`data:${e.mimeType};base64,${e.base64}`,alt:e.name}),(0,l.jsx)(`span`,{className:`text-xs`,children:e.name}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:X,onClick:()=>K({images:y.images?.filter((e,n)=>n!==t)}),children:`Remove picture`})]},t)),U&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Bold, italic, strikethrough and code are supported. Your reply becomes the picture caption.`})]}),L&&(0,l.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:L}),z&&(0,l.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[z.status===`accepted`?`Accepted by the provider.`:z.message,` `,z.warnings?.join(` `),` `,z.rejected?.length?`Not accepted for: ${z.rejected.join(`, `)}`:``]}),z?.status!==`accepted`&&(0,l.jsx)(r,{size:`sm`,disabled:N||j||!F&&(!V||!G&&!W&&!(H&&f)||f&&!y.to?.some(e=>e.trim()))||!O,onClick:()=>void q(),children:N?`Sending…`:F?`Check send status`:`Send`}),(0,l.jsx)(r,{size:`sm`,variant:`ghost`,disabled:N,onClick:()=>{window.confirm(F?`This message may already have been sent. Discard this draft only after checking the conversation.`:`Discard this draft?`)&&(b({...v(),driver:y.driver,address:y.address}),I(!1),B(null),R(``))},children:`Discard draft`}),F&&z?.status!==`accepted`&&(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Do not start another send until you have checked the conversation. The same request will not be delivered twice by Canvas.`})]})}function T(e){let t=(0,d.useRef)(null),n=(0,d.useRef)(e.onClose);return(0,d.useEffect)(()=>{n.current=e.onClose}),(0,d.useEffect)(()=>{let e=t.current;if(!e)return;let n=document.activeElement;return e.showModal(),()=>{e.close(),n?.focus()}},[]),(0,l.jsx)(`dialog`,{ref:t,"aria-label":e.replyToDocumentId?`${e.mode===`forward`?`Forward`:e.mode===`replyAll`?`Reply all`:`Reply`} message`:`Send test email`,className:`m-auto w-[calc(100%-2rem)] max-w-3xl max-h-[90dvh] overflow-y-auto rounded-(--panel-radius) border bg-card p-0 text-foreground shadow-elevation-4 backdrop:bg-black/40`,onKeyDown:e=>e.stopPropagation(),onCancel:e=>{e.preventDefault(),e.stopPropagation(),n.current()},children:(0,l.jsx)(w,{...e})})}export{g as a,p as i,w as n,v as o,y as r,u as s,T 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{Nt as r}from"./workspace-46EFyEKZ.js";var i=e(n(),1),a=t(),o=[`Inbox sweep`,`Canvas edge notes`,`Release 2.7`];function s(){let[e,t]=(0,i.useState)(`none`),[n,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{e===`workspaces`&&n===null&&r().then(s).catch(()=>s([]))},[e,n]);let c=e=>t(t=>t===e?`none`:e);return(0,a.jsxs)(`div`,{className:`next-shell`,children:[(0,a.jsx)(`div`,{className:`next-wallpaper`,"aria-hidden":!0,children:(0,a.jsx)(`i`,{})}),(0,a.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 select-none`,children:[(0,a.jsx)(`p`,{className:`text-2xl font-light tracking-wide text-white/80`,children:`Canvas`}),(0,a.jsx)(`p`,{className:`text-sm text-white/40`,children:`say something, or tap the orb. Swipe up for canvases (soon)`})]}),e===`tasks`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 left-6 w-64 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Pinned`}),(0,a.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:e},e))})]}),e===`workspaces`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 right-6 w-72 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Workspaces`}),(0,a.jsxs)(`div`,{className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:[n===null&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`Loading…`}),n?.map(e=>(0,a.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:[(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color||`rgb(255 255 255 / 0.35)`}}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.id)),n?.length===0&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`No workspaces`})]})]}),(0,a.jsxs)(`div`,{className:`absolute bottom-6 right-6 flex items-center gap-3`,children:[e!==`none`&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(e===`tasks`?`workspaces`:`tasks`),className:`next-glass rounded-full px-4 py-2 text-xs text-white/70`,children:e===`tasks`?`workspaces`:`pinned`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(`tasks`),"aria-label":`Toolbox`,className:`next-orb flex h-14 w-14 items-center justify-center rounded-full`,children:(0,a.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white/85`})})]})]})}export{s 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{Nt as r}from"./workspace-BJELPCNs.js";var i=e(n(),1),a=t(),o=[`Inbox sweep`,`Canvas edge notes`,`Release 2.7`];function s(){let[e,t]=(0,i.useState)(`none`),[n,s]=(0,i.useState)(null);(0,i.useEffect)(()=>{e===`workspaces`&&n===null&&r().then(s).catch(()=>s([]))},[e,n]);let c=e=>t(t=>t===e?`none`:e);return(0,a.jsxs)(`div`,{className:`next-shell`,children:[(0,a.jsx)(`div`,{className:`next-wallpaper`,"aria-hidden":!0,children:(0,a.jsx)(`i`,{})}),(0,a.jsxs)(`div`,{className:`relative flex h-full flex-col items-center justify-center gap-3 select-none`,children:[(0,a.jsx)(`p`,{className:`text-2xl font-light tracking-wide text-white/80`,children:`Canvas`}),(0,a.jsx)(`p`,{className:`text-sm text-white/40`,children:`say something, or tap the orb. Swipe up for canvases (soon)`})]}),e===`tasks`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 left-6 w-64 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Pinned`}),(0,a.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:e},e))})]}),e===`workspaces`&&(0,a.jsxs)(`div`,{className:`next-glass absolute bottom-24 right-6 w-72 rounded-2xl p-3`,children:[(0,a.jsx)(`p`,{className:`px-2 pb-2 text-[11px] uppercase tracking-widest text-white/40`,children:`Workspaces`}),(0,a.jsxs)(`div`,{className:`flex max-h-80 flex-col gap-1 overflow-y-auto`,children:[n===null&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`Loading…`}),n?.map(e=>(0,a.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-white/85 transition-colors hover:bg-white/10`,children:[(0,a.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:e.color||`rgb(255 255 255 / 0.35)`}}),(0,a.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.id)),n?.length===0&&(0,a.jsx)(`p`,{className:`px-3 py-2 text-sm text-white/50`,children:`No workspaces`})]})]}),(0,a.jsxs)(`div`,{className:`absolute bottom-6 right-6 flex items-center gap-3`,children:[e!==`none`&&(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(e===`tasks`?`workspaces`:`tasks`),className:`next-glass rounded-full px-4 py-2 text-xs text-white/70`,children:e===`tasks`?`workspaces`:`pinned`}),(0,a.jsx)(`button`,{type:`button`,onClick:()=>c(`tasks`),"aria-label":`Toolbox`,className:`next-orb flex h-14 w-14 items-center justify-center rounded-full`,children:(0,a.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white/85`})})]})]})}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{L as r,Pt as i,ci as a,mi as o,pn as s,yt as c}from"./ui-76Hw0NU_.js";import{t as l}from"./utils-2pl1SbIp.js";import{Bn as u}from"./workspace-46EFyEKZ.js";import{t as d}from"./useAddTarget-D4ra50Am.js";import{t as f}from"./note-save-status-DPz4VzL6.js";import{t as p}from"./useEditNoteFields-CKYMBf8V.js";import{n as m}from"./use-applet-target-DmIdCxa_.js";import{k as h}from"./index-CJapDuPp.js";import{n as g,r as _,t as v}from"./shared-C-uHNNY8.js";import{n as y,r as b}from"./use-applet-docs-DBshA7yq.js";var x=e(n(),1),S=t();function C({doc:e,updateWorkspace:t,registerEl:n,registerBody:r,highlighted:i,onLinkTo:a,onDelete:o}){let s=p(e,t||``,!!t),{title:c,content:u,setTitle:d,setContent:m}=s,h=()=>{s.save().catch(()=>{})};return(0,S.jsxs)(`div`,{ref:t=>n(e.id,t),className:l(`group border-t border-border/60 px-4 py-3 transition-colors`,i&&`bg-primary/5`),children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,S.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[y(e.createdAt),` · #`,e.id]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[(0,S.jsx)(f,{...s,onRetry:s.save}),(0,S.jsx)(g,{onLinkTo:a,onDelete:o})]})]}),(0,S.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),onBlur:h,placeholder:`Untitled`,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:u,onChange:m,onBlur:h,innerRef:t=>r(e.id,t)})]})}function w({target:e,onCreated:t,onCancel:n}){let i=h(e,void 0,`applet`),{title:a,content:o,setTitle:s,setContent:c,saving:l}=i,[u,d]=(0,x.useState)(null),p=async()=>{try{await i.save(e),i.finish(),t()}catch(e){d(e instanceof Error?e.message:`Failed to save note`)}};return(0,S.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New note`}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close note`,children:(0,S.jsx)(r,{className:`h-3 w-3`})})]}),(0,S.jsx)(`input`,{value:a,onChange:e=>s(e.target.value),placeholder:`Untitled`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:o,onChange:c,placeholder:`Write your note…`}),(0,S.jsx)(f,{...i,onRetry:i.retry}),u&&(0,S.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:u}),(0,S.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:p,disabled:!o.trim()||l,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:l?`Saving…`:`Done`})})]})}function T({autoAdd:e=!1}){let t=m(),{docs:n,loading:r,error:l,scope:f,reload:p,removeDoc:h}=b(t,u),[g,v]=(0,x.useState)(``),[y,T]=(0,x.useState)(0),[E,D]=(0,x.useState)(`desc`),[O,k]=(0,x.useState)(e),[A,j]=(0,x.useState)(null),M=(0,x.useRef)(new Map),N=(0,x.useRef)(new Map),P=(0,x.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),F=(0,x.useCallback)((e,t)=>{t?N.current.set(e,t):N.current.delete(e)},[]),I=(0,x.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete note ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await h(e.id)}catch{}},[h]),L=(0,x.useMemo)(()=>{let e=[...n];return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return E===`asc`?n:-n}),e},[n,E]),R=(0,x.useMemo)(()=>{let e=g.trim().toLowerCase();if(!e)return[];let t=[];for(let n of L){let r=String(n.data?.content??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[g,L]),z=R.length?R[Math.min(y,R.length-1)]:null;(0,x.useEffect)(()=>{z&&M.current.get(z.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[z]);let B=(0,x.useCallback)(e=>{if(!R.length)return;let t=e?(y+1)%R.length:y;e&&T(t);let n=R[t],r=N.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+g.trim().length)),M.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[R,y,g]);return t?(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,S.jsx)(`input`,{value:g,onChange:e=>{v(e.target.value),T(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B(!0))},placeholder:`Search notes…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),g.trim()&&(0,S.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:R.length?`${Math.min(y+1,R.length)}/${R.length}`:`0/0`})]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>D(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:E===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:E===`desc`?(0,S.jsx)(o,{className:`h-3.5 w-3.5`}):(0,S.jsx)(a,{className:`h-3.5 w-3.5`})}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a note`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),`Note`]})]}),(0,S.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[O&&(0,S.jsx)(w,{target:t,onCreated:()=>{k(!1),p()},onCancel:()=>k(!1)},JSON.stringify(t)),r&&!n.length&&(0,S.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,S.jsx)(s,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),l&&(0,S.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:l}),!r&&!l&&!L.length&&!O&&(0,S.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No notes here yet - add the first one.`}),L.map(e=>(0,S.jsx)(C,{doc:e,updateWorkspace:f?.workspaceName??null,registerEl:P,registerBody:F,highlighted:z?.docId===e.id,onLinkTo:()=>j(e.id),onDelete:()=>I(e)},e.id))]}),A!==null&&(0,S.jsx)(_,{documentId:A,workspaceName:f?.workspaceName,onClose:()=>j(null)})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:d(t)})}export{T as NotesApplet};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,Pt as i,hi as a,li as o,pn as s,yt as c}from"./ui-CDoK3F3U.js";import{t as l}from"./utils-2pl1SbIp.js";import{Bn as u}from"./workspace-BJELPCNs.js";import{t as d}from"./useAddTarget-B3b6TyZr.js";import{t as f}from"./note-save-status-DPz4VzL6.js";import{t as p}from"./useEditNoteFields-DXLTFEqL.js";import{n as m}from"./use-applet-target-ffIGaAqT.js";import{k as h}from"./index-DRHEGJ8I.js";import{n as g,r as _,t as v}from"./shared-BnpwVpxG.js";import{n as y,r as b}from"./use-applet-docs-B2dk__vk.js";var x=e(n(),1),S=t();function C({doc:e,updateWorkspace:t,registerEl:n,registerBody:r,highlighted:i,onLinkTo:a,onDelete:o}){let s=p(e,t||``,!!t),{title:c,content:u,setTitle:d,setContent:m}=s,h=()=>{s.save().catch(()=>{})};return(0,S.jsxs)(`div`,{ref:t=>n(e.id,t),className:l(`group border-t border-border/60 px-4 py-3 transition-colors`,i&&`bg-primary/5`),children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,S.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:[y(e.createdAt),` · #`,e.id]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/70`,children:[(0,S.jsx)(f,{...s,onRetry:s.save}),(0,S.jsx)(g,{onLinkTo:a,onDelete:o})]})]}),(0,S.jsx)(`input`,{value:c,onChange:e=>d(e.target.value),onBlur:h,placeholder:`Untitled`,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:u,onChange:m,onBlur:h,innerRef:t=>r(e.id,t)})]})}function w({target:e,onCreated:t,onCancel:n}){let i=h(e,void 0,`applet`),{title:a,content:o,setTitle:s,setContent:c,saving:l}=i,[u,d]=(0,x.useState)(null),p=async()=>{try{await i.save(e),i.finish(),t()}catch(e){d(e instanceof Error?e.message:`Failed to save note`)}};return(0,S.jsxs)(`div`,{className:`border-t border-border/60 bg-muted/30 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between`,children:[(0,S.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70`,children:`New note`}),(0,S.jsx)(`button`,{type:`button`,onClick:n,className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close note`,children:(0,S.jsx)(r,{className:`h-3 w-3`})})]}),(0,S.jsx)(`input`,{value:a,onChange:e=>s(e.target.value),placeholder:`Untitled`,autoFocus:!0,spellCheck:!1,className:`mb-1 w-full border-0 bg-transparent p-0 text-sm font-semibold text-foreground outline-none placeholder:text-muted-foreground/50`}),(0,S.jsx)(v,{value:o,onChange:c,placeholder:`Write your note…`}),(0,S.jsx)(f,{...i,onRetry:i.retry}),u&&(0,S.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:u}),(0,S.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,S.jsx)(`button`,{type:`button`,onClick:p,disabled:!o.trim()||l,className:`rounded-md bg-primary px-2.5 py-1 text-xs text-primary-foreground disabled:opacity-50`,children:l?`Saving…`:`Done`})})]})}function T({autoAdd:e=!1}){let t=m(),{docs:n,loading:r,error:l,scope:f,reload:p,removeDoc:h}=b(t,u),[g,v]=(0,x.useState)(``),[y,T]=(0,x.useState)(0),[E,D]=(0,x.useState)(`desc`),[O,k]=(0,x.useState)(e),[A,j]=(0,x.useState)(null),M=(0,x.useRef)(new Map),N=(0,x.useRef)(new Map),P=(0,x.useCallback)((e,t)=>{t?M.current.set(e,t):M.current.delete(e)},[]),F=(0,x.useCallback)((e,t)=>{t?N.current.set(e,t):N.current.delete(e)},[]),I=(0,x.useCallback)(async e=>{let t=e.data?.title?`"${e.data.title}"`:`#${e.id}`;if(window.confirm(`Delete note ${t}?\n\nIt is removed from this path and moves to the workspace trash if nothing else links it.`))try{await h(e.id)}catch{}},[h]),L=(0,x.useMemo)(()=>{let e=[...n];return e.sort((e,t)=>{let n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();return E===`asc`?n:-n}),e},[n,E]),R=(0,x.useMemo)(()=>{let e=g.trim().toLowerCase();if(!e)return[];let t=[];for(let n of L){let r=String(n.data?.content??``),i=String(n.data?.title??``),a=r.toLowerCase().indexOf(e);a>=0?t.push({docId:n.id,offset:a}):i.toLowerCase().includes(e)&&t.push({docId:n.id,offset:-1})}return t},[g,L]),z=R.length?R[Math.min(y,R.length-1)]:null;(0,x.useEffect)(()=>{z&&M.current.get(z.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[z]);let B=(0,x.useCallback)(e=>{if(!R.length)return;let t=e?(y+1)%R.length:y;e&&T(t);let n=R[t],r=N.current.get(n.docId);r&&n.offset>=0&&(r.focus(),r.setSelectionRange(n.offset,n.offset+g.trim().length)),M.current.get(n.docId)?.scrollIntoView({block:`center`,behavior:`smooth`})},[R,y,g]);return t?(0,S.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-border px-3 py-2`,children:[(0,S.jsxs)(`div`,{className:`relative flex-1`,children:[(0,S.jsx)(c,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,S.jsx)(`input`,{value:g,onChange:e=>{v(e.target.value),T(0)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),B(!0))},placeholder:`Search notes…`,spellCheck:!1,className:`w-full rounded-md border border-input bg-transparent py-1 pl-7 pr-14 text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring`}),g.trim()&&(0,S.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-[10px] tabular-nums text-muted-foreground`,children:R.length?`${Math.min(y+1,R.length)}/${R.length}`:`0/0`})]}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>D(e=>e===`desc`?`asc`:`desc`),className:`rounded-md border border-border p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:E===`desc`?`Newest first (click for oldest first)`:`Oldest first (click for newest first)`,"aria-label":`Toggle sort order`,children:E===`desc`?(0,S.jsx)(a,{className:`h-3.5 w-3.5`}):(0,S.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>k(!0),className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1.5 text-xs text-primary-foreground`,title:`Add a note`,children:[(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),`Note`]})]}),(0,S.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[O&&(0,S.jsx)(w,{target:t,onCreated:()=>{k(!1),p()},onCancel:()=>k(!1)},JSON.stringify(t)),r&&!n.length&&(0,S.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,S.jsx)(s,{className:`h-5 w-5 animate-spin text-muted-foreground`})}),l&&(0,S.jsx)(`p`,{className:`px-4 py-6 text-center text-sm text-destructive`,children:l}),!r&&!l&&!L.length&&!O&&(0,S.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`No notes here yet - add the first one.`}),L.map(e=>(0,S.jsx)(C,{doc:e,updateWorkspace:f?.workspaceName??null,registerEl:P,registerBody:F,highlighted:z?.docId===e.id,onLinkTo:()=>j(e.id),onDelete:()=>I(e)},e.id))]}),A!==null&&(0,S.jsx)(_,{documentId:A,workspaceName:f?.workspaceName,onClose:()=>j(null)})]}):(0,S.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:d(t)})}export{T as NotesApplet};