dorkos 0.111.0 → 0.114.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 (192) hide show
  1. package/core-extensions/hello-world/index.ts +2 -2
  2. package/dist/bin/cli.js +13549 -1698
  3. package/dist/browser/native/package-manifest.json +1 -1
  4. package/dist/browser/source-manifest.json +1 -1
  5. package/dist/client/assets/{AboutPage-BKzqcz_A.js → AboutPage-mErbIY0l.js} +1 -1
  6. package/dist/client/assets/{ActivityErrorState-BXOZg9ve.js → ActivityErrorState-AlI4F82u.js} +1 -1
  7. package/dist/client/assets/{ActivityPage-CFN2MEAV.js → ActivityPage-CHUqb-8c.js} +1 -1
  8. package/dist/client/assets/{ActivityRow-CujXx04u.js → ActivityRow-Baqdr6cP.js} +1 -1
  9. package/dist/client/assets/AdapterIcon-C_fBZXHQ.js +1 -0
  10. package/dist/client/assets/{AdapterSetupWizard-3Bt9HEWF.js → AdapterSetupWizard-BL70qy2J.js} +2 -2
  11. package/dist/client/assets/{AgentRequestCard-CAaBGC0L.js → AgentRequestCard-CcMh6JyE.js} +3 -3
  12. package/dist/client/assets/{AppearancePage-BEe-Gssu.js → AppearancePage-t9SnSRs-.js} +1 -1
  13. package/dist/client/assets/{AttentionSignalRow-Cp0AJs73.js → AttentionSignalRow-jlgWaSSd.js} +1 -1
  14. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-CN1iW2cB.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-DHr_AhUv.js} +3 -3
  15. package/dist/client/assets/{BlintzCanvas-B7qs2dxW.js → BlintzCanvas-Bq4e7n__.js} +1 -1
  16. package/dist/client/assets/{CanvasCsvContent-DiB5zXOC.js → CanvasCsvContent-OR226CLS.js} +2 -2
  17. package/dist/client/assets/CanvasFileContent-BejM-9Wg.js +2 -0
  18. package/dist/client/assets/CanvasModel3dContent-BD-eCVsX.js +2 -0
  19. package/dist/client/assets/{CodeMirrorDiff-BJhflpbC.js → CodeMirrorDiff-D7BWMOim.js} +1 -1
  20. package/dist/client/assets/{CodeMirrorEditor-SkdXRKSN.js → CodeMirrorEditor-BodwsIG7.js} +1 -1
  21. package/dist/client/assets/{CommitmentList-DsEn6iK1.js → CommitmentList-YVb3yTvO.js} +1 -1
  22. package/dist/client/assets/{CommitmentsPage-W5h0GjRr.js → CommitmentsPage-DL_jJQbw.js} +1 -1
  23. package/dist/client/assets/{ConnectionAccessLists-DVFqelmV.js → ConnectionAccessLists-BPsgToSR.js} +1 -1
  24. package/dist/client/assets/{ConnectionsPage-CZhSh2mO.js → ConnectionsPage-D7vlYnjf.js} +2 -2
  25. package/dist/client/assets/{ConventionPage-DcDBP-vR.js → ConventionPage-BR7I3AdE.js} +3 -3
  26. package/dist/client/assets/{ExtensionPageRoute-mKN8Jqyx.js → ExtensionPageRoute-CzXGvVRm.js} +2 -2
  27. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-CGXG-x9g.js → FloatingTanStackRouterDevtools-CqogiFob-BV3h0rFa.js} +1 -1
  28. package/dist/client/assets/HandlePage-B33P0oh0.js +1 -0
  29. package/dist/client/assets/{HeartbeatPage-DFf7Udem.js → HeartbeatPage-CfjZuvtQ.js} +1 -1
  30. package/dist/client/assets/{LexicalField-vJ284m2H.js → LexicalField-Cc6wFZAZ.js} +2 -2
  31. package/dist/client/assets/{ManagesPage-mDuaA2JT.js → ManagesPage-BxHSb65X.js} +1 -1
  32. package/dist/client/assets/{Marketplace-BoiupH2Z.js → Marketplace-EgG6JmBG.js} +4 -4
  33. package/dist/client/assets/{MarketplaceSourcesView-krw9hUyu.js → MarketplaceSourcesView-D9kq9hl6.js} +1 -1
  34. package/dist/client/assets/{McpAppFrame-DmHduNgp.js → McpAppFrame-6zxszx9A.js} +2 -2
  35. package/dist/client/assets/{McpSigninBody-DoY09n4J.js → McpSigninBody-DBWSc6bm.js} +1 -1
  36. package/dist/client/assets/{Model3dViewer-BZEdR7-9.js → Model3dViewer-CgeJ2v-F.js} +1 -1
  37. package/dist/client/assets/NamePage-MfybpnwN.js +1 -0
  38. package/dist/client/assets/NewDirectMessageMenu-BnBO4aGI.js +1 -0
  39. package/dist/client/assets/{NotificationsPage-CybW1eIb.js → NotificationsPage-C5aRITCd.js} +1 -1
  40. package/dist/client/assets/{OpenMeshSwitch-DrmjsCDY.js → OpenMeshSwitch-UKMQeS7-.js} +2 -2
  41. package/dist/client/assets/{OperatorIdentityForm-byU2FeSU.js → OperatorIdentityForm-DH2au7QU.js} +1 -1
  42. package/dist/client/assets/{PermissionsPage-CP3kbqyJ.js → PermissionsPage-BgLLmdg2.js} +1 -1
  43. package/dist/client/assets/{PersonalityPopover-BLsjgaum.js → PersonalityPopover-vLDfndfo.js} +1 -1
  44. package/dist/client/assets/PhotoPage-BgyB3B2_.js +1 -0
  45. package/dist/client/assets/{PreviewRefusedNotice-fTN8MJ1h.js → PreviewRefusedNotice-Dh3SCC_A.js} +1 -1
  46. package/dist/client/assets/{PromptSuggestionChips-BZOaY5Tx.js → PromptSuggestionChips-EO_0zbzq.js} +1 -1
  47. package/dist/client/assets/{ReportsToPopover-B6JvfRt3.js → ReportsToPopover-C9Ceg1AW.js} +1 -1
  48. package/dist/client/assets/{RoomSurface-BM0QO_av.js → RoomSurface-B8ec3_at.js} +8 -8
  49. package/dist/client/assets/{RoomsPage-B-NOCLXC.js → RoomsPage-pPw8vrsB.js} +1 -1
  50. package/dist/client/assets/{RunsOnPopover-D1jQQatj.js → RunsOnPopover-CJoSj8w7.js} +1 -1
  51. package/dist/client/assets/RuntimeSetupDialog-Cqn_Grel.js +1 -0
  52. package/dist/client/assets/SessionsPage-BASybh9v.js +1 -0
  53. package/dist/client/assets/{SkillsPage-CPTFjEUe.js → SkillsPage-DL0909et.js} +1 -1
  54. package/dist/client/assets/{TasksPage-BRUqs3v5.js → TasksPage-BwUW6dia.js} +1 -1
  55. package/dist/client/assets/{ToolsPage-C25kL822.js → ToolsPage-C3xfGWdb.js} +2 -2
  56. package/dist/client/assets/{TopologyGraph-of6Cp5Kj.js → TopologyGraph-D7Ik1Xt6.js} +1 -1
  57. package/dist/client/assets/{TourHost-zwSilkjm.js → TourHost-Db0fxAXo.js} +1 -1
  58. package/dist/client/assets/{UnlinkDialog-BgwHAqdW.js → UnlinkDialog-TTK5Z_QD.js} +1 -1
  59. package/dist/client/assets/{WidgetErrorCard-BQwrR6PJ.js → WidgetErrorCard-D--KcgW1.js} +24 -29
  60. package/dist/client/assets/_shell-CGWsN6Gs.js +88 -0
  61. package/dist/client/assets/{_shell._home-BkP0NafS.js → _shell._home-CzpVyTzo.js} +1 -1
  62. package/dist/client/assets/{_shell._home.activity-BO_2ciGK.js → _shell._home.activity-BbWquOK0.js} +1 -1
  63. package/dist/client/assets/_shell._home.index-Cg0nRFMN.js +3 -0
  64. package/dist/client/assets/_shell._home.tasks-BpoOVihw.js +1 -0
  65. package/dist/client/assets/{_shell._home.workspaces-B34Uk1SP.js → _shell._home.workspaces-DVF1rM3t.js} +1 -1
  66. package/dist/client/assets/_shell.channels-CCGSs0Bn.js +10 -0
  67. package/dist/client/assets/{_shell.connections-BNbeBrxQ.js → _shell.connections-0_34lXIQ.js} +1 -1
  68. package/dist/client/assets/{_shell.feedback-requests-B71l48KB.js → _shell.feedback-requests-C6alx2ox.js} +1 -1
  69. package/dist/client/assets/_shell.marketplace-Dp-p8E3V.js +1 -0
  70. package/dist/client/assets/_shell.marketplace_.sources-SN2Fb1eb.js +1 -0
  71. package/dist/client/assets/{_shell.session-ybAc0bwn.js → _shell.session-Bt3jdQdD.js} +15 -15
  72. package/dist/client/assets/_shell.team-BIwJNdkd.js +28 -0
  73. package/dist/client/assets/_shell.x._extensionId-Bjn-MKsP.js +1 -0
  74. package/dist/client/assets/_shell.x._extensionId_._-Bjn-MKsP.js +1 -0
  75. package/dist/client/assets/{agent-browser-Cs8abkZs.js → agent-browser-CO5haI5Y.js} +1 -1
  76. package/dist/client/assets/{banner-CU2Nh3Kv.js → banner-Dh5mO27l.js} +2 -2
  77. package/dist/client/assets/{card-BTgwskmX.js → card-CKZCX8ol.js} +1 -1
  78. package/dist/client/assets/{file-DlQX-hKl.js → file-CMPbZedq.js} +1 -1
  79. package/dist/client/assets/{file-exclamation-point-Dg2iCyPM.js → file-exclamation-point-emLeXvmw.js} +1 -1
  80. package/dist/client/assets/file-text-9a0DChCq.js +6 -0
  81. package/dist/client/assets/{find-latest-widget-fence-BGiexm6r.js → find-latest-widget-fence--3kWMT1F.js} +3 -3
  82. package/dist/client/assets/{git-branch-Dq_w3Iyx.js → git-branch-hfu8isLA.js} +1 -1
  83. package/dist/client/assets/{heart-Bp14wOx6.js → heart-SRafwnSd.js} +1 -1
  84. package/dist/client/assets/{highlighted-body-KPVGNVTW-kD1HK_wk.js → highlighted-body-KPVGNVTW-Dxwd3mxT.js} +1 -1
  85. package/dist/client/assets/index-3GDQSKet.js +1 -0
  86. package/dist/client/assets/{index-BA-nPsLw.js → index-BB18IeC2.js} +1 -1
  87. package/dist/client/assets/index-BBQMqcO_.js +1 -0
  88. package/dist/client/assets/{index-CcV9S7cO.js → index-BDfoFNcA.js} +1 -1
  89. package/dist/client/assets/{index-DNglWRBB.js → index-BNn3-chz.js} +1 -1
  90. package/dist/client/assets/{index-Dm53S0up.js → index-BRGOMmOM.js} +1 -1
  91. package/dist/client/assets/{index-5OyUurJr.js → index-BTXBESRm.js} +1 -1
  92. package/dist/client/assets/{index-B8R78Nnj.js → index-BTreBsWa.js} +2 -2
  93. package/dist/client/assets/{index-kHXlTLUx.js → index-BUVKya1M.js} +8 -8
  94. package/dist/client/assets/{index-aDNEGBTK.js → index-BYp9xcmS.js} +1 -1
  95. package/dist/client/assets/{index-DnmtTIUB.js → index-BokDvdOG.js} +1 -1
  96. package/dist/client/assets/{index-BxrZwUJp.js → index-C3xuhmPa.js} +2 -2
  97. package/dist/client/assets/{index-B6_ikFYj.js → index-C4nEz6I-.js} +1 -1
  98. package/dist/client/assets/{index-Dr-0P6rd.js → index-C63bLSO4.js} +267 -262
  99. package/dist/client/assets/{index-Cc280M3V.js → index-C7BTAdSc.js} +1 -1
  100. package/dist/client/assets/{index-knGXyHhh.js → index-CAlXjm0N.js} +1 -1
  101. package/dist/client/assets/index-CTxEG5rD.js +1 -0
  102. package/dist/client/assets/{index-gu2JYnOq.js → index-CbFo-7kM.js} +1 -1
  103. package/dist/client/assets/{index-DKlxz3u7.js → index-Ch41JOI2.js} +1 -1
  104. package/dist/client/assets/{index-BxUoa3yn.js → index-CkknQ52Q.js} +5 -5
  105. package/dist/client/assets/{index-C-DN0Vg_.js → index-Cow815Qa.js} +1 -1
  106. package/dist/client/assets/{index-DO6a5Hey.js → index-Cp7oifSs.js} +1 -1
  107. package/dist/client/assets/{index--3UwFg2s.js → index-CpYs0Lli.js} +1 -1
  108. package/dist/client/assets/{index-C99173Ze.js → index-D0Nd2LA-.js} +1 -1
  109. package/dist/client/assets/{index-BeBmUxo_.js → index-D67aFWxz.js} +1 -1
  110. package/dist/client/assets/index-DFEF2MFy.css +1 -0
  111. package/dist/client/assets/{index-CAhJGlSW.js → index-DIlV08Vw.js} +1 -1
  112. package/dist/client/assets/{index-BHsZlKfx.js → index-DLNwEM2Q.js} +1 -1
  113. package/dist/client/assets/{index-PxSRtDpP.js → index-DLZi_nae.js} +1 -1
  114. package/dist/client/assets/{index-LszRbEbX.js → index-DRqEM5Wb.js} +1 -1
  115. package/dist/client/assets/{index-B0OZehWe.js → index-DX-j3Ul0.js} +1 -1
  116. package/dist/client/assets/{index-CKCMjqcu.js → index-DX7V94qe.js} +1 -1
  117. package/dist/client/assets/{index-C_uYJzKi.js → index-D_Wc_qTa.js} +3 -3
  118. package/dist/client/assets/{index-DW6zqLoM.js → index-DdsKmfEH.js} +1 -1
  119. package/dist/client/assets/{index-DHUToGjI.js → index-DmTI5Hye.js} +1 -1
  120. package/dist/client/assets/{index-DKQDBIWq.js → index-YswfjpmW.js} +1 -1
  121. package/dist/client/assets/{index-DSPs6GF4.js → index-g_5oOlG6.js} +1 -1
  122. package/dist/client/assets/{index-DS-thlE8.js → index-iD0epmn3.js} +1 -1
  123. package/dist/client/assets/{index-CDWsIVX7.js → index-lJc8v0Z3.js} +1 -1
  124. package/dist/client/assets/index-t7gsOfUI.js +1 -0
  125. package/dist/client/assets/kickoff-xkt4LpIP.js +3 -0
  126. package/dist/client/assets/{layers-B0oCOfxz.js → layers-Cy8Tme6i.js} +1 -1
  127. package/dist/client/assets/{lightbulb-D80IzMqz.js → lightbulb-tNm7gLYi.js} +1 -1
  128. package/dist/client/assets/{markdown-content-aNzh-54y.js → markdown-content-CoK3F0c0.js} +1 -1
  129. package/dist/client/assets/{mention-pill-BxMK0xuY.js → mention-pill-Bgs_yujj.js} +1 -1
  130. package/dist/client/assets/{message-square-off-D-CJXmTq.js → message-square-off-CF2Bzen3.js} +1 -1
  131. package/dist/client/assets/{owner-notice-BkrTEMDm.js → owner-notice-cgCWG4hG.js} +1 -1
  132. package/dist/client/assets/{package-CoTlAnXZ.js → package-DE8sQpId.js} +1 -1
  133. package/dist/client/assets/{page-container-CPxW5T9E.js → page-container-BoXmmBSs.js} +1 -1
  134. package/dist/client/assets/{paperclip-Cj1P85mz.js → paperclip-IgDeVFea.js} +1 -1
  135. package/dist/client/assets/{radio-DICkTr_p.js → radio-BzTkFBDD.js} +1 -1
  136. package/dist/client/assets/{room-files-source-BywWQPBN.js → room-files-source-CIIDTSTA.js} +2 -2
  137. package/dist/client/assets/{rotate-ccw-clock-cx5RyP4l.js → rotate-ccw-clock-CGcSqHnk.js} +1 -1
  138. package/dist/client/assets/{rotate-cw-DrGRGSwy.js → rotate-cw-DaduzRfP.js} +1 -1
  139. package/dist/client/assets/{scroll-area-XlDz8u4m.js → scroll-area-DW0-Liri.js} +1 -1
  140. package/dist/client/assets/{search-x-LIKnWE64.js → search-x-Sme5ElYi.js} +1 -1
  141. package/dist/client/assets/{shield-x-DioB6qH_.js → shield-x-Bh5xap8N.js} +1 -1
  142. package/dist/client/assets/{soul-file-C7YgkNET.js → soul-file-NcuTUIiB.js} +1 -1
  143. package/dist/client/assets/{table-P4N5xQn2.js → table-BEtvgYmW.js} +1 -1
  144. package/dist/client/assets/{use-connector-management-pgVHbXoO.js → use-connector-management-Cohvs7jD.js} +1 -1
  145. package/dist/client/assets/{use-delete-binding-DxEiOjjh.js → use-delete-binding-C19umm_i.js} +1 -1
  146. package/dist/client/assets/{use-dev-links-BImQrE6g.js → use-dev-links-DRnLdl--.js} +1 -1
  147. package/dist/client/assets/{use-external-adapter-catalog-D8KHMSZU.js → use-external-adapter-catalog-BOn9aj72.js} +1 -1
  148. package/dist/client/assets/use-full-activity-feed-BpQANbns.js +1 -0
  149. package/dist/client/assets/use-is-below-desktop-5LlietdR.js +1 -0
  150. package/dist/client/assets/{use-jump-back-in-D9tBJ4v5.js → use-jump-back-in-CkFErfWY.js} +3 -3
  151. package/dist/client/assets/{use-mesh-topology-DBeqzUoy.js → use-mesh-topology-CIsDeAY0.js} +1 -1
  152. package/dist/client/assets/use-panel-tab-placements-AFrWTQ0a.js +1 -0
  153. package/dist/client/assets/use-pending-read-Dol8yvIx.js +1 -0
  154. package/dist/client/assets/{use-personality-commit-Gfoi__sT.js → use-personality-commit-fUtuc2lC.js} +1 -1
  155. package/dist/client/assets/{use-promo-activation-Bv1gnqKq.js → use-promo-activation-Dxt-1yuT.js} +3 -3
  156. package/dist/client/assets/{use-pulse-freshness-SFRdnugS.js → use-pulse-freshness-DRRM5Hza.js} +1 -1
  157. package/dist/client/assets/{use-room-follow-claim-Cf20JiJ_.js → use-room-follow-claim-huRfaa4e.js} +1 -1
  158. package/dist/client/assets/{use-roving-tab-list-3Pb7ps4E.js → use-roving-tab-list-BZIBAGgJ.js} +1 -1
  159. package/dist/client/assets/{use-session-canvas-BaXuEhw8.js → use-session-canvas-CZIsr9qL.js} +4 -4
  160. package/dist/client/assets/{use-session-diagnostics-7xxJ6zQQ.js → use-session-diagnostics-C41hV7rK.js} +4 -4
  161. package/dist/client/assets/{use-unclaimed-chats-D4k-EK_f.js → use-unclaimed-chats-BMlFQ2v1.js} +1 -1
  162. package/dist/client/index.html +2 -2
  163. package/dist/server/index.js +123677 -118335
  164. package/dist/server/index.js.map +2 -2
  165. package/package.json +7 -8
  166. package/dist/client/assets/AdapterIcon-BdM7K69W.js +0 -1
  167. package/dist/client/assets/CanvasFileContent-CDNfnWMW.js +0 -2
  168. package/dist/client/assets/CanvasModel3dContent-C7EINmuq.js +0 -2
  169. package/dist/client/assets/HandlePage-Bun58ePo.js +0 -1
  170. package/dist/client/assets/NamePage-CXyClUPJ.js +0 -1
  171. package/dist/client/assets/NewDirectMessageMenu-BjqYwnXW.js +0 -1
  172. package/dist/client/assets/PhotoPage-hn5b42qN.js +0 -1
  173. package/dist/client/assets/RuntimeSetupDialog-ufwCvCJB.js +0 -1
  174. package/dist/client/assets/SessionsPage-CBE1KHYg.js +0 -1
  175. package/dist/client/assets/_shell-bcx2y7VT.js +0 -88
  176. package/dist/client/assets/_shell._home.index-B-OFwU9u.js +0 -3
  177. package/dist/client/assets/_shell._home.tasks-jAQczH7j.js +0 -1
  178. package/dist/client/assets/_shell.channels-CGzsxvXD.js +0 -10
  179. package/dist/client/assets/_shell.marketplace-3YAsNaRk.js +0 -1
  180. package/dist/client/assets/_shell.marketplace_.sources-cI3nNBXr.js +0 -1
  181. package/dist/client/assets/_shell.team-BE_60YS4.js +0 -28
  182. package/dist/client/assets/_shell.x._extensionId-jiyP599c.js +0 -1
  183. package/dist/client/assets/_shell.x._extensionId_._-jiyP599c.js +0 -1
  184. package/dist/client/assets/index-B2JJZXsq.js +0 -1
  185. package/dist/client/assets/index-BAjUSKoJ.js +0 -1
  186. package/dist/client/assets/index-BpDY3eoD.js +0 -1
  187. package/dist/client/assets/index-ExcAk4pE.css +0 -1
  188. package/dist/client/assets/index-F7Lcwnfm.js +0 -1
  189. package/dist/client/assets/kickoff-Btbza7bw.js +0 -3
  190. package/dist/client/assets/use-full-activity-feed-2o7GNAMe.js +0 -1
  191. package/dist/client/assets/use-is-below-desktop-DBet5zg_.js +0 -1
  192. package/dist/client/assets/use-pending-read-DmrlNHS0.js +0 -1
@@ -1,17 +1,17 @@
1
- import{a4 as Se,gh as Me,ae as ne,r as s,i6 as Ie,i7 as Q,i8 as G,i9 as H,ga as ie,ia as Ce,cQ as J,ib as ee,dK as it,i3 as lt,af as oe,ic as ct,id as dt,ie as ut,ig as ft,aN as Te,ih as ht,j as e,F as Fe,df as pt,C as Ke,ii as mt,e1 as be,ij as xt,hg as gt,Z as Pe,ik as yt,il as vt,im as Ct,io as Z,ip as ue,fR as fe,fS as he,fT as pe,fU as me,fV as xe,fW as ge,fX as ye,fY as ve,B as W,b1 as bt,e8 as _e,hk as kt,iq as jt,aj as ce,ir as He,dd as wt,is as Et,it as Dt,iu as Nt,iv as Rt,eJ as De,iw as Ue,ag as St,g8 as Tt,at as Ft,cP as Pt,ix as Ot,dC as Mt,ho as _t,iy as At,cV as Lt,cW as zt,cX as $t,cY as It,cZ as Kt,da as Ht,I as Ut,c_ as qt}from"./index-Dr-0P6rd.js";import{t as ae,g as Qt,C as Bt,n as qe,r as Qe,a as Yt,p as Wt,F as Gt,w as Vt,c as Be,b as Xt}from"./room-files-source-BywWQPBN.js";import{N as ts,R as ns}from"./room-files-source-BywWQPBN.js";import{r as Zt,c as Jt}from"./composer-insert-BpyATrmR.js";import{u as en}from"./index-CcV9S7cO.js";import{r as Ye,h as We,F as tn}from"./file-drag-GDx2qhdk.js";import{R as Ge}from"./rotate-cw-DrGRGSwy.js";import{F as Ve}from"./file-DlQX-hKl.js";import{G as Xe}from"./git-branch-Dq_w3Iyx.js";import"./markdown-content-aNzh-54y.js";import"./file-exclamation-point-Dg2iCyPM.js";/**
1
+ import{a4 as Se,gz as Me,ae as ne,r as s,ik as Ie,il as Q,im as W,io as H,gs as ie,ip as Ce,cT as X,iq as ee,ap as it,ih as lt,af as oe,ir as ct,is as dt,it as ut,iu as ft,aQ as Te,iv as ht,j as e,F as Fe,di as pt,C as Ke,iw as mt,e3 as be,ix as xt,hx as gt,Z as Pe,iy as yt,iz as vt,iA as Ct,iB as J,iC as ue,gb as fe,gc as he,gd as pe,ge as me,gf as xe,gg as ge,gh as ye,gi as ve,B as G,b4 as bt,ea as _e,hB as kt,iD as jt,aj as ce,iE as He,dg as wt,iF as Et,iG as Dt,iH as Nt,iI as Rt,ek as De,iJ as qe,ag as St,gq as Tt,aw as Ft,cS as Pt,iK as Ot,dF as Mt,hF as _t,iL as At,cY as Lt,cZ as zt,c_ as $t,c$ as It,d0 as Kt,dd as Ht,I as qt,d1 as Ut}from"./index-C63bLSO4.js";import{t as ae,g as Qt,C as Bt,n as Ue,r as Qe,a as Yt,p as Gt,F as Wt,w as Vt,c as Be,b as Zt}from"./room-files-source-CIIDTSTA.js";import{N as ts,R as ns}from"./room-files-source-CIIDTSTA.js";import{r as Jt,c as Xt}from"./composer-insert-BpyATrmR.js";import{u as en}from"./index-BDfoFNcA.js";import{r as Ye,h as Ge,F as tn}from"./file-drag-GDx2qhdk.js";import{R as We}from"./rotate-cw-DaduzRfP.js";import{F as Ve}from"./file-CMPbZedq.js";import{G as Ze}from"./git-branch-hfu8isLA.js";import"./markdown-content-CoK3F0c0.js";import"./file-exclamation-point-emLeXvmw.js";/**
2
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
- */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 nn=Se(Ze);/**
6
+ */const Je={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"}]]};Je.node;const nn=Se(Je);/**
7
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
- */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);/**
11
+ */const Xe={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"}]]};Xe.node;const et=Se(Xe);/**
12
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 sn=Se(tt);function le(t,n,a){return["file-explorer","tree",t.scopeKey,n,t.filtersHidden?a:null]}function je(t,n,a,x){return{queryKey:le(t,n,a),queryFn:()=>t.list(n,{showHidden:a}),staleTime:Me.FILE_TREE_STALE_TIME_MS,gcTime:Me.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??x.getQueryData(le(t,n,!a))}}const an=[".git",".dork",".claude",".agents","node_modules"];function rn(t){return t.startsWith(".")||an.includes(t)}const Ne=["ROOM.md","README.md"];function Re(t){return Ne.some(n=>n.toLowerCase()===t.toLowerCase())}function nt(t){return t.filter(n=>!rn(n.name))}function on(t){if(t.reduce((p,c)=>c.type==="file"&&Re(c.name)?p+1:p,0)===0)return t;const a=[],x=[];for(const p of t)p.type==="file"&&Re(p.name)?a.push(p):x.push(p);return a.sort((p,c)=>Ne.findIndex(o=>o.toLowerCase()===p.name.toLowerCase())-Ne.findIndex(o=>o.toLowerCase()===c.name.toLowerCase())),[...a,...x]}const ln=/ copy(?: \d+)?$/;function Oe({name:t,isDir:n,taken:a}){const x=new Set(a);if(!x.has(t))return t;const p=n?-1:t.lastIndexOf("."),c=p>0,o=c?t.slice(p):"",m=(c?t.slice(0,p):t).replace(ln,"");for(let r=1;;r+=1){const i=r===1?`${m} copy${o}`:`${m} copy ${r}${o}`;if(!x.has(i))return i}}function Ae(t,n,a){return{name:n,path:t,type:a,size:0,mtime:Date.now(),isSymlink:!1}}function cn(t){const n=ne(),{source:a,showHidden:x,queryClient:p,inFlightRef:c}=t,o=a.cwd??"",[m,r]=s.useState(null),i=s.useCallback(async h=>{c.current+=1;try{return await h()}finally{c.current-=1}},[c]),u=s.useMemo(()=>{const h=g=>le(a,g,x);return{getChildren:g=>{var w;return((w=p.getQueryData(h(g)))==null?void 0:w.entries)??[]},isLoaded:g=>p.getQueryData(h(g))!==void 0,takenNames:async g=>(await n.readFileTree(o,{path:g===Q?void 0:g,showHidden:!0})).entries.map(b=>b.name),snapshot:g=>p.getQueryData(h(g)),setChildren:(g,w)=>{p.setQueryData(h(g),b=>({entries:Ie(w((b==null?void 0:b.entries)??[]))}))},restore:(g,w)=>{p.setQueryData(h(g),w)},invalidate:g=>{p.invalidateQueries({queryKey:h(g),exact:!0})}}},[p,n,o,a,x]),N=s.useCallback((h,g,w)=>i(async()=>{const b=ee(h,g),S=!u.getChildren(h).some(A=>A.path===b),K=u.snapshot(h);S&&u.setChildren(h,A=>[...A,Ae(b,g,w)]);try{return await n.createEntry(o,b,w),!0}catch(A){return S&&u.restore(h,K),ae(A,`Couldn’t create ${w==="dir"?"folder":"file"}`),!1}finally{u.invalidate(h)}}),[n,o,u,i]),F=s.useCallback((h,g)=>i(async()=>{if(g===h.name||g.length===0)return!0;const w=G(h.path),b=ee(w,g),S=u.getChildren(w).some(_=>_.path===b),K=u.snapshot(w),A={...h,name:g,path:b};S||u.setChildren(w,_=>_.map($=>$.path===h.path?A:$));try{return await n.renameEntry(o,h.path,b),H.getState().remapExpandedPaths(h.path,b),!0}catch(_){return S||u.restore(w,K),ae(_,"Couldn’t rename"),!1}finally{u.invalidate(w)}}),[n,o,u,i]),D=s.useCallback(h=>i(async()=>{const g=G(h.path),w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path,{recursive:!0}),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}}),[n,o,u,i]),L=s.useCallback(h=>i(async()=>{const g=G(h.path);if(h.type==="file"){const w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}return}try{await n.deleteEntry(o,h.path),u.setChildren(g,w=>w.filter(b=>b.path!==h.path)),H.getState().dropExpandedPaths(h.path),u.invalidate(g)}catch(w){if(Qt(w)==="DIR_NOT_EMPTY"){r(h);return}ae(w,"Couldn’t delete")}}),[n,o,u,i]),C=s.useCallback(async()=>{const h=m;r(null),h&&await D(h)},[m,D]),U=s.useCallback(()=>r(null),[]),I=s.useCallback((h,g)=>i(async()=>{const w=G(h),b=ie(h),S=ee(g,b);if(g===w||S===h||Ce(g,h))return;const K=u.getChildren(w).find(v=>v.path===h);if(!K)return;const A=u.isLoaded(g),_=A&&u.getChildren(g).some(v=>v.path===S),$={...K,name:b,path:S},Y=u.snapshot(w),P=A?u.snapshot(g):void 0;u.setChildren(w,v=>v.filter(z=>z.path!==h)),A&&!_&&u.setChildren(g,v=>[...v,$]);try{await n.renameEntry(o,h,S),H.getState().remapExpandedPaths(h,S)}catch(v){u.restore(w,Y),A&&!_&&u.restore(g,P),ae(v,"Couldn’t move")}finally{u.invalidate(w),A&&u.invalidate(g)}}),[n,o,u,i]),j=s.useCallback((h,g)=>i(async()=>{if(h.isDir&&Ce(g,h.path)){J.error(Bt);return}let w;try{w=await u.takenNames(g)}catch(_){ae(_,"Couldn’t copy");return}const b=Oe({name:ie(h.path),isDir:h.isDir,taken:w}),S=ee(g,b),K=u.isLoaded(g),A=K?u.snapshot(g):void 0;if(K){const _=u.getChildren(G(h.path)).find(Y=>Y.path===h.path),$=_?{..._,name:b,path:S}:Ae(S,b,h.isDir?"dir":"file");u.setChildren(g,Y=>[...Y,$])}try{await n.copyEntry(o,h.path,S)}catch(_){K&&u.restore(g,A),ae(_,"Couldn’t copy")}finally{u.invalidate(g)}}),[n,o,u,i]);return{createEntry:N,renameEntry:F,removeEntry:L,moveEntry:I,copyEntry:j,pendingRecursiveDelete:m,confirmRecursiveDelete:C,cancelRecursiveDelete:U}}function dn(t){return t!=null&&t.startsWith("darwin")?"Reveal in Finder":t!=null&&t.startsWith("win32")?"Reveal in File Explorer":"Show in file manager"}function un(t,n){const a=t.includes("\\")&&!t.includes("/"),x=t.replace(/[\\/]+$/,""),p=a?n.split("/").join("\\"):n;return`${x}${a?"\\":"/"}${p}`}function fn(t){const n=ne(),{data:a}=it(),x=s.useMemo(()=>n.supportsReveal?dn(a==null?void 0:a.platform):null,[n.supportsReveal,a==null?void 0:a.platform]),p=s.useCallback(async i=>{if(t)try{await n.revealEntry(t,i.path)}catch(u){ae(u,"Couldn’t open the file manager")}},[n,t]),{copy:c}=lt(),o=s.useCallback(async(i,u)=>{const N=u==="absolute"&&t?un(t,i.path):i.path;await c(N)||J.error("Couldn’t copy to the clipboard")},[t,c]),m=s.useCallback(i=>{Zt(Jt(i.path))||J.error("Open a chat to add this file")},[]),r=s.useCallback(i=>{H.getState().setClipboard({path:i.path,isDir:i.type==="dir"});try{navigator.clipboard.writeText(i.path).catch(()=>{})}catch{}},[]);return{revealLabel:x,reveal:p,copyPath:o,addToChat:m,copyToClipboard:r}}const hn=1e3;function pn(t){const{source:n,showHidden:a,queryClient:x,inFlightRef:p}=t,c=n.changes,[o,m]=s.useState(null),[r,i]=s.useState(null),[u,N]=s.useState(null),[F,D]=s.useState(0),L=s.useCallback(async d=>{p.current+=1,D(f=>f+1);try{return await d()}finally{p.current-=1,D(f=>f-1)}},[p]),C=s.useMemo(()=>{const d=f=>le(n,f,a);return{listing:f=>x.getQueryData(d(f)),isLoaded:f=>x.getQueryData(d(f))!==void 0,entries:f=>{var T;return((T=x.getQueryData(d(f)))==null?void 0:T.entries)??[]},setEntries:(f,T)=>x.setQueryData(d(f),y=>({...y,entries:Ie(T((y==null?void 0:y.entries)??[]))})),restore:(f,T)=>x.setQueryData(d(f),T),fetch:f=>n.list(f,{showHidden:!0}),refreshAll:()=>{x.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),x.invalidateQueries({queryKey:["file-explorer","preview",n.scopeKey]})}}},[x,n,a]),U=s.useCallback(async d=>{const f=C.listing(d);return(f==null?void 0:f.commit)!==void 0?f.commit:(await C.fetch(d)).commit??null},[C]),I=s.useCallback((d,f,T,y)=>{switch(d.status){case"changed":return!0;case"conflict":return N({kind:f,path:d.path,lastCommit:d.lastCommit,retry:()=>T(d.commit)}),!1;case"exists":return J.error(y===void 0?d.reason:qe(y)),!1;case"refused":return J.error(d.reason),!1}},[]),j=s.useCallback((d,f)=>{J.error(Qe(d)??f)},[]),h=s.useCallback((d,f,T)=>{const y=O=>L(async()=>{if(c===void 0)return!1;const E=G(d.path),R=G(f),k=ie(f),q=C.isLoaded(R),te=q&&C.entries(R).some(X=>X.path===f),V=C.listing(E),de=R===E?void 0:C.listing(R),l={...d,name:k,path:f};te||(R===E?C.setEntries(E,X=>X.map(se=>se.path===d.path?l:se)):(C.setEntries(E,X=>X.filter(se=>se.path!==d.path)),q&&C.setEntries(R,X=>[...X,l])));const M=()=>{C.restore(E,V),R!==E&&q&&C.restore(R,de)};try{const X=O??await U(E);if(X===null)return M(),J.error("This room has no files to change yet."),!1;const se=await c.move({from:d.path,to:f,baseCommit:X}),we=I(se,T,async re=>{await y(re)},k);return we?H.getState().remapExpandedPaths(d.path,f):M(),we}catch(X){return M(),j(X,T==="rename"?"Couldn’t rename":"Couldn’t move"),!1}finally{C.refreshAll()}});return y(null)},[c,C,L,U,I,j]),g=s.useCallback(async(d,f)=>f===d.name||f.length===0?!0:h(d,ee(G(d.path),f),"rename"),[h]),w=s.useCallback(async(d,f)=>{const T=G(d),y=ee(f,ie(d));if(f===T||y===d||Ce(f,d))return;const O=C.entries(T).find(E=>E.path===d);O&&await h(O,y,"move")},[C,h]),b=s.useCallback(async d=>{let f=0;const T=[d];for(;T.length>0;){const y=T.shift(),O=await C.fetch(y);for(const E of O.entries)if(E.type==="dir"?T.push(E.path):f+=1,f>=hn)return{count:f,moreThan:!0}}return{count:f,moreThan:!1}},[C]),S=s.useCallback(d=>{if(d.type!=="dir"){m({entry:d,fileCount:1,moreThan:!1});return}m({entry:d,fileCount:null,moreThan:!1}),b(d.path).then(({count:f,moreThan:T})=>m(y=>(y==null?void 0:y.entry.path)===d.path?{entry:d,fileCount:f,moreThan:T}:y),()=>{})},[b]),K=s.useCallback(d=>{const f=T=>L(async()=>{if(c===void 0)return;const y=G(d.path),O=C.listing(y);C.setEntries(y,E=>E.filter(R=>R.path!==d.path));try{const E=T??await U(y);if(E===null){C.restore(y,O);return}const R=await c.remove({path:d.path,baseCommit:E});I(R,"delete",q=>f(q))?H.getState().dropExpandedPaths(d.path):C.restore(y,O)}catch(E){C.restore(y,O),j(E,"Couldn’t delete")}finally{C.refreshAll()}});return f(null)},[c,C,L,U,I,j]),A=s.useCallback(async()=>{const d=o;m(null),d&&await K(d.entry)},[o,K]),_=s.useCallback(()=>m(null),[]),$=s.useCallback((d,f,T,y)=>{const O=E=>L(async()=>{if(c===void 0)return;const R=C.isLoaded(d),k=R?C.listing(d):void 0;if(R){const q=new Set(C.entries(d).map(V=>V.name)),te=f.filter(V=>!q.has(V.name)).map(V=>({name:V.name,path:ee(d,V.name),type:"file",size:V.size}));te.length>0&&C.setEntries(d,V=>[...V,...te])}try{const q=await c.upload({dir:d,baseCommit:E,replace:T,files:f});!I(q,"upload",V=>O(V))&&R&&C.restore(d,k)}catch(q){R&&C.restore(d,k),j(q,"Couldn’t upload")}finally{C.refreshAll()}});return O(y)},[c,C,L,I,j]),Y=s.useCallback(async(d,f)=>{if(c===void 0||f.length===0)return;if(f.length>c.maxUploadFiles){J.error(`Nothing was uploaded. One upload takes up to ${c.maxUploadFiles} files.`);return}let T;try{T=await C.fetch(d)}catch(k){j(k,"Couldn’t upload");return}const y=T.entries.map(k=>k.name),O=new Set(y),E=f.map(k=>k.name).filter(k=>O.has(k)),R=T.commit??null;if(E.length===0){await $(d,f,[],R);return}i({dir:d,files:f,names:E,taken:y,baseCommit:R})},[c,C,j,$]),P=s.useCallback(async d=>{const f=r;if(i(null),f===null)return;if(d==="replace"){await $(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 R=Oe({name:E.name,isDir:!1,taken:T});return T.add(R),new File([E],R,{type:E.type,lastModified:E.lastModified})});await $(f.dir,O,[],f.baseCommit)},[r,$]),v=s.useCallback(()=>i(null),[]),z=s.useCallback(()=>N(null),[]),B=s.useMemo(()=>r===null?null:{dir:r.dir,names:r.names},[r]);return{renameEntry:g,moveEntry:w,requestDelete:S,pendingDelete:o,confirmDelete:A,cancelDelete:_,upload:Y,pendingClash:B,resolveClash:P,cancelClash:v,conflict:u,dismissConflict:z,busy:F>0}}const Le={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function mn(t){var d,f,T;const n=ne(),a=oe(),{setTheme:x}=ct(),p=H(y=>y.showHidden),c=H(y=>y.expanded),o=H(y=>y.loadExplorerForCwd),m=H(y=>y.pruneMissing),r=(t==null?void 0:t.scopeKey)??null,i=(t==null?void 0:t.cwd)??null;s.useEffect(()=>{o(r)},[r,o]);const u=s.useMemo(()=>[Q,...dt(c)],[c]),N=ut({queries:t?u.map(y=>je(t,y,p,a)):[]}),F=(t==null?void 0:t.filtersHidden)??!0,D=s.useMemo(()=>{const y={};return u.forEach((O,E)=>{var q;const R=N[E];let k=((q=R==null?void 0:R.data)==null?void 0:q.entries)??[];!p&&!F&&(k=nt(k)),O===Q&&(k=on(k)),y[O]={entries:k,loading:(R==null?void 0:R.isLoading)??!1,error:(R==null?void 0:R.isError)??!1}}),y},[u,N,p,F]),L=s.useRef(0),C=s.useRef({});s.useEffect(()=>{L.current>0||u.forEach((y,O)=>{var R,k,q;const E=(k=(R=N[O])==null?void 0:R.data)==null?void 0:k.entries;!E||(q=N[O])!=null&&q.isError||C.current[y]!==E&&(C.current[y]=E,m(y,E.map(te=>te.name)))})},[u,N,m]);const U=s.useMemo(()=>ft(c,D),[c,D]),I=!!t&&!!((d=D[Q])!=null&&d.loading),j=!!t&&!!((f=D[Q])!=null&&f.error),h=(T=N[0])==null?void 0:T.error,g=j&&h?Yt(h):void 0,w=(g==null?void 0:g.message)??null,b=(g==null?void 0:g.command)??null,S=s.useMemo(()=>{var O;const y=new Set;for(const E of u)E!==Q&&((O=D[E])!=null&&O.error)&&y.add(E);return y},[u,D]),K=s.useCallback(y=>{if(y.type!=="dir")return;const O=H.getState();O.setDirExpanded(y.path,!O.expanded[y.path])},[]),A=s.useCallback(y=>{if(y===Q)return;const O=H.getState();O.expanded[y]||O.setDirExpanded(y,!0)},[]),_=(t==null?void 0:t.preview)==="canvas",$=s.useCallback(y=>{if(y.type!=="file"||!_)return;const O={getStore:Te.getState,setTheme:x,supportsTerminal:n.supportsTerminal};ht(O,{action:"open_file",sourcePath:y.path},"user")},[_,x,n]),Y=s.useCallback(()=>{r!==null&&a.invalidateQueries({queryKey:["file-explorer","tree",r]})},[a,r]),P=s.useCallback(y=>{t!==null&&a.invalidateQueries({queryKey:le(t,y,p),exact:!0})},[a,t,p]);s.useEffect(()=>{if(t!=null&&t.events)return t.events(Y)},[t,Y]);const v=cn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),z=pn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),B=fn(i);return{rows:U,rootLoading:I,rootError:j,rootErrorMessage:w,rootErrorCommand:b,errorPaths:S,toggleExpand:K,ensureExpanded:A,openFile:$,reload:Y,retryDir:P,changes:t!=null&&t.changes?z:null,...v,...B}}function xn(t){const{transport:n,cwd:a}=t;return{scopeKey:a,cwd:a,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(x,p){return n.readFileTree(a,{path:x===""?void 0:x,showHidden:p.showHidden})}}}function ke(t){return Array.from(t).includes("Files")}function st(t){const n=Array.from(t.items??[]);if(!(n.length>0&&n.every(c=>"webkitGetAsEntry"in c)))return{files:Array.from(t.files??[]),folders:0};const x=[];let p=0;for(const c of n){if(c.kind!=="file")continue;const o=c.webkitGetAsEntry();if(o!=null&&o.isDirectory){p+=1;continue}const m=c.getAsFile();m&&x.push(m)}return{files:x,folders:p}}const gn=12;function yn({row:t,selected:n,renaming:a,error:x,onSelect:p,onActivate:c,onRetry:o,onSubmitRename:m,onCancelRename:r,onNewFile:i,onNewFolder:u,onStartRename:N,onDelete:F,onMove:D,onCopyInto:L,onCopy:C,onPaste:U,onDuplicate:I,canPasteInto:j,revealLabel:h,onReveal:g,onAddToChat:w,onCopyPath:b,readOnly:S=!1,provenance:K=!1,copyable:A=!0,onDisk:_=!0,onUpload:$,onPickUpload:Y}){const{entry:P,depth:v,expanded:z,loading:B}=t,d=P.type==="dir",f=d?P.path:G(P.path),[T,y]=s.useState(!1),O=!d&&v===0&&Re(P.name),E=Wt(P.lastCommit),R=e.jsxs("div",{role:"treeitem","aria-label":P.name,"aria-expanded":d?z:void 0,"aria-selected":n,tabIndex:-1,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),p(P),c(P))},draggable:!a&&!S,onDragStart:k=>{S||(k.dataTransfer.setData("text/plain",P.path),k.dataTransfer.setData(tn,P.path),k.dataTransfer.effectAllowed="copyMove")},onDragOver:k=>{if(k.stopPropagation(),!S&&$&&ke(k.dataTransfer.types)){k.preventDefault(),k.dataTransfer.dropEffect="copy",y(!0);return}S||!d||!We(k.dataTransfer.types)||(k.preventDefault(),k.dataTransfer.dropEffect=k.altKey&&A?"copy":"move",y(!0))},onDragLeave:()=>y(!1),onDrop:k=>{if(k.stopPropagation(),S)return;if(y(!1),$&&ke(k.dataTransfer.types)){k.preventDefault();const{files:te}=st(k.dataTransfer);$(f,te);return}if(!d)return;const q=Ye(k.dataTransfer);q!==null&&(k.preventDefault(),k.altKey&&A?L(q,P.path):D(q,P.path))},onClick:()=>{p(P),c(P)},className:Pe("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*gn+8},children:[e.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:d&&(B?e.jsx(Fe,{size:"xs",className:"text-muted-foreground"}):x?e.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:k=>{k.stopPropagation(),o()},className:"flex items-center justify-center",children:e.jsx(Ge,{className:"text-destructive size-3.5"})}):z?e.jsx(pt,{className:"text-muted-foreground size-3.5"}):e.jsx(Ke,{className:"text-muted-foreground size-3.5"}))}),d?z?e.jsx(mt,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):P.isSymlink===!0?e.jsx(xt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),a?e.jsx(vn,{initialName:P.name,onSubmit:k=>m(P,k),onCancel:r}):e.jsx("span",{className:"min-w-0 flex-1 truncate",children:P.name}),O&&!a&&e.jsx(gt,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),K&&!a&&e.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?R:e.jsxs(yt,{children:[e.jsx(vt,{asChild:!0,children:R}),e.jsxs(Ct,{className:"w-52",children:[e.jsx(Z,{movesFocus:!0,onClick:()=>i(f),children:"New file"}),e.jsx(Z,{movesFocus:!0,onClick:()=>u(f),children:"New folder"}),Y&&e.jsx(Z,{onClick:()=>Y(f),children:"Upload files…"}),_&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),h&&e.jsx(Z,{onClick:()=>g(P),children:h}),e.jsx(Z,{movesFocus:!0,onClick:()=>w(P),children:"Add to chat"})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),e.jsx(Z,{onClick:()=>C(P),children:"Copy"}),e.jsx(Z,{disabled:!j(f),onClick:()=>U(f),children:"Paste"}),e.jsx(Z,{onClick:()=>I(P),children:"Duplicate"})]}),e.jsx(ue,{}),_?e.jsxs(e.Fragment,{children:[e.jsx(Z,{onClick:()=>b(P,"absolute"),children:"Copy path"}),e.jsx(Z,{onClick:()=>b(P,"relative"),children:"Copy relative path"})]}):e.jsx(Z,{onClick:()=>b(P,"relative"),children:"Copy path"}),e.jsx(ue,{}),e.jsx(Z,{movesFocus:!0,onClick:()=>N(P),children:"Rename"}),e.jsx(Z,{variant:"destructive",onClick:()=>F(P),children:"Delete"})]})]})}function vn({initialName:t,onSubmit:n,onCancel:a}){const x=s.useRef(null),[p,c]=s.useState(t);s.useEffect(()=>{const m=x.current;if(!m)return;m.focus();const r=t.lastIndexOf(".");m.setSelectionRange(0,r>0?r:t.length)},[t]);const o=()=>{const m=p.trim();m&&m!==t?n(m):a()};return e.jsx("input",{ref:x,type:"text",value:p,"aria-label":"New name",onChange:m=>c(m.target.value),onClick:m=>m.stopPropagation(),onBlur:o,onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"?o():m.key==="Escape"&&a()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Cn=100,bn=28,kn=250;function jn(t){const{rows:n,selectedPath:a,renamingPath:x,errorPaths:p,onSelectPath:c,onRetryDir:o}=t,m=s.useRef(null),r=H(v=>v.setScrollTop),i=H(v=>v.scopeKey),u=s.useCallback(v=>v.type==="dir"?t.onToggle(v):t.onOpen(v),[t]),N=En(t,u),F=n.length>Cn,D=en({count:n.length,getScrollElement:()=>m.current,estimateSize:()=>bn,overscan:12,enabled:F}),L=s.useRef({scope:void 0,done:!1}),C=s.useRef(null);s.useLayoutEffect(()=>{const v=L.current;if(v.scope!==i&&(v.scope=i,v.done=!1),v.done||n.length===0)return;const z=m.current;if(!z)return;const B=H.getState().scrollTop;if(B<=0){v.done=!0;return}F?D.scrollToOffset(B):z.scrollTop=B,C.current=z.scrollTop,z.scrollTop>=B&&(v.done=!0)},[n.length,i,F,D]);const U=s.useRef(null),I=s.useRef(null),j=s.useCallback(()=>{const v=m.current;v&&v.scrollTop!==C.current&&(L.current.done=!0,U.current=v.scrollTop,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,U.current!==null&&r(U.current)},kn))},[r]);s.useEffect(()=>()=>{I.current&&clearTimeout(I.current),U.current!==null&&r(U.current)},[r]);const h=s.useRef(void 0);s.useEffect(()=>{var d,f;const v=h.current;if(h.current=a,v===void 0||a===v||a===null)return;const z=n.findIndex(T=>T.entry.path===a);if(z<0)return;const B=m.current;B&&(F?D.scrollToIndex(z,{align:"auto"}):(f=(d=B.querySelector(`[data-row-index="${z}"]`))==null?void 0:d.scrollIntoView)==null||f.call(d,{block:"nearest"}),C.current=B.scrollTop)},[a,n,F,D]);const[g,w]=s.useState(!1),{onCopyInto:b,onMove:S}=t,K=t.readOnly===!0,A=t.copyable!==!1,_=s.useCallback(v=>{K||!We(v.dataTransfer.types)||(v.preventDefault(),v.dataTransfer.dropEffect=v.altKey&&A?"copy":"move",w(!0))},[K,A]),$=s.useCallback((v,z)=>{const B=n.find(d=>d.entry.path===v);B&&b({path:v,isDir:B.entry.type==="dir"},z)},[n,b]),Y=s.useCallback(v=>{if(w(!1),K)return;const z=Ye(v.dataTransfer);z!==null&&(v.preventDefault(),v.altKey&&A?$(z,Q):S(z,Q))},[$,S,K,A]),P=v=>e.jsx(yn,{row:v,selected:v.entry.path===a,renaming:v.entry.path===x,error:v.entry.type==="dir"&&v.expanded&&p.has(v.entry.path),onSelect:z=>c(z.path),onActivate:u,onRetry:()=>o(v.entry.path),onSubmitRename:t.onSubmitRename,onCancelRename:t.onCancelRename,onStartRename:t.onStartRename,onNewFile:t.onNewFile,onNewFolder:t.onNewFolder,onDelete:t.onDelete,onMove:t.onMove,onCopyInto:$,onCopy:t.onCopy,onPaste:t.onPaste,onDuplicate:t.onDuplicate,canPasteInto:t.canPasteInto,revealLabel:t.revealLabel,onReveal:t.onReveal,onAddToChat:t.onAddToChat,onCopyPath:t.onCopyPath,readOnly:t.readOnly,provenance:t.provenance,copyable:t.copyable,onDisk:t.onDisk,onUpload:t.onUpload,onPickUpload:t.onPickUpload});return e.jsx("div",{ref:m,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:N,onScroll:j,onDragOver:_,onDragLeave:()=>w(!1),onDrop:Y,className:Pe("focus-visible:ring-ring h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",g&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:F?e.jsx("div",{style:{height:D.getTotalSize()},className:"relative w-full",children:D.getVirtualItems().map(v=>e.jsx("div",{"data-row-index":v.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${v.start}px)`},children:P(n[v.index])},n[v.index].entry.path))}):n.map((v,z)=>e.jsx("div",{"data-row-index":z,children:P(v)},v.entry.path))})}function wn(t){return t?t.type==="dir"?t.path:G(t.path):Q}function En(t,n){const{rows:a,selectedPath:x,renamingPath:p,onSelectPath:c}=t;return s.useCallback(o=>{var i,u,N,F;if(p!==null)return;const m=a.findIndex(D=>D.entry.path===x),r=m>=0?a[m]:void 0;if(o.metaKey||o.ctrlKey){if(t.readOnly===!0||t.copyable===!1)return;const D=o.key.toLowerCase();if(D==="c"&&r){o.preventDefault(),t.onCopy(r.entry);return}if(D==="v"){o.preventDefault(),t.onPaste(wn(r==null?void 0:r.entry));return}return}switch(o.key){case"ArrowDown":o.preventDefault(),c(((i=a[Math.min(m+1,a.length-1)])==null?void 0:i.entry.path)??((u=a[0])==null?void 0:u.entry.path));break;case"ArrowUp":o.preventDefault(),c(((N=a[Math.max(m-1,0)])==null?void 0:N.entry.path)??((F=a[0])==null?void 0:F.entry.path));break;case"ArrowRight":(r==null?void 0:r.entry.type)==="dir"&&!r.expanded&&(o.preventDefault(),t.onToggle(r.entry));break;case"ArrowLeft":if(!r)break;if(o.preventDefault(),r.entry.type==="dir"&&r.expanded)t.onToggle(r.entry);else{const D=G(r.entry.path);D&&c(D)}break;case"Enter":r&&(o.preventDefault(),n(r.entry));break;case"F2":r&&t.readOnly!==!0&&(o.preventDefault(),t.onStartRename(r.entry));break;case"Delete":case"Backspace":r&&t.readOnly!==!0&&(o.preventDefault(),t.onDelete(r.entry));break}},[a,x,p,c,t,n])}const Dn={rename:"Rename it anyway",move:"Move it anyway",delete:"Delete it anyway",upload:"Upload mine over it"},Nn={rename:"nothing was renamed",move:"nothing was moved",delete:"nothing was deleted",upload:"nothing was uploaded"};function Rn(t){const{entry:n,fileCount:a,moreThan:x}=t;if(n.type!=="dir")return`“${n.name}” leaves the room’s files.`;const p=a===null?"everything in it":x?`the more than ${a.toLocaleString()} files in it`:a===1?"the 1 file in it":`the ${a.toLocaleString()} files in it`;return`“${n.name}” and ${p} leave the room’s files.`}const Sn="The room’s history keeps a copy. An agent can restore it.";function Tn({changes:t,onOpenTheirs:n,onReturnFocus:a}){var D;const x=L=>{L.preventDefault();const C=document.activeElement;C!==null&&C!==document.body||a()},{pendingDelete:p,pendingClash:c,conflict:o}=t,[m,r]=s.useState(p);p!==null&&p!==m&&r(p);const[i,u]=s.useState(c);c!==null&&c!==i&&u(c);const N=i===null?"":i.dir===Q?"The top folder":`“${i.dir}”`,F=(i==null?void 0:i.names.length)===1;return e.jsxs(e.Fragment,{children:[e.jsx(fe,{open:p!==null,onOpenChange:L=>!L&&t.cancelDelete(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:m===null?"":`Delete “${m.entry.name}”?`}),e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:m===null?"":Rn(m)}),e.jsx("p",{children:Sn})]})})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void t.confirmDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:(m==null?void 0:m.entry.type)==="dir"?"Delete folder":"Delete file"})]})]})}),e.jsx(fe,{open:c!==null,onOpenChange:L=>!L&&t.cancelClash(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:F?`Replace “${i==null?void 0:i.names[0]}”?`:`Replace ${(i==null?void 0:i.names.length)??0} files?`}),e.jsx(xe,{children:F?`${N} already has a file with this name. Replace it, or keep both.`:`${N} already has files named ${(i==null?void 0:i.names.join(", "))??""}. Replace them, or keep both.`})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelClash,children:"Cancel"}),e.jsx(W,{variant:"outline",onClick:()=>void t.resolveClash("keep-both"),children:"Keep both"}),e.jsx(ve,{onClick:()=>void t.resolveClash("replace"),children:"Replace"})]})]})}),e.jsx(fe,{open:o!==null,onOpenChange:L=>!L&&t.dismissConflict(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:"Somebody changed this first"}),e.jsx(xe,{children:o===null?"":`${((D=o.lastCommit)==null?void 0:D.author)??"Somebody"} changed “${o.path}” after you opened it, so ${Nn[o.kind]}.`})]}),(o==null?void 0:o.lastCommit)&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[o.lastCommit.subject," · ",bt(o.lastCommit.at)]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.dismissConflict,children:"Cancel"}),e.jsx(W,{variant:"outline",onClick:()=>{o!==null&&(t.dismissConflict(),n(o.path))},children:"Open their version"}),e.jsx(ve,{onClick:()=>{o!==null&&(t.dismissConflict(),o.retry())},className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:o===null?"":Dn[o.kind]})]})]})})]})}function ze(t,n){return n.name===t?qe(t):`“${n.name}” is already there. Some computers ignore capital letters in names. Pick another name.`}const Fn="Folders can’t be uploaded. Drop the files inside instead.";function Pn({source:t,className:n,onCommands:a}={}){var de;const x=ne(),p=Te(l=>l.selectedCwd),c=s.useMemo(()=>p?xn({transport:x,cwd:p}):null,[x,p]),o=t===void 0?c:t,m=o!==null&&!o.writable,r=mn(o),i=r.changes,u=oe(),N=H(l=>l.showHidden),{rows:F,rootLoading:D,rootError:L,rootErrorMessage:C,rootErrorCommand:U,errorPaths:I}=r,j=H(l=>l.setCommands),h=H(l=>l.selectedPath),g=H(l=>l.setSelectedPath),w=H(l=>l.clipboard),[b,S]=s.useState(null),[K,A]=s.useState(null),[_,$]=s.useState(null),Y=s.useCallback(l=>$(l===null?null:{path:l,isNew:!1}),[]),P=s.useRef(null),v=s.useRef(Q),[z,B]=s.useState(!1),d=s.useCallback((l,M)=>{if(i!==null){if(M.length===0){J.error(Fn);return}r.ensureExpanded(l),i.upload(l,M)}},[i,r]),f=s.useRef(null),T=s.useCallback(()=>{var l,M;(M=(l=f.current)==null?void 0:l.querySelector('[role="tree"]'))==null||M.focus()},[]),y=s.useCallback(l=>{var M;v.current=l,(M=P.current)==null||M.click()},[]),O=s.useCallback(l=>w!==null&&!(w.isDir&&Ce(l,w.path)),[w]),E=s.useCallback((l,M)=>{r.ensureExpanded(l),_e.flushSync(()=>{A(null),S({parent:l,type:M})})},[r]),R=s.useCallback(l=>{_e.flushSync(()=>A(l.path))},[]),k=s.useRef({startCreate:E,reload:r.reload,pickUpload:y});s.useEffect(()=>{k.current={startCreate:E,reload:r.reload,pickUpload:y}});const q=i!==null;s.useEffect(()=>{if(m||a===void 0&&q)return;const l=a??j;return l({newFile:()=>k.current.startCreate(Q,"file"),newFolder:()=>k.current.startCreate(Q,"dir"),refresh:()=>k.current.reload(),...q&&{upload:()=>k.current.pickUpload(Q)}}),()=>l(null)},[j,a,m,q]);const te=s.useCallback(async l=>{var se;if(!b||o===null)return;const M=b;if(S(null),i!==null){const re=(((se=u.getQueryData(le(o,M.parent,N)))==null?void 0:se.entries)??[]).find(ot=>ot.name.toLowerCase()===l.toLowerCase());if(M.type==="dir"){if(re!==void 0&&!(re.type==="dir"&&re.name===l)){J.error(ze(l,re));return}S({parent:ee(M.parent,l),type:"file",firstInFolder:l});return}if(re!==void 0){J.error(ze(l,re));return}const rt=ee(M.parent,l);$({path:rt,isNew:!0});return}await r.createEntry(M.parent,l,M.type)&&g(ee(M.parent,l))},[b,o,i,u,N,r,g]),V=s.useCallback(async(l,M)=>{A(null),(i?await i.renameEntry(l,M):await r.renameEntry(l,M))&&g(ee(G(l.path),M))},[i,r,g]);return o===null?t!==void 0?null:e.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Pick a folder to see its files."}):e.jsxs("div",{ref:f,className:Pe("flex h-full flex-col",z&&"ring-ring/60 bg-accent/30 ring-1 ring-inset",n),onDragOver:l=>{i===null||!ke(l.dataTransfer.types)||(l.preventDefault(),l.dataTransfer.dropEffect="copy",B(!0))},onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||B(!1)},onDrop:l=>{B(!1),!(i===null||!ke(l.dataTransfer.types))&&(l.preventDefault(),d(Q,st(l.dataTransfer).files))},children:[i!==null&&e.jsx("input",{ref:P,type:"file",multiple:!0,hidden:!0,"aria-hidden":!0,tabIndex:-1,"data-testid":"room-files-upload-input",onChange:l=>{const M=Array.from(l.target.files??[]);l.target.value="",d(v.current,M)}}),e.jsxs("div",{className:"min-h-0 flex-1",children:[b&&e.jsx(On,{type:b.type,firstInFolder:b.firstInFolder,onSubmit:l=>void te(l),onCancel:()=>S(null)},`${b.parent}:${b.type}:${b.firstInFolder??""}`),D&&F.length===0?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx(Fe,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):L&&F.length===0?e.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:[e.jsx("span",{children:C??"Couldn’t load files."}),U!==null&&e.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:U}),e.jsxs(W,{variant:"outline",size:"xs",onClick:r.reload,children:[e.jsx(Ge,{}),"Retry"]})]}):F.length===0&&!b?e.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center px-4 text-center text-xs",children:i!==null?"No files yet. Drop files here, or use Upload.":"Empty folder"}):e.jsx(jn,{rows:F,selectedPath:h,renamingPath:K,errorPaths:I,onSelectPath:g,onToggle:r.toggleExpand,onOpen:l=>{o.preview==="inline"?Y(l.path):r.openFile(l)},onRetryDir:r.retryDir,onSubmitRename:(l,M)=>void V(l,M),onCancelRename:()=>A(null),onStartRename:R,onNewFile:l=>E(l,"file"),onNewFolder:l=>E(l,"dir"),onDelete:l=>i?i.requestDelete(l):void r.removeEntry(l),onMove:(l,M)=>void(i?i.moveEntry(l,M):r.moveEntry(l,M)),onCopyInto:(l,M)=>void r.copyEntry(l,M),onCopy:r.copyToClipboard,onPaste:l=>{w&&r.copyEntry(w,l)},onDuplicate:l=>void r.copyEntry({path:l.path,isDir:l.type==="dir"},G(l.path)),canPasteInto:O,readOnly:m,provenance:o.provenance,copyable:i===null,onDisk:o.cwd!==null,onUpload:i?d:void 0,onPickUpload:i?y:void 0,revealLabel:r.revealLabel,onReveal:l=>void r.reveal(l),onAddToChat:r.addToChat,onCopyPath:(l,M)=>void r.copyPath(l,M)})]}),o.preview==="inline"&&e.jsx(Gt,{source:o,path:(_==null?void 0:_.path)??null,isNew:(_==null?void 0:_.isNew)??!1,onCreated:()=>{_!==null&&($({path:_.path,isNew:!1}),g(_.path))},onClose:()=>$(null)}),i!==null&&e.jsx(Tn,{changes:i,onOpenTheirs:l=>Y(l),onReturnFocus:T}),e.jsx(fe,{open:r.pendingRecursiveDelete!==null,onOpenChange:l=>!l&&r.cancelRecursiveDelete(),children:e.jsxs(he,{children:[e.jsxs(pe,{children:[e.jsxs(me,{children:["Delete “",(de=r.pendingRecursiveDelete)==null?void 0:de.name,"”?"]}),e.jsx(xe,{children:"This folder isn’t empty. Everything inside is deleted. This can’t be undone."})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:r.cancelRecursiveDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void r.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete folder"})]})]})})]})}function On({type:t,firstInFolder:n,onSubmit:a,onCancel:x}){const p=s.useRef(null),[c,o]=s.useState("");s.useEffect(()=>{var i;(i=p.current)==null||i.focus()},[]);const m=()=>{const i=c.trim();i?a(i):x()},r=e.jsxs("div",{className:"flex items-center gap-1",children:[t==="dir"?e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("input",{ref:p,type:"text",value:c,"aria-label":n!==void 0?`First file in ${n}`:t==="dir"?"New folder name":"New file name",placeholder:t==="dir"?"folder-name":"file-name",onChange:i=>o(i.target.value),onBlur:m,onKeyDown:i=>{i.key==="Enter"?m():i.key==="Escape"&&x()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]});return n===void 0?e.jsx("div",{className:"px-3 py-1",children:r}):e.jsxs("div",{className:"space-y-1 px-3 py-1",children:[e.jsxs("p",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(be,{className:"size-(--size-icon-xs) flex-shrink-0 text-sky-500"}),e.jsx("span",{className:"truncate",children:n})]}),r,e.jsx("p",{className:"text-muted-foreground text-2xs",children:"Name its first file. The folder appears on save."})]})}function at(){const t=H(x=>x.showHidden),n=H(x=>x.setShowHidden),a=t?"Hide hidden files":"Show hidden files";return e.jsx(W,{variant:"ghost",size:"icon-xs","aria-label":a,title:a,onClick:()=>n(!t),children:t?e.jsx(kt,{className:"text-muted-foreground"}):e.jsx(jt,{className:"text-muted-foreground"})})}function Mn({cwd:t}){const n=ne(),{data:a}=ce({queryKey:["file-explorer","workspace",t],queryFn:()=>n.resolveWorkspace(t),staleTime:6e4});return a!=null&&a.branch?e.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 ${a.key} on ${a.branch}`,children:[e.jsx(Xe,{className:"size-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a.branch})]}):null}function Vn(){const t=Te(a=>a.selectedCwd),n=H(a=>a.commands);return t?e.jsxs(e.Fragment,{children:[e.jsx(Mn,{cwd:t}),e.jsx(W,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>n==null?void 0:n.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(W,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>n==null?void 0:n.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(at,{}),e.jsx(W,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>n==null?void 0:n.refresh(),children:e.jsx(wt,{className:"text-muted-foreground"})})]}):null}function _n({roomId:t}){const n=ne(),a=oe(),x=ce(Ue(n,t));s.useEffect(()=>Vt(a,t,()=>{a.invalidateQueries({queryKey:De.repoStatus(t)})}),[a,t]);const p=s.useMemo(()=>{var r;return((r=x.data)==null?void 0:r.kind)==="ok"?Et(x.data.status):[]},[x.data]),c=Dt(p),o=Nt(p);if(!o)return null;const m=p.map((r,i)=>`${c[i]}: ${Rt(r)}`);return e.jsxs("span",{"data-slot":"pending-work-badge",title:m.join(`
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:[e.jsx(Xe,{className:"size-3 flex-shrink-0"}),e.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",m.join(". "),"."]}),e.jsx("span",{"aria-hidden":"true",className:"truncate",children:o})]})}const An={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Ln=new Map([["OPERATOR_ONLY","Only the owner of this DorkOS can keep or discard these."],["ROOM_FILE_NOT_FOUND","One of those changes is gone, so nothing was discarded. The list is refreshed."],["MERGE_IN_FLIGHT","Something else is writing to these files. Nothing changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","These files are on another branch. Switch them back to main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","Room files need git, and git isn’t installed on this computer."],["ROOM_HAS_NO_REPO","This room no longer has its own files."],["ROOM_REPOS_DISABLED","Room files are turned off on this install."]]);function zn({roomId:t}){var U,I;const n=ne(),a=oe(),x=ce(Ue(n,t)),[p,c]=s.useState([]),[o,m]=s.useState(!1),[r,i]=s.useState(null),u=St({mutationFn:j=>n.repairRoomMain(t,j),onSuccess:()=>{c([]),m(!1),i(null),a.invalidateQueries({queryKey:De.repoStatus(t)})},onError:j=>{m(!1);const h=Ln.get(Tt(j)??"");i(h??"Couldn’t update the files. Try again in a moment."),a.invalidateQueries({queryKey:De.repoStatus(t)})}});if(((U=x.data)==null?void 0:U.kind)==="unavailable")return e.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:"Couldn’t check this room’s files. Saves may not work. Try again soon."});const N=((I=x.data)==null?void 0:I.kind)==="ok"?x.data.status.main:void 0;if(N===void 0||!N.dirty)return null;const F=N.branch!=="main",D=p.filter(j=>N.strays.some(h=>h.path===j)),L=o&&D.length>0,C=j=>c(h=>h.includes(j)?h.filter(g=>g!==j):[...h,j]);return e.jsxs("div",{"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:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ft,{className:"text-muted-foreground mt-0.5 size-(--size-icon-sm) flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{role:"alert",className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Somebody changed this room’s files outside DorkOS"}),F?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:`This room’s files are on ${N.branch??"no branch"}, not main.`}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until they’re back on main."})]}):e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until you keep or discard these."})]}),F&&e.jsx(Pt,{className:"text-xs",children:e.jsx("p",{children:"DorkOS won’t switch the branch for you. There may be work on it."})})]})]}),!F&&e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-1.5",children:N.strays.map(j=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Ot,{id:`stray-${t}-${j.path}`,checked:D.includes(j.path),onCheckedChange:()=>C(j.path),disabled:u.isPending}),e.jsx("label",{htmlFor:`stray-${t}-${j.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:j.path,children:j.path}),e.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:An[j.kind]})]},j.path))}),N.strayCount>N.strays.length&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",N.strayCount-N.strays.length," more not shown. “Keep them all” keeps these too."]}),L?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs",children:D.length===1?"Discard this change? It can’t be undone.":`Discard these ${D.length} changes? They can’t be undone.`}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(W,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending,onClick:()=>m(!1),children:"Cancel"}),e.jsx(W,{type:"button",variant:"destructive",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"discard",paths:[...D]}),children:D.length===1?"Discard change":`Discard ${D.length} changes`})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(W,{type:"button",variant:"outline",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"commit"}),children:"Keep them all"}),e.jsx(W,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending||D.length===0,onClick:()=>m(!0),children:D.length===0?"Discard…":`Discard ${D.length}`})]})]}),r!==null&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:r})]})}const Ee="pointer-coarse:size-11";function Xn({roomId:t,canChange:n}){const a=ne(),x=oe(),p=H(F=>F.showHidden),[c,o]=s.useState(null),m=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t,canChange:n}),[a,x,t,n]),r=ce(je(m,Q,p,x)),i=r.isSuccess&&r.data.absent!==!0||r.isError,[u,N]=s.useState(null);return i&&u!==t&&N(t),!i&&u!==t?null:e.jsxs("section",{"aria-label":"Room files",className:"space-y-2",children:[e.jsxs("header",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Files"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(_n,{roomId:t})}),n&&e.jsxs(e.Fragment,{children:[e.jsx(W,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New file",title:"New file",disabled:c===null,onClick:()=>c==null?void 0:c.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(W,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New folder",title:"New folder",disabled:c===null,onClick:()=>c==null?void 0:c.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(W,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"Upload files",title:"Upload files",disabled:(c==null?void 0:c.upload)===void 0,onClick:()=>{var F;return(F=c==null?void 0:c.upload)==null?void 0:F.call(c)},children:e.jsx(sn,{className:"text-muted-foreground"})})]}),e.jsx(at,{})]}),e.jsx(zn,{roomId:t}),e.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:e.jsx(Pn,{source:m,onCommands:o})})]})}function Zn({roomId:t,attachment:n}){var i;const a=ne(),x=oe(),p=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t}),[a,x,t]),c=ce(je(p,Q,!1,x)),[o,m]=s.useState(!1),r=_t(t);return!c.isSuccess||c.data.absent===!0||((i=r.data)==null?void 0:i.archived)!==!1?null:e.jsxs(e.Fragment,{children:[e.jsx(W,{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:()=>m(!0),children:e.jsx(At,{})}),o&&e.jsx($n,{roomId:t,source:p,attachment:n,onClose:()=>m(!1)})]})}function $n({roomId:t,source:n,attachment:a,onClose:x}){const p=ne(),c=oe(),[o,m]=s.useState(Q),[r,i]=s.useState(a.name),[u,N]=s.useState(null),[F,D]=s.useState(!1),L=s.useId(),C=ce(je(n,o,!1,c)),U=s.useMemo(()=>{var j;return nt(((j=C.data)==null?void 0:j.entries)??[]).filter(h=>h.type==="dir")},[C.data]),I=async()=>{var h,g;const j=r.trim();if(j!==""){D(!0),N(null);try{await p.saveAttachmentToRoomFiles(t,{attachmentId:a.id,dir:o,name:j,baseCommit:((h=C.data)==null?void 0:h.commit)??null}),c.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),J.success(`Saved ${j} to the room’s files`),x()}catch(w){let b;try{b=Xt(w,c,t)}catch{b={status:"refused",reason:Qe(w)??"Couldn’t save. Try again in a moment."}}if(b.status==="exists"){const S=(((g=C.data)==null?void 0:g.entries)??[]).map(K=>K.name);N({reason:`This folder already has a file called “${j}”. Pick another name.`,suggestion:Oe({name:j,isDir:!1,taken:[...S,j]})})}else b.status==="conflict"?(N({reason:"This folder changed while you chose, so nothing was saved. Try again."}),C.refetch()):b.status==="refused"&&N({reason:b.reason})}finally{D(!1)}}};return e.jsx(Lt,{open:!0,onOpenChange:j=>!j&&x(),children:e.jsxs(zt,{className:"sm:max-w-md",children:[e.jsxs($t,{children:[e.jsx(It,{children:"Save to room files"}),e.jsx(Kt,{children:"Everyone in the room, and their agents, can find it there."})]}),e.jsxs(Ht,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Folder"}),e.jsxs("div",{role:"group","aria-label":"Folders",className:"border-border/60 max-h-56 overflow-auto rounded-md border",children:[e.jsx("p",{className:"bg-muted/40 truncate px-3 py-1.5 font-mono text-xs",children:o===Q?"Top folder":`${o}/`}),o!==Q&&e.jsx($e,{label:"Up one folder",icon:e.jsx(nn,{className:"text-muted-foreground size-(--size-icon-sm)"}),onClick:()=>m(G(o))}),C.isPending?e.jsx("div",{className:"flex h-12 items-center justify-center",children:e.jsx(Fe,{size:"sm",className:"text-muted-foreground",label:"Loading folders"})}):U.length===0?e.jsx("p",{className:"text-muted-foreground px-3 py-2 text-xs",children:"No folders in here."}):U.map(j=>e.jsx($e,{label:j.name,icon:e.jsx(be,{className:"size-(--size-icon-sm) text-sky-500"}),chevron:!0,onClick:()=>m(ee(o,ie(j.path)))},j.path))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:L,className:"text-muted-foreground text-xs font-medium",children:"Name"}),e.jsx(Ut,{id:L,value:r,onChange:j=>{i(j.target.value),N(null)},spellCheck:!1,autoComplete:"off"})]}),u!==null&&e.jsxs("div",{role:"alert",className:"text-destructive space-y-1 text-xs",children:[e.jsx("p",{children:u.reason}),u.suggestion!==void 0&&e.jsxs(W,{type:"button",variant:"outline",size:"xs",onClick:()=>{i(u.suggestion),N(null)},children:["Use “",u.suggestion,"”"]})]})]}),e.jsxs(qt,{className:"gap-2",children:[e.jsx(W,{type:"button",variant:"ghost",onClick:x,children:"Cancel"}),e.jsx(W,{type:"button",disabled:F||r.trim()===""||C.isPending,onClick:()=>void I(),children:F?"Saving…":o===Q?"Save to the top folder":`Save to ${ie(o)}`})]})]})})}function $e({label:t,icon:n,chevron:a=!1,onClick:x}){return e.jsxs("button",{type:"button",onClick:x,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,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),a&&e.jsx(Ke,{className:"text-muted-foreground size-3.5"})]})}export{Pn as FileExplorer,Vn as FileExplorerActions,Gt as FilePreviewDialog,an as HIDDEN_ENTRY_NAMES,at as HiddenEntriesToggle,ts as NO_PROVENANCE,Ne as PINNED_ENTRY_NAMES,ns as ROOM_FILES_REFRESH_INTERVAL_MS,Xn as RoomFilesSection,Zn as SaveToRoomFilesButton,Be as createRoomFilesSource,xn as createSessionCwdSource,le as explorerDirQueryKey,je as explorerDirQueryOptions,rn as isHiddenEntryName,Re as isPinnedEntryName,on as pinnedFirst,Wt as provenanceLine,Ue as roomRepoStatusQueryOptions,nt as withoutHidden};
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 sn=Se(tt);function le(t,n,a){return["file-explorer","tree",t.scopeKey,n,t.filtersHidden?a:null]}function je(t,n,a,x){return{queryKey:le(t,n,a),queryFn:()=>t.list(n,{showHidden:a}),staleTime:Me.FILE_TREE_STALE_TIME_MS,gcTime:Me.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??x.getQueryData(le(t,n,!a))}}const an=[".git",".dork",".claude",".agents","node_modules"];function rn(t){return t.startsWith(".")||an.includes(t)}const Ne=["ROOM.md","README.md"];function Re(t){return Ne.some(n=>n.toLowerCase()===t.toLowerCase())}function nt(t){return t.filter(n=>!rn(n.name))}function on(t){if(t.reduce((p,c)=>c.type==="file"&&Re(c.name)?p+1:p,0)===0)return t;const a=[],x=[];for(const p of t)p.type==="file"&&Re(p.name)?a.push(p):x.push(p);return a.sort((p,c)=>Ne.findIndex(o=>o.toLowerCase()===p.name.toLowerCase())-Ne.findIndex(o=>o.toLowerCase()===c.name.toLowerCase())),[...a,...x]}const ln=/ copy(?: \d+)?$/;function Oe({name:t,isDir:n,taken:a}){const x=new Set(a);if(!x.has(t))return t;const p=n?-1:t.lastIndexOf("."),c=p>0,o=c?t.slice(p):"",m=(c?t.slice(0,p):t).replace(ln,"");for(let r=1;;r+=1){const i=r===1?`${m} copy${o}`:`${m} copy ${r}${o}`;if(!x.has(i))return i}}function Ae(t,n,a){return{name:n,path:t,type:a,size:0,mtime:Date.now(),isSymlink:!1}}function cn(t){const n=ne(),{source:a,showHidden:x,queryClient:p,inFlightRef:c}=t,o=a.cwd??"",[m,r]=s.useState(null),i=s.useCallback(async h=>{c.current+=1;try{return await h()}finally{c.current-=1}},[c]),u=s.useMemo(()=>{const h=g=>le(a,g,x);return{getChildren:g=>{var w;return((w=p.getQueryData(h(g)))==null?void 0:w.entries)??[]},isLoaded:g=>p.getQueryData(h(g))!==void 0,takenNames:async g=>(await n.readFileTree(o,{path:g===Q?void 0:g,showHidden:!0})).entries.map(b=>b.name),snapshot:g=>p.getQueryData(h(g)),setChildren:(g,w)=>{p.setQueryData(h(g),b=>({entries:Ie(w((b==null?void 0:b.entries)??[]))}))},restore:(g,w)=>{p.setQueryData(h(g),w)},invalidate:g=>{p.invalidateQueries({queryKey:h(g),exact:!0})}}},[p,n,o,a,x]),N=s.useCallback((h,g,w)=>i(async()=>{const b=ee(h,g),S=!u.getChildren(h).some(A=>A.path===b),K=u.snapshot(h);S&&u.setChildren(h,A=>[...A,Ae(b,g,w)]);try{return await n.createEntry(o,b,w),!0}catch(A){return S&&u.restore(h,K),ae(A,`Couldn’t create ${w==="dir"?"folder":"file"}`),!1}finally{u.invalidate(h)}}),[n,o,u,i]),F=s.useCallback((h,g)=>i(async()=>{if(g===h.name||g.length===0)return!0;const w=W(h.path),b=ee(w,g),S=u.getChildren(w).some(_=>_.path===b),K=u.snapshot(w),A={...h,name:g,path:b};S||u.setChildren(w,_=>_.map($=>$.path===h.path?A:$));try{return await n.renameEntry(o,h.path,b),H.getState().remapExpandedPaths(h.path,b),!0}catch(_){return S||u.restore(w,K),ae(_,"Couldn’t rename"),!1}finally{u.invalidate(w)}}),[n,o,u,i]),D=s.useCallback(h=>i(async()=>{const g=W(h.path),w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path,{recursive:!0}),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}}),[n,o,u,i]),L=s.useCallback(h=>i(async()=>{const g=W(h.path);if(h.type==="file"){const w=u.snapshot(g);u.setChildren(g,b=>b.filter(S=>S.path!==h.path));try{await n.deleteEntry(o,h.path),H.getState().dropExpandedPaths(h.path)}catch(b){u.restore(g,w),ae(b,"Couldn’t delete")}finally{u.invalidate(g)}return}try{await n.deleteEntry(o,h.path),u.setChildren(g,w=>w.filter(b=>b.path!==h.path)),H.getState().dropExpandedPaths(h.path),u.invalidate(g)}catch(w){if(Qt(w)==="DIR_NOT_EMPTY"){r(h);return}ae(w,"Couldn’t delete")}}),[n,o,u,i]),C=s.useCallback(async()=>{const h=m;r(null),h&&await D(h)},[m,D]),q=s.useCallback(()=>r(null),[]),I=s.useCallback((h,g)=>i(async()=>{const w=W(h),b=ie(h),S=ee(g,b);if(g===w||S===h||Ce(g,h))return;const K=u.getChildren(w).find(v=>v.path===h);if(!K)return;const A=u.isLoaded(g),_=A&&u.getChildren(g).some(v=>v.path===S),$={...K,name:b,path:S},Y=u.snapshot(w),P=A?u.snapshot(g):void 0;u.setChildren(w,v=>v.filter(z=>z.path!==h)),A&&!_&&u.setChildren(g,v=>[...v,$]);try{await n.renameEntry(o,h,S),H.getState().remapExpandedPaths(h,S)}catch(v){u.restore(w,Y),A&&!_&&u.restore(g,P),ae(v,"Couldn’t move")}finally{u.invalidate(w),A&&u.invalidate(g)}}),[n,o,u,i]),j=s.useCallback((h,g)=>i(async()=>{if(h.isDir&&Ce(g,h.path)){X.error(Bt);return}let w;try{w=await u.takenNames(g)}catch(_){ae(_,"Couldn’t copy");return}const b=Oe({name:ie(h.path),isDir:h.isDir,taken:w}),S=ee(g,b),K=u.isLoaded(g),A=K?u.snapshot(g):void 0;if(K){const _=u.getChildren(W(h.path)).find(Y=>Y.path===h.path),$=_?{..._,name:b,path:S}:Ae(S,b,h.isDir?"dir":"file");u.setChildren(g,Y=>[...Y,$])}try{await n.copyEntry(o,h.path,S)}catch(_){K&&u.restore(g,A),ae(_,"Couldn’t copy")}finally{u.invalidate(g)}}),[n,o,u,i]);return{createEntry:N,renameEntry:F,removeEntry:L,moveEntry:I,copyEntry:j,pendingRecursiveDelete:m,confirmRecursiveDelete:C,cancelRecursiveDelete:q}}function dn(t){return t!=null&&t.startsWith("darwin")?"Reveal in Finder":t!=null&&t.startsWith("win32")?"Reveal in File Explorer":"Show in file manager"}function un(t,n){const a=t.includes("\\")&&!t.includes("/"),x=t.replace(/[\\/]+$/,""),p=a?n.split("/").join("\\"):n;return`${x}${a?"\\":"/"}${p}`}function fn(t){const n=ne(),{data:a}=it(),x=s.useMemo(()=>n.supportsReveal?dn(a==null?void 0:a.platform):null,[n.supportsReveal,a==null?void 0:a.platform]),p=s.useCallback(async i=>{if(t)try{await n.revealEntry(t,i.path)}catch(u){ae(u,"Couldn’t open the file manager")}},[n,t]),{copy:c}=lt(),o=s.useCallback(async(i,u)=>{const N=u==="absolute"&&t?un(t,i.path):i.path;await c(N)||X.error("Couldn’t copy to the clipboard")},[t,c]),m=s.useCallback(i=>{Jt(Xt(i.path))||X.error("Open a chat to add this file")},[]),r=s.useCallback(i=>{H.getState().setClipboard({path:i.path,isDir:i.type==="dir"});try{navigator.clipboard.writeText(i.path).catch(()=>{})}catch{}},[]);return{revealLabel:x,reveal:p,copyPath:o,addToChat:m,copyToClipboard:r}}const hn=1e3;function pn(t){const{source:n,showHidden:a,queryClient:x,inFlightRef:p}=t,c=n.changes,[o,m]=s.useState(null),[r,i]=s.useState(null),[u,N]=s.useState(null),[F,D]=s.useState(0),L=s.useCallback(async d=>{p.current+=1,D(f=>f+1);try{return await d()}finally{p.current-=1,D(f=>f-1)}},[p]),C=s.useMemo(()=>{const d=f=>le(n,f,a);return{listing:f=>x.getQueryData(d(f)),isLoaded:f=>x.getQueryData(d(f))!==void 0,entries:f=>{var T;return((T=x.getQueryData(d(f)))==null?void 0:T.entries)??[]},setEntries:(f,T)=>x.setQueryData(d(f),y=>({...y,entries:Ie(T((y==null?void 0:y.entries)??[]))})),restore:(f,T)=>x.setQueryData(d(f),T),fetch:f=>n.list(f,{showHidden:!0}),refreshAll:()=>{x.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),x.invalidateQueries({queryKey:["file-explorer","preview",n.scopeKey]})}}},[x,n,a]),q=s.useCallback(async d=>{const f=C.listing(d);return(f==null?void 0:f.commit)!==void 0?f.commit:(await C.fetch(d)).commit??null},[C]),I=s.useCallback((d,f,T,y)=>{switch(d.status){case"changed":return!0;case"conflict":return N({kind:f,path:d.path,lastCommit:d.lastCommit,retry:()=>T(d.commit)}),!1;case"exists":return X.error(y===void 0?d.reason:Ue(y)),!1;case"refused":return X.error(d.reason),!1}},[]),j=s.useCallback((d,f)=>{X.error(Qe(d)??f)},[]),h=s.useCallback((d,f,T)=>{const y=O=>L(async()=>{if(c===void 0)return!1;const E=W(d.path),R=W(f),k=ie(f),U=C.isLoaded(R),te=U&&C.entries(R).some(Z=>Z.path===f),V=C.listing(E),de=R===E?void 0:C.listing(R),l={...d,name:k,path:f};te||(R===E?C.setEntries(E,Z=>Z.map(se=>se.path===d.path?l:se)):(C.setEntries(E,Z=>Z.filter(se=>se.path!==d.path)),U&&C.setEntries(R,Z=>[...Z,l])));const M=()=>{C.restore(E,V),R!==E&&U&&C.restore(R,de)};try{const Z=O??await q(E);if(Z===null)return M(),X.error("This room has no files to change yet."),!1;const se=await c.move({from:d.path,to:f,baseCommit:Z}),we=I(se,T,async re=>{await y(re)},k);return we?H.getState().remapExpandedPaths(d.path,f):M(),we}catch(Z){return M(),j(Z,T==="rename"?"Couldn’t rename":"Couldn’t move"),!1}finally{C.refreshAll()}});return y(null)},[c,C,L,q,I,j]),g=s.useCallback(async(d,f)=>f===d.name||f.length===0?!0:h(d,ee(W(d.path),f),"rename"),[h]),w=s.useCallback(async(d,f)=>{const T=W(d),y=ee(f,ie(d));if(f===T||y===d||Ce(f,d))return;const O=C.entries(T).find(E=>E.path===d);O&&await h(O,y,"move")},[C,h]),b=s.useCallback(async d=>{let f=0;const T=[d];for(;T.length>0;){const y=T.shift(),O=await C.fetch(y);for(const E of O.entries)if(E.type==="dir"?T.push(E.path):f+=1,f>=hn)return{count:f,moreThan:!0}}return{count:f,moreThan:!1}},[C]),S=s.useCallback(d=>{if(d.type!=="dir"){m({entry:d,fileCount:1,moreThan:!1});return}m({entry:d,fileCount:null,moreThan:!1}),b(d.path).then(({count:f,moreThan:T})=>m(y=>(y==null?void 0:y.entry.path)===d.path?{entry:d,fileCount:f,moreThan:T}:y),()=>{})},[b]),K=s.useCallback(d=>{const f=T=>L(async()=>{if(c===void 0)return;const y=W(d.path),O=C.listing(y);C.setEntries(y,E=>E.filter(R=>R.path!==d.path));try{const E=T??await q(y);if(E===null){C.restore(y,O);return}const R=await c.remove({path:d.path,baseCommit:E});I(R,"delete",U=>f(U))?H.getState().dropExpandedPaths(d.path):C.restore(y,O)}catch(E){C.restore(y,O),j(E,"Couldn’t delete")}finally{C.refreshAll()}});return f(null)},[c,C,L,q,I,j]),A=s.useCallback(async()=>{const d=o;m(null),d&&await K(d.entry)},[o,K]),_=s.useCallback(()=>m(null),[]),$=s.useCallback((d,f,T,y)=>{const O=E=>L(async()=>{if(c===void 0)return;const R=C.isLoaded(d),k=R?C.listing(d):void 0;if(R){const U=new Set(C.entries(d).map(V=>V.name)),te=f.filter(V=>!U.has(V.name)).map(V=>({name:V.name,path:ee(d,V.name),type:"file",size:V.size}));te.length>0&&C.setEntries(d,V=>[...V,...te])}try{const U=await c.upload({dir:d,baseCommit:E,replace:T,files:f});!I(U,"upload",V=>O(V))&&R&&C.restore(d,k)}catch(U){R&&C.restore(d,k),j(U,"Couldn’t upload")}finally{C.refreshAll()}});return O(y)},[c,C,L,I,j]),Y=s.useCallback(async(d,f)=>{if(c===void 0||f.length===0)return;if(f.length>c.maxUploadFiles){X.error(`Nothing was uploaded. One upload takes up to ${c.maxUploadFiles} files.`);return}let T;try{T=await C.fetch(d)}catch(k){j(k,"Couldn’t upload");return}const y=T.entries.map(k=>k.name),O=new Set(y),E=f.map(k=>k.name).filter(k=>O.has(k)),R=T.commit??null;if(E.length===0){await $(d,f,[],R);return}i({dir:d,files:f,names:E,taken:y,baseCommit:R})},[c,C,j,$]),P=s.useCallback(async d=>{const f=r;if(i(null),f===null)return;if(d==="replace"){await $(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 R=Oe({name:E.name,isDir:!1,taken:T});return T.add(R),new File([E],R,{type:E.type,lastModified:E.lastModified})});await $(f.dir,O,[],f.baseCommit)},[r,$]),v=s.useCallback(()=>i(null),[]),z=s.useCallback(()=>N(null),[]),B=s.useMemo(()=>r===null?null:{dir:r.dir,names:r.names},[r]);return{renameEntry:g,moveEntry:w,requestDelete:S,pendingDelete:o,confirmDelete:A,cancelDelete:_,upload:Y,pendingClash:B,resolveClash:P,cancelClash:v,conflict:u,dismissConflict:z,busy:F>0}}const Le={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function mn(t){var d,f,T;const n=ne(),a=oe(),{setTheme:x}=ct(),p=H(y=>y.showHidden),c=H(y=>y.expanded),o=H(y=>y.loadExplorerForCwd),m=H(y=>y.pruneMissing),r=(t==null?void 0:t.scopeKey)??null,i=(t==null?void 0:t.cwd)??null;s.useEffect(()=>{o(r)},[r,o]);const u=s.useMemo(()=>[Q,...dt(c)],[c]),N=ut({queries:t?u.map(y=>je(t,y,p,a)):[]}),F=(t==null?void 0:t.filtersHidden)??!0,D=s.useMemo(()=>{const y={};return u.forEach((O,E)=>{var U;const R=N[E];let k=((U=R==null?void 0:R.data)==null?void 0:U.entries)??[];!p&&!F&&(k=nt(k)),O===Q&&(k=on(k)),y[O]={entries:k,loading:(R==null?void 0:R.isLoading)??!1,error:(R==null?void 0:R.isError)??!1}}),y},[u,N,p,F]),L=s.useRef(0),C=s.useRef({});s.useEffect(()=>{L.current>0||u.forEach((y,O)=>{var R,k,U;const E=(k=(R=N[O])==null?void 0:R.data)==null?void 0:k.entries;!E||(U=N[O])!=null&&U.isError||C.current[y]!==E&&(C.current[y]=E,m(y,E.map(te=>te.name)))})},[u,N,m]);const q=s.useMemo(()=>ft(c,D),[c,D]),I=!!t&&!!((d=D[Q])!=null&&d.loading),j=!!t&&!!((f=D[Q])!=null&&f.error),h=(T=N[0])==null?void 0:T.error,g=j&&h?Yt(h):void 0,w=(g==null?void 0:g.message)??null,b=(g==null?void 0:g.command)??null,S=s.useMemo(()=>{var O;const y=new Set;for(const E of u)E!==Q&&((O=D[E])!=null&&O.error)&&y.add(E);return y},[u,D]),K=s.useCallback(y=>{if(y.type!=="dir")return;const O=H.getState();O.setDirExpanded(y.path,!O.expanded[y.path])},[]),A=s.useCallback(y=>{if(y===Q)return;const O=H.getState();O.expanded[y]||O.setDirExpanded(y,!0)},[]),_=(t==null?void 0:t.preview)==="canvas",$=s.useCallback(y=>{if(y.type!=="file"||!_)return;const O={getStore:Te.getState,setTheme:x,supportsTerminal:n.supportsTerminal};ht(O,{action:"open_file",sourcePath:y.path},"user")},[_,x,n]),Y=s.useCallback(()=>{r!==null&&a.invalidateQueries({queryKey:["file-explorer","tree",r]})},[a,r]),P=s.useCallback(y=>{t!==null&&a.invalidateQueries({queryKey:le(t,y,p),exact:!0})},[a,t,p]);s.useEffect(()=>{if(t!=null&&t.events)return t.events(Y)},[t,Y]);const v=cn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),z=pn({source:t??Le,showHidden:p,queryClient:a,inFlightRef:L}),B=fn(i);return{rows:q,rootLoading:I,rootError:j,rootErrorMessage:w,rootErrorCommand:b,errorPaths:S,toggleExpand:K,ensureExpanded:A,openFile:$,reload:Y,retryDir:P,changes:t!=null&&t.changes?z:null,...v,...B}}function xn(t){const{transport:n,cwd:a}=t;return{scopeKey:a,cwd:a,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(x,p){return n.readFileTree(a,{path:x===""?void 0:x,showHidden:p.showHidden})}}}function ke(t){return Array.from(t).includes("Files")}function st(t){const n=Array.from(t.items??[]);if(!(n.length>0&&n.every(c=>"webkitGetAsEntry"in c)))return{files:Array.from(t.files??[]),folders:0};const x=[];let p=0;for(const c of n){if(c.kind!=="file")continue;const o=c.webkitGetAsEntry();if(o!=null&&o.isDirectory){p+=1;continue}const m=c.getAsFile();m&&x.push(m)}return{files:x,folders:p}}const gn=12;function yn({row:t,selected:n,renaming:a,error:x,onSelect:p,onActivate:c,onRetry:o,onSubmitRename:m,onCancelRename:r,onNewFile:i,onNewFolder:u,onStartRename:N,onDelete:F,onMove:D,onCopyInto:L,onCopy:C,onPaste:q,onDuplicate:I,canPasteInto:j,revealLabel:h,onReveal:g,onAddToChat:w,onCopyPath:b,readOnly:S=!1,provenance:K=!1,copyable:A=!0,onDisk:_=!0,onUpload:$,onPickUpload:Y}){const{entry:P,depth:v,expanded:z,loading:B}=t,d=P.type==="dir",f=d?P.path:W(P.path),[T,y]=s.useState(!1),O=!d&&v===0&&Re(P.name),E=Gt(P.lastCommit),R=e.jsxs("div",{role:"treeitem","aria-label":P.name,"aria-expanded":d?z:void 0,"aria-selected":n,tabIndex:-1,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),p(P),c(P))},draggable:!a&&!S,onDragStart:k=>{S||(k.dataTransfer.setData("text/plain",P.path),k.dataTransfer.setData(tn,P.path),k.dataTransfer.effectAllowed="copyMove")},onDragOver:k=>{if(k.stopPropagation(),!S&&$&&ke(k.dataTransfer.types)){k.preventDefault(),k.dataTransfer.dropEffect="copy",y(!0);return}S||!d||!Ge(k.dataTransfer.types)||(k.preventDefault(),k.dataTransfer.dropEffect=k.altKey&&A?"copy":"move",y(!0))},onDragLeave:()=>y(!1),onDrop:k=>{if(k.stopPropagation(),S)return;if(y(!1),$&&ke(k.dataTransfer.types)){k.preventDefault();const{files:te}=st(k.dataTransfer);$(f,te);return}if(!d)return;const U=Ye(k.dataTransfer);U!==null&&(k.preventDefault(),k.altKey&&A?L(U,P.path):D(U,P.path))},onClick:()=>{p(P),c(P)},className:Pe("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*gn+8},children:[e.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:d&&(B?e.jsx(Fe,{size:"xs",className:"text-muted-foreground"}):x?e.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:k=>{k.stopPropagation(),o()},className:"flex items-center justify-center",children:e.jsx(We,{className:"text-destructive size-3.5"})}):z?e.jsx(pt,{className:"text-muted-foreground size-3.5"}):e.jsx(Ke,{className:"text-muted-foreground size-3.5"}))}),d?z?e.jsx(mt,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):P.isSymlink===!0?e.jsx(xt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),a?e.jsx(vn,{initialName:P.name,onSubmit:k=>m(P,k),onCancel:r}):e.jsx("span",{className:"min-w-0 flex-1 truncate",children:P.name}),O&&!a&&e.jsx(gt,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),K&&!a&&e.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?R:e.jsxs(yt,{children:[e.jsx(vt,{asChild:!0,children:R}),e.jsxs(Ct,{className:"w-52",children:[e.jsx(J,{movesFocus:!0,onClick:()=>i(f),children:"New file"}),e.jsx(J,{movesFocus:!0,onClick:()=>u(f),children:"New folder"}),Y&&e.jsx(J,{onClick:()=>Y(f),children:"Upload files…"}),_&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),h&&e.jsx(J,{onClick:()=>g(P),children:h}),e.jsx(J,{movesFocus:!0,onClick:()=>w(P),children:"Add to chat"})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),e.jsx(J,{onClick:()=>C(P),children:"Copy"}),e.jsx(J,{disabled:!j(f),onClick:()=>q(f),children:"Paste"}),e.jsx(J,{onClick:()=>I(P),children:"Duplicate"})]}),e.jsx(ue,{}),_?e.jsxs(e.Fragment,{children:[e.jsx(J,{onClick:()=>b(P,"absolute"),children:"Copy path"}),e.jsx(J,{onClick:()=>b(P,"relative"),children:"Copy relative path"})]}):e.jsx(J,{onClick:()=>b(P,"relative"),children:"Copy path"}),e.jsx(ue,{}),e.jsx(J,{movesFocus:!0,onClick:()=>N(P),children:"Rename"}),e.jsx(J,{variant:"destructive",onClick:()=>F(P),children:"Delete"})]})]})}function vn({initialName:t,onSubmit:n,onCancel:a}){const x=s.useRef(null),[p,c]=s.useState(t);s.useEffect(()=>{const m=x.current;if(!m)return;m.focus();const r=t.lastIndexOf(".");m.setSelectionRange(0,r>0?r:t.length)},[t]);const o=()=>{const m=p.trim();m&&m!==t?n(m):a()};return e.jsx("input",{ref:x,type:"text",value:p,"aria-label":"New name",onChange:m=>c(m.target.value),onClick:m=>m.stopPropagation(),onBlur:o,onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"?o():m.key==="Escape"&&a()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Cn=100,bn=28,kn=250;function jn(t){const{rows:n,selectedPath:a,renamingPath:x,errorPaths:p,onSelectPath:c,onRetryDir:o}=t,m=s.useRef(null),r=H(v=>v.setScrollTop),i=H(v=>v.scopeKey),u=s.useCallback(v=>v.type==="dir"?t.onToggle(v):t.onOpen(v),[t]),N=En(t,u),F=n.length>Cn,D=en({count:n.length,getScrollElement:()=>m.current,estimateSize:()=>bn,overscan:12,enabled:F}),L=s.useRef({scope:void 0,done:!1}),C=s.useRef(null);s.useLayoutEffect(()=>{const v=L.current;if(v.scope!==i&&(v.scope=i,v.done=!1),v.done||n.length===0)return;const z=m.current;if(!z)return;const B=H.getState().scrollTop;if(B<=0){v.done=!0;return}F?D.scrollToOffset(B):z.scrollTop=B,C.current=z.scrollTop,z.scrollTop>=B&&(v.done=!0)},[n.length,i,F,D]);const q=s.useRef(null),I=s.useRef(null),j=s.useCallback(()=>{const v=m.current;v&&v.scrollTop!==C.current&&(L.current.done=!0,q.current=v.scrollTop,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,q.current!==null&&r(q.current)},kn))},[r]);s.useEffect(()=>()=>{I.current&&clearTimeout(I.current),q.current!==null&&r(q.current)},[r]);const h=s.useRef(void 0);s.useEffect(()=>{var d,f;const v=h.current;if(h.current=a,v===void 0||a===v||a===null)return;const z=n.findIndex(T=>T.entry.path===a);if(z<0)return;const B=m.current;B&&(F?D.scrollToIndex(z,{align:"auto"}):(f=(d=B.querySelector(`[data-row-index="${z}"]`))==null?void 0:d.scrollIntoView)==null||f.call(d,{block:"nearest"}),C.current=B.scrollTop)},[a,n,F,D]);const[g,w]=s.useState(!1),{onCopyInto:b,onMove:S}=t,K=t.readOnly===!0,A=t.copyable!==!1,_=s.useCallback(v=>{K||!Ge(v.dataTransfer.types)||(v.preventDefault(),v.dataTransfer.dropEffect=v.altKey&&A?"copy":"move",w(!0))},[K,A]),$=s.useCallback((v,z)=>{const B=n.find(d=>d.entry.path===v);B&&b({path:v,isDir:B.entry.type==="dir"},z)},[n,b]),Y=s.useCallback(v=>{if(w(!1),K)return;const z=Ye(v.dataTransfer);z!==null&&(v.preventDefault(),v.altKey&&A?$(z,Q):S(z,Q))},[$,S,K,A]),P=v=>e.jsx(yn,{row:v,selected:v.entry.path===a,renaming:v.entry.path===x,error:v.entry.type==="dir"&&v.expanded&&p.has(v.entry.path),onSelect:z=>c(z.path),onActivate:u,onRetry:()=>o(v.entry.path),onSubmitRename:t.onSubmitRename,onCancelRename:t.onCancelRename,onStartRename:t.onStartRename,onNewFile:t.onNewFile,onNewFolder:t.onNewFolder,onDelete:t.onDelete,onMove:t.onMove,onCopyInto:$,onCopy:t.onCopy,onPaste:t.onPaste,onDuplicate:t.onDuplicate,canPasteInto:t.canPasteInto,revealLabel:t.revealLabel,onReveal:t.onReveal,onAddToChat:t.onAddToChat,onCopyPath:t.onCopyPath,readOnly:t.readOnly,provenance:t.provenance,copyable:t.copyable,onDisk:t.onDisk,onUpload:t.onUpload,onPickUpload:t.onPickUpload});return e.jsx("div",{ref:m,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:N,onScroll:j,onDragOver:_,onDragLeave:()=>w(!1),onDrop:Y,className:Pe("focus-visible:ring-ring h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",g&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:F?e.jsx("div",{style:{height:D.getTotalSize()},className:"relative w-full",children:D.getVirtualItems().map(v=>e.jsx("div",{"data-row-index":v.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${v.start}px)`},children:P(n[v.index])},n[v.index].entry.path))}):n.map((v,z)=>e.jsx("div",{"data-row-index":z,children:P(v)},v.entry.path))})}function wn(t){return t?t.type==="dir"?t.path:W(t.path):Q}function En(t,n){const{rows:a,selectedPath:x,renamingPath:p,onSelectPath:c}=t;return s.useCallback(o=>{var i,u,N,F;if(p!==null)return;const m=a.findIndex(D=>D.entry.path===x),r=m>=0?a[m]:void 0;if(o.metaKey||o.ctrlKey){if(t.readOnly===!0||t.copyable===!1)return;const D=o.key.toLowerCase();if(D==="c"&&r){o.preventDefault(),t.onCopy(r.entry);return}if(D==="v"){o.preventDefault(),t.onPaste(wn(r==null?void 0:r.entry));return}return}switch(o.key){case"ArrowDown":o.preventDefault(),c(((i=a[Math.min(m+1,a.length-1)])==null?void 0:i.entry.path)??((u=a[0])==null?void 0:u.entry.path));break;case"ArrowUp":o.preventDefault(),c(((N=a[Math.max(m-1,0)])==null?void 0:N.entry.path)??((F=a[0])==null?void 0:F.entry.path));break;case"ArrowRight":(r==null?void 0:r.entry.type)==="dir"&&!r.expanded&&(o.preventDefault(),t.onToggle(r.entry));break;case"ArrowLeft":if(!r)break;if(o.preventDefault(),r.entry.type==="dir"&&r.expanded)t.onToggle(r.entry);else{const D=W(r.entry.path);D&&c(D)}break;case"Enter":r&&(o.preventDefault(),n(r.entry));break;case"F2":r&&t.readOnly!==!0&&(o.preventDefault(),t.onStartRename(r.entry));break;case"Delete":case"Backspace":r&&t.readOnly!==!0&&(o.preventDefault(),t.onDelete(r.entry));break}},[a,x,p,c,t,n])}const Dn={rename:"Rename it anyway",move:"Move it anyway",delete:"Delete it anyway",upload:"Upload mine over it"},Nn={rename:"nothing was renamed",move:"nothing was moved",delete:"nothing was deleted",upload:"nothing was uploaded"};function Rn(t){const{entry:n,fileCount:a,moreThan:x}=t;if(n.type!=="dir")return`“${n.name}” leaves the room’s files.`;const p=a===null?"everything in it":x?`the more than ${a.toLocaleString()} files in it`:a===1?"the 1 file in it":`the ${a.toLocaleString()} files in it`;return`“${n.name}” and ${p} leave the room’s files.`}const Sn="The room’s history keeps a copy. An agent can restore it.";function Tn({changes:t,onOpenTheirs:n,onReturnFocus:a}){var D;const x=L=>{L.preventDefault();const C=document.activeElement;C!==null&&C!==document.body||a()},{pendingDelete:p,pendingClash:c,conflict:o}=t,[m,r]=s.useState(p);p!==null&&p!==m&&r(p);const[i,u]=s.useState(c);c!==null&&c!==i&&u(c);const N=i===null?"":i.dir===Q?"The top folder":`“${i.dir}”`,F=(i==null?void 0:i.names.length)===1;return e.jsxs(e.Fragment,{children:[e.jsx(fe,{open:p!==null,onOpenChange:L=>!L&&t.cancelDelete(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:m===null?"":`Delete “${m.entry.name}”?`}),e.jsx(xe,{asChild:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:m===null?"":Rn(m)}),e.jsx("p",{children:Sn})]})})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void t.confirmDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:(m==null?void 0:m.entry.type)==="dir"?"Delete folder":"Delete file"})]})]})}),e.jsx(fe,{open:c!==null,onOpenChange:L=>!L&&t.cancelClash(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:F?`Replace “${i==null?void 0:i.names[0]}”?`:`Replace ${(i==null?void 0:i.names.length)??0} files?`}),e.jsx(xe,{children:F?`${N} already has a file with this name. Replace it, or keep both.`:`${N} already has files named ${(i==null?void 0:i.names.join(", "))??""}. Replace them, or keep both.`})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.cancelClash,children:"Cancel"}),e.jsx(G,{variant:"outline",onClick:()=>void t.resolveClash("keep-both"),children:"Keep both"}),e.jsx(ve,{onClick:()=>void t.resolveClash("replace"),children:"Replace"})]})]})}),e.jsx(fe,{open:o!==null,onOpenChange:L=>!L&&t.dismissConflict(),children:e.jsxs(he,{onCloseAutoFocus:x,children:[e.jsxs(pe,{children:[e.jsx(me,{children:"Somebody changed this first"}),e.jsx(xe,{children:o===null?"":`${((D=o.lastCommit)==null?void 0:D.author)??"Somebody"} changed “${o.path}” after you opened it, so ${Nn[o.kind]}.`})]}),(o==null?void 0:o.lastCommit)&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[o.lastCommit.subject," · ",bt(o.lastCommit.at)]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:t.dismissConflict,children:"Cancel"}),e.jsx(G,{variant:"outline",onClick:()=>{o!==null&&(t.dismissConflict(),n(o.path))},children:"Open their version"}),e.jsx(ve,{onClick:()=>{o!==null&&(t.dismissConflict(),o.retry())},className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:o===null?"":Dn[o.kind]})]})]})})]})}function ze(t,n){return n.name===t?Ue(t):`“${n.name}” is already there. Some computers ignore capital letters in names. Pick another name.`}const Fn="Folders can’t be uploaded. Drop the files inside instead.";function Pn({source:t,className:n,onCommands:a}={}){var de;const x=ne(),p=Te(l=>l.selectedCwd),c=s.useMemo(()=>p?xn({transport:x,cwd:p}):null,[x,p]),o=t===void 0?c:t,m=o!==null&&!o.writable,r=mn(o),i=r.changes,u=oe(),N=H(l=>l.showHidden),{rows:F,rootLoading:D,rootError:L,rootErrorMessage:C,rootErrorCommand:q,errorPaths:I}=r,j=H(l=>l.setCommands),h=H(l=>l.selectedPath),g=H(l=>l.setSelectedPath),w=H(l=>l.clipboard),[b,S]=s.useState(null),[K,A]=s.useState(null),[_,$]=s.useState(null),Y=s.useCallback(l=>$(l===null?null:{path:l,isNew:!1}),[]),P=s.useRef(null),v=s.useRef(Q),[z,B]=s.useState(!1),d=s.useCallback((l,M)=>{if(i!==null){if(M.length===0){X.error(Fn);return}r.ensureExpanded(l),i.upload(l,M)}},[i,r]),f=s.useRef(null),T=s.useCallback(()=>{var l,M;(M=(l=f.current)==null?void 0:l.querySelector('[role="tree"]'))==null||M.focus()},[]),y=s.useCallback(l=>{var M;v.current=l,(M=P.current)==null||M.click()},[]),O=s.useCallback(l=>w!==null&&!(w.isDir&&Ce(l,w.path)),[w]),E=s.useCallback((l,M)=>{r.ensureExpanded(l),_e.flushSync(()=>{A(null),S({parent:l,type:M})})},[r]),R=s.useCallback(l=>{_e.flushSync(()=>A(l.path))},[]),k=s.useRef({startCreate:E,reload:r.reload,pickUpload:y});s.useEffect(()=>{k.current={startCreate:E,reload:r.reload,pickUpload:y}});const U=i!==null;s.useEffect(()=>{if(m||a===void 0&&U)return;const l=a??j;return l({newFile:()=>k.current.startCreate(Q,"file"),newFolder:()=>k.current.startCreate(Q,"dir"),refresh:()=>k.current.reload(),...U&&{upload:()=>k.current.pickUpload(Q)}}),()=>l(null)},[j,a,m,U]);const te=s.useCallback(async l=>{var se;if(!b||o===null)return;const M=b;if(S(null),i!==null){const re=(((se=u.getQueryData(le(o,M.parent,N)))==null?void 0:se.entries)??[]).find(ot=>ot.name.toLowerCase()===l.toLowerCase());if(M.type==="dir"){if(re!==void 0&&!(re.type==="dir"&&re.name===l)){X.error(ze(l,re));return}S({parent:ee(M.parent,l),type:"file",firstInFolder:l});return}if(re!==void 0){X.error(ze(l,re));return}const rt=ee(M.parent,l);$({path:rt,isNew:!0});return}await r.createEntry(M.parent,l,M.type)&&g(ee(M.parent,l))},[b,o,i,u,N,r,g]),V=s.useCallback(async(l,M)=>{A(null),(i?await i.renameEntry(l,M):await r.renameEntry(l,M))&&g(ee(W(l.path),M))},[i,r,g]);return o===null?t!==void 0?null:e.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Pick a folder to see its files."}):e.jsxs("div",{ref:f,className:Pe("flex h-full flex-col",z&&"ring-ring/60 bg-accent/30 ring-1 ring-inset",n),onDragOver:l=>{i===null||!ke(l.dataTransfer.types)||(l.preventDefault(),l.dataTransfer.dropEffect="copy",B(!0))},onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||B(!1)},onDrop:l=>{B(!1),!(i===null||!ke(l.dataTransfer.types))&&(l.preventDefault(),d(Q,st(l.dataTransfer).files))},children:[i!==null&&e.jsx("input",{ref:P,type:"file",multiple:!0,hidden:!0,"aria-hidden":!0,tabIndex:-1,"data-testid":"room-files-upload-input",onChange:l=>{const M=Array.from(l.target.files??[]);l.target.value="",d(v.current,M)}}),e.jsxs("div",{className:"min-h-0 flex-1",children:[b&&e.jsx(On,{type:b.type,firstInFolder:b.firstInFolder,onSubmit:l=>void te(l),onCancel:()=>S(null)},`${b.parent}:${b.type}:${b.firstInFolder??""}`),D&&F.length===0?e.jsx("div",{className:"flex h-20 items-center justify-center",children:e.jsx(Fe,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):L&&F.length===0?e.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:[e.jsx("span",{children:C??"Couldn’t load files."}),q!==null&&e.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:q}),e.jsxs(G,{variant:"outline",size:"xs",onClick:r.reload,children:[e.jsx(We,{}),"Retry"]})]}):F.length===0&&!b?e.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center px-4 text-center text-xs",children:i!==null?"No files yet. Drop files here, or use Upload.":"Empty folder"}):e.jsx(jn,{rows:F,selectedPath:h,renamingPath:K,errorPaths:I,onSelectPath:g,onToggle:r.toggleExpand,onOpen:l=>{o.preview==="inline"?Y(l.path):r.openFile(l)},onRetryDir:r.retryDir,onSubmitRename:(l,M)=>void V(l,M),onCancelRename:()=>A(null),onStartRename:R,onNewFile:l=>E(l,"file"),onNewFolder:l=>E(l,"dir"),onDelete:l=>i?i.requestDelete(l):void r.removeEntry(l),onMove:(l,M)=>void(i?i.moveEntry(l,M):r.moveEntry(l,M)),onCopyInto:(l,M)=>void r.copyEntry(l,M),onCopy:r.copyToClipboard,onPaste:l=>{w&&r.copyEntry(w,l)},onDuplicate:l=>void r.copyEntry({path:l.path,isDir:l.type==="dir"},W(l.path)),canPasteInto:O,readOnly:m,provenance:o.provenance,copyable:i===null,onDisk:o.cwd!==null,onUpload:i?d:void 0,onPickUpload:i?y:void 0,revealLabel:r.revealLabel,onReveal:l=>void r.reveal(l),onAddToChat:r.addToChat,onCopyPath:(l,M)=>void r.copyPath(l,M)})]}),o.preview==="inline"&&e.jsx(Wt,{source:o,path:(_==null?void 0:_.path)??null,isNew:(_==null?void 0:_.isNew)??!1,onCreated:()=>{_!==null&&($({path:_.path,isNew:!1}),g(_.path))},onClose:()=>$(null)}),i!==null&&e.jsx(Tn,{changes:i,onOpenTheirs:l=>Y(l),onReturnFocus:T}),e.jsx(fe,{open:r.pendingRecursiveDelete!==null,onOpenChange:l=>!l&&r.cancelRecursiveDelete(),children:e.jsxs(he,{children:[e.jsxs(pe,{children:[e.jsxs(me,{children:["Delete “",(de=r.pendingRecursiveDelete)==null?void 0:de.name,"”?"]}),e.jsx(xe,{children:"This folder isn’t empty. Everything inside is deleted. This can’t be undone."})]}),e.jsxs(ge,{children:[e.jsx(ye,{onClick:r.cancelRecursiveDelete,children:"Cancel"}),e.jsx(ve,{onClick:()=>void r.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete folder"})]})]})})]})}function On({type:t,firstInFolder:n,onSubmit:a,onCancel:x}){const p=s.useRef(null),[c,o]=s.useState("");s.useEffect(()=>{var i;(i=p.current)==null||i.focus()},[]);const m=()=>{const i=c.trim();i?a(i):x()},r=e.jsxs("div",{className:"flex items-center gap-1",children:[t==="dir"?e.jsx(be,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):e.jsx(Ve,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("input",{ref:p,type:"text",value:c,"aria-label":n!==void 0?`First file in ${n}`:t==="dir"?"New folder name":"New file name",placeholder:t==="dir"?"folder-name":"file-name",onChange:i=>o(i.target.value),onBlur:m,onKeyDown:i=>{i.key==="Enter"?m():i.key==="Escape"&&x()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]});return n===void 0?e.jsx("div",{className:"px-3 py-1",children:r}):e.jsxs("div",{className:"space-y-1 px-3 py-1",children:[e.jsxs("p",{className:"text-muted-foreground flex min-w-0 items-center gap-1 text-xs",children:[e.jsx(be,{className:"size-(--size-icon-xs) flex-shrink-0 text-sky-500"}),e.jsx("span",{className:"truncate",children:n})]}),r,e.jsx("p",{className:"text-muted-foreground text-2xs",children:"Name its first file. The folder appears on save."})]})}function at(){const t=H(x=>x.showHidden),n=H(x=>x.setShowHidden),a=t?"Hide hidden files":"Show hidden files";return e.jsx(G,{variant:"ghost",size:"icon-xs","aria-label":a,title:a,onClick:()=>n(!t),children:t?e.jsx(kt,{className:"text-muted-foreground"}):e.jsx(jt,{className:"text-muted-foreground"})})}function Mn({cwd:t}){const n=ne(),{data:a}=ce({queryKey:["file-explorer","workspace",t],queryFn:()=>n.resolveWorkspace(t),staleTime:6e4});return a!=null&&a.branch?e.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 ${a.key} on ${a.branch}`,children:[e.jsx(Ze,{className:"size-3 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:a.branch})]}):null}function Vn(){const t=Te(a=>a.selectedCwd),n=H(a=>a.commands);return t?e.jsxs(e.Fragment,{children:[e.jsx(Mn,{cwd:t}),e.jsx(G,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>n==null?void 0:n.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(G,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>n==null?void 0:n.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(at,{}),e.jsx(G,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>n==null?void 0:n.refresh(),children:e.jsx(wt,{className:"text-muted-foreground"})})]}):null}function _n({roomId:t}){const n=ne(),a=oe(),x=ce(qe(n,t));s.useEffect(()=>Vt(a,t,()=>{a.invalidateQueries({queryKey:De.repoStatus(t)})}),[a,t]);const p=s.useMemo(()=>{var r;return((r=x.data)==null?void 0:r.kind)==="ok"?Et(x.data.status):[]},[x.data]),c=Dt(p),o=Nt(p);if(!o)return null;const m=p.map((r,i)=>`${c[i]}: ${Rt(r)}`);return e.jsxs("span",{"data-slot":"pending-work-badge",title:m.join(`
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:[e.jsx(Ze,{className:"size-3 flex-shrink-0"}),e.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",m.join(". "),"."]}),e.jsx("span",{"aria-hidden":"true",className:"truncate",children:o})]})}const An={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Ln=new Map([["OPERATOR_ONLY","Only the owner of this DorkOS can keep or discard these."],["ROOM_FILE_NOT_FOUND","One of those changes is gone, so nothing was discarded. The list is refreshed."],["MERGE_IN_FLIGHT","Something else is writing to these files. Nothing changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","These files are on another branch. Switch them back to main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","Room files need git, and git isn’t installed on this computer."],["ROOM_HAS_NO_REPO","This room no longer has its own files."],["ROOM_REPOS_DISABLED","Room files are turned off on this install."]]);function zn({roomId:t}){var q,I;const n=ne(),a=oe(),x=ce(qe(n,t)),[p,c]=s.useState([]),[o,m]=s.useState(!1),[r,i]=s.useState(null),u=St({mutationFn:j=>n.repairRoomMain(t,j),onSuccess:()=>{c([]),m(!1),i(null),a.invalidateQueries({queryKey:De.repoStatus(t)})},onError:j=>{m(!1);const h=Ln.get(Tt(j)??"");i(h??"Couldn’t update the files. Try again in a moment."),a.invalidateQueries({queryKey:De.repoStatus(t)})}});if(((q=x.data)==null?void 0:q.kind)==="unavailable")return e.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:"Couldn’t check this room’s files. Saves may not work. Try again soon."});const N=((I=x.data)==null?void 0:I.kind)==="ok"?x.data.status.main:void 0;if(N===void 0||!N.dirty)return null;const F=N.branch!=="main",D=p.filter(j=>N.strays.some(h=>h.path===j)),L=o&&D.length>0,C=j=>c(h=>h.includes(j)?h.filter(g=>g!==j):[...h,j]);return e.jsxs("div",{"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:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ft,{className:"text-muted-foreground mt-0.5 size-(--size-icon-sm) flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{role:"alert",className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Somebody changed this room’s files outside DorkOS"}),F?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:`This room’s files are on ${N.branch??"no branch"}, not main.`}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until they’re back on main."})]}):e.jsx("p",{className:"text-muted-foreground text-xs",children:"Saves and agent merges wait until you keep or discard these."})]}),F&&e.jsx(Pt,{className:"text-xs",children:e.jsx("p",{children:"DorkOS won’t switch the branch for you. There may be work on it."})})]})]}),!F&&e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"space-y-1.5",children:N.strays.map(j=>e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(Ot,{id:`stray-${t}-${j.path}`,checked:D.includes(j.path),onCheckedChange:()=>C(j.path),disabled:u.isPending}),e.jsx("label",{htmlFor:`stray-${t}-${j.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:j.path,children:j.path}),e.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:An[j.kind]})]},j.path))}),N.strayCount>N.strays.length&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",N.strayCount-N.strays.length," more not shown. “Keep them all” keeps these too."]}),L?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs",children:D.length===1?"Discard this change? It can’t be undone.":`Discard these ${D.length} changes? They can’t be undone.`}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(G,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending,onClick:()=>m(!1),children:"Cancel"}),e.jsx(G,{type:"button",variant:"destructive",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"discard",paths:[...D]}),children:D.length===1?"Discard change":`Discard ${D.length} changes`})]})]}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(G,{type:"button",variant:"outline",size:"sm",disabled:u.isPending,onClick:()=>u.mutate({action:"commit"}),children:"Keep them all"}),e.jsx(G,{type:"button",variant:"ghost",size:"sm",disabled:u.isPending||D.length===0,onClick:()=>m(!0),children:D.length===0?"Discard…":`Discard ${D.length}`})]})]}),r!==null&&e.jsx("p",{role:"alert",className:"text-destructive text-xs",children:r})]})}const Ee="pointer-coarse:size-11";function Zn({roomId:t,canChange:n}){const a=ne(),x=oe(),p=H(F=>F.showHidden),[c,o]=s.useState(null),m=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t,canChange:n}),[a,x,t,n]),r=ce(je(m,Q,p,x)),i=r.isSuccess&&r.data.absent!==!0||r.isError,[u,N]=s.useState(null);return i&&u!==t&&N(t),!i&&u!==t?null:e.jsxs("section",{"aria-label":"Room files",className:"space-y-2",children:[e.jsxs("header",{className:"flex items-center gap-2",children:[e.jsx(Mt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),e.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Files"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(_n,{roomId:t})}),n&&e.jsxs(e.Fragment,{children:[e.jsx(G,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New file",title:"New file",disabled:c===null,onClick:()=>c==null?void 0:c.newFile(),children:e.jsx(et,{className:"text-muted-foreground"})}),e.jsx(G,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"New folder",title:"New folder",disabled:c===null,onClick:()=>c==null?void 0:c.newFolder(),children:e.jsx(He,{className:"text-muted-foreground"})}),e.jsx(G,{variant:"ghost",size:"icon-xs",className:Ee,"aria-label":"Upload files",title:"Upload files",disabled:(c==null?void 0:c.upload)===void 0,onClick:()=>{var F;return(F=c==null?void 0:c.upload)==null?void 0:F.call(c)},children:e.jsx(sn,{className:"text-muted-foreground"})})]}),e.jsx(at,{})]}),e.jsx(zn,{roomId:t}),e.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:e.jsx(Pn,{source:m,onCommands:o})})]})}function Jn({roomId:t,attachment:n}){var i;const a=ne(),x=oe(),p=s.useMemo(()=>Be({transport:a,queryClient:x,roomId:t}),[a,x,t]),c=ce(je(p,Q,!1,x)),[o,m]=s.useState(!1),r=_t(t);return!c.isSuccess||c.data.absent===!0||((i=r.data)==null?void 0:i.archived)!==!1?null:e.jsxs(e.Fragment,{children:[e.jsx(G,{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:()=>m(!0),children:e.jsx(At,{})}),o&&e.jsx($n,{roomId:t,source:p,attachment:n,onClose:()=>m(!1)})]})}function $n({roomId:t,source:n,attachment:a,onClose:x}){const p=ne(),c=oe(),[o,m]=s.useState(Q),[r,i]=s.useState(a.name),[u,N]=s.useState(null),[F,D]=s.useState(!1),L=s.useId(),C=ce(je(n,o,!1,c)),q=s.useMemo(()=>{var j;return nt(((j=C.data)==null?void 0:j.entries)??[]).filter(h=>h.type==="dir")},[C.data]),I=async()=>{var h,g;const j=r.trim();if(j!==""){D(!0),N(null);try{await p.saveAttachmentToRoomFiles(t,{attachmentId:a.id,dir:o,name:j,baseCommit:((h=C.data)==null?void 0:h.commit)??null}),c.invalidateQueries({queryKey:["file-explorer","tree",n.scopeKey]}),X.success(`Saved ${j} to the room’s files`),x()}catch(w){let b;try{b=Zt(w,c,t)}catch{b={status:"refused",reason:Qe(w)??"Couldn’t save. Try again in a moment."}}if(b.status==="exists"){const S=(((g=C.data)==null?void 0:g.entries)??[]).map(K=>K.name);N({reason:`This folder already has a file called “${j}”. Pick another name.`,suggestion:Oe({name:j,isDir:!1,taken:[...S,j]})})}else b.status==="conflict"?(N({reason:"This folder changed while you chose, so nothing was saved. Try again."}),C.refetch()):b.status==="refused"&&N({reason:b.reason})}finally{D(!1)}}};return e.jsx(Lt,{open:!0,onOpenChange:j=>!j&&x(),children:e.jsxs(zt,{className:"sm:max-w-md",children:[e.jsxs($t,{children:[e.jsx(It,{children:"Save to room files"}),e.jsx(Kt,{children:"Everyone in the room, and their agents, can find it there."})]}),e.jsxs(Ht,{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-muted-foreground text-xs font-medium",children:"Folder"}),e.jsxs("div",{role:"group","aria-label":"Folders",className:"border-border/60 max-h-56 overflow-auto rounded-md border",children:[e.jsx("p",{className:"bg-muted/40 truncate px-3 py-1.5 font-mono text-xs",children:o===Q?"Top folder":`${o}/`}),o!==Q&&e.jsx($e,{label:"Up one folder",icon:e.jsx(nn,{className:"text-muted-foreground size-(--size-icon-sm)"}),onClick:()=>m(W(o))}),C.isPending?e.jsx("div",{className:"flex h-12 items-center justify-center",children:e.jsx(Fe,{size:"sm",className:"text-muted-foreground",label:"Loading folders"})}):q.length===0?e.jsx("p",{className:"text-muted-foreground px-3 py-2 text-xs",children:"No folders in here."}):q.map(j=>e.jsx($e,{label:j.name,icon:e.jsx(be,{className:"size-(--size-icon-sm) text-sky-500"}),chevron:!0,onClick:()=>m(ee(o,ie(j.path)))},j.path))]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:L,className:"text-muted-foreground text-xs font-medium",children:"Name"}),e.jsx(qt,{id:L,value:r,onChange:j=>{i(j.target.value),N(null)},spellCheck:!1,autoComplete:"off"})]}),u!==null&&e.jsxs("div",{role:"alert",className:"text-destructive space-y-1 text-xs",children:[e.jsx("p",{children:u.reason}),u.suggestion!==void 0&&e.jsxs(G,{type:"button",variant:"outline",size:"xs",onClick:()=>{i(u.suggestion),N(null)},children:["Use “",u.suggestion,"”"]})]})]}),e.jsxs(Ut,{className:"gap-2",children:[e.jsx(G,{type:"button",variant:"ghost",onClick:x,children:"Cancel"}),e.jsx(G,{type:"button",disabled:F||r.trim()===""||C.isPending,onClick:()=>void I(),children:F?"Saving…":o===Q?"Save to the top folder":`Save to ${ie(o)}`})]})]})})}function $e({label:t,icon:n,chevron:a=!1,onClick:x}){return e.jsxs("button",{type:"button",onClick:x,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,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),a&&e.jsx(Ke,{className:"text-muted-foreground size-3.5"})]})}export{Pn as FileExplorer,Vn as FileExplorerActions,Wt as FilePreviewDialog,an as HIDDEN_ENTRY_NAMES,at as HiddenEntriesToggle,ts as NO_PROVENANCE,Ne as PINNED_ENTRY_NAMES,ns as ROOM_FILES_REFRESH_INTERVAL_MS,Zn as RoomFilesSection,Jn as SaveToRoomFilesButton,Be as createRoomFilesSource,xn as createSessionCwdSource,le as explorerDirQueryKey,je as explorerDirQueryOptions,rn as isHiddenEntryName,Re as isPinnedEntryName,on as pinnedFirst,Gt as provenanceLine,qe as roomRepoStatusQueryOptions,nt as withoutHidden};