@augmentd-labs/canvas-web 2.26.41 → 2.26.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CalendarApplet-Bno3IDzO.js → CalendarApplet-D-zqm-ie.js} +1 -1
- package/dist/assets/{FiltersApplet-PclPc7fz.js → FiltersApplet-JdYOvvVo.js} +1 -1
- package/dist/assets/{HomeFab-B3f-hO-p.js → HomeFab-KnJ0amal.js} +1 -1
- package/dist/assets/{LensApplet-BnW7b0KX.js → LensApplet-DmJnK9xh.js} +1 -1
- package/dist/assets/{NotesApplet-FjdHMWCV.js → NotesApplet-CQElHVk-.js} +1 -1
- package/dist/assets/{_agentId_-CW33ane1.js → _agentId_-D-qxZUMa.js} +0 -0
- package/dist/assets/{_contextId_-wbu8w6OE.js → _contextId_-Dn4SYTZE.js} +1 -1
- package/dist/assets/_workspaceName_-BsPptLde.js +1 -0
- package/dist/assets/{about-DRzhyy-e.js → about-CYt1r_NF.js} +1 -1
- package/dist/assets/{add-BeESP_fg.js → add-Di0PTHej.js} +1 -1
- package/dist/assets/{agents-BYNJHrPc.js → agents-DcNNzyQt.js} +1 -1
- package/dist/assets/{appearance-DiQhAis2.js → appearance-Bs11PYYg.js} +1 -1
- package/dist/assets/{apps-C2mb0HML.js → apps-DN8Ux5ac.js} +1 -1
- package/dist/assets/{home-BRx1tOR-.js → home-7tcQ6_Mc.js} +1 -1
- package/dist/assets/{index-I9cslsRe.js → index-DDoPhET6.js} +2 -2
- package/dist/assets/{key-bindings-CvzGVYrr.js → key-bindings-CqCOuyv6.js} +1 -1
- package/dist/assets/{registry-NAExJwr9.js → registry-fC-KNk2X.js} +2 -2
- package/dist/assets/{settings-HBpYbGPW.js → settings-BIvpUSK-.js} +1 -1
- package/dist/assets/{settings-DrQdeEUS.js → settings-B_suOk2v.js} +1 -1
- package/dist/assets/{settings-DMM8k_4o.js → settings-CP_46X21.js} +6 -6
- package/dist/assets/{settings-CjKOuPew.js → settings-Dluo6P1Q.js} +1 -1
- package/dist/assets/{share-target-q77WkQhO.js → share-target-C7PbTH7r.js} +1 -1
- package/dist/assets/{shared-DsgNtRuD.js → shared-0beOwGSQ.js} +1 -1
- package/dist/assets/{tree-folders-CNu09uPg.js → tree-folders-CNbp7be7.js} +1 -1
- package/dist/assets/{useAgentModels-B48KqDI7.js → useAgentModels-Dw0ibJnv.js} +1 -1
- package/dist/assets/{workspaces-y3zARr9A.js → workspaces-BTYGLm4X.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/dist/assets/_workspaceName_-Ck6op9kd.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{_ 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};
|
|
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-DDoPhET6.js";import{n as be}from"./page-header-DrDt1sQ2.js";import{n as xe,r as Se,t as Ce}from"./useAgentModels-Dw0ibJnv.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 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{g as r,v as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{n as a,t as o}from"./HomeFab-KnJ0amal.js";var s=e(n(),1),c=`share-target-inbox`,l=t(),u={"too-large":`Android shares are limited to 100 MiB in total for temporary device storage. Nothing was uploaded. Use Add File to upload larger files directly.`,"stash-failed":`Canvas couldn't hold on to the shared file — device storage may be full. Try again, or upload it from the app.`,"empty-share":`Canvas received no files or text from the sharing app. Try again, or use Add File to select the photo directly.`,"empty-file":`The sharing app delivered an empty file. Try again, or use Add File to select the original directly.`,expired:`Nothing shared, or the share expired.`};async function d(e){let t=await caches.open(c),n=null,r=Date.now()+3e5;for(;Date.now()<r;){let r=await t.match(`/share-target-inbox/${e}/meta`);if(!r)return null;if(n=await r.json(),n?.status===`error`)throw Error(n.error||`stash-failed`);if(n?.status!==`receiving`)break;await new Promise(e=>setTimeout(e,300))}if(!n||n.status===`receiving`)throw Error(`stash-failed`);let i=[];for(let r=0;r<n.fileNames.length;r++){let a=await t.match(`/share-target-inbox/${e}/file-${r}`);if(!a)throw Error(`stash-failed`);let o=await a.blob();i.push(new File([o],n.fileNames[r],{type:o.type}))}let o=i.length?await a(i):null;if(await Promise.all(n.fileNames.map((n,r)=>t.delete(`/share-target-inbox/${e}/file-${r}`))),await t.delete(`/share-target-inbox/${e}/meta`),o)return{kind:o.kind,data:{files:o.files}};if(![n.title,n.text,n.url].some(e=>e.trim()))throw Error(`empty-share`);let s=n.text.trim(),l=n.url||(m(s)?s:``);return l?{kind:`link`,data:{url:l,title:n.title}}:{kind:`note`,data:{title:n.title,content:n.text}}}var f=new Map;function p(e){let t=f.get(e);return t||(t=d(e),f.set(e,t),t.finally(()=>setTimeout(()=>f.delete(e),6e4)).catch(()=>{})),t}function m(e){if(!e||/\s/.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function h(){let[e]=i(),t=r(),[n,a]=(0,s.useState)(null),[c,d]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=!1;async function n(){let n=e.get(`error`);if(n){d(n);return}let r=e.get(`token`),i=r?await p(r):null;t||(i?a(i):d(`expired`))}return n().catch(e=>{t||d(e instanceof Error?e.message:`stash-failed`)}),()=>{t=!0}},[e]);let f=()=>t(`/home`,{replace:!0});return c?(0,l.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,l.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u[c]??u.expired}),(0,l.jsx)(`button`,{type:`button`,onClick:()=>t(`/apps/add/file`,{replace:!0}),className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Add File`}),(0,l.jsx)(`button`,{type:`button`,onClick:f,className:`text-sm font-medium text-primary underline underline-offset-4`,children:`Go to Canvas`})]}):n?(0,l.jsx)(o,{initialKind:n.kind,initialData:n.data,onInitialCardClose:f}):(0,l.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Receiving shared content on this device… No upload has started.`})}export{h 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{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button-SeUZ_Pvi.js";import{t as a}from"./input-BOtCd4HP.js";import{t as o}from"./api-CA6WiiYM.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{At as c}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{t as i}from"./button-SeUZ_Pvi.js";import{t as a}from"./input-BOtCd4HP.js";import{t as o}from"./api-CA6WiiYM.js";import{n as s}from"./use-toast-BlLDqSUO.js";import{At as c}from"./index-DDoPhET6.js";import{n as l}from"./page-header-DrDt1sQ2.js";import{t as u}from"./use-settings-back-DGmLAD63.js";var d=e(n(),1),f=t();function p(){let e=r(),{showToast:t}=s(),n=new URLSearchParams(e.search),p=e=>{try{let t=new URL(e);return t.pathname.includes(`/rest/v2/workspaces/`)&&!t.pathname.includes(`/rest/v2/pub/`)?t.pathname=t.pathname.replace(`/rest/v2/workspaces/`,`/rest/v2/pub/workspaces/`):t.pathname.includes(`/rest/v2/contexts/`)&&!t.pathname.includes(`/rest/v2/pub/`)&&(t.pathname=t.pathname.replace(`/rest/v2/contexts/`,`/rest/v2/pub/contexts/`)),t.toString()}catch{return e}},m=p(n.get(`url`)||``),h=sessionStorage.getItem(`sharedToken:last`)||``,[g,_]=(0,d.useState)(m),[v,y]=(0,d.useState)(h),[b,x]=(0,d.useState)(null),[S,C]=(0,d.useState)([]),[w,T]=(0,d.useState)(!1),E=(0,d.useMemo)(()=>{try{let e=new URL(g);return e.pathname.includes(`/pub/workspaces/`)?`workspace`:e.pathname.includes(`/pub/contexts/`)?`context`:`unknown`}catch{return`unknown`}},[g]),D=()=>({Authorization:`Bearer ${v.trim()}`}),O=async()=>{if(!(!g||!v)){T(!0);try{let e=p(g),t=await o.get(e,{skipAuth:!0,headers:D()});x(t);let n=await o.get(`${e}/documents`,{skipAuth:!0,headers:D()}),r=Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[];C(Array.isArray(r)?r:[])}catch(e){let n=g.includes(`/rest/v2/workspaces/`)?`Ensure the URL uses /rest/v2/pub/workspaces/<workspace-id> and the token matches that workspace.`:g.includes(`/rest/v2/contexts/`)?`Ensure the URL uses /rest/v2/pub/contexts/<context-id>.`:void 0;t({title:`Error`,description:`${e instanceof Error?e.message:`Failed to load shared resource`}${n?`: ${n}`:``}`,variant:`destructive`}),x(null),C([])}finally{T(!1)}}},k=(0,d.useRef)(O);return(0,d.useEffect)(()=>{k.current()},[]),(0,f.jsxs)(`div`,{className:`space-y-4`,children:[(0,f.jsx)(l,{onBack:u(),title:`Shared Resource Viewer`,description:`Open a resource someone shared with you.`}),(0,f.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,f.jsx)(a,{value:g,onChange:e=>_(e.target.value),placeholder:`Full pub URL`}),(0,f.jsx)(a,{value:v,onChange:e=>y(e.target.value),placeholder:`Access token (canvas-...)`}),(0,f.jsx)(i,{onClick:O,disabled:w||!g||!v,children:`Load`})]}),(0,f.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[`Type: `,E]}),w?(0,f.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`Loading...`}):(0,f.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsx)(`h2`,{className:`font-semibold mb-2`,children:`Metadata`}),(0,f.jsx)(`pre`,{className:`text-xs overflow-auto max-h-80`,children:JSON.stringify(b,null,2)})]}),(0,f.jsxs)(`div`,{className:`border rounded p-3`,children:[(0,f.jsxs)(`h2`,{className:`font-semibold mb-2`,children:[`Documents (`,S.length,`)`]}),S.length===0?(0,f.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`No documents`}):(0,f.jsx)(`ul`,{className:`space-y-2 text-sm`,children:S.slice(0,100).map((e,t)=>(0,f.jsxs)(`li`,{className:`border rounded p-2`,children:[(0,f.jsx)(`div`,{className:`font-mono text-xs`,children:e.id}),(0,f.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.schema})]},t))})]})]}),(0,f.jsx)(c,{className:`mt-8`})]})}export{p 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{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ct as i,Er as a,G as o,Jr as s,L as c,Lt as l,Pt as u,Rt as d,St as f,Vr as p,Wt as ee,X as m,Zr as h,bn as g,ct as _,hn as v,it as y,mt as b,ri as x,tt as S,xn as C,yn as w}from"./ui-CDoK3F3U.js";import{t as T}from"./utils-2pl1SbIp.js";import{Dn as E,G as D,In as O,bn as te,zn as ne}from"./workspace-C5V-ZCOE.js";import{t as re}from"./TodosWidget-CNnfNk4L.js";import{d as ie,o as ae,u as oe}from"./ObjectPropertiesCard-D2lrTQqT.js";import{g as se,t as ce,w as le,y as ue}from"./document-list-CUmMhD6M.js";import{n as de,r as fe}from"./use-toolbox-Ck_cLGgf.js";import{t as pe}from"./useToastHelpers-CRrpIIdY.js";import{n as me}from"./color-DFEH4BfK.js";import{t as k}from"./DocumentIcon-9i1uCMQa.js";import{r as he}from"./workspace-BydSRtST.js";import{t as ge}from"./registry-NAExJwr9.js";import{t as _e}from"./FileForm-CDiVKvxq.js";import{t as ve}from"./applet-target-pLdP-R76.js";var A=e(n(),1);function j(e){let{pathname:t}=r(),n=fe()?.setAgentView,i=JSON.stringify(e);(0,A.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function M(e,t,n,r){return structuredClone({...e,query:he(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function ye({target:e,children:t}){let[n,r]=(0,A.useState)([]),i=(0,A.useRef)(!1),[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null),{showErrorToast:d}=pe();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(ue,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(_e,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function P({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:a=!0,urlType:s,urlDisplay:c,contextPath:u,treeName:f,workspaceId:p,workspaceLabel:ee,workspaceIcon:h,documentSchema:_,documents:v,isLoading:y,totalCount:S,currentPage:C,pageSize:w,onPageChange:T,onPageSizeChange:E,onRemoveDocument:D,onDeleteDocument:O,onDestroyDocument:ne,onRemoveDocuments:re,onDeleteDocuments:se,onDestroyDocuments:ue,onCopyDocuments:fe,onCutDocuments:pe,onPasteDocuments:me,onImportDocuments:k,onSelectionChange:he,pastedDocumentIds:ge,onPurgeDocuments:_e,disablePurgeDocuments:ve,canvasInfo:j,isCanvasPinned:M,onTogglePinCanvas:P,onSaveAsCanvas:F,onShareCanvas:I,onUnshareCanvas:L,onDeleteCanvas:R,isSharingCanvas:z,isDeletingCanvas:B,isCanvasShared:V,isCanvasLocked:H,backendSearchQueries:U,onBackendSearch:W,onRemoveBackendQuery:G,serverSort:be,onServerSortChange:xe,scope:K,onScopeChange:q,canSaveChanges:J,isSavingChanges:Y,onSaveChanges:X,onBrowseWorkspaces:Se,onBrowseTree:Ce,onNavigatePath:we,linkTree:Te,children:Z,contentBanner:Ee,folders:De,onOpenFolder:Oe}){let ke=s===`canvas`,Q=le(),{state:Ae,toggleView:je,hasActiveFilters:Me,openAddPicker:Ne}=de(),$=ae(),[Pe,Fe]=(0,A.useState)(``),Ie=JSON.stringify([p,f,u,_]),[Le,Re]=(0,A.useState)(Ie);Le!==Ie&&(Re(Ie),Fe(``));let ze=(0,N.jsxs)(N.Fragment,{children:[t,F&&(0,N.jsx)(`button`,{type:`button`,onClick:F,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(x,{className:`h-4 w-4`})})]});return(0,N.jsxs)(ye,{target:k&&p?{mode:`workspace`,workspaceName:p,path:u,treeName:f||`context`,treeType:te(f)}:null,children:[e&&!Q&&(0,N.jsx)(ie,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${a&&!Q?` is-framed`:``}`,children:[(0,N.jsx)(oe,{workspaceIcon:h,workspace:ee||p||c.split(`://`)[0]||`Workspace`,actions:Q&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${s.endsWith(`-layer`)?`:layer`:``}`:s.replace(`-layer`,``),path:u,accentColor:r,onBack:$.location?$.location.section===`view`?$.close:()=>$.update?.({section:`view`}):n,section:$.location?`document/${$.location.documentId}/${$.location.section}`:void 0,onSection:$.location?()=>$.update?.({section:`view`}):void 0,onBrowseWorkspaces:Se,onBrowseTree:Ce,onNavigatePath:we,onFilter:()=>je(`tools`),filtersActive:Me,filtersOpen:Ae.t1Open&&Ae.t1View===`tools`,onAdd:e=>Ne({modal:e.shiftKey,fresh:!0}),search:W||!Z?{workspaceId:p,queries:U||[],onSearch:W??Fe,localOnly:!W,onRemoveQuery:G,scope:K,onScopeChange:q}:void 0,onDraftChange:Z?void 0:Fe}),ke&&j?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[j.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:j.color}}),(0,N.jsx)(g,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:j.label||c.split(`://`)[1]||`Canvas`}),j.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:j.description})]}),J&&X&&(0,N.jsxs)(`button`,{type:`button`,onClick:X,disabled:Y,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(i,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:Y?`Saving...`:`Save filters`})]}),P&&(0,N.jsxs)(`button`,{type:`button`,onClick:P,"aria-pressed":!!M,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:M?`Unpin from home`:`Pin to home`,children:[M?(0,N.jsx)(d,{className:`w-3 h-3`}):(0,N.jsx)(l,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:M?`Unpin`:`Pin`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,disabled:z||B,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:V?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(b,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:z?`Sharing...`:V?`Copy link`:`Share`})]}),V&&L&&(0,N.jsxs)(`button`,{type:`button`,onClick:L,disabled:z||B,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:B||H&&!V,title:H&&!V?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:B?`Deleting…`:`Delete`})]})]})}):null,Z&&(F||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[Ee,Z||(0,N.jsx)(ce,{readingPane:!0,externalSearchQuery:Pe,toolbarActions:ze,documents:_?v.filter(e=>e.schema===_):v,isLoading:y,folders:_?void 0:De,onOpenFolder:Oe,contextPath:u,treeName:f,workspaceId:p,totalCount:S,viewMode:_?`card`:`table`,allowViewToggle:!0,currentPage:C,pageSize:w,onPageChange:T,onPageSizeChange:E,onRemoveDocument:D,onDeleteDocument:O,onDestroyDocument:ne,onRemoveDocuments:re,onDeleteDocuments:se,onDestroyDocuments:ue,onCopyDocuments:fe,onCutDocuments:pe,onPasteDocuments:me,onImportDocuments:k,onSelectionChange:he,pastedDocumentIds:ge,onPurgeDocuments:_?void 0:_e,disablePurgeDocuments:ve,backendSearchQueries:U,onBackendSearch:W,serverSort:be,onServerSortChange:xe,onRemoveBackendQuery:G,scope:K,onScopeChange:q,canSaveChanges:!ke&&J,isSavingChanges:Y,onSaveChanges:X,linkTree:Te},_??`documents`)]})]})]})}var F=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`apps`,label:`Apps`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function I(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var L={id:`default`,name:`All`,kind:`documents`};function R(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function z(e){let t=e?.views;if(!Array.isArray(t))return[L];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(F.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[L]}var B={todos:v,"todo-app":v,notes:S,"notes-app":S,calendar:s,filters:_,sketch:h,terminal:y,lens:f,apps:C};function V({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:o,accentColor:s,onOpenToSide:l}){let[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(``),[h,g]=(0,A.useState)(!1),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)(null),x=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,A.useEffect)(()=>{x.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let S=()=>{v(null),b(null)},C=()=>{if(_&&y&&_!==y.id){let t=e.find(e=>e.id===_),n=e.filter(e=>e.id!==_),i=n.findIndex(e=>e.id===y.id);t&&i>=0&&(n.splice(y.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}S()},E=()=>{if(!d)return;let t=p.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},D=(t,n)=>{g(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?F.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:R()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),m(a)},O=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[L],n===t?i[0]?.id??L.id:void 0)};return(0,N.jsxs)(`div`,{className:T(`relative flex h-full min-w-0 items-end`,o),children:[(0,N.jsx)(`div`,{ref:x,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let o=r.id===t,u=r.kind===`columns`?a:r.kind===`app`&&r.app?B[r.app]:w;return d===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:p,onChange:e=>m(e.target.value),onBlur:E,onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&f(null)},className:T(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,o?T(`z-[2] bg-background font-medium`,s?me(s):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:o?s:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(r.id),m(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,v(r.id)},onDragOver:e=>{if(!_||_===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;b(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),C()},onDragEnd:S,className:T(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,o?T(`z-[2] bg-background font-medium`,s?me(s):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,_===r.id&&`opacity-50`),style:{backgroundColor:o?s:void 0,boxShadow:y?.id===r.id?`inset ${y.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),l&&(0,N.jsx)(ee,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),l(r.id)}}),!i&&e.length>1&&(0,N.jsx)(c,{className:T(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,o?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),O(r.id)}})]},r.id)})}),!i&&(h?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(w,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(a,{className:`h-3 w-3`}),` Board`]}),F.map(e=>{let t=B[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(c,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>g(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var H=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function U(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function W({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,A.useState)(null),[s,l]=(0,A.useState)(!1),[d,f]=(0,A.useState)({}),[ee,m]=(0,A.useState)({}),h=(0,A.useRef)(null),[g,_]=(0,A.useState)(!1),v=(0,A.useCallback)(()=>{let e=h.current;e&&_(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,A.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>v());return t.observe(e),()=>t.disconnect()},[v]);let y=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),m(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},b=e=>{m(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},x=e=>{let t=d[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},S=H.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:h,onScroll:v,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let a=(d[t.id]??t.filter??``).toLowerCase(),s=e.filter(e=>U(e,t.schemas)).filter(e=>{if(!a)return!0;let t=E(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=ee[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!i&&(0,N.jsx)(`div`,{onPointerDown:e=>y(e,t.id),onDoubleClick:()=>b(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!i&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>f(n=>({...n,[t.id]:e.target.value})),onBlur:()=>x(t.id),onKeyDown:e=>{e.key===`Enter`&&x(t.id)},placeholder:`Filter…`,readOnly:i,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[s.map(e=>{let t=E(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(k,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),s.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&S.length>0||g)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!i&&S.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}),s&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),S.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),g&&(0,N.jsx)(p,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(se,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function G(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r.join(`,`)}\0${i??``}`,[o,s]=(0,A.useState)(0),[c,l]=(0,A.useState)(null);(0,A.useEffect)(()=>{let o=!1;return D(e,n,t,{limit:200,allOf:r,...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,A.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,A.useCallback)(()=>s(e=>e+1),[])}}function be({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=G(e,t,n,[ne],`tasks`),[o,s]=(0,A.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(re,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}var xe=[O,`data/type/webapp`],K=`Other`;function q({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i}=G(e,t,n,xe),a=(0,A.useMemo)(()=>{let e=new Map;for(let t of r){let n=String(t.data?.category??``).trim(),r=n?n.toLowerCase():``,i=e.get(r)??[];i.push(t),e.set(r,i)}return[...e.entries()].map(([e,t])=>({key:e,label:e?String(t[0].data.category).trim():K,items:t.sort((e,t)=>Y(e).localeCompare(Y(t)))})).sort((e,t)=>!e.key-+!t.key||e.label.localeCompare(t.label))},[r]);return(0,N.jsx)(`div`,{className:`mx-auto h-full w-full max-w-5xl overflow-y-auto p-4`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):a.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No web apps here. Add a link and tick “Web app”.`}):a.map(e=>(0,N.jsxs)(`section`,{className:`mb-6`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,N.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(7rem,1fr))] gap-3`,children:e.items.map(e=>(0,N.jsx)(X,{doc:e},e.id))})]},e.key||K))})}function J(e){return String(e.data?.uri??``)}function Y(e){let t=String(e.data?.label??``).trim();if(t)return t;try{return new URL(J(e)).hostname.replace(/^www\./,``)}catch{return J(e)}}function X({doc:e}){let t=Y(e);return(0,N.jsxs)(`a`,{href:J(e),target:`_blank`,rel:`noopener noreferrer`,title:J(e),className:`flex flex-col items-center gap-2 rounded-lg border border-border bg-card p-3 text-center outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,N.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-md bg-primary/10 text-lg font-semibold text-primary`,children:t.charAt(0).toUpperCase()}),(0,N.jsx)(`span`,{className:`w-full truncate text-xs text-foreground`,children:t})]})}function Se({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:te(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=ge.find(e=>e.id===i);return(0,N.jsx)(ve,{target:r,children:e===`todos`?(0,N.jsx)(be,{...n}):e===`apps`?(0,N.jsx)(q,{...n}):a?(0,N.jsx)(a.Component,{}):null})}function Ce(e,t){if(!e)return[];let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e)??null,!r)return[];let i=n.length?`/${n.join(`/`)}`:``,a=(r.children??[]).filter(e=>e.type!==`canvas`).map(e=>({name:e.name,path:`${i}/${e.name}`,label:e.label,color:e.color,childCount:e.children?.length??0})).sort((e,t)=>(e.label||e.name).localeCompare(t.label||t.name,void 0,{numeric:!0,sensitivity:`base`}));return n.length>0&&a.unshift({name:`..`,path:n.length>1?`/${n.slice(0,-1).join(`/`)}`:`/`,isParent:!0}),a}export{L as a,P as c,V as i,M as l,Se as n,I as o,W as r,z as s,Ce as t,j as u};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{h as r}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Ct as i,Er as a,G as o,Jr as s,L as c,Lt as l,Pt as u,Rt as d,St as f,Vr as p,Wt as ee,X as m,Zr as h,bn as g,ct as _,hn as v,it as y,mt as b,ri as x,tt as S,xn as C,yn as w}from"./ui-CDoK3F3U.js";import{t as T}from"./utils-2pl1SbIp.js";import{Dn as E,G as D,In as O,bn as te,zn as ne}from"./workspace-C5V-ZCOE.js";import{t as re}from"./TodosWidget-CNnfNk4L.js";import{d as ie,o as ae,u as oe}from"./ObjectPropertiesCard-D2lrTQqT.js";import{g as se,t as ce,w as le,y as ue}from"./document-list-CUmMhD6M.js";import{n as de,r as fe}from"./use-toolbox-Ck_cLGgf.js";import{t as pe}from"./useToastHelpers-CRrpIIdY.js";import{n as me}from"./color-DFEH4BfK.js";import{t as k}from"./DocumentIcon-9i1uCMQa.js";import{r as he}from"./workspace-BydSRtST.js";import{t as ge}from"./registry-fC-KNk2X.js";import{t as _e}from"./FileForm-CDiVKvxq.js";import{t as ve}from"./applet-target-pLdP-R76.js";var A=e(n(),1);function j(e){let{pathname:t}=r(),n=fe()?.setAgentView,i=JSON.stringify(e);(0,A.useEffect)(()=>(n?.({pathname:t,view:JSON.parse(i)}),()=>n?.(null)),[t,i,n])}function M(e,t,n,r){return structuredClone({...e,query:he(t,n,r),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})}var N=t();function ye({target:e,children:t}){let[n,r]=(0,A.useState)([]),i=(0,A.useRef)(!1),[a,o]=(0,A.useState)(!1),[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null),{showErrorToast:d}=pe();return(0,N.jsxs)(`div`,{className:`relative flex flex-col h-full min-h-0 bg-background ${a?`ring-2 ring-inset ring-primary`:``}`,onDragOverCapture:t=>{s||!e||!Array.from(t.dataTransfer.types).includes(`Files`)||(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=i.current?`none`:`copy`,o(!i.current))},onDragLeaveCapture:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},onDropCapture:t=>{if(s||!e||!Array.from(t.dataTransfer.types).includes(`Files`))return;if(t.preventDefault(),t.stopPropagation(),o(!1),i.current){d(`Wait for the current upload to finish`);return}let n=Array.from(t.dataTransfer.files);if(!n.length){d(`Drop files rather than folders`);return}r(n),u(e),c(!0)},children:[t,a&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 z-30 flex items-center justify-center bg-background/80 text-sm font-medium`,children:[`Drop files to upload to `,e?.mode===`workspace`?e.path:`this context`]}),s&&(0,N.jsxs)(ue,{label:`Import files`,onClose:()=>{i.current||c(!1)},children:[(0,N.jsx)(`h2`,{className:`border-b px-4 py-3 text-sm font-medium`,children:`Import files`}),(0,N.jsx)(_e,{target:l,initialFiles:n,onClose:()=>c(!1),onBusyChange:e=>{i.current=e}})]})]})}function P({navigationTabs:e,navigationActions:t,onBack:n,accentColor:r,frameContent:a=!0,urlType:s,urlDisplay:c,contextPath:u,treeName:f,workspaceId:p,workspaceLabel:ee,workspaceIcon:h,documentSchema:_,documents:v,isLoading:y,totalCount:S,currentPage:C,pageSize:w,onPageChange:T,onPageSizeChange:E,onRemoveDocument:D,onDeleteDocument:O,onDestroyDocument:ne,onRemoveDocuments:re,onDeleteDocuments:se,onDestroyDocuments:ue,onCopyDocuments:fe,onCutDocuments:pe,onPasteDocuments:me,onImportDocuments:k,onSelectionChange:he,pastedDocumentIds:ge,onPurgeDocuments:_e,disablePurgeDocuments:ve,canvasInfo:j,isCanvasPinned:M,onTogglePinCanvas:P,onSaveAsCanvas:F,onShareCanvas:I,onUnshareCanvas:L,onDeleteCanvas:R,isSharingCanvas:z,isDeletingCanvas:B,isCanvasShared:V,isCanvasLocked:H,backendSearchQueries:U,onBackendSearch:W,onRemoveBackendQuery:G,serverSort:be,onServerSortChange:xe,scope:K,onScopeChange:q,canSaveChanges:J,isSavingChanges:Y,onSaveChanges:X,onBrowseWorkspaces:Se,onBrowseTree:Ce,onNavigatePath:we,linkTree:Te,children:Z,contentBanner:Ee,folders:De,onOpenFolder:Oe}){let ke=s===`canvas`,Q=le(),{state:Ae,toggleView:je,hasActiveFilters:Me,openAddPicker:Ne}=de(),$=ae(),[Pe,Fe]=(0,A.useState)(``),Ie=JSON.stringify([p,f,u,_]),[Le,Re]=(0,A.useState)(Ie);Le!==Ie&&(Re(Ie),Fe(``));let ze=(0,N.jsxs)(N.Fragment,{children:[t,F&&(0,N.jsx)(`button`,{type:`button`,onClick:F,title:`Save as canvas`,"aria-label":`Save as canvas`,className:`flex h-control-sm w-control-sm shrink-0 items-center justify-center rounded-md border text-muted-foreground hover:bg-accent touch-target`,children:(0,N.jsx)(x,{className:`h-4 w-4`})})]});return(0,N.jsxs)(ye,{target:k&&p?{mode:`workspace`,workspaceName:p,path:u,treeName:f||`context`,treeType:te(f)}:null,children:[e&&!Q&&(0,N.jsx)(ie,{accentColor:r,children:e}),(0,N.jsxs)(`div`,{className:`canvas-surface-body${a&&!Q?` is-framed`:``}`,children:[(0,N.jsx)(oe,{workspaceIcon:h,workspace:ee||p||c.split(`://`)[0]||`Workspace`,actions:Q&&e?(0,N.jsxs)(`details`,{className:`relative shrink-0`,"aria-label":`Canvas views`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer rounded-md border px-2 py-1 text-xs`,title:`Choose or manage content views`,children:`Views`}),(0,N.jsx)(`div`,{className:`absolute right-0 top-full z-30 mt-2 min-w-64 max-w-[80vw] rounded-md border bg-background p-2 shadow-lg`,children:e})]}):void 0,tree:f?`${f}${s.endsWith(`-layer`)?`:layer`:``}`:s.replace(`-layer`,``),path:u,accentColor:r,onBack:$.location?$.location.section===`view`?$.close:()=>$.update?.({section:`view`}):n,section:$.location?`document/${$.location.documentId}/${$.location.section}`:void 0,onSection:$.location?()=>$.update?.({section:`view`}):void 0,onBrowseWorkspaces:Se,onBrowseTree:Ce,onNavigatePath:we,onFilter:()=>je(`tools`),filtersActive:Me,filtersOpen:Ae.t1Open&&Ae.t1View===`tools`,onAdd:e=>Ne({modal:e.shiftKey,fresh:!0}),search:W||!Z?{workspaceId:p,queries:U||[],onSearch:W??Fe,localOnly:!W,onRemoveQuery:G,scope:K,onScopeChange:q}:void 0,onDraftChange:Z?void 0:Fe}),ke&&j?(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 border-b bg-muted/20 shrink-0 min-w-0`,children:[j.color&&(0,N.jsx)(`div`,{className:`w-1 h-6 rounded-full shrink-0`,style:{backgroundColor:j.color}}),(0,N.jsx)(g,{className:`w-4 h-4 shrink-0 text-primary`}),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,N.jsx)(`span`,{className:`text-lg font-semibold leading-tight truncate`,children:j.label||c.split(`://`)[1]||`Canvas`}),j.description&&(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:j.description})]}),J&&X&&(0,N.jsxs)(`button`,{type:`button`,onClick:X,disabled:Y,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:`Save filters`,children:[(0,N.jsx)(i,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:Y?`Saving...`:`Save filters`})]}),P&&(0,N.jsxs)(`button`,{type:`button`,onClick:P,"aria-pressed":!!M,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground`,title:M?`Unpin from home`:`Pin to home`,children:[M?(0,N.jsx)(d,{className:`w-3 h-3`}):(0,N.jsx)(l,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:M?`Unpin`:`Pin`})]}),I&&(0,N.jsxs)(`button`,{type:`button`,onClick:I,disabled:z||B,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-accent transition-colors text-muted-foreground hover:text-foreground disabled:opacity-50`,title:V?`Copy public link`:`Share canvas`,children:[(0,N.jsx)(b,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:z?`Sharing...`:V?`Copy link`:`Share`})]}),V&&L&&(0,N.jsxs)(`button`,{type:`button`,onClick:L,disabled:z||B,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(o,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Unshare`})]}),R&&(0,N.jsxs)(`button`,{type:`button`,onClick:R,disabled:B||H&&!V,title:H&&!V?`Unlock this canvas before deleting it`:`Delete canvas`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1 text-xs border rounded-md hover:bg-destructive/10 transition-colors text-muted-foreground hover:text-destructive disabled:opacity-50`,children:[(0,N.jsx)(m,{className:`w-3 h-3`}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:B?`Deleting…`:`Delete`})]})]})}):null,Z&&(F||t)&&(0,N.jsx)(`div`,{className:`flex items-center gap-2 border-b px-3 py-1`,children:ze}),(0,N.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:[Ee,Z||(0,N.jsx)(ce,{readingPane:!0,externalSearchQuery:Pe,toolbarActions:ze,documents:_?v.filter(e=>e.schema===_):v,isLoading:y,folders:_?void 0:De,onOpenFolder:Oe,contextPath:u,treeName:f,workspaceId:p,totalCount:S,viewMode:_?`card`:`table`,allowViewToggle:!0,currentPage:C,pageSize:w,onPageChange:T,onPageSizeChange:E,onRemoveDocument:D,onDeleteDocument:O,onDestroyDocument:ne,onRemoveDocuments:re,onDeleteDocuments:se,onDestroyDocuments:ue,onCopyDocuments:fe,onCutDocuments:pe,onPasteDocuments:me,onImportDocuments:k,onSelectionChange:he,pastedDocumentIds:ge,onPurgeDocuments:_?void 0:_e,disablePurgeDocuments:ve,backendSearchQueries:U,onBackendSearch:W,serverSort:be,onServerSortChange:xe,onRemoveBackendQuery:G,scope:K,onScopeChange:q,canSaveChanges:!ke&&J,isSavingChanges:Y,onSaveChanges:X,linkTree:Te},_??`documents`)]})]})]})}var F=[{id:`todos`,label:`Todo list`},{id:`todo-app`,label:`Todo App`},{id:`notes`,label:`Notes list`},{id:`notes-app`,label:`Notes App`},{id:`calendar`,label:`Calendar`},{id:`apps`,label:`Apps`},{id:`sketch`,label:`Sketch`},{id:`terminal`,label:`Terminal`}];function I(e){return e?.kind===`app`&&e.app===`notes`?`data/schema/note`:void 0}var L={id:`default`,name:`All`,kind:`documents`};function R(){return[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}]}function z(e){let t=e?.views;if(!Array.isArray(t))return[L];let n=t.filter(e=>{let t=e;return!t||typeof t.id!=`string`||typeof t.name!=`string`?!1:t.kind===`documents`||t.kind===`columns`||t.kind===`app`&&(F.some(e=>e.id===t.app)||t.app===`filters`||t.app===`lens`)});return n.length>0?n:[L]}var B={todos:v,"todo-app":v,notes:S,"notes-app":S,calendar:s,filters:_,sketch:h,terminal:y,lens:f,apps:C};function V({views:e,activeId:t,onSelect:n,onSave:r,readOnly:i=!1,className:o,accentColor:s,onOpenToSide:l}){let[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(``),[h,g]=(0,A.useState)(!1),[_,v]=(0,A.useState)(null),[y,b]=(0,A.useState)(null),x=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=x.current;if(!e)return;let t=t=>{if(t.ctrlKey||e.scrollWidth<=e.clientWidth)return;let n=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY,r=t.deltaMode===1?16:t.deltaMode===2?e.clientWidth:1;t.preventDefault(),e.scrollLeft+=n*r};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,A.useEffect)(()=>{x.current?.querySelector(`[aria-pressed="true"], input`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[t,d]);let S=()=>{v(null),b(null)},C=()=>{if(_&&y&&_!==y.id){let t=e.find(e=>e.id===_),n=e.filter(e=>e.id!==_),i=n.findIndex(e=>e.id===y.id);t&&i>=0&&(n.splice(y.before?i:i+1,0,t),n.some((t,n)=>t.id!==e[n].id)&&r(n))}S()},E=()=>{if(!d)return;let t=p.trim();t&&r(e.map(e=>e.id===d?{...e,name:t}:e)),f(null)},D=(t,n)=>{g(!1);let i=`view-${Date.now().toString(36)}`,a=t===`columns`?`Board`:t===`app`?F.find(e=>e.id===n)?.label??`App`:`List`,o=t===`columns`?{id:i,name:a,kind:t,columns:R()}:t===`app`?{id:i,name:a,kind:t,app:n}:{id:i,name:a,kind:t};r([...e,o],i),f(i),m(a)},O=n=>{let i=e.filter(e=>e.id!==n);r(i.length>0?i:[L],n===t?i[0]?.id??L.id:void 0)};return(0,N.jsxs)(`div`,{className:T(`relative flex h-full min-w-0 items-end`,o),children:[(0,N.jsx)(`div`,{ref:x,className:`flex min-w-0 items-end gap-0.5 overflow-x-auto overscroll-x-contain pt-1 [scrollbar-width:none]`,children:e.map(r=>{let o=r.id===t,u=r.kind===`columns`?a:r.kind===`app`&&r.app?B[r.app]:w;return d===r.id?(0,N.jsx)(`input`,{autoFocus:!0,"aria-label":`Tab name`,value:p,onChange:e=>m(e.target.value),onBlur:E,onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&f(null)},className:T(`relative h-[2.3rem] w-28 shrink-0 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs outline-none ring-0`,o?T(`z-[2] bg-background font-medium`,s?me(s):`text-foreground`):`bg-muted text-muted-foreground`),style:{backgroundColor:o?s:void 0}},r.id):(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":o,onClick:()=>n(r.id),onDoubleClick:()=>{i||(f(r.id),m(r.name))},title:i?r.name:`${r.name}: double-click to rename, drag to reorder`,draggable:!i,onDragStart:e=>{e.dataTransfer.setData(`text/plain`,r.name),e.dataTransfer.effectAllowed=`move`,v(r.id)},onDragOver:e=>{if(!_||_===r.id)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX<t.left+t.width/2;b(e=>e?.id===r.id&&e.before===n?e:{id:r.id,before:n})},onDrop:e=>{e.preventDefault(),C()},onDragEnd:S,className:T(`group relative flex h-[2.3rem] shrink-0 items-center gap-1.5 rounded-t-[.5rem] border-0 px-3 pb-1 text-xs transition-colors`,o?T(`z-[2] bg-background font-medium`,s?me(s):`text-foreground`):`bg-muted text-muted-foreground hover:bg-accent hover:text-foreground`,_===r.id&&`opacity-50`),style:{backgroundColor:o?s:void 0,boxShadow:y?.id===r.id?`inset ${y.before?`2px`:`-2px`} 0 0 var(--primary)`:void 0},children:[(0,N.jsx)(u,{className:`h-3 w-3 shrink-0`}),(0,N.jsx)(`span`,{className:`max-w-32 truncate`,children:r.name}),l&&(0,N.jsx)(ee,{className:`h-3 w-3 shrink-0 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-60`,"aria-label":`Open to the side`,onClick:e=>{e.stopPropagation(),l(r.id)}}),!i&&e.length>1&&(0,N.jsx)(c,{className:T(`h-3 w-3 shrink-0 transition-opacity hover:text-destructive`,o?`opacity-60 hover:opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>{e.stopPropagation(),O(r.id)}})]},r.id)})}),!i&&(h?(0,N.jsxs)(`span`,{className:`absolute left-0 top-full z-30 flex w-full min-w-64 flex-wrap items-center gap-2 rounded-b-xl border bg-card p-2 shadow-lg`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`documents`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(w,{className:`h-3 w-3`}),` List`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`columns`),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(a,{className:`h-3 w-3`}),` Board`]}),F.map(e=>{let t=B[e.id];return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>D(`app`,e.id),className:`flex h-10 items-center gap-1.5 rounded-md border px-2 text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:[(0,N.jsx)(t,{className:`h-3 w-3`}),` `,e.label]},e.id)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>g(!1),className:`p-1 text-muted-foreground hover:text-foreground`,"aria-label":`Cancel`,children:(0,N.jsx)(c,{className:`h-3 w-3`})})]}):(0,N.jsx)(`button`,{type:`button`,onClick:()=>g(!0),title:`Add view`,"aria-label":`Add view`,className:`relative ml-1 flex h-[2.3rem] w-10 shrink-0 items-center justify-center rounded-md pb-1 text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}))]})}var H=[{id:`emails`,label:`Emails`,schemas:[`data/schema/message`]},{id:`todos`,label:`Todos`,schemas:[`data/schema/task`]},{id:`notes`,label:`Notes`,schemas:[`data/schema/note`]},{id:`links`,label:`Links`,schemas:[`data/schema/tab`,`data/schema/link`]},{id:`files`,label:`Files`,schemas:[`data/schema/file`]}];function U(e,t){return t.some(t=>e.schema===t||e.schema.startsWith(`${t}/`))}function W({documents:e,workspaceId:t,columns:n,onColumnsChange:r,readOnly:i=!1}){let[a,o]=(0,A.useState)(null),[s,l]=(0,A.useState)(!1),[d,f]=(0,A.useState)({}),[ee,m]=(0,A.useState)({}),h=(0,A.useRef)(null),[g,_]=(0,A.useState)(!1),v=(0,A.useCallback)(()=>{let e=h.current;e&&_(e.scrollWidth-e.clientWidth-e.scrollLeft>8)},[]);(0,A.useEffect)(()=>{let e=h.current;if(!e)return;let t=new ResizeObserver(()=>v());return t.observe(e),()=>t.disconnect()},[v]);let y=(e,t)=>{e.preventDefault();let i=e.currentTarget.parentElement;if(!i)return;let a=e.clientX,o=i.getBoundingClientRect().width,s=o,c=e=>{s=Math.min(900,Math.max(220,o+e.clientX-a)),m(e=>({...e,[t]:s}))},l=()=>{window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l),r(n.map(e=>e.id===t?{...e,width:Math.round(s)}:e))};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},b=e=>{m(t=>{let n={...t};return delete n[e],n}),r(n.map(t=>t.id===e?{...t,width:void 0}:t))},x=e=>{let t=d[e];if(t===void 0)return;let i=n.find(t=>t.id===e);i&&(i.filter||``)!==t&&r(n.map(n=>n.id===e?{...n,filter:t||void 0}:n))},S=H.filter(e=>!n.some(t=>t.id===e.id));return(0,N.jsxs)(`div`,{className:`relative h-full`,children:[(0,N.jsx)(`div`,{ref:h,onScroll:v,className:`flex h-full snap-x snap-mandatory gap-3 overflow-x-auto overscroll-x-contain p-2`,"data-testid":`schema-columns-board`,children:n.map(t=>{let a=(d[t.id]??t.filter??``).toLowerCase(),s=e.filter(e=>U(e,t.schemas)).filter(e=>{if(!a)return!0;let t=E(e);return`${t.title}\n${t.preview}\n${t.subtitle}`.toLowerCase().includes(a)}),l=ee[t.id]??t.width;return(0,N.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 shrink-0 grow-0 basis-full snap-start flex-col rounded-(--card-radius) border bg-muted/20 ${l?`sm:basis-[var(--col-w)]`:`sm:basis-[48%] lg:basis-[32%] xl:basis-[24%]`}`,style:l?{"--col-w":`${l}px`}:void 0,children:[!i&&(0,N.jsx)(`div`,{onPointerDown:e=>y(e,t.id),onDoubleClick:()=>b(t.id),title:`Drag to resize; double-click to reset`,className:`absolute right-0 inset-y-0 z-10 w-2 cursor-col-resize touch-none rounded-r-lg transition-colors hover:bg-primary/25 active:bg-primary/40 max-sm:hidden`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-2.5 max-sm:pr-10`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t.label}),(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.length}),(0,N.jsx)(`span`,{className:`flex-1`}),!i&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>r(n.filter(e=>e.id!==t.id)),title:`Remove column`,className:`rounded-sm p-0.5 text-muted-foreground hover:text-destructive`,children:(0,N.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,N.jsx)(`div`,{className:`px-3 pb-2`,children:(0,N.jsx)(`input`,{value:d[t.id]??t.filter??``,onChange:e=>f(n=>({...n,[t.id]:e.target.value})),onBlur:()=>x(t.id),onKeyDown:e=>{e.key===`Enter`&&x(t.id)},placeholder:`Filter…`,readOnly:i,className:`h-7 w-full rounded-md border border-input bg-background px-2 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})}),(0,N.jsxs)(`div`,{className:`flex-1 space-y-1.5 overflow-y-auto px-2 pb-2`,children:[s.map(e=>{let t=E(e);return(0,N.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`w-full min-w-0 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-accent/50`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(k,{document:e,size:3.5}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium`,title:t.title,children:t.title})]}),t.preview&&(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 break-words text-[11px] leading-snug text-muted-foreground`,children:t.preview}),(0,N.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:new Date(e.updatedAt||e.createdAt).toLocaleDateString()})]},e.id)}),s.length===0&&(0,N.jsx)(`p`,{className:`px-2 py-3 text-center text-xs text-muted-foreground/60`,children:`Empty`})]})]},t.id)})}),(!i&&S.length>0||g)&&(0,N.jsxs)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 z-20 flex w-7 flex-col items-end bg-gradient-to-l from-background via-background/60 to-transparent py-2`,children:[!i&&S.length>0&&(0,N.jsxs)(`div`,{className:`pointer-events-auto relative`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),title:`Add column`,"aria-label":`Add column`,className:`flex h-7 w-6 items-center justify-center rounded-l-md border border-r-0 bg-background text-muted-foreground shadow-elevation-1 hover:bg-accent hover:text-foreground`,children:(0,N.jsx)(u,{className:`h-3.5 w-3.5`})}),s&&(0,N.jsxs)(`div`,{className:`absolute right-0 top-8 w-44 rounded-lg border bg-background p-2 shadow-elevation-2`,children:[(0,N.jsx)(`p`,{className:`px-2 pb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:`Add column`}),S.map(e=>(0,N.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),r([...n,{...e}])},className:`w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent/50 hover:text-foreground`,children:e.label},e.id)),(0,N.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`mt-1 w-full rounded-md px-2 py-1.5 text-left text-xs text-muted-foreground/60 hover:bg-accent/50`,children:`Cancel`})]})]}),g&&(0,N.jsx)(p,{className:`my-auto h-4 w-4 self-center text-muted-foreground/70`,"aria-label":`More columns`})]}),(0,N.jsx)(se,{document:a,isOpen:a!==null,onClose:()=>o(null),workspaceId:t})]})}function G(e,t,n,r,i){let a=`${e}\0${t}\0${n}\0${r.join(`,`)}\0${i??``}`,[o,s]=(0,A.useState)(0),[c,l]=(0,A.useState)(null);(0,A.useEffect)(()=>{let o=!1;return D(e,n,t,{limit:200,allOf:r,...i?{sortBy:i,order:`asc`}:{}}).then(e=>{o||l({key:a,docs:e.payload||[]})}).catch(()=>{o||l({key:a,docs:[]})}),()=>{o=!0}},[a,o]);let u=c?.key===a?c.docs:[],d=c?.key!==a;return(0,A.useEffect)(()=>{let e=()=>s(e=>e+1);return window.addEventListener(`workspace:documents:refresh`,e),()=>window.removeEventListener(`workspace:documents:refresh`,e)},[]),{docs:u,isLoading:d,refresh:(0,A.useCallback)(()=>s(e=>e+1),[])}}function be({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i,refresh:a}=G(e,t,n,[ne],`tasks`),[o,s]=(0,A.useState)(!1),c=o?r.filter(e=>e.data?.status!==`completed`):r,l=r.filter(e=>{let t=e.data?.status;return t!==`completed`&&t!==`cancelled`}).length;return(0,N.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-3xl flex-col p-4`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center justify-between gap-2`,children:[(0,N.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l,` open`]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`hide done`]})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-y-auto`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):c.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No todos here.`}):c.map(t=>(0,N.jsx)(re,{doc:t,workspaceId:e,readOnly:!1,onChanged:a},t.id))})]})}var xe=[O,`data/type/webapp`],K=`Other`;function q({workspaceId:e,treeName:t,path:n}){let{docs:r,isLoading:i}=G(e,t,n,xe),a=(0,A.useMemo)(()=>{let e=new Map;for(let t of r){let n=String(t.data?.category??``).trim(),r=n?n.toLowerCase():``,i=e.get(r)??[];i.push(t),e.set(r,i)}return[...e.entries()].map(([e,t])=>({key:e,label:e?String(t[0].data.category).trim():K,items:t.sort((e,t)=>Y(e).localeCompare(Y(t)))})).sort((e,t)=>!e.key-+!t.key||e.label.localeCompare(t.label))},[r]);return(0,N.jsx)(`div`,{className:`mx-auto h-full w-full max-w-5xl overflow-y-auto p-4`,children:i?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`Loading…`}):a.length===0?(0,N.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No web apps here. Add a link and tick “Web app”.`}):a.map(e=>(0,N.jsxs)(`section`,{className:`mb-6`,children:[(0,N.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,N.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(7rem,1fr))] gap-3`,children:e.items.map(e=>(0,N.jsx)(X,{doc:e},e.id))})]},e.key||K))})}function J(e){return String(e.data?.uri??``)}function Y(e){let t=String(e.data?.label??``).trim();if(t)return t;try{return new URL(J(e)).hostname.replace(/^www\./,``)}catch{return J(e)}}function X({doc:e}){let t=Y(e);return(0,N.jsxs)(`a`,{href:J(e),target:`_blank`,rel:`noopener noreferrer`,title:J(e),className:`flex flex-col items-center gap-2 rounded-lg border border-border bg-card p-3 text-center outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,N.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-md bg-primary/10 text-lg font-semibold text-primary`,children:t.charAt(0).toUpperCase()}),(0,N.jsx)(`span`,{className:`w-full truncate text-xs text-foreground`,children:t})]})}function Se({app:e,contextId:t,...n}){let r=t&&e!==`lens`?{mode:`context`,contextId:t}:{mode:`workspace`,workspaceName:n.workspaceId,treeName:n.treeName,path:n.path,treeType:te(n.treeName)},i=e===`todo-app`?`todo`:e===`notes-app`?`notes`:e,a=ge.find(e=>e.id===i);return(0,N.jsx)(ve,{target:r,children:e===`todos`?(0,N.jsx)(be,{...n}):e===`apps`?(0,N.jsx)(q,{...n}):a?(0,N.jsx)(a.Component,{}):null})}function Ce(e,t){if(!e)return[];let n=t.split(`/`).filter(Boolean),r=e;for(let e of n)if(r=r?.children?.find(t=>t.name===e)??null,!r)return[];let i=n.length?`/${n.join(`/`)}`:``,a=(r.children??[]).filter(e=>e.type!==`canvas`).map(e=>({name:e.name,path:`${i}/${e.name}`,label:e.label,color:e.color,childCount:e.children?.length??0})).sort((e,t)=>(e.label||e.name).localeCompare(t.label||t.name,void 0,{numeric:!0,sensitivity:`base`}));return n.length>0&&a.unshift({name:`..`,path:n.length>1?`/${n.slice(0,-1).join(`/`)}`:`/`,isParent:!0}),a}export{L as a,P as c,V as i,M as l,Se as n,I as o,W as r,z as s,Ce as t,j as u};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-SeUZ_Pvi.js";import{t as i}from"./input-BOtCd4HP.js";import{B as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{t as r}from"./button-SeUZ_Pvi.js";import{t as i}from"./input-BOtCd4HP.js";import{B as a}from"./index-DDoPhET6.js";function o(e,t,n){return[e.trim()?`## Role\n${e.trim()}`:``,t.trim()?`## Identity\n${t.trim()}`:``,n.trim()?`## Instructions\n${n.trim()}`:``].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)}var s=e(n(),1),c=t();function l({value:e,onChange:t,models:n,loading:a,error:o,refresh:l,disabled:u,id:d}){let f=(0,s.useId)(),p=n.find(t=>t.id===e);return(0,c.jsxs)(`div`,{className:`space-y-2`,children:[(0,c.jsxs)(`div`,{className:`flex gap-2`,children:[(0,c.jsx)(i,{id:d,"aria-label":`Model`,list:f,value:e,onChange:e=>t(e.target.value,n.find(t=>t.id===e.target.value)),placeholder:`Choose or enter a model ID`,disabled:u}),(0,c.jsx)(r,{type:`button`,variant:`outline`,disabled:u||a,onClick:l,children:`Refresh models`})]}),(0,c.jsx)(`datalist`,{id:f,children:n.map(e=>(0,c.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,c.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:a?`Loading models…`:o||(n.length?`${n.length} models available`:`Enter provider credentials to load available models. You can also enter a model ID.`)}),p&&(0,c.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Context: `,p.contextWindow?.toLocaleString()??`not reported`,` · Max output: `,p.maxTokens?.toLocaleString()??`not reported`,` tokens`,p.limitsSource===`runtime`?` (runtime catalogue)`:p.limitsSource===`provider`?` (provider)`:``]})]})}function u(e,t,n,r){let[i,o]=(0,s.useState)(0),c=JSON.stringify([e,t,n,r,i]),[l,u]=(0,s.useState)({key:``,models:[],loading:!1,error:``}),d=!!t.trim()||!!r||[`ollama`,`lm-studio`,`vllm`,`custom`].includes(e);return(0,s.useEffect)(()=>{if(!d)return;let i=new AbortController,o=setTimeout(()=>{u({key:c,models:[],loading:!0,error:``}),a({provider:e,apiKey:t.trim()||void 0,baseUrl:n.trim()||void 0,agentIdentifier:r},i.signal).then(e=>{i.signal.aborted||u({key:c,models:e,loading:!1,error:``})}).catch(e=>{i.signal.aborted||u({key:c,models:[],loading:!1,error:e instanceof Error?e.message:`Unable to load models`})})},700);return()=>{clearTimeout(o),i.abort()}},[c,d,e,t,n,r]),{...l.key===c?l:{models:[],loading:d,error:``},refresh:()=>o(e=>e+1)}}export{l as n,o as r,u as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{l as t,u as n}from"./code-editor-BOIngd5F.js";import{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Bn as a,Hn as o,It as s,Pt as c,X as l,at as u,ht as d,qn as f,rt as p,yr as m}from"./ui-CDoK3F3U.js";import{t as h}from"./button-SeUZ_Pvi.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Ut as y,Wt as b,ft as x,i as S,in as C,jt as w,mn as T,rn as E,t as D,v as O,yt as k}from"./workspace-C5V-ZCOE.js";import{a as ee,c as A,i as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./alert-dialog-CFeuDt0T.js";import{t as te}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as R,r as ne,t as z}from"./color-DFEH4BfK.js";import{t as B}from"./workspace-access-C9nZlBBZ.js";import{i as re}from"./use-menu-DIP1zh7I.js";import{r as ie}from"./last-path-BbXWC3b3.js";import{Dt as V,Et as ae,Ft as H,Mt as oe,Nt as se,Ot as ce,Pt as U,Tt as le,jt as W,kt as ue,mt as G,wt as de}from"./index-I9cslsRe.js";import{n as fe}from"./page-header-DrDt1sQ2.js";import{t as K}from"./form-panel-3p-ncEVK.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 ve,r as ye,t as be}from"./workspace-import-form-DTvV9jYt.js";var q=e(n(),1),J=t();function xe({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:a,onDestroy:o}){let[c,f]=(0,q.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,T=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,E=e.origin===`remote`,D=e.status===`offline`,O=R(e.color),k=O?``:`border-border`,te=O?{borderLeftColor:O,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(W,{className:`relative ${k}`,style:te,children:[(0,J.jsx)(U,{children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(H,{className:`truncate`,children:e.label||e.name}),(0,J.jsx)(se,{children:b?`Shared from ${x}`:e.description||``})]}),(0,J.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(G(e)),title:`Stop Workspace`,disabled:v||y,children:(0,J.jsx)(p,{className:`h-4 w-4`})}):(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(G(e)),title:D?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||D,children:(0,J.jsx)(s,{className:`h-4 w-4`})}),g&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(G(e)),title:`Enter Workspace`,disabled:v||y,children:(0,J.jsx)(m,{className:`h-4 w-4`})}),a&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>a(e),title:B(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!B(e),children:(0,J.jsx)(d,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,J.jsx)(u,{className:`h-4 w-4`})}),o&&!_&&!b&&(0,J.jsxs)(L,{open:c,onOpenChange:f,children:[(0,J.jsx)(M,{asChild:!0,children:(0,J.jsx)(h,{variant:`outline`,size:`icon`,title:E?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!E,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,J.jsx)(l,{className:`h-4 w-4`})})}),(0,J.jsxs)(j,{children:[(0,J.jsxs)(I,{children:[(0,J.jsx)(A,{children:E?`Remove remote workspace`:`Delete Workspace`}),(0,J.jsx)(ee,{children:E?(0,J.jsxs)(J.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,J.jsx)(`br`,{}),(0,J.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,J.jsxs)(J.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,J.jsx)(`br`,{}),(0,J.jsx)(`br`,{}),(0,J.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,J.jsxs)(P,{children:[(0,J.jsx)(F,{children:`Cancel`}),(0,J.jsx)(N,{onClick:()=>{o(e),f(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:E?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,J.jsx)(oe,{children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.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,J.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,J.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),E&&(0,J.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,J.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[T,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var Y=[{value:`full`,icon:f,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:a,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function Se({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,J.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:Y.map(i=>{let a=e===i.value,o=i.icon;return(0,J.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,J.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,J.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,J.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,J.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Ce(){let[e,t]=(0,q.useState)(`full`),[n,r]=(0,q.useState)(!1);return(0,q.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 we(){let[e,t]=(0,q.useState)([]),[n,a]=(0,q.useState)(!0),[s,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,_]=(0,q.useState)(z()),[y,x]=(0,q.useState)(null),[S,D]=(0,q.useState)(``),[k,ee]=Ce(),[A,j]=(0,q.useState)(null),[M,N]=(0,q.useState)(null),[P,F]=(0,q.useState)(!1),I=ue(),[L,B]=pe(),H=ge(),[oe,se]=(0,q.useState)(!1),[U,W]=(0,q.useState)(!1),[ve,Y]=(0,q.useState)(!1),[we,Oe]=(0,q.useState)(!1),[X,Z]=(0,q.useState)(null),{showToast:Q}=v(),ke=i(),Ae=te(),{openM2Drawer:je}=re(),$=me();he($,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||w().then(e=>t(V(e))).catch(()=>{})}}),(0,q.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await w();t(V(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),Q({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[$,Q]);let Me=async e=>{if(e.preventDefault(),u.trim()){F(!0);try{let e=await O({name:u,description:f||void 0,color:m,icon:y,label:S||u,layout:k});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),H.selected.size>0){try{await E(e.name);let{ok:t,failed:n}=await _e(e.name,Array.from(H.selected),H.tree);n&&Q({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),Q({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}H.setSelected(new Set)}d(``),p(``),_(z()),x(null),D(``),Q({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),B(!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`}Q({title:`Error`,description:t,variant:`destructive`})}finally{F(!1)}}},Ne=async e=>{if(e.preventDefault(),X)try{let e={label:X.label,description:X.description,color:X.color,icon:X.icon??null};await T(X.name,e),t(t=>t.map(t=>t.id===X.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),Q({title:`Success`,description:`Workspace '${X.label}' details updated.`}),Z(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;Q({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Z(e)},Fe=async e=>{try{await b(e.name),t(t=>t.filter(t=>t.id!==e.id)),Q({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;Q({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await E(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),Q({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`}Q({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await C(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),Q({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`}Q({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{ke(ie(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=ce((n,r)=>{let i=le(e,n,r);t(i),ae(i,(e,t)=>T(G(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&Q({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(fe,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(h,{variant:`outline`,onClick:()=>se(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>Y(e=>!e),children:`Import workspace`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>W(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>Oe(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!I.local&&!L&&(0,J.jsxs)(h,{onClick:()=>B(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,J.jsx)(c,{className:`h-4 w-4 sm:mr-2`}),(0,J.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!I.local&&L&&(0,J.jsx)(K,{title:`Create New Workspace`,onClose:()=>B(!1),children:(0,J.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:P}),(0,J.jsx)(g,{value:S,onChange:e=>D(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:P})]}),(0,J.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:P}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,J.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:P,onClick:e=>j({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,J.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:R(m)})}),(0,J.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:P}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(z()),disabled:P,children:`Randomize`})]}),A&&(0,J.jsx)(de,{x:A.x,y:A.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:()=>j(null)}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,J.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,J.jsx)(Se,{value:k,onChange:ee,disabled:P,idPrefix:`create-workspace-layout`})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,J.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,J.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,J.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,J.jsx)(ye,{selected:H.selected,onToggle:H.toggle,tree:H.tree,onTreeChange:H.setTree,disabled:P,idPrefix:`create-default-folders`})]}),(0,J.jsxs)(h,{type:`submit`,disabled:P||!u.trim(),children:[(0,J.jsx)(c,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),oe&&(0,J.jsx)(Ee,{}),we&&(0,J.jsx)(De,{onClose:()=>Oe(!1),onChanged:async()=>{try{t(V(await w()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),ve&&(0,J.jsx)(K,{title:`Import workspace`,onClose:()=>Y(!1),children:(0,J.jsx)(be,{onImported:()=>Y(!1)})}),U&&(0,J.jsx)(Te,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),W(!1)},onClose:()=>W(!1)}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,J.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),s&&(0,J.jsx)(`div`,{className:`text-center text-destructive`,children:(0,J.jsx)(`p`,{children:s})}),!n&&!s&&e.length===0&&(0,J.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,J.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=R(t.color);return(0,J.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,J.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,J.jsx)(o,{className:`h-4 w-4 ${ne(i)}`})}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(xe,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{Ae?je(`workspaces`,`settings`,G(e)):ke(`/workspaces/${G(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),X&&(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,X.label]}),(0,J.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,J.jsx)(g,{id:`edit-label`,value:X.label,onChange:e=>Z(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,J.jsx)(g,{id:`edit-description`,value:X.description||``,onChange:e=>Z(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>N({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,J.jsx)(r,{icon:X.icon||`ph:stack-fill`,width:22,height:22,color:R(X.color)})}),(0,J.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:X.color||`#FFFFFF`,onChange:e=>Z(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Z(e=>e?{...e,color:z()}:null),children:`Randomize Color`})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(h,{type:`submit`,disabled:!X.label?.trim(),children:`Save Changes`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Z(null),children:`Cancel`})]})]}),M&&(0,J.jsx)(de,{x:M.x,y:M.y,current:{icon:X.icon??void 0,color:X.color??void 0},onChange:e=>{Z(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:()=>N(null)})]})]})}function Te({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``);return(0,J.jsx)(K,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,J.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await x(i,a.trim(),e=>{m(D[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,J.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,J.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,J.jsx)(ve,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,J.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 Ee(){let{showToast:e}=v(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,J.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,J.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,J.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 De({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)([]),p=(0,q.useCallback)(async()=>{try{f(await k())}catch{f([])}},[]);(0,q.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await S(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,J.jsxs)(K,{title:`Open a remote Workspace`,onClose:e,children:[(0,J.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,J.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,J.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,J.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,J.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,J.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,J.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{we 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{_t as r}from"./react-BHzhHVTZ.js";import{g as i}from"./chunk-62JRHF6Z-vspAGgtK.js";import{Bn as a,Hn as o,It as s,Pt as c,X as l,at as u,ht as d,qn as f,rt as p,yr as m}from"./ui-CDoK3F3U.js";import{t as h}from"./button-SeUZ_Pvi.js";import{t as g}from"./input-BOtCd4HP.js";import{t as _}from"./api-CA6WiiYM.js";import{n as v}from"./use-toast-BlLDqSUO.js";import{Ut as y,Wt as b,ft as x,i as S,in as C,jt as w,mn as T,rn as E,t as D,v as O,yt as k}from"./workspace-C5V-ZCOE.js";import{a as ee,c as A,i as j,l as M,n as N,o as P,r as F,s as I,t as L}from"./alert-dialog-CFeuDt0T.js";import{t as te}from"./use-mobile-Db-vWu9Y.js";import"./layer-style-Byl5LNFR.js";import{i as R,r as ne,t as z}from"./color-DFEH4BfK.js";import{t as B}from"./workspace-access-C9nZlBBZ.js";import{i as re}from"./use-menu-DIP1zh7I.js";import{r as ie}from"./last-path-BbXWC3b3.js";import{Dt as V,Et as ae,Ft as H,Mt as oe,Nt as se,Ot as ce,Pt as U,Tt as le,jt as W,kt as ue,mt as G,wt as de}from"./index-DDoPhET6.js";import{n as fe}from"./page-header-DrDt1sQ2.js";import{t as K}from"./form-panel-3p-ncEVK.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 ve,r as ye,t as be}from"./workspace-import-form-DTvV9jYt.js";var q=e(n(),1),J=t();function xe({workspace:e,onStart:t,onStop:n,onEnter:r,onEdit:i,onSettings:a,onDestroy:o}){let[c,f]=(0,q.useState)(!1),g=e.status===`active`,_=e.type===`universe`||e.name===`universe`,v=e.status===`error`,y=e.status===`not_found`,b=e.isShared===!0||e.type===`shared`,x=e.ownerEmail||e.owner,S=typeof e.sharedVia==`object`&&e.sharedVia?e.sharedVia:null,C=S?.permissions||[],w=C.includes(`admin`)?`admin`:C.includes(`write`)?`read/write`:`read-only`,T=S?.type===`group`?`via group ${S.principal}`:S?.type===`user`?`shared with you`:``,E=e.origin===`remote`,D=e.status===`offline`,O=R(e.color),k=O?``:`border-border`,te=O?{borderLeftColor:O,borderLeftWidth:`4px`}:{borderLeftWidth:`4px`};return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(W,{className:`relative ${k}`,style:te,children:[(0,J.jsx)(U,{children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 basis-40`,children:[(0,J.jsx)(H,{className:`truncate`,children:e.label||e.name}),(0,J.jsx)(se,{children:b?`Shared from ${x}`:e.description||``})]}),(0,J.jsxs)(`div`,{className:`flex w-full shrink-0 flex-wrap items-center gap-2 sm:w-auto`,children:[g?(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>n(G(e)),title:`Stop Workspace`,disabled:v||y,children:(0,J.jsx)(p,{className:`h-4 w-4`})}):(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>t(G(e)),title:D?`Remote unreachable${e.statusMessage?`: ${e.statusMessage}`:``}`:`Start Workspace`,disabled:v||y||D,children:(0,J.jsx)(s,{className:`h-4 w-4`})}),g&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>r(G(e)),title:`Enter Workspace`,disabled:v||y,children:(0,J.jsx)(m,{className:`h-4 w-4`})}),a&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>a(e),title:B(e)?`Workspace settings`:`Workspace settings require admin access`,"aria-label":`Workspace settings`,disabled:y||!B(e),children:(0,J.jsx)(d,{className:`h-4 w-4`})}),i&&!_&&!b&&(0,J.jsx)(h,{variant:`outline`,size:`icon`,onClick:()=>i(e),title:`Edit Workspace`,disabled:v||y,children:(0,J.jsx)(u,{className:`h-4 w-4`})}),o&&!_&&!b&&(0,J.jsxs)(L,{open:c,onOpenChange:f,children:[(0,J.jsx)(M,{asChild:!0,children:(0,J.jsx)(h,{variant:`outline`,size:`icon`,title:E?`Remove remote workspace reference`:`Delete Workspace`,disabled:g&&!E,className:`text-destructive hover:text-destructive hover:bg-destructive/10`,children:(0,J.jsx)(l,{className:`h-4 w-4`})})}),(0,J.jsxs)(j,{children:[(0,J.jsxs)(I,{children:[(0,J.jsx)(A,{children:E?`Remove remote workspace`:`Delete Workspace`}),(0,J.jsx)(ee,{children:E?(0,J.jsxs)(J.Fragment,{children:[`Remove the reference to "`,e.label||e.name,`" from this server?`,(0,J.jsx)(`br`,{}),(0,J.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,J.jsxs)(J.Fragment,{children:[`Are you sure you want to delete the workspace "`,e.label||e.name,`"?`,(0,J.jsx)(`br`,{}),(0,J.jsx)(`br`,{}),(0,J.jsx)(`strong`,{children:`This action cannot be undone.`}),` All data associated with this workspace, including documents, contexts, and configurations will be permanently removed.`]})})]}),(0,J.jsxs)(P,{children:[(0,J.jsx)(F,{children:`Cancel`}),(0,J.jsx)(N,{onClick:()=>{o(e),f(!1)},className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:E?`Remove reference`:`Delete Workspace`})]})]})]})]})]})}),(0,J.jsx)(oe,{children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.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,J.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,J.jsx)(`span`,{className:`ml-2 rounded-full bg-primary/10 px-2 py-1 text-xs text-primary`,children:`Universe`}),E&&(0,J.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,J.jsxs)(`span`,{className:`ml-2 rounded-full bg-info/10 px-2 py-1 text-xs text-info`,title:[T,`${w} access`].filter(Boolean).join(` · `),children:[`Shared · `,w]})]})})]})})}var Y=[{value:`full`,icon:f,title:`Standard`,blurb:`Everything in one folder: your files in home/, alongside db/, data/, git/.`,tree:[`workspace.json`,`home/ ← your files`,`db/ data/ cache/ Git/`]},{value:`home`,icon:a,title:`Roaming home`,blurb:`The workspace folder IS your drive. Mount it over WebDAV and it looks like a plain home directory. Canvas keeps its files in a hidden .workspace/.`,tree:[`your files, at the top level`,`.workspace/ ← hidden, ignored`]}];function Se({value:e,onChange:t,disabled:n=!1,idPrefix:r=`workspace-layout`,compact:i=!1}){return(0,J.jsx)(`div`,{className:i?`space-y-1.5`:`grid gap-2 sm:grid-cols-2`,children:Y.map(i=>{let a=e===i.value,o=i.icon;return(0,J.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,J.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 ${a?`text-primary`:`text-muted-foreground`}`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block text-xs font-medium`,children:i.title}),(0,J.jsx)(`span`,{className:`mt-0.5 block text-[11px] leading-snug text-muted-foreground`,children:i.blurb}),(0,J.jsx)(`span`,{className:`mt-1 block font-mono text-[10px] leading-relaxed text-muted-foreground/80`,children:i.tree.map(e=>(0,J.jsx)(`span`,{className:`block truncate`,children:e},e))})]})]},i.value)})})}function Ce(){let[e,t]=(0,q.useState)(`full`),[n,r]=(0,q.useState)(!1);return(0,q.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 we(){let[e,t]=(0,q.useState)([]),[n,a]=(0,q.useState)(!0),[s,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,_]=(0,q.useState)(z()),[y,x]=(0,q.useState)(null),[S,D]=(0,q.useState)(``),[k,ee]=Ce(),[A,j]=(0,q.useState)(null),[M,N]=(0,q.useState)(null),[P,F]=(0,q.useState)(!1),I=ue(),[L,B]=pe(),H=ge(),[oe,se]=(0,q.useState)(!1),[U,W]=(0,q.useState)(!1),[ve,Y]=(0,q.useState)(!1),[we,Oe]=(0,q.useState)(!1),[X,Z]=(0,q.useState)(null),{showToast:Q}=v(),ke=i(),Ae=te(),{openM2Drawer:je}=re(),$=me();he($,`workspace`,{"workspace:status:changed":e=>t(t=>t.map(t=>t.id===e.workspaceId?{...t,status:e.status}:t)),"workspace:created":e=>t(t=>[...t,e.workspace]),"workspace:deleted":e=>t(t=>t.filter(t=>t.id!==e.workspaceId)),"workspaces.scanned":({report:e})=>{!e.discovered.length&&!e.adopted.length&&!e.updated.length&&!e.missing.length||w().then(e=>t(V(e))).catch(()=>{})}}),(0,q.useEffect)(()=>{let e=async()=>{try{a(!0);let e=await w();t(V(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),Q({title:`Error`,description:t,variant:`destructive`})}finally{a(!1)}};e();let n=()=>{e()};return window.addEventListener(`workspaces:refresh`,n),()=>{window.removeEventListener(`workspaces:refresh`,n)}},[$,Q]);let Me=async e=>{if(e.preventDefault(),u.trim()){F(!0);try{let e=await O({name:u,description:f||void 0,color:m,icon:y,label:S||u,layout:k});if(t(t=>[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),H.selected.size>0){try{await E(e.name);let{ok:t,failed:n}=await _e(e.name,Array.from(H.selected),H.tree);n&&Q({title:`Folders`,description:`${t} folder(s) created, ${n} failed`,variant:`destructive`})}catch(e){console.error(`Default folder creation failed:`,e),Q({title:`Folders`,description:`Workspace created, but default folders failed`,variant:`destructive`})}H.setSelected(new Set)}d(``),p(``),_(z()),x(null),D(``),Q({title:`Success`,description:`Workspace '${e.label||e.name}' created.`}),B(!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`}Q({title:`Error`,description:t,variant:`destructive`})}finally{F(!1)}}},Ne=async e=>{if(e.preventDefault(),X)try{let e={label:X.label,description:X.description,color:X.color,icon:X.icon??null};await T(X.name,e),t(t=>t.map(t=>t.id===X.id?{...t,...e}:t)),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),Q({title:`Success`,description:`Workspace '${X.label}' details updated.`}),Z(null)}catch(e){let t=e instanceof Error?e.message:`Failed to update workspace`;Q({title:`Error`,description:t,variant:`destructive`})}},Pe=e=>{Z(e)},Fe=async e=>{try{await b(e.name),t(t=>t.filter(t=>t.id!==e.id)),Q({title:`Success`,description:`Workspace '${e.label||e.name}' has been destroyed.`})}catch(e){let t=e instanceof Error?e.message:`Failed to destroy workspace`;Q({title:`Error`,description:t,variant:`destructive`})}},Ie=async e=>{try{let n=await E(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),Q({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`}Q({title:`Error`,description:t,variant:`destructive`})}},Le=async e=>{try{let n=await C(e);t(e=>e.map(e=>e.id===n.id?{...e,...n}:e)),Q({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`}Q({title:`Error`,description:t,variant:`destructive`})}},Re=e=>{ke(ie(e))},{rowProps:ze,handleProps:Be,draggingIndex:Ve,insertLineClass:He}=ce((n,r)=>{let i=le(e,n,r);t(i),ae(i,(e,t)=>T(G(e),{order:t})).then(({failed:e})=>{window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),e&&Q({title:`Partial reorder`,description:`${e} workspace(s) could not be reordered`,variant:`destructive`})})});return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsx)(fe,{title:`Workspaces`,description:`Divide your Universe into self-contained workspaces`,actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(h,{variant:`outline`,onClick:()=>se(e=>!e),className:`max-sm:hidden`,children:`Open shared Workspace (local)…`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>Y(e=>!e),children:`Import workspace`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>W(e=>!e),className:`max-sm:hidden`,children:`Import remote…`}),(0,J.jsx)(h,{variant:`outline`,onClick:()=>Oe(e=>!e),className:`max-sm:hidden`,children:`Open remote…`}),!I.local&&!L&&(0,J.jsxs)(h,{onClick:()=>B(!0),className:`max-sm:h-9 max-sm:w-9 max-sm:p-0`,"aria-label":`Create workspace`,title:`Create workspace`,children:[(0,J.jsx)(c,{className:`h-4 w-4 sm:mr-2`}),(0,J.jsx)(`span`,{className:`max-sm:hidden`,children:`Create Workspace`})]})]})}),!I.local&&L&&(0,J.jsx)(K,{title:`Create New Workspace`,onClose:()=>B(!1),children:(0,J.jsxs)(`form`,{onSubmit:Me,className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(g,{value:u,onChange:e=>d(e.target.value),placeholder:`Workspace Name (e.g., 'my-project')`,disabled:P}),(0,J.jsx)(g,{value:S,onChange:e=>D(e.target.value),placeholder:`Workspace Label (display name, optional)`,disabled:P})]}),(0,J.jsx)(g,{value:f,onChange:e=>p(e.target.value),placeholder:`Description (optional)`,disabled:P}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`label`,{htmlFor:`workspace-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,J.jsx)(`button`,{type:`button`,title:`Pick icon & color`,disabled:P,onClick:e=>j({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,J.jsx)(r,{icon:y||`ph:stack-fill`,width:22,height:22,color:R(m)})}),(0,J.jsx)(g,{id:`workspace-color`,type:`color`,value:m,onChange:e=>_(e.target.value),className:`h-10 w-16 p-1`,disabled:P}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(z()),disabled:P,children:`Randomize`})]}),A&&(0,J.jsx)(de,{x:A.x,y:A.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:()=>j(null)}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,J.jsx)(`p`,{className:`text-sm font-medium`,children:`Folder structure`}),(0,J.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,J.jsx)(Se,{value:k,onChange:ee,disabled:P,idPrefix:`create-workspace-layout`})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border p-3`,children:[(0,J.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Default folders `,(0,J.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:`(optional)`})]}),(0,J.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,J.jsx)(ye,{selected:H.selected,onToggle:H.toggle,tree:H.tree,onTreeChange:H.setTree,disabled:P,idPrefix:`create-default-folders`})]}),(0,J.jsxs)(h,{type:`submit`,disabled:P||!u.trim(),children:[(0,J.jsx)(c,{className:`mr-2 h-4 w-4`}),`Create Workspace`]})]})}),oe&&(0,J.jsx)(Ee,{}),we&&(0,J.jsx)(De,{onClose:()=>Oe(!1),onChanged:async()=>{try{t(V(await w()))}catch{}window.dispatchEvent(new CustomEvent(`workspaces:refresh`))}}),ve&&(0,J.jsx)(K,{title:`Import workspace`,onClose:()=>Y(!1),children:(0,J.jsx)(be,{onImported:()=>Y(!1)})}),U&&(0,J.jsx)(Te,{onImported:e=>{t(t=>t.some(t=>t.id===e.id)?t:[...t,e]),window.dispatchEvent(new CustomEvent(`workspaces:refresh`)),W(!1)},onClose:()=>W(!1)}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Your Workspaces`}),n&&(0,J.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`Loading workspaces...`}),s&&(0,J.jsx)(`div`,{className:`text-center text-destructive`,children:(0,J.jsx)(`p`,{children:s})}),!n&&!s&&e.length===0&&(0,J.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No workspaces found`}),e.length>0&&(0,J.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=R(t.color);return(0,J.jsxs)(`div`,{...ze(n),className:`flex items-stretch rounded-lg ${He(n,e.length)||``} ${Ve===n?`opacity-60`:``}`,children:[(0,J.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,J.jsx)(o,{className:`h-4 w-4 ${ne(i)}`})}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(xe,{workspace:r,onStart:Ie,onStop:Le,onEnter:Re,onEdit:Pe,onSettings:e=>{Ae?je(`workspaces`,`settings`,G(e)):ke(`/workspaces/${G(e)}/settings/general`)},onDestroy:Fe})})]},t.id)})})]}),X&&(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`h2`,{className:`text-xl font-semibold`,children:[`Edit Workspace: `,X.label]}),(0,J.jsxs)(`form`,{onSubmit:Ne,className:`space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-label`,className:`text-sm font-medium`,children:`Label`}),(0,J.jsx)(g,{id:`edit-label`,value:X.label,onChange:e=>Z(t=>t?{...t,label:e.target.value}:null),placeholder:`Workspace Label`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-description`,className:`text-sm font-medium`,children:`Description`}),(0,J.jsx)(g,{id:`edit-description`,value:X.description||``,onChange:e=>Z(t=>t?{...t,description:e.target.value}:null),placeholder:`Description (optional)`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{htmlFor:`edit-color`,className:`text-sm font-medium`,children:`Icon & Color`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,title:`Pick icon & color`,onClick:e=>N({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,J.jsx)(r,{icon:X.icon||`ph:stack-fill`,width:22,height:22,color:R(X.color)})}),(0,J.jsx)(g,{id:`edit-workspace-color`,type:`color`,value:X.color||`#FFFFFF`,onChange:e=>Z(t=>t?{...t,color:e.target.value}:null),className:`h-10 w-16 p-1`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>Z(e=>e?{...e,color:z()}:null),children:`Randomize Color`})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(h,{type:`submit`,disabled:!X.label?.trim(),children:`Save Changes`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>Z(null),children:`Cancel`})]})]}),M&&(0,J.jsx)(de,{x:M.x,y:M.y,current:{icon:X.icon??void 0,color:X.color??void 0},onChange:e=>{Z(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:()=>N(null)})]})]})}function Te({onImported:e,onClose:t}){let{showToast:n}=v(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``);return(0,J.jsx)(K,{title:`Import (pull) a remote Workspace`,onClose:t,children:(0,J.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let i;try{i=new URL(r.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}if(!a.trim().startsWith(`canvas-`)){n({title:`Error`,description:`Invalid access token (expected canvas-...)`,variant:`destructive`});return}f(!0),m(`Starting…`);try{let t=await x(i,a.trim(),e=>{m(D[e.phase]||e.phase)},{name:s.trim(),label:l.trim()});n({title:`Success`,description:`Workspace '${t.label||t.name}' imported from ${i}.`}),e(t)}catch(e){let t=e,r=t?.message||t?.payload?.message||`Failed to import remote workspace`;n({title:`Error`,description:r,variant:`destructive`})}finally{f(!1),m(``)}},className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:r,onChange:e=>i(e.target.value),disabled:d}),(0,J.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:a,onChange:e=>o(e.target.value),disabled:d}),(0,J.jsx)(h,{type:`submit`,disabled:d||!r.trim()||!a.trim()||!s.trim()||!l.trim(),children:d?`Importing…`:`Import Workspace`})]}),(0,J.jsx)(ve,{name:s,label:l,setName:c,setLabel:u,disabled:d}),d&&p&&(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Pulls a full `,(0,J.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 Ee(){let{showToast:e}=v(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(!1),s=e=>{try{return new URL(e)}catch{return null}};return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold`,children:`Open shared Workspace (local)`}),(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Shared URL (e.g., https://host/rest/v2/pub/workspaces/ID)`,value:t,onChange:e=>n(e.target.value)}),(0,J.jsx)(g,{placeholder:`Access token (canvas-...)`,value:r,onChange:e=>i(e.target.value)}),(0,J.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,J.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 De({onClose:e,onChanged:t}){let{showToast:n}=v(),r=i(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)([]),p=(0,q.useCallback)(async()=>{try{f(await k())}catch{f([])}},[]);(0,q.useEffect)(()=>{p()},[p]);let m=async e=>{e.preventDefault();let r;try{r=new URL(a.trim()).origin}catch{n({title:`Error`,description:`Invalid server URL`,variant:`destructive`});return}u(!0);try{let e=await S(r,s.trim());n({title:`Remote workspace added`,description:`'${e.label}' is available as ${e.address}.`}),o(``),c(``),await p(),t?.()}catch(e){let t=e;n({title:`Error`,description:t?.message||t?.payload?.message||`Failed to add remote workspace`,variant:`destructive`})}finally{u(!1)}},_=async e=>{try{await y(e.id),await p(),t?.()}catch(e){n({title:`Error`,description:e instanceof Error?e.message:`Failed to remove remote workspace`,variant:`destructive`})}};return(0,J.jsxs)(K,{title:`Open a remote Workspace`,onClose:e,children:[(0,J.jsxs)(`form`,{onSubmit:m,className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:[(0,J.jsx)(g,{placeholder:`Server URL (e.g., https://my.canvas-server.tld)`,value:a,onChange:e=>o(e.target.value),disabled:l}),(0,J.jsx)(g,{placeholder:`Workspace share token (canvas-...)`,value:s,onChange:e=>c(e.target.value),disabled:l}),(0,J.jsx)(h,{type:`submit`,disabled:l||!a.trim()||!s.trim(),children:l?`Checking…`:`Add Remote`})]}),(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Keeps the workspace on its own server and registers it here as`,` `,(0,J.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,J.jsx)(`ul`,{className:`mt-4 space-y-2 border-t pt-3`,children:d.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-col gap-2 rounded-md border p-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`truncate text-sm font-medium`,children:[e.label,(0,J.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,J.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground`,children:[e.address,` · `,e.remote.url]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(`/workspaces/${e.address}`),children:`Open`}),(0,J.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>_(e),className:`text-destructive hover:text-destructive`,children:`Remove`})]})]},e.id))})]})}export{we as default};
|
package/dist/index.html
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
})()
|
|
48
48
|
</script>
|
|
49
|
-
<script type="module" crossorigin src="/assets/index-
|
|
49
|
+
<script type="module" crossorigin src="/assets/index-DDoPhET6.js"></script>
|
|
50
50
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-C0FnF6B9.js">
|
|
51
51
|
<link rel="modulepreload" crossorigin href="/assets/code-editor-BOIngd5F.js">
|
|
52
52
|
<link rel="modulepreload" crossorigin href="/assets/react-BHzhHVTZ.js">
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
<link rel="modulepreload" crossorigin href="/assets/url-params-n7kU_WZ-.js">
|
|
112
112
|
<link rel="modulepreload" crossorigin href="/assets/use-canvas-pins-Bhd7_wde.js">
|
|
113
113
|
<link rel="modulepreload" crossorigin href="/assets/use-menu-DIP1zh7I.js">
|
|
114
|
-
<link rel="modulepreload" crossorigin href="/assets/registry-
|
|
114
|
+
<link rel="modulepreload" crossorigin href="/assets/registry-fC-KNk2X.js">
|
|
115
115
|
<link rel="modulepreload" crossorigin href="/assets/use-applet-target-BygCSj5n.js">
|
|
116
116
|
<link rel="modulepreload" crossorigin href="/assets/last-path-BbXWC3b3.js">
|
|
117
117
|
<link rel="modulepreload" crossorigin href="/assets/workspace-area-menu-B-bXURzn.js">
|