dorkos 0.81.0 → 0.83.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.
Files changed (99) hide show
  1. package/README.md +4 -0
  2. package/dist/bin/cli.js +8980 -3197
  3. package/dist/client/assets/{AboutPage-CG2PlGB9.js → AboutPage-BCPZr0Kt.js} +1 -1
  4. package/dist/client/assets/{AppearancePage-uc6vrPjQ.js → AppearancePage-CJfCCSBv.js} +1 -1
  5. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CZ9OxU7F.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Rg6hvlIh.js} +1 -1
  6. package/dist/client/assets/{BlintzCanvas-C0dWt42q.js → BlintzCanvas-CUSuHP_Q.js} +23 -23
  7. package/dist/client/assets/{CanvasCsvContent-DpTj502y.js → CanvasCsvContent-B3gnlTxe.js} +1 -1
  8. package/dist/client/assets/{CanvasFileContent-BfbMK0ME.js → CanvasFileContent-C2PyVniO.js} +2 -2
  9. package/dist/client/assets/{CanvasModel3dContent-BjkWZBVq.js → CanvasModel3dContent-BU77_Cf0.js} +2 -2
  10. package/dist/client/assets/{CodeMirrorDiff-BtkeZDXX.js → CodeMirrorDiff-Dsell_F0.js} +1 -1
  11. package/dist/client/assets/{CodeMirrorEditor-C2mjcn0M.js → CodeMirrorEditor-DW4-Dilh.js} +1 -1
  12. package/dist/client/assets/ConnectionAccessLists-C6PZsSaI.js +1 -0
  13. package/dist/client/assets/ConnectionsPage-d1mpye9j.js +1 -0
  14. package/dist/client/assets/{ConventionPage-CGoZt1nC.js → ConventionPage-Dto1Cfs1.js} +3 -3
  15. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-Dl7G5M5j.js → FloatingTanStackRouterDevtools-CqogiFob-B8JWq1xE.js} +1 -1
  16. package/dist/client/assets/HandlePage-D9x_OTks.js +1 -0
  17. package/dist/client/assets/{LexicalField-CCu1Ihg3.js → LexicalField-BymSjNLW.js} +1 -1
  18. package/dist/client/assets/{ManagesPage-c1KIJkFC.js → ManagesPage-D0ykMsYy.js} +1 -1
  19. package/dist/client/assets/{Model3dViewer-BO0fwX9g.js → Model3dViewer-DpzkRmRI.js} +1 -1
  20. package/dist/client/assets/NamePage-zm23PjaF.js +1 -0
  21. package/dist/client/assets/{NotificationsPage-BVSSDb9i.js → NotificationsPage-C4Ol8NO6.js} +1 -1
  22. package/dist/client/assets/PermissionsPage-BEtP78wl.js +1 -0
  23. package/dist/client/assets/{PersonalityPopover-CI9kf81k.js → PersonalityPopover-xJuTkLLJ.js} +1 -1
  24. package/dist/client/assets/PhotoPage-DlqgNQWM.js +1 -0
  25. package/dist/client/assets/{RoomsPage-B7s1XM1i.js → RoomsPage-CeB_8k-m.js} +1 -1
  26. package/dist/client/assets/{RunsOnPopover-LTrQIz4S.js → RunsOnPopover-DT6aWGUP.js} +1 -1
  27. package/dist/client/assets/{SessionsPage-FLHcXJLg.js → SessionsPage-CoZhOOr9.js} +2 -2
  28. package/dist/client/assets/SkillsPage-C8bahTTW.js +1 -0
  29. package/dist/client/assets/{TasksPage-CjTt9J5n.js → TasksPage-CuFN--Cj.js} +1 -1
  30. package/dist/client/assets/ToolsPage-C5cJiedq.js +2 -0
  31. package/dist/client/assets/{TopologyGraph-CRAGEuPI.js → TopologyGraph-3rXK5QTB.js} +2 -2
  32. package/dist/client/assets/{agent-browser-DH-qe6tt.js → agent-browser-DaDOSH9H.js} +1 -1
  33. package/dist/client/assets/{highlighted-body-KPVGNVTW-CKyNuC2a.js → highlighted-body-KPVGNVTW-CGXZGdzv.js} +1 -1
  34. package/dist/client/assets/{index-BmHCO7JA.js → index-3xtUyFwf.js} +1 -1
  35. package/dist/client/assets/{index-Cn5LkLHK.js → index-4zzP7Qsj.js} +1 -1
  36. package/dist/client/assets/{index-CugRpUpy.js → index-B2AJ6tkg.js} +1 -1
  37. package/dist/client/assets/{index-C_H8Na06.js → index-B9qRpVKa.js} +3 -3
  38. package/dist/client/assets/index-BMR65QI4.js +1658 -0
  39. package/dist/client/assets/{index-CWuLOWsu.js → index-BabO0TEf.js} +2 -2
  40. package/dist/client/assets/{index-CoJiX2o7.js → index-Bco5PCIk.js} +1 -1
  41. package/dist/client/assets/{index-UTvS0wz6.js → index-Bg2WUou4.js} +1 -1
  42. package/dist/client/assets/{index-CCa_zFfO.js → index-BiKxY3b6.js} +1 -1
  43. package/dist/client/assets/{index-CGYDEGb1.js → index-C4yxotik.js} +1 -1
  44. package/dist/client/assets/index-C9o2w5d_.js +1 -0
  45. package/dist/client/assets/{index-_r_3OCOV.js → index-CUDguphz.js} +1 -1
  46. package/dist/client/assets/{index-DBsoxmLK.js → index-CUXXDUxt.js} +1 -1
  47. package/dist/client/assets/{index-O1R1Ir-o.js → index-CXeb3CZh.js} +1 -1
  48. package/dist/client/assets/{index-BVkt7309.js → index-Cc8vG2jf.js} +1 -1
  49. package/dist/client/assets/{index-DN2SO8dj.js → index-Ce4ArSsI.js} +1 -1
  50. package/dist/client/assets/{index-9FBdK--F.js → index-CemK6fUn.js} +1 -1
  51. package/dist/client/assets/{index-BL-LFVsO.js → index-Ck1VEXu0.js} +1 -1
  52. package/dist/client/assets/{index-BPl8DTOI.js → index-D4OPDslu.js} +1 -1
  53. package/dist/client/assets/index-D9vFzXJR.js +1 -0
  54. package/dist/client/assets/{index-CPiL-M1V.js → index-DPpw-DKV.js} +1 -1
  55. package/dist/client/assets/{index-Bq1ocT_z.js → index-DQdV5YDl.js} +1 -1
  56. package/dist/client/assets/{index-B0rpOocp.js → index-DT376l6b.js} +3 -3
  57. package/dist/client/assets/index-DZ-SO2sz.css +1 -0
  58. package/dist/client/assets/{index-D-nXANER.js → index-DdpxcyXN.js} +1 -1
  59. package/dist/client/assets/{index-BhMgFrop.js → index-FOgsYoCt.js} +1 -1
  60. package/dist/client/assets/{index-BGLRcYYE.js → index-MUbvQBCQ.js} +1 -1
  61. package/dist/client/assets/{index-hnccffr-.js → index-Rf5Yz119.js} +1 -1
  62. package/dist/client/assets/index-Ygg0URfB.js +1 -0
  63. package/dist/client/assets/{index-CT4uhPjz.js → index-bR1UztQC.js} +1 -1
  64. package/dist/client/assets/{index-0R0NT72V.js → index-dDcguWyg.js} +1 -1
  65. package/dist/client/assets/{index-Z0979U-2.js → index-i6WvrE1p.js} +1 -1
  66. package/dist/client/assets/{index-BHz_iLMm.js → index-oU5xA1N3.js} +3 -3
  67. package/dist/client/assets/{index-D2P8UWWS.js → index-pBoKYStL.js} +1 -1
  68. package/dist/client/assets/{index-CgTvuqsz.js → index-rJuQe7Pl.js} +1 -1
  69. package/dist/client/assets/{index-37p1_k_N.js → index-z0vAkUHY.js} +1 -1
  70. package/dist/client/assets/{index-C6itZC0I.js → index-zrZDQvuW.js} +11 -11
  71. package/dist/client/assets/{room-files-source-BmK7_zzB.js → room-files-source-BXF5daqI.js} +2 -2
  72. package/dist/client/assets/{soul-file-0ee-EflV.js → soul-file-C1wnpxhH.js} +1 -1
  73. package/dist/client/assets/{use-mesh-update-D1KVLTOA.js → use-mesh-update-CZIA8V07.js} +1 -1
  74. package/dist/client/assets/{use-personality-commit-KFutjy9j.js → use-personality-commit-OViAsTwD.js} +1 -1
  75. package/dist/client/index.html +5 -4
  76. package/dist/drizzle/0107_productive_peter_parker.sql +5 -0
  77. package/dist/drizzle/0108_magical_morph.sql +2 -0
  78. package/dist/drizzle/0109_aspiring_union_jack.sql +5 -0
  79. package/dist/drizzle/0110_ambiguous_wendigo.sql +1 -0
  80. package/dist/drizzle/meta/0107_snapshot.json +8966 -0
  81. package/dist/drizzle/meta/0108_snapshot.json +8980 -0
  82. package/dist/drizzle/meta/0109_snapshot.json +8987 -0
  83. package/dist/drizzle/meta/0110_snapshot.json +8994 -0
  84. package/dist/drizzle/meta/_journal.json +28 -0
  85. package/dist/server/index.js +105552 -89583
  86. package/dist/server/index.js.map +2 -2
  87. package/package.json +3 -4
  88. package/dist/client/assets/ConnectionAccessLists-CrvGcp6D.js +0 -1
  89. package/dist/client/assets/ConnectionsPage-C2q7w1vY.js +0 -1
  90. package/dist/client/assets/HandlePage-DbVA5ABk.js +0 -1
  91. package/dist/client/assets/NamePage-Cvksm2Vr.js +0 -1
  92. package/dist/client/assets/PhotoPage-DOvne6fS.js +0 -1
  93. package/dist/client/assets/SkillsPage-loa1-bcL.js +0 -1
  94. package/dist/client/assets/ToolsPage-DMnjLq2L.js +0 -2
  95. package/dist/client/assets/index-BaITIF12.js +0 -1
  96. package/dist/client/assets/index-Criu5f4m.js +0 -1
  97. package/dist/client/assets/index-D9FWq0Sm.css +0 -1
  98. package/dist/client/assets/index-DRBI-tjH.js +0 -1
  99. package/dist/client/assets/index-DyAjYNxU.js +0 -1636
@@ -1,7 +1,7 @@
1
- import{e0 as we,fX as re,aV as W,ec as le,w as B,r as l,fY as ke,fZ as z,f_ as H,f$ as S,e5 as oe,g0 as J,g1 as Q,cS as Ee,g2 as Re,bv as je,g3 as Ne,x as V,g4 as Te,g5 as De,et as Se,g6 as Oe,ac as se,g7 as Fe,j as t,aA as ce,ah as de,aM as _e,C as Pe,g8 as Me,d7 as ue,g9 as Ae,fa as he,ff as Le,ag as ae,ga as fe,gb as pe,gc as Ie,eB as ze,eC as Ke,eD as He,eE as K,eF as q,dl as $e,B as Y,dC as Ye,dD as Ue,dE as Be,dF as Qe,dG as qe,dH as We,dI as Ge,dJ as Ve,fl as Xe,gd as Ze,ae as X,ge as me,gf as Je,aU as et,gg as tt,gh as nt,gi as st,gj as at,eb as ee,gk as xe,y as rt,aK as ot,gl as it,gm as lt}from"./index-DyAjYNxU.js";import{p as ct,F as dt,w as ut,c as ht}from"./room-files-source-BmK7_zzB.js";import{N as Xt,R as Zt}from"./room-files-source-BmK7_zzB.js";/**
1
+ import{e3 as we,fY as re,aY as W,ef as le,z as U,r as l,fZ as ke,f_ as z,f$ as H,g0 as S,e8 as oe,g1 as J,g2 as q,cV as Ee,g3 as Re,by as je,g4 as Ne,A as V,g5 as De,g6 as Te,ew as Se,g7 as Oe,af as se,g8 as Fe,j as t,aD as ce,ak as de,aP as _e,C as Pe,g9 as Me,da as ue,ga as Le,fc as he,fh as Ae,aj as ae,gb as fe,gc as pe,gd as Ie,eD as ze,eE as Ke,eF as He,eG as K,eH as B,dp as $e,B as Y,dF as Ye,dG as Qe,dH as Ue,dI as qe,dJ as Be,dK as We,dL as Ge,dM as Ve,fn as Xe,ge as Ze,ah as X,gf as me,gg as Je,aX as et,gh as tt,gi as nt,gj as st,gk as at,ee,gl as xe,D as rt,aN as ot,gm as it,gn as lt}from"./index-BMR65QI4.js";import{p as ct,F as dt,w as ut,c as ht}from"./room-files-source-BXF5daqI.js";import{N as Xt,R as Zt}from"./room-files-source-BXF5daqI.js";/**
2
2
  * @license lucide-react v1.44.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
- */const ge={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"}]]};ge.node;const ft=we(ge),pt=[".git",".dork",".claude",".agents","node_modules"];function mt(e){return e.startsWith(".")||pt.includes(e)}const te=["ROOM.md","README.md"];function ne(e){return te.some(s=>s.toLowerCase()===e.toLowerCase())}function xt(e){return e.filter(s=>!mt(s.name))}function gt(e){if(e.reduce((p,x)=>x.type==="file"&&ne(x.name)?p+1:p,0)===0)return e;const n=[],m=[];for(const p of e)p.type==="file"&&ne(p.name)?n.push(p):m.push(p);return n.sort((p,x)=>te.findIndex(h=>h.toLowerCase()===p.name.toLowerCase())-te.findIndex(h=>h.toLowerCase()===x.name.toLowerCase())),[...n,...m]}function G(e,s,n){return["file-explorer","tree",e.scopeKey,s,e.filtersHidden?n:null]}function ye(e,s,n,m){return{queryKey:G(e,s,n),queryFn:()=>e.list(s,{showHidden:n}),staleTime:re.FILE_TREE_STALE_TIME_MS,gcTime:re.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(G(e,s,!n))}}const yt=["CONFLICT","COPY_INTO_SELF","DIR_NOT_EMPTY","NOT_FOUND","REFUSE_ROOT","OUTSIDE_BOUNDARY"];function ve(e){const s=le(e);return s!==void 0&&yt.includes(s)?s:void 0}const Ce="Can’t copy a folder into itself",vt={CONFLICT:"That name already exists",COPY_INTO_SELF:Ce,DIR_NOT_EMPTY:"This folder isn’t empty",NOT_FOUND:"That item no longer exists",REFUSE_ROOT:"Can’t modify the working directory root",OUTSIDE_BOUNDARY:"That path is outside the working directory"};function $(e,s){const n=ve(e);W.error(n?vt[n]:s)}const Ct=/ copy(?: \d+)?$/;function bt({name:e,isDir:s,taken:n}){const m=new Set(n);if(!m.has(e))return e;const p=s?-1:e.lastIndexOf("."),x=p>0,h=x?e.slice(p):"",a=(x?e.slice(0,p):e).replace(Ct,"");for(let f=1;;f+=1){const v=f===1?`${a} copy${h}`:`${a} copy ${f}${h}`;if(!m.has(v))return v}}function ie(e,s,n){return{name:s,path:e,type:n,size:0,mtime:Date.now(),isSymlink:!1}}function wt(e){const s=B(),{source:n,showHidden:m,queryClient:p,inFlightRef:x}=e,h=n.cwd??"",[a,f]=l.useState(null),v=l.useCallback(async r=>{x.current+=1;try{return await r()}finally{x.current-=1}},[x]),i=l.useMemo(()=>{const r=d=>G(n,d,m);return{getChildren:d=>{var g;return((g=p.getQueryData(r(d)))==null?void 0:g.entries)??[]},isLoaded:d=>p.getQueryData(r(d))!==void 0,takenNames:async d=>(await s.readFileTree(h,{path:d===z?void 0:d,showHidden:!0})).entries.map(C=>C.name),snapshot:d=>p.getQueryData(r(d)),setChildren:(d,g)=>{p.setQueryData(r(d),C=>({entries:ke(g((C==null?void 0:C.entries)??[]))}))},restore:(d,g)=>{p.setQueryData(r(d),g)},invalidate:d=>{p.invalidateQueries({queryKey:r(d),exact:!0})}}},[p,s,h,n,m]),E=l.useCallback((r,d,g)=>v(async()=>{const C=Q(r,d),w=!i.getChildren(r).some(y=>y.path===C),j=i.snapshot(r);w&&i.setChildren(r,y=>[...y,ie(C,d,g)]);try{return await s.createEntry(h,C,g),!0}catch(y){return w&&i.restore(r,j),$(y,`Couldn’t create ${g==="dir"?"folder":"file"}`),!1}finally{i.invalidate(r)}}),[s,h,i,v]),T=l.useCallback((r,d)=>v(async()=>{if(d===r.name||d.length===0)return!0;const g=H(r.path),C=Q(g,d),w=i.getChildren(g).some(N=>N.path===C),j=i.snapshot(g),y={...r,name:d,path:C};w||i.setChildren(g,N=>N.map(A=>A.path===r.path?y:A));try{return await s.renameEntry(h,r.path,C),S.getState().remapExpandedPaths(r.path,C),!0}catch(N){return w||i.restore(g,j),$(N,"Couldn’t rename"),!1}finally{i.invalidate(g)}}),[s,h,i,v]),b=l.useCallback(r=>v(async()=>{const d=H(r.path),g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path,{recursive:!0}),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}}),[s,h,i,v]),M=l.useCallback(r=>v(async()=>{const d=H(r.path);if(r.type==="file"){const g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}return}try{await s.deleteEntry(h,r.path),i.setChildren(d,g=>g.filter(C=>C.path!==r.path)),S.getState().dropExpandedPaths(r.path),i.invalidate(d)}catch(g){if(ve(g)==="DIR_NOT_EMPTY"){f(r);return}$(g,"Couldn’t delete")}}),[s,h,i,v]),_=l.useCallback(async()=>{const r=a;f(null),r&&await b(r)},[a,b]),O=l.useCallback(()=>f(null),[]),P=l.useCallback((r,d)=>v(async()=>{const g=H(r),C=oe(r),w=Q(d,C);if(d===g||w===r||J(d,r))return;const j=i.getChildren(g).find(c=>c.path===r);if(!j)return;const y=i.isLoaded(d),N=y&&i.getChildren(d).some(c=>c.path===w),A={...j,name:C,path:w},u=i.snapshot(g),o=y?i.snapshot(d):void 0;i.setChildren(g,c=>c.filter(k=>k.path!==r)),y&&!N&&i.setChildren(d,c=>[...c,A]);try{await s.renameEntry(h,r,w),S.getState().remapExpandedPaths(r,w)}catch(c){i.restore(g,u),y&&!N&&i.restore(d,o),$(c,"Couldn’t move")}finally{i.invalidate(g),y&&i.invalidate(d)}}),[s,h,i,v]),R=l.useCallback((r,d)=>v(async()=>{if(r.isDir&&J(d,r.path)){W.error(Ce);return}let g;try{g=await i.takenNames(d)}catch(N){$(N,"Couldn’t copy");return}const C=bt({name:oe(r.path),isDir:r.isDir,taken:g}),w=Q(d,C),j=i.isLoaded(d),y=j?i.snapshot(d):void 0;if(j){const N=i.getChildren(H(r.path)).find(u=>u.path===r.path),A=N?{...N,name:C,path:w}:ie(w,C,r.isDir?"dir":"file");i.setChildren(d,u=>[...u,A])}try{await s.copyEntry(h,r.path,w)}catch(N){j&&i.restore(d,y),$(N,"Couldn’t copy")}finally{i.invalidate(d)}}),[s,h,i,v]);return{createEntry:E,renameEntry:T,removeEntry:M,moveEntry:P,copyEntry:R,pendingRecursiveDelete:a,confirmRecursiveDelete:_,cancelRecursiveDelete:O}}function kt(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function Et(e,s){const n=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=n?s.split("/").join("\\"):s;return`${m}${n?"\\":"/"}${p}`}function Rt(e){const s=B(),{data:n}=Ee(),m=l.useMemo(()=>s.supportsReveal?kt(n==null?void 0:n.platform):null,[s.supportsReveal,n==null?void 0:n.platform]),p=l.useCallback(async v=>{if(e)try{await s.revealEntry(e,v.path)}catch(i){$(i,"Couldn’t open the file manager")}},[s,e]),{copy:x}=Re(),h=l.useCallback(async(v,i)=>{const E=i==="absolute"&&e?Et(e,v.path):v.path;await x(E)||W.error("Couldn’t copy to the clipboard")},[e,x]),a=l.useCallback(v=>{je(Ne(v.path))||W.error("Open a chat first to add a file to it")},[]),f=l.useCallback(v=>{S.getState().setClipboard({path:v.path,isDir:v.type==="dir"});try{navigator.clipboard.writeText(v.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:h,addToChat:a,copyToClipboard:f}}const jt={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function Nt(e){var u,o;const s=B(),n=V(),{setTheme:m}=Te(),p=S(c=>c.showHidden),x=S(c=>c.expanded),h=S(c=>c.loadExplorerForCwd),a=S(c=>c.pruneMissing),f=(e==null?void 0:e.scopeKey)??null,v=(e==null?void 0:e.cwd)??null;l.useEffect(()=>{h(f)},[f,h]);const i=l.useMemo(()=>[z,...De(x)],[x]),E=Se({queries:e?i.map(c=>ye(e,c,p,n)):[]}),T=(e==null?void 0:e.filtersHidden)??!0,b=l.useMemo(()=>{const c={};return i.forEach((k,F)=>{var U;const L=E[F];let I=((U=L==null?void 0:L.data)==null?void 0:U.entries)??[];!p&&!T&&(I=xt(I)),k===z&&(I=gt(I)),c[k]={entries:I,loading:(L==null?void 0:L.isLoading)??!1,error:(L==null?void 0:L.isError)??!1}}),c},[i,E,p,T]),M=l.useRef(0),_=l.useRef({});l.useEffect(()=>{M.current>0||i.forEach((c,k)=>{var L,I,U;const F=(I=(L=E[k])==null?void 0:L.data)==null?void 0:I.entries;!F||(U=E[k])!=null&&U.isError||_.current[c]!==F&&(_.current[c]=F,a(c,F.map(D=>D.name)))})},[i,E,a]);const O=l.useMemo(()=>Oe(x,b),[x,b]),P=!!e&&!!((u=b[z])!=null&&u.loading),R=!!e&&!!((o=b[z])!=null&&o.error),r=l.useMemo(()=>{var k;const c=new Set;for(const F of i)F!==z&&((k=b[F])!=null&&k.error)&&c.add(F);return c},[i,b]),d=l.useCallback(c=>{if(c.type!=="dir")return;const k=S.getState();k.setDirExpanded(c.path,!k.expanded[c.path])},[]),g=l.useCallback(c=>{if(c===z)return;const k=S.getState();k.expanded[c]||k.setDirExpanded(c,!0)},[]),C=(e==null?void 0:e.preview)==="canvas",w=l.useCallback(c=>{if(c.type!=="file"||!C)return;const k={getStore:se.getState,setTheme:m,supportsTerminal:s.supportsTerminal};Fe(k,{action:"open_file",sourcePath:c.path},"user")},[C,m,s]),j=l.useCallback(()=>{f!==null&&n.invalidateQueries({queryKey:["file-explorer","tree",f]})},[n,f]),y=l.useCallback(c=>{e!==null&&n.invalidateQueries({queryKey:G(e,c,p),exact:!0})},[n,e,p]);l.useEffect(()=>{if(e!=null&&e.events)return e.events(j)},[e,j]);const N=wt({source:e??jt,showHidden:p,queryClient:n,inFlightRef:M}),A=Rt(v);return{rows:O,rootLoading:P,rootError:R,errorPaths:r,toggleExpand:d,ensureExpanded:g,openFile:w,reload:j,retryDir:y,...N,...A}}function Tt(e){const{transport:s,cwd:n}=e;return{scopeKey:n,cwd:n,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return s.readFileTree(n,{path:m===""?void 0:m,showHidden:p.showHidden})}}}const Dt=12;function St({row:e,selected:s,renaming:n,error:m,onSelect:p,onActivate:x,onRetry:h,onSubmitRename:a,onCancelRename:f,onNewFile:v,onNewFolder:i,onStartRename:E,onDelete:T,onMove:b,onCopyInto:M,onCopy:_,onPaste:O,onDuplicate:P,canPasteInto:R,revealLabel:r,onReveal:d,onAddToChat:g,onCopyPath:C,readOnly:w=!1,provenance:j=!1}){const{entry:y,depth:N,expanded:A,loading:u}=e,o=y.type==="dir",c=o?y.path:H(y.path),[k,F]=l.useState(!1),L=!o&&N===0&&ne(y.name),I=ct(y.lastCommit),U=t.jsxs("div",{role:"treeitem","aria-label":y.name,"aria-expanded":o?A:void 0,"aria-selected":s,tabIndex:-1,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),p(y),x(y))},draggable:!n&&!w,onDragStart:D=>{w||(D.dataTransfer.setData("text/plain",y.path),D.dataTransfer.setData(Ie,y.path),D.dataTransfer.effectAllowed="copyMove")},onDragOver:D=>{D.stopPropagation(),!(w||!o||!pe(D.dataTransfer.types))&&(D.preventDefault(),D.dataTransfer.dropEffect=D.altKey?"copy":"move",F(!0))},onDragLeave:()=>F(!1),onDrop:D=>{if(D.stopPropagation(),w||!o)return;F(!1);const Z=fe(D.dataTransfer);Z!==null&&(D.preventDefault(),D.altKey?M(Z,y.path):b(Z,y.path))},onClick:()=>{p(y),x(y)},className:ae("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",s?"bg-accent text-foreground":"hover:bg-accent/50",k&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:N*Dt+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:o&&(u?t.jsx(ce,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:D=>{D.stopPropagation(),h()},className:"flex items-center justify-center",children:t.jsx(de,{className:"text-destructive size-3.5"})}):A?t.jsx(_e,{className:"text-muted-foreground size-3.5"}):t.jsx(Pe,{className:"text-muted-foreground size-3.5"}))}),o?A?t.jsx(Me,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):y.isSymlink===!0?t.jsx(Ae,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),n?t.jsx(Ot,{initialName:y.name,onSubmit:D=>a(y,D),onCancel:f}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.name}),L&&!n&&t.jsx(Le,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),j&&!n&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:I.title??void 0,children:I.label})]});return w?U:t.jsxs(ze,{children:[t.jsx(Ke,{asChild:!0,children:U}),t.jsxs(He,{className:"w-52",children:[t.jsx(K,{onClick:()=>v(c),children:"New file"}),t.jsx(K,{onClick:()=>i(c),children:"New folder"}),t.jsx(q,{}),r&&t.jsx(K,{onClick:()=>d(y),children:r}),t.jsx(K,{movesFocus:!0,onClick:()=>g(y),children:"Add to chat"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>_(y),children:"Copy"}),t.jsx(K,{disabled:!R(c),onClick:()=>O(c),children:"Paste"}),t.jsx(K,{onClick:()=>P(y),children:"Duplicate"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>C(y,"absolute"),children:"Copy path"}),t.jsx(K,{onClick:()=>C(y,"relative"),children:"Copy relative path"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>E(y),children:"Rename"}),t.jsx(K,{variant:"destructive",onClick:()=>T(y),children:"Delete"})]})]})}function Ot({initialName:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState(e);l.useEffect(()=>{const a=m.current;if(!a)return;a.focus();const f=e.lastIndexOf(".");a.setSelectionRange(0,f>0?f:e.length)},[e]);const h=()=>{const a=p.trim();a&&a!==e?s(a):n()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:a=>x(a.target.value),onClick:a=>a.stopPropagation(),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Ft=100,_t=28,Pt=250;function Mt(e){const{rows:s,selectedPath:n,renamingPath:m,errorPaths:p,onSelectPath:x,onRetryDir:h}=e,a=l.useRef(null),f=S(o=>o.setScrollTop),v=S(o=>o.scopeKey),i=l.useCallback(o=>o.type==="dir"?e.onToggle(o):e.onOpen(o),[e]),E=Lt(e,i),T=s.length>Ft,b=$e({count:s.length,getScrollElement:()=>a.current,estimateSize:()=>_t,overscan:12,enabled:T}),M=l.useRef({scope:void 0,done:!1}),_=l.useRef(null);l.useLayoutEffect(()=>{const o=M.current;if(o.scope!==v&&(o.scope=v,o.done=!1),o.done||s.length===0)return;const c=a.current;if(!c)return;const k=S.getState().scrollTop;if(k<=0){o.done=!0;return}T?b.scrollToOffset(k):c.scrollTop=k,_.current=c.scrollTop,c.scrollTop>=k&&(o.done=!0)},[s.length,v,T,b]);const O=l.useRef(null),P=l.useRef(null),R=l.useCallback(()=>{const o=a.current;o&&o.scrollTop!==_.current&&(M.current.done=!0,O.current=o.scrollTop,P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,O.current!==null&&f(O.current)},Pt))},[f]);l.useEffect(()=>()=>{P.current&&clearTimeout(P.current),O.current!==null&&f(O.current)},[f]);const r=l.useRef(void 0);l.useEffect(()=>{var F,L;const o=r.current;if(r.current=n,o===void 0||n===o||n===null)return;const c=s.findIndex(I=>I.entry.path===n);if(c<0)return;const k=a.current;k&&(T?b.scrollToIndex(c,{align:"auto"}):(L=(F=k.querySelector(`[data-row-index="${c}"]`))==null?void 0:F.scrollIntoView)==null||L.call(F,{block:"nearest"}),_.current=k.scrollTop)},[n,s,T,b]);const[d,g]=l.useState(!1),{onCopyInto:C,onMove:w}=e,j=e.readOnly===!0,y=l.useCallback(o=>{j||!pe(o.dataTransfer.types)||(o.preventDefault(),o.dataTransfer.dropEffect=o.altKey?"copy":"move",g(!0))},[j]),N=l.useCallback((o,c)=>{const k=s.find(F=>F.entry.path===o);k&&C({path:o,isDir:k.entry.type==="dir"},c)},[s,C]),A=l.useCallback(o=>{if(g(!1),j)return;const c=fe(o.dataTransfer);c!==null&&(o.preventDefault(),o.altKey?N(c,z):w(c,z))},[N,w,j]),u=o=>t.jsx(St,{row:o,selected:o.entry.path===n,renaming:o.entry.path===m,error:o.entry.type==="dir"&&o.expanded&&p.has(o.entry.path),onSelect:c=>x(c.path),onActivate:i,onRetry:()=>h(o.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:N,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});return t.jsx("div",{ref:a,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:E,onScroll:R,onDragOver:y,onDragLeave:()=>g(!1),onDrop:A,className:ae("focus-visible:ring-ring/40 h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",d&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:T?t.jsx("div",{style:{height:b.getTotalSize()},className:"relative w-full",children:b.getVirtualItems().map(o=>t.jsx("div",{"data-row-index":o.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${o.start}px)`},children:u(s[o.index])},s[o.index].entry.path))}):s.map((o,c)=>t.jsx("div",{"data-row-index":c,children:u(o)},o.entry.path))})}function At(e){return e?e.type==="dir"?e.path:H(e.path):z}function Lt(e,s){const{rows:n,selectedPath:m,renamingPath:p,onSelectPath:x}=e;return l.useCallback(h=>{var v,i,E,T;if(p!==null)return;const a=n.findIndex(b=>b.entry.path===m),f=a>=0?n[a]:void 0;if(h.metaKey||h.ctrlKey){if(e.readOnly===!0)return;const b=h.key.toLowerCase();if(b==="c"&&f){h.preventDefault(),e.onCopy(f.entry);return}if(b==="v"){h.preventDefault(),e.onPaste(At(f==null?void 0:f.entry));return}return}switch(h.key){case"ArrowDown":h.preventDefault(),x(((v=n[Math.min(a+1,n.length-1)])==null?void 0:v.entry.path)??((i=n[0])==null?void 0:i.entry.path));break;case"ArrowUp":h.preventDefault(),x(((E=n[Math.max(a-1,0)])==null?void 0:E.entry.path)??((T=n[0])==null?void 0:T.entry.path));break;case"ArrowRight":(f==null?void 0:f.entry.type)==="dir"&&!f.expanded&&(h.preventDefault(),e.onToggle(f.entry));break;case"ArrowLeft":if(!f)break;if(h.preventDefault(),f.entry.type==="dir"&&f.expanded)e.onToggle(f.entry);else{const b=H(f.entry.path);b&&x(b)}break;case"Enter":f&&(h.preventDefault(),s(f.entry));break;case"F2":f&&e.readOnly!==!0&&(h.preventDefault(),e.onStartRename(f.entry));break;case"Delete":case"Backspace":f&&e.readOnly!==!0&&(h.preventDefault(),e.onDelete(f.entry));break}},[n,m,p,x,e,s])}function It({source:e,className:s}={}){var A;const n=B(),m=se(u=>u.selectedCwd),p=l.useMemo(()=>m?Tt({transport:n,cwd:m}):null,[n,m]),x=e===void 0?p:e,h=x!==null&&!x.writable,a=Nt(x),{rows:f,rootLoading:v,rootError:i,errorPaths:E}=a,T=S(u=>u.setCommands),b=S(u=>u.selectedPath),M=S(u=>u.setSelectedPath),_=S(u=>u.clipboard),[O,P]=l.useState(null),[R,r]=l.useState(null),[d,g]=l.useState(null),C=l.useCallback(u=>_!==null&&!(_.isDir&&J(u,_.path)),[_]),w=l.useCallback((u,o)=>{a.ensureExpanded(u),r(null),P({parent:u,type:o})},[a]),j=l.useRef({startCreate:w,reload:a.reload});l.useEffect(()=>{j.current={startCreate:w,reload:a.reload}}),l.useEffect(()=>{if(!h)return T({newFile:()=>j.current.startCreate(z,"file"),newFolder:()=>j.current.startCreate(z,"dir"),refresh:()=>j.current.reload()}),()=>T(null)},[T,h]);const y=l.useCallback(async u=>{if(!O)return;const o=O;P(null),await a.createEntry(o.parent,u,o.type)&&M(Q(o.parent,u))},[O,a,M]),N=l.useCallback(async(u,o)=>{r(null),await a.renameEntry(u,o)&&M(Q(H(u.path),o))},[a,M]);return x===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",{className:ae("flex h-full flex-col",s),children:[t.jsxs("div",{className:"min-h-0 flex-1",children:[O&&t.jsx(zt,{type:O.type,onSubmit:u=>void y(u),onCancel:()=>P(null)}),v&&f.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(ce,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):i&&f.length===0?t.jsxs("div",{className:"text-muted-foreground flex h-20 flex-col items-center justify-center gap-2 text-xs",children:[t.jsx("span",{children:"Couldn’t load files."}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:a.reload,children:[t.jsx(de,{}),"Retry"]})]}):f.length===0&&!O?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center text-xs",children:"Empty directory"}):t.jsx(Mt,{rows:f,selectedPath:b,renamingPath:R,errorPaths:E,onSelectPath:M,onToggle:a.toggleExpand,onOpen:u=>{x.preview==="inline"?g(u.path):a.openFile(u)},onRetryDir:a.retryDir,onSubmitRename:(u,o)=>void N(u,o),onCancelRename:()=>r(null),onStartRename:u=>r(u.path),onNewFile:u=>w(u,"file"),onNewFolder:u=>w(u,"dir"),onDelete:u=>void a.removeEntry(u),onMove:(u,o)=>void a.moveEntry(u,o),onCopyInto:(u,o)=>void a.copyEntry(u,o),onCopy:a.copyToClipboard,onPaste:u=>{_&&a.copyEntry(_,u)},onDuplicate:u=>void a.copyEntry({path:u.path,isDir:u.type==="dir"},H(u.path)),canPasteInto:C,readOnly:h,provenance:x.provenance,revealLabel:a.revealLabel,onReveal:u=>void a.reveal(u),onAddToChat:a.addToChat,onCopyPath:(u,o)=>void a.copyPath(u,o)})]}),x.preview==="inline"&&t.jsx(dt,{source:x,path:d,onClose:()=>g(null)}),t.jsx(Ye,{open:a.pendingRecursiveDelete!==null,onOpenChange:u=>!u&&a.cancelRecursiveDelete(),children:t.jsxs(Ue,{children:[t.jsxs(Be,{children:[t.jsx(Qe,{children:"Delete this folder?"}),t.jsxs(qe,{children:["“",(A=a.pendingRecursiveDelete)==null?void 0:A.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(We,{children:[t.jsx(Ge,{onClick:a.cancelRecursiveDelete,children:"Cancel"}),t.jsx(Ve,{onClick:()=>void a.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 text-white",children:"Delete"})]})]})})]})}function zt({type:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState("");l.useEffect(()=>{var a;(a=m.current)==null||a.focus()},[]);const h=()=>{const a=p.trim();a?s(a):n()};return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1",children:[e==="dir"?t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:m,type:"text",value:p,"aria-label":e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:a=>x(a.target.value),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]})}function be(){const e=S(m=>m.showHidden),s=S(m=>m.setShowHidden),n=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":n,title:n,onClick:()=>s(!e),children:e?t.jsx(Xe,{className:"text-muted-foreground"}):t.jsx(Ze,{className:"text-muted-foreground"})})}function Kt({cwd:e}){const s=B(),{data:n}=X({queryKey:["file-explorer","workspace",e],queryFn:()=>s.resolveWorkspace(e),staleTime:6e4});return n!=null&&n.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 ${n.key} on ${n.branch}`,children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:n.branch})]}):null}function qt(){const e=se(n=>n.selectedCwd),s=S(n=>n.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(Kt,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>s==null?void 0:s.newFile(),children:t.jsx(ft,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>s==null?void 0:s.newFolder(),children:t.jsx(Je,{className:"text-muted-foreground"})}),t.jsx(be,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>s==null?void 0:s.refresh(),children:t.jsx(et,{className:"text-muted-foreground"})})]}):null}function Ht({roomId:e}){const s=B(),n=V(),m=X(xe(s,e));l.useEffect(()=>ut(n,e,()=>{n.invalidateQueries({queryKey:ee.repoStatus(e)})}),[n,e]);const p=l.useMemo(()=>{var f;return((f=m.data)==null?void 0:f.kind)==="ok"?tt(m.data.status):[]},[m.data]),x=nt(p),h=st(p);if(!h)return null;const a=p.map((f,v)=>`${x[v]}: ${at(f)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:a.join(`
7
- `),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(me,{className:"size-3 flex-shrink-0"}),t.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",a.join(". "),"."]}),t.jsx("span",{"aria-hidden":"true",className:"truncate",children:h})]})}const $t={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Yt=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 Ut({roomId:e}){var O,P;const s=B(),n=V(),m=X(xe(s,e)),[p,x]=l.useState([]),[h,a]=l.useState(!1),[f,v]=l.useState(null),i=rt({mutationFn:R=>s.repairRoomMain(e,R),onSuccess:()=>{x([]),a(!1),v(null),n.invalidateQueries({queryKey:ee.repoStatus(e)})},onError:R=>{a(!1);const r=Yt.get(le(R)??"");v(r??"That didn’t work. Try again in a moment."),n.invalidateQueries({queryKey:ee.repoStatus(e)})}});if(((O=m.data)==null?void 0:O.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 E=((P=m.data)==null?void 0:P.kind)==="ok"?m.data.status.main:void 0;if(E===void 0||!E.dirty)return null;const T=E.branch!=="main",b=p.filter(R=>E.strays.some(r=>r.path===R)),M=h&&b.length>0,_=R=>x(r=>r.includes(R)?r.filter(d=>d!==R):[...r,R]);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(ot,{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:T?`This room’s files are on ${E.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."})]})]}),!T&&t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"space-y-1.5",children:E.strays.map(R=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(it,{id:`stray-${e}-${R.path}`,checked:b.includes(R.path),onCheckedChange:()=>_(R.path),disabled:i.isPending}),t.jsx("label",{htmlFor:`stray-${e}-${R.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:R.path,children:R.path}),t.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:$t[R.kind]})]},R.path))}),E.strayCount>E.strays.length&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",E.strayCount-E.strays.length," more, not listed here. Keeping them all still keeps every one."]}),M?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs",children:b.length===1?"Throw away that change? It cannot be brought back.":`Throw away those ${b.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:i.isPending,onClick:()=>a(!1),children:"Cancel"}),t.jsx(Y,{type:"button",variant:"destructive",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"discard",paths:[...b]}),children:"Yes, discard"})]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"commit"}),children:"Keep them all"}),t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:i.isPending||b.length===0,onClick:()=>a(!0),children:b.length===0?"Discard…":`Discard ${b.length}`})]})]}),f!==null&&t.jsx("p",{className:"text-destructive text-xs",children:f})]})}function Wt({roomId:e}){const s=B(),n=V(),m=S(v=>v.showHidden),p=l.useMemo(()=>ht({transport:s,queryClient:n,roomId:e}),[s,n,e]),x=X(ye(p,z,m,n)),h=x.isSuccess&&x.data.absent!==!0||x.isError,[a,f]=l.useState(null);return h&&a!==e&&f(e),!h&&a!==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(Ht,{roomId:e})}),t.jsx(be,{})]}),t.jsx(Ut,{roomId:e}),t.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:t.jsx(It,{source:p})})]})}export{It as FileExplorer,qt as FileExplorerActions,dt as FilePreviewDialog,pt as HIDDEN_ENTRY_NAMES,be as HiddenEntriesToggle,Xt as NO_PROVENANCE,te as PINNED_ENTRY_NAMES,Zt as ROOM_FILES_REFRESH_INTERVAL_MS,Wt as RoomFilesSection,ht as createRoomFilesSource,Tt as createSessionCwdSource,G as explorerDirQueryKey,ye as explorerDirQueryOptions,mt as isHiddenEntryName,ne as isPinnedEntryName,gt as pinnedFirst,ct as provenanceLine,xe as roomRepoStatusQueryOptions,xt as withoutHidden};
6
+ */const ge={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"}]]};ge.node;const ft=we(ge),pt=[".git",".dork",".claude",".agents","node_modules"];function mt(e){return e.startsWith(".")||pt.includes(e)}const te=["ROOM.md","README.md"];function ne(e){return te.some(s=>s.toLowerCase()===e.toLowerCase())}function xt(e){return e.filter(s=>!mt(s.name))}function gt(e){if(e.reduce((p,x)=>x.type==="file"&&ne(x.name)?p+1:p,0)===0)return e;const n=[],m=[];for(const p of e)p.type==="file"&&ne(p.name)?n.push(p):m.push(p);return n.sort((p,x)=>te.findIndex(h=>h.toLowerCase()===p.name.toLowerCase())-te.findIndex(h=>h.toLowerCase()===x.name.toLowerCase())),[...n,...m]}function G(e,s,n){return["file-explorer","tree",e.scopeKey,s,e.filtersHidden?n:null]}function ye(e,s,n,m){return{queryKey:G(e,s,n),queryFn:()=>e.list(s,{showHidden:n}),staleTime:re.FILE_TREE_STALE_TIME_MS,gcTime:re.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(G(e,s,!n))}}const yt=["CONFLICT","COPY_INTO_SELF","DIR_NOT_EMPTY","NOT_FOUND","REFUSE_ROOT","OUTSIDE_BOUNDARY"];function ve(e){const s=le(e);return s!==void 0&&yt.includes(s)?s:void 0}const Ce="Can’t copy a folder into itself",vt={CONFLICT:"That name already exists",COPY_INTO_SELF:Ce,DIR_NOT_EMPTY:"This folder isn’t empty",NOT_FOUND:"That item no longer exists",REFUSE_ROOT:"Can’t modify the working directory root",OUTSIDE_BOUNDARY:"That path is outside the working directory"};function $(e,s){const n=ve(e);W.error(n?vt[n]:s)}const Ct=/ copy(?: \d+)?$/;function bt({name:e,isDir:s,taken:n}){const m=new Set(n);if(!m.has(e))return e;const p=s?-1:e.lastIndexOf("."),x=p>0,h=x?e.slice(p):"",a=(x?e.slice(0,p):e).replace(Ct,"");for(let f=1;;f+=1){const v=f===1?`${a} copy${h}`:`${a} copy ${f}${h}`;if(!m.has(v))return v}}function ie(e,s,n){return{name:s,path:e,type:n,size:0,mtime:Date.now(),isSymlink:!1}}function wt(e){const s=U(),{source:n,showHidden:m,queryClient:p,inFlightRef:x}=e,h=n.cwd??"",[a,f]=l.useState(null),v=l.useCallback(async r=>{x.current+=1;try{return await r()}finally{x.current-=1}},[x]),i=l.useMemo(()=>{const r=d=>G(n,d,m);return{getChildren:d=>{var g;return((g=p.getQueryData(r(d)))==null?void 0:g.entries)??[]},isLoaded:d=>p.getQueryData(r(d))!==void 0,takenNames:async d=>(await s.readFileTree(h,{path:d===z?void 0:d,showHidden:!0})).entries.map(C=>C.name),snapshot:d=>p.getQueryData(r(d)),setChildren:(d,g)=>{p.setQueryData(r(d),C=>({entries:ke(g((C==null?void 0:C.entries)??[]))}))},restore:(d,g)=>{p.setQueryData(r(d),g)},invalidate:d=>{p.invalidateQueries({queryKey:r(d),exact:!0})}}},[p,s,h,n,m]),E=l.useCallback((r,d,g)=>v(async()=>{const C=q(r,d),w=!i.getChildren(r).some(y=>y.path===C),j=i.snapshot(r);w&&i.setChildren(r,y=>[...y,ie(C,d,g)]);try{return await s.createEntry(h,C,g),!0}catch(y){return w&&i.restore(r,j),$(y,`Couldn’t create ${g==="dir"?"folder":"file"}`),!1}finally{i.invalidate(r)}}),[s,h,i,v]),D=l.useCallback((r,d)=>v(async()=>{if(d===r.name||d.length===0)return!0;const g=H(r.path),C=q(g,d),w=i.getChildren(g).some(N=>N.path===C),j=i.snapshot(g),y={...r,name:d,path:C};w||i.setChildren(g,N=>N.map(L=>L.path===r.path?y:L));try{return await s.renameEntry(h,r.path,C),S.getState().remapExpandedPaths(r.path,C),!0}catch(N){return w||i.restore(g,j),$(N,"Couldn’t rename"),!1}finally{i.invalidate(g)}}),[s,h,i,v]),b=l.useCallback(r=>v(async()=>{const d=H(r.path),g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path,{recursive:!0}),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}}),[s,h,i,v]),M=l.useCallback(r=>v(async()=>{const d=H(r.path);if(r.type==="file"){const g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}return}try{await s.deleteEntry(h,r.path),i.setChildren(d,g=>g.filter(C=>C.path!==r.path)),S.getState().dropExpandedPaths(r.path),i.invalidate(d)}catch(g){if(ve(g)==="DIR_NOT_EMPTY"){f(r);return}$(g,"Couldn’t delete")}}),[s,h,i,v]),_=l.useCallback(async()=>{const r=a;f(null),r&&await b(r)},[a,b]),O=l.useCallback(()=>f(null),[]),P=l.useCallback((r,d)=>v(async()=>{const g=H(r),C=oe(r),w=q(d,C);if(d===g||w===r||J(d,r))return;const j=i.getChildren(g).find(c=>c.path===r);if(!j)return;const y=i.isLoaded(d),N=y&&i.getChildren(d).some(c=>c.path===w),L={...j,name:C,path:w},u=i.snapshot(g),o=y?i.snapshot(d):void 0;i.setChildren(g,c=>c.filter(k=>k.path!==r)),y&&!N&&i.setChildren(d,c=>[...c,L]);try{await s.renameEntry(h,r,w),S.getState().remapExpandedPaths(r,w)}catch(c){i.restore(g,u),y&&!N&&i.restore(d,o),$(c,"Couldn’t move")}finally{i.invalidate(g),y&&i.invalidate(d)}}),[s,h,i,v]),R=l.useCallback((r,d)=>v(async()=>{if(r.isDir&&J(d,r.path)){W.error(Ce);return}let g;try{g=await i.takenNames(d)}catch(N){$(N,"Couldn’t copy");return}const C=bt({name:oe(r.path),isDir:r.isDir,taken:g}),w=q(d,C),j=i.isLoaded(d),y=j?i.snapshot(d):void 0;if(j){const N=i.getChildren(H(r.path)).find(u=>u.path===r.path),L=N?{...N,name:C,path:w}:ie(w,C,r.isDir?"dir":"file");i.setChildren(d,u=>[...u,L])}try{await s.copyEntry(h,r.path,w)}catch(N){j&&i.restore(d,y),$(N,"Couldn’t copy")}finally{i.invalidate(d)}}),[s,h,i,v]);return{createEntry:E,renameEntry:D,removeEntry:M,moveEntry:P,copyEntry:R,pendingRecursiveDelete:a,confirmRecursiveDelete:_,cancelRecursiveDelete:O}}function kt(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function Et(e,s){const n=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=n?s.split("/").join("\\"):s;return`${m}${n?"\\":"/"}${p}`}function Rt(e){const s=U(),{data:n}=Ee(),m=l.useMemo(()=>s.supportsReveal?kt(n==null?void 0:n.platform):null,[s.supportsReveal,n==null?void 0:n.platform]),p=l.useCallback(async v=>{if(e)try{await s.revealEntry(e,v.path)}catch(i){$(i,"Couldn’t open the file manager")}},[s,e]),{copy:x}=Re(),h=l.useCallback(async(v,i)=>{const E=i==="absolute"&&e?Et(e,v.path):v.path;await x(E)||W.error("Couldn’t copy to the clipboard")},[e,x]),a=l.useCallback(v=>{je(Ne(v.path))||W.error("Open a chat first to add a file to it")},[]),f=l.useCallback(v=>{S.getState().setClipboard({path:v.path,isDir:v.type==="dir"});try{navigator.clipboard.writeText(v.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:h,addToChat:a,copyToClipboard:f}}const jt={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function Nt(e){var u,o;const s=U(),n=V(),{setTheme:m}=De(),p=S(c=>c.showHidden),x=S(c=>c.expanded),h=S(c=>c.loadExplorerForCwd),a=S(c=>c.pruneMissing),f=(e==null?void 0:e.scopeKey)??null,v=(e==null?void 0:e.cwd)??null;l.useEffect(()=>{h(f)},[f,h]);const i=l.useMemo(()=>[z,...Te(x)],[x]),E=Se({queries:e?i.map(c=>ye(e,c,p,n)):[]}),D=(e==null?void 0:e.filtersHidden)??!0,b=l.useMemo(()=>{const c={};return i.forEach((k,F)=>{var Q;const A=E[F];let I=((Q=A==null?void 0:A.data)==null?void 0:Q.entries)??[];!p&&!D&&(I=xt(I)),k===z&&(I=gt(I)),c[k]={entries:I,loading:(A==null?void 0:A.isLoading)??!1,error:(A==null?void 0:A.isError)??!1}}),c},[i,E,p,D]),M=l.useRef(0),_=l.useRef({});l.useEffect(()=>{M.current>0||i.forEach((c,k)=>{var A,I,Q;const F=(I=(A=E[k])==null?void 0:A.data)==null?void 0:I.entries;!F||(Q=E[k])!=null&&Q.isError||_.current[c]!==F&&(_.current[c]=F,a(c,F.map(T=>T.name)))})},[i,E,a]);const O=l.useMemo(()=>Oe(x,b),[x,b]),P=!!e&&!!((u=b[z])!=null&&u.loading),R=!!e&&!!((o=b[z])!=null&&o.error),r=l.useMemo(()=>{var k;const c=new Set;for(const F of i)F!==z&&((k=b[F])!=null&&k.error)&&c.add(F);return c},[i,b]),d=l.useCallback(c=>{if(c.type!=="dir")return;const k=S.getState();k.setDirExpanded(c.path,!k.expanded[c.path])},[]),g=l.useCallback(c=>{if(c===z)return;const k=S.getState();k.expanded[c]||k.setDirExpanded(c,!0)},[]),C=(e==null?void 0:e.preview)==="canvas",w=l.useCallback(c=>{if(c.type!=="file"||!C)return;const k={getStore:se.getState,setTheme:m,supportsTerminal:s.supportsTerminal};Fe(k,{action:"open_file",sourcePath:c.path},"user")},[C,m,s]),j=l.useCallback(()=>{f!==null&&n.invalidateQueries({queryKey:["file-explorer","tree",f]})},[n,f]),y=l.useCallback(c=>{e!==null&&n.invalidateQueries({queryKey:G(e,c,p),exact:!0})},[n,e,p]);l.useEffect(()=>{if(e!=null&&e.events)return e.events(j)},[e,j]);const N=wt({source:e??jt,showHidden:p,queryClient:n,inFlightRef:M}),L=Rt(v);return{rows:O,rootLoading:P,rootError:R,errorPaths:r,toggleExpand:d,ensureExpanded:g,openFile:w,reload:j,retryDir:y,...N,...L}}function Dt(e){const{transport:s,cwd:n}=e;return{scopeKey:n,cwd:n,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return s.readFileTree(n,{path:m===""?void 0:m,showHidden:p.showHidden})}}}const Tt=12;function St({row:e,selected:s,renaming:n,error:m,onSelect:p,onActivate:x,onRetry:h,onSubmitRename:a,onCancelRename:f,onNewFile:v,onNewFolder:i,onStartRename:E,onDelete:D,onMove:b,onCopyInto:M,onCopy:_,onPaste:O,onDuplicate:P,canPasteInto:R,revealLabel:r,onReveal:d,onAddToChat:g,onCopyPath:C,readOnly:w=!1,provenance:j=!1}){const{entry:y,depth:N,expanded:L,loading:u}=e,o=y.type==="dir",c=o?y.path:H(y.path),[k,F]=l.useState(!1),A=!o&&N===0&&ne(y.name),I=ct(y.lastCommit),Q=t.jsxs("div",{role:"treeitem","aria-label":y.name,"aria-expanded":o?L:void 0,"aria-selected":s,tabIndex:-1,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),p(y),x(y))},draggable:!n&&!w,onDragStart:T=>{w||(T.dataTransfer.setData("text/plain",y.path),T.dataTransfer.setData(Ie,y.path),T.dataTransfer.effectAllowed="copyMove")},onDragOver:T=>{T.stopPropagation(),!(w||!o||!pe(T.dataTransfer.types))&&(T.preventDefault(),T.dataTransfer.dropEffect=T.altKey?"copy":"move",F(!0))},onDragLeave:()=>F(!1),onDrop:T=>{if(T.stopPropagation(),w||!o)return;F(!1);const Z=fe(T.dataTransfer);Z!==null&&(T.preventDefault(),T.altKey?M(Z,y.path):b(Z,y.path))},onClick:()=>{p(y),x(y)},className:ae("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",s?"bg-accent text-foreground":"hover:bg-accent/50",k&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:N*Tt+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:o&&(u?t.jsx(ce,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:T=>{T.stopPropagation(),h()},className:"flex items-center justify-center",children:t.jsx(de,{className:"text-destructive size-3.5"})}):L?t.jsx(_e,{className:"text-muted-foreground size-3.5"}):t.jsx(Pe,{className:"text-muted-foreground size-3.5"}))}),o?L?t.jsx(Me,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):y.isSymlink===!0?t.jsx(Le,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),n?t.jsx(Ot,{initialName:y.name,onSubmit:T=>a(y,T),onCancel:f}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.name}),A&&!n&&t.jsx(Ae,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),j&&!n&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:I.title??void 0,children:I.label})]});return w?Q:t.jsxs(ze,{children:[t.jsx(Ke,{asChild:!0,children:Q}),t.jsxs(He,{className:"w-52",children:[t.jsx(K,{onClick:()=>v(c),children:"New file"}),t.jsx(K,{onClick:()=>i(c),children:"New folder"}),t.jsx(B,{}),r&&t.jsx(K,{onClick:()=>d(y),children:r}),t.jsx(K,{movesFocus:!0,onClick:()=>g(y),children:"Add to chat"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>_(y),children:"Copy"}),t.jsx(K,{disabled:!R(c),onClick:()=>O(c),children:"Paste"}),t.jsx(K,{onClick:()=>P(y),children:"Duplicate"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>C(y,"absolute"),children:"Copy path"}),t.jsx(K,{onClick:()=>C(y,"relative"),children:"Copy relative path"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>E(y),children:"Rename"}),t.jsx(K,{variant:"destructive",onClick:()=>D(y),children:"Delete"})]})]})}function Ot({initialName:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState(e);l.useEffect(()=>{const a=m.current;if(!a)return;a.focus();const f=e.lastIndexOf(".");a.setSelectionRange(0,f>0?f:e.length)},[e]);const h=()=>{const a=p.trim();a&&a!==e?s(a):n()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:a=>x(a.target.value),onClick:a=>a.stopPropagation(),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Ft=100,_t=28,Pt=250;function Mt(e){const{rows:s,selectedPath:n,renamingPath:m,errorPaths:p,onSelectPath:x,onRetryDir:h}=e,a=l.useRef(null),f=S(o=>o.setScrollTop),v=S(o=>o.scopeKey),i=l.useCallback(o=>o.type==="dir"?e.onToggle(o):e.onOpen(o),[e]),E=At(e,i),D=s.length>Ft,b=$e({count:s.length,getScrollElement:()=>a.current,estimateSize:()=>_t,overscan:12,enabled:D}),M=l.useRef({scope:void 0,done:!1}),_=l.useRef(null);l.useLayoutEffect(()=>{const o=M.current;if(o.scope!==v&&(o.scope=v,o.done=!1),o.done||s.length===0)return;const c=a.current;if(!c)return;const k=S.getState().scrollTop;if(k<=0){o.done=!0;return}D?b.scrollToOffset(k):c.scrollTop=k,_.current=c.scrollTop,c.scrollTop>=k&&(o.done=!0)},[s.length,v,D,b]);const O=l.useRef(null),P=l.useRef(null),R=l.useCallback(()=>{const o=a.current;o&&o.scrollTop!==_.current&&(M.current.done=!0,O.current=o.scrollTop,P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,O.current!==null&&f(O.current)},Pt))},[f]);l.useEffect(()=>()=>{P.current&&clearTimeout(P.current),O.current!==null&&f(O.current)},[f]);const r=l.useRef(void 0);l.useEffect(()=>{var F,A;const o=r.current;if(r.current=n,o===void 0||n===o||n===null)return;const c=s.findIndex(I=>I.entry.path===n);if(c<0)return;const k=a.current;k&&(D?b.scrollToIndex(c,{align:"auto"}):(A=(F=k.querySelector(`[data-row-index="${c}"]`))==null?void 0:F.scrollIntoView)==null||A.call(F,{block:"nearest"}),_.current=k.scrollTop)},[n,s,D,b]);const[d,g]=l.useState(!1),{onCopyInto:C,onMove:w}=e,j=e.readOnly===!0,y=l.useCallback(o=>{j||!pe(o.dataTransfer.types)||(o.preventDefault(),o.dataTransfer.dropEffect=o.altKey?"copy":"move",g(!0))},[j]),N=l.useCallback((o,c)=>{const k=s.find(F=>F.entry.path===o);k&&C({path:o,isDir:k.entry.type==="dir"},c)},[s,C]),L=l.useCallback(o=>{if(g(!1),j)return;const c=fe(o.dataTransfer);c!==null&&(o.preventDefault(),o.altKey?N(c,z):w(c,z))},[N,w,j]),u=o=>t.jsx(St,{row:o,selected:o.entry.path===n,renaming:o.entry.path===m,error:o.entry.type==="dir"&&o.expanded&&p.has(o.entry.path),onSelect:c=>x(c.path),onActivate:i,onRetry:()=>h(o.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:N,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});return t.jsx("div",{ref:a,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:E,onScroll:R,onDragOver:y,onDragLeave:()=>g(!1),onDrop:L,className:ae("focus-visible:ring-ring/40 h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",d&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:D?t.jsx("div",{style:{height:b.getTotalSize()},className:"relative w-full",children:b.getVirtualItems().map(o=>t.jsx("div",{"data-row-index":o.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${o.start}px)`},children:u(s[o.index])},s[o.index].entry.path))}):s.map((o,c)=>t.jsx("div",{"data-row-index":c,children:u(o)},o.entry.path))})}function Lt(e){return e?e.type==="dir"?e.path:H(e.path):z}function At(e,s){const{rows:n,selectedPath:m,renamingPath:p,onSelectPath:x}=e;return l.useCallback(h=>{var v,i,E,D;if(p!==null)return;const a=n.findIndex(b=>b.entry.path===m),f=a>=0?n[a]:void 0;if(h.metaKey||h.ctrlKey){if(e.readOnly===!0)return;const b=h.key.toLowerCase();if(b==="c"&&f){h.preventDefault(),e.onCopy(f.entry);return}if(b==="v"){h.preventDefault(),e.onPaste(Lt(f==null?void 0:f.entry));return}return}switch(h.key){case"ArrowDown":h.preventDefault(),x(((v=n[Math.min(a+1,n.length-1)])==null?void 0:v.entry.path)??((i=n[0])==null?void 0:i.entry.path));break;case"ArrowUp":h.preventDefault(),x(((E=n[Math.max(a-1,0)])==null?void 0:E.entry.path)??((D=n[0])==null?void 0:D.entry.path));break;case"ArrowRight":(f==null?void 0:f.entry.type)==="dir"&&!f.expanded&&(h.preventDefault(),e.onToggle(f.entry));break;case"ArrowLeft":if(!f)break;if(h.preventDefault(),f.entry.type==="dir"&&f.expanded)e.onToggle(f.entry);else{const b=H(f.entry.path);b&&x(b)}break;case"Enter":f&&(h.preventDefault(),s(f.entry));break;case"F2":f&&e.readOnly!==!0&&(h.preventDefault(),e.onStartRename(f.entry));break;case"Delete":case"Backspace":f&&e.readOnly!==!0&&(h.preventDefault(),e.onDelete(f.entry));break}},[n,m,p,x,e,s])}function It({source:e,className:s}={}){var L;const n=U(),m=se(u=>u.selectedCwd),p=l.useMemo(()=>m?Dt({transport:n,cwd:m}):null,[n,m]),x=e===void 0?p:e,h=x!==null&&!x.writable,a=Nt(x),{rows:f,rootLoading:v,rootError:i,errorPaths:E}=a,D=S(u=>u.setCommands),b=S(u=>u.selectedPath),M=S(u=>u.setSelectedPath),_=S(u=>u.clipboard),[O,P]=l.useState(null),[R,r]=l.useState(null),[d,g]=l.useState(null),C=l.useCallback(u=>_!==null&&!(_.isDir&&J(u,_.path)),[_]),w=l.useCallback((u,o)=>{a.ensureExpanded(u),r(null),P({parent:u,type:o})},[a]),j=l.useRef({startCreate:w,reload:a.reload});l.useEffect(()=>{j.current={startCreate:w,reload:a.reload}}),l.useEffect(()=>{if(!h)return D({newFile:()=>j.current.startCreate(z,"file"),newFolder:()=>j.current.startCreate(z,"dir"),refresh:()=>j.current.reload()}),()=>D(null)},[D,h]);const y=l.useCallback(async u=>{if(!O)return;const o=O;P(null),await a.createEntry(o.parent,u,o.type)&&M(q(o.parent,u))},[O,a,M]),N=l.useCallback(async(u,o)=>{r(null),await a.renameEntry(u,o)&&M(q(H(u.path),o))},[a,M]);return x===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",{className:ae("flex h-full flex-col",s),children:[t.jsxs("div",{className:"min-h-0 flex-1",children:[O&&t.jsx(zt,{type:O.type,onSubmit:u=>void y(u),onCancel:()=>P(null)}),v&&f.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(ce,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):i&&f.length===0?t.jsxs("div",{className:"text-muted-foreground flex h-20 flex-col items-center justify-center gap-2 text-xs",children:[t.jsx("span",{children:"Couldn’t load files."}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:a.reload,children:[t.jsx(de,{}),"Retry"]})]}):f.length===0&&!O?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center text-xs",children:"Empty directory"}):t.jsx(Mt,{rows:f,selectedPath:b,renamingPath:R,errorPaths:E,onSelectPath:M,onToggle:a.toggleExpand,onOpen:u=>{x.preview==="inline"?g(u.path):a.openFile(u)},onRetryDir:a.retryDir,onSubmitRename:(u,o)=>void N(u,o),onCancelRename:()=>r(null),onStartRename:u=>r(u.path),onNewFile:u=>w(u,"file"),onNewFolder:u=>w(u,"dir"),onDelete:u=>void a.removeEntry(u),onMove:(u,o)=>void a.moveEntry(u,o),onCopyInto:(u,o)=>void a.copyEntry(u,o),onCopy:a.copyToClipboard,onPaste:u=>{_&&a.copyEntry(_,u)},onDuplicate:u=>void a.copyEntry({path:u.path,isDir:u.type==="dir"},H(u.path)),canPasteInto:C,readOnly:h,provenance:x.provenance,revealLabel:a.revealLabel,onReveal:u=>void a.reveal(u),onAddToChat:a.addToChat,onCopyPath:(u,o)=>void a.copyPath(u,o)})]}),x.preview==="inline"&&t.jsx(dt,{source:x,path:d,onClose:()=>g(null)}),t.jsx(Ye,{open:a.pendingRecursiveDelete!==null,onOpenChange:u=>!u&&a.cancelRecursiveDelete(),children:t.jsxs(Qe,{children:[t.jsxs(Ue,{children:[t.jsx(qe,{children:"Delete this folder?"}),t.jsxs(Be,{children:["“",(L=a.pendingRecursiveDelete)==null?void 0:L.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(We,{children:[t.jsx(Ge,{onClick:a.cancelRecursiveDelete,children:"Cancel"}),t.jsx(Ve,{onClick:()=>void a.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})})]})}function zt({type:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState("");l.useEffect(()=>{var a;(a=m.current)==null||a.focus()},[]);const h=()=>{const a=p.trim();a?s(a):n()};return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1",children:[e==="dir"?t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:m,type:"text",value:p,"aria-label":e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:a=>x(a.target.value),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]})}function be(){const e=S(m=>m.showHidden),s=S(m=>m.setShowHidden),n=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":n,title:n,onClick:()=>s(!e),children:e?t.jsx(Xe,{className:"text-muted-foreground"}):t.jsx(Ze,{className:"text-muted-foreground"})})}function Kt({cwd:e}){const s=U(),{data:n}=X({queryKey:["file-explorer","workspace",e],queryFn:()=>s.resolveWorkspace(e),staleTime:6e4});return n!=null&&n.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 ${n.key} on ${n.branch}`,children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:n.branch})]}):null}function Bt(){const e=se(n=>n.selectedCwd),s=S(n=>n.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(Kt,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>s==null?void 0:s.newFile(),children:t.jsx(ft,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>s==null?void 0:s.newFolder(),children:t.jsx(Je,{className:"text-muted-foreground"})}),t.jsx(be,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>s==null?void 0:s.refresh(),children:t.jsx(et,{className:"text-muted-foreground"})})]}):null}function Ht({roomId:e}){const s=U(),n=V(),m=X(xe(s,e));l.useEffect(()=>ut(n,e,()=>{n.invalidateQueries({queryKey:ee.repoStatus(e)})}),[n,e]);const p=l.useMemo(()=>{var f;return((f=m.data)==null?void 0:f.kind)==="ok"?tt(m.data.status):[]},[m.data]),x=nt(p),h=st(p);if(!h)return null;const a=p.map((f,v)=>`${x[v]}: ${at(f)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:a.join(`
7
+ `),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(me,{className:"size-3 flex-shrink-0"}),t.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",a.join(". "),"."]}),t.jsx("span",{"aria-hidden":"true",className:"truncate",children:h})]})}const $t={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Yt=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 Qt({roomId:e}){var O,P;const s=U(),n=V(),m=X(xe(s,e)),[p,x]=l.useState([]),[h,a]=l.useState(!1),[f,v]=l.useState(null),i=rt({mutationFn:R=>s.repairRoomMain(e,R),onSuccess:()=>{x([]),a(!1),v(null),n.invalidateQueries({queryKey:ee.repoStatus(e)})},onError:R=>{a(!1);const r=Yt.get(le(R)??"");v(r??"That didn’t work. Try again in a moment."),n.invalidateQueries({queryKey:ee.repoStatus(e)})}});if(((O=m.data)==null?void 0:O.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 E=((P=m.data)==null?void 0:P.kind)==="ok"?m.data.status.main:void 0;if(E===void 0||!E.dirty)return null;const D=E.branch!=="main",b=p.filter(R=>E.strays.some(r=>r.path===R)),M=h&&b.length>0,_=R=>x(r=>r.includes(R)?r.filter(d=>d!==R):[...r,R]);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(ot,{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:D?`This room’s files are on ${E.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."})]})]}),!D&&t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"space-y-1.5",children:E.strays.map(R=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(it,{id:`stray-${e}-${R.path}`,checked:b.includes(R.path),onCheckedChange:()=>_(R.path),disabled:i.isPending}),t.jsx("label",{htmlFor:`stray-${e}-${R.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:R.path,children:R.path}),t.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:$t[R.kind]})]},R.path))}),E.strayCount>E.strays.length&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",E.strayCount-E.strays.length," more, not listed here. Keeping them all still keeps every one."]}),M?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs",children:b.length===1?"Throw away that change? It cannot be brought back.":`Throw away those ${b.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:i.isPending,onClick:()=>a(!1),children:"Cancel"}),t.jsx(Y,{type:"button",variant:"destructive",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"discard",paths:[...b]}),children:"Yes, discard"})]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"commit"}),children:"Keep them all"}),t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:i.isPending||b.length===0,onClick:()=>a(!0),children:b.length===0?"Discard…":`Discard ${b.length}`})]})]}),f!==null&&t.jsx("p",{className:"text-destructive text-xs",children:f})]})}function Wt({roomId:e}){const s=U(),n=V(),m=S(v=>v.showHidden),p=l.useMemo(()=>ht({transport:s,queryClient:n,roomId:e}),[s,n,e]),x=X(ye(p,z,m,n)),h=x.isSuccess&&x.data.absent!==!0||x.isError,[a,f]=l.useState(null);return h&&a!==e&&f(e),!h&&a!==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(Ht,{roomId:e})}),t.jsx(be,{})]}),t.jsx(Qt,{roomId:e}),t.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:t.jsx(It,{source:p})})]})}export{It as FileExplorer,Bt as FileExplorerActions,dt as FilePreviewDialog,pt as HIDDEN_ENTRY_NAMES,be as HiddenEntriesToggle,Xt as NO_PROVENANCE,te as PINNED_ENTRY_NAMES,Zt as ROOM_FILES_REFRESH_INTERVAL_MS,Wt as RoomFilesSection,ht as createRoomFilesSource,Dt as createSessionCwdSource,G as explorerDirQueryKey,ye as explorerDirQueryOptions,mt as isHiddenEntryName,ne as isPinnedEntryName,gt as pinnedFirst,ct as provenanceLine,xe as roomRepoStatusQueryOptions,xt as withoutHidden};