@jingyi0605/codingns 1.0.0-beta.1 → 1.0.0-beta.3

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 (123) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-CLHLiZSY.js +2 -0
  2. package/dist/public/assets/{App-CHsm-VrM.js → App-FYuZfAoO.js} +6 -6
  3. package/dist/public/assets/{BootstrapPage-Bp0KfySv.js → BootstrapPage-3xpnsG-A.js} +1 -1
  4. package/dist/public/assets/ConversationPage-C5_ZqhU3.js +9 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-DlDSb_tf.js → DesktopDetachPreviewPage-B77MG82y.js} +1 -1
  6. package/dist/public/assets/{DesktopModal-Csj5AdAN.js → DesktopModal-K5bEcj38.js} +1 -1
  7. package/dist/public/assets/{DesktopWindowPage-CacXiWjV.js → DesktopWindowPage-DbG-RBAf.js} +1 -1
  8. package/dist/public/assets/{FileContextPanel-DzMUQvE5.js → FileContextPanel-C-1yOton.js} +1 -1
  9. package/dist/public/assets/{GitSidebar-C8IC18GH.js → GitSidebar-DFHAPT3S.js} +1 -1
  10. package/dist/public/assets/{MobileCreateSessionSheet-BtqR_hKc.js → MobileCreateSessionSheet-gOyAZ857.js} +1 -1
  11. package/dist/public/assets/{MobileSheet-Co-qPMBD.js → MobileSheet-D0MfNkTv.js} +1 -1
  12. package/dist/public/assets/{PluginAccessOverview-D-KXkcyj.js → PluginAccessOverview-IrYIPLg3.js} +1 -1
  13. package/dist/public/assets/{PluginContainerPage-BKwCIs4r.js → PluginContainerPage-b9LQVuqG.js} +1 -1
  14. package/dist/public/assets/{PluginDetailPage-Djv_swcO.js → PluginDetailPage-BX7gohai.js} +1 -1
  15. package/dist/public/assets/{PluginsListPage-DAECNoN6.js → PluginsListPage-R0SibHMi.js} +1 -1
  16. package/dist/public/assets/{PureConversationPage-DP1X7Hix.js → PureConversationPage-CcakFvo0.js} +1 -1
  17. package/dist/public/assets/{RelayConnectEntryPage-xL_IPH8a.js → RelayConnectEntryPage-cAVq_kNM.js} +1 -1
  18. package/dist/public/assets/{ServerSettingsModal-CyhMgk10.js → ServerSettingsModal-BJwYHdKD.js} +1 -1
  19. package/dist/public/assets/{SessionIndexPage-CVEz50tc.js → SessionIndexPage-CJKRHB_F.js} +1 -1
  20. package/dist/public/assets/SettingsPage-Csp7wEBC.js +2 -0
  21. package/dist/public/assets/{TerminalManagerPanel-wVnoRA8u.js → TerminalManagerPanel-2HG-NyfR.js} +1 -1
  22. package/dist/public/assets/{ToolFilesPage-BospXumK.js → ToolFilesPage-BAZdjNaF.js} +1 -1
  23. package/dist/public/assets/{ToolGitPage-B2zOeCAD.js → ToolGitPage-CGkPmgsz.js} +1 -1
  24. package/dist/public/assets/{ToolProcessesPage-BDShao4b.js → ToolProcessesPage-BHpS7-VH.js} +1 -1
  25. package/dist/public/assets/{ToolsHomePage-s4zH7D9M.js → ToolsHomePage-DDGqYwYU.js} +1 -1
  26. package/dist/public/assets/{WorkbenchLandingPage-D51QCU_u.js → WorkbenchLandingPage-B4aooEYJ.js} +1 -1
  27. package/dist/public/assets/WorkbenchLayout-DrAvGjGK.js +1083 -0
  28. package/dist/public/assets/{WorkbenchModal-YsyEdJ_m.js → WorkbenchModal-BK5ix8YI.js} +1 -1
  29. package/dist/public/assets/WorkbenchShellRoute-DpycFsbp.css +1 -0
  30. package/dist/public/assets/WorkbenchShellRoute-p1FvkoPN.js +1 -0
  31. package/dist/public/assets/{WorkspaceDebugDetailPage-CMjNLqFq.js → WorkspaceDebugDetailPage-CPgAe8dd.js} +1 -1
  32. package/dist/public/assets/{WorkspaceDetailPage-CKxTbPKh.js → WorkspaceDetailPage-YM85dTGg.js} +1 -1
  33. package/dist/public/assets/{WorkspaceHomePage-CEy4ShCu.js → WorkspaceHomePage-DPPvwM93.js} +1 -1
  34. package/dist/public/assets/{client-runtime-manager-BFXU9DmS.js → client-runtime-manager-Clq-8rWh.js} +1 -1
  35. package/dist/public/assets/{host-alias-Zb2xyVrf.js → host-alias-BxzpRYrt.js} +1 -1
  36. package/dist/public/assets/index-BArTKWXk.js +50 -0
  37. package/dist/public/assets/index-CqKepLbu.css +1 -0
  38. package/dist/public/assets/{login-direct-candidate-resolver-DL8DS-Si.js → login-direct-candidate-resolver-BiWwFKnk.js} +1 -1
  39. package/dist/public/assets/peer-host-config-sync-kTom1_pp.js +1 -0
  40. package/dist/public/assets/{plugin-permission-copy-DrLk22m5.js → plugin-permission-copy-1_1wViri.js} +1 -1
  41. package/dist/public/assets/{plugins-api-COF4oh24.js → plugins-api-C0JqR2-W.js} +1 -1
  42. package/dist/public/assets/{preferences-service-CEWNV1w9.js → preferences-service-DWeLWZST.js} +1 -1
  43. package/dist/public/assets/{relay-entry-Cmc8vTlE.js → relay-entry-ClEd3cjN.js} +1 -1
  44. package/dist/public/assets/{useRegisteredDebugTemplates-FdmHG2S4.js → useRegisteredDebugTemplates-wJGOYam9.js} +1 -1
  45. package/dist/public/assets/{workbench-navigation-ED0157V-.js → workbench-navigation-vIWt3Rv_.js} +1 -1
  46. package/dist/public/index.html +2 -2
  47. package/dist/server/modules/client/client-controller.d.ts +1 -0
  48. package/dist/server/modules/client/client-controller.js +4 -0
  49. package/dist/server/modules/client/client-controller.js.map +1 -1
  50. package/dist/server/modules/client/client-service.d.ts +3 -0
  51. package/dist/server/modules/client/client-service.js +3 -0
  52. package/dist/server/modules/client/client-service.js.map +1 -1
  53. package/dist/server/modules/client/npm-global-package-service.js +32 -7
  54. package/dist/server/modules/client/npm-global-package-service.js.map +1 -1
  55. package/dist/server/modules/peer-host/host-ws-proxy-service.js +73 -12
  56. package/dist/server/modules/peer-host/host-ws-proxy-service.js.map +1 -1
  57. package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +2 -0
  58. package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
  59. package/dist/server/modules/provider/provider-discovery-helper-process.js +6 -3
  60. package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
  61. package/dist/server/modules/provider/provider-discovery-runtime.js +4 -1
  62. package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
  63. package/dist/server/modules/sessions/codex-app-server-helper-process.js +84 -20
  64. package/dist/server/modules/sessions/codex-app-server-helper-process.js.map +1 -1
  65. package/dist/server/modules/sessions/session-controller.js +2 -1
  66. package/dist/server/modules/sessions/session-controller.js.map +1 -1
  67. package/dist/server/modules/sessions/session-history-service.d.ts +8 -0
  68. package/dist/server/modules/sessions/session-history-service.js +123 -5
  69. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  70. package/dist/server/modules/sessions/session-live-runtime-service.d.ts +27 -0
  71. package/dist/server/modules/sessions/session-live-runtime-service.js +457 -9
  72. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  73. package/dist/server/modules/sessions/session-permission-request-service.d.ts +17 -1
  74. package/dist/server/modules/sessions/session-permission-request-service.js +397 -9
  75. package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
  76. package/dist/server/modules/sessions/session-provider-config-service.js +1 -0
  77. package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -1
  78. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +15 -1
  79. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
  80. package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +1 -0
  81. package/dist/server/modules/tasks/task-helper-process-handlers.js +4 -1
  82. package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
  83. package/dist/server/modules/workbench/workbench-service.js +7 -4
  84. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  85. package/dist/server/routes/client.js +1 -0
  86. package/dist/server/routes/client.js.map +1 -1
  87. package/dist/server/shared/utils/peer-host-proxy-log.d.ts +3 -0
  88. package/dist/server/shared/utils/peer-host-proxy-log.js +48 -0
  89. package/dist/server/shared/utils/peer-host-proxy-log.js.map +1 -0
  90. package/dist/server/storage/repositories/session-send-queue-repository.d.ts +1 -0
  91. package/dist/server/storage/repositories/session-send-queue-repository.js +23 -0
  92. package/dist/server/storage/repositories/session-send-queue-repository.js.map +1 -1
  93. package/node_modules/@codingns/session-sync-core/dist/index.d.ts +1 -0
  94. package/node_modules/@codingns/session-sync-core/dist/index.js +1 -0
  95. package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -1
  96. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +2 -0
  97. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +93 -12
  98. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
  99. package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +3 -0
  100. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +116 -2
  101. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
  102. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +1 -0
  103. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +19 -8
  104. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
  105. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +27 -1
  106. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +48 -4
  107. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -1
  108. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +53 -15
  109. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
  110. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +1 -0
  111. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +30 -2
  112. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -1
  113. package/package.json +2 -1
  114. package/scripts/claude-hook-bridge.cjs +167 -0
  115. package/dist/public/assets/AdaptiveButlerPage-BYETYaIe.js +0 -2
  116. package/dist/public/assets/ConversationPage-BCrNml1k.js +0 -9
  117. package/dist/public/assets/SettingsPage-CQNCrgaj.js +0 -2
  118. package/dist/public/assets/WorkbenchLayout-Bo2BbMY6.js +0 -1081
  119. package/dist/public/assets/WorkbenchShellRoute-D3l4aWJS.js +0 -1
  120. package/dist/public/assets/WorkbenchShellRoute-D5fnyF8z.css +0 -1
  121. package/dist/public/assets/index-BilHJjYU.js +0 -50
  122. package/dist/public/assets/index-OR7OITpQ.css +0 -1
  123. package/dist/public/assets/peer-host-config-sync-d2ZcPC5P.js +0 -1
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
2
- import{b as d,o as F,_ as q,j as s,t as o}from"./index-BilHJjYU.js";import{r as O,u as C,W as _,m as N,F as $,T as A,g as U}from"./WorkbenchLayout-Bo2BbMY6.js";import{FileContextPanel as V}from"./FileContextPanel-DzMUQvE5.js";import{GitSidebar as z}from"./GitSidebar-C8IC18GH.js";import{TerminalManagerPanel as B}from"./TerminalManagerPanel-wVnoRA8u.js";import{b as H,a as K}from"./workbench-navigation-ED0157V-.js";import{c as J,u as Q,e as X,N as W}from"./App-CHsm-VrM.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-Zb2xyVrf.js";import"./DesktopModal-Csj5AdAN.js";import"./relay-entry-Cmc8vTlE.js";import"./WorkbenchModal-YsyEdJ_m.js";import"./MobileSheet-Co-qPMBD.js";function Y(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function Z(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function ee(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function re(n,a){return{navigationGroups:a,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function T(n){return n.kind==="file-preview"?o("conversation.fileViewerWindowTitle"):n.kind==="files"?o("shell.filesEntry"):n.kind==="git"?o("shell.gitEntry"):n.kind==="processes"?o("shell.terminalManagerEntry"):n.kind==="terminals"?o("shell.terminalsEntry"):n.kind==="affairs"?o("shell.workbenchModeAffairs"):n.kind==="code"?o("shell.workbenchModeCode"):n.kind}function x(n,a){var t;return n.workspaceName??(n.workspaceId?((t=a.find(l=>l.workspace.id===n.workspaceId))==null?void 0:t.workspace.name)??null:null)}function j(n){const a=(n==null?void 0:n.trim().replace(/\\/g,"/"))??"";return a?a.split("/").filter(Boolean).at(-1)??a:null}function ne(n){var l,u;const a=((l=n.payload.routePath)==null?void 0:l.trim())??"";if(a)return a;const t=((u=n.workspaceId)==null?void 0:u.trim())??"";return t?H(t):null}function te(n){var t;return((t=n.workspaceId)==null?void 0:t.trim())??""?K():"/landing"}function ie(n,a){const t=x(n,a);if(n.kind==="file-preview"){const u=j(n.payload.filePath)??T(n);return t?`${u}(${t})`:u}const l=T(n);return t?`CodingNS - ${l}(${t})`:`CodingNS - ${l}`}function be(){var I;const{windowId:n}=J(),a=Q(),t=X(),l=O(t),u=C(i=>i.sessionDisplaySortMode),[e,b]=d.useState(null),[R,m]=d.useState(!0),[M,v]=d.useState(null),[c,f]=d.useState([]),[r,S]=d.useState(null);d.useEffect(()=>{let i=!1;async function p(){if(!n){b(null),m(!1),v(o("desktopWindow.invalidWindowId"));return}m(!0),v(null);const w=await t.bridge.getWindowDescriptor(n),g=w.ok?w.value??null:t.windows.getDescriptor(n);if(!i){if(!g){b(null),m(!1),v(w.detail??o("desktopWindow.loadDescriptorFailed"));return}t.windows.registerDescriptor(g),t.windows.markWindowOpen(g.windowId),b(g),m(!1)}}return p(),()=>{i=!0}},[t,n]),d.useEffect(()=>{if(!(e!=null&&e.workspaceId)){f([]);return}let i=!1;async function p(){try{const w=await U();if(i)return;f(N(w,u))}catch{if(i)return;f([])}}return p(),()=>{i=!0}},[e==null?void 0:e.workspaceId,u]),d.useEffect(()=>{if(!e){S(null);return}const i=new _({onConnectionChange:()=>{},onSnapshot:p=>{f(N(p,u))},onUnauthorized:()=>{F.clear(),a(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return S(i),i.start(),()=>{i.close(),S(null)}},[e,a,u]),d.useEffect(()=>{if(!t.isDesktop||!t.bridge.supported||!e||e.mode!=="external")return;const i=ie(e,c);document.title=i,q(async()=>{const{getCurrentWindow:p}=await import("./window-BVUB8gMK.js").then(w=>w.w);return{getCurrentWindow:p}},__vite__mapDeps([0,1])).then(({getCurrentWindow:p})=>p().setTitle(i)).catch(()=>{})},[e,c,t.bridge.supported,t.isDesktop]);const D=d.useMemo(()=>r?{navigationGroups:c,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:Y(c),[c,r]),G=d.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:Z(),[r]),y=d.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:ee(),[r]),L=d.useMemo(()=>r?{navigationGroups:c,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:re((e==null?void 0:e.workspaceId)??null,c),[e==null?void 0:e.workspaceId,c,r]);if(!t.isDesktop)return s.jsx(W,{to:"/",replace:!0});if(R)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("common.loading")})});if(M)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:M})});if(!e)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.loadDescriptorFailed")})});if(e.kind==="code"){const i=ne(e);return i?s.jsx(W,{to:i,replace:!0}):s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.invalidCodeTarget")})})}if(e.kind==="affairs"){const i=te(e);return s.jsx(W,{to:i,replace:!0})}let h=null;if(e.kind==="file-preview"){const i=((I=e.payload.filePath)==null?void 0:I.trim())??"";x(e,c),h=i?s.jsx($,{workspaceId:e.workspaceId,filePath:i,open:!0,chrome:"window",windowTitle:j(i)??i,onClose:()=>void t.bridge.setWindowState("close"),onSaved:()=>{}}):s.jsx("p",{className:"status-text",children:o("desktopWindow.invalidFilePreviewTarget")})}else e.kind==="files"?h=s.jsx(V,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:D}):e.kind==="git"?h=s.jsx(z,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:G}):e.kind==="processes"?h=s.jsx(B,{currentWorkspaceId:e.workspaceId,navigationGroups:c,externalWindowMode:!0,workbenchShellOverrides:y}):e.kind==="terminals"&&(h=s.jsx(A,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:L}));if(!h)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.unsupportedKind",{kind:e.kind})})});const k=T(e),P=x(e,c),E=e.mode==="external"&&e.kind==="processes";return s.jsxs("main",{className:"desktop-window-page",children:[E?s.jsx("header",{className:"desktop-window-drag-header","data-window-kind":e.kind,"data-window-drag-handle":"desktop-window-drag-header","data-tauri-drag-region":l,"aria-label":k,children:s.jsxs("div",{className:"desktop-window-drag-header-copy","data-tauri-drag-region":l,children:[s.jsx("span",{className:"desktop-window-drag-header-tag","data-tauri-drag-region":l,children:k}),s.jsx("strong",{"data-tauri-drag-region":l,children:P??k})]})}):null,s.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":k,children:h})]})}export{be as DesktopWindowPage};
2
+ import{b as d,o as F,_ as q,j as s,t as o}from"./index-BArTKWXk.js";import{r as O,u as C,W as _,m as N,F as $,T as A,g as U}from"./WorkbenchLayout-DrAvGjGK.js";import{FileContextPanel as V}from"./FileContextPanel-C-1yOton.js";import{GitSidebar as z}from"./GitSidebar-DFHAPT3S.js";import{TerminalManagerPanel as B}from"./TerminalManagerPanel-2HG-NyfR.js";import{b as H,a as K}from"./workbench-navigation-vIWt3Rv_.js";import{c as J,u as Q,e as X,N as W}from"./App-FYuZfAoO.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-BxzpRYrt.js";import"./DesktopModal-K5bEcj38.js";import"./relay-entry-ClEd3cjN.js";import"./WorkbenchModal-BK5ix8YI.js";import"./MobileSheet-D0MfNkTv.js";function Y(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function Z(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function ee(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function re(n,a){return{navigationGroups:a,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function T(n){return n.kind==="file-preview"?o("conversation.fileViewerWindowTitle"):n.kind==="files"?o("shell.filesEntry"):n.kind==="git"?o("shell.gitEntry"):n.kind==="processes"?o("shell.terminalManagerEntry"):n.kind==="terminals"?o("shell.terminalsEntry"):n.kind==="affairs"?o("shell.workbenchModeAffairs"):n.kind==="code"?o("shell.workbenchModeCode"):n.kind}function x(n,a){var t;return n.workspaceName??(n.workspaceId?((t=a.find(l=>l.workspace.id===n.workspaceId))==null?void 0:t.workspace.name)??null:null)}function j(n){const a=(n==null?void 0:n.trim().replace(/\\/g,"/"))??"";return a?a.split("/").filter(Boolean).at(-1)??a:null}function ne(n){var l,u;const a=((l=n.payload.routePath)==null?void 0:l.trim())??"";if(a)return a;const t=((u=n.workspaceId)==null?void 0:u.trim())??"";return t?H(t):null}function te(n){var t;return((t=n.workspaceId)==null?void 0:t.trim())??""?K():"/landing"}function ie(n,a){const t=x(n,a);if(n.kind==="file-preview"){const u=j(n.payload.filePath)??T(n);return t?`${u}(${t})`:u}const l=T(n);return t?`CodingNS - ${l}(${t})`:`CodingNS - ${l}`}function be(){var I;const{windowId:n}=J(),a=Q(),t=X(),l=O(t),u=C(i=>i.sessionDisplaySortMode),[e,b]=d.useState(null),[R,m]=d.useState(!0),[M,v]=d.useState(null),[c,f]=d.useState([]),[r,S]=d.useState(null);d.useEffect(()=>{let i=!1;async function p(){if(!n){b(null),m(!1),v(o("desktopWindow.invalidWindowId"));return}m(!0),v(null);const w=await t.bridge.getWindowDescriptor(n),g=w.ok?w.value??null:t.windows.getDescriptor(n);if(!i){if(!g){b(null),m(!1),v(w.detail??o("desktopWindow.loadDescriptorFailed"));return}t.windows.registerDescriptor(g),t.windows.markWindowOpen(g.windowId),b(g),m(!1)}}return p(),()=>{i=!0}},[t,n]),d.useEffect(()=>{if(!(e!=null&&e.workspaceId)){f([]);return}let i=!1;async function p(){try{const w=await U();if(i)return;f(N(w,u))}catch{if(i)return;f([])}}return p(),()=>{i=!0}},[e==null?void 0:e.workspaceId,u]),d.useEffect(()=>{if(!e){S(null);return}const i=new _({onConnectionChange:()=>{},onSnapshot:p=>{f(N(p,u))},onUnauthorized:()=>{F.clear(),a(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return S(i),i.start(),()=>{i.close(),S(null)}},[e,a,u]),d.useEffect(()=>{if(!t.isDesktop||!t.bridge.supported||!e||e.mode!=="external")return;const i=ie(e,c);document.title=i,q(async()=>{const{getCurrentWindow:p}=await import("./window-BVUB8gMK.js").then(w=>w.w);return{getCurrentWindow:p}},__vite__mapDeps([0,1])).then(({getCurrentWindow:p})=>p().setTitle(i)).catch(()=>{})},[e,c,t.bridge.supported,t.isDesktop]);const D=d.useMemo(()=>r?{navigationGroups:c,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:Y(c),[c,r]),G=d.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:Z(),[r]),y=d.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:ee(),[r]),L=d.useMemo(()=>r?{navigationGroups:c,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:re((e==null?void 0:e.workspaceId)??null,c),[e==null?void 0:e.workspaceId,c,r]);if(!t.isDesktop)return s.jsx(W,{to:"/",replace:!0});if(R)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("common.loading")})});if(M)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:M})});if(!e)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.loadDescriptorFailed")})});if(e.kind==="code"){const i=ne(e);return i?s.jsx(W,{to:i,replace:!0}):s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.invalidCodeTarget")})})}if(e.kind==="affairs"){const i=te(e);return s.jsx(W,{to:i,replace:!0})}let h=null;if(e.kind==="file-preview"){const i=((I=e.payload.filePath)==null?void 0:I.trim())??"";x(e,c),h=i?s.jsx($,{workspaceId:e.workspaceId,filePath:i,open:!0,chrome:"window",windowTitle:j(i)??i,onClose:()=>void t.bridge.setWindowState("close"),onSaved:()=>{}}):s.jsx("p",{className:"status-text",children:o("desktopWindow.invalidFilePreviewTarget")})}else e.kind==="files"?h=s.jsx(V,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:D}):e.kind==="git"?h=s.jsx(z,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:G}):e.kind==="processes"?h=s.jsx(B,{currentWorkspaceId:e.workspaceId,navigationGroups:c,externalWindowMode:!0,workbenchShellOverrides:y}):e.kind==="terminals"&&(h=s.jsx(A,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:L}));if(!h)return s.jsx("main",{className:"desktop-window-page",children:s.jsx("p",{className:"status-text",children:o("desktopWindow.unsupportedKind",{kind:e.kind})})});const k=T(e),P=x(e,c),E=e.mode==="external"&&e.kind==="processes";return s.jsxs("main",{className:"desktop-window-page",children:[E?s.jsx("header",{className:"desktop-window-drag-header","data-window-kind":e.kind,"data-window-drag-handle":"desktop-window-drag-header","data-tauri-drag-region":l,"aria-label":k,children:s.jsxs("div",{className:"desktop-window-drag-header-copy","data-tauri-drag-region":l,children:[s.jsx("span",{className:"desktop-window-drag-header-tag","data-tauri-drag-region":l,children:k}),s.jsx("strong",{"data-tauri-drag-region":l,children:P??k})]})}):null,s.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":k,children:h})]})}export{be as DesktopWindowPage};
@@ -1 +1 @@
1
- import{b as c,E as nn,j as i,t as o,F as dt,B as ni}from"./index-BilHJjYU.js";import{f as ii,e as Li,g as Bi}from"./App-CHsm-VrM.js";import{bT as Wi,bU as Hi,bV as ai,bW as an,bX as $i,bY as Rt,bZ as Tt,b as Oi,u as Vi,ar as Fe,b_ as Jt,b$ as Ui,c0 as zi,c1 as Ki,c2 as ft,c3 as Ct,c4 as qe,c5 as Gi,c6 as Xi,c7 as qi,c8 as Ii,c9 as Yi}from"./WorkbenchLayout-Bo2BbMY6.js";import{s as Zi,w as Ji}from"./workbench-navigation-ED0157V-.js";import{W as $n}from"./WorkbenchModal-YsyEdJ_m.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-Zb2xyVrf.js";import"./DesktopModal-Csj5AdAN.js";import"./relay-entry-Cmc8vTlE.js";import"./MobileSheet-Co-qPMBD.js";async function Dt(t,n,l={}){const[s,h]=await Promise.all([Wi(n,{targetHostId:l.targetHostId}),Hi(t,{targetHostId:l.targetHostId})]);return Qi(s.changes,h.items)}function Qi(t,n){const l=new Set(n.map(s=>kt(s.path)));return t.filter(s=>l.has(kt(s.path))||s.oldPath!==null&&l.has(kt(s.oldPath)))}function ea(t){const n=On("","");for(const l of t){const s=kt(l.path),h=s.split("/").filter(Boolean);let m=n;h.forEach((b,g)=>{const D=h.slice(0,g+1).join("/");if(g===h.length-1){m.children.set(`file:${D}`,{kind:"file",name:b,path:s,change:l});return}const R=`directory:${D}`,T=m.children.get(R);if(T&&T.kind==="directory"){m=T;return}const xe=On(b,D);m.children.set(R,xe),m=xe})}return oi(ri([...n.children.values()]))}function li(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return rn(t)?`${l} ${n}`:l}function rn(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Et(t){return t.split("/").filter(Boolean).pop()??t}function kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ri(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ri([...n.children.values()])}:n)}function oi(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=oi(n.children);let s=n.name,h=n.path,m=l;for(;m.length===1&&((b=m[0])==null?void 0:b.kind)==="directory";){const g=m[0];s=`${s}/${g.name}`,h=g.path,m=g.children}return{kind:"directory",name:s,path:h,children:m}})}const ta=450,na=60*1e3,Vn=20,Un=16;function ia({sessionId:t,workspaceId:n,targetHostId:l,showSystemFiles:s,selectedPath:h,refreshVersion:m,onCountChange:b,onSelectFile:g,onOpenFile:D}){const[R,T]=c.useState("tree"),[xe,J]=c.useState([]),[ge,G]=c.useState(!0),[Ne,v]=c.useState(!1),[ie,mt]=c.useState([]),k=c.useRef(null),Ft=ai(),{showToast:De}=ii();c.useEffect(()=>{const p=nn(Pt(n,t),na);T("tree"),J(p??[]),G(p===null),v(!1),mt([]),k.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){G(!0);try{const y=await Dt(t,n,{targetHostId:l});p||(J(y),dt(Pt(n,t),y))}catch(y){p||De({title:Qt(y,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||G(!1)}}return w(),()=>{p=!0}},[m,t,De,l,n]);async function Ee(){G(!0);try{const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p)}catch(p){De({title:Qt(p,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{G(!1)}}async function E(){if(_.length!==0){v(!0);try{await $i(n,_.map(w=>w.path),{targetHostId:l});const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p),De({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){De({title:Qt(p,o("git.stageFailed")),tone:"error"})}finally{v(!1)}}}function A(p){mt(w=>w.includes(p)?w.filter(y=>y!==p):[...w,p])}function X(p){const w=Date.now(),y=k.current;return k.current={filePath:p,timestamp:w},(y==null?void 0:y.filePath)===p&&w-y.timestamp<=ta}async function $(p,w){if(w&&X(p)){await D(p),k.current=null;return}w||(k.current=null),await g(p)}const ae=c.useMemo(()=>an(xe,p=>Et(p.path),s),[xe,s]),_=ae.filter(p=>!p.staged),Ae=ea(ae),le=new Set(ie);return c.useEffect(()=>{b==null||b(ae.length)},[b,ae.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:R==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="tree",onClick:()=>T("tree"),children:o("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:R==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="list",onClick:()=>T("list"),children:o("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ee(),disabled:ge||Ne,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void E(),disabled:Ne||_.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${ae.length}`}),i.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${_.length}`})]}),i.jsx("div",{ref:Ft,className:"file-tree","data-scrollbar-autohide":"true",children:ge?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):ae.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):R==="tree"?si({nodes:Ae,depth:0,collapsedPathSet:le,selectedPath:h,onToggleTreePath:A,onFileClick:$}):aa({items:ae,selectedPath:h,onFileClick:$})})]})}function si({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m}){return t.map(b=>{if(b.kind==="directory"){const g=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":g,style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>h(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:g?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),g?i.jsx("div",{className:"file-tree-children",children:si({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>void m(b.change.path,!rn(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(b.name),"aria-hidden":"true",children:Rt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:li(b.change,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function aa({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!rn(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(Et(s.path)),"aria-hidden":"true",children:Rt(Et(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Et(s.path)}),i.jsx("span",{className:"file-tree-path",children:li(s,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Pt(t,n){return`file-panel.session-changes.${t}.${n}`}function Qt(t,n){return t instanceof ni?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const C="",la=450,ne=8,jt=4,ra=176,oa=120,sa=300*1e3,ca=60*1e3,zn=1600,ua=220,fa=20,da=16;function ha(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function rl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:h=!1,externalRevealRequest:m=null,externalWindowMode:b=!1,workbenchShellOverrides:g}){var Bn,Wn;const D=Oi(),{navigationGroups:R,subscribeFileTree:T,requestFileTreeRefresh:xe,addFileTreeSnapshotListener:J,subscribeGitSnapshot:ge,requestGitRefresh:G,addGitSnapshotListener:Ne,currentTargetHostId:v}={...D,...g},[ie,mt]=c.useState({}),[k,Ft]=c.useState([]),[De,Ee]=c.useState([]),[E,A]=c.useState(C),[X,$]=c.useState([]),[ae,_]=c.useState(null),[Ae,le]=c.useState(!1),[p,w]=c.useState(!1),[y,pt]=c.useState(!1),[Ye,Ze]=c.useState(!1),[L,Je]=c.useState(""),[At,q]=c.useState(null),[bt,vt]=c.useState(!1),[re,Le]=c.useState(null),[O,Qe]=c.useState("workspace"),[sn,ke]=c.useState(0),[cn,Lt]=c.useState(0),[et,Q]=c.useState(!1),[tt,B]=c.useState(!1),[oe,V]=c.useState(null),[Ce,Be]=c.useState(null),[W,We]=c.useState(null),[P,Bt]=c.useState(null),[S,nt]=c.useState(null),[Wt,He]=c.useState(""),[un,fn]=c.useState([]),[ee,Ht]=c.useState(!1),[bi,se]=c.useState(null),dn=c.useId(),ce=c.useRef({}),I=c.useRef({}),F=c.useRef([]),te=c.useRef(C),it=c.useRef(!1),at=c.useRef(null),vi=ai(),hn=c.useRef(null),mn=c.useRef(null),$t=c.useRef(null),pn=c.useRef(null),bn=c.useRef(null),ue=c.useRef(0),fe=c.useRef(new Map),{showToast:j}=ii(),Pe=Li(),U=Vi(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),vn=s&&Pe.isMobile;c.useEffect(()=>{Fe("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=E},[E]);function Ot(e){Lt(e),!(!l||!n)&&dt(Jn(l,n),e)}async function yn(){if(!l||!n){Ot(0);return}const e=await Dt(n,l,{targetHostId:v}),a=an(e,r=>ft(r.path),U).length;Ot(a)}function Me(e){mt(a=>{const r=typeof e=="function"?e(a):e;return ce.current=r,r})}function Oe(e){Ft(a=>{const r=typeof e=="function"?e(a):e;return F.current=r,r})}c.useEffect(()=>{var f,d;if(Kt(),!l){Kt(),it.current=!1,ce.current={},I.current={},F.current=[],te.current=C,Me({}),Oe([]),Ee([]),A(C),Ze(!1),Je(""),q(null),vt(!1),le(!1),Ht(!1),se(null),$([]),_(null),V(null),Be(null),We(null),nt(null),He("");return}it.current=!0;const e=nn(Zn(l),sa);Fe("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[C])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ra((e==null?void 0:e.activeDirectoryPath)??C,(e==null?void 0:e.treeCache)??{}),r=Yn((e==null?void 0:e.expandedDirectories)??[],a),u=Nt((e==null?void 0:e.treeCache)??{},a,r);ce.current=u,I.current=Qn((e==null?void 0:e.treeRevisionByPath)??{},u),F.current=r,te.current=a,Me(u),Oe(r),Ee([]),A(a),le(!1),w(!1),Ze(!1),Je(""),q(null),vt(!1),queueMicrotask(()=>{it.current=!1})},[l]),c.useEffect(()=>{if(!m||m.workspaceId!==l)return;const e=()=>{if(bn.current===m.requestId)return;bn.current=m.requestId,Qe("workspace"),(m.openViewer?Ke(m.filePath):me(m.filePath)).catch(r=>{j({title:Z(r,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(it.current){queueMicrotask(e);return}e()},[m,Ke,me,j,l]),c.useEffect(()=>{if(l)return J(e=>{e.workspaceId!==l||!Gn(Kn(e),v)||(I.current={...I.current,[e.path]:typeof e.revision=="string"?e.revision:null},Me(a=>({...a,[e.path]:e.items})),e.path===C&&le(!1),Ee(a=>a.filter(r=>r!==e.path)),Sn(e.path,e.items))})},[J,l]),c.useEffect(()=>()=>{Kt()},[]),c.useEffect(()=>{l&&T(l,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v})},[E,v,k,T,l]),c.useEffect(()=>{$([]),_(null),Le(null),se(null),ke(0),Q(!1),B(!1),V(null),Be(null),We(null),nt(null),He(""),at.current=null,ue.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Qe("workspace")},[O,$e]),c.useEffect(()=>{h&&O!=="workspace"&&Qe("workspace")},[O,h]),c.useEffect(()=>{if(!et&&!tt&&!oe)return;function e(r){var x,N,be;if(!(r.target instanceof Node))return;const u=((x=hn.current)==null?void 0:x.contains(r.target))??!1,f=((N=mn.current)==null?void 0:N.contains(r.target))??!1,d=((be=$t.current)==null?void 0:be.contains(r.target))??!1;!u&&!f&&!d&&(Q(!1),B(!1),V(null),Be(null))}function a(r){r.key==="Escape"&&(Q(!1),B(!1),V(null),Be(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[et,tt,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Be(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Be(Ca({x:e.positionX,y:e.positionY},{width:f.width||ra,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const r=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Yn(k,E),a=Nt(ie,E,e);dt(Zn(l),{treeCache:a,treeRevisionByPath:Qn(I.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,k,ie,l]),c.useEffect(()=>{if(it.current)return;const e=Nt(ie,E,k);_a(ie,e)||Me(e)},[E,k,ie]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function r(f){if(!a)return;const d=Jt(ce.current[C]??[],U),x=(f==null?void 0:f.silent)!==!0&&d.length===0;x&&le(!0),Fe("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await zt(C,{force:!0});e||(Fe("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),Me(be=>({...Nt(be,te.current,F.current),[C]:N})))}catch(N){!e&&!ei(N)&&j({title:Z(N,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&le(!1)}}if(Jt(ce.current[C]??[],U).length>0){const f=window.setTimeout(()=>{a&&(T(a,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v}),r({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return r(),()=>{e=!0}},[n,U,j,l]),c.useEffect(()=>{if(!l||!n){Lt(0);return}const e=nn(Jn(l,n),ca);Fe("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),Lt(e??0);let a=!1;return yn().catch(()=>{}),()=>{a=!0}},[n,sn,U,l]),c.useEffect(()=>{if(!l){fn([]);return}const e=l.trim();ge(e,{targetHostId:v}),G(e,{targetHostId:v})},[v,l,ge,G]),c.useEffect(()=>{if(!l)return;const e=l.trim();return Ne(a=>{var r;a.workspaceId!==e||!Gn(Kn(a),v)||fn(((r=a.status)==null?void 0:r.changes)??[])})},[Ne,l]);const yt=c.useMemo(()=>an(un,e=>ft(e.path),U),[un,U]),H=c.useMemo(()=>{const e=new Map,a=new Set;for(const r of yt){const u=r.path.replace(/\\/g,"/"),f=r.worktreeStatus??r.stagedStatus??r.status;e.set(u,f);const d=u.split("/");for(let x=1;x<d.length;x++)a.add(d.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[yt]),Re=c.useMemo(()=>Ui(ie,U),[U,ie]),Te=c.useMemo(()=>At===null?null:Jt(At,U),[At,U]),Ve=Re[C]??[],de=Ye&&Te!==null,xt=c.useMemo(()=>ee?ln(Ve,Re,H.statusByPath,H.changedDirs):Ve,[H.changedDirs,H.statusByPath,Ve,ee,Re]),yi=c.useMemo(()=>de?(Te??[]).map(e=>K(e.path,e.kind)):ci(xt,Re,k,ee,H.statusByPath,H.changedDirs),[k,H.changedDirs,H.statusByPath,de,ee,Te,Re,xt]),he=((Bn=R.find(e=>e.workspace.id===l))==null?void 0:Bn.workspace)??null,M=In(X),Vt=(M==null?void 0:M.path)??null,je=(M==null?void 0:M.kind)==="file"?M.path:null,gt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),lt=c.useMemo(()=>St(X),[X]),Ut=!!(he!=null&&he.path&&X.length===1&&Vt),xn=X.length===1&&(M==null?void 0:M.kind)==="file",gn=lt.length>0,_e=lt.length>0,rt=!!(P!=null&&P.items.length&&l),Cn=!!l&&X.length===1&&M!==null,Pn=!!((je?ye(je):E)&&k.length),jn=P?P.mode==="copy"?o("conversation.filePanelClipboardCopyReady",{count:P.items.length}):o("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,z=S?Sa(S):null;async function wn(e,a=!1){if(!l)return[];if(!a){const r=ce.current[e];if(r)return r}e===C?le(!0):Ee(r=>Mt(r,e));try{const r=await zt(e,{force:a});return Me(u=>({...u,[e]:r})),r}catch(r){throw ei(r)||j({title:Z(r,o("conversation.filePanelLoadFailed")),tone:"error"}),r}finally{e===C?le(!1):Ee(r=>r.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,r=(e==null?void 0:e.expandedDirectories)??F.current,u=Ta(ce.current,a,r);Fe("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,be])=>(x[N]=be,x),{});Fe("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),Me(d)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=ce.current[e];if(d)return d}const r=tn(Mt(F.current,e),e||te.current);T(l,r,{knownRevisionByPath:I.current,targetHostId:v}),xe(l,[e],{knownRevisionByPath:I.current,targetHostId:v});const u=xi(e,zn,{allowCached:(a==null?void 0:a.force)!==!0}),f=Fa(ua).then(async()=>{if(!l)return[];const x=(await Ii(l,e||void 0,{targetHostId:v})).items;return I.current={...I.current,[e]:null},Sn(e,x),x});try{return await Promise.race([u,f])}catch(d){if(!mi(d))throw d;return await f}}function xi(e,a=zn,r){const u=ce.current[e];return(r==null?void 0:r.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const x=window.setTimeout(()=>{gi(e,x),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=fe.current.get(e)??[];fe.current.set(e,[...N,{resolve:f,reject:d,timerId:x}])})}function Sn(e,a){const r=fe.current.get(e)??[];r.length!==0&&(fe.current.delete(e),r.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function gi(e,a){const u=(fe.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){fe.current.delete(e);return}fe.current.set(e,u)}function Kt(){for(const[e,a]of fe.current.entries())a.forEach(r=>{window.clearTimeout(r.timerId),r.reject(new Error(`FILE_TREE_ABORTED:${e}`))});fe.current.clear()}function Ue(e){$([e]),_(e.path)}function ot(e){A(e.kind==="directory"?e.path:ye(e.path))}function Ci(e){const a=ba(yi,ae,e);$(a),_(e.path),ot(e)}function Pi(e){const a=pa(X,e),r=In(a);$(a),_(e.path),r&&ot(r)}function Nn(e){Ue(e),ot(e)}function ze(e,a){if(a!=null&&a.shiftKey){Ci(e);return}if(wt(a)){Pi(e);return}Nn(e)}async function st(e,a=!1){const r=ht(e,a);if(!r.length){A(C);return}Oe(u=>hi(u,r)),A(r[r.length-1]??C);for(const u of r)try{await wn(u)}catch{return}}async function me(e){const a=K(e,"file");Ue(a),ot(a),await st(e)}async function Ke(e){Le(e),se(null),at.current=null,ue.current+=1,me(e),await ji(e)}async function ji(e){const a=ue.current,r=e.replace(/\\/g,"/"),u=H.statusByPath.get(r);if(l&&u&&u!=="?"&&u!=="D")try{const f=await zi(l,e,!1,{targetHostId:v});ue.current===a&&se(f.content||null)}catch{ue.current===a&&se(null)}}async function wi(e){if(!l)return;const a=ha(),r=await Gi(Pe,{workspaceId:l,workspaceName:(he==null?void 0:he.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!r.ok){j({title:r.detail??o("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ue.current+=1,Le(null),se(null)}function Dn(e){const a=Date.now(),r=at.current;return at.current={filePath:e,timestamp:a},(r==null?void 0:r.filePath)===e&&a-r.timestamp<=la}function Se(){at.current=null}async function Si(e,a){const r=K(e,"file");if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(Dn(e)){await Ke(e);return}ze(r,a),await st(e)}function En(){Ze(!1),Je(""),q(null),Se()}async function Ni(e,a){const r=K(e.path,e.kind);if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(e.kind==="directory"){En(),ze(r,a),await kn(e.path);return}if(Dn(e.path)){En(),await Ke(e.path);return}await me(e.path)}async function kn(e){if(Ue(K(e,"directory")),A(e),!F.current.includes(e))try{await wn(e),Oe(a=>Mt(a,e))}catch{}}async function Mn(e){if(Ue(K(e,"directory")),A(e),F.current.includes(e)){Rn(e);return}await kn(e)}function Rn(e){Oe(a=>a.filter(r=>r!==e&&!r.startsWith(`${e}/`))),A(ye(e)),$([]),_(null)}async function Tn(){if(!l)return;const e=l;try{if(G(e,{targetHostId:v}),await we(),je&&await st(je),de&&L.trim()){const a=await qe(e,L.trim(),1,20,{targetHostId:v});q(a.items)}if($e&&n)if(O==="session")ke(a=>a+1);else try{await yn()}catch(a){j({title:Z(a,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){j({title:Z(a,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function Di(e){if(e==null||e.preventDefault(),!l||!L.trim()){q(null);return}vt(!0);try{const a=await qe(l,L.trim(),1,20,{targetHostId:v});q(a.items)}catch(a){j({title:Z(a,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{vt(!1)}}function _n(){if(Ye){Ze(!1),Je(""),q(null);return}Ze(!0)}function Y(e){B(!1),e()}function Fn(){var e;(e=pn.current)==null||e.click()}async function Ei(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const r=ma(a.name);if(!r){j({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Xn(E,M),f=qn(u,r);pt(!0);try{const x=await Na(a);await Xi({workspaceId:l,path:f,contentBase64:x},{targetHostId:v}),await we(),await me(f),j({title:o("conversation.filePanelUploadSuccess",{name:r}),tone:"success"})}catch(x){j({title:Z(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{pt(!1)}}async function Gt(e=je){if(!(!l||!e)){pt(!0);try{const a=await qi(l,e,{targetHostId:v}),r=Da(a.contentBase64);Ea(a.fileName,new Blob([r],{type:"application/octet-stream"})),j({title:o("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){j({title:Z(a,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{pt(!1)}}}function An(){const e=je?ye(je):E;!e||!F.current.includes(e)||Rn(e)}function Xt(){nt(null),He("")}function qt(){p||Xt()}function Ge(e,a=Xn(E,M)){if(!l)return;const r=a,u=r?`${r}/`:"";Q(!1),B(!1),V(null),nt({mode:e,baseDirectory:r}),He(u)}function It(e=M){!l||!e||(Q(!1),B(!1),V(null),nt({mode:"rename",target:e}),He(e.path))}async function ki(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Wt??"").trim();if(a){if(S.mode==="rename"&&Ie(S.target.path)===Ie(a)){qt();return}w(!0);try{if(S.mode==="rename"){const r=S.target.path,u=K(a,S.target.kind),f=re?di(re,r,a):null;if(await Ct({workspaceId:l,opType:"rename",srcPath:r,dstPath:a},{targetHostId:v}),P&&Bt({...P,items:wa(P.items,r,a)}),Xt(),Se(),await we(),S.target.kind==="directory"?(await st(a,!0),Ue(u),A(a)):await me(a),f!==re&&(ue.current+=1,Le(f),se(null)),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelRenameSuccess",{name:ft(a)||a}),tone:"success"});return}if(await Ct({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0},{targetHostId:v}),Xt(),await we(),S.mode==="create_directory"?(await st(a,!0),Ue(K(a,"directory")),A(a)):await me(a),de&&L.trim()){const r=await qe(l,L.trim(),1,20,{targetHostId:v});q(r.items)}ke(r=>r+1)}catch(r){j({title:Z(r,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function pe(e,a=lt){var u;if(a.length===0)return;const r=St(a);Bt({mode:e,items:r}),$(r),_(((u=r[r.length-1])==null?void 0:u.path)??null),j({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:r.length}):o("conversation.filePanelCutSelectionSuccess",{count:r.length}),tone:"success"}),V(null)}async function ct(e=xa(M,E)){if(!l||!P||!P.items.length)return;const a=e??C,r=P.items.map(u=>({source:u,destinationPath:qn(a,ft(u.path)||u.path)}));w(!0);try{for(const d of r)P.mode==="cut"&&Ie(d.source.path)===Ie(d.destinationPath)||await Ct({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath},{targetHostId:v});const u=r.map(d=>K(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Bt(null),$(u),_((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ye(f.path):te.current,expandedDirectories:F.current}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),V(null)}catch(u){await we().catch(()=>{}),j({title:Z(u,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=lt){!e.length||p||(We(St(e)),V(null))}async function Mi(){var a,r;if(!l||!(W!=null&&W.length))return;const e=St(W);w(!0);try{for(const d of e)await Ct({workspaceId:l,opType:"delete",srcPath:d.path},{targetHostId:v});const u=ga(E,e),f=F.current.filter(d=>!e.some(x=>x.kind==="directory"&&_t(x.path,d)));if(re&&e.some(d=>_t(d.path,re))&&(ue.current+=1,Le(null),se(null)),We(null),$([]),_(null),te.current=u,F.current=f,A(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:ft(((a=e[0])==null?void 0:a.path)??"")||((r=e[0])==null?void 0:r.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){j({title:Z(u,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Xe(e,a=M){const r=(he==null?void 0:he.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!r){Q(!1);return}try{const f=ja(r),d=e==="absolute"?Pa(r,u,f):Ie(u,f);await ka(d,Pe),j({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){j({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Q(!1),V(null)}}function Ri(e,a,r){return[{id:`open-${e.path}`,label:e.kind==="directory"?k.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Mn(e.path);return}Ke(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||y,onSelect:()=>{Gt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!l||p||y,onSelect:()=>{Ge("create_file",r)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!l||p||y,onSelect:()=>{Ge("create_directory",r)}},{id:`rename-${e.path}`,label:o("conversation.filePanelRenameMove"),disabled:a.length!==1||p||y,onSelect:()=>It(e)},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>pe("copy",a)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>pe("cut",a)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!rt,onSelect:()=>{ct(r)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{Xe("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Xe("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:a.length===0||p||y,onSelect:()=>Yt(a)}]}async function Ln(e,a){if(Pe.isMobile)return;e.preventDefault();const r=K(a.path,a.kind),u=gt.has(r.path)?lt:[r],f=r.kind==="directory"?r.path:ye(r.path);gt.has(r.path)||Nn(r);const d=Ri(r,u,f);if(Pe.isDesktop){await Yi(d);return}Pe.isWeb&&(Q(!1),B(!1),V({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!va(a)||a.altKey||a.shiftKey||ya(a.target))return;const r=a.key.toLowerCase();if(r==="c"&&_e){a.preventDefault(),pe("copy");return}if(r==="x"&&_e){a.preventDefault(),pe("cut");return}r==="v"&&rt&&(a.preventDefault(),ct())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,_e,rt,pe,ct]);function Zt(e,a){return i.jsx(i.Fragment,{children:e.map(r=>{const u=K(r.path,r.kind),f=r.kind==="directory",d=f&&k.includes(r.path),x=f&&De.includes(r.path),N=Re[r.path]??[],be=ee?ln(N,Re,H.statusByPath,H.changedDirs):N,_i=gt.has(r.path),Fi=Vt===r.path,ut=H.statusByPath.get(r.path.replace(/\\/g,"/")),Hn=f&&H.changedDirs.has(r.path.replace(/\\/g,"/")),Ai=(P==null?void 0:P.mode)==="cut"&&P.items.some(ve=>ve.path===r.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Fi,"data-selected":_i,"data-cut-pending":Ai||void 0,"data-kind":r.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${fa+a*da}px`},onClick:ve=>{if(f){if(ve.shiftKey||wt(ve)){Se(),ze(u,ve);return}Se(),ze(u,ve),Mn(r.path);return}Si(r.path,ve)},onContextMenu:ve=>{Ln(ve,r)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(r.name),"aria-hidden":"true",children:Rt(r.name)}),i.jsx("span",{className:"file-tree-label","data-status":ut??void 0,"data-has-changes":Hn||void 0,children:r.name}),!f&&ut?i.jsx("span",{className:"git-status-badge","data-status":ut,"aria-label":ut,children:ut}):null,f&&Hn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?i.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:x&&!N.length?i.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):be.length?Zt(be,a+1):i.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${r.kind}-${r.path}`)})})}function Ti(e){return i.jsx(i.Fragment,{children:e.map(a=>{const r=a.kind==="directory",u=gt.has(a.path),f=Vt===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{Ni(a,d)},onContextMenu:d=>{Ln(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),r?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(a.name),"aria-hidden":"true",children:Rt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Ki,{workspaceId:l,filePath:re,open:re!==null,onClose:()=>{ue.current+=1,Le(null),se(null)},onSaved:async e=>{await we(),await me(e),ke(a=>a+1)},diffContent:bi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{re&&wi(re)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Qe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Qe("session")},disabled:!$e,children:[o("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${cn}`,children:cn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:pn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Ei(e)}),vn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:mn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":tt,"data-active":tt,onClick:()=>{Q(!1),B(e=>!e)},children:[i.jsx("span",{children:o("conversation.filePanelActionsMenu")}),i.jsx(Xa,{})]}),tt?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("copy")),disabled:!_e,children:o("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("cut")),disabled:!_e,children:o("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ct()),disabled:!rt||p||y,children:o("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),_n()},children:Ye?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Ht(e=>!e)},disabled:yt.length===0,children:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Tn),disabled:Ae||p||bt,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),An()},disabled:!Pn,children:o("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Fn()},disabled:p||y,children:o("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Gt),disabled:!xn||y,children:o("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(It),disabled:!Cn||p||y,children:o("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(Yt),disabled:!gn||p||y,children:o("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_file")),disabled:p||y,children:o("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_directory")),disabled:p||y,children:o("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("absolute")),disabled:!Ut,children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("relative")),disabled:!Ut,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>pe("copy"),disabled:!_e,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>pe("cut"),disabled:!_e,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void ct(),disabled:!rt||p||y,children:i.jsx($a,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:hn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{B(!1),Q(e=>!e)},disabled:!Ut,children:i.jsx(Ba,{})}),et?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:An,disabled:!Pn,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void Tn(),disabled:Ae||p||bt,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Ye,onClick:_n,disabled:Ae,children:i.jsx(ti,{})}),yt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Ht(e=>!e),children:i.jsx(qa,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:Fn,disabled:p||y,children:i.jsx(Va,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void Gt(),disabled:!xn||y,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRenameMove"),"aria-label":o("conversation.filePanelRenameMove"),onClick:()=>It(),disabled:!Cn||p||y,children:i.jsx(Ga,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!gn||p||y,children:i.jsx(za,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ge("create_file"),disabled:p||y,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ge("create_directory"),disabled:p||y,children:i.jsx(Ka,{})})]}),oe&&typeof document<"u"?Bi.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{V(null),e.onSelect()},children:e.label},e.id))}),document.body):null,jn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:jn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void Di(e),children:[i.jsx("input",{value:L,onChange:e=>Je(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),vn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:o("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:i.jsx(ti,{})})]}):null,i.jsx("div",{ref:vi,className:"file-tree","data-search-mode":de,"data-scrollbar-autohide":"true",children:Ae&&Ve.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):de?Te!=null&&Te.length?Ti(Te):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):ee?xt.length?Zt(xt,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Ve.length?Zt(Ve,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(z==null?void 0:z.title)??"",description:z==null?void 0:z.description,onClose:qt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void ki(e),children:[i.jsx(Zi,{label:o("conversation.filePanelPathFieldLabel"),htmlFor:dn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:dn,type:"text",value:Wt??"",placeholder:o("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>He(e.target.value)})}),i.jsxs(Ji,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:qt,children:o("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Wt??"").trim(),children:p?(z==null?void 0:z.pendingLabel)??o("common.loading"):(z==null?void 0:z.submitLabel)??o("common.save")})]})]})}),i.jsxs($n,{open:W!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||We(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:W!=null&&W.length?W.length===1?((Wn=W[0])==null?void 0:Wn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:W[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:W[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:W.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>We(null),children:o("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Mi()},children:p?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ia,{sessionId:n,workspaceId:l,targetHostId:v,showSystemFiles:U,selectedPath:je,refreshVersion:sn,onCountChange:Ot,onSelectFile:me,onOpenFile:Ke}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function Kn(t){const n=t==null?void 0:t.targetHostId;return typeof n=="string"&&n.trim()?n.trim():null}function Gn(t,n){return((t==null?void 0:t.trim())||null)===((n==null?void 0:n.trim())||null)}function ye(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):C}function ht(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,h=[];for(let m=0;m<s;m+=1)h.push(l.slice(0,m+1).join("/"));return h}function Xn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ye(n.path):C)}function qn(t,n){return t?`${t}/${n}`:n}function ma(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function K(t,n){return{path:t,kind:n}}function In(t){return t[t.length-1]??null}function pa(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ba(t,n,l){const s=t.findIndex(g=>g.path===l.path);if(s<0)return[l];const h=n?t.findIndex(g=>g.path===n):s;if(h<0)return[l];const m=Math.min(h,s),b=Math.max(h,s);return t.slice(m,b+1)}function wt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function va(t){return t.ctrlKey||t.metaKey}function ya(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function St(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,h)=>s.path.localeCompare(h.path)),l=[];for(const s of n)l.some(h=>h.kind==="directory"&&_t(h.path,s.path))||l.push(s);return l}function xa(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ye(t.path):n}function ga(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&_t(s.path,l));)l=ye(l);return l}function ci(t,n,l,s,h,m){const b=[];for(const g of t){if(b.push(K(g.path,g.kind)),g.kind!=="directory"||!l.includes(g.path))continue;const D=n[g.path]??[],R=s?ln(D,n,h,m):D;b.push(...ci(R,n,l,s,h,m))}return b}function Ca(t,n,l){const s=Math.max(0,l.width),h=Math.max(0,l.height),m=Math.max(0,h-ne*2),b=Math.max(0,s-ne*2),g=Math.min(Math.max(n.width,0),b),D=Math.max(0,h-t.y-jt-ne),R=Math.max(0,t.y-jt-ne),T=D<n.height&&R>D,J=en(Math.max(T?R:D,oa),0,m),ge=Math.min(Math.max(n.height,0),J),G=T?t.y-jt-ge:t.y+jt,Ne=Math.max(ne,h-ne-ge),v=Math.max(ne,s-ne-g);return{top:en(G,ne,Ne),left:en(t.x,ne,v),maxHeight:Math.max(0,J)}}function en(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function Ie(t,n="posix"){return t?ui(t,n):"."}function Pa(t,n,l){const s=ui(t,l),h=Ie(n,l).replace(/^\.[/\\]?/,"");if(!h)return s;const m=fi(l),b=h.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${m}${b}`:s}function ja(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ui(t,n){return t&&(fi(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function fi(t){return t==="windows"?"\\":"/"}function _t(t,n){return n===t||n.startsWith(`${t}/`)}function di(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function wa(t,n,l){return t.map(s=>({...s,path:di(s.path,n,l)}))}function Sa(t){return t.mode==="create_file"?{title:o("conversation.filePanelNewFile"),description:o("conversation.filePanelCreateFileDescription"),submitLabel:o("conversation.filePanelCreateFileSubmit"),pendingLabel:o("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:o("conversation.filePanelNewDirectory"),description:o("conversation.filePanelCreateDirectoryDescription"),submitLabel:o("conversation.filePanelCreateDirectorySubmit"),pendingLabel:o("conversation.filePanelCreatingDirectory")}:{title:o("conversation.filePanelRenameMove"),description:o("conversation.filePanelRenameDescription"),submitLabel:o("conversation.filePanelRenameSubmit"),pendingLabel:o("conversation.filePanelRenaming")}}async function Na(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let h="";for(let m=0;m<l.length;m+=s){const b=l.subarray(m,m+s);h+=String.fromCharCode(...b)}return btoa(h)}function Da(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Ea(t,n){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function ka(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Ma(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function Ma(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ra(t,n){return t&&ht(t,!0).every(h=>h in n)?t:C}function Yn(t,n){if(!n)return[];const l=ht(n,!0);return t.filter(s=>l.includes(s))}function Nt(t,n,l){const s=on(n,l);return Object.entries(t).reduce((h,[m,b])=>(s.has(m)&&(h[m]=b),h),{})}function Ta(t,n,l){const h=[...on(n,l)].filter(m=>m===C||m in t);return h.length?h:[C]}function on(t,n){const l=new Set([C]),s=hi(n,ht(t,!0));for(const h of s){l.add(h);for(const m of ht(h,!0))l.add(m)}return l}function _a(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(h=>t[h]===n[h])}function Mt(t,n){return t.includes(n)?t:[...t,n]}function hi(t,n){return n.reduce((l,s)=>Mt(l,s),t)}function Zn(t){return`file-panel.workspace-tree.${t}`}function Jn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Qn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function tn(t,n){return[...on(n,t)]}function Z(t,n){return t instanceof ni?t.message:n}function mi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function ei(t){return mi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Fa(t){return new Promise(n=>{window.setTimeout(n,t)})}function Aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function ti(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ua(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ka(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ga(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function qa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function ln(t,n,l,s){const h=[];for(const m of t){const b=m.path.replace(/\\/g,"/");m.kind==="file"?l.has(b)&&h.push(m):pi(b,n,l,s)&&h.push(m)}return h}function pi(t,n,l,s,h){const m=h??new Set;if(m.has(t))return!1;m.add(t);const b=n[t];if(!b)return s.has(t);for(const g of b){const D=g.path.replace(/\\/g,"/");if(g.kind==="file"){if(l.has(D))return!0}else if(pi(D,n,l,s,m))return!0}return!1}export{rl as FileContextPanel};
1
+ import{b as c,E as nn,j as i,t as o,F as dt,B as ni}from"./index-BArTKWXk.js";import{f as ii,e as Li,g as Bi}from"./App-FYuZfAoO.js";import{bT as Wi,bU as Hi,bV as ai,bW as an,bX as $i,bY as Rt,bZ as Tt,b as Oi,u as Vi,ar as Fe,b_ as Jt,b$ as Ui,c0 as zi,c1 as Ki,c2 as ft,c3 as Ct,c4 as qe,c5 as Gi,c6 as Xi,c7 as qi,c8 as Ii,c9 as Yi}from"./WorkbenchLayout-DrAvGjGK.js";import{s as Zi,w as Ji}from"./workbench-navigation-vIWt3Rv_.js";import{W as $n}from"./WorkbenchModal-BK5ix8YI.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./host-alias-BxzpRYrt.js";import"./DesktopModal-K5bEcj38.js";import"./relay-entry-ClEd3cjN.js";import"./MobileSheet-D0MfNkTv.js";async function Dt(t,n,l={}){const[s,h]=await Promise.all([Wi(n,{targetHostId:l.targetHostId}),Hi(t,{targetHostId:l.targetHostId})]);return Qi(s.changes,h.items)}function Qi(t,n){const l=new Set(n.map(s=>kt(s.path)));return t.filter(s=>l.has(kt(s.path))||s.oldPath!==null&&l.has(kt(s.oldPath)))}function ea(t){const n=On("","");for(const l of t){const s=kt(l.path),h=s.split("/").filter(Boolean);let m=n;h.forEach((b,g)=>{const D=h.slice(0,g+1).join("/");if(g===h.length-1){m.children.set(`file:${D}`,{kind:"file",name:b,path:s,change:l});return}const R=`directory:${D}`,T=m.children.get(R);if(T&&T.kind==="directory"){m=T;return}const xe=On(b,D);m.children.set(R,xe),m=xe})}return oi(ri([...n.children.values()]))}function li(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return rn(t)?`${l} ${n}`:l}function rn(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Et(t){return t.split("/").filter(Boolean).pop()??t}function kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ri(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ri([...n.children.values()])}:n)}function oi(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=oi(n.children);let s=n.name,h=n.path,m=l;for(;m.length===1&&((b=m[0])==null?void 0:b.kind)==="directory";){const g=m[0];s=`${s}/${g.name}`,h=g.path,m=g.children}return{kind:"directory",name:s,path:h,children:m}})}const ta=450,na=60*1e3,Vn=20,Un=16;function ia({sessionId:t,workspaceId:n,targetHostId:l,showSystemFiles:s,selectedPath:h,refreshVersion:m,onCountChange:b,onSelectFile:g,onOpenFile:D}){const[R,T]=c.useState("tree"),[xe,J]=c.useState([]),[ge,G]=c.useState(!0),[Ne,v]=c.useState(!1),[ie,mt]=c.useState([]),k=c.useRef(null),Ft=ai(),{showToast:De}=ii();c.useEffect(()=>{const p=nn(Pt(n,t),na);T("tree"),J(p??[]),G(p===null),v(!1),mt([]),k.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function w(){G(!0);try{const y=await Dt(t,n,{targetHostId:l});p||(J(y),dt(Pt(n,t),y))}catch(y){p||De({title:Qt(y,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||G(!1)}}return w(),()=>{p=!0}},[m,t,De,l,n]);async function Ee(){G(!0);try{const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p)}catch(p){De({title:Qt(p,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{G(!1)}}async function E(){if(_.length!==0){v(!0);try{await $i(n,_.map(w=>w.path),{targetHostId:l});const p=await Dt(t,n,{targetHostId:l});J(p),dt(Pt(n,t),p),De({title:o("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){De({title:Qt(p,o("git.stageFailed")),tone:"error"})}finally{v(!1)}}}function A(p){mt(w=>w.includes(p)?w.filter(y=>y!==p):[...w,p])}function X(p){const w=Date.now(),y=k.current;return k.current={filePath:p,timestamp:w},(y==null?void 0:y.filePath)===p&&w-y.timestamp<=ta}async function $(p,w){if(w&&X(p)){await D(p),k.current=null;return}w||(k.current=null),await g(p)}const ae=c.useMemo(()=>an(xe,p=>Et(p.path),s),[xe,s]),_=ae.filter(p=>!p.staged),Ae=ea(ae),le=new Set(ie);return c.useEffect(()=>{b==null||b(ae.length)},[b,ae.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":o("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:R==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="tree",onClick:()=>T("tree"),children:o("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:R==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":R==="list",onClick:()=>T("list"),children:o("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Ee(),disabled:ge||Ne,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void E(),disabled:Ne||_.length===0,children:o("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${o("conversation.filePanelSessionSummary")} ${ae.length}`}),i.jsx("span",{children:`${o("conversation.filePanelSessionUnstagedSummary")} ${_.length}`})]}),i.jsx("div",{ref:Ft,className:"file-tree","data-scrollbar-autohide":"true",children:ge?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionLoading")}):ae.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSessionEmpty")}):R==="tree"?si({nodes:Ae,depth:0,collapsedPathSet:le,selectedPath:h,onToggleTreePath:A,onFileClick:$}):aa({items:ae,selectedPath:h,onFileClick:$})})]})}function si({nodes:t,depth:n,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m}){return t.map(b=>{if(b.kind==="directory"){const g=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":g,style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>h(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:g?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),g?i.jsx("div",{className:"file-tree-children",children:si({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:s,onToggleTreePath:h,onFileClick:m})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":s===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Vn+n*Un}px`},onClick:()=>void m(b.change.path,!rn(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(b.name),"aria-hidden":"true",children:Rt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:li(b.change,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function aa({items:t,selectedPath:n,onFileClick:l}){return t.map(s=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===s.path,onClick:()=>void l(s.path,!rn(s)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(Et(s.path)),"aria-hidden":"true",children:Rt(Et(s.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Et(s.path)}),i.jsx("span",{className:"file-tree-path",children:li(s,o("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":s.status,children:s.status}),i.jsx("span",{className:"file-session-badge subtle",children:s.staged?o("git.stagedLabel"):o("git.workingTreeLabel")})]})]})},`session-list:${s.path}`))}function Pt(t,n){return`file-panel.session-changes.${t}.${n}`}function Qt(t,n){return t instanceof ni?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const C="",la=450,ne=8,jt=4,ra=176,oa=120,sa=300*1e3,ca=60*1e3,zn=1600,ua=220,fa=20,da=16;function ha(){if(typeof document>"u")return;const t=document.querySelector(".workbench-modal-card.file-viewer-modal"),n=t==null?void 0:t.getBoundingClientRect();if(!(!n||n.width<=0||n.height<=0))return{width:Math.round(n.width),height:Math.round(n.height),minWidth:720,minHeight:480}}function rl({className:t,sessionId:n,workspaceId:l,hideHeading:s=!1,hideTabs:h=!1,externalRevealRequest:m=null,externalWindowMode:b=!1,workbenchShellOverrides:g}){var Bn,Wn;const D=Oi(),{navigationGroups:R,subscribeFileTree:T,requestFileTreeRefresh:xe,addFileTreeSnapshotListener:J,subscribeGitSnapshot:ge,requestGitRefresh:G,addGitSnapshotListener:Ne,currentTargetHostId:v}={...D,...g},[ie,mt]=c.useState({}),[k,Ft]=c.useState([]),[De,Ee]=c.useState([]),[E,A]=c.useState(C),[X,$]=c.useState([]),[ae,_]=c.useState(null),[Ae,le]=c.useState(!1),[p,w]=c.useState(!1),[y,pt]=c.useState(!1),[Ye,Ze]=c.useState(!1),[L,Je]=c.useState(""),[At,q]=c.useState(null),[bt,vt]=c.useState(!1),[re,Le]=c.useState(null),[O,Qe]=c.useState("workspace"),[sn,ke]=c.useState(0),[cn,Lt]=c.useState(0),[et,Q]=c.useState(!1),[tt,B]=c.useState(!1),[oe,V]=c.useState(null),[Ce,Be]=c.useState(null),[W,We]=c.useState(null),[P,Bt]=c.useState(null),[S,nt]=c.useState(null),[Wt,He]=c.useState(""),[un,fn]=c.useState([]),[ee,Ht]=c.useState(!1),[bi,se]=c.useState(null),dn=c.useId(),ce=c.useRef({}),I=c.useRef({}),F=c.useRef([]),te=c.useRef(C),it=c.useRef(!1),at=c.useRef(null),vi=ai(),hn=c.useRef(null),mn=c.useRef(null),$t=c.useRef(null),pn=c.useRef(null),bn=c.useRef(null),ue=c.useRef(0),fe=c.useRef(new Map),{showToast:j}=ii(),Pe=Li(),U=Vi(e=>e.showSystemFiles),$e=!!(n!=null&&n.trim()),vn=s&&Pe.isMobile;c.useEffect(()=>{Fe("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=E},[E]);function Ot(e){Lt(e),!(!l||!n)&&dt(Jn(l,n),e)}async function yn(){if(!l||!n){Ot(0);return}const e=await Dt(n,l,{targetHostId:v}),a=an(e,r=>ft(r.path),U).length;Ot(a)}function Me(e){mt(a=>{const r=typeof e=="function"?e(a):e;return ce.current=r,r})}function Oe(e){Ft(a=>{const r=typeof e=="function"?e(a):e;return F.current=r,r})}c.useEffect(()=>{var f,d;if(Kt(),!l){Kt(),it.current=!1,ce.current={},I.current={},F.current=[],te.current=C,Me({}),Oe([]),Ee([]),A(C),Ze(!1),Je(""),q(null),vt(!1),le(!1),Ht(!1),se(null),$([]),_(null),V(null),Be(null),We(null),nt(null),He("");return}it.current=!0;const e=nn(Zn(l),sa);Fe("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[C])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ra((e==null?void 0:e.activeDirectoryPath)??C,(e==null?void 0:e.treeCache)??{}),r=Yn((e==null?void 0:e.expandedDirectories)??[],a),u=Nt((e==null?void 0:e.treeCache)??{},a,r);ce.current=u,I.current=Qn((e==null?void 0:e.treeRevisionByPath)??{},u),F.current=r,te.current=a,Me(u),Oe(r),Ee([]),A(a),le(!1),w(!1),Ze(!1),Je(""),q(null),vt(!1),queueMicrotask(()=>{it.current=!1})},[l]),c.useEffect(()=>{if(!m||m.workspaceId!==l)return;const e=()=>{if(bn.current===m.requestId)return;bn.current=m.requestId,Qe("workspace"),(m.openViewer?Ke(m.filePath):me(m.filePath)).catch(r=>{j({title:Z(r,o("conversation.filePanelOpenFailed")),tone:"error"})})};if(it.current){queueMicrotask(e);return}e()},[m,Ke,me,j,l]),c.useEffect(()=>{if(l)return J(e=>{e.workspaceId!==l||!Gn(Kn(e),v)||(I.current={...I.current,[e.path]:typeof e.revision=="string"?e.revision:null},Me(a=>({...a,[e.path]:e.items})),e.path===C&&le(!1),Ee(a=>a.filter(r=>r!==e.path)),Sn(e.path,e.items))})},[J,l]),c.useEffect(()=>()=>{Kt()},[]),c.useEffect(()=>{l&&T(l,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v})},[E,v,k,T,l]),c.useEffect(()=>{$([]),_(null),Le(null),se(null),ke(0),Q(!1),B(!1),V(null),Be(null),We(null),nt(null),He(""),at.current=null,ue.current+=1},[n]),c.useEffect(()=>{!$e&&O==="session"&&Qe("workspace")},[O,$e]),c.useEffect(()=>{h&&O!=="workspace"&&Qe("workspace")},[O,h]),c.useEffect(()=>{if(!et&&!tt&&!oe)return;function e(r){var x,N,be;if(!(r.target instanceof Node))return;const u=((x=hn.current)==null?void 0:x.contains(r.target))??!1,f=((N=mn.current)==null?void 0:N.contains(r.target))??!1,d=((be=$t.current)==null?void 0:be.contains(r.target))??!1;!u&&!f&&!d&&(Q(!1),B(!1),V(null),Be(null))}function a(r){r.key==="Escape"&&(Q(!1),B(!1),V(null),Be(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[et,tt,oe]),c.useLayoutEffect(()=>{if(!oe||typeof window>"u"){Be(null);return}const e=oe;function a(){const u=$t.current;if(!u)return;const f=u.getBoundingClientRect();Be(Ca({x:e.positionX,y:e.positionY},{width:f.width||ra,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const r=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(r),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[oe]),c.useEffect(()=>{if(!l)return;const e=Yn(k,E),a=Nt(ie,E,e);dt(Zn(l),{treeCache:a,treeRevisionByPath:Qn(I.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,k,ie,l]),c.useEffect(()=>{if(it.current)return;const e=Nt(ie,E,k);_a(ie,e)||Me(e)},[E,k,ie]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function r(f){if(!a)return;const d=Jt(ce.current[C]??[],U),x=(f==null?void 0:f.silent)!==!0&&d.length===0;x&&le(!0),Fe("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await zt(C,{force:!0});e||(Fe("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),Me(be=>({...Nt(be,te.current,F.current),[C]:N})))}catch(N){!e&&!ei(N)&&j({title:Z(N,o("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&x&&le(!1)}}if(Jt(ce.current[C]??[],U).length>0){const f=window.setTimeout(()=>{a&&(T(a,tn(F.current,te.current),{knownRevisionByPath:I.current,targetHostId:v}),r({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return r(),()=>{e=!0}},[n,U,j,l]),c.useEffect(()=>{if(!l||!n){Lt(0);return}const e=nn(Jn(l,n),ca);Fe("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),Lt(e??0);let a=!1;return yn().catch(()=>{}),()=>{a=!0}},[n,sn,U,l]),c.useEffect(()=>{if(!l){fn([]);return}const e=l.trim();ge(e,{targetHostId:v}),G(e,{targetHostId:v})},[v,l,ge,G]),c.useEffect(()=>{if(!l)return;const e=l.trim();return Ne(a=>{var r;a.workspaceId!==e||!Gn(Kn(a),v)||fn(((r=a.status)==null?void 0:r.changes)??[])})},[Ne,l]);const yt=c.useMemo(()=>an(un,e=>ft(e.path),U),[un,U]),H=c.useMemo(()=>{const e=new Map,a=new Set;for(const r of yt){const u=r.path.replace(/\\/g,"/"),f=r.worktreeStatus??r.stagedStatus??r.status;e.set(u,f);const d=u.split("/");for(let x=1;x<d.length;x++)a.add(d.slice(0,x).join("/"))}return{statusByPath:e,changedDirs:a}},[yt]),Re=c.useMemo(()=>Ui(ie,U),[U,ie]),Te=c.useMemo(()=>At===null?null:Jt(At,U),[At,U]),Ve=Re[C]??[],de=Ye&&Te!==null,xt=c.useMemo(()=>ee?ln(Ve,Re,H.statusByPath,H.changedDirs):Ve,[H.changedDirs,H.statusByPath,Ve,ee,Re]),yi=c.useMemo(()=>de?(Te??[]).map(e=>K(e.path,e.kind)):ci(xt,Re,k,ee,H.statusByPath,H.changedDirs),[k,H.changedDirs,H.statusByPath,de,ee,Te,Re,xt]),he=((Bn=R.find(e=>e.workspace.id===l))==null?void 0:Bn.workspace)??null,M=In(X),Vt=(M==null?void 0:M.path)??null,je=(M==null?void 0:M.kind)==="file"?M.path:null,gt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),lt=c.useMemo(()=>St(X),[X]),Ut=!!(he!=null&&he.path&&X.length===1&&Vt),xn=X.length===1&&(M==null?void 0:M.kind)==="file",gn=lt.length>0,_e=lt.length>0,rt=!!(P!=null&&P.items.length&&l),Cn=!!l&&X.length===1&&M!==null,Pn=!!((je?ye(je):E)&&k.length),jn=P?P.mode==="copy"?o("conversation.filePanelClipboardCopyReady",{count:P.items.length}):o("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,z=S?Sa(S):null;async function wn(e,a=!1){if(!l)return[];if(!a){const r=ce.current[e];if(r)return r}e===C?le(!0):Ee(r=>Mt(r,e));try{const r=await zt(e,{force:a});return Me(u=>({...u,[e]:r})),r}catch(r){throw ei(r)||j({title:Z(r,o("conversation.filePanelLoadFailed")),tone:"error"}),r}finally{e===C?le(!1):Ee(r=>r.filter(u=>u!==e))}}async function we(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,r=(e==null?void 0:e.expandedDirectories)??F.current,u=Ta(ce.current,a,r);Fe("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async x=>{const N=await zt(x,{force:!0});return[x,N]}))).reduce((x,[N,be])=>(x[N]=be,x),{});Fe("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),Me(d)}async function zt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=ce.current[e];if(d)return d}const r=tn(Mt(F.current,e),e||te.current);T(l,r,{knownRevisionByPath:I.current,targetHostId:v}),xe(l,[e],{knownRevisionByPath:I.current,targetHostId:v});const u=xi(e,zn,{allowCached:(a==null?void 0:a.force)!==!0}),f=Fa(ua).then(async()=>{if(!l)return[];const x=(await Ii(l,e||void 0,{targetHostId:v})).items;return I.current={...I.current,[e]:null},Sn(e,x),x});try{return await Promise.race([u,f])}catch(d){if(!mi(d))throw d;return await f}}function xi(e,a=zn,r){const u=ce.current[e];return(r==null?void 0:r.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const x=window.setTimeout(()=>{gi(e,x),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=fe.current.get(e)??[];fe.current.set(e,[...N,{resolve:f,reject:d,timerId:x}])})}function Sn(e,a){const r=fe.current.get(e)??[];r.length!==0&&(fe.current.delete(e),r.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function gi(e,a){const u=(fe.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){fe.current.delete(e);return}fe.current.set(e,u)}function Kt(){for(const[e,a]of fe.current.entries())a.forEach(r=>{window.clearTimeout(r.timerId),r.reject(new Error(`FILE_TREE_ABORTED:${e}`))});fe.current.clear()}function Ue(e){$([e]),_(e.path)}function ot(e){A(e.kind==="directory"?e.path:ye(e.path))}function Ci(e){const a=ba(yi,ae,e);$(a),_(e.path),ot(e)}function Pi(e){const a=pa(X,e),r=In(a);$(a),_(e.path),r&&ot(r)}function Nn(e){Ue(e),ot(e)}function ze(e,a){if(a!=null&&a.shiftKey){Ci(e);return}if(wt(a)){Pi(e);return}Nn(e)}async function st(e,a=!1){const r=ht(e,a);if(!r.length){A(C);return}Oe(u=>hi(u,r)),A(r[r.length-1]??C);for(const u of r)try{await wn(u)}catch{return}}async function me(e){const a=K(e,"file");Ue(a),ot(a),await st(e)}async function Ke(e){Le(e),se(null),at.current=null,ue.current+=1,me(e),await ji(e)}async function ji(e){const a=ue.current,r=e.replace(/\\/g,"/"),u=H.statusByPath.get(r);if(l&&u&&u!=="?"&&u!=="D")try{const f=await zi(l,e,!1,{targetHostId:v});ue.current===a&&se(f.content||null)}catch{ue.current===a&&se(null)}}async function wi(e){if(!l)return;const a=ha(),r=await Gi(Pe,{workspaceId:l,workspaceName:(he==null?void 0:he.name)??null,sessionId:n??null,filePath:e,bounds:a});if(!r.ok){j({title:r.detail??o("conversation.fileViewerOpenInWindowFailed"),tone:"error"});return}ue.current+=1,Le(null),se(null)}function Dn(e){const a=Date.now(),r=at.current;return at.current={filePath:e,timestamp:a},(r==null?void 0:r.filePath)===e&&a-r.timestamp<=la}function Se(){at.current=null}async function Si(e,a){const r=K(e,"file");if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(Dn(e)){await Ke(e);return}ze(r,a),await st(e)}function En(){Ze(!1),Je(""),q(null),Se()}async function Ni(e,a){const r=K(e.path,e.kind);if(a!=null&&a.shiftKey||wt(a)){Se(),ze(r,a);return}if(e.kind==="directory"){En(),ze(r,a),await kn(e.path);return}if(Dn(e.path)){En(),await Ke(e.path);return}await me(e.path)}async function kn(e){if(Ue(K(e,"directory")),A(e),!F.current.includes(e))try{await wn(e),Oe(a=>Mt(a,e))}catch{}}async function Mn(e){if(Ue(K(e,"directory")),A(e),F.current.includes(e)){Rn(e);return}await kn(e)}function Rn(e){Oe(a=>a.filter(r=>r!==e&&!r.startsWith(`${e}/`))),A(ye(e)),$([]),_(null)}async function Tn(){if(!l)return;const e=l;try{if(G(e,{targetHostId:v}),await we(),je&&await st(je),de&&L.trim()){const a=await qe(e,L.trim(),1,20,{targetHostId:v});q(a.items)}if($e&&n)if(O==="session")ke(a=>a+1);else try{await yn()}catch(a){j({title:Z(a,o("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){j({title:Z(a,o("conversation.filePanelLoadFailed")),tone:"error"})}}async function Di(e){if(e==null||e.preventDefault(),!l||!L.trim()){q(null);return}vt(!0);try{const a=await qe(l,L.trim(),1,20,{targetHostId:v});q(a.items)}catch(a){j({title:Z(a,o("conversation.filePanelSearchFailed")),tone:"error"})}finally{vt(!1)}}function _n(){if(Ye){Ze(!1),Je(""),q(null);return}Ze(!0)}function Y(e){B(!1),e()}function Fn(){var e;(e=pn.current)==null||e.click()}async function Ei(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const r=ma(a.name);if(!r){j({title:o("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Xn(E,M),f=qn(u,r);pt(!0);try{const x=await Na(a);await Xi({workspaceId:l,path:f,contentBase64:x},{targetHostId:v}),await we(),await me(f),j({title:o("conversation.filePanelUploadSuccess",{name:r}),tone:"success"})}catch(x){j({title:Z(x,o("conversation.filePanelUploadFailed")),tone:"error"})}finally{pt(!1)}}async function Gt(e=je){if(!(!l||!e)){pt(!0);try{const a=await qi(l,e,{targetHostId:v}),r=Da(a.contentBase64);Ea(a.fileName,new Blob([r],{type:"application/octet-stream"})),j({title:o("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){j({title:Z(a,o("conversation.filePanelDownloadFailed")),tone:"error"})}finally{pt(!1)}}}function An(){const e=je?ye(je):E;!e||!F.current.includes(e)||Rn(e)}function Xt(){nt(null),He("")}function qt(){p||Xt()}function Ge(e,a=Xn(E,M)){if(!l)return;const r=a,u=r?`${r}/`:"";Q(!1),B(!1),V(null),nt({mode:e,baseDirectory:r}),He(u)}function It(e=M){!l||!e||(Q(!1),B(!1),V(null),nt({mode:"rename",target:e}),He(e.path))}async function ki(e){if(e==null||e.preventDefault(),!l||!S)return;const a=(Wt??"").trim();if(a){if(S.mode==="rename"&&Ie(S.target.path)===Ie(a)){qt();return}w(!0);try{if(S.mode==="rename"){const r=S.target.path,u=K(a,S.target.kind),f=re?di(re,r,a):null;if(await Ct({workspaceId:l,opType:"rename",srcPath:r,dstPath:a},{targetHostId:v}),P&&Bt({...P,items:wa(P.items,r,a)}),Xt(),Se(),await we(),S.target.kind==="directory"?(await st(a,!0),Ue(u),A(a)):await me(a),f!==re&&(ue.current+=1,Le(f),se(null)),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelRenameSuccess",{name:ft(a)||a}),tone:"success"});return}if(await Ct({workspaceId:l,opType:S.mode,dstPath:a,content:S.mode==="create_file"?"":void 0},{targetHostId:v}),Xt(),await we(),S.mode==="create_directory"?(await st(a,!0),Ue(K(a,"directory")),A(a)):await me(a),de&&L.trim()){const r=await qe(l,L.trim(),1,20,{targetHostId:v});q(r.items)}ke(r=>r+1)}catch(r){j({title:Z(r,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}}function pe(e,a=lt){var u;if(a.length===0)return;const r=St(a);Bt({mode:e,items:r}),$(r),_(((u=r[r.length-1])==null?void 0:u.path)??null),j({title:e==="copy"?o("conversation.filePanelCopySelectionSuccess",{count:r.length}):o("conversation.filePanelCutSelectionSuccess",{count:r.length}),tone:"success"}),V(null)}async function ct(e=xa(M,E)){if(!l||!P||!P.items.length)return;const a=e??C,r=P.items.map(u=>({source:u,destinationPath:qn(a,ft(u.path)||u.path)}));w(!0);try{for(const d of r)P.mode==="cut"&&Ie(d.source.path)===Ie(d.destinationPath)||await Ct({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath},{targetHostId:v});const u=r.map(d=>K(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Bt(null),$(u),_((f==null?void 0:f.path)??null),f&&ot(f),Se(),await we({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?ye(f.path):te.current,expandedDirectories:F.current}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:o("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),V(null)}catch(u){await we().catch(()=>{}),j({title:Z(u,o("conversation.filePanelPasteFailed")),tone:"error"})}finally{w(!1)}}function Yt(e=lt){!e.length||p||(We(St(e)),V(null))}async function Mi(){var a,r;if(!l||!(W!=null&&W.length))return;const e=St(W);w(!0);try{for(const d of e)await Ct({workspaceId:l,opType:"delete",srcPath:d.path},{targetHostId:v});const u=ga(E,e),f=F.current.filter(d=>!e.some(x=>x.kind==="directory"&&_t(x.path,d)));if(re&&e.some(d=>_t(d.path,re))&&(ue.current+=1,Le(null),se(null)),We(null),$([]),_(null),te.current=u,F.current=f,A(u),Oe(f),Se(),await we({activeDirectoryPath:u,expandedDirectories:f}),de&&L.trim()){const d=await qe(l,L.trim(),1,20,{targetHostId:v});q(d.items)}ke(d=>d+1),j({title:e.length===1?o("conversation.filePanelDeleteSuccess",{name:ft(((a=e[0])==null?void 0:a.path)??"")||((r=e[0])==null?void 0:r.path)||""}):o("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){j({title:Z(u,o("conversation.filePanelMutateFailed")),tone:"error"})}finally{w(!1)}}async function Xe(e,a=M){const r=(he==null?void 0:he.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!r){Q(!1);return}try{const f=ja(r),d=e==="absolute"?Pa(r,u,f):Ie(u,f);await ka(d,Pe),j({title:e==="absolute"?o("conversation.filePanelCopyAbsolutePathSuccess"):o("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){j({title:f instanceof Error?f.message:o("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{Q(!1),V(null)}}function Ri(e,a,r){return[{id:`open-${e.path}`,label:e.kind==="directory"?k.includes(e.path)?o("conversation.filePanelCollapseDirectory"):o("conversation.filePanelExpandDirectory"):o("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){Mn(e.path);return}Ke(e.path)}},{id:`download-${e.path}`,label:o("conversation.filePanelDownload"),disabled:e.kind!=="file"||y,onSelect:()=>{Gt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:o("conversation.filePanelNewFile"),disabled:!l||p||y,onSelect:()=>{Ge("create_file",r)}},{id:`create-directory-${e.path}`,label:o("conversation.filePanelNewDirectory"),disabled:!l||p||y,onSelect:()=>{Ge("create_directory",r)}},{id:`rename-${e.path}`,label:o("conversation.filePanelRenameMove"),disabled:a.length!==1||p||y,onSelect:()=>It(e)},{id:`copy-${e.path}`,label:o("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>pe("copy",a)},{id:`cut-${e.path}`,label:o("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>pe("cut",a)},{id:`paste-${e.path}`,label:o("conversation.filePanelPaste"),disabled:!rt,onSelect:()=>{ct(r)}},{id:`copy-relative-${e.path}`,label:o("conversation.filePanelCopyRelativePath"),onSelect:()=>{Xe("relative",e)}},{id:`copy-absolute-${e.path}`,label:o("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Xe("absolute",e)}},{id:`delete-${e.path}`,label:o("conversation.filePanelDelete"),disabled:a.length===0||p||y,onSelect:()=>Yt(a)}]}async function Ln(e,a){if(Pe.isMobile)return;e.preventDefault();const r=K(a.path,a.kind),u=gt.has(r.path)?lt:[r],f=r.kind==="directory"?r.path:ye(r.path);gt.has(r.path)||Nn(r);const d=Ri(r,u,f);if(Pe.isDesktop){await Yi(d);return}Pe.isWeb&&(Q(!1),B(!1),V({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!va(a)||a.altKey||a.shiftKey||ya(a.target))return;const r=a.key.toLowerCase();if(r==="c"&&_e){a.preventDefault(),pe("copy");return}if(r==="x"&&_e){a.preventDefault(),pe("cut");return}r==="v"&&rt&&(a.preventDefault(),ct())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,_e,rt,pe,ct]);function Zt(e,a){return i.jsx(i.Fragment,{children:e.map(r=>{const u=K(r.path,r.kind),f=r.kind==="directory",d=f&&k.includes(r.path),x=f&&De.includes(r.path),N=Re[r.path]??[],be=ee?ln(N,Re,H.statusByPath,H.changedDirs):N,_i=gt.has(r.path),Fi=Vt===r.path,ut=H.statusByPath.get(r.path.replace(/\\/g,"/")),Hn=f&&H.changedDirs.has(r.path.replace(/\\/g,"/")),Ai=(P==null?void 0:P.mode)==="cut"&&P.items.some(ve=>ve.path===r.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":Fi,"data-selected":_i,"data-cut-pending":Ai||void 0,"data-kind":r.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${fa+a*da}px`},onClick:ve=>{if(f){if(ve.shiftKey||wt(ve)){Se(),ze(u,ve);return}Se(),ze(u,ve),Mn(r.path);return}Si(r.path,ve)},onContextMenu:ve=>{Ln(ve,r)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(r.name),"aria-hidden":"true",children:Rt(r.name)}),i.jsx("span",{className:"file-tree-label","data-status":ut??void 0,"data-has-changes":Hn||void 0,children:r.name}),!f&&ut?i.jsx("span",{className:"git-status-badge","data-status":ut,"aria-label":ut,children:ut}):null,f&&Hn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,x?i.jsx("span",{className:"file-tree-meta",children:o("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:x&&!N.length?i.jsx("p",{className:"file-tree-empty",children:o("common.loading")}):be.length?Zt(be,a+1):i.jsx("p",{className:"file-tree-empty",children:o("conversation.filePanelEmptyDirectory")})}):null]},`${r.kind}-${r.path}`)})})}function Ti(e){return i.jsx(i.Fragment,{children:e.map(a=>{const r=a.kind==="directory",u=gt.has(a.path),f=Vt===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{Ni(a,d)},onContextMenu:d=>{Ln(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),r?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":Tt(a.name),"aria-hidden":"true",children:Rt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Ki,{workspaceId:l,filePath:re,open:re!==null,onClose:()=>{ue.current+=1,Le(null),se(null)},onSaved:async e=>{await we(),await me(e),ke(a=>a+1)},diffContent:bi,showDetachAction:Pe.isDesktop&&Pe.bridge.supported,onDetach:()=>{re&&wi(re)}}),s?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:o("conversation.filePanelTitle")})}),h?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Qe("workspace"),children:o("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{$e&&Qe("session")},disabled:!$e,children:[o("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${o("conversation.filePanelSessionTab")} ${cn}`,children:cn})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:pn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void Ei(e)}),vn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":o("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:mn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":o("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":tt,"data-active":tt,onClick:()=>{Q(!1),B(e=>!e)},children:[i.jsx("span",{children:o("conversation.filePanelActionsMenu")}),i.jsx(Xa,{})]}),tt?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":o("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("copy")),disabled:!_e,children:o("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>pe("cut")),disabled:!_e,children:o("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>ct()),disabled:!rt||p||y,children:o("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),_n()},children:Ye?o("conversation.filePanelHideSearch"):o("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Ht(e=>!e)},disabled:yt.length===0,children:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Tn),disabled:Ae||p||bt,children:o("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),An()},disabled:!Pn,children:o("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{B(!1),Fn()},disabled:p||y,children:o("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(Gt),disabled:!xn||y,children:o("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(It),disabled:!Cn||p||y,children:o("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Y(Yt),disabled:!gn||p||y,children:o("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_file")),disabled:p||y,children:o("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Ge("create_directory")),disabled:p||y,children:o("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("absolute")),disabled:!Ut,children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Y(()=>Xe("relative")),disabled:!Ut,children:o("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":o("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopy"),"aria-label":o("conversation.filePanelCopy"),onClick:()=>pe("copy"),disabled:!_e,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCut"),"aria-label":o("conversation.filePanelCut"),onClick:()=>pe("cut"),disabled:!_e,children:i.jsx(Ha,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelPaste"),"aria-label":o("conversation.filePanelPaste"),onClick:()=>void ct(),disabled:!rt||p||y,children:i.jsx($a,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:hn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCopyPath"),"aria-label":o("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":et,"data-active":et,onClick:()=>{B(!1),Q(e=>!e)},disabled:!Ut,children:i.jsx(Ba,{})}),et?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("absolute"),children:o("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Xe("relative"),children:o("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelCollapseCurrent"),"aria-label":o("conversation.filePanelCollapseCurrent"),onClick:An,disabled:!Pn,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRefresh"),"aria-label":o("conversation.filePanelRefresh"),onClick:()=>void Tn(),disabled:Ae||p||bt,children:i.jsx(La,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),"data-active":Ye,onClick:_n,disabled:Ae,children:i.jsx(ti,{})}),yt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"aria-label":ee?o("conversation.filePanelShowAll"):o("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Ht(e=>!e),children:i.jsx(qa,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelUpload"),"aria-label":o("conversation.filePanelUpload"),onClick:Fn,disabled:p||y,children:i.jsx(Va,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelDownload"),"aria-label":o("conversation.filePanelDownload"),onClick:()=>void Gt(),disabled:!xn||y,children:i.jsx(Ua,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelRenameMove"),"aria-label":o("conversation.filePanelRenameMove"),onClick:()=>It(),disabled:!Cn||p||y,children:i.jsx(Ga,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:o("conversation.filePanelDelete"),"aria-label":o("conversation.filePanelDelete"),onClick:()=>Yt(),disabled:!gn||p||y,children:i.jsx(za,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewFile"),"aria-label":o("conversation.filePanelNewFile"),onClick:()=>void Ge("create_file"),disabled:p||y,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:o("conversation.filePanelNewDirectory"),"aria-label":o("conversation.filePanelNewDirectory"),onClick:()=>void Ge("create_directory"),disabled:p||y,children:i.jsx(Ka,{})})]}),oe&&typeof document<"u"?Bi.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:$t,role:"menu","aria-label":o("conversation.filePanelActionsMenu"),style:{left:`${(Ce==null?void 0:Ce.left)??Math.max(8,oe.positionX)}px`,top:`${(Ce==null?void 0:Ce.top)??Math.max(8,oe.positionY)}px`,maxHeight:Ce?`${Ce.maxHeight}px`:void 0},children:oe.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===o("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{V(null),e.onSelect()},children:e.label},e.id))}),document.body):null,jn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:jn}):null,Ye?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void Di(e),children:[i.jsx("input",{value:L,onChange:e=>Je(e.target.value),placeholder:o("conversation.filePanelSearchPlaceholder")}),vn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:o("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:o("conversation.filePanelSearchButton"),"aria-label":o("conversation.filePanelSearchButton"),disabled:bt,children:i.jsx(ti,{})})]}):null,i.jsx("div",{ref:vi,className:"file-tree","data-search-mode":de,"data-scrollbar-autohide":"true",children:Ae&&Ve.length===0?i.jsx("p",{className:"file-tree-status status-text",children:o("common.loading")}):de?Te!=null&&Te.length?Ti(Te):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelSearchEmpty")}):ee?xt.length?Zt(xt,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelNoChanges")}):Ve.length?Zt(Ve,0):i.jsx("p",{className:"file-tree-status status-text",children:o("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:S!==null,title:(z==null?void 0:z.title)??"",description:z==null?void 0:z.description,onClose:qt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void ki(e),children:[i.jsx(Zi,{label:o("conversation.filePanelPathFieldLabel"),htmlFor:dn,description:(S==null?void 0:S.mode)==="rename"?S.target.path:(S==null?void 0:S.baseDirectory)||void 0,children:i.jsx("input",{id:dn,type:"text",value:Wt??"",placeholder:o("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>He(e.target.value)})}),i.jsxs(Ji,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:qt,children:o("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!(Wt??"").trim(),children:p?(z==null?void 0:z.pendingLabel)??o("common.loading"):(z==null?void 0:z.submitLabel)??o("common.save")})]})]})}),i.jsxs($n,{open:W!==null,title:o("conversation.filePanelDeleteConfirmTitle"),description:o("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||We(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:W!=null&&W.length?W.length===1?((Wn=W[0])==null?void 0:Wn.kind)==="directory"?o("conversation.filePanelDeleteDirectoryConfirm",{path:W[0].path}):o("conversation.filePanelDeleteFileConfirm",{path:W[0].path}):o("conversation.filePanelDeleteSelectionConfirm",{count:W.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>We(null),children:o("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{Mi()},children:p?o("conversation.filePanelDeleting"):o("conversation.filePanelDelete")})]})]})]}):$e&&n?i.jsx(ia,{sessionId:n,workspaceId:l,targetHostId:v,showSystemFiles:U,selectedPath:je,refreshVersion:sn,onCountChange:Ot,onSelectFile:me,onOpenFile:Ke}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:o("conversation.filePanelNoWorkspace")})})})}function Kn(t){const n=t==null?void 0:t.targetHostId;return typeof n=="string"&&n.trim()?n.trim():null}function Gn(t,n){return((t==null?void 0:t.trim())||null)===((n==null?void 0:n.trim())||null)}function ye(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):C}function ht(t,n=!1){const l=t.split("/").filter(Boolean),s=n?l.length:l.length-1,h=[];for(let m=0;m<s;m+=1)h.push(l.slice(0,m+1).join("/"));return h}function Xn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?ye(n.path):C)}function qn(t,n){return t?`${t}/${n}`:n}function ma(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function K(t,n){return{path:t,kind:n}}function In(t){return t[t.length-1]??null}function pa(t,n){return t.findIndex(s=>s.path===n.path)>=0?t.filter(s=>s.path!==n.path):[...t,n]}function ba(t,n,l){const s=t.findIndex(g=>g.path===l.path);if(s<0)return[l];const h=n?t.findIndex(g=>g.path===n):s;if(h<0)return[l];const m=Math.min(h,s),b=Math.max(h,s);return t.slice(m,b+1)}function wt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function va(t){return t.ctrlKey||t.metaKey}function ya(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function St(t){const n=[...new Map(t.map(s=>[s.path,s])).values()].sort((s,h)=>s.path.localeCompare(h.path)),l=[];for(const s of n)l.some(h=>h.kind==="directory"&&_t(h.path,s.path))||l.push(s);return l}function xa(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?ye(t.path):n}function ga(t,n){let l=t;for(;l&&n.some(s=>s.kind==="directory"&&_t(s.path,l));)l=ye(l);return l}function ci(t,n,l,s,h,m){const b=[];for(const g of t){if(b.push(K(g.path,g.kind)),g.kind!=="directory"||!l.includes(g.path))continue;const D=n[g.path]??[],R=s?ln(D,n,h,m):D;b.push(...ci(R,n,l,s,h,m))}return b}function Ca(t,n,l){const s=Math.max(0,l.width),h=Math.max(0,l.height),m=Math.max(0,h-ne*2),b=Math.max(0,s-ne*2),g=Math.min(Math.max(n.width,0),b),D=Math.max(0,h-t.y-jt-ne),R=Math.max(0,t.y-jt-ne),T=D<n.height&&R>D,J=en(Math.max(T?R:D,oa),0,m),ge=Math.min(Math.max(n.height,0),J),G=T?t.y-jt-ge:t.y+jt,Ne=Math.max(ne,h-ne-ge),v=Math.max(ne,s-ne-g);return{top:en(G,ne,Ne),left:en(t.x,ne,v),maxHeight:Math.max(0,J)}}function en(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function Ie(t,n="posix"){return t?ui(t,n):"."}function Pa(t,n,l){const s=ui(t,l),h=Ie(n,l).replace(/^\.[/\\]?/,"");if(!h)return s;const m=fi(l),b=h.replace(/^[/\\]+/,"");return b?s.endsWith("/")||s.endsWith("\\")?`${s}${b}`:`${s}${m}${b}`:s}function ja(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ui(t,n){return t&&(fi(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function fi(t){return t==="windows"?"\\":"/"}function _t(t,n){return n===t||n.startsWith(`${t}/`)}function di(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function wa(t,n,l){return t.map(s=>({...s,path:di(s.path,n,l)}))}function Sa(t){return t.mode==="create_file"?{title:o("conversation.filePanelNewFile"),description:o("conversation.filePanelCreateFileDescription"),submitLabel:o("conversation.filePanelCreateFileSubmit"),pendingLabel:o("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:o("conversation.filePanelNewDirectory"),description:o("conversation.filePanelCreateDirectoryDescription"),submitLabel:o("conversation.filePanelCreateDirectorySubmit"),pendingLabel:o("conversation.filePanelCreatingDirectory")}:{title:o("conversation.filePanelRenameMove"),description:o("conversation.filePanelRenameDescription"),submitLabel:o("conversation.filePanelRenameSubmit"),pendingLabel:o("conversation.filePanelRenaming")}}async function Na(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),s=32768;let h="";for(let m=0;m<l.length;m+=s){const b=l.subarray(m,m+s);h+=String.fromCharCode(...b)}return btoa(h)}function Da(t){const n=atob(t),l=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1)l[s]=n.charCodeAt(s);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Ea(t,n){if(typeof document>"u")throw new Error(o("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),s=document.createElement("a");s.href=l,s.download=t,document.body.append(s),s.click(),s.remove(),window.URL.revokeObjectURL(l)}async function ka(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Ma(t))throw new Error(o("conversation.filePanelCopyPathFailed"))}}function Ma(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ra(t,n){return t&&ht(t,!0).every(h=>h in n)?t:C}function Yn(t,n){if(!n)return[];const l=ht(n,!0);return t.filter(s=>l.includes(s))}function Nt(t,n,l){const s=on(n,l);return Object.entries(t).reduce((h,[m,b])=>(s.has(m)&&(h[m]=b),h),{})}function Ta(t,n,l){const h=[...on(n,l)].filter(m=>m===C||m in t);return h.length?h:[C]}function on(t,n){const l=new Set([C]),s=hi(n,ht(t,!0));for(const h of s){l.add(h);for(const m of ht(h,!0))l.add(m)}return l}function _a(t,n){const l=Object.keys(t),s=Object.keys(n);return l.length!==s.length?!1:l.every(h=>t[h]===n[h])}function Mt(t,n){return t.includes(n)?t:[...t,n]}function hi(t,n){return n.reduce((l,s)=>Mt(l,s),t)}function Zn(t){return`file-panel.workspace-tree.${t}`}function Jn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Qn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function tn(t,n){return[...on(n,t)]}function Z(t,n){return t instanceof ni?t.message:n}function mi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function ei(t){return mi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Fa(t){return new Promise(n=>{window.setTimeout(n,t)})}function Aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function La(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function ti(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ha(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Oa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Va(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ua(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ka(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ga(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Xa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function qa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function ln(t,n,l,s){const h=[];for(const m of t){const b=m.path.replace(/\\/g,"/");m.kind==="file"?l.has(b)&&h.push(m):pi(b,n,l,s)&&h.push(m)}return h}function pi(t,n,l,s,h){const m=h??new Set;if(m.has(t))return!1;m.add(t);const b=n[t];if(!b)return s.has(t);for(const g of b){const D=g.path.replace(/\\/g,"/");if(g.kind==="file"){if(l.has(D))return!0}else if(pi(D,n,l,s,m))return!0}return!1}export{rl as FileContextPanel};