dorkos 0.93.0 → 0.95.0
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/README.md +1 -1
- package/dist/bin/cli.js +4450 -2445
- package/dist/client/assets/{AboutPage-R35A-Uu-.js → AboutPage-CG2AYFFf.js} +1 -1
- package/dist/client/assets/{AdapterIcon-kPDXiFU1.js → AdapterIcon-CBMQLe9z.js} +1 -1
- package/dist/client/assets/{AppearancePage-COqDtruX.js → AppearancePage-DspUlsTR.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CIKvkn5X.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-huqqF6pu.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-4FX_eaSh.js → BlintzCanvas-C6RZ2Ma8.js} +34 -34
- package/dist/client/assets/{CanvasCsvContent-Dq2X1kUl.js → CanvasCsvContent-B_2SiitK.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-CZUc62IR.js → CanvasFileContent-CzQ4p-Et.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-D1IN_nl9.js → CanvasModel3dContent-ClJWuggg.js} +2 -2
- package/dist/client/assets/{CodeMirrorDiff-BeEhMSvL.js → CodeMirrorDiff-CCPfe0EW.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-BlNLMvbo.js → CodeMirrorEditor-DPx3FVLK.js} +1 -1
- package/dist/client/assets/{ConnectionAccessLists-s7RnRr1y.js → ConnectionAccessLists-ZIjMb4KK.js} +1 -1
- package/dist/client/assets/{ConnectionsPage-BTTdQBdS.js → ConnectionsPage-BjJkzoDN.js} +3 -3
- package/dist/client/assets/{ConventionPage-CI3PeUHm.js → ConventionPage-D5vfTKHe.js} +1 -1
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-D6OvDT9K.js → FloatingTanStackRouterDevtools-CqogiFob-DNaod9If.js} +1 -1
- package/dist/client/assets/HandlePage-C57WT1ZF.js +1 -0
- package/dist/client/assets/{LexicalField-Bqq5KeUW.js → LexicalField-rxowXJdq.js} +1 -1
- package/dist/client/assets/{ManagesPage-CWdKDvw1.js → ManagesPage-0BFekgi1.js} +1 -1
- package/dist/client/assets/{Model3dViewer-ClJVGLDb.js → Model3dViewer-Czy1kuZW.js} +1 -1
- package/dist/client/assets/NamePage-C-fa4chy.js +1 -0
- package/dist/client/assets/{NotificationsPage-C6tE8iuE.js → NotificationsPage-zXNdi5ED.js} +1 -1
- package/dist/client/assets/{PermissionsPage-BqDl7shN.js → PermissionsPage-BaU8pkuw.js} +1 -1
- package/dist/client/assets/{PersonalityPopover-B3q8QYcS.js → PersonalityPopover-8KiTZkS5.js} +1 -1
- package/dist/client/assets/PhotoPage-DBNYhKBY.js +1 -0
- package/dist/client/assets/{RoomsPage-DwYtOhd7.js → RoomsPage-DAJz2lm6.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-BDPs-RYB.js → RunsOnPopover-6Paa4ED-.js} +1 -1
- package/dist/client/assets/{SessionsPage-Du24E934.js → SessionsPage-CBPMrutR.js} +2 -2
- package/dist/client/assets/{SkillsPage-DjLUEngt.js → SkillsPage-C5EjuSO4.js} +1 -1
- package/dist/client/assets/{TasksPage-B6i3r76o.js → TasksPage-B-v9Yfni.js} +1 -1
- package/dist/client/assets/{ToolsPage-DNoC2MMz.js → ToolsPage-DW-wnHEF.js} +2 -2
- package/dist/client/assets/{TopologyGraph-DtBDaHqX.js → TopologyGraph-BvrMJGBi.js} +17 -17
- package/dist/client/assets/{agent-browser-da9rKrej.js → agent-browser-CNWjB1KM.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-DJ5Xz8gv.js → highlighted-body-KPVGNVTW-CUHC5uD6.js} +1 -1
- package/dist/client/assets/{index-BzDP7VXZ.js → index-2SYRmZS_.js} +1 -1
- package/dist/client/assets/{index-Cvzimc0W.js → index-5pfHZhLE.js} +1 -1
- package/dist/client/assets/{index-DwfaFQZo.js → index-BDKfVboN.js} +1 -1
- package/dist/client/assets/{index-LcH-4hgH.js → index-BMFF169T.js} +1 -1
- package/dist/client/assets/{index-BVpHI-1y.js → index-BNDk_Yg-.js} +1 -1
- package/dist/client/assets/{index-DnN4PJaN.js → index-BOdZFetD.js} +1 -1
- package/dist/client/assets/{index-DsH33VjO.js → index-BRHzCdcO.js} +5 -5
- package/dist/client/assets/{index-CJK5Iw50.js → index-BU22tQ_6.js} +1 -1
- package/dist/client/assets/{index-Ca5JlBEc.js → index-Ba27lo1n.js} +1 -1
- package/dist/client/assets/{index-DdsOOmtz.js → index-BdIkR2G_.js} +1 -1
- package/dist/client/assets/{index-C9wgMNj5.js → index-BeRPIaN9.js} +8 -8
- package/dist/client/assets/{index-D1kH8Sr2.js → index-Bf3Hi1vd.js} +2 -2
- package/dist/client/assets/{index-Bp2CiCey.js → index-BorGy4Yi.js} +1 -1
- package/dist/client/assets/{index-CObinYlG.js → index-C1aaKV3U.js} +1 -1
- package/dist/client/assets/{index-DJGEk3-H.js → index-C6TgT2cV.js} +1 -1
- package/dist/client/assets/{index-CZ0BaV1t.js → index-CHcxc12T.js} +1 -1
- package/dist/client/assets/{index-CfUAagLY.js → index-CJ-SARTZ.js} +1 -1
- package/dist/client/assets/{index-CotYqF0w.js → index-CNQ9sgQn.js} +1 -1
- package/dist/client/assets/{index-1o6WO7iZ.js → index-CZuM2Qxl.js} +1 -1
- package/dist/client/assets/{index-Bl2j_xjE.js → index-CaBuRXmp.js} +1 -1
- package/dist/client/assets/{index-BQ-o6bQ0.js → index-CbrQOJ-r.js} +1 -1
- package/dist/client/assets/{index-Bu16-jWo.js → index-ChgU0Tq5.js} +1 -1
- package/dist/client/assets/{index-BnORUrPC.js → index-Ciylp2I7.js} +1 -1
- package/dist/client/assets/{index-B5yJddXH.js → index-DH0nOUQX.js} +1 -1
- package/dist/client/assets/{index-D0sn-ct6.js → index-DNl876ao.js} +1 -1
- package/dist/client/assets/{index-Dyeo69l2.js → index-DaIYCr-9.js} +1 -1
- package/dist/client/assets/{index-gIAwAMkn.js → index-DcdVwTgX.js} +1 -1
- package/dist/client/assets/{index-gHd4-GL-.js → index-DgrlhG9H.js} +1 -1
- package/dist/client/assets/index-DleaJjK-.js +1668 -0
- package/dist/client/assets/{index-3DE2Q3OD.js → index-DpnE5nll.js} +1 -1
- package/dist/client/assets/{index-CQXxVt4A.js → index-DyDsd7_9.js} +1 -1
- package/dist/client/assets/{index-CtJTMcuR.js → index-DzZSPXzN.js} +1 -1
- package/dist/client/assets/{index-DQWAoAN-.js → index-J5dXaon7.js} +1 -1
- package/dist/client/assets/index-XdysNkCU.css +1 -0
- package/dist/client/assets/{index-FsBhOkNr.js → index-iw7zEfsj.js} +1 -1
- package/dist/client/assets/{index-BC9LsNlJ.js → index-lnHJkPRg.js} +1 -1
- package/dist/client/assets/{index-CtlzkOJ3.js → index-m4dRQao_.js} +8 -8
- package/dist/client/assets/{room-files-source-DRQNpCWs.js → room-files-source-JVU1fIeW.js} +3 -3
- package/dist/client/assets/{soul-file-DcQD5pcS.js → soul-file-BQhkHCzH.js} +1 -1
- package/dist/client/assets/{use-personality-commit-Dsy9tqWY.js → use-personality-commit-CC3Q_bi4.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/drizzle/0136_mirror_timeline_order.sql +23 -0
- package/dist/drizzle/meta/0136_snapshot.json +10232 -0
- package/dist/drizzle/meta/_journal.json +8 -1
- package/dist/server/index.js +8416 -5337
- package/dist/server/index.js.map +2 -2
- package/package.json +11 -11
- package/dist/client/assets/HandlePage-Dvqztr0N.js +0 -1
- package/dist/client/assets/NamePage-BgVZ-KD1.js +0 -1
- package/dist/client/assets/PhotoPage-lt6ZevHW.js +0 -1
- package/dist/client/assets/index-BCGiD7pg.js +0 -1674
- package/dist/client/assets/index-BG-HtbEP.css +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{dT as Se,gi as Me,af as ne,r as a,gj as Ie,gk as Q,gl as G,gm as K,d_ as ie,gn as Ce,cS as J,go as ee,dj as it,gp as lt,bm as ct,gq as dt,aj as oe,gr as ut,gs as ft,eT as ht,gt as pt,ag as Te,gu as mt,j as t,aF as Fe,am as Ke,cW as xt,C as He,gv as gt,dB as be,gw as yt,fR as Ue,fW as vt,al as Oe,gx as qe,gy as Qe,gz as Ct,f3 as bt,f4 as wt,f5 as kt,f6 as Z,f7 as ue,dQ as jt,eh as fe,ei as he,ej as pe,ek as me,el as xe,em as ge,en as ye,eo as ve,B as Y,aG as Et,gA as Ae,g0 as Dt,gB as Rt,ai as ce,gC as Be,gD as We,d4 as Nt,gE as St,gF as Tt,gG as Ft,gH as Ot,e5 as De,gI as Ye,dh as Pt,dU as Mt,cU as At,gJ as _t,gK as Lt,g5 as zt,gL as $t,dW as It,dX as Kt,dY as Ht,dZ as Ut,d$ as qt,e0 as Qt,I as Bt,e1 as Wt}from"./index-
|
|
2
|
-
* @license lucide-react v1.
|
|
1
|
+
import{dT as Se,gi as Me,af as ne,r as a,gj as Ie,gk as Q,gl as G,gm as K,d_ as ie,gn as Ce,cS as J,go as ee,dj as it,gp as lt,bm as ct,gq as dt,aj as oe,gr as ut,gs as ft,eT as ht,gt as pt,ag as Te,gu as mt,j as t,aF as Fe,am as Ke,cW as xt,C as He,gv as gt,dB as be,gw as yt,fR as Ue,fW as vt,al as Oe,gx as qe,gy as Qe,gz as Ct,f3 as bt,f4 as wt,f5 as kt,f6 as Z,f7 as ue,dQ as jt,eh as fe,ei as he,ej as pe,ek as me,el as xe,em as ge,en as ye,eo as ve,B as Y,aG as Et,gA as Ae,g0 as Dt,gB as Rt,ai as ce,gC as Be,gD as We,d4 as Nt,gE as St,gF as Tt,gG as Ft,gH as Ot,e5 as De,gI as Ye,dh as Pt,dU as Mt,cU as At,gJ as _t,gK as Lt,g5 as zt,gL as $t,dW as It,dX as Kt,dY as Ht,dZ as Ut,d$ as qt,e0 as Qt,I as Bt,e1 as Wt}from"./index-DleaJjK-.js";import{t as ae,g as Yt,C as Gt,n as Ge,r as Ve,a as Vt,p as Xt,F as Zt,w as Jt,c as Xe,b as en}from"./room-files-source-JVU1fIeW.js";import{N as Qn,R as Bn}from"./room-files-source-JVU1fIeW.js";/**
|
|
2
|
+
* @license lucide-react v1.48.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/const Ze={name:"corner-left-up",size:24,node:[["path",{d:"M14 9 9 4 4 9",key:"1af5af"}],["path",{d:"M20 20h-7a4 4 0 0 1-4-4V4",key:"1blwi3"}]]};Ze.node;const tn=Se(Ze);/**
|
|
7
|
-
* @license lucide-react v1.
|
|
7
|
+
* @license lucide-react v1.48.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const Je={name:"file-plus",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};Je.node;const et=Se(Je);/**
|
|
12
|
-
* @license lucide-react v1.
|
|
12
|
+
* @license lucide-react v1.48.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const tt={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};tt.node;const nn=Se(tt);function le(e,n,s){return["file-explorer","tree",e.scopeKey,n,e.filtersHidden?s:null]}function ke(e,n,s,m){return{queryKey:le(e,n,s),queryFn:()=>e.list(n,{showHidden:s}),staleTime:Me.FILE_TREE_STALE_TIME_MS,gcTime:Me.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(le(e,n,!s))}}const sn=[".git",".dork",".claude",".agents","node_modules"];function an(e){return e.startsWith(".")||sn.includes(e)}const Re=["ROOM.md","README.md"];function Ne(e){return Re.some(n=>n.toLowerCase()===e.toLowerCase())}function nt(e){return e.filter(n=>!an(n.name))}function rn(e){if(e.reduce((p,i)=>i.type==="file"&&Ne(i.name)?p+1:p,0)===0)return e;const s=[],m=[];for(const p of e)p.type==="file"&&Ne(p.name)?s.push(p):m.push(p);return s.sort((p,i)=>Re.findIndex(o=>o.toLowerCase()===p.name.toLowerCase())-Re.findIndex(o=>o.toLowerCase()===i.name.toLowerCase())),[...s,...m]}const on=/ copy(?: \d+)?$/;function Pe({name:e,isDir:n,taken:s}){const m=new Set(s);if(!m.has(e))return e;const p=n?-1:e.lastIndexOf("."),i=p>0,o=i?e.slice(p):"",g=(i?e.slice(0,p):e).replace(on,"");for(let r=1;;r+=1){const d=r===1?`${g} copy${o}`:`${g} copy ${r}${o}`;if(!m.has(d))return d}}function _e(e,n,s){return{name:n,path:e,type:s,size:0,mtime:Date.now(),isSymlink:!1}}function ln(e){const n=ne(),{source:s,showHidden:m,queryClient:p,inFlightRef:i}=e,o=s.cwd??"",[g,r]=a.useState(null),d=a.useCallback(async h=>{i.current+=1;try{return await h()}finally{i.current-=1}},[i]),c=a.useMemo(()=>{const h=x=>le(s,x,m);return{getChildren:x=>{var j;return((j=p.getQueryData(h(x)))==null?void 0:j.entries)??[]},isLoaded:x=>p.getQueryData(h(x))!==void 0,takenNames:async x=>(await n.readFileTree(o,{path:x===Q?void 0:x,showHidden:!0})).entries.map(C=>C.name),snapshot:x=>p.getQueryData(h(x)),setChildren:(x,j)=>{p.setQueryData(h(x),C=>({entries:Ie(j((C==null?void 0:C.entries)??[]))}))},restore:(x,j)=>{p.setQueryData(h(x),j)},invalidate:x=>{p.invalidateQueries({queryKey:h(x),exact:!0})}}},[p,n,o,s,m]),D=a.useCallback((h,x,j)=>d(async()=>{const C=ee(h,x),S=!c.getChildren(h).some(_=>_.path===C),I=c.snapshot(h);S&&c.setChildren(h,_=>[..._,_e(C,x,j)]);try{return await n.createEntry(o,C,j),!0}catch(_){return S&&c.restore(h,I),ae(_,`Couldn’t create ${j==="dir"?"folder":"file"}`),!1}finally{c.invalidate(h)}}),[n,o,c,d]),M=a.useCallback((h,x)=>d(async()=>{if(x===h.name||x.length===0)return!0;const j=G(h.path),C=ee(j,x),S=c.getChildren(j).some(A=>A.path===C),I=c.snapshot(j),_={...h,name:x,path:C};S||c.setChildren(j,A=>A.map(z=>z.path===h.path?_:z));try{return await n.renameEntry(o,h.path,C),K.getState().remapExpandedPaths(h.path,C),!0}catch(A){return S||c.restore(j,I),ae(A,"Couldn’t rename"),!1}finally{c.invalidate(j)}}),[n,o,c,d]),R=a.useCallback(h=>d(async()=>{const x=G(h.path),j=c.snapshot(x);c.setChildren(x,C=>C.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path,{recursive:!0}),K.getState().dropExpandedPaths(h.path)}catch(C){c.restore(x,j),ae(C,"Couldn’t delete")}finally{c.invalidate(x)}}),[n,o,c,d]),q=a.useCallback(h=>d(async()=>{const x=G(h.path);if(h.type==="file"){const j=c.snapshot(x);c.setChildren(x,C=>C.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path),K.getState().dropExpandedPaths(h.path)}catch(C){c.restore(x,j),ae(C,"Couldn’t delete")}finally{c.invalidate(x)}return}try{await n.deleteEntry(o,h.path),c.setChildren(x,j=>j.filter(C=>C.path!==h.path)),K.getState().dropExpandedPaths(h.path),c.invalidate(x)}catch(j){if(Yt(j)==="DIR_NOT_EMPTY"){r(h);return}ae(j,"Couldn’t delete")}}),[n,o,c,d]),b=a.useCallback(async()=>{const h=g;r(null),h&&await R(h)},[g,R]),H=a.useCallback(()=>r(null),[]),$=a.useCallback((h,x)=>d(async()=>{const j=G(h),C=ie(h),S=ee(x,C);if(x===j||S===h||Ce(x,h))return;const I=c.getChildren(j).find(v=>v.path===h);if(!I)return;const _=c.isLoaded(x),A=_&&c.getChildren(x).some(v=>v.path===S),z={...I,name:C,path:S},W=c.snapshot(j),F=_?c.snapshot(x):void 0;c.setChildren(j,v=>v.filter(L=>L.path!==h)),_&&!A&&c.setChildren(x,v=>[...v,z]);try{await n.renameEntry(o,h,S),K.getState().remapExpandedPaths(h,S)}catch(v){c.restore(j,W),_&&!A&&c.restore(x,F),ae(v,"Couldn’t move")}finally{c.invalidate(j),_&&c.invalidate(x)}}),[n,o,c,d]),k=a.useCallback((h,x)=>d(async()=>{if(h.isDir&&Ce(x,h.path)){J.error(Gt);return}let j;try{j=await c.takenNames(x)}catch(A){ae(A,"Couldn’t copy");return}const C=Pe({name:ie(h.path),isDir:h.isDir,taken:j}),S=ee(x,C),I=c.isLoaded(x),_=I?c.snapshot(x):void 0;if(I){const A=c.getChildren(G(h.path)).find(W=>W.path===h.path),z=A?{...A,name:C,path:S}:_e(S,C,h.isDir?"dir":"file");c.setChildren(x,W=>[...W,z])}try{await n.copyEntry(o,h.path,S)}catch(A){I&&c.restore(x,_),ae(A,"Couldn’t copy")}finally{c.invalidate(x)}}),[n,o,c,d]);return{createEntry:D,renameEntry:M,removeEntry:q,moveEntry:$,copyEntry:k,pendingRecursiveDelete:g,confirmRecursiveDelete:b,cancelRecursiveDelete:H}}function cn(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function dn(e,n){const s=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=s?n.split("/").join("\\"):n;return`${m}${s?"\\":"/"}${p}`}function un(e){const n=ne(),{data:s}=it(),m=a.useMemo(()=>n.supportsReveal?cn(s==null?void 0:s.platform):null,[n.supportsReveal,s==null?void 0:s.platform]),p=a.useCallback(async d=>{if(e)try{await n.revealEntry(e,d.path)}catch(c){ae(c,"Couldn’t open the file manager")}},[n,e]),{copy:i}=lt(),o=a.useCallback(async(d,c)=>{const D=c==="absolute"&&e?dn(e,d.path):d.path;await i(D)||J.error("Couldn’t copy to the clipboard")},[e,i]),g=a.useCallback(d=>{ct(dt(d.path))||J.error("Open a chat first to add a file to it")},[]),r=a.useCallback(d=>{K.getState().setClipboard({path:d.path,isDir:d.type==="dir"});try{navigator.clipboard.writeText(d.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:o,addToChat:g,copyToClipboard:r}}const fn=1e3;function hn(e){const{source:n,showHidden:s,queryClient:m,inFlightRef:p}=e,i=n.changes,[o,g]=a.useState(null),[r,d]=a.useState(null),[c,D]=a.useState(null),[M,R]=a.useState(0),q=a.useCallback(async u=>{p.current+=1,R(f=>f+1);try{return await u()}finally{p.current-=1,R(f=>f-1)}},[p]),b=a.useMemo(()=>{const u=f=>le(n,f,s);return{listing:f=>m.getQueryData(u(f)),isLoaded:f=>m.getQueryData(u(f))!==void 0,entries:f=>{var T;return((T=m.getQueryData(u(f)))==null?void 0:T.entries)??[]},setEntries:(f,T)=>m.setQueryData(u(f),y=>({...y,entries:Ie(T((y==null?void 0:y.entries)??[]))})),restore:(f,T)=>m.setQueryData(u(f),T),fetch:f=>n.list(f,{showHidden:!0}),refreshAll:()=>{m.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),m.invalidateQueries({queryKey:["file-explorer","preview",n.scopeKey]})}}},[m,n,s]),H=a.useCallback(async u=>{const f=b.listing(u);return(f==null?void 0:f.commit)!==void 0?f.commit:(await b.fetch(u)).commit??null},[b]),$=a.useCallback((u,f,T,y)=>{switch(u.status){case"changed":return!0;case"conflict":return D({kind:f,path:u.path,lastCommit:u.lastCommit,retry:()=>T(u.commit)}),!1;case"exists":return J.error(y===void 0?u.reason:Ge(y)),!1;case"refused":return J.error(u.reason),!1}},[]),k=a.useCallback((u,f)=>{J.error(Ve(u)??f)},[]),h=a.useCallback((u,f,T)=>{const y=O=>q(async()=>{if(i===void 0)return!1;const E=G(u.path),N=G(f),w=ie(f),U=b.isLoaded(N),te=U&&b.entries(N).some(X=>X.path===f),V=b.listing(E),de=N===E?void 0:b.listing(N),l={...u,name:w,path:f};te||(N===E?b.setEntries(E,X=>X.map(se=>se.path===u.path?l:se)):(b.setEntries(E,X=>X.filter(se=>se.path!==u.path)),U&&b.setEntries(N,X=>[...X,l])));const P=()=>{b.restore(E,V),N!==E&&U&&b.restore(N,de)};try{const X=O??await H(E);if(X===null)return P(),J.error("There’s nothing in this room’s files to change yet."),!1;const se=await i.move({from:u.path,to:f,baseCommit:X}),je=$(se,T,async re=>{await y(re)},w);return je?K.getState().remapExpandedPaths(u.path,f):P(),je}catch(X){return P(),k(X,T==="rename"?"Couldn’t rename":"Couldn’t move"),!1}finally{b.refreshAll()}});return y(null)},[i,b,q,H,$,k]),x=a.useCallback(async(u,f)=>f===u.name||f.length===0?!0:h(u,ee(G(u.path),f),"rename"),[h]),j=a.useCallback(async(u,f)=>{const T=G(u),y=ee(f,ie(u));if(f===T||y===u||Ce(f,u))return;const O=b.entries(T).find(E=>E.path===u);O&&await h(O,y,"move")},[b,h]),C=a.useCallback(async u=>{let f=0;const T=[u];for(;T.length>0;){const y=T.shift(),O=await b.fetch(y);for(const E of O.entries)if(E.type==="dir"?T.push(E.path):f+=1,f>=fn)return{count:f,moreThan:!0}}return{count:f,moreThan:!1}},[b]),S=a.useCallback(u=>{if(u.type!=="dir"){g({entry:u,fileCount:1,moreThan:!1});return}g({entry:u,fileCount:null,moreThan:!1}),C(u.path).then(({count:f,moreThan:T})=>g(y=>(y==null?void 0:y.entry.path)===u.path?{entry:u,fileCount:f,moreThan:T}:y),()=>{})},[C]),I=a.useCallback(u=>{const f=T=>q(async()=>{if(i===void 0)return;const y=G(u.path),O=b.listing(y);b.setEntries(y,E=>E.filter(N=>N.path!==u.path));try{const E=T??await H(y);if(E===null){b.restore(y,O);return}const N=await i.remove({path:u.path,baseCommit:E});$(N,"delete",U=>f(U))?K.getState().dropExpandedPaths(u.path):b.restore(y,O)}catch(E){b.restore(y,O),k(E,"Couldn’t delete")}finally{b.refreshAll()}});return f(null)},[i,b,q,H,$,k]),_=a.useCallback(async()=>{const u=o;g(null),u&&await I(u.entry)},[o,I]),A=a.useCallback(()=>g(null),[]),z=a.useCallback((u,f,T,y)=>{const O=E=>q(async()=>{if(i===void 0)return;const N=b.isLoaded(u),w=N?b.listing(u):void 0;if(N){const U=new Set(b.entries(u).map(V=>V.name)),te=f.filter(V=>!U.has(V.name)).map(V=>({name:V.name,path:ee(u,V.name),type:"file",size:V.size}));te.length>0&&b.setEntries(u,V=>[...V,...te])}try{const U=await i.upload({dir:u,baseCommit:E,replace:T,files:f});!$(U,"upload",V=>O(V))&&N&&b.restore(u,w)}catch(U){N&&b.restore(u,w),k(U,"Couldn’t upload")}finally{b.refreshAll()}});return O(y)},[i,b,q,$,k]),W=a.useCallback(async(u,f)=>{if(i===void 0||f.length===0)return;if(f.length>i.maxUploadFiles){J.error(`One upload can carry up to ${i.maxUploadFiles} files, so nothing was uploaded. Try again with fewer.`);return}let T;try{T=await b.fetch(u)}catch(w){k(w,"Couldn’t upload");return}const y=T.entries.map(w=>w.name),O=new Set(y),E=f.map(w=>w.name).filter(w=>O.has(w)),N=T.commit??null;if(E.length===0){await z(u,f,[],N);return}d({dir:u,files:f,names:E,taken:y,baseCommit:N})},[i,b,k,z]),F=a.useCallback(async u=>{const f=r;if(d(null),f===null)return;if(u==="replace"){await z(f.dir,f.files,f.names,f.baseCommit);return}const T=new Set([...f.taken,...f.files.map(E=>E.name)]),y=new Set(f.names),O=f.files.map(E=>{if(!y.has(E.name))return E;const N=Pe({name:E.name,isDir:!1,taken:T});return T.add(N),new File([E],N,{type:E.type,lastModified:E.lastModified})});await z(f.dir,O,[],f.baseCommit)},[r,z]),v=a.useCallback(()=>d(null),[]),L=a.useCallback(()=>D(null),[]),B=a.useMemo(()=>r===null?null:{dir:r.dir,names:r.names},[r]);return{renameEntry:x,moveEntry:j,requestDelete:S,pendingDelete:o,confirmDelete:_,cancelDelete:A,upload:W,pendingClash:B,resolveClash:F,cancelClash:v,conflict:c,dismissConflict:L,busy:M>0}}const Le={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function pn(e){var u,f,T;const n=ne(),s=oe(),{setTheme:m}=ut(),p=K(y=>y.showHidden),i=K(y=>y.expanded),o=K(y=>y.loadExplorerForCwd),g=K(y=>y.pruneMissing),r=(e==null?void 0:e.scopeKey)??null,d=(e==null?void 0:e.cwd)??null;a.useEffect(()=>{o(r)},[r,o]);const c=a.useMemo(()=>[Q,...ft(i)],[i]),D=ht({queries:e?c.map(y=>ke(e,y,p,s)):[]}),M=(e==null?void 0:e.filtersHidden)??!0,R=a.useMemo(()=>{const y={};return c.forEach((O,E)=>{var U;const N=D[E];let w=((U=N==null?void 0:N.data)==null?void 0:U.entries)??[];!p&&!M&&(w=nt(w)),O===Q&&(w=rn(w)),y[O]={entries:w,loading:(N==null?void 0:N.isLoading)??!1,error:(N==null?void 0:N.isError)??!1}}),y},[c,D,p,M]),q=a.useRef(0),b=a.useRef({});a.useEffect(()=>{q.current>0||c.forEach((y,O)=>{var N,w,U;const E=(w=(N=D[O])==null?void 0:N.data)==null?void 0:w.entries;!E||(U=D[O])!=null&&U.isError||b.current[y]!==E&&(b.current[y]=E,g(y,E.map(te=>te.name)))})},[c,D,g]);const H=a.useMemo(()=>pt(i,R),[i,R]),$=!!e&&!!((u=R[Q])!=null&&u.loading),k=!!e&&!!((f=R[Q])!=null&&f.error),h=(T=D[0])==null?void 0:T.error,x=k&&h?Vt(h):void 0,j=(x==null?void 0:x.message)??null,C=(x==null?void 0:x.command)??null,S=a.useMemo(()=>{var O;const y=new Set;for(const E of c)E!==Q&&((O=R[E])!=null&&O.error)&&y.add(E);return y},[c,R]),I=a.useCallback(y=>{if(y.type!=="dir")return;const O=K.getState();O.setDirExpanded(y.path,!O.expanded[y.path])},[]),_=a.useCallback(y=>{if(y===Q)return;const O=K.getState();O.expanded[y]||O.setDirExpanded(y,!0)},[]),A=(e==null?void 0:e.preview)==="canvas",z=a.useCallback(y=>{if(y.type!=="file"||!A)return;const O={getStore:Te.getState,setTheme:m,supportsTerminal:n.supportsTerminal};mt(O,{action:"open_file",sourcePath:y.path},"user")},[A,m,n]),W=a.useCallback(()=>{r!==null&&s.invalidateQueries({queryKey:["file-explorer","tree",r]})},[s,r]),F=a.useCallback(y=>{e!==null&&s.invalidateQueries({queryKey:le(e,y,p),exact:!0})},[s,e,p]);a.useEffect(()=>{if(e!=null&&e.events)return e.events(W)},[e,W]);const v=ln({source:e??Le,showHidden:p,queryClient:s,inFlightRef:q}),L=hn({source:e??Le,showHidden:p,queryClient:s,inFlightRef:q}),B=un(d);return{rows:H,rootLoading:$,rootError:k,rootErrorMessage:j,rootErrorCommand:C,errorPaths:S,toggleExpand:I,ensureExpanded:_,openFile:z,reload:W,retryDir:F,changes:e!=null&&e.changes?L:null,...v,...B}}function mn(e){const{transport:n,cwd:s}=e;return{scopeKey:s,cwd:s,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return n.readFileTree(s,{path:m===""?void 0:m,showHidden:p.showHidden})}}}function we(e){return Array.from(e).includes("Files")}function st(e){const n=Array.from(e.items??[]);if(!(n.length>0&&n.every(i=>"webkitGetAsEntry"in i)))return{files:Array.from(e.files??[]),folders:0};const m=[];let p=0;for(const i of n){if(i.kind!=="file")continue;const o=i.webkitGetAsEntry();if(o!=null&&o.isDirectory){p+=1;continue}const g=i.getAsFile();g&&m.push(g)}return{files:m,folders:p}}const xn=12;function gn({row:e,selected:n,renaming:s,error:m,onSelect:p,onActivate:i,onRetry:o,onSubmitRename:g,onCancelRename:r,onNewFile:d,onNewFolder:c,onStartRename:D,onDelete:M,onMove:R,onCopyInto:q,onCopy:b,onPaste:H,onDuplicate:$,canPasteInto:k,revealLabel:h,onReveal:x,onAddToChat:j,onCopyPath:C,readOnly:S=!1,provenance:I=!1,copyable:_=!0,onDisk:A=!0,onUpload:z,onPickUpload:W}){const{entry:F,depth:v,expanded:L,loading:B}=e,u=F.type==="dir",f=u?F.path:G(F.path),[T,y]=a.useState(!1),O=!u&&v===0&&Ne(F.name),E=Xt(F.lastCommit),N=t.jsxs("div",{role:"treeitem","aria-label":F.name,"aria-expanded":u?L:void 0,"aria-selected":n,tabIndex:-1,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),p(F),i(F))},draggable:!s&&!S,onDragStart:w=>{S||(w.dataTransfer.setData("text/plain",F.path),w.dataTransfer.setData(Ct,F.path),w.dataTransfer.effectAllowed="copyMove")},onDragOver:w=>{if(w.stopPropagation(),!S&&z&&we(w.dataTransfer.types)){w.preventDefault(),w.dataTransfer.dropEffect="copy",y(!0);return}S||!u||!Qe(w.dataTransfer.types)||(w.preventDefault(),w.dataTransfer.dropEffect=w.altKey&&_?"copy":"move",y(!0))},onDragLeave:()=>y(!1),onDrop:w=>{if(w.stopPropagation(),S)return;if(y(!1),z&&we(w.dataTransfer.types)){w.preventDefault();const{files:te}=st(w.dataTransfer);z(f,te);return}if(!u)return;const U=qe(w.dataTransfer);U!==null&&(w.preventDefault(),w.altKey&&_?q(U,F.path):R(U,F.path))},onClick:()=>{p(F),i(F)},className:Oe("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",n?"bg-accent text-foreground":"hover:bg-accent/50",T&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:v*xn+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:u&&(B?t.jsx(Fe,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:w=>{w.stopPropagation(),o()},className:"flex items-center justify-center",children:t.jsx(Ke,{className:"text-destructive size-3.5"})}):L?t.jsx(xt,{className:"text-muted-foreground size-3.5"}):t.jsx(He,{className:"text-muted-foreground size-3.5"}))}),u?L?t.jsx(gt,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):F.isSymlink===!0?t.jsx(yt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(Ue,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),s?t.jsx(yn,{initialName:F.name,onSubmit:w=>g(F,w),onCancel:r}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.name}),O&&!s&&t.jsx(vt,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),I&&!s&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:E.title??void 0,children:E.label})]});return S?N:t.jsxs(bt,{children:[t.jsx(wt,{asChild:!0,children:N}),t.jsxs(kt,{className:"w-52",children:[t.jsx(Z,{movesFocus:!0,onClick:()=>d(f),children:"New file"}),t.jsx(Z,{movesFocus:!0,onClick:()=>c(f),children:"New folder"}),W&&t.jsx(Z,{onClick:()=>W(f),children:"Upload files…"}),A&&t.jsxs(t.Fragment,{children:[t.jsx(ue,{}),h&&t.jsx(Z,{onClick:()=>x(F),children:h}),t.jsx(Z,{movesFocus:!0,onClick:()=>j(F),children:"Add to chat"})]}),_&&t.jsxs(t.Fragment,{children:[t.jsx(ue,{}),t.jsx(Z,{onClick:()=>b(F),children:"Copy"}),t.jsx(Z,{disabled:!k(f),onClick:()=>H(f),children:"Paste"}),t.jsx(Z,{onClick:()=>$(F),children:"Duplicate"})]}),t.jsx(ue,{}),A?t.jsxs(t.Fragment,{children:[t.jsx(Z,{onClick:()=>C(F,"absolute"),children:"Copy path"}),t.jsx(Z,{onClick:()=>C(F,"relative"),children:"Copy relative path"})]}):t.jsx(Z,{onClick:()=>C(F,"relative"),children:"Copy path"}),t.jsx(ue,{}),t.jsx(Z,{movesFocus:!0,onClick:()=>D(F),children:"Rename"}),t.jsx(Z,{variant:"destructive",onClick:()=>M(F),children:"Delete"})]})]})}function yn({initialName:e,onSubmit:n,onCancel:s}){const m=a.useRef(null),[p,i]=a.useState(e);a.useEffect(()=>{const g=m.current;if(!g)return;g.focus();const r=e.lastIndexOf(".");g.setSelectionRange(0,r>0?r:e.length)},[e]);const o=()=>{const g=p.trim();g&&g!==e?n(g):s()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:g=>i(g.target.value),onClick:g=>g.stopPropagation(),onBlur:o,onKeyDown:g=>{g.stopPropagation(),g.key==="Enter"?o():g.key==="Escape"&&s()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const vn=100,Cn=28,bn=250;function wn(e){const{rows:n,selectedPath:s,renamingPath:m,errorPaths:p,onSelectPath:i,onRetryDir:o}=e,g=a.useRef(null),r=K(v=>v.setScrollTop),d=K(v=>v.scopeKey),c=a.useCallback(v=>v.type==="dir"?e.onToggle(v):e.onOpen(v),[e]),D=jn(e,c),M=n.length>vn,R=jt({count:n.length,getScrollElement:()=>g.current,estimateSize:()=>Cn,overscan:12,enabled:M}),q=a.useRef({scope:void 0,done:!1}),b=a.useRef(null);a.useLayoutEffect(()=>{const v=q.current;if(v.scope!==d&&(v.scope=d,v.done=!1),v.done||n.length===0)return;const L=g.current;if(!L)return;const B=K.getState().scrollTop;if(B<=0){v.done=!0;return}M?R.scrollToOffset(B):L.scrollTop=B,b.current=L.scrollTop,L.scrollTop>=B&&(v.done=!0)},[n.length,d,M,R]);const H=a.useRef(null),$=a.useRef(null),k=a.useCallback(()=>{const v=g.current;v&&v.scrollTop!==b.current&&(q.current.done=!0,H.current=v.scrollTop,$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,H.current!==null&&r(H.current)},bn))},[r]);a.useEffect(()=>()=>{$.current&&clearTimeout($.current),H.current!==null&&r(H.current)},[r]);const h=a.useRef(void 0);a.useEffect(()=>{var u,f;const v=h.current;if(h.current=s,v===void 0||s===v||s===null)return;const L=n.findIndex(T=>T.entry.path===s);if(L<0)return;const B=g.current;B&&(M?R.scrollToIndex(L,{align:"auto"}):(f=(u=B.querySelector(`[data-row-index="${L}"]`))==null?void 0:u.scrollIntoView)==null||f.call(u,{block:"nearest"}),b.current=B.scrollTop)},[s,n,M,R]);const[x,j]=a.useState(!1),{onCopyInto:C,onMove:S}=e,I=e.readOnly===!0,_=e.copyable!==!1,A=a.useCallback(v=>{I||!Qe(v.dataTransfer.types)||(v.preventDefault(),v.dataTransfer.dropEffect=v.altKey&&_?"copy":"move",j(!0))},[I,_]),z=a.useCallback((v,L)=>{const B=n.find(u=>u.entry.path===v);B&&C({path:v,isDir:B.entry.type==="dir"},L)},[n,C]),W=a.useCallback(v=>{if(j(!1),I)return;const L=qe(v.dataTransfer);L!==null&&(v.preventDefault(),v.altKey&&_?z(L,Q):S(L,Q))},[z,S,I,_]),F=v=>t.jsx(gn,{row:v,selected:v.entry.path===s,renaming:v.entry.path===m,error:v.entry.type==="dir"&&v.expanded&&p.has(v.entry.path),onSelect:L=>i(L.path),onActivate:c,onRetry:()=>o(v.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:z,onCopy:e.onCopy,onPaste:e.onPaste,onDuplicate:e.onDuplicate,canPasteInto:e.canPasteInto,revealLabel:e.revealLabel,onReveal:e.onReveal,onAddToChat:e.onAddToChat,onCopyPath:e.onCopyPath,readOnly:e.readOnly,provenance:e.provenance,copyable:e.copyable,onDisk:e.onDisk,onUpload:e.onUpload,onPickUpload:e.onPickUpload});return t.jsx("div",{ref:g,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:D,onScroll:k,onDragOver:A,onDragLeave:()=>j(!1),onDrop:W,className:Oe("focus-visible:ring-ring/40 h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",x&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:M?t.jsx("div",{style:{height:R.getTotalSize()},className:"relative w-full",children:R.getVirtualItems().map(v=>t.jsx("div",{"data-row-index":v.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${v.start}px)`},children:F(n[v.index])},n[v.index].entry.path))}):n.map((v,L)=>t.jsx("div",{"data-row-index":L,children:F(v)},v.entry.path))})}function kn(e){return e?e.type==="dir"?e.path:G(e.path):Q}function jn(e,n){const{rows:s,selectedPath:m,renamingPath:p,onSelectPath:i}=e;return a.useCallback(o=>{var d,c,D,M;if(p!==null)return;const g=s.findIndex(R=>R.entry.path===m),r=g>=0?s[g]:void 0;if(o.metaKey||o.ctrlKey){if(e.readOnly===!0||e.copyable===!1)return;const R=o.key.toLowerCase();if(R==="c"&&r){o.preventDefault(),e.onCopy(r.entry);return}if(R==="v"){o.preventDefault(),e.onPaste(kn(r==null?void 0:r.entry));return}return}switch(o.key){case"ArrowDown":o.preventDefault(),i(((d=s[Math.min(g+1,s.length-1)])==null?void 0:d.entry.path)??((c=s[0])==null?void 0:c.entry.path));break;case"ArrowUp":o.preventDefault(),i(((D=s[Math.max(g-1,0)])==null?void 0:D.entry.path)??((M=s[0])==null?void 0:M.entry.path));break;case"ArrowRight":(r==null?void 0:r.entry.type)==="dir"&&!r.expanded&&(o.preventDefault(),e.onToggle(r.entry));break;case"ArrowLeft":if(!r)break;if(o.preventDefault(),r.entry.type==="dir"&&r.expanded)e.onToggle(r.entry);else{const R=G(r.entry.path);R&&i(R)}break;case"Enter":r&&(o.preventDefault(),n(r.entry));break;case"F2":r&&e.readOnly!==!0&&(o.preventDefault(),e.onStartRename(r.entry));break;case"Delete":case"Backspace":r&&e.readOnly!==!0&&(o.preventDefault(),e.onDelete(r.entry));break}},[s,m,p,i,e,n])}const En={rename:"Rename it anyway",move:"Move it anyway",delete:"Delete it anyway",upload:"Upload mine over it"},Dn={rename:"nothing was renamed",move:"nothing was moved",delete:"nothing was deleted",upload:"nothing was uploaded"};function Rn(e){const{entry:n,fileCount:s,moreThan:m}=e,p="The room’s history keeps a copy, so an agent or git can bring it back if you need it.";if(n.type!=="dir")return`“${n.name}” leaves the room’s files. ${p}`;const i=s===null?"everything in it":m?`the more than ${s.toLocaleString()} files in it`:s===1?"the 1 file in it":`the ${s.toLocaleString()} files in it`;return`“${n.name}” and ${i} leave the room’s files. ${p}`}function Nn({changes:e,onOpenTheirs:n,onReturnFocus:s}){var d;const m=c=>{c.preventDefault();const D=document.activeElement;D!==null&&D!==document.body||s()},{pendingDelete:p,pendingClash:i,conflict:o}=e,g=i===null?"":i.dir===Q?"The top folder":`“${i.dir}”`,r=(i==null?void 0:i.names.length)===1;return t.jsxs(t.Fragment,{children:[t.jsx(fe,{open:p!==null,onOpenChange:c=>!c&&e.cancelDelete(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:(p==null?void 0:p.entry.type)==="dir"?"Delete this folder?":"Delete this file?"}),t.jsx(xe,{children:p===null?"":Rn(p)})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.cancelDelete,children:"Cancel"}),t.jsx(ve,{onClick:()=>void e.confirmDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})}),t.jsx(fe,{open:i!==null,onOpenChange:c=>!c&&e.cancelClash(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:r?`Replace “${i==null?void 0:i.names[0]}”?`:`Replace ${(i==null?void 0:i.names.length)??0} files?`}),t.jsx(xe,{children:r?`${g} already has a file with this name. Replace it with yours, or keep both and add yours under a new name.`:`${g} already has files with these names: ${(i==null?void 0:i.names.join(", "))??""}. Replace them with yours, or keep both and add yours under new names.`})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.cancelClash,children:"Cancel"}),t.jsx(Y,{variant:"outline",onClick:()=>void e.resolveClash("keep-both"),children:"Keep both"}),t.jsx(ve,{onClick:()=>void e.resolveClash("replace"),children:"Replace"})]})]})}),t.jsx(fe,{open:o!==null,onOpenChange:c=>!c&&e.dismissConflict(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:"Somebody changed this first"}),t.jsx(xe,{children:o===null?"":`${((d=o.lastCommit)==null?void 0:d.author)??"Somebody"} changed “${o.path}” after you opened it, so ${Dn[o.kind]}.`})]}),(o==null?void 0:o.lastCommit)&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:[o.lastCommit.subject," · ",Et(o.lastCommit.at)]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.dismissConflict,children:"Cancel"}),t.jsx(Y,{variant:"outline",onClick:()=>{o!==null&&(e.dismissConflict(),n(o.path))},children:"Open their version"}),t.jsx(ve,{onClick:()=>{o!==null&&(e.dismissConflict(),o.retry())},className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:o===null?"":En[o.kind]})]})]})})]})}function ze(e,n){return n.name===e?Ge(e):`There’s already “${n.name}” there, and a name that differs only in capital letters is the same ${n.type==="dir"?"folder":"file"} on some computers. Pick another name.`}const Sn="Folders can’t be uploaded whole. Open the folder and drop the files inside it.";function Tn({source:e,className:n,onCommands:s}={}){var de;const m=ne(),p=Te(l=>l.selectedCwd),i=a.useMemo(()=>p?mn({transport:m,cwd:p}):null,[m,p]),o=e===void 0?i:e,g=o!==null&&!o.writable,r=pn(o),d=r.changes,c=oe(),D=K(l=>l.showHidden),{rows:M,rootLoading:R,rootError:q,rootErrorMessage:b,rootErrorCommand:H,errorPaths:$}=r,k=K(l=>l.setCommands),h=K(l=>l.selectedPath),x=K(l=>l.setSelectedPath),j=K(l=>l.clipboard),[C,S]=a.useState(null),[I,_]=a.useState(null),[A,z]=a.useState(null),W=a.useCallback(l=>z(l===null?null:{path:l,isNew:!1}),[]),F=a.useRef(null),v=a.useRef(Q),[L,B]=a.useState(!1),u=a.useCallback((l,P)=>{if(d!==null){if(P.length===0){J.error(Sn);return}r.ensureExpanded(l),d.upload(l,P)}},[d,r]),f=a.useRef(null),T=a.useCallback(()=>{var l,P;(P=(l=f.current)==null?void 0:l.querySelector('[role="tree"]'))==null||P.focus()},[]),y=a.useCallback(l=>{var P;v.current=l,(P=F.current)==null||P.click()},[]),O=a.useCallback(l=>j!==null&&!(j.isDir&&Ce(l,j.path)),[j]),E=a.useCallback((l,P)=>{r.ensureExpanded(l),Ae.flushSync(()=>{_(null),S({parent:l,type:P})})},[r]),N=a.useCallback(l=>{Ae.flushSync(()=>_(l.path))},[]),w=a.useRef({startCreate:E,reload:r.reload,pickUpload:y});a.useEffect(()=>{w.current={startCreate:E,reload:r.reload,pickUpload:y}});const U=d!==null;a.useEffect(()=>{if(g||s===void 0&&U)return;const l=s??k;return l({newFile:()=>w.current.startCreate(Q,"file"),newFolder:()=>w.current.startCreate(Q,"dir"),refresh:()=>w.current.reload(),...U&&{upload:()=>w.current.pickUpload(Q)}}),()=>l(null)},[k,s,g,U]);const te=a.useCallback(async l=>{var se;if(!C||o===null)return;const P=C;if(S(null),d!==null){const re=(((se=c.getQueryData(le(o,P.parent,D)))==null?void 0:se.entries)??[]).find(ot=>ot.name.toLowerCase()===l.toLowerCase());if(P.type==="dir"){if(re!==void 0&&!(re.type==="dir"&&re.name===l)){J.error(ze(l,re));return}S({parent:ee(P.parent,l),type:"file",firstInFolder:l});return}if(re!==void 0){J.error(ze(l,re));return}const rt=ee(P.parent,l);z({path:rt,isNew:!0});return}await r.createEntry(P.parent,l,P.type)&&x(ee(P.parent,l))},[C,o,d,c,D,r,x]),V=a.useCallback(async(l,P)=>{_(null),(d?await d.renameEntry(l,P):await r.renameEntry(l,P))&&x(ee(G(l.path),P))},[d,r,x]);return o===null?e!==void 0?null:t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Select a working directory to browse its files."}):t.jsxs("div",{ref:f,className:Oe("flex h-full flex-col",L&&"ring-ring/60 bg-accent/30 ring-1 ring-inset",n),onDragOver:l=>{d===null||!we(l.dataTransfer.types)||(l.preventDefault(),l.dataTransfer.dropEffect="copy",B(!0))},onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||B(!1)},onDrop:l=>{B(!1),!(d===null||!we(l.dataTransfer.types))&&(l.preventDefault(),u(Q,st(l.dataTransfer).files))},children:[d!==null&&t.jsx("input",{ref:F,type:"file",multiple:!0,hidden:!0,"aria-hidden":!0,tabIndex:-1,"data-testid":"room-files-upload-input",onChange:l=>{const P=Array.from(l.target.files??[]);l.target.value="",u(v.current,P)}}),t.jsxs("div",{className:"min-h-0 flex-1",children:[C&&t.jsx(Fn,{type:C.type,firstInFolder:C.firstInFolder,onSubmit:l=>void te(l),onCancel:()=>S(null)},`${C.parent}:${C.type}:${C.firstInFolder??""}`),R&&M.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(Fe,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):q&&M.length===0?t.jsxs("div",{className:"text-muted-foreground flex min-h-20 flex-col items-center justify-center gap-2 px-4 py-3 text-center text-xs [overflow-wrap:anywhere]",children:[t.jsx("span",{children:b??"Couldn’t load files."}),H!==null&&t.jsx("code",{"aria-label":"Command that removes the settings",className:"bg-muted text-foreground block w-full rounded px-2 py-1.5 text-left font-mono select-all",children:H}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:r.reload,children:[t.jsx(Ke,{}),"Retry"]})]}):M.length===0&&!C?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center px-4 text-center text-xs",children:d!==null?"No files yet. Drop files here, or use Upload.":"Empty directory"}):t.jsx(wn,{rows:M,selectedPath:h,renamingPath:I,errorPaths:$,onSelectPath:x,onToggle:r.toggleExpand,onOpen:l=>{o.preview==="inline"?W(l.path):r.openFile(l)},onRetryDir:r.retryDir,onSubmitRename:(l,P)=>void V(l,P),onCancelRename:()=>_(null),onStartRename:N,onNewFile:l=>E(l,"file"),onNewFolder:l=>E(l,"dir"),onDelete:l=>d?d.requestDelete(l):void r.removeEntry(l),onMove:(l,P)=>void(d?d.moveEntry(l,P):r.moveEntry(l,P)),onCopyInto:(l,P)=>void r.copyEntry(l,P),onCopy:r.copyToClipboard,onPaste:l=>{j&&r.copyEntry(j,l)},onDuplicate:l=>void r.copyEntry({path:l.path,isDir:l.type==="dir"},G(l.path)),canPasteInto:O,readOnly:g,provenance:o.provenance,copyable:d===null,onDisk:o.cwd!==null,onUpload:d?u:void 0,onPickUpload:d?y:void 0,revealLabel:r.revealLabel,onReveal:l=>void r.reveal(l),onAddToChat:r.addToChat,onCopyPath:(l,P)=>void r.copyPath(l,P)})]}),o.preview==="inline"&&t.jsx(Zt,{source:o,path:(A==null?void 0:A.path)??null,isNew:(A==null?void 0:A.isNew)??!1,onCreated:()=>{A!==null&&(z({path:A.path,isNew:!1}),x(A.path))},onClose:()=>z(null)}),d!==null&&t.jsx(Nn,{changes:d,onOpenTheirs:l=>W(l),onReturnFocus:T}),t.jsx(fe,{open:r.pendingRecursiveDelete!==null,onOpenChange:l=>!l&&r.cancelRecursiveDelete(),children:t.jsxs(he,{children:[t.jsxs(pe,{children:[t.jsx(me,{children:"Delete this folder?"}),t.jsxs(xe,{children:["“",(de=r.pendingRecursiveDelete)==null?void 0:de.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:r.cancelRecursiveDelete,children:"Cancel"}),t.jsx(ve,{onClick:()=>void r.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})})]})}function Fn({type:e,firstInFolder:n,onSubmit:s,onCancel:m}){const p=a.useRef(null),[i,o]=a.useState("");a.useEffect(()=>{var d;(d=p.current)==null||d.focus()},[]);const g=()=>{const d=i.trim();d?s(d):m()},r=t.jsxs("div",{className:"flex items-center gap-1",children:[e==="dir"?t.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(Ue,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:p,type:"text",value:i,"aria-label":n!==void 0?`First file in ${n}`:e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:d=>o(d.target.value),onBlur:g,onKeyDown:d=>{d.key==="Enter"?g():d.key==="Escape"&&m()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]});return n===void 0?t.jsx("div",{className:"px-3 py-1",children:r}):t.jsxs("div",{className:"space-y-1 px-3 py-1",children:[t.jsxs("p",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[t.jsx(be,{className:"size-(--size-icon-xs) flex-shrink-0 text-sky-500"}),t.jsx("span",{className:"truncate",children:n})]}),r,t.jsx("p",{className:"text-muted-foreground text-2xs",children:"Name its first file. The folder appears when you save it."})]})}function at(){const e=K(m=>m.showHidden),n=K(m=>m.setShowHidden),s=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:()=>n(!e),children:e?t.jsx(Dt,{className:"text-muted-foreground"}):t.jsx(Rt,{className:"text-muted-foreground"})})}function On({cwd:e}){const n=ne(),{data:s}=ce({queryKey:["file-explorer","workspace",e],queryFn:()=>n.resolveWorkspace(e),staleTime:6e4});return s!=null&&s.branch?t.jsxs("span",{className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",title:`Workspace ${s.key} on ${s.branch}`,children:[t.jsx(Be,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:s.branch})]}):null}function In(){const e=Te(s=>s.selectedCwd),n=K(s=>s.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(On,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>n==null?void 0:n.newFile(),children:t.jsx(et,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>n==null?void 0:n.newFolder(),children:t.jsx(We,{className:"text-muted-foreground"})}),t.jsx(at,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>n==null?void 0:n.refresh(),children:t.jsx(Nt,{className:"text-muted-foreground"})})]}):null}function Pn({roomId:e}){const n=ne(),s=oe(),m=ce(Ye(n,e));a.useEffect(()=>Jt(s,e,()=>{s.invalidateQueries({queryKey:De.repoStatus(e)})}),[s,e]);const p=a.useMemo(()=>{var r;return((r=m.data)==null?void 0:r.kind)==="ok"?St(m.data.status):[]},[m.data]),i=Tt(p),o=Ft(p);if(!o)return null;const g=p.map((r,d)=>`${i[d]}: ${Ot(r)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:g.join(`
|
|
16
|
+
*/const tt={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};tt.node;const nn=Se(tt);function le(e,n,s){return["file-explorer","tree",e.scopeKey,n,e.filtersHidden?s:null]}function ke(e,n,s,m){return{queryKey:le(e,n,s),queryFn:()=>e.list(n,{showHidden:s}),staleTime:Me.FILE_TREE_STALE_TIME_MS,gcTime:Me.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(le(e,n,!s))}}const sn=[".git",".dork",".claude",".agents","node_modules"];function an(e){return e.startsWith(".")||sn.includes(e)}const Re=["ROOM.md","README.md"];function Ne(e){return Re.some(n=>n.toLowerCase()===e.toLowerCase())}function nt(e){return e.filter(n=>!an(n.name))}function rn(e){if(e.reduce((p,i)=>i.type==="file"&&Ne(i.name)?p+1:p,0)===0)return e;const s=[],m=[];for(const p of e)p.type==="file"&&Ne(p.name)?s.push(p):m.push(p);return s.sort((p,i)=>Re.findIndex(o=>o.toLowerCase()===p.name.toLowerCase())-Re.findIndex(o=>o.toLowerCase()===i.name.toLowerCase())),[...s,...m]}const on=/ copy(?: \d+)?$/;function Pe({name:e,isDir:n,taken:s}){const m=new Set(s);if(!m.has(e))return e;const p=n?-1:e.lastIndexOf("."),i=p>0,o=i?e.slice(p):"",g=(i?e.slice(0,p):e).replace(on,"");for(let r=1;;r+=1){const d=r===1?`${g} copy${o}`:`${g} copy ${r}${o}`;if(!m.has(d))return d}}function _e(e,n,s){return{name:n,path:e,type:s,size:0,mtime:Date.now(),isSymlink:!1}}function ln(e){const n=ne(),{source:s,showHidden:m,queryClient:p,inFlightRef:i}=e,o=s.cwd??"",[g,r]=a.useState(null),d=a.useCallback(async h=>{i.current+=1;try{return await h()}finally{i.current-=1}},[i]),c=a.useMemo(()=>{const h=x=>le(s,x,m);return{getChildren:x=>{var j;return((j=p.getQueryData(h(x)))==null?void 0:j.entries)??[]},isLoaded:x=>p.getQueryData(h(x))!==void 0,takenNames:async x=>(await n.readFileTree(o,{path:x===Q?void 0:x,showHidden:!0})).entries.map(C=>C.name),snapshot:x=>p.getQueryData(h(x)),setChildren:(x,j)=>{p.setQueryData(h(x),C=>({entries:Ie(j((C==null?void 0:C.entries)??[]))}))},restore:(x,j)=>{p.setQueryData(h(x),j)},invalidate:x=>{p.invalidateQueries({queryKey:h(x),exact:!0})}}},[p,n,o,s,m]),D=a.useCallback((h,x,j)=>d(async()=>{const C=ee(h,x),S=!c.getChildren(h).some(_=>_.path===C),I=c.snapshot(h);S&&c.setChildren(h,_=>[..._,_e(C,x,j)]);try{return await n.createEntry(o,C,j),!0}catch(_){return S&&c.restore(h,I),ae(_,`Couldn’t create ${j==="dir"?"folder":"file"}`),!1}finally{c.invalidate(h)}}),[n,o,c,d]),M=a.useCallback((h,x)=>d(async()=>{if(x===h.name||x.length===0)return!0;const j=G(h.path),C=ee(j,x),S=c.getChildren(j).some(A=>A.path===C),I=c.snapshot(j),_={...h,name:x,path:C};S||c.setChildren(j,A=>A.map(z=>z.path===h.path?_:z));try{return await n.renameEntry(o,h.path,C),K.getState().remapExpandedPaths(h.path,C),!0}catch(A){return S||c.restore(j,I),ae(A,"Couldn’t rename"),!1}finally{c.invalidate(j)}}),[n,o,c,d]),R=a.useCallback(h=>d(async()=>{const x=G(h.path),j=c.snapshot(x);c.setChildren(x,C=>C.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path,{recursive:!0}),K.getState().dropExpandedPaths(h.path)}catch(C){c.restore(x,j),ae(C,"Couldn’t delete")}finally{c.invalidate(x)}}),[n,o,c,d]),q=a.useCallback(h=>d(async()=>{const x=G(h.path);if(h.type==="file"){const j=c.snapshot(x);c.setChildren(x,C=>C.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path),K.getState().dropExpandedPaths(h.path)}catch(C){c.restore(x,j),ae(C,"Couldn’t delete")}finally{c.invalidate(x)}return}try{await n.deleteEntry(o,h.path),c.setChildren(x,j=>j.filter(C=>C.path!==h.path)),K.getState().dropExpandedPaths(h.path),c.invalidate(x)}catch(j){if(Yt(j)==="DIR_NOT_EMPTY"){r(h);return}ae(j,"Couldn’t delete")}}),[n,o,c,d]),b=a.useCallback(async()=>{const h=g;r(null),h&&await R(h)},[g,R]),H=a.useCallback(()=>r(null),[]),$=a.useCallback((h,x)=>d(async()=>{const j=G(h),C=ie(h),S=ee(x,C);if(x===j||S===h||Ce(x,h))return;const I=c.getChildren(j).find(v=>v.path===h);if(!I)return;const _=c.isLoaded(x),A=_&&c.getChildren(x).some(v=>v.path===S),z={...I,name:C,path:S},W=c.snapshot(j),F=_?c.snapshot(x):void 0;c.setChildren(j,v=>v.filter(L=>L.path!==h)),_&&!A&&c.setChildren(x,v=>[...v,z]);try{await n.renameEntry(o,h,S),K.getState().remapExpandedPaths(h,S)}catch(v){c.restore(j,W),_&&!A&&c.restore(x,F),ae(v,"Couldn’t move")}finally{c.invalidate(j),_&&c.invalidate(x)}}),[n,o,c,d]),k=a.useCallback((h,x)=>d(async()=>{if(h.isDir&&Ce(x,h.path)){J.error(Gt);return}let j;try{j=await c.takenNames(x)}catch(A){ae(A,"Couldn’t copy");return}const C=Pe({name:ie(h.path),isDir:h.isDir,taken:j}),S=ee(x,C),I=c.isLoaded(x),_=I?c.snapshot(x):void 0;if(I){const A=c.getChildren(G(h.path)).find(W=>W.path===h.path),z=A?{...A,name:C,path:S}:_e(S,C,h.isDir?"dir":"file");c.setChildren(x,W=>[...W,z])}try{await n.copyEntry(o,h.path,S)}catch(A){I&&c.restore(x,_),ae(A,"Couldn’t copy")}finally{c.invalidate(x)}}),[n,o,c,d]);return{createEntry:D,renameEntry:M,removeEntry:q,moveEntry:$,copyEntry:k,pendingRecursiveDelete:g,confirmRecursiveDelete:b,cancelRecursiveDelete:H}}function cn(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function dn(e,n){const s=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=s?n.split("/").join("\\"):n;return`${m}${s?"\\":"/"}${p}`}function un(e){const n=ne(),{data:s}=it(),m=a.useMemo(()=>n.supportsReveal?cn(s==null?void 0:s.platform):null,[n.supportsReveal,s==null?void 0:s.platform]),p=a.useCallback(async d=>{if(e)try{await n.revealEntry(e,d.path)}catch(c){ae(c,"Couldn’t open the file manager")}},[n,e]),{copy:i}=lt(),o=a.useCallback(async(d,c)=>{const D=c==="absolute"&&e?dn(e,d.path):d.path;await i(D)||J.error("Couldn’t copy to the clipboard")},[e,i]),g=a.useCallback(d=>{ct(dt(d.path))||J.error("Open a chat first to add a file to it")},[]),r=a.useCallback(d=>{K.getState().setClipboard({path:d.path,isDir:d.type==="dir"});try{navigator.clipboard.writeText(d.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:o,addToChat:g,copyToClipboard:r}}const fn=1e3;function hn(e){const{source:n,showHidden:s,queryClient:m,inFlightRef:p}=e,i=n.changes,[o,g]=a.useState(null),[r,d]=a.useState(null),[c,D]=a.useState(null),[M,R]=a.useState(0),q=a.useCallback(async u=>{p.current+=1,R(f=>f+1);try{return await u()}finally{p.current-=1,R(f=>f-1)}},[p]),b=a.useMemo(()=>{const u=f=>le(n,f,s);return{listing:f=>m.getQueryData(u(f)),isLoaded:f=>m.getQueryData(u(f))!==void 0,entries:f=>{var T;return((T=m.getQueryData(u(f)))==null?void 0:T.entries)??[]},setEntries:(f,T)=>m.setQueryData(u(f),y=>({...y,entries:Ie(T((y==null?void 0:y.entries)??[]))})),restore:(f,T)=>m.setQueryData(u(f),T),fetch:f=>n.list(f,{showHidden:!0}),refreshAll:()=>{m.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),m.invalidateQueries({queryKey:["file-explorer","preview",n.scopeKey]})}}},[m,n,s]),H=a.useCallback(async u=>{const f=b.listing(u);return(f==null?void 0:f.commit)!==void 0?f.commit:(await b.fetch(u)).commit??null},[b]),$=a.useCallback((u,f,T,y)=>{switch(u.status){case"changed":return!0;case"conflict":return D({kind:f,path:u.path,lastCommit:u.lastCommit,retry:()=>T(u.commit)}),!1;case"exists":return J.error(y===void 0?u.reason:Ge(y)),!1;case"refused":return J.error(u.reason),!1}},[]),k=a.useCallback((u,f)=>{J.error(Ve(u)??f)},[]),h=a.useCallback((u,f,T)=>{const y=O=>q(async()=>{if(i===void 0)return!1;const E=G(u.path),N=G(f),w=ie(f),U=b.isLoaded(N),te=U&&b.entries(N).some(X=>X.path===f),V=b.listing(E),de=N===E?void 0:b.listing(N),l={...u,name:w,path:f};te||(N===E?b.setEntries(E,X=>X.map(se=>se.path===u.path?l:se)):(b.setEntries(E,X=>X.filter(se=>se.path!==u.path)),U&&b.setEntries(N,X=>[...X,l])));const P=()=>{b.restore(E,V),N!==E&&U&&b.restore(N,de)};try{const X=O??await H(E);if(X===null)return P(),J.error("There’s nothing in this room’s files to change yet."),!1;const se=await i.move({from:u.path,to:f,baseCommit:X}),je=$(se,T,async re=>{await y(re)},w);return je?K.getState().remapExpandedPaths(u.path,f):P(),je}catch(X){return P(),k(X,T==="rename"?"Couldn’t rename":"Couldn’t move"),!1}finally{b.refreshAll()}});return y(null)},[i,b,q,H,$,k]),x=a.useCallback(async(u,f)=>f===u.name||f.length===0?!0:h(u,ee(G(u.path),f),"rename"),[h]),j=a.useCallback(async(u,f)=>{const T=G(u),y=ee(f,ie(u));if(f===T||y===u||Ce(f,u))return;const O=b.entries(T).find(E=>E.path===u);O&&await h(O,y,"move")},[b,h]),C=a.useCallback(async u=>{let f=0;const T=[u];for(;T.length>0;){const y=T.shift(),O=await b.fetch(y);for(const E of O.entries)if(E.type==="dir"?T.push(E.path):f+=1,f>=fn)return{count:f,moreThan:!0}}return{count:f,moreThan:!1}},[b]),S=a.useCallback(u=>{if(u.type!=="dir"){g({entry:u,fileCount:1,moreThan:!1});return}g({entry:u,fileCount:null,moreThan:!1}),C(u.path).then(({count:f,moreThan:T})=>g(y=>(y==null?void 0:y.entry.path)===u.path?{entry:u,fileCount:f,moreThan:T}:y),()=>{})},[C]),I=a.useCallback(u=>{const f=T=>q(async()=>{if(i===void 0)return;const y=G(u.path),O=b.listing(y);b.setEntries(y,E=>E.filter(N=>N.path!==u.path));try{const E=T??await H(y);if(E===null){b.restore(y,O);return}const N=await i.remove({path:u.path,baseCommit:E});$(N,"delete",U=>f(U))?K.getState().dropExpandedPaths(u.path):b.restore(y,O)}catch(E){b.restore(y,O),k(E,"Couldn’t delete")}finally{b.refreshAll()}});return f(null)},[i,b,q,H,$,k]),_=a.useCallback(async()=>{const u=o;g(null),u&&await I(u.entry)},[o,I]),A=a.useCallback(()=>g(null),[]),z=a.useCallback((u,f,T,y)=>{const O=E=>q(async()=>{if(i===void 0)return;const N=b.isLoaded(u),w=N?b.listing(u):void 0;if(N){const U=new Set(b.entries(u).map(V=>V.name)),te=f.filter(V=>!U.has(V.name)).map(V=>({name:V.name,path:ee(u,V.name),type:"file",size:V.size}));te.length>0&&b.setEntries(u,V=>[...V,...te])}try{const U=await i.upload({dir:u,baseCommit:E,replace:T,files:f});!$(U,"upload",V=>O(V))&&N&&b.restore(u,w)}catch(U){N&&b.restore(u,w),k(U,"Couldn’t upload")}finally{b.refreshAll()}});return O(y)},[i,b,q,$,k]),W=a.useCallback(async(u,f)=>{if(i===void 0||f.length===0)return;if(f.length>i.maxUploadFiles){J.error(`One upload can carry up to ${i.maxUploadFiles} files, so nothing was uploaded. Try again with fewer.`);return}let T;try{T=await b.fetch(u)}catch(w){k(w,"Couldn’t upload");return}const y=T.entries.map(w=>w.name),O=new Set(y),E=f.map(w=>w.name).filter(w=>O.has(w)),N=T.commit??null;if(E.length===0){await z(u,f,[],N);return}d({dir:u,files:f,names:E,taken:y,baseCommit:N})},[i,b,k,z]),F=a.useCallback(async u=>{const f=r;if(d(null),f===null)return;if(u==="replace"){await z(f.dir,f.files,f.names,f.baseCommit);return}const T=new Set([...f.taken,...f.files.map(E=>E.name)]),y=new Set(f.names),O=f.files.map(E=>{if(!y.has(E.name))return E;const N=Pe({name:E.name,isDir:!1,taken:T});return T.add(N),new File([E],N,{type:E.type,lastModified:E.lastModified})});await z(f.dir,O,[],f.baseCommit)},[r,z]),v=a.useCallback(()=>d(null),[]),L=a.useCallback(()=>D(null),[]),B=a.useMemo(()=>r===null?null:{dir:r.dir,names:r.names},[r]);return{renameEntry:x,moveEntry:j,requestDelete:S,pendingDelete:o,confirmDelete:_,cancelDelete:A,upload:W,pendingClash:B,resolveClash:F,cancelClash:v,conflict:c,dismissConflict:L,busy:M>0}}const Le={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function pn(e){var u,f,T;const n=ne(),s=oe(),{setTheme:m}=ut(),p=K(y=>y.showHidden),i=K(y=>y.expanded),o=K(y=>y.loadExplorerForCwd),g=K(y=>y.pruneMissing),r=(e==null?void 0:e.scopeKey)??null,d=(e==null?void 0:e.cwd)??null;a.useEffect(()=>{o(r)},[r,o]);const c=a.useMemo(()=>[Q,...ft(i)],[i]),D=ht({queries:e?c.map(y=>ke(e,y,p,s)):[]}),M=(e==null?void 0:e.filtersHidden)??!0,R=a.useMemo(()=>{const y={};return c.forEach((O,E)=>{var U;const N=D[E];let w=((U=N==null?void 0:N.data)==null?void 0:U.entries)??[];!p&&!M&&(w=nt(w)),O===Q&&(w=rn(w)),y[O]={entries:w,loading:(N==null?void 0:N.isLoading)??!1,error:(N==null?void 0:N.isError)??!1}}),y},[c,D,p,M]),q=a.useRef(0),b=a.useRef({});a.useEffect(()=>{q.current>0||c.forEach((y,O)=>{var N,w,U;const E=(w=(N=D[O])==null?void 0:N.data)==null?void 0:w.entries;!E||(U=D[O])!=null&&U.isError||b.current[y]!==E&&(b.current[y]=E,g(y,E.map(te=>te.name)))})},[c,D,g]);const H=a.useMemo(()=>pt(i,R),[i,R]),$=!!e&&!!((u=R[Q])!=null&&u.loading),k=!!e&&!!((f=R[Q])!=null&&f.error),h=(T=D[0])==null?void 0:T.error,x=k&&h?Vt(h):void 0,j=(x==null?void 0:x.message)??null,C=(x==null?void 0:x.command)??null,S=a.useMemo(()=>{var O;const y=new Set;for(const E of c)E!==Q&&((O=R[E])!=null&&O.error)&&y.add(E);return y},[c,R]),I=a.useCallback(y=>{if(y.type!=="dir")return;const O=K.getState();O.setDirExpanded(y.path,!O.expanded[y.path])},[]),_=a.useCallback(y=>{if(y===Q)return;const O=K.getState();O.expanded[y]||O.setDirExpanded(y,!0)},[]),A=(e==null?void 0:e.preview)==="canvas",z=a.useCallback(y=>{if(y.type!=="file"||!A)return;const O={getStore:Te.getState,setTheme:m,supportsTerminal:n.supportsTerminal};mt(O,{action:"open_file",sourcePath:y.path},"user")},[A,m,n]),W=a.useCallback(()=>{r!==null&&s.invalidateQueries({queryKey:["file-explorer","tree",r]})},[s,r]),F=a.useCallback(y=>{e!==null&&s.invalidateQueries({queryKey:le(e,y,p),exact:!0})},[s,e,p]);a.useEffect(()=>{if(e!=null&&e.events)return e.events(W)},[e,W]);const v=ln({source:e??Le,showHidden:p,queryClient:s,inFlightRef:q}),L=hn({source:e??Le,showHidden:p,queryClient:s,inFlightRef:q}),B=un(d);return{rows:H,rootLoading:$,rootError:k,rootErrorMessage:j,rootErrorCommand:C,errorPaths:S,toggleExpand:I,ensureExpanded:_,openFile:z,reload:W,retryDir:F,changes:e!=null&&e.changes?L:null,...v,...B}}function mn(e){const{transport:n,cwd:s}=e;return{scopeKey:s,cwd:s,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return n.readFileTree(s,{path:m===""?void 0:m,showHidden:p.showHidden})}}}function we(e){return Array.from(e).includes("Files")}function st(e){const n=Array.from(e.items??[]);if(!(n.length>0&&n.every(i=>"webkitGetAsEntry"in i)))return{files:Array.from(e.files??[]),folders:0};const m=[];let p=0;for(const i of n){if(i.kind!=="file")continue;const o=i.webkitGetAsEntry();if(o!=null&&o.isDirectory){p+=1;continue}const g=i.getAsFile();g&&m.push(g)}return{files:m,folders:p}}const xn=12;function gn({row:e,selected:n,renaming:s,error:m,onSelect:p,onActivate:i,onRetry:o,onSubmitRename:g,onCancelRename:r,onNewFile:d,onNewFolder:c,onStartRename:D,onDelete:M,onMove:R,onCopyInto:q,onCopy:b,onPaste:H,onDuplicate:$,canPasteInto:k,revealLabel:h,onReveal:x,onAddToChat:j,onCopyPath:C,readOnly:S=!1,provenance:I=!1,copyable:_=!0,onDisk:A=!0,onUpload:z,onPickUpload:W}){const{entry:F,depth:v,expanded:L,loading:B}=e,u=F.type==="dir",f=u?F.path:G(F.path),[T,y]=a.useState(!1),O=!u&&v===0&&Ne(F.name),E=Xt(F.lastCommit),N=t.jsxs("div",{role:"treeitem","aria-label":F.name,"aria-expanded":u?L:void 0,"aria-selected":n,tabIndex:-1,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),p(F),i(F))},draggable:!s&&!S,onDragStart:w=>{S||(w.dataTransfer.setData("text/plain",F.path),w.dataTransfer.setData(Ct,F.path),w.dataTransfer.effectAllowed="copyMove")},onDragOver:w=>{if(w.stopPropagation(),!S&&z&&we(w.dataTransfer.types)){w.preventDefault(),w.dataTransfer.dropEffect="copy",y(!0);return}S||!u||!Qe(w.dataTransfer.types)||(w.preventDefault(),w.dataTransfer.dropEffect=w.altKey&&_?"copy":"move",y(!0))},onDragLeave:()=>y(!1),onDrop:w=>{if(w.stopPropagation(),S)return;if(y(!1),z&&we(w.dataTransfer.types)){w.preventDefault();const{files:te}=st(w.dataTransfer);z(f,te);return}if(!u)return;const U=qe(w.dataTransfer);U!==null&&(w.preventDefault(),w.altKey&&_?q(U,F.path):R(U,F.path))},onClick:()=>{p(F),i(F)},className:Oe("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",n?"bg-accent text-foreground":"hover:bg-accent/50",T&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:v*xn+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:u&&(B?t.jsx(Fe,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:w=>{w.stopPropagation(),o()},className:"flex items-center justify-center",children:t.jsx(Ke,{className:"text-destructive size-3.5"})}):L?t.jsx(xt,{className:"text-muted-foreground size-3.5"}):t.jsx(He,{className:"text-muted-foreground size-3.5"}))}),u?L?t.jsx(gt,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):F.isSymlink===!0?t.jsx(yt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(Ue,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),s?t.jsx(yn,{initialName:F.name,onSubmit:w=>g(F,w),onCancel:r}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:F.name}),O&&!s&&t.jsx(vt,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),I&&!s&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:E.title??void 0,children:E.label})]});return S?N:t.jsxs(bt,{children:[t.jsx(wt,{asChild:!0,children:N}),t.jsxs(kt,{className:"w-52",children:[t.jsx(Z,{movesFocus:!0,onClick:()=>d(f),children:"New file"}),t.jsx(Z,{movesFocus:!0,onClick:()=>c(f),children:"New folder"}),W&&t.jsx(Z,{onClick:()=>W(f),children:"Upload files…"}),A&&t.jsxs(t.Fragment,{children:[t.jsx(ue,{}),h&&t.jsx(Z,{onClick:()=>x(F),children:h}),t.jsx(Z,{movesFocus:!0,onClick:()=>j(F),children:"Add to chat"})]}),_&&t.jsxs(t.Fragment,{children:[t.jsx(ue,{}),t.jsx(Z,{onClick:()=>b(F),children:"Copy"}),t.jsx(Z,{disabled:!k(f),onClick:()=>H(f),children:"Paste"}),t.jsx(Z,{onClick:()=>$(F),children:"Duplicate"})]}),t.jsx(ue,{}),A?t.jsxs(t.Fragment,{children:[t.jsx(Z,{onClick:()=>C(F,"absolute"),children:"Copy path"}),t.jsx(Z,{onClick:()=>C(F,"relative"),children:"Copy relative path"})]}):t.jsx(Z,{onClick:()=>C(F,"relative"),children:"Copy path"}),t.jsx(ue,{}),t.jsx(Z,{movesFocus:!0,onClick:()=>D(F),children:"Rename"}),t.jsx(Z,{variant:"destructive",onClick:()=>M(F),children:"Delete"})]})]})}function yn({initialName:e,onSubmit:n,onCancel:s}){const m=a.useRef(null),[p,i]=a.useState(e);a.useEffect(()=>{const g=m.current;if(!g)return;g.focus();const r=e.lastIndexOf(".");g.setSelectionRange(0,r>0?r:e.length)},[e]);const o=()=>{const g=p.trim();g&&g!==e?n(g):s()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:g=>i(g.target.value),onClick:g=>g.stopPropagation(),onBlur:o,onKeyDown:g=>{g.stopPropagation(),g.key==="Enter"?o():g.key==="Escape"&&s()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const vn=100,Cn=28,bn=250;function wn(e){const{rows:n,selectedPath:s,renamingPath:m,errorPaths:p,onSelectPath:i,onRetryDir:o}=e,g=a.useRef(null),r=K(v=>v.setScrollTop),d=K(v=>v.scopeKey),c=a.useCallback(v=>v.type==="dir"?e.onToggle(v):e.onOpen(v),[e]),D=jn(e,c),M=n.length>vn,R=jt({count:n.length,getScrollElement:()=>g.current,estimateSize:()=>Cn,overscan:12,enabled:M}),q=a.useRef({scope:void 0,done:!1}),b=a.useRef(null);a.useLayoutEffect(()=>{const v=q.current;if(v.scope!==d&&(v.scope=d,v.done=!1),v.done||n.length===0)return;const L=g.current;if(!L)return;const B=K.getState().scrollTop;if(B<=0){v.done=!0;return}M?R.scrollToOffset(B):L.scrollTop=B,b.current=L.scrollTop,L.scrollTop>=B&&(v.done=!0)},[n.length,d,M,R]);const H=a.useRef(null),$=a.useRef(null),k=a.useCallback(()=>{const v=g.current;v&&v.scrollTop!==b.current&&(q.current.done=!0,H.current=v.scrollTop,$.current&&clearTimeout($.current),$.current=setTimeout(()=>{$.current=null,H.current!==null&&r(H.current)},bn))},[r]);a.useEffect(()=>()=>{$.current&&clearTimeout($.current),H.current!==null&&r(H.current)},[r]);const h=a.useRef(void 0);a.useEffect(()=>{var u,f;const v=h.current;if(h.current=s,v===void 0||s===v||s===null)return;const L=n.findIndex(T=>T.entry.path===s);if(L<0)return;const B=g.current;B&&(M?R.scrollToIndex(L,{align:"auto"}):(f=(u=B.querySelector(`[data-row-index="${L}"]`))==null?void 0:u.scrollIntoView)==null||f.call(u,{block:"nearest"}),b.current=B.scrollTop)},[s,n,M,R]);const[x,j]=a.useState(!1),{onCopyInto:C,onMove:S}=e,I=e.readOnly===!0,_=e.copyable!==!1,A=a.useCallback(v=>{I||!Qe(v.dataTransfer.types)||(v.preventDefault(),v.dataTransfer.dropEffect=v.altKey&&_?"copy":"move",j(!0))},[I,_]),z=a.useCallback((v,L)=>{const B=n.find(u=>u.entry.path===v);B&&C({path:v,isDir:B.entry.type==="dir"},L)},[n,C]),W=a.useCallback(v=>{if(j(!1),I)return;const L=qe(v.dataTransfer);L!==null&&(v.preventDefault(),v.altKey&&_?z(L,Q):S(L,Q))},[z,S,I,_]),F=v=>t.jsx(gn,{row:v,selected:v.entry.path===s,renaming:v.entry.path===m,error:v.entry.type==="dir"&&v.expanded&&p.has(v.entry.path),onSelect:L=>i(L.path),onActivate:c,onRetry:()=>o(v.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:z,onCopy:e.onCopy,onPaste:e.onPaste,onDuplicate:e.onDuplicate,canPasteInto:e.canPasteInto,revealLabel:e.revealLabel,onReveal:e.onReveal,onAddToChat:e.onAddToChat,onCopyPath:e.onCopyPath,readOnly:e.readOnly,provenance:e.provenance,copyable:e.copyable,onDisk:e.onDisk,onUpload:e.onUpload,onPickUpload:e.onPickUpload});return t.jsx("div",{ref:g,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:D,onScroll:k,onDragOver:A,onDragLeave:()=>j(!1),onDrop:W,className:Oe("focus-visible:ring-ring h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",x&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:M?t.jsx("div",{style:{height:R.getTotalSize()},className:"relative w-full",children:R.getVirtualItems().map(v=>t.jsx("div",{"data-row-index":v.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${v.start}px)`},children:F(n[v.index])},n[v.index].entry.path))}):n.map((v,L)=>t.jsx("div",{"data-row-index":L,children:F(v)},v.entry.path))})}function kn(e){return e?e.type==="dir"?e.path:G(e.path):Q}function jn(e,n){const{rows:s,selectedPath:m,renamingPath:p,onSelectPath:i}=e;return a.useCallback(o=>{var d,c,D,M;if(p!==null)return;const g=s.findIndex(R=>R.entry.path===m),r=g>=0?s[g]:void 0;if(o.metaKey||o.ctrlKey){if(e.readOnly===!0||e.copyable===!1)return;const R=o.key.toLowerCase();if(R==="c"&&r){o.preventDefault(),e.onCopy(r.entry);return}if(R==="v"){o.preventDefault(),e.onPaste(kn(r==null?void 0:r.entry));return}return}switch(o.key){case"ArrowDown":o.preventDefault(),i(((d=s[Math.min(g+1,s.length-1)])==null?void 0:d.entry.path)??((c=s[0])==null?void 0:c.entry.path));break;case"ArrowUp":o.preventDefault(),i(((D=s[Math.max(g-1,0)])==null?void 0:D.entry.path)??((M=s[0])==null?void 0:M.entry.path));break;case"ArrowRight":(r==null?void 0:r.entry.type)==="dir"&&!r.expanded&&(o.preventDefault(),e.onToggle(r.entry));break;case"ArrowLeft":if(!r)break;if(o.preventDefault(),r.entry.type==="dir"&&r.expanded)e.onToggle(r.entry);else{const R=G(r.entry.path);R&&i(R)}break;case"Enter":r&&(o.preventDefault(),n(r.entry));break;case"F2":r&&e.readOnly!==!0&&(o.preventDefault(),e.onStartRename(r.entry));break;case"Delete":case"Backspace":r&&e.readOnly!==!0&&(o.preventDefault(),e.onDelete(r.entry));break}},[s,m,p,i,e,n])}const En={rename:"Rename it anyway",move:"Move it anyway",delete:"Delete it anyway",upload:"Upload mine over it"},Dn={rename:"nothing was renamed",move:"nothing was moved",delete:"nothing was deleted",upload:"nothing was uploaded"};function Rn(e){const{entry:n,fileCount:s,moreThan:m}=e,p="The room’s history keeps a copy, so an agent or git can bring it back if you need it.";if(n.type!=="dir")return`“${n.name}” leaves the room’s files. ${p}`;const i=s===null?"everything in it":m?`the more than ${s.toLocaleString()} files in it`:s===1?"the 1 file in it":`the ${s.toLocaleString()} files in it`;return`“${n.name}” and ${i} leave the room’s files. ${p}`}function Nn({changes:e,onOpenTheirs:n,onReturnFocus:s}){var d;const m=c=>{c.preventDefault();const D=document.activeElement;D!==null&&D!==document.body||s()},{pendingDelete:p,pendingClash:i,conflict:o}=e,g=i===null?"":i.dir===Q?"The top folder":`“${i.dir}”`,r=(i==null?void 0:i.names.length)===1;return t.jsxs(t.Fragment,{children:[t.jsx(fe,{open:p!==null,onOpenChange:c=>!c&&e.cancelDelete(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:(p==null?void 0:p.entry.type)==="dir"?"Delete this folder?":"Delete this file?"}),t.jsx(xe,{children:p===null?"":Rn(p)})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.cancelDelete,children:"Cancel"}),t.jsx(ve,{onClick:()=>void e.confirmDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})}),t.jsx(fe,{open:i!==null,onOpenChange:c=>!c&&e.cancelClash(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:r?`Replace “${i==null?void 0:i.names[0]}”?`:`Replace ${(i==null?void 0:i.names.length)??0} files?`}),t.jsx(xe,{children:r?`${g} already has a file with this name. Replace it with yours, or keep both and add yours under a new name.`:`${g} already has files with these names: ${(i==null?void 0:i.names.join(", "))??""}. Replace them with yours, or keep both and add yours under new names.`})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.cancelClash,children:"Cancel"}),t.jsx(Y,{variant:"outline",onClick:()=>void e.resolveClash("keep-both"),children:"Keep both"}),t.jsx(ve,{onClick:()=>void e.resolveClash("replace"),children:"Replace"})]})]})}),t.jsx(fe,{open:o!==null,onOpenChange:c=>!c&&e.dismissConflict(),children:t.jsxs(he,{onCloseAutoFocus:m,children:[t.jsxs(pe,{children:[t.jsx(me,{children:"Somebody changed this first"}),t.jsx(xe,{children:o===null?"":`${((d=o.lastCommit)==null?void 0:d.author)??"Somebody"} changed “${o.path}” after you opened it, so ${Dn[o.kind]}.`})]}),(o==null?void 0:o.lastCommit)&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:[o.lastCommit.subject," · ",Et(o.lastCommit.at)]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:e.dismissConflict,children:"Cancel"}),t.jsx(Y,{variant:"outline",onClick:()=>{o!==null&&(e.dismissConflict(),n(o.path))},children:"Open their version"}),t.jsx(ve,{onClick:()=>{o!==null&&(e.dismissConflict(),o.retry())},className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:o===null?"":En[o.kind]})]})]})})]})}function ze(e,n){return n.name===e?Ge(e):`There’s already “${n.name}” there, and a name that differs only in capital letters is the same ${n.type==="dir"?"folder":"file"} on some computers. Pick another name.`}const Sn="Folders can’t be uploaded whole. Open the folder and drop the files inside it.";function Tn({source:e,className:n,onCommands:s}={}){var de;const m=ne(),p=Te(l=>l.selectedCwd),i=a.useMemo(()=>p?mn({transport:m,cwd:p}):null,[m,p]),o=e===void 0?i:e,g=o!==null&&!o.writable,r=pn(o),d=r.changes,c=oe(),D=K(l=>l.showHidden),{rows:M,rootLoading:R,rootError:q,rootErrorMessage:b,rootErrorCommand:H,errorPaths:$}=r,k=K(l=>l.setCommands),h=K(l=>l.selectedPath),x=K(l=>l.setSelectedPath),j=K(l=>l.clipboard),[C,S]=a.useState(null),[I,_]=a.useState(null),[A,z]=a.useState(null),W=a.useCallback(l=>z(l===null?null:{path:l,isNew:!1}),[]),F=a.useRef(null),v=a.useRef(Q),[L,B]=a.useState(!1),u=a.useCallback((l,P)=>{if(d!==null){if(P.length===0){J.error(Sn);return}r.ensureExpanded(l),d.upload(l,P)}},[d,r]),f=a.useRef(null),T=a.useCallback(()=>{var l,P;(P=(l=f.current)==null?void 0:l.querySelector('[role="tree"]'))==null||P.focus()},[]),y=a.useCallback(l=>{var P;v.current=l,(P=F.current)==null||P.click()},[]),O=a.useCallback(l=>j!==null&&!(j.isDir&&Ce(l,j.path)),[j]),E=a.useCallback((l,P)=>{r.ensureExpanded(l),Ae.flushSync(()=>{_(null),S({parent:l,type:P})})},[r]),N=a.useCallback(l=>{Ae.flushSync(()=>_(l.path))},[]),w=a.useRef({startCreate:E,reload:r.reload,pickUpload:y});a.useEffect(()=>{w.current={startCreate:E,reload:r.reload,pickUpload:y}});const U=d!==null;a.useEffect(()=>{if(g||s===void 0&&U)return;const l=s??k;return l({newFile:()=>w.current.startCreate(Q,"file"),newFolder:()=>w.current.startCreate(Q,"dir"),refresh:()=>w.current.reload(),...U&&{upload:()=>w.current.pickUpload(Q)}}),()=>l(null)},[k,s,g,U]);const te=a.useCallback(async l=>{var se;if(!C||o===null)return;const P=C;if(S(null),d!==null){const re=(((se=c.getQueryData(le(o,P.parent,D)))==null?void 0:se.entries)??[]).find(ot=>ot.name.toLowerCase()===l.toLowerCase());if(P.type==="dir"){if(re!==void 0&&!(re.type==="dir"&&re.name===l)){J.error(ze(l,re));return}S({parent:ee(P.parent,l),type:"file",firstInFolder:l});return}if(re!==void 0){J.error(ze(l,re));return}const rt=ee(P.parent,l);z({path:rt,isNew:!0});return}await r.createEntry(P.parent,l,P.type)&&x(ee(P.parent,l))},[C,o,d,c,D,r,x]),V=a.useCallback(async(l,P)=>{_(null),(d?await d.renameEntry(l,P):await r.renameEntry(l,P))&&x(ee(G(l.path),P))},[d,r,x]);return o===null?e!==void 0?null:t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Select a working directory to browse its files."}):t.jsxs("div",{ref:f,className:Oe("flex h-full flex-col",L&&"ring-ring/60 bg-accent/30 ring-1 ring-inset",n),onDragOver:l=>{d===null||!we(l.dataTransfer.types)||(l.preventDefault(),l.dataTransfer.dropEffect="copy",B(!0))},onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||B(!1)},onDrop:l=>{B(!1),!(d===null||!we(l.dataTransfer.types))&&(l.preventDefault(),u(Q,st(l.dataTransfer).files))},children:[d!==null&&t.jsx("input",{ref:F,type:"file",multiple:!0,hidden:!0,"aria-hidden":!0,tabIndex:-1,"data-testid":"room-files-upload-input",onChange:l=>{const P=Array.from(l.target.files??[]);l.target.value="",u(v.current,P)}}),t.jsxs("div",{className:"min-h-0 flex-1",children:[C&&t.jsx(Fn,{type:C.type,firstInFolder:C.firstInFolder,onSubmit:l=>void te(l),onCancel:()=>S(null)},`${C.parent}:${C.type}:${C.firstInFolder??""}`),R&&M.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(Fe,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):q&&M.length===0?t.jsxs("div",{className:"text-muted-foreground flex min-h-20 flex-col items-center justify-center gap-2 px-4 py-3 text-center text-xs [overflow-wrap:anywhere]",children:[t.jsx("span",{children:b??"Couldn’t load files."}),H!==null&&t.jsx("code",{"aria-label":"Command that removes the settings",className:"bg-muted text-foreground block w-full rounded px-2 py-1.5 text-left font-mono select-all",children:H}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:r.reload,children:[t.jsx(Ke,{}),"Retry"]})]}):M.length===0&&!C?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center px-4 text-center text-xs",children:d!==null?"No files yet. Drop files here, or use Upload.":"Empty directory"}):t.jsx(wn,{rows:M,selectedPath:h,renamingPath:I,errorPaths:$,onSelectPath:x,onToggle:r.toggleExpand,onOpen:l=>{o.preview==="inline"?W(l.path):r.openFile(l)},onRetryDir:r.retryDir,onSubmitRename:(l,P)=>void V(l,P),onCancelRename:()=>_(null),onStartRename:N,onNewFile:l=>E(l,"file"),onNewFolder:l=>E(l,"dir"),onDelete:l=>d?d.requestDelete(l):void r.removeEntry(l),onMove:(l,P)=>void(d?d.moveEntry(l,P):r.moveEntry(l,P)),onCopyInto:(l,P)=>void r.copyEntry(l,P),onCopy:r.copyToClipboard,onPaste:l=>{j&&r.copyEntry(j,l)},onDuplicate:l=>void r.copyEntry({path:l.path,isDir:l.type==="dir"},G(l.path)),canPasteInto:O,readOnly:g,provenance:o.provenance,copyable:d===null,onDisk:o.cwd!==null,onUpload:d?u:void 0,onPickUpload:d?y:void 0,revealLabel:r.revealLabel,onReveal:l=>void r.reveal(l),onAddToChat:r.addToChat,onCopyPath:(l,P)=>void r.copyPath(l,P)})]}),o.preview==="inline"&&t.jsx(Zt,{source:o,path:(A==null?void 0:A.path)??null,isNew:(A==null?void 0:A.isNew)??!1,onCreated:()=>{A!==null&&(z({path:A.path,isNew:!1}),x(A.path))},onClose:()=>z(null)}),d!==null&&t.jsx(Nn,{changes:d,onOpenTheirs:l=>W(l),onReturnFocus:T}),t.jsx(fe,{open:r.pendingRecursiveDelete!==null,onOpenChange:l=>!l&&r.cancelRecursiveDelete(),children:t.jsxs(he,{children:[t.jsxs(pe,{children:[t.jsx(me,{children:"Delete this folder?"}),t.jsxs(xe,{children:["“",(de=r.pendingRecursiveDelete)==null?void 0:de.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(ge,{children:[t.jsx(ye,{onClick:r.cancelRecursiveDelete,children:"Cancel"}),t.jsx(ve,{onClick:()=>void r.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})})]})}function Fn({type:e,firstInFolder:n,onSubmit:s,onCancel:m}){const p=a.useRef(null),[i,o]=a.useState("");a.useEffect(()=>{var d;(d=p.current)==null||d.focus()},[]);const g=()=>{const d=i.trim();d?s(d):m()},r=t.jsxs("div",{className:"flex items-center gap-1",children:[e==="dir"?t.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(Ue,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:p,type:"text",value:i,"aria-label":n!==void 0?`First file in ${n}`:e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:d=>o(d.target.value),onBlur:g,onKeyDown:d=>{d.key==="Enter"?g():d.key==="Escape"&&m()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]});return n===void 0?t.jsx("div",{className:"px-3 py-1",children:r}):t.jsxs("div",{className:"space-y-1 px-3 py-1",children:[t.jsxs("p",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[t.jsx(be,{className:"size-(--size-icon-xs) flex-shrink-0 text-sky-500"}),t.jsx("span",{className:"truncate",children:n})]}),r,t.jsx("p",{className:"text-muted-foreground text-2xs",children:"Name its first file. The folder appears when you save it."})]})}function at(){const e=K(m=>m.showHidden),n=K(m=>m.setShowHidden),s=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:()=>n(!e),children:e?t.jsx(Dt,{className:"text-muted-foreground"}):t.jsx(Rt,{className:"text-muted-foreground"})})}function On({cwd:e}){const n=ne(),{data:s}=ce({queryKey:["file-explorer","workspace",e],queryFn:()=>n.resolveWorkspace(e),staleTime:6e4});return s!=null&&s.branch?t.jsxs("span",{className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",title:`Workspace ${s.key} on ${s.branch}`,children:[t.jsx(Be,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:s.branch})]}):null}function In(){const e=Te(s=>s.selectedCwd),n=K(s=>s.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(On,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>n==null?void 0:n.newFile(),children:t.jsx(et,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>n==null?void 0:n.newFolder(),children:t.jsx(We,{className:"text-muted-foreground"})}),t.jsx(at,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>n==null?void 0:n.refresh(),children:t.jsx(Nt,{className:"text-muted-foreground"})})]}):null}function Pn({roomId:e}){const n=ne(),s=oe(),m=ce(Ye(n,e));a.useEffect(()=>Jt(s,e,()=>{s.invalidateQueries({queryKey:De.repoStatus(e)})}),[s,e]);const p=a.useMemo(()=>{var r;return((r=m.data)==null?void 0:r.kind)==="ok"?St(m.data.status):[]},[m.data]),i=Tt(p),o=Ft(p);if(!o)return null;const g=p.map((r,d)=>`${i[d]}: ${Ot(r)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:g.join(`
|
|
17
17
|
`),className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",children:[t.jsx(Be,{className:"size-3 flex-shrink-0"}),t.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",g.join(". "),"."]}),t.jsx("span",{"aria-hidden":"true",className:"truncate",children:o})]})}const Mn={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},An=new Map([["OPERATOR_ONLY","Only the person who owns this DorkOS can decide what happens to those changes."],["ROOM_FILE_NOT_FOUND","One of those changes is not there any more, so nothing was discarded. The list below has been refreshed."],["MERGE_IN_FLIGHT","Something else is writing to this room’s files right now. Nothing was changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","This room’s files are on another branch, which DorkOS will not move for you. Put them back on main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","This computer doesn’t have git installed, and a room’s files are a git repository."],["ROOM_HAS_NO_REPO","This room does not have files of its own any more."],["ROOM_REPOS_DISABLED","Rooms cannot have files of their own on this install right now."]]);function _n({roomId:e}){var H,$;const n=ne(),s=oe(),m=ce(Ye(n,e)),[p,i]=a.useState([]),[o,g]=a.useState(!1),[r,d]=a.useState(null),c=Pt({mutationFn:k=>n.repairRoomMain(e,k),onSuccess:()=>{i([]),g(!1),d(null),s.invalidateQueries({queryKey:De.repoStatus(e)})},onError:k=>{g(!1);const h=An.get(Mt(k)??"");d(h??"That didn’t work. Try again in a moment."),s.invalidateQueries({queryKey:De.repoStatus(e)})}});if(((H=m.data)==null?void 0:H.kind)==="unavailable")return t.jsx("p",{role:"alert","data-slot":"room-main-warning",className:"border-border/60 text-muted-foreground rounded-lg border px-3 py-2.5 text-xs",children:"DorkOS couldn’t check whether this room’s files are in order. If saving here is refused, this is why. Try again in a moment."});const D=(($=m.data)==null?void 0:$.kind)==="ok"?m.data.status.main:void 0;if(D===void 0||!D.dirty)return null;const M=D.branch!=="main",R=p.filter(k=>D.strays.some(h=>h.path===k)),q=o&&R.length>0,b=k=>i(h=>h.includes(k)?h.filter(x=>x!==k):[...h,k]);return t.jsxs("div",{role:"alert","data-slot":"room-main-warning",className:"border-border/60 bg-muted/40 space-y-3 rounded-lg border px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(At,{className:"text-muted-foreground mt-0.5 size-(--size-icon-sm) flex-shrink-0"}),t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsx("p",{className:"font-medium",children:"Somebody changed this room’s files outside DorkOS"}),t.jsx("p",{className:"text-muted-foreground text-xs",children:M?`This room’s files are on ${D.branch??"no branch"} instead of main. Nobody can save a file here and no agent can merge into it until they are back on main. DorkOS will not move a branch it did not move, in case there is work on it.`:"Nobody can save a file here, and no agent can merge its work in, until these are dealt with."})]})]}),!M&&t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"space-y-1.5",children:D.strays.map(k=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(_t,{id:`stray-${e}-${k.path}`,checked:R.includes(k.path),onCheckedChange:()=>b(k.path),disabled:c.isPending}),t.jsx("label",{htmlFor:`stray-${e}-${k.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:k.path,children:k.path}),t.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:Mn[k.kind]})]},k.path))}),D.strayCount>D.strays.length&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",D.strayCount-D.strays.length," more, not listed here. Keeping them all still keeps every one."]}),q?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs",children:R.length===1?"Throw away that change? It cannot be brought back.":`Throw away those ${R.length} changes? They cannot be brought back.`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:c.isPending,onClick:()=>g(!1),children:"Cancel"}),t.jsx(Y,{type:"button",variant:"destructive",size:"sm",disabled:c.isPending,onClick:()=>c.mutate({action:"discard",paths:[...R]}),children:"Yes, discard"})]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:c.isPending,onClick:()=>c.mutate({action:"commit"}),children:"Keep them all"}),t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:c.isPending||R.length===0,onClick:()=>g(!0),children:R.length===0?"Discard…":`Discard ${R.length}`})]})]}),r!==null&&t.jsx("p",{className:"text-destructive text-xs",children:r})]})}const Ee="pointer-coarse:size-11";function Kn({roomId:e,canChange:n}){const s=ne(),m=oe(),p=K(M=>M.showHidden),[i,o]=a.useState(null),g=a.useMemo(()=>Xe({transport:s,queryClient:m,roomId:e,canChange:n}),[s,m,e,n]),r=ce(ke(g,Q,p,m)),d=r.isSuccess&&r.data.absent!==!0||r.isError,[c,D]=a.useState(null);return d&&c!==e&&D(e),!d&&c!==e?null:t.jsxs("section",{"aria-label":"Room files",className:"space-y-2",children:[t.jsxs("header",{className:"flex items-center gap-2",children:[t.jsx(Lt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Files"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Pn,{roomId:e})}),n&&t.jsxs(t.Fragment,{children:[t.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New file",title:"New file",disabled:i===null,onClick:()=>i==null?void 0:i.newFile(),children:t.jsx(et,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New folder",title:"New folder",disabled:i===null,onClick:()=>i==null?void 0:i.newFolder(),children:t.jsx(We,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"Upload files",title:"Upload files",disabled:(i==null?void 0:i.upload)===void 0,onClick:()=>{var M;return(M=i==null?void 0:i.upload)==null?void 0:M.call(i)},children:t.jsx(nn,{className:"text-muted-foreground"})})]}),t.jsx(at,{})]}),t.jsx(_n,{roomId:e}),t.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:t.jsx(Tn,{source:g,onCommands:o})})]})}function Hn({roomId:e,attachment:n}){var d;const s=ne(),m=oe(),p=a.useMemo(()=>Xe({transport:s,queryClient:m,roomId:e}),[s,m,e]),i=ce(ke(p,Q,!1,m)),[o,g]=a.useState(!1),r=zt(e);return!i.isSuccess||i.data.absent===!0||((d=r.data)==null?void 0:d.archived)!==!1?null:t.jsxs(t.Fragment,{children:[t.jsx(Y,{type:"button",variant:"ghost",size:"icon-xs","aria-label":`Save ${n.name} to the room’s files`,title:"Save to room files",className:"text-muted-foreground hover:text-foreground mt-0.5 pointer-coarse:size-11",onClick:()=>g(!0),children:t.jsx($t,{})}),o&&t.jsx(Ln,{roomId:e,source:p,attachment:n,onClose:()=>g(!1)})]})}function Ln({roomId:e,source:n,attachment:s,onClose:m}){const p=ne(),i=oe(),[o,g]=a.useState(Q),[r,d]=a.useState(s.name),[c,D]=a.useState(null),[M,R]=a.useState(!1),q=a.useId(),b=ce(ke(n,o,!1,i)),H=a.useMemo(()=>{var k;return nt(((k=b.data)==null?void 0:k.entries)??[]).filter(h=>h.type==="dir")},[b.data]),$=async()=>{var h,x;const k=r.trim();if(k!==""){R(!0),D(null);try{await p.saveAttachmentToRoomFiles(e,{attachmentId:s.id,dir:o,name:k,baseCommit:((h=b.data)==null?void 0:h.commit)??null}),i.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),J.success(`Saved ${k} to the room’s files`),m()}catch(j){let C;try{C=en(j,i,e)}catch{C={status:"refused",reason:Ve(j)??"That didn’t save. Try again in a moment."}}if(C.status==="exists"){const S=(((x=b.data)==null?void 0:x.entries)??[]).map(I=>I.name);D({reason:`This folder already has a file called “${k}”. Pick another name.`,suggestion:Pe({name:k,isDir:!1,taken:[...S,k]})})}else C.status==="conflict"?(D({reason:"Somebody changed this folder while you were choosing, so nothing was saved. Try again."}),b.refetch()):C.status==="refused"&&D({reason:C.reason})}finally{R(!1)}}};return t.jsx(It,{open:!0,onOpenChange:k=>!k&&m(),children:t.jsxs(Kt,{className:"sm:max-w-md",children:[t.jsxs(Ht,{children:[t.jsx(Ut,{children:"Save to room files"}),t.jsx(qt,{children:"Keep this file with the room’s files, where everyone in the room and their agents can find it."})]}),t.jsxs(Qt,{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Folder"}),t.jsxs("div",{role:"group","aria-label":"Folders",className:"border-border/60 max-h-56 overflow-auto rounded-md border",children:[t.jsx("p",{className:"bg-muted/40 truncate px-3 py-1.5 font-mono text-xs",children:o===Q?"Top folder":`${o}/`}),o!==Q&&t.jsx($e,{label:"Up one folder",icon:t.jsx(tn,{className:"text-muted-foreground size-(--size-icon-sm)"}),onClick:()=>g(G(o))}),b.isPending?t.jsx("div",{className:"flex h-12 items-center justify-center",children:t.jsx(Fe,{size:"sm",className:"text-muted-foreground",label:"Loading folders"})}):H.length===0?t.jsx("p",{className:"text-muted-foreground px-3 py-2 text-xs",children:"No folders in here."}):H.map(k=>t.jsx($e,{label:k.name,icon:t.jsx(be,{className:"size-(--size-icon-sm) text-sky-500"}),chevron:!0,onClick:()=>g(ee(o,ie(k.path)))},k.path))]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:q,className:"text-muted-foreground text-xs font-medium",children:"Name"}),t.jsx(Bt,{id:q,value:r,onChange:k=>{d(k.target.value),D(null)},spellCheck:!1,autoComplete:"off"})]}),c!==null&&t.jsxs("div",{role:"alert",className:"text-destructive space-y-1 text-xs",children:[t.jsx("p",{children:c.reason}),c.suggestion!==void 0&&t.jsxs(Y,{type:"button",variant:"outline",size:"xs",onClick:()=>{d(c.suggestion),D(null)},children:["Use “",c.suggestion,"”"]})]})]}),t.jsxs(Wt,{className:"gap-2",children:[t.jsx(Y,{type:"button",variant:"ghost",onClick:m,children:"Cancel"}),t.jsx(Y,{type:"button",disabled:M||r.trim()===""||b.isPending,onClick:()=>void $(),children:M?"Saving…":o===Q?"Save to the top folder":`Save to ${ie(o)}`})]})]})})}function $e({label:e,icon:n,chevron:s=!1,onClick:m}){return t.jsxs("button",{type:"button",onClick:m,className:"hover:bg-accent/50 focus-visible:bg-accent flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm outline-none",children:[n,t.jsx("span",{className:"min-w-0 flex-1 truncate",children:e}),s&&t.jsx(He,{className:"text-muted-foreground size-3.5"})]})}export{Tn as FileExplorer,In as FileExplorerActions,Zt as FilePreviewDialog,sn as HIDDEN_ENTRY_NAMES,at as HiddenEntriesToggle,Qn as NO_PROVENANCE,Re as PINNED_ENTRY_NAMES,Bn as ROOM_FILES_REFRESH_INTERVAL_MS,Kn as RoomFilesSection,Hn as SaveToRoomFilesButton,Xe as createRoomFilesSource,mn as createSessionCwdSource,le as explorerDirQueryKey,ke as explorerDirQueryOptions,an as isHiddenEntryName,Ne as isPinnedEntryName,rn as pinnedFirst,Xt as provenanceLine,Ye as roomRepoStatusQueryOptions,nt as withoutHidden};
|