@augmentd-labs/canvas-web 2.26.44 → 2.26.45

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 (119) hide show
  1. package/dist/assets/CalendarApplet-CsyUmI2B.js +2 -0
  2. package/dist/assets/{DocumentBodyEditor-CVO5KPCs.js → DocumentBodyEditor-C8AEpqX3.js} +1 -1
  3. package/dist/assets/{DocumentIcon-9i1uCMQa.js → DocumentIcon-0ya9gycp.js} +1 -1
  4. package/dist/assets/{EditorOverlay-D5t3xg4w.js → EditorOverlay-DglJkHo3.js} +1 -1
  5. package/dist/assets/{FiltersApplet-BT3fR4Fu.js → FiltersApplet-CVnCAs-P.js} +1 -1
  6. package/dist/assets/HomeFab-iC5BF7LV.js +3 -0
  7. package/dist/assets/{IdentityFields-D-NCTUaE.js → IdentityFields-CB3Ap0bl.js} +1 -1
  8. package/dist/assets/{LensApplet-CVUc1-vK.js → LensApplet-DA0ZWS1k.js} +1 -1
  9. package/dist/assets/LinkToCard-oi3wGP0a.js +1 -0
  10. package/dist/assets/{MarkdownEditor-DbpRWbO6.js → MarkdownEditor-bDoyR7l2.js} +2 -2
  11. package/dist/assets/{MessageComposerDialog-CdPp-3GR.js → MessageComposerDialog-CLrwtB76.js} +1 -1
  12. package/dist/assets/{NextShell-ull6WmMg.js → NextShell-DCWxD5TR.js} +1 -1
  13. package/dist/assets/{NotesApplet-Bbd61mrH.js → NotesApplet-BSJ-9RKl.js} +1 -1
  14. package/dist/assets/ObjectPropertiesCard-DesXRw-_.js +8 -0
  15. package/dist/assets/{PathPickerField-CW2yG2Yg.js → PathPickerField-CSIa7jSl.js} +1 -1
  16. package/dist/assets/PickDocumentsCard-DVdBxx3s.js +1 -0
  17. package/dist/assets/{SketchApplet-BKnhzTBA.js → SketchApplet--3uyqpmo.js} +1 -1
  18. package/dist/assets/{SketchEditor-DmGMcbU0.js → SketchEditor-CSA7dTyq.js} +2 -2
  19. package/dist/assets/{TerminalApplet-D7YxftqM.js → TerminalApplet-BZJx2ztD.js} +1 -1
  20. package/dist/assets/{TextDocumentEditor-BQnVD0dd.js → TextDocumentEditor-VYIF2XCX.js} +1 -1
  21. package/dist/assets/{TodosApplet-DU5VWc5i.js → TodosApplet-DY7JzeZS.js} +1 -1
  22. package/dist/assets/{TodosWidget-CNnfNk4L.js → TodosWidget-DGftEAbs.js} +1 -1
  23. package/dist/assets/{_agentId_-CrBQ54X2.js → _agentId_-BrzFDu8r.js} +0 -0
  24. package/dist/assets/{_contextId_-CEcdj7Ec.js → _contextId_-DS6b9Uml.js} +1 -1
  25. package/dist/assets/_workspaceName_-XRqfa4c6.js +1 -0
  26. package/dist/assets/{about-CdAN00wx.js → about-hcdKJNm5.js} +1 -1
  27. package/dist/assets/{add-COjQRnFC.js → add-CEBusWuu.js} +1 -1
  28. package/dist/assets/{agents-DxqAi3vk.js → agents-BfSFdg41.js} +1 -1
  29. package/dist/assets/{agents-D_t6cQMW.js → agents-wFp7Vh3p.js} +1 -1
  30. package/dist/assets/{alert-dialog-CFeuDt0T.js → alert-dialog-BKtaX1_a.js} +1 -1
  31. package/dist/assets/{api-tokens-drrVuCYc.js → api-tokens-Biqt5TnG.js} +1 -1
  32. package/dist/assets/{appearance-BnUcoqpz.js → appearance-D5BUjZm8.js} +1 -1
  33. package/dist/assets/{applet-target-pLdP-R76.js → applet-target-LvhUEvE5.js} +1 -1
  34. package/dist/assets/{apps-CCC-xyI2.js → apps-65YXCnzH.js} +1 -1
  35. package/dist/assets/{auth-PqttD05H.js → auth-BwxT5xRB.js} +1 -1
  36. package/dist/assets/{button-SeUZ_Pvi.js → button--VYZekMF.js} +1 -1
  37. package/dist/assets/{context-t3rdtGUB.js → context-DY40EDc6.js} +1 -1
  38. package/dist/assets/{contexts-DDJagU4j.js → contexts-BPO_Wb9W.js} +1 -1
  39. package/dist/assets/{contexts-Bq8LHUTK2.js → contexts-DBJ0_-AO2.js} +1 -1
  40. package/dist/assets/{date-time-picker-DCikruos.js → date-time-picker-p3vy4nst.js} +1 -1
  41. package/dist/assets/{devices-BwU9M8-W.js → devices-DZbbaWYU.js} +1 -1
  42. package/dist/assets/{document-Cr7GhnVd.js → document-Dv8NCUoM.js} +1 -1
  43. package/dist/assets/document-list-Bbbx-pTZ.js +3 -0
  44. package/dist/assets/document-paste-BuTC6S7_.js +1 -0
  45. package/dist/assets/{embedding-D-I_ygUZ.js → embedding-B9vSy_a9.js} +1 -1
  46. package/dist/assets/{embedding-BvXcVfij.js → embedding-M2hUmnk0.js} +1 -1
  47. package/dist/assets/{form-panel-3p-ncEVK.js → form-panel-CEbNKttr.js} +1 -1
  48. package/dist/assets/{home-DrRSXywO.js → home-vr8b8oR-.js} +1 -1
  49. package/dist/assets/index-CTvqbEB8.js +16 -0
  50. package/dist/assets/index-CoVFQpP3.css +2 -0
  51. package/dist/assets/{inferd-config-editor-B8x_XPOt.js → inferd-config-editor-Dpdj90iN.js} +1 -1
  52. package/dist/assets/{key-bindings-6SHAlZR8.js → key-bindings-DmqvYSaF.js} +1 -1
  53. package/dist/assets/{label-BSTdjCWU.js → label-RuOXXC8t.js} +1 -1
  54. package/dist/assets/{lazy-editor-BUFAkTGl.js → lazy-editor-CShGeIep.js} +2 -2
  55. package/dist/assets/{logs-DjG8_wJ2.js → logs-7eSz9yjc.js} +1 -1
  56. package/dist/assets/{offline-ByoT6JJX.js → offline-C-Yvb6LA.js} +1 -1
  57. package/dist/assets/{page-header-DrDt1sQ2.js → page-header-NyYSXjfY.js} +1 -1
  58. package/dist/assets/{public-share-CXR25Q1X.js → public-share-0DqS7L2Q.js} +1 -1
  59. package/dist/assets/{query-debug-lD5vbJGi.js → query-debug-PEWbZsOP.js} +1 -1
  60. package/dist/assets/registry-g1SKt_fD.js +2 -0
  61. package/dist/assets/{remotes-RPGcw6fH.js → remotes-DqCLds8Q.js} +1 -1
  62. package/dist/assets/{roles-sb8vgjV_.js → roles-BwVDE1aQ.js} +1 -1
  63. package/dist/assets/{roles-p2cRajz-.js → roles-W7oJ5WMg.js} +1 -1
  64. package/dist/assets/rule-builder-CziPqpNe.js +6 -0
  65. package/dist/assets/settings-BIoSwdXv.js +16 -0
  66. package/dist/assets/{settings-CGncOyKY.js → settings-BWCMmkjr.js} +1 -1
  67. package/dist/assets/{settings-r7slYioS.js → settings-CbMkpipO.js} +1 -1
  68. package/dist/assets/settings-XMhqrvTu.js +1 -0
  69. package/dist/assets/{share-target-CoDDhZI5.js → share-target-hDXdgW6o.js} +1 -1
  70. package/dist/assets/{shared-BLOuO2Is.js → shared-CLjTxih0.js} +1 -1
  71. package/dist/assets/{shared-bYen6pjw.js → shared-DVlDThVA.js} +1 -1
  72. package/dist/assets/sketch-lazy-CtjOUfVz.js +2 -0
  73. package/dist/assets/{subtree-transfer-dialog-DQM5zfx2.js → subtree-transfer-dialog-DtE6JSUr.js} +1 -1
  74. package/dist/assets/{text-documents-Cdb3U63i.js → text-documents-wu6fzOuw.js} +2 -2
  75. package/dist/assets/tree-folders-IDoobsGN.js +1 -0
  76. package/dist/assets/ui-DEgHnkQu.js +41 -0
  77. package/dist/assets/{use-applet-docs-rimRHjID.js → use-applet-docs-C08GAUm3.js} +1 -1
  78. package/dist/assets/{use-applet-target-BygCSj5n.js → use-applet-target-BlpVWlnA.js} +1 -1
  79. package/dist/assets/{use-canvas-pins-BPCW4twY.js → use-canvas-pins-q5Tncavk.js} +2 -2
  80. package/dist/assets/{use-menu-DIP1zh7I.js → use-menu-CKSpS96u.js} +1 -1
  81. package/dist/assets/use-settings-back-D_MM9diy.js +1 -0
  82. package/dist/assets/{use-sortable-data-BBKmqs79.js → use-sortable-data-D7zS2qCC.js} +1 -1
  83. package/dist/assets/{use-workspace-identity-CSkRwVyo.js → use-workspace-identity-XSv3dATQ.js} +1 -1
  84. package/dist/assets/{useAddTarget-DeRZWtGg.js → useAddTarget-BvuFR5pN.js} +1 -1
  85. package/dist/assets/{useAgentModels-BufYelEA.js → useAgentModels-CI9XT6yc.js} +1 -1
  86. package/dist/assets/{useDocumentThumbnail-Cj4UYyhC.js → useDocumentThumbnail-CZIaXkIi.js} +1 -1
  87. package/dist/assets/{useEditNoteFields-BT1ASu_q.js → useEditNoteFields-DsVKIHWm.js} +1 -1
  88. package/dist/assets/{users-DuVk-TEd.js → users-DzlbKZp6.js} +1 -1
  89. package/dist/assets/workspace-4hWrSEku.js +1 -0
  90. package/dist/assets/{workspace-content-gate-C54J9Man.js → workspace-content-gate-BlFdbi67.js} +1 -1
  91. package/dist/assets/{workspace-import-form-DTvV9jYt.js → workspace-import-form-CWs9ZTts.js} +1 -1
  92. package/dist/assets/{workspaces-CqHYstZv.js → workspaces-67v2hWrl.js} +1 -1
  93. package/dist/assets/workspaces-ByYQ6L3I.js +1 -0
  94. package/dist/index.html +36 -38
  95. package/dist/sw.js +1 -1
  96. package/package.json +2 -2
  97. package/dist/assets/CalendarApplet-BNT0vegP.js +0 -2
  98. package/dist/assets/FileForm-CDiVKvxq.js +0 -1
  99. package/dist/assets/HomeFab-B17r3232.js +0 -3
  100. package/dist/assets/LinkToCard-CKVi4Nrg.js +0 -1
  101. package/dist/assets/ObjectPropertiesCard-D2lrTQqT.js +0 -8
  102. package/dist/assets/PickDocumentsCard-BWgc-A02.js +0 -1
  103. package/dist/assets/UploadProgressList-D2wEpa7t.js +0 -1
  104. package/dist/assets/_workspaceName_-BhZWt9RG.js +0 -1
  105. package/dist/assets/backend-sync-progress-B3lZB9Ha.js +0 -6
  106. package/dist/assets/document-list-rzRLzfkF.js +0 -3
  107. package/dist/assets/index-DOXi2QgX.css +0 -2
  108. package/dist/assets/index-G_67YwLB.js +0 -16
  109. package/dist/assets/registry-FfNYUpRF.js +0 -2
  110. package/dist/assets/settings-CCr9Jr0Q.js +0 -1
  111. package/dist/assets/settings-Cv6jdSA0.js +0 -16
  112. package/dist/assets/sketch-lazy-BY_ka1hw.js +0 -2
  113. package/dist/assets/tree-folders-Q5iu5vpu.js +0 -1
  114. package/dist/assets/ui-CDoK3F3U.js +0 -41
  115. package/dist/assets/use-settings-back-DGmLAD63.js +0 -1
  116. package/dist/assets/workspace-C5V-ZCOE.js +0 -1
  117. package/dist/assets/workspace-area-menu-BN5ysUpx.js +0 -1
  118. package/dist/assets/workspaces-Dj9dNIWZ.js +0 -1
  119. /package/dist/assets/{backend-sync-progress-DU-e9TWi.css → rule-builder-DU-e9TWi.css} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{Z as n}from"./workspace-C5V-ZCOE.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(!e)return;let t=!1,r=()=>{n(e).then(n=>{t||i({ref:e,workspace:n})}).catch(()=>{})};return r(),window.addEventListener(`workspaces:refresh`,r),()=>{t=!0,window.removeEventListener(`workspaces:refresh`,r)}},[e]),t?.ref===e?t?.workspace:void 0}export{i as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{Z as n}from"./workspace-4hWrSEku.js";var r=e(t(),1);function i(e){let[t,i]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if(!e)return;let t=!1,r=()=>{n(e).then(n=>{t||i({ref:e,workspace:n})}).catch(()=>{})};return r(),window.addEventListener(`workspaces:refresh`,r),()=>{t=!0,window.removeEventListener(`workspaces:refresh`,r)}},[e]),t?.ref===e?t?.workspace:void 0}export{i as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{At as n,Lt as r,bn as i,lt as a,vt as o}from"./workspace-C5V-ZCOE.js";import{n as s}from"./use-toolbox-Ck_cLGgf.js";import{_ as c,a as l,d as u}from"./context-t3rdtGUB.js";var d=e(t(),1);function f(e){return!/[\\\0]/.test(e)&&e.split(`/`).every(e=>e!==`.`&&e!==`..`)}function p(e,t){if(!f(e))throw Error(`Invalid backend folder path`);let n=`/`+e.split(`/`).filter(Boolean).join(`/`),r=[...t].filter(e=>e.treePath&&(n===e.treePath||n.startsWith(e.treePath+`/`))).sort((e,t)=>t.treePath.length-e.treePath.length)[0];if(!r)throw Error(`Choose a writable storage backend folder`);if(!r.enabled||r.config?.readOnly===!0||!r.capabilities.upload)throw Error(`This backend does not support file uploads or is read-only`);return{driver:r.driver,address:r.address,key:n.slice(r.treePath.length).replace(/^\//,``)}}function m(e,t){if(!t||t.includes(`/`)||!f(t)||!f(e))throw Error(`Invalid upload filename or folder`);return[e.replace(/^\/+|\/+$/g,``),t].filter(Boolean).join(`/`)}function h(){let{state:e}=s(),{activeContextType:t,activeContextId:n,activeWorkspaceName:r,activeTreeName:a,activeContextPath:o}=e;return(0,d.useMemo)(()=>t===`context`&&n?{mode:`context`,contextId:n}:r&&o?{mode:`workspace`,workspaceName:r,path:o,treeName:a||`context`,treeType:i(a)}:null,[t,n,r,a,o])}var g=new Map,_=15e3;function v(e){let t=g.get(e);if(t&&Date.now()-t.at<_)return t.promise;let r=n(e);return r.catch(()=>g.delete(e)),g.set(e,{at:Date.now(),promise:r}),r}function y(e){e?.mode===`workspace`&&window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e.workspaceName,treeName:e.treeName,path:e.path}}))}async function b(e,t,n={}){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`){if(e.treeName===`backends`)throw Error(`Backend folders accept files, not database-only documents`);let r=e.treeType;try{let t=(await v(e.workspaceName)).find(t=>t?.name===e.treeName||t?.id===e.treeName);(t?.type===`directory`||t?.type===`context`)&&(r=t.type)}catch{}let i=await a(e.workspaceName,e.path,t,e.treeName,r);return i.length&&n.refresh!==!1&&y(e),i}return u(e.contextId,t)}async function x(e){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`)return{workspaceName:e.workspaceName,path:e.path,treeName:e.treeName,treeType:e.treeType};let t=await l(e.contextId),n=t.workspaceName||t.workspaceId;if(!n)throw Error(`Context has no bound workspace`);return{workspaceName:n,path:t.path||`/`,treeName:t.treeId||`context`,treeType:`context`}}async function S(e,t){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`){let n=await r(e.workspaceName,e.path,t,e.treeName,e.treeType);return n&&window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e.workspaceName,treeName:e.treeName,path:e.path}})),n}let n=await l(e.contextId);return c(e.contextId,n.path||`/`,t)}function C(e){return e?e.mode===`context`?`Adds to the current context`:`Adds to ${e.path===`/`?`/`:e.path}`:`No destination. Open a workspace path or a context first`}async function w(e,t){return p(t,await o(e))}function T(e){let t=e?.mode===`workspace`&&e.treeName===`backends`,n=t?e.workspaceName:``,r=t?e.path:``,i=`${n}\0${r}`,[a,o]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!t)return;let e=!1;return w(n,r).then(t=>{e||o({key:i,destination:t})}).catch(t=>{e||o({key:i,error:t instanceof Error?t.message:`Unable to load backend`})}),()=>{e=!0}},[t,n,r,i]),{isBackend:t,loading:t&&a?.key!==i,destination:a?.key===i?a.destination:void 0,error:a?.key===i?a.error:void 0}}export{x as a,T as c,w as i,m as l,S as n,b as o,y as r,h as s,C as t,p as u};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{At as n,Lt as r,lt as i,vt as a,xn as o}from"./workspace-4hWrSEku.js";import{n as s}from"./use-toolbox-Ck_cLGgf.js";import{_ as c,a as l,d as u}from"./context-DY40EDc6.js";var d=e(t(),1);function f(e){return!/[\\\0]/.test(e)&&e.split(`/`).every(e=>e!==`.`&&e!==`..`)}function p(e,t){if(!f(e))throw Error(`Invalid backend folder path`);let n=`/`+e.split(`/`).filter(Boolean).join(`/`),r=[...t].filter(e=>e.treePath&&(n===e.treePath||n.startsWith(e.treePath+`/`))).sort((e,t)=>t.treePath.length-e.treePath.length)[0];if(!r)throw Error(`Choose a writable storage backend folder`);if(!r.enabled||r.config?.readOnly===!0||!r.capabilities.upload)throw Error(`This backend does not support file uploads or is read-only`);return{driver:r.driver,address:r.address,key:n.slice(r.treePath.length).replace(/^\//,``)}}function m(e,t){if(!t||t.includes(`/`)||!f(t)||!f(e))throw Error(`Invalid upload filename or folder`);return[e.replace(/^\/+|\/+$/g,``),t].filter(Boolean).join(`/`)}function h(){let{state:e}=s(),{activeContextType:t,activeContextId:n,activeWorkspaceName:r,activeTreeName:i,activeContextPath:a}=e;return(0,d.useMemo)(()=>t===`context`&&n?{mode:`context`,contextId:n}:r&&a?{mode:`workspace`,workspaceName:r,path:a,treeName:i||`context`,treeType:o(i)}:null,[t,n,r,i,a])}var g=new Map,_=15e3;function v(e){let t=g.get(e);if(t&&Date.now()-t.at<_)return t.promise;let r=n(e);return r.catch(()=>g.delete(e)),g.set(e,{at:Date.now(),promise:r}),r}function y(e){e?.mode===`workspace`&&window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e.workspaceName,treeName:e.treeName,path:e.path}}))}async function b(e,t,n={}){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`){if(e.treeName===`backends`)throw Error(`Backend folders accept files, not database-only documents`);let r=e.treeType;try{let t=(await v(e.workspaceName)).find(t=>t?.name===e.treeName||t?.id===e.treeName);(t?.type===`directory`||t?.type===`context`)&&(r=t.type)}catch{}let a=await i(e.workspaceName,e.path,t,e.treeName,r);return a.length&&n.refresh!==!1&&y(e),a}return u(e.contextId,t)}async function x(e){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`)return{workspaceName:e.workspaceName,path:e.path,treeName:e.treeName,treeType:e.treeType};let t=await l(e.contextId),n=t.workspaceName||t.workspaceId;if(!n)throw Error(`Context has no bound workspace`);return{workspaceName:n,path:t.path||`/`,treeName:t.treeId||`context`,treeType:`context`}}async function S(e,t){if(!e)throw Error(`No active workspace or context to add to`);if(e.mode===`workspace`){let n=await r(e.workspaceName,e.path,t,e.treeName,e.treeType);return n&&window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`,{detail:{workspaceName:e.workspaceName,treeName:e.treeName,path:e.path}})),n}let n=await l(e.contextId);return c(e.contextId,n.path||`/`,t)}function C(e){return e?e.mode===`context`?`Adds to the current context`:`Adds to ${e.path===`/`?`/`:e.path}`:`No destination. Open a workspace path or a context first`}async function w(e,t){return p(t,await a(e))}function T(e){let t=e?.mode===`workspace`&&e.treeName===`backends`,n=t?e.workspaceName:``,r=t?e.path:``,i=`${n}\0${r}`,[a,o]=(0,d.useState)(null);return(0,d.useEffect)(()=>{if(!t)return;let e=!1;return w(n,r).then(t=>{e||o({key:i,destination:t})}).catch(t=>{e||o({key:i,error:t instanceof Error?t.message:`Unable to load backend`})}),()=>{e=!0}},[t,n,r,i]),{isBackend:t,loading:t&&a?.key!==i,destination:a?.key===i?a.destination:void 0,error:a?.key===i?a.error:void 0}}export{x as a,T as c,w as i,m as l,S as n,b as o,y as r,h as s,C as t,p as u};
@@ -1,3 +1,3 @@
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{B as a}from"./index-G_67YwLB.js";function o(e,t,n){return[e.trim()?`## Role\n${e.trim()}`:``,t.trim()?`## Identity\n${t.trim()}`:``,n.trim()?`## Instructions\n${n.trim()}`:``].filter(Boolean).join(`
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--VYZekMF.js";import{t as i}from"./input-BOtCd4HP.js";import{W as a}from"./index-CTvqbEB8.js";function o(e,t,n){return[e.trim()?`## Role\n${e.trim()}`:``,t.trim()?`## Identity\n${t.trim()}`:``,n.trim()?`## Instructions\n${n.trim()}`:``].filter(Boolean).join(`
2
2
 
3
3
  `)}var s=e(n(),1),c=t();function l({value:e,onChange:t,models:n,loading:a,error:o,refresh:l,disabled:u,id:d}){let f=(0,s.useId)(),p=n.find(t=>t.id===e);return(0,c.jsxs)(`div`,{className:`space-y-2`,children:[(0,c.jsxs)(`div`,{className:`flex gap-2`,children:[(0,c.jsx)(i,{id:d,"aria-label":`Model`,list:f,value:e,onChange:e=>t(e.target.value,n.find(t=>t.id===e.target.value)),placeholder:`Choose or enter a model ID`,disabled:u}),(0,c.jsx)(r,{type:`button`,variant:`outline`,disabled:u||a,onClick:l,children:`Refresh models`})]}),(0,c.jsx)(`datalist`,{id:f,children:n.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:a?`Loading models…`:o||(n.length?`${n.length} models available`:`Enter provider credentials to load available models. You can also enter a model ID.`)}),p&&(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Context: `,p.contextWindow?.toLocaleString()??`not reported`,` · Max output: `,p.maxTokens?.toLocaleString()??`not reported`,` tokens`,p.limitsSource===`runtime`?` (runtime catalogue)`:p.limitsSource===`provider`?` (provider)`:``]})]})}function u(e,t,n,r){let[i,o]=(0,s.useState)(0),c=JSON.stringify([e,t,n,r,i]),[l,u]=(0,s.useState)({key:``,models:[],loading:!1,error:``}),d=!!t.trim()||!!r||[`ollama`,`lm-studio`,`vllm`,`custom`].includes(e);return(0,s.useEffect)(()=>{if(!d)return;let i=new AbortController,o=setTimeout(()=>{u({key:c,models:[],loading:!0,error:``}),a({provider:e,apiKey:t.trim()||void 0,baseUrl:n.trim()||void 0,agentIdentifier:r},i.signal).then(e=>{i.signal.aborted||u({key:c,models:e,loading:!1,error:``})}).catch(e=>{i.signal.aborted||u({key:c,models:[],loading:!1,error:e instanceof Error?e.message:`Unable to load models`})})},700);return()=>{clearTimeout(o),i.abort()}},[c,d,e,t,n,r]),{...l.key===c?l:{models:[],loading:d,error:``},refresh:()=>o(e=>e+1)}}export{l as n,o as r,u as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{r as n}from"./public-share-CXR25Q1X.js";var r=e(t(),1);function i(e,t,i=256,{enabled:a=!0,blobFallback:o=!0,version:s=null}={}){let{isPublic:c,fetchBlob:l,fetchThumbnail:u}=n(e),d=`${c?`pub`:`ws`}:${e}:${t}:${i}:${a}:${s??``}`,[f,p]=(0,r.useState)({blobUrl:null,error:null,loading:a}),[m,h]=(0,r.useState)(d);return d!==m&&(h(d),p({blobUrl:null,error:null,loading:a})),(0,r.useEffect)(()=>{if(!a)return;let e=!1,n=null;return u(t,i,s).catch(e=>{if(!o)throw e;return l(t)}).then(({blob:t})=>{e||(n=URL.createObjectURL(t),p({blobUrl:n,error:null,loading:!1}))}).catch(t=>{e||p({blobUrl:null,error:String(t instanceof Error?t.message:t),loading:!1})}),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[d]),f}export{i as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{r as n}from"./public-share-0DqS7L2Q.js";var r=e(t(),1);function i(e,t,i=256,{enabled:a=!0,blobFallback:o=!0,version:s=null}={}){let{isPublic:c,fetchBlob:l,fetchThumbnail:u}=n(e),d=`${c?`pub`:`ws`}:${e}:${t}:${i}:${a}:${s??``}`,[f,p]=(0,r.useState)({blobUrl:null,error:null,loading:a}),[m,h]=(0,r.useState)(d);return d!==m&&(h(d),p({blobUrl:null,error:null,loading:a})),(0,r.useEffect)(()=>{if(!a)return;let e=!1,n=null;return u(t,i,s).catch(e=>{if(!o)throw e;return l(t)}).then(({blob:t})=>{e||(n=URL.createObjectURL(t),p({blobUrl:n,error:null,loading:!1}))}).catch(t=>{e||p({blobUrl:null,error:String(t instanceof Error?t.message:t),loading:!1})}),()=>{e=!0,n&&URL.revokeObjectURL(n)}},[d]),f}export{i as t};
@@ -1 +1 @@
1
- import{hn as e}from"./workspace-C5V-ZCOE.js";import{n as t,t as n}from"./tags-YamdPoBK.js";import{n as r,r as i}from"./note-save-status-DPz4VzL6.js";function a(a,o,s=!0){let c=a.features??a.metadata?.features??[],l={title:String(a.data?.title??``),content:String(a.data?.content??``),comment:String(a.comment??``),tags:n(c),geo:a.metadata?.geo??null},u=r(i(`document:${o}:${a.id}`),l,{save:s?async n=>{await e(o,{id:a.id,schema:a.schema,schemaVersion:a.schemaVersion,data:{...a.data,title:n.title.trim(),content:n.content},comment:n.comment,metadata:{features:[...c.filter(e=>!e.startsWith(`tag/`)),...t(n.tags)],geo:n.geo}}),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`))}:void 0});return{...u.value,status:u.status,error:u.error,storageError:u.storageError,setTitle:e=>u.update({title:e}),setContent:e=>u.update({content:e}),setComment:e=>u.update({comment:e}),setTags:e=>u.update({tags:e}),setGeo:e=>u.update({geo:e}),saving:u.status===`saving`,canSave:u.status!==`saving`,save:u.flush}}export{a as t};
1
+ import{hn as e}from"./workspace-4hWrSEku.js";import{n as t,t as n}from"./tags-YamdPoBK.js";import{n as r,r as i}from"./note-save-status-DPz4VzL6.js";function a(a,o,s=!0){let c=a.features??a.metadata?.features??[],l={title:String(a.data?.title??``),content:String(a.data?.content??``),comment:String(a.comment??``),tags:n(c),geo:a.metadata?.geo??null},u=r(i(`document:${o}:${a.id}`),l,{save:s?async n=>{await e(o,{id:a.id,schema:a.schema,schemaVersion:a.schemaVersion,data:{...a.data,title:n.title.trim(),content:n.content},comment:n.comment,metadata:{features:[...c.filter(e=>!e.startsWith(`tag/`)),...t(n.tags)],geo:n.geo}}),window.dispatchEvent(new CustomEvent(`workspace:documents:refresh`))}:void 0});return{...u.value,status:u.status,error:u.error,storageError:u.storageError,setTitle:e=>u.update({title:e}),setContent:e=>u.update({content:e}),setComment:e=>u.update({comment:e}),setTags:e=>u.update({tags:e}),setGeo:e=>u.update({geo:e}),saving:u.status===`saving`,canSave:u.status!==`saving`,save:u.flush}}export{a 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{L as r,Pt as i,Vt as a,Y as o}from"./ui-CDoK3F3U.js";import{t as s}from"./button-SeUZ_Pvi.js";import{t as c}from"./input-BOtCd4HP.js";import{t as l}from"./label-BSTdjCWU.js";import{i as u,n as d,u as f}from"./auth-Bx9fAZmz.js";import{n as p}from"./use-toast-BlLDqSUO.js";import{t as m}from"./useEscapeClose-DR_xKT_k.js";import{n as h}from"./page-header-DrDt1sQ2.js";import{t as g}from"./use-settings-back-DGmLAD63.js";import{t as _}from"./admin-Bhg9QBHL.js";var v=e(n(),1),y=t();function b(){let e=g(),t=u(),n=t?.userType===`admin`,[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(n),[w,T]=(0,v.useState)(n?null:`Access denied. Admin privileges required.`),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(null),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)({status:``,userType:``,search:``}),[R,z]=(0,v.useState)({name:``,email:``,password:``,userType:`user`,status:`active`}),{showToast:B}=p();(0,v.useEffect)(()=>{n&&(async()=>{try{let e=await d(),t=!!e?.strategies?.local?.requireEmailVerification;N(t),F(e?.strategies?.local?.passwordPolicy||null)}catch{N(!1),F(null)}})()},[n]);let V=e=>{let t=e.trim().toLowerCase();return t.length<3||t.length>39?`Username must be 3-39 characters long`:/^[a-z0-9_-]+$/.test(t)?null:`Username can only contain lowercase letters, numbers, underscores, and hyphens`},H=e=>{let t=e||``,n=P||{},r=n.minLength??12,i=n.maxLength??128,a=[];return t.length<r&&a.push(`at least ${r} characters`),t.length>i&&a.push(`no more than ${i} characters`),(n.requireUppercase??!0)&&!/[A-Z]/.test(t)&&a.push(`an uppercase letter`),(n.requireLowercase??!0)&&!/[a-z]/.test(t)&&a.push(`a lowercase letter`),(n.requireNumbers??!0)&&!/[0-9]/.test(t)&&a.push(`a number`),(n.requireSpecialChars??!0)&&!/[^A-Za-z0-9]/.test(t)&&a.push(`a special character`),a.length?`Password must contain ${a.join(`, `).replace(/, ([^,]*)$/,` and $1`)}.`:null},U=()=>{let e=P||{},t=[],n=e.minLength??12;return t.push(`${n}+ chars`),(e.requireUppercase??!0)&&t.push(`uppercase`),(e.requireLowercase??!0)&&t.push(`lowercase`),(e.requireNumbers??!0)&&t.push(`number`),(e.requireSpecialChars??!0)&&t.push(`special`),t.join(`, `)},W=e=>{if(!e)return`-`;let t=new Date(e);return isNaN(t.getTime())?`-`:t.toLocaleString()},G=async e=>{try{await f(e),B({title:`Verification email`,description:`If the account exists, a verification email was sent.`})}catch(e){let t=e instanceof Error?e.message:`Failed to send verification email`;B({title:`Error`,description:t,variant:`destructive`})}},K=(0,v.useCallback)(async()=>{try{C(!0);let{status:e,userType:t}=I,n=await _.users.listUsers({status:e||void 0,userType:t||void 0});x(n),T(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch users`;T(t),B({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[I,B]);(0,v.useEffect)(()=>{n&&K()},[K,n]);let q=async e=>{if(e.preventDefault(),!R.name.trim()||!R.email.trim()){B({title:`Validation Error`,description:`Name and email are required`,variant:`destructive`});return}let t=V(R.name);if(t){B({title:`Validation Error`,description:t,variant:`destructive`});return}if(!R.password.trim()){B({title:`Validation Error`,description:`Password is required`,variant:`destructive`});return}let n=H(R.password);if(n){B({title:`Validation Error`,description:n,variant:`destructive`});return}D(!0);try{let e={name:R.name.trim().toLowerCase(),email:R.email.trim(),userType:R.userType,status:R.status};if(R.password.trim()&&(e.password=R.password),await _.users.createUser(e),M&&R.status===`pending`)try{await f(R.email.trim())}catch{}z({name:``,email:``,password:``,userType:`user`,status:M?`pending`:`active`}),j(!1),await K(),B({title:`Success`,description:`User created successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to create user`;B({title:`Error`,description:t,variant:`destructive`})}finally{D(!1)}},J=async e=>{if(e.preventDefault(),!O)return;let t=V(R.name);if(t){B({title:`Validation Error`,description:t,variant:`destructive`});return}if(R.password.trim()){let e=H(R.password);if(e){B({title:`Validation Error`,description:e,variant:`destructive`});return}}D(!0);try{let e={name:R.name.trim().toLowerCase(),email:R.email.trim(),userType:R.userType,status:R.status};R.password.trim()&&(e.password=R.password),await _.users.updateUser(O.id,e),k(null),j(!1),await K(),B({title:`Success`,description:`User updated successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to update user`;B({title:`Error`,description:t,variant:`destructive`})}finally{D(!1)}},Y=async(e,t)=>{if(confirm(`Are you sure you want to delete user "${t}"? This action cannot be undone.`))try{await _.users.deleteUser(e),await K(),B({title:`Success`,description:`User deleted successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete user`;B({title:`Error`,description:t,variant:`destructive`})}},X=()=>{k(null),z({name:``,email:``,password:``,userType:`user`,status:M?`pending`:`active`}),j(!0)},Z=e=>{k(e),z({name:e.name,email:e.email,password:``,userType:e.userType,status:e.status}),j(!0)},Q=()=>{j(!1),k(null)};m(Q,A);let $=b.filter(e=>I.search===``||e.name.toLowerCase().includes(I.search.toLowerCase())||e.email.toLowerCase().includes(I.search.toLowerCase()));return n?(0,y.jsxs)(`div`,{className:`space-y-6`,children:[(0,y.jsx)(h,{onBack:e,title:`User Management`,description:`Manage user accounts and permissions`}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,y.jsx)(c,{placeholder:`Search users...`,value:I.search,onChange:e=>L(t=>({...t,search:e.target.value})),className:`md:w-64`}),(0,y.jsxs)(`select`,{value:I.status,onChange:e=>L(t=>({...t,status:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:``,children:`All Statuses`}),(0,y.jsx)(`option`,{value:`active`,children:`Active`}),(0,y.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,y.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,y.jsx)(`option`,{value:`deleted`,children:`Deleted`})]}),(0,y.jsxs)(`select`,{value:I.userType,onChange:e=>L(t=>({...t,userType:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:``,children:`All Types`}),(0,y.jsx)(`option`,{value:`user`,children:`User`}),(0,y.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,y.jsxs)(s,{onClick:X,children:[(0,y.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create User`]})]}),(0,y.jsxs)(`div`,{className:`space-y-4`,children:[S&&(0,y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading users...`}),w&&!b.length&&(0,y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,y.jsx)(`p`,{children:w})}),!S&&!w&&$.length===0&&(0,y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No users found`}),$.length>0&&(0,y.jsx)(`div`,{className:`border rounded-md`,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`bg-muted/50`,children:[(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Name`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Email`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Type`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Created`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Updated`}),(0,y.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:$.map(e=>(0,y.jsxs)(`tr`,{className:`border-t`,children:[(0,y.jsx)(`td`,{className:`p-3 font-medium`,children:e.name}),(0,y.jsx)(`td`,{className:`p-3`,children:e.email}),(0,y.jsx)(`td`,{className:`p-3`,children:(0,y.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.userType===`admin`?`bg-destructive-subtle text-destructive`:`bg-info-subtle text-info`}`,children:e.userType})}),(0,y.jsx)(`td`,{className:`p-3`,children:(0,y.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.status===`active`?`bg-success-subtle text-success`:e.status===`inactive`?`bg-warning-subtle text-warning`:e.status===`pending`?`bg-info-subtle text-info`:`bg-destructive-subtle text-destructive`}`,children:e.status})}),(0,y.jsx)(`td`,{className:`p-3`,children:W(e.createdAt)}),(0,y.jsx)(`td`,{className:`p-3`,children:W(e.updatedAt)}),(0,y.jsxs)(`td`,{className:`p-3 text-right space-x-2`,children:[(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>Z(e),children:(0,y.jsx)(a,{className:`h-4 w-4`})}),M&&e.status===`pending`&&(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>G(e.email),title:`Resend activation email`,children:`Resend activation`}),(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>Y(e.id,e.name),className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,disabled:e.id===t?.id,title:e.id===t?.id?`Cannot delete your own account`:`Delete user`,children:(0,y.jsx)(o,{className:`h-4 w-4`})})]})]},e.id))})]})})})]}),A&&(0,y.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,y.jsxs)(`div`,{className:`bg-card rounded-lg p-6 w-full max-w-md mx-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,y.jsx)(`h3`,{className:`text-lg font-semibold`,children:O?`Edit User`:`Create New User`}),(0,y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:Q,children:(0,y.jsx)(r,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`form`,{onSubmit:O?J:q,className:`space-y-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`name`,children:`Username`}),(0,y.jsx)(c,{id:`name`,type:`text`,value:R.name,onChange:e=>z(t=>({...t,name:e.target.value.toLowerCase().replace(/\s+/g,``)})),placeholder:`Enter username`,disabled:E,required:!0}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`3-39 characters, lowercase letters, numbers, underscores, and hyphens only`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`email`,children:`Email`}),(0,y.jsx)(c,{id:`email`,type:`email`,value:R.email,onChange:e=>z(t=>({...t,email:e.target.value})),placeholder:`Enter email address`,disabled:E,required:!0})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(l,{htmlFor:`password`,children:[`Password `,O&&`(leave blank to keep current)`]}),(0,y.jsx)(c,{id:`password`,type:`password`,value:R.password,onChange:e=>z(t=>({...t,password:e.target.value})),placeholder:O?`Leave blank to keep current`:`Enter password`,disabled:E,required:!O}),!O&&(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Must satisfy: `,U()]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`userType`,children:`User Type`}),(0,y.jsxs)(`select`,{id:`userType`,value:R.userType,onChange:e=>z(t=>({...t,userType:e.target.value})),disabled:E,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:`user`,children:`User`}),(0,y.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`status`,children:`Status`}),(0,y.jsxs)(`select`,{id:`status`,value:R.status,onChange:e=>z(t=>({...t,status:e.target.value})),disabled:E,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:`active`,children:`Active`}),(0,y.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,y.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,y.jsx)(`option`,{value:`deleted`,children:`Deleted`})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[(0,y.jsx)(s,{type:`submit`,disabled:E,className:`flex-1`,children:E?`Processing...`:O?`Update User`:`Create User`}),(0,y.jsx)(s,{type:`button`,variant:`outline`,onClick:Q,disabled:E,children:`Cancel`})]})]})]})})]}):(0,y.jsx)(`div`,{className:`text-center space-y-4`,children:(0,y.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{b 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{L as r,Pt as i,Vt as a,Y as o}from"./ui-DEgHnkQu.js";import{t as s}from"./button--VYZekMF.js";import{t as c}from"./input-BOtCd4HP.js";import{t as l}from"./label-RuOXXC8t.js";import{i as u,n as d,u as f}from"./auth-Bx9fAZmz.js";import{n as p}from"./use-toast-BlLDqSUO.js";import{t as m}from"./useEscapeClose-DR_xKT_k.js";import{n as h}from"./page-header-NyYSXjfY.js";import{t as g}from"./use-settings-back-D_MM9diy.js";import{t as _}from"./admin-Bhg9QBHL.js";var v=e(n(),1),y=t();function b(){let e=g(),t=u(),n=t?.userType===`admin`,[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(n),[w,T]=(0,v.useState)(n?null:`Access denied. Admin privileges required.`),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(null),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)({status:``,userType:``,search:``}),[R,z]=(0,v.useState)({name:``,email:``,password:``,userType:`user`,status:`active`}),{showToast:B}=p();(0,v.useEffect)(()=>{n&&(async()=>{try{let e=await d(),t=!!e?.strategies?.local?.requireEmailVerification;N(t),F(e?.strategies?.local?.passwordPolicy||null)}catch{N(!1),F(null)}})()},[n]);let V=e=>{let t=e.trim().toLowerCase();return t.length<3||t.length>39?`Username must be 3-39 characters long`:/^[a-z0-9_-]+$/.test(t)?null:`Username can only contain lowercase letters, numbers, underscores, and hyphens`},H=e=>{let t=e||``,n=P||{},r=n.minLength??12,i=n.maxLength??128,a=[];return t.length<r&&a.push(`at least ${r} characters`),t.length>i&&a.push(`no more than ${i} characters`),(n.requireUppercase??!0)&&!/[A-Z]/.test(t)&&a.push(`an uppercase letter`),(n.requireLowercase??!0)&&!/[a-z]/.test(t)&&a.push(`a lowercase letter`),(n.requireNumbers??!0)&&!/[0-9]/.test(t)&&a.push(`a number`),(n.requireSpecialChars??!0)&&!/[^A-Za-z0-9]/.test(t)&&a.push(`a special character`),a.length?`Password must contain ${a.join(`, `).replace(/, ([^,]*)$/,` and $1`)}.`:null},U=()=>{let e=P||{},t=[],n=e.minLength??12;return t.push(`${n}+ chars`),(e.requireUppercase??!0)&&t.push(`uppercase`),(e.requireLowercase??!0)&&t.push(`lowercase`),(e.requireNumbers??!0)&&t.push(`number`),(e.requireSpecialChars??!0)&&t.push(`special`),t.join(`, `)},W=e=>{if(!e)return`-`;let t=new Date(e);return isNaN(t.getTime())?`-`:t.toLocaleString()},G=async e=>{try{await f(e),B({title:`Verification email`,description:`If the account exists, a verification email was sent.`})}catch(e){let t=e instanceof Error?e.message:`Failed to send verification email`;B({title:`Error`,description:t,variant:`destructive`})}},K=(0,v.useCallback)(async()=>{try{C(!0);let{status:e,userType:t}=I,n=await _.users.listUsers({status:e||void 0,userType:t||void 0});x(n),T(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch users`;T(t),B({title:`Error`,description:t,variant:`destructive`})}finally{C(!1)}},[I,B]);(0,v.useEffect)(()=>{n&&K()},[K,n]);let q=async e=>{if(e.preventDefault(),!R.name.trim()||!R.email.trim()){B({title:`Validation Error`,description:`Name and email are required`,variant:`destructive`});return}let t=V(R.name);if(t){B({title:`Validation Error`,description:t,variant:`destructive`});return}if(!R.password.trim()){B({title:`Validation Error`,description:`Password is required`,variant:`destructive`});return}let n=H(R.password);if(n){B({title:`Validation Error`,description:n,variant:`destructive`});return}D(!0);try{let e={name:R.name.trim().toLowerCase(),email:R.email.trim(),userType:R.userType,status:R.status};if(R.password.trim()&&(e.password=R.password),await _.users.createUser(e),M&&R.status===`pending`)try{await f(R.email.trim())}catch{}z({name:``,email:``,password:``,userType:`user`,status:M?`pending`:`active`}),j(!1),await K(),B({title:`Success`,description:`User created successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to create user`;B({title:`Error`,description:t,variant:`destructive`})}finally{D(!1)}},J=async e=>{if(e.preventDefault(),!O)return;let t=V(R.name);if(t){B({title:`Validation Error`,description:t,variant:`destructive`});return}if(R.password.trim()){let e=H(R.password);if(e){B({title:`Validation Error`,description:e,variant:`destructive`});return}}D(!0);try{let e={name:R.name.trim().toLowerCase(),email:R.email.trim(),userType:R.userType,status:R.status};R.password.trim()&&(e.password=R.password),await _.users.updateUser(O.id,e),k(null),j(!1),await K(),B({title:`Success`,description:`User updated successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to update user`;B({title:`Error`,description:t,variant:`destructive`})}finally{D(!1)}},Y=async(e,t)=>{if(confirm(`Are you sure you want to delete user "${t}"? This action cannot be undone.`))try{await _.users.deleteUser(e),await K(),B({title:`Success`,description:`User deleted successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete user`;B({title:`Error`,description:t,variant:`destructive`})}},X=()=>{k(null),z({name:``,email:``,password:``,userType:`user`,status:M?`pending`:`active`}),j(!0)},Z=e=>{k(e),z({name:e.name,email:e.email,password:``,userType:e.userType,status:e.status}),j(!0)},Q=()=>{j(!1),k(null)};m(Q,A);let $=b.filter(e=>I.search===``||e.name.toLowerCase().includes(I.search.toLowerCase())||e.email.toLowerCase().includes(I.search.toLowerCase()));return n?(0,y.jsxs)(`div`,{className:`space-y-6`,children:[(0,y.jsx)(h,{onBack:e,title:`User Management`,description:`Manage user accounts and permissions`}),(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,y.jsx)(c,{placeholder:`Search users...`,value:I.search,onChange:e=>L(t=>({...t,search:e.target.value})),className:`md:w-64`}),(0,y.jsxs)(`select`,{value:I.status,onChange:e=>L(t=>({...t,status:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:``,children:`All Statuses`}),(0,y.jsx)(`option`,{value:`active`,children:`Active`}),(0,y.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,y.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,y.jsx)(`option`,{value:`deleted`,children:`Deleted`})]}),(0,y.jsxs)(`select`,{value:I.userType,onChange:e=>L(t=>({...t,userType:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:``,children:`All Types`}),(0,y.jsx)(`option`,{value:`user`,children:`User`}),(0,y.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,y.jsxs)(s,{onClick:X,children:[(0,y.jsx)(i,{className:`mr-2 h-4 w-4`}),`Create User`]})]}),(0,y.jsxs)(`div`,{className:`space-y-4`,children:[S&&(0,y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading users...`}),w&&!b.length&&(0,y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,y.jsx)(`p`,{children:w})}),!S&&!w&&$.length===0&&(0,y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No users found`}),$.length>0&&(0,y.jsx)(`div`,{className:`border rounded-md`,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`bg-muted/50`,children:[(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Name`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Email`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Type`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Status`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Created`}),(0,y.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Updated`}),(0,y.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:$.map(e=>(0,y.jsxs)(`tr`,{className:`border-t`,children:[(0,y.jsx)(`td`,{className:`p-3 font-medium`,children:e.name}),(0,y.jsx)(`td`,{className:`p-3`,children:e.email}),(0,y.jsx)(`td`,{className:`p-3`,children:(0,y.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.userType===`admin`?`bg-destructive-subtle text-destructive`:`bg-info-subtle text-info`}`,children:e.userType})}),(0,y.jsx)(`td`,{className:`p-3`,children:(0,y.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.status===`active`?`bg-success-subtle text-success`:e.status===`inactive`?`bg-warning-subtle text-warning`:e.status===`pending`?`bg-info-subtle text-info`:`bg-destructive-subtle text-destructive`}`,children:e.status})}),(0,y.jsx)(`td`,{className:`p-3`,children:W(e.createdAt)}),(0,y.jsx)(`td`,{className:`p-3`,children:W(e.updatedAt)}),(0,y.jsxs)(`td`,{className:`p-3 text-right space-x-2`,children:[(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>Z(e),children:(0,y.jsx)(a,{className:`h-4 w-4`})}),M&&e.status===`pending`&&(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>G(e.email),title:`Resend activation email`,children:`Resend activation`}),(0,y.jsx)(s,{variant:`outline`,size:`sm`,onClick:()=>Y(e.id,e.name),className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,disabled:e.id===t?.id,title:e.id===t?.id?`Cannot delete your own account`:`Delete user`,children:(0,y.jsx)(o,{className:`h-4 w-4`})})]})]},e.id))})]})})})]}),A&&(0,y.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,y.jsxs)(`div`,{className:`bg-card rounded-lg p-6 w-full max-w-md mx-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,y.jsx)(`h3`,{className:`text-lg font-semibold`,children:O?`Edit User`:`Create New User`}),(0,y.jsx)(s,{variant:`ghost`,size:`sm`,onClick:Q,children:(0,y.jsx)(r,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`form`,{onSubmit:O?J:q,className:`space-y-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`name`,children:`Username`}),(0,y.jsx)(c,{id:`name`,type:`text`,value:R.name,onChange:e=>z(t=>({...t,name:e.target.value.toLowerCase().replace(/\s+/g,``)})),placeholder:`Enter username`,disabled:E,required:!0}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`3-39 characters, lowercase letters, numbers, underscores, and hyphens only`})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`email`,children:`Email`}),(0,y.jsx)(c,{id:`email`,type:`email`,value:R.email,onChange:e=>z(t=>({...t,email:e.target.value})),placeholder:`Enter email address`,disabled:E,required:!0})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(l,{htmlFor:`password`,children:[`Password `,O&&`(leave blank to keep current)`]}),(0,y.jsx)(c,{id:`password`,type:`password`,value:R.password,onChange:e=>z(t=>({...t,password:e.target.value})),placeholder:O?`Leave blank to keep current`:`Enter password`,disabled:E,required:!O}),!O&&(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Must satisfy: `,U()]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`userType`,children:`User Type`}),(0,y.jsxs)(`select`,{id:`userType`,value:R.userType,onChange:e=>z(t=>({...t,userType:e.target.value})),disabled:E,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:`user`,children:`User`}),(0,y.jsx)(`option`,{value:`admin`,children:`Admin`})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(l,{htmlFor:`status`,children:`Status`}),(0,y.jsxs)(`select`,{id:`status`,value:R.status,onChange:e=>z(t=>({...t,status:e.target.value})),disabled:E,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,y.jsx)(`option`,{value:`active`,children:`Active`}),(0,y.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,y.jsx)(`option`,{value:`pending`,children:`Pending`}),(0,y.jsx)(`option`,{value:`deleted`,children:`Deleted`})]})]}),(0,y.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[(0,y.jsx)(s,{type:`submit`,disabled:E,className:`flex-1`,children:E?`Processing...`:O?`Update User`:`Create User`}),(0,y.jsx)(s,{type:`button`,variant:`outline`,onClick:Q,disabled:E,children:`Cancel`})]})]})]})})]}):(0,y.jsx)(`div`,{className:`text-center space-y-4`,children:(0,y.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{b as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{vt as r}from"./react-BHzhHVTZ.js";import{t as i}from"./button--VYZekMF.js";import{t as a}from"./input-BOtCd4HP.js";import{c as o,l as s,t as c}from"./api-CA6WiiYM.js";import{a as l,c as u,i as ee,s as te,t as ne}from"./alert-dialog-BKtaX1_a.js";var re=`data/schema/note`,ie=`data/schema/link`,ae=`data/schema/tab`,oe=`data/schema/file`,se=`data/schema/drawing`,ce=`data/schema/message/email`,le=`data/schema/task`,ue=`data/schema/event/calendar`,d=`data/schema/identity`;function f(e,t){return e.startsWith(`${t}/`)?e.slice(t.length+1):``}var de={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,oga:`audio/ogg`,m4a:`audio/mp4`,flac:`audio/flac`,aac:`audio/aac`,mp4:`video/mp4`,m4v:`video/mp4`,webm:`video/webm`,mov:`video/quicktime`,mkv:`video/x-matroska`,avi:`video/x-msvideo`,ogv:`video/ogg`,pdf:`application/pdf`,html:`text/html`,htm:`text/html`,xhtml:`application/xhtml+xml`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,json:`application/json`,xml:`application/xml`,csv:`text/csv`,log:`text/plain`,yml:`text/yaml`,yaml:`text/yaml`};function fe(e){let t=/\.([a-z0-9]+)$/i.exec(e||``);return t?t[1].toLowerCase():``}function pe(e){return de[fe(e)]}function p(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:e===`application/pdf`?`pdf`:e===`text/html`||e===`application/xhtml+xml`?`html`:e.startsWith(`text/`)||e.endsWith(`+json`)||e===`application/json`||e===`application/xml`?`text`:null}function me(e,t){if(e=e.split(`;`)[0].trim().toLowerCase(),e===`text/markdown`||/\.(md|markdown)$/i.test(t||``))return`markdown`;if(e&&e!==`application/octet-stream`){let t=p(e);if(t)return t}let n=pe(t);if(n){let e=p(n);if(e)return e}return`binary`}function he(e){if(!e)return null;try{let t=new URL(e),n=t.hostname.replace(/^www\.|^m\./,``);if(n===`youtu.be`)return t.pathname.slice(1).split(`/`)[0]||null;if(n===`youtube.com`||n===`youtube-nocookie.com`){if(t.pathname===`/watch`)return t.searchParams.get(`v`);let e=t.pathname.match(/^\/(shorts|embed|live)\/([^/]+)/);if(e)return e[2]}return null}catch{return null}}var ge=`data/schema/message/email`,_e=`data/schema/tab`,m=`data/schema/task`;function h(e,t){let n=String(e||``).replace(/\s+/g,` `).trim();return n?n.length>t?`${n.slice(0,t)}...`:n:``}function g(e){return String(e||``).replace(/```[\s\S]*?```/g,` `).replace(/`([^`]*)`/g,`$1`).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*>\s?/gm,``).replace(/^\s*[-*+]\s+/gm,``).replace(/(\*\*|__|\*|_|~~)/g,``)}function _(e){if(!e)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(_).filter(Boolean).join(`, `);if(typeof e==`object`){let t=e,n=String(t.address||``).trim(),r=String(t.name||``).trim();return r&&n&&r!==n?`${r} <${n}>`:r||n}return``}function ve(e){let t=Array.isArray(e?.channels)?e.channels.length:0,n=Array.isArray(e?.identifiers)?e.identifiers.length:0,r=Array.isArray(e?.organizations)?e.organizations.length:0;return[t?`${t} channel${t===1?``:`s`}`:``,n?`${n} identifier${n===1?``:`s`}`:``,r?`${r} organization${r===1?``:`s`}`:``].filter(Boolean).join(` · `)}function ye(e){let t=String(e?.displayName||``).trim();if(t)return t;let n=e?.name;if(!n||typeof n!=`object`)return String(n||``).trim();let r=n;return[r.prefix,r.given,r.middle,r.family,r.suffix].map(e=>String(e||``).trim()).filter(Boolean).join(` `)}function be(e){let t=String(e?.primaryEmail||``).trim();if(t)return t;let n=Array.isArray(e?.channels)?e.channels:[],r=n.find(e=>e?.kind===`email`&&e?.primary)||n.find(e=>e?.kind===`email`);return String(r?.value||``).trim()}function xe(e){try{let t=new URL(e);return`${t.hostname}${t.pathname}`}catch{return e}}function Se(e){return e.schema===`data/schema/file`&&String(e.metadata?.contentType||``).startsWith(`image/`)}var Ce=/^(imaps?|pop3s?|mailto|graph|ews|news|nntp):/i;function we(e){if(!e||Ce.test(e))return``;let t=e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``),n=t.indexOf(`/`),r=(n>=0?t.slice(n+1):t).split(`/`).filter(Boolean).pop();if(!r)return``;let i;try{i=decodeURIComponent(r)}catch{i=r}return/^stored:\/\//i.test(e)&&!Te(i)?``:i}function Te(e){return e.length>0&&!/^[a-f0-9]{12,}$/i.test(e)&&!/^[a-f0-9]{16,}\.[A-Za-z0-9]{1,12}$/i.test(e)}function Ee(e){return typeof e.comment==`string`?e.comment.trim():``}function v(e){let t=String(e.metadata?.filename||``).trim();if(t)return t;let n=String(e.data?.filename||``).trim();if(n)return n;let r=(e.locations||[]).filter(Boolean),i=r.find(e=>/^stored:\/\/workspace:/i.test(e.url||``)),a=String(i?.metadata?.filename||``).trim();if(a)return a;let o=[...r].sort((e,t)=>String(e.url||``).localeCompare(String(t.url||``))),s=o.find(e=>String(e.metadata?.filename||``).trim());if(s)return String(s.metadata?.filename||``).trim();for(let e of o){let t=we(e.url);if(t)return t}return``}function De(e){let t=e.data;for(let e of[t.url,t.htmlUrl,t.htmlLink])if(typeof e==`string`&&/^https?:\/\//i.test(e))return e;for(let t of e.locations||[])if(typeof t?.url==`string`&&/^https?:\/\//i.test(t.url))return t.url;return null}function y(e){let t=e.schema===ge,n=e.schema===_e,r=e.schema.split(`/`).pop()||e.schema;if(t)return{title:h(e.data.title||e.data.name||e.data.subject,160)||`Email ${e.id}`,preview:h(e.data.bodyPreview||e.data.body||``,140),subtitle:h(_(e.data.from),120),icon:`mail`,isExternal:!1,schemaLabel:r};if(e.schema===`data/schema/message`){let t=e.data.sender,n=e.data.channel;return{title:h(e.data.text,160)||`Message`,preview:h(e.data.text,400),subtitle:[t?.name||t?.displayName||t?.username||t?.id,n?.name||n?.id].filter(Boolean).join(` · `),icon:`mail`,isExternal:!1,schemaLabel:r}}if(n||e.schema===`data/schema/link`){let t=String(e.data.title||e.data.name||e.data.label||``).trim(),n=String(e.data.url||e.data.uri||``).trim();return{title:t||xe(n)||`Document ${e.id}`,preview:h(e.data.description||e.data.summary||n,140),subtitle:n,icon:`globe`,isExternal:!!n,schemaLabel:r}}if(e.schema===m||e.schema.startsWith(`${m}/`)){let t=String(e.data.status||(e.data.completed?`completed`:`pending`)).trim(),n=e.data.dueDate?new Date(String(e.data.dueDate)):null,i=n&&!Number.isNaN(n.getTime())?n.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):``;return{title:h(e.data.title||e.data.name,160)||`Task ${e.id}`,preview:h(g(e.data.description||e.data.summary),400),subtitle:[t,i?`due ${i}`:``].filter(Boolean).join(` · `),icon:`file`,isExternal:!1,schemaLabel:r}}if(e.schema===`data/schema/identity`||e.schema.startsWith(`data/schema/identity/`)){let t=be(e.data),n=f(e.schema,d);return{title:h(ye(e.data),160)||`Identity ${e.id}`,preview:h(ve(e.data),140),subtitle:[t,n].filter(Boolean).join(` · `),icon:t?`mail`:`file`,isExternal:!1,schemaLabel:r}}if(e.schema===`data/schema/file`){let t=v(e),n=String(e.metadata?.contentType||``).trim(),i=e.metadata?.size,a=[n,Number.isFinite(i)?`${i} bytes`:``].filter(Boolean);return{title:h(t||e.data.title||e.data.name,160)||`File ${e.id}`,preview:a.join(` · `),subtitle:t,icon:`file`,isExternal:!1,schemaLabel:r}}return{title:h(e.data.title||e.data.name||e.data.subject||v(e),160)||`Document ${e.id}`,preview:h(g(e.data.content||e.data.description||e.data.summary||e.data.bodyPreview||e.data.body),400),subtitle:``,icon:`file`,isExternal:!1,schemaLabel:r}}function b(e){return e===`alphabetical`||e===`type`}function x(e){return e.schema===`data/schema/file`?(/\.([^.]+)$/.exec(v(e))?.[1]||e.metadata?.contentType||`file`).toLowerCase():e.schema.split(`/`).pop()||e.schema}function S(e,t,n=`asc`){let r=n===`desc`?-1:1,i=(e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`}),a=e.map(e=>({document:e,title:y(e).title,type:x(e)}));return a.sort((e,n)=>((t===`type`?i(e.type,n.type):0)||i(e.title,n.title)||e.document.id-n.document.id)*r),a.map(({document:e})=>e)}async function C(e,t){let n=[],r=new Set,i,a=0,o=500;for(;i=await t({limit:o,offset:a,page:void 0}),a===0&&i.payload.length&&i.payload.length<o&&(i.totalCount==null||i.payload.length<i.totalCount)&&(o=i.payload.length,i=await t({limit:o,offset:a,page:void 0})),!(!i.payload.length&&(i.totalCount==null||a>=i.totalCount));){let e=0;for(let t of i.payload)r.has(t.id)||(r.add(t.id),n.push(t),e++);if(i.payload.length&&!e)throw Error(`Document pagination did not advance`);if(a+=o,i.totalCount!=null&&a>=i.totalCount)break}let s=S(n,e.sortBy,e.order),c=e.limit??50,l=Math.max(0,e.offset??((e.page??1)-1)*(c||100)),u=c===0?s:s.slice(l,l+c);return{...i,payload:u,count:u.length,totalCount:s.length}}var w=e(n(),1),Oe=r(),T=t();function ke(e){return new Promise((t,n)=>{let r=document.createElement(`div`);document.body.appendChild(r);let o=(0,Oe.createRoot)(r),s=e=>{o.unmount(),r.remove(),e?t(e):n(Error(`Workspace start cancelled`))};function c(){let[t,n]=(0,w.useState)(``);return(0,T.jsx)(ne,{open:!0,onOpenChange:e=>{e||s()},children:(0,T.jsxs)(ee,{children:[(0,T.jsxs)(te,{children:[(0,T.jsx)(u,{children:`Start protected workspace`}),(0,T.jsx)(l,{children:e===`workspace`?`Enter the workspace PIN/password or recovery key to start.`:`Unlock integrations, or start with authenticated integrations unavailable.`})]}),(0,T.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),s({passphrase:t})},children:[(0,T.jsxs)(`label`,{className:`space-y-2 block text-sm`,children:[`PIN/password or recovery key`,(0,T.jsx)(a,{autoFocus:!0,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,T.jsx)(i,{type:`submit`,disabled:!t,children:`Unlock and start`}),e===`secrets`&&(0,T.jsx)(i,{type:`button`,variant:`outline`,onClick:()=>s({withoutSecrets:!0}),children:`Start without integrations`}),(0,T.jsx)(i,{type:`button`,variant:`ghost`,onClick:()=>s(),children:`Cancel`})]})]})]})})}o.render((0,T.jsx)(c,{}))})}var Ae={gh:`GitHub`,slack:`Slack`,gcal:`Google Calendar`,caldav:`CalDAV`,msteams:`Microsoft Teams`};function je(e){for(let t of e.locations||[]){let e=t?.url;if(typeof e!=`string`)continue;let n=e.indexOf(`://`);if(n<=0)continue;let r=e.slice(0,n),i=Ae[r];if(i)return{scheme:r,label:i,url:e}}return null}var E=new Map,D=new Set;function O(){for(let e of D)e()}function Me(e){E.set(e,(E.get(e)||0)+1),O()}function Ne(e){let t=(E.get(e)||0)-1;t>0?E.set(e,t):E.delete(e),O()}function Pe(e){return D.add(e),()=>{D.delete(e)}}function Fe(e){let t=(0,w.useCallback)(()=>e!=null&&E.has(e),[e]);return(0,w.useSyncExternalStore)(Pe,t,()=>!1)}function Ie(e){let t=Fe(e.id),n=je(e),r=t&&n!=null;return{mirror:n,replicating:r,label:r?`Replicating to ${n.label}…`:``}}var k=`context`,Le=`backends`,A=e=>e===`directory`||e===`backends`?`directory`:`context`,j=`data/schema/identity`;function Re(e,t){if(!e||t===`/`)return null;let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e),!r)return null;return r??null}var M=new Map,N=new Map;function P(e,t=`/`,n=k,r=`context`){e.append(`treeNameOrTreeId`,n),e.append(`treeType`,r),t&&e.append(`context`,t)}function F(e,t=[]){t.filter(Boolean).forEach(t=>e.append(`allOf`,t))}function ze(e,t=[]){t.filter(Boolean).forEach(t=>e.append(`anyOf`,t))}function Be(e,t=[]){t.filter(Boolean).forEach(t=>e.append(`noneOf`,t))}function Ve(e,t=[]){t.filter(Boolean).forEach(t=>e.append(`filters`,t))}function He(e,t){for(let n of t??[])e.append(`ids`,String(n))}function Ue(e,t){for(let n of t??[]){let t=n.op===`allOf`?`+`:n.op===`noneOf`?`!`:``;e.append(`rel`,`${t}${n.p}:${n.of}:${n.dir??`out`}`)}}function I(e,t,n){let r=(t&&t.length?t:n?[n]:[]).map(e=>e.trim()).filter(Boolean);for(let t of r)e.append(`q`,t)}function We(e,t=k){return`${o.workspaces}/${e}/trees/${encodeURIComponent(t)}`}function L(e,t=k){return`${e}\0${t}`}function Ge(e){return String(e||`/`).split(`/`).filter(Boolean).map(encodeURIComponent).join(`/`)}function R(e,t,n){let r=Ge(n);return`${We(e,t)}/path/${r}`}async function Ke(e){let t=await c.get(`${o.workspaces}/${e}`);return t&&`workspace`in t?{...t.workspace,access:t.access}:t}async function qe(e){return c.get(`${o.workspaces}/${e}/status`)}async function Je(){try{let e=await c.get(o.workspaces);return Array.isArray(e)?e:(console.warn(`listWorkspaces: response.payload is not an array:`,e),[])}catch(e){throw console.error(`Failed to list workspaces:`,e),e}}async function Ye(){return c.post(`${o.workspaces}/scan`)}async function Xe(e){try{return await c.post(o.workspaces,e)}catch(e){throw console.error(`Failed to create workspace:`,e),e}}var Ze={resolving:`Resolving token on the remote server…`,exporting:`Remote server is packing the workspace…`,downloading:`Downloading archive…`,extracting:`Extracting…`,loading:`Validating and loading…`,done:`Done`};async function Qe(e){return c.get(`${o.workspaces}/import/jobs/${encodeURIComponent(e)}`)}async function z(e,t,{intervalMs:n=1500,signal:r}={}){for(;;){if(r?.aborted)throw Error(`Import tracking cancelled`);let i=await Qe(e);if(t?.(i),i.status===`done`){if(!i.result)throw Error(`Import finished without returning a workspace`);return i.result}if(i.status===`failed`)throw Error(i.error?.message||`Import failed`);await new Promise(e=>setTimeout(e,n))}}async function $e(e,t,n,r={}){return z((await c.post(`${o.workspaces}/import`,{url:e,token:t,...r})).id,n)}async function et(){return c.get(`${o.workspaces}/remotes`)}async function tt(e,t,n){return c.post(`${o.workspaces}/remotes`,{url:e,token:t,...n?{label:n}:{}})}async function nt(e){await c.delete(`${o.workspaces}/remotes/${encodeURIComponent(e)}`)}async function rt(e,t={}){return c.post(`${o.workspaces}/${e}/export`,{stop:t.stop===!0})}async function it(e){return c.get(`${o.workspaces}/${e}/exports`)}async function at(e){await c.delete(`${o.workspaces}/exports/${encodeURIComponent(e)}`)}async function ot(e){await c.post(`${o.workspaces}/exports/ticket`);let t=`${o.workspaces}/exports/${encodeURIComponent(e)}`,n=document.createElement(`a`);n.href=t,n.download=e,document.body.appendChild(n),n.click(),n.remove()}async function st(e,t,n,r={}){return z((await ct(e,t,r)).id,n)}function ct(e,t,n={}){let r=localStorage.getItem(`authToken`),i=new URLSearchParams({filename:e.name,...n}),a=`${o.workspaces}/import/upload?${i}`;return new Promise((n,i)=>{let o=new XMLHttpRequest;o.open(`POST`,a,!0),o.withCredentials=!0,r&&o.setRequestHeader(`Authorization`,`Bearer ${r}`),o.setRequestHeader(`Content-Type`,`application/octet-stream`),o.upload.onprogress=e=>{e.lengthComputable&&t&&t(e.loaded/e.total)},o.onload=()=>{let e=null;try{e=JSON.parse(o.responseText)}catch{}let t=e?.payload?.job;o.status>=200&&o.status<300&&t?n(t):i(Error(e?.message||`Import failed (HTTP ${o.status})`))},o.onerror=()=>i(Error(`Upload failed — the connection dropped`)),o.onabort=()=>i(Error(`Upload cancelled`)),o.send(e)})}async function lt(e,t,n){let r=await c.post(`${o.workspaces}/import`,{path:e,...t});return`phase`in r?z(r.id,n):r}async function ut(e,t){try{if(!t){let n=await c.get(`${o.workspaces}/${e}/status`),r=n.protection?.mode||`none`;t=n.status!==`active`&&r!==`none`?await ke(r):{}}let n=await c.post(`${o.workspaces}/${e}/start`,t);return window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),n}catch(e){throw console.error(`Failed to start workspace:`,e),e}}async function dt(e){try{let t=await c.post(`${o.workspaces}/${e}/stop`);return V(e),window.dispatchEvent(new CustomEvent(`workspace:stopped`,{detail:{refs:[e]}})),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),t}catch(e){throw console.error(`Failed to stop workspace:`,e),e}}async function ft(e){try{return await c.delete(`${o.workspaces}/${e}`)}catch(e){throw console.error(`Failed to remove workspace:`,e),e}}async function pt(e){try{return await c.get(`${o.workspaces}/${e}/trees`)||[]}catch(t){throw console.error(`Failed to list workspace trees ${e}:`,t),t}}async function B(e,t){try{return await c.get(`${o.workspaces}/${e}/trees/${encodeURIComponent(t)}`)}catch(n){throw console.error(`Failed to get workspace tree ${e}/${t}:`,n),n}}function V(e,t){if(!e){M.clear(),N.clear();return}if(!t){let t=`${e}\0`;for(let e of M.keys())e.startsWith(t)&&M.delete(e);for(let e of N.keys())e.startsWith(t)&&N.delete(e);return}let n=L(e,t);M.delete(n),N.delete(n)}var mt=`.trash`;function ht(e){return e?Array.isArray(e.children)?{...e,children:e.children.filter(e=>e?.name!==mt)}:e:null}async function gt(e,t,n={}){let r=L(e,t);if(!n.force&&M.has(r))return M.get(r);if(!n.force&&N.has(r))return N.get(r);let i=B(e,t).then(e=>{let t=ht(e);return N.get(r)===i&&M.set(r,t),t}).finally(()=>{N.get(r)===i&&N.delete(r)});return N.set(r,i),i}function H(e,t,n){let r=new URLSearchParams;Ue(r,n.rel);let i=new URLSearchParams;return I(i,n.queries,n.q),{treeNameOrTreeId:n.treeName||`context`,...n.treeType?{treeType:n.treeType}:{},context:e||`/`,scope:n.scope??`path`,allOf:t.filter(Boolean),anyOf:(n.anyOf??[]).filter(Boolean),noneOf:(n.noneOf??[]).filter(Boolean),filters:(n.filters??[]).filter(Boolean),rel:r.getAll(`rel`),q:i.getAll(`q`),...n.ids?.length?{ids:[...n.ids]}:{},applyCanvasSpec:n.applyCanvasSpec!==!1,...n.layerId&&n.scope!==`workspace`?{layerId:n.layerId}:{}}}async function U(e,t=`/`,n=[],r={}){if(b(r.sortBy))return C(r,i=>U(e,t,n,{...r,...i,sortBy:void 0,order:`asc`}));try{let i=new URLSearchParams,a=H(t,n,r);for(let[e,t]of Object.entries(a))Array.isArray(t)?t.forEach(t=>i.append(e,String(t))):i.append(e,String(t));r.limit!==void 0&&i.append(`limit`,r.limit.toString()),r.offset!==void 0&&i.append(`offset`,r.offset.toString()),r.page!==void 0&&i.append(`page`,r.page.toString()),r.debug&&i.append(`debug`,`true`),r.debug&&r.debugLimit&&i.append(`debugLimit`,String(r.debugLimit)),r.sortBy&&i.append(`sortBy`,r.sortBy),r.order&&i.append(`order`,r.order);let s=i.toString(),l=`${o.workspaces}/${e}/documents${s?`?`+s:``}`;return await c.getEnvelope(l)}catch(t){throw console.error(`Failed to get workspace documents ${e}:`,t),t}}async function _t(e,t,n=k,r={}){return U(e,t,r.allOf||[],{treeName:n,treeType:A(n),limit:r.limit,page:r.page,offset:r.offset,q:r.q,queries:r.queries,anyOf:r.anyOf,noneOf:r.noneOf,filters:r.filters,ids:r.ids,sortBy:r.sortBy,order:r.order,applyCanvasSpec:r.applyCanvasSpec})}async function W(e,t,n,r={}){if(b(r.sortBy))return C(r,i=>W(e,t,n,{...r,...i,sortBy:void 0,order:`asc`}));try{let i=new URLSearchParams;r.limit!==void 0&&i.append(`limit`,r.limit.toString()),r.offset!==void 0&&i.append(`offset`,r.offset.toString()),r.page!==void 0&&i.append(`page`,r.page.toString()),I(i,r.queries,r.q),F(i,r.allOf),ze(i,r.anyOf),Be(i,r.noneOf),Ve(i,r.filters),He(i,r.ids),r.sortBy&&i.append(`sortBy`,r.sortBy),r.order&&i.append(`order`,r.order);let a=i.toString(),s=`${o.workspaces}/${e}/trees/${encodeURIComponent(t)}/layers/${encodeURIComponent(n)}/documents${a?`?`+a:``}`;return await c.getEnvelope(s)}catch(r){throw console.error(`Failed to get workspace layer documents ${e}/${t}/${n}:`,r),r}}async function vt(e,t){try{return await c.patch(`${o.workspaces}/${e}`,t)}catch(e){throw console.error(`Failed to update workspace:`,e),e}}async function yt(e,t,n=!0,r=k,i=`context`){try{return await c.put(R(e,r,t),{type:i,autoCreateLayers:n}),!0}catch(e){throw console.error(`Failed to insert workspace path ${t}:`,e),e}}async function bt(e,t,n=k,r={}){try{return await c.put(R(e,n,t),{type:`canvas`,...r}),!0}catch(e){throw console.error(`Failed to create workspace canvas ${t}:`,e),e}}async function xt(e,t,n,r,i){let a={metadata:r};return i&&(a.querySpec=i),await c.patch(R(e,n,t),a),!0}async function St(e,t,n=k){return await c.post(`${s}/pub/c`,{workspaceId:e,path:t,treeName:n})}async function Ct(e,t,n=k){let r=new URLSearchParams({workspaceId:e,path:t,treeName:n});return await c.get(`${s}/pub/c?${r.toString()}`)}async function wt(e){return await c.delete(`${s}/pub/c/${encodeURIComponent(e)}`),!0}async function Tt(e){let t=await c.get(`${o.workspaces}/${e}/shares`);return{publicCanvasShares:t?.publicCanvasShares||[],emailShares:t?.emailShares||[]}}async function Et(e,t){return await c.delete(`${o.workspaces}/${e}/shares/public-canvas/${encodeURIComponent(t)}`),!0}async function Dt(e,t,n,r=k){try{return await c.patch(R(e,r,t),n),!0}catch(e){throw console.error(`Failed to update workspace path ${t}:`,e),e}}async function Ot(e,t,n=!1,r=k,i=!1,a=!1){try{let o=new URLSearchParams({recursive:n.toString()});return i&&o.set(`purge`,`true`),a&&o.set(`destroy`,`true`),await c.delete(`${R(e,r,t)}?${o.toString()}`),!0}catch(e){throw console.error(`Failed to remove workspace path ${t}:`,e),e}}async function kt(e,t,n,r=!1,i=k,a,o={}){try{return await c.patch(R(e,i,t),{to:n,recursive:r,...o.mergeDown?{mergeDown:!0}:{},...a&&a!==i?{targetTreeNameOrTreeId:a}:{}}),!0}catch(e){throw console.error(`Failed to move workspace path from ${t} to ${n}:`,e),e}}async function At(e,t,n,r=!1,i=k,a){try{return await c.post(R(e,i,t),{to:n,recursive:r,...a&&a!==i?{targetTreeNameOrTreeId:a}:{}}),!0}catch(e){throw console.error(`Failed to copy workspace path from ${t} to ${n}:`,e),e}}async function jt(e,t,n,r=k,i=`context`){try{let a=K(Array.isArray(n)?n:[n]),s=performance.now();return await c.post(`${o.workspaces}/${e}/documents`,{documentIds:a,treeNameOrTreeId:r,treeType:i,context:t}),console.info(`[paste] linked ${a.length} document(s) → ${r}:${t} in ${Math.round(performance.now()-s)} ms`),!0}catch(e){throw console.error(`Failed to paste documents to workspace path ${t}:`,e),e}}async function Mt(e,t,n,r=k,i=`context`){try{let a=Array.isArray(n)?n:[n],s=await c.post(`${o.workspaces}/${e}/documents`,{documents:a,treeNameOrTreeId:r,treeType:i,context:t});return Array.isArray(s)?s:[]}catch(e){throw console.error(`Failed to import documents to workspace path ${t}:`,e),e}}var G=e=>`${o.workspaces}/${e}/pins`,Nt=(e,t)=>`${e}\0${t}`;async function Pt(e){let t=await c.get(G(e));return Array.isArray(t)?t:[]}async function Ft(e,t,n=k){return c.post(G(e),{path:t,tree:n})}async function It(e,t){await c.delete(`${G(e)}/${encodeURIComponent(t)}`)}async function Lt(e,t){let n=await c.patch(`${G(e)}/order`,{order:t});return Array.isArray(n)?n:[]}async function Rt(e,t=k){return await c.get(`${o.workspaces}/${e}/trees/${encodeURIComponent(t)}/layers`)||[]}async function zt(e,t,n,r=k){return await c.patch(`${o.workspaces}/${e}/trees/${encodeURIComponent(r)}/layers/${t}`,{name:n})}async function Bt(e,t,n,r=k){return await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(r)}/layers/${t}/lock`,{lockBy:n}),!0}async function Vt(e,t,n,r=k){return await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(r)}/layers/${t}/unlock`,{lockBy:n}),!0}async function Ht(e,t,n=k){return await c.delete(`${o.workspaces}/${e}/trees/${encodeURIComponent(n)}/layers/${t}`),!0}async function Ut(e,t,n,r=k){return await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(r)}/layers/merge`,{layerId:t,targetLayers:n})}async function Wt(e,t,n=k){return(await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(n)}/paths/merge-down`,{path:t}))?.data??null}async function Gt(e,t,n=k){return(await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(n)}/paths/subtract-down`,{path:t}))?.data??null}async function Kt(e,t,n,r=k){return await c.post(`${o.workspaces}/${e}/trees/${encodeURIComponent(r)}/layers/subtract`,{layerId:t,targetLayers:n})}function K(e){let t=e.map(e=>typeof e==`number`?e:Number(e));if(t.some(e=>!Number.isFinite(e)))throw Error(`Invalid document ID(s): expected numbers (or numeric strings), got ${JSON.stringify(e)}`);return t}async function qt(e,t,n=`/`,r=[],i=k,a=`context`,s={}){let l=new URLSearchParams;P(l,n,i,a),F(l,r),s.trashIfOrphaned&&l.append(`trashIfOrphaned`,`true`);let u=K(t);return await c.delete(`${o.workspaces}/${e}/documents/remove?${l.toString()}`,{headers:{"Content-Type":`application/json`},body:JSON.stringify(u)}),!0}async function Jt(e,t,n=`/`,r=[],i=k,a=`context`){let s=new URLSearchParams;P(s,n,i,a),F(s,r);let l=K(t);return await c.delete(`${o.workspaces}/${e}/documents?${s.toString()}`,{headers:{"Content-Type":`application/json`},body:JSON.stringify(l)}),!0}async function Yt(e,t){Me(t.id);try{await c.put(`${o.workspaces}/${e}/documents`,{documents:[t]})}finally{Ne(t.id)}return!0}async function Xt(e,t,n={}){let r={documentIds:K(t)};return n.urls&&(r.urls=n.urls),n.keepDocument&&(r.keepDocument=!0),await c.delete(`${o.workspaces}/${e}/documents/destroy`,{headers:{"Content-Type":`application/json`},body:JSON.stringify(r)})}async function Zt(e,t,n){let r=n.folder?.trim().replace(/^\/+|\/+$/g,``),i=n.filename?.trim();return await c.post(`${o.workspaces}/${e}/documents/transfer`,{documentIds:K(t),to:n.to,mode:n.mode??`copy`,...n.deleteFrom?{deleteFrom:n.deleteFrom}:{},...n.keepDocument?{keepDocument:!0}:{},...r?{folder:r}:{},...i?{filename:i}:{},...n.onConflict?{onConflict:n.onConflict}:{}})}function Qt(e){return typeof e.capabilities?.paths==`boolean`?e.capabilities.paths:e.kind===`storage`&&e.driver!==`cacache`}async function $t(e,t){return await c.get(`${o.workspaces}/${encodeURIComponent(e)}/documents/${t}`)}async function en(e,t,n){return await c.get(`${o.workspaces}/${encodeURIComponent(e)}/documents/by-hash/${encodeURIComponent(t)}/${encodeURIComponent(n)}`)}async function tn(e,t){return await c.get(`${o.workspaces}/${e}/documents/${t}/locations`)||[]}async function nn(e,t,n){let r=n?`?tree=${encodeURIComponent(n)}`:``;return(await c.get(`${o.workspaces}/${e}/documents/${t}/memberships${r}`))?.memberships||[]}async function rn(e,t,n=500){return(await U(e,`/`,[t?`${j}/${t}`:j],{scope:`workspace`,limit:n})).payload||[]}async function an(e){return(await c.get(`${o.workspaces}/${encodeURIComponent(e)}/documents/relations/predicates`))?.predicates??[]}async function on(e,t,n={}){let r=new URLSearchParams;n.resolve===!1&&r.set(`resolve`,`false`),n.offset!==void 0&&r.set(`offset`,String(n.offset)),n.limit!==void 0&&r.set(`limit`,String(n.limit)),n.summary&&r.set(`summary`,`true`);let i=r.size?`?${r}`:``;return await c.get(`${o.workspaces}/${e}/documents/${t}/relations${i}`)??{documentId:Number(t),predicates:[],outgoing:[],incoming:[]}}async function sn(e,t,n,r,i=`out`){return await c.post(`${o.workspaces}/${e}/documents/${t}/relations`,{p:n,to:Array.isArray(r)?K(r):r,dir:i}),!0}async function cn(e,t,n,r,i=`out`){return await c.delete(`${o.workspaces}/${e}/documents/${t}/relations`,{headers:{"Content-Type":`application/json`},body:JSON.stringify({p:n,to:r,dir:i})}),!0}function q(e,t,n={}){let r=new URLSearchParams;n.version&&r.set(`v`,n.version),n.download&&r.set(`download`,`1`),n.url&&r.set(`url`,n.url),n.format&&r.set(`format`,n.format);let i=r.toString();return`${o.workspaces}/${e}/documents/${t}/content${i?`?${i}`:``}`}async function ln(e,t,n=256,r){let i=localStorage.getItem(`authToken`),a=r?`&v=${encodeURIComponent(r)}`:``,s=await fetch(`${o.workspaces}/${e}/documents/${t}/thumbnail?size=${n}${a}`,{headers:i?{Authorization:`Bearer ${i}`}:{}});if(!s.ok)throw Error(`HTTP ${s.status}`);let c=s.headers.get(`content-type`)||`image/webp`;return{blob:await s.blob(),mime:c}}async function un(e,t,n={}){let r=localStorage.getItem(`authToken`),i=await fetch(q(e,t,n),{signal:n.signal,headers:r?{Authorization:`Bearer ${r}`}:{}});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=i.headers.get(`content-type`)||`application/octet-stream`;return{blob:await i.blob(),mime:a}}function dn(e,t,n={}){return q(e,t,n)}async function fn(e,t){let n=localStorage.getItem(`authToken`);return(await fetch(`${o.workspaces}/${e}/documents/${t}/content-ticket`,{method:`POST`,headers:n?{Authorization:`Bearer ${n}`}:{},credentials:`include`})).ok}async function pn(e,t,n,r={}){let i=localStorage.getItem(`authToken`),a=await fetch(q(e,t,{download:!0,url:r.url}),{headers:i?{Authorization:`Bearer ${i}`}:{}});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.blob(),s=URL.createObjectURL(o),c=document.createElement(`a`);c.href=s,c.download=n,document.body.appendChild(c),c.click(),c.remove(),setTimeout(()=>URL.revokeObjectURL(s),3e4)}async function mn(e,t,n){return c.post(`${o.workspaces}/${e}/documents/purge`,{selection:t,expectedCount:n})}async function hn(e){try{return await c.get(`${o.workspaces}/${e}/services`)}catch(e){throw console.error(`Failed to get workspace services status:`,e),e}}async function gn(e,t){try{return await c.post(`${o.workspaces}/${e}/services/${t}/enable`)}catch(e){throw console.error(`Failed to enable ${t} service:`,e),e}}async function _n(e,t){try{return await c.post(`${o.workspaces}/${e}/services/${t}/disable`)}catch(e){throw console.error(`Failed to disable ${t} service:`,e),e}}var J=e=>`${o.workspaces}/${e}/backends`,Y=(e,t,n)=>`${J(e)}/${encodeURIComponent(t)}/${encodeURIComponent(n)}`;async function vn(e,t){let n=t?`${J(e)}/${encodeURIComponent(t)}`:J(e);return await c.get(n)||[]}async function yn(e,t,n){return await c.get(Y(e,t,n))}async function bn(e,t,n){return await c.get(`${Y(e,t,n)}/usage`)}async function xn(e){return await c.delete(`${o.workspaces}/${e}/thumbnails`)}async function Sn(e){return await c.get(`${o.workspaces}/${e}/usage`)}function Cn(e){if(e==null||!Number.isFinite(e))return`—`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=`B`;for(let e of t){if(n<1024)break;n/=1024,r=e}return`${n.toFixed(n>=100?0:1)} ${r}`}async function wn(e,t,n){return await c.post(`${J(e)}/${encodeURIComponent(t)}`,n)}async function Tn(e,t,n,r){return await c.patch(Y(e,t,n),r)}async function En(e,t,n){return await c.delete(Y(e,t,n))}async function Dn(e,t,n){return await c.post(`${Y(e,t,n)}/sync`)}async function On(e,t,n){return await c.post(`${Y(e,t,n)}/sync/cancel`)}async function kn(e,t,n){return await c.post(`${Y(e,t,n)}/test`)}async function An(e,t,n){return await c.get(`${Y(e,t,n)}/containers`)||[]}async function jn(e,t,n,r,i){return await c.post(`${Y(e,t,n)}/containers/${encodeURIComponent(r)}/documents`,i)}async function Mn(e,t,n,r){return await c.post(`${Y(e,t,n)}/containers/${encodeURIComponent(r)}/sync`)}function Nn(e){let t=String(e||``).split(`/`).filter(Boolean);return t[0]!==`imap`||t.length<3||t[t.length-1]===`attachments`?null:{address:t[1]}}async function Pn(e,t,n,r){return c.post(`${Y(e,`imap`,t)}/messages/move`,{documentIds:n,targetPath:r})}async function Fn(e,t,n){return await c.get(`${Y(e,t,n)}/containers?available=1`)||[]}async function In(e,t,n,r){return await c.post(`${Y(e,t,n)}/containers`,{folders:r})}async function Ln(e,t,n,r){return await c.delete(`${Y(e,t,n)}/containers/${encodeURIComponent(r)}`)}async function Rn(e,t,n,r,i){return await c.patch(`${Y(e,t,n)}/containers/${encodeURIComponent(r)}`,{name:i})}function X(e,t){if(!t?.length)return null;let n=`/`+String(e||``).split(`/`).filter(Boolean).join(`/`);for(let e of t)if(e.treePath){if(n===e.treePath)return{backend:e,key:``};if(n.startsWith(e.treePath+`/`))return{backend:e,key:n.slice(e.treePath.length+1)}}return null}function zn(e,t){let n=X(e,t);if(n)return{driver:n.backend.driver,address:n.backend.address,key:n.key};let r=Z(e);return r?{...r,driver:t?.find(e=>e.address===r.address)?.driver||r.driver}:null}function Z(e,t){let n=X(e,t);if(n)return n.backend.driver===`file`?{driver:`file`,address:n.backend.address,key:n.key}:null;let r=String(e||``).split(`/`).filter(Boolean);return r[0]===`workspace`&&r[1]===`git`?null:r[0]===`workspace`&&r.length>=2?{driver:`file`,address:`workspace:${r[1]}`,key:r.slice(2).join(`/`)}:r[0]===`device`&&r.length>=3?{driver:`file`,address:r[2],key:r.slice(3).join(`/`)}:r[0]===`file`&&r.length>=2?{driver:`file`,address:r[1],key:r.slice(2).join(`/`)}:null}function Bn(e,t){let n=X(e,t);if(n){let{backend:e,key:t}=n;return!t||![`file`,`gdrive`].includes(e.driver)||!e.enabled||!e.capabilities.mutableContainers||e.config?.readOnly===!0?null:{driver:e.driver,address:e.address,key:t}}if(t)return null;let r=String(e||``).split(`/`).filter(Boolean);if(r[0]===`gdrive`&&r.length>2)return{driver:`gdrive`,address:r[1],key:r.slice(2).join(`/`)};let i=Z(e);return i?.key?i:null}async function Vn(e,t,n,r={}){let i=new URLSearchParams;r.linked!==void 0&&i.append(`linked`,String(r.linked)),r.limit!==void 0&&i.append(`limit`,String(r.limit)),r.offset!==void 0&&i.append(`offset`,String(r.offset));let a=i.toString();return await c.getEnvelope(`${Y(e,t,n)}/documents${a?`?${a}`:``}`)}async function Hn(e,t,n){return await c.post(`${J(e)}/${encodeURIComponent(t)}/discover`,n)||[]}function Un(e,t){let n=X(e,t);if(n)return{driver:n.backend.driver,address:n.backend.address};let r=String(e||``).split(`/`).filter(Boolean);return r.length<2||r[0]===`workspace`&&r[1]===`git`?null:r[0]===`workspace`?{driver:`file`,address:`workspace:${r[1]}`}:r[0]===`device`?r.length>=3?{driver:`file`,address:r[2]}:null:{driver:r[0],address:r[1]}}var Wn=[`internal/`,`context/`,`vfs/`];async function Q(e){try{return(await c.get(`${o.workspaces}/${encodeURIComponent(e)}/bitmaps`)||[]).map(e=>typeof e==`string`?e:e.key??String(e)).filter(e=>e&&!Wn.some(t=>e.startsWith(t)))}catch{return[]}}async function Gn(e){return(await Q(e)).filter(e=>e.startsWith(`tag/`)).map(e=>e.slice(4)).filter(Boolean).sort()}async function Kn(e,t){let n=t.replace(/^\/+|\/+$/g,``);if(!n)throw Error(`Bitmap key is required`);if(n.startsWith(`data/`)||n===`data`)throw Error(`data/* bitmaps are protected and cannot be deleted manually`);return await c.delete(`${o.workspaces}/${encodeURIComponent(e)}/bitmaps/${n.split(`/`).map(encodeURIComponent).join(`/`)}`),!0}async function qn(e,t,n=!0){let r=t.replace(/^data\/dataset\//,``).replace(/^\/+|\/+$/g,``);if(!r)throw Error(`Dataset name is required`);if(r==="default")throw Error(`The "default" dataset is virtual and cannot be deleted`);return await c.delete(`${o.workspaces}/${encodeURIComponent(e)}/datasets/${r.split(`/`).map(encodeURIComponent).join(`/`)}?dropDocuments=${n}`)}function $(e){return`${o.workspaces}/${encodeURIComponent(e)}/timelines`}async function Jn(e){try{return await c.get($(e))||[]}catch{return[]}}async function Yn(e){try{return await c.get(`${$(e)}?verbose=true`)||[]}catch{return[]}}async function Xn(e,t){return await c.post($(e),{name:t})}async function Zn(e,t){return await c.delete(`${$(e)}/${encodeURIComponent(t)}`),!0}async function Qn(e,t){return(await c.post(`${$(e)}/histogram`,t))?.buckets??[]}async function $n(e,t){let n=t?`?workspaceId=${encodeURIComponent(t)}`:``;return await c.post(`${o.admin.inferd}/${e?`pause`:`resume`}${n}`)}async function er(e){return await c.get(`${o.workspaces}/${e}/db/stats`)}async function tr(e,t){return await c.put(`${o.workspaces}/${e}/db/tuning`,t)}var nr=(e,t,n)=>`${o.workspaces}/${e}/members/${encodeURIComponent(`${t}:${n}`)}`;async function rr(e){return c.get(`${o.workspaces}/${e}/members`)}async function ir(e,t,n,r){return c.post(`${o.workspaces}/${e}/members`,{...t,permissions:n,...r?{description:r}:{}})}async function ar(e,t,n,r){return c.put(nr(e,t,n),{permissions:r})}async function or(e,t,n){await c.delete(nr(e,t,n))}async function sr(e,t,n){return c.post(`${o.workspaces}/${encodeURIComponent(e)}/documents/copy-to-workspace`,{documentId:t,...n})}async function cr(e,t){return c.post(`${o.workspaces}/${e}/documents/${t}/download`)}export{Sn as $,xt as $t,Hn as A,v as An,pt as At,Re as B,le as Bn,En as Bt,qn as C,x as Cn,Rt as Ct,Xt as D,Ee as Dn,Gn as Dt,Zn as E,S as En,Tt as Et,gn as F,oe as Fn,Pn as Ft,_t as G,qt as Gt,yn as H,f as Hn,cn as Ht,rt as I,d as In,kt as It,on as J,zt as Jt,tn as K,Ot as Kt,un as L,ie as Ln,jt as Lt,pn as M,se as Mn,Bt as Mt,cr as N,ce as Nn,Wt as Nt,Ht as O,y as On,Jn as Ot,ot as P,ue as Pn,Ut as Pt,er as Q,Et as Qt,ln as R,re as Rn,Ft as Rt,Kn as S,Ie as Sn,rn as St,at as T,b as Tn,Pt as Tt,bn as U,he as Un,nt as Ut,Cn as V,me as Vn,Ln as Vt,gt as W,ft as Wt,an as X,fn as Xt,Ct as Y,Lt as Yt,Ke as Z,or as Zt,St as _,Dt as _n,Fn as _t,Un as a,Gt as an,qe as at,Xn as b,k as bn,Q as bt,Bn as c,Mn as cn,Nn as ct,On as d,Vt as dn,lt as dt,Ye as en,$t as et,xn as f,It as fn,$e as ft,sn as g,ar as gn,Vn as gt,jn as h,Yt as hn,An as ht,tt as i,dt as in,hn as it,dn as j,Se as jn,Je as jt,_n as k,De as kn,Yn as kt,zn as l,kn as ln,Mt as lt,At as m,vt as mn,V as mt,wn as n,tr as nn,U as nt,Z as o,Kt as on,B as ot,sr as p,Tn as pn,yt as pt,nn as q,Rn as qt,In as r,ut as rn,W as rt,Qt as s,Dn as sn,ir as st,Ze as t,$n as tn,en as tt,H as u,Zt as un,st as ut,Xe as v,Nt as vn,vn as vt,Jt as w,C as wn,rr as wt,wt as x,A as xn,it as xt,bt as y,Le as yn,et as yt,Qn as z,ae as zn,mn as zt};
@@ -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{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button-SeUZ_Pvi.js";import{i as a,n as o,r as s}from"./api-CA6WiiYM.js";import{t as c}from"./socket-CtH3EU9m.js";import{Z as l,at as u,rn as d}from"./workspace-C5V-ZCOE.js";import{t as f}from"./workspace-access-C9nZlBBZ.js";var p=e(n(),1),m=t();function h({workspaceName:e,children:t}){let n=e,[h,g]=(0,p.useState)(null),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(!1),[x,S]=(0,p.useState)(0),[C,w]=(0,p.useState)(null);if((0,p.useEffect)(()=>{let t=!1,r=0,i,d=!1,p=async()=>{if(d||t)return;d=!0;let a=++r;try{let o=i?await u(e):await l(e);!t&&a===r&&(`id`in o&&(i=o.id,w({identity:n,allowed:f(o)})),g({identity:n,state:s()||o.status===`active`?`active`:o.status===`inactive`?`stopped`:`unavailable`}),v(``))}catch(e){if(!t&&a===r){let t=e instanceof Error?e.message:`Unable to check workspace status`,r=o(t);g(e=>r&&e?.identity===n&&e.state===`active`?e:{identity:n,state:r?`offline`:`unavailable`}),v(t)}}finally{d=!1}},m=t=>{let a=t.detail?.refs;!a?.includes(e)&&!(i&&a?.includes(i))||(r++,g({identity:n,state:`stopped`}),v(``))},h=t=>{let a=t.workspaceId||t.id;!a||a!==e&&a!==i||!t.status||(r++,g({identity:n,state:t.status===`active`?`active`:t.status===`inactive`?`stopped`:`unavailable`}),v(``))};p(),window.addEventListener(`workspaces:refresh`,p),window.addEventListener(`workspace:stopped`,m),window.addEventListener(`focus`,p);let _=c.on(`connect`,p);c.on(`workspace:status:changed`,h),c.on(`workspace.status.changed`,h);let y=a(e=>{e||p()});return()=>{t=!0,_?.(),y(),c.off(`workspace:status:changed`,h),c.off(`workspace.status.changed`,h),window.removeEventListener(`workspaces:refresh`,p),window.removeEventListener(`workspace:stopped`,m),window.removeEventListener(`focus`,p)}},[e,n,x]),h?.identity!==n)return(0,m.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Checking workspace…`});if(h.state===`active`)return t;let T=h.state===`stopped`;return(0,m.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:T?`Workspace stopped`:h.state===`offline`?`Server unreachable`:`Workspace unavailable`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:T?`Start this workspace to view its content.`:h.state===`offline`?`Reconnect to load this workspace. Previously loaded content stays available offline.`:`Unable to check this workspace. Try again or check its settings.`}),_&&(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,m.jsx)(i,{disabled:y,onClick:async()=>{b(!0),v(``);try{T&&await d(e),S(e=>e+1)}catch(e){v(e instanceof Error?e.message:`Unable to start workspace`)}finally{b(!1)}},children:y?T?`Starting…`:`Checking…`:T?`Start workspace`:`Retry`}),C?.identity===n&&C.allowed&&(0,m.jsx)(r,{className:`text-sm underline`,to:`/workspaces/${encodeURIComponent(e)}/settings`,children:`Workspace settings`})]})}export{h as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button--VYZekMF.js";import{i as a,n as o,r as s}from"./api-CA6WiiYM.js";import{t as c}from"./socket-CtH3EU9m.js";import{Z as l,at as u,rn as d}from"./workspace-4hWrSEku.js";import{t as f}from"./workspace-access-C9nZlBBZ.js";var p=e(n(),1),m=t();function h({workspaceName:e,children:t}){let n=e,[h,g]=(0,p.useState)(null),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(!1),[x,S]=(0,p.useState)(0),[C,w]=(0,p.useState)(null);if((0,p.useEffect)(()=>{let t=!1,r=0,i,d=!1,p=async()=>{if(d||t)return;d=!0;let a=++r;try{let o=i?await u(e):await l(e);!t&&a===r&&(`id`in o&&(i=o.id,w({identity:n,allowed:f(o)})),g({identity:n,state:s()||o.status===`active`?`active`:o.status===`inactive`?`stopped`:`unavailable`}),v(``))}catch(e){if(!t&&a===r){let t=e instanceof Error?e.message:`Unable to check workspace status`,r=o(t);g(e=>r&&e?.identity===n&&e.state===`active`?e:{identity:n,state:r?`offline`:`unavailable`}),v(t)}}finally{d=!1}},m=t=>{let a=t.detail?.refs;!a?.includes(e)&&!(i&&a?.includes(i))||(r++,g({identity:n,state:`stopped`}),v(``))},h=t=>{let a=t.workspaceId||t.id;!a||a!==e&&a!==i||!t.status||(r++,g({identity:n,state:t.status===`active`?`active`:t.status===`inactive`?`stopped`:`unavailable`}),v(``))};p(),window.addEventListener(`workspaces:refresh`,p),window.addEventListener(`workspace:stopped`,m),window.addEventListener(`focus`,p);let _=c.on(`connect`,p);c.on(`workspace:status:changed`,h),c.on(`workspace.status.changed`,h);let y=a(e=>{e||p()});return()=>{t=!0,_?.(),y(),c.off(`workspace:status:changed`,h),c.off(`workspace.status.changed`,h),window.removeEventListener(`workspaces:refresh`,p),window.removeEventListener(`workspace:stopped`,m),window.removeEventListener(`focus`,p)}},[e,n,x]),h?.identity!==n)return(0,m.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:`Checking workspace…`});if(h.state===`active`)return t;let T=h.state===`stopped`;return(0,m.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:T?`Workspace stopped`:h.state===`offline`?`Server unreachable`:`Workspace unavailable`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:T?`Start this workspace to view its content.`:h.state===`offline`?`Reconnect to load this workspace. Previously loaded content stays available offline.`:`Unable to check this workspace. Try again or check its settings.`}),_&&(0,m.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:_}),(0,m.jsx)(i,{disabled:y,onClick:async()=>{b(!0),v(``);try{T&&await d(e),S(e=>e+1)}catch(e){v(e instanceof Error?e.message:`Unable to start workspace`)}finally{b(!1)}},children:y?T?`Starting…`:`Checking…`:T?`Start workspace`:`Retry`}),C?.identity===n&&C.allowed&&(0,m.jsx)(r,{className:`text-sm underline`,to:`/workspaces/${encodeURIComponent(e)}/settings`,children:`Workspace settings`})]})}export{h 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{_t as r}from"./react-BHzhHVTZ.js";import{r as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{W as a,kt as o}from"./ui-CDoK3F3U.js";import{t as s}from"./button-SeUZ_Pvi.js";import{t as c}from"./input-BOtCd4HP.js";import{_n as l,dt as u,en as d,mt as f,pt as p,t as m,ut as h}from"./workspace-C5V-ZCOE.js";import{i as g,u as _}from"./layer-style-Byl5LNFR.js";var v=e(n(),1),y=[`Home`,`Travel`,`Work`,`Books`,`Workouts`,`Beauty`,`Recipes`,`To Watch`,`To Read`,`Learning`,`Tech`,`Music`,`Finance`,`Shopping`,`Ideas`];async function b(e,t,n){let r=0,i=0,a=n===`directory`?`directory`:`context`;for(let n of t)try{await p(e,`/${n}`,!0,a);let t=_(`/${n}`);t&&await l(e,`/${n}`,t,a).catch(()=>{}),r+=1}catch{i+=1}return f(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:n}})),{ok:r,failed:i}}function x(){let[e,t]=(0,v.useState)(new Set),[n,r]=(0,v.useState)(`context`);return{selected:e,setSelected:t,tree:n,setTree:r,toggle:e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}}var S=t();function C({selected:e,onToggle:t,tree:n,onTreeChange:i,disabled:a=!1,idPrefix:o=`default-folders`,stacked:s=!1}){return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Create in:`}),[`context`,`directory`].map(e=>(0,S.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`${o}-tree`,checked:n===e,onChange:()=>i(e),disabled:a}),e,` tree`]},e))]}),(0,S.jsx)(`div`,{className:`mt-3 grid gap-1.5 ${s?`grid-cols-1`:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4`}`,children:y.map(n=>{let i=g[n.toLowerCase()];return(0,S.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded border px-2 py-1.5 text-sm hover:bg-accent/50`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:e.has(n),onChange:()=>t(n),disabled:a}),i?.icon&&(0,S.jsx)(r,{icon:i.icon,width:16,height:16,color:i.color}),(0,S.jsx)(`span`,{className:`truncate`,children:n})]},n)})})]})}function w({disabled:e}){let[t,n]=(0,v.useState)(0),[r,a]=(0,v.useState)(!0),[c,l]=(0,v.useState)([]),[u,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=!0;return h.current?.id!==t&&(h.current={id:t,promise:d()}),h.current.promise.then(t=>{if(!e)return;let n=[...t.discovered,...t.adopted];l(e=>[...new Map([...e,...n].map(e=>[e.id,e])).values()]),f(t)}).catch(t=>{e&&m(t instanceof Error?t.message:`Workspace scan failed`)}).finally(()=>{e&&a(!1)}),()=>{e=!1}},[t]),(0,S.jsxs)(`section`,{className:`space-y-2 rounded-md border p-3`,"aria-label":`Find workspace folders`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium`,children:`Workspaces folder`}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Copied a workspace folder here? Scan to add it to your workspaces.`})]}),(0,S.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:e||r,onClick:()=>{a(!0),m(``),n(e=>e+1)},children:[(0,S.jsx)(o,{className:`mr-2 h-3.5 w-3.5 ${r?`animate-spin`:``}`}),r?`Scanning…`:`Rescan`]})]}),r&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Looking for workspace folders…`}),!r&&!p&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm`,children:c.length?`Found ${c.length} ${c.length===1?`workspace`:`workspaces`}. Added to your workspace list.`:`No new workspace folders found.`}),c.length>0&&(0,S.jsx)(`ul`,{className:`space-y-2`,children:c.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(i,{className:`text-sm font-medium underline underline-offset-2`,to:`/workspaces/${encodeURIComponent(e.name)}`,children:e.label||e.name}),(0,S.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.dir})]},e.id))}),p&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p}),!!u?.skipped.length&&(0,S.jsxs)(`details`,{className:`text-sm text-muted-foreground`,children:[(0,S.jsxs)(`summary`,{children:[u.skipped.length,` `,u.skipped.length===1?`folder could`:`folders could`,` not be added`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1`,children:u.skipped.map(e=>(0,S.jsxs)(`li`,{className:`break-all`,children:[e.dir,`: `,e.reason]},e.dir))})]})]})}function T({name:e,label:t,setName:n,setLabel:r,disabled:i=!1}){return(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Workspace name`,(0,S.jsx)(c,{required:!0,pattern:`[a-zA-Z0-9]([a-zA-Z0-9_]|-)*`,placeholder:`my-workspace`,value:e,onChange:e=>n(e.target.value),disabled:i}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Used in addresses. Archive imports also use it as the folder name.`})]}),(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Display label`,(0,S.jsx)(c,{required:!0,placeholder:`My Workspace`,value:t,onChange:e=>r(e.target.value),disabled:i})]})]})}function E({onImported:e,disabled:t=!1}){let[n,r]=(0,v.useState)(`upload`),[i,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[C,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(null),j=t||b,M=async t=>{t.preventDefault(),x(!0),O(``),A(null),E(`Starting…`);let r={name:p.trim(),label:_.trim()},a=e=>E(m[e.phase]||e.phase);try{let t=n===`upload`?await h(i,e=>E(e<1?`Uploading… ${Math.round(e*100)}%`:`Extracting…`),a,r):await u(d.trim(),r,a);A(t),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e?.(t)}catch(e){O(e instanceof Error?e.message:`Workspace import failed`)}finally{x(!1)}};return(0,S.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>void M(e),children:[(0,S.jsx)(w,{disabled:j}),(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Import from`,(0,S.jsxs)(`select`,{value:n,disabled:j,onChange:e=>r(e.target.value),className:`rounded-md border bg-background p-2`,children:[(0,S.jsx)(`option`,{value:`upload`,children:`Upload an archive`}),(0,S.jsx)(`option`,{value:`path`,children:`Path on this server`})]})]}),n===`upload`?(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Workspace archive`,(0,S.jsx)(c,{required:!0,type:`file`,accept:`.tar.gz,.tgz,.tar.bz2,.tbz2,.tbz`,disabled:j,onChange:e=>l(e.target.files?.[0]||null)})]}):(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Server path`,(0,S.jsx)(c,{required:!0,placeholder:`/tmp/workspace.tar.gz`,value:d,disabled:j,onChange:e=>f(e.target.value)}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`An archive or workspace folder on the server. Archives are extracted into your Workspaces directory.`})]}),(0,S.jsx)(T,{name:p,label:_,setName:g,setLabel:y,disabled:j}),(0,S.jsxs)(s,{type:`submit`,disabled:j||!p.trim()||!_.trim()||(n===`upload`?!i:!d.trim()),children:[b?(0,S.jsx)(o,{className:`mr-2 h-4 w-4 animate-spin`}):(0,S.jsx)(a,{className:`mr-2 h-4 w-4`}),b?`Importing…`:`Import workspace`]}),b&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:C}),D&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:D}),k&&(0,S.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[`Imported `,k.label||k.name,`.`]})]})}export{x as a,b as i,T as n,C as r,E as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r}from"./react-BHzhHVTZ.js";import{r as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{W as a,kt as o}from"./ui-DEgHnkQu.js";import{t as s}from"./button--VYZekMF.js";import{t as c}from"./input-BOtCd4HP.js";import{_n as l,dt as u,en as d,mt as f,pt as p,t as m,ut as h}from"./workspace-4hWrSEku.js";import{i as g,u as _}from"./layer-style-Byl5LNFR.js";var v=e(n(),1),y=[`Home`,`Travel`,`Work`,`Books`,`Workouts`,`Beauty`,`Recipes`,`To Watch`,`To Read`,`Learning`,`Tech`,`Music`,`Finance`,`Shopping`,`Ideas`];async function b(e,t,n){let r=0,i=0,a=n===`directory`?`directory`:`context`;for(let n of t)try{await p(e,`/${n}`,!0,a);let t=_(`/${n}`);t&&await l(e,`/${n}`,t,a).catch(()=>{}),r+=1}catch{i+=1}return f(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e,treeName:n}})),{ok:r,failed:i}}function x(){let[e,t]=(0,v.useState)(new Set),[n,r]=(0,v.useState)(`context`);return{selected:e,setSelected:t,tree:n,setTree:r,toggle:e=>{t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}}var S=t();function C({selected:e,onToggle:t,tree:n,onTreeChange:i,disabled:a=!1,idPrefix:o=`default-folders`,stacked:s=!1}){return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground`,children:`Create in:`}),[`context`,`directory`].map(e=>(0,S.jsxs)(`label`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`${o}-tree`,checked:n===e,onChange:()=>i(e),disabled:a}),e,` tree`]},e))]}),(0,S.jsx)(`div`,{className:`mt-3 grid gap-1.5 ${s?`grid-cols-1`:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4`}`,children:y.map(n=>{let i=g[n.toLowerCase()];return(0,S.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded border px-2 py-1.5 text-sm hover:bg-accent/50`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:e.has(n),onChange:()=>t(n),disabled:a}),i?.icon&&(0,S.jsx)(r,{icon:i.icon,width:16,height:16,color:i.color}),(0,S.jsx)(`span`,{className:`truncate`,children:n})]},n)})})]})}function w({disabled:e}){let[t,n]=(0,v.useState)(0),[r,a]=(0,v.useState)(!0),[c,l]=(0,v.useState)([]),[u,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),h=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=!0;return h.current?.id!==t&&(h.current={id:t,promise:d()}),h.current.promise.then(t=>{if(!e)return;let n=[...t.discovered,...t.adopted];l(e=>[...new Map([...e,...n].map(e=>[e.id,e])).values()]),f(t)}).catch(t=>{e&&m(t instanceof Error?t.message:`Workspace scan failed`)}).finally(()=>{e&&a(!1)}),()=>{e=!1}},[t]),(0,S.jsxs)(`section`,{className:`space-y-2 rounded-md border p-3`,"aria-label":`Find workspace folders`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium`,children:`Workspaces folder`}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Copied a workspace folder here? Scan to add it to your workspaces.`})]}),(0,S.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,disabled:e||r,onClick:()=>{a(!0),m(``),n(e=>e+1)},children:[(0,S.jsx)(o,{className:`mr-2 h-3.5 w-3.5 ${r?`animate-spin`:``}`}),r?`Scanning…`:`Rescan`]})]}),r&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Looking for workspace folders…`}),!r&&!p&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm`,children:c.length?`Found ${c.length} ${c.length===1?`workspace`:`workspaces`}. Added to your workspace list.`:`No new workspace folders found.`}),c.length>0&&(0,S.jsx)(`ul`,{className:`space-y-2`,children:c.map(e=>(0,S.jsxs)(`li`,{children:[(0,S.jsx)(i,{className:`text-sm font-medium underline underline-offset-2`,to:`/workspaces/${encodeURIComponent(e.name)}`,children:e.label||e.name}),(0,S.jsx)(`p`,{className:`break-all text-xs text-muted-foreground`,children:e.dir})]},e.id))}),p&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:p}),!!u?.skipped.length&&(0,S.jsxs)(`details`,{className:`text-sm text-muted-foreground`,children:[(0,S.jsxs)(`summary`,{children:[u.skipped.length,` `,u.skipped.length===1?`folder could`:`folders could`,` not be added`]}),(0,S.jsx)(`ul`,{className:`mt-1 space-y-1`,children:u.skipped.map(e=>(0,S.jsxs)(`li`,{className:`break-all`,children:[e.dir,`: `,e.reason]},e.dir))})]})]})}function T({name:e,label:t,setName:n,setLabel:r,disabled:i=!1}){return(0,S.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Workspace name`,(0,S.jsx)(c,{required:!0,pattern:`[a-zA-Z0-9]([a-zA-Z0-9_]|-)*`,placeholder:`my-workspace`,value:e,onChange:e=>n(e.target.value),disabled:i}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Used in addresses. Archive imports also use it as the folder name.`})]}),(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Display label`,(0,S.jsx)(c,{required:!0,placeholder:`My Workspace`,value:t,onChange:e=>r(e.target.value),disabled:i})]})]})}function E({onImported:e,disabled:t=!1}){let[n,r]=(0,v.useState)(`upload`),[i,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[C,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(null),j=t||b,M=async t=>{t.preventDefault(),x(!0),O(``),A(null),E(`Starting…`);let r={name:p.trim(),label:_.trim()},a=e=>E(m[e.phase]||e.phase);try{let t=n===`upload`?await h(i,e=>E(e<1?`Uploading… ${Math.round(e*100)}%`:`Extracting…`),a,r):await u(d.trim(),r,a);A(t),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e?.(t)}catch(e){O(e instanceof Error?e.message:`Workspace import failed`)}finally{x(!1)}};return(0,S.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>void M(e),children:[(0,S.jsx)(w,{disabled:j}),(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Import from`,(0,S.jsxs)(`select`,{value:n,disabled:j,onChange:e=>r(e.target.value),className:`rounded-md border bg-background p-2`,children:[(0,S.jsx)(`option`,{value:`upload`,children:`Upload an archive`}),(0,S.jsx)(`option`,{value:`path`,children:`Path on this server`})]})]}),n===`upload`?(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Workspace archive`,(0,S.jsx)(c,{required:!0,type:`file`,accept:`.tar.gz,.tgz,.tar.bz2,.tbz2,.tbz`,disabled:j,onChange:e=>l(e.target.files?.[0]||null)})]}):(0,S.jsxs)(`label`,{className:`grid gap-1 text-sm`,children:[`Server path`,(0,S.jsx)(c,{required:!0,placeholder:`/tmp/workspace.tar.gz`,value:d,disabled:j,onChange:e=>f(e.target.value)}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`An archive or workspace folder on the server. Archives are extracted into your Workspaces directory.`})]}),(0,S.jsx)(T,{name:p,label:_,setName:g,setLabel:y,disabled:j}),(0,S.jsxs)(s,{type:`submit`,disabled:j||!p.trim()||!_.trim()||(n===`upload`?!i:!d.trim()),children:[b?(0,S.jsx)(o,{className:`mr-2 h-4 w-4 animate-spin`}):(0,S.jsx)(a,{className:`mr-2 h-4 w-4`}),b?`Importing…`:`Import workspace`]}),b&&(0,S.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:C}),D&&(0,S.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:D}),k&&(0,S.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[`Imported `,k.label||k.name,`.`]})]})}export{x as a,b as i,T as n,C as r,E 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{H as r,L as i,Pt as a,Y as o,fr as s}from"./ui-CDoK3F3U.js";import{t as c}from"./button-SeUZ_Pvi.js";import{t as l}from"./input-BOtCd4HP.js";import{t as u}from"./label-BSTdjCWU.js";import{i as d}from"./auth-Bx9fAZmz.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{t as p}from"./useEscapeClose-DR_xKT_k.js";import{n as m}from"./page-header-DrDt1sQ2.js";import{t as h}from"./admin-Bhg9QBHL.js";var g=e(n(),1),_=t(),v=()=>{let e=[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FECA57`,`#FF9FF3`,`#54A0FF`,`#5F27CD`,`#00D2D3`,`#FF9F43`,`#10AC84`,`#EE5A24`,`#EA2027`,`#009432`,`#0652DD`];return e[Math.floor(Math.random()*e.length)]};function y(){let e=d()?.userType===`admin`,[t,n]=(0,g.useState)([]),[y,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(e),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(e?null:`Access denied. Admin privileges required.`),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,M]=(0,g.useState)({search:``,owner:``,type:``,status:``}),[N,P]=(0,g.useState)({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),{showToast:F}=f(),I=(0,g.useCallback)(async()=>{try{S(!0);let e=await h.workspaces.listAllWorkspaces();n(e),E(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch workspaces`;E(t),F({title:`Error`,description:t,variant:`destructive`})}finally{S(!1)}},[F]);(0,g.useEffect)(()=>{e&&I()},[e,I]);let L=(0,g.useCallback)(async()=>{try{w(!0);let e=await h.users.listUsers({status:`active`});b(e)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch users`;F({title:`Error`,description:t,variant:`destructive`})}finally{w(!1)}},[F]),R=async e=>{if(e.preventDefault(),!N.userId||!N.name.trim()){F({title:`Validation Error`,description:`User and workspace name are required`,variant:`destructive`});return}O(!0);try{let e={userId:N.userId,name:N.name.trim(),label:N.label.trim()||N.name.trim(),description:N.description.trim(),color:N.color,type:N.type};await h.workspaces.createWorkspace(e),P({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),A(!1),await I(),F({title:`Success`,description:`Workspace created successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to create workspace`;F({title:`Error`,description:t,variant:`destructive`})}finally{O(!1)}},z=async(e,t)=>{if(confirm(`Are you sure you want to delete workspace "${t}"? This action cannot be undone and will delete all data in the workspace.`))try{await h.workspaces.deleteWorkspace(e),await I(),F({title:`Success`,description:`Workspace deleted successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete workspace`;F({title:`Error`,description:t,variant:`destructive`})}},B=async()=>{P({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),A(!0),await L()},V=()=>{A(!1)};p(V,k);let H=t.filter(e=>{let t=j.search===``||e.name.toLowerCase().includes(j.search.toLowerCase())||e.label.toLowerCase().includes(j.search.toLowerCase())||e.ownerName&&e.ownerName.toLowerCase().includes(j.search.toLowerCase())||e.ownerEmail&&e.ownerEmail.toLowerCase().includes(j.search.toLowerCase()),n=j.owner===``||e.owner===j.owner,r=j.type===``||e.type===j.type,i=j.status===``||e.status===j.status;return t&&n&&r&&i}),U=Array.from(new Set(t.map(e=>e.owner))).map(e=>{let n=t.find(t=>t.owner===e);return{id:e,name:n?.ownerName||n?.ownerEmail||e}});return e?(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsx)(m,{title:`Workspace Administration`,description:`Manage workspaces across all users`}),t.some(e=>e.status!==`active`&&e.protection?.mode&&e.protection.mode!==`none`)&&(0,_.jsxs)(`p`,{className:`text-sm rounded border p-3`,children:[t.filter(e=>e.status!==`active`&&e.protection?.mode&&e.protection.mode!==`none`).length,` protected workspaces waiting for their owners to start them.`]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(l,{placeholder:`Search workspaces...`,value:j.search,onChange:e=>M(t=>({...t,search:e.target.value})),className:`md:w-64`}),(0,_.jsxs)(`select`,{value:j.owner,onChange:e=>M(t=>({...t,owner:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Owners`}),U.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,_.jsxs)(`select`,{value:j.type,onChange:e=>M(t=>({...t,type:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Types`}),(0,_.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,_.jsx)(`option`,{value:`universe`,children:`Universe`})]}),(0,_.jsxs)(`select`,{value:j.status,onChange:e=>M(t=>({...t,status:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Statuses`}),(0,_.jsx)(`option`,{value:`active`,children:`Active`}),(0,_.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,_.jsx)(`option`,{value:`error`,children:`Error`})]})]}),(0,_.jsxs)(c,{onClick:B,children:[(0,_.jsx)(a,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[x&&(0,_.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),T&&!t.length&&(0,_.jsx)(`div`,{className:`text-center text-destructive`,children:(0,_.jsx)(`p`,{children:T})}),!x&&!T&&H.length===0&&(0,_.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),H.length>0&&(0,_.jsx)(`div`,{className:`border rounded-md`,children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`bg-muted/50`,children:[(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Label`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Owner`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Type`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Color`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Created`}),(0,_.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`Actions`})]})}),(0,_.jsx)(`tbody`,{children:H.map(e=>(0,_.jsxs)(`tr`,{className:`border-t`,children:[(0,_.jsx)(`td`,{className:`p-3 font-medium font-mono text-sm`,children:e.name}),(0,_.jsx)(`td`,{className:`p-3`,children:e.label}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{className:`h-4 w-4 text-muted-foreground`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`font-medium`,children:e.ownerName||`Unknown`}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.ownerEmail})]})]})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.type===`universe`?`bg-accent text-primary`:`bg-info-subtle text-info`}`,children:e.type})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.status===`active`?`bg-success-subtle text-success`:e.status===`inactive`?`bg-warning-subtle text-warning`:`bg-destructive-subtle text-destructive`}`,children:e.status})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`div`,{className:`w-4 h-4 rounded border`,style:{backgroundColor:e.color}}),(0,_.jsx)(`span`,{className:`font-mono text-xs`,children:e.color})]})}),(0,_.jsx)(`td`,{className:`p-3`,children:new Date(e.createdAt).toLocaleDateString()}),(0,_.jsxs)(`td`,{className:`p-3 text-right space-x-2`,children:[(0,_.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>window.open(`/workspaces/${e.name}`,`_blank`),title:`View workspace`,children:(0,_.jsx)(s,{className:`h-4 w-4`})}),(0,_.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>z(e.id,e.name),className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,title:`Delete workspace`,disabled:e.type===`universe`,children:(0,_.jsx)(o,{className:`h-4 w-4`})})]})]},e.id))})]})})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4 mt-8`,children:[(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Total Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.filter(e=>e.status===`active`).length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Active Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.filter(e=>e.type===`universe`).length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Universe Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:U.length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Unique Owners`})]})]}),k&&(0,_.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,_.jsxs)(`div`,{className:`bg-card rounded-lg p-6 w-full max-w-md mx-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,_.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Create New Workspace`}),(0,_.jsx)(c,{variant:`ghost`,size:`sm`,onClick:V,children:(0,_.jsx)(i,{className:`h-4 w-4`})})]}),(0,_.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`userId`,children:`User`}),(0,_.jsxs)(`select`,{id:`userId`,value:N.userId,onChange:e=>P(t=>({...t,userId:e.target.value})),disabled:D||C,className:`w-full px-3 py-2 border border-border rounded-md`,required:!0,children:[(0,_.jsx)(`option`,{value:``,children:`Select a user...`}),y.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),C&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Loading users...`})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`name`,children:`Workspace Name`}),(0,_.jsx)(l,{id:`name`,type:`text`,value:N.name,onChange:e=>P(t=>({...t,name:e.target.value})),placeholder:`my-workspace`,disabled:D,required:!0}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Lowercase letters, numbers, and hyphens only`})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`label`,children:`Display Label`}),(0,_.jsx)(l,{id:`label`,type:`text`,value:N.label,onChange:e=>P(t=>({...t,label:e.target.value})),placeholder:`My Workspace`,disabled:D})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`description`,children:`Description`}),(0,_.jsx)(l,{id:`description`,type:`text`,value:N.description,onChange:e=>P(t=>({...t,description:e.target.value})),placeholder:`Workspace description (optional)`,disabled:D})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`type`,children:`Type`}),(0,_.jsxs)(`select`,{id:`type`,value:N.type,onChange:e=>P(t=>({...t,type:e.target.value})),disabled:D,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,_.jsx)(`option`,{value:`universe`,children:`Universe`})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`color`,children:`Color`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(l,{id:`color`,type:`color`,value:N.color,onChange:e=>P(t=>({...t,color:e.target.value})),className:`h-10 w-16 p-1`,disabled:D}),(0,_.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>P(e=>({...e,color:v()})),disabled:D,children:`Random`})]})]}),(0,_.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[(0,_.jsx)(c,{type:`submit`,disabled:D||C,className:`flex-1`,children:D?`Creating...`:`Create Workspace`}),(0,_.jsx)(c,{type:`button`,variant:`outline`,onClick:V,disabled:D,children:`Cancel`})]})]})]})})]}):(0,_.jsx)(`div`,{className:`text-center space-y-4`,children:(0,_.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{y 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{H as r,L as i,Pt as a,Y as o,pr as s}from"./ui-DEgHnkQu.js";import{t as c}from"./button--VYZekMF.js";import{t as l}from"./input-BOtCd4HP.js";import{t as u}from"./label-RuOXXC8t.js";import{i as d}from"./auth-Bx9fAZmz.js";import{n as f}from"./use-toast-BlLDqSUO.js";import{t as p}from"./useEscapeClose-DR_xKT_k.js";import{n as m}from"./page-header-NyYSXjfY.js";import{t as h}from"./admin-Bhg9QBHL.js";var g=e(n(),1),_=t(),v=()=>{let e=[`#FF6B6B`,`#4ECDC4`,`#45B7D1`,`#96CEB4`,`#FECA57`,`#FF9FF3`,`#54A0FF`,`#5F27CD`,`#00D2D3`,`#FF9F43`,`#10AC84`,`#EE5A24`,`#EA2027`,`#009432`,`#0652DD`];return e[Math.floor(Math.random()*e.length)]};function y(){let e=d()?.userType===`admin`,[t,n]=(0,g.useState)([]),[y,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(e),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(e?null:`Access denied. Admin privileges required.`),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,M]=(0,g.useState)({search:``,owner:``,type:``,status:``}),[N,P]=(0,g.useState)({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),{showToast:F}=f(),I=(0,g.useCallback)(async()=>{try{S(!0);let e=await h.workspaces.listAllWorkspaces();n(e),E(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch workspaces`;E(t),F({title:`Error`,description:t,variant:`destructive`})}finally{S(!1)}},[F]);(0,g.useEffect)(()=>{e&&I()},[e,I]);let L=(0,g.useCallback)(async()=>{try{w(!0);let e=await h.users.listUsers({status:`active`});b(e)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch users`;F({title:`Error`,description:t,variant:`destructive`})}finally{w(!1)}},[F]),R=async e=>{if(e.preventDefault(),!N.userId||!N.name.trim()){F({title:`Validation Error`,description:`User and workspace name are required`,variant:`destructive`});return}O(!0);try{let e={userId:N.userId,name:N.name.trim(),label:N.label.trim()||N.name.trim(),description:N.description.trim(),color:N.color,type:N.type};await h.workspaces.createWorkspace(e),P({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),A(!1),await I(),F({title:`Success`,description:`Workspace created successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to create workspace`;F({title:`Error`,description:t,variant:`destructive`})}finally{O(!1)}},z=async(e,t)=>{if(confirm(`Are you sure you want to delete workspace "${t}"? This action cannot be undone and will delete all data in the workspace.`))try{await h.workspaces.deleteWorkspace(e),await I(),F({title:`Success`,description:`Workspace deleted successfully`})}catch(e){let t=e instanceof Error?e.message:`Failed to delete workspace`;F({title:`Error`,description:t,variant:`destructive`})}},B=async()=>{P({userId:``,name:``,label:``,description:``,color:v(),type:`workspace`}),A(!0),await L()},V=()=>{A(!1)};p(V,k);let H=t.filter(e=>{let t=j.search===``||e.name.toLowerCase().includes(j.search.toLowerCase())||e.label.toLowerCase().includes(j.search.toLowerCase())||e.ownerName&&e.ownerName.toLowerCase().includes(j.search.toLowerCase())||e.ownerEmail&&e.ownerEmail.toLowerCase().includes(j.search.toLowerCase()),n=j.owner===``||e.owner===j.owner,r=j.type===``||e.type===j.type,i=j.status===``||e.status===j.status;return t&&n&&r&&i}),U=Array.from(new Set(t.map(e=>e.owner))).map(e=>{let n=t.find(t=>t.owner===e);return{id:e,name:n?.ownerName||n?.ownerEmail||e}});return e?(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsx)(m,{title:`Workspace Administration`,description:`Manage workspaces across all users`}),t.some(e=>e.status!==`active`&&e.protection?.mode&&e.protection.mode!==`none`)&&(0,_.jsxs)(`p`,{className:`text-sm rounded border p-3`,children:[t.filter(e=>e.status!==`active`&&e.protection?.mode&&e.protection.mode!==`none`).length,` protected workspaces waiting for their owners to start them.`]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center`,children:[(0,_.jsx)(l,{placeholder:`Search workspaces...`,value:j.search,onChange:e=>M(t=>({...t,search:e.target.value})),className:`md:w-64`}),(0,_.jsxs)(`select`,{value:j.owner,onChange:e=>M(t=>({...t,owner:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Owners`}),U.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,_.jsxs)(`select`,{value:j.type,onChange:e=>M(t=>({...t,type:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Types`}),(0,_.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,_.jsx)(`option`,{value:`universe`,children:`Universe`})]}),(0,_.jsxs)(`select`,{value:j.status,onChange:e=>M(t=>({...t,status:e.target.value})),className:`px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:``,children:`All Statuses`}),(0,_.jsx)(`option`,{value:`active`,children:`Active`}),(0,_.jsx)(`option`,{value:`inactive`,children:`Inactive`}),(0,_.jsx)(`option`,{value:`error`,children:`Error`})]})]}),(0,_.jsxs)(c,{onClick:B,children:[(0,_.jsx)(a,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[x&&(0,_.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),T&&!t.length&&(0,_.jsx)(`div`,{className:`text-center text-destructive`,children:(0,_.jsx)(`p`,{children:T})}),!x&&!T&&H.length===0&&(0,_.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),H.length>0&&(0,_.jsx)(`div`,{className:`border rounded-md`,children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`bg-muted/50`,children:[(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Name`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Label`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Owner`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Type`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Status`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Color`}),(0,_.jsx)(`th`,{className:`text-left p-3 font-medium`,children:`Created`}),(0,_.jsx)(`th`,{className:`text-right p-3 font-medium`,children:`Actions`})]})}),(0,_.jsx)(`tbody`,{children:H.map(e=>(0,_.jsxs)(`tr`,{className:`border-t`,children:[(0,_.jsx)(`td`,{className:`p-3 font-medium font-mono text-sm`,children:e.name}),(0,_.jsx)(`td`,{className:`p-3`,children:e.label}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{className:`h-4 w-4 text-muted-foreground`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`font-medium`,children:e.ownerName||`Unknown`}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.ownerEmail})]})]})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.type===`universe`?`bg-accent text-primary`:`bg-info-subtle text-info`}`,children:e.type})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsx)(`span`,{className:`px-2 py-1 rounded-full text-xs ${e.status===`active`?`bg-success-subtle text-success`:e.status===`inactive`?`bg-warning-subtle text-warning`:`bg-destructive-subtle text-destructive`}`,children:e.status})}),(0,_.jsx)(`td`,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`div`,{className:`w-4 h-4 rounded border`,style:{backgroundColor:e.color}}),(0,_.jsx)(`span`,{className:`font-mono text-xs`,children:e.color})]})}),(0,_.jsx)(`td`,{className:`p-3`,children:new Date(e.createdAt).toLocaleDateString()}),(0,_.jsxs)(`td`,{className:`p-3 text-right space-x-2`,children:[(0,_.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>window.open(`/workspaces/${e.name}`,`_blank`),title:`View workspace`,children:(0,_.jsx)(s,{className:`h-4 w-4`})}),(0,_.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>z(e.id,e.name),className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,title:`Delete workspace`,disabled:e.type===`universe`,children:(0,_.jsx)(o,{className:`h-4 w-4`})})]})]},e.id))})]})})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4 mt-8`,children:[(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Total Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.filter(e=>e.status===`active`).length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Active Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:t.filter(e=>e.type===`universe`).length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Universe Workspaces`})]}),(0,_.jsxs)(`div`,{className:`bg-card p-4 rounded-lg border`,children:[(0,_.jsx)(`div`,{className:`text-2xl font-bold`,children:U.length}),(0,_.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Unique Owners`})]})]}),k&&(0,_.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,_.jsxs)(`div`,{className:`bg-card rounded-lg p-6 w-full max-w-md mx-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,_.jsx)(`h3`,{className:`text-lg font-semibold`,children:`Create New Workspace`}),(0,_.jsx)(c,{variant:`ghost`,size:`sm`,onClick:V,children:(0,_.jsx)(i,{className:`h-4 w-4`})})]}),(0,_.jsxs)(`form`,{onSubmit:R,className:`space-y-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`userId`,children:`User`}),(0,_.jsxs)(`select`,{id:`userId`,value:N.userId,onChange:e=>P(t=>({...t,userId:e.target.value})),disabled:D||C,className:`w-full px-3 py-2 border border-border rounded-md`,required:!0,children:[(0,_.jsx)(`option`,{value:``,children:`Select a user...`}),y.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.email,`)`]},e.id))]}),C&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Loading users...`})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`name`,children:`Workspace Name`}),(0,_.jsx)(l,{id:`name`,type:`text`,value:N.name,onChange:e=>P(t=>({...t,name:e.target.value})),placeholder:`my-workspace`,disabled:D,required:!0}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Lowercase letters, numbers, and hyphens only`})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`label`,children:`Display Label`}),(0,_.jsx)(l,{id:`label`,type:`text`,value:N.label,onChange:e=>P(t=>({...t,label:e.target.value})),placeholder:`My Workspace`,disabled:D})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`description`,children:`Description`}),(0,_.jsx)(l,{id:`description`,type:`text`,value:N.description,onChange:e=>P(t=>({...t,description:e.target.value})),placeholder:`Workspace description (optional)`,disabled:D})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`type`,children:`Type`}),(0,_.jsxs)(`select`,{id:`type`,value:N.type,onChange:e=>P(t=>({...t,type:e.target.value})),disabled:D,className:`w-full px-3 py-2 border border-border rounded-md`,children:[(0,_.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,_.jsx)(`option`,{value:`universe`,children:`Universe`})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(u,{htmlFor:`color`,children:`Color`}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(l,{id:`color`,type:`color`,value:N.color,onChange:e=>P(t=>({...t,color:e.target.value})),className:`h-10 w-16 p-1`,disabled:D}),(0,_.jsx)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>P(e=>({...e,color:v()})),disabled:D,children:`Random`})]})]}),(0,_.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[(0,_.jsx)(c,{type:`submit`,disabled:D||C,className:`flex-1`,children:D?`Creating...`:`Create Workspace`}),(0,_.jsx)(c,{type:`button`,variant:`outline`,onClick:V,disabled:D,children:`Cancel`})]})]})]})})]}):(0,_.jsx)(`div`,{className:`text-center space-y-4`,children:(0,_.jsx)(`div`,{className:`text-destructive`,children:`Access denied. Admin privileges required.`})})}export{y as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Bn as a,Hn as o,It as s,Pt as c,X as l,at as u,br as d,ht as f,qn as p,rt as m}from"./ui-DEgHnkQu.js";import{t as h}from"./button--VYZekMF.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Ut as y,Wt as b,ft as x,i as S,in as C,jt as w,mn as T,rn as E,t as D,v as O,yt as k}from"./workspace-4hWrSEku.js";import{a as A,c as j,i as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./alert-dialog-BKtaX1_a.js";import{t as ee}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as z,r as te,t as B}from"./color-DFEH4BfK.js";import{t as V}from"./workspace-access-C9nZlBBZ.js";import{i as ne}from"./use-menu-CKSpS96u.js";import{r as re}from"./last-path-BbXWC3b3.js";import{At as ie,Ft as H,It as U,Lt as ae,Mt as oe,Nt as se,Ot as ce,Rt as le,jt as W,kt as ue,vt as G,zt as K}from"./index-CTvqbEB8.js";import{n as de}from"./page-header-NyYSXjfY.js";import{t as q}from"./form-panel-CEbNKttr.js";import{t as fe}from"./use-create-panel-DhSNIGtr.js";import{n as pe,t as me}from"./useSocketSubscription-ifW-vnlb.js";import{a as he,i as ge,n as _e,r as ve,t as ye}from"./workspace-import-form-CWs9ZTts.js";var J=e(n(),1),Y=t();function be({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:a,onDestroy:o}){let[c,p]=(0,J.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,T=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,E=e.origin===`remote`,D=e.status===`offline`,O=z(e.color),k=O?``:`border-border`,ee=O?{borderLeftColor:O,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(H,{className:`relative ${k}`,style:ee,children:[(0,Y.jsx)(le,{children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(K,{className:`truncate`,children:e.label||e.name}),(0,Y.jsx)(ae,{children:b?`Shared from ${x}`:e.description||``})]}),(0,Y.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(G(e)),title:`Stop Workspace`,disabled:v||y,children:(0,Y.jsx)(m,{className:`h-4 w-4`})}):(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(G(e)),title:D?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||D,children:(0,Y.jsx)(s,{className:`h-4 w-4`})}),g&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(G(e)),title:`Enter Workspace`,disabled:v||y,children:(0,Y.jsx)(d,{className:`h-4 w-4`})}),a&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>a(e),title:V(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!V(e),children:(0,Y.jsx)(f,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,Y.jsx)(u,{className:`h-4 w-4`})}),o&&!_&&!b&&(0,Y.jsxs)(R,{open:c,onOpenChange:p,children:[(0,Y.jsx)(N,{asChild:!0,children:(0,Y.jsx)(h,{variant:`outline`,size:`icon`,title:E?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!E,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,Y.jsx)(l,{className:`h-4 w-4`})})}),(0,Y.jsxs)(M,{children:[(0,Y.jsxs)(L,{children:[(0,Y.jsx)(j,{children:E?`Remove remote workspace`:`Delete Workspace`}),(0,Y.jsx)(A,{children:E?(0,Y.jsxs)(Y.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),`The workspace itself stays untouched on `,e.remote?.url||e.host,`; only the stored share token and the local cache entry are dropped.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,Y.jsxs)(F,{children:[(0,Y.jsx)(I,{children:`Cancel`}),(0,Y.jsx)(P,{onClick:()=>{o(e),p(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:E?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-3 w-3 rounded-full ${(()=>{switch(e.status){case`active`:return`bg-success`;case`inactive`:case`available`:return`bg-muted-foreground`;case`error`:case`offline`:return`bg-destructive`;case`not_found`:return`bg-muted-foreground`;default:return`bg-accent`}})()}`}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:(()=>{switch(e.status){case`active`:return`Active`;case`inactive`:return`Inactive`;case`error`:return`Error`;case`not_found`:return`Not Found`;case`available`:return`Available`;case`removed`:return`Removed`;case`destroyed`:return`Destroyed`;case`offline`:return`Offline`;default:return e.status}})()}),_&&(0,Y.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),E&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:e.remote?.url?`${e.remote.url} (${(e.remote.permissions||[]).join(`, `)||`no permissions`})`:void 0,children:[`Remote · `,e.host]}),b&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[T,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var X=[{value:`full`,icon:p,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:a,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function xe({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,Y.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:X.map(i=>{let a=e===i.value,o=i.icon;return(0,Y.jsxs)(`button`,{id:`${r}-${i.value}`,type:`button`,role:`radio`,"aria-checked":a,disabled:n,onClick:()=>t(i.value),className:`flex w-full gap-2 rounded-md border p-2.5 text-left transition-colors disabled:opacity-50 ${a?`border-primary bg-accent/40`:`hover:bg-accent/20`}`,children:[(0,Y.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,Y.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,Y.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Se(){let[e,t]=(0,J.useState)(`full`),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let e=!0;return _.get(`/ping`,{skipAuth:!0}).then(r=>{let i=r?.defaults?.workspaceLayout;e&&!n&&(i===`home`||i===`full`)&&t(i)}).catch(()=>{}),()=>{e=!1}},[]),[e,e=>{r(!0),t(e)}]}function Ce(){let[e,t]=(0,J.useState)([]),[n,a]=(0,J.useState)(!0),[s,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,_]=(0,J.useState)(B()),[y,x]=(0,J.useState)(null),[S,D]=(0,J.useState)(``),[k,A]=Se(),[j,M]=(0,J.useState)(null),[N,P]=(0,J.useState)(null),[F,I]=(0,J.useState)(!1),L=se(),[R,V]=fe(),H=he(),[U,ae]=(0,J.useState)(!1),[le,K]=(0,J.useState)(!1),[_e,X]=(0,J.useState)(!1),[Ce,De]=(0,J.useState)(!1),[Z,Q]=(0,J.useState)(null),{showToast:$}=v(),Oe=i(),ke=ee(),{openM2Drawer:Ae}=ne(),je=pe();me(je,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||w().then(e=>t(W(e))).catch(()=>{})}}),(0,J.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await w();t(W(e)),l(null)}catch(e){console.error(`Workspace fetch error:`,e);let t=`Failed to fetch workspaces`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch workspaces`}l(t),$({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[je,$]);let Me=async e=>{if(e.preventDefault(),u.trim()){I(!0);try{let e=await O({name:u,description:f||void 0,color:m,icon:y,label:S||u,layout:k});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),H.selected.size>0){try{await E(e.name);let{ok:t,failed:n}=await ge(e.name,Array.from(H.selected),H.tree);n&&$({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),$({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}H.setSelected(new Set)}d(``),p(``),_(B()),x(null),D(``),$({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),V(!1)}catch(e){console.error(`Workspace creation error:`,e);let t=`Failed to create workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create workspace`}$({title:`Error`,description:t,variant:`destructive`})}finally{I(!1)}}},Ne=async e=>{if(e.preventDefault(),Z)try{let e={label:Z.label,description:Z.description,color:Z.color,icon:Z.icon??null};await T(Z.name,e),t(t=>t.map(t=>t.id===Z.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),$({title:`Success`,description:`Workspace '${Z.label}' details updated.`}),Q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Q(e)},Fe=async e=>{try{await b(e.name),t(t=>t.filter(t=>t.id!==e.id)),$({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await E(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' started.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace start error:`,e);let t=`Failed to start workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await C(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' stopped.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace stop error:`,e);let t=`Failed to stop workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{Oe(re(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=oe((n,r)=>{let i=ue(e,n,r);t(i),ie(i,(e,t)=>T(G(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&$({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsx)(de,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h,{variant:`outline`,onClick:()=>ae(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>X(e=>!e),children:`Import workspace`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>K(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>De(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!L.local&&!R&&(0,Y.jsxs)(h,{onClick:()=>V(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,Y.jsx)(c,{className:`h-4 w-4 sm:mr-2`}),(0,Y.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!L.local&&R&&(0,Y.jsx)(q,{title:`Create New Workspace`,onClose:()=>V(!1),children:(0,Y.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:F}),(0,Y.jsx)(g,{value:S,onChange:e=>D(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:F})]}),(0,Y.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:F}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:F,onClick:e=>M({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:z(m)})}),(0,Y.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:F}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(B()),disabled:F,children:`Randomize`})]}),j&&(0,Y.jsx)(ce,{x:j.x,y:j.y,current:{icon:y??void 0,color:m},onChange:e=>{`icon`in e&&x(e.icon??null),`color`in e&&e.color&&_(e.color)},onClose:()=>M(null)}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`How the workspace directory is laid out on disk. Fixed once created.`}),(0,Y.jsx)(xe,{value:k,onChange:A,disabled:F,idPrefix:`create-workspace-layout`})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,Y.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`Ticked folders are created right after the workspace, with matching icons and colors.`}),(0,Y.jsx)(ve,{selected:H.selected,onToggle:H.toggle,tree:H.tree,onTreeChange:H.setTree,disabled:F,idPrefix:`create-default-folders`})]}),(0,Y.jsxs)(h,{type:`submit`,disabled:F||!u.trim(),children:[(0,Y.jsx)(c,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),U&&(0,Y.jsx)(Te,{}),Ce&&(0,Y.jsx)(Ee,{onClose:()=>De(!1),onChanged:async()=>{try{t(W(await w()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),_e&&(0,Y.jsx)(q,{title:`Import workspace`,onClose:()=>X(!1),children:(0,Y.jsx)(ye,{onImported:()=>X(!1)})}),le&&(0,Y.jsx)(we,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),K(!1)},onClose:()=>K(!1)}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),s&&(0,Y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,Y.jsx)(`p`,{children:s})}),!n&&!s&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,Y.jsx)(`div`,{className:`grid gap-4`,children:e.map((t,n)=>{let r={...t,createdAt:t.createdAt,updatedAt:t.updatedAt,color:t.color===null?void 0:t.color},i=z(t.color);return(0,Y.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,...Be(n),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:`hidden w-5 shrink-0 cursor-grab items-center justify-center rounded-l-lg active:cursor-grabbing md:flex ${i?``:`bg-muted`}`,style:i?{backgroundColor:i}:void 0,children:(0,Y.jsx)(o,{className:`h-4 w-4 ${te(i)}`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(be,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{ke?Ae(`workspaces`,`settings`,G(e)):Oe(`/workspaces/${G(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),Z&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,Z.label]}),(0,Y.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,Y.jsx)(g,{id:`edit-label`,value:Z.label,onChange:e=>Q(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,Y.jsx)(g,{id:`edit-description`,value:Z.description||``,onChange:e=>Q(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>P({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:Z.icon||`ph:stack-fill`,width:22,height:22,color:z(Z.color)})}),(0,Y.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:Z.color||`#FFFFFF`,onChange:e=>Q(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(e=>e?{...e,color:B()}:null),children:`Randomize Color`})]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(h,{type:`submit`,disabled:!Z.label?.trim(),children:`Save Changes`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Q(null),children:`Cancel`})]})]}),N&&(0,Y.jsx)(ce,{x:N.x,y:N.y,current:{icon:Z.icon??void 0,color:Z.color??void 0},onChange:e=>{Q(t=>{if(!t)return null;let n={...t};return`icon`in e&&(n.icon=e.icon??null),`color`in e&&e.color&&(n.color=e.color),n})},onClose:()=>P(null)})]})]})}function we({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``);return(0,Y.jsx)(q,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,Y.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await x(i,a.trim(),e=>{m(D[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,Y.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,Y.jsx)(_e,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,Y.jsx)(`strong`,{children:`copy`}),` of the workspace from the remote canvas-server into this one, where it then lives independently. The remote workspace is stopped while it is packed, and large workspaces can take several minutes — progress is shown above.`]})]})})}function Te(){let{showToast:e}=v(),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,Y.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,Y.jsx)(h,{onClick:async()=>{if(!s(t.trim())){e({title:`Error`,description:`Invalid URL`,variant:`destructive`});return}if(!r.trim().startsWith(`canvas-`)){e({title:`Error`,description:`Invalid access token`,variant:`destructive`});return}o(!0);try{sessionStorage.setItem(`sharedToken:last`,r.trim());let e=new URLSearchParams({url:t.trim()}).toString();window.location.href=`/shared?${e}`}catch(t){e({title:`Error`,description:t instanceof Error?t.message:`Failed to open shared resource`,variant:`destructive`})}finally{o(!1)}},disabled:a||!t.trim()||!r.trim(),children:`Open`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We use your provided URL and token to fetch via the remote's public API.`})]})}function Ee({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)([]),p=(0,J.useCallback)(async()=>{try{f(await k())}catch{f([])}},[]);(0,J.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await S(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,Y.jsxs)(q,{title:`Open a remote Workspace`,onClose:e,children:[(0,Y.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,Y.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-xs`,children:`name@host`}),` — nothing is copied. Every call you make to it is forwarded to the remote with the share token (its permissions apply); document content and thumbnails are cached locally so they stay readable when the remote is offline. Use “Import remote…” if you want an independent local copy instead.`]})]}),d.length>0&&(0,Y.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,Y.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`remote`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{Ce as default};
package/dist/index.html CHANGED
@@ -46,86 +46,84 @@
46
46
  }
47
47
  })()
48
48
  </script>
49
- <script type="module" crossorigin src="/assets/index-G_67YwLB.js"></script>
49
+ <script type="module" crossorigin src="/assets/index-CTvqbEB8.js"></script>
50
50
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
51
51
  <link rel="modulepreload" crossorigin href="/assets/code-editor-BOIngd5F.js">
52
52
  <link rel="modulepreload" crossorigin href="/assets/react-BHzhHVTZ.js">
53
53
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
54
54
  <link rel="modulepreload" crossorigin href="/assets/chunk-62JRHF6Z-vspAGgtK.js">
55
- <link rel="modulepreload" crossorigin href="/assets/ui-CDoK3F3U.js">
55
+ <link rel="modulepreload" crossorigin href="/assets/ui-DEgHnkQu.js">
56
56
  <link rel="modulepreload" crossorigin href="/assets/utils-BxVxyehK.js">
57
57
  <link rel="modulepreload" crossorigin href="/assets/utils-2pl1SbIp.js">
58
- <link rel="modulepreload" crossorigin href="/assets/button-SeUZ_Pvi.js">
58
+ <link rel="modulepreload" crossorigin href="/assets/button--VYZekMF.js">
59
59
  <link rel="modulepreload" crossorigin href="/assets/input-BOtCd4HP.js">
60
- <link rel="modulepreload" crossorigin href="/assets/label-BSTdjCWU.js">
60
+ <link rel="modulepreload" crossorigin href="/assets/label-RuOXXC8t.js">
61
61
  <link rel="modulepreload" crossorigin href="/assets/api-CA6WiiYM.js">
62
62
  <link rel="modulepreload" crossorigin href="/assets/socket-hM4c-ZSl.js">
63
63
  <link rel="modulepreload" crossorigin href="/assets/socket-CtH3EU9m.js">
64
64
  <link rel="modulepreload" crossorigin href="/assets/auth-Bx9fAZmz.js">
65
65
  <link rel="modulepreload" crossorigin href="/assets/use-toast-BlLDqSUO.js">
66
- <link rel="modulepreload" crossorigin href="/assets/alert-dialog-CFeuDt0T.js">
67
- <link rel="modulepreload" crossorigin href="/assets/workspace-C5V-ZCOE.js">
66
+ <link rel="modulepreload" crossorigin href="/assets/alert-dialog-BKtaX1_a.js">
67
+ <link rel="modulepreload" crossorigin href="/assets/workspace-4hWrSEku.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/useEscapeClose-DR_xKT_k.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/useToastHelpers-CRrpIIdY.js">
70
70
  <link rel="modulepreload" crossorigin href="/assets/layer-style-Byl5LNFR.js">
71
71
  <link rel="modulepreload" crossorigin href="/assets/color-DFEH4BfK.js">
72
- <link rel="modulepreload" crossorigin href="/assets/DocumentIcon-9i1uCMQa.js">
73
- <link rel="modulepreload" crossorigin href="/assets/LinkToCard-CKVi4Nrg.js">
72
+ <link rel="modulepreload" crossorigin href="/assets/DocumentIcon-0ya9gycp.js">
73
+ <link rel="modulepreload" crossorigin href="/assets/LinkToCard-oi3wGP0a.js">
74
74
  <link rel="modulepreload" crossorigin href="/assets/use-mobile-Db-vWu9Y.js">
75
75
  <link rel="modulepreload" crossorigin href="/assets/tags-YamdPoBK.js">
76
76
  <link rel="modulepreload" crossorigin href="/assets/use-toolbox-Ck_cLGgf.js">
77
- <link rel="modulepreload" crossorigin href="/assets/context-t3rdtGUB.js">
78
- <link rel="modulepreload" crossorigin href="/assets/useAddTarget-DeRZWtGg.js">
77
+ <link rel="modulepreload" crossorigin href="/assets/context-DY40EDc6.js">
78
+ <link rel="modulepreload" crossorigin href="/assets/useAddTarget-BvuFR5pN.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/relation-events-CKio19hE.js">
80
- <link rel="modulepreload" crossorigin href="/assets/date-time-picker-DCikruos.js">
80
+ <link rel="modulepreload" crossorigin href="/assets/date-time-picker-p3vy4nst.js">
81
81
  <link rel="modulepreload" crossorigin href="/assets/map-BxCwdK0d.js">
82
- <link rel="modulepreload" crossorigin href="/assets/IdentityFields-D-NCTUaE.js">
83
- <link rel="modulepreload" crossorigin href="/assets/public-share-CXR25Q1X.js">
82
+ <link rel="modulepreload" crossorigin href="/assets/IdentityFields-CB3Ap0bl.js">
83
+ <link rel="modulepreload" crossorigin href="/assets/public-share-0DqS7L2Q.js">
84
84
  <link rel="modulepreload" crossorigin href="/assets/blobs-WiXP9QRi.js">
85
- <link rel="modulepreload" crossorigin href="/assets/text-documents-Cdb3U63i.js">
86
- <link rel="modulepreload" crossorigin href="/assets/useDocumentThumbnail-Cj4UYyhC.js">
85
+ <link rel="modulepreload" crossorigin href="/assets/text-documents-wu6fzOuw.js">
86
+ <link rel="modulepreload" crossorigin href="/assets/useDocumentThumbnail-CZIaXkIi.js">
87
87
  <link rel="modulepreload" crossorigin href="/assets/markdown-view-BBBZtNSR.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/sanitize-DrVcFY1Q.js">
89
89
  <link rel="modulepreload" crossorigin href="/assets/punycode.es6-ZbLrB_Dn.js">
90
90
  <link rel="modulepreload" crossorigin href="/assets/markdown-it-DRESbtwK.js">
91
- <link rel="modulepreload" crossorigin href="/assets/lazy-editor-BUFAkTGl.js">
92
- <link rel="modulepreload" crossorigin href="/assets/MessageComposerDialog-CdPp-3GR.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/lazy-editor-CShGeIep.js">
92
+ <link rel="modulepreload" crossorigin href="/assets/MessageComposerDialog-CLrwtB76.js">
93
93
  <link rel="modulepreload" crossorigin href="/assets/LinkToSidePanel-eCy3nW4R.js">
94
94
  <link rel="modulepreload" crossorigin href="/assets/note-save-status-DPz4VzL6.js">
95
- <link rel="modulepreload" crossorigin href="/assets/useEditNoteFields-BT1ASu_q.js">
96
- <link rel="modulepreload" crossorigin href="/assets/DocumentBodyEditor-CVO5KPCs.js">
95
+ <link rel="modulepreload" crossorigin href="/assets/useEditNoteFields-DsVKIHWm.js">
96
+ <link rel="modulepreload" crossorigin href="/assets/DocumentBodyEditor-C8AEpqX3.js">
97
97
  <link rel="modulepreload" crossorigin href="/assets/use-document-modal-PG8bQyIB.js">
98
- <link rel="modulepreload" crossorigin href="/assets/sketch-lazy-BY_ka1hw.js">
98
+ <link rel="modulepreload" crossorigin href="/assets/sketch-lazy-CtjOUfVz.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/geo-CZfs0E-x.js">
100
- <link rel="modulepreload" crossorigin href="/assets/ObjectPropertiesCard-D2lrTQqT.js">
101
- <link rel="modulepreload" crossorigin href="/assets/TodosWidget-CNnfNk4L.js">
100
+ <link rel="modulepreload" crossorigin href="/assets/ObjectPropertiesCard-DesXRw-_.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/TodosWidget-DGftEAbs.js">
102
102
  <link rel="modulepreload" crossorigin href="/assets/document-open-mode-DoImW-xs.js">
103
- <link rel="modulepreload" crossorigin href="/assets/PickDocumentsCard-BWgc-A02.js">
104
- <link rel="modulepreload" crossorigin href="/assets/PathPickerField-CW2yG2Yg.js">
105
- <link rel="modulepreload" crossorigin href="/assets/backend-sync-progress-B3lZB9Ha.js">
103
+ <link rel="modulepreload" crossorigin href="/assets/sha256-65KIjGvZ.js">
104
+ <link rel="modulepreload" crossorigin href="/assets/PickDocumentsCard-DVdBxx3s.js">
105
+ <link rel="modulepreload" crossorigin href="/assets/PathPickerField-CSIa7jSl.js">
106
+ <link rel="modulepreload" crossorigin href="/assets/rule-builder-CziPqpNe.js">
106
107
  <link rel="modulepreload" crossorigin href="/assets/workspace-access-C9nZlBBZ.js">
107
108
  <link rel="modulepreload" crossorigin href="/assets/search-COMZIxA7.js">
108
- <link rel="modulepreload" crossorigin href="/assets/use-sortable-data-BBKmqs79.js">
109
+ <link rel="modulepreload" crossorigin href="/assets/use-sortable-data-D7zS2qCC.js">
109
110
  <link rel="modulepreload" crossorigin href="/assets/workspace-BydSRtST.js">
110
- <link rel="modulepreload" crossorigin href="/assets/document-list-rzRLzfkF.js">
111
+ <link rel="modulepreload" crossorigin href="/assets/document-list-Bbbx-pTZ.js">
111
112
  <link rel="modulepreload" crossorigin href="/assets/url-params-n7kU_WZ-.js">
112
- <link rel="modulepreload" crossorigin href="/assets/use-canvas-pins-BPCW4twY.js">
113
- <link rel="modulepreload" crossorigin href="/assets/use-menu-DIP1zh7I.js">
114
- <link rel="modulepreload" crossorigin href="/assets/registry-FfNYUpRF.js">
115
- <link rel="modulepreload" crossorigin href="/assets/use-applet-target-BygCSj5n.js">
113
+ <link rel="modulepreload" crossorigin href="/assets/use-canvas-pins-q5Tncavk.js">
114
+ <link rel="modulepreload" crossorigin href="/assets/use-menu-CKSpS96u.js">
115
+ <link rel="modulepreload" crossorigin href="/assets/registry-g1SKt_fD.js">
116
+ <link rel="modulepreload" crossorigin href="/assets/use-applet-target-BlpVWlnA.js">
116
117
  <link rel="modulepreload" crossorigin href="/assets/last-path-BbXWC3b3.js">
117
- <link rel="modulepreload" crossorigin href="/assets/workspace-area-menu-BN5ysUpx.js">
118
- <link rel="modulepreload" crossorigin href="/assets/workspace-content-gate-C54J9Man.js">
119
- <link rel="modulepreload" crossorigin href="/assets/sha256-65KIjGvZ.js">
120
- <link rel="modulepreload" crossorigin href="/assets/UploadProgressList-D2wEpa7t.js">
121
- <link rel="modulepreload" crossorigin href="/assets/FileForm-CDiVKvxq.js">
118
+ <link rel="modulepreload" crossorigin href="/assets/document-paste-BuTC6S7_.js">
119
+ <link rel="modulepreload" crossorigin href="/assets/workspace-content-gate-BlFdbi67.js">
122
120
  <link rel="modulepreload" crossorigin href="/assets/use-theme-DaxpiICf.js">
123
121
  <link rel="stylesheet" crossorigin href="/assets/map-BcsP_QXj.css">
124
122
  <link rel="stylesheet" crossorigin href="/assets/ObjectPropertiesCard-Docu7O5V.css">
125
- <link rel="stylesheet" crossorigin href="/assets/backend-sync-progress-DU-e9TWi.css">
123
+ <link rel="stylesheet" crossorigin href="/assets/rule-builder-DU-e9TWi.css">
126
124
  <link rel="stylesheet" crossorigin href="/assets/document-list-DAYdk5vh.css">
127
125
  <link rel="stylesheet" crossorigin href="/assets/use-canvas-pins-C57Vbkrq.css">
128
- <link rel="stylesheet" crossorigin href="/assets/index-DOXi2QgX.css">
126
+ <link rel="stylesheet" crossorigin href="/assets/index-CoVFQpP3.css">
129
127
  <link rel="manifest" href="/manifest.webmanifest"></head>
130
128
  <body>
131
129
  <div id="root"></div>