@augmentd-labs/canvas-web 2.26.39 → 2.26.41

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 (82) hide show
  1. package/dist/assets/CalendarApplet-Bno3IDzO.js +2 -0
  2. package/dist/assets/FileForm-CDiVKvxq.js +1 -0
  3. package/dist/assets/{FiltersApplet-CvdFlyn1.js → FiltersApplet-PclPc7fz.js} +1 -1
  4. package/dist/assets/{HomeFab-DRmbW2Uu.js → HomeFab-B3f-hO-p.js} +1 -1
  5. package/dist/assets/{IdentityFields-C7sv9pMk.js → IdentityFields-D-NCTUaE.js} +1 -1
  6. package/dist/assets/{LensApplet-gIiGSdLb.js → LensApplet-BnW7b0KX.js} +1 -1
  7. package/dist/assets/LinkToCard-CKVi4Nrg.js +1 -0
  8. package/dist/assets/{NextShell-DiyMsTp5.js → NextShell-ull6WmMg.js} +1 -1
  9. package/dist/assets/{NotesApplet-BUXkez68.js → NotesApplet-FjdHMWCV.js} +1 -1
  10. package/dist/assets/{ObjectPropertiesCard-pE3IL82x.js → ObjectPropertiesCard-D2lrTQqT.js} +4 -4
  11. package/dist/assets/{PathPickerField-D7SubxSh.js → PathPickerField-CW2yG2Yg.js} +1 -1
  12. package/dist/assets/{PickDocumentsCard-BhJbPlxk.js → PickDocumentsCard-BWgc-A02.js} +1 -1
  13. package/dist/assets/{SketchApplet-CQexRECa.js → SketchApplet-BKnhzTBA.js} +1 -1
  14. package/dist/assets/{SketchEditor-DxIN-6wI.js → SketchEditor-DmGMcbU0.js} +2 -2
  15. package/dist/assets/{TerminalApplet-D-F4-4Zt.js → TerminalApplet-D7YxftqM.js} +1 -1
  16. package/dist/assets/{TextDocumentEditor-YAeo69K7.js → TextDocumentEditor-BQnVD0dd.js} +1 -1
  17. package/dist/assets/{TodosApplet-OBi0XUdm.js → TodosApplet-DU5VWc5i.js} +1 -1
  18. package/dist/assets/{TodosWidget-B_R-vHxf.js → TodosWidget-CNnfNk4L.js} +1 -1
  19. package/dist/assets/{UploadProgressList-C9teR7r-.js → UploadProgressList-D2wEpa7t.js} +1 -1
  20. package/dist/assets/{_agentId_-CYfkXrJk.js → _agentId_-CW33ane1.js} +0 -0
  21. package/dist/assets/_contextId_-wbu8w6OE.js +1 -0
  22. package/dist/assets/_workspaceName_-Ck6op9kd.js +1 -0
  23. package/dist/assets/{about-CCShKl-5.js → about-DRzhyy-e.js} +1 -1
  24. package/dist/assets/{add-G2dEzOng.js → add-BeESP_fg.js} +1 -1
  25. package/dist/assets/{agents-vx49b2X5.js → agents-BYNJHrPc.js} +1 -1
  26. package/dist/assets/{appearance-Dmzr0s9n.js → appearance-DiQhAis2.js} +1 -1
  27. package/dist/assets/{applet-target-DYrCD8BZ.js → applet-target-pLdP-R76.js} +1 -1
  28. package/dist/assets/{apps-B6DG6ZpO.js → apps-C2mb0HML.js} +1 -1
  29. package/dist/assets/backend-sync-progress-CFe6JPuR.js +6 -0
  30. package/dist/assets/{context-1vR30CeC.js → context-t3rdtGUB.js} +1 -1
  31. package/dist/assets/{contexts-DFYjIhsj2.js → contexts-Bq8LHUTK2.js} +1 -1
  32. package/dist/assets/{date-time-picker-C40sYmga.js → date-time-picker-DCikruos.js} +1 -1
  33. package/dist/assets/{document-BiNwuf1n.js → document-Cr7GhnVd.js} +1 -1
  34. package/dist/assets/document-list-CUmMhD6M.js +3 -0
  35. package/dist/assets/{home-B1ilyR89.js → home-BRx1tOR-.js} +1 -1
  36. package/dist/assets/index-CYvpxvg6.css +2 -0
  37. package/dist/assets/{index-CXPA9Fj8.js → index-I9cslsRe.js} +6 -6
  38. package/dist/assets/{key-bindings-DXepopri.js → key-bindings-CvzGVYrr.js} +1 -1
  39. package/dist/assets/{offline-DonGsRsw.js → offline-ByoT6JJX.js} +1 -1
  40. package/dist/assets/{public-share-DLXh7Ie6.js → public-share-CXR25Q1X.js} +1 -1
  41. package/dist/assets/query-debug-lD5vbJGi.js +1 -0
  42. package/dist/assets/{registry-eFbDXN9w.js → registry-NAExJwr9.js} +2 -2
  43. package/dist/assets/{roles-DDiKiRii.js → roles-sb8vgjV_.js} +1 -1
  44. package/dist/assets/{settings-D-yPOLZk.js → settings-CjKOuPew.js} +1 -1
  45. package/dist/assets/settings-DMM8k_4o.js +16 -0
  46. package/dist/assets/{settings-CwyGwKFU.js → settings-DrQdeEUS.js} +1 -1
  47. package/dist/assets/{settings-CgjGE01m.js → settings-HBpYbGPW.js} +1 -1
  48. package/dist/assets/{share-target-BhGDitlj.js → share-target-q77WkQhO.js} +1 -1
  49. package/dist/assets/{shared-XYVtCrC8.js → shared-BLOuO2Is.js} +1 -1
  50. package/dist/assets/{shared-DimeKqW8.js → shared-DsgNtRuD.js} +1 -1
  51. package/dist/assets/{sketch-lazy-6eEi8GIA.js → sketch-lazy-BY_ka1hw.js} +2 -2
  52. package/dist/assets/{text-documents-DxVsu9zG.js → text-documents-Cdb3U63i.js} +2 -2
  53. package/dist/assets/tree-folders-CNu09uPg.js +1 -0
  54. package/dist/assets/{use-applet-docs-FqhvvOWx.js → use-applet-docs-rimRHjID.js} +1 -1
  55. package/dist/assets/{use-applet-target-1DU4mgJH.js → use-applet-target-BygCSj5n.js} +1 -1
  56. package/dist/assets/use-canvas-pins-Bhd7_wde.js +3 -0
  57. package/dist/assets/{use-workspace-identity-KEG0VpcX.js → use-workspace-identity-CSkRwVyo.js} +1 -1
  58. package/dist/assets/{useAddTarget-BEgKjqGj.js → useAddTarget-DeRZWtGg.js} +1 -1
  59. package/dist/assets/{useAgentModels-CI7iZlUR.js → useAgentModels-B48KqDI7.js} +1 -1
  60. package/dist/assets/{useDocumentThumbnail-DutrNFK3.js → useDocumentThumbnail-Cj4UYyhC.js} +1 -1
  61. package/dist/assets/{useEditNoteFields-HAsbBak7.js → useEditNoteFields-BT1ASu_q.js} +1 -1
  62. package/dist/assets/{workspace-cv6Hrfhh.js → workspace-C5V-ZCOE.js} +1 -1
  63. package/dist/assets/{workspace-area-menu-CUqTxXmz.js → workspace-area-menu-B-bXURzn.js} +1 -1
  64. package/dist/assets/{workspace-content-gate-B6T3nLfW.js → workspace-content-gate-C54J9Man.js} +1 -1
  65. package/dist/assets/{workspace-import-form-D5qPcNFq.js → workspace-import-form-DTvV9jYt.js} +1 -1
  66. package/dist/assets/workspaces-y3zARr9A.js +1 -0
  67. package/dist/index.html +26 -26
  68. package/dist/sw.js +1 -1
  69. package/package.json +2 -2
  70. package/dist/assets/CalendarApplet-DVUCGIPB.js +0 -2
  71. package/dist/assets/FileForm-CMuWZbUX.js +0 -1
  72. package/dist/assets/LinkToCard-DGpvNE_V.js +0 -1
  73. package/dist/assets/_contextId_-CkahAS5d.js +0 -1
  74. package/dist/assets/_workspaceName_--lNvJpY1.js +0 -1
  75. package/dist/assets/backend-sync-progress-m7wUKTJn.js +0 -7
  76. package/dist/assets/document-list-ASCemk7T.js +0 -2
  77. package/dist/assets/index-Bi5-zGgp.css +0 -2
  78. package/dist/assets/query-debug-DhboV3qX.js +0 -1
  79. package/dist/assets/settings-CcdxMKot.js +0 -16
  80. package/dist/assets/tree-folders-whK_PK4c.js +0 -1
  81. package/dist/assets/use-canvas-pins-DqkSe_aU.js +0 -3
  82. package/dist/assets/workspaces-yHyufXqs.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{dt as r,ft as i,pt as a}from"./index-CXPA9Fj8.js";import{n as o}from"./page-header-DrDt1sQ2.js";import{t as s}from"./use-settings-back-DGmLAD63.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(i),[n,u]=(0,c.useState)(``),d=e=>{if(e.previousTree&&e.previousTree===e.nextTree){u(`Choose a different shortcut: that combination is already assigned.`);return}try{a(e),t(e),u(`Saved on this device.`)}catch{u(`Could not save shortcuts in this browser.`)}};return(0,l.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,l.jsx)(o,{className:`mb-6`,title:`Key bindings`,onBack:s(),description:`Web UI shortcuts, saved on this device and available offline.`}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`font-medium`,children:`Tree navigation`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cycle the open workspace menu’s tabs in their displayed order, including Pins and Layers. Swipe left for next or right for previous over the tab bar. Shortcuts pause while typing or using a dialog.`}),[`previousTree`,`nextTree`].map(t=>(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,l.jsx)(`label`,{htmlFor:t,className:`min-w-32 text-sm`,children:t===`previousTree`?`Previous tree`:`Next tree`}),(0,l.jsxs)(`select`,{id:t,className:`rounded-md border bg-background p-2 text-sm`,value:e[t].split(`+`).slice(0,-1).join(`+`),onChange:n=>d({...e,[t]:n.target.value?`${n.target.value}+${e[t].slice(-1)||r[t].slice(-1)}`:``}),children:[(0,l.jsx)(`option`,{value:``,children:`Disabled`}),[`Alt`,`Alt+Shift`,`Ctrl+Shift`,`Meta+Shift`].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))]}),(0,l.jsx)(`select`,{"aria-label":`${t===`previousTree`?`Previous`:`Next`} tree key`,disabled:!e[t],className:`rounded-md border bg-background p-2 text-sm disabled:opacity-50`,value:e[t].slice(-1)||r[t].slice(-1),onChange:n=>d({...e,[t]:`${e[t].split(`+`).slice(0,-1).join(`+`)}+${n.target.value}`}),children:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``).map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]},t)),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browsers and operating systems may reserve combinations. Choose another if a shortcut does not reach Canvas. Letters refer to physical keyboard positions (Q/W on a US keyboard); Meta is Command on Mac.`}),(0,l.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 text-sm hover:bg-accent`,onClick:()=>d({...r}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u 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{dt as r,ft as i,pt as a}from"./index-I9cslsRe.js";import{n as o}from"./page-header-DrDt1sQ2.js";import{t as s}from"./use-settings-back-DGmLAD63.js";var c=e(n(),1),l=t();function u(){let[e,t]=(0,c.useState)(i),[n,u]=(0,c.useState)(``),d=e=>{if(e.previousTree&&e.previousTree===e.nextTree){u(`Choose a different shortcut: that combination is already assigned.`);return}try{a(e),t(e),u(`Saved on this device.`)}catch{u(`Could not save shortcuts in this browser.`)}};return(0,l.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,l.jsx)(o,{className:`mb-6`,title:`Key bindings`,onBack:s(),description:`Web UI shortcuts, saved on this device and available offline.`}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`font-medium`,children:`Tree navigation`}),(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cycle the open workspace menu’s tabs in their displayed order, including Pins and Layers. Swipe left for next or right for previous over the tab bar. Shortcuts pause while typing or using a dialog.`}),[`previousTree`,`nextTree`].map(t=>(0,l.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,l.jsx)(`label`,{htmlFor:t,className:`min-w-32 text-sm`,children:t===`previousTree`?`Previous tree`:`Next tree`}),(0,l.jsxs)(`select`,{id:t,className:`rounded-md border bg-background p-2 text-sm`,value:e[t].split(`+`).slice(0,-1).join(`+`),onChange:n=>d({...e,[t]:n.target.value?`${n.target.value}+${e[t].slice(-1)||r[t].slice(-1)}`:``}),children:[(0,l.jsx)(`option`,{value:``,children:`Disabled`}),[`Alt`,`Alt+Shift`,`Ctrl+Shift`,`Meta+Shift`].map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))]}),(0,l.jsx)(`select`,{"aria-label":`${t===`previousTree`?`Previous`:`Next`} tree key`,disabled:!e[t],className:`rounded-md border bg-background p-2 text-sm disabled:opacity-50`,value:e[t].slice(-1)||r[t].slice(-1),onChange:n=>d({...e,[t]:`${e[t].split(`+`).slice(0,-1).join(`+`)}+${n.target.value}`}),children:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``).map(e=>(0,l.jsx)(`option`,{value:e,children:e},e))})]},t)),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Browsers and operating systems may reserve combinations. Choose another if a shortcut does not reach Canvas. Letters refer to physical keyboard positions (Q/W on a US keyboard); Meta is Command on Mac.`}),(0,l.jsx)(`button`,{type:`button`,className:`rounded-md border px-3 py-2 text-sm hover:bg-accent`,onClick:()=>d({...r}),children:`Restore defaults`}),(0,l.jsx)(`p`,{role:`status`,className:`text-sm`,children:n})]})]})}export{u as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{L as r,Lt as i,Vn as a,Wr as o,X as s,kt as c,oi as l,pn as u}from"./ui-CDoK3F3U.js";import{t as d}from"./utils-2pl1SbIp.js";import{t as f}from"./button-SeUZ_Pvi.js";import{c as p}from"./api-CA6WiiYM.js";import{t as m}from"./LinkToCard-DGpvNE_V.js";import{Nt as h,R as g,rt as _,z as v}from"./workspace-cv6Hrfhh.js";import{t as y}from"./useToastHelpers-CRrpIIdY.js";import{n as b}from"./LinkToSidePanel-eCy3nW4R.js";import{n as x}from"./page-header-DrDt1sQ2.js";import{t as S}from"./use-settings-back-DGmLAD63.js";var C=e(n(),1),w=`offline-content-v1`,T=`offline-api-v1`,E=1073741824,D={enabled:!1,budgetBytes:4*E,excludedWorkspaces:[]},O=1e3;function k(e){return(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``)||`/`}function A(e,t,n){return`${e}:${t}:${k(n)}`}var j=`canvas-offline`,M=2,N=null;function P(){return N||(N=new Promise((e,t)=>{let n=indexedDB.open(j,M);n.onupgradeneeded=e=>{let t=n.result;if(t.objectStoreNames.contains(`config`)||t.createObjectStore(`config`),t.objectStoreNames.contains(`entries`)||t.createObjectStore(`entries`,{keyPath:`url`}),e.oldVersion>=1&&t.objectStoreNames.contains(`pins`)){t.deleteObjectStore(`pins`);let e=n.transaction.objectStore(`entries`).openCursor();e.onsuccess=()=>{let t=e.result;if(!t)return;let n=t.value;n.pinned&&t.update({...n,pinned:!1}),t.continue()}}t.objectStoreNames.contains(`scopes`)||t.createObjectStore(`scopes`,{keyPath:`id`})},n.onsuccess=()=>{n.result.onversionchange=()=>{n.result.close(),N=null},e(n.result)},n.onerror=()=>{N=null,t(n.error)}}),N)}function F(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error)})}function I(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function L(e,t){return I((await P()).transaction(e).objectStore(e).get(t))}async function R(e){return I((await P()).transaction(e).objectStore(e).getAll())}async function z(e,t,n){let r=(await P()).transaction(e,`readwrite`);return r.objectStore(e).put(t,n),F(r)}async function B(e,t){let n=(await P()).transaction(e,`readwrite`);return n.objectStore(e).delete(t),F(n)}async function V(e){let t=(await P()).transaction(e,`readwrite`);return t.objectStore(e).clear(),F(t)}async function H(){try{let e=await L(`config`,`settings`);return e?{...D,...e}:D}catch{return D}}async function U(e){await z(`config`,e,`settings`)}async function W(e,t){let n=(await P()).transaction(`entries`,`readwrite`),r=n.objectStore(`entries`);for(let n of e){let e=r.get(n);e.onsuccess=()=>{let i=e.result;i?r.put({...i,pinned:t}):t&&r.put({url:n,kind:`content`,size:0,lastAccess:Date.now(),pinned:t})}}return F(n)}async function ee(e){let t=await R(`entries`),n=t.filter(e=>e.kind===`api`).sort((e,t)=>e.lastAccess-t.lastAccess),r=n.slice(0,Math.max(0,n.length-O)),i=t.filter(e=>e.kind===`content`),a=i.reduce((e,t)=>e+t.size,0),o=i.filter(e=>!e.pinned).sort((e,t)=>e.lastAccess-t.lastAccess),s=[];for(let t of o){if(a<=e)break;s.push(t),a-=t.size}if(!r.length&&!s.length)return;let[c,l]=await Promise.all([caches.open(T),caches.open(w)]);await Promise.all([...r.map(async e=>{await c.delete(e.url),await B(`entries`,e.url)}),...s.map(async e=>{await l.delete(e.url),await B(`entries`,e.url)})])}async function te(){let e=await R(`entries`),t=e.filter(e=>e.kind===`content`);return{contentBytes:t.reduce((e,t)=>e+t.size,0),contentCount:t.length,pinnedBytes:t.filter(e=>e.pinned).reduce((e,t)=>e+t.size,0),apiCount:e.length-t.length}}async function ne(){await Promise.all([caches.delete(w),caches.delete(T)]),await V(`entries`),await V(`scopes`)}async function re(){return R(`scopes`)}async function ie(e){return L(`scopes`,e)}async function G(e){await z(`scopes`,e)}async function K(e){let t=await L(`scopes`,e);await B(`scopes`,e),t?.urls.length&&await q(t.urls)}async function q(e){let t=await R(`scopes`),n=new Set(t.flatMap(e=>e.urls)),r=e.filter(e=>!n.has(e));r.length&&await W(r,!1)}var J=3,ae=`data/schema/file`,Y=128;async function oe({workspaceRef:e,path:t,treeName:n,treeType:r},i){let a=await H();if(!a.enabled)throw Error(`Enable the offline cache first`);if(a.excludedWorkspaces.includes(e))throw Error(`Workspace "${e}" is excluded from offline caching`);let o=A(e,n,t),s=k(t),c=await ie(o),l=((await _(e,s,[],{limit:1e4,treeName:n,treeType:r})).payload??[]).filter(e=>e.schema===ae),u=[],d=0,f=0,m=!1,h=l.length;i?.({done:f,total:h,bytes:d});let y=0;await Promise.all(Array.from({length:Math.min(J,l.length)},async()=>{for(;y<l.length;){let t=l[y++];if(d>=a.budgetBytes*.9){m=!0;return}try{let{blob:n}=await g(e,t.id);d+=n.size,u.push(`${p.workspaces}/${e}/documents/${t.id}/content`);try{await v(e,t.id,Y),u.push(`${p.workspaces}/${e}/documents/${t.id}/thumbnail?size=${Y}`)}catch{}}catch{}f+=1,i?.({done:f,total:h,bytes:d})}})),await W(u,!0);let b={id:o,workspaceRef:e,treeName:n,treeType:r,path:s,urls:u,bytes:d,warmedAt:Date.now(),...m?{truncated:!0}:{}};if(await G(b),c){let e=new Set(u),t=c.urls.filter(t=>!e.has(t));t.length&&await q(t)}return b}var X=t(),Z=[{label:`1 GB`,bytes:1*E},{label:`2 GB`,bytes:2*E},{label:`4 GB`,bytes:4*E},{label:`8 GB`,bytes:8*E}];function Q(e){return e<1048576?`${(e/1024).toFixed(0)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/E).toFixed(2)} GB`}function se(){navigator.serviceWorker?.controller?.postMessage({type:`OFFLINE_SETTINGS_CHANGED`})}function ce(){let{showSuccessToast:e,showErrorToast:t}=y(),[n,p]=(0,C.useState)(null),[g,_]=(0,C.useState)(null),[v,x]=(0,C.useState)(null),[S,w]=(0,C.useState)([]),[T,E]=(0,C.useState)([]),[D,O]=(0,C.useState)({}),[k,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),P=(0,C.useCallback)(()=>{H().then(p).catch(()=>{}),te().then(_).catch(()=>{}),re().then(e=>E(e.sort((e,t)=>e.id.localeCompare(t.id)))).catch(()=>{}),navigator.storage?.persisted?.().then(x).catch(()=>{})},[]);(0,C.useEffect)(()=>{P(),h().then(e=>w(e.map(e=>e.name).filter(Boolean).sort())).catch(()=>{})},[P]);let F=async e=>{p(e),await U(e),se(),e.enabled&&navigator.storage?.persist?.().then(x).catch(()=>{}),ee(e.budgetBytes).then(P).catch(()=>{})},I=e=>{if(!n)return;let t=n.excludedWorkspaces.includes(e)?n.excludedWorkspaces.filter(t=>t!==e):[...n.excludedWorkspaces,e];F({...n,excludedWorkspaces:t})},L=async()=>{j(!0);try{await ne(),e(`Offline cache cleared`),P()}catch(e){t(e instanceof Error?e.message:`Failed to clear cache`)}finally{j(!1)}},R=async n=>{let r=A(n.workspaceRef,n.treeName,n.path);O(e=>({...e,[r]:{done:0,total:0,bytes:0}}));try{let t=await oe(n,e=>O(t=>({...t,[r]:e})));e(t.truncated?`Pinned ${Q(t.bytes)} — stopped at the size budget`:`Pinned ${t.workspaceRef}:/${t.path} (${Q(t.bytes)})`)}catch(e){t(e instanceof Error?e.message:`Failed to pin`)}finally{O(e=>{let{[r]:t,...n}=e;return n}),P()}},z=(e,t)=>{N(!1);for(let n of e)R({workspaceRef:t.workspaceName,path:n,treeName:t.treeName,treeType:t.treeType})},B=e=>({workspaceRef:e.workspaceRef,path:e.path,treeName:e.treeName||`context`,treeType:e.treeType||`context`}),V=async e=>{await K(e),P()};return n?(0,X.jsxs)(`div`,{className:`space-y-8`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Offline cache`,description:`Keep documents you open (and scopes you pin) readable without a connection. Cached on this device only; least-recently-used files are evicted when the size budget fills. Video streaming is not cached.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>F({...n,enabled:!n.enabled}),"aria-pressed":n.enabled,className:d(`focus-ring flex items-center gap-3 rounded-lg border p-4 text-left transition-colors`,n.enabled?`border-primary bg-accent`:`border-input hover:bg-muted/40`),children:[(0,X.jsx)(a,{className:`h-5 w-5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:n.enabled?`Enabled`:`Disabled`}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:n.enabled?v===!1?`Storage is not persistent — the browser may still evict the cache under disk pressure`:`Documents are cached as you browse`:`Nothing is cached for offline use`})]}),n.enabled&&(0,X.jsx)(o,{className:`h-4 w-4 shrink-0 text-primary`})]}),n.enabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Size budget`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map(e=>(0,X.jsx)(f,{variant:n.budgetBytes===e.bytes?`default`:`outline`,size:`sm`,onClick:()=>F({...n,budgetBytes:e.bytes}),children:e.label},e.bytes))})]}),g&&(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between text-sm`,children:[(0,X.jsxs)(`span`,{children:[Q(g.contentBytes),` of `,Q(n.budgetBytes),` used`]}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[g.contentCount,` file(s)`,g.pinnedBytes>0?`, ${Q(g.pinnedBytes)} pinned`:``]})]}),(0,X.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${Math.min(100,g.contentBytes/n.budgetBytes*100)}%`}})})]}),(0,X.jsx)(`div`,{children:(0,X.jsxs)(f,{variant:`outline`,size:`sm`,onClick:L,disabled:k,children:[k?(0,X.jsx)(u,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(s,{className:`mr-1.5 h-3.5 w-3.5`}),`Clear offline cache`]})})]})]})]}),n.enabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Pinned scopes`,description:`A pinned scope — a workspace, or one of its tree paths — is downloaded up front and never evicted. Scopes resolve fresh on every re-warm, so moved contexts and reorganized trees are picked up; documents that left a scope return to normal eviction.`}),(0,X.jsx)(`div`,{className:`mb-3`,children:(0,X.jsxs)(f,{size:`sm`,onClick:()=>N(!0),disabled:!!Object.keys(D).length,children:[(0,X.jsx)(i,{className:`mr-1.5 h-3.5 w-3.5`}),`Pin a path…`]})}),(0,X.jsxs)(`ul`,{className:`space-y-1`,children:[T.map(e=>{let t=D[e.id];return(0,X.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border border-input px-3 py-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex-1 truncate font-mono text-xs sm:text-sm`,children:[e.workspaceRef,`://`,e.path.replace(/^\//,``),e.treeName&&e.treeName!==`context`&&(0,X.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 font-sans text-[10px] text-muted-foreground`,children:e.treeName})]}),t?(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}),t.total>0?`${t.done}/${t.total} · ${Q(t.bytes)}`:`listing…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[Q(e.bytes),e.truncated?` (partial)`:``]}),(0,X.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>R(B(e)),"aria-label":`Re-warm ${e.id}`,title:`Re-warm: re-resolve the scope and download anything new`,children:(0,X.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>V(e.id),"aria-label":`Unpin ${e.id}`,children:(0,X.jsx)(r,{className:`h-3.5 w-3.5`})})]})]},e.id)}),T.length===0&&(0,X.jsx)(`li`,{className:`rounded-md border border-dashed border-input px-3 py-4 text-center text-sm text-muted-foreground`,children:`Nothing pinned — everything relies on browse-caching and LRU`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Workspace caching`,description:`Excluded workspaces are never cached — not even as you browse — and are not served from cache.`}),(0,X.jsx)(`ul`,{className:`space-y-1`,children:S.map(e=>{let t=n.excludedWorkspaces.includes(e);return(0,X.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border border-input px-3 py-2 text-sm`,children:[(0,X.jsx)(`span`,{className:d(`flex-1 truncate`,t&&`text-muted-foreground line-through`),children:e}),t&&(0,X.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(f,{variant:t?`outline`:`ghost`,size:`sm`,onClick:()=>I(e),children:t?`Include`:`Exclude`})]},e)})})]})]}),M&&(0,X.jsx)(b,{onClose:()=>N(!1),children:(0,X.jsx)(m,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,multiple:!1,tabs:[`context`,`directory`],title:`Pin for offline…`,confirmLabel:`Pin path`,onConfirm:z,onClose:()=>N(!1)})})]}):null}function $({title:e,description:t}){return(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function le(){return(0,X.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,X.jsx)(x,{className:`mb-6`,title:`Offline`,onBack:S(),description:`Per-device offline cache: browse notes, files, photos and saved websites without a connection.`}),(0,X.jsx)(ce,{})]})}export{le 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,Lt as i,Vn as a,Wr as o,X as s,kt as c,oi as l,pn as u}from"./ui-CDoK3F3U.js";import{t as d}from"./utils-2pl1SbIp.js";import{t as f}from"./button-SeUZ_Pvi.js";import{c as p}from"./api-CA6WiiYM.js";import{t as m}from"./LinkToCard-CKVi4Nrg.js";import{L as h,R as g,jt as _,nt as v}from"./workspace-C5V-ZCOE.js";import{t as y}from"./useToastHelpers-CRrpIIdY.js";import{n as b}from"./LinkToSidePanel-eCy3nW4R.js";import{n as x}from"./page-header-DrDt1sQ2.js";import{t as S}from"./use-settings-back-DGmLAD63.js";var C=e(n(),1),w=`offline-content-v1`,T=`offline-api-v1`,E=1073741824,D={enabled:!1,budgetBytes:4*E,excludedWorkspaces:[]},O=1e3;function k(e){return(e.startsWith(`/`)?e:`/${e}`).replace(/\/+$/,``)||`/`}function A(e,t,n){return`${e}:${t}:${k(n)}`}var j=`canvas-offline`,M=2,N=null;function P(){return N||(N=new Promise((e,t)=>{let n=indexedDB.open(j,M);n.onupgradeneeded=e=>{let t=n.result;if(t.objectStoreNames.contains(`config`)||t.createObjectStore(`config`),t.objectStoreNames.contains(`entries`)||t.createObjectStore(`entries`,{keyPath:`url`}),e.oldVersion>=1&&t.objectStoreNames.contains(`pins`)){t.deleteObjectStore(`pins`);let e=n.transaction.objectStore(`entries`).openCursor();e.onsuccess=()=>{let t=e.result;if(!t)return;let n=t.value;n.pinned&&t.update({...n,pinned:!1}),t.continue()}}t.objectStoreNames.contains(`scopes`)||t.createObjectStore(`scopes`,{keyPath:`id`})},n.onsuccess=()=>{n.result.onversionchange=()=>{n.result.close(),N=null},e(n.result)},n.onerror=()=>{N=null,t(n.error)}}),N)}function F(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error)})}function I(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}async function L(e,t){return I((await P()).transaction(e).objectStore(e).get(t))}async function R(e){return I((await P()).transaction(e).objectStore(e).getAll())}async function z(e,t,n){let r=(await P()).transaction(e,`readwrite`);return r.objectStore(e).put(t,n),F(r)}async function B(e,t){let n=(await P()).transaction(e,`readwrite`);return n.objectStore(e).delete(t),F(n)}async function V(e){let t=(await P()).transaction(e,`readwrite`);return t.objectStore(e).clear(),F(t)}async function H(){try{let e=await L(`config`,`settings`);return e?{...D,...e}:D}catch{return D}}async function U(e){await z(`config`,e,`settings`)}async function W(e,t){let n=(await P()).transaction(`entries`,`readwrite`),r=n.objectStore(`entries`);for(let n of e){let e=r.get(n);e.onsuccess=()=>{let i=e.result;i?r.put({...i,pinned:t}):t&&r.put({url:n,kind:`content`,size:0,lastAccess:Date.now(),pinned:t})}}return F(n)}async function ee(e){let t=await R(`entries`),n=t.filter(e=>e.kind===`api`).sort((e,t)=>e.lastAccess-t.lastAccess),r=n.slice(0,Math.max(0,n.length-O)),i=t.filter(e=>e.kind===`content`),a=i.reduce((e,t)=>e+t.size,0),o=i.filter(e=>!e.pinned).sort((e,t)=>e.lastAccess-t.lastAccess),s=[];for(let t of o){if(a<=e)break;s.push(t),a-=t.size}if(!r.length&&!s.length)return;let[c,l]=await Promise.all([caches.open(T),caches.open(w)]);await Promise.all([...r.map(async e=>{await c.delete(e.url),await B(`entries`,e.url)}),...s.map(async e=>{await l.delete(e.url),await B(`entries`,e.url)})])}async function te(){let e=await R(`entries`),t=e.filter(e=>e.kind===`content`);return{contentBytes:t.reduce((e,t)=>e+t.size,0),contentCount:t.length,pinnedBytes:t.filter(e=>e.pinned).reduce((e,t)=>e+t.size,0),apiCount:e.length-t.length}}async function ne(){await Promise.all([caches.delete(w),caches.delete(T)]),await V(`entries`),await V(`scopes`)}async function re(){return R(`scopes`)}async function ie(e){return L(`scopes`,e)}async function G(e){await z(`scopes`,e)}async function K(e){let t=await L(`scopes`,e);await B(`scopes`,e),t?.urls.length&&await q(t.urls)}async function q(e){let t=await R(`scopes`),n=new Set(t.flatMap(e=>e.urls)),r=e.filter(e=>!n.has(e));r.length&&await W(r,!1)}var J=3,ae=`data/schema/file`,Y=128;async function oe({workspaceRef:e,path:t,treeName:n,treeType:r},i){let a=await H();if(!a.enabled)throw Error(`Enable the offline cache first`);if(a.excludedWorkspaces.includes(e))throw Error(`Workspace "${e}" is excluded from offline caching`);let o=A(e,n,t),s=k(t),c=await ie(o),l=((await v(e,s,[],{limit:1e4,treeName:n,treeType:r})).payload??[]).filter(e=>e.schema===ae),u=[],d=0,f=0,m=!1,_=l.length;i?.({done:f,total:_,bytes:d});let y=0;await Promise.all(Array.from({length:Math.min(J,l.length)},async()=>{for(;y<l.length;){let t=l[y++];if(d>=a.budgetBytes*.9){m=!0;return}try{let{blob:n}=await h(e,t.id);d+=n.size,u.push(`${p.workspaces}/${e}/documents/${t.id}/content`);try{await g(e,t.id,Y),u.push(`${p.workspaces}/${e}/documents/${t.id}/thumbnail?size=${Y}`)}catch{}}catch{}f+=1,i?.({done:f,total:_,bytes:d})}})),await W(u,!0);let b={id:o,workspaceRef:e,treeName:n,treeType:r,path:s,urls:u,bytes:d,warmedAt:Date.now(),...m?{truncated:!0}:{}};if(await G(b),c){let e=new Set(u),t=c.urls.filter(t=>!e.has(t));t.length&&await q(t)}return b}var X=t(),Z=[{label:`1 GB`,bytes:1*E},{label:`2 GB`,bytes:2*E},{label:`4 GB`,bytes:4*E},{label:`8 GB`,bytes:8*E}];function Q(e){return e<1048576?`${(e/1024).toFixed(0)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/E).toFixed(2)} GB`}function se(){navigator.serviceWorker?.controller?.postMessage({type:`OFFLINE_SETTINGS_CHANGED`})}function ce(){let{showSuccessToast:e,showErrorToast:t}=y(),[n,p]=(0,C.useState)(null),[h,g]=(0,C.useState)(null),[v,x]=(0,C.useState)(null),[S,w]=(0,C.useState)([]),[T,E]=(0,C.useState)([]),[D,O]=(0,C.useState)({}),[k,j]=(0,C.useState)(!1),[M,N]=(0,C.useState)(!1),P=(0,C.useCallback)(()=>{H().then(p).catch(()=>{}),te().then(g).catch(()=>{}),re().then(e=>E(e.sort((e,t)=>e.id.localeCompare(t.id)))).catch(()=>{}),navigator.storage?.persisted?.().then(x).catch(()=>{})},[]);(0,C.useEffect)(()=>{P(),_().then(e=>w(e.map(e=>e.name).filter(Boolean).sort())).catch(()=>{})},[P]);let F=async e=>{p(e),await U(e),se(),e.enabled&&navigator.storage?.persist?.().then(x).catch(()=>{}),ee(e.budgetBytes).then(P).catch(()=>{})},I=e=>{if(!n)return;let t=n.excludedWorkspaces.includes(e)?n.excludedWorkspaces.filter(t=>t!==e):[...n.excludedWorkspaces,e];F({...n,excludedWorkspaces:t})},L=async()=>{j(!0);try{await ne(),e(`Offline cache cleared`),P()}catch(e){t(e instanceof Error?e.message:`Failed to clear cache`)}finally{j(!1)}},R=async n=>{let r=A(n.workspaceRef,n.treeName,n.path);O(e=>({...e,[r]:{done:0,total:0,bytes:0}}));try{let t=await oe(n,e=>O(t=>({...t,[r]:e})));e(t.truncated?`Pinned ${Q(t.bytes)} — stopped at the size budget`:`Pinned ${t.workspaceRef}:/${t.path} (${Q(t.bytes)})`)}catch(e){t(e instanceof Error?e.message:`Failed to pin`)}finally{O(e=>{let{[r]:t,...n}=e;return n}),P()}},z=(e,t)=>{N(!1);for(let n of e)R({workspaceRef:t.workspaceName,path:n,treeName:t.treeName,treeType:t.treeType})},B=e=>({workspaceRef:e.workspaceRef,path:e.path,treeName:e.treeName||`context`,treeType:e.treeType||`context`}),V=async e=>{await K(e),P()};return n?(0,X.jsxs)(`div`,{className:`space-y-8`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Offline cache`,description:`Keep documents you open (and scopes you pin) readable without a connection. Cached on this device only; least-recently-used files are evicted when the size budget fills. Video streaming is not cached.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>F({...n,enabled:!n.enabled}),"aria-pressed":n.enabled,className:d(`focus-ring flex items-center gap-3 rounded-lg border p-4 text-left transition-colors`,n.enabled?`border-primary bg-accent`:`border-input hover:bg-muted/40`),children:[(0,X.jsx)(a,{className:`h-5 w-5 shrink-0 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:n.enabled?`Enabled`:`Disabled`}),(0,X.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:n.enabled?v===!1?`Storage is not persistent — the browser may still evict the cache under disk pressure`:`Documents are cached as you browse`:`Nothing is cached for offline use`})]}),n.enabled&&(0,X.jsx)(o,{className:`h-4 w-4 shrink-0 text-primary`})]}),n.enabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Size budget`}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map(e=>(0,X.jsx)(f,{variant:n.budgetBytes===e.bytes?`default`:`outline`,size:`sm`,onClick:()=>F({...n,budgetBytes:e.bytes}),children:e.label},e.bytes))})]}),h&&(0,X.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between text-sm`,children:[(0,X.jsxs)(`span`,{children:[Q(h.contentBytes),` of `,Q(n.budgetBytes),` used`]}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[h.contentCount,` file(s)`,h.pinnedBytes>0?`, ${Q(h.pinnedBytes)} pinned`:``]})]}),(0,X.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary`,style:{width:`${Math.min(100,h.contentBytes/n.budgetBytes*100)}%`}})})]}),(0,X.jsx)(`div`,{children:(0,X.jsxs)(f,{variant:`outline`,size:`sm`,onClick:L,disabled:k,children:[k?(0,X.jsx)(u,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,X.jsx)(s,{className:`mr-1.5 h-3.5 w-3.5`}),`Clear offline cache`]})})]})]})]}),n.enabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Pinned scopes`,description:`A pinned scope — a workspace, or one of its tree paths — is downloaded up front and never evicted. Scopes resolve fresh on every re-warm, so moved contexts and reorganized trees are picked up; documents that left a scope return to normal eviction.`}),(0,X.jsx)(`div`,{className:`mb-3`,children:(0,X.jsxs)(f,{size:`sm`,onClick:()=>N(!0),disabled:!!Object.keys(D).length,children:[(0,X.jsx)(i,{className:`mr-1.5 h-3.5 w-3.5`}),`Pin a path…`]})}),(0,X.jsxs)(`ul`,{className:`space-y-1`,children:[T.map(e=>{let t=D[e.id];return(0,X.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border border-input px-3 py-2 text-sm`,children:[(0,X.jsxs)(`span`,{className:`flex-1 truncate font-mono text-xs sm:text-sm`,children:[e.workspaceRef,`://`,e.path.replace(/^\//,``),e.treeName&&e.treeName!==`context`&&(0,X.jsx)(`span`,{className:`ml-1.5 rounded bg-muted px-1 py-0.5 font-sans text-[10px] text-muted-foreground`,children:e.treeName})]}),t?(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}),t.total>0?`${t.done}/${t.total} · ${Q(t.bytes)}`:`listing…`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[Q(e.bytes),e.truncated?` (partial)`:``]}),(0,X.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>R(B(e)),"aria-label":`Re-warm ${e.id}`,title:`Re-warm: re-resolve the scope and download anything new`,children:(0,X.jsx)(c,{className:`h-3.5 w-3.5`})}),(0,X.jsx)(f,{variant:`ghost`,size:`sm`,onClick:()=>V(e.id),"aria-label":`Unpin ${e.id}`,children:(0,X.jsx)(r,{className:`h-3.5 w-3.5`})})]})]},e.id)}),T.length===0&&(0,X.jsx)(`li`,{className:`rounded-md border border-dashed border-input px-3 py-4 text-center text-sm text-muted-foreground`,children:`Nothing pinned — everything relies on browse-caching and LRU`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)($,{title:`Workspace caching`,description:`Excluded workspaces are never cached — not even as you browse — and are not served from cache.`}),(0,X.jsx)(`ul`,{className:`space-y-1`,children:S.map(e=>{let t=n.excludedWorkspaces.includes(e);return(0,X.jsxs)(`li`,{className:`flex items-center gap-3 rounded-md border border-input px-3 py-2 text-sm`,children:[(0,X.jsx)(`span`,{className:d(`flex-1 truncate`,t&&`text-muted-foreground line-through`),children:e}),t&&(0,X.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(f,{variant:t?`outline`:`ghost`,size:`sm`,onClick:()=>I(e),children:t?`Include`:`Exclude`})]},e)})})]})]}),M&&(0,X.jsx)(b,{onClose:()=>N(!1),children:(0,X.jsx)(m,{sizeClassName:`h-full w-[380px] max-w-[90vw] max-md:w-full`,multiple:!1,tabs:[`context`,`directory`],title:`Pin for offline…`,confirmLabel:`Pin path`,onConfirm:z,onClose:()=>N(!1)})})]}):null}function $({title:e,description:t}){return(0,X.jsxs)(`div`,{className:`mb-4`,children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function le(){return(0,X.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[(0,X.jsx)(x,{className:`mb-6`,title:`Offline`,onBack:S(),description:`Per-device offline cache: browse notes, files, photos and saved websites without a connection.`}),(0,X.jsx)(ce,{})]})}export{le as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{l as n}from"./api-CA6WiiYM.js";import{M as r,Qt as i,R as a,j as o,z as s}from"./workspace-cv6Hrfhh.js";var c=e(t(),1),l=(0,c.createContext)(null);function u(){return(0,c.useContext)(l)}function d(e,t,r={}){let i=new URLSearchParams;r.download&&i.set(`download`,`1`),r.url&&i.set(`url`,r.url),r.format&&i.set(`format`,r.format),r.version&&i.set(`v`,r.version);let a=i.toString();return`${n}/pub/c/${encodeURIComponent(e)}/documents/${t}/content${a?`?${a}`:``}`}async function f(e,t,r=256){let i=await fetch(`${n}/pub/c/${encodeURIComponent(e)}/documents/${t}/thumbnail?size=${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=i.headers.get(`content-type`)||`image/webp`;return{blob:await i.blob(),mime:a}}async function p(e,t,n={}){let r=await fetch(d(e,t,n),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=r.headers.get(`content-type`)||`application/octet-stream`;return{blob:await r.blob(),mime:i}}async function m(e,t,n,r={}){let{blob:i}=await p(e,t,{...r}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(a),3e4)}function h(e){let t=u();return(0,c.useMemo)(()=>({isPublic:t!=null,fetchBlob:(n,r={})=>t?p(t,n,r):a(e,n,r),fetchThumbnail:(n,r=256,i)=>t?f(t,n,r):s(e,n,r,i),download:(n,i,a={})=>t?m(t,n,i,a):r(e,n,i,a),streamUrl:(n,r={})=>t?d(t,n,r):o(e,n,r),mintTicket:n=>t?Promise.resolve(!0):i(e,n)}),[e,t])}export{u as i,d as n,h as r,l as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{u as t}from"./code-editor-BOIngd5F.js";import{l as n}from"./api-CA6WiiYM.js";import{L as r,M as i,R as a,Xt as o,j as s}from"./workspace-C5V-ZCOE.js";var c=e(t(),1),l=(0,c.createContext)(null);function u(){return(0,c.useContext)(l)}function d(e,t,r={}){let i=new URLSearchParams;r.download&&i.set(`download`,`1`),r.url&&i.set(`url`,r.url),r.format&&i.set(`format`,r.format),r.version&&i.set(`v`,r.version);let a=i.toString();return`${n}/pub/c/${encodeURIComponent(e)}/documents/${t}/content${a?`?${a}`:``}`}async function f(e,t,r=256){let i=await fetch(`${n}/pub/c/${encodeURIComponent(e)}/documents/${t}/thumbnail?size=${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=i.headers.get(`content-type`)||`image/webp`;return{blob:await i.blob(),mime:a}}async function p(e,t,n={}){let r=await fetch(d(e,t,n),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}`);let i=r.headers.get(`content-type`)||`application/octet-stream`;return{blob:await r.blob(),mime:i}}async function m(e,t,n,r={}){let{blob:i}=await p(e,t,{...r}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(a),3e4)}function h(e){let t=u();return(0,c.useMemo)(()=>({isPublic:t!=null,fetchBlob:(n,i={})=>t?p(t,n,i):r(e,n,i),fetchThumbnail:(n,r=256,i)=>t?f(t,n,r):a(e,n,r,i),download:(n,r,a={})=>t?m(t,n,r,a):i(e,n,r,a),streamUrl:(n,r={})=>t?d(t,n,r):s(e,n,r),mintTicket:n=>t?Promise.resolve(!0):o(e,n)}),[e,t])}export{u as i,d as n,h as r,l as t};
@@ -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{Kn as r,Tt as i,X as a,ar as o,kt as s,or as c}from"./ui-CDoK3F3U.js";import{t as l}from"./button-SeUZ_Pvi.js";import{t as u}from"./input-BOtCd4HP.js";import{t as d}from"./api-CA6WiiYM.js";import{Z as f,mt as p,pn as m,vt as h}from"./workspace-C5V-ZCOE.js";import{t as g}from"./workspace-access-C9nZlBBZ.js";var _=e(n(),1),v={membership:`keep`,propagation:`never`,targets:[],acceptPropagatedDeletions:!1},y=e=>`/workspaces/${encodeURIComponent(e)}/trash/operations`,b=(e,t)=>d.get(`${y(e)}?${new URLSearchParams(Object.entries(t).map(([e,t])=>[e,String(t)]))}`),x=(e,t,n,r={})=>d.post(`${y(e)}/${n}`,{ids:t,...r}),S=(e,t,n,r)=>d.patch(`/workspaces/${encodeURIComponent(e)}/backends/imap/${encodeURIComponent(t)}/containers/${encodeURIComponent(n)}`,{removalPolicy:r}),C=e=>`/workspaces/${encodeURIComponent(e)}/trash/items`,w=(e,t={})=>d.get(`${C(e)}?${new URLSearchParams(Object.entries(t).filter(([,e])=>e!==void 0&&e!==``).map(([e,t])=>[e,String(t)]))}`);async function T(e,t,n){let r=[];for(let i=0;i<n.length;i+=200)r.push(...(await d.post(`${C(e)}/${t}`,{ids:n.slice(i,i+200)})).results);return r}var E=(e,t)=>T(e,`restore`,t),D=(e,t)=>T(e,`discard`,t),O=t(),k=200,A=864e5;function j(e,t){return e.expiresAt?Math.max(0,Math.ceil((Date.parse(e.expiresAt)-t)/A)):null}function M(e,t){if(!e.deletedAt)return`Earlier`;let n=new Date(t).setHours(0,0,0,0),r=Date.parse(e.deletedAt);return r>=n?`Today`:r>=n-A?`Yesterday`:r>=n-6*A?`Last 7 days`:`Earlier`}function N(e){return e==null?``:e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(1)} GB`}var P={document:c,file:o,folder:r};function F({workspaceName:e,canWrite:t}){let[n,r]=(0,_.useState)([]),[o,c]=(0,_.useState)(0),[d,f]=(0,_.useState)(null),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!0),[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(``),[C,T]=(0,_.useState)(new Set),[A,F]=(0,_.useState)(null),[I]=(0,_.useState)(()=>Date.now()),L=(0,_.useCallback)(async(t=0)=>{v(!0);try{let n=await w(e,{search:m.trim(),limit:k,offset:t});r(e=>t?[...e,...n.items]:n.items),c(n.total),f(n.retentionDays),S(``)}catch(e){S(e instanceof Error?e.message:`Could not load deleted items`)}finally{v(!1)}},[e,m]);(0,_.useEffect)(()=>{let e=setTimeout(()=>{T(new Set),L()},m?250:0);return()=>clearTimeout(e)},[L,m]);let R=(0,_.useMemo)(()=>{let e=[];for(let t of n){let n=M(t,I),r=e[e.length-1];r?.label===n?r.items.push(t):e.push({label:n,items:[t]})}return e},[n,I]),z=async(t,r)=>{if(!(!r.length||y)){b(!0),S(``),F(null);try{let i=(t===`restore`?await E(e,r):await D(e,r)).filter(e=>!e.ok);if(i.length){let e=new Map(n.map(e=>[e.id,e.name]));S(`${i.length} of ${r.length} could not be ${t===`restore`?`restored`:`deleted`}: ${i.slice(0,3).map(t=>`${e.get(t.id)||t.id} (${t.message||`failed`})`).join(`, `)}`)}p(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),T(new Set),await L()}catch(e){S(e instanceof Error?e.message:`Action failed`)}finally{b(!1)}}},B=(e,t)=>T(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),V=[...C],H=n.map(e=>e.id);return(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(u,{"aria-label":`Search deleted items`,placeholder:`Search by name or folder`,className:`max-w-xs`,value:m,onChange:e=>h(e.target.value)}),(0,O.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[o,` item`,o===1?``:`s`,d?`, kept for ${d} days`:``]}),(0,O.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,O.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>void L(),disabled:g||y,"aria-label":`Refresh`,children:(0,O.jsx)(s,{className:`h-3.5 w-3.5 ${g?`animate-spin`:``}`})}),V.length>0?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(l,{size:`sm`,variant:`outline`,disabled:!t||y,onClick:()=>void z(`restore`,V),children:[(0,O.jsx)(i,{className:`mr-2 h-3.5 w-3.5`}),`Restore `,V.length]}),(0,O.jsxs)(l,{size:`sm`,variant:`destructive`,disabled:!t||y,onClick:()=>F({ids:V,label:`${V.length} selected item${V.length===1?``:`s`}`}),children:[(0,O.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),`Delete forever`]})]}):(0,O.jsxs)(l,{size:`sm`,variant:`outline`,disabled:!t||y||!n.length,onClick:()=>F({ids:H,label:m.trim()?`all ${H.length} listed items`:`all ${H.length} items`}),children:[(0,O.jsx)(a,{className:`mr-2 h-3.5 w-3.5`}),`Empty trash`]})]})]}),A&&(0,O.jsxs)(`div`,{role:`alertdialog`,className:`flex flex-wrap items-center gap-3 rounded border border-destructive/50 bg-destructive/5 px-3 py-2 text-sm`,children:[(0,O.jsxs)(`span`,{children:[`Delete `,A.label,` forever? This cannot be undone.`]}),(0,O.jsx)(l,{size:`sm`,variant:`destructive`,disabled:y,onClick:()=>void z(`discard`,A.ids),children:`Delete forever`}),(0,O.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>F(null),children:`Cancel`})]}),x&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:x}),!n.length&&(0,O.jsx)(`p`,{className:`py-10 text-center text-sm text-muted-foreground`,children:g?`Loading…`:m.trim()?`Nothing deleted matches that search.`:`Nothing was deleted recently.`}),R.map(e=>(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h3`,{className:`mb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,O.jsx)(`ul`,{className:`divide-y rounded-md border`,children:e.items.map(e=>{let n=P[e.kind],r=j(e,I);return(0,O.jsxs)(`li`,{className:`flex items-center gap-3 px-3 py-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,disabled:!t||y,checked:C.has(e.id),onChange:t=>B(e.id,t.target.checked)}),(0,O.jsx)(n,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`div`,{className:`truncate text-sm`,children:e.name}),(0,O.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.from.length?e.from.join(`, `):`No folder recorded`,e.reason===`source-missing`?` · disappeared from its source`:``]})]}),(0,O.jsxs)(`div`,{className:`hidden shrink-0 text-right text-xs text-muted-foreground sm:block`,children:[(0,O.jsx)(`div`,{children:e.deletedAt?new Date(e.deletedAt).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}),(0,O.jsx)(`div`,{children:[N(e.size),r==null?``:r===0?`expires today`:`${r} day${r===1?``:`s`} left`].filter(Boolean).join(` · `)})]}),(0,O.jsxs)(l,{size:`sm`,variant:`outline`,disabled:!t||y,onClick:()=>void z(`restore`,[e.id]),title:`Put it back where it was`,children:[(0,O.jsx)(i,{className:`h-3.5 w-3.5 sm:mr-2`}),(0,O.jsx)(`span`,{className:`hidden sm:inline`,children:`Restore`})]}),(0,O.jsx)(l,{size:`sm`,variant:`ghost`,disabled:!t||y,onClick:()=>F({ids:[e.id],label:`"${e.name}"`}),"aria-label":`Delete ${e.name} forever`,children:(0,O.jsx)(a,{className:`h-3.5 w-3.5`})})]},e.id)})})]},e.label)),n.length<o&&(0,O.jsx)(`div`,{className:`text-center`,children:(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:g,onClick:()=>void L(n.length),children:`Show more`})})]})}function I({value:e,backends:t,source:n,onSave:r,destination:i=!0}){let[a,o]=(0,_.useState)({...v,...e}),[s,c]=(0,_.useState)(!1),[u,d]=(0,_.useState)(``),f=`rounded border bg-background px-2 py-1.5 text-xs w-full`,p=async()=>{c(!0),d(``);try{await r(a),d(`Removal policy saved.`)}catch(e){d(e instanceof Error?e.message:`Could not save policy`)}finally{c(!1)}};return(0,O.jsxs)(`details`,{className:`border-t pt-3 text-xs`,children:[(0,O.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:`Source removals and Trash`}),(0,O.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`A completed scan removes missing locations from the backend tree. Items with no remaining locations go to Trash until you purge them.`}),(0,O.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,O.jsxs)(`label`,{className:`space-y-1 block`,children:[`When an item disappears from this source`,(0,O.jsxs)(`select`,{className:f,value:a.membership,disabled:s,onChange:e=>o({...a,membership:e.target.value}),children:[(0,O.jsx)(`option`,{value:`keep`,children:`Keep in managed trees`}),(0,O.jsx)(`option`,{value:`review`,children:`Review removal in Trash`}),(0,O.jsx)(`option`,{value:`trash`,children:`Move to Trash automatically`})]})]}),(0,O.jsxs)(`label`,{className:`space-y-1 block`,children:[`Remove tracked copies from other backends`,(0,O.jsxs)(`select`,{className:f,value:a.propagation,disabled:s,onChange:e=>o({...a,propagation:e.target.value}),children:[(0,O.jsx)(`option`,{value:`never`,children:`Never`}),(0,O.jsx)(`option`,{value:`review`,children:`Review in Trash`}),(0,O.jsx)(`option`,{value:`automatic`,children:`Automatically, retaining recovery copies`})]})]})]}),a.propagation!==`never`&&(0,O.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,O.jsx)(`legend`,{className:`mb-1 font-medium`,children:`Destinations`}),(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:a.targets===`all`,disabled:s,onChange:e=>o({...a,targets:e.target.checked?`all`:[]})}),`All eligible backends`]}),a.targets!==`all`&&t.filter(e=>e.address!==n&&e.kind===`storage`).map(e=>(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,disabled:s||e.config?.propagatedRemovalSupported!==!0,checked:a.targets.includes(e.address),onChange:t=>o({...a,targets:t.target.checked?[...a.targets,e.address]:a.targets.filter(t=>t!==e.address)})}),String(e.config?.label||e.address),e.config?.propagatedRemovalSupported===!0?!e.config?.removalPolicy?.acceptPropagatedDeletions&&` · protected`:` · recovery removal unavailable`]},e.address)),(0,O.jsx)(`p`,{className:`text-muted-foreground`,children:`Only tracked, Canvas-owned copies are eligible. Protected destinations refuse propagated deletion. Recovery removal currently supports filesystem and workspace blob storage; remote destinations remain protected.`})]}),i&&(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,disabled:s,checked:a.acceptPropagatedDeletions,onChange:e=>o({...a,acceptPropagatedDeletions:e.target.checked})}),`Accept propagated deletions on this backend`]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:s,onClick:()=>void p(),children:s?`Saving…`:`Save removal policy`}),(0,O.jsx)(`span`,{role:`status`,children:u})]})]})]})}function L({workspaceName:e}){return(0,O.jsx)(R,{workspaceName:e},e)}function R({workspaceName:e}){let[t,n]=(0,_.useState)(`deleted`),[r,i]=(0,_.useState)(0),[a,o]=(0,_.useState)({write:!1,admin:!1});return(0,_.useEffect)(()=>{let t=!0;return f(e).then(e=>{let n=e.remote?.permissions||e.access?.permissions||(typeof e.sharedVia==`object`?e.sharedVia?.permissions:[])||[],r=g(e);t&&o({admin:r,write:r||n.includes(`write`)})}).catch(()=>{}),b(e,{view:`pending`,offset:0}).then(e=>{t&&i(e.total)}).catch(()=>{}),()=>{t=!1}},[e]),(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash`,children:[(0,O.jsx)(l,{role:`tab`,"aria-selected":t===`deleted`,size:`sm`,variant:t===`deleted`?`default`:`outline`,onClick:()=>n(`deleted`),children:`Recently deleted`}),(0,O.jsxs)(l,{role:`tab`,"aria-selected":t===`removals`,size:`sm`,variant:t===`removals`?`default`:`outline`,onClick:()=>n(`removals`),children:[`Source removals`,r>0?` (${r} to review)`:``]})]}),t===`deleted`?(0,O.jsx)(F,{workspaceName:e,canWrite:a.write}):(0,O.jsx)(z,{workspaceName:e,access:a,onPending:i})]})}function z({workspaceName:e,access:t,onPending:n}){let[r,i]=(0,_.useState)(`pending`),[a,o]=(0,_.useState)(``),[c,d]=(0,_.useState)(``),[f,g]=(0,_.useState)(0),[y,C]=(0,_.useState)(0),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(``),[k,A]=(0,_.useState)(!1),[j,M]=(0,_.useState)(new Set),[N,P]=(0,_.useState)({}),[F,L]=(0,_.useState)([]),[R,z]=(0,_.useState)(null);(0,_.useEffect)(()=>{let t=!0;return h(e).then(e=>{t&&L(e)}).catch(()=>{}),()=>{t=!1}},[e]),(0,_.useEffect)(()=>{let t=!1,i=()=>b(e,{view:r,search:a,...c?{backend:c}:{},offset:f}).then(e=>{t||(T(e),D(``),r===`pending`&&!a&&!c&&n(e.total))}).catch(e=>{t||D(e instanceof Error?e.message:`Could not load Trash`)});i();let o=setInterval(()=>{k||i()},5e3);return()=>{t=!0,clearInterval(o)}},[e,r,a,c,f,y,k,n]);let B=w?.operations||[],V=()=>{M(new Set),C(e=>e+1)},H=()=>{p(e),window.dispatchEvent(new CustomEvent(`workspace:tree:refresh`,{detail:{workspaceName:e}})),window.dispatchEvent(new CustomEvent(`workspace:trash:refresh`,{detail:{workspaceName:e}}))},U=async(t,n=[...j])=>{if(!(!n.length||k)&&!(t===`purge`&&!window.confirm(`Permanently delete retained recovery copies for ${n.length} operation(s)?`))){A(!0),D(``);try{let r=(t===`approve`?(await Promise.all(n.map(n=>x(e,[n],t,N[n])))).flatMap(e=>e.results):(await x(e,n,t)).results).filter(e=>!e.ok||e.operation?.state===`failed`);r.length&&D(r.map(e=>e.error||e.operation?.error||`A destination could not be changed. Expand the item for details.`).join(` `)),H(),V()}catch(e){D(e instanceof Error?e.message:`Trash action failed`)}finally{A(!1)}}},W=e=>{i(e),g(0),T(null),M(new Set),P({})};return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Files that disappeared from a backend or mailbox. Decide what happens to the copies Canvas still holds, and see what the removal policies did.`}),(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,role:`tablist`,"aria-label":`Trash views`,children:[[[`pending`,`To review`],[`trashed`,`Recovery copies`],[`activity`,`Activity`]].map(([e,t])=>(0,O.jsx)(l,{role:`tab`,"aria-selected":r===e,size:`sm`,variant:r===e?`default`:`outline`,onClick:()=>W(e),children:t},e)),(0,O.jsxs)(l,{size:`sm`,variant:`ghost`,className:`ml-auto`,onClick:V,disabled:k,children:[(0,O.jsx)(s,{className:`mr-2 h-3.5 w-3.5`}),`Refresh`]})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,O.jsx)(u,{"aria-label":`Filter Trash items`,placeholder:`Filter by item or path…`,className:`max-w-xs`,value:a,onChange:e=>{o(e.target.value),T(null),g(0),M(new Set)}}),(0,O.jsx)(u,{"aria-label":`Filter by backend`,placeholder:`Backend name…`,className:`max-w-56`,value:c,onChange:e=>{d(e.target.value),T(null),g(0),M(new Set)}}),j.size>0&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,O.jsxs)(`span`,{children:[j.size,` selected`]}),r===`pending`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(l,{size:`sm`,disabled:k,onClick:()=>void U(`approve`),children:`Approve selected`}),(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:k,onClick:()=>void U(`keep`),children:`Keep selected`}),(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:k,onClick:()=>void U(`retry`),children:`Retry`})]}),r===`trashed`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:k,onClick:()=>void U(`restore`),children:`Restore copies`}),(0,O.jsx)(l,{size:`sm`,variant:`destructive`,disabled:k,onClick:()=>void U(`purge`),children:`Purge copies`})]})]})]}),R&&(0,O.jsxs)(`div`,{className:`rounded border p-3 space-y-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Removal policy · `,R.source.account||R.source.backend,R.source.folder?` / ${R.source.folder}`:``]}),(0,O.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>z(null),children:`Close`})]}),(0,O.jsx)(I,{source:R.source.backend,backends:F,destination:!1,value:{...v,...F.find(e=>e.address===R.source.backend)?.config?.removalPolicy,membership:N[R.id]?.membership??R.membership!==`keep`?`review`:`keep`,propagation:R.targets.length?`review`:`never`,targets:[...new Set(R.targets.filter(e=>!N[R.id]||N[R.id].targets.includes(JSON.stringify([e.backend,e.key]))).map(e=>e.backend))]},onSave:async t=>{R.source.driver===`imap`?await S(e,R.source.account,R.source.folder,t):await m(e,R.source.driver,R.source.backend,{removalPolicy:t}),L(await h(e))}},R.id)]}),E&&(0,O.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:E}),(0,O.jsxs)(`div`,{className:`overflow-x-auto rounded border`,children:[(0,O.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,O.jsx)(`thead`,{className:`bg-muted`,children:(0,O.jsxs)(`tr`,{children:[(0,O.jsx)(`th`,{className:`p-3 w-8`,children:(0,O.jsx)(`input`,{type:`checkbox`,"aria-label":`Select visible operations`,disabled:!t.write||k||!B.length||r===`activity`,checked:B.length>0&&B.every(e=>j.has(e.id)),onChange:e=>M(e.target.checked?new Set(B.map(e=>e.id)):new Set)})}),(0,O.jsx)(`th`,{className:`p-3`,children:`Item and affected copies`}),(0,O.jsx)(`th`,{className:`p-3`,children:`Source`}),(0,O.jsx)(`th`,{className:`p-3`,children:`Status`}),(0,O.jsx)(`th`,{className:`p-3`,children:`Detected`})]})}),(0,O.jsx)(`tbody`,{children:B.map(e=>{let n=N[e.id]||{targets:e.targets.filter(e=>e.state!==`kept`).map(e=>JSON.stringify([e.backend,e.key])),membership:e.membership!==`keep`};return(0,O.jsxs)(`tr`,{className:`border-t align-top`,children:[(0,O.jsx)(`td`,{className:`p-3`,children:(0,O.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,disabled:!t.write||k||r===`activity`,checked:j.has(e.id),onChange:t=>M(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,O.jsx)(`td`,{className:`p-3 min-w-64`,children:(0,O.jsxs)(`details`,{children:[(0,O.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:e.title}),(0,O.jsxs)(`div`,{className:`mt-2 space-y-2 text-muted-foreground`,children:[(0,O.jsx)(`p`,{children:e.orphan?`No remaining byte locations. Restore placements only unless recovery bytes are available.`:`${e.remainingLocations.length} remaining location(s) when detected.`}),e.placements.map(e=>(0,O.jsxs)(`p`,{children:[e.tree,`: `,e.paths.join(`, `)]},e.tree)),e.membership!==`keep`&&(0,O.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,checked:n.membership,disabled:k||r!==`pending`||e.membershipApplied,onChange:t=>P({...N,[e.id]:{...n,membership:t.target.checked}})}),e.membershipApplied?`Managed placements moved to Trash`:`Move managed placements to Trash`]}),e.targets.map(t=>{let i=JSON.stringify([t.backend,t.key]);return(0,O.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(`input`,{type:`checkbox`,disabled:k||r!==`pending`||!!t.trashId,checked:n.targets.includes(i),onChange:t=>P({...N,[e.id]:{...n,targets:t.target.checked?[...n.targets,i]:n.targets.filter(e=>e!==i)}})}),(0,O.jsxs)(`span`,{className:`break-all`,children:[t.backend,`:`,t.key,` · `,t.state,t.error&&(0,O.jsx)(`span`,{className:`block text-destructive`,children:t.error})]})]},i)}),(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:!t.admin,onClick:()=>z(e),children:`Use these choices as a source policy`}),e.remainingLocations.map(e=>(0,O.jsx)(`p`,{className:`break-all`,children:e.url},e.url))]})]})}),(0,O.jsxs)(`td`,{className:`p-3 break-all`,children:[e.source.account||e.source.backend,e.source.folder&&(0,O.jsx)(`span`,{className:`block text-muted-foreground`,children:e.source.folder})]}),(0,O.jsxs)(`td`,{className:`p-3`,children:[e.state,e.error&&(0,O.jsx)(`p`,{className:`mt-1 max-w-xs text-destructive`,children:e.error})]}),(0,O.jsx)(`td`,{className:`p-3 whitespace-nowrap text-muted-foreground`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]}),!B.length&&(0,O.jsx)(`p`,{className:`p-5 text-center text-sm text-muted-foreground`,children:w?`No matching operations.`:`Loading…`})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[w?.total??0,` operation(s)`]}),(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:!f||k,onClick:()=>{g(Math.max(0,f-200)),M(new Set)},children:`Previous`}),(0,O.jsx)(l,{size:`sm`,variant:`outline`,disabled:f+B.length>=(w?.total??0)||k,onClick:()=>{g(f+200),M(new Set)},children:`Next`})]})]})]})}var B=`canvas:query-debug`,V=`canvas:query-debug-changed`;function H(){try{return localStorage.getItem(B)===`1`}catch{return!1}}function U(e){try{e?localStorage.setItem(B,`1`):localStorage.removeItem(B)}catch{}window.dispatchEvent(new CustomEvent(V,{detail:e}))}function W(){let[e,t]=(0,_.useState)(H);return(0,_.useEffect)(()=>{let e=()=>t(H());return window.addEventListener(V,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(V,e),window.removeEventListener(`storage`,e)}},[]),e}export{I as a,L as i,U as n,S as o,W as r,H as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-D-F4-4Zt.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-CDoK3F3U.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-1DU4mgJH.js","assets/workspace-cv6Hrfhh.js","assets/button-SeUZ_Pvi.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CFeuDt0T.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-BUXkez68.js","assets/useAddTarget-BEgKjqGj.js","assets/context-1vR30CeC.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-HAsbBak7.js","assets/tags-YamdPoBK.js","assets/index-CXPA9Fj8.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-BSTdjCWU.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-DGpvNE_V.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-9i1uCMQa.js","assets/use-canvas-pins-DqkSe_aU.js","assets/TodosWidget-B_R-vHxf.js","assets/ObjectPropertiesCard-pE3IL82x.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-C7sv9pMk.js","assets/date-time-picker-C40sYmga.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-DLXh7Ie6.js","assets/text-documents-DxVsu9zG.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-DutrNFK3.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-CdPp-3GR.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BUFAkTGl.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-CVO5KPCs.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-6eEi8GIA.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-Docu7O5V.css","assets/document-list-ASCemk7T.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-BhJbPlxk.js","assets/backend-sync-progress-m7wUKTJn.js","assets/PathPickerField-D7SubxSh.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-BBKmqs79.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-DIP1zh7I.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-CUqTxXmz.js","assets/workspace-content-gate-B6T3nLfW.js","assets/UploadProgressList-C9teR7r-.js","assets/sha256-65KIjGvZ.js","assets/FileForm-CMuWZbUX.js","assets/use-theme-DaxpiICf.js","assets/index-Bi5-zGgp.css","assets/shared-XYVtCrC8.js","assets/use-applet-docs-FqhvvOWx.js","assets/TodosApplet-OBi0XUdm.js","assets/LensApplet-gIiGSdLb.js","assets/FiltersApplet-CvdFlyn1.js","assets/SketchApplet-CQexRECa.js","assets/CalendarApplet-DVUCGIPB.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-Czpn1I53.js";import{Jr as i,St as a,Zr as o,ct as s,hn as c,it as l,tt as u}from"./ui-CDoK3F3U.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-D-F4-4Zt.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-BUXkez68.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-OBi0XUdm.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-gIiGSdLb.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-CvdFlyn1.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-CQexRECa.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-DVUCGIPB.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,29,7,6,10,11,12,30,31,28,32,33,34,16,13,17,40,20,41,5,21,24,25,26,27,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:l,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:s,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:c,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:i,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:o,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:a,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalApplet-D7YxftqM.js","assets/rolldown-runtime-C0FnF6B9.js","assets/code-editor-BOIngd5F.js","assets/ui-CDoK3F3U.js","assets/react-BHzhHVTZ.js","assets/use-applet-target-BygCSj5n.js","assets/workspace-C5V-ZCOE.js","assets/button-SeUZ_Pvi.js","assets/utils-BxVxyehK.js","assets/utils-2pl1SbIp.js","assets/input-BOtCd4HP.js","assets/api-CA6WiiYM.js","assets/alert-dialog-CFeuDt0T.js","assets/use-toolbox-Ck_cLGgf.js","assets/TerminalApplet-BrP-ENHg.css","assets/NotesApplet-FjdHMWCV.js","assets/useAddTarget-DeRZWtGg.js","assets/context-t3rdtGUB.js","assets/note-save-status-DPz4VzL6.js","assets/useEditNoteFields-BT1ASu_q.js","assets/tags-YamdPoBK.js","assets/index-I9cslsRe.js","assets/preload-helper-Czpn1I53.js","assets/chunk-62JRHF6Z-vspAGgtK.js","assets/label-BSTdjCWU.js","assets/socket-hM4c-ZSl.js","assets/socket-CtH3EU9m.js","assets/auth-Bx9fAZmz.js","assets/use-toast-BlLDqSUO.js","assets/LinkToCard-CKVi4Nrg.js","assets/useEscapeClose-DR_xKT_k.js","assets/useToastHelpers-CRrpIIdY.js","assets/layer-style-Byl5LNFR.js","assets/color-DFEH4BfK.js","assets/DocumentIcon-9i1uCMQa.js","assets/use-canvas-pins-Bhd7_wde.js","assets/TodosWidget-CNnfNk4L.js","assets/ObjectPropertiesCard-D2lrTQqT.js","assets/use-mobile-Db-vWu9Y.js","assets/IdentityFields-D-NCTUaE.js","assets/date-time-picker-DCikruos.js","assets/relation-events-CKio19hE.js","assets/map-BxCwdK0d.js","assets/map-BcsP_QXj.css","assets/public-share-CXR25Q1X.js","assets/text-documents-Cdb3U63i.js","assets/blobs-WiXP9QRi.js","assets/useDocumentThumbnail-Cj4UYyhC.js","assets/markdown-view-BBBZtNSR.js","assets/sanitize-DrVcFY1Q.js","assets/MessageComposerDialog-CdPp-3GR.js","assets/markdown-it-DRESbtwK.js","assets/punycode.es6-ZbLrB_Dn.js","assets/lazy-editor-BUFAkTGl.js","assets/LinkToSidePanel-eCy3nW4R.js","assets/DocumentBodyEditor-CVO5KPCs.js","assets/use-document-modal-PG8bQyIB.js","assets/sketch-lazy-BY_ka1hw.js","assets/geo-CZfs0E-x.js","assets/ObjectPropertiesCard-Docu7O5V.css","assets/document-list-CUmMhD6M.js","assets/document-open-mode-DoImW-xs.js","assets/PickDocumentsCard-BWgc-A02.js","assets/backend-sync-progress-CFe6JPuR.js","assets/PathPickerField-CW2yG2Yg.js","assets/backend-sync-progress-DU-e9TWi.css","assets/workspace-access-C9nZlBBZ.js","assets/search-COMZIxA7.js","assets/use-sortable-data-BBKmqs79.js","assets/workspace-BydSRtST.js","assets/document-list-DAYdk5vh.css","assets/url-params-n7kU_WZ-.js","assets/use-canvas-pins-C57Vbkrq.css","assets/use-menu-DIP1zh7I.js","assets/last-path-BbXWC3b3.js","assets/workspace-area-menu-B-bXURzn.js","assets/workspace-content-gate-C54J9Man.js","assets/UploadProgressList-D2wEpa7t.js","assets/sha256-65KIjGvZ.js","assets/FileForm-CDiVKvxq.js","assets/use-theme-DaxpiICf.js","assets/index-CYvpxvg6.css","assets/shared-BLOuO2Is.js","assets/use-applet-docs-rimRHjID.js","assets/TodosApplet-DU5VWc5i.js","assets/LensApplet-BnW7b0KX.js","assets/FiltersApplet-PclPc7fz.js","assets/SketchApplet-BKnhzTBA.js","assets/CalendarApplet-Bno3IDzO.js"])))=>i.map(i=>d[i]);
2
+ 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"./preload-helper-Czpn1I53.js";import{Jr as i,St as a,Zr as o,ct as s,hn as c,it as l,tt as u}from"./ui-CDoK3F3U.js";var d=e(n(),1),f=t();function p(e){let t=(0,d.lazy)(e);return function(e){return(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,role:`status`,children:`Opening app…`}),children:(0,f.jsx)(t,{...e})})}}var m=p(()=>r(()=>import(`./TerminalApplet-D7YxftqM.js`).then(e=>({default:e.TerminalApplet})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),h=p(()=>r(()=>import(`./NotesApplet-FjdHMWCV.js`).then(e=>({default:e.NotesApplet})),__vite__mapDeps([15,1,2,3,4,9,8,6,7,10,11,12,16,13,17,18,19,20,5,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),g=p(()=>r(()=>import(`./TodosApplet-DU5VWc5i.js`).then(e=>({default:e.TodosApplet})),__vite__mapDeps([84,1,2,3,4,9,8,6,7,10,11,12,16,13,17,40,20,41,5,82,29,30,31,28,32,33,34,54,83]))),_=p(()=>r(()=>import(`./LensApplet-BnW7b0KX.js`).then(e=>({default:e.LensApplet})),__vite__mapDeps([85,1,2,3,4,9,8,6,7,10,11,12,47,44,34,56,5,13,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,20,16,17,40,41,42,43,45,46,48,49,50,51,52,53,54,18,19,55,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),v=p(()=>r(()=>import(`./FiltersApplet-PclPc7fz.js`).then(e=>({default:e.FiltersApplet})),__vite__mapDeps([86,1,2,26,11,25,13,5,6,4,7,3,8,9,10,12,21,22,23,24,27,28,29,30,31,32,33,34,35,36,37,38,39,20,16,17,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81]))),y=p(()=>r(()=>import(`./SketchApplet-BKnhzTBA.js`).then(e=>({default:e.SketchApplet})),__vite__mapDeps([87,1,2,3,4,7,8,9,6,10,11,12,47,44,31,28,57,22,5,13,83,17]))),b=p(()=>r(()=>import(`./CalendarApplet-Bno3IDzO.js`).then(e=>({default:e.CalendarApplet})),__vite__mapDeps([88,1,2,23,22,3,4,9,8,29,7,6,10,11,12,30,31,28,32,33,34,16,13,17,40,20,41,5,21,24,25,26,27,35,36,37,38,39,42,43,44,45,46,47,48,49,50,51,52,53,54,18,19,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82]))),x=[{id:`terminal`,category:`utilities`,label:`Terminal`,icon:l,modes:[`context`],description:`Shell sessions for this context`,Component:m},{id:`filters`,category:`utilities`,label:`Filters`,icon:s,modes:[`context`,`global`],description:`Search and filter a workspace or a live context`,Component:v},{id:`notes`,category:`productivity`,label:`Notes`,icon:u,modes:[`context`],description:`All notes in the current context, editable in place`,Component:h},{id:`todo`,category:`productivity`,label:`Todos`,icon:c,modes:[`context`],description:`Todos in the current context, done items hidden by default`,Component:g},{id:`calendar`,category:`productivity`,label:`Calendar`,icon:i,modes:[`context`],description:`Day, week, month, year and schedule views of the events and due tasks in the current context`,Component:b},{id:`sketch`,category:`creative`,label:`Sketch`,icon:o,modes:[`context`],description:`Quick-sketch into the current context; tap a sketch to keep editing`,Component:y},{id:`lens`,category:`media`,label:`Lens`,icon:a,modes:[`context`],description:`Point a camera at things; matching documents surface live`,Component:_}];function S(e){return x.filter(t=>t.modes.includes(e))}export{S as n,x as t};
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,It as i,Lr as a,Mr as o,Pt as s,_t as c,bi as l,kr as u,or as d,rt as f,wt as p}from"./ui-CDoK3F3U.js";import{t as m}from"./button-SeUZ_Pvi.js";import{t as h}from"./input-BOtCd4HP.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{Nt as v}from"./workspace-cv6Hrfhh.js";import{t as y}from"./useEscapeClose-DR_xKT_k.js";import{n as b}from"./page-header-DrDt1sQ2.js";import{t as x}from"./role-C5I0Plgn.js";import{t as S}from"./form-panel-3p-ncEVK.js";import{t as C}from"./use-create-panel-DhSNIGtr.js";var w=e(n(),1),T=t();function E({status:e}){let t={running:{icon:r,color:`text-success`,bg:`bg-success-subtle`,label:`Running`},stopped:{icon:o,color:`text-muted-foreground`,bg:`bg-muted`,label:`Stopped`},starting:{icon:u,color:`text-info`,bg:`bg-info-subtle`,label:`Starting`},stopping:{icon:u,color:`text-warning`,bg:`bg-warning-subtle`,label:`Stopping`},error:{icon:a,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Error`},created:{icon:l,color:`text-muted-foreground`,bg:`bg-muted`,label:`Created`},configured:{icon:l,color:`text-info`,bg:`bg-info-subtle`,label:`Configured`},removed:{icon:o,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Removed`}},n=t[e]||t.created,i=n.icon;return(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium ${n.bg} ${n.color}`,children:[(0,T.jsx)(i,{className:`w-3 h-3`}),n.label]})}function D(){let[e,t]=(0,w.useState)([]),[n,r]=(0,w.useState)(!0),[a,o]=(0,w.useState)(null),[l,D]=(0,w.useState)(null);y(()=>D(null),l!==null);let[O,k]=C(),[A,j]=(0,w.useState)([]),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(!1),{showToast:H}=_(),U=g(),W=(0,w.useCallback)(async()=>{try{r(!0);let e=await x.listRoles({type:`workspace`,userId:U?.id});t(e),o(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch roles`;o(t)}finally{r(!1)}},[U?.id]);(0,w.useEffect)(()=>{let e=()=>W();e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[W]),(0,w.useEffect)(()=>{O&&(x.listTemplates().then(e=>{let t=e.filter(e=>e.type===`workspace`);j(t),F(e=>e||t[0]?.id||``)}).catch(()=>j([])),v().then(e=>{N(e),z(t=>t||e[0]?.id||``)}).catch(()=>N([])))},[O]);let G=async e=>{if(e.preventDefault(),!(!P||!I.trim()||!R)){V(!0);try{let e=await x.createRole({template:P,name:I.trim(),type:`workspace`,userId:U?.id,workspaceId:R});L(``),k(!1),await W(),H({title:`Created`,description:`Role "${e.name}" created`})}catch(e){H({title:`Error`,description:e instanceof Error?e.message:`Failed to create role`,variant:`destructive`})}finally{V(!1)}}},K=async e=>{try{await x.startRole(e.id),H({title:`Success`,description:`Role "${e.name}" started successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to start role`;H({title:`Error`,description:t,variant:`destructive`})}},q=async e=>{try{await x.stopRole(e.id),H({title:`Success`,description:`Role "${e.name}" stopped successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to stop role`;H({title:`Error`,description:t,variant:`destructive`})}},J=async e=>{try{await x.restartRole(e.id),H({title:`Success`,description:`Role "${e.name}" restarted successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to restart role`;H({title:`Error`,description:t,variant:`destructive`})}},Y=async e=>{try{let t=await x.getRoleLogs(e.id,100);D({role:e,logs:t})}catch(e){let t=e instanceof Error?e.message:`Failed to fetch logs`;H({title:`Error`,description:t,variant:`destructive`})}};return(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(b,{title:`My Roles`,description:`Manage your workspace roles and services`,actions:(0,T.jsxs)(T.Fragment,{children:[!O&&(0,T.jsxs)(m,{onClick:()=>k(!0),children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),`Create Role`]}),(0,T.jsxs)(m,{onClick:W,variant:`outline`,children:[(0,T.jsx)(p,{className:`mr-2 h-4 w-4`}),`Refresh`]})]})}),O&&(0,T.jsx)(S,{title:`Create New Role`,onClose:()=>k(!1),children:(0,T.jsxs)(`form`,{onSubmit:G,className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-template`,className:`mb-1 block text-sm font-medium`,children:`Template`}),(0,T.jsxs)(`select`,{id:`role-template`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:P,onChange:e=>F(e.target.value),disabled:B||A.length===0,children:[A.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspace templates available`}),A.map(e=>(0,T.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-name`,className:`mb-1 block text-sm font-medium`,children:`Role Name`}),(0,T.jsx)(h,{id:`role-name`,value:I,onChange:e=>L(e.target.value),placeholder:`e.g., canvas-sshd`,disabled:B})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-workspace`,className:`mb-1 block text-sm font-medium`,children:`Workspace`}),(0,T.jsxs)(`select`,{id:`role-workspace`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:R,onChange:e=>z(e.target.value),disabled:B||M.length===0,children:[M.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),M.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.label||e.name},e.id))]})]}),(0,T.jsxs)(m,{type:`submit`,disabled:B||!P||!I.trim()||!R,children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),B?`Creating…`:`Create Role`]})]})}),n?(0,T.jsx)(`div`,{className:`text-center py-8`,children:`Loading roles...`}):a?(0,T.jsx)(`div`,{className:`text-center py-8 text-destructive`,children:a}):e.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 border rounded-lg`,children:[(0,T.jsx)(c,{className:`w-12 h-12 mx-auto text-muted-foreground mb-4`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`You don't have any workspace roles yet`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-2`,children:`Contact your administrator to set up roles for your workspaces`})]}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map(e=>(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 space-y-4 hover:shadow-elevation-2 transition-shadow`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`h3`,{className:`font-semibold text-lg`,children:e.name}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.template})]}),(0,T.jsx)(E,{status:e.status})]}),e.container&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(c,{className:`w-3 h-3`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.container.name})]})}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[e.status===`stopped`||e.status===`created`?(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>K(e),className:`flex-1`,children:[(0,T.jsx)(i,{className:`w-4 h-4 mr-2`}),`Start`]}):e.status===`running`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>q(e),className:`flex-1`,children:[(0,T.jsx)(f,{className:`w-4 h-4 mr-2`}),`Stop`]}),(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>J(e),className:`flex-1`,children:[(0,T.jsx)(p,{className:`w-4 h-4 mr-2`}),`Restart`]})]}):(0,T.jsxs)(m,{size:`sm`,variant:`outline`,disabled:!0,className:`flex-1`,children:[(0,T.jsx)(u,{className:`w-4 h-4 mr-2`}),e.status]}),(0,T.jsx)(m,{size:`sm`,variant:`outline`,onClick:()=>Y(e),title:`View Logs`,children:(0,T.jsx)(d,{className:`w-4 h-4`})})]})]},e.id))}),(0,T.jsxs)(`div`,{className:`border-t pt-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Global Services`}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[(0,T.jsx)(`p`,{children:`Global roles are server-wide services managed by your administrator. These include services like SSH access, storage, and other shared infrastructure.`}),(0,T.jsx)(`p`,{children:`To check the status of global services, contact your system administrator.`})]})]}),l&&(0,T.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,T.jsxs)(`div`,{className:`bg-background rounded-lg shadow-elevation-3 max-w-4xl w-full mx-4 max-h-viewport-modal flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`p-6 border-b`,children:[(0,T.jsxs)(`h2`,{className:`text-xl font-bold`,children:[l.role.name,` - Logs`]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l.role.template})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:(0,T.jsx)(`div`,{"data-scheme":`dark`,className:`bg-background text-success p-4 rounded font-mono text-xs overflow-x-auto`,children:l.logs.length===0?(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:`No logs available`}):(0,T.jsx)(`pre`,{children:l.logs.join(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{Ir as r,It as i,Lr as a,Mr as o,Pt as s,_t as c,bi as l,kr as u,or as d,rt as f,wt as p}from"./ui-CDoK3F3U.js";import{t as m}from"./button-SeUZ_Pvi.js";import{t as h}from"./input-BOtCd4HP.js";import{i as g}from"./auth-Bx9fAZmz.js";import{n as _}from"./use-toast-BlLDqSUO.js";import{jt as v}from"./workspace-C5V-ZCOE.js";import{t as y}from"./useEscapeClose-DR_xKT_k.js";import{n as b}from"./page-header-DrDt1sQ2.js";import{t as x}from"./role-C5I0Plgn.js";import{t as S}from"./form-panel-3p-ncEVK.js";import{t as C}from"./use-create-panel-DhSNIGtr.js";var w=e(n(),1),T=t();function E({status:e}){let t={running:{icon:r,color:`text-success`,bg:`bg-success-subtle`,label:`Running`},stopped:{icon:o,color:`text-muted-foreground`,bg:`bg-muted`,label:`Stopped`},starting:{icon:u,color:`text-info`,bg:`bg-info-subtle`,label:`Starting`},stopping:{icon:u,color:`text-warning`,bg:`bg-warning-subtle`,label:`Stopping`},error:{icon:a,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Error`},created:{icon:l,color:`text-muted-foreground`,bg:`bg-muted`,label:`Created`},configured:{icon:l,color:`text-info`,bg:`bg-info-subtle`,label:`Configured`},removed:{icon:o,color:`text-destructive`,bg:`bg-destructive-subtle`,label:`Removed`}},n=t[e]||t.created,i=n.icon;return(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium ${n.bg} ${n.color}`,children:[(0,T.jsx)(i,{className:`w-3 h-3`}),n.label]})}function D(){let[e,t]=(0,w.useState)([]),[n,r]=(0,w.useState)(!0),[a,o]=(0,w.useState)(null),[l,D]=(0,w.useState)(null);y(()=>D(null),l!==null);let[O,k]=C(),[A,j]=(0,w.useState)([]),[M,N]=(0,w.useState)([]),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(``),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(!1),{showToast:H}=_(),U=g(),W=(0,w.useCallback)(async()=>{try{r(!0);let e=await x.listRoles({type:`workspace`,userId:U?.id});t(e),o(null)}catch(e){let t=e instanceof Error?e.message:`Failed to fetch roles`;o(t)}finally{r(!1)}},[U?.id]);(0,w.useEffect)(()=>{let e=()=>W();e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[W]),(0,w.useEffect)(()=>{O&&(x.listTemplates().then(e=>{let t=e.filter(e=>e.type===`workspace`);j(t),F(e=>e||t[0]?.id||``)}).catch(()=>j([])),v().then(e=>{N(e),z(t=>t||e[0]?.id||``)}).catch(()=>N([])))},[O]);let G=async e=>{if(e.preventDefault(),!(!P||!I.trim()||!R)){V(!0);try{let e=await x.createRole({template:P,name:I.trim(),type:`workspace`,userId:U?.id,workspaceId:R});L(``),k(!1),await W(),H({title:`Created`,description:`Role "${e.name}" created`})}catch(e){H({title:`Error`,description:e instanceof Error?e.message:`Failed to create role`,variant:`destructive`})}finally{V(!1)}}},K=async e=>{try{await x.startRole(e.id),H({title:`Success`,description:`Role "${e.name}" started successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to start role`;H({title:`Error`,description:t,variant:`destructive`})}},q=async e=>{try{await x.stopRole(e.id),H({title:`Success`,description:`Role "${e.name}" stopped successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to stop role`;H({title:`Error`,description:t,variant:`destructive`})}},J=async e=>{try{await x.restartRole(e.id),H({title:`Success`,description:`Role "${e.name}" restarted successfully`}),W()}catch(e){let t=e instanceof Error?e.message:`Failed to restart role`;H({title:`Error`,description:t,variant:`destructive`})}},Y=async e=>{try{let t=await x.getRoleLogs(e.id,100);D({role:e,logs:t})}catch(e){let t=e instanceof Error?e.message:`Failed to fetch logs`;H({title:`Error`,description:t,variant:`destructive`})}};return(0,T.jsxs)(`div`,{className:`space-y-6`,children:[(0,T.jsx)(b,{title:`My Roles`,description:`Manage your workspace roles and services`,actions:(0,T.jsxs)(T.Fragment,{children:[!O&&(0,T.jsxs)(m,{onClick:()=>k(!0),children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),`Create Role`]}),(0,T.jsxs)(m,{onClick:W,variant:`outline`,children:[(0,T.jsx)(p,{className:`mr-2 h-4 w-4`}),`Refresh`]})]})}),O&&(0,T.jsx)(S,{title:`Create New Role`,onClose:()=>k(!1),children:(0,T.jsxs)(`form`,{onSubmit:G,className:`space-y-4`,children:[(0,T.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-template`,className:`mb-1 block text-sm font-medium`,children:`Template`}),(0,T.jsxs)(`select`,{id:`role-template`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:P,onChange:e=>F(e.target.value),disabled:B||A.length===0,children:[A.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspace templates available`}),A.map(e=>(0,T.jsxs)(`option`,{value:e.id,children:[e.name,` - `,e.description]},e.id))]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-name`,className:`mb-1 block text-sm font-medium`,children:`Role Name`}),(0,T.jsx)(h,{id:`role-name`,value:I,onChange:e=>L(e.target.value),placeholder:`e.g., canvas-sshd`,disabled:B})]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`role-workspace`,className:`mb-1 block text-sm font-medium`,children:`Workspace`}),(0,T.jsxs)(`select`,{id:`role-workspace`,className:`w-full rounded-md border border-border bg-background px-3 py-2`,value:R,onChange:e=>z(e.target.value),disabled:B||M.length===0,children:[M.length===0&&(0,T.jsx)(`option`,{value:``,children:`No workspaces available. Create one first.`}),M.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.label||e.name},e.id))]})]}),(0,T.jsxs)(m,{type:`submit`,disabled:B||!P||!I.trim()||!R,children:[(0,T.jsx)(s,{className:`mr-2 h-4 w-4`}),B?`Creating…`:`Create Role`]})]})}),n?(0,T.jsx)(`div`,{className:`text-center py-8`,children:`Loading roles...`}):a?(0,T.jsx)(`div`,{className:`text-center py-8 text-destructive`,children:a}):e.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 border rounded-lg`,children:[(0,T.jsx)(c,{className:`w-12 h-12 mx-auto text-muted-foreground mb-4`}),(0,T.jsx)(`p`,{className:`text-muted-foreground`,children:`You don't have any workspace roles yet`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-2`,children:`Contact your administrator to set up roles for your workspaces`})]}):(0,T.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:e.map(e=>(0,T.jsxs)(`div`,{className:`border rounded-lg p-6 space-y-4 hover:shadow-elevation-2 transition-shadow`,children:[(0,T.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex-1`,children:[(0,T.jsx)(`h3`,{className:`font-semibold text-lg`,children:e.name}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.template})]}),(0,T.jsx)(E,{status:e.status})]}),e.container&&(0,T.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(c,{className:`w-3 h-3`}),(0,T.jsx)(`span`,{className:`truncate`,children:e.container.name})]})}),(0,T.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[e.status===`stopped`||e.status===`created`?(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>K(e),className:`flex-1`,children:[(0,T.jsx)(i,{className:`w-4 h-4 mr-2`}),`Start`]}):e.status===`running`?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>q(e),className:`flex-1`,children:[(0,T.jsx)(f,{className:`w-4 h-4 mr-2`}),`Stop`]}),(0,T.jsxs)(m,{size:`sm`,variant:`outline`,onClick:()=>J(e),className:`flex-1`,children:[(0,T.jsx)(p,{className:`w-4 h-4 mr-2`}),`Restart`]})]}):(0,T.jsxs)(m,{size:`sm`,variant:`outline`,disabled:!0,className:`flex-1`,children:[(0,T.jsx)(u,{className:`w-4 h-4 mr-2`}),e.status]}),(0,T.jsx)(m,{size:`sm`,variant:`outline`,onClick:()=>Y(e),title:`View Logs`,children:(0,T.jsx)(d,{className:`w-4 h-4`})})]})]},e.id))}),(0,T.jsxs)(`div`,{className:`border-t pt-6`,children:[(0,T.jsx)(`h2`,{className:`text-lg font-semibold mb-4`,children:`Global Services`}),(0,T.jsxs)(`div`,{className:`text-sm text-muted-foreground space-y-2`,children:[(0,T.jsx)(`p`,{children:`Global roles are server-wide services managed by your administrator. These include services like SSH access, storage, and other shared infrastructure.`}),(0,T.jsx)(`p`,{children:`To check the status of global services, contact your system administrator.`})]})]}),l&&(0,T.jsx)(`div`,{className:`fixed inset-0 bg-scrim flex items-center justify-center z-50`,children:(0,T.jsxs)(`div`,{className:`bg-background rounded-lg shadow-elevation-3 max-w-4xl w-full mx-4 max-h-viewport-modal flex flex-col`,children:[(0,T.jsxs)(`div`,{className:`p-6 border-b`,children:[(0,T.jsxs)(`h2`,{className:`text-xl font-bold`,children:[l.role.name,` - Logs`]}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l.role.template})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:(0,T.jsx)(`div`,{"data-scheme":`dark`,className:`bg-background text-success p-4 rounded font-mono text-xs overflow-x-auto`,children:l.logs.length===0?(0,T.jsx)(`div`,{className:`text-muted-foreground`,children:`No logs available`}):(0,T.jsx)(`pre`,{children:l.logs.join(`
2
2
  `)})})}),(0,T.jsx)(`div`,{className:`p-4 border-t flex justify-end`,children:(0,T.jsx)(m,{onClick:()=>D(null),children:`Close`})})]})})]})}export{D as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-CDoK3F3U.js";import{t as a}from"./button-SeUZ_Pvi.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{Nt as ne}from"./workspace-cv6Hrfhh.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-1vR30CeC.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-DIP1zh7I.js";import{$ as oe,H as se,J as ce,K as le,Q as ue,U as de,X as fe,Z as pe,et as me,ht as he,q as ge,rt as _e,vt as ve,z as ye}from"./index-CXPA9Fj8.js";import{n as be}from"./page-header-DrDt1sQ2.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-CI7iZlUR.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return se(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ce(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),le(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await _e(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await ye(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await ge(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await fe(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await me(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await oe(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=he.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h 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{_ as r,g as ee}from"./chunk-62JRHF6Z-vspAGgtK.js";import{X as i}from"./ui-CDoK3F3U.js";import{t as a}from"./button-SeUZ_Pvi.js";import{t as o}from"./input-BOtCd4HP.js";import{n as te}from"./use-toast-BlLDqSUO.js";import{jt as ne}from"./workspace-C5V-ZCOE.js";import{t as re}from"./use-mobile-Db-vWu9Y.js";import{p as ie}from"./context-t3rdtGUB.js";import{t as s}from"./color-DFEH4BfK.js";import{i as ae}from"./use-menu-DIP1zh7I.js";import{$ as oe,H as se,J as ce,K as le,Q as ue,U as de,X as fe,Z as pe,et as me,ht as he,q as ge,rt as _e,vt as ve,z as ye}from"./index-I9cslsRe.js";import{n as be}from"./page-header-DrDt1sQ2.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-B48KqDI7.js";var c=e(n(),1),l=t(),we={anthropic:`claude-3-5-sonnet-20241022`,openai:`gpt-4o`,ollama:`qwen2.5-coder:latest`,"lm-studio":``,vllm:``,custom:``},u={anthropic:`https://api.anthropic.com`,openai:`https://api.openai.com/v1`,ollama:`http://localhost:11434/v1`,"lm-studio":`http://localhost:1234/v1`,vllm:`http://localhost:8000/v1`,custom:``};function d(e){return u[e]||``}function f({label:e,hint:t,children:n}){return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{className:`text-sm font-medium`,children:e}),t&&(0,l.jsx)(`p`,{className:`mb-1 mt-0.5 text-xs text-muted-foreground`,children:t}),(0,l.jsx)(`div`,{className:t?void 0:`mt-1`,children:n})]})}var p=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-y`,m=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`;function h(){let{agentId:e,tab:t}=r(),n=ee(),{showToast:u}=te(),{selectEntity:h,goBack:Te}=ae(),Ee=re(),g=ve(t);(0,c.useEffect)(()=>{t!==g&&e&&n(`/agents/${encodeURIComponent(e)}/settings/${g}`,{replace:!0})},[t,g,e,n]);let[_,v]=(0,c.useState)(null),[De,Oe]=(0,c.useState)(!0),[ke,Ae]=(0,c.useState)(null),[je,Me]=(0,c.useState)(!1),[Ne,Pe]=(0,c.useState)(!1),[Fe,Ie]=(0,c.useState)(``),[Le,Re]=(0,c.useState)(``),[ze,Be]=(0,c.useState)(``),[Ve,y]=(0,c.useState)(s()),[b,He]=(0,c.useState)(``),[x,Ue]=(0,c.useState)(``),[S,We]=(0,c.useState)(``),[C,Ge]=(0,c.useState)(``),[w,Ke]=(0,c.useState)(`anthropic`),[T,qe]=(0,c.useState)(``),[E,D]=(0,c.useState)(``),[O,k]=(0,c.useState)(``),[Je,Ye]=(0,c.useState)(.7),[Xe,A]=(0,c.useState)(4096),[Ze,Qe]=(0,c.useState)(1),$e=Ce(w,T,E,_?.id),et=$e.models.find(e=>e.id===O),[tt,j]=(0,c.useState)([]),[M,N]=(0,c.useState)(``),[nt,P]=(0,c.useState)(``),[F,I]=(0,c.useState)(``),[L,R]=(0,c.useState)(``),[rt,it]=(0,c.useState)(!1),[at,ot]=(0,c.useState)(null),[z,B]=(0,c.useState)(null),[st,ct]=(0,c.useState)(null),[V,H]=(0,c.useState)(!1),[U,W]=(0,c.useState)(null),[G,K]=(0,c.useState)(``),[q,J]=(0,c.useState)(!1),[Y,lt]=(0,c.useState)(`context`),[X,ut]=(0,c.useState)(``),[dt,ft]=(0,c.useState)(`/`),[Z,pt]=(0,c.useState)(``),[mt,ht]=(0,c.useState)(!0),[Q,gt]=(0,c.useState)(!1),[_t,vt]=(0,c.useState)([]),[yt,bt]=(0,c.useState)([]),[$,xt]=(0,c.useState)(null),[St,Ct]=(0,c.useState)(`{}`),[wt,Tt]=(0,c.useState)(null),[Et,Dt]=(0,c.useState)(e);Et!==e&&(Dt(e),Oe(!0),v(null)),(0,c.useEffect)(()=>{if(!e)return;let t=!1;return se(e).then(async e=>{if(t)return;let n=e.config?.identity||{};v(e),h(e.id),Ie(e.name||``),Re(e.label||``),Be(e.description||``),y(e.color||s()),He(n.role||``),Ue(n.identity||``),We(n.instructions||``),Ge(e.config?.prompts?.system||``),Ke(e.llmProvider||`anthropic`),qe(e.config?.apiKey||``),D(e.config?.baseUrl||d(e.llmProvider)),k(e.model||we[e.llmProvider]||``);let r=e.config?.connectors?.[e.llmProvider];r&&(Ye(r.temperature??.7),A(r.maxTokens??4096),Qe(r.topP??1)),Ct(JSON.stringify(e.config?.tools??{},null,2)),Tt(null),Ae(null);try{j(await ce(e.id))}catch{j([])}}).catch(e=>{t||Ae(e instanceof Error?e.message:`Failed to load agent`)}).finally(()=>{t||Oe(!1)}),()=>{t=!0}},[e,h]),(0,c.useEffect)(()=>{if(g!==`access`&&g!==`tools`||!_?.id)return;let e=_.id,t=!1;return Promise.all([de(_.id).catch(()=>null),ne().catch(()=>[]),ie().catch(()=>[]),le(_.id).catch(()=>null)]).then(([n,r,ee,i])=>{t||(B(n),vt(r),bt(ee),xt(i?i.tools:[]),ct(e))}),()=>{t=!0}},[g,_?.id]);let Ot=()=>{let e=Se(b,x,S),t;try{let e=JSON.parse(St);e&&typeof e==`object`&&!Array.isArray(e)&&(t=e)}catch{}return{...t===void 0?{}:{tools:t},name:Fe.trim(),label:Le.trim(),description:ze.trim()||void 0,color:Ve,llmProvider:w,model:O,apiKey:T.trim()||(w===_?.llmProvider?void 0:``),baseUrl:E||void 0,config:{type:w,model:O,identity:{role:b.trim()||void 0,identity:x.trim()||void 0,instructions:S.trim()||void 0},prompts:C.trim()||e?{system:C.trim()||e}:void 0,connectors:{[w]:{...w===`anthropic`?{}:{temperature:Je},maxTokens:Xe,topP:Ze}}}}},kt=async e=>{if(e.preventDefault(),_){Me(!0);try{let e=await _e(_.id,Ot());v(e),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Saved`,description:`Agent updated`}),e.name&&e.name!==_.name&&n(`/agents/${encodeURIComponent(e.name)}/settings/${g}`,{replace:!0})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Save failed`,variant:`destructive`})}finally{Me(!1)}}},At=async()=>{if(_&&window.confirm(`Delete agent "${_.label||_.name}"? This cannot be undone.`)){Pe(!0);try{await ye(_.id),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Deleted`,description:`Agent removed`}),n(`/agents`)}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Delete failed`,variant:`destructive`})}finally{Pe(!1)}}},jt=()=>{N(``),P(``),I(``),R(``)},Mt=async()=>{if(!(!_||!L.trim()&&!F.trim())){it(!0);try{let e=await ge(_.id,L.trim()?{source:L.trim()}:{name:M,description:nt,content:F});j(e),jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Installed`,description:`Skill saved`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill install failed`,variant:`destructive`})}finally{it(!1)}}},Nt=async e=>{if(_){ot(e);try{let t=await fe(_.id,e);j(t),(M===e||L===e)&&jt(),window.dispatchEvent(new CustomEvent(`agents:refresh`)),u({title:`Removed`,description:`Skill "${e}" removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Skill remove failed`,variant:`destructive`})}finally{ot(null)}}},Pt=()=>Y===`global`?{type:`global`}:Y===`context`?Z?{type:`context`,context:Z}:null:X?Y===`path`?{type:`path`,workspace:X,path:dt.trim()||`/`}:{type:`workspace`,workspace:X}:null,Ft=async()=>{if(!_||V)return;let e=Pt(),t=[];if(mt&&t.push(`read`),Q&&t.push(`write`),!e||!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(G.trim())||t.length===0||!q&&z?.grants.some(e=>e.id===G.trim())){u({title:`Invalid binding`,description:`Choose a unique connection name (letters, numbers, hyphens or underscores), scope and permissions`,variant:`destructive`});return}if(!(e.type===`global`&&!window.confirm(`Global scope lets this agent ${Q?`read and write`:`read`} ALL your workspaces. Continue?`))){H(!0);try{let n=await me(_.id,G.trim(),{label:z?.grants.find(e=>e.id===G.trim())?.label||G.trim(),binding:e,permissions:t});B(n.access),W(n.tokens[0]?.token??null),K(``),J(!1),u({title:`Connection saved`,description:`Other connections and their tokens are unchanged`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Bind failed`,variant:`destructive`})}finally{H(!1)}}},It=async e=>{if(!(!_||V)){H(!0);try{let t=await oe(_.id,e);B(t.access),W(t.tokens[0]?.token??null),u({title:`Rotated`,description:`New token minted — the previous one no longer works`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Rotate failed`,variant:`destructive`})}finally{H(!1)}}},Lt=e=>{K(e.id),J(!0),lt(e.binding.type),ut(e.binding.workspace||``),ft(e.binding.path||`/`),pt(e.binding.context||``),ht(e.permissions.includes(`read`)),gt(e.permissions.includes(`write`))},Rt=async e=>{if(!(!_||V)){H(!0);try{let t=await ue(_.id,e);B(t.access),W(null),G===e&&(K(``),J(!1))}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},zt=async()=>{if(!(!_||V)&&window.confirm(`Revoke this agent's canvas access? All its connection tokens stop working immediately.`)){H(!0);try{await pe(_.id),B(null),W(null),u({title:`Revoked`,description:`Agent access removed`})}catch(e){u({title:`Error`,description:e instanceof Error?e.message:`Revoke failed`,variant:`destructive`})}finally{H(!1)}}},Bt=e=>{if(e.type===`global`)return`Global — all workspaces`;if(e.type===`context`){let t=yt.find(t=>t.id===e.context);return`Context ${t?`${t.id} (${t.url})`:e.context} — follows the context live`}let t=e.workspaceName||e.workspace;return e.type===`path`?`Workspace ${t}, path ${e.path||`/`}`:`Workspace ${t} (whole tree)`};if(De)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Loading...`});if(!_||ke)return(0,l.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:ke||`Agent not found`});let Vt=he.find(e=>e.id===g),Ht=encodeURIComponent(_.name||_.id),Ut=g===`identity`||g===`provider`||g===`models`||g===`tools`;return(0,l.jsx)(`div`,{className:`h-full min-h-0 overflow-y-auto`,children:(0,l.jsxs)(`div`,{className:`mx-auto max-w-5xl p-6 pb-12 max-md:px-4 max-md:pb-rail-stack`,children:[(0,l.jsx)(be,{compact:!0,className:`mb-6 border-b pb-4`,title:`${Vt.label} - ${_.label||_.name}`,description:Vt.description,backTo:`/agents/${Ht}`,onBack:Ee?Te:void 0}),(0,l.jsxs)(`form`,{onSubmit:kt,className:`space-y-6`,children:[g===`identity`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,hint:`ID: ${_.id}`,children:(0,l.jsx)(o,{value:Fe,onChange:e=>Ie(e.target.value),placeholder:`lucy`})}),(0,l.jsx)(f,{label:`Label`,children:(0,l.jsx)(o,{value:Le,onChange:e=>Re(e.target.value),placeholder:`Display name`})})]}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:ze,onChange:e=>Be(e.target.value),placeholder:`Short description`})}),(0,l.jsx)(f,{label:`Color`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(o,{type:`color`,value:Ve,onChange:e=>y(e.target.value),className:`h-10 w-16 p-1`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(s()),children:`Randomize`})]})})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Persona`}),(0,l.jsx)(f,{label:`Role`,children:(0,l.jsx)(o,{value:b,onChange:e=>He(e.target.value),placeholder:`e.g. Software Engineer`})}),(0,l.jsx)(f,{label:`Identity`,children:(0,l.jsx)(`textarea`,{value:x,onChange:e=>Ue(e.target.value),placeholder:`Who this agent is…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`Instructions`,children:(0,l.jsx)(`textarea`,{value:S,onChange:e=>We(e.target.value),placeholder:`Behavioral instructions…`,className:`${p} min-h-[80px]`})}),(0,l.jsx)(f,{label:`System Prompt`,hint:`Compiled from Role + Identity + Instructions. Override manually.`,children:(0,l.jsx)(`textarea`,{value:C,onChange:e=>Ge(e.target.value),placeholder:`System prompt sent to the LLM…`,className:`${p} min-h-[140px] font-mono text-xs`})})]}),(0,l.jsxs)(`section`,{className:`rounded-lg border border-destructive/30 p-4`,children:[(0,l.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-destructive`,children:`Danger Zone`}),(0,l.jsxs)(a,{type:`button`,variant:`destructive`,disabled:Ne,onClick:At,children:[(0,l.jsx)(i,{className:`mr-2 h-4 w-4`}),Ne?`Deleting...`:`Delete Agent`]})]})]}),g===`provider`&&(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(f,{label:`Provider`,children:(0,l.jsxs)(`select`,{value:w,onChange:e=>{let t=e.target.value;Ke(t),qe(``),k(we[t]||``),D(d(t))},className:`w-full rounded-md border border-input bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring`,children:[(0,l.jsx)(`option`,{value:`anthropic`,children:`Anthropic Claude`}),(0,l.jsx)(`option`,{value:`openai`,children:`OpenAI GPT`}),(0,l.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,l.jsx)(`option`,{value:`lm-studio`,children:`LM Studio (Local)`}),(0,l.jsx)(`option`,{value:`vllm`,children:`vLLM (Local)`}),(0,l.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,l.jsx)(f,{label:`API Key`,hint:[`ollama`,`lm-studio`,`vllm`].includes(w)?`Any value works for local providers.`:void 0,children:(0,l.jsx)(o,{type:`password`,value:T,onChange:e=>qe(e.target.value),placeholder:w===`ollama`?`ollama`:w===`lm-studio`?`lm-studio`:`sk-…`})}),(0,l.jsx)(f,{label:`Host / Base URL`,children:(0,l.jsx)(o,{value:E,onChange:e=>D(e.target.value),placeholder:d(w)||`https://api.example.com`})})]}),g===`models`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Main Model`}),(0,l.jsx)(f,{label:`Model`,children:(0,l.jsx)(xe,{value:O,onChange:(e,t)=>{k(e),t?.maxTokens&&A(t.maxTokens)},...$e})}),(0,l.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[w!==`anthropic`&&(0,l.jsx)(f,{label:`Temperature`,children:(0,l.jsx)(o,{type:`number`,min:0,max:2,step:.1,value:Je,onChange:e=>Ye(Number.isNaN(e.target.valueAsNumber)?.7:e.target.valueAsNumber)})}),(0,l.jsx)(f,{label:`Max Output Tokens`,children:(0,l.jsx)(o,{type:`number`,min:1,max:et?.maxTokens,value:Xe,onChange:e=>A(parseInt(e.target.value)||4096)})}),(0,l.jsx)(f,{label:`Top P`,children:(0,l.jsx)(o,{type:`number`,min:0,max:1,step:.1,value:Ze,onChange:e=>Qe(Number.isNaN(e.target.valueAsNumber)?1:e.target.valueAsNumber)})})]})]}),[`Governance`,`Memory Management`,`Subagent / Tool Use`].map(e=>(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-4`,children:[(0,l.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:[e,` Model`]}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Coming soon`})]},e))]}),g===`tools`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runtime Tools`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Injected at start (pi defineTool): coding tools plus canvas tools scoped by the token binding (Access / ACL). Definitions live in the runtime — read-only here until the agent-runtime workspace lands.`})]}),$===null?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}):$.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No tools resolved.`}):(0,l.jsx)(`div`,{className:`space-y-1.5`,children:$.map(e=>(0,l.jsxs)(`details`,{className:`rounded-md border px-3 py-2`,children:[(0,l.jsxs)(`summary`,{className:`cursor-pointer text-sm`,children:[(0,l.jsx)(`code`,{className:`font-mono text-xs font-medium`,children:e.name}),(0,l.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground`,children:e.source})]}),e.description&&(0,l.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-xs text-muted-foreground`,children:e.description}),e.parameters!=null&&(0,l.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-[11px]`,children:JSON.stringify(e.parameters,null,2)})]},e.name))}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:z?z.grants.map(e=>`${e.label}: ${Bt(e.binding)}`).join(`; `):`Unbound — no canvas tools are injected. Bind under Access / ACL.`})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Tools Config`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`config.tools JSON, merged server-side — e.g. {"canvas": {"enabled": false}} gates the canvas tools. Saved with Save Changes.`})]}),(0,l.jsx)(`textarea`,{value:St,onChange:e=>{Ct(e.target.value);try{JSON.parse(e.target.value),Tt(null)}catch(e){Tt(e instanceof Error?e.message:`Invalid JSON`)}},className:`${p} min-h-[120px] font-mono text-xs`}),wt&&(0,l.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Invalid JSON (not saved): `,wt]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Skills`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Installed skills are saved immediately, independent of Save Changes.`})]}),tt.length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No skills installed.`}):tt.map(e=>(0,l.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border p-3`,children:[(0,l.jsxs)(`div`,{className:`min-w-0`,children:[(0,l.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,l.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.package?e.source:e.description||`No description`})]}),(0,l.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{N(e.name),P(e.description||``),I(e.content||``),R(e.source||``)},children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:at===(e.source||e.name),onClick:()=>Nt(e.source||e.name),children:at===(e.source||e.name)?`Removing…`:`Remove`})]})]},e.name)),(0,l.jsxs)(`div`,{className:`space-y-4 rounded-md border p-4`,children:[(0,l.jsx)(f,{label:`Package Source`,hint:`Use this for whole pi packages. Leave empty to save inline SKILL.md content.`,children:(0,l.jsx)(o,{value:L,onChange:e=>R(e.target.value),placeholder:`npm:@foo/pi-tools or git:github.com/badlogic/pi-doom`})}),(0,l.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,l.jsx)(f,{label:`Name`,children:(0,l.jsx)(o,{value:M,onChange:e=>N(e.target.value),placeholder:`skill-name, or read from frontmatter`,disabled:!!L.trim()})}),(0,l.jsx)(f,{label:`Description`,children:(0,l.jsx)(o,{value:nt,onChange:e=>P(e.target.value),placeholder:`What this skill helps with`,disabled:!!L.trim()})})]}),(0,l.jsx)(f,{label:`SKILL.md Content`,children:(0,l.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:`# Skill instructions…`,disabled:!!L.trim(),className:`${p} min-h-[160px] font-mono text-xs`})}),(0,l.jsxs)(`div`,{className:`flex gap-2`,children:[(0,l.jsx)(a,{type:`button`,disabled:rt||!L.trim()&&!F.trim(),onClick:Mt,children:rt?`Saving…`:`Install / Update Skill`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:jt,children:`Clear`})]})]})]}),(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`MCP Servers`}),(_.config?.mcp?.servers||[]).length===0?(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`No MCP servers configured.`}):(_.config?.mcp?.servers||[]).map((e,t)=>(0,l.jsxs)(`div`,{className:`rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.name}),(0,l.jsxs)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:[e.command,` `,(e.args||[]).join(` `)]})]},t))]})]}),g===`access`&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`section`,{className:`space-y-3 rounded-lg border p-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Canvas Access`}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add named connections to workspaces, paths or contexts, with permissions for each. Every connection has its own scoped token. Overlapping grants are additive: a whole-workspace grant is not restricted by a context on that workspace.`})]}),st===_.id?z?(0,l.jsxs)(`div`,{className:`space-y-2`,children:[z.grants.map(e=>(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,l.jsx)(`div`,{className:`text-sm font-medium`,children:e.label||e.id}),(0,l.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Bt(e.binding)}),(0,l.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Permissions: `,e.permissions.join(`, `)]}),(0,l.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>Lt(e),children:`Edit`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,disabled:V,onClick:()=>It(e.id),children:`Rotate Token`}),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:()=>Rt(e.id),children:`Remove`})]})]},e.id)),(0,l.jsx)(a,{type:`button`,variant:`destructive`,size:`sm`,disabled:V,onClick:zt,children:`Revoke All Access`})]}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Unbound — this agent has no canvas access.`}):(0,l.jsx)(`div`,{className:`rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:`Loading…`}),U&&(0,l.jsxs)(`div`,{className:`space-y-2 rounded-md border border-warning/50 bg-warning/10 p-3`,children:[(0,l.jsx)(`div`,{className:`text-xs font-medium`,children:`Agent token — shown once, store it now`}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`code`,{className:`flex-1 truncate rounded bg-background px-2 py-1 font-mono text-xs`,children:U}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>navigator.clipboard?.writeText(U),children:`Copy`}),(0,l.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>W(null),children:`Dismiss`})]}),(0,l.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Managed agents receive their connections automatically. External runtimes use the CANVAS_CONNECTIONS JSON array.`})]})]}),(0,l.jsxs)(`section`,{className:`space-y-4 rounded-lg border p-4`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold`,children:q?`Edit Connection`:`Add Connection`}),(0,l.jsx)(f,{label:`Connection name`,hint:`Agents use this name to select the scope for each tool call.`,children:(0,l.jsx)(o,{value:G,disabled:q,onChange:e=>K(e.target.value),placeholder:`bar, baz, baf`})}),(0,l.jsx)(f,{label:`Scope`,hint:`Context bindings follow the context live; global spans all workspaces.`,children:(0,l.jsxs)(`select`,{value:Y,onChange:e=>lt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:`context`,children:`Context (follows live)`}),(0,l.jsx)(`option`,{value:`workspace`,children:`Workspace`}),(0,l.jsx)(`option`,{value:`path`,children:`Workspace path`}),(0,l.jsx)(`option`,{value:`global`,children:`Global (all workspaces)`})]})}),Y===`context`&&(0,l.jsx)(f,{label:`Context`,children:(0,l.jsxs)(`select`,{value:Z,onChange:e=>pt(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a context…`}),yt.map(e=>(0,l.jsxs)(`option`,{value:e.id,children:[e.id,` — `,e.url]},e.id))]})}),(Y===`workspace`||Y===`path`)&&(0,l.jsx)(f,{label:`Workspace`,children:(0,l.jsxs)(`select`,{value:X,onChange:e=>ut(e.target.value),className:m,children:[(0,l.jsx)(`option`,{value:``,children:`Select a workspace…`}),_t.map(e=>(0,l.jsx)(`option`,{value:e.name||e.id,children:e.label||e.name},e.id))]})}),Y===`path`&&(0,l.jsx)(f,{label:`Base path`,hint:`The agent is clamped to this subtree.`,children:(0,l.jsx)(o,{value:dt,onChange:e=>ft(e.target.value),placeholder:`/work/projects/foo`})}),(0,l.jsx)(f,{label:`Permissions`,children:(0,l.jsxs)(`div`,{className:`flex gap-4 text-sm`,children:[(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked)}),` read`]}),(0,l.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:Q,onChange:e=>gt(e.target.checked)}),` write`]})]})}),(0,l.jsx)(a,{type:`button`,disabled:V,onClick:Ft,children:V?`Working…`:q?`Save Connection`:`Add Connection`}),q&&(0,l.jsx)(a,{type:`button`,variant:`outline`,onClick:()=>{K(``),J(!1)},children:`Cancel Edit`})]})]}),g===`memory`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Memory Engine`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Loop-based memory management. Settings coming soon.`})]}),g===`integrations`&&(0,l.jsxs)(`section`,{className:`rounded-lg border border-dashed p-6 text-center`,children:[(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground`,children:`Integrations`}),(0,l.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`IMAP, chat, SQL and REST API accounts. Coming soon.`})]}),Ut&&(0,l.jsx)(a,{type:`submit`,disabled:je,children:je?`Saving…`:`Save Changes`})]})]})})}export{h as default};