@openchamber/web 1.23.2 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-DdNGwbBw.js → CodeMirrorCommentWidgets-C9kV-n7r.js} +1 -1
  2. package/dist/assets/DiffView-B7YkbY-u.js +4 -0
  3. package/dist/assets/DirtyBranchSwitchDialog-CU0A93Zx.js +1 -0
  4. package/dist/assets/FilesView-vjJx7VaM.js +13 -0
  5. package/dist/assets/GitView-BLhlMYEY.js +6 -0
  6. package/dist/assets/GuestAttachDialog-B-fwE8r3.js +3 -0
  7. package/dist/assets/{JsonTreeView-Chzx5Y6N.js → JsonTreeView-D_4G5X6-.js} +1 -1
  8. package/dist/assets/LinearIssuesView-1uKhePfH.js +1 -0
  9. package/dist/assets/{MarkdownImageGallery-CugnrZ6f.js → MarkdownImageGallery-Ix7N_2wp.js} +1 -1
  10. package/dist/assets/MarkdownRendererImpl-Deel_y5S.js +12 -0
  11. package/dist/assets/{OnboardingScreen-hH9xcTjA.js → OnboardingScreen-ToIakxb_.js} +1 -1
  12. package/dist/assets/{PatchDiff-DRgNYc9l.js → PatchDiff-BjMgezr1.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-ZT2CKuzJ.js → PierreDiffViewer-53Ghfnlr.js} +5 -5
  14. package/dist/assets/PlanView-BGAzxDwD.js +5 -0
  15. package/dist/assets/SettingsView-n2X-jfBB.js +29 -0
  16. package/dist/assets/SettingsWindow-Bi8LE9XI.js +1 -0
  17. package/dist/assets/SubmoduleDiffSummary--YFqK6Ih.js +1 -0
  18. package/dist/assets/ToolOutputDialog-DRWBvdaJ.js +15 -0
  19. package/dist/assets/{ToolPartDiffPreview-oWxWCu-4.js → ToolPartDiffPreview-BxZJCU28.js} +2 -2
  20. package/dist/assets/{VirtualizedFileDiff-CiyrAq_I.js → VirtualizedFileDiff-DCXjBGRf.js} +3 -3
  21. package/dist/assets/{WalkthroughView-CKTevaea.js → WalkthroughView-CfIPvWWa.js} +2 -2
  22. package/dist/assets/appThemeRegistry-DDROzcUO.js +1 -0
  23. package/dist/assets/{computeVirtualFileMetrics-SUWoTyPe.js → computeVirtualFileMetrics-DHgQIkUq.js} +1 -1
  24. package/dist/assets/de-CX_f-T5U.js +10 -0
  25. package/dist/assets/es-BERmWNn_.js +16 -0
  26. package/dist/assets/fr-BjYYE_-z.js +14 -0
  27. package/dist/assets/index-DpzTz2UH.css +1 -0
  28. package/dist/assets/index-Dy8xgawx.js +40 -0
  29. package/dist/assets/{index-C4jJ3Ur5.js → index-WjufPkIV.js} +1 -1
  30. package/dist/assets/{isDiffPlainText-DfG0cZxr.js → isDiffPlainText-D9faP70y.js} +1 -1
  31. package/dist/assets/{isFilePlainText-CyNivOCU.js → isFilePlainText-6qOcz5Ky.js} +1 -1
  32. package/dist/assets/ja-DxqeAk9N.js +16 -0
  33. package/dist/assets/ko-Dty1aUod.js +16 -0
  34. package/dist/assets/main-BOYSXfYn.js +896 -0
  35. package/dist/assets/{main-B8cGozKr.js → main-Bjcre_GE.js} +2 -2
  36. package/dist/assets/{markdown-shiki.worker-D5fBU-lw.js → markdown-shiki.worker-CahLvHIq.js} +5 -5
  37. package/dist/assets/{markdownCore-kyGrWGsn.js → markdownCore-DPrwM1rU.js} +5 -5
  38. package/dist/assets/{miniChat-Cay99IxR.js → miniChat-Dz_bPgMc.js} +2 -2
  39. package/dist/assets/{mobile-Zfhix7nz.js → mobile-BbZPBJrK.js} +2 -2
  40. package/dist/assets/{patchFileDiff-CJ5AN9Ql.js → patchFileDiff-BvU6KOQC.js} +3 -3
  41. package/dist/assets/pl-CX-_ROkr.js +16 -0
  42. package/dist/assets/{pt-BR-CLosVawq.js → pt-BR-DhRR1arx.js} +4 -4
  43. package/dist/assets/renderElectronMiniChatApp-uNEUkeAI.js +2 -0
  44. package/dist/assets/renderMobileApp-BK1kFlcJ.js +25 -0
  45. package/dist/assets/runtimeEndpointReset-BULHvOwb.js +25 -0
  46. package/dist/assets/{scheduledTasksApi-CGFV4Pap.js → scheduledTasksApi-DW3xqMQ8.js} +1 -1
  47. package/dist/assets/shikiHighlight-DsxD9QEa.js +1 -0
  48. package/dist/assets/textMateThemeFromAppTheme-Da7ed8qM.js +1 -0
  49. package/dist/assets/tr-cIQtYBpg.js +7 -0
  50. package/dist/assets/uk-CD21CXFV.js +16 -0
  51. package/dist/assets/{useAppFontEffects-DgCHy6Mr.js → useAppFontEffects-hfv2s6mZ.js} +198 -147
  52. package/dist/assets/useInlineCommentController-BmtfVbo8.js +2 -0
  53. package/dist/assets/useRootScrollLock-Cwc4kSl2.js +1 -0
  54. package/dist/assets/{vendor-base-ui-BY_5qla_.js → vendor-base-ui-CsXYnR5c.js} +1 -1
  55. package/dist/assets/{vendor-codemirror-language-data-ES33GhKK.js → vendor-codemirror-language-data-BPMJpOpT.js} +2 -2
  56. package/dist/assets/vendor-framer-motion-Bq3iTZ6r.js +1 -0
  57. package/dist/assets/{vendor-motion-dom-D_o3BTI3.js → vendor-motion-dom-DcCgeG69.js} +1 -1
  58. package/dist/assets/vendor-strip-json-comments-5dJlOkP1.js +4 -0
  59. package/dist/assets/{vendor-zod-B6551dwG.js → vendor-zod-fZppILAM.js} +4 -4
  60. package/dist/assets/{web-components-CJZwV5BE.js → web-components-U-hWbgJo.js} +2 -2
  61. package/dist/assets/zh-CN-BWvlPHY-.js +16 -0
  62. package/dist/assets/zh-TW-CRp5dJU2.js +16 -0
  63. package/dist/index.html +4 -4
  64. package/dist/mini-chat.html +4 -4
  65. package/dist/mobile.html +4 -4
  66. package/package.json +7 -5
  67. package/server/built-in-extensions/registry.json +4 -0
  68. package/server/index.d.ts +2 -0
  69. package/server/index.js +15 -3
  70. package/server/lib/fs/DOCUMENTATION.md +8 -0
  71. package/server/lib/fs/git-process.test.js +77 -0
  72. package/server/lib/fs/routes.js +2 -1
  73. package/server/lib/fs/search.js +2 -1
  74. package/server/lib/git/DOCUMENTATION.md +3 -1
  75. package/server/lib/git/routes.js +16 -3
  76. package/server/lib/git/service.js +112 -8
  77. package/server/lib/git/service.test.js +127 -0
  78. package/server/lib/guests/DOCUMENTATION.md +66 -0
  79. package/server/lib/guests/auth-store.js +184 -0
  80. package/server/lib/guests/auth-store.test.js +112 -0
  81. package/server/lib/guests/builtins.js +34 -0
  82. package/server/lib/guests/builtins.test.js +174 -0
  83. package/server/lib/guests/catalog.js +466 -0
  84. package/server/lib/guests/catalog.test.js +390 -0
  85. package/server/lib/guests/clone.js +297 -0
  86. package/server/lib/guests/extract-zip.js +136 -0
  87. package/server/lib/guests/extract-zip.test.js +109 -0
  88. package/server/lib/guests/files.js +308 -0
  89. package/server/lib/guests/files.test.js +262 -0
  90. package/server/lib/guests/grant-scope.js +81 -0
  91. package/server/lib/guests/grant-scope.test.js +75 -0
  92. package/server/lib/guests/host-session.js +73 -0
  93. package/server/lib/guests/host-session.test.js +30 -0
  94. package/server/lib/guests/html-styles.js +6 -0
  95. package/server/lib/guests/html-styles.test.js +45 -0
  96. package/server/lib/guests/html-tokens.js +73 -0
  97. package/server/lib/guests/html-tokens.test.js +53 -0
  98. package/server/lib/guests/install.js +406 -0
  99. package/server/lib/guests/install.test.js +338 -0
  100. package/server/lib/guests/oauth.js +501 -0
  101. package/server/lib/guests/oauth.test.js +481 -0
  102. package/server/lib/guests/persist.js +336 -0
  103. package/server/lib/guests/persist.test.js +288 -0
  104. package/server/lib/guests/request.js +112 -0
  105. package/server/lib/guests/request.test.js +206 -0
  106. package/server/lib/guests/routes.js +838 -0
  107. package/server/lib/guests/service.js +538 -0
  108. package/server/lib/guests/service.test.js +277 -0
  109. package/server/lib/guests/sockets.js +129 -0
  110. package/server/lib/guests/sockets.test.js +110 -0
  111. package/server/lib/guests/ssh-install.test.js +188 -0
  112. package/server/lib/guests/storage.js +68 -0
  113. package/server/lib/guests/storage.test.js +59 -0
  114. package/server/lib/guests/updates.js +294 -0
  115. package/server/lib/guests/updates.test.js +334 -0
  116. package/server/lib/guests/upload.js +50 -0
  117. package/server/lib/guests/upload.test.js +131 -0
  118. package/server/lib/linear/DOCUMENTATION.md +1 -1
  119. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -0
  120. package/server/lib/openchamber-sessions/routes.js +44 -11
  121. package/server/lib/openchamber-sessions/routes.test.js +47 -0
  122. package/server/lib/opencode/DOCUMENTATION.md +40 -0
  123. package/server/lib/opencode/core-routes.js +39 -1
  124. package/server/lib/opencode/feature-routes-runtime.js +10 -0
  125. package/server/lib/opencode/lifecycle-process.test.js +84 -0
  126. package/server/lib/opencode/lifecycle.js +54 -67
  127. package/server/lib/opencode/settings-normalization-runtime.js +2 -0
  128. package/server/lib/opencode/settings-normalization-runtime.test.js +13 -0
  129. package/server/lib/opencode/settings-registry.json +4 -0
  130. package/server/lib/opencode/shutdown-runtime.js +3 -0
  131. package/server/lib/opencode/shutdown-runtime.test.js +24 -0
  132. package/server/lib/opencode/theme-archive.js +53 -0
  133. package/server/lib/opencode/theme-catalog.js +171 -0
  134. package/server/lib/opencode/theme-catalog.test.js +125 -0
  135. package/server/lib/opencode/theme-import.test.js +144 -0
  136. package/server/lib/opencode/theme-runtime.js +100 -28
  137. package/server/lib/opencode/theme-runtime.test.js +15 -0
  138. package/server/lib/quota/DOCUMENTATION.md +0 -1
  139. package/server/lib/quota/providers/index.js +0 -7
  140. package/server/lib/terminal/DOCUMENTATION.md +2 -0
  141. package/server/lib/terminal/runtime.js +17 -2
  142. package/server/lib/terminal/runtime.test.js +45 -0
  143. package/server/lib/ui-auth/ui-auth.js +43 -8
  144. package/server/lib/ui-auth/ui-auth.test.js +40 -0
  145. package/dist/assets/DiffView-GYriC0Wk.js +0 -4
  146. package/dist/assets/DirtyBranchSwitchDialog-Bv0C99hc.js +0 -1
  147. package/dist/assets/FilesView-2Lin13wx.js +0 -13
  148. package/dist/assets/GitView-9wKba3UO.js +0 -6
  149. package/dist/assets/LinearIssuesView-DXS9QJiR.js +0 -1
  150. package/dist/assets/MarkdownRendererImpl-CaMyct2Q.js +0 -12
  151. package/dist/assets/PlanView-DiTBm2BD.js +0 -5
  152. package/dist/assets/SettingsView-CN8VeM99.js +0 -28
  153. package/dist/assets/SettingsWindow-DisOghhD.js +0 -1
  154. package/dist/assets/ToolOutputDialog-BqiKydxR.js +0 -15
  155. package/dist/assets/appThemeRegistry-BK0dHKa6.js +0 -1
  156. package/dist/assets/de-DQWC94VK.js +0 -10
  157. package/dist/assets/es-DixFUD3m.js +0 -16
  158. package/dist/assets/fr-D6u8tvfA.js +0 -14
  159. package/dist/assets/index-BvpFzhLs.js +0 -40
  160. package/dist/assets/index-n5p3SnES.css +0 -1
  161. package/dist/assets/ja-4u4pCorB.js +0 -16
  162. package/dist/assets/ko-C27-LW_b.js +0 -16
  163. package/dist/assets/main-tEA-fFPg.js +0 -930
  164. package/dist/assets/pl-FtCjsNdW.js +0 -16
  165. package/dist/assets/registerCustomTheme-BBXUCRnG.js +0 -1
  166. package/dist/assets/renderElectronMiniChatApp-CuHOGlF4.js +0 -2
  167. package/dist/assets/renderMobileApp-C4X_KUH8.js +0 -25
  168. package/dist/assets/runtimeEndpointReset-CMg-KUx3.js +0 -41
  169. package/dist/assets/shikiHighlight-DdKWYWrV.js +0 -1
  170. package/dist/assets/tr-D2j6wUez.js +0 -7
  171. package/dist/assets/uk-C6IzmwM_.js +0 -16
  172. package/dist/assets/useGitComparison-BIaI0WZI.js +0 -1
  173. package/dist/assets/useInlineCommentController-2wcCtpM3.js +0 -2
  174. package/dist/assets/useRootScrollLock-CbWA03xR.js +0 -1
  175. package/dist/assets/vendor-framer-motion-livSKyyV.js +0 -1
  176. package/dist/assets/zh-CN-Wl6tIDz1.js +0 -16
  177. package/dist/assets/zh-TW-hgphoWSN.js +0 -16
  178. package/server/lib/quota/providers/crof.js +0 -96
  179. package/server/lib/quota/providers/crof.test.js +0 -98
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-2wcCtpM3.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-BmtfVbo8.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -0,0 +1,4 @@
1
+ import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as ae,O as Ce,a as Re,G as Fn}from"./index-Dy8xgawx.js";import{c as Dn,b as An,u as Vn,a as En,B as Ln,C as Tn,P as Tt,h as Mn,e as Bn,g as Pn,i as In,f as zn}from"./patchFileDiff-BvU6KOQC.js";import{c as On,b as _n,i as Kn,u as Gn,a as Hn,d as $n,S as qn}from"./SubmoduleDiffSummary--YFqK6Ih.js";import{f as ze,B as fe,I as L,h as je,Z as $t,af as Wn,K as ne,ag as Un,bf as Jn,J as Xn,ah as Yn,aj as Qn,z as Mt,k as Zn,d6 as qt,t as Je,kb as es,aw as Xe,aa as ts,ab as ns,ac as ss,k1 as Wt,kc as rs,ax as Ut,gy as is,au as Ue,av as os,c4 as Jt,aq as as,as as ls,at as cs,ap as us}from"./useAppFontEffects-hfv2s6mZ.js";import{f as ds,d as fs}from"./runtimeEndpointReset-BULHvOwb.js";import{P as ms}from"./PierreDiffViewer-53Ghfnlr.js";import{u as ps,v as hs,g as gs,W as xs}from"./main-BOYSXfYn.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-DCXjBGRf.js";import"./web-components-U-hWbgJo.js";import"./computeVirtualFileMetrics-DHgQIkUq.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-D9faP70y.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-B-fwE8r3.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BmtfVbo8.js";import"./appThemeRegistry-DDROzcUO.js";import"./textMateThemeFromAppTheme-Da7ed8qM.js";import"./useRootScrollLock-Cwc4kSl2.js";import"./scheduledTasksApi-DW3xqMQ8.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const ys=i.memo(function(e){const s=Ye.c(13),{index:u,staged:g,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=ze();let c;s[0]!==g?(c=g?["unstage"]:["discard","stage"],s[0]=g,s[1]=c):c=s[1];const w=c;let R;s[2]===Symbol.for("react.memo_cache_sentinel")?(R={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=R):R=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(y=>{const K=C(y==="stage"?"diffView.hunk.stageTitle":y==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),I=m?.index===u&&m.action===y;return t.jsx(fe,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",y==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",y==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:K,"aria-label":K,onPointerDown:ws,onClick:f=>{f.stopPropagation(),j(u,y)},children:t.jsx(L,{name:I?"loader-4":y==="stage"?"add":"arrow-go-back",className:je(y==="stage"?"size-4":"size-3.5",I&&"animate-spin")})},y)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let T;return s[10]!==u||s[11]!==d?(T=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:R,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=T):T=s[12],T});function ws(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const g=s??u;return g?{path:g.path,topOffset:g.top-o}:null},bs=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Pt=o=>{if(!o)return null;const e=o.split(`
2
+ `);let s=null;for(const u of e){const g=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(g){const m=Number.parseInt(g[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},js=1100,vs=15e3,It=500,zt=300,Xt=1e6,yt=3,Ss=o=>o<=6?o:o<=12?6:o<=25?4:2,Ot={status:"loading"},Ns=3,ks=i.memo(()=>{const o=Ye.c(4),{t:e}=ze();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Cs=Yt.M,Rs=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=Rs(o);return Yt[e]??Cs},Fs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Kt=o=>!!o.working_dir?.trim()||o.index==="?",Ds=(o,e)=>is(o,e),Gt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Ht=(o,e)=>{const s=o.split(`
3
+ `),u=e.split(`
4
+ `),g=Math.min(s.length,u.length);for(let m=0;m<g;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},As=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Vs=o=>o==="added"?"A":o==="deleted"?"D":"M",wt=(o,e,s)=>In(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:zn(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,g=e??0;return!u&&!g?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,g?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",g]}):null]})},Es=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:g,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:R}=o,{t:d}=ze(),[T,y]=i.useState(!1),K=s==="pr"?C??0:s==="staged"?g:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let I;e[0]!==s||e[1]!==d?(I=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=I):I=e[2];const f=I;let me;e[3]!==d?(me=d("diffView.scope.selectorAria"),e[3]=d,e[4]=me):me=e[4];let pe;e[5]!==K?(pe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",K]}),e[5]=K,e[6]=pe):pe=e[6];let te;e[7]!==f||e[8]!==pe?(te=t.jsxs("span",{className:"whitespace-nowrap",children:[f,pe]}),e[7]=f,e[8]=pe,e[9]=te):te=e[9];let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=t.jsx(L,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=k):k=e[10];let V;e[11]!==me||e[12]!==te?(V=t.jsx(as,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":me,children:[te,k]})}),e[11]=me,e[12]=te,e[13]=V):V=e[13];let v;e[14]!==R?(v=Q=>{(Q==="working"||Q==="staged"||Q==="turn"||Q==="branch"||Q==="commit"||Q==="pr")&&(R?.(Q),y(!1))},e[14]=R,e[15]=v):v=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let J;e[18]!==se?(J=t.jsx("span",{children:se}),e[18]=se,e[19]=J):J=e[19];let le;e[20]!==u?(le=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=le):le=e[21];let re;e[22]!==le||e[23]!==J?(re=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[J,le]})}),e[22]=le,e[23]=J,e[24]=re):re=e[24];let ce;e[25]!==d?(ce=d("diffView.scope.staged"),e[25]=d,e[26]=ce):ce=e[26];let X;e[27]!==ce?(X=t.jsx("span",{children:ce}),e[27]=ce,e[28]=X):X=e[28];let $;e[29]!==g?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:g}),e[29]=g,e[30]=$):$=e[30];let ue;e[31]!==X||e[32]!==$?(ue=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[X,$]})}),e[31]=X,e[32]=$,e[33]=ue):ue=e[33];let M;e[34]!==d?(M=d("diffView.scope.lastTurn"),e[34]=d,e[35]=M):M=e[35];let D;e[36]!==M?(D=t.jsx("span",{children:M}),e[36]=M,e[37]=D):D=e[37];let q;e[38]!==m?(q=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=q):q=e[39];let G;e[40]!==D||e[41]!==q?(G=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[D,q]})}),e[40]=D,e[41]=q,e[42]=G):G=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let Y;e[47]!==j||e[48]!==c||e[49]!==d?(Y=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=Y):Y=e[50];let E;e[51]!==C||e[52]!==c||e[53]!==d?(E=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=E):E=e[54];let W;e[55]!==s||e[56]!==re||e[57]!==ue||e[58]!==G||e[59]!==de||e[60]!==Y||e[61]!==E||e[62]!==v?(W=t.jsx(ls,{align:"start",className:"w-40",children:t.jsxs(cs,{value:s,onValueChange:v,children:[re,ue,G,de,Y,E]})}),e[55]=s,e[56]=re,e[57]=ue,e[58]=G,e[59]=de,e[60]=Y,e[61]=E,e[62]=v,e[63]=W):W=e[63];let ve;return e[64]!==T||e[65]!==W||e[66]!==V?(ve=t.jsxs(us,{open:T,onOpenChange:y,children:[V,W]}),e[64]=T,e[65]=W,e[66]=V,e[67]=ve):ve=e[67],ve}),Ls=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:g}=o,{t:m}=ze();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==g||e[2]!==u||e[3]!==m){let C;e[5]!==g||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),R=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>g(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",R?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=g,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=g,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Ts=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:g}=o,{t:m}=ze(),x=u.original.length>0,j=u.modified.length>0,C=g?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=g?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let R;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==g||e[6]!==m?(R=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=g,e[6]=m,e[7]=R):R=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==g||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:g?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=g,e[14]=m,e[15]=d):d=e[15];let T;return e[16]!==C||e[17]!==R||e[18]!==d?(T=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[R,d]})}),e[16]=C,e[17]=R,e[18]=d,e[19]=T):T=e[19],T}),Ms=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,staged:g,renderSideBySide:m,wrapLines:x,hunkActions:j}=o;let C;e[0]!==s?(C=os(s)||"text",e[0]=s,e[1]=C):C=e[1];const c=C;if(u.submodule){let d;return e[2]!==u.submodule||e[3]!==g?(d=t.jsx(qn,{state:u.submodule,staged:g}),e[2]=u.submodule,e[3]=g,e[4]=d):d=e[4],d}if(u.isBinary){let d;return e[5]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(ks,{}),e[5]=d):d=e[5],d}if(Xe(s)){let d;return e[6]!==u||e[7]!==s||e[8]!==m?(d=t.jsx(Ts,{filePath:s,diff:u,renderSideBySide:m}),e[6]=u,e[7]=s,e[8]=m,e[9]=d):d=e[9],d}let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[10]=w):w=e[10];let R;return e[11]!==u.fileDiff||e[12]!==u.modified||e[13]!==u.original||e[14]!==s||e[15]!==j||e[16]!==c||e[17]!==m||e[18]!==x?(R=t.jsx("div",{className:"w-full",style:w,children:t.jsx(ms,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:c,fileName:s,renderSideBySide:m,wrapLines:x,layout:"inline",hunkActions:j})}),e[11]=u.fileDiff,e[12]=u.modified,e[13]=u.original,e[14]=s,e[15]=j,e[16]=c,e[17]=m,e[18]=x,e[19]=R):R=e[19],R}),Bs=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:g,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:R=!1,isOpeningInEditor:d=!1,onOpenInEditor:T,staged:y=!1,loadFullFiles:K=!1,initialDiffData:I=null,comparisonDiff:f,onRetryComparisonDiff:me,readOnlyActions:pe=!1,hunkActionsEnabled:te=!1})=>{const{t:k}=ze(),{git:V}=$t(),v=ne(i.useCallback(h=>h.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),se=ne(h=>h.setDiff),J=ne(h=>h.fetchStatus),le=ae(h=>h.setDiffFileLayout),[re,ce]=i.useState(0),[X,$]=i.useState(null),[ue,M]=i.useState(!1),D=i.useMemo(()=>f?f.status==="error"?{kind:"error",message:f.message}:null:X,[f,X]),q=f?f.status==="loading":ue,[G,de]=i.useState(null),Y=i.useRef(!1),[E,W]=i.useState(null),[ve,Q]=i.useState(!1),[ie,Qe]=i.useState(null),[lt,Fe]=i.useState(null),he=i.useRef(null),mt=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),_e=u==="side-by-side",De=K?"full":"patch",ge=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=te&&!pe&&!I&&!f&&!Xe(s.path),xe=JSON.stringify([Re(),e,s.path,y,ge,re]),z=E?.scope===xe?E.patch:null,Ze=E?.scope===xe?E.submodule:null,U=i.useMemo(()=>f?f.status==="ready"?f.data:null:I||(y?lt:ie||(v?{original:v.original,modified:v.modified,isBinary:v.isBinary,submodule:v.submodule,contextMode:"full"}:null)),[f,v,I,ie,y,lt]),et=U?.contextMode===De,tt=i.useCallback(h=>{mt.current=h,w(s.path,h)},[s.path,w]),nt=i.useCallback(h=>{c(s.path,h)},[s.path,c]),st=i.useCallback(()=>{C(s.path)},[s.path,C]),rt=i.useRef({fileStatusKey:ge,staged:y});i.useEffect(()=>{if(!o)return;const h=rt.current;h.fileStatusKey===ge&&h.staged===y||(rt.current={fileStatusKey:ge,staged:y},y?Fe(null):Qe(null),$(null),he.current=null)},[ge,y,o]),i.useEffect(()=>{if(!o||!x||!j||X)return;if(!e||f||I||U&&et&&(!a||z!==null)){he.current=null,M(!1);return}const h=`${e}::${s.path}::${y?"staged":"unstaged"}::${ge}::${De}::${re}`;if(he.current===h)return;he.current=h,$(null),M(!0);let O=!1;const ye=Re(),Ge=K?Xt:yt,Z=Xe(s.path)?V.getGitFileDiff(e,{path:s.path,staged:y}):!K&&z!==null?Promise.resolve({diff:z,submodule:Ze}):V.getGitDiff(e,{path:s.path,staged:y,contextLines:Ge}),Ve=a&&K&&z===null?V.getGitDiff(e,{path:s.path,staged:y,contextLines:yt}).then(S=>S.diff):Promise.resolve(z),Pe=Promise.all([Z,Ve]),we=vs;let _;const Ee=new Promise((S,He)=>{_=setTimeout(()=>He(new Error(`Timed out after ${we}ms`)),we)});return Promise.race([Pe,Ee]).then(([S,He])=>{if(O||ye!==Re())return;const be="diff"in S&&!K?S.diff:He;if(a&&K&&be!==null&&/^@@\s/m.test(be)&&"diff"in S&&S.diff!==be&&!Mn(S.diff,be))throw W(null),new Error(k("diffView.hunk.unavailable"));if(a&&be!==null&&W({scope:xe,patch:be,submodule:S.submodule}),"diff"in S){const Ne={...wt(s.path,S.diff,De),submodule:S.submodule};y?Fe(Ne):Qe(Ne)}else{const Ne={original:S.original??"",modified:S.modified??"",isBinary:S.isBinary,submodule:S.submodule,contextMode:"full"};y?Fe(Ne):se(e,s.path,Ne,ye)}M(!1)}).catch(S=>{if(!(O||ye!==Re())){if(M(!1),S instanceof Fn){$({kind:"unavailable",reason:S.reason}),S.reason==="path_not_found"&&J(e,V,{force:!0,silent:!0});return}$({kind:"error",message:S instanceof Error?S.message:String(S)})}}).finally(()=>clearTimeout(_)),()=>{O=!0,clearTimeout(_),he.current===h&&(he.current=null)}},[z,Ze,a,xe,f,De,U,et,re,e,J,s.path,ge,V,I,x,j,K,X,se,y,k,o]);const ct=i.useCallback(()=>{nt(!x),st()},[nt,st,x]),Ae=i.useCallback(()=>{$(null),W(null),Qe(null),Fe(null),he.current=null,ce(h=>h+1)},[]),Se=i.useCallback(async(h,O)=>{if(!e||!a||q||D||Y.current||G!==null)return;const ye=z?Bn(z,h):null;if(!ye){Je.error(k("diffView.hunk.unavailable"));return}if(y&&O!=="unstage"||!y&&O==="unstage")return;Y.current=!0;const Ge=Re();de({index:h,action:O});try{const Z=O==="stage"?V.stageGitHunk:O==="unstage"?V.unstageGitHunk:V.revertGitHunk;if(!Z){Je.error(k("diffView.hunk.unsupported"));return}if(await Z(e,s.path,ye),Ge!==Re())return;Ae(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await J(e,V)}catch(Z){if(Ge!==Re())return;Ae(),Je.error(Z instanceof Error&&Z.message?Z.message:k("diffView.hunk.unavailable"))}finally{Y.current=!1,de(Z=>Z?.index===h&&Z.action===O?null:Z)}},[z,a,q,D,e,J,s.path,V,G,Ae,y,k]),Be=i.useMemo(()=>a&&z!==null?Pn(z):[],[z,a]),Ke=i.useCallback(h=>t.jsx(ys,{index:h,staged:y,busyHunk:G,disabled:q||!!D,onAction:Se}),[D,Se,G,q,y]),it=i.useMemo(()=>Be.length>0?{anchors:Be,render:Ke}:void 0,[Be,Ke]);return t.jsxs("div",{ref:tt,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:ct,onKeyDown:h=>{h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),ct())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(L,{name:"arrow-down-s",className:"size-4"}):t.jsx(L,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:k(Oe.descriptionKey),"aria-label":k(Oe.descriptionKey),children:Oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const h=s.path.lastIndexOf("/");if(h===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const O=s.path.slice(0,h),ye=s.path.slice(h+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:O}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ye})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),R&&T?t.jsx(fe,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:k("diffView.actions.openFileInEditorAtChange"),onClick:h=>{h.stopPropagation(),T(s.path,U)},disabled:d,children:d?t.jsx(L,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(L,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:_e?"side-by-side":"unified",onModeChange:h=>{const O=h==="side-by-side"?"side-by-side":"inline";le(s.path,O)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!D?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,D?.kind==="unavailable"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryTitle"):k("diffView.unavailable.missingTitle")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.reason==="nested_repository"?k("diffView.unavailable.nestedRepositoryDescription"):k("diffView.unavailable.missingDescription")}),D.reason==="path_not_found"?t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:Ae,children:k("diffView.actions.retry")}):null]}):null,D?.kind==="error"?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:D.message}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?me?.():Ae(),children:k("diffView.actions.retry")})]}):null,j&&q&&!U&&!D?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),k("diffView.state.loadingDiff")]}):null,j&&U&&!ve&&s.insertions+s.deletions>It?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:k("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:k("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Q(!0),children:k("diffView.actions.renderAnyway")})]}):null,j&&U&&(ve||s.insertions+s.deletions<=It)?t.jsx(t.Fragment,{children:t.jsx(Ms,{filePath:s.path,diff:U,staged:y,renderSideBySide:_e,wrapLines:g,hunkActions:it})}):null]})]})}),eo=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:g=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=ze(),{git:w,files:R}=$t(),d=Wn(),T=ne(n=>n.runtimeKey),{rootIsGitRepo:y,gitDirectory:K,nestedRepos:I}=Un(d??null,{enabled:o}),f=K??d,me=ae(n=>n.openContextSurface),pe=ps(n=>n.requestSource),{screenWidth:te,isMobile:k}=Jn(),V=Xn(f??null),v=Yn(f??null),se=Qn(f??null),J=ne(n=>n.setActiveDirectory),le=ne(n=>n.ensureStatus),re=ne(n=>n.selectNestedRepo),ce=ne(n=>n.fetchStatus),X=ne(n=>n.fetchBranches),$=ne(n=>n.clearDiffCache),ue=ne(n=>n.setDiff),[M,D]=i.useState(null),[q,G]=i.useState(!1),[de,Y]=i.useState(null),[E,W]=i.useState(()=>new Set),[ve,Q]=i.useState(()=>new Set),[ie,Qe]=i.useState(!1),[lt,Fe]=i.useState(0),[he,mt]=i.useState(()=>new Map),[Oe,_e]=i.useState(!1),[De,ge]=i.useState(!1),[a,xe]=i.useState(m);i.useEffect(()=>{xe(m)},[m]);const z=ae(n=>n.pendingDiffFile),Ze=ae(n=>n.pendingDiffStaged),U=ae(n=>n.pendingDiffScope),et=ae(n=>n.setPendingDiffFile),tt=ae(n=>n.diffLayoutPreference),nt=ae(n=>n.diffFileLayout),st=ae(n=>n.setDiffFileLayout),rt=ae(n=>n.diffWrapLines),ct=ae(n=>n.setDiffWrapLines),Ae=ae(n=>n.openContextFileAtLine),Se=Mt(n=>n.currentSessionId),Be=Zn(a==="turn"?Se??"":"",d??void 0),Ke=rt,it=a==="staged"?!0:a==="working"?!1:null,h=it??q,O=k||te<=768,ye=!!Se&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!O&&!Ce(),Ge=a!=="turn"&&!O&&!Ce(),Z=!e&&!O&&te>=1024,Ve=i.useRef(null),Pe=i.useRef(new Map),we=i.useRef(null),_=i.useRef(null),Ee=i.useRef(!1),S=i.useRef(null),He=i.useRef(null),be=i.useRef(null),Ne=i.useRef(null),bt=i.useCallback(()=>{const n=Ve.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,b]of Pe.current)b&&l.push({path:p,top:b.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{we.current=null,Ee.current=!1,Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)},[]),qe=i.useCallback(n=>{W(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),ot=i.useMemo(()=>{for(let n=Be.length-1;n>=0;n-=1){const r=Be[n];if(r.role==="user")return As(r.summary?.diffs)}return[]},[Be]),en=i.useMemo(()=>{const n=new Map;for(const r of ot)if(r.file){if(typeof r.patch=="string"){n.set(r.file,wt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[ot]),tn=i.useMemo(()=>v?.files?v.files.filter(Kt).length:0,[v]),nn=i.useMemo(()=>v?.files?v.files.filter(_t).length:0,[v]),sn=ot.length,H=v?.current??null,Le=Dn(f??null,H,o&&a==="pr"&&!Ce()),Te=Le.selectedSource,Me=An(f??null,H,o&&a==="commit"&&!Ce()),Ie=Me.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Ce()&&(xe("working"),x?.("working"))},[a,x]);const We=ne(n=>f?n.directories.get(f)?.branches??null:null),rn=ne(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&X(f,w)},[f,X,w]),an=On(f??null,o&&V!==!1,rn,!!We,on,Ns),jt=i.useMemo(()=>{const n=v?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,v?.tracking]),vt=!Ce()&&_n(H,jt),ln=v!==null,St=Ce()||an||Kn(H,jt,ln,We!==null),cn=Vn(n=>n.setOverride),{base:ke,resolved:un,revision:Nt}=En(f??null,H,o&&vt&&a==="branch"),[dn,fn]=i.useState(0);i.useEffect(()=>{const n=$n(a,!St);n!==a&&(xe(n),n==="working"&&x?.("working"))},[a,St,x]);const mn=i.useMemo(()=>a==="pr"?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:null,[a,ke,H,Ie,Te]),A=Gn(f??null,mn,o&&!Ce(),a==="branch"?Nt:""),{fetchDiff:kt}=A,Ct=a==="commit"?A.files:null,Rt=a==="commit"?A.error:null,ut=a==="branch"?A.files:null,Ft=a==="branch"?A.error:null,Dt=A.files?a==="pr"?JSON.stringify([A.key,A.revision]):A.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(E).sort().join("\0"):"",[a,E]),hn=i.useCallback(async n=>{try{const r=ie&&a!=="pr",l=await kt(n,r?Xt:yt);return{status:"ready",data:wt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,kt,ie,c]),gn=Hn(Dt,o?pn:"",Dt?hn:null,Ot,JSON.stringify([a==="branch"?Nt:"",a==="pr"?A.revision:0,dn,ie])),xn=ut?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(A.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(ut??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return ot.map(l=>({path:l.file??"",index:"",working_dir:Vs(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!v?.files)return[];const n=v.diffStats??{},r=a==="staged"?_t:a==="working"?Kt:()=>!0;return v.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Fs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,ut,A.files,ot,v]),pt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=pt?pt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=He.current!==l;He.current=l,W(b=>{if(p){const P=s?0:Ss(n.length);return new Set(n.slice(0,P))}let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b}),Q(b=>{if(p)return new Set;let B=!1;const F=new Set;for(const P of b){if(!r.has(P)){B=!0;continue}F.add(P)}return B?F:b})},[a,pt,f,s]);const At=i.useCallback(()=>{if(S.current=null,!o)return;const n=Ve.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-zt,p=r.bottom+zt,b={},B=[];for(const[F,P]of Pe.current){if(!P)continue;const ee=P.getBoundingClientRect();B.push({path:F,top:ee.top}),E.has(F)&&(ee.bottom<l||ee.top>p||(b[F]=!0))}be.current=Bt(r.top,B),Q(F=>{let P=!1;const ee=new Set(F);for(const at of Object.keys(b))ee.has(at)||(ee.add(at),P=!0);return P?ee:F})},[E,o]),oe=i.useCallback(()=>{o&&(typeof window>"u"||S.current===null&&(S.current=window.requestAnimationFrame(At)))},[At,o]);i.useEffect(()=>{const n=Ve.current;if(!(!o||!n))return oe(),n.addEventListener("scroll",oe,{passive:!0}),window.addEventListener("resize",oe),()=>{n.removeEventListener("scroll",oe),window.removeEventListener("resize",oe),S.current!==null&&(window.cancelAnimationFrame(S.current),S.current=null)}},[N,E,oe,o]);const ht=i.useCallback(n=>{const r=nt[n.path];if(r)return r;if(tt==="inline")return"inline";if(tt==="side-by-side")return"side-by-side";const l=te<js;return n.isNew||l?"inline":"side-by-side"},[nt,tt,te]),Vt=i.useMemo(()=>N.length===0?null:N.every(n=>ht(n)==="side-by-side")?"side-by-side":"inline",[N,ht]);i.useEffect(()=>{o&&f&&(J(f),le(f,w))},[f,J,le,w,o]);const dt=JSON.stringify([T,f]),gt=i.useRef({scope:dt,paths:new Set,dirty:!1}),Et=i.useRef(o);i.useEffect(()=>{const n=o&&!Et.current;if(Et.current=o,gt.current.scope!==dt&&(gt.current={scope:dt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(Ne.current=bt()??be.current,$(f,p),mt(b=>{const B=new Map(b);for(const F of p)B.set(F,(B.get(F)??0)+1);return B})),ce(f,w,{silent:!0})},l=gt.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Gt(p.directory)===Gt(f)){if(!o){l.dirty=!0;for(const b of p.paths??[])l.paths.add(b);return}r(p.paths)}})},[bt,$,f,ce,w,dt,o]),i.useLayoutEffect(()=>{const n=Ne.current;if(!n)return;Ne.current=null;const r=Ve.current,l=Pe.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,b=l.getBoundingClientRect().top-p;r.scrollTop=bs(r.scrollTop,n.topOffset,b,r.scrollHeight-r.clientHeight),be.current=n},[he]),i.useEffect(()=>{!o||a!=="all"&&!U||z&&(U&&xe(U),D(z),G(U==="staged"||!U&&Ze),et(null),Ee.current=!0,we.current=z,qe(z),Fe(n=>n+1))},[a,qe,z,U,Ze,et,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(D(n),G(a==="staged"),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!M)return;N.some(r=>r.path===M)||(D(null),G(!1))},[N,M]);const yn=i.useCallback((n,r)=>{const l=Pe.current;r?l.set(n,r):l.delete(n),oe()},[oe]),wn=i.useCallback((n,r)=>{$e(),W(l=>{const p=l.has(n);if(r===p)return l;const b=new Set(l);return r?b.add(n):b.delete(n),b}),r||Q(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),oe()},[$e,oe]),bn=i.useCallback(()=>{$e(),W(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),Q(new Set),oe()},[$e,N,oe]),jn=i.useCallback(async n=>{if(!Se)return;const r=Mt.getState().getDirectoryForSession(Se)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}ge(!0);try{await es({originalSessionID:Se,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),_e(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{ge(!1)}},[Se,d,c]),ft=i.useCallback(n=>{const r=Pe.current.get(n),l=Ve.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=we.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const b=(F=!0)=>{p||(p=!0,we.current=null,Ee.current=!1,F&&Y(null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null))},B=()=>{if(p){_.current=null;return}const F=we.current;if(!F){b(),_.current=null;return}if(!ft(F)){r+=1,r<l?_.current=window.requestAnimationFrame(B):(b(),_.current=null);return}if(u&&Ee.current){Y(F),b(!1);return}b()};return _.current=window.requestAnimationFrame(B),()=>{p=!0,_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[u,lt,ft,o]);const vn=i.useCallback(n=>{},[]),xt=i.useCallback(n=>{$e(),D(n),G(!1),Ee.current=!0,we.current=n,qe(n),Fe(r=>r+1),ft(n)},[$e,qe,ft]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,b=M?N.findIndex(P=>P.path===M):-1,B=b===-1?p>0?0:N.length-1:b+p,F=N[B];F&&(r.preventDefault(),xt(F.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,M,xt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{st(l.path,r)})},[N,st]),[Nn,Lt]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Lt(n);const l=Re();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=Pt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Ht(r.original,r.modified)),p===null)try{const ee=await w.getGitDiff(f,{path:n,staged:h,contextLines:3});p=Pt(ee.diff)}catch{p=null}let b=r;if(p===null||!b){const ee=await w.getGitFileDiff(f,{path:n,staged:h}),at={original:ee.original??"",modified:ee.modified??"",isBinary:ee.isBinary,submodule:ee.submodule};b=at,h||ue(f,n,at,l)}const B=p??(b.isBinary||Xe(n)?1:Ht(b.original,b.modified)),F=Ds(f,n),P=await hs(R,F,{directory:f});if(!P.ok){Je.error(gs(P.reason));return}Ae(f,F,B,1)}finally{Lt(p=>p===n?null:p)}},[h,f,R,w,Ae,ue]),Cn=()=>{if(!f)return null;const n=r=>it!==null?it:q&&r===M;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Z&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Ls,{changedFiles:N,selectedFile:null,onSelectFile:xt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Bs,{visible:o,directory:f,file:r,layout:ht(r),wrapLines:Ke,isSelected:!1,isExpanded:E.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:g&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:ie&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>fn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${Re()}:${f}:${r.path}:${he.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&se&&!v)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&V===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Te||A.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:A.error??Le.error??(Le.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(A.error||Le.error)&&t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{Te?A.refresh():Le.refresh()},children:c("diffView.actions.retry")}),!Te&&!Le.loading&&t.jsx(Tt,{comparison:Le})]});if(!A.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Rt}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(!Ie&&!Me.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Me.error??c("commitComparison.noCommits")});if(!Ct)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!ke)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(L,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Ft)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Ft}),t.jsx(fe,{variant:"outline",size:"sm",onClick:()=>{A.refresh()},children:c("diffView.actions.retry")})]});if(ut===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&ke?c("diffView.branch.empty",{base:fs(ke)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[y===!1&&Array.isArray(I)&&I.length>0?t.jsx(ds,{repositories:I,selectedRepository:K??null,onSelectRepository:n=>{d&&re(d,n)},repositoryRoot:d??void 0}):null,!k&&(a!=="all"?t.jsx(Es,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?Ct?.length??null:null,prCount:a==="pr"?A.files?.length??null:null,showCommitOption:!Ce(),showBranchOption:vt,onScopeChange:n=>{xe(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:se&&!v?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(Ln,{branches:We?.all??[],currentBranch:H,base:ke,onSelect:n=>{f&&H&&cn(f,H,n)}},JSON.stringify([f,H])),a==="commit"&&t.jsx(Tn,{commits:Me.commits,selectedHash:Ie,loading:Me.loading,error:Me.error,onSelect:Me.select,onRefresh:()=>{Me.refresh()}},JSON.stringify([f,H])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Le},JSON.stringify([T,f,H])),Te&&t.jsx(fe,{variant:"ghost",size:"sm",disabled:A.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{A.refresh()},children:t.jsx(L,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(fe,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(L,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&ye&&t.jsxs(fe,{variant:"default",size:"sm",onClick:()=>_e(!0),disabled:De,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[De?t.jsx(L,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(L,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&Ge&&t.jsxs(fe,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";pe(n,a==="pr"&&Te?Te:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&ke&&H?{kind:"branch",baseRef:ke,headRef:H}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),me(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",xs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(L,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(ts,{children:[t.jsx(ns,{asChild:!0,children:t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":ie,"aria-label":c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",ie&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(L,{name:"file-download",className:"size-4"})})}),t.jsx(ss,{children:t.jsx("p",{children:c(ie?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>ct(!rt),className:je("h-5 w-5 p-0 transition-opacity",Ke?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(Ke?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(L,{name:"text-wrap",className:"size-4"})}),Vt&&t.jsx(Wt,{mode:Vt==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(rs,{open:Oe,onOpenChange:_e,projectDirectory:f??null,submitting:De,onConfirm:jn}),Rn()]})};export{eo as DiffView,Bs as MultiFileDiffEntry};
@@ -0,0 +1 @@
1
+ import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,ax as Ee,aa as be,ab as ye,I as E,ac as we,h as J,B as Y,a5 as Te,jk as Ie,b_ as fe,b$ as ue,c0 as pe,c1 as ge,c2 as xe,c3 as ve,bf as Me,cm as Re,t as ae}from"./useAppFontEffects-hfv2s6mZ.js";import{u as ke}from"./index-Dy8xgawx.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Fe=Se.M;function Pe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function $e(p){const e=Pe(p);return Se[e]??Fe}const He=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=$e(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=Q(),$=u.description,F=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let H;t[7]!==a?(H=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=H):H=t[8];const W=H;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const P=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?P:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==$||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:$,"aria-label":$,children:u.code}),t[17]=u.code,t[18]=$,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Z;t[30]===Symbol.for("react.memo_cache_sentinel")?(Z={color:"var(--status-success)"},t[30]=Z):Z=t[30];let i;t[31]!==F?(i=s.jsxs("span",{style:Z,children:["+",F]}),t[31]=F,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:P;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Ze=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=Q(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),$=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),F=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from($[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[$,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(F);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),F.forEach(m=>n.add(m)),n})},[f,F]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe($[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,$,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),H=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice(H,H+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,H]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),P=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=P.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||P.length===0||(await g(P),c(!1))},[P,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx(He,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Z=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(Z(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:J("relative",Z(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=Q(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const H=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const P=y.scrollHeight,X=Math.min(Math.max(P,he),re);y.style.height=`${X}px`,y.style.overflowY=P>re?"auto":"hidden",P>re&&!H&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",$=S?"sentences":"off",F=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==$||e[15]!==F||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:$,spellCheck:F,className:z,style:T}),e[13]=h,e[14]=$,e[15]=F,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=Q();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Je=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=Q(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:$}=Me();let F;e[5]!==o?(F=o("gitView.commit.title"),e[5]=o,e[6]=F):F=e[6];let A;e[7]!==F?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:F}),e[7]=F,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let H;e[22]!==o?(H=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=H):H=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==$||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==H?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:H,disabled:W,hasTouchInput:$,isMobile:I}),e[24]=r,e[25]=$,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=H,e[31]=L):L=e[31];let P;e[32]!==V||e[33]!==k||e[34]!==o?(P=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=P):P=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Z=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Z||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Z,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Z,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==P||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,P,D]}),e[72]=L,e[73]=P,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Qe=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=Q(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Ze as C,Qe as D,Je as a};
@@ -0,0 +1,13 @@
1
+ import{f as ut,R as s,c as ei,j as n,r as ct}from"./vendor-react-BUCujlKS.js";import{Y as Ua,Z as qa,_ as Ka,$ as Ha,v as Ye,a as lt,u as wt,dO as Ga,I as ti,B as Xa,h as ri,a4 as ni,e as Ja,dM as Ya,a3 as Za,dN as Qa}from"./index-Dy8xgawx.js";import{f as tr,z as si,af as Si,cb as eo,h as K,jR as to,g0 as ro,W as gr,B as I,I as F,Z as no,S as so,bf as io,K as ao,ah as oo,cw as lo,eM as ii,jS as ai,jT as co,i2 as uo,gc as fo,t as J,l as oi,av as Cn,cp as pr,d6 as mo,b as po,jU as hr,bZ as ho,aw as Sn,jV as li,cq as ci,cr as ui,h4 as go,jW as vo,jX as xo,jY as wo,b_ as Ri,b$ as ki,c0 as Ti,c1 as Ei,c2 as Vi,c3 as Pi,ap as Pn,aq as Mn,ax as Gr,as as Dn,bd as Xr,c4 as Rn,ay as kn,cl as di,aa as Xt,ab as Jt,ac as Yt,bX as bo,bY as yo,g as Yr,be as jo,cv as Fo}from"./useAppFontEffects-hfv2s6mZ.js";import{ag as No,R as Co,V as So,W as Ro,X as ko,Y as To}from"./runtimeEndpointReset-BULHvOwb.js";import{c as fi,s as Eo,P as Tn,C as Vo}from"./shikiHighlight-DsxD9QEa.js";import{a as Po}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Tt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as Mo,J as Do,F as zo}from"./JsonTreeView-D_4G5X6-.js";import{ensurePierreThemeRegistered as mi,getResolvedShikiTheme as Lo}from"./appThemeRegistry-DDROzcUO.js";import{V as Ao,W as Io}from"./Virtualizer-CZlLSacm.js";import{V as Oo}from"./Virtualizer-D_a8gKmg.js";import{a as Bo,u as qr,b as $o,g as _o,h as Wo,i as Uo}from"./scheduledTasksApi-DW3xqMQ8.js";import{D as qo}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Ko,u as Ho,n as Go}from"./useInlineCommentController-BmtfVbo8.js";import{b as Xo}from"./CodeMirrorCommentWidgets-C9kV-n7r.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-fZppILAM.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-CsXYnR5c.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BPMJpOpT.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./GuestAttachDialog-B-fwE8r3.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-U-hWbgJo.js";import"./computeVirtualFileMetrics-DHgQIkUq.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-6qOcz5Ky.js";import"./textMateThemeFromAppTheme-Da7ed8qM.js";function pi(i){const e=ut.c(41),{containerRef:r,filePath:o,fileContent:w}=i,{t:h}=tr(),b=si(nl),x=si(rl),v=Si(),m=eo(tl),[f,j]=s.useState(null),[N,k]=s.useState(""),[S,E]=s.useState(!1),y=s.useRef(!1),c=s.useRef(null),M=s.useRef(null),[T,D]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{j(null),k(""),E(!1),y.current=!1,M.current=null,D(null)},e[0]=P):P=e[0];const V=P;let R,L;e[1]!==r?(R=()=>{const q=r.current;if(!q)return;const X=()=>{if(y.current)return;const re=window.getSelection(),ge=re?.toString().trim()??"";if(!re||!ge||re.rangeCount===0){V();return}const ne=re.getRangeAt(0);if(!q.contains(ne.commonAncestorContainer)){V();return}const Q=ne.getBoundingClientRect();M.current=ne.cloneRange(),k(ge),j({x:Q.left+Q.width/2,y:Q.top-10})},_=re=>{c.current?.contains(re.target)||y.current&&V()};return document.addEventListener("selectionchange",X),document.addEventListener("pointerdown",_),()=>{document.removeEventListener("selectionchange",X),document.removeEventListener("pointerdown",_)}},L=[r,V],e[1]=r,e[2]=R,e[3]=L):(R=e[2],L=e[3]),s.useEffect(R,L);let B;e[4]!==w?(B=q=>{const X=fe=>w.slice(0,fe).split(`
2
+ `).length,_=Qo,re=(fe,xe)=>{for(const ke of _(fe)){const Ue=w.indexOf(ke,xe);if(Ue>=0)return Ue}return-1},ge=q.length>=8?w.indexOf(q):-1;if(ge>=0){const fe=X(ge);return{start:fe,end:fe+q.split(`
3
+ `).length-1}}const ne=q.split(`
4
+ `).map(Zo).filter(Boolean);if(ne.length===0)return null;const Q=re(ne[0],0);if(Q<0)return null;const ye=X(Q);if(ne.length===1)return{start:ye,end:ye};const ve=re(ne[ne.length-1],Q);return ve<0?null:{start:ye,end:Math.max(ye,X(ve))}},e[4]=w,e[5]=B):B=e[5];const $=B;let ue;e[6]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{const q=M.current;if(!q){D(null);return}D(to(q))},e[6]=ue):ue=e[6];const de=ue;let Y,Z;e[7]!==S?(Y=()=>{if(!S)return;let q=null;const X=()=>{q===null&&(q=window.requestAnimationFrame(()=>{q=null,de()}))};return document.addEventListener("scroll",X,{capture:!0,passive:!0}),window.addEventListener("resize",X),()=>{q!==null&&window.cancelAnimationFrame(q),document.removeEventListener("scroll",X,{capture:!0}),window.removeEventListener("resize",X)}},Z=[S,de],e[7]=S,e[8]=Y,e[9]=Z):(Y=e[8],Z=e[9]),s.useEffect(Y,Z);let ae;e[10]!==N?(ae=()=>{N&&(E(!0),y.current=!0,de(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ae):ae=e[11];const pe=ae;let oe;e[12]!==m||e[13]!==b||e[14]!==v||e[15]!==o||e[16]!==x||e[17]!==$||e[18]!==N?(oe=q=>{const X=b??(x?"draft":null);if(!N||!X||!v){V();return}const _=$(N);m({directory:v,sessionKey:X},{source:"file-quote",fileLabel:o,startLine:_?.start??0,endLine:_?.end??0,code:N,language:"",text:q.trim()}),V(),queueMicrotask(Yo)},e[12]=m,e[13]=b,e[14]=v,e[15]=o,e[16]=x,e[17]=$,e[18]=N,e[19]=oe):oe=e[19];const H=oe;if(!f)return null;let G;e[20]!==S||e[21]!==$||e[22]!==N?(G=S?$(N):null,e[20]=S,e[21]=$,e[22]=N,e[23]=G):G=e[23];const We=G;let te;e[24]!==f.x||e[25]!==f.y?(te={left:f.x,top:f.y,transform:"translate(-50%, -100%)"},e[24]=f.x,e[25]=f.y,e[26]=te):te=e[26];let he;e[27]!==S||e[28]!==T?(he=S&&T&&T.length>0?ei.createPortal(n.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:T.map(Jo)}),document.body):null,e[27]=S,e[28]=T,e[29]=he):he=e[29];let Me;e[30]!==S||e[31]!==o||e[32]!==We||e[33]!==pe||e[34]!==H||e[35]!==h?(Me=S?n.jsx("div",{className:"w-[min(420px,80vw)]",children:n.jsx(Ko,{fileLabel:o,lineRange:We?{start:We.start,end:We.end}:void 0,onSave:H,onCancel:V})}):n.jsx("div",{className:K("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:n.jsx("button",{type:"button",onClick:pe,className:K("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-foreground","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:h("chat.textSelection.title.commentOnSelection"),children:h("chat.textSelection.actions.comment")})}),e[30]=S,e[31]=o,e[32]=We,e[33]=pe,e[34]=H,e[35]=h,e[36]=Me):Me=e[36];let be;return e[37]!==te||e[38]!==he||e[39]!==Me?(be=ei.createPortal(n.jsxs("div",{ref:c,className:"fixed z-50",style:te,children:[he,Me]}),document.body),e[37]=te,e[38]=he,e[39]=Me,e[40]=be):be=e[40],be}function Jo(i,e){return n.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:i.left,top:i.top,width:i.width,height:i.height}},e)}function Yo(){ro()}function Zo(i){return i.trim()}function Qo(i){const e=i.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(el)}function el(i){return i.length>=8}function tl(i){return i.addDraft}function rl(i){return i.newSessionDraft?.open}function nl(i){return i.currentSessionId}const sl=(i,e)=>{if(!e)return null;const r=Number.parseInt(i.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},hi=(i,e)=>{const r=i.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},gi=(i,e,r)=>{const o=i.state.doc.line(e),w=Math.max(1,Math.min(r,o.length+1)),h=o.from+w-1;i.dispatch({selection:Po.cursor(h),effects:Tt.scrollIntoView(h,{y:"center"})})};function il({open:i,onOpenChange:e,view:r,variant:o="overlay"}){const{t:w}=tr(),[h,b]=s.useState(""),x=s.useRef(null),v=s.useRef(!1),m=s.useRef(null),f=s.useRef(null),j=s.useMemo(()=>sl(h,r),[h,r]);s.useEffect(()=>{!i||!r||(v.current=!1,x.current=hi(r,r.state.selection),b(""))},[i,r]),s.useEffect(()=>{i&&window.requestAnimationFrame(()=>{f.current?.focus(),f.current?.select()})},[i]),s.useEffect(()=>{if(!(!i||!r||!x.current)){if(j===null){const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})});return}gi(r,j,x.current.character)}},[j,i,r]);const N=s.useCallback(()=>{if(!r||v.current||!x.current)return;const{selection:y}=x.current;r.dispatch({selection:y,effects:Tt.scrollIntoView(y.main.from,{y:"center"})})},[r]),k=s.useCallback(y=>{y||N(),e(y)},[e,N]),S=s.useCallback(()=>{!r||j===null||!x.current||(v.current=!0,gi(r,j,x.current.character),e(!1),r.focus())},[j,e,r]);s.useEffect(()=>{if(!i)return;const y=M=>{const T=m.current,D=M.target;!T||!(D instanceof Node)||T.contains(D)||k(!1)},c=M=>{M.key==="Escape"&&(M.preventDefault(),k(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",c,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",c,!0)}},[k,i,o]);const E=s.useMemo(()=>{if(!r)return w("goToLineDialog.helper.editorUnavailable");if(j===null){const y=x.current??hi(r,r.state.selection);return w("goToLineDialog.helper.currentLineRange",{current:y.lineNumber,max:r.state.doc.lines})}return w("goToLineDialog.helper.goToLine",{line:j})},[j,w,r]);return o==="inline"?i?n.jsxs("div",{ref:m,className:"ml-1 flex h-6 items-center gap-1",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:h,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),n.jsx(I,{variant:"outline",size:"xs",onClick:S,disabled:!r||j===null,className:"h-6 px-2",children:w("goToLineDialog.actions.go")})]}):null:n.jsx("div",{ref:m,className:K("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",i?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:n.jsxs("div",{className:"min-w-0",children:[n.jsx(gr,{ref:f,type:"number",min:1,step:1,inputMode:"numeric",value:h,onChange:y=>b(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:w("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-surface-elevated/60 typography-ui-label"}),n.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:E})]})})}const al=(i,e)=>{const r=e.trim().toLowerCase(),o=[];if(!r)return o;const w=i.toLowerCase();let h=0;for(;;){const b=w.indexOf(r,h);if(b===-1)break;o.push({start:b,end:b+r.length}),h=b+r.length}return o},Qr="data-md-find",En="data-md-find-current",Mi="rounded-[2px] bg-status-warning/30 text-foreground",ol="rounded-[2px] bg-status-warning/60 text-foreground",ll=120,cl=i=>i instanceof Element&&i.hasAttribute(Qr),ul=i=>i.target instanceof Element&&i.target.hasAttribute(Qr)?!0:[...i.addedNodes].some(e=>cl(e)),Di=i=>{const e=new Set;i.querySelectorAll(`mark[${Qr}]`).forEach(r=>{const o=r.parentNode;o&&(o.replaceChild(document.createTextNode(r.textContent??""),r),e.add(o))}),e.forEach(r=>r.normalize())},dl=(i,e)=>{Di(i);const r=e.trim().toLowerCase();if(!r)return[];const o=[],w=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,{acceptNode(b){const x=b.parentElement;return!x||x.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),h=[];for(;w.nextNode();){const b=w.currentNode;b instanceof Text&&h.push(b)}for(const b of h){const x=b.nodeValue??"";if(!x)continue;const v=al(x,r);if(v.length===0)continue;const m=b.parentNode;if(!m)continue;const f=document.createDocumentFragment();let j=0;for(const N of v){N.start>j&&f.appendChild(document.createTextNode(x.slice(j,N.start)));const k=document.createElement("mark");k.setAttribute(Qr,""),k.className=Mi,k.textContent=x.slice(N.start,N.end),f.appendChild(k),o.push(k),j=N.end}j<x.length&&f.appendChild(document.createTextNode(x.slice(j))),m.replaceChild(f,b)}return o},vi=({containerRef:i,open:e,onOpenChange:r,focusNonce:o,className:w})=>{const{t:h}=tr(),[b,x]=s.useState(""),[v,m]=s.useState(0),[f,j]=s.useState(0),N=s.useRef(null),k=s.useRef([]),S=s.useRef(b);S.current=b;const E=s.useRef(null),y=s.useRef(null),c=s.useCallback((R,L=!1)=>{const B=i.current;if(!B){k.current=[],m(0),j(0);return}k.current=dl(B,R);const $=k.current.length;m($),j(ue=>!L||$===0?0:Math.min(ue,$-1))},[i]),M=s.useCallback((R,L=!1)=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{E.current=null,c(R,L)},ll)},[c]);s.useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const T=s.useCallback(()=>{r(!1);const R=y.current;y.current=null,R?.isConnected&&R.focus()},[r]);s.useEffect(()=>{const R=i.current;if(!e||!R)return;const L=new MutationObserver(B=>{!S.current.trim()||!B.some(ue=>!ul(ue))||M(S.current,!0)});return L.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>{L.disconnect(),Di(R)}},[i,e,M]),s.useEffect(()=>{if(!e)return;const R=document.activeElement;R instanceof HTMLElement&&!y.current&&(y.current=R),N.current?.focus()},[e]),s.useEffect(()=>{e&&o>0&&(N.current?.focus(),N.current?.select())},[e,o]),s.useEffect(()=>{const R=i.current;if(!R||(R.querySelectorAll(`mark[${En}]`).forEach(B=>{B.removeAttribute(En),B.className=Mi}),v===0))return;const L=k.current[Math.min(Math.max(f,0),v-1)];L&&(L.setAttribute(En,""),L.className=ol,L.scrollIntoView({block:"nearest"}))},[i,f,v]);const D=s.useCallback(()=>{j(R=>v===0?0:(R+1)%v)},[v]),P=s.useCallback(()=>{j(R=>v===0?0:(R-1+v)%v)},[v]),V=s.useCallback(R=>{R.key==="Enter"?(R.preventDefault(),R.shiftKey?P():D()):R.key==="Escape"&&(R.preventDefault(),T())},[T,D,P]);return e?n.jsxs("div",{className:K("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",w),children:[n.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),n.jsx(gr,{ref:N,value:b,onChange:R=>{x(R.target.value),M(R.target.value)},onKeyDown:V,placeholder:h("filesView.preview.find.placeholder"),"aria-label":h("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),n.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":v>0?h("filesView.preview.find.countAria",{current:f+1,total:v}):h("filesView.preview.find.noMatches"),children:b.trim()&&v===0?h("filesView.preview.find.noMatches"):v>0?`${f+1}/${v}`:""}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:h("filesView.preview.find.previousAria"),"aria-label":h("filesView.preview.find.previousAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-up",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:D,title:h("filesView.preview.find.nextAria"),"aria-label":h("filesView.preview.find.nextAria"),disabled:v===0,children:n.jsx(F,{name:"arrow-down",className:"size-3.5"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:T,title:h("filesView.preview.find.closeAria"),"aria-label":h("filesView.preview.find.closeAria"),children:n.jsx(F,{name:"close",className:"size-3.5"})})]}):null},fl=i=>{let e=!0;return{poll:async()=>{if(!e||i.isDirty())return!1;const r=i.getLoadedContent(),o=i.getLoadedRevision();try{const w=await i.readContent();if(!e||i.isDirty()||o!==i.getLoadedRevision())return!1;if(w===r)return!0;const h=await i.readContent();return!e||i.isDirty()||h!==w||o!==i.getLoadedRevision()?!1:(i.applyContent(w),!0)}catch{return!1}},dispose:()=>{e=!1}}},ml=1,pl=(i,e)=>e.size!==i.size||e.mtimeMs!==void 0&&i.mtimeMs!==void 0&&Math.abs(e.mtimeMs-i.mtimeMs)>=ml;function xi(){const i=ut.c(8),[e]=ct.useState(hl),r=ct.useRef(!1);let o;i[0]!==e?(o=v=>{if(v==null){e.cleanUp(),r.current=!1;return}r.current||(r.current=!0,e.setup(v,v.firstElementChild??void 0))},i[0]=e,i[1]=o):o=i[1];const w=o;let h,b;i[2]!==e?(h=()=>()=>{r.current=!1,e.cleanUp()},b=[e],i[2]=e,i[3]=h,i[4]=b):(h=i[3],b=i[4]),ct.useLayoutEffect(h,b);let x;return i[5]!==w||i[6]!==e?(x={virtualizer:e,setScroller:w},i[5]=w,i[6]=e,i[7]=x):x=i[7],x}function hl(){return new Oo}const Zt=new Map,gl=100;function Kr(i){const[e,r]=ct.useState(null),o=ct.useRef(null),w=ct.useRef(null),h=ct.useRef(null),b=ct.useCallback((x,v)=>{x&&v instanceof Mo&&(h.current={key:i,file:v,node:x});const m=o.current,f=w.current,j=()=>{o.current===m&&(m?.(),f?.())};v?queueMicrotask(j):j()},[i]);return ct.useLayoutEffect(()=>{if(!e||!i)return;const x=Zt.get(i)??{top:0,left:0};let v=!0;const m=()=>h.current?.key===i?h.current.file:null,f=c=>h.current?.key===i?h.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${c-1}"]`):null,j=()=>{k.disconnect(),S.disconnect()},N=()=>{if(!v)return;const c=m(),M=x.line&&c?.getLinePosition(x.line.number),T=x.line&&f(x.line.number);let D=x.top;x.line&&M&&(D=(c?.top??0)+M.top-x.line.offset),x.line&&T&&(D=e.scrollTop+T.getBoundingClientRect().top-e.getBoundingClientRect().top-x.line.offset),e.scrollTop=D,e.scrollLeft=x.left,(!x.line||T)&&Math.abs(e.scrollTop-D)<1&&Math.abs(e.scrollLeft-x.left)<1&&(v=!1,j())},k=new ResizeObserver(N),S=new MutationObserver(()=>{if(v){for(const c of e.children)k.observe(c);N()}});k.observe(e);for(const c of e.children)k.observe(c);S.observe(e,{childList:!0,subtree:!0});const E=()=>{if(v)return;const c=m(),M=c?.getNumericScrollAnchor(e.scrollTop-(c.top??0)),T=M&&f(M.lineNumber),D=T?T.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(Zt.delete(i),Zt.set(i,{top:e.scrollTop,left:e.scrollLeft,line:M&&D!==null&&D>=0&&D<e.clientHeight?{number:M.lineNumber,offset:D}:void 0}),Zt.size>gl){const P=Zt.keys().next().value;P!==void 0&&Zt.delete(P)}},y=()=>{v=!1,j()};return o.current=N,w.current=E,N(),e.addEventListener("scroll",E,{passive:!0}),e.addEventListener("wheel",y,{passive:!0}),e.addEventListener("touchstart",y,{passive:!0}),e.addEventListener("pointerdown",y,{passive:!0}),e.addEventListener("keydown",y),()=>{o.current=null,w.current=null,h.current?.key===i&&(h.current=null),j(),e.removeEventListener("scroll",E),e.removeEventListener("wheel",y),e.removeEventListener("touchstart",y),e.removeEventListener("pointerdown",y),e.removeEventListener("keydown",y)}},[i,e]),{setScroller:r,restore:b}}function vl(i){return!(!i.autoSaveEnabled||!i.isDirty||!i.canWrite||i.isSaving||i.fileLoading||i.isNonEditableBinary||!i.selectedFilePath||i.loadedFilePath!==i.selectedFilePath)}function xl(i){return i.selectedFilePath?i.isDirty?!(i.fileLoading||i.loadedFilePath!==i.selectedFilePath||i.isNonEditableBinary||i.draftContent===""&&i.fileContent!==""&&i.loadedFilePath!==i.selectedFilePath):!0:!1}const zi=2e5,wl=i=>{let e=0,r=0;for(let o=0;o<i.length;o++)i.charCodeAt(o)===10&&(o>0&&i.charCodeAt(o-1)===13?e++:r++);return e>r?`\r
5
+ `:`
6
+ `},Li=i=>i.replace(/\r\n/g,`
7
+ `).replace(/\r/g,`
8
+ `),bl=i=>({content:Li(i),lineEnding:wl(i)}),yl=(i,e)=>{const r=Li(i);return e===`\r
9
+ `?r.replace(/\n/g,`\r
10
+ `):r},jl=(i,e)=>e??(i.length>zi?"view":"edit"),Fl=i=>{let e=2166136261;for(let r=0;r<i.length;r++)e^=i.charCodeAt(r),e=e+((e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24))>>>0;return`${i.length}:${e.toString(16)}`},Nl='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function wi(){if(typeof document>"u")return!1;const i=document.documentElement.getAttribute("data-theme");return i==="dark"||!i&&window.matchMedia("(prefers-color-scheme: dark)").matches}const Cl=s.forwardRef(function({xml:e,readOnly:r,className:o,onChange:w},h){const b=s.useRef(e),x=s.useRef(null),v=s.useRef(!1),[m,f]=s.useState(wi),j=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,j.current=e,b.current=e);const k=s.useRef(m);k.current!==m&&(k.current=m,j.current=b.current);const S=s.useRef(null);s.useEffect(()=>{const c=()=>f(wi());c();const M=new MutationObserver(c);return M.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>M.disconnect()},[]),s.useEffect(()=>{const c=setTimeout(()=>{S.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(c)},[]),s.useImperativeHandle(h,()=>({getXml:()=>b.current}));const E=s.useCallback(()=>{!e&&!v.current&&(v.current=!0,setTimeout(()=>{x.current?.template({})},500))},[e]),y=s.useCallback(c=>{b.current=c.xml,w?.(c.xml)},[w]);return n.jsx("div",{ref:S,className:K("h-full w-full",o),children:n.jsx(qo,{ref:x,xml:j.current||Nl,autosave:!0,urlParameters:{ui:r?"simple":m?"dark":"kennedy",spin:!0,libraries:!r,chrome:r,nav:r,layers:r,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:E,onAutoSave:y},m?"dark":"light")})}),Sl=i=>{const e=U(i);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const o=e.slice(0,r);return/^[A-Za-z]:$/.test(o)?`${o}/`:o},Rl=i=>{const e=ut.c(8),{label:r,iconDataUrl:o}=i,[w,h]=s.useState(!1);let b;e[0]!==r?(b=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=b):b=e[1];const x=b;if(o&&!w){let f;e[2]===Symbol.for("react.memo_cache_sentinel")?(f=()=>h(!0),e[2]=f):f=e[2];let j;return e[3]!==o?(j=n.jsx("img",{src:o,alt:"",className:"size-4 rounded-sm",onError:f}),e[3]=o,e[4]=j):j=e[4],j}let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=K("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=v):v=e[5];let m;return e[6]!==x?(m=n.jsx("span",{className:v,children:x}),e[6]=x,e[7]=m):m=e[7],m},kl=i=>i.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),U=i=>{if(!i)return"";const e=i.replace(/\\/g,"/"),r=e.startsWith("//");let o=e.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const w=o==="/",h=/^[A-Za-z]:\/$/.test(o);return!w&&!h&&(o=o.replace(/\/+$/,"")),o},Tl=i=>i.startsWith("/")||i.startsWith("//")||/^[A-Za-z]:\//.test(i),er=i=>/^[A-Za-z]:\//.test(i)?i.toLowerCase():i,Zr=(i,e)=>{const r=U(e),o=U(i);if(!r||!o)return!1;const w=er(r),h=er(o);return h===w||h.startsWith(`${w}/`)},bi=(i,e)=>{const r=U(e),o=U(i);if(!Zr(o,r))return[];const h=o.slice(r.length).replace(/^\//,"").split("/"),b=[];let x=r;for(let v=0;v<h.length-1;v++)x=x?`${x}/${h[v]}`:h[v],b.push(x);return b},Jr=(i,e)=>{if(!e)return"";const r=U(e);if(!i||!Zr(r,i))return r;const o=r.slice(i.length);return o.startsWith("/")?o.slice(1):o},El=new Set(["node_modules"]),Vl=i=>{const e=ut.c(3),{status:r}=i;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=o):o=e[0];const w=o[r];let h;return e[1]!==w?(h=n.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:w}}),e[1]=w,e[2]=h):h=e[2],h},yi=i=>{const e=ut.c(11),{name:r}=i,o=s.useRef(null),w=s.useRef(null),[h,b]=s.useState(!1);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{const N=o.current,k=w.current;if(!N||!k)return;const S=()=>{b(k.scrollWidth>N.clientWidth+1)};S();const E=new ResizeObserver(S);return E.observe(N),E.observe(k),()=>{E.disconnect()}},e[0]=x):x=e[0];let v;e[1]!==r?(v=[r],e[1]=r,e[2]=v):v=e[2],s.useLayoutEffect(x,v);let m;e[3]!==r?(m=n.jsx("span",{ref:w,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=m):m=e[4];let f;e[5]!==r||e[6]!==h?(f=h?n.jsxs("span",{className:"open-file-name-marquee-track",children:[n.jsx("span",{className:"open-file-name-marquee-item",children:r}),n.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):n.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=h,e[7]=f):f=e[7];let j;return e[8]!==m||e[9]!==f?(j=n.jsxs("span",{ref:o,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[m,f]}),e[8]=m,e[9]=f,e[10]=j):j=e[10],j},Pl=i=>El.has(i),Ml=i=>{const e=U(i);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},Dl=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},ji=i=>{const r=(i instanceof Error?i.message:String(i??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},zl=2e5,Ai=(i,e)=>n.jsx(Gr,{filePath:i,extension:e}),Vn=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fi=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},Hr=i=>{if(!i)return!1;const e=i.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ll=i=>{const e=ut.c(76),{node:r,root:o,isExpanded:w,isActive:h,isMobile:b,isBrowserClient:x,alwaysShowActions:v,status:m,badge:f,permissions:j,downloadFile:N,contextMenuPath:k,setContextMenuPath:S,rightClickMenuPath:E,setRightClickMenuPath:y,onSelect:c,onToggle:M,onRevealPath:T,onOpenDialog:D}=i,{t:P}=tr(),V=r.type==="directory",{canRename:R,canCreateFile:L,canCreateFolder:B,canDelete:$,canReveal:ue}=j,de=!V&&!!N,Y=ue&&!x,Z=R||L||B||$||de||Y;let ae;e[0]!==Z||e[1]!==r.path||e[2]!==y?(ae=Te=>{Z&&(Te?.preventDefault(),y(r.path))},e[0]=Z,e[1]=r.path,e[2]=y,e[3]=ae):ae=e[3];const pe=ae;let oe;e[4]!==V||e[5]!==r||e[6]!==c||e[7]!==M?(oe=()=>{V?M(r.path):c(r)},e[4]=V,e[5]=r,e[6]=c,e[7]=M,e[8]=oe):oe=e[8];const H=oe;let G;e[9]!==r.path||e[10]!==S||e[11]!==y?(G=Te=>{Te.stopPropagation(),y(null),S(r.path)},e[9]=r.path,e[10]=S,e[11]=y,e[12]=G):G=e[12];const We=G;let te;e[13]!==L||e[14]!==B||e[15]!==$||e[16]!==R||e[17]!==Y||e[18]!==N||e[19]!==x||e[20]!==V||e[21]!==r||e[22]!==D||e[23]!==T||e[24]!==o||e[25]!==P?(te=Te=>{const{Item:Ie,Separator:Vt}=Te;return n.jsxs(n.Fragment,{children:[R&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),D("rename",r)},children:[n.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),Yr(r.path).then(Ze=>{if(Ze.ok){J.success(P("sidebarFilesTree.toast.pathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation();const Ze=Jr(o,r.path)||r.path;Yr(Ze).then(Pt=>{if(Pt.ok){J.success(P("filesView.toast.relativePathCopied"));return}J.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[n.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!V&&N&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),N(r.path).catch(Ze=>{console.error("Download failed:",Ze),J.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(x?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),Y&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),T(r.path)},children:[n.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(Fo())]}),V&&(L||B)&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),L&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),D("createFile",r)},children:[n.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),B&&n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),D("createFolder",r)},children:[n.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),$&&n.jsxs(n.Fragment,{children:[n.jsx(Vt,{}),n.jsxs(Ie,{onClick:le=>{le.stopPropagation(),D("delete",r)},className:"text-destructive focus:text-destructive",children:[n.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=L,e[14]=B,e[15]=$,e[16]=R,e[17]=Y,e[18]=N,e[19]=x,e[20]=V,e[21]=r,e[22]=D,e[23]=T,e[24]=o,e[25]=P,e[26]=te):te=e[26];const he=te,Me=E===r.path;let be;e[27]!==r.path||e[28]!==y?(be=Te=>y(Te?r.path:null),e[27]=r.path,e[28]=y,e[29]=be):be=e[29];const q=b?void 0:pe;let X;e[30]!==q?(X=n.jsx("div",{className:"group relative flex items-center",onContextMenu:q}),e[30]=q,e[31]=X):X=e[31];const _=b?void 0:pe,re=h?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ge;e[32]!==re?(ge=K("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",re),e[32]=re,e[33]=ge):ge=e[33];let ne;e[34]!==V||e[35]!==w||e[36]!==r.extension||e[37]!==r.path?(ne=V?w?n.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):n.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ai(r.path,r.extension),e[34]=V,e[35]=w,e[36]=r.extension,e[37]=r.path,e[38]=ne):ne=e[38];let Q;e[39]!==r.name||e[40]!==r.path?(Q=n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=Q):Q=e[41];let ye;e[42]!==V||e[43]!==m?(ye=!V&&m&&n.jsx(Vl,{status:m}),e[42]=V,e[43]=m,e[44]=ye):ye=e[44];let ve;e[45]!==f||e[46]!==V?(ve=V&&f&&n.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[f.modified>0&&n.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",f.modified]}),f.added>0&&n.jsxs("span",{className:"text-[var(--status-success)]",children:["+",f.added]})]}),e[45]=f,e[46]=V,e[47]=ve):ve=e[47];let fe;e[48]!==H||e[49]!==ge||e[50]!==ne||e[51]!==Q||e[52]!==ye||e[53]!==ve||e[54]!==_?(fe=n.jsxs("button",{type:"button",onClick:H,onContextMenu:_,className:ge,children:[ne,Q,ye,ve]}),e[48]=H,e[49]=ge,e[50]=ne,e[51]=Q,e[52]=ye,e[53]=ve,e[54]=_,e[55]=fe):fe=e[55];let xe;e[56]!==v||e[57]!==k||e[58]!==We||e[59]!==Z||e[60]!==b||e[61]!==r.path||e[62]!==he||e[63]!==S?(xe=Z&&n.jsx("div",{className:K("absolute right-1 top-1/2 -translate-y-1/2",v?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:n.jsxs(Pn,{open:k===r.path,onOpenChange:Te=>S(Te?r.path:null),children:[n.jsx(Mn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"icon",className:"size-6",onClick:We,children:n.jsx(F,{name:"more-2-fill",className:"size-4"})})}),n.jsx(Dn,{align:"end",side:"bottom",onCloseAutoFocus:()=>S(null),children:he({Item:Xr,Separator:jo})})]})}),e[56]=v,e[57]=k,e[58]=We,e[59]=Z,e[60]=b,e[61]=r.path,e[62]=he,e[63]=S,e[64]=xe):xe=e[64];let ke;e[65]!==fe||e[66]!==xe||e[67]!==X?(ke=n.jsxs(ko,{render:X,children:[fe,xe]}),e[65]=fe,e[66]=xe,e[67]=X,e[68]=ke):ke=e[68];let Ue;e[69]!==he?(Ue=n.jsx(Co,{className:"min-w-[180px]",children:he({Item:Ro,Separator:So})}),e[69]=he,e[70]=Ue):Ue=e[70];let Et;return e[71]!==ke||e[72]!==Ue||e[73]!==Me||e[74]!==be?(Et=n.jsxs(To,{open:Me,onOpenChange:be,children:[ke,Ue]}),e[71]=ke,e[72]=Ue,e[73]=Me,e[74]=be,e[75]=Et):Et=e[75],Et},Al=i=>{const e=ut.c(83),{activeDialog:r,dialogData:o,dialogInputValue:w,onDialogInputChange:h,isDialogSubmitting:b,onDialogSubmit:x,onClose:v,inputRef:m}=i,{t:f}=tr(),j=!!r;let N;e[0]!==v?(N=G=>!G&&v(),e[0]=v,e[1]=N):N=e[1];let k;e[2]!==r||e[3]!==f?(k=r==="createFile"&&f("filesView.dialog.createFile.title"),e[2]=r,e[3]=f,e[4]=k):k=e[4];let S;e[5]!==r||e[6]!==f?(S=r==="createFolder"&&f("filesView.dialog.createFolder.title"),e[5]=r,e[6]=f,e[7]=S):S=e[7];let E;e[8]!==r||e[9]!==f?(E=r==="rename"&&f("filesView.dialog.rename.title"),e[8]=r,e[9]=f,e[10]=E):E=e[10];let y;e[11]!==r||e[12]!==f?(y=r==="delete"&&f("filesView.dialog.delete.title"),e[11]=r,e[12]=f,e[13]=y):y=e[13];let c;e[14]!==k||e[15]!==S||e[16]!==E||e[17]!==y?(c=n.jsxs(Ei,{children:[k,S,E,y]}),e[14]=k,e[15]=S,e[16]=E,e[17]=y,e[18]=c):c=e[18];let M;e[19]!==r||e[20]!==o?.path||e[21]!==f?(M=r==="createFile"&&f("filesView.dialog.createFile.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[19]=r,e[20]=o?.path,e[21]=f,e[22]=M):M=e[22];let T;e[23]!==r||e[24]!==o?.path||e[25]!==f?(T=r==="createFolder"&&f("filesView.dialog.createFolder.description",{path:o?.path??f("filesView.dialog.rootFallback")}),e[23]=r,e[24]=o?.path,e[25]=f,e[26]=T):T=e[26];let D;e[27]!==r||e[28]!==o?.name||e[29]!==f?(D=r==="rename"&&f("filesView.dialog.rename.description",{name:o?.name??""}),e[27]=r,e[28]=o?.name,e[29]=f,e[30]=D):D=e[30];let P;e[31]!==r||e[32]!==o?.name||e[33]!==f?(P=r==="delete"&&f("filesView.dialog.delete.description",{name:o?.name??""}),e[31]=r,e[32]=o?.name,e[33]=f,e[34]=P):P=e[34];let V;e[35]!==D||e[36]!==P||e[37]!==M||e[38]!==T?(V=n.jsxs(Vi,{children:[M,T,D,P]}),e[35]=D,e[36]=P,e[37]=M,e[38]=T,e[39]=V):V=e[39];let R;e[40]!==V||e[41]!==c?(R=n.jsxs(Ti,{children:[c,V]}),e[40]=V,e[41]=c,e[42]=R):R=e[42];let L;e[43]!==r||e[44]!==w||e[45]!==m||e[46]!==h||e[47]!==x||e[48]!==f?(L=r!=="delete"&&n.jsx("div",{className:"py-4",children:n.jsx(gr,{value:w,onChange:G=>h(G.target.value),placeholder:f(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:G=>{G.key==="Enter"&&x()},ref:m})}),e[43]=r,e[44]=w,e[45]=m,e[46]=h,e[47]=x,e[48]=f,e[49]=L):L=e[49];let B;e[50]!==f?(B=f("filesView.dialog.cancel"),e[50]=f,e[51]=B):B=e[51];let $;e[52]!==b||e[53]!==v||e[54]!==B?($=n.jsx(I,{variant:"outline",onClick:v,disabled:b,children:B}),e[52]=b,e[53]=v,e[54]=B,e[55]=$):$=e[55];const ue=r==="delete"?"destructive":"default";let de;e[56]!==x?(de=()=>{x()},e[56]=x,e[57]=de):de=e[57];let Y;e[58]!==r||e[59]!==w||e[60]!==b?(Y=b||r!=="delete"&&!w.trim(),e[58]=r,e[59]=w,e[60]=b,e[61]=Y):Y=e[61];let Z;e[62]!==r||e[63]!==b||e[64]!==f?(Z=b?n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):f(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=b,e[64]=f,e[65]=Z):Z=e[65];let ae;e[66]!==ue||e[67]!==de||e[68]!==Y||e[69]!==Z?(ae=n.jsx(I,{variant:ue,onClick:de,disabled:Y,children:Z}),e[66]=ue,e[67]=de,e[68]=Y,e[69]=Z,e[70]=ae):ae=e[70];let pe;e[71]!==$||e[72]!==ae?(pe=n.jsxs(Pi,{children:[$,ae]}),e[71]=$,e[72]=ae,e[73]=pe):pe=e[73];let oe;e[74]!==m||e[75]!==R||e[76]!==L||e[77]!==pe?(oe=n.jsxs(ki,{initialFocus:m,children:[R,L,pe]}),e[74]=m,e[75]=R,e[76]=L,e[77]=pe,e[78]=oe):oe=e[78];let H;return e[79]!==j||e[80]!==N||e[81]!==oe?(H=n.jsx(Ri,{open:j,onOpenChange:N,children:oe}),e[79]=j,e[80]=N,e[81]=oe,e[82]=H):H=e[82],H},Qt=new Map,Il=100,Ni=i=>{const e=ut.c(13);let r,o,w;e[0]!==i?({positionKey:o,onViewReady:r,...w}=i,e[0]=i,e[1]=r,e[2]=o,e[3]=w):(r=e[1],o=e[2],w=e[3]);const h=s.useRef(null);let b,x;e[4]!==o?(b=()=>()=>{const f=h.current;if(!f)return;const{anchor:j,head:N}=f.state.selection.main;if(Qt.delete(o),Qt.set(o,{scroll:f.scrollSnapshot(),anchor:j,head:N}),Qt.size>Il){const k=Qt.keys().next().value;k!==void 0&&Qt.delete(k)}},x=[o],e[4]=o,e[5]=b,e[6]=x):(b=e[5],x=e[6]),s.useLayoutEffect(b,x);let v;e[7]!==r||e[8]!==o?(v=f=>{h.current=f;const j=Qt.get(o);j&&f.dispatch({selection:{anchor:Math.min(j.anchor,f.state.doc.length),head:Math.min(j.head,f.state.doc.length)},effects:j.scroll}),r?.(f)},e[7]=r,e[8]=o,e[9]=v):v=e[9];let m;return e[10]!==w||e[11]!==v?(m=n.jsx(Vo,{...w,onViewReady:v}),e[10]=w,e[11]=v,e[12]=m):m=e[12],m},Ci=(i,e,r)=>{const o=ut.c(8),[w,h]=s.useState(""),[b,x]=s.useState(0);let v,m;o[0]!==i||o[1]!==r||o[2]!==e?(v=()=>{if(!i){h("");return}let j=!1;h("");const N=Ja(),k=Ya(N);Za(N).then(E=>{j||!E||(h(i),e(null))}).catch(E=>{j||(e(E instanceof Error?E.message:r),h(i))});const S=Qa(()=>{j||(h(i),x(Ol),e(null))});return()=>{j=!0,k(),S()}},m=[i,e,r],o[0]=i,o[1]=r,o[2]=e,o[3]=v,o[4]=m):(v=o[3],m=o[4]),s.useEffect(v,m);let f;return o[5]!==b||o[6]!==w?(f={readyKey:w,nonce:b},o[5]=b,o[6]=w,o[7]=f):f=o[7],f},id=({mode:i="full",visible:e=!0})=>{const{t:r}=tr(),{files:o,runtime:w}=no(),{currentTheme:h,availableThemes:b,lightThemeId:x,darkThemeId:v}=so(),{isMobile:m,isTablet:f,screenWidth:j}=io(),N=Ua(w.platform),k=m||f,S=qa(),E=Ka(),y=Si()??"",c=U(y.trim()),M=m||i==="full",T=M&&e,D=ao(t=>t.runtimeKey),P=JSON.stringify([D,c]),V=s.useRef(P);V.current=P;const R=JSON.stringify([D,c,S,E]),L=s.useRef(R);L.current=R;const B=i!=="editor-only",$=i==="editor-only"&&!m,ue=Ha(t=>t.searchFiles),de=oo(T?y:null),[Y,Z]=s.useState(""),ae=lo(Y,200),pe=s.useRef(null),[oe,H]=s.useState(!1),[G,We]=s.useState(!0),[te,he]=s.useState(!1),[Me,be]=s.useState(!1),q=s.useRef(0),X=s.useCallback(t=>{q.current=Math.max(0,q.current+(t?1:-1))},[]),[_,re]=s.useState("edit"),[ge,ne]=s.useState("edit"),[Q,ye]=s.useState("tree"),[ve,fe]=s.useState("edit"),[xe,ke]=s.useState("preview"),[Ue,Et]=s.useState(0),Te=s.useRef({}),Ie=s.useRef({}),Vt=s.useRef({}),le=s.useRef({}),Ze=s.useMemo(()=>b.find(t=>t.metadata.id===x)??ii(!1),[b,x]),Pt=s.useMemo(()=>b.find(t=>t.metadata.id===v)??ii(!0),[b,v]);s.useEffect(()=>{mi(Ze),mi(Pt)},[Ze,Pt]);const vr=s.useMemo(()=>[],[]),je=Ye(t=>c?t.byRoot[c]?.openPaths??vr:vr),bt=Ye(t=>c?t.byRoot[c]?.selectedPath??null:null),Qe=Ye(t=>c?t.byRoot[c]?.expandedPaths??vr:vr),Ii=s.useMemo(()=>new Set(Qe),[Qe]),Mt=Ye(t=>t.removeOpenPath),dt=Ye(t=>t.removeOpenPathsByPrefix),zn=Ye(t=>t.removeExpandedPathsByPrefix),Fe=Ye(t=>t.setSelectedPath),Ln=Ye(t=>t.toggleExpandedPath),xr=Ye(t=>t.expandPaths),Dt=s.useCallback(t=>{const a=U(t),l=a.split("/"),d=l[l.length-1]||a,p=d.includes(".")?d.split(".").pop()?.toLowerCase():void 0;return{name:d,path:a,type:"file",extension:p}},[]),zt=s.useMemo(()=>je.map(Dt),[je,Dt]),en=s.useMemo(()=>{if(bt){const t=er(bt);if(je.some(a=>er(a)===t))return bt}return je[0]??null},[je,bt]),u=s.useMemo(()=>en?Dt(en):null,[en,Dt]),qe=u?.path??"",[,Oi]=s.useState(0);s.useEffect(()=>{if(!c||!bt)return;const t=er(bt);je.some(l=>er(l)===t)||Fe(c,je[0]??null)},[je,c,bt,Fe]);const wr=!!(c&&qe&&!Zr(qe,c)),An=wr?ai(qe):void 0,yt=s.useMemo(()=>({allowOutsideWorkspace:i==="editor-only"&&wr,outsideFileGrant:An,directory:c||void 0}),[i,wr,An,c]),et=s.useCallback(async t=>{const a=ai(t),l=await co(t,c,i==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==a&&Oi(d=>d+1),l},[i,c]),tn=s.useRef(null),[In,Bi]=s.useState({left:!1,right:!1}),On=s.useCallback(()=>{const t=tn.current;t&&Bi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Bn=s.useRef(On);Bn.current=On,s.useEffect(()=>{const t=tn.current;if(!t)return;const a=()=>Bn.current();a(),t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(a);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[zt.length]);const[$n,rn]=s.useState({}),[br,rr]=s.useState({}),Oe=s.useRef(new Set),Ee=s.useMemo(()=>new Bo,[]);s.useEffect(()=>()=>Ee.clear(),[Ee]);const[_n,yr]=s.useState([]),[$i,jr]=s.useState(!1),[O,me]=s.useState(""),{isPlaying:Fr,play:_i,stop:Wi}=uo(),[De,ft]=s.useState(!1),[tt,we]=s.useState(null),[Ui,Be]=s.useState(""),[Ne,ce]=s.useState(null),mt=JSON.stringify([lt(),c,Ne]),[ee,Ce]=s.useState(""),[nr,nn]=s.useState(!1),[Wn,qi]=s.useState(`
11
+ `),Ki=s.useRef(null),rt=s.useRef(null),ze=s.useRef(null),pt=s.useRef(""),sr=s.useRef(""),st=s.useRef(null),Un=s.useRef(null),Ke=s.useRef(null),sn=s.useRef(""),an=s.useRef(0),Lt=s.useRef(0),jt=s.useRef(null),[Nr,Hi]=s.useState(0),[Gi,At]=s.useState("idle"),[Xi,Cr]=s.useState(!1),[Ft,qn]=s.useState(!1),Se=wt(t=>t.autoSaveEnabled),Ji=wt(t=>t.setAutoSaveEnabled),[on,ir]=s.useState(!1),It=s.useRef(null),ar=s.useRef(null),or=s.useRef(!1),lr=s.useRef(null),cr=s.useRef(null),He=s.useRef(null),Sr=s.useRef(null),[Yi,ln]=s.useState(0),Ot=s.useRef(null),Nt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Ot.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Ot.current),Ot.current=null)},[]);const[Ct,cn]=s.useState(null),[St,Zi]=s.useState(null),[ht,Kn]=s.useState(""),[Qi,un]=s.useState(!1),[ea,ta]=s.useState(null),[ra,na]=s.useState(null),[sa,Hn]=s.useState(!1),[ia,Gn]=s.useState(!1),[aa,dn]=s.useState(!1),[Xn,Rr]=s.useState(!1),[Jn,Yn]=s.useState(0),kr=s.useRef(null),Tr=s.useCallback(t=>{const a=t?.currentTarget??kr.current;if(!a)return;const l=document.activeElement;l&&l!==document.body&&l!==a&&(fo(l)||a.contains(l))||a.focus({preventScroll:!0})},[]),Er=s.useRef(null),Zn=!!o.writeFile,Qn=!!o.createDirectory,es=!!o.rename,ts=!!o.delete,rs=!!o.revealPath,oa=qr(t=>t.availableApps),la=qr(t=>t.isCacheStale),ns=qr(t=>t.initialize),ca=qr(t=>t.loadInstalledApps);s.useEffect(()=>{ns()},[ns]);const ua=s.useCallback(t=>{o.revealPath&&o.revealPath(t).catch(()=>{J.error(r("sidebarFilesTree.toast.revealFailed"))})},[o,r]),da=s.useCallback(async t=>{if(!u?.path||await Ga(u.path,t.id,t.appName)||await ti(u.path,t.appName))return;const d=Sl(u.path)||c;d&&await ti(d,t.appName)||J.error(r("filesView.toast.openInAppFailed",{app:t.appName}))},[c,u?.path,r]),fn=s.useCallback((t,a)=>{cn(t),Zi(a),Kn(t==="rename"&&a.name||""),un(!1)},[]),[W,Ge]=s.useState(null),Bt=s.useRef(!1),gt=s.useRef(null),[ss,$t]=s.useState(!1),nt=wt(t=>t.pendingFileNavigation),Vr=wt(t=>t.setPendingFileNavigation),mn=wt(t=>t.pendingFileFocusPath),pn=wt(t=>t.setPendingFileFocusPath),is=wt(t=>t.fileEditorKeymap),ur=oi(t=>t.settingsDefaultFileViewerPreview),fa=oi(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Bt.current=!1,gt.current=null,$t(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{lr.current!==null&&window.clearTimeout(lr.current),cr.current!==null&&window.clearTimeout(cr.current)},[]);const ma=s.useCallback((t,a)=>{const l=t.split(`
12
+ `),d=Math.max(1,a.start),p=Math.min(l.length,a.end);return d>p?"":l.slice(d-1,p).join(`
13
+ `)},[]),as=s.useRef(null),pa=Ho({source:"file",fileLabel:u?.path??null,language:u?.path&&Cn(u.path)||"text",getCodeForRange:t=>ma(O,Go(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:os,commentText:Pr,setCommentText:ls,editingDraftId:Mr,setSelection:cs,saveComment:us,cancel:dr,reset:ds,startEdit:fs,deleteDraft:ms}=pa;s.useEffect(()=>{Ge(null),ds(),Ce(""),nn(!1)},[u?.path,ds]),s.useEffect(()=>{cs(W)},[W,cs]),s.useEffect(()=>{if(!W&&!Mr)return;const t=l=>{const d=l.target;d.closest('[data-comment-input="true"]')||d.closest('[data-comment-card="true"]')||d.closest(".cm-gutterElement")||d.closest("[data-sonner-toast]")||d.closest("[data-sonner-toaster]")||Pr.trim()||(Ge(null),dr())},a=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(a),document.removeEventListener("click",t)}},[dr,Pr,Mr,W]);const ps=s.useCallback((t,a)=>{const l=a??W??void 0;a&&Ge(a),us(t,l),Ge(null)},[W,us]),hs=s.useCallback((t,a)=>{const l=[];for(const d of a){if(!(d&&typeof d.name=="string"&&d.name.length>0)||!S&&d.name.startsWith(".")||!E&&Pl(d.name))continue;const p=d.name,g=U(d.path||""),C=g?Tl(g)?g:U(`${t}/${g}`):U(`${t}/${p}`),A=d.isDirectory?"directory":"file",se=A==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:C,type:A,extension:se})}return kl(l)},[E,S]),Ve=s.useCallback(async(t,a=!1)=>{if(!T)return;const l=U(t.trim());if(!l||!a&&Oe.current.has(l))return;const d=L.current,p=lt();return Ee.run(l,async g=>{const C=()=>g()&&L.current===d&&lt()===p;try{const A=o.listDirectory?(await o.listDirectory(l)).entries:await Xa.listLocalDirectory(l);if(!C())return;const se=hs(l,A);Oe.current=new Set(Oe.current),Oe.current.add(l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie}),rn(z=>z[l]&&$o(z[l],se)?z:{...z,[l]:se})}catch(A){if(!C())return;const se=A instanceof Error?A.message:String(A??"");if(se==="Directory not found"&&c&&l!==c){zn(c,l),rr(z=>{if(!z[l])return z;const ie={...z};return delete ie[l],ie});return}console.error("Failed to load files directory:",A),rr(z=>({...z,[l]:se}))}},a)},[Ee,o,hs,zn,c,T]),Dr=s.useCallback(async()=>{c&&(Oe.current=new Set,Ee.clear(),rr({}),rn(t=>Object.keys(t).length===0?t:{}),await Ve(c))},[Ee,Ve,c]),$e=s.useCallback(async t=>{if(!t){await Dr();return}const a=U(t);Oe.current=new Set(Oe.current),Oe.current.delete(a),await Ve(a,!0)},[Ve,Dr]),gs=s.useRef(""),vs=s.useRef("");s.useEffect(()=>{if(!c)return;const t=R,a=gs.current!==P,l=vs.current!==t;!a&&!l||(a&&(gs.current=P,Lt.current+=1,jt.current=null,me(""),we(null),Be(""),ce(null),H(!1)),l&&(vs.current=t,Oe.current=new Set,Ee.clear(),rr({}),rn(d=>Object.keys(d).length===0?d:{}),Ve(c)))},[Ee,P,Ve,c,R]),s.useEffect(()=>{if(!T||!o.listDirectory)return;const t=()=>{if(!document.hidden&&Qe.length>0)for(const a of Qe)Ee.has(a)||$e(a)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Ee,Qe,o.listDirectory,$e,T]);const xs=s.useRef(!1);s.useEffect(()=>{const t=T&&!xs.current;if(xs.current=T,!(!T||!c)&&(Ve(c),t))for(const a of Qe)Ee.has(a)||$e(a)},[Ee,Qe,Ve,$e,c,T]),s.useEffect(()=>{if(!T||!o.listDirectory||Qe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const a of Qe)Ee.has(a)||$e(a)},8e3);return()=>clearInterval(t)},[Ee,Qe,o.listDirectory,$e,T]);const ha=s.useCallback(async t=>{if(t?.preventDefault(),!St||!Ct)return;un(!0);const a=()=>{cn(null)},l=p=>{J.error(p)},d=()=>{un(!1)};if(Ct==="createFile"){if(!ht.trim()){l(r("sidebarFilesTree.toast.filenameRequired")),d();return}if(!o.writeFile){l(r("sidebarFilesTree.toast.writeNotSupported")),d();return}const p=St.path,g=p?`${p}/`:"",C=U(`${g}${ht.trim()}`);await o.writeFile(C,"").then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.fileCreated")),await $e(p)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="createFolder"){if(!ht.trim()){l(r("sidebarFilesTree.toast.folderNameRequired")),d();return}const p=St.path,g=p?`${p}/`:"",C=U(`${g}${ht.trim()}`);await o.createDirectory(C).then(async A=>{A.success&&(J.success(r("sidebarFilesTree.toast.folderCreated")),await $e(p)),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="rename"){if(!ht.trim()){l(r("sidebarFilesTree.toast.nameRequired")),d();return}if(!o.rename){l(r("sidebarFilesTree.toast.renameNotSupported")),d();return}const p=St.path,g=p.split("/").slice(0,-1).join("/"),C=g?`${g}/`:"",A=U(`${C}${ht.trim()}`);await o.rename(p,A).then(async se=>{se.success&&(J.success(r("sidebarFilesTree.toast.renamedSuccessfully")),await $e(g),c&&dt(c,p),(u?.path===p||u?.path.startsWith(`${p}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}if(Ct==="delete"){if(!o.delete){l(r("sidebarFilesTree.toast.deleteNotSupported")),d();return}const p=St.path,g=p.split("/").slice(0,-1).join("/");await o.delete(p).then(async C=>{C.success&&(J.success(r("sidebarFilesTree.toast.deletedSuccessfully")),await $e(g),c&&dt(c,p),(u?.path===p||u?.path.startsWith(`${p}/`))&&(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1))),a()}).catch(()=>l(r("sidebarFilesTree.toast.operationFailed"))).finally(d);return}d()},[Ct,St,ht,o,$e,m,dt,c,u?.path,Fe,r]);s.useEffect(()=>{if(!y){yr([]),jr(!1);return}const t=ae.trim();if(!t){yr([]),jr(!1);return}let a=!1;return jr(!0),ue(y,t,150,{includeHidden:S,respectGitignore:!E,type:"file"}).then(l=>{if(a)return;const p=l.filter(g=>E||!Ml(g.path)).map(g=>({name:g.name,path:U(g.path),type:"file",extension:g.extension,relativePath:g.relativePath}));yr(p)}).catch(()=>{a||yr([])}).finally(()=>{a||jr(!1)}),()=>{a=!0}},[y,ae,ue,S,E]);const zr=s.useCallback(async(t,a)=>{const l=await et(t);if(o.readFile)return(await o.readFile(t,{...l,directory:c||void 0,...a})).content??"";const d=new URLSearchParams({path:t});l.allowOutsideWorkspace&&d.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&d.set("outsideFileGrant",l.outsideFileGrant),c&&d.set("directory",c);const p=await ri(`/api/fs/read?${d.toString()}`,a?.fresh?{cache:"no-store"}:void 0);if(!p.ok){const g=await p.json().catch(()=>({error:p.statusText}));throw new Error(g.error||r("filesView.error.readFileFailed"))}return p.text()},[o,et,c,r]),vt=s.useCallback(async t=>{if(o.statFile){const a=await et(t),l=await o.statFile(t,{...a,directory:c||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[o,et,c]);s.useEffect(()=>{if(!c||!o.statFile||je.length===0)return;let t=!1;const a=[...je];return Promise.all(a.map(async l=>{try{const d=await et(l),p=await o.statFile?.(l,{...d,directory:c||void 0});!t&&p&&!p.isFile&&dt(c,l)}catch(d){!t&&ji(d)&&dt(c,l)}})),()=>{t=!0}},[o,je,dt,et,c]);const Le=ee!==O,_t=s.useCallback(async()=>{if(!u||!o.writeFile)return J.error(r("filesView.toast.savingNotSupported")),!1;const t=pr(u.path)||Ft;if(!xl({selectedFilePath:u.path,loadedFilePath:Ne,fileLoading:De,isDirty:Le,draftContent:ee,fileContent:O,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${u.path}".`):ee===""&&O!==""&&Ne!==u.path&&console.warn(`[saveDraft] refusing to save empty draft for "${u.path}" (${O.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!Le)return!0;nn(!0);try{const a=yl(ee,Wn);if(!(await o.writeFile(u.path,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;if(me(ee),sn.current=a,an.current+=1,c&&Zr(u.path,c)){const d=Jr(c,u.path);d&&mo.requestGitRefresh({directory:c,paths:[d]})}if(c&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(U(u.path))){const d=po.getState().projects.find(p=>U(p.path)===U(c));if(d)try{await _o(d.id)}catch{J.error(r("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return u?.path&&hr(u.path)&&(pt.current=ee,sr.current=ee),vt(u.path).then(d=>{d&&(Ke.current=d)}).catch(()=>{}),!0}catch(a){return J.error(a instanceof Error?a.message:r("filesView.toast.saveFailed")),!1}finally{nn(!1)}},[Ft,ee,O,De,o,Le,Wn,Ne,vt,c,u,r]);s.useEffect(()=>{Se||(At("idle"),rt.current&&(clearTimeout(rt.current),rt.current=null))},[Se]);const ws=1500;s.useEffect(()=>{const t=!!(u&&o.writeFile),a=!!(u?.path&&(pr(u.path)||Ft));if(vl({autoSaveEnabled:Se,isDirty:Le,canWrite:t,isSaving:nr,fileLoading:De,selectedFilePath:u?.path,loadedFilePath:Ne,isNonEditableBinary:a}))return rt.current=setTimeout(()=>{_t().then(l=>{l&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},ws),()=>{rt.current&&(clearTimeout(rt.current),rt.current=null)}},[Se,Ft,ee,De,Le,Ne,u,o.writeFile,nr,_t]),s.useEffect(()=>{At("idle")},[u?.path]),ho({save_file:t=>{if(!(t.target instanceof Node)||!Sr.current?.contains(t.target))return!1;rt.current&&(clearTimeout(rt.current),rt.current=null),nr||_t().then(a=>{a&&(At("saved"),setTimeout(()=>At("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(Je&&Ae()==="preview"){if(m||!(te?Er.current:kr.current)?.contains(t.target))return!1;Rr(!0),Yn(l=>l+1);return}if(!Sr.current?.contains(t.target))return!1;be(!0)}});const Wt=s.useCallback(t=>{const{content:a,lineEnding:l}=bl(t);return sn.current=t,an.current+=1,qi(l),me(a),pt.current=a,sr.current=a,Ce(a),a},[]),bs=s.useCallback(async t=>{const a=Lt.current+1;Lt.current=a;const l=lt(),d=V.current,p=()=>{if(!c||lt()!==l||V.current!==d)return!1;const z=Ye.getState().byRoot[c],ie=z?.selectedPath??z?.openPaths[0]??null;return Lt.current===a&&ie===t.path};if(we(null),Be(""),ce(null),qn(!1),ft(!0),await et(t.path),!p())return;const g=Sn(t.path),C=li(t.path),A=ci(t.path),se=pr(t.path);if(m&&H(!0),w.isDesktop&&g&&!C){me(""),Ce("");return}if(!w.isDesktop&&g&&!C){me(""),Ce(""),ce(t.path),ft(!1);return}if(A){me(""),Ce(""),ce(t.path),ft(!1);return}if(se){me(""),Ce(""),ce(t.path),ft(!1);return}await zr(t.path).then(z=>{if(!p())return;if(ui(z)){qn(!0),me(""),Ce(""),ce(t.path);return}const ie=Wt(z),Rt=Vn(t.path)||Hr(t.path)||Fi(t.path)||hr(t.path);re(Rt?"edit":jl(ie,Te.current[t.path])),ce(t.path),vt(t.path).then(Gt=>{Gt&&p()&&(Ke.current=Gt)}).catch(()=>{})}).catch(z=>{if(p()){if(Dl(z)){if(ft(!1),c&&Fe(c,null),we(null),me(""),Ce(""),ce(null),Ke.current=null,Y.trim().length>0&&Z(""),m&&H(!1),c){const Rt=[...bi(t.path,c),t.path];Rt.length>0&&xr(c,Rt);for(const Gt of Rt)Oe.current.has(Gt)||Ve(Gt)}return}if(ji(z)){c&&dt(c,t.path),me(""),Ce(""),we(null),Ke.current=null,m&&H(!1);return}me(""),Ce(""),we(z instanceof Error?z.message:r("filesView.error.readFileFailed")),Ke.current=null}}).finally(()=>{p()&&ft(!1)})},[Wt,xr,m,Ve,zr,vt,dt,et,c,w.isDesktop,Y,Fe,r]),Lr=s.useCallback(async(t,a)=>{if(!e||!c)return;const l=bi(t,c),d=a?[...l,t]:l;if(d.length>0&&xr(c,d),!T)return;const p=d.map(g=>{if(!Oe.current.has(g))return Ve(g)}).filter(Boolean);await Promise.all(p)},[xr,Ve,c,T,e]),ys=s.useCallback((t,a)=>{const l=a.findIndex(d=>d.path===t);return l===-1||a.length<=1?null:a[l+1]??a[l-1]??null},[]),Pe=s.useCallback(async t=>{if(or.current)or.current=!1;else if(Le){ir(!0),It.current=t;return}c&&(Fe(c,t.path),Lr(t.path,!1)),we(null),Be(""),me(""),pt.current="",sr.current="",Ce(""),ce(null),m&&H(!0)},[Lr,Le,m,c,Fe]);s.useEffect(()=>{u?.path&&Lr(u.path,!1)},[Lr,u?.path]),s.useEffect(()=>{if(!e)return;if(!u){Lt.current+=1,jt.current=null,ft(!1);return}if(Ne===u.path||jt.current===u.path)return;const t=u.path;jt.current=t,bs(u).finally(()=>{jt.current===t&&(jt.current=null)})},[Nr,bs,Ne,u,e]);const Ar=s.useRef(Le);Ar.current=Le,s.useEffect(()=>Wo(({runtimeKey:t,paths:a})=>{const l=u?.path;t!==lt()||!l||Ar.current||!a.includes(U(l))||(Lt.current+=1,jt.current=null,Ke.current=null,Be(""),we(null),ce(null),Hi(d=>d+1))}),[u?.path]),s.useEffect(()=>{if(!e||!u?.path||Ne!==u.path)return;const t=u.path,a=lt(),l=V.current,d=()=>Ar.current||hr(t)&&pt.current!==sr.current,p=!pr(t)&&!Sn(t)&&!Ft?fl({readContent:()=>zr(t,{fresh:!0}),getLoadedContent:()=>sn.current,getLoadedRevision:()=>an.current,isDirty:d,applyContent:z=>{if(!(g||lt()!==a||V.current!==l)){if(ui(z)){ce(null);return}Wt(z)}}}):null;let g=!1,C=!1;const A=()=>{document.hidden||C||(C=!0,vt(t).then(async z=>{if(g||lt()!==a||V.current!==l||!z)return;const ie=Ke.current;if(!ie||ie.path!==t){Ke.current=z;return}if(pl(ie,z)){if(p&&z.size<=zl){await p.poll()&&!g&&(Ke.current=z);return}Ar.current||(Ke.current=z,ce(null))}}).catch(()=>{}).finally(()=>{C=!1}))};A();const se=window.setInterval(A,2e3);return()=>{g=!0,p?.dispose(),window.clearInterval(se)}},[Wt,Ft,Ne,zr,vt,u?.path,e]);const ga=s.useCallback(()=>{const t=It.current,a=ar.current;if(It.current=null,ar.current=null,or.current=!0,ir(!1),Ce(O),a){c&&Mt(c,a),u?.path===a&&(t?Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){Pe(t);return}},[O,Pe,m,Mt,c,u?.path,Fe]),va=s.useCallback(async()=>{const t=It.current,a=ar.current;if(!await _t()){or.current=!1;return}if(It.current=null,ar.current=null,or.current=!0,ir(!1),a){c&&Mt(c,a),u?.path===a&&(t?await Pe(t):(c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)));return}if(t){await Pe(t);return}},[Pe,m,Mt,c,_t,u?.path,Fe]),js=s.useCallback(t=>{const a=u?.path===t,l=ys(t,zt);if(a&&Le){ir(!0),It.current=l,ar.current=t;return}if(c&&Mt(c,t),!!a){if(l){Pe(l);return}c&&Fe(c,null),me(""),we(null),Be(""),ce(null),m&&H(!1)}},[ys,Pe,Le,m,zt,Mt,c,u?.path,Fe]),Fs=s.useMemo(()=>new Set(je),[je]),Ir=s.useMemo(()=>Uo(M?de?.files??[]:[]),[de?.files,M]),xa=s.useCallback(t=>{if(Fs.has(t))return"open";const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.statusByPath.get(a)??null},[Fs,Ir,c]),wa=s.useCallback(t=>{if(!de?.files)return null;const a=t.startsWith(c+"/")?t.slice(c.length+1):t;return Ir.badgeByDir.get(a)??null},[de,Ir,c]),ba=s.useCallback(async t=>{const a=U(t);c&&(Ln(c,a),Oe.current.has(a)||await Ve(a))},[Ve,c,Ln]),ya=s.useMemo(()=>({canRename:es,canCreateFile:Zn,canCreateFolder:Qn,canDelete:ts,canReveal:rs}),[es,Zn,Qn,ts,rs]);function Ns(t,a){const l=$n[t]??[];return l.map((d,p)=>{const g=d.type==="directory",C=g&&Ii.has(d.path),A=u?.path===d.path,se=p===l.length-1;return n.jsxs("li",{className:"relative",children:[a>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),se&&n.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),n.jsx(Ll,{node:d,root:c,isExpanded:C,isActive:A,isMobile:m,isBrowserClient:N,alwaysShowActions:k,status:g?void 0:xa(d.path),badge:g?wa(d.path):void 0,permissions:ya,downloadFile:o.downloadFile,contextMenuPath:ea,setContextMenuPath:ta,rightClickMenuPath:ra,setRightClickMenuPath:na,onSelect:Pe,onToggle:ba,onRevealPath:ua,onOpenDialog:fn}),g&&C&&n.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[br[d.path]?n.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:br[d.path],children:br[d.path]}),n.jsxs(I,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{$e(d.path)},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):null,Ns(d.path,a+1)]})]},d.path)})}const Re=!!(u?.path&&Sn(u.path)),Or=!!(u?.path&&li(u.path)),_e=!!(u?.path&&ci(u.path)),hn=!!(u?.path&&(pr(u.path)||Ft)),it=hn&&!Re&&!_e,Cs=s.useMemo(()=>U(nt?.path??""),[nt?.path]),Ut=!!(nt&&Cs&&qe&&qe===Cs&&!De&&!tt&&!Re&&!_e&&!it),xt=s.useMemo(()=>Jr(c,qe),[qe,c]),ja=!!(u&&(!Re||Or)&&!_e&&!it&&O.length>0),Fa=!!(u&&xt.length>0),Xe=!!(u&&!wr&&!hn&&!Re&&o.writeFile),Je=!!(u?.path&&Vn(u.path)),qt=!!(u?.path&&Fi(u.path)),Kt=!!(u?.path&&Hr(u.path)),fr=!!(u?.path&&hr(u.path)),Br=!!(u&&!hn&&!Re)&&!Je&&!fr&&!(Kt&&ve==="preview"),Na=Je&&ge==="edit"||Kt&&ve==="edit"||qt&&Q==="text"||!Je&&!Kt&&!qt&&_==="edit",$r=s.useMemo(()=>qe?go(qe):null,[qe]),[Ss,gn]=s.useState(null);s.useEffect(()=>{let t=!1;const a=u?.path;if(!a||$r){gn(null);return}return gn(null),vo(a).then(l=>{t||gn(l)}),()=>{t=!0}},[u?.path,$r]),s.useEffect(()=>{!Xe&&_==="edit"&&re("view")},[Xe,_]);const vn="openchamber:files:md-viewer-mode",xn="openchamber:files:html-viewer-mode",wn="openchamber:files:json-viewer-mode";s.useEffect(()=>{const t=u?.path;if(!t)return;re(Te.current[t]??"edit");let a=ur?"preview":"edit";try{const p=localStorage.getItem(vn);(p==="preview"||p==="edit")&&(a=p)}catch{}ne(Ie.current[t]??a);let l=ur?"preview":"edit";try{const p=localStorage.getItem(xn);(p==="preview"||p==="edit")&&(l=p)}catch{}fe(Vt.current[t]??l),ke(le.current[t]??(ur?"preview":"edit"));let d=ur?"tree":"text";try{const p=localStorage.getItem(wn);(p==="tree"||p==="text")&&(d=p)}catch{}ye(d)},[u?.path,ur]);const Ca=s.useCallback(t=>{const a=u?.path;a&&(Te.current[a]=t),re(t)},[u?.path]),Sa=s.useCallback(t=>{const a=u?.path;a&&(Ie.current[a]=t),ne(t);try{localStorage.setItem(vn,t)}catch{}},[u?.path]),Ae=s.useCallback(()=>ge,[ge]),Rs=u&&Je&&Ae()==="preview"&&!De?u.path:null;s.useEffect(()=>{!Rs||m||Tr()},[Tr,te,m,Rs]);const Ra=s.useCallback(t=>{ye(t);try{localStorage.setItem(wn,t)}catch{}},[]),ka=s.useCallback(t=>{const a=u?.path;a&&(Vt.current[a]=t),fe(t);try{localStorage.setItem(xn,t)}catch{}},[u?.path]),Ta=s.useCallback(t=>{const a=u?.path;if(a&&(le.current[a]=t),ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null),t==="edit")Ce(pt.current||O),ke(t);else{pt.current=ee;const l=a;ke("edit"),st.current=requestAnimationFrame(()=>{st.current=requestAnimationFrame(()=>{st.current=null,!(c&&l&&Ye.getState().byRoot[c]?.selectedPath!==l)&&(Et(d=>d+1),ke("preview"))})});return}},[ee,O,c,u?.path]),bn=s.useCallback(async(t,a)=>{if(!o.writeFile||a===sr.current)return!1;if(!(await o.writeFile(t,a))?.success)return J.error(r("filesView.toast.writeFileFailed")),!1;Wt(a);const d=await vt(t).catch(()=>null);return d&&(Ke.current=d),!0},[Wt,o,vt,r]);s.useEffect(()=>()=>{ze.current&&(clearTimeout(ze.current),ze.current=null),st.current!==null&&(cancelAnimationFrame(st.current),st.current=null)},[xe,u?.path]);const Ea=s.useCallback(t=>{if(pt.current=t,!Se||!u?.path||xe!=="preview"||!o.writeFile)return;ze.current&&clearTimeout(ze.current);const a=u.path;ze.current=setTimeout(()=>{ze.current=null,bn(a,t).then(l=>{l&&(Cr(!0),setTimeout(()=>Cr(!1),1500))}).catch(l=>{J.error(l instanceof Error?l.message:r("filesView.toast.saveFailed"))})},ws)},[Se,xe,o.writeFile,bn,u?.path,r]),Va=s.useMemo(()=>fr&&(pt.current||ee)||O,[ee,O,fr]),ks=s.useCallback(()=>ve,[ve]);s.useEffect(()=>{const t=l=>{const d=l?"preview":"edit",p=l?"tree":"text";for(const g of je)Te.current[g]="edit",Vn(g)&&(Ie.current[g]=d),Hr(g)&&(Vt.current[g]=d),hr(g)&&(le.current[g]=d);re("edit"),ne(d),fe(d),ke(d),ye(p);try{localStorage.setItem(vn,d),localStorage.setItem(xn,d),localStorage.setItem(wn,p)}catch{}},a=l=>{const d=!!l.detail?.enabled;t(d)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",a),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",a)}},[je]),s.useEffect(()=>{if(!nt||!c)return;const t=()=>{typeof window>"u"||Ot.current===null&&(Ot.current=window.requestAnimationFrame(()=>{Ot.current=null,ln(ot=>ot+1)}))},a=(ot,kt)=>{if(ot.state.doc.length!==kt.length)return!1;if(kt.length===0)return!0;const Nn=Math.min(128,kt.length);if(ot.state.sliceDoc(0,Nn)!==kt.slice(0,Nn))return!1;const Qs=Math.max(0,kt.length-Nn);return ot.state.sliceDoc(Qs,kt.length)===kt.slice(Qs)},l=U(nt.path);if(!l){Vr(null),Nt.current={key:"",attempts:0};return}const d=`${l}:${nt.line}:${nt.column??1}`;if(Nt.current.key!==d&&(Nt.current={key:d,attempts:0}),u?.path!==l){if(on)return;Pe(Dt(l));return}if(De||Ne!==l)return;if(tt||Re||_e||it){Vr(null),Nt.current={key:"",attempts:0};return}if(!Xe)return;if(_!=="edit"){re("edit");return}const p=He.current;if(!p){t();return}if(!a(p,ee)){t();return}const g=Math.max(1,Math.min(nt.line,p.state.doc.lines)),C=p.state.doc.line(g),A=Math.max(1,nt.column||1),se=Math.max(0,C.to-C.from),z=Math.min(se,A-1),ie=C.from+z;if(!(p.state.selection.main.head===ie)||Nt.current.attempts===0){Nt.current.attempts+=1,p.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const ot=He.current;ot&&(ot.dispatch({selection:{anchor:ie},effects:Tt.scrollIntoView(ie,{y:"center"})}),ot.focus())}),Vr(null),Nt.current={key:"",attempts:0}},[Xe,on,ee,Yi,tt,De,Re,_e,it,Ne,Pe,nt,c,u?.path,Vr,_,Dt]),s.useEffect(()=>{if(!mn||!c)return;const t=U(mn);if(!t){pn(null);return}u?.path===t&&(De||Ne!==t||(!tt&&!Re&&!_e&&!it&&Xe&&_==="edit"&&He.current?.focus(),pn(null)))},[Xe,tt,De,Re,_e,it,Ne,mn,c,u?.path,pn,_]);const Ht=s.useCallback(t=>{if(!m||!t||!t.hasFocus||typeof window>"u")return;const a=window.visualViewport;if(!a)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(a.offsetTop+a.height))<=0)return;const p=t.state.selection.main.head,g=t.coordsAtPos(p);if(!g)return;const C=Math.round(a.offsetTop+a.height),se=g.bottom+20-C;se<=0||(t.scrollDOM.scrollTop+=se)},[m]);s.useEffect(()=>{if(!m||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Ht(He.current)})},a=window.visualViewport;return a?.addEventListener("resize",t),a?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{a?.removeEventListener("resize",t),a?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[m,Ht]),xo("open_go_to_line",t=>{if(!Xe||_!=="edit"||m)return!1;const a=t.target;if(a?.closest('[role="dialog"]')||!(a instanceof Node)||!Sr.current?.contains(a))return!1;const l=!!a?.closest(".cm-editor");if(!!a?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;dn(!0)});const _r=wt(t=>t.editorFontSize),Ts=s.useMemo(()=>{if(!u?.path)return[fi(h,{fontSize:_r})];const t=Cn(u.path),a=[fi(h,t?{syntaxColors:!1,fontSize:_r}:{fontSize:_r})],l=$r??Ss;return l&&a.push(l),t&&a.push(Eo({language:t,themeName:h.metadata.id,theme:Lo(h)})),G&&a.push(Tt.lineWrapping),m&&a.push(Tt.updateListener.of(d=>{d.view.hasFocus&&(d.selectionSet||d.focusChanged||d.viewportChanged||d.geometryChanged)&&window.requestAnimationFrame(()=>{Ht(d.view)})})),a},[h,u?.path,$r,Ss,G,m,Ht,_r]),Es=s.useMemo(()=>({light:Ze.metadata.id,dark:Pt.metadata.id}),[Ze.metadata.id,Pt.metadata.id]),mr=u?.path&&_e&&(!yt.allowOutsideWorkspace||yt.outsideFileGrant)?`${u.path}|${yt.allowOutsideWorkspace?"outside":"workspace"}|${yt.outsideFileGrant??""}|${Nr}`:"",Wr=u?.path&&Kt&&ve==="preview"&&!w.isVSCode?`${u.path}|${Nr}`:"",Vs=r("filesView.error.readFileFailed"),{readyKey:Ps,nonce:Pa}=Ci(Wr,we,Vs),{readyKey:Ms,nonce:Ds}=Ci(mr,we,Vs),Ma=!!(Wr&&Ps!==Wr),zs=!!(mr&&Ms!==mr),Ls=u?.path&&Re?Or?`data:${wo(u.path)};utf8,${encodeURIComponent(O)}`:Ui:"",As=u?.path&&_e&&mr&&Ms===mr?ni().authenticatedAsset("/api/fs/raw",{path:u.path,allowOutsideWorkspace:yt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:yt.outsideFileGrant,directory:c||void 0}):"",Is=s.useCallback(t=>n.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:n.jsx("iframe",{src:As,className:"h-full w-full border-0",title:t.name},Ds)}),[As,Ds]);s.useEffect(()=>{let t=!1,a="";return(async()=>{if(!u?.path||!Re||Or){Be("");return}we(null);const d=await et(u.path);if(t)return;await(o.readFileBinary?o.readFileBinary(u.path,d).then(g=>g.dataUrl):(async()=>{const g=await ri("/api/fs/raw",{query:{path:u.path,allowOutsideWorkspace:d.allowOutsideWorkspace?"true":void 0,outsideFileGrant:d.outsideFileGrant,directory:c||void 0}});if(!g.ok)throw new Error(r("filesView.error.readFileFailed"));const C=await g.blob();return a=URL.createObjectURL(C),t?(URL.revokeObjectURL(a),a="",""):a})()).then(g=>{t||(Be(g),ce(u.path))}).catch(g=>{t||(Be(""),we(g instanceof Error?g.message:r("filesView.error.readFileFailed")),ce(null))}).finally(()=>{t||ft(!1)})})(),()=>{t=!0,a&&URL.revokeObjectURL(a)}},[Nr,o,Re,Or,et,c,u?.path,yt,r]);const Da=s.useCallback(()=>cn(null),[]),za=s.useMemo(()=>Xo({drafts:os,editingDraftId:Mr,commentText:Pr,onTextChange:ls,selection:W,isDragging:ss,fileLabel:u?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:ps,onCancel:()=>{Ge(null),dr()},onEdit:t=>{fs(t),Ge({start:t.startLine,end:t.endLine})},onDelete:ms}),[dr,Pr,ms,Mr,os,ps,ss,W,u?.path,ls,fs]),Os=xi(),Bs=xi(),$s=!De&&!tt&&Ne===qe,Ur=$s&&Br&&_==="view"&&!(qt&&Q==="tree"),_s=$s&&Je&&Ae()==="preview",{setScroller:Ws,restore:La}=Kr(Ur?`${mt}:code`:null),{setScroller:Us,restore:Aa}=Kr(Ur?`${mt}:code:fullscreen`:null),{setScroller:qs}=Kr(_s?`${mt}:markdown`:null),{setScroller:Ks}=Kr(_s?`${mt}:markdown:fullscreen`:null),{setScroller:Hs}=Os,{setScroller:Gs}=Bs,Ia=s.useCallback(t=>{Hs(t),Ws(t)},[Hs,Ws]),Oa=s.useCallback(t=>{Gs(t),Us(t)},[Gs,Us]),Ba=s.useCallback(t=>{as.current=t,kr.current=t,qs(t)},[qs]),$a=s.useCallback(t=>{Er.current=t,Ks(t)},[Ks]),yn=No("unified"),at=ee.length>zi,jn=s.useMemo(()=>at&&Ur?Fl(ee):void 0,[Ur,ee,at]),Xs=s.useCallback((t,a,l,d)=>{const p={name:t.name,contents:a,lang:Cn(t.path)||void 0},g=C=>n.jsx(zo,{file:at&&jn?{...p,cacheKey:`${t.path}:${jn}`}:p,options:{disableFileHeader:!0,overflow:G?"wrap":"scroll",theme:Es,themeType:h.metadata.variant==="dark"?"dark":"light",onPostRender:d},className:at?"block w-full":"block h-full w-full",style:at?void 0:{height:"100%"}},C);return at?n.jsx("div",{className:"h-full",children:n.jsx(Ao.Provider,{value:l.virtualizer,children:n.jsx(Io.Provider,{value:yn,children:g(`${t.path}:${yn?"pool":"pending"}`)})})}):n.jsx("div",{className:"h-full",children:g(t.path)})},[h.metadata.variant,at,jn,Es,yn,G]),Js=({exitFullscreenOnly:t=!1,layout:a="floating"}={})=>{if(!u)return null;const l=a==="docked",d=bo(yo("save_file")),p=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",g=(C,A)=>n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:A})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:C})]});return n.jsxs("div",{className:p,children:[Xe&&Na&&n.jsxs(n.Fragment,{children:[nr?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[n.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),r("filesView.editor.saving")]}):Se&&Gi==="saved"&&!Le?n.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[n.jsx(F,{name:"check",className:"size-3.5"}),r("filesView.editor.saved")]}):Le?g(r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{_t()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:r(Se?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:d}),"aria-label":r("filesView.editor.saveAria",{shortcut:d}),children:n.jsx(F,{name:"save-3",className:"size-4"})})):null,g(r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Ji(!Se),className:K("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Se?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":r(Se?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Se?n.jsx(F,{name:"file-check-fill",className:"size-4"}):n.jsx(F,{name:"file-check",className:"size-4"})}))]}),n.jsxs(Pn,{onOpenChange:X,children:[n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex",children:n.jsx(Mn,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.openInDesktopApp"),"aria-label":r("filesView.editor.openInDesktopApp"),children:n.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.editor.openInDesktopApp")})]}),n.jsxs(Dn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[oa.map(C=>n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{da(C)},children:[n.jsx(Rl,{label:C.label,iconDataUrl:C.iconDataUrl}),n.jsx("span",{className:"typography-ui-label text-foreground",children:C.label})]},C.id)),la?n.jsxs(Xr,{className:"flex items-center gap-2",onClick:()=>{ca(!0)},children:[n.jsx(F,{name:"refresh",className:"size-4"}),n.jsx("span",{className:"typography-ui-label text-foreground",children:r("filesView.editor.refreshApps")})]}):null]})]}),!Re&&!_e&&!it&&n.jsxs(n.Fragment,{children:[g(r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>We(!G),className:K("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",G?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(G?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:n.jsx(F,{name:"text-wrap",className:"size-4"})})),_==="edit"&&n.jsxs(n.Fragment,{children:[g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{be(!Me),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),g(r("filesView.editor.goToLine"),n.jsx(I,{variant:"ghost",size:"sm",onClick:C=>{dn(A=>!A),C.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.goToLine"),children:n.jsx(F,{name:"menu-fold-2",className:"size-4"})})),n.jsx(il,{open:aa,onOpenChange:dn,view:He.current,variant:"inline"})]})]}),Br&&Xe&&!qt&&!Kt&&n.jsx(Tn,{currentMode:_==="view"?"preview":"edit",onToggle:()=>{Ca(_==="view"?"edit":"view")}}),Je&&g(r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Sa(Ae()==="preview"?"edit":"preview"),className:K("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":r(Ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:n.jsx(F,{name:Ae()==="preview"?"eye":"eye-off",className:"size-4"})})),Hr(u?.path??"")&&n.jsx(Tn,{currentMode:ks(),onToggle:()=>{ka(ks()==="preview"?"edit":"preview")}}),Je&&Ae()==="preview"&&g(r("filesView.editor.findInFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Rr(!0),Yn(C=>C+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.findInFile"),children:n.jsx(F,{name:"search",className:"size-4"})})),Je&&Ae()==="preview"&&fa&&n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx(I,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{Fr?Wi():O.trim()&&_i(O)},children:Fr?n.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"volume-up",className:"size-4"})})}),n.jsx(Yt,{sideOffset:8,children:r(Fr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),fr&&n.jsxs(n.Fragment,{children:[n.jsx(Tn,{currentMode:xe,onToggle:()=>Ta(xe==="preview"?"edit":"preview")}),xe==="preview"&&n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{const C=Un.current?.getXml();if(ze.current&&(clearTimeout(ze.current),ze.current=null),u?.path&&C){if(!await bn(u.path,C))return;Cr(!0),setTimeout(()=>Cr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.diagram.saveDiagram"),children:Xi?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"save-3",className:"size-4"})})]}),qt&&g(r(Q==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Ra(Q==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:r(Q==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Q==="tree"?n.jsx(F,{name:"code-sslash",className:"size-4"}):n.jsx(F,{name:"node-tree",className:"size-4"})})),ja&&g(r("filesView.editor.copyFileContents"),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(O)).ok?(Hn(!0),lr.current!==null&&window.clearTimeout(lr.current),lr.current=window.setTimeout(()=>{Hn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFileContents"),"aria-label":r("filesView.editor.copyFileContents"),children:sa?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"clipboard",className:"size-4"})})),Fa&&g(r("filesView.editor.copyFilePathTitle",{path:xt}),n.jsx(I,{variant:"ghost",size:"sm",onClick:async()=>{(await Yr(xt)).ok?(Gn(!0),cr.current!==null&&window.clearTimeout(cr.current),cr.current=window.setTimeout(()=>{Gn(!1)},1200)):J.error(r("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.copyFilePathTitle",{path:xt}),"aria-label":r("filesView.editor.copyFilePathTitle",{path:xt}),children:ia?n.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):n.jsx(F,{name:"file-copy-2",className:"size-4"})})),o.downloadFile&&g(r("filesView.editor.saveFile"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{const C=o.downloadFile;C&&C(u.path).catch(A=>{console.error("Download failed:",A),J.error(r("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.saveFile"),"aria-label":r("filesView.editor.saveFile"),children:n.jsx(F,{name:"download",className:"size-4"})})),t?g(r("filesView.editor.exitFullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>he(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r("filesView.editor.exitFullscreen"),"aria-label":r("filesView.editor.exitFullscreen"),children:n.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!m&&i==="full"&&g(r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>he(!te),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":r(te?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:te?n.jsx(F,{name:"fullscreen-exit",className:"size-4"}):n.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},Fn=n.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[n.jsx(Ri,{open:on,onOpenChange:t=>{t||ir(!0)},children:n.jsxs(ki,{showCloseButton:!1,className:"max-w-md",children:[n.jsxs(Ti,{children:[n.jsx(Ei,{children:r("filesView.unsaved.title")}),n.jsx(Vi,{children:r("filesView.unsaved.description")})]}),n.jsxs(Pi,{children:[n.jsx(I,{variant:"outline",onClick:()=>{va()},disabled:nr,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:r("filesView.unsaved.saveChanges")}),n.jsx(I,{variant:"destructive",onClick:ga,children:r("filesView.unsaved.discard")})]})]})}),n.jsxs("div",{className:K("flex flex-col flex-shrink-0",B&&"border-b border-border/40"),children:[B?n.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[m&&oe&&n.jsx("button",{type:"button",onClick:()=>H(!1),"aria-label":r("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:n.jsx(F,{name:"arrow-left-s",className:"size-5"})}),m?u?n.jsxs(Pn,{children:[n.jsx(Mn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":r("filesView.editor.openFilesAria"),children:[n.jsx(Gr,{filePath:u.path,extension:u.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:u.name}),n.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),n.jsx(Dn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs(Xr,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}a||Pe(t)},className:K("flex min-w-0 items-center justify-between gap-2 overflow-hidden",a&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[n.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx(yi,{name:t.name})]}),n.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),js(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")}):zt.length>0?n.jsxs("div",{className:"relative min-w-0 flex-1",children:[In.left&&n.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),In.right&&n.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),n.jsx("div",{ref:tn,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:zt.map(t=>{const a=u?.path===t.path;return n.jsxs("div",{title:Jr(c,t.path),className:K("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",a?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[n.jsx(Gr,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),n.jsx("button",{type:"button",onClick:()=>{a||Pe(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),n.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),js(t.path)},className:K("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!a&&!k&&"opacity-0 group-hover:opacity-100"),"aria-label":r("filesView.editor.closeFileAria",{name:t.name}),children:n.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):n.jsx("div",{className:"typography-ui-label font-medium truncate",children:r("filesView.editor.selectFile")})]}):null,u?n.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[xt&&!m?n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:xt,children:xt}):null,n.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Js({layout:"docked"})})]}):null]}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:n.jsx(Rn,{ref:Ia,outerClassName:"h-full min-w-0",className:K("h-full min-w-0",at&&"[overflow-anchor:none]"),children:u?De||zs?$?n.jsx("div",{className:"p-3"}):n.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.loading")]}):tt?n.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:tt}):Re?n.jsx("div",{className:"flex h-full items-center justify-center p-3",children:n.jsx("img",{src:Ls,alt:u?.name??r("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):u&&fr&&xe==="preview"?n.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:n.jsx(Cl,{ref:Un,xml:Va,onChange:Ea},`${u.path}:${Ue}`)}):u&&qt&&Q==="tree"?n.jsx(kn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.jsonViewerUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToTextMode")})]}),children:n.jsx("div",{className:"h-full overflow-auto",children:n.jsx(Do,{jsonString:O,maxHeight:"100%",initiallyExpandedDepth:2})})}):u&&Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:Tr,ref:Ba,children:[n.jsx(pi,{containerRef:as,filePath:u.path,fileContent:O}),O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(kn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!te&&n.jsx(vi,{containerRef:kr,open:Xn,onOpenChange:Rr,focusNonce:Jn})]}):u&&Kt&&ve==="preview"?Ma?n.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:r("common.loading")}):n.jsx("div",{className:"h-full overflow-hidden",children:n.jsx("iframe",{src:!w.isVSCode&&Ps===Wr?(()=>{const t=u.path.split("/").map(a=>encodeURIComponent(a)).join("/");return ni().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:w.isVSCode?(()=>{const t=u.path.substring(0,u.path.lastIndexOf("/")+1);return t?O.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):O})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:r("filesView.editor.htmlPreviewTitle")},Pa)}):u&&Br&&_==="view"?Xs(u,ee,Os,La):n.jsxs("div",{className:K("relative h-full",Ut&&"overflow-hidden"),ref:Sr,children:[n.jsx("div",{className:K("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:mt,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",blockWidgets:za,onViewReady:t=>{He.current=t,ln(a=>a+1),window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null),ln(t=>t+1)},enableSearch:!0,searchOpen:Me,onSearchOpenChange:be,highlightLines:W?{start:Math.min(W.start,W.end),end:Math.max(W.start,W.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const d=t.state.doc.lineAt(a.from).number;if(W&&!l.shiftKey&&Math.min(W.start,W.end)===d&&Math.max(W.start,W.end)===d)return Ge(null),dr(),Bt.current=!1,gt.current=null,$t(!1),!0;if(m&&W&&!l.shiftKey){const p=Math.min(W.start,W.end,d),g=Math.max(W.start,W.end,d);return Ge({start:p,end:g}),Bt.current=!1,gt.current=null,$t(!1),!0}if(Bt.current=!0,gt.current=d,$t(!0),W&&l.shiftKey){const p=Math.min(W.start,d),g=Math.max(W.end,d);Ge({start:p,end:g})}else Ge({start:d,end:d});return!0},mouseover:(t,a,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Bt.current||gt.current===null)return!1;const d=t.state.doc.lineAt(a.from).number,p=Math.min(gt.current,d),g=Math.max(gt.current,d);return Ge({start:p,end:g}),$t(!0),!1},mouseup:()=>(Bt.current=!1,gt.current=null,$t(!1),!1)}}},mt)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]}):n.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:r("filesView.editor.pickFileFromTree")})})})]}),_a=!!(c&&$n[c]),Ys=c?br[c]:null,Zs=M?n.jsxs("section",{className:K("flex min-h-0 flex-col overflow-hidden",m?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[n.jsx("div",{className:K("flex flex-col gap-2 py-2",m?"px-3":"px-2"),children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1 min-w-0",children:[n.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),n.jsx(gr,{ref:pe,value:Y,onChange:t=>Z(t.target.value),placeholder:r("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),Y.trim().length>0&&n.jsx("button",{type:"button","aria-label":r("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{Z(""),pe.current?.focus()},children:n.jsx(F,{name:"close",className:"size-4"})})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFile",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFileTitle"),"aria-label":r("filesView.tree.actions.newFileTitle"),children:n.jsx(F,{name:"file-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFileTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>fn("createFolder",{path:y,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.newFolderTitle"),"aria-label":r("filesView.tree.actions.newFolderTitle"),children:n.jsx(F,{name:"folder-add",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.newFolderTitle")})]}),n.jsxs(Xt,{children:[n.jsx(Jt,{asChild:!0,children:n.jsx("span",{className:"inline-flex flex-shrink-0",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{Dr()},className:"size-8 p-0 flex-shrink-0",title:r("filesView.tree.actions.refreshTitle"),"aria-label":r("filesView.tree.actions.refreshTitle"),children:n.jsx(F,{name:"refresh",className:"size-4"})})})}),n.jsx(Yt,{side:"bottom",sideOffset:6,children:r("filesView.tree.actions.refreshTitle")})]})]})}),n.jsx(Rn,{outerClassName:"flex-1 min-h-0",className:K("py-2",m?"px-3":"px-2"),children:n.jsx("ul",{className:"flex flex-col",children:$i?n.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.tree.search.searching")]}):_n.length>0?_n.map(t=>{const a=u?.path===t.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>{Pe(t)},className:K("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",a?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ai(t.path,t.extension),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Ys?n.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[n.jsx("span",{className:"text-[var(--status-error)]",children:Ys}),n.jsxs(I,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Dr()},children:[n.jsx(F,{name:"refresh",className:"size-3.5"}),r("filesView.tree.actions.refreshTitle")]})]}):_a?Ns(c,0):n.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:r("filesView.state.loading")})})})]}):null,Wa=i==="full"&&te&&u&&n.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:n.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[n.jsx("div",{className:"absolute right-4 top-4 z-30",children:Js({exitFullscreenOnly:!0})}),n.jsx(Rn,{ref:Oa,outerClassName:"h-full min-w-0",className:K("h-full min-w-0",at&&"[overflow-anchor:none]"),children:De||zs?$?n.jsx("div",{className:"p-4"}):n.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):tt?n.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:tt}):Re?n.jsx("div",{className:"flex h-full items-center justify-center p-4",children:n.jsx("img",{src:Ls,alt:u.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},u.path)}):_e?Is(u):it?n.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("div",{className:"typography-ui-header text-foreground",children:r("filesView.editor.cannotPreviewBinary")}),n.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:r("filesView.editor.binaryFileDescription")}),o.downloadFile?n.jsxs(I,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=o.downloadFile;!t||!u||t(u.path).catch(a=>{console.error("Download failed:",a),J.error(r("sidebarFilesTree.toast.operationFailed"))})},children:[n.jsx(F,{name:"download",className:"mr-2 size-4"}),r("filesView.editor.saveFile")]}):null]}):Je&&Ae()==="preview"?n.jsxs("div",{className:"relative h-full min-h-0",children:[n.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:Tr,ref:$a,children:[u?n.jsx(pi,{containerRef:Er,filePath:u.path,fileContent:O}):null,O.length>500*1024&&n.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:r("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(O.length/1024)})}),n.jsx(kn,{fallback:n.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[n.jsx("div",{className:"mb-1 font-medium text-destructive",children:r("filesView.error.previewUnavailable")}),n.jsx("div",{className:"text-sm text-muted-foreground",children:r("filesView.error.switchToEditMode")})]}),children:n.jsx(di,{content:O,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),n.jsx(vi,{containerRef:Er,open:Xn,onOpenChange:Rr,focusNonce:Jn,className:"right-4 top-16"})]}):Br&&_==="view"?Xs(u,ee,Bs,Aa):n.jsxs("div",{className:K("relative h-full",Ut&&"overflow-hidden"),children:[n.jsx("div",{className:K("h-full",Ut&&"invisible"),children:n.jsx(Ni,{positionKey:`${mt}:fullscreen`,value:ee,onChange:Ce,readOnly:!Xe,vimMode:is==="vim",extensions:Ts,className:"h-full",onViewReady:t=>{He.current=t,window.requestAnimationFrame(()=>{Ht(t)})},onViewDestroy:()=>{He.current&&(He.current=null)}},`${mt}:fullscreen`)}),Ut&&n.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:n.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[n.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),r("filesView.state.openingFileAtChange")]})})]})})]})});return n.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[n.jsx(Al,{activeDialog:Ct,dialogData:St,dialogInputValue:ht,onDialogInputChange:Kn,isDialogSubmitting:Qi,onDialogSubmit:ha,onClose:Da,inputRef:Ki}),Wa,m?oe?Fn:Zs:i==="editor-only"?n.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Fn})}):n.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[j>=700&&n.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:Zs}),n.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Fn})]})]})};function Ol(i){return i+1}export{id as FilesView};