@augmentd-labs/canvas-web 2.26.26 → 2.26.27

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 (31) hide show
  1. package/dist/assets/{FiltersApplet-BJALOBRh.js → FiltersApplet-C-WD5XT9.js} +1 -1
  2. package/dist/assets/{HomeFab-Chvwu8rQ.js → HomeFab-CzKEIYDk.js} +1 -1
  3. package/dist/assets/{LensApplet-Ckl0M4Wi.js → LensApplet-BCJXNx84.js} +1 -1
  4. package/dist/assets/{NotesApplet-tNMaEcoj.js → NotesApplet-CvPyt7xB.js} +1 -1
  5. package/dist/assets/{_agentId_-sMYqsnQk.js → _agentId_-BXYnpAWp.js} +0 -0
  6. package/dist/assets/{_contextId_-DRvqFeiU.js → _contextId_-BEC7o1ya.js} +1 -1
  7. package/dist/assets/{_workspaceName_-DqFTMP44.js → _workspaceName_-5rSLTtJT.js} +1 -1
  8. package/dist/assets/{about-DbGpwqCH.js → about-DrgIxiPQ.js} +1 -1
  9. package/dist/assets/{add-DsH8MVg6.js → add-CPkuZwMW.js} +1 -1
  10. package/dist/assets/agents-jmTwCDAu.js +1 -0
  11. package/dist/assets/{appearance-CN8I4_GQ.js → appearance-DRBtL9nd.js} +1 -1
  12. package/dist/assets/{apps-CvInUZwB.js → apps-CqFFzo_Z.js} +1 -1
  13. package/dist/assets/{content-app-view-BGg1GOMt.js → content-app-view-y5TmcjuO.js} +1 -1
  14. package/dist/assets/{home-CFZRa_Mu.js → home-C6aXJsmf.js} +1 -1
  15. package/dist/assets/{index-BytAmMhU.js → index-CyEIU2rL.js} +6 -6
  16. package/dist/assets/{key-bindings-Dfa7ehDw.js → key-bindings-BDktmxOD.js} +1 -1
  17. package/dist/assets/{registry--2kt6I6T.js → registry-ZMLdscra.js} +2 -2
  18. package/dist/assets/{settings-DhVz_Osu.js → settings-Be_a2PGC.js} +1 -1
  19. package/dist/assets/{settings-FiiJ5QFa.js → settings-DJyvE-wf.js} +1 -1
  20. package/dist/assets/settings-TQmRYAGg.js +1 -0
  21. package/dist/assets/{settings-BOHindnt.js → settings-VF2v3Ya5.js} +3 -3
  22. package/dist/assets/{share-target-fpk-pz15.js → share-target-BDbVdgTo.js} +1 -1
  23. package/dist/assets/{shared-CCCuTYCU.js → shared-BbAavKdN.js} +1 -1
  24. package/dist/assets/{useAgentModels-CwNiA-Ak.js → useAgentModels-PQVPjrQu.js} +1 -1
  25. package/dist/assets/workspaces-BGbHBVHs.js +1 -0
  26. package/dist/index.html +2 -2
  27. package/dist/sw.js +1 -1
  28. package/package.json +2 -2
  29. package/dist/assets/agents-BBKnR8_O.js +0 -1
  30. package/dist/assets/settings-N3fbO22m.js +0 -1
  31. package/dist/assets/workspaces-By3jZzrz.js +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ft as a,Kn as o,Nt as s,Vn as c,X as l,at as u,ht as d,rt as f,vr as p,zn as m}from"./ui-Byg1cZDr.js";import{t as h}from"./button-SgR3GVvV.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Kt as y,Pt as b,a as x,cn as S,mt as C,n as w,qt as ee,sn as T,xt as E,y as D,yn as O}from"./workspace-CrSpR4xf.js";import{a as te,c as k,i as A,l as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-izlVMXfa.js";import{t as ne}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as L,r as re,t as R}from"./color-DFEH4BfK.js";import{t as z}from"./workspace-access-C9nZlBBZ.js";import{i as ie}from"./use-menu-BiJ8N7sS.js";import{r as ae}from"./last-path-BbXWC3b3.js";import{At as B,Ct as oe,Et as se,Mt as ce,Ot as le,St as ue,Tt as de,dt as V,jt as H,kt as U,wt as W,xt as G}from"./index-BytAmMhU.js";import{n as fe}from"./page-header-DkOHw0g-.js";import{t as K}from"./form-panel-C34lByEH.js";import{t as pe}from"./use-create-panel-DhSNIGtr.js";import{n as me,t as he}from"./useSocketSubscription-ifW-vnlb.js";import{a as ge,i as _e,n as q,r as ve,t as ye}from"./workspace-import-form-aR-DwHf6.js";var J=e(n(),1),Y=t();function be({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:o,onDestroy:s}){let[c,m]=(0,J.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,ee=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,T=e.origin===`remote`,E=e.status===`offline`,D=L(e.color),O=D?``:`border-border`,ne=D?{borderLeftColor:D,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(le,{className:`relative ${O}`,style:ne,children:[(0,Y.jsx)(H,{children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,Y.jsx)(ce,{className:`truncate`,children:e.label||e.name}),(0,Y.jsx)(B,{children:b?`Shared from ${x}`:e.description||``})]}),(0,Y.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(V(e)),title:`Stop Workspace`,disabled:v||y,children:(0,Y.jsx)(f,{className:`h-4 w-4`})}):(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(V(e)),title:E?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||E,children:(0,Y.jsx)(a,{className:`h-4 w-4`})}),g&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(V(e)),title:`Enter Workspace`,disabled:v||y,children:(0,Y.jsx)(p,{className:`h-4 w-4`})}),o&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>o(e),title:z(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!z(e),children:(0,Y.jsx)(d,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,Y.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,Y.jsx)(u,{className:`h-4 w-4`})}),s&&!_&&!b&&(0,Y.jsxs)(I,{open:c,onOpenChange:m,children:[(0,Y.jsx)(j,{asChild:!0,children:(0,Y.jsx)(h,{variant:`outline`,size:`icon`,title:T?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!T,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,Y.jsx)(l,{className:`h-4 w-4`})})}),(0,Y.jsxs)(A,{children:[(0,Y.jsxs)(F,{children:[(0,Y.jsx)(k,{children:T?`Remove remote workspace`:`Delete Workspace`}),(0,Y.jsx)(te,{children:T?(0,Y.jsxs)(Y.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),`The workspace itself stays untouched on `,e.remote?.url||e.host,`; only the stored share token and the local cache entry are dropped.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`br`,{}),(0,Y.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(P,{children:`Cancel`}),(0,Y.jsx)(M,{onClick:()=>{s(e),m(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:T?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,Y.jsx)(U,{children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`h-3 w-3 rounded-full ${(()=>{switch(e.status){case`active`:return`bg-success`;case`inactive`:case`available`:return`bg-muted-foreground`;case`error`:case`offline`:return`bg-destructive`;case`not_found`:return`bg-muted-foreground`;default:return`bg-accent`}})()}`}),(0,Y.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:(()=>{switch(e.status){case`active`:return`Active`;case`inactive`:return`Inactive`;case`error`:return`Error`;case`not_found`:return`Not Found`;case`available`:return`Available`;case`removed`:return`Removed`;case`destroyed`:return`Destroyed`;case`offline`:return`Offline`;default:return e.status}})()}),_&&(0,Y.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),T&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:e.remote?.url?`${e.remote.url} (${(e.remote.permissions||[]).join(`, `)||`no permissions`})`:void 0,children:[`Remote · `,e.host]}),b&&(0,Y.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[ee,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var X=[{value:`full`,icon:o,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:m,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function xe({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,Y.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:X.map(i=>{let a=e===i.value,o=i.icon;return(0,Y.jsxs)(`button`,{id:`${r}-${i.value}`,type:`button`,role:`radio`,"aria-checked":a,disabled:n,onClick:()=>t(i.value),className:`flex w-full gap-2 rounded-md border p-2.5 text-left transition-colors disabled:opacity-50 ${a?`border-primary bg-accent/40`:`hover:bg-accent/20`}`,children:[(0,Y.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,Y.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,Y.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,Y.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Se(){let[e,t]=(0,J.useState)(`full`),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{let e=!0;return _.get(`/ping`,{skipAuth:!0}).then(r=>{let i=r?.defaults?.workspaceLayout;e&&!n&&(i===`home`||i===`full`)&&t(i)}).catch(()=>{}),()=>{e=!1}},[]),[e,e=>{r(!0),t(e)}]}function Ce(){let[e,t]=(0,J.useState)([]),[n,a]=(0,J.useState)(!0),[o,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,_]=(0,J.useState)(R()),[y,x]=(0,J.useState)(null),[C,w]=(0,J.useState)(``),[E,te]=Se(),[k,A]=(0,J.useState)(null),[j,M]=(0,J.useState)(null),[N,P]=(0,J.useState)(!1),F=se(),[I,z]=pe(),B=ge(),[ce,le]=(0,J.useState)(!1),[H,U]=(0,J.useState)(!1),[q,X]=(0,J.useState)(!1),[Ce,De]=(0,J.useState)(!1),[Z,Q]=(0,J.useState)(null),{showToast:$}=v(),Oe=i(),ke=ne(),{openM2Drawer:Ae}=ie(),je=me();he(je,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||b().then(e=>t(W(e))).catch(()=>{})}}),(0,J.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await b();t(W(e)),l(null)}catch(e){console.error(`Workspace fetch error:`,e);let t=`Failed to fetch workspaces`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to fetch workspaces`}l(t),$({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[je,$]);let Me=async e=>{if(e.preventDefault(),u.trim()){P(!0);try{let e=await D({name:u,description:f||void 0,color:m,icon:y,label:C||u,layout:E});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),B.selected.size>0){try{await T(e.name);let{ok:t,failed:n}=await _e(e.name,Array.from(B.selected),B.tree);n&&$({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),$({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}B.setSelected(new Set)}d(``),p(``),_(R()),x(null),w(``),$({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),z(!1)}catch(e){console.error(`Workspace creation error:`,e);let t=`Failed to create workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to create workspace`}$({title:`Error`,description:t,variant:`destructive`})}finally{P(!1)}}},Ne=async e=>{if(e.preventDefault(),Z)try{let e={label:Z.label,description:Z.description,color:Z.color,icon:Z.icon??null};await O(Z.name,e),t(t=>t.map(t=>t.id===Z.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),$({title:`Success`,description:`Workspace '${Z.label}' details updated.`}),Q(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Q(e)},Fe=async e=>{try{await ee(e.name),t(t=>t.filter(t=>t.id!==e.id)),$({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;$({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await T(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' started.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace start error:`,e);let t=`Failed to start workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to start workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await S(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),$({title:`Success`,description:`Workspace '${n.label||n.name}' stopped.`}),window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}catch(e){console.error(`Workspace stop error:`,e);let t=`Failed to stop workspace`;if(e instanceof Error)t=e.message;else if(typeof e==`object`&&e){let n=e;t=n.message||n.error||n.payload?.message||n.payload?.error||n.statusText||`Failed to stop workspace`}$({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{Oe(ae(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=de((n,r)=>{let i=ue(e,n,r);t(i),oe(i,(e,t)=>O(V(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&$({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,Y.jsxs)(`div`,{className:`space-y-6`,children:[(0,Y.jsx)(fe,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(h,{variant:`outline`,onClick:()=>le(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>X(e=>!e),children:`Import workspace`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>U(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,Y.jsx)(h,{variant:`outline`,onClick:()=>De(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!F.local&&!I&&(0,Y.jsxs)(h,{onClick:()=>z(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,Y.jsx)(s,{className:`h-4 w-4 sm:mr-2`}),(0,Y.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!F.local&&I&&(0,Y.jsx)(K,{title:`Create New Workspace`,onClose:()=>z(!1),children:(0,Y.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Y.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:N}),(0,Y.jsx)(g,{value:C,onChange:e=>w(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:N})]}),(0,Y.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:N}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:N,onClick:e=>A({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:L(m)})}),(0,Y.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:N}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(R()),disabled:N,children:`Randomize`})]}),k&&(0,Y.jsx)(G,{x:k.x,y:k.y,current:{icon:y??void 0,color:m},onChange:e=>{`icon`in e&&x(e.icon??null),`color`in e&&e.color&&_(e.color)},onClose:()=>A(null)}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`How the workspace directory is laid out on disk. Fixed once created.`}),(0,Y.jsx)(xe,{value:E,onChange:te,disabled:N,idPrefix:`create-workspace-layout`})]}),(0,Y.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,Y.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,Y.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,Y.jsx)(`p`,{className:`mb-3 mt-0.5 text-xs text-muted-foreground`,children:`Ticked folders are created right after the workspace, with matching icons and colors.`}),(0,Y.jsx)(ve,{selected:B.selected,onToggle:B.toggle,tree:B.tree,onTreeChange:B.setTree,disabled:N,idPrefix:`create-default-folders`})]}),(0,Y.jsxs)(h,{type:`submit`,disabled:N||!u.trim(),children:[(0,Y.jsx)(s,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),ce&&(0,Y.jsx)(Te,{}),Ce&&(0,Y.jsx)(Ee,{onClose:()=>De(!1),onChanged:async()=>{try{t(W(await b()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),q&&(0,Y.jsx)(K,{title:`Import workspace`,onClose:()=>X(!1),children:(0,Y.jsx)(ye,{onImported:()=>X(!1)})}),H&&(0,Y.jsx)(we,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),U(!1)},onClose:()=>U(!1)}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),o&&(0,Y.jsx)(`div`,{className:`text-center text-destructive`,children:(0,Y.jsx)(`p`,{children:o})}),!n&&!o&&e.length===0&&(0,Y.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,Y.jsx)(`div`,{className:`grid gap-4`,children:e.map((t,n)=>{let r={...t,createdAt:t.createdAt,updatedAt:t.updatedAt,color:t.color===null?void 0:t.color},i=L(t.color);return(0,Y.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,...Be(n),title:`Drag to reorder`,"aria-label":`Drag to reorder`,className:`hidden w-5 shrink-0 cursor-grab items-center justify-center rounded-l-lg active:cursor-grabbing md:flex ${i?``:`bg-muted`}`,style:i?{backgroundColor:i}:void 0,children:(0,Y.jsx)(c,{className:`h-4 w-4 ${re(i)}`})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Y.jsx)(be,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{ke?Ae(`workspaces`,`settings`,V(e)):Oe(`/workspaces/${V(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),Z&&(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,Z.label]}),(0,Y.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,Y.jsx)(g,{id:`edit-label`,value:Z.label,onChange:e=>Q(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,Y.jsx)(g,{id:`edit-description`,value:Z.description||``,onChange:e=>Q(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>M({x:Math.min(e.clientX,window.innerWidth-290),y:Math.min(e.clientY,window.innerHeight-360)}),className:`flex h-10 w-10 items-center justify-center rounded-md border hover:bg-accent`,children:(0,Y.jsx)(r,{icon:Z.icon||`ph:stack-fill`,width:22,height:22,color:L(Z.color)})}),(0,Y.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:Z.color||`#FFFFFF`,onChange:e=>Q(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Q(e=>e?{...e,color:R()}:null),children:`Randomize Color`})]})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(h,{type:`submit`,disabled:!Z.label?.trim(),children:`Save Changes`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Q(null),children:`Cancel`})]})]}),j&&(0,Y.jsx)(G,{x:j.x,y:j.y,current:{icon:Z.icon??void 0,color:Z.color??void 0},onChange:e=>{Q(t=>{if(!t)return null;let n={...t};return`icon`in e&&(n.icon=e.icon??null),`color`in e&&e.color&&(n.color=e.color),n})},onClose:()=>M(null)})]})]})}function we({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(``);return(0,Y.jsx)(K,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,Y.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await C(i,a.trim(),e=>{m(w[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,Y.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,Y.jsx)(q,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,Y.jsx)(`strong`,{children:`copy`}),` of the workspace from the remote canvas-server into this one, where it then lives independently. The remote workspace is stopped while it is packed, and large workspaces can take several minutes — progress is shown above.`]})]})})}function Te(){let{showToast:e}=v(),[t,n]=(0,J.useState)(``),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,Y.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,Y.jsx)(h,{onClick:async()=>{if(!s(t.trim())){e({title:`Error`,description:`Invalid URL`,variant:`destructive`});return}if(!r.trim().startsWith(`canvas-`)){e({title:`Error`,description:`Invalid access token`,variant:`destructive`});return}o(!0);try{sessionStorage.setItem(`sharedToken:last`,r.trim());let e=new URLSearchParams({url:t.trim()}).toString();window.location.href=`/shared?${e}`}catch(t){e({title:`Error`,description:t instanceof Error?t.message:`Failed to open shared resource`,variant:`destructive`})}finally{o(!1)}},disabled:a||!t.trim()||!r.trim(),children:`Open`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`We use your provided URL and token to fetch via the remote's public API.`})]})}function Ee({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)([]),p=(0,J.useCallback)(async()=>{try{f(await E())}catch{f([])}},[]);(0,J.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await x(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,Y.jsxs)(K,{title:`Open a remote Workspace`,onClose:e,children:[(0,Y.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,Y.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,Y.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,Y.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-xs`,children:`name@host`}),` — nothing is copied. Every call you make to it is forwarded to the remote with the share token (its permissions apply); document content and thumbnails are cached locally so they stay readable when the remote is offline. Use “Import remote…” if you want an independent local copy instead.`]})]}),d.length>0&&(0,Y.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,Y.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,Y.jsx)(`span`,{className:`ml-2 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`remote`})]}),(0,Y.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,Y.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{Ce as default};