@surething/cockpit 1.0.214 → 1.0.216

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 (185) hide show
  1. package/.next-prod/BUILD_ID +1 -1
  2. package/.next-prod/app-path-routes-manifest.json +3 -3
  3. package/.next-prod/build-manifest.json +2 -2
  4. package/.next-prod/prerender-manifest.json +3 -3
  5. package/.next-prod/server/app/_global-error/page.js.nft.json +1 -1
  6. package/.next-prod/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next-prod/server/app/_global-error.html +1 -1
  8. package/.next-prod/server/app/_global-error.rsc +1 -1
  9. package/.next-prod/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next-prod/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next-prod/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  12. package/.next-prod/server/app/_global-error.segments/_head.segment.rsc +1 -1
  13. package/.next-prod/server/app/_global-error.segments/_index.segment.rsc +1 -1
  14. package/.next-prod/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  15. package/.next-prod/server/app/_not-found/page.js.nft.json +1 -1
  16. package/.next-prod/server/app/_not-found/page_client-reference-manifest.js +1 -1
  17. package/.next-prod/server/app/_not-found.html +1 -1
  18. package/.next-prod/server/app/_not-found.rsc +3 -3
  19. package/.next-prod/server/app/_not-found.segments/_full.segment.rsc +3 -3
  20. package/.next-prod/server/app/_not-found.segments/_head.segment.rsc +1 -1
  21. package/.next-prod/server/app/_not-found.segments/_index.segment.rsc +3 -3
  22. package/.next-prod/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  23. package/.next-prod/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  24. package/.next-prod/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  25. package/.next-prod/server/app/api/agent/test/route.js.nft.json +1 -1
  26. package/.next-prod/server/app/api/bash/route.js.nft.json +1 -1
  27. package/.next-prod/server/app/api/chat/codex/route.js +2 -2
  28. package/.next-prod/server/app/api/chat/codex/route.js.nft.json +1 -1
  29. package/.next-prod/server/app/api/chat/deepseek/route.js +2 -2
  30. package/.next-prod/server/app/api/chat/deepseek/route.js.nft.json +1 -1
  31. package/.next-prod/server/app/api/chat/kimi/route.js +2 -2
  32. package/.next-prod/server/app/api/chat/kimi/route.js.nft.json +1 -1
  33. package/.next-prod/server/app/api/chat/ollama/route.js +2 -2
  34. package/.next-prod/server/app/api/chat/ollama/route.js.nft.json +1 -1
  35. package/.next-prod/server/app/api/chat/route.js +2 -2
  36. package/.next-prod/server/app/api/chat/route.js.nft.json +1 -1
  37. package/.next-prod/server/app/api/claude-stats/route.js.nft.json +1 -1
  38. package/.next-prod/server/app/api/commands/route.js +1 -1
  39. package/.next-prod/server/app/api/commands/route.js.nft.json +1 -1
  40. package/.next-prod/server/app/api/comments/route.js.nft.json +1 -1
  41. package/.next-prod/server/app/api/db/columns/route.js.nft.json +1 -1
  42. package/.next-prod/server/app/api/db/connect/route.js.nft.json +1 -1
  43. package/.next-prod/server/app/api/db/disconnect/route.js.nft.json +1 -1
  44. package/.next-prod/server/app/api/db/export/route.js.nft.json +1 -1
  45. package/.next-prod/server/app/api/db/query/route.js.nft.json +1 -1
  46. package/.next-prod/server/app/api/db/schemas/route.js.nft.json +1 -1
  47. package/.next-prod/server/app/api/dev/spans/route.js.nft.json +1 -1
  48. package/.next-prod/server/app/api/extension/version/route.js.nft.json +1 -1
  49. package/.next-prod/server/app/api/file/route.js.nft.json +1 -1
  50. package/.next-prod/server/app/api/files/blame/route.js.nft.json +1 -1
  51. package/.next-prod/server/app/api/files/clipboard/route.js.nft.json +1 -1
  52. package/.next-prod/server/app/api/files/copy/route.js.nft.json +1 -1
  53. package/.next-prod/server/app/api/files/delete/route.js.nft.json +1 -1
  54. package/.next-prod/server/app/api/files/expanded/route.js.nft.json +1 -1
  55. package/.next-prod/server/app/api/files/index/route.js.nft.json +1 -1
  56. package/.next-prod/server/app/api/files/init/route.js.nft.json +1 -1
  57. package/.next-prod/server/app/api/files/paste/route.js.nft.json +1 -1
  58. package/.next-prod/server/app/api/files/read/route.js.nft.json +1 -1
  59. package/.next-prod/server/app/api/files/readdir/route.js.nft.json +1 -1
  60. package/.next-prod/server/app/api/files/recent/route.js.nft.json +1 -1
  61. package/.next-prod/server/app/api/files/save/route.js.nft.json +1 -1
  62. package/.next-prod/server/app/api/files/search/route.js.nft.json +1 -1
  63. package/.next-prod/server/app/api/files/stat/route.js.nft.json +1 -1
  64. package/.next-prod/server/app/api/files/text/route.js.nft.json +1 -1
  65. package/.next-prod/server/app/api/git/branch-diff/route.js.nft.json +1 -1
  66. package/.next-prod/server/app/api/git/branches/route.js.nft.json +1 -1
  67. package/.next-prod/server/app/api/git/commit-diff/route.js.nft.json +1 -1
  68. package/.next-prod/server/app/api/git/commits/route.js.nft.json +1 -1
  69. package/.next-prod/server/app/api/git/diff/route.js.nft.json +1 -1
  70. package/.next-prod/server/app/api/git/discard/route.js.nft.json +1 -1
  71. package/.next-prod/server/app/api/git/stage/route.js.nft.json +1 -1
  72. package/.next-prod/server/app/api/git/status/route.js.nft.json +1 -1
  73. package/.next-prod/server/app/api/git/unstage/route.js.nft.json +1 -1
  74. package/.next-prod/server/app/api/git/worktree/route.js.nft.json +1 -1
  75. package/.next-prod/server/app/api/global-state/route.js.nft.json +1 -1
  76. package/.next-prod/server/app/api/jupyter/load/route.js.nft.json +1 -1
  77. package/.next-prod/server/app/api/jupyter/save/route.js.nft.json +1 -1
  78. package/.next-prod/server/app/api/jupyter/shutdown/route.js.nft.json +1 -1
  79. package/.next-prod/server/app/api/lsp/definition/route.js.nft.json +1 -1
  80. package/.next-prod/server/app/api/lsp/hover/route.js.nft.json +1 -1
  81. package/.next-prod/server/app/api/lsp/references/route.js.nft.json +1 -1
  82. package/.next-prod/server/app/api/lsp/status/route.js.nft.json +1 -1
  83. package/.next-prod/server/app/api/lsp/warmup/route.js.nft.json +1 -1
  84. package/.next-prod/server/app/api/mysql/columns/route.js.nft.json +1 -1
  85. package/.next-prod/server/app/api/mysql/connect/route.js.nft.json +1 -1
  86. package/.next-prod/server/app/api/mysql/disconnect/route.js.nft.json +1 -1
  87. package/.next-prod/server/app/api/mysql/export/route.js.nft.json +1 -1
  88. package/.next-prod/server/app/api/mysql/query/route.js.nft.json +1 -1
  89. package/.next-prod/server/app/api/mysql/schemas/route.js.nft.json +1 -1
  90. package/.next-prod/server/app/api/neo4j/connect/route.js.nft.json +1 -1
  91. package/.next-prod/server/app/api/neo4j/disconnect/route.js.nft.json +1 -1
  92. package/.next-prod/server/app/api/neo4j/query/route.js.nft.json +1 -1
  93. package/.next-prod/server/app/api/neo4j/schema/route.js.nft.json +1 -1
  94. package/.next-prod/server/app/api/note/route.js.nft.json +1 -1
  95. package/.next-prod/server/app/api/ollama/models/route.js.nft.json +1 -1
  96. package/.next-prod/server/app/api/ollama/start/route.js.nft.json +1 -1
  97. package/.next-prod/server/app/api/open-cursor/route.js.nft.json +1 -1
  98. package/.next-prod/server/app/api/open-vscode/route.js.nft.json +1 -1
  99. package/.next-prod/server/app/api/pick-folder/route.js.nft.json +1 -1
  100. package/.next-prod/server/app/api/pinned-sessions/route.js.nft.json +1 -1
  101. package/.next-prod/server/app/api/project-settings/route.js.nft.json +1 -1
  102. package/.next-prod/server/app/api/project-state/route.js.nft.json +1 -1
  103. package/.next-prod/server/app/api/projectGraph/affected/route.js.nft.json +1 -1
  104. package/.next-prod/server/app/api/projectGraph/callees/route.js.nft.json +1 -1
  105. package/.next-prod/server/app/api/projectGraph/callers/route.js.nft.json +1 -1
  106. package/.next-prod/server/app/api/projectGraph/coedit/route.js.nft.json +1 -1
  107. package/.next-prod/server/app/api/projectGraph/context/route.js.nft.json +1 -1
  108. package/.next-prod/server/app/api/projectGraph/file/route.js.nft.json +1 -1
  109. package/.next-prod/server/app/api/projectGraph/file-functions/route.js.nft.json +1 -1
  110. package/.next-prod/server/app/api/projectGraph/impact/route.js.nft.json +1 -1
  111. package/.next-prod/server/app/api/projectGraph/related/route.js.nft.json +1 -1
  112. package/.next-prod/server/app/api/projectGraph/risk/route.js.nft.json +1 -1
  113. package/.next-prod/server/app/api/projectGraph/search/route.js +1 -1
  114. package/.next-prod/server/app/api/projectGraph/search/route.js.nft.json +1 -1
  115. package/.next-prod/server/app/api/projects/route.js.nft.json +1 -1
  116. package/.next-prod/server/app/api/redis/command/route.js.nft.json +1 -1
  117. package/.next-prod/server/app/api/redis/connect/route.js.nft.json +1 -1
  118. package/.next-prod/server/app/api/redis/delete/route.js.nft.json +1 -1
  119. package/.next-prod/server/app/api/redis/disconnect/route.js.nft.json +1 -1
  120. package/.next-prod/server/app/api/redis/get/route.js.nft.json +1 -1
  121. package/.next-prod/server/app/api/redis/keys/route.js.nft.json +1 -1
  122. package/.next-prod/server/app/api/redis/set/route.js.nft.json +1 -1
  123. package/.next-prod/server/app/api/review/[id]/comments/route.js.nft.json +1 -1
  124. package/.next-prod/server/app/api/review/[id]/replies/route.js.nft.json +1 -1
  125. package/.next-prod/server/app/api/review/[id]/route.js.nft.json +1 -1
  126. package/.next-prod/server/app/api/review/identify/route.js.nft.json +1 -1
  127. package/.next-prod/server/app/api/review/order/route.js.nft.json +1 -1
  128. package/.next-prod/server/app/api/review/route.js.nft.json +1 -1
  129. package/.next-prod/server/app/api/review/share-info/route.js.nft.json +1 -1
  130. package/.next-prod/server/app/api/review/users/route.js.nft.json +1 -1
  131. package/.next-prod/server/app/api/scheduled-tasks/route.js.nft.json +1 -1
  132. package/.next-prod/server/app/api/services/config/route.js.nft.json +1 -1
  133. package/.next-prod/server/app/api/services/scripts/route.js.nft.json +1 -1
  134. package/.next-prod/server/app/api/session/[sessionId]/fork/route.js.nft.json +1 -1
  135. package/.next-prod/server/app/api/session/[sessionId]/history/route.js.nft.json +1 -1
  136. package/.next-prod/server/app/api/session-by-path/route.js.nft.json +1 -1
  137. package/.next-prod/server/app/api/sessions/projects/[encodedPath]/route.js.nft.json +1 -1
  138. package/.next-prod/server/app/api/sessions/projects/route.js.nft.json +1 -1
  139. package/.next-prod/server/app/api/sessions/route.js.nft.json +1 -1
  140. package/.next-prod/server/app/api/settings/route.js.nft.json +1 -1
  141. package/.next-prod/server/app/api/skills/[id]/route.js.nft.json +1 -1
  142. package/.next-prod/server/app/api/skills/content/route.js.nft.json +1 -1
  143. package/.next-prod/server/app/api/skills/route.js.nft.json +1 -1
  144. package/.next-prod/server/app/api/terminal/aliases/route.js.nft.json +1 -1
  145. package/.next-prod/server/app/api/terminal/autocomplete/route.js.nft.json +1 -1
  146. package/.next-prod/server/app/api/terminal/bubble-order/route.js.nft.json +1 -1
  147. package/.next-prod/server/app/api/terminal/env/route.js.nft.json +1 -1
  148. package/.next-prod/server/app/api/terminal/history/route.js.nft.json +1 -1
  149. package/.next-prod/server/app/api/version/route.js.nft.json +1 -1
  150. package/.next-prod/server/app/favicon.ico/route.js.nft.json +1 -1
  151. package/.next-prod/server/app/manifest.webmanifest/route.js.nft.json +1 -1
  152. package/.next-prod/server/app/page.js.nft.json +1 -1
  153. package/.next-prod/server/app/page_client-reference-manifest.js +1 -1
  154. package/.next-prod/server/app/project/page.js.nft.json +1 -1
  155. package/.next-prod/server/app/project/page_client-reference-manifest.js +1 -1
  156. package/.next-prod/server/app/review/[id]/page.js.nft.json +1 -1
  157. package/.next-prod/server/app/review/[id]/page_client-reference-manifest.js +1 -1
  158. package/.next-prod/server/app-paths-manifest.json +3 -3
  159. package/.next-prod/server/chunks/2939.js +1 -1
  160. package/.next-prod/server/chunks/8916.js +1 -1
  161. package/.next-prod/server/chunks/9658.js +3 -3
  162. package/.next-prod/server/chunks/{7828.js → 9877.js} +11 -2
  163. package/.next-prod/server/middleware-build-manifest.js +1 -1
  164. package/.next-prod/server/pages/404.html +1 -1
  165. package/.next-prod/server/pages/500.html +1 -1
  166. package/.next-prod/server/server-reference-manifest.json +1 -1
  167. package/.next-prod/static/chunks/{5188-38f55b21ae1eeb28.js → 5188-415582403ef0e29c.js} +1 -1
  168. package/.next-prod/static/chunks/6345-e5ceeb2aeb698eb6.js +14 -0
  169. package/.next-prod/static/css/{f016b445331fc5a2.css → cc6d733cdf607b30.css} +1 -1
  170. package/.next-prod/trace +13 -13
  171. package/.next-prod/trace-build +1 -1
  172. package/README.md +8 -7
  173. package/README.zh.md +8 -7
  174. package/bin/cock-browser.mjs +93 -3
  175. package/bin/cock-codegraph.mjs +907 -0
  176. package/bin/cock-terminal.mjs +5 -0
  177. package/bin/cock.mjs +4 -4
  178. package/bin/cockpit-dev.mjs +9 -0
  179. package/bin/setup-dev.mjs +92 -0
  180. package/package.json +3 -2
  181. package/.next-prod/static/chunks/6345-fc2d45a72316c5f8.js +0 -14
  182. package/bin/cock-affected.mjs +0 -190
  183. package/bin/cock-dev.mjs +0 -6
  184. /package/.next-prod/static/{ekMRRxcvpy2AIjMrVn4lK → GAYKr2BmQpFqJgRJfvQ3D}/_buildManifest.js +0 -0
  185. /package/.next-prod/static/{ekMRRxcvpy2AIjMrVn4lK → GAYKr2BmQpFqJgRJfvQ3D}/_ssgManifest.js +0 -0
@@ -1,4 +1,4 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5188],{1058:(e,t,r)=>{r.d(t,{_:()=>a});var n=r(12115),s=r(90717),o=r(86957),l=r(46456);function a({cwd:e,filePath:t}){let[r,i]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{if(!e||!t)return;d(!0),m(null);let r=await o.t4.runPromiseExit((0,l.lb)(e,t));if("Success"===r._tag)i(r.value.comments??[]);else{let e="Fail"===r.cause._tag?r.cause.error:null,t=e?.cause;m(t instanceof Error?t.message:"Failed to load comments")}d(!1)},[e,t]);(0,n.useEffect)(()=>{x()},[x]),(0,n.useEffect)(()=>(0,s.zL)(()=>{x()}),[x]);let h=(0,n.useCallback)(async(r,n,s,a)=>{let c=await o.t4.runPromiseExit((0,l.BC)({cwd:e,filePath:t,startLine:r,endLine:n,content:s,...a?{selectedText:a}:{}}));if("Success"===c._tag&&c.value.comment){let e=c.value.comment;return i(t=>[...t,e]),e}return"Failure"===c._tag&&console.error("Failed to add comment:",c.cause),null},[e,t]),f=(0,n.useCallback)(async(t,r)=>{let n=await o.t4.runPromiseExit((0,l.vv)(e,t,r));if("Success"===n._tag&&n.value.comment){let e=n.value.comment;return i(r=>r.map(r=>r.id===t?e:r)),!0}return"Failure"===n._tag&&console.error("Failed to update comment:",n.cause),!1},[e]),p=(0,n.useCallback)(async t=>{let r=await o.t4.runPromiseExit((0,l.Tu)(e,t));return"Success"===r._tag?(i(e=>e.filter(e=>e.id!==t)),!0):(console.error("Failed to delete comment:",r.cause),!1)},[e]),g=(0,n.useCallback)(e=>r.filter(t=>e>=t.startLine&&e<=t.endLine),[r]);return{comments:r,isLoading:c,error:u,addComment:h,updateComment:f,deleteComment:p,refresh:x,getCommentsForLine:g}}},2228:(e,t,r)=>{r.d(t,{ProjectItem:()=>a});var n=r(95155),s=r(12115),o=r(79114);function l({number:e,isActive:t}){return(0,n.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${t?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,n.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:e})]})}function a({index:e,name:t,cwd:r,isActive:i,collapsed:c,hasUnread:d,isLoading:u,onClick:m,onRemove:x,onOpenNote:h}){let{t:f}=(0,o.Bd)(),[p,g]=(0,s.useState)(!1);return(0,n.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${c?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:m,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),title:r,children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(l,{number:e+1,isActive:i}),d&&!i&&!u&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),u&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"flex-1 truncate text-sm",children:t}),!u&&i?(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),p&&!c&&(0,n.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[h&&(0,n.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:e=>{e.stopPropagation(),h()},title:f("workspace.projectNotes"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,n.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:e=>{e.stopPropagation(),x()},title:f("workspace.closeProject"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})}},3292:(e,t,r)=>{r.d(t,{P:()=>c});var n=r(12115),s=r(95045),o=r(75346),l=r(49433),a=r(86957),i=r(82680);function c(){let[e,t]=(0,n.useState)([]),r=(0,n.useCallback)(()=>{let e=l.tryPromise({try:async()=>{let e=await fetch("/api/pinned-sessions");return await e.json()},catch:e=>new i.uV({message:"loadPinnedSessions failed",cause:e})});a.t4.runPromise(e.pipe(l.match({onSuccess:e=>t(e.sessions||[]),onFailure:()=>{}})))},[]);(0,n.useEffect)(()=>{r()},[r]),(0,n.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&r()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[r]);let c=(0,n.useCallback)(e=>{t(e);let r=l.tryPromise({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})})},catch:e=>new i.uV({message:"savePinnedSessions failed",cause:e})});a.t4.runFork(r.pipe(l.orElse(()=>l.void))),(0,s.F)(o.n.PinnedSessionsChanged,{})},[]),d=(0,n.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),u=(0,n.useCallback)((t,r,n)=>{e.some(e=>e.sessionId===t)||c([...e,{sessionId:t,cwd:r,customTitle:n}])},[e,c]),m=(0,n.useCallback)(t=>{c(e.filter(e=>e.sessionId!==t))},[e,c]),x=(0,n.useCallback)((t,r)=>{c(e.map(e=>e.sessionId===t?{...e,customTitle:r}:e))},[e,c]);return{pinnedSessions:e,isPinned:d,pinSession:u,unpinSession:m,updateTitle:x,reorder:(0,n.useCallback)(e=>{c(e)},[c]),reload:r}}},7320:(e,t,r)=>{r.d(t,{G:()=>a,t:()=>l});var n=r(95155),s=r(12115),o=r(79114);function l({x:e,y:t,range:r,lineSnapshot:a,container:i,onSubmit:c,onClose:d}){let{t:u}=(0,o.Bd)(),[m,x]=(0,s.useState)(""),[h,f]=(0,s.useState)(!1),p=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0}),j=a?.split("\n").slice(0,5).join("\n"),w=!!a&&a.split("\n").length>5;return(0,s.useEffect)(()=>{if(p.current&&i){let r=i.getBoundingClientRect(),n=p.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,i]),(0,s.useEffect)(()=>{g.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{h||!p.current||p.current.contains(e.target)||d()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d,h]),(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,n.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-amber-11",children:u("comments.addComment")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:r.start,end:r.end})})]})}),a&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[j,w&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:g,value:m,onChange:e=>x(e.target.value),placeholder:u("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:h,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!h&&m.trim()&&(f(!0),c(m.trim()))),"Escape"!==e.key||h||d()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:u(h?"comments.submitting":"comments.enterSubmit")})]})]})}function a({x:e,y:t,range:r,filePath:l,lineSnapshot:i,container:c,onSubmit:d,onClose:u,isChatLoading:m}){let{t:x}=(0,o.Bd)(),[h,f]=(0,s.useState)(""),p=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(p.current&&c){let r=c.getBoundingClientRect(),n=p.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,c]),(0,s.useEffect)(()=>{g.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let j=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,n.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-brand",children:x("comments.askAI")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:x("comments.lineRange",{start:r.start,end:r.end})})]}),l&&(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:l})]}),i&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[j,w&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:g,value:h,onChange:e=>f(e.target.value),placeholder:x("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&h.trim()&&(d(h.trim()),u())),"Escape"===e.key&&u()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:x(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},8648:(e,t,r)=>{r.d(t,{NoteModal:()=>C});var n=r(95155),s=r(12115),o=r(79114),l=r(69809),a=r(13439),i=r(37795),c=r(43561),d=r(5989),u=r(76065),m=r(43203),x=r(6268),h=r(48434),f=r(44695),p=r(59265),g=r(26932);function b(e){return e.storage.markdown.getMarkdown()}function v(){return[{label:l.A.t("slashCommands.heading1"),icon:"H1",description:l.A.t("slashCommands.heading1Desc"),action:e=>e.chain().focus().toggleHeading({level:1}).run()},{label:l.A.t("slashCommands.heading2"),icon:"H2",description:l.A.t("slashCommands.heading2Desc"),action:e=>e.chain().focus().toggleHeading({level:2}).run()},{label:l.A.t("slashCommands.heading3"),icon:"H3",description:l.A.t("slashCommands.heading3Desc"),action:e=>e.chain().focus().toggleHeading({level:3}).run()},{label:l.A.t("slashCommands.bulletList"),icon:"•",description:l.A.t("slashCommands.bulletListDesc"),action:e=>e.chain().focus().toggleBulletList().run()},{label:l.A.t("slashCommands.orderedList"),icon:"1.",description:l.A.t("slashCommands.orderedListDesc"),action:e=>e.chain().focus().toggleOrderedList().run()},{label:l.A.t("slashCommands.taskList"),icon:"☑",description:l.A.t("slashCommands.taskListDesc"),action:e=>e.chain().focus().toggleTaskList().run()},{label:l.A.t("slashCommands.blockquote"),icon:"❝",description:l.A.t("slashCommands.blockquoteDesc"),action:e=>e.chain().focus().toggleBlockquote().run()},{label:l.A.t("slashCommands.codeBlock"),icon:"<>",description:l.A.t("slashCommands.codeBlockDesc"),action:e=>e.chain().focus().toggleCodeBlock().run()},{label:l.A.t("slashCommands.table"),icon:"▦",description:l.A.t("slashCommands.tableDesc"),action:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:l.A.t("slashCommands.horizontalRule"),icon:"──",description:l.A.t("slashCommands.horizontalRuleDesc"),action:e=>e.chain().focus().setHorizontalRule().run()},{label:l.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:l.A.t("slashCommands.linkDesc"),action:e=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}function j({editor:e,query:t,position:r,onClose:o}){let[l,a]=(0,s.useState)(0),i=(0,s.useRef)(null),c=v().filter(e=>e.label.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));(0,s.useEffect)(()=>{queueMicrotask(()=>a(0))},[t]);let d=r=>{e.chain().focus().deleteRange({from:e.state.selection.from-t.length-1,to:e.state.selection.from}).run(),r.action(e),o()};return((0,s.useEffect)(()=>{let e=e=>{"ArrowDown"===e.key?(e.preventDefault(),a(e=>(e+1)%c.length)):"ArrowUp"===e.key?(e.preventDefault(),a(e=>(e-1+c.length)%c.length)):"Enter"===e.key?(e.preventDefault(),c[l]&&d(c[l])):"Escape"===e.key&&(e.preventDefault(),o())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[c,l,o]),0===c.length)?null:(0,n.jsx)("div",{ref:i,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:r.top,left:r.left},children:c.map((e,t)=>(0,n.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${t===l?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>d(e),onMouseEnter:()=>a(t),children:[(0,n.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:e.icon}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-medium",children:e.label}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.label))})}v();var w=r(76043),y=r(86957),k=r(49433),N=r(76900);function C({isOpen:e,onClose:t,projectCwd:r,projectName:v}){let{t:S}=(0,o.Bd)(),[L,E]=(0,s.useState)(!0),[M,T]=(0,s.useState)(!1),$=(0,s.useRef)(null),P=(0,s.useRef)(!1),[R,B]=(0,s.useState)(null),F=(0,s.useRef)(null),I=(0,s.useCallback)(async e=>{T(!0),"Success"===(await y.t4.runPromiseExit((0,N.Cq)(r,e).pipe(k.tapError(e=>k.sync(()=>console.error("Failed to save note:",e))))))._tag&&(P.current=!1),T(!1)},[r]),D=(0,s.useCallback)(e=>{P.current=!0,$.current&&clearTimeout($.current),$.current=setTimeout(()=>{I(e)},5e3)},[I]),A=(0,a.hG)({immediatelyRender:!1,extensions:[i.A.configure({heading:{levels:[1,2,3]}}),c.A.configure({placeholder:()=>l.A.t("editor.placeholder")}),d.XI.configure({resizable:!0}),u.H,m.n,x.A,h._,p.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),f.L.configure({nested:!0}),g.o.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(e,t,r)=>{if(r.metaKey||r.ctrlKey){let r=e.state.doc.resolve(t).marks().find(e=>"link"===e.type.name)?.attrs;if(r?.href)return window.open(r.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(e,t)=>{if("Backspace"===t.key&&_.current){let e=_.current;if(e.isActive("codeBlock")){let{$from:t}=e.state.selection,r=t.node(t.depth);if("codeBlock"===r.type.name&&""===r.textContent)return e.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==t.key||R||setTimeout(()=>{if(!_.current)return;let{from:e}=_.current.state.selection;if("/"===_.current.state.doc.textBetween(Math.max(0,e-1),e,"\n")){F.current=e;let t=_.current.view.coordsAtPos(e);B({query:"",position:{top:t.bottom+4,left:t.left}})}},0),!1}},onUpdate:({editor:e})=>{if(D(b(e)),null!==F.current){let{from:t}=e.state.selection;if(t<F.current)B(null),F.current=null;else{let r=e.state.doc.textBetween(F.current,t,"\n");r.includes(" ")||r.includes("\n")?(B(null),F.current=null):B(e=>e?{...e,query:r}:null)}}}}),_=(0,s.useRef)(A);(0,s.useEffect)(()=>{_.current=A},[A]),(0,s.useEffect)(()=>{e&&A&&(E(!0),B(null),F.current=null,y.t4.runPromiseExit((0,N.zF)(r)).then(e=>{"Success"===e._tag?(A.commands.setContent(e.value.content||""),P.current=!1):console.error("Failed to load note:",e.cause),E(!1)}))},[e,A,r]);let W=(0,s.useCallback)(()=>{$.current&&(clearTimeout($.current),$.current=null),P.current&&A&&I(b(A)),B(null),F.current=null,t()},[A,I,t]);return((0,s.useEffect)(()=>()=>{$.current&&clearTimeout($.current)},[]),(0,s.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(R?(B(null),F.current=null):W())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,W,R]),e)?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:W}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:v?S("editor.noteTitle",{name:v}):S("editor.noteUntitled")}),M&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:S("editor.saving")})]}),(0,n.jsx)("button",{onClick:W,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(w.NoteToolbar,{editor:A}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:L?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,n.jsx)("span",{children:S("common.loading")})}):(0,n.jsx)(a.$Z,{editor:A})})]}),R&&A&&(0,n.jsx)(j,{editor:A,query:R.query,position:R.position,onClose:()=>{B(null),F.current=null}})]}):null}},12786:(e,t,r)=>{r.d(t,{L:()=>s,Mu:()=>o});var n=r(41463);function s(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function o(){return s()?"⌘":"Ctrl+"}n.platform,n.platform,n.platform},17196:(e,t,r)=>{r.d(t,{Np:()=>d,ZD:()=>i,b8:()=>c,kS:()=>l,sQ:()=>a});var n=r(67014);let s=null,o=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function l(){return s||(s=(0,n.O_)({themes:["github-dark","github-light"],langs:[...o]})),s}function a(e){let t=e.split("/").pop()?.toLowerCase()||"",r=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let n={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[r||""]||"text";return o.includes(n)?n:"text"}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function c(e){return e.map(e=>e.color?`<span style="color:${e.color}">${i(e.content)}</span>`:i(e.content)).join("")}function d(e,t,r,n){if(!t)return[];let s=[],o=r?t:t.toLowerCase();for(let t=0;t<e.length;t++){let l=r?e[t]:e[t].toLowerCase(),a=0;for(;;){let e=l.indexOf(o,a);if(-1===e)break;let r=e+o.length;if(n){let n=e>0?l[e-1]:" ",o=r<l.length?l[r]:" ",a=!/\w/.test(n),i=!/\w/.test(o);a&&i&&s.push({lineIndex:t,startCol:e,endCol:r})}else s.push({lineIndex:t,startCol:e,endCol:r});a=e+1}}return s}},21484:(e,t,r)=>{r.d(t,{SettingsModal:()=>x});var n=r(95155),s=r(12115),o=r(79114),l=r(3238),a=r(34075),i=r(12786),c=r(53853),d=r(86957),u=r(49433),m=r(76900);function x({isOpen:e,onClose:t}){let{t:r,i18n:h}=(0,o.Bd)(),{theme:f,setTheme:p}=(0,l.D)(),g=(0,c.G)(),[b,v]=(0,s.useState)(""),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)("auto");(0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.M5)()).then(e=>{"Success"===e._tag&&e.value.language&&k(e.value.language)})},[e]);let N=(0,s.useCallback)(e=>{k(e),d.t4.runFork((0,m.DZ)({language:e}).pipe(u.orElse(()=>u.void)));let t="auto"===e?navigator.language.startsWith("zh")?"zh":"en":e;h.changeLanguage(t)},[h]),C=g?"installed":"not-installed",S=g?.version??null;if((0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.Wr)()).then(e=>{"Success"===e._tag&&e.value.version&&w(e.value.version)})},[e]),(0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.Or)()).then(e=>{"Success"===e._tag&&e.value.path&&v(e.value.path)})},[e]),!e)return null;let L=[{value:"system",label:r("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:r("settings.themeLight"),icon:"☀️"},{value:"dark",label:r("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("settings.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"p-4 space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.theme")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:L.map(e=>(0,n.jsxs)("button",{onClick:()=>p(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${f===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.language")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:r("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(e=>(0,n.jsxs)("button",{onClick:()=>N(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${y===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.browserExtension")}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===C?"bg-green-500":"bg-slate-400"}`}),(0,n.jsxs)("span",{children:["installed"===C&&`${r("settings.extensionInstalled")}${S?` (v${S})`:""}`,"not-installed"===C&&r("settings.extensionNotInstalled")]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r("settings.extensionDescription")}),"installed"!==C&&(0,n.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,n.jsx)("p",{className:"font-medium text-foreground",children:r("settings.installSteps")}),(0,n.jsxs)("p",{children:[r("settings.step1")," ",(0,n.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,n.jsx)("p",{children:r("settings.step2")}),(0,n.jsx)("p",{children:r("settings.step3")}),(0,i.L)()&&(0,n.jsx)("p",{dangerouslySetInnerHTML:{__html:r("settings.step4mac")}})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{onClick:()=>{let e=b||"chrome-extension";navigator.clipboard.writeText(e),(0,a.oR)(r("toast.copiedName",{name:e}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:r("settings.copyExtensionPath")}),"installed"===C&&(0,n.jsx)("button",{onClick:()=>{g?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(g.id,{type:"reload"}),(0,a.oR)(r("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:r("settings.reloadExtension")})]}),b&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:b})]})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.about")}),(0,n.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,n.jsxs)("p",{children:["Cockpit",j?` v${j}`:""]}),(0,n.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},23121:(e,t,r)=>{r.d(t,{n:()=>m});var n=r(12115),s=r(95045),o=r(75346),l=r(49433),a=r(86957),i=r(82680);let c=(e,t,r)=>l.tryPromise({try:async()=>{let n=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:r=>new i.uV({message:`${t} ${e} failed`,cause:r})}),d="SCHEDULED_TASKS_CHANGED";function u(){(0,s.F)(o.n.ScheduledTasksChanged,{}),document.querySelectorAll("iframe").forEach(e=>{try{e.contentWindow?.postMessage({type:d},"*")}catch{}})}function m(){let[e,t]=(0,n.useState)([]),[r,s]=(0,n.useState)(0),o=(0,n.useCallback)(()=>{let e;a.t4.runPromise((e="/api/scheduled-tasks",l.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new i.uV({message:`fetch ${e} failed`,cause:t})})).pipe(l.match({onSuccess:e=>{t(e.tasks??[]),s(e.unreadCount??0)},onFailure:()=>{}})))},[]);(0,n.useEffect)(()=>{o()},[o]),(0,n.useEffect)(()=>{let e=e=>{e.data?.type===d&&o()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[o]);let m=(0,n.useCallback)(async e=>{let t=await a.t4.runPromiseExit(c("/api/scheduled-tasks","POST",e));if("Success"!==t._tag)return null;let r=t.value;return r.task?(o(),u(),r.task):null},[o]),x=(0,n.useCallback)(async(e,t,r)=>{await a.t4.runPromise(c("/api/scheduled-tasks","PATCH",{id:e,action:t,fields:r}).pipe(l.asVoid).pipe(l.orElse(()=>l.void))),o(),u()},[o]),h=(0,n.useCallback)(e=>x(e,"pause"),[x]),f=(0,n.useCallback)(e=>x(e,"resume"),[x]),p=(0,n.useCallback)(async e=>{await a.t4.runPromise(c("/api/scheduled-tasks","DELETE",{id:e}).pipe(l.asVoid).pipe(l.orElse(()=>l.void))),o(),u()},[o]),g=(0,n.useCallback)((e,t)=>x(e,"update",t),[x]),b=(0,n.useCallback)(e=>x(e,"trigger"),[x]),v=(0,n.useCallback)(e=>x(e,"markRead"),[x]);return{tasks:e,unreadCount:r,reload:o,createTask:m,pauseTask:h,resumeTask:f,triggerTask:b,deleteTask:p,updateTask:g,markRead:v,markAllRead:(0,n.useCallback)(()=>x("_","markAllRead"),[x]),reorderTasks:(0,n.useCallback)(e=>x("_","reorder",{orderedIds:e}),[x])}}},24058:(e,t,r)=>{r.d(t,{TabBar:()=>d});var n=r(95155),s=r(12115),o=r(94287),l=r(64428),a=r(79114);function i({number:e,isActive:t}){return(0,n.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${t?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,n.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:e})]})}function c({onNewTab:e,onNewClaude2Tab:t,onNewCodexTab:r,onNewKimiTab:o,onNewOllamaTab:a,onNewDeepseekTab:i}){let[d,u]=(0,s.useState)(!1),m=(0,s.useRef)(null),x=(0,s.useRef)(null),[h,f]=(0,s.useState)({top:0,right:0}),p=(0,l.F2)();(0,s.useEffect)(()=>{if(!d)return;let e=e=>{x.current&&!x.current.contains(e.target)&&m.current&&!m.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);let g=n=>{u(!1),"claude2"===n?t?.():"codex"===n?r?.():"kimi"===n?o?.():"ollama"===n?a?.():"deepseek"===n?i?.():e()};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:m,onClick:()=>{if(!d&&m.current){let e=m.current.getBoundingClientRect(),t=p?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0,s=t?.width??window.innerWidth;f({top:e.bottom+4-n,right:s-(e.right-r)})}u(e=>!e)},className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"New tab",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),d&&(0,n.jsx)(l.ZL,{children:(0,n.jsxs)("div",{ref:x,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[140px]",style:{top:h.top,right:h.right},children:[(0,n.jsxs)("button",{onClick:()=>g("claude"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}),"Claude Code"]}),(0,n.jsxs)("button",{onClick:()=>g("claude2"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-500 flex-shrink-0"}),"Claude 2"]}),(0,n.jsxs)("button",{onClick:()=>g("codex"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),"OpenAI Codex"]}),(0,n.jsxs)("button",{onClick:()=>g("deepseek"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),"DeepSeek"]}),(0,n.jsxs)("button",{onClick:()=>g("kimi"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"}),"Kimi"]}),(0,n.jsxs)("button",{onClick:()=>g("ollama"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-violet-500 flex-shrink-0"}),"Ollama"]})]})})]})}function d({tabs:e,activeTabId:t,unreadTabs:r,dragTabIndex:s,dragOverTabIndex:l,isPinned:u,onTogglePin:m,onSwitchTab:x,onCloseTab:h,onNewTab:f,onNewClaude2Tab:p,onNewCodexTab:g,onNewKimiTab:b,onNewOllamaTab:v,onNewDeepseekTab:j,onDragStart:w,onDragOver:y,onDrop:k,onDragEnd:N}){let{t:C}=(0,a.Bd)();return(0,n.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,n.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[e.map((a,c)=>(0,n.jsx)(o.m,{content:a.title,delay:200,className:"flex-1 min-w-16 max-w-32",children:(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>w(c),onDragOver:e=>y(e,c),onDrop:()=>k(c),onDragEnd:N,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${a.id===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${s===c?"opacity-50":""} ${l===c?"border-l-2 border-brand":""}`,onClick:()=>x(a.id),children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(i,{number:c+1,isActive:a.id===t}),a.isLoading&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!a.isLoading&&r.has(a.id)&&a.id!==t&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),m&&u?.(a.id)&&!a.isLoading&&!(r.has(a.id)&&a.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m(a.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:C("tabBar.unpin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),m&&!u?.(a.id)&&!a.isLoading&&!(r.has(a.id)&&a.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m(a.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:C("tabBar.pin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,n.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.title}),"claude2"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-orange-500/15 text-orange-400 font-medium leading-relaxed",children:"C2"}),"codex"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-emerald-500/15 text-emerald-400 font-medium leading-relaxed",children:"CX"}),"kimi"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-blue-500/15 text-blue-400 font-medium leading-relaxed",children:"KM"}),"ollama"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-violet-500/15 text-violet-400 font-medium leading-relaxed",children:"OL"}),"deepseek"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-sky-500/15 text-sky-400 font-medium leading-relaxed",children:"DS"}),e.length>1&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),h(a.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:C("tabBar.closeTab"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},a.id)),(0,n.jsx)(c,{onNewTab:f,onNewClaude2Tab:p,onNewCodexTab:g,onNewKimiTab:b,onNewOllamaTab:v,onNewDeepseekTab:j})]})})}},27570:(e,t,r)=>{r.d(t,{L:()=>s});var n=r(12115);function s({enabled:e,container:t,resolveLineRange:r,buildLineSnapshot:o,dragThresholdPx:l=5}){let a=(0,n.useRef)(null),i=(0,n.useRef)(()=>{}),c=(0,n.useRef)(r),d=(0,n.useRef)(o),u=(0,n.useRef)(l);return c.current=r,d.current=o,u.current=l,(0,n.useEffect)(()=>{if(!e||!t)return;let r=!1,n=0,s=0,o=()=>{a.current&&(a.current=null,i.current())},l=e=>{r=!0,n=e.clientX,s=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||o()},m=e=>{r=!1;let l=e.target;if(l?.closest?.(".floating-toolbar"))return;let m=u.current,x=Math.abs(e.clientX-n)>m||Math.abs(e.clientY-s)>m,h=window.getSelection();if(!h||h.isCollapsed||!h.toString().trim()||!x)return void o();let f=h.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void o();let p=c.current(f.startContainer),g=c.current(f.endContainer);if(!p||!g)return void o();let b=Math.min(p.start,g.start),v=Math.max(p.end,g.end),j=h.toString(),w=d.current({start:b,end:v});a.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:j,lineSnapshot:w},i.current()},x=()=>{if(r||!a.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||o()};return t.addEventListener("mousedown",l),document.addEventListener("mouseup",m),document.addEventListener("selectionchange",x),()=>{t.removeEventListener("mousedown",l),document.removeEventListener("mouseup",m),document.removeEventListener("selectionchange",x)}},[e,t]),{toolbarRef:a,bumpRef:i,clearToolbar:()=>{a.current&&(a.current=null,i.current())}}}},33408:(e,t,r)=>{r.d(t,{TabManager:()=>sd});var n=r(95155),s=r(12115),o=r(79114),l=r(95045),a=r(75346),i=r(86957),c=r(83448);function d({isOpen:e,onClose:t,cwd:r,onSelectSession:u}){let{t:m}=(0,o.Bd)(),[x,h]=(0,s.useState)([]),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(""),w=(0,s.useRef)(null),y=(0,s.useCallback)(async()=>{if(!r)return;p(!0),b(null);let e=r.replace(/\//g,"-"),t=await i.t4.runPromiseExit((0,c.QW)(e));"Success"===t._tag?h(t.value):b("Failed to load sessions"),p(!1)},[r]);(0,s.useEffect)(()=>{e&&(y(),setTimeout(()=>{w.current?.focus()},100))},[e,y]),(0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]);let k=x.filter(e=>{if(!v)return!0;let t=v.toLowerCase();return e.title.toLowerCase().includes(t)||e.firstMessages.some(e=>e.toLowerCase().includes(t))||e.lastMessages.some(e=>e.toLowerCase().includes(t))});return e?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),(0,n.jsxs)("div",{className:"relative w-full max-w-6xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:r,children:r})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsx)("input",{ref:w,type:"text",placeholder:m("sessions.searchSessions"),value:v,onChange:e=>j(e.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[f&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:m("sessions.loadingSessions")})]})}),g&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:g})}),!f&&!g&&0===k.length&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:m(v?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!f&&!g&&k.length>0&&(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:k.map(e=>(0,n.jsxs)("div",{onClick:()=>{let n;return n=(e.path.split("/").pop()||"").replace(".jsonl",""),void(u?(u(n,e.title),t()):(0,l.F)(a.n.OpenProject,{cwd:r,sessionId:n}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[e.engine&&"claude"!==e.engine&&(0,n.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===e.engine?"bg-orange-500/15 text-orange-11":"ollama"===e.engine?"bg-blue-500/15 text-blue-11":"codex"===e.engine?"bg-green-500/15 text-green-11":"kimi"===e.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:e.engine}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:e.title,children:e.title})]}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(e.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,n.jsxs)("div",{className:"space-y-0.5 text-xs",children:[e.firstMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`first-${t}`)),e.lastMessages.length>0&&(0,n.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),e.lastMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`last-${t}`))]})]},e.path))})]})]})]}):null}var u=r(47650),m=r(64428),x=r(60938),h=r(53213),f=r(64702),p=r(1058),g=r(90717),b=r(70188),v=r(48347),j=r(89109),w=r(7320);function y(e,t){let r=e.split("\n"),n=t.split("\n"),s=[],o=r.length,l=n.length,a=Array(o+1).fill(null).map(()=>Array(l+1).fill(0));for(let e=1;e<=o;e++)for(let t=1;t<=l;t++)r[e-1]===n[t-1]?a[e][t]=a[e-1][t-1]+1:a[e][t]=Math.max(a[e-1][t],a[e][t-1]);let i=o,c=l,d=[];for(;i>0||c>0;)i>0&&c>0&&r[i-1]===n[c-1]?(d.push({type:"unchanged",content:r[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||a[i][c-1]>=a[i-1][c])?(d.push({type:"added",content:n[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:r[i-1],oldLineNum:i}),i--);for(;d.length>0;)s.push(d.pop());return s}var k=r(34075),N=r(56978),C=r(17196);function S({lines:e,containerRef:t}){let r=(0,s.useRef)(null),[o,l]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:s}=e,o=r.current?.clientHeight||0;if(n<=s)l({top:0,height:o});else{let e=o/n;l({top:t*e,height:s*e})}};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[t]),0===e.length)return null;let a=100/e.length;return(0,n.jsxs)("div",{ref:r,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let n=t.current,s=r.current;if(!n||!s)return;let o=s.getBoundingClientRect(),l=(e.clientY-o.top)/o.height*n.scrollHeight-n.clientHeight/2;n.scrollTo({top:Math.max(0,l),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,n.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*a}%`,height:`${Math.max(a,.5)}%`,minHeight:"2px"}},t)),(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${o.top}px`,height:`${Math.max(o.height,10)}px`}})]})}var L=r(37614),E=r(27570);function M(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function T({oldContent:e,newContent:t,filePath:r,isNew:l=!1,isDeleted:a=!1,cwd:i,enableComments:c=!1,onPreview:d,previewLabel:m,onContentSearch:x,targetLine:h,compact:$=!1,symbols:P}){let{t:R}=(0,o.Bd)(),B=m??R("common.preview"),F=(0,s.useMemo)(()=>y(e,t),[e,t]),I=(0,s.useRef)(null),D=(0,s.useRef)(null),A=(0,s.useRef)(null),_=(0,s.useRef)(!1),[W,z]=(0,s.useState)(!1),H=(0,b.iN)(),O=(0,v.r)(),q=c&&!!i,{comments:V,addComment:K,updateComment:U,deleteComment:J,refresh:Q}=(0,p._)({cwd:i||"",filePath:r}),[X,Y]=(0,s.useState)(null),[Z,G]=(0,s.useState)(null);(0,s.useEffect)(()=>{A.current!==Z&&G(A.current)});let{toolbarRef:ee,bumpRef:et,clearToolbar:er}=(0,E.L)({enabled:q,container:Z,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=t?.closest("[data-new-line]");if(!r)return null;let n=parseInt(r.getAttribute("data-new-line")||"0",10);return!Number.isFinite(n)||n<=0?null:{start:n,end:n}},buildLineSnapshot:({start:e,end:t})=>{let r=[],n=0;for(let s of F)("unchanged"===s.type||"added"===s.type)&&++n>=e&&n<=t&&r.push(s.content);return r.join("\n")}}),[en,es]=(0,s.useState)(null),[eo,el]=(0,s.useState)(null);(0,s.useEffect)(()=>{z(!0)},[]);let ea=(0,s.useMemo)(()=>{let e=new Set;for(let t of V)for(let r=t.startLine;r<=t.endLine;r++)e.add(r);return e},[V]),ei=(0,s.useMemo)(()=>{let e=new Map;for(let t of V){let r=t.endLine;e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[V]),ec=(0,s.useCallback)((e,t)=>{t.stopPropagation(),Y({comment:e,x:t.clientX,y:t.clientY}),er(),es(null),el(null)},[er]),ed=(0,s.useCallback)(()=>{let e=ee.current;e&&(es({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),er())},[er,ee]),eu=(0,s.useCallback)(()=>{let e=ee.current;e&&(el({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),er())},[er,ee]),em=(0,s.useCallback)(()=>{let e=ee.current;if(!e||!x)return;let t=e.selectedText.trim();er(),t&&x(t)},[x,er,ee]),ex=(0,s.useCallback)(async e=>{if(eo&&O&&i)try{let t=await (0,g.$3)(i),n=[];for(let e of t)n.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});n.push({filePath:r,startLine:eo.range.start,endLine:eo.range.end,codeContent:eo.lineSnapshot});let s=(0,g.Gw)(n,e);O.sendMessage(s),await (0,g.RP)(i),Q(),el(null)}catch(e){console.error("Failed to send to AI:",e)}},[eo,O,r,i,Q]),eh=(0,s.useCallback)(async e=>{en&&(await K(en.range.start,en.range.end,e,en.selectedText),es(null))},[en,K]);(0,s.useEffect)(()=>{let e=D.current,t=A.current;if(!e||!t)return;let r=(e,t)=>{_.current||(_.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{_.current=!1}))},n=()=>r(e,t),s=()=>r(t,e);return e.addEventListener("scroll",n),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",n),t.removeEventListener("scroll",s)}},[]);let{leftLines:ef,rightLines:ep}=(0,s.useMemo)(()=>{let e=[],t=[],r=0,n=0;for(let s=0;s<F.length;s++){let o=F[s];if("unchanged"===o.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});r++,n++,e.push({lineNum:r,content:o.content,type:"unchanged",originalIdx:s}),t.push({lineNum:n,content:o.content,type:"unchanged",originalIdx:s})}else"removed"===o.type?(r++,e.push({lineNum:r,content:o.content,type:"removed",originalIdx:s})):"added"===o.type&&(n++,t.push({lineNum:n,content:o.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[F]),eg=(0,s.useMemo)(()=>F.map(e=>e.content),[F]),eb=(0,N.C)(eg,r),[ev,ej]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ej(new Map),eE.measure()},[ef,ep]);let ew=(0,s.useMemo)(()=>P??[],[P]),{rows:ey,gaps:ek}=(0,s.useMemo)(()=>$?function(e,t,r,n=[]){let s=e.length,o=r=>"unchanged"!==e[r].type||"unchanged"!==t[r].type,l=new Set;for(let e=0;e<s;e++){if(!o(e))continue;let t=Math.max(0,e-3),r=Math.min(s-1,e+3);for(let e=t;e<=r;e++)l.add(e)}let a=[];for(let e=0;e<s;e++){if(l.has(e))continue;let t=e;for(;e<s&&!l.has(e);)e++;a.push({id:a.length,startIdx:t,endIdx:e-1}),e--}for(let e of a){let t=r.get(e.id)??{topRevealed:0,bottomRevealed:0},n=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,n)),o=Math.max(0,Math.min(t.bottomRevealed,n-s));for(let t=e.startIdx;t<e.startIdx+s;t++)l.add(t);for(let t=e.endIdx-o+1;t<=e.endIdx;t++)l.add(t)}let i=[];for(let e=0;e<s;e++){let r;if(l.has(e)){i.push({kind:"diff",idx:e});continue}let o=e;for(;e<s&&!l.has(e);)e++;let c=e-1;e--;let d=a.find(e=>e.startIdx<=o&&c<=e.endIdx);if(!d)continue;let u=c-o+1,m=Math.min(20,u);if(n.length>0&&c+1<s)for(let e=c+1;e<s;e++){let s=t[e].lineNum;if(!(s<=0)){r=function(e,t){let r=null;for(let n of e)n.startLine<=t&&t<=n.endLine&&(!r||n.endLine-n.startLine<r.endLine-r.startLine)&&(r=n);return r}(n,s)??void 0;break}}i.push({kind:"gap-expand",gapId:d.id,direction:"up",revealCount:m}),i.push({kind:"gap-label",gapId:d.id,hiddenCount:u,enclosingFn:r}),i.push({kind:"gap-expand",gapId:d.id,direction:"down",revealCount:m})}return{rows:i,gaps:a}}(ef,ep,ev,ew):{rows:ef.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[$,ef,ef,ep,ev,ew]),eN=(0,s.useCallback)((e,t)=>{let r=ek.find(t=>t.id===e);r&&ej(n=>{let s=n.get(e)??{topRevealed:0,bottomRevealed:0},o=r.endIdx-r.startIdx+1-s.topRevealed-s.bottomRevealed;if(o<=0)return n;let l=Math.min(20,o),a="up"===t?{...s,topRevealed:s.topRevealed+l}:{...s,bottomRevealed:s.bottomRevealed+l};return new Map(n).set(e,a)})},[ek]),eC=(0,s.useCallback)(e=>{for(let t of ek)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[ek]),eS=(0,s.useCallback)(e=>ey[e]?.kind==="gap-label"?28:20,[ey]),eL=(0,s.useCallback)(e=>{let t=ey[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let r=ef[t.idx],n=ep[t.idx];return`d:${r?.lineNum??"x"}:${r?.type??"x"}:${n?.lineNum??"x"}:${n?.type??"x"}`},[ey,ef,ep]),eE=(0,f.Te)({count:ey.length,getScrollElement:()=>I.current,estimateSize:eS,getItemKey:eL,overscan:20}),eM=l?"w-1/4":a?"w-3/4":"w-1/2",eT=l?"w-3/4":a?"w-1/4":"w-1/2",e$=(0,s.useMemo)(()=>ey.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=ef[e.idx],r=ep[e.idx];return"removed"===t.type?{type:"removed"}:r?.type==="added"?{type:"added"}:{type:"unchanged"}}),[ey,ef,ep]),eP=eE.getTotalSize(),eR=eE.getVirtualItems();return(0,s.useEffect)(()=>{if(!h)return;let e=("after"===h.side?ep:ef).findIndex(e=>e.lineNum===h.line);if(-1===e)return;let t=ey.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eC(e);if(null!==t){let e=ek.find(e=>e.id===t);if(!e)return;let r=e.endIdx-e.startIdx+1;ej(e=>{let n=e.get(t)??{topRevealed:0,bottomRevealed:0};if(n.topRevealed+n.bottomRevealed>=r)return e;let s=new Map(e);return s.set(t,{topRevealed:r,bottomRevealed:0}),s})}return}let r=requestAnimationFrame(()=>{eE.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(r)},[h,ef,ep,ey]),(0,n.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,n.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,n.jsx)("div",{className:`${eM} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:l?"(New File)":a?"Deleted":"Old"}),(0,n.jsxs)("div",{className:`${eT} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,n.jsx)("span",{className:"block text-center",children:a?"(Deleted)":"New"}),(0,n.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[d&&(0,n.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:B}),!a&&t&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,k.oR)(R("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:R("common.copy")})]})]}),(0,n.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,n.jsx)("div",{ref:I,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,n.jsxs)("div",{className:"flex",style:{height:`${eP}px`},children:[(0,n.jsx)("div",{ref:D,className:`${eM} overflow-x-auto border-r border-border`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eR.map(e=>{let t=ey[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let r="gap-label"===t.kind;return(0,n.jsx)("div",{ref:eE.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:r?"bg-accent border-y border-border":""},e.key)}let r=ef[t.idx];return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===r.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:r.lineNum||""}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:r.originalIdx>=0&&eb[r.originalIdx]||(0,C.ZD)(r.content||" ")}})]},e.key)})})}),(0,n.jsx)("div",{ref:A,className:`${eT} overflow-x-auto`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eR.map(e=>{let t=ey[e.index];if("gap-expand"===t.kind)return(0,n.jsx)("button",{ref:eE.measureElement,"data-index":e.index,type:"button",onClick:()=>eN(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,n.jsx)("span",{className:"select-none",children:R("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,n.jsx)("span",{className:"flex-shrink-0",children:R("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,n.jsx)("span",{className:"truncate min-w-0 font-medium",title:M(t.enclosingFn),children:M(t.enclosingFn)})]})]},e.key);let r=ep[t.idx],s=r?.lineNum||0,o=s>0&&ea.has(s),l=ei.get(s),a=l?.[0],i=en&&s>=en.range.start&&s<=en.range.end,c=eo&&s>=eo.range.start&&s<=eo.range.end,d=i||c;return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":o?"bg-amber-9/10":r?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${d?"bg-blue-9/30":""}`,style:{width:q?"52px":"40px"},children:[q&&s>0&&o&&a&&(0,n.jsx)("button",{onClick:e=>ec(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:R("codeViewer.nComments",{count:l?.length}),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),q&&s>0&&!o&&(0,n.jsx)("span",{className:"w-4"}),(0,n.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:r?.originalIdx>=0&&eb[r.originalIdx]||(0,C.ZD)(r?.content||" ")}})]},e.key)})})})]})}),(0,n.jsx)(S,{lines:e$,containerRef:I})]}),W&&H&&(0,u.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.f,{floatingToolbarRef:ee,bumpRef:et,container:H,onAddComment:ed,onSendToAI:eu,onSearch:x?em:void 0,isChatLoading:O?.isLoading??!1}),en&&(0,n.jsx)(w.t,{x:en.x,y:en.y,range:en.range,lineSnapshot:en.lineSnapshot,container:H,onSubmit:eh,onClose:()=>es(null)}),eo&&(0,n.jsx)(w.G,{x:eo.x,y:eo.y,range:eo.range,filePath:r,lineSnapshot:eo.lineSnapshot,container:H,onSubmit:ex,onClose:()=>el(null),isChatLoading:O?.isLoading}),X&&(0,n.jsx)(L.t,{x:X.x,y:X.y,comment:X.comment,container:H,onClose:()=>Y(null),onUpdateComment:U,onDeleteComment:J})]}),H)]})}function $({oldContent:e,newContent:t,filePath:r}){let o=(0,s.useMemo)(()=>y(e,t),[e,t]),l=(0,s.useRef)(null),a=(0,s.useMemo)(()=>o.map(e=>e.content),[o]),i=(0,N.C)(a,r),c=(0,s.useCallback)(e=>{let t=o[e];return t?`${t.type}:${t.oldLineNum??"x"}:${t.newLineNum??"x"}`:e},[o]),d=(0,f.Te)({count:o.length,getScrollElement:()=>l.current,estimateSize:()=>20,getItemKey:c,overscan:20});return(0,n.jsx)("div",{ref:l,className:"font-mono text-sm overflow-auto h-full",children:(0,n.jsx)("div",{style:{height:`${d.getTotalSize()}px`,position:"relative"},children:d.getVirtualItems().map(e=>{let t=o[e.index];return(0,n.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===t.type?"bg-red-9/15 dark:bg-red-9/25":"added"===t.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==t.type?t.oldLineNum:""}),(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==t.type?t.newLineNum:""}),(0,n.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===t.type?"text-red-11":"added"===t.type?"text-green-11":"text-slate-9"}`,children:"removed"===t.type?"-":"added"===t.type?"+":" "}),(0,n.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:i[e.index]||(0,C.ZD)(t.content||" ")}})]},e.key)})})})}let P={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},R={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function B({name:e,className:t="",size:r=16}){let s,o=R[s=e.toLowerCase()]?R[s]:P[e.split(".").pop()?.toLowerCase()||""]||P.default,l=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===l||"tsx"===l&&e.includes("component")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:o})]}):["md","mdx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,n.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:o}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:o,strokeWidth:"2",fill:"none"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:o}),(0,n.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:o}),(0,n.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"html"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,n.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===l||".gitignore"===e.toLowerCase()?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:o}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,n.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===l||"dockerfile"===e.toLowerCase()||e.toLowerCase().startsWith("dockerfile")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:o}),(0,n.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"env"===l||e.startsWith(".env")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:o}),(0,n.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"vue"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:o}),(0,n.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M14 3v5h5",stroke:o,strokeWidth:"1.5",fill:"none"})]})}function F({status:e}){let{label:t,className:r}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,n.jsx)("span",{className:`text-xs font-bold ${r}`,children:t})}let I=s.memo(function e({node:t,level:r,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d=!1,renderActions:u}){let m=o===t.path,x=l.has(t.path),h=(0,s.useCallback)(()=>{t.isDirectory?i(t.path):a(t)},[t,a,i]),f=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),c(e,t.path,t.isDirectory)},[t.path,t.isDirectory,c]);return t.isDirectory?(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*r+8}px`},onClick:h,onContextMenu:f,children:[(0,n.jsx)("span",{className:"text-slate-9 text-xs",children:x?"▼":"▶"}),(0,n.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),u&&u(t)]}),x&&t.children.map(t=>(0,n.jsx)(e,{node:t,level:r+1,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d,renderActions:u},t.path))]}):(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${m?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*r+8}px`},onClick:h,onContextMenu:f,children:[(0,n.jsx)(B,{name:t.name,size:16,className:"flex-shrink-0"}),(0,n.jsx)("span",{className:`text-sm flex-1 truncate ${m?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,n.jsx)(F,{status:t.status}),d&&void 0!==t.additions&&void 0!==t.deletions&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,n.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),u&&u(t)]})});function D({files:e,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,cwd:a,showChanges:i=!1,renderActions:c,emptyMessage:d,className:u}){let{t:m}=(0,o.Bd)(),x=d??m("gitFileTree.noFiles"),{contextMenu:h,showContextMenu:f,hideContextMenu:p}=(0,b.Ee)();return 0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:x}):(0,n.jsxs)("div",{className:u||"py-1",children:[e.map(e=>(0,n.jsx)(I,{node:e,level:0,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,onContextMenu:f,showChanges:i,renderActions:c},e.path)),h&&(0,n.jsx)(b.ft,{x:h.x,y:h.y,path:h.path,cwd:a,isDirectory:h.isDirectory,onClose:p})]})}function A(e){let t=[];for(let r of e){let e=r.path.split("/"),n=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,l=e.slice(0,t+1).join("/"),a=n.find(e=>e.name===s);a||(a={name:s,path:l,isDirectory:!o,children:[],...o&&{status:r.status,additions:r.additions,deletions:r.deletions,oldPath:r.oldPath,file:r}},n.push(a)),o||(n=a.children)}}let r=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>r(e.children))};return r(t),t}function _(e){let t=[],r=e=>{for(let n of e)n.isDirectory&&(t.push(n.path),r(n.children))};return r(e),t}function W(e){let t=[],r=e=>{if(e.isDirectory)for(let t of e.children)r(t);else t.push(e)};return r(e),t}var z=r(69809);function H(e){try{let t=JSON.parse(e);return Q(t,0)}catch{return e}}let O="#79c0ff",q="#a5d6ff",V="#ff7b72",K="#8b949e",U=(e,t)=>s.createElement("span",{style:{color:e}},t);function J({label:e,labelColor:t,value:r,indent:n}){let[o,l]=s.useState(!1),[a,i]=s.useState({x:0,y:0}),c="string"==typeof r&&r.replace(/\\n/g,"\n").split("\n").length>3,d={onMouseDown:e=>{i({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-a.x,r=e.clientY-a.y;t*t+r*r>25||(e.stopPropagation(),l(e=>!e))},style:{cursor:"pointer"}};if(c&&o&&"string"==typeof r){let n=r.replace(/\\n/g,"\n").split("\n")[0],o=r.replace(/\\n/g,"\n").split("\n").length;return s.createElement("span",d,U(t,e),U(K,": "),U(q,n),U("#6e7681",` ${z.A.t("toolCall.foldedLines",{count:o})}`))}let u=s.createElement(s.Fragment,null,U(t,e),U(K,": "),Q(r,n));return c?s.createElement("span",d,u):u}function Q(e,t){let r=" ".repeat(t);if(null===e)return U(V,"null");if(void 0===e)return U(V,"undefined");if("string"==typeof e)return U(q,e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+r));if("number"==typeof e)return U("#79c0ff",String(e));if("boolean"==typeof e)return U(V,String(e));if(Array.isArray(e))return 0===e.length?U(K,"[]"):s.createElement(s.Fragment,null,U(K,"["),"\n",...e.map((n,o)=>s.createElement("span",{key:o},r+" ",s.createElement(J,{label:`[${o}]`,labelColor:O,value:n,indent:t+1}),o<e.length-1?s.createElement(s.Fragment,null,U(K,","),"\n"):"\n")),r,U(K,"]"));if("object"==typeof e){let n=Object.entries(e);return 0===n.length?U(K,"{}"):s.createElement(s.Fragment,null,U(K,"{"),"\n",...n.map(([e,o],l)=>s.createElement("span",{key:e},r+" ",s.createElement(J,{label:e,labelColor:O,value:o,indent:t+1}),l<n.length-1?s.createElement(s.Fragment,null,U(K,","),"\n"):"\n")),r,U(K,"}"))}return String(e)}let X=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function Y(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return X.has(t)}function Z(e){return e.toLowerCase().endsWith(".md")}let G="json-search-highlight-style";function ee(e){let[t,r]=(0,s.useState)(!1),[n,o]=(0,s.useState)(""),[l,a]=(0,s.useState)(!1),[i,c]=(0,s.useState)(0),[d,u]=(0,s.useState)(0),m=(0,s.useRef)(null),x=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),x.current=[];let r=e.current;if(!r||!n){c(0),u(0);return}!function(){if(document.getElementById(G))return;let e=document.createElement("style");e.id=G,e.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(e)}();let s=r.textContent||"",o=l?n:n.toLowerCase(),a=l?s:s.toLowerCase(),i=[],d=0;for(;d<a.length;){let e=a.indexOf(o,d);if(-1===e)break;i.push([e,e+o.length]),d=e+1}if(0===i.length){c(0),u(0);return}let m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),h=0,f=0,p=[],g=null,b=0;for(;(t=m.nextNode())&&f<i.length;){let e=t.textContent?.length||0,r=h,n=h+e;for(;f<i.length;){let[e,s]=i[f];if(e>=n)break;if(!g)if(e>=r)(g=document.createRange()).setStart(t,e-r),b=s;else break;if(b<=n)g.setEnd(t,b-r),p.push(g),g=null,f++;else break}h=n}x.current=p,c(p.length),u(e=>p.length>0?Math.min(e,p.length-1):0),CSS.highlights&&p.length>0&&CSS.highlights.set("json-search",new Highlight(...p))},[e,n,l]),f=(0,s.useCallback)((e,t)=>{let r=e.getBoundingClientRect();(t.top<r.top||t.bottom>r.bottom)&&(e.scrollTop+=t.top-r.top-r.height/2+t.height/2)},[]),p=(0,s.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let r=x.current[t];if(!r||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(r));let n=r.getBoundingClientRect(),s=e.current?.parentElement;s&&f(s,n)},[e,f]);(0,s.useEffect)(()=>{queueMicrotask(()=>h())},[h]),(0,s.useEffect)(()=>{p(d)},[d,i,p]),(0,s.useEffect)(()=>{let t=e.current;if(!t||!n)return;let r=new MutationObserver(()=>h());return r.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[e,n,h]),(0,s.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),x.current=[])},[t]),(0,s.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let g=(0,s.useCallback)(()=>{0!==i&&u(e=>(e+1)%i)},[i]),b=(0,s.useCallback)(()=>{0!==i&&u(e=>(e-1+i)%i)},[i]),v=(0,s.useCallback)(()=>{r(!0),setTimeout(()=>m.current?.focus(),0)},[]),j=(0,s.useCallback)(()=>{r(!1),o(""),u(0)},[]),w=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?b():g()),"Escape"===e.key&&(e.preventDefault(),j())},[g,b,j]);return{isVisible:t,query:n,setQuery:o,caseSensitive:l,setCaseSensitive:a,matchCount:i,currentIndex:d,searchInputRef:m,open:v,close:j,goToNext:g,goToPrev:b,handleKeyDown:w}}function et({search:e}){return e.isVisible?s.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},s.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:z.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),s.createElement("button",{onClick:()=>e.setCaseSensitive(e=>!e),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${e.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:z.A.t("codeViewer.caseSensitive")},"Aa"),s.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:z.A.t("common.noMatch")),s.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:z.A.t("common.previous")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),s.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:z.A.t("common.next")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),s.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:z.A.t("common.close")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}function er({isOpen:e,onClose:t,commit:r,cwd:l,embedded:a=!1,initialFilePath:c,onContentSearch:d}){let{t:u}=(0,o.Bd)(),[m,x]=(0,s.useState)([]),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(null),M=(0,s.useRef)(null),$=ee(M);(0,s.useEffect)(()=>{let r=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&L){e.preventDefault(),$.open();return}if("Escape"===e.key){if($.isVisible)return void $.close();if(L)return void E(null);t()}};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,L,$]),(0,s.useEffect)(()=>{e&&r&&(queueMicrotask(()=>{x([]),p([]),j(null),y(null),N(!0)}),i.t4.runPromiseExit((0,h.Zi)(l,r.hash)).then(e=>{if("Success"===e._tag){let t=e.value.files??[];x(t);let n=A(t);if(p(n),b(new Set(_(n))),c&&t.length>0){let e=t.find(e=>e.path===c);e&&setTimeout(()=>{j(e),i.t4.runPromiseExit((0,h.Zi)(l,r.hash,e.path)).then(e=>{"Success"===e._tag?y(e.value):console.error(e.cause)})},0)}}else console.error(e.cause);N(!1)}))},[e,r,l,c]);let P=(0,s.useCallback)(e=>{r&&(j(e),S(!0),i.t4.runPromiseExit((0,h.Zi)(l,r.hash,e.path)).then(e=>{"Success"===e._tag?y(e.value):console.error(e.cause),S(!1)}))},[l,r]),R=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),B=(0,s.useMemo)(()=>{if(!r)return"";if(r.date){let e,t,n,s,o,l,a;return e=new Date(r.date),t=new Date,n=e.getFullYear()===t.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),l=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),n?`${s}-${o} ${l}:${a}`:`${e.getFullYear()}-${s}-${o} ${l}:${a}`}return r.time?new Date(1e3*r.time).toLocaleString():""},[r]);if(!e||!r)return null;let F=(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border bg-secondary flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:r.subject}),r.body&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:r.body}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.hash")}),(0,n.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:r.hash})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.author")}),(0,n.jsx)("span",{children:r.author}),(0,n.jsxs)("span",{className:"text-slate-9",children:["<",r.authorEmail,">"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.date")}),(0,n.jsx)("span",{children:B}),r.relativeDate&&(0,n.jsxs)("span",{className:"text-slate-9",children:["(",r.relativeDate,")"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.files")}),(0,n.jsx)("span",{children:u("commitDetail.nChanges",{count:m.length})})]})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:k?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:u("commitDetail.loadingFiles")}):(0,n.jsx)(D,{files:f,selectedPath:v?.path||null,expandedPaths:g,onSelect:e=>e.file&&P(e.file),onToggle:R,cwd:l,showChanges:!0,emptyMessage:u("commitDetail.noFileChanges"),className:"py-1"})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:C?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:u("commitDetail.loadingDiff")}):w?(0,n.jsx)(T,{oldContent:w.oldContent,newContent:w.newContent,filePath:w.filePath,isNew:w.isNew,isDeleted:w.isDeleted,cwd:l,enableComments:!0,onPreview:!w.isDeleted&&w.filePath.endsWith(".json")?()=>E({content:w.newContent,filePath:w.filePath}):void 0,previewLabel:u("common.readable"),onContentSearch:d}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:u("commitDetail.selectFileToView")})})]})]}),I=L&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>E(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:L.filePath}),(0,n.jsx)("button",{onClick:()=>E(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(et,{search:$}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:M,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(L.content)})})]})});return a?(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsx)("button",{onClick:t,className:"absolute top-2 right-2 z-10 p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:u("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),F,I]}):(0,n.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u("commitDetail.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F,I]})})}let en={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},es=s.memo(function({item:e,isSelected:t,isExpanded:r,isLoading:o,onSelect:l,onToggle:a,onContextMenu:i,renderActions:c}){let{node:d,level:u,gitStatus:m,hasChangedChildren:x}=e,h=m?en[m]:null,f=(0,s.useCallback)(()=>{d.isDirectory?a(d.path):l(d.path)},[d.isDirectory,d.path,l,a]),p=(0,s.useCallback)(e=>{i(e,d.path,d.isDirectory)},[d.path,d.isDirectory,i]),g=!d.isDirectory&&(".env"===d.name||d.name.startsWith(".env.")),b=m?h.text:x?"text-amber-11":g?"text-yellow-600 dark:text-yellow-500":t&&!d.isDirectory?"text-brand":"text-foreground";return(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${t?"bg-brand/10":""}`,style:{paddingLeft:`${12*u+8}px`},onClick:f,onContextMenu:p,children:[d.isDirectory?o?(0,n.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,n.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,n.jsx)(B,{name:d.name,size:16,className:"flex-shrink-0 ml-4"}),(0,n.jsx)("span",{className:`text-sm truncate flex-1 ${b}`,"data-tooltip":d.isSymlink&&d.symlinkTarget?`${d.path} → ${d.symlinkTarget}`:d.path,children:d.name}),d.isSymlink&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),m&&(0,n.jsx)("span",{className:`text-xs font-mono px-1 rounded ${h.text} ${h.bg} flex-shrink-0`,children:m}),d.isDirectory&&x&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),c?.(d)]})});function eo({files:e,selectedPath:t,expandedPaths:r,matchedPaths:o=null,gitStatusMap:l=null,loadingDirs:a,onSelect:i,onToggle:c,cwd:d,shouldScrollToSelected:u=!1,onScrolledToSelected:m,className:x,renderActions:h,onCreateFile:p,onDelete:g,onRefresh:v,onCopyFile:j,onPaste:w}){let y=(0,s.useRef)(null),{contextMenu:k,showContextMenu:N,hideContextMenu:C}=(0,b.Ee)(),S=(0,s.useMemo)(()=>(function e(t,r,n,s=null,o=0){let l=[];for(let a of t){if(null!==n&&!n.has(a.path))continue;let t=s?.get(a.path),i=a.isDirectory?function(e,t){if(!t)return!1;let r=e+"/";for(let e of t.keys())if(e.startsWith(r))return!0;return!1}(a.path,s):void 0;l.push({node:a,level:o,gitStatus:t,hasChangedChildren:i}),a.isDirectory&&a.children&&r.has(a.path)&&l.push(...e(a.children,r,n,s,o+1))}return l})(e,r,o,l),[e,r,o,l]),L=(0,f.Te)({count:S.length,getScrollElement:()=>y.current,estimateSize:()=>26,overscan:10}),E=(0,s.useRef)(m);return(E.current=m,(0,s.useEffect)(()=>{if(u&&t&&S.length>0){let e=S.findIndex(e=>e.node.path===t);if(e>=0){let t=setTimeout(()=>{L.scrollToIndex(e,{align:"center"}),E.current?.()},150);return()=>clearTimeout(t)}}},[u,t,S,L]),0===S.length)?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,n.jsxs)("div",{ref:y,className:x||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,n.jsx)("div",{style:{height:`${L.getTotalSize()}px`,width:"100%",position:"relative"},children:L.getVirtualItems().map(e=>{let s=S[e.index];return(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${e.size}px`,transform:`translateY(${e.start}px)`},children:(0,n.jsx)(es,{item:s,isSelected:t===s.node.path,isExpanded:r.has(s.node.path),isLoading:a?.has(s.node.path),onSelect:i,onToggle:c,onContextMenu:N,renderActions:h})},s.node.path)})}),k&&(0,n.jsx)(b.ft,{x:k.x,y:k.y,path:k.path,cwd:d,isDirectory:k.isDirectory,onClose:C,onCreateFile:p,onDelete:g,onRefresh:v,onCopyFile:j,onPaste:w})]})}var el=r(38408),ea=r(82292),ei=r(45048),ec=r(97251),ed=r(47176),eu=r(79968);let em=[ec.W];function ex({content:e,filePath:t,cwd:r,onClose:l,sourceFile:a}){let i=a||(r&&t.startsWith(r)?t.slice(r.endsWith("/")?r.length:r.length+1):t),{t:c}=(0,o.Bd)(),d=(0,b.iN)(),m=(0,v.r)(),{comments:x,addComment:h,updateComment:f,deleteComment:y,refresh:k}=(0,p._)({cwd:r,filePath:t}),[N,C]=(0,s.useState)(!1),[S,M]=(0,s.useState)(null),[T,$]=(0,s.useState)(null),[P,R]=(0,s.useState)(null),B=(0,s.useMemo)(()=>e.split("\n"),[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>C(!0))},[]);let[F,I]=(0,s.useState)(null),D=(0,s.useRef)(null);(0,s.useEffect)(()=>{D.current!==F&&I(D.current)});let{toolbarRef:A,bumpRef:_,clearToolbar:W}=(0,E.L)({enabled:!0,container:F,resolveLineRange:e=>{let t=function(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let r=t.closest("[data-source-start]");if(!r)return null;let n=r.getAttribute("data-source-start"),s=r.getAttribute("data-source-end");return n&&s?{start:parseInt(n,10),end:parseInt(s,10)}:null}(e);return t?{start:t.start,end:t.end}:null},buildLineSnapshot:({start:e,end:t})=>{let r=Math.max(0,e-1),n=Math.min(B.length,t);return B.slice(r,n).join("\n")}}),z=(0,s.useCallback)(()=>{let e=A.current;e&&(M({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),W())},[W,A]),H=(0,s.useCallback)(()=>{let e=A.current;e&&($({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),W())},[W,A]),O=(0,s.useCallback)(async e=>{S&&(await h(S.range.start,S.range.end,e,S.selectedText),M(null))},[S,h]),q=(0,s.useCallback)(async e=>{if(T&&m)try{let n=await (0,g.$3)(r),s=[];for(let e of n)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:T.range.start,endLine:T.range.end,codeContent:T.lineSnapshot});let o=(0,g.Gw)(s,e);m.sendMessage(o),await (0,g.RP)(r),k(),$(null)}catch(e){console.error("Failed to send to AI:",e)}},[T,m,t,r,k]),V=(0,s.useMemo)(()=>{if(0===x.length)return[];let e=new Map;for(let t of x){let r=`${t.startLine}-${t.endLine}`;e.has(r)||e.set(r,[]),e.get(r).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[x]),[K,U]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===V.length||!D.current)return void queueMicrotask(()=>U([]));let e=setTimeout(()=>{let e=D.current;if(!e)return;let t=[],r=e.querySelectorAll("[data-source-start]");for(let n of V){let s=null,o=1/0;for(let e of r){let t=parseInt(e.getAttribute("data-source-start"),10),r=parseInt(e.getAttribute("data-source-end"),10);if(t<=n.startLine&&r>=n.endLine){let n=r-t;n<o&&(o=n,s=e)}}if(s){let r=e.getBoundingClientRect(),o=s.getBoundingClientRect();t.push({key:n.key,top:o.top-r.top+e.scrollTop,comments:n.comments})}}U(t)},100);return()=>clearTimeout(e)},[V,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(T){$(null),e.stopPropagation();return}if(S){M(null),e.stopPropagation();return}if(A.current){A.current=null,_.current(),e.stopPropagation();return}if(P){R(null),e.stopPropagation();return}l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[T,S,P,l]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:t}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(eu.ShareReviewToggle,{content:e,sourceFile:i}),(0,n.jsx)("button",{onClick:l,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:c("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)(ed.l,{content:e,containerRef:D}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:D,children:[(0,n.jsx)("div",{className:"p-6",children:(0,n.jsx)(ei.T,{content:e,rehypePlugins:em})}),K.map(({key:e,top:t,comments:r})=>(0,n.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),R({comment:r[0],x:e.clientX,y:e.clientY})},children:(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:r.length})},e))]})]}),N&&d&&(0,u.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.f,{floatingToolbarRef:A,bumpRef:_,container:d,onAddComment:z,onSendToAI:H,isChatLoading:m?.isLoading}),S&&(0,n.jsx)(w.t,{x:S.x,y:S.y,range:S.range,lineSnapshot:S.lineSnapshot,container:d,onSubmit:O,onClose:()=>M(null)}),T&&(0,n.jsx)(w.G,{x:T.x,y:T.y,range:T.range,filePath:t,lineSnapshot:T.lineSnapshot,container:d,onSubmit:q,onClose:()=>$(null),isChatLoading:m?.isLoading}),P&&(0,n.jsx)(L.t,{x:P.x,y:P.y,comment:P.comment,container:d,onClose:()=>R(null),onUpdateComment:f,onDeleteComment:y})]}),d)]})}function eh({path:e,matchedIndices:t}){let r=(0,s.useMemo)(()=>new Set(t),[t]),o=e.lastIndexOf("/"),l=o>=0?e.slice(0,o+1):"",a=o>=0?e.slice(o+1):e,i=(e,t,s)=>{let o=[],l="",a=!1;for(let s=0;s<e.length;s++){let i=t+s,c=r.has(i);c!==a&&l&&(o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-${s}`):(0,n.jsx)("span",{children:l},`${t}-${s}`)),l=""),a=c,l+=e[s]}return l&&o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-end`):(0,n.jsx)("span",{children:l},`${t}-end`)),(0,n.jsx)("span",{className:s,children:o})};return(0,n.jsxs)("span",{className:"truncate",children:[l&&i(l,0,"text-muted-foreground"),i(a,l.length,"text-foreground")]})}function ef({files:e,fileIndex:t,recentFiles:r,onSelectFile:l,onClose:a}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)(""),[u,x]=(0,s.useState)(0),h=(0,s.useRef)(null),f=(0,s.useRef)(null),p=(0,s.useMemo)(()=>{let r,n;return t??(r=[],(n=e=>{for(let t of e)t.isDirectory&&t.children?n(t.children):t.isDirectory||r.push(t.path)})(e),r)},[t,e]),g=(0,s.useMemo)(()=>{if(!c.trim()){let e=new Set(r);return[...r.map(e=>({path:e,score:0,matchedIndices:[]})),...p.filter(t=>!e.has(t)).slice(0,50).map(e=>({path:e,score:0,matchedIndices:[]}))]}let e=[];for(let t of p){let n=function(e,t){let r=e.toLowerCase(),n=t.toLowerCase(),s=[],o=0,l=0,a=-1;for(let i=0;i<r.length&&o<n.length;i++)r[i]===n[o]&&(s.push(i),a===i-1&&(l+=5),(0===i||"/"===e[i-1]||"."===e[i-1]||"-"===e[i-1]||"_"===e[i-1])&&(l+=10),i>e.lastIndexOf("/")&&(l+=3),e[i]===t[o]&&(l+=1),a=i,o++);return o<n.length?null:(l-=.1*e.length,{path:e,score:l,matchedIndices:s})}(t,c.trim());n&&(r.includes(t)&&(n.score+=20),e.push(n))}return e.sort((e,t)=>t.score-e.score),e.slice(0,50)},[c,p,r]),b=(0,s.useCallback)(e=>{d(e),x(0)},[]);(0,s.useEffect)(()=>{h.current?.focus()},[]),(0,s.useEffect)(()=>{if(f.current){let e=f.current.children[u];e?.scrollIntoView({block:"nearest"})}},[u]);let v=(0,s.useCallback)(e=>{l(e),a()},[l,a]),j=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing)switch(e.key){case"ArrowDown":e.preventDefault(),x(e=>Math.min(e+1,g.length-1));break;case"ArrowUp":e.preventDefault(),x(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),g[u]&&v(g[u].path);break;case"Escape":e.preventDefault(),a()}},[g,u,v,a]);return(0,n.jsx)(m.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:a,children:(0,n.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,n.jsx)("input",{ref:h,value:c,onChange:e=>b(e.target.value),onKeyDown:j,placeholder:i("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,n.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,n.jsx)("div",{ref:f,className:"flex-1 overflow-y-auto py-1",children:0===g.length?(0,n.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:i("quickFileOpen.noMatch")}):g.map((e,t)=>(0,n.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${t===u?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":e.path,onClick:()=>v(e.path),children:[(0,n.jsx)(B,{name:e.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,n.jsx)(eh,{path:e.path,matchedIndices:e.matchedIndices}),!c.trim()&&r.includes(e.path)&&(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:i("quickFileOpen.recent")})]},e.path))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",i("quickFileOpen.selectHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",i("quickFileOpen.openHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",i("quickFileOpen.closeHint")]})]})]})})})}var ep=r(2111),eg=r(41474),eb=r(61878),ev=r(33210),ej=r(48368),ew=r(91958),ey=r(45916),ek=r(31794),eN=r(69048),eC=r(97567),eS=r(68806),eL=r(52475);function eE({kind:e,qname:t,className:r}){let s=`${(function(e,t){if("__file__"===t||"__preamble__"===t||t&&t.startsWith("__heading_"))return"text-muted-foreground/60";switch(e){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(e,t)} ${r??""}`.trim();if("__file__"===t)return(0,n.jsx)(ej.A,{className:s});if("__preamble__"===t)return(0,n.jsx)(ey.A,{className:s});if(t&&t.startsWith("__heading_"))return(0,n.jsx)(ek.A,{className:s});switch(e){case"function":case"method":return(0,n.jsx)(eN.A,{className:s});case"class":return(0,n.jsx)(eC.A,{className:s});case"interface":return(0,n.jsx)(eS.A,{className:s});default:return(0,n.jsx)(eL.A,{className:s})}}var eM=r(49433),eT=r(82680);let e$=new Map,eP=new Map;async function eR(e,t,r=!1){let n=`${e}::${t}`;if(r)!function(e){if(!e){e$.clear(),eP.clear();return}let t=`${e}::`;for(let e of e$.keys())e.startsWith(t)&&e$.delete(e);for(let e of eP.keys())e.startsWith(t)&&eP.delete(e)}(e);else{let e=e$.get(n);if(e)return e;let t=eP.get(n);if(t)return t}let s=eM.tryPromise({try:async()=>{let s=new URLSearchParams({cwd:e,path:t});r&&s.set("refresh","1");let o=await fetch(`/api/projectGraph/file-functions?${s}`);if(404===o.status)return"not-found";if(!o.ok)throw Error((await o.json().catch(()=>({error:`HTTP ${o.status}`}))).error||`HTTP ${o.status}`);let l=await o.json();return e$.set(n,l),l},catch:e=>new eT.uV({message:"fetchFileFunctions failed",cause:e})}),o=i.t4.runPromiseExit(s).then(e=>{if("Success"===e._tag)return e.value;let t="Fail"===e.cause._tag?e.cause.error:null,r=t?.cause;if(r instanceof Error)throw r;throw Error(t?.message??"fetchFileFunctions failed")}).finally(()=>eP.delete(n));return eP.set(n,o),o}function eB(e,t){let[r,n]=(0,s.useState)({state:"idle"}),o=(0,s.useRef)(!0);(0,s.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let l=(0,s.useCallback)((e,t,r)=>{n({state:"loading"}),eR(e,t,r).then(e=>{o.current&&("not-found"===e?n({state:"notFound"}):n({state:"ready",data:e}))}).catch(e=>{o.current&&n({state:"error",message:e.message})})},[]);return(0,s.useEffect)(()=>{e&&t?l(e,t,!1):n({state:"idle"})},[e,t,l]),{state:r,refresh:(0,s.useCallback)(()=>{e&&t&&l(e,t,!0)},[e,t,l])}}var eF=r(3238),eI=r(50538),eD=r(94287);function eA({entries:e,onSelect:t,onClear:r}){let{t:s}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-l border-border flex flex-col","data-testid":"function-history-drawer",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono min-w-0",children:[(0,n.jsx)(eI.A,{className:"w-3 h-3 flex-shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:0===e.length?s("blockViewer.history.title"):`${s("blockViewer.history.title")} \xb7 ${e.length}/15`})]}),e.length>0&&(0,n.jsx)(eD.m,{content:s("blockViewer.history.clear"),children:(0,n.jsx)("button",{onClick:r,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,n.jsx)(ev.A,{className:"w-3 h-3"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===e.length?(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:s("blockViewer.history.empty")}):e.map((e,r)=>{var s;let o;return(0,n.jsx)(eD.m,{content:`${e.qname} \xb7 ${e.filePath}`,children:(0,n.jsxs)("button",{onClick:()=>t(e),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:bg-secondary/60 transition-colors group flex items-start gap-1.5",children:[(0,n.jsx)(eE,{kind:e.kind??"unknown",qname:e.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:e.name}),(0,n.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(o=(s=e.filePath).lastIndexOf("/"))>=0?s.slice(o+1):s,e.kind&&(0,n.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",e.kind]})]})]})]})},`${e.filePath}::${e.qname}::${r}`)})})]})}function e_(e,t){let r=e.filter(e=>e.filePath!==t.filePath||e.qname!==t.qname),n=[t,...r];return n.length>15?n.slice(0,15):n}let eW=new Set(["function","class","method"]);function ez(e){return eW.has(e.kind)}function eH({functions:e,currentQname:t,onSelect:r}){let{t:l}=(0,o.Bd)(),a=(0,s.useMemo)(()=>e.filter(ez),[e]);return(0,n.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-r border-border flex flex-col","data-testid":"file-toc-section",children:[(0,n.jsx)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:0===a.length?l("blockViewer.toc.title"):`${l("blockViewer.toc.title")} \xb7 ${a.length}`}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:l("blockViewer.toc.empty")}):a.map(e=>{let s=t===e.qualifiedName;return(0,n.jsx)(eD.m,{content:`${e.qualifiedName} \xb7 L${e.startLine}`,children:(0,n.jsxs)("button",{onClick:()=>r(e.qualifiedName,e.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-center gap-1.5 min-w-0 ${s?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,n.jsx)(eE,{kind:e.kind,qname:e.qualifiedName,className:"w-3 h-3 flex-shrink-0"}),(0,n.jsx)("span",{className:`text-xs font-mono truncate ${s?"font-semibold text-brand":""}`,children:e.name})]})},e.qualifiedName)})})]})}var eO=r(96035);function eq({comments:e,startLine:t,endLine:r,lineHeight:s,bodyTopOffset:o,onCommentClick:l}){let a=new Map;for(let n of e){if(n.endLine<t||n.endLine>r)continue;let e=a.get(n.endLine);e?e.push(n):a.set(n.endLine,[n])}return 0===a.size?null:(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(a.entries()).map(([e,r])=>{let a=o+(e-t)*s,i=r[0],c=r.length-1;return(0,n.jsx)(eD.m,{content:1===r.length?i.content:`${r.length} comments — click to view`,children:(0,n.jsxs)("button",{onClick:e=>l(i,e),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-sm transition-colors",style:{top:`${a+s/2-8}px`},children:[(0,n.jsx)(eO.A,{className:"w-2.5 h-2.5"}),c>0&&(0,n.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:c+1})]})},e)})})}function eV(e,t){for(let r=0;r<e.blocks.length;r++){let n=e.blocks[r];if(t>=n.startLine&&t<=n.endLine)return e.prefix[r]+(t-n.startLine)}return null}function eK({addedLines:e,blockRanges:t,viewportRange:r,onJumpToLine:o}){let l,a=(0,s.useRef)(null),i=(0,s.useMemo)(()=>(function(e){let t=[...e].sort((e,t)=>e.startLine-t.startLine),r=[0];for(let e of t){let t=Math.max(0,e.endLine-e.startLine+1);r.push(r[r.length-1]+t)}return{blocks:t,prefix:r,total:r[r.length-1]}})(t),[t]),c=(0,s.useMemo)(()=>{if(i.total<=0||0===e.size)return[];let t=[];for(let r of e){let e=i.blocks.find(e=>r>=e.startLine&&r<=e.endLine);e&&t.push({line:r,qname:e.qname})}t.sort((e,t)=>e.line-t.line);let r=[],n=null;for(let e of t)n&&e.line===n.end+1&&e.qname===n.qname?n.end=e.line:(n&&r.push(n),n={start:e.line,end:e.line,qname:e.qname});return n&&r.push(n),r},[e,i]);if(i.total<=0)return null;let d=(e,t)=>{let r=eV(i,e),n=eV(i,t);return null===r||null===n?null:{top:r/i.total*100,heightPct:(n-r+1)/i.total*100}};return(0,n.jsxs)("div",{ref:a,onClick:e=>{let t=a.current;if(!t)return;let r=t.getBoundingClientRect();if(r.height<=0)return;let n=function(e,t){if(e.total<=0)return null;let r=Math.max(0,Math.min(e.total-1,t));for(let t=0;t<e.blocks.length;t++){let n=e.prefix[t],s=e.prefix[t+1];if(r>=n&&r<s){let s=e.blocks[t];return{qname:s.qname,line:s.startLine+Math.round(r-n)}}}return null}(i,(e.clientY-r.top)/r.height*i.total);if(!n)return;let s=n.line,l=c.find(e=>e.qname===n.qname&&s>=e.start&&s<=e.end);if(l)return void o(l.qname,s);if(c.length>0){let e=Math.max(2,Math.round(.05*i.total)),t=eV(i,s);if(null!==t){let r=null,n=1/0;for(let e of c){let s=eV(i,e.start),o=eV(i,e.end);if(null===s||null===o)continue;let l=t<s?s-t:t>o?t-o:0;l<n&&(r=e,n=l)}if(r&&n<=e){let e=s<r.start?r.start:s>r.end?r.end:s;o(r.qname,e);return}}}let d=i.blocks.find(e=>e.qname===n.qname);d&&o(d.qname,d.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[c.map(e=>{let t=d(e.start,e.end);return t?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${t.top}%`,height:`${t.heightPct}%`,minHeight:"2px"}},`run:${e.qname}:${e.start}-${e.end}`):null}),r&&r.end>=r.start&&((l=d(r.start,r.end))?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${l.top}%`,height:`${Math.max(1.2,l.heightPct)}%`}}):null)]})}function eU(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function eJ({symbol:e,fileSource:t,hasChange:r,onHighlighted:o,comments:l,onCommentClick:a,addedLines:i}){let{resolvedTheme:c}=(0,eF.D)(),d=(0,s.useMemo)(()=>(0,C.sQ)(e.filePath),[e.filePath]),[u,m]=(0,s.useState)(null),[x,h]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!t)return void m(null);let r=!1;return(async()=>{try{let n=t.split("\n").slice(e.startLine-1,e.endLine).join("\n"),s=(await (0,C.kS)()).codeToTokens(n,{lang:d,theme:"dark"===c?"github-dark":"github-light"}).tokens.map((t,r)=>{let n=e.startLine+r,s=i?.has(n)??!1;return`<div class="flex${s?" bg-green-9/15":""}" style="min-width:max-content" data-line="${n}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${n}</span><span class="whitespace-pre">${(0,C.b8)(t)}</span></div>`}).join("");r||(m(s),h(null))}catch(e){r||h(e instanceof Error?e.message:"highlight failed")}})(),()=>{r=!0}},[t,e.startLine,e.endLine,d,c,e.filePath,i]),(0,s.useEffect)(()=>{(null!==u||null!==x)&&o(e.qualifiedName)},[u,x,e.qualifiedName,o]),(0,n.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,n.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border bg-secondary/40 text-xs",children:[(0,n.jsx)(eE,{kind:e.kind,qname:e.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),(0,n.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:e.name}),void 0!==e.params&&(0,n.jsxs)("span",{className:"text-muted-foreground/80",children:["(",e.params.join(", "),")"]})]}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:[e.kind," \xb7 L",e.startLine,"-",e.endLine]}),(0,n.jsx)("span",{className:"flex-1"}),r&&(0,n.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,n.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${eX}px`},children:[!t&&(0,n.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),x&&(0,n.jsx)("span",{className:"text-red-11",children:x}),u&&(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:u}})]}),l&&l.length>0&&a&&(0,n.jsx)(eq,{comments:l,startLine:e.startLine,endLine:e.endLine,lineHeight:eX,bodyTopOffset:eY+eZ,onCommentClick:a})]})}function eQ({side:e,pin:t,accent:r,onClick:s}){let o,l,a,i,c,d,u,m=t.lines.length;"ext"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",l="ext",a="text-muted-foreground/60",i=t.name,c=t.packageSpec,d="external",u=t.packageSpec):"method"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",l="method",a="text-muted-foreground/60",i=`${t.receiverName}.${t.methodName}`,c=null,d="method (unresolved)",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):"self"===t.kind?(o="bg-secondary/40 border-border hover:border-muted-foreground",l="self",a="text-muted-foreground/70",i=t.external.name,c=null,d="same-file",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):(o="in"===e?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",l=e,a="in"===e?"text-amber-11":"text-green-11",i=t.external.name,c=eU(t.external.filePath),d="in"===e?"caller":"callee",u=t.external.filePath);let x=r&&"ext"!==t.kind&&"method"!==t.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},className:`${o}${x} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors flex items-center gap-1.5`,"data-tooltip":`${d}${u?" \xb7 "+u:""}`,children:[(0,n.jsx)("span",{className:`${a} text-[9px] uppercase tracking-wider font-semibold flex-shrink-0`,children:l}),(0,n.jsxs)("span",{className:"truncate flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:i}),c&&(0,n.jsx)("span",{className:"text-muted-foreground/70 ml-1",children:c}),m>1&&(0,n.jsxs)("span",{className:"text-muted-foreground/60 ml-1",children:["\xb7",m,"\xd7"]})]})]})}let eX=18,eY=29,eZ=8;function eG(e,t){switch(t.kind){case"cross":return`${e}:x:${t.external.filePath}::${t.external.qualifiedName}`;case"self":return`${e}:s:${t.external.filePath}::${t.external.qualifiedName}`;case"ext":return`${e}:e:${t.packageSpec}::${t.name}`;case"method":return`${e}:m:${t.receiverName}::${t.methodName}`}}function e0(e,t){return"ext"!==e.kind&&"method"!==e.kind&&(t?.has(e.external.qualifiedName)??!1)}function e1(e){return{filePath:e.filePath,qname:e.qualifiedName,name:e.name,kind:e.kind}}function e2({symbol:e,fileSource:t,hasChange:r,upstream:s,downstream:o,onPinClick:l,onHighlighted:a,comments:i,onCommentClick:c,accentQnames:d,addedLines:u}){let m=function(e,t){if(0===e.length)return[];let r=e.map((e,r)=>{var n,s;return{i:r,line:(n=e.lines[0]??t.startLine,s=t.startLine,Math.max(s,Math.min(t.endLine,n)))}});r.sort((e,t)=>e.line-t.line||e.i-t.i);let n=Array(e.length).fill(0),s=-1/0;for(let{i:e,line:o}of r){let r=Math.max(eY+eZ+(o-t.startLine)*eX,s);n[e]=r,s=r+22}return n}(o,e);return(0,n.jsxs)("div",{"data-block-qname":e.qualifiedName,"data-start-line":e.startLine,"data-end-line":e.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,n.jsx)("div",{className:"w-44 flex-shrink-0 flex flex-col gap-1 pt-1",children:0===s.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):s.map(t=>(0,n.jsx)(eQ,{side:"in",pin:t,accent:e0(t,d),onClick:()=>l(t,e)},eG("in",t)))}),(0,n.jsx)(eJ,{symbol:e,fileSource:t,hasChange:r,onHighlighted:a,comments:i,onCommentClick:c,addedLines:u}),(0,n.jsx)("div",{className:"w-44 flex-shrink-0 relative",children:0===o.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):o.map((t,r)=>(0,n.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${m[r]}px`},children:(0,n.jsx)(eQ,{side:"out",pin:t,accent:e0(t,d),onClick:()=>l(t,e)})},eG("out",t)))})]})}function e5({cwd:e,onSelect:t,onClose:r}){let{t:l}=(0,o.Bd)(),[a,c]=(0,s.useState)(""),[d,u]=(0,s.useState)({files:[],symbols:[]}),[m,x]=(0,s.useState)(0),[f,p]=(0,s.useState)(!1),g=(0,s.useMemo)(()=>[...d.files,...d.symbols],[d]);(0,s.useEffect)(()=>{let t=a.trim();if(!t)return void u({files:[],symbols:[]});p(!0);let r=setTimeout(async()=>{let r=new URLSearchParams({cwd:e,q:t,limit:"12"}),n=await i.t4.runPromiseExit((0,h.MB)(r));"Success"===n._tag&&(u(n.value),x(0)),p(!1)},120);return()=>clearTimeout(r)},[a,e]);let b=(0,s.useCallback)(e=>{if("Escape"===e.key)return void r();if(0!==g.length){if("ArrowDown"===e.key)e.preventDefault(),x(e=>Math.min(e+1,g.length-1));else if("ArrowUp"===e.key)e.preventDefault(),x(e=>Math.max(e-1,0));else if("Enter"===e.key){e.preventDefault();let r=g[m];r&&t(r)}}},[g,m,r,t]);return(0,n.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:r,children:(0,n.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,n.jsx)(eb.A,{className:"w-4 h-4 text-muted-foreground"}),(0,n.jsx)("input",{autoFocus:!0,value:a,onChange:e=>c(e.target.value),onKeyDown:b,placeholder:l("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),f&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,n.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===g.length&&a&&!f&&(0,n.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:l("blockViewer.search.noResults","No matches")}),(0,n.jsx)(e4,{label:l("blockViewer.search.files","Files"),hits:d.files,startIdx:0,activeIdx:m,onSelect:t,setActive:x}),(0,n.jsx)(e4,{label:l("blockViewer.search.symbols","Symbols"),hits:d.symbols,startIdx:d.files.length,activeIdx:m,onSelect:t,setActive:x})]})]})})}function e4({label:e,hits:t,startIdx:r,activeIdx:s,onSelect:o,setActive:l}){return 0===t.length?null:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:e}),t.map((e,t)=>{let a=r+t,i=a===s;return(0,n.jsxs)("button",{onMouseEnter:()=>l(a),onClick:()=>o(e),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===e.target.kind?(0,n.jsx)(ej.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,n.jsx)(eE,{kind:e.target.symbolKind,qname:e.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"font-mono truncate",children:e.label}),e.hint&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:e.hint})]})]},`${e.type}:${e.label}:${t}`)})]})}function e3({cwd:e,highlightedFilePath:t,changedFiles:r,onSwitchToCode:l,enableComments:a=!1,onContentSearch:c,onFocalChange:d,qnameFilter:u,qnameFilterFile:m,accentQnames:h,accentFile:f,addedLines:b,addedLinesFile:y,headerExtraLeft:k,headerExtraRight:N}){let{t:C}=(0,o.Bd)(),[S,M]=(0,s.useState)(null),T=S??t??null;(0,s.useEffect)(()=>{M(null)},[t]),(0,s.useEffect)(()=>{d?.(T)},[T,d]);let{state:$,refresh:P}=eB(e,T),[R,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!T)return void B(null);let t=!1;return B(null),(async()=>{let r=new URLSearchParams({cwd:e,path:T}),n=await i.t4.runPromiseExit((0,x.eA)(r));t||("Success"===n._tag?B({content:n.value.content,mtimeMs:n.value.mtimeMs}):console.error("[BlockViewer] failed to load file source for",T,n.cause))})(),()=>{t=!0}},[e,T]);let F=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!R||"ready"!==$.state)return;let e=$.data.mtimeMs;!e||R.mtimeMs<=e||F.current!==R.mtimeMs&&(F.current=R.mtimeMs,P())},[R,$,P]);let[I,D]=(0,s.useState)([]),[A,_]=(0,s.useState)(!1),[W,z]=(0,s.useState)(null),H=(0,s.useRef)(0),O=(0,s.useRef)(0),[q,V]=(0,s.useState)(()=>new Set),K="ready"===$.state?$.data.filePath:null;(0,s.useEffect)(()=>{V(new Set)},[K]);let U=(0,s.useCallback)(e=>{V(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},[]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),_(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let J=(0,s.useCallback)((e,t)=>{if("ext"===e.kind||"method"===e.kind){let e=t.filePath;if(!e)return;H.current+=1,z({filePath:e,qname:"__imports__",nonce:H.current});return}let r=e1(t),n=e1(e.external);D(e=>e_(e_(e,r),n)),M(n.filePath),H.current+=1,z({filePath:n.filePath,qname:n.qname,nonce:H.current})},[]),Q=(0,s.useCallback)(e=>{M(e.filePath),H.current+=1,z({filePath:e.filePath,qname:e.qname,nonce:H.current})},[]),X=(0,s.useCallback)(e=>{_(!1),M(e.target.filePath),"symbol"===e.target.kind&&(H.current+=1,z({filePath:e.target.filePath,qname:e.target.qualifiedName,line:e.target.line,nonce:H.current}))},[]),Y=(0,s.useCallback)((e,t)=>{T&&(H.current+=1,z({filePath:T,qname:e,line:t,nonce:H.current}))},[T]),[Z,G]=(0,s.useState)(null),[ee,et]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!Z)return;let e=null,t=()=>{e=null;let t=Z.getBoundingClientRect();if(t.height<=0)return;let r=Z.querySelectorAll("[data-block-qname]"),n=1/0,s=-1/0;r.forEach(e=>{let r=e.dataset.startLine,o=e.dataset.endLine;if(!r||!o)return;let l=Number(r),a=Number(o);if(!Number.isFinite(l)||!Number.isFinite(a))return;let i=e.getBoundingClientRect();if(i.height<=0||i.bottom<=t.top||i.top>=t.bottom)return;let c=Math.max(0,t.top-i.top),d=Math.min(i.height,t.bottom-i.top),u=a-l+1,m=Math.floor(c/i.height*u),x=Math.ceil(d/i.height*u)-1,h=l+Math.max(0,m),f=l+Math.min(u-1,Math.max(0,x));h<n&&(n=h),f>s&&(s=f)}),n===1/0||s===-1/0?et(null):et(e=>e&&e.start===n&&e.end===s?e:{start:n,end:s})},r=()=>{null===e&&(e=requestAnimationFrame(t))};r(),Z.addEventListener("scroll",r,{passive:!0});let n=new ResizeObserver(r);n.observe(Z);let s=new MutationObserver(r);return s.observe(Z,{childList:!0,subtree:!0}),()=>{Z.removeEventListener("scroll",r),n.disconnect(),s.disconnect(),null!==e&&cancelAnimationFrame(e)}},[Z]);let er=(0,s.useMemo)(()=>{if("ready"!==$.state||!ee)return null;let e=$.data.functions;if(0===e.length)return null;let t=(ee.start+ee.end)/2;for(let r of e)if(r.startLine<=t&&t<=r.endLine)return r.qualifiedName;let r=null;for(let t of e)t.startLine<=ee.start&&(!r||t.startLine>r.startLine)&&(r=t);return r?.qualifiedName??null},[$,ee]),en=a&&!!e&&!!T,es=(0,v.r)(),{comments:eo,addComment:el,updateComment:ea,deleteComment:ei,refresh:ec}=(0,p._)({cwd:e,filePath:T??""}),[ed,eu]=(0,s.useState)(null),{toolbarRef:em,bumpRef:ex,clearToolbar:eh}=(0,E.L)({enabled:en,container:ed,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=t?.closest("[data-line]");if(!r||!ed||!ed.contains(r))return null;let n=r.getAttribute("data-line");if(!n)return null;let s=parseInt(n,10);return Number.isFinite(s)?{start:s,end:s}:null},buildLineSnapshot:({start:e,end:t})=>{let r=R?.content;return r?r.split("\n").slice(e-1,t).join("\n"):""}}),[ef,ep]=(0,s.useState)(null),[eg,eb]=(0,s.useState)(null),[ev,ej]=(0,s.useState)(null),ew=(0,s.useCallback)(()=>{let e=em.current;e&&(ep({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eh())},[eh,em]),ey=(0,s.useCallback)(()=>{let e=em.current;e&&(eb({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eh())},[eh,em]),ek=(0,s.useCallback)(()=>{let e=em.current;if(!e||!c)return;let t=e.selectedText.trim();eh(),t&&c(t)},[c,eh,em]),eN=(0,s.useCallback)(async e=>{ef&&(await el(ef.range.start,ef.range.end,e,ef.selectedText),ep(null))},[ef,el]),eC=(0,s.useCallback)(async t=>{if(eg&&es&&e&&T)try{let r=(await (0,g.$3)(e)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:T,startLine:eg.range.start,endLine:eg.range.end,codeContent:eg.lineSnapshot});let n=(0,g.Gw)(r,t);es.sendMessage(n),await (0,g.RP)(e),ec(),eb(null)}catch(e){console.error("[BlockViewer] send to AI failed:",e)}},[eg,es,e,T,ec]),eS=(0,s.useCallback)((e,t)=>{t.stopPropagation(),ej({comment:e,x:t.clientX,y:t.clientY}),eh(),ep(null),eb(null)},[eh]);if((0,s.useEffect)(()=>{let e;if(!W||O.current>=W.nonce||"ready"!==$.state||!R||$.data.filePath!==W.filePath)return;if(m&&m===$.data.filePath&&u){let t=0;for(let e of $.data.functions)u.has(e.qualifiedName)&&t++;e=Math.max(1,t)}else e=Math.max(1,$.data.functions.length);if(q.size<e)return;O.current=W.nonce;let t=null,r=requestAnimationFrame(()=>{let e=W.qname.indexOf(">"),r=e>=0?W.qname.slice(0,e):W.qname,n=document.querySelector(`[data-block-qname="${CSS.escape(r)}"]`);if(!n)return;if("number"==typeof W.line){let e=n.querySelector(`[data-line="${W.line}"]`);if(e instanceof HTMLElement){e.scrollIntoView({behavior:"instant",block:"center"}),e.classList.remove("line-flash"),e.offsetWidth,e.classList.add("line-flash"),t=window.setTimeout(()=>{e.classList.remove("line-flash")},1700);return}}n.scrollIntoView({behavior:"instant",block:"start"});let s=n.querySelector("[data-block-header]");s instanceof HTMLElement&&(s.classList.remove("block-flash"),s.offsetWidth,s.classList.add("block-flash"),t=window.setTimeout(()=>{s.classList.remove("block-flash")},1700))});return()=>{cancelAnimationFrame(r),null!==t&&window.clearTimeout(t)}},[W,$,R,q,u,m]),!T)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:null,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,refreshDisabled:!0,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,n.jsx)("span",{children:C("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,n.jsx)("span",{className:"text-xs",children:C("blockViewer.empty.hint","or press ⌘K to search.")})]}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]});if("idle"===$.state||"loading"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,refreshDisabled:!0,extraLeft:k,extraRight:N}),(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:C("blockViewer.fileMode.loading","Loading…")})]});if("notFound"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:C("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]});if("error"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-red-11",children:$.message}),(0,n.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:C("blockViewer.retry","Retry")})]})]});let eL=$.data,eE=eL.functions;if(0===eE.length&&R){let e=Math.max(1,R.content.split("\n").length);eE=[{filePath:eL.filePath,qualifiedName:"__file__",name:eU(eL.filePath),kind:"unknown",startLine:1,endLine:e}]}let eM=m&&m===eL.filePath,eT=f&&f===eL.filePath,e$=y&&y===eL.filePath;eM&&u&&(eE=eE.filter(e=>u.has(e.qualifiedName)));let eP=eT?h:void 0,eR=e$?b:void 0,eF=e6(eL.upstreamCalls),eI=e6(eL.downstreamCalls),eD=new Map(eE.map(e=>[e.qualifiedName,e])),eW=new Map,ez=new Map;for(let e of eL.intraCalls){let t=eD.get(e.to),r=eD.get(e.from);if(t){let r=eW.get(e.from),n={kind:"self",external:t,lines:e.lines};r?r.push(n):eW.set(e.from,[n])}if(r){let t=ez.get(e.to),n={kind:"self",external:r,lines:e.lines};t?t.push(n):ez.set(e.to,[n])}}let eO=new Map;for(let e of eL.externalCalls??[]){let t=eO.get(e.focalQname),r={kind:"ext",name:e.external.name,packageSpec:e.external.packageSpec,lines:e.lines};t?t.push(r):eO.set(e.focalQname,[r])}let eq=new Map;for(let e of eL.methodCalls??[]){let t=eq.get(e.focalQname),r={kind:"method",receiverName:e.receiverName,methodName:e.methodName,lines:e.lines};t?t.push(r):eq.set(e.focalQname,[r])}let eV=r.has(eL.filePath);return(0,n.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:eL.fileCount,functionCount:eL.functions.length,upstreamCount:eL.upstreamCalls.length,downstreamCount:eL.downstreamCalls.length,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{ref:eu,className:"flex-1 relative min-h-0 flex",children:[(0,n.jsx)(eH,{functions:eE,currentQname:er,onSelect:Y}),(0,n.jsx)("div",{ref:G,className:"flex-1 min-w-0 overflow-auto",children:(0,n.jsx)("div",{className:"flex flex-col gap-3 p-3",children:eE.map(e=>{let t,r,s,o,l,a;return(0,n.jsx)(e2,{symbol:e,fileSource:R?.content??null,hasChange:eV,upstream:(t=eF.get(e.qualifiedName),r=ez.get(e.qualifiedName),[...(t??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...r??[]]),downstream:(s=eI.get(e.qualifiedName),o=eW.get(e.qualifiedName),l=eq.get(e.qualifiedName),a=eO.get(e.qualifiedName),[...(s??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...o??[],...l??[],...a??[]]),onPinClick:J,onHighlighted:U,comments:en?eo:void 0,onCommentClick:en?eS:void 0,accentQnames:eP,addedLines:eR},e.qualifiedName)})})}),en&&ed&&(0,n.jsx)(j.f,{floatingToolbarRef:em,bumpRef:ex,container:ed,onAddComment:ew,onSendToAI:ey,onSearch:c?ek:void 0,isChatLoading:es?.isLoading}),en&&ef&&(0,n.jsx)(w.t,{x:ef.x,y:ef.y,range:ef.range,lineSnapshot:ef.lineSnapshot,container:ed,onSubmit:eN,onClose:()=>ep(null)}),en&&eg&&T&&(0,n.jsx)(w.G,{x:eg.x,y:eg.y,range:eg.range,filePath:T,lineSnapshot:eg.lineSnapshot,container:ed,onSubmit:eC,onClose:()=>eb(null),isChatLoading:es?.isLoading}),en&&ev&&(0,n.jsx)(L.t,{x:ev.x,y:ev.y,comment:ev.comment,container:ed,onClose:()=>ej(null),onUpdateComment:ea,onDeleteComment:ei}),eR&&eR.size>0&&eE.length>0&&(0,n.jsx)(eK,{addedLines:eR,blockRanges:eE.map(e=>({qname:e.qualifiedName,startLine:e.startLine,endLine:e.endLine})),viewportRange:ee,onJumpToLine:Y}),(0,n.jsx)(eA,{entries:I,onSelect:Q,onClear:()=>D([])}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]})]})}function e6(e){let t=new Map;for(let r of e){let e=t.get(r.focalQname);if(!e){t.set(r.focalQname,[r]);continue}e.some(e=>e.external.filePath===r.external.filePath&&e.external.qualifiedName===r.external.qualifiedName)||e.push(r)}return t}function e8({focalFile:e,fileCount:t,functionCount:r,upstreamCount:s,downstreamCount:l,onSwitchToCode:a,onSearch:i,onRefresh:c,refreshDisabled:d,extraLeft:u,extraRight:m}){let{t:x}=(0,o.Bd)(),h={focalFile:e,blockCount:r??0,upstreamCount:s??0,downstreamCount:l??0};return(0,n.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between bg-secondary/30 gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,n.jsx)("span",{className:"truncate min-w-0",children:e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-foreground",children:e}),"number"==typeof r&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",r," blocks"]}),"number"==typeof s&&"number"==typeof l&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",s," in \xb7 ",l," out"]})]}):(0,n.jsx)("span",{children:null!==t?`${t} files`:"…"})}),u&&(0,n.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:u(h)})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[m&&(0,n.jsx)("span",{className:"flex items-center gap-1",children:m(h)}),(0,n.jsxs)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":x("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,n.jsx)(eb.A,{className:"w-3 h-3"})," ⌘K"]}),(0,n.jsx)("button",{onClick:c,disabled:d,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":x("blockViewer.refresh","Rebuild project graph"),children:(0,n.jsx)(ew.A,{className:"w-3 h-3"})}),a&&(0,n.jsx)("button",{onClick:a,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:"Code"})]})]})}function e9(e){let t=0xdeadbeef,r=0x41c6ce57;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);t=Math.imul(t^s,0x9e3779b1),r=Math.imul(r^s,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35),(0x100000000*(2097151&(r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35)))+(t>>>0)>>>0).toString(16)}function e7(e){return e.replace(/\s+/g," ").trim()}function te(e,t){return e?`${e}>${t}`:t}function tt(e){let t=e.childForFieldName("name");if(t)return t.text;for(let t=0;t<e.namedChildCount;t++){let r=e.namedChild(t);if(r&&("identifier"===r.type||"type_identifier"===r.type||"property_identifier"===r.type))return r.text}return"<anonymous>"}function tr(e,t,r,n,s=[],o){return{qualifiedName:te(n,t),name:t,kind:r,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e9(e7(e.text)),children:s,params:o}}function tn(e){let t=e.childForFieldName("parameter");if(t)return[t.text];let r=e.childForFieldName("parameters");if(!r)return;let n=[];for(let e=0;e<r.namedChildCount;e++){let t=r.namedChild(e);t&&n.push(function e(t){switch(t.type){case"required_parameter":case"optional_parameter":{let r=t.childForFieldName("pattern");return r?e(r):t.text}case"assignment_pattern":{let r=t.childForFieldName("left");return r?e(r):t.text}case"default_parameter":case"typed_default_parameter":{let e=t.childForFieldName("name");return e?e.text:t.text}case"typed_parameter":for(let e=0;e<t.namedChildCount;e++){let r=t.namedChild(e);if(r?.type==="identifier")return r.text}return t.text;default:return t.text}}(t))}return n}function ts(e){let t=e.split("/").pop()?.toLowerCase()??"";switch(t.includes(".")?t.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";default:return null}}var to=r(14066);let tl="/tree-sitter",ta=null,ti=new Map;async function tc(e){let t,r=await (!(t=ti.get(e))&&(t=(async()=>(await (!ta&&(ta=to.iX.init({locateFile:e=>`${tl}/${e}`})),ta),to.TM.load(`${tl}/tree-sitter-${e}.wasm`)))(),ti.set(e,t)),t),n=new to.iX;return n.setLanguage(r),n}function td(e){return e.qualifiedName.startsWith("__code_")||e.qualifiedName.startsWith("__heading_")}function tu(e){return!td(e)&&"__file__"!==e.qualifiedName}async function tm(e,t){if(!e)return[];let r=ts(t);if(!r)return null;let n=(await tc(r)).parse(e);if(!n)return null;try{return function(e){let t=[],r=function(e){let t=[],r=-1,n=-1;for(let s=0;s<e.namedChildCount;s++){let o=e.namedChild(s);if(o){if("import_statement"===o.type||"export_statement"===o.type&&null!==o.childForFieldName("source")||"import_from_statement"===o.type||"future_import_statement"===o.type)t.push(o),r<0&&(r=o.startPosition.row+1),n=o.endPosition.row+1;else if(r>=0)break}}return r<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:r,endLine:n,contentHash:e9(e7(t.map(e=>e.text).join("\n"))),children:[]}}(e);r&&t.push(r);for(let r=0;r<e.namedChildCount;r++){let n=e.namedChild(r);n&&t.push(...function e(t,r,n=!1){switch(t.type){case"export_statement":case"export_default_declaration":{let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);o&&n.push(...e(o,r,!0))}return n}case"function_declaration":case"generator_function_declaration":case"function_definition":return[tr(t,tt(t),"function",r,[],tn(t))];case"class_declaration":case"abstract_class_declaration":{let e=tt(t),n=te(r,e),s=function(e,t){if(!e)return[];let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(s){if("method_definition"===s.type)r.push(tr(s,tt(s),"method",t,[],tn(s)));else if("public_field_definition"===s.type){let e=s.childForFieldName("value");e&&("arrow_function"===e.type||"function_expression"===e.type)&&r.push(tr(s,tt(s),"method",t,[],tn(e)))}}}return r}(t.childForFieldName("body"),n);return[tr(t,e,"class",r,s)]}case"interface_declaration":return[tr(t,tt(t),"interface",r)];case"type_alias_declaration":return[tr(t,tt(t),"type",r)];case"enum_declaration":return[tr(t,tt(t),"enum",r)];case"lexical_declaration":case"variable_declaration":return function(e,t){let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(!s||"variable_declarator"!==s.type)continue;let o=s.childForFieldName("name"),l=s.childForFieldName("value");if(!o)continue;let a=o.text,i=l&&("arrow_function"===l.type||"function_expression"===l.type),c=i&&l?tn(l):void 0;if(r.push(tr(e,a,i?"function":"const",t,[],c)),l&&"object"===l.type&&!i){let e=t?`${t}>${a}`:a;for(let t=0;t<l.namedChildCount;t++){let n=l.namedChild(t);if(n){if("pair"===n.type){let t=n.childForFieldName("key"),s=n.childForFieldName("value");if(!t||!s||"property_identifier"!==t.type&&"identifier"!==t.type||"arrow_function"!==s.type&&"function_expression"!==s.type)continue;r.push(tr(n,t.text,"method",e,[],tn(s)))}else if("method_definition"===n.type){let t=tt(n);t&&r.push(tr(n,t,"method",e,[],tn(n)))}}}}}return r}(t,r);case"class_definition":{let e=tt(t),n=te(r,e),s=function e(t,r){if(!t)return[];let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);if(o){if("function_definition"===o.type)n.push(tr(o,tt(o),"method",r,[],tn(o)));else if("decorated_definition"===o.type){let t=o.childForFieldName("definition");if(t?.type==="function_definition")n.push({...tr(t,tt(t),"method",r,[],tn(t)),startLine:o.startPosition.row+1,contentHash:e9(e7(o.text))});else if(t?.type==="class_definition"){let s=tt(t),l=te(r,s),a=e(t.childForFieldName("body"),l);n.push({...tr(t,s,"class",r,a),startLine:o.startPosition.row+1,contentHash:e9(e7(o.text))})}}else if("class_definition"===o.type){let t=tt(o),s=te(r,t),l=e(o.childForFieldName("body"),s);n.push(tr(o,t,"class",r,l))}}}return n}(t.childForFieldName("body"),n);return[tr(t,e,"class",r,s)]}case"decorated_definition":{let n=t.childForFieldName("definition");if(!n)return[];return e(n,r,!1).map(e=>({...e,startLine:t.startPosition.row+1,contentHash:e9(e7(t.text))}))}case"expression_statement":{let e=[];for(let n=0;n<t.namedChildCount;n++){let s=t.namedChild(n);if(s?.type==="assignment"){let n=function(e,t,r){let n=t.childForFieldName("left");if(!n||"identifier"!==n.type)return null;let s=n.text;return{qualifiedName:te(r,s),name:s,kind:"const",startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e9(e7(e.text)),children:[]}}(t,s,r);n&&e.push(n)}}return e.push(...function(e,t){let r=null;for(let t=0;t<e.namedChildCount;t++){let n=e.namedChild(t);if(n){if("call_expression"===n.type){r=n;break}if("await_expression"===n.type){for(let e=0;e<n.namedChildCount;e++){let t=n.namedChild(e);if(t?.type==="call_expression"){r=t;break}}break}}}if(!r)return[];let n=r.childForFieldName("function"),s=r.childForFieldName("arguments");if(!n||!s)return[];let o=null,l=[];for(let e=0;e<s.namedChildCount;e++){let t=s.namedChild(e);if(t){if(null===o&&("string"===t.type||"template_string"===t.type)){let e=t.text;o=e.length>=2&&/^["'`]/.test(e)?e.slice(1,-1):e}("arrow_function"===t.type||"function_expression"===t.type)&&l.push(t)}}if(0===l.length||!o)return[];let a=function e(t){if("identifier"===t.type)return t.text;if("member_expression"===t.type){let e=t.childForFieldName("property");return e?.text??""}if("call_expression"===t.type){let r=t.childForFieldName("function");return r?e(r):""}return""}(n),i=a?`${a} ${o}`:o;return l.map((e,r)=>tr(e,l.length>1?`${i} #${r+1}`:i,"function",t,[],tn(e)))}(t,r)),e}default:return[]}}(n,void 0,!1))}return t.push(...function(e,t){let r=e.text.split("\n"),n=r.length;if(0===n)return[];let s=new Uint8Array(n+2);for(let e of t){let t=Math.max(1,e.startLine),r=Math.min(n,e.endLine);for(let e=t;e<=r;e++)s[e]=1}let o=[],l=(e,t)=>{let n=!1;for(let s=e;s<=t;s++){let e=r[s-1];if(e&&e.trim().length>0){n=!0;break}}if(!n)return;let s=r.slice(e-1,t).join("\n");o.push({qualifiedName:`__code_${e}_${t}__`,name:"code",kind:"unknown",startLine:e,endLine:t,contentHash:e9(e7(s)),children:[]})},a=-1;for(let e=1;e<=n;e++)s[e]?a>=0&&(l(a,e-1),a=-1):a<0&&(a=e);return a>=0&&l(a,n),o}(e,t)),t}(n.rootNode)}finally{n.delete()}}async function tx(e,t,r,n,s){let o=new Set;if(e!==t)for(let r of y(n?"":e,s?"":t))"added"===r.type&&void 0!==r.newLineNum&&o.add(r.newLineNum);if(!ts(r))return{addedLines:o};let[l,a]=await Promise.all([tm(n?"":e,r),tm(s?"":t,r)]),i=a??[],c=function(e,t){let r=new Map;for(let t of e)r.set(t.qualifiedName,t);let n=new Map;for(let e of t)n.set(e.qualifiedName,e);let s=[];for(let e of t){let t=r.get(e.qualifiedName);t?t.contentHash!==e.contentHash&&s.push({id:`mod:${e.qualifiedName}`,changeKind:"modified",qname:e.qualifiedName}):s.push({id:`add:${e.qualifiedName}`,changeKind:"added",qname:e.qualifiedName})}for(let t of e)n.has(t.qualifiedName)||s.push({id:`del:${t.qualifiedName}`,changeKind:"deleted",qname:t.qualifiedName});return s}((l??[]).filter(tu),i.filter(tu)),d=new Set;for(let e of c)"deleted"!==e.changeKind&&d.add(e.qname);for(let e of function(e,t){if(0===t.size)return[];let r=[];for(let n of e)if(td(n)){for(let e of t)if(e>=n.startLine&&e<=n.endLine){r.push(n.qualifiedName);break}}return r}(i,o))d.add(e);return{changedQnames:d,addedLines:o}}function th({cwd:e,filePath:t,oldContent:r,newContent:o,isNew:l=!1,isDeleted:a=!1,changedFiles:i,fileGitStatusMap:c,enableComments:d=!1,onContentSearch:u,headerExtraLeft:m,headerExtraRight:x}){let[h,f]=(0,s.useState)(t);(0,s.useEffect)(()=>{f(t)},[t]);let[p,g]=(0,s.useState)(null);return(0,s.useEffect)(()=>{let n=!1;return g(null),(async()=>{try{let s=await tf(h,t,r,o,l,a,i,c,e);if(n||!s)return;let d=await tx(s.oldContent,s.newContent,h,s.isNew,s.isDeleted);if(n)return;g(d)}catch(e){n||console.error("[BlockDiffViewer] projection failed:",e)}})(),()=>{n=!0}},[h,t,r,o,l,a,i,c,e]),(0,n.jsx)(e3,{cwd:e,highlightedFilePath:t,changedFiles:i,enableComments:d,qnameFilter:p?.changedQnames,qnameFilterFile:h,accentQnames:p?.changedQnames,accentFile:h,addedLines:p?.addedLines,addedLinesFile:h,onFocalChange:e=>e&&f(e),onContentSearch:u,headerExtraLeft:m,headerExtraRight:x})}async function tf(e,t,r,n,s,o,l,a,c){if(e===t)return{oldContent:r,newContent:n,isNew:s,isDeleted:o};if(!l.has(e))return null;let d=a?.get(e);if(!d)return null;let u=new URLSearchParams({cwd:c,file:e,type:d}),m=await i.t4.runPromiseExit((0,h.oh)(u));if("Success"!==m._tag)return null;let x=m.value;return{oldContent:x.oldContent,newContent:x.newContent,isNew:x.isNew??!1,isDeleted:x.isDeleted??!1}}function tp(e){let{refreshKey:t,className:r="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:o="max-w-full max-h-full object-contain",alt:l}=e,a="absPath"in e&&"string"==typeof e.absPath,c=a?void 0:e.cwd,d=a?void 0:e.path,u=a?e.absPath:void 0,[m,h]=(0,s.useState)({kind:"loading"}),f=(0,s.useRef)(0);if((0,s.useEffect)(()=>{let e=++f.current;return h({kind:"loading"}),(async()=>{if(a){if(e!==f.current)return;h({kind:"ready",etag:null,size:0});return}let t=await i.t4.runPromiseExit((0,x.r6)(c,d));if(e!==f.current)return;if("Failure"===t._tag){let e="Fail"===t.cause._tag?t.cause.error:null,r=e?.cause;h({kind:"error",message:r instanceof Error?r.message:"Unknown error"});return}let r=t.value;if(!r.ok)return h({kind:"error",message:`stat failed (${r.status})`});let n=r.data;n&&n.exists?"too-large"===n.category?h({kind:"too-large",size:n.size??0}):"image"!==n.category?h({kind:"error",message:`Not an image (${n.category})`}):h({kind:"ready",etag:n.etag||`t-${n.mtimeMs??Date.now()}`,size:n.size??0}):h({kind:"missing"})})(),()=>{f.current++}},[a,c,d,u,t]),"loading"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(m.size/1024/1024)," MB)"]})});if("error"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("div",{className:"text-sm text-red-11",children:m.message})});let p=a?`/api/file?path=${encodeURIComponent(u)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(d)}&v=${encodeURIComponent(m.etag)}`;return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("img",{src:p,alt:l??(d||u),className:o})})}function tg({cwd:e,selected:t,diff:r,showMarkdownPreview:l,setShowMarkdownPreview:a,changedFiles:i,fileGitStatusMap:c,onContentSearch:d,locateInTree:u,jsonPreview:m,setJsonPreview:x,jsonPreviewSearch:h,jsonPreviewPreRef:f}){let{t:p}=(0,o.Bd)(),[g,b]=(0,s.useState)("file"),[v,j]=(0,s.useState)("compact"),w=t.file.path,y=(0,ea.u)(w),{state:N}=eB(e,w),C=(0,s.useMemo)(()=>{if("ready"===N.state)return N.data.functions.filter(ez).map(e=>({name:e.name,startLine:e.startLine,endLine:e.endLine,params:e.params}))},[N]);return(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[y||"map"!==g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:w}),(0,n.jsx)(eD.m,{content:p("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(`${e}/${w}`),(0,k.oR)(p("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(eD.m,{content:p("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(w)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,n.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===t.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===t.type?p("fileBrowser.staged"):p("fileBrowser.unstaged")}),(0,n.jsx)("div",{className:"flex-1"}),!y&&"file"===g&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["compact","full"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),j(e)},className:`px-2 py-0.5 text-xs transition-colors ${v===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("compact"===e?"diffViewer.compact":"diffViewer.full")},e))}),!y&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),b(e)},className:`px-2 py-0.5 text-xs transition-colors ${g===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("file"===e?"common.file":"common.codeMap")},e))})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:y?(0,n.jsx)(tp,{cwd:e,path:w,className:"p-4 flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:w}):(0,n.jsx)(T,{oldContent:r.oldContent,newContent:r.newContent,filePath:r.filePath,isNew:r.isNew,isDeleted:r.isDeleted,cwd:e,enableComments:!0,compact:"compact"===v,symbols:C,onPreview:!r.isDeleted&&Z(w)?()=>a(!0):!r.isDeleted&&w.endsWith(".json")?()=>x({content:r.newContent,filePath:r.filePath}):void 0,previewLabel:w.endsWith(".json")?p("common.readable"):p("common.preview"),onContentSearch:d})})]}):(0,n.jsx)(th,{cwd:e,filePath:r.filePath,oldContent:r.oldContent,newContent:r.newContent,isNew:r.isNew,isDeleted:r.isDeleted,changedFiles:i,fileGitStatusMap:c,enableComments:!0,onContentSearch:d,headerExtraLeft:({focalFile:t})=>{if(!t)return null;let r=c.get(t);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eD.m,{content:p("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${e}/${t}`),(0,k.oR)(p("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(eD.m,{content:p("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(t)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),r&&(0,n.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===r?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===r?p("fileBrowser.staged"):p("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),b(e)},className:`px-2 py-0.5 text-[11px] transition-colors ${g===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("file"===e?"common.file":"common.codeMap")},e))})}),l&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>a(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(ex,{content:r.newContent,filePath:r.filePath,cwd:e,onClose:()=>a(!1)})})}),m&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>x(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:m.filePath}),(0,n.jsx)("button",{onClick:()=>x(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(et,{search:h}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:f,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(m.content)})})]})})]})}function tb({branches:e,selectedBranch:t,onSelect:r,isLoading:l,pinnedBranches:a=[]}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(""),x=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{c&&h.current&&h.current.focus()},[c]);let f=u.toLowerCase(),p=new Set([...e?.local||[],...e?.remote||[]]),g=a.filter(e=>p.has(e)&&e.toLowerCase().includes(f)),b=new Set(g),v=e?.local.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],j=e?.remote.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],w=e=>{r(e),d(!1),m("")};return(0,n.jsxs)("div",{className:"relative",ref:x,children:[(0,n.jsxs)("button",{onClick:()=>d(!c),disabled:l,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,n.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),t||i("git.selectBranch"),e?.current===t&&(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["(",i("git.currentBranch"),")"]})]}),(0,n.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${c?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),c&&(0,n.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:h,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:i("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,n.jsxs)("div",{className:"overflow-y-auto flex-1",children:[g.length>0&&g.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${r}`)),v.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:i("git.localBranches")}),v.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},r))]}),j.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:i("git.remoteBranches")}),j.map(e=>(0,n.jsxs)("div",{onClick:()=>w(e),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${e===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:e}),e===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},e))]}),0===g.length&&0===v.length&&0===j.length&&(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("git.noMatchingBranches")})]})]})]})}function tv(e){let t=e.split(".").pop()?.toLowerCase();return t?["ts","tsx","js","jsx","mjs","cjs"].includes(t)?"typescript":["py","pyi"].includes(t)?"python":null:null}let tj=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()},catch:t=>new eT.uV({message:`${e} failed`,cause:t})});function tw(e){return e.replace(/^\([^)]+\)\s*/,"")}let ty=(0,s.forwardRef)(function({displayString:e,documentation:t,x:r,y:l,container:a,onMouseEnter:i,onMouseLeave:c,onFindReferences:d,onSearch:u},m){let{t:x}=(0,o.Bd)(),h=(0,s.useRef)(null);(0,s.useImperativeHandle)(m,()=>h.current,[]);let f=a.getBoundingClientRect(),p=r-f.left,g=l-f.top,b=(0,s.useMemo)(()=>tw(e),[e]),v=(0,s.useMemo)(()=>(function(e){let t,r=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,s=[],o=0,l=0,a=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(t=a.exec(e));){t.index>o&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o,t.index)},l++));let a=t[0];/^["']/.test(a)?s.push((0,n.jsx)("span",{className:"text-green-400",children:a},l++)):/^\d+$/.test(a)?s.push((0,n.jsx)("span",{className:"text-orange-300",children:a},l++)):r.test(a)?(r.lastIndex=0,s.push((0,n.jsx)("span",{className:"text-pink-400",children:a},l++))):s.push((0,n.jsx)("span",{className:"text-foreground",children:a},l++)),o=t.index+a.length}return o<e.length&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o)},l++)),s})(b),[b]);return(0,s.useEffect)(()=>{if(!h.current)return;let e=h.current,t=a.getBoundingClientRect(),n=e.getBoundingClientRect(),s=r-t.left,o=l-t.top;s+n.width>t.width-8&&(s=t.width-n.width-8),s<8&&(s=8),o+n.height>t.height-8&&(o=o-n.height-24),e.style.left=`${s}px`,e.style.top=`${o}px`},[r,l,a]),(0,n.jsxs)("div",{ref:h,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:p,top:g},children:[(0,n.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:v}),t&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:t})]}),(d||u)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1.5"}),(0,n.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:i,onMouseLeave:c,children:[d&&(0,n.jsx)("button",{onClick:d,className:"text-[11px] text-brand hover:underline cursor-pointer",children:x("hoverTooltip.findReferences")}),u&&(0,n.jsx)("button",{onClick:()=>u(function(e){let t=tw(e),r=t.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(r)return r[1];let n=e.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(n)return n[1];let s=t.match(/([a-zA-Z_$][\w$]*)/);return s?s[1]:t.split(/[(\s:]/)[0]}(e)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:x("hoverTooltip.search")})]})]})]})});function tk({references:e,loading:t,onSelect:r,onClose:l}){let{t:a}=(0,o.Bd)(),i=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,C.kS)();if(t!==l.current)return;let o=new Map;for(let t=0;t<e.length;t++){let r=e[t];if(!r.lineText)continue;let l=(0,C.sQ)(r.file);if("text"!==l)try{let e=n.codeToTokens(r.lineText,{lang:l,theme:s}),a=(0,C.b8)(e.tokens[0]||[]);a&&o.set(t,a)}catch{}}t===l.current&&r(o)})()},[e,n]),t}(e),c=[],d=new Map;for(let t=0;t<e.length;t++){let r=e[t],n=d.get(r.file);void 0===n&&(n=c.length,d.set(r.file,n),c.push({file:r.file,items:[]})),c[n].items.push({ref:r,idx:t})}return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[a("references.title")," ",!t&&`(${e.length})`]}),(0,n.jsx)("button",{onClick:l,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("references.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("references.notFound")}):c.map(({file:e,items:t})=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:e}),t.map(({ref:e,idx:t})=>(0,n.jsxs)("button",{onClick:()=>r(e),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:e.line}),i.has(t)?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:i.get(t)}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:e.lineText||""})]},`${e.line}-${e.column}-${t}`))]},e))})]})}function tN({results:e,loading:t,totalMatches:r,onSelect:l,onClose:a}){let{t:i}=(0,o.Bd)(),c=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,C.kS)(),o=new Map;for(let t of e){let e=(0,C.sQ)(t.path);if("text"!==e)for(let r of t.matches){if(!r.content)continue;let l=`${t.path}:${r.lineNumber}`;try{let t=n.codeToTokens(r.content,{lang:e,theme:s}),a=(0,C.b8)(t.tokens[0]||[]);a&&o.set(l,a)}catch{}}}t===l.current&&r(o)})()},[e,n]),t}(e);return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[i("searchResults.title")," ",!t&&i("searchResults.nMatches",{count:r})]}),(0,n.jsx)("button",{onClick:a,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("searchResults.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("searchResults.noResults")}):e.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:e.path}),e.matches.map((t,r)=>{let s=`${e.path}:${t.lineNumber}`,o=c.get(s);return(0,n.jsxs)("button",{onClick:()=>l(e.path,t.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:t.lineNumber}),o?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:o}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:t.content||""})]},`${t.lineNumber}-${r}`)})]},e.path))})]})}var tC=r(63728);function tS({onClose:e,cwd:t,initialTab:r="tree",tabSwitchTrigger:l,initialSearchQuery:a,searchQueryTrigger:c}){var d;let f,p,g,v,j,w,{t:y}=(0,o.Bd)(),{activeView:N}=(0,tC.R8)(),[C,S]=(0,s.useState)(r),[L,E]=(0,s.useState)("code"),M=(0,s.useRef)(null),$=(0,s.useRef)(!1),[P,R]=(0,s.useState)(null),[B,F]=(0,s.useState)(null),[I,O]=(0,s.useState)(!1),q=(0,s.useRef)(1),V=(0,s.useRef)(null),[K,U]=(0,s.useState)(null),J=(0,s.useRef)(null),[Q,X]=(0,s.useState)({isDirty:!1,isSaving:!1}),[Y,G]=(0,s.useState)(!1),[en,es]=(0,s.useState)(!1),[ei,ec]=(0,s.useState)(null),ed=(0,s.useRef)(null),eu=ee(ed),em=(0,s.useRef)(null),eh=ee(em),eb=function(e){let[t,r]=(0,s.useState)(!1);return{goToDefinition:(0,s.useCallback)(async(t,n,s)=>{r(!0);let o=await i.t4.runPromiseExit(tj("/api/lsp/definition",{cwd:e,filePath:t,line:n,column:s}));return(r(!1),"Success"===o._tag)?o.value.definitions??[]:(console.error("[useLSP] definition error:",o.cause),[])},[e]),loading:t}}(t),ev=function(e){let[t,r]=(0,s.useState)(null),n=(0,s.useRef)(null),o=(0,s.useRef)(null),l=(0,s.useRef)(0),a=(0,s.useRef)(!1),c=(0,s.useRef)(null),d=(0,s.useRef)({x:0,y:0}),u=(0,s.useCallback)(e=>{c.current=e},[]);(0,s.useEffect)(()=>{let e=e=>{d.current.x=e.clientX,d.current.y=e.clientY};return document.addEventListener("mousemove",e),()=>document.removeEventListener("mousemove",e)},[]);let m=(0,s.useRef)(!1),x=(0,s.useRef)(null),h=(0,s.useCallback)(()=>{let e=c.current;e&&m.current&&(e.style.pointerEvents="none"),m.current=!1,x.current&&(c.current?.removeEventListener("mouseleave",x.current),x.current=null)},[]),f=(0,s.useCallback)(()=>{let e=c.current;if(!e||m.current)return;m.current=!0,a.current=!0,e.style.pointerEvents="auto";let t=()=>{a.current=!1,h(),l.current++,r(null)};x.current=t,e.addEventListener("mouseleave",t)},[h]),p=(0,s.useCallback)((t,s,a,c)=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current);let d=++l.current;n.current=setTimeout(async()=>{let n=await i.t4.runPromiseExit(tj("/api/lsp/hover",{cwd:e,filePath:t,line:s,column:a}));if(d!==l.current||"Success"!==n._tag)return;let o=n.value.hover;o&&o.displayString&&r({...o,x:c.x,y:c.y,filePath:t,line:s,column:a})},300)},[e]),g=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),l.current++,o.current=setTimeout(function(){if(a.current)return;let e=c.current;if(e){let t=e.getBoundingClientRect(),{x:r,y:n}=d.current;if(r>=t.left&&r<=t.right&&n>=t.top&&n<=t.bottom)return void f()}r(null)},150)},[f]),b=(0,s.useCallback)(()=>{a.current=!0,o.current&&clearTimeout(o.current)},[]),v=(0,s.useCallback)(()=>{a.current=!1,l.current++,r(null)},[]),j=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current),a.current=!1,h(),l.current++,r(null)},[h]);return(0,s.useEffect)(()=>{t||h()},[t,h]),{hoverInfo:t,onTokenMouseEnter:p,onTokenMouseLeave:g,onCardMouseEnter:b,onCardMouseLeave:v,clearHover:j,setTooltipEl:u}}(t),ej=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!1),[l,a]=(0,s.useState)(!1);return{references:t,loading:n,visible:l,findReferences:(0,s.useCallback)(async(t,n,s)=>{o(!0),a(!0);let l=await i.t4.runPromiseExit(tj("/api/lsp/references",{cwd:e,filePath:t,line:n,column:s}));"Success"===l._tag?r(l.value.references??[]):(console.error("[useLSP] references error:",l.cause),r([])),o(!1)},[e]),closeReferences:(0,s.useCallback)(()=>{a(!1),r([])},[])}}(t),ew=(f=(0,s.useRef)([]),p=(0,s.useRef)([]),g=(0,s.useCallback)(e=>{f.current.push(e),f.current.length>50&&(f.current=f.current.slice(-50)),p.current=[]},[]),v=(0,s.useCallback)(e=>{if(0===f.current.length)return null;let t=f.current.pop();return p.current.push(e),p.current.length>50&&(p.current=p.current.slice(-50)),t},[]),j=(0,s.useCallback)(e=>{if(0===p.current.length)return null;let t=p.current.pop();return f.current.push(e),f.current.length>50&&(f.current=f.current.slice(-50)),t},[]),{push:g,goBack:v,goForward:j,canGoBack:(0,s.useCallback)(()=>f.current.length>0,[]),canGoForward:(0,s.useCallback)(()=>p.current.length>0,[])}),ey=(0,eg.F)(),ek=function({cwd:e}){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(null),[l,a]=(0,s.useState)(new Set),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(null),[h,f]=(0,s.useState)(null),[p,g]=(0,s.useState)(new Set),[b,v]=(0,s.useState)(null),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(null),P=(0,s.useRef)(null),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(null),[D,A]=(0,s.useState)("center"),[_,W]=(0,s.useState)(null),[z,H]=(0,s.useState)(null),[O,q]=(0,s.useState)(!1),[V,K]=(0,s.useState)([]),[U,J]=(0,s.useState)(!1),[Q,X]=(0,s.useState)(null),[Y,Z]=(0,s.useState)(null),[G,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(!1),en=(0,s.useMemo)(()=>c.map(e=>e.path).filter(Boolean),[c]),es=(0,s.useMemo)(()=>(0,ea.v3)(en),[en]),eo=(0,s.useMemo)(()=>new Set((0,ea.tW)(es)),[es]),el=(0,s.useMemo)(()=>j?n?(0,ea.KH)(n,j,y):(0,ea.q3)(t,j,y):null,[t,n,j,y]);(0,s.useEffect)(()=>{if(!el||0===el.size)return void v(null);let e=new Set;if(n){let t=new Set(n);for(let r of el)t.has(r)||e.add(r)}else{let r=t=>{for(let n of t)n.isDirectory&&n.children&&el.has(n.path)&&(e.add(n.path),r(n.children))};r(t)}v(e)},[el,t,n]);let ei=b??p,ec=(0,s.useRef)(null),ed=(0,s.useCallback)(t=>{ec.current&&clearTimeout(ec.current),ec.current=setTimeout(()=>{i.t4.runFork((0,x.Ft)(e,Array.from(t)).pipe(eM.tapError(e=>eM.sync(()=>console.error("Error saving expanded paths:",e))),eM.orElse(()=>eM.void)))},500)},[e]),eu=(0,s.useCallback)(async()=>{L(!0),$(null),await i.t4.runPromise((0,x.mP)(e).pipe(eM.match({onSuccess:e=>{e.error?$(e.error):(r(e.files??[]),e.expandedPaths&&Array.isArray(e.expandedPaths)&&g(new Set(e.expandedPaths)))},onFailure:e=>{console.error("Error loading files:",e),$("Failed to load files")}}))),L(!1)},[e]),em=(0,s.useCallback)(()=>{i.t4.runPromise((0,x.DZ)(e).pipe(eM.match({onSuccess:e=>{e.paths&&o(e.paths)},onFailure:e=>{console.error("Error loading file index:",e)}})))},[e]),ex=(0,s.useCallback)(async t=>{a(e=>new Set([...e,t])),await i.t4.runPromise((0,x.gZ)(e,t).pipe(eM.match({onSuccess:e=>{e.children&&r(r=>{if(!t){let t=new Map(r.map(e=>[e.path,e]));return e.children.map(e=>{let r=t.get(e.path);return r?.children&&e.isDirectory?{...e,children:r.children}:e})}let n=structuredClone(r),s=(0,ea.MB)(n,t);return s&&(s.children=e.children),n})},onFailure:e=>{console.error("Error loading directory:",e)}}))),a(e=>{let r=new Set(e);return r.delete(t),r})},[e]),eh=(0,s.useRef)(l);eh.current=l,(0,s.useEffect)(()=>{for(let e of b??p){let r=(0,ea.MB)(t,e);r&&r.isDirectory&&!r.children&&!eh.current.has(e)&&ex(e)}},[t,p,b,ex]);let ef=(0,s.useCallback)(async()=>{await i.t4.runPromise((0,x.r9)(e).pipe(eM.match({onSuccess:e=>d(e.files??[]),onFailure:e=>console.error("Error loading recent files:",e)})))},[e]),ep=(0,s.useCallback)(async t=>{d(e=>{let r=e.filter(e=>e.path!==t);return[{path:t},...r].slice(0,15)}),await i.t4.runPromise((0,x.YW)(e,t).pipe(eM.tapError(e=>eM.sync(()=>console.error("Error adding to recent files:",e))),eM.orElse(()=>eM.void)))},[e]),eg=(0,s.useCallback)((t,r,n,s)=>{d(e=>e.map(e=>e.path===t?{...e,scrollLine:r,cursorLine:n,cursorCol:s}:e)),i.t4.runFork((0,x.YW)(e,t,{scrollLine:r,cursorLine:n,cursorCol:s}).pipe(eM.orElse(()=>eM.void)))},[e]),eb=(0,s.useCallback)(e=>c.find(t=>t.path===e),[c]),ev=(0,s.useCallback)(async t=>{let r=t||u;r&&(J(!0),X(null),await i.t4.runPromise((0,x.eE)(e,r).pipe(eM.match({onSuccess:e=>{e.error?X(e.error):K(e.blame??[])},onFailure:e=>{console.error("Error loading blame:",e),X("Failed to load blame info")}}))),J(!1))},[e,u]),ej=(0,s.useCallback)(async t=>{M(!0),f(null),q(!1),K([]),X(null),Z(null);let r=eM.gen(function*(){let r=yield*(0,x.r6)(e,t);if(!r.ok)return{type:"error",message:r.data?.error||"Failed to stat file"};let n=r.data??{};if(!n.exists)return{type:"error",message:"File not found"};if("dir"===n.kind)return{type:"error",message:"Path is a directory"};switch(n.category){case"image":return{type:"image",size:n.size,mtime:n.mtimeMs,...n.isSymlink?{isSymlink:!0,symlinkTarget:n.symlinkTarget}:{}};case"binary":return{type:"binary",message:"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};case"too-large":return{type:"error",message:"File too large to preview",size:n.size,mtime:n.mtimeMs};default:{let r=yield*(0,x.K9)(e,t);if(409===r.status)return{type:"binary",message:r.data?.error||"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};if(!r.ok)return{type:"error",message:r.data?.error||"Failed to load file"};let s=r.data??{};return{type:"text",content:s.content,size:s.size,mtime:s.mtimeMs,...s.isSymlink?{isSymlink:!0,symlinkTarget:s.symlinkTarget}:{}}}}});await i.t4.runPromise(r.pipe(eM.match({onSuccess:e=>f(e),onFailure:e=>{console.error("Error loading file content:",e),f({type:"error",message:"Failed to load file"})}}))),ep(t),ev(t),M(!1)},[e,ep,ev]),ew=(0,s.useCallback)(()=>{O?q(!1):(q(!0),0===V.length&&ev())},[O,V.length,ev]),ey=(0,s.useCallback)((e,t)=>{if(!e)return;if(m(e),I(t??null),null==t){let t=c.find(t=>t.path===e);t?.scrollLine?(I(t.scrollLine),A("start"),W(t.cursorLine??null),H(t.cursorCol??null)):(A("center"),W(null),H(null))}else A("center"),W(null),H(null);ej(e);let r=e.split("/");if(r.length>1){let e=[];for(let t=1;t<r.length;t++)e.push(r.slice(0,t).join("/"));g(t=>{let r=new Set(t),n=!1;for(let t of e)r.has(t)||(r.add(t),n=!0);return n&&ed(r),n?r:t})}},[ej,ed,c]),ek=(0,s.useCallback)(e=>{if(b)v(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});else{let r=!p.has(e);if(g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),ed(r),r}),r){let r=(0,ea.MB)(t,e);r&&r.isDirectory&&!r.children&&ex(e)}}},[b,ed,p,t,ex]);return{files:t,setFiles:r,fileIndex:n,setFileIndex:o,loadingDirs:l,expandedPaths:p,setExpandedPaths:g,searchTreeExpandedPaths:b,setSearchTreeExpandedPaths:v,effectiveExpandedPaths:ei,searchQuery:j,setSearchQuery:w,searchExactMatch:y,setSearchDirExact:k,matchedPaths:el,creatingItem:N,setCreatingItem:C,isLoadingFiles:S,fileError:T,searchInputRef:P,shouldScrollToSelected:R,setShouldScrollToSelected:B,targetLineNumber:F,setTargetLineNumber:I,targetScrollAlign:D,setTargetScrollAlign:A,initialCursorLine:_,initialCursorCol:z,setInitialCursorLine:W,setInitialCursorCol:H,selectedPath:u,setSelectedPath:m,fileContent:h,setFileContent:f,isLoadingContent:E,recentFiles:c,recentFilePaths:en,setRecentFiles:d,recentFilesTree:es,recentTreeDirPaths:eo,showBlame:O,setShowBlame:q,blameLines:V,isLoadingBlame:U,blameError:Q,blameSelectedCommit:Y,setBlameSelectedCommit:Z,showMarkdownPreview:G,setShowMarkdownPreview:ee,showEditor:et,setShowEditor:er,saveExpandedPaths:ed,loadFiles:eu,loadFileIndex:em,loadDirectory:ex,loadRecentFiles:ef,addToRecentFiles:ep,updateRecentFilePosition:eg,getRecentFilePosition:eb,loadFileContent:ej,loadBlame:ev,handleToggleBlame:ew,handleSelectFile:ey,handleToggle:ek}}({cwd:t});d=ek.selectedPath,w=(0,s.useRef)(null),(0,s.useEffect)(()=>{d&&d!==w.current&&tv(d)&&(w.current=d,i.t4.runFork(tj("/api/lsp/warmup",{cwd:t,filePath:d}).pipe(eM.asVoid).pipe(eM.orElse(()=>eM.void))))},[t,d]);let eN=function({cwd:e,onSearchComplete:t}){let[r,n]=(0,s.useState)(""),[o,l]=(0,s.useState)([]),[a,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(new Set),[h,f]=(0,s.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useCallback)(async r=>{let n=r.trim();if(!n){l([]),g(null);return}if(n.length<2)return void u(z.A.t("fileBrowser.searchMinChars"));c(!0),u(null);let s=new URLSearchParams({cwd:e,q:r,caseSensitive:String(h.caseSensitive),wholeWord:String(h.wholeWord),regex:String(h.regex),fileType:h.fileType}),o=eM.tryPromise({try:async()=>{let e=await fetch(`/api/files/search?${s}`),t=await e.json();if(t.error)throw Error(t.error);return t},catch:e=>new eT.uV({message:"content search failed",cause:e})});await i.t4.runPromise(o.pipe(eM.match({onSuccess:e=>{l(e.results),g({totalFiles:e.totalFiles,totalMatches:e.totalMatches,truncated:e.truncated}),x(new Set(e.results.map(e=>e.path))),e.results.length>0&&t?.()},onFailure:e=>{u(e.cause instanceof Error?e.cause.message:"Search failed"),l([])}}))),c(!1)},[e,h,t]);return{contentSearchQuery:r,setContentSearchQuery:n,contentSearchResults:o,isSearching:a,searchError:d,searchExpandedPaths:m,searchOptions:h,setSearchOptions:f,searchStats:p,contentSearchInputRef:b,performContentSearch:v,handleSearchToggle:(0,s.useCallback)(e=>{x(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[])}}({cwd:t,onSearchComplete:()=>G(!0)}),eC=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[a,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(null),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(new Set),[w,y]=(0,s.useState)([]),[N,C]=(0,s.useState)([]),S=(0,s.useMemo)(()=>{let e=new Set(_(w));for(let t of g)e.delete(t);return e},[w,g]),L=(0,s.useMemo)(()=>{let e=new Set(_(N));for(let t of v)e.delete(t);return e},[N,v]),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(0),P=(0,s.useCallback)(async()=>{l(!0),c(null),await i.t4.runPromise((0,h.lv)(e).pipe(eM.match({onSuccess:e=>{n(e);let t=A(e.staged),r=A(e.unstaged);y(t),C(r)},onFailure:e=>{c(e.cause instanceof Error?e.cause.message:"Unknown error")}}))),l(!1)},[e]),R=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),B=(0,s.useCallback)(e=>{j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),F=(0,s.useCallback)((e,r)=>{u({file:e,type:r}),t(e.path)},[t]),I=(0,s.useCallback)(async(e,t,r,n)=>{let s=await i.t4.runPromiseExit(e);"Success"===s._tag?(await P(),(0,k.oR)(t,"success")):(console.error(r,s.cause),(0,k.oR)(n,"error"))},[P]),D=(0,s.useCallback)(t=>I((0,h.Iz)(e,[t]),z.A.t("toast.staged"),"Error staging file:",z.A.t("toast.stageFailed")),[e,I]),W=(0,s.useCallback)(t=>I((0,h.X0)(e,[t]),z.A.t("toast.unstaged"),"Error unstaging file:",z.A.t("toast.unstageFailed")),[e,I]),H=(0,s.useCallback)(async t=>{0!==t.length&&await I((0,h.Iz)(e,t),z.A.t("toast.stagedNFiles",{count:t.length}),"Error staging files:",z.A.t("toast.stageFailed"))},[e,I]),O=(0,s.useCallback)(async t=>{0!==t.length&&await I((0,h.X0)(e,t),z.A.t("toast.unstagedNFiles",{count:t.length}),"Error unstaging files:",z.A.t("toast.unstageFailed"))},[e,I]),q=(0,s.useCallback)(async t=>{if(0===t.length)return;let r=t.filter(e=>"untracked"===e.status).map(e=>e.path),n=t.filter(e=>"untracked"!==e.status).map(e=>e.path),s=eM.gen(function*(){r.length>0&&(yield*(0,h.Ub)(e,r,!0)),n.length>0&&(yield*(0,h.Ub)(e,n,!1))});await I(s,z.A.t("toast.discardedNFiles",{count:t.length}),"Error discarding files:",z.A.t("toast.discardFailed"))},[e,I]),V=(0,s.useCallback)(async()=>{r?.unstaged.length&&await I((0,h.Iz)(e,r.unstaged.map(e=>e.path)),z.A.t("toast.stagedNFiles",{count:r.unstaged.length}),"Error staging all files:",z.A.t("toast.stageFailed"))},[e,r,I]),K=(0,s.useCallback)(async()=>{r?.staged.length&&await I((0,h.X0)(e,r.staged.map(e=>e.path)),z.A.t("toast.unstagedNFiles",{count:r.staged.length}),"Error unstaging all files:",z.A.t("toast.unstageFailed"))},[e,r,I]),U=(0,s.useCallback)(async t=>{let r="untracked"===t.status;await I((0,h.Ub)(e,[t.path],r),r?z.A.t("toast.deletedFile"):z.A.t("toast.discardedChanges"),"Error discarding file:",z.A.t("toast.discardFailed"))},[e,I]),J=(0,s.useCallback)(async()=>{if(!r?.unstaged.length||!await (0,k.lJ)(z.A.t("git.discardAllConfirm",{count:r.unstaged.length}),{danger:!0}))return;let t=r.unstaged.filter(e=>"untracked"===e.status).map(e=>e.path),n=r.unstaged.filter(e=>"untracked"!==e.status).map(e=>e.path),s=r.unstaged.length,o=eM.gen(function*(){n.length>0&&(yield*(0,h.Ub)(e,n,!1)),t.length>0&&(yield*(0,h.Ub)(e,t,!0))});await I(o,z.A.t("toast.discardedNFiles",{count:s}),"Error discarding all:",z.A.t("toast.discardFailed"))},[e,r,I]);return(0,s.useEffect)(()=>{d?(p(!0),i.t4.runPromiseExit((0,h.w2)(e,d.file.path,d.type)).then(e=>{"Success"===e._tag?x(e.value):console.error("Error fetching diff:",e.cause),p(!1)})):x(null)},[d,e,T]),{status:r,setStatus:n,statusLoading:o,statusError:a,statusSelectedFile:d,statusDiff:m,statusDiffLoading:f,stagedExpandedPaths:S,unstagedExpandedPaths:L,stagedTree:w,setStagedTree:y,unstagedTree:N,setUnstagedTree:C,showStatusDiffPreview:E,setShowStatusDiffPreview:M,fetchStatus:P,handleStagedToggle:R,handleUnstagedToggle:B,handleStatusFileSelect:F,handleStage:D,handleUnstage:W,handleStageFiles:H,handleUnstageFiles:O,handleDiscardFiles:q,handleStageAll:V,handleUnstageAll:K,handleDiscardFile:U,handleDiscardAll:J,refreshDiff:(0,s.useCallback)(()=>$(e=>e+1),[])}}({cwd:t,addToRecentFiles:ek.addToRecentFiles}),eS=(0,s.useMemo)(()=>{let e=new Set;if(eC.status){for(let t of eC.status.staged)e.add(t.path);for(let t of eC.status.unstaged)e.add(t.path)}return e},[eC.status]),eL=(0,s.useMemo)(()=>{let e=new Map;if(eC.status){for(let t of eC.status.staged)e.set(t.path,"staged");for(let t of eC.status.unstaged)e.set(t.path,"unstaged")}return e},[eC.status]),eE=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[a,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)([]),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(!1),[M,T]=(0,s.useState)(!0),[$,P]=(0,s.useState)(!1),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(null),D=(0,s.useRef)(null),[W,H]=(0,s.useState)(null),[O,q]=(0,s.useState)(!1),[V,K]=(0,s.useState)(""),[U,J]=(0,s.useState)(""),[Q,X]=(0,s.useState)([]),[Y,Z]=(0,s.useState)([]),[G,ee]=(0,s.useState)(new Set),[et,er]=(0,s.useState)(null),[en,es]=(0,s.useState)(null),[eo,el]=(0,s.useState)(!1),[ei,ec]=(0,s.useState)(!1),ed=(0,s.useCallback)(()=>{N(!0),I(null),i.t4.runPromise((0,h.r4)(e).pipe(eM.match({onSuccess:e=>{e.local&&e.current?(n(e),l(e.current),e.upstream&&K(e.upstream)):(I(z.A.t("git.cannotGetBranches")),n(null))},onFailure:e=>{console.error(e),"NotFoundError"===e._tag?I(z.A.t("git.notGitRepo")):I(z.A.t("git.getBranchesFailed")),n(null)}}))).finally(()=>N(!1))},[e]),eu=(0,s.useCallback)(t=>{S(!0),u(null),x([]),p([]),j(null),y(null),T(!0),i.t4.runPromise((0,h.Bj)(e,t,ea.B_).pipe(eM.match({onSuccess:e=>{let t=e.commits||[];c(t),T(t.length>=ea.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>S(!1))},[e]),em=(0,s.useCallback)(()=>{if(L||!M||!o)return;E(!0);let t=a.length;i.t4.runPromise((0,h.Bj)(e,o,ea.B_,t).pipe(eM.match({onSuccess:e=>{let t=e.commits||[];t.length>0&&c(e=>[...e,...t]),T(t.length>=ea.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>E(!1))},[e,o,a.length,L,M]),ex=(0,s.useCallback)(e=>{let{scrollTop:t,scrollHeight:r,clientHeight:n}=e.target;r-t-n<100&&em()},[em]),eh=(0,s.useCallback)(t=>{u(t),j(null),y(null),P(!0),i.t4.runPromise((0,h.Zi)(e,t.hash).pipe(eM.match({onSuccess:e=>{let t=e.files||[];x(t);let r=A(t);p(r),b(new Set(_(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>P(!1))},[e]),ef=(0,s.useCallback)(r=>{d&&(j(r),t(r.path),B(!0),i.t4.runPromise((0,h.Zi)(e,d.hash,r.path).pipe(eM.match({onSuccess:e=>y(e),onFailure:e=>{console.error(e)}}))).finally(()=>B(!1)))},[e,d,t]),ep=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),eg=(0,s.useCallback)(t=>{el(!0),er(null),es(null),i.t4.runPromise((0,h.yy)(e,t).pipe(eM.match({onSuccess:e=>{let t=e.files||[];X(t);let r=A(t);Z(r),ee(new Set(_(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>el(!1))},[e]),eb=(0,s.useCallback)(r=>{er(r),t(r.path),ec(!0),i.t4.runPromise((0,h.yy)(e,U,r.path).pipe(eM.match({onSuccess:e=>es(e),onFailure:e=>{console.error(e)}}))).finally(()=>ec(!1))},[e,U,t]),ev=(0,s.useCallback)(e=>{ee(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ej=(0,s.useCallback)(e=>{if(q(e),e){let e="origin/main";J(e),eg(e)}else X([]),Z([]),er(null),es(null),J("")},[V,eg]);return{branches:r,selectedBranch:o,setSelectedBranch:l,commits:a,setCommits:c,selectedCommit:d,setSelectedCommit:u,historyFiles:m,historyFileTree:f,historyExpandedPaths:g,historySelectedFile:v,historyFileDiff:w,isLoadingBranches:k,isLoadingCommits:C,isLoadingMore:L,hasMoreCommits:M,setHasMoreCommits:T,isLoadingHistoryFiles:$,isLoadingHistoryDiff:R,historyError:F,commitListRef:D,tooltipPos:W,loadBranches:ed,loadCommits:eu,loadMoreCommits:em,handleCommitListScroll:ex,handleSelectCommit:eh,handleSelectHistoryFile:ef,handleHistoryToggle:ep,handleCommitInfoMouseMove:(0,s.useCallback)(e=>{H({x:e.clientX,y:e.clientY})},[]),handleCommitInfoMouseLeave:(0,s.useCallback)(()=>{H(null)},[]),compareMode:O,toggleCompareMode:ej,compareBaseBranch:U,setCompareBaseBranch:J,upstreamBranch:V,compareFiles:Q,compareFileTree:Y,compareExpandedPaths:G,compareSelectedFile:et,compareFileDiff:en,isLoadingCompareFiles:eo,isLoadingCompareDiff:ei,handleSelectCompareFile:eb,handleCompareToggle:ev,loadCompareFiles:eg}}({cwd:t,addToRecentFiles:ek.addToRecentFiles}),e$=(0,s.useRef)(!1),eP=(0,s.useCallback)(e=>{ek.setFileContent(t=>t?.type==="text"?{...t,content:e}:t),ek.showEditor||(e$.current=!0,ek.setShowEditor(!0))},[ek]);(0,s.useEffect)(()=>{ek.showEditor&&e$.current&&(J.current?.markDirty(),e$.current=!1)},[ek.showEditor]);let eR=(0,s.useCallback)(e=>{ek.setShowEditor(!0)},[ek]),eB=(0,s.useCallback)(async()=>{if(!ek.fileContent||"text"!==ek.fileContent.type||!ek.fileContent.content)return;let e=await i.t4.runPromiseExit((0,x.OJ)({cwd:t,path:ek.selectedPath,content:ek.fileContent.content}));try{if("Failure"===e._tag||!e.value.ok)throw Error("Failed to save file");let t=e.value.data?.mtime;t&&ek.setFileContent(e=>e?.type==="text"?{...e,mtime:t}:e),(0,k.oR)(y("toast.savedSuccess"),"success")}catch{(0,k.oR)(y("toast.saveFailed"),"error")}},[t,ek]),eF=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e=q.current,t=V.current;e>0&&ek.updateRecentFilePosition(ek.selectedPath,e,t?t.cursorLine+1:e,t?t.cursorCol+1:1)},[ek]),eI=(0,s.useCallback)(async(e,t)=>{let r=e!==ek.selectedPath;if(r&&ek.showEditor){if(Q.isDirty&&(!await (0,k.lJ)(y("fileBrowser.saveBeforeSwitch"),{confirmText:y("fileBrowser.saveAndSwitch"),cancelText:y("common.cancel")})||(await J.current?.save(),J.current?.isDirty)))return;ek.setShowEditor(!1)}r&&eF(),ek.handleSelectFile(e,t)},[ek,eF,Q.isDirty,y]),eD=(0,s.useMemo)(()=>{let e=eN.contentSearchResults;if(0===e.length)return{files:[],expandDirs:new Set,matchMap:new Map};let t=new Map,r=[];for(let n of e)t.set(n.path,n),r.push(n.path);let n=(0,ea.v3)(r),s=new Set((0,ea.tW)(n));return{files:n,expandDirs:s,matchMap:t}},[eN.contentSearchResults]),[eA,e_]=(0,s.useState)(new Set);(0,s.useEffect)(()=>{e_(eD.expandDirs)},[eD.expandDirs]);let eW=(0,s.useCallback)(e=>{e_(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ez=(0,s.useCallback)(e=>{if(e.isDirectory)return null;let t=eD.matchMap.get(e.path);return t?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t.matches.length}):null},[eD.matchMap]),eH=Y&&eN.contentSearchResults.length>0,eO=!!ek.selectedPath&&null!==tv(ek.selectedPath),eq=(0,s.useCallback)(async(e,r)=>{if(!ek.selectedPath||!eO)return;let n=await eb.goToDefinition(ek.selectedPath,e,r);if(0===n.length)return;let s=n[0],o=t.endsWith("/")?t:t+"/",l=s.file.startsWith(o)?s.file.slice(o.length):s.file;ew.push({filePath:ek.selectedPath,lineNumber:q.current}),l===ek.selectedPath?ek.setTargetLineNumber(s.line):eI(l,s.line)},[ek,t,eO,eb,ew]),eV=(0,s.useCallback)((e,t,r)=>{ek.selectedPath&&eO&&ev.onTokenMouseEnter(ek.selectedPath,e,t,r)},[ek.selectedPath,eO,ev]),eK=(0,s.useCallback)(e=>{let r=t.endsWith("/")?t:t+"/",n=e.file.startsWith(r)?e.file.slice(r.length):e.file;ek.selectedPath&&ew.push({filePath:ek.selectedPath,lineNumber:q.current}),n===ek.selectedPath?ek.setTargetLineNumber(e.line):eI(n,e.line)},[ek,t,ew]),eU=(0,s.useMemo)(()=>{if(!eC.status)return null;let e=new Map,t=e=>{switch(e){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let r of eC.status.staged)e.set(r.path,t(r.status));for(let r of eC.status.unstaged)e.set(r.path,t(r.status));return e},[eC.status]);(0,s.useEffect)(()=>{R(M.current)},[]),(0,s.useEffect)(()=>{S(r)},[r,l]),(0,s.useEffect)(()=>{a&&(S("search"),eN.setContentSearchQuery(a),eN.performContentSearch(a))},[c]);let eJ=(0,s.useCallback)(e=>{S(e),ek.setBlameSelectedCommit(null),"history"===e&&eE.selectedBranch&&eE.loadCommits(eE.selectedBranch)},[ek,eE.selectedBranch,eE.loadCommits]),eQ=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e={filePath:ek.selectedPath,lineNumber:q.current},t=ew.goBack(e);t&&(t.filePath===ek.selectedPath?ek.setTargetLineNumber(t.lineNumber):eI(t.filePath,t.lineNumber))},[ek,ew]),eX=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e={filePath:ek.selectedPath,lineNumber:q.current},t=ew.goForward(e);t&&(t.filePath===ek.selectedPath?ek.setTargetLineNumber(t.lineNumber):eI(t.filePath,t.lineNumber))},[ek,ew]),eY=(0,s.useCallback)(async e=>{let r=e.split("/").pop()||e;"Success"===(await i.t4.runPromiseExit((0,x.__)({cwd:t,paths:[e],op:"copy"})))._tag?(0,k.oR)(y("toast.copiedName",{name:r}),"success"):(0,k.oR)(y("toast.copyFailed"),"error")},[t,y]),eZ=(0,s.useCallback)(async e=>{let r=await i.t4.runPromiseExit((0,x.dt)());if("Success"!==r._tag||!r.value.path)return void(0,k.oR)(y("toast.noFileToPaste"),"info");let n=r.value.path,s=await i.t4.runPromiseExit((0,x.Nn)({cwd:t,targetDir:e,sourceAbsPath:n}));if("Success"===s._tag)(0,k.oR)(y("toast.pastedFile",{name:s.value.newName}),"success"),ek.loadDirectory(e),ek.loadFileIndex();else{let e="Fail"===s.cause._tag?s.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:y("toast.pasteFailed");(0,k.oR)(r,"error")}},[t,ek,y]),eG=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=t=>{let r="explorer"===N;if(r&&t.ctrlKey&&!t.metaKey&&"Minus"===t.code){t.preventDefault(),t.shiftKey?eX():eQ();return}if(r&&(t.metaKey||t.ctrlKey)&&"p"===t.key){t.preventDefault(),O(e=>!e);return}if(r&&(t.metaKey||t.ctrlKey)&&"c"===t.key&&!t.shiftKey){let e=t.target?.tagName,r=window.getSelection()?.toString();if(("tree"===C||"recent"===C)&&ek.selectedPath&&!r&&"INPUT"!==e&&"TEXTAREA"!==e){t.preventDefault(),eY(ek.selectedPath);return}}if(r&&(t.metaKey||t.ctrlKey)&&"v"===t.key){let e=t.target?.tagName;if(("tree"===C||"recent"===C)&&"INPUT"!==e&&"TEXTAREA"!==e&&!t.target?.isContentEditable){t.preventDefault(),eZ((0,ea.S7)(ek.selectedPath,ek.files));return}}if(r&&(t.metaKey||t.ctrlKey)&&"f"===t.key){if(ei){t.preventDefault(),eh.open();return}if(en&&ek.selectedPath?.endsWith(".json")){t.preventDefault(),eu.open();return}}if(r&&"Escape"===t.key){if(I)return void O(!1);if(eh.isVisible)return void eh.close();if(eu.isVisible)return void eu.close();if(ei)return void ec(null);let t=Date.now();if(t-eG.current<3e3)return;eG.current=t,ej.visible?ej.closeReferences():Y?G(!1):ek.blameSelectedCommit?ek.setBlameSelectedCommit(null):ek.showBlame?ek.setShowBlame(!1):e()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,ek.showBlame,ek.blameSelectedCommit,ek,I,ej.visible,ej.closeReferences,Y,eQ,eX,en,eu,ei,eh,C,eY,eZ,N]),(0,s.useEffect)(()=>{ek.loadFiles(),ek.loadFileIndex(),ek.loadRecentFiles(),eC.fetchStatus(),eE.loadBranches()},[]),(0,s.useEffect)(()=>{let e=()=>{eC.fetchStatus()};return window.addEventListener("git-status-changed",e),()=>window.removeEventListener("git-status-changed",e)},[eC.fetchStatus]);let e0=(0,s.useRef)(ey);(0,s.useEffect)(()=>{ey&&!e0.current&&(ek.loadFiles(),ek.loadFileIndex(),ek.loadRecentFiles(),eC.fetchStatus(),eE.loadBranches()),e0.current=ey},[ey]),(0,s.useEffect)(()=>{eE.selectedBranch&&eE.loadCommits(eE.selectedBranch)},[eE.selectedBranch,eE.loadCommits]);let e1=(0,s.useRef)(C);(0,s.useEffect)(()=>{let e=e1.current;if(e1.current=C,("tree"===C||"recent"===C)&&ek.recentFiles.length>0){let t=ek.recentFiles[0].path;ek.selectedPath&&("status"!==e&&"history"!==e||ek.selectedPath===t)||(ek.setShouldScrollToSelected(!0),eI(t))}},[C,ek.recentFiles,ek.selectedPath,eI,ek]);let e2=(0,s.useRef)(eE.selectedBranch);e2.current=eE.selectedBranch;let e5=(0,s.useRef)(ek.selectedPath);e5.current=ek.selectedPath;let e4=(0,s.useRef)(ek.fileContent?.type);e4.current=ek.fileContent?.type;let e6=(0,s.useCallback)(async e=>{try{let{data:r}=e;if(!r)return;let n=r.some(e=>"git"===e.type),s=r.some(e=>"file"===e.type),o=[];if((s||n)&&(o.push(i.t4.runPromise((0,x.mP)(t)).then(e=>{e.error||ek.setFiles(t=>(0,ea.HR)(e.files??[],t))}).catch(()=>{})),o.push(i.t4.runPromise((0,x.DZ)(t)).then(e=>{e.paths&&ek.setFileIndex(e.paths)}).catch(()=>{})),o.push(i.t4.runPromise((0,x.r9)(t)).then(e=>{ek.setRecentFiles(e.files??[])}).catch(()=>{}))),n||s){o.push(i.t4.runPromise((0,h.lv)(t)).then(e=>{eC.setStatus(e);let t=A(e.staged),r=A(e.unstaged);eC.setStagedTree(t),eC.setUnstagedTree(r)}).catch(()=>{})),eC.refreshDiff(),n&&eE.loadBranches();let e=e2.current;e&&o.push(i.t4.runPromise((0,h.Bj)(t,e,ea.B_)).then(e=>{let t=e.commits??[];eE.setCommits(t),eE.setHasMoreCommits(t.length>=ea.B_)}).catch(()=>{}))}let l=e5.current,a=e4.current;l&&"text"===a&&o.push(i.t4.runPromise((0,x.K9)(t,l)).then(e=>{let t=e.ok?e.data:null;t&&"string"==typeof t.content&&ek.setFileContent({type:"text",content:t.content,size:t.size,mtime:t.mtimeMs,...t.isSymlink?{isSymlink:!0,symlinkTarget:t.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(o)}catch(e){console.error("File watch handler error:",e)}},[t]);(0,ep.h)({url:`/ws/watch?cwd=${encodeURIComponent(t)}`,onMessage:e6,enabled:ey});let e8=(0,s.useCallback)(e=>{let t=e.split("/");if(t.length>1){let e=[];for(let r=1;r<t.length;r++)e.push(t.slice(0,r).join("/"));ek.setExpandedPaths(t=>{let r=new Set(t);for(let t of e)r.add(t);return ek.saveExpandedPaths(r),r})}ek.setSelectedPath(e),ek.setShouldScrollToSelected(!0),S("tree")},[ek]);return(0,n.jsxs)(b.SU,{container:P,children:[(0,n.jsxs)("div",{ref:M,className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex border-b border-border",children:[(0,n.jsx)("button",{onClick:()=>eJ("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.directoryTree")}),(0,n.jsx)("button",{onClick:()=>eJ("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.searchTab")}),(0,n.jsx)("button",{onClick:()=>eJ("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.recentTab")}),(0,n.jsx)("button",{onClick:()=>eJ("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.changesTab")}),(0,n.jsx)("button",{onClick:()=>eJ("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.historyTab")})]}),"tree"===C&&(0,n.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:ek.searchInputRef,type:"text",value:ek.searchQuery,onChange:e=>ek.setSearchQuery(e.target.value),placeholder:y("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ek.searchQuery&&(0,n.jsx)("button",{onClick:()=>ek.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>ek.setSearchDirExact(e=>!e),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${ek.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:ek.searchExactMatch?y("fileBrowser.exactMatchOn"):y("fileBrowser.exactMatchOff"),children:"ab"}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>ek.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.refreshTree"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:()=>ek.searchTreeExpandedPaths?ek.setSearchTreeExpandedPaths(new Set):ek.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.collapseAll"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===C&&(0,n.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:eN.contentSearchInputRef,type:"text",value:eN.contentSearchQuery,onChange:e=>eN.setContentSearchQuery(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eN.performContentSearch(eN.contentSearchQuery)},placeholder:y("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),eN.contentSearchQuery&&(0,n.jsx)("button",{onClick:()=>eN.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>eN.performContentSearch(eN.contentSearchQuery),disabled:eN.isSearching||!eN.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:eN.isSearching?"...":y("common.search")})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.caseSensitive,onChange:e=>eN.setSearchOptions(t=>({...t,caseSensitive:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.caseSensitive")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.wholeWord,onChange:e=>eN.setSearchOptions(t=>({...t,wholeWord:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.wholeWord")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.regex,onChange:e=>eN.setSearchOptions(t=>({...t,regex:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.regex")})]}),(0,n.jsx)("input",{type:"text",value:eN.searchOptions.fileType,onChange:e=>eN.setSearchOptions(t=>({...t,fileType:e.target.value})),placeholder:y("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===C&&(0,n.jsx)("div",{className:"p-3 border-b border-border",children:eE.compareMode?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,n.jsx)("span",{className:"truncate",children:eE.branches?.current||"HEAD"}),(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,n.jsx)("button",{onClick:()=>eE.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:y("fileBrowser.compareModeOff"),children:y("fileBrowser.compareMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tb,{branches:eE.branches,selectedBranch:eE.compareBaseBranch,onSelect:e=>{eE.setCompareBaseBranch(e),eE.loadCompareFiles(e)},isLoading:eE.isLoadingBranches,pinnedBranches:["origin/main",...eE.upstreamBranch&&"origin/main"!==eE.upstreamBranch?[eE.upstreamBranch]:[]]})})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tb,{branches:eE.branches,selectedBranch:eE.selectedBranch,onSelect:e=>{eE.setSelectedBranch(e)},isLoading:eE.isLoadingBranches,pinnedBranches:["origin/main",...eE.upstreamBranch&&"origin/main"!==eE.upstreamBranch?[eE.upstreamBranch]:[]]})}),(0,n.jsx)("button",{onClick:()=>eE.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:y("fileBrowser.compareModeOn"),children:y("fileBrowser.compareMode")})]})}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===C?"":"hidden"}`,children:[ek.creatingItem&&(0,n.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:ek.creatingItem.parentPath?y("fileBrowser.createFileIn",{path:ek.creatingItem.parentPath}):y("fileBrowser.createFile")}),(0,n.jsx)("input",{type:"text",autoFocus:!0,placeholder:y("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{$.current=!0},onCompositionEnd:()=>{$.current=!1},onKeyDown:async e=>{if("Enter"===e.key){if($.current)return;let r=e.target.value.trim();if(!r)return;let n=ek.creatingItem.parentPath,s=n?`${n}/${r}`:r,o=await i.t4.runPromiseExit((0,x.OJ)({cwd:t,path:s,content:""}));if("Success"===o._tag&&o.value.ok)(0,k.oR)(y("toast.createdFile",{name:r}),"success"),ek.setCreatingItem(null),ek.loadDirectory(n),ek.loadFileIndex(),n&&ek.setExpandedPaths(e=>new Set([...e,n])),eI(s);else if("Success"===o._tag){let e=o.value.data?.error;(0,k.oR)(e||y("toast.createFailed"),"error")}else(0,k.oR)(y("toast.createFailed"),"error")}else"Escape"===e.key&&ek.setCreatingItem(null)},onBlur:()=>ek.setCreatingItem(null)})]}),ek.isLoadingFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("common.loading")}):ek.fileError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ek.fileError}):(0,n.jsx)(eo,{files:ek.files,selectedPath:ek.selectedPath,expandedPaths:ek.effectiveExpandedPaths,matchedPaths:ek.matchedPaths,gitStatusMap:eU,loadingDirs:ek.loadingDirs,onSelect:e=>{ek.setShouldScrollToSelected(!1),eI(e)},onToggle:ek.handleToggle,cwd:t,shouldScrollToSelected:ek.shouldScrollToSelected,onScrolledToSelected:()=>ek.setShouldScrollToSelected(!1),onCreateFile:e=>ek.setCreatingItem({type:"file",parentPath:e}),onDelete:(e,t,r)=>F({path:e,isDirectory:t,name:r}),onRefresh:()=>ek.loadFiles(),onCopyFile:eY,onPaste:eZ})]}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===C?"":"hidden"}`,children:eN.isSearching?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):eN.searchError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:eN.searchError}):0===eN.contentSearchResults.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:eN.contentSearchQuery?y("fileBrowser.noContentSearchResults"):y("fileBrowser.enterKeywordToSearch")}):(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[eN.searchStats&&(0,n.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[y("fileBrowser.nFilesNMatches",{files:eN.searchStats.totalFiles,matches:eN.searchStats.totalMatches}),eN.searchStats.truncated&&(0,n.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",y("fileBrowser.resultsTruncated"),")"]})]}),(0,n.jsx)(eo,{files:eD.files,selectedPath:ek.selectedPath,expandedPaths:eA,onSelect:e=>{let t=eD.matchMap.get(e);eI(e,t?.matches[0]?.lineNumber),Y||G(!0)},onToggle:eW,cwd:t,renderActions:ez,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===C?"":"hidden"}`,children:0===ek.recentFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noRecentFiles")}):(0,n.jsx)(eo,{files:ek.recentFilesTree,selectedPath:ek.selectedPath,expandedPaths:ek.recentTreeDirPaths,onSelect:eI,onToggle:ea.tE,cwd:t})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===C?"":"hidden"}`,children:eC.statusLoading?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):eC.statusError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,n.jsx)("span",{className:"text-red-11 text-sm",children:eC.statusError})}):(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,n.jsxs)("div",{className:"border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:y("fileBrowser.stagingArea",{count:eC.status?.staged.length||0})}),(0,n.jsx)("button",{onClick:()=>eC.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.refreshChanges"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(eC.status?.staged.length||0)>0&&(0,n.jsx)("button",{onClick:eC.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:y("fileBrowser.unstageAll")})]}),(0,n.jsx)(D,{files:eC.stagedTree,selectedPath:eC.statusSelectedFile?.type==="staged"?eC.statusSelectedFile.file.path:null,expandedPaths:eC.stagedExpandedPaths,onSelect:e=>e.file&&eC.handleStatusFileSelect(e.file,"staged"),onToggle:eC.handleStagedToggle,cwd:t,emptyMessage:y("fileBrowser.noStagedFiles"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=W(e);return 0===t.length?null:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleUnstageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:y("fileBrowser.unstageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleUnstage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:y("fileBrowser.unstageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:y("fileBrowser.workspace",{count:eC.status?.unstaged.length||0})}),(eC.status?.unstaged.length||0)>0&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:eC.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:y("fileBrowser.discardAll")}),(0,n.jsx)("button",{onClick:eC.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:y("fileBrowser.stageAll")})]})]}),(0,n.jsx)(D,{files:eC.unstagedTree,selectedPath:eC.statusSelectedFile?.type==="unstaged"?eC.statusSelectedFile.file.path:null,expandedPaths:eC.unstagedExpandedPaths,onSelect:e=>e.file&&eC.handleStatusFileSelect(e.file,"unstaged"),onToggle:eC.handleUnstagedToggle,cwd:t,emptyMessage:y("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=W(e);if(0===t.length)return null;let r=t.map(e=>e.file).filter(Boolean);return(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleDiscardFiles(r)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:y("fileBrowser.discardNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleStageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:y("fileBrowser.stageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return e.file?(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleDiscardFile(e.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:y("fileBrowser.discardChanges"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleStage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:y("fileBrowser.stageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===C?"":"hidden"}`,children:eE.historyError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,n.jsx)("p",{className:"text-muted-foreground",children:eE.historyError})]})}):eE.compareMode?(0,n.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:eE.isLoadingCompareFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiff")}):0===eE.compareFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noDiffFiles")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:y("fileBrowser.nFilesChanged",{count:eE.compareFiles.length,branch:eE.compareBaseBranch})})}),(0,n.jsx)(D,{files:eE.compareFileTree,expandedPaths:eE.compareExpandedPaths,onToggle:eE.handleCompareToggle,selectedPath:eE.compareSelectedFile?.path||null,onSelect:e=>{e.file&&eE.handleSelectCompareFile(e.file)},cwd:t,showChanges:!0})]})}):(0,n.jsx)("div",{ref:eE.commitListRef,className:"flex-1 overflow-y-auto",onScroll:eE.handleCommitListScroll,children:eE.isLoadingCommits?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingCommits")}):0===eE.commits.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noCommits")}):(0,n.jsxs)(n.Fragment,{children:[eE.commits.map(e=>(0,n.jsxs)("div",{onClick:()=>eE.handleSelectCommit(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${eE.selectedCommit?.hash===e.hash?"bg-brand/10":""}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),(0,n.jsxs)("span",{className:"text-xs text-slate-9",title:e.date,children:[e.relativeDate," \xb7 ",(0,ea.r6)(e.date)]})]}),(0,n.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":e.subject,children:e.subject}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.author})]},e.hash)),eE.isLoadingMore&&(0,n.jsx)("div",{className:"p-3 text-center",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!eE.hasMoreCommits&&eE.commits.length>0&&(0,n.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:y("fileBrowser.allLoaded",{count:eE.commits.length})})]})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===C||"search"===C||"recent"===C)&&(ek.blameSelectedCommit?(0,n.jsx)(er,{isOpen:!0,onClose:()=>ek.setBlameSelectedCommit(null),commit:ek.blameSelectedCommit,cwd:t,embedded:!0,initialFilePath:ek.selectedPath||void 0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):"map"===L?(0,n.jsx)(e3,{cwd:t,highlightedFilePath:ek.selectedPath,changedFiles:eS,onSwitchToCode:()=>E("code"),enableComments:!0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)},headerExtraLeft:({focalFile:e})=>e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${t}/${e}`),(0,k.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),e8(e)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):ek.selectedPath?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:ek.selectedPath}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(`${t}/${ek.selectedPath}`),(0,k.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),e8(ek.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,n.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:ek.showEditor?(0,n.jsxs)(n.Fragment,{children:[Q.isDirty&&(0,n.jsx)("span",{className:"text-xs text-amber-11",children:y("fileBrowser.unsaved")}),(0,n.jsx)("button",{onClick:()=>J.current?.save(),disabled:!Q.isDirty||Q.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${Q.isDirty&&!Q.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:Q.isSaving?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):y("common.save")}),(0,n.jsx)("button",{onClick:()=>J.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.closeEdit"),children:y("fileBrowser.closeBtn")})]}):(0,n.jsxs)(n.Fragment,{children:[ek.fileContent?.type==="text"&&ek.fileContent.content&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(ek.fileContent.content),(0,k.oR)(y("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.copyFileContent"),children:y("common.copy")}),ek.selectedPath?.endsWith(".json")&&ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>es(e=>!e),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${en?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:y("fileBrowser.toggleJsonReadable"),children:y("common.readable")}),ek.fileContent?.type==="text"&&Z(ek.selectedPath)&&(0,n.jsx)("button",{onClick:()=>ek.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.previewMarkdown"),children:y("common.preview")}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:ek.handleToggleBlame,disabled:ek.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ek.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:y("fileBrowser.viewBlame"),children:ek.isLoadingBlame?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>E("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("blockViewer.viewerToggle.toBlock"),children:y("common.codeMap")}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>ek.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.editFile"),children:y("common.edit")})]})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:ek.isLoadingContent?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):ek.fileContent?"text"===ek.fileContent.type&&"string"==typeof ek.fileContent.content?ek.showBlame&&ek.blameError?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("p",{className:"text-red-11",children:ek.blameError}),(0,n.jsx)("button",{onClick:()=>ek.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:y("fileBrowser.backToPreview")})]})}):ek.showBlame&&0===ek.blameLines.length&&ek.isLoadingBlame?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):en&&ek.selectedPath?.endsWith(".json")?(0,n.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,n.jsx)(et,{search:eu}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,n.jsx)("pre",{ref:ed,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(ek.fileContent.content)})})]}):(0,n.jsx)(el.Cv,{ref:J,content:ek.fileContent.content,filePath:ek.selectedPath,cwd:t,enableComments:!0,scrollToLine:K??ek.targetLineNumber,scrollToLineAlign:null!=K?"start":ek.targetScrollAlign,onScrollToLineComplete:()=>{U(null),ek.setTargetLineNumber(null)},highlightKeyword:"search"===C?eN.contentSearchQuery:null,visibleLineRef:q,viStateRef:V,initialCursorLine:ek.initialCursorLine,initialCursorCol:ek.initialCursorCol,onInitialCursorSet:()=>{ek.setInitialCursorLine(null),ek.setInitialCursorCol(null)},onCmdClick:eO?eq:void 0,onTokenHover:eO?eV:void 0,onTokenHoverLeave:eO?ev.onTokenMouseLeave:void 0,onTokenHoverCancel:eO?ev.clearHover:void 0,blameLines:ek.showBlame&&ek.blameLines.length>0?ek.blameLines:void 0,inlineBlameLines:ek.blameLines.length>0?ek.blameLines:void 0,onSelectCommit:ek.setBlameSelectedCommit,editable:ek.showEditor,initialMtime:ek.fileContent.mtime,onEditorClose:e=>{ek.setShowEditor(!1),U(e)},onSaved:()=>{let e=q.current??1;ek.loadFileContent(ek.selectedPath),ek.setShowEditor(!1),U(e)},onEditorStateChange:X,viMode:!0,onContentMutate:eP,onEnterInsertMode:eR,onViSave:eB,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):"image"===ek.fileContent.type&&ek.selectedPath?(0,n.jsx)(tp,{cwd:t,path:ek.selectedPath,refreshKey:ek.fileContent.mtime,alt:ek.selectedPath}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,n.jsx)("p",{children:ek.fileContent.message||y("fileBrowser.cannotPreview")})]})}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:y("fileBrowser.selectFileToPreview")})})]}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,n.jsx)("p",{children:y("fileBrowser.selectFileToPreview")})]})})),"status"===C&&(eC.statusSelectedFile&&eC.statusDiff?(0,n.jsx)(tg,{cwd:t,selected:eC.statusSelectedFile,diff:eC.statusDiff,showMarkdownPreview:eC.showStatusDiffPreview,setShowMarkdownPreview:eC.setShowStatusDiffPreview,changedFiles:eS,fileGitStatusMap:eL,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)},locateInTree:e8,jsonPreview:ei,setJsonPreview:ec,jsonPreviewSearch:eh,jsonPreviewPreRef:em}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectFileToViewDiff")})})),"history"===C&&!eE.historyError&&(eE.compareMode?eE.isLoadingCompareDiff?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiffContent")}):eE.compareFileDiff?(0,n.jsx)(T,{oldContent:eE.compareFileDiff.oldContent,newContent:eE.compareFileDiff.newContent,filePath:eE.compareFileDiff.filePath,isNew:eE.compareFileDiff.isNew,isDeleted:eE.compareFileDiff.isDeleted,cwd:t,enableComments:!0,onPreview:!eE.compareFileDiff.isDeleted&&eE.compareFileDiff.filePath.endsWith(".json")?()=>ec({content:eE.compareFileDiff.newContent,filePath:eE.compareFileDiff.filePath}):void 0,previewLabel:y("common.readable"),onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:eE.compareFiles.length>0?y("fileBrowser.selectFileToViewDiff"):y("fileBrowser.clickCompareToLoad")})}):eE.selectedCommit?(0,n.jsx)(er,{isOpen:!0,onClose:()=>eE.setSelectedCommit(null),commit:eE.selectedCommit,cwd:t,embedded:!0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectCommitToView")})}))]})]}),ek.showMarkdownPreview&&ek.fileContent?.type==="text"&&ek.selectedPath&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ek.setShowMarkdownPreview(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(ex,{content:ek.fileContent.content||"",filePath:ek.selectedPath,cwd:t,onClose:()=>ek.setShowMarkdownPreview(!1)})})}),I&&(0,n.jsx)(ef,{files:ek.files,fileIndex:ek.fileIndex,recentFiles:ek.recentFilePaths,onSelectFile:e=>{eI(e),ek.setShouldScrollToSelected(!0),S("tree")},onClose:()=>O(!1)}),(eH||ej.visible)&&(0,n.jsxs)("div",{className:`flex ${ej.visible&&eH?"":"flex-col"}`,children:[eH&&(0,n.jsx)("div",{className:ej.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,n.jsx)(tN,{results:eN.contentSearchResults,loading:eN.isSearching,totalMatches:eN.searchStats?.totalMatches??0,onSelect:(e,t)=>{ek.selectedPath&&ew.push({filePath:ek.selectedPath,lineNumber:q.current}),eI(e,t)},onClose:()=>G(!1)})}),ej.visible&&(0,n.jsx)("div",{className:eH?"flex-1 min-w-0":"",children:(0,n.jsx)(tk,{references:ej.references,loading:ej.loading,onSelect:eK,onClose:ej.closeReferences})})]})]}),B&&(0,n.jsx)(m.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>F(null),children:(0,n.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:y("fileBrowser.confirmDelete")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:y("fileBrowser.confirmDeleteMessage",{name:B.name}).split(/<\/?file>/g).map((e,t)=>1===t?(0,n.jsx)("span",{className:"font-mono text-foreground",children:e},t):e)}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>F(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:y("common.cancel")}),(0,n.jsx)("button",{onClick:async()=>{let{path:e,name:r}=B;F(null);let n=await i.t4.runPromiseExit((0,x.VK)({cwd:t,path:e}));if("Success"===n._tag){(0,k.oR)(y("toast.movedToTrash",{name:r}),"success");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")):"";ek.loadDirectory(t),ek.loadFileIndex(),ek.selectedPath===e&&eI("")}else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:y("toast.deleteFailed");(0,k.oR)(r,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:y("common.delete")})]})]})})}),ev.hoverInfo&&P&&(0,u.createPortal)((0,n.jsx)(ty,{ref:ev.setTooltipEl,displayString:ev.hoverInfo.displayString,documentation:ev.hoverInfo.documentation,x:ev.hoverInfo.x,y:ev.hoverInfo.y,container:P,onMouseEnter:ev.onCardMouseEnter,onMouseLeave:ev.onCardMouseLeave,onFindReferences:()=>{let{filePath:e,line:t,column:r}=ev.hoverInfo;ev.clearHover(),ej.findReferences(e,t,r)},onSearch:e=>{ev.clearHover(),S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}),P)]})}function tL({isOpen:e,onClose:t,cwd:r}){let c,{t:d}=(0,o.Bd)(),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),[b,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[y,N]=(0,s.useState)(null),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(""),[M,T]=(0,s.useState)(!1),[$,P]=(0,s.useState)([]),[R,B]=(0,s.useState)(""),[F,I]=(0,s.useState)(!1),D=(0,s.useCallback)((e,t)=>e?._tag==="Fail"&&e.error?.cause instanceof Error?e.error.cause.message:d(t),[d]),A=(0,s.useCallback)(async()=>{v(!0);let e=await i.t4.runPromiseExit((0,h.FK)(r));if("Success"===e._tag){let t=e.value;m(t.worktrees),f(t.nextPath),g(t.nextRandomWord),t.gitUserName&&E(t.gitUserName)}else console.error("Failed to load worktrees:",e.cause),(0,k.oR)(d("toast.worktreeLoadFailed"),"error");v(!1)},[r,d]),_=(0,s.useCallback)(e=>{let{local:t,remote:r}=e;return r.includes("origin/main")?"origin/main":r.includes("origin/master")?"origin/master":t.includes("main")?"main":t.includes("master")?"master":r.length>0?r[0]:t.length>0?t[0]:"main"},[]);(0,s.useEffect)(()=>{e&&(A(),N(null))},[e,A]);let W=async()=>{if(!x)return;let e="origin/main",t=await i.t4.runPromiseExit((0,h.r4)(r));"Success"===t._tag&&(e=_(t.value));let n=p||function(){let e="bcdfghjklmnprstvwz",t=["a","e","i","o","u","ai","au","ea","ee","ia","io","oa","oo","ou","ui"],r="";for(let n=0;n<2;n++)r+=e[Math.floor(Math.random()*e.length)],r+=t[Math.floor(Math.random()*t.length)];return r}(),s=L?`${L}/${n}`:n;w(!0);let o=await i.t4.runPromiseExit((0,h.CM)({action:"add",cwd:r,path:x,newBranch:s,baseBranch:e}));"Success"===o._tag?((0,k.oR)(d("toast.worktreeCreateSuccess",{name:s}),"success"),A()):(console.error("Failed to create worktree:",o.cause),(0,k.oR)(D(o.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},z=async()=>{I(!0),B(""),T(!0);let e=await i.t4.runPromiseExit((0,h.r4)(r));if("Success"===e._tag){let t=e.value,r=t.local??[],n=t.remote??[],s=new Set(u.map(e=>e.branch).filter(Boolean));P([...r.filter(e=>!s.has(e)),...n.filter(e=>!s.has(e)&&!r.includes(e.replace(/^origin\//,"")))])}else(0,k.oR)(d("toast.loadBranchFailed"),"error");I(!1)},H=async e=>{if(!x)return;T(!1),w(!0);let t=await i.t4.runPromiseExit((0,h.CM)({action:"add",cwd:r,path:x,branch:e}));"Success"===t._tag?((0,k.oR)(d("toast.worktreeCreateSuccess",{name:e}),"success"),A()):(console.error("Failed to create worktree:",t.cause),(0,k.oR)(D(t.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},O=async()=>{if(!y)return;S(!0);let e=await i.t4.runPromiseExit((0,h.CM)({action:"remove",cwd:r,path:y.path}));"Success"===e._tag?((0,k.oR)(d("toast.worktreeDeleted"),"success"),N(null),A()):(console.error("Failed to delete worktree:",e.cause),(0,k.oR)(D(e.cause,"toast.worktreeDeleteFailed"),"error")),S(!1)},q=async e=>{let t=e.isLocked?"unlock":"lock",n=await i.t4.runPromiseExit((0,h.CM)({action:t,cwd:r,path:e.path}));"Success"===n._tag?((0,k.oR)(e.isLocked?d("toast.worktreeUnlocked"):d("toast.worktreeLocked"),"success"),A()):(console.error("Failed to toggle lock:",n.cause),(0,k.oR)(D(n.cause,"toast.operationFailed"),"error"))};return e?(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[480px] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Git Worktrees"}),(0,n.jsx)("button",{onClick:t,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:b?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):(0,n.jsx)("div",{className:"space-y-2",children:u.map(e=>{let s=e.path===r;return(0,n.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${s?"border-brand bg-brand/5":"border-border hover:bg-accent cursor-pointer"}`,onClick:()=>{e.path!==r&&((0,l.F)(a.n.OpenProject,{cwd:e.path}),t())},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?"bg-brand":"bg-muted-foreground/30"}`}),(0,n.jsx)("span",{className:"font-medium text-foreground truncate",children:e.branch||(e.isDetached?"detached":"unknown")}),e.isLocked&&(0,n.jsx)("span",{className:"text-amber-11",title:d("git.worktree.locked"),children:"\uD83D\uDD12"}),s&&(0,n.jsxs)("span",{className:"text-xs text-brand",children:["(",d("common.current"),")"]})]}),(0,n.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!s&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),q(e)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:e.isLocked?d("git.worktree.unlock"):d("git.worktree.lock"),children:e.isLocked?(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"})}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),N(e)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:d("common.delete"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate pl-4",children:e.path}),e.isDetached&&(0,n.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},e.path)})})}),M&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,n.jsx)("input",{value:R,onChange:e=>B(e.target.value),placeholder:d("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none placeholder:text-muted-foreground",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,n.jsx)("button",{onClick:()=>T(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:d("common.cancel")})]}),(0,n.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:F?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===(c=$.filter(e=>e.toLowerCase().includes(R.toLowerCase()))).length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("git.worktree.noBranches")}):c.map(e=>(0,n.jsx)("button",{onClick:()=>H(e),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate",children:(0,n.jsx)("span",{className:`${e.startsWith("origin/")?"text-muted-foreground":"text-foreground"}`,children:e})},e))})]}),(0,n.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:d("git.worktree.count",{count:u.length})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:z,disabled:!x||j,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!j?"bg-secondary text-foreground hover:bg-accent":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:d("git.worktree.selectBranch")}),(0,n.jsx)("button",{onClick:W,disabled:!x||j,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!j?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:j?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):d("git.worktree.addWorktree")})]})]}),y&&(0,n.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/50 rounded-lg",onClick:()=>N(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[360px] p-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:d("git.worktree.confirmDelete")}),(0,n.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,n.jsx)("p",{className:"mb-2",children:d("git.worktree.confirmDeleteMsg")}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:d("git.worktree.path")}),(0,n.jsx)("span",{className:"text-foreground",children:y.path})]}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:d("git.worktree.branch")}),(0,n.jsx)("span",{className:"text-foreground",children:y.branch||"detached"})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>N(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:d("common.cancel")}),(0,n.jsx)("button",{onClick:O,disabled:C,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:C?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):d("common.delete")})]})]})})]})}):null}var tE=r(67635),tM=r(73300),tT=r(20986),t$=r(9921),tP=r(66088),tR=r(42790);function tB(e){let t=function(e){let t=0xffffffff;for(let r=0;r<e.length;r++){t^=e.charCodeAt(r);for(let e=0;e<8;e++)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e),r="",n=t;for(let e=0;e<4;e++)r+=String.fromCharCode(97+n%26),n=Math.floor(n/26);return r}let tF=(0,s.memo)(function({shortId:e,type:t,onRegister:r,onUnregister:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)(async n=>{if(n.stopPropagation(),i)await l(),c(!1),(0,k.oR)(a("toast.disconnected",{id:e}));else{await r(),c(!0);let n=`${"3456"===window.location.port?"cock-dev":"cock"} ${t} ${e}`;navigator.clipboard.writeText(n),(0,k.oR)(a("toast.copiedCommand",{command:n}))}},[i,e,t,r,l,a]);return(0,n.jsxs)("button",{onClick:d,className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:i?a("shortIdBadge.clickToDisconnect"):a("shortIdBadge.clickToRegister"),children:[(0,n.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${i?"bg-green-500":"bg-muted-foreground/40"}`}),e]})});var tI=r(12786);let tD=e=>eM.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new eT.uV({message:`fetch ${e} failed`,cause:t})}),tA=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,t);if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:r=>new eT.uV({message:`${t.method} ${e} failed`,cause:r})}),t_=(e,t)=>tA(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),tW=(e,t)=>eM.gen(function*(){let r=new URLSearchParams({cwd:e});return t&&r.set("tabId",t),(yield*tD(`/api/terminal/env?${r}`)).env||{}}),tz=()=>tD("/api/terminal/aliases").pipe(eM.map(e=>e.aliases||{})),tH=(e,t,r)=>t_("/api/terminal/bubble-order",{cwd:e,tabId:t,order:r}),tO=(e,t,r)=>t_("/api/terminal/history",{cwd:e,tabId:t,entry:r}),tq=(e,t,r)=>tA(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(t)}&commandId=${encodeURIComponent(r)}`,{method:"DELETE"}),tV=e=>tD(`/api/services/config?cwd=${encodeURIComponent(e)}`),tK=(0,s.lazy)(()=>Promise.all([r.e(3888),r.e(1959)]).then(r.bind(r,71959)).then(e=>({default:e.XtermRenderer}))),tU={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},tJ=/\x1b\[[0-9;]*m/g;function tQ({output:e,query:t,mode:r,currentIdx:o,matchListRef:l}){let a=(0,s.useRef)(null);a.current||(a.current=new tR.v,a.current.use_classes=!0);let i=e.split("\n"),c=t.toLowerCase(),d=0;return l.current=[],(0,n.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((e,t)=>{let s=e.replace(tJ,""),i=s.toLowerCase().includes(c);if("filter"===r&&!i)return null;if(!i){let r=a.current.ansi_to_html(e);return(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:r}},t)}let u=[],m=0,x=s.toLowerCase(),h=0;for(;h<x.length;){let e=x.indexOf(c,h);if(-1===e)break;e>m&&u.push((0,n.jsx)("span",{children:s.slice(m,e)},`t${m}`));let t=d++,r=t===o;u.push((0,n.jsx)("mark",{ref:e=>{l.current[t]=e},className:r?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:s.slice(e,e+c.length)},`m${e}`)),h=m=e+c.length}return m<s.length&&u.push((0,n.jsx)("span",{children:s.slice(m)},`t${m}`)),(0,n.jsx)("div",{children:u},t)})})}let tX=(0,s.memo)(function({commandId:e,tabId:t,projectCwd:r,command:l,output:a,exitCode:c,isRunning:d,selected:u,onSelect:m,onInterrupt:x,onStdin:h,onDelete:f,onRerun:p,timestamp:g,usePty:b,subscribePtyOutput:v,subscribePtyReset:j,onPtyResize:w,onToggleMaximize:y,maximized:N,expandedHeight:C,bubbleContentHeight:S,onTitleMouseDown:L}){let{t:E}=(0,o.Bd)(),M=(0,s.useRef)(null),T=(0,s.useRef)(null),$=(0,s.useRef)(!0),P=(0,s.useRef)(null),R=(0,s.useRef)(null),B=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`})(g),F=e&&t?tB(t+e):void 0,[I,D]=(0,s.useState)(!1),[A,_]=(0,s.useState)(""),W=(0,s.useRef)(null),z=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!v||!e)return;let t=()=>W.current?v(e,W.current.write):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[v,e]),(0,s.useEffect)(()=>{if(!j||!e)return;let t=()=>W.current?j(e,W.current.reset):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[j,e]);let[H,O]=(0,s.useState)(!1),[q,V]=(0,s.useState)(""),[K,U]=(0,s.useState)("search"),[J,Q]=(0,s.useState)(0),X=(0,s.useRef)([]),Y=(0,s.useRef)(null),Z=(0,s.useRef)(0);(0,s.useEffect)(()=>{Y.current||(Y.current=new tR.v,Y.current.use_classes=!0)},[]),(0,s.useLayoutEffect)(()=>{let e=T.current;if(e&&Y.current){if(a.length<Z.current&&(Y.current=new tR.v,Y.current.use_classes=!0,Z.current=0,e.innerHTML=""),a.length>Z.current){let t=a.slice(Z.current),r=Y.current.ansi_to_html(t);Z.current=a.length,e.insertAdjacentHTML("beforeend",r)}if(M.current){let e=M.current.scrollHeight>M.current.clientHeight;D(e),e&&(M.current.scrollTop=M.current.scrollHeight)}}},[a]),(0,s.useEffect)(()=>(d&&$.current&&M.current&&(null!==P.current&&cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight),P.current=null})),()=>{null!==P.current&&cancelAnimationFrame(P.current)}),[a,d]),(0,s.useEffect)(()=>{if(!N)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),y?.())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[N,y]);let G=a?a.split("\n").length:0,ee=(0,s.useCallback)(()=>{O(!0),requestAnimationFrame(()=>z.current?.focus())},[]),et=(0,s.useCallback)(()=>{O(!1),V(""),Q(0),W.current?.clearSearch()},[]),er=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findNext(e):Q(e=>{let t=e+1,r=X.current[t];return r?(r.scrollIntoView({block:"nearest"}),t):(X.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[b]),en=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findPrevious(e):Q(e=>{let t=e-1;if(t>=0)return X.current[t]?.scrollIntoView({block:"nearest"}),t;let r=X.current.length-1;return r>=0&&X.current[r]?.scrollIntoView({block:"nearest"}),Math.max(r,0)}))},[b]);(0,s.useEffect)(()=>{if(!u)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key){e.preventDefault(),e.stopPropagation(),ee();return}if("Escape"===e.key&&H){e.preventDefault(),e.stopPropagation(),et();return}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[u,H,ee,et]);let es=N&&C?C-41:S??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${N?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${N?"":u?"border-brand":"border-brand/30"}`,onClick:m,children:[N?(0,n.jsxs)("div",{onDoubleClick:()=>y?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,n.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:l}),d&&(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),E("console.runningText")]}),d&&x&&(0,n.jsx)("button",{onClick:x,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,n.jsx)("button",{onClick:()=>y?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.restoreTooltip",{modKey:(0,tI.Mu)()}),children:(0,n.jsx)(ev.A,{className:"w-4 h-4"})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>L?.(),onDoubleClick:e=>{e.stopPropagation(),y?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${u?"border-brand":"border-brand/30"}`,children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),F&&e&&t&&(0,n.jsx)(tF,{shortId:F,type:"terminal",onRegister:()=>{i.t4.runFork(t_("/api/terminal/register",{tabId:t,commandId:e,command:l,projectCwd:r}).pipe(eM.orElse(()=>eM.void)))},onUnregister:()=>{i.t4.runFork(t_("/api/terminal/unregister",{commandId:e}).pipe(eM.orElse(()=>eM.void)))}}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:l}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(l),(0,k.oR)(E("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.copyCommand"),children:(0,n.jsx)(tE.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("span",{className:"flex-1"}),I&&!d&&(0,n.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:E("console.totalLines",{count:G})}),a&&(0,n.jsx)("button",{onClick:e=>{let t;e.stopPropagation(),t=a.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(t),(0,k.oR)(E("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.copyOutput"),children:(0,n.jsx)(tM.A,{className:"w-3.5 h-3.5"})}),p&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),p()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.rerun"),children:(0,n.jsx)(tT.A,{className:"w-3.5 h-3.5"})}),f&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),f()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:E("console.deleteRecord"),children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),H&&(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,n.jsx)(eb.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("input",{ref:z,value:q,onChange:e=>{let t=e.target.value;V(t),Q(0),b&&(t.trim()?W.current?.findNext(t):W.current?.clearSearch())},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?en(q):er(q))},placeholder:E("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!b&&(0,n.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,n.jsx)("button",{onClick:()=>U("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:E("console.searchMode")}),(0,n.jsx)("button",{onClick:()=>U("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:E("console.filterMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>en(q),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.prevShiftEnter"),children:(0,n.jsx)(t$.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>er(q),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.nextEnter"),children:(0,n.jsx)(tP.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("button",{onClick:et,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),b?(0,n.jsxs)("div",{className:"relative group",style:{height:es,overflow:"hidden"},children:[(0,n.jsx)(s.Suspense,{fallback:(0,n.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:es},children:E("console.loadingTerminal")}),children:(0,n.jsx)(tK,{ref:W,output:a,isRunning:d,onInput:h,onResize:w,maximized:N,height:es,directWrite:!!v})}),!d&&p&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:e=>{e.stopPropagation(),p()},title:E("console.rerun"),children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,n.jsx)(tT.A,{className:"w-3.5 h-3.5"}),E("console.rerun")]})})]}):(0,n.jsx)("div",{ref:M,className:"overflow-auto px-4 py-2",style:{height:es},onScroll:()=>{if(M.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=M.current;$.current=t-e-r<50}},children:H&&q.trim()?(0,n.jsx)(tQ,{output:a,query:q,mode:K,currentIdx:J,matchListRef:X}):(0,n.jsx)("pre",{ref:T,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),d&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),b?(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:E("console.clickToInput")}):h?(0,n.jsx)("input",{ref:R,value:A,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey){let t=tU[e.key.toLowerCase()];if(t){e.preventDefault(),e.stopPropagation(),h(t);return}}"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),h(A+"\n"),_("")),"Tab"===e.key&&(e.preventDefault(),h(" "))},placeholder:E("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:E("console.runningText")}),x&&(0,n.jsx)("button",{onClick:x,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),B&&(0,n.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:B})]}),!d&&void 0!==c&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===c?"bg-green-500":"bg-red-500"}`}),(0,n.jsx)("span",{children:E("console.exitCode",{code:c})}),(0,n.jsx)("span",{className:"flex-1"}),B&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:B})]})]})})});var tY=r(68459),tZ=r(51914);function tG({cwd:e,tabId:t,onClose:r,onSave:l}){let{t:a}=(0,o.Bd)(),[c,d]=(0,s.useState)({}),[u,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(""),[f,p]=(0,s.useState)(!0),g=(0,s.useCallback)(async()=>{p(!0);let r=await i.t4.runPromiseExit(tW(e,t));"Success"===r._tag?d(r.value):console.error("Failed to load env:",r.cause),p(!1)},[e,t]);(0,s.useEffect)(()=>{g()},[g]);let b=()=>{u.trim()&&(d(e=>({...e,[u.trim()]:x})),m(""),h(""))},v=async()=>{let n=await i.t4.runPromiseExit(t_("/api/terminal/env",{cwd:e,tabId:t,env:c}));"Success"===n._tag?(l(c),r()):console.error("Failed to save env:",n.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:a("envManager.title")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t?a("envManager.tabScope"):a("envManager.globalScope")})]}),(0,n.jsx)("button",{onClick:r,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:f?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:a("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(c).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void d(t=>({...t,[e]:r}))},placeholder:a("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,n.jsx)("button",{onClick:()=>{d(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,n.jsx)(tY.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:a("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),placeholder:a("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("button",{onClick:b,disabled:!u.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(tZ.A,{className:"w-4 h-4"})})]}),0===Object.keys(c).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:a("envManager.noVars")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:r,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:a("common.cancel")}),(0,n.jsx)("button",{onClick:v,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:a("common.save")})]})]})})}var t0=r(10762);function t1({onClose:e,onSave:t}){let{t:r}=(0,o.Bd)(),[l,a]=(0,s.useState)({}),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(!0),f=(0,s.useCallback)(async()=>{h(!0);let e=await i.t4.runPromiseExit(tz());"Success"===e._tag?a(e.value):console.error("Failed to load aliases:",e.cause),h(!1)},[]);(0,s.useEffect)(()=>{f()},[f]);let p=()=>{c.trim()&&u.trim()&&(a(e=>({...e,[c.trim()]:u.trim()})),d(""),m(""))},g=async()=>{let r=await i.t4.runPromiseExit(t_("/api/terminal/aliases",{aliases:l}));"Success"===r._tag?(t(l),e()):console.error("Failed to save aliases:",r.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,n.jsx)(t0.A,{className:"w-5 h-5"}),r("aliasManager.title")]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:r("aliasManager.description")})]}),(0,n.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:x?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:r("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(l).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void a(t=>({...t,[e]:r}))},placeholder:r("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,n.jsx)("button",{onClick:()=>{a(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,n.jsx)(tY.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:r("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:r("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("button",{onClick:p,disabled:!c.trim()||!u.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(tZ.A,{className:"w-4 h-4"})})]}),(0,n.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,n.jsx)("strong",{children:r("aliasManager.usage")}),r("aliasManager.usageDesc")]}),(0,n.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(l).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:r("aliasManager.noAliases")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:e,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:r("common.cancel")}),(0,n.jsx)("button",{onClick:g,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:r("common.save")})]})]})})}var t2=r(53961),t5=r(15813),t4=r(37595),t3=r(49698),t6=r(20232);let t8=new Map;function t9(e){t8.set(e.type,e)}function t7(e){return t8.get(e)}function re(e){for(let t of t8.values())if(t.match(e))return t;return null}let rt=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:t=>new eT.uV({message:`POST ${e} failed`,cause:t})}),rr=(e,t)=>i.t4.runPromise(rt(`/api/${e}/disconnect`,{id:t}).pipe(eM.orElse(()=>eM.void))),rn=e=>i.t4.runPromise(rt("/api/browser/unregister",{id:e}).pipe(eM.orElse(()=>eM.void))),rs=e=>i.t4.runPromise(e.pipe(eM.catchAll(e=>eM.sync(()=>{if(e.cause instanceof Error)throw e.cause;throw Error(e.message)})))),ro=(e,t)=>{if(e&&"object"==typeof e&&"error"in e){let t=e.error;if("string"==typeof t&&t.length>0)return t;if(t&&"object"==typeof t){let e=t.message;if("string"==typeof e&&e.length>0)return e;let r=t._tag;if("string"==typeof r&&r.length>0)return r}}return`HTTP ${t}`},rl=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json();if(!r.ok)throw Error(ro(n,r.status));return n},catch:t=>new eT.uV({message:`POST ${e} failed`,cause:t})})),ra=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=new URLSearchParams(t),n=await fetch(`${e}?${r}`),s=await n.json();if(!n.ok)throw Error(ro(s,n.status));return s},catch:t=>new eT.uV({message:`GET ${e} failed`,cause:t})})),ri=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return r.blob()},catch:t=>new eT.uV({message:`POST blob ${e} failed`,cause:t})}));var rc=r(53853);function rd(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.set("_cockpit","1"),t.toString()}catch{let t=e.includes("?")?"&":"?";return`${e}${t}_cockpit=1`}}function ru(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.delete("_cockpit"),t.toString()}catch{return e.replace(/[?&]_cockpit=1/,"")}}async function rm(e){let t=(0,rc.f)()?.id??null;return!!t&&new Promise(r=>{try{let n=globalThis.chrome?.runtime;if(!n?.sendMessage)return void r(!1);let s=setTimeout(()=>r(!1),2e3);n.sendMessage(t,{type:"prepare-iframe",url:e},e=>{clearTimeout(s),r(e?.ok??!1)})}catch{r(!1)}})}function rx(e){try{let t=new URL(e).hostname;return"localhost"===t||"127.0.0.1"===t}catch{return!1}}function rh({url:e,id:t,selected:r,maximized:i,expandedHeight:c,bubbleContentHeight:d,onSelect:u,onClose:m,onToggleMaximize:x,onNewTab:h,timestamp:f,onTitleMouseDown:p,initialSleeping:g,onSleep:b,onWake:v}){let{t:j}=(0,o.Bd)(),[w,y]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),[S,L]=(0,s.useState)(e),[E,M]=(0,s.useState)(null),[T,$]=(0,s.useState)(g??!1),P=(0,s.useRef)(null),R=(0,s.useRef)(null),B=(0,s.useRef)(null);(0,s.useEffect)(()=>{L(e)},[e]);let F=(0,s.useRef)(!0),I=(0,s.useCallback)(()=>{T||($(!0),M(null),b?.(t))},[T,t,b]),D=(0,s.useCallback)(()=>{P.current&&(clearTimeout(P.current),P.current=null)},[]),{shortId:A,connected:_,connect:W,disconnect:z}=function(e,t,r){let n=(0,s.useMemo)(()=>tB(e),[e]),[o,i]=(0,s.useState)(!1),c=(0,s.useRef)(null),d=(0,s.useRef)([]),u=(0,s.useRef)(null),m=(0,s.useRef)(!1),x=(0,s.useRef)(r);(0,s.useEffect)(()=>{x.current=r});let h=(0,s.useRef)([]);(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="cockpit:cmd-result"){let{reqId:t,ok:r,data:n,error:s}=e.data,o=c.current;o&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"browser:cmd-result",reqId:t,ok:r,data:n,error:s}));return}if(e.data?.type==="cockpit:prepare-screenshot"){let r=t.current;if(!r?.contentWindow)return;let n=new URLSearchParams(window.location.search).get("cwd")||"";window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!0}})),(0,l.F)(a.n.ScreenshotPrepare,{cwd:n}),requestAnimationFrame(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{setTimeout(()=>{let t=r.getBoundingClientRect(),n=window.devicePixelRatio||1,s=t.x,o=t.y;try{let e=window;for(;e!==e.top;){let t=e.frameElement;if(t){let e=t.getBoundingClientRect();s+=e.x,o+=e.y}e=e.parent}}catch{}r.contentWindow?.postMessage({type:"cockpit:screenshot-bounds",reqId:e.data.reqId,bounds:{x:Math.round(s*n),y:Math.round(o*n),width:Math.round(t.width*n),height:Math.round(t.height*n),dpr:n}},"*")},150)})));return}if(e.data?.type==="cockpit:screenshot-done"){window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!1}})),(0,l.F)(a.n.ScreenshotDone,{});return}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let f=(0,s.useCallback)(e=>{let r=t.current;if(!r?.contentWindow){let t=c.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"browser:cmd-result",reqId:e.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}r.contentWindow.postMessage({type:"cockpit:cmd",reqId:e.reqId,action:e.action,params:e.params},"*")},[t]);(0,s.useEffect)(()=>{if(!o)return;let r=!1;return m.current=!0,!function n(){if(r||!m.current)return;let s="https:"===window.location.protocol?"wss:":"ws:",o=new WebSocket(`${s}//${window.location.host}/ws/browser?fullId=${encodeURIComponent(e)}`);c.current=o,o.onopen=()=>{for(let e of h.current)e();if(h.current=[],d.current.length>0){for(let e of d.current)f(e);d.current=[]}},o.onmessage=e=>{let r;try{r=JSON.parse(e.data)}catch{return}if("browser:cmd"===r.type){let e=r;t.current?.contentWindow&&x.current?f(e):d.current.push(e)}},o.onclose=()=>{c.current=null,!r&&m.current&&(u.current=setTimeout(n,3e3))},o.onerror=()=>o.close()}(),()=>{r=!0,m.current=!1,u.current&&clearTimeout(u.current),c.current&&(c.current.close(),c.current=null),h.current=[]}},[o,e,t,f]),(0,s.useEffect)(()=>{if(r&&d.current.length>0){for(let e of d.current)f(e);d.current=[]}},[r,f]);let p=(0,s.useCallback)(()=>o&&c.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(e=>{h.current.push(e),o||i(!0)}),[o]);return{shortId:n,connected:o,connect:p,disconnect:(0,s.useCallback)(()=>{i(!1)},[])}}(t,B,!!E&&!T&&!w),H=(0,s.useRef)(_);H.current=_,(0,s.useEffect)(()=>{let e=R.current;if(!e||T)return;let t=new IntersectionObserver(([e])=>{F.current=e.isIntersecting,e.isIntersecting||H.current?D():(P.current&&clearTimeout(P.current),P.current=setTimeout(I,3e5))});return t.observe(e),()=>t.disconnect()},[T,I,D]),(0,s.useEffect)(()=>{T?z():_?D():F.current||(P.current&&clearTimeout(P.current),P.current=setTimeout(I,3e5))},[_,T,z,D,I]),(0,s.useEffect)(()=>{g&&M(null)},[]);let O=(0,s.useCallback)(()=>{$(!1),v?.(t);let r=rd(e);rx(e)?M(r):rm(e).then(()=>M(r))},[e,t,v]);(0,s.useEffect)(()=>{if(!e||T){e||M(null);return}let t=rd(e);if(rx(e))return void M(t);let r=!1;return rm(e).then(()=>{r||M(t)}),()=>{r=!0}},[e,T]);let q=(0,s.useCallback)(()=>y(!1),[]);(0,s.useEffect)(()=>{let e=R.current;if(!e)return;let t=null,r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e){t=r;break}r=r.parentElement}if(!t)return;let n="",s=0,o=!1,l=()=>{o&&t&&(t.scrollTop=s)},a=()=>{n=t.style.overflow,s=t.scrollTop,o=!0,t.style.overflow="hidden",t.addEventListener("scroll",l)},i=()=>{o=!1,t.removeEventListener("scroll",l),t.style.overflow=n};return e.addEventListener("mouseenter",a),e.addEventListener("mouseleave",i),()=>{e.removeEventListener("mouseenter",a),e.removeEventListener("mouseleave",i),t.removeEventListener("scroll",l),o&&(t.style.overflow=n)}},[]),(0,s.useEffect)(()=>{let e=e=>{if(!e.data||"string"!=typeof e.data.type||!e.data.type.startsWith("cockpit:"))return;let r=R.current?.querySelector("iframe");if(!r||e.source!==r.contentWindow)return;let n=e.data.type;"cockpit:new-tab"===n&&e.data.url?h?.(ru(e.data.url),t):("cockpit:navigate"===n||"cockpit:loaded"===n)&&e.data.url&&L(ru(e.data.url))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[t,h]);let V=(0,s.useCallback)(()=>{y(!1),C(j("browser.pageLoadFailed"))},[]),K=(0,s.useCallback)(()=>{if(T)return void O();let e=R.current?.querySelector("iframe");if(e&&E){y(!0),C(null);let t=e.src;e.src="",setTimeout(()=>{e.src=t},0)}},[T,O,E]);(0,s.useEffect)(()=>{e&&!T&&(y(!0),C(null))},[e,T]);let U=(0,s.useCallback)(()=>{S&&window.open(S,"_blank")},[S]);(0,s.useEffect)(()=>{if(!r&&!i)return;let e=e=>{"Escape"===e.key&&i&&(e.stopPropagation(),x()),"m"===e.key&&(e.metaKey||e.ctrlKey)&&r&&(e.preventDefault(),e.stopPropagation(),x())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[i,r,x]);let J=function(e){if(!e)return"";try{let t=new URL(e);return t.port?`${t.hostname}:${t.port}`:t.hostname}catch{return e}}(S),Q=i&&c?c-41:d??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5188],{1058:(e,t,r)=>{r.d(t,{_:()=>a});var n=r(12115),s=r(90717),o=r(86957),l=r(46456);function a({cwd:e,filePath:t}){let[r,i]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[u,m]=(0,n.useState)(null),x=(0,n.useCallback)(async()=>{if(!e||!t)return;d(!0),m(null);let r=await o.t4.runPromiseExit((0,l.lb)(e,t));if("Success"===r._tag)i(r.value.comments??[]);else{let e="Fail"===r.cause._tag?r.cause.error:null,t=e?.cause;m(t instanceof Error?t.message:"Failed to load comments")}d(!1)},[e,t]);(0,n.useEffect)(()=>{x()},[x]),(0,n.useEffect)(()=>(0,s.zL)(()=>{x()}),[x]);let h=(0,n.useCallback)(async(r,n,s,a)=>{let c=await o.t4.runPromiseExit((0,l.BC)({cwd:e,filePath:t,startLine:r,endLine:n,content:s,...a?{selectedText:a}:{}}));if("Success"===c._tag&&c.value.comment){let e=c.value.comment;return i(t=>[...t,e]),e}return"Failure"===c._tag&&console.error("Failed to add comment:",c.cause),null},[e,t]),f=(0,n.useCallback)(async(t,r)=>{let n=await o.t4.runPromiseExit((0,l.vv)(e,t,r));if("Success"===n._tag&&n.value.comment){let e=n.value.comment;return i(r=>r.map(r=>r.id===t?e:r)),!0}return"Failure"===n._tag&&console.error("Failed to update comment:",n.cause),!1},[e]),p=(0,n.useCallback)(async t=>{let r=await o.t4.runPromiseExit((0,l.Tu)(e,t));return"Success"===r._tag?(i(e=>e.filter(e=>e.id!==t)),!0):(console.error("Failed to delete comment:",r.cause),!1)},[e]),g=(0,n.useCallback)(e=>r.filter(t=>e>=t.startLine&&e<=t.endLine),[r]);return{comments:r,isLoading:c,error:u,addComment:h,updateComment:f,deleteComment:p,refresh:x,getCommentsForLine:g}}},2228:(e,t,r)=>{r.d(t,{ProjectItem:()=>a});var n=r(95155),s=r(12115),o=r(79114);function l({number:e,isActive:t}){return(0,n.jsxs)("svg",{className:`w-6 h-6 flex-shrink-0 ${t?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"4"}),(0,n.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:e})]})}function a({index:e,name:t,cwd:r,isActive:i,collapsed:c,hasUnread:d,isLoading:u,onClick:m,onRemove:x,onOpenNote:h}){let{t:f}=(0,o.Bd)(),[p,g]=(0,s.useState)(!1);return(0,n.jsxs)("div",{className:`flex items-center gap-2 px-2 py-1 rounded-lg cursor-pointer transition-colors relative ${c?"justify-center":""} ${i?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary hover:text-foreground"}`,onClick:m,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),title:r,children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(l,{number:e+1,isActive:i}),d&&!i&&!u&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),u&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"})]}),!c&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"flex-1 truncate text-sm",children:t}),!u&&i?(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}):null]}),p&&!c&&(0,n.jsxs)("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 flex items-center gap-0.5",children:[h&&(0,n.jsx)("button",{className:"p-1 rounded hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:e=>{e.stopPropagation(),h()},title:f("workspace.projectNotes"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,n.jsx)("button",{className:"p-1 rounded hover:bg-red-500/20 text-muted-foreground hover:text-red-500 transition-colors",onClick:e=>{e.stopPropagation(),x()},title:f("workspace.closeProject"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]})}},3292:(e,t,r)=>{r.d(t,{P:()=>c});var n=r(12115),s=r(95045),o=r(75346),l=r(49433),a=r(86957),i=r(82680);function c(){let[e,t]=(0,n.useState)([]),r=(0,n.useCallback)(()=>{let e=l.tryPromise({try:async()=>{let e=await fetch("/api/pinned-sessions");return await e.json()},catch:e=>new i.uV({message:"loadPinnedSessions failed",cause:e})});a.t4.runPromise(e.pipe(l.match({onSuccess:e=>t(e.sessions||[]),onFailure:()=>{}})))},[]);(0,n.useEffect)(()=>{r()},[r]),(0,n.useEffect)(()=>{let e=e=>{e.data?.type==="PINNED_SESSIONS_CHANGED"&&r()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[r]);let c=(0,n.useCallback)(e=>{t(e);let r=l.tryPromise({try:async()=>{await fetch("/api/pinned-sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessions:e})})},catch:e=>new i.uV({message:"savePinnedSessions failed",cause:e})});a.t4.runFork(r.pipe(l.orElse(()=>l.void))),(0,s.F)(o.n.PinnedSessionsChanged,{})},[]),d=(0,n.useCallback)(t=>e.some(e=>e.sessionId===t),[e]),u=(0,n.useCallback)((t,r,n)=>{e.some(e=>e.sessionId===t)||c([...e,{sessionId:t,cwd:r,customTitle:n}])},[e,c]),m=(0,n.useCallback)(t=>{c(e.filter(e=>e.sessionId!==t))},[e,c]),x=(0,n.useCallback)((t,r)=>{c(e.map(e=>e.sessionId===t?{...e,customTitle:r}:e))},[e,c]);return{pinnedSessions:e,isPinned:d,pinSession:u,unpinSession:m,updateTitle:x,reorder:(0,n.useCallback)(e=>{c(e)},[c]),reload:r}}},7320:(e,t,r)=>{r.d(t,{G:()=>a,t:()=>l});var n=r(95155),s=r(12115),o=r(79114);function l({x:e,y:t,range:r,lineSnapshot:a,container:i,onSubmit:c,onClose:d}){let{t:u}=(0,o.Bd)(),[m,x]=(0,s.useState)(""),[h,f]=(0,s.useState)(!1),p=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0}),j=a?.split("\n").slice(0,5).join("\n"),w=!!a&&a.split("\n").length>5;return(0,s.useEffect)(()=>{if(p.current&&i){let r=i.getBoundingClientRect(),n=p.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,i]),(0,s.useEffect)(()=>{g.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{h||!p.current||p.current.contains(e.target)||d()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d,h]),(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,n.jsx)("div",{className:"px-3 py-2 bg-amber-9/10 border-b border-border",children:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-amber-11",children:u("comments.addComment")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:u("comments.lineRange",{start:r.start,end:r.end})})]})}),a&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[j,w&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:g,value:m,onChange:e=>x(e.target.value),placeholder:u("comments.inputPlaceholder"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:h,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!h&&m.trim()&&(f(!0),c(m.trim()))),"Escape"!==e.key||h||d()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:u(h?"comments.submitting":"comments.enterSubmit")})]})]})}function a({x:e,y:t,range:r,filePath:l,lineSnapshot:i,container:c,onSubmit:d,onClose:u,isChatLoading:m}){let{t:x}=(0,o.Bd)(),[h,f]=(0,s.useState)(""),p=(0,s.useRef)(null),g=(0,s.useRef)(null),[b,v]=(0,s.useState)({x:0,y:0});(0,s.useEffect)(()=>{if(p.current&&c){let r=c.getBoundingClientRect(),n=p.current.getBoundingClientRect(),s=e-r.left,o=t-r.top;s+n.width>r.width-16&&(s=r.width-n.width-16),s<16&&(s=16),o+n.height>r.height-16&&(o=o-n.height-8),o<16&&(o=16),queueMicrotask(()=>v({x:s,y:o}))}},[e,t,c]),(0,s.useEffect)(()=>{g.current?.focus()},[]),(0,s.useEffect)(()=>{let e=e=>{p.current&&!p.current.contains(e.target)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);let j=i?.split("\n").slice(0,5).join("\n"),w=!!i&&i.split("\n").length>5;return(0,n.jsxs)("div",{ref:p,className:"absolute z-[200] w-[640px] bg-card border border-border rounded-lg shadow-lg overflow-hidden",style:{left:b.x,top:b.y},children:[(0,n.jsxs)("div",{className:"px-3 py-2 bg-brand/10 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-brand",children:x("comments.askAI")}),(r.start>0||r.end>0)&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:x("comments.lineRange",{start:r.start,end:r.end})})]}),l&&(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate",children:l})]}),i&&(0,n.jsx)("div",{className:"px-3 py-2 bg-secondary/50 border-b border-border max-h-24 overflow-hidden",children:(0,n.jsxs)("pre",{className:"text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all",children:[j,w&&(0,n.jsx)("span",{className:"text-muted-foreground/50",children:"..."})]})}),(0,n.jsxs)("div",{className:"p-2",children:[(0,n.jsx)("textarea",{ref:g,value:h,onChange:e=>f(e.target.value),placeholder:x("comments.inputQuestion"),className:"w-full px-2 py-1.5 text-sm border border-border rounded bg-card resize-none focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50 disabled:cursor-not-allowed",rows:2,disabled:m,onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),!m&&h.trim()&&(d(h.trim()),u())),"Escape"===e.key&&u()}}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground",children:x(m?"comments.aiGenerating":"comments.enterSend")})]})]})}},8648:(e,t,r)=>{r.d(t,{NoteModal:()=>C});var n=r(95155),s=r(12115),o=r(79114),l=r(69809),a=r(13439),i=r(37795),c=r(43561),d=r(5989),u=r(76065),m=r(43203),x=r(6268),h=r(48434),f=r(44695),p=r(59265),g=r(26932);function b(e){return e.storage.markdown.getMarkdown()}function v(){return[{label:l.A.t("slashCommands.heading1"),icon:"H1",description:l.A.t("slashCommands.heading1Desc"),action:e=>e.chain().focus().toggleHeading({level:1}).run()},{label:l.A.t("slashCommands.heading2"),icon:"H2",description:l.A.t("slashCommands.heading2Desc"),action:e=>e.chain().focus().toggleHeading({level:2}).run()},{label:l.A.t("slashCommands.heading3"),icon:"H3",description:l.A.t("slashCommands.heading3Desc"),action:e=>e.chain().focus().toggleHeading({level:3}).run()},{label:l.A.t("slashCommands.bulletList"),icon:"•",description:l.A.t("slashCommands.bulletListDesc"),action:e=>e.chain().focus().toggleBulletList().run()},{label:l.A.t("slashCommands.orderedList"),icon:"1.",description:l.A.t("slashCommands.orderedListDesc"),action:e=>e.chain().focus().toggleOrderedList().run()},{label:l.A.t("slashCommands.taskList"),icon:"☑",description:l.A.t("slashCommands.taskListDesc"),action:e=>e.chain().focus().toggleTaskList().run()},{label:l.A.t("slashCommands.blockquote"),icon:"❝",description:l.A.t("slashCommands.blockquoteDesc"),action:e=>e.chain().focus().toggleBlockquote().run()},{label:l.A.t("slashCommands.codeBlock"),icon:"<>",description:l.A.t("slashCommands.codeBlockDesc"),action:e=>e.chain().focus().toggleCodeBlock().run()},{label:l.A.t("slashCommands.table"),icon:"▦",description:l.A.t("slashCommands.tableDesc"),action:e=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{label:l.A.t("slashCommands.horizontalRule"),icon:"──",description:l.A.t("slashCommands.horizontalRuleDesc"),action:e=>e.chain().focus().setHorizontalRule().run()},{label:l.A.t("slashCommands.link"),icon:"\uD83D\uDD17",description:l.A.t("slashCommands.linkDesc"),action:e=>{window.dispatchEvent(new CustomEvent("tiptap-insert-link"))}}]}function j({editor:e,query:t,position:r,onClose:o}){let[l,a]=(0,s.useState)(0),i=(0,s.useRef)(null),c=v().filter(e=>e.label.toLowerCase().includes(t.toLowerCase())||e.description.toLowerCase().includes(t.toLowerCase()));(0,s.useEffect)(()=>{queueMicrotask(()=>a(0))},[t]);let d=r=>{e.chain().focus().deleteRange({from:e.state.selection.from-t.length-1,to:e.state.selection.from}).run(),r.action(e),o()};return((0,s.useEffect)(()=>{let e=e=>{"ArrowDown"===e.key?(e.preventDefault(),a(e=>(e+1)%c.length)):"ArrowUp"===e.key?(e.preventDefault(),a(e=>(e-1+c.length)%c.length)):"Enter"===e.key?(e.preventDefault(),c[l]&&d(c[l])):"Escape"===e.key&&(e.preventDefault(),o())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[c,l,o]),0===c.length)?null:(0,n.jsx)("div",{ref:i,className:"slash-command-menu fixed z-[60] bg-popover border border-border rounded-lg shadow-lg py-1 w-56 max-h-64 overflow-y-auto",style:{top:r.top,left:r.left},children:c.map((e,t)=>(0,n.jsxs)("button",{className:`w-full flex items-center gap-3 px-3 py-2 text-left text-sm transition-colors ${t===l?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>d(e),onMouseEnter:()=>a(t),children:[(0,n.jsx)("span",{className:"w-6 text-center text-xs font-mono flex-shrink-0",children:e.icon}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"font-medium",children:e.label}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.label))})}v();var w=r(76043),y=r(86957),k=r(49433),N=r(76900);function C({isOpen:e,onClose:t,projectCwd:r,projectName:v}){let{t:S}=(0,o.Bd)(),[L,E]=(0,s.useState)(!0),[M,T]=(0,s.useState)(!1),$=(0,s.useRef)(null),P=(0,s.useRef)(!1),[R,B]=(0,s.useState)(null),F=(0,s.useRef)(null),I=(0,s.useCallback)(async e=>{T(!0),"Success"===(await y.t4.runPromiseExit((0,N.Cq)(r,e).pipe(k.tapError(e=>k.sync(()=>console.error("Failed to save note:",e))))))._tag&&(P.current=!1),T(!1)},[r]),D=(0,s.useCallback)(e=>{P.current=!0,$.current&&clearTimeout($.current),$.current=setTimeout(()=>{I(e)},5e3)},[I]),A=(0,a.hG)({immediatelyRender:!1,extensions:[i.A.configure({heading:{levels:[1,2,3]}}),c.A.configure({placeholder:()=>l.A.t("editor.placeholder")}),d.XI.configure({resizable:!0}),u.H,m.n,x.A,h._,p.Ay.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1,HTMLAttributes:{class:"tiptap-link",target:"_blank",rel:"noopener noreferrer"}}),f.L.configure({nested:!0}),g.o.configure({html:!0,transformCopiedText:!0,transformPastedText:!0})],editorProps:{attributes:{class:"tiptap-editor focus:outline-none min-h-[60vh] px-6 py-4"},handleClick:(e,t,r)=>{if(r.metaKey||r.ctrlKey){let r=e.state.doc.resolve(t).marks().find(e=>"link"===e.type.name)?.attrs;if(r?.href)return window.open(r.href,"_blank","noopener,noreferrer"),!0}return!1},handleKeyDown:(e,t)=>{if("Backspace"===t.key&&_.current){let e=_.current;if(e.isActive("codeBlock")){let{$from:t}=e.state.selection,r=t.node(t.depth);if("codeBlock"===r.type.name&&""===r.textContent)return e.chain().focus().toggleCodeBlock().run(),!0}}return"/"!==t.key||R||setTimeout(()=>{if(!_.current)return;let{from:e}=_.current.state.selection;if("/"===_.current.state.doc.textBetween(Math.max(0,e-1),e,"\n")){F.current=e;let t=_.current.view.coordsAtPos(e);B({query:"",position:{top:t.bottom+4,left:t.left}})}},0),!1}},onUpdate:({editor:e})=>{if(D(b(e)),null!==F.current){let{from:t}=e.state.selection;if(t<F.current)B(null),F.current=null;else{let r=e.state.doc.textBetween(F.current,t,"\n");r.includes(" ")||r.includes("\n")?(B(null),F.current=null):B(e=>e?{...e,query:r}:null)}}}}),_=(0,s.useRef)(A);(0,s.useEffect)(()=>{_.current=A},[A]),(0,s.useEffect)(()=>{e&&A&&(E(!0),B(null),F.current=null,y.t4.runPromiseExit((0,N.zF)(r)).then(e=>{"Success"===e._tag?(A.commands.setContent(e.value.content||""),P.current=!1):console.error("Failed to load note:",e.cause),E(!1)}))},[e,A,r]);let W=(0,s.useCallback)(()=>{$.current&&(clearTimeout($.current),$.current=null),P.current&&A&&I(b(A)),B(null),F.current=null,t()},[A,I,t]);return((0,s.useEffect)(()=>()=>{$.current&&clearTimeout($.current)},[]),(0,s.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&(R?(B(null),F.current=null):W())};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,W,R]),e)?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:W}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-6xl h-[90vh] mx-4 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:v?S("editor.noteTitle",{name:v}):S("editor.noteUntitled")}),M&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:S("editor.saving")})]}),(0,n.jsx)("button",{onClick:W,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(w.NoteToolbar,{editor:A}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:L?(0,n.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:(0,n.jsx)("span",{children:S("common.loading")})}):(0,n.jsx)(a.$Z,{editor:A})})]}),R&&A&&(0,n.jsx)(j,{editor:A,query:R.query,position:R.position,onClose:()=>{B(null),F.current=null}})]}):null}},12786:(e,t,r)=>{r.d(t,{L:()=>s,Mu:()=>o});var n=r(41463);function s(){return!("u"<typeof navigator)&&(/Mac|iPhone|iPad/.test(navigator.platform||"")||navigator.userAgentData?.platform==="macOS")}function o(){return s()?"⌘":"Ctrl+"}n.platform,n.platform,n.platform},17196:(e,t,r)=>{r.d(t,{Np:()=>d,ZD:()=>i,b8:()=>c,kS:()=>l,sQ:()=>a});var n=r(67014);let s=null,o=["typescript","tsx","javascript","jsx","html","css","scss","json","yaml","python","go","rust","java","ruby","php","bash","shell","markdown","sql","c","cpp","swift","kotlin","dart","lua","graphql","xml"];function l(){return s||(s=(0,n.O_)({themes:["github-dark","github-light"],langs:[...o]})),s}function a(e){let t=e.split("/").pop()?.toLowerCase()||"",r=t.split(".").pop()?.toLowerCase();if(".env"===t||t.startsWith(".env.")||"dockerfile"===t||t.startsWith("dockerfile.")||"makefile"===t)return"bash";let n={ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",rb:"ruby",php:"php",cs:"cpp",cpp:"cpp",c:"c",h:"c",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",sql:"sql",swift:"swift",dart:"dart",lua:"lua",graphql:"graphql",gql:"graphql",toml:"yaml",sass:"scss",less:"css",scala:"java",r:"python",vim:"bash",env:"bash"}[r||""]||"text";return o.includes(n)?n:"text"}function i(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function c(e){return e.map(e=>e.color?`<span style="color:${e.color}">${i(e.content)}</span>`:i(e.content)).join("")}function d(e,t,r,n){if(!t)return[];let s=[],o=r?t:t.toLowerCase();for(let t=0;t<e.length;t++){let l=r?e[t]:e[t].toLowerCase(),a=0;for(;;){let e=l.indexOf(o,a);if(-1===e)break;let r=e+o.length;if(n){let n=e>0?l[e-1]:" ",o=r<l.length?l[r]:" ",a=!/\w/.test(n),i=!/\w/.test(o);a&&i&&s.push({lineIndex:t,startCol:e,endCol:r})}else s.push({lineIndex:t,startCol:e,endCol:r});a=e+1}}return s}},21484:(e,t,r)=>{r.d(t,{SettingsModal:()=>x});var n=r(95155),s=r(12115),o=r(79114),l=r(3238),a=r(34075),i=r(12786),c=r(53853),d=r(86957),u=r(49433),m=r(76900);function x({isOpen:e,onClose:t}){let{t:r,i18n:h}=(0,o.Bd)(),{theme:f,setTheme:p}=(0,l.D)(),g=(0,c.G)(),[b,v]=(0,s.useState)(""),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)("auto");(0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.M5)()).then(e=>{"Success"===e._tag&&e.value.language&&k(e.value.language)})},[e]);let N=(0,s.useCallback)(e=>{k(e),d.t4.runFork((0,m.DZ)({language:e}).pipe(u.orElse(()=>u.void)));let t="auto"===e?navigator.language.startsWith("zh")?"zh":"en":e;h.changeLanguage(t)},[h]),C=g?"installed":"not-installed",S=g?.version??null;if((0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.Wr)()).then(e=>{"Success"===e._tag&&e.value.version&&w(e.value.version)})},[e]),(0,s.useEffect)(()=>{e&&d.t4.runPromiseExit((0,m.Or)()).then(e=>{"Success"===e._tag&&e.value.path&&v(e.value.path)})},[e]),!e)return null;let L=[{value:"system",label:r("settings.themeSystem"),icon:"\uD83D\uDCBB"},{value:"light",label:r("settings.themeLight"),icon:"☀️"},{value:"dark",label:r("settings.themeDark"),icon:"\uD83C\uDF19"}];return(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:t}),(0,n.jsxs)("div",{className:"relative bg-card rounded-lg shadow-xl w-full max-w-md mx-4 overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:r("settings.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsxs)("div",{className:"p-4 space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.theme")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:L.map(e=>(0,n.jsxs)("button",{onClick:()=>p(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${f===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.language")}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-2",children:[{value:"auto",label:r("settings.languageAuto"),icon:"\uD83C\uDF10"},{value:"en",label:"English",icon:"\uD83C\uDDFA\uD83C\uDDF8"},{value:"zh",label:"中文",icon:"\uD83C\uDDE8\uD83C\uDDF3"}].map(e=>(0,n.jsxs)("button",{onClick:()=>N(e.value),className:`flex flex-col items-center gap-1 p-3 rounded-lg border transition-colors ${y===e.value?"border-brand bg-brand/10 text-brand":"border-border hover:border-slate-6 text-muted-foreground hover:text-foreground"}`,children:[(0,n.jsx)("span",{className:"text-xl",children:e.icon}),(0,n.jsx)("span",{className:"text-xs font-medium",children:e.label})]},e.value))})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.browserExtension")}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${"installed"===C?"bg-green-500":"bg-slate-400"}`}),(0,n.jsxs)("span",{children:["installed"===C&&`${r("settings.extensionInstalled")}${S?` (v${S})`:""}`,"not-installed"===C&&r("settings.extensionNotInstalled")]})]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r("settings.extensionDescription")}),"installed"!==C&&(0,n.jsxs)("div",{className:"text-xs text-muted-foreground bg-muted/50 rounded-md p-2 space-y-1",children:[(0,n.jsx)("p",{className:"font-medium text-foreground",children:r("settings.installSteps")}),(0,n.jsxs)("p",{children:[r("settings.step1")," ",(0,n.jsx)("code",{className:"px-1 py-0.5 bg-muted rounded text-foreground",children:"chrome://extensions"})]}),(0,n.jsx)("p",{children:r("settings.step2")}),(0,n.jsx)("p",{children:r("settings.step3")}),(0,i.L)()&&(0,n.jsx)("p",{dangerouslySetInnerHTML:{__html:r("settings.step4mac")}})]}),(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsx)("button",{onClick:()=>{let e=b||"chrome-extension";navigator.clipboard.writeText(e),(0,a.oR)(r("toast.copiedName",{name:e}))},className:"px-3 py-1.5 text-xs bg-brand text-white rounded-md hover:bg-brand/90 transition-colors",children:r("settings.copyExtensionPath")}),"installed"===C&&(0,n.jsx)("button",{onClick:()=>{g?.id&&window.chrome?.runtime?.sendMessage&&(window.chrome.runtime.sendMessage(g.id,{type:"reload"}),(0,a.oR)(r("toast.pluginReloading")))},className:"px-3 py-1.5 text-xs border border-border text-foreground rounded-md hover:bg-muted transition-colors",children:r("settings.reloadExtension")})]}),b&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground font-mono truncate",children:b})]})]}),(0,n.jsx)("div",{className:"border-t border-border"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-foreground mb-2",children:r("settings.about")}),(0,n.jsxs)("div",{className:"text-xs text-muted-foreground space-y-1",children:[(0,n.jsxs)("p",{children:["Cockpit",j?` v${j}`:""]}),(0,n.jsx)("p",{className:"text-muted-foreground/60",children:"One seat. One AI. Everything under control."})]})]})]})]})]})}},23121:(e,t,r)=>{r.d(t,{n:()=>m});var n=r(12115),s=r(95045),o=r(75346),l=r(49433),a=r(86957),i=r(82680);let c=(e,t,r)=>l.tryPromise({try:async()=>{let n=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()},catch:r=>new i.uV({message:`${t} ${e} failed`,cause:r})}),d="SCHEDULED_TASKS_CHANGED";function u(){(0,s.F)(o.n.ScheduledTasksChanged,{}),document.querySelectorAll("iframe").forEach(e=>{try{e.contentWindow?.postMessage({type:d},"*")}catch{}})}function m(){let[e,t]=(0,n.useState)([]),[r,s]=(0,n.useState)(0),o=(0,n.useCallback)(()=>{let e;a.t4.runPromise((e="/api/scheduled-tasks",l.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new i.uV({message:`fetch ${e} failed`,cause:t})})).pipe(l.match({onSuccess:e=>{t(e.tasks??[]),s(e.unreadCount??0)},onFailure:()=>{}})))},[]);(0,n.useEffect)(()=>{o()},[o]),(0,n.useEffect)(()=>{let e=e=>{e.data?.type===d&&o()};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[o]);let m=(0,n.useCallback)(async e=>{let t=await a.t4.runPromiseExit(c("/api/scheduled-tasks","POST",e));if("Success"!==t._tag)return null;let r=t.value;return r.task?(o(),u(),r.task):null},[o]),x=(0,n.useCallback)(async(e,t,r)=>{await a.t4.runPromise(c("/api/scheduled-tasks","PATCH",{id:e,action:t,fields:r}).pipe(l.asVoid).pipe(l.orElse(()=>l.void))),o(),u()},[o]),h=(0,n.useCallback)(e=>x(e,"pause"),[x]),f=(0,n.useCallback)(e=>x(e,"resume"),[x]),p=(0,n.useCallback)(async e=>{await a.t4.runPromise(c("/api/scheduled-tasks","DELETE",{id:e}).pipe(l.asVoid).pipe(l.orElse(()=>l.void))),o(),u()},[o]),g=(0,n.useCallback)((e,t)=>x(e,"update",t),[x]),b=(0,n.useCallback)(e=>x(e,"trigger"),[x]),v=(0,n.useCallback)(e=>x(e,"markRead"),[x]);return{tasks:e,unreadCount:r,reload:o,createTask:m,pauseTask:h,resumeTask:f,triggerTask:b,deleteTask:p,updateTask:g,markRead:v,markAllRead:(0,n.useCallback)(()=>x("_","markAllRead"),[x]),reorderTasks:(0,n.useCallback)(e=>x("_","reorder",{orderedIds:e}),[x])}}},24058:(e,t,r)=>{r.d(t,{TabBar:()=>d});var n=r(95155),s=r(12115),o=r(94287),l=r(64428),a=r(79114);function i({number:e,isActive:t}){return(0,n.jsxs)("svg",{className:`w-5 h-5 flex-shrink-0 ${t?"text-brand":"text-muted-foreground"}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,n.jsx)("text",{x:"12",y:"16",textAnchor:"middle",fill:"currentColor",stroke:"none",fontSize:"12",fontWeight:"500",children:e})]})}function c({onNewTab:e,onNewClaude2Tab:t,onNewCodexTab:r,onNewKimiTab:o,onNewOllamaTab:a,onNewDeepseekTab:i}){let[d,u]=(0,s.useState)(!1),m=(0,s.useRef)(null),x=(0,s.useRef)(null),[h,f]=(0,s.useState)({top:0,right:0}),p=(0,l.F2)();(0,s.useEffect)(()=>{if(!d)return;let e=e=>{x.current&&!x.current.contains(e.target)&&m.current&&!m.current.contains(e.target)&&u(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[d]);let g=n=>{u(!1),"claude2"===n?t?.():"codex"===n?r?.():"kimi"===n?o?.():"ollama"===n?a?.():"deepseek"===n?i?.():e()};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:m,onClick:()=>{if(!d&&m.current){let e=m.current.getBoundingClientRect(),t=p?.getBoundingClientRect(),r=t?.left??0,n=t?.top??0,s=t?.width??window.innerWidth;f({top:e.bottom+4-n,right:s-(e.right-r)})}u(e=>!e)},className:"flex-shrink-0 p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:"New tab",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),d&&(0,n.jsx)(l.ZL,{children:(0,n.jsxs)("div",{ref:x,className:"fixed z-[9999] bg-popover border border-border rounded-lg shadow-lg py-1 min-w-[140px]",style:{top:h.top,right:h.right},children:[(0,n.jsxs)("button",{onClick:()=>g("claude"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-brand flex-shrink-0"}),"Claude Code"]}),(0,n.jsxs)("button",{onClick:()=>g("claude2"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-orange-500 flex-shrink-0"}),"Claude 2"]}),(0,n.jsxs)("button",{onClick:()=>g("codex"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),"OpenAI Codex"]}),(0,n.jsxs)("button",{onClick:()=>g("deepseek"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),"DeepSeek"]}),(0,n.jsxs)("button",{onClick:()=>g("kimi"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-500 flex-shrink-0"}),"Kimi"]}),(0,n.jsxs)("button",{onClick:()=>g("ollama"),className:"w-full flex items-center gap-2 px-3 py-1.5 text-xs text-foreground hover:bg-brand/10 transition-colors whitespace-nowrap",children:[(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-violet-500 flex-shrink-0"}),"Ollama"]})]})})]})}function d({tabs:e,activeTabId:t,unreadTabs:r,dragTabIndex:s,dragOverTabIndex:l,isPinned:u,onTogglePin:m,onSwitchTab:x,onCloseTab:h,onNewTab:f,onNewClaude2Tab:p,onNewCodexTab:g,onNewKimiTab:b,onNewOllamaTab:v,onNewDeepseekTab:j,onDragStart:w,onDragOver:y,onDrop:k,onDragEnd:N}){let{t:C}=(0,a.Bd)();return(0,n.jsx)("div",{className:"border-b border-border bg-card shrink-0",children:(0,n.jsxs)("div",{className:"flex items-center px-2 gap-1 overflow-x-auto",children:[e.map((a,c)=>(0,n.jsx)(o.m,{content:a.title,delay:200,className:"flex-1 min-w-16 max-w-32",children:(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>w(c),onDragOver:e=>y(e,c),onDrop:()=>k(c),onDragEnd:N,className:`group flex items-center gap-1 px-3 py-1.5 text-sm cursor-pointer rounded-t-lg transition-colors ${a.id===t?"bg-accent text-foreground":"text-muted-foreground hover:bg-secondary"} ${s===c?"opacity-50":""} ${l===c?"border-l-2 border-brand":""}`,onClick:()=>x(a.id),children:[(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)(i,{number:c+1,isActive:a.id===t}),a.isLoading&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orange-9 animate-pulse"}),!a.isLoading&&r.has(a.id)&&a.id!==t&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-red-500"}),m&&u?.(a.id)&&!a.isLoading&&!(r.has(a.id)&&a.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m(a.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-amber-500 hover:text-destructive transition-colors",title:C("tabBar.unpin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"currentColor",children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})}),m&&!u?.(a.id)&&!a.isLoading&&!(r.has(a.id)&&a.id!==t)&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),m(a.id)},className:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center rounded-full bg-card text-muted-foreground opacity-0 group-hover:opacity-60 hover:!opacity-100 hover:!text-brand transition-all",title:C("tabBar.pin"),children:(0,n.jsx)("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:(0,n.jsx)("path",{d:"M16 4h-2V2h-4v2H8c-.55 0-1 .45-1 1v4l-2 3v2h5.97v7l1 1 1-1v-7H19v-2l-2-3V5c0-.55-.45-1-1-1z"})})})]}),(0,n.jsx)("span",{className:"flex-1 min-w-0 truncate",children:a.title}),"claude2"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-orange-500/15 text-orange-400 font-medium leading-relaxed",children:"C2"}),"codex"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-emerald-500/15 text-emerald-400 font-medium leading-relaxed",children:"CX"}),"kimi"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-blue-500/15 text-blue-400 font-medium leading-relaxed",children:"KM"}),"ollama"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-violet-500/15 text-violet-400 font-medium leading-relaxed",children:"OL"}),"deepseek"===a.engine&&(0,n.jsx)("span",{className:"flex-shrink-0 text-[9px] px-1 py-0 rounded bg-sky-500/15 text-sky-400 font-medium leading-relaxed",children:"DS"}),e.length>1&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),h(a.id)},className:"ml-1 p-0.5 rounded hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:C("tabBar.closeTab"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},a.id)),(0,n.jsx)(c,{onNewTab:f,onNewClaude2Tab:p,onNewCodexTab:g,onNewKimiTab:b,onNewOllamaTab:v,onNewDeepseekTab:j})]})})}},27570:(e,t,r)=>{r.d(t,{L:()=>s});var n=r(12115);function s({enabled:e,container:t,resolveLineRange:r,buildLineSnapshot:o,dragThresholdPx:l=5}){let a=(0,n.useRef)(null),i=(0,n.useRef)(()=>{}),c=(0,n.useRef)(r),d=(0,n.useRef)(o),u=(0,n.useRef)(l);return c.current=r,d.current=o,u.current=l,(0,n.useEffect)(()=>{if(!e||!t)return;let r=!1,n=0,s=0,o=()=>{a.current&&(a.current=null,i.current())},l=e=>{r=!0,n=e.clientX,s=e.clientY;let t=e.target;t?.closest?.(".floating-toolbar")||o()},m=e=>{r=!1;let l=e.target;if(l?.closest?.(".floating-toolbar"))return;let m=u.current,x=Math.abs(e.clientX-n)>m||Math.abs(e.clientY-s)>m,h=window.getSelection();if(!h||h.isCollapsed||!h.toString().trim()||!x)return void o();let f=h.getRangeAt(0);if(!t.contains(f.commonAncestorContainer))return void o();let p=c.current(f.startContainer),g=c.current(f.endContainer);if(!p||!g)return void o();let b=Math.min(p.start,g.start),v=Math.max(p.end,g.end),j=h.toString(),w=d.current({start:b,end:v});a.current={x:e.clientX,y:e.clientY,range:{start:b,end:v},selectedText:j,lineSnapshot:w},i.current()},x=()=>{if(r||!a.current)return;let e=window.getSelection();e&&!e.isCollapsed&&e.toString().trim()||o()};return t.addEventListener("mousedown",l),document.addEventListener("mouseup",m),document.addEventListener("selectionchange",x),()=>{t.removeEventListener("mousedown",l),document.removeEventListener("mouseup",m),document.removeEventListener("selectionchange",x)}},[e,t]),{toolbarRef:a,bumpRef:i,clearToolbar:()=>{a.current&&(a.current=null,i.current())}}}},33408:(e,t,r)=>{r.d(t,{TabManager:()=>sd});var n=r(95155),s=r(12115),o=r(79114),l=r(95045),a=r(75346),i=r(86957),c=r(83448);function d({isOpen:e,onClose:t,cwd:r,onSelectSession:u}){let{t:m}=(0,o.Bd)(),[x,h]=(0,s.useState)([]),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(null),[v,j]=(0,s.useState)(""),w=(0,s.useRef)(null),y=(0,s.useCallback)(async()=>{if(!r)return;p(!0),b(null);let e=r.replace(/\//g,"-"),t=await i.t4.runPromiseExit((0,c.QW)(e));"Success"===t._tag?h(t.value):b("Failed to load sessions"),p(!1)},[r]);(0,s.useEffect)(()=>{e&&(y(),setTimeout(()=>{w.current?.focus()},100))},[e,y]),(0,s.useEffect)(()=>{let r=r=>{"Escape"===r.key&&e&&t()};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e,t]);let k=x.filter(e=>{if(!v)return!0;let t=v.toLowerCase();return e.title.toLowerCase().includes(t)||e.firstMessages.some(e=>e.toLowerCase().includes(t))||e.lastMessages.some(e=>e.toLowerCase().includes(t))});return e?(0,n.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:t}),(0,n.jsxs)("div",{className:"relative w-full max-w-6xl h-[90vh] mx-4 bg-card rounded-lg shadow-xl flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("h2",{className:"text-sm font-medium text-foreground",children:m("sessions.sessionList")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground truncate",title:r,children:r})]}),(0,n.jsxs)("div",{className:"flex items-center gap-3 ml-4",children:[(0,n.jsx)("input",{ref:w,type:"text",placeholder:m("sessions.searchSessions"),value:v,onChange:e=>j(e.target.value),className:"px-2 py-1 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent"}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[f&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("svg",{className:"animate-spin h-4 w-4",fill:"none",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,n.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,n.jsx)("span",{children:m("sessions.loadingSessions")})]})}),g&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-red-11",children:g})}),!f&&!g&&0===k.length&&(0,n.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:m(v?"sessions.noMatchingSessions":"sessions.noSessionsYet")})}),!f&&!g&&k.length>0&&(0,n.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:k.map(e=>(0,n.jsxs)("div",{onClick:()=>{let n;return n=(e.path.split("/").pop()||"").replace(".jsonl",""),void(u?(u(n,e.title),t()):(0,l.F)(a.n.OpenProject,{cwd:r,sessionId:n}))},className:"p-3 bg-secondary rounded border border-border hover:border-brand hover:shadow-md cursor-pointer transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[e.engine&&"claude"!==e.engine&&(0,n.jsx)("span",{className:`shrink-0 px-1 py-0.5 text-[10px] leading-none font-medium rounded ${"claude2"===e.engine?"bg-orange-500/15 text-orange-11":"ollama"===e.engine?"bg-blue-500/15 text-blue-11":"codex"===e.engine?"bg-green-500/15 text-green-11":"kimi"===e.engine?"bg-purple-500/15 text-purple-11":"bg-muted text-muted-foreground"}`,children:e.engine}),(0,n.jsx)("h4",{className:"text-xs font-medium text-foreground truncate",title:e.title,children:e.title})]}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mb-2",children:new Date(e.modifiedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}),(0,n.jsxs)("div",{className:"space-y-0.5 text-xs",children:[e.firstMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`first-${t}`)),e.lastMessages.length>0&&(0,n.jsx)("div",{className:"text-slate-9 text-center py-0.5",children:"\xb7\xb7\xb7"}),e.lastMessages.map((e,t)=>(0,n.jsxs)("div",{className:"text-foreground truncate",title:e,children:[(0,n.jsx)("span",{className:"text-slate-9 mr-1",children:"•"}),e]},`last-${t}`))]})]},e.path))})]})]})]}):null}var u=r(47650),m=r(64428),x=r(60938),h=r(53213),f=r(64702),p=r(1058),g=r(90717),b=r(70188),v=r(48347),j=r(89109),w=r(7320);function y(e,t){let r=e.split("\n"),n=t.split("\n"),s=[],o=r.length,l=n.length,a=Array(o+1).fill(null).map(()=>Array(l+1).fill(0));for(let e=1;e<=o;e++)for(let t=1;t<=l;t++)r[e-1]===n[t-1]?a[e][t]=a[e-1][t-1]+1:a[e][t]=Math.max(a[e-1][t],a[e][t-1]);let i=o,c=l,d=[];for(;i>0||c>0;)i>0&&c>0&&r[i-1]===n[c-1]?(d.push({type:"unchanged",content:r[i-1],oldLineNum:i,newLineNum:c}),i--,c--):c>0&&(0===i||a[i][c-1]>=a[i-1][c])?(d.push({type:"added",content:n[c-1],newLineNum:c}),c--):(d.push({type:"removed",content:r[i-1],oldLineNum:i}),i--);for(;d.length>0;)s.push(d.pop());return s}var k=r(34075),N=r(56978),C=r(17196);function S({lines:e,containerRef:t}){let r=(0,s.useRef)(null),[o,l]=(0,s.useState)({top:0,height:0});if((0,s.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{let{scrollTop:t,scrollHeight:n,clientHeight:s}=e,o=r.current?.clientHeight||0;if(n<=s)l({top:0,height:o});else{let e=o/n;l({top:t*e,height:s*e})}};return n(),e.addEventListener("scroll",n),window.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[t]),0===e.length)return null;let a=100/e.length;return(0,n.jsxs)("div",{ref:r,className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",onClick:e=>{let n=t.current,s=r.current;if(!n||!s)return;let o=s.getBoundingClientRect(),l=(e.clientY-o.top)/o.height*n.scrollHeight-n.clientHeight/2;n.scrollTo({top:Math.max(0,l),behavior:"smooth"})},children:[e.map((e,t)=>"unchanged"!==e.type&&(0,n.jsx)("div",{className:`absolute left-0 right-0 ${"removed"===e.type?"bg-red-9":"bg-green-9"}`,style:{top:`${t*a}%`,height:`${Math.max(a,.5)}%`,minHeight:"2px"}},t)),(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border",style:{top:`${o.top}px`,height:`${Math.max(o.height,10)}px`}})]})}var L=r(37614),E=r(27570);function M(e){return e.params?`${e.name}(${e.params.join(", ")})`:e.name}function T({oldContent:e,newContent:t,filePath:r,isNew:l=!1,isDeleted:a=!1,cwd:i,enableComments:c=!1,onPreview:d,previewLabel:m,onContentSearch:x,targetLine:h,compact:$=!1,symbols:P}){let{t:R}=(0,o.Bd)(),B=m??R("common.preview"),F=(0,s.useMemo)(()=>y(e,t),[e,t]),I=(0,s.useRef)(null),D=(0,s.useRef)(null),A=(0,s.useRef)(null),_=(0,s.useRef)(!1),[W,z]=(0,s.useState)(!1),H=(0,b.iN)(),O=(0,v.r)(),q=c&&!!i,{comments:V,addComment:K,updateComment:U,deleteComment:J,refresh:Q}=(0,p._)({cwd:i||"",filePath:r}),[X,Y]=(0,s.useState)(null),[Z,G]=(0,s.useState)(null);(0,s.useEffect)(()=>{A.current!==Z&&G(A.current)});let{toolbarRef:ee,bumpRef:et,clearToolbar:er}=(0,E.L)({enabled:q,container:Z,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=t?.closest("[data-new-line]");if(!r)return null;let n=parseInt(r.getAttribute("data-new-line")||"0",10);return!Number.isFinite(n)||n<=0?null:{start:n,end:n}},buildLineSnapshot:({start:e,end:t})=>{let r=[],n=0;for(let s of F)("unchanged"===s.type||"added"===s.type)&&++n>=e&&n<=t&&r.push(s.content);return r.join("\n")}}),[en,es]=(0,s.useState)(null),[eo,el]=(0,s.useState)(null);(0,s.useEffect)(()=>{z(!0)},[]);let ea=(0,s.useMemo)(()=>{let e=new Set;for(let t of V)for(let r=t.startLine;r<=t.endLine;r++)e.add(r);return e},[V]),ei=(0,s.useMemo)(()=>{let e=new Map;for(let t of V){let r=t.endLine;e.has(r)||e.set(r,[]),e.get(r).push(t)}return e},[V]),ec=(0,s.useCallback)((e,t)=>{t.stopPropagation(),Y({comment:e,x:t.clientX,y:t.clientY}),er(),es(null),el(null)},[er]),ed=(0,s.useCallback)(()=>{let e=ee.current;e&&(es({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),er())},[er,ee]),eu=(0,s.useCallback)(()=>{let e=ee.current;e&&(el({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),er())},[er,ee]),em=(0,s.useCallback)(()=>{let e=ee.current;if(!e||!x)return;let t=e.selectedText.trim();er(),t&&x(t)},[x,er,ee]),ex=(0,s.useCallback)(async e=>{if(eo&&O&&i)try{let t=await (0,g.$3)(i),n=[];for(let e of t)n.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});n.push({filePath:r,startLine:eo.range.start,endLine:eo.range.end,codeContent:eo.lineSnapshot});let s=(0,g.Gw)(n,e);O.sendMessage(s),await (0,g.RP)(i),Q(),el(null)}catch(e){console.error("Failed to send to AI:",e)}},[eo,O,r,i,Q]),eh=(0,s.useCallback)(async e=>{en&&(await K(en.range.start,en.range.end,e,en.selectedText),es(null))},[en,K]);(0,s.useEffect)(()=>{let e=D.current,t=A.current;if(!e||!t)return;let r=(e,t)=>{_.current||(_.current=!0,t.scrollLeft=e.scrollLeft,requestAnimationFrame(()=>{_.current=!1}))},n=()=>r(e,t),s=()=>r(t,e);return e.addEventListener("scroll",n),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",n),t.removeEventListener("scroll",s)}},[]);let{leftLines:ef,rightLines:ep}=(0,s.useMemo)(()=>{let e=[],t=[],r=0,n=0;for(let s=0;s<F.length;s++){let o=F[s];if("unchanged"===o.type){for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});r++,n++,e.push({lineNum:r,content:o.content,type:"unchanged",originalIdx:s}),t.push({lineNum:n,content:o.content,type:"unchanged",originalIdx:s})}else"removed"===o.type?(r++,e.push({lineNum:r,content:o.content,type:"removed",originalIdx:s})):"added"===o.type&&(n++,t.push({lineNum:n,content:o.content,type:"added",originalIdx:s}))}for(;e.length<t.length;)e.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});for(;t.length<e.length;)t.push({lineNum:0,content:"",type:"unchanged",originalIdx:-1});return{leftLines:e,rightLines:t}},[F]),eg=(0,s.useMemo)(()=>F.map(e=>e.content),[F]),eb=(0,N.C)(eg,r),[ev,ej]=(0,s.useState)(()=>new Map);(0,s.useLayoutEffect)(()=>{ej(new Map),eE.measure()},[ef,ep]);let ew=(0,s.useMemo)(()=>P??[],[P]),{rows:ey,gaps:ek}=(0,s.useMemo)(()=>$?function(e,t,r,n=[]){let s=e.length,o=r=>"unchanged"!==e[r].type||"unchanged"!==t[r].type,l=new Set;for(let e=0;e<s;e++){if(!o(e))continue;let t=Math.max(0,e-3),r=Math.min(s-1,e+3);for(let e=t;e<=r;e++)l.add(e)}let a=[];for(let e=0;e<s;e++){if(l.has(e))continue;let t=e;for(;e<s&&!l.has(e);)e++;a.push({id:a.length,startIdx:t,endIdx:e-1}),e--}for(let e of a){let t=r.get(e.id)??{topRevealed:0,bottomRevealed:0},n=e.endIdx-e.startIdx+1,s=Math.max(0,Math.min(t.topRevealed,n)),o=Math.max(0,Math.min(t.bottomRevealed,n-s));for(let t=e.startIdx;t<e.startIdx+s;t++)l.add(t);for(let t=e.endIdx-o+1;t<=e.endIdx;t++)l.add(t)}let i=[];for(let e=0;e<s;e++){let r;if(l.has(e)){i.push({kind:"diff",idx:e});continue}let o=e;for(;e<s&&!l.has(e);)e++;let c=e-1;e--;let d=a.find(e=>e.startIdx<=o&&c<=e.endIdx);if(!d)continue;let u=c-o+1,m=Math.min(20,u);if(n.length>0&&c+1<s)for(let e=c+1;e<s;e++){let s=t[e].lineNum;if(!(s<=0)){r=function(e,t){let r=null;for(let n of e)n.startLine<=t&&t<=n.endLine&&(!r||n.endLine-n.startLine<r.endLine-r.startLine)&&(r=n);return r}(n,s)??void 0;break}}i.push({kind:"gap-expand",gapId:d.id,direction:"up",revealCount:m}),i.push({kind:"gap-label",gapId:d.id,hiddenCount:u,enclosingFn:r}),i.push({kind:"gap-expand",gapId:d.id,direction:"down",revealCount:m})}return{rows:i,gaps:a}}(ef,ep,ev,ew):{rows:ef.map((e,t)=>({kind:"diff",idx:t})),gaps:[]},[$,ef,ef,ep,ev,ew]),eN=(0,s.useCallback)((e,t)=>{let r=ek.find(t=>t.id===e);r&&ej(n=>{let s=n.get(e)??{topRevealed:0,bottomRevealed:0},o=r.endIdx-r.startIdx+1-s.topRevealed-s.bottomRevealed;if(o<=0)return n;let l=Math.min(20,o),a="up"===t?{...s,topRevealed:s.topRevealed+l}:{...s,bottomRevealed:s.bottomRevealed+l};return new Map(n).set(e,a)})},[ek]),eC=(0,s.useCallback)(e=>{for(let t of ek)if(e>=t.startIdx&&e<=t.endIdx)return t.id;return null},[ek]),eS=(0,s.useCallback)(e=>ey[e]?.kind==="gap-label"?28:20,[ey]),eL=(0,s.useCallback)(e=>{let t=ey[e];if(!t)return e;if("gap-label"===t.kind)return`gl:${t.gapId}`;if("gap-expand"===t.kind)return`ge:${t.gapId}:${t.direction}`;let r=ef[t.idx],n=ep[t.idx];return`d:${r?.lineNum??"x"}:${r?.type??"x"}:${n?.lineNum??"x"}:${n?.type??"x"}`},[ey,ef,ep]),eE=(0,f.Te)({count:ey.length,getScrollElement:()=>I.current,estimateSize:eS,getItemKey:eL,overscan:20}),eM=l?"w-1/4":a?"w-3/4":"w-1/2",eT=l?"w-3/4":a?"w-1/4":"w-1/2",e$=(0,s.useMemo)(()=>ey.map(e=>{if("diff"!==e.kind)return{type:"unchanged"};let t=ef[e.idx],r=ep[e.idx];return"removed"===t.type?{type:"removed"}:r?.type==="added"?{type:"added"}:{type:"unchanged"}}),[ey,ef,ep]),eP=eE.getTotalSize(),eR=eE.getVirtualItems();return(0,s.useEffect)(()=>{if(!h)return;let e=("after"===h.side?ep:ef).findIndex(e=>e.lineNum===h.line);if(-1===e)return;let t=ey.findIndex(t=>"diff"===t.kind&&t.idx===e);if(-1===t){let t=eC(e);if(null!==t){let e=ek.find(e=>e.id===t);if(!e)return;let r=e.endIdx-e.startIdx+1;ej(e=>{let n=e.get(t)??{topRevealed:0,bottomRevealed:0};if(n.topRevealed+n.bottomRevealed>=r)return e;let s=new Map(e);return s.set(t,{topRevealed:r,bottomRevealed:0}),s})}return}let r=requestAnimationFrame(()=>{eE.scrollToIndex(t,{align:"start"})});return()=>cancelAnimationFrame(r)},[h,ef,ep,ey]),(0,n.jsxs)("div",{className:"font-mono flex flex-col h-full text-sm",children:[(0,n.jsxs)("div",{className:"flex flex-shrink-0 border-b border-border",children:[(0,n.jsx)("div",{className:`${eM} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-center text-xs font-medium border-r border-border`,children:l?"(New File)":a?"Deleted":"Old"}),(0,n.jsxs)("div",{className:`${eT} min-w-0 px-2 py-1 bg-accent text-muted-foreground text-xs font-medium relative`,children:[(0,n.jsx)("span",{className:"block text-center",children:a?"(Deleted)":"New"}),(0,n.jsxs)("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-2",children:[d&&(0,n.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:B}),!a&&t&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(t),(0,k.oR)(R("diffViewer.copiedAll"))},className:"text-muted-foreground hover:text-foreground transition-colors",children:R("common.copy")})]})]}),(0,n.jsx)("div",{className:"w-4 flex-shrink-0 bg-accent"})]}),(0,n.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,n.jsx)("div",{ref:I,className:"flex-1 overflow-y-auto overflow-x-hidden",children:(0,n.jsxs)("div",{className:"flex",style:{height:`${eP}px`},children:[(0,n.jsx)("div",{ref:D,className:`${eM} overflow-x-auto border-r border-border`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eR.map(e=>{let t=ey[e.index];if("gap-expand"===t.kind||"gap-label"===t.kind){let r="gap-label"===t.kind;return(0,n.jsx)("div",{ref:eE.measureElement,"data-index":e.index,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:r?"bg-accent border-y border-border":""},e.key)}let r=ef[t.idx];return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===r.type?"bg-red-9/15 dark:bg-red-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:r.lineNum||""}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:r.originalIdx>=0&&eb[r.originalIdx]||(0,C.ZD)(r.content||" ")}})]},e.key)})})}),(0,n.jsx)("div",{ref:A,className:`${eT} overflow-x-auto`,children:(0,n.jsx)("div",{className:"min-w-max h-full",style:{position:"relative"},children:eR.map(e=>{let t=ey[e.index];if("gap-expand"===t.kind)return(0,n.jsx)("button",{ref:eE.measureElement,"data-index":e.index,type:"button",onClick:()=>eN(t.gapId,t.direction),style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center text-[11px] text-foreground/50 hover:bg-accent hover:text-brand active:bg-brand/15 transition-colors duration-100 cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-brand/60",title:R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),"aria-label":R("up"===t.direction?"diffViewer.gap.expandUp":"diffViewer.gap.expandDown",{count:t.revealCount}),children:(0,n.jsx)("span",{className:"select-none",children:R("diffViewer.gap.more",{count:t.revealCount})})},e.key);if("gap-label"===t.kind)return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-gap-id":t.gapId,style:{position:"absolute",top:0,left:0,width:"100%",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:"flex items-center justify-center gap-2 px-3 text-[11px] text-foreground/80 bg-accent border-y border-border min-w-0 select-none",children:[(0,n.jsx)("span",{className:"flex-shrink-0",children:R("diffViewer.gap.hidden",{count:t.hiddenCount})}),t.enclosingFn&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"opacity-50 flex-shrink-0",children:"\xb7"}),(0,n.jsx)("span",{className:"truncate min-w-0 font-medium",title:M(t.enclosingFn),children:M(t.enclosingFn)})]})]},e.key);let r=ep[t.idx],s=r?.lineNum||0,o=s>0&&ea.has(s),l=ei.get(s),a=l?.[0],i=en&&s>=en.range.start&&s<=en.range.end,c=eo&&s>=eo.range.start&&s<=eo.range.end,d=i||c;return(0,n.jsxs)("div",{ref:eE.measureElement,"data-index":e.index,"data-new-line":s||void 0,"data-row-idx":t.idx,style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${Math.max(e.size,eS(e.index))}px`,transform:`translateY(${e.start}px)`},className:`flex ${d?"bg-blue-9/20":o?"bg-amber-9/10":r?.type==="added"?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsxs)("span",{className:`flex-shrink-0 flex items-center gap-0.5 pr-1 text-slate-9 select-none border-r border-border ${d?"bg-blue-9/30":""}`,style:{width:q?"52px":"40px"},children:[q&&s>0&&o&&a&&(0,n.jsx)("button",{onClick:e=>ec(a,e),className:"w-4 h-4 flex items-center justify-center rounded hover:bg-accent text-amber-9",title:R("codeViewer.nComments",{count:l?.length}),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4.083-.98L2 17l1.338-3.123C2.493 12.767 2 11.434 2 10c0-3.866 3.582-7 8-7s8 3.134 8 7zM7 9H5v2h2V9zm8 0h-2v2h2V9zM9 9h2v2H9V9z",clipRule:"evenodd"})})}),q&&s>0&&!o&&(0,n.jsx)("span",{className:"w-4"}),(0,n.jsx)("span",{className:"flex-1 text-right pr-1",children:s||""})]}),(0,n.jsx)("span",{className:"whitespace-pre pl-2",dangerouslySetInnerHTML:{__html:r?.originalIdx>=0&&eb[r.originalIdx]||(0,C.ZD)(r?.content||" ")}})]},e.key)})})})]})}),(0,n.jsx)(S,{lines:e$,containerRef:I})]}),W&&H&&(0,u.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.f,{floatingToolbarRef:ee,bumpRef:et,container:H,onAddComment:ed,onSendToAI:eu,onSearch:x?em:void 0,isChatLoading:O?.isLoading??!1}),en&&(0,n.jsx)(w.t,{x:en.x,y:en.y,range:en.range,lineSnapshot:en.lineSnapshot,container:H,onSubmit:eh,onClose:()=>es(null)}),eo&&(0,n.jsx)(w.G,{x:eo.x,y:eo.y,range:eo.range,filePath:r,lineSnapshot:eo.lineSnapshot,container:H,onSubmit:ex,onClose:()=>el(null),isChatLoading:O?.isLoading}),X&&(0,n.jsx)(L.t,{x:X.x,y:X.y,comment:X.comment,container:H,onClose:()=>Y(null),onUpdateComment:U,onDeleteComment:J})]}),H)]})}function $({oldContent:e,newContent:t,filePath:r}){let o=(0,s.useMemo)(()=>y(e,t),[e,t]),l=(0,s.useRef)(null),a=(0,s.useMemo)(()=>o.map(e=>e.content),[o]),i=(0,N.C)(a,r),c=(0,s.useCallback)(e=>{let t=o[e];return t?`${t.type}:${t.oldLineNum??"x"}:${t.newLineNum??"x"}`:e},[o]),d=(0,f.Te)({count:o.length,getScrollElement:()=>l.current,estimateSize:()=>20,getItemKey:c,overscan:20});return(0,n.jsx)("div",{ref:l,className:"font-mono text-sm overflow-auto h-full",children:(0,n.jsx)("div",{style:{height:`${d.getTotalSize()}px`,position:"relative"},children:d.getVirtualItems().map(e=>{let t=o[e.index];return(0,n.jsxs)("div",{style:{position:"absolute",top:0,left:0,minWidth:"100%",width:"max-content",height:`${e.size}px`,transform:`translateY(${e.start}px)`},className:`flex ${"removed"===t.type?"bg-red-9/15 dark:bg-red-9/25":"added"===t.type?"bg-green-9/15 dark:bg-green-9/25":""}`,children:[(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"added"!==t.type?t.oldLineNum:""}),(0,n.jsx)("span",{className:"w-10 flex-shrink-0 text-right pr-2 text-slate-9 select-none border-r border-border",children:"removed"!==t.type?t.newLineNum:""}),(0,n.jsx)("span",{className:`w-6 flex-shrink-0 text-center select-none ${"removed"===t.type?"text-red-11":"added"===t.type?"text-green-11":"text-slate-9"}`,children:"removed"===t.type?"-":"added"===t.type?"+":" "}),(0,n.jsx)("span",{className:"flex-1 whitespace-pre pl-1",dangerouslySetInnerHTML:{__html:i[e.index]||(0,C.ZD)(t.content||" ")}})]},e.key)})})})}let P={ts:"#3178c6",tsx:"#3178c6",js:"#f1e05a",jsx:"#61dafb",mjs:"#f1e05a",cjs:"#f1e05a",html:"#e44d26",css:"#563d7c",scss:"#cd6799",sass:"#cd6799",less:"#1d365d",vue:"#41b883",svelte:"#ff3e00",json:"#cbcb41",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4121",xml:"#e37933",env:"#ecd53f",md:"#519aba",mdx:"#519aba",txt:"#89898a",py:"#3572a5",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",kts:"#a97bff",c:"#555555",h:"#555555",cpp:"#f34b7d",hpp:"#f34b7d",rb:"#701516",php:"#4f5d95",sh:"#89e051",bash:"#89e051",zsh:"#89e051",png:"#a074c4",jpg:"#a074c4",jpeg:"#a074c4",gif:"#a074c4",svg:"#ffb13b",webp:"#a074c4",ico:"#a074c4",lock:"#89898a",gitignore:"#f14e32",dockerfile:"#2496ed",sql:"#e38c00",graphql:"#e535ab",gql:"#e535ab",default:"#8a8a8a"},R={"package.json":"#cb3837","package-lock.json":"#cb3837","tsconfig.json":"#3178c6","jsconfig.json":"#f1e05a",".gitignore":"#f14e32",".eslintrc":"#4b32c3",".eslintrc.js":"#4b32c3",".eslintrc.json":"#4b32c3",".prettierrc":"#56b3b4",dockerfile:"#2496ed",".env":"#ecd53f",".env.local":"#ecd53f",".env.development":"#ecd53f",".env.production":"#ecd53f","readme.md":"#519aba",license:"#d4af37",makefile:"#6d8086","cargo.toml":"#dea584","go.mod":"#00add8","go.sum":"#00add8","requirements.txt":"#3572a5","yarn.lock":"#2c8ebb","pnpm-lock.yaml":"#f9ad00","vite.config.ts":"#646cff","vite.config.js":"#646cff","next.config.js":"#000000","next.config.mjs":"#000000","tailwind.config.js":"#38bdf8","tailwind.config.ts":"#38bdf8"};function B({name:e,className:t="",size:r=16}){let s,o=R[s=e.toLowerCase()]?R[s]:P[e.split(".").pop()?.toLowerCase()||""]||P.default,l=e.split(".").pop()?.toLowerCase()||"";return["ts","tsx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M7 10h10M12 10v8",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):["js","jsx","mjs","cjs"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2",fill:o}),(0,n.jsx)("path",{d:"M10 10v6c0 1-1 2-2 2M14 10v4c0 2 4 2 4 0v-4",stroke:"#323330",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):"jsx"===l||"tsx"===l&&e.includes("component")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(60 12 12)"}),(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"10",ry:"4",stroke:"#61dafb",strokeWidth:"1.5",fill:"none",transform:"rotate(120 12 12)"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"2",fill:"#61dafb"})]}):"json"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 4C4 4 4 6 4 8v2c0 1-1 2-2 2 1 0 2 1 2 2v2c0 2 0 4 2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("path",{d:"M18 4c2 0 2 2 2 4v2c0 1 1 2 2 2-1 0-2 1-2 2v2c0 2 0 4-2 4",stroke:o,strokeWidth:"2",fill:"none",strokeLinecap:"round"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"1.5",fill:o})]}):["md","mdx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M5 15V9l3 4 3-4v6M17 12l-2-3v6M17 12l2-3v6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["py","pyi","pyx"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M12 4c-4 0-4 2-4 3v2h5v1H6c-2 0-3 2-3 4s1 4 3 4h2v-2c0-2 1-3 3-3h4c1 0 2-1 2-2V7c0-2-2-3-5-3z",fill:"#3572a5"}),(0,n.jsx)("path",{d:"M12 20c4 0 4-2 4-3v-2h-5v-1h7c2 0 3-2 3-4s-1-4-3-4h-2v2c0 2-1 3-3 3h-4c-1 0-2 1-2 2v4c0 2 2 3 5 3z",fill:"#ffd43b"}),(0,n.jsx)("circle",{cx:"9",cy:"7",r:"1",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"17",r:"1",fill:"white"})]}):"go"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"12",rx:"8",ry:"6",fill:o}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"1.5",fill:"white"}),(0,n.jsx)("circle",{cx:"9",cy:"11",r:"0.7",fill:"#333"}),(0,n.jsx)("circle",{cx:"15",cy:"11",r:"0.7",fill:"#333"})]}):"rs"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:o,strokeWidth:"2",fill:"none"}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:o}),(0,n.jsx)("path",{d:"M12 3v3M12 18v3M3 12h3M18 12h3",stroke:o,strokeWidth:"2",strokeLinecap:"round"})]}):["png","jpg","jpeg","gif","webp","ico","bmp"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"9",r:"2",fill:o}),(0,n.jsx)("path",{d:"M3 16l5-5 3 3 4-4 6 6",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"svg"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 12 Q12 6 17 12 Q12 18 7 12",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"html"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M8 7h8l-.5 6-3.5 1-3.5-1-.2-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["css","scss","sass","less"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M4 3l1.5 17L12 22l6.5-2L20 3H4z",fill:o}),(0,n.jsx)("path",{d:"M15 8H9l.3 3h5.2l-.4 4-2.1.7-2.1-.7-.1-2",stroke:"white",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}):["yaml","yml"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M7 8l3 4v5M17 8l-3 4v5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):["sh","bash","zsh","fish"].includes(l)?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",fill:"#1e1e1e",stroke:"#555",strokeWidth:"1"}),(0,n.jsx)("path",{d:"M6 9l3 3-3 3M12 15h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}):"gitignore"===l||".gitignore"===e.toLowerCase()?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"9",fill:o}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",fill:"white"}),(0,n.jsx)("path",{d:"M12 6v3M12 15v3M6 12h3M15 12h3",stroke:"white",strokeWidth:"2",strokeLinecap:"round"})]}):"dockerfile"===l||"dockerfile"===e.toLowerCase()||e.toLowerCase().startsWith("dockerfile")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M3 12h3v3H3zM7 12h3v3H7zM11 12h3v3h-3zM7 8h3v3H7zM11 8h3v3h-3zM11 4h3v3h-3zM15 12h3v3h-3z",fill:o}),(0,n.jsx)("path",{d:"M21 13c-1-2-3-2-4-2h-1c0-1 0-2-2-3h-1v1c0 1-1 2-2 2H3c-1 3 0 6 2 8s5 3 9 3c5 0 8-2 10-6",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"env"===l||e.startsWith(".env")?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("circle",{cx:"8",cy:"8",r:"2",fill:o}),(0,n.jsx)("path",{d:"M12 8h6M8 12h8M8 16h5",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"})]}):"sql"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("ellipse",{cx:"12",cy:"7",rx:"8",ry:"3",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 7v10c0 1.7 3.6 3 8 3s8-1.3 8-3V7",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",stroke:o,strokeWidth:"1.5",fill:"none"})]}):"vue"===l?(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M2 4h4l6 10 6-10h4L12 22 2 4z",fill:o}),(0,n.jsx)("path",{d:"M6 4h4l2 4 2-4h4l-6 10L6 4z",fill:"#35495e"})]}):(0,n.jsxs)("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",className:t,children:[(0,n.jsx)("path",{d:"M6 3h8l5 5v13H6V3z",stroke:o,strokeWidth:"1.5",fill:"none"}),(0,n.jsx)("path",{d:"M14 3v5h5",stroke:o,strokeWidth:"1.5",fill:"none"})]})}function F({status:e}){let{label:t,className:r}={added:{label:"A",className:"text-green-11"},untracked:{label:"A",className:"text-green-11"},modified:{label:"M",className:"text-amber-11"},deleted:{label:"D",className:"text-red-11"},renamed:{label:"R",className:"text-brand"}}[e]||{label:"?",className:"text-muted-foreground"};return(0,n.jsx)("span",{className:`text-xs font-bold ${r}`,children:t})}let I=s.memo(function e({node:t,level:r,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d=!1,renderActions:u}){let m=o===t.path,x=l.has(t.path),h=(0,s.useCallback)(()=>{t.isDirectory?i(t.path):a(t)},[t,a,i]),f=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),c(e,t.path,t.isDirectory)},[t.path,t.isDirectory,c]);return t.isDirectory?(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 py-0.5 px-2 pr-3 hover:bg-accent cursor-pointer whitespace-nowrap group",style:{paddingLeft:`${12*r+8}px`},onClick:h,onContextMenu:f,children:[(0,n.jsx)("span",{className:"text-slate-9 text-xs",children:x?"▼":"▶"}),(0,n.jsx)("span",{className:"text-sm text-foreground flex-1 truncate","data-tooltip":t.path,children:t.name}),u&&u(t)]}),x&&t.children.map(t=>(0,n.jsx)(e,{node:t,level:r+1,selectedPath:o,expandedPaths:l,onSelect:a,onToggle:i,onContextMenu:c,showChanges:d,renderActions:u},t.path))]}):(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 pr-3 cursor-pointer whitespace-nowrap group ${m?"bg-brand/10":"hover:bg-accent"}`,style:{paddingLeft:`${12*r+8}px`},onClick:h,onContextMenu:f,children:[(0,n.jsx)(B,{name:t.name,size:16,className:"flex-shrink-0"}),(0,n.jsx)("span",{className:`text-sm flex-1 truncate ${m?"text-brand":"text-foreground"}`,"data-tooltip":t.path,children:t.name}),t.status&&(0,n.jsx)(F,{status:t.status}),d&&void 0!==t.additions&&void 0!==t.deletions&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["+",t.additions]}),(0,n.jsxs)("span",{className:"text-xs text-red-11",children:["-",t.deletions]})]}),u&&u(t)]})});function D({files:e,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,cwd:a,showChanges:i=!1,renderActions:c,emptyMessage:d,className:u}){let{t:m}=(0,o.Bd)(),x=d??m("gitFileTree.noFiles"),{contextMenu:h,showContextMenu:f,hideContextMenu:p}=(0,b.Ee)();return 0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-slate-9",children:x}):(0,n.jsxs)("div",{className:u||"py-1",children:[e.map(e=>(0,n.jsx)(I,{node:e,level:0,selectedPath:t,expandedPaths:r,onSelect:s,onToggle:l,onContextMenu:f,showChanges:i,renderActions:c},e.path)),h&&(0,n.jsx)(b.ft,{x:h.x,y:h.y,path:h.path,cwd:a,isDirectory:h.isDirectory,onClose:p})]})}function A(e){let t=[];for(let r of e){let e=r.path.split("/"),n=t;for(let t=0;t<e.length;t++){let s=e[t],o=t===e.length-1,l=e.slice(0,t+1).join("/"),a=n.find(e=>e.name===s);a||(a={name:s,path:l,isDirectory:!o,children:[],...o&&{status:r.status,additions:r.additions,deletions:r.deletions,oldPath:r.oldPath,file:r}},n.push(a)),o||(n=a.children)}}let r=e=>{e.sort((e,t)=>e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)),e.forEach(e=>r(e.children))};return r(t),t}function _(e){let t=[],r=e=>{for(let n of e)n.isDirectory&&(t.push(n.path),r(n.children))};return r(e),t}function W(e){let t=[],r=e=>{if(e.isDirectory)for(let t of e.children)r(t);else t.push(e)};return r(e),t}var z=r(69809);function H(e){try{let t=JSON.parse(e);return Q(t,0)}catch{return e}}let O="#79c0ff",q="#a5d6ff",V="#ff7b72",K="#8b949e",U=(e,t)=>s.createElement("span",{style:{color:e}},t);function J({label:e,labelColor:t,value:r,indent:n}){let[o,l]=s.useState(!1),[a,i]=s.useState({x:0,y:0}),c="string"==typeof r&&r.replace(/\\n/g,"\n").split("\n").length>3,d={onMouseDown:e=>{i({x:e.clientX,y:e.clientY})},onClick:e=>{let t=e.clientX-a.x,r=e.clientY-a.y;t*t+r*r>25||(e.stopPropagation(),l(e=>!e))},style:{cursor:"pointer"}};if(c&&o&&"string"==typeof r){let n=r.replace(/\\n/g,"\n").split("\n")[0],o=r.replace(/\\n/g,"\n").split("\n").length;return s.createElement("span",d,U(t,e),U(K,": "),U(q,n),U("#6e7681",` ${z.A.t("toolCall.foldedLines",{count:o})}`))}let u=s.createElement(s.Fragment,null,U(t,e),U(K,": "),Q(r,n));return c?s.createElement("span",d,u):u}function Q(e,t){let r=" ".repeat(t);if(null===e)return U(V,"null");if(void 0===e)return U(V,"undefined");if("string"==typeof e)return U(q,e.replace(/\\n/g,"\n").replace(/\n/g,"\n"+r));if("number"==typeof e)return U("#79c0ff",String(e));if("boolean"==typeof e)return U(V,String(e));if(Array.isArray(e))return 0===e.length?U(K,"[]"):s.createElement(s.Fragment,null,U(K,"["),"\n",...e.map((n,o)=>s.createElement("span",{key:o},r+" ",s.createElement(J,{label:`[${o}]`,labelColor:O,value:n,indent:t+1}),o<e.length-1?s.createElement(s.Fragment,null,U(K,","),"\n"):"\n")),r,U(K,"]"));if("object"==typeof e){let n=Object.entries(e);return 0===n.length?U(K,"{}"):s.createElement(s.Fragment,null,U(K,"{"),"\n",...n.map(([e,o],l)=>s.createElement("span",{key:e},r+" ",s.createElement(J,{label:e,labelColor:O,value:o,indent:t+1}),l<n.length-1?s.createElement(s.Fragment,null,U(K,","),"\n"):"\n")),r,U(K,"}"))}return String(e)}let X=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg",".bmp",".ico",".avif"]);function Y(e){let t=e.slice(e.lastIndexOf(".")).toLowerCase();return X.has(t)}function Z(e){return e.toLowerCase().endsWith(".md")}let G="json-search-highlight-style";function ee(e){let[t,r]=(0,s.useState)(!1),[n,o]=(0,s.useState)(""),[l,a]=(0,s.useState)(!1),[i,c]=(0,s.useState)(0),[d,u]=(0,s.useState)(0),m=(0,s.useRef)(null),x=(0,s.useRef)([]),h=(0,s.useCallback)(()=>{let t;CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),x.current=[];let r=e.current;if(!r||!n){c(0),u(0);return}!function(){if(document.getElementById(G))return;let e=document.createElement("style");e.id=G,e.textContent="::highlight(json-search){background:rgba(217,119,6,.3)}::highlight(json-search-current){background:rgba(217,119,6,.5)}",document.head.appendChild(e)}();let s=r.textContent||"",o=l?n:n.toLowerCase(),a=l?s:s.toLowerCase(),i=[],d=0;for(;d<a.length;){let e=a.indexOf(o,d);if(-1===e)break;i.push([e,e+o.length]),d=e+1}if(0===i.length){c(0),u(0);return}let m=document.createTreeWalker(r,NodeFilter.SHOW_TEXT),h=0,f=0,p=[],g=null,b=0;for(;(t=m.nextNode())&&f<i.length;){let e=t.textContent?.length||0,r=h,n=h+e;for(;f<i.length;){let[e,s]=i[f];if(e>=n)break;if(!g)if(e>=r)(g=document.createRange()).setStart(t,e-r),b=s;else break;if(b<=n)g.setEnd(t,b-r),p.push(g),g=null,f++;else break}h=n}x.current=p,c(p.length),u(e=>p.length>0?Math.min(e,p.length-1):0),CSS.highlights&&p.length>0&&CSS.highlights.set("json-search",new Highlight(...p))},[e,n,l]),f=(0,s.useCallback)((e,t)=>{let r=e.getBoundingClientRect();(t.top<r.top||t.bottom>r.bottom)&&(e.scrollTop+=t.top-r.top-r.height/2+t.height/2)},[]),p=(0,s.useCallback)(t=>{CSS.highlights?.delete("json-search-current");let r=x.current[t];if(!r||!CSS.highlights)return;CSS.highlights.set("json-search-current",new Highlight(r));let n=r.getBoundingClientRect(),s=e.current?.parentElement;s&&f(s,n)},[e,f]);(0,s.useEffect)(()=>{queueMicrotask(()=>h())},[h]),(0,s.useEffect)(()=>{p(d)},[d,i,p]),(0,s.useEffect)(()=>{let t=e.current;if(!t||!n)return;let r=new MutationObserver(()=>h());return r.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>r.disconnect()},[e,n,h]),(0,s.useEffect)(()=>{t||(CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current"),x.current=[])},[t]),(0,s.useEffect)(()=>()=>{CSS.highlights?.delete("json-search"),CSS.highlights?.delete("json-search-current")},[]);let g=(0,s.useCallback)(()=>{0!==i&&u(e=>(e+1)%i)},[i]),b=(0,s.useCallback)(()=>{0!==i&&u(e=>(e-1+i)%i)},[i]),v=(0,s.useCallback)(()=>{r(!0),setTimeout(()=>m.current?.focus(),0)},[]),j=(0,s.useCallback)(()=>{r(!1),o(""),u(0)},[]),w=(0,s.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?b():g()),"Escape"===e.key&&(e.preventDefault(),j())},[g,b,j]);return{isVisible:t,query:n,setQuery:o,caseSensitive:l,setCaseSensitive:a,matchCount:i,currentIndex:d,searchInputRef:m,open:v,close:j,goToNext:g,goToPrev:b,handleKeyDown:w}}function et({search:e}){return e.isVisible?s.createElement("div",{className:"flex-shrink-0 flex items-center gap-2 px-3 py-2 bg-secondary border-b border-border"},s.createElement("input",{ref:e.searchInputRef,type:"text",value:e.query,onChange:t=>e.setQuery(t.target.value),onKeyDown:e.handleKeyDown,placeholder:z.A.t("codeViewer.searchPlaceholder"),className:"flex-1 max-w-xs px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),s.createElement("button",{onClick:()=>e.setCaseSensitive(e=>!e),className:`px-2 py-1 text-xs font-mono rounded border transition-colors ${e.caseSensitive?"bg-brand text-white border-brand":"border-border text-muted-foreground hover:bg-accent"}`,title:z.A.t("codeViewer.caseSensitive")},"Aa"),s.createElement("span",{className:"text-xs text-muted-foreground"},e.matchCount>0?`${e.currentIndex+1}/${e.matchCount}`:z.A.t("common.noMatch")),s.createElement("button",{onClick:e.goToPrev,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:z.A.t("common.previous")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"}))),s.createElement("button",{onClick:e.goToNext,disabled:0===e.matchCount,className:"p-1 rounded hover:bg-accent disabled:opacity-50",title:z.A.t("common.next")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),s.createElement("button",{onClick:e.close,className:"p-1 rounded hover:bg-accent",title:z.A.t("common.close")},s.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},s.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))):null}function er({isOpen:e,onClose:t,commit:r,cwd:l,embedded:a=!1,initialFilePath:c,onContentSearch:d}){let{t:u}=(0,o.Bd)(),[m,x]=(0,s.useState)([]),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(null),M=(0,s.useRef)(null),$=ee(M);(0,s.useEffect)(()=>{let r=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key&&L){e.preventDefault(),$.open();return}if("Escape"===e.key){if($.isVisible)return void $.close();if(L)return void E(null);t()}};if(e)return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,L,$]),(0,s.useEffect)(()=>{e&&r&&(queueMicrotask(()=>{x([]),p([]),j(null),y(null),N(!0)}),i.t4.runPromiseExit((0,h.Zi)(l,r.hash)).then(e=>{if("Success"===e._tag){let t=e.value.files??[];x(t);let n=A(t);if(p(n),b(new Set(_(n))),c&&t.length>0){let e=t.find(e=>e.path===c);e&&setTimeout(()=>{j(e),i.t4.runPromiseExit((0,h.Zi)(l,r.hash,e.path)).then(e=>{"Success"===e._tag?y(e.value):console.error(e.cause)})},0)}}else console.error(e.cause);N(!1)}))},[e,r,l,c]);let P=(0,s.useCallback)(e=>{r&&(j(e),S(!0),i.t4.runPromiseExit((0,h.Zi)(l,r.hash,e.path)).then(e=>{"Success"===e._tag?y(e.value):console.error(e.cause),S(!1)}))},[l,r]),R=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),B=(0,s.useMemo)(()=>{if(!r)return"";if(r.date){let e,t,n,s,o,l,a;return e=new Date(r.date),t=new Date,n=e.getFullYear()===t.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),l=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),n?`${s}-${o} ${l}:${a}`:`${e.getFullYear()}-${s}-${o} ${l}:${a}`}return r.time?new Date(1e3*r.time).toLocaleString():""},[r]);if(!e||!r)return null;let F=(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border bg-secondary flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-2",children:r.subject}),r.body&&(0,n.jsx)("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap mb-3 max-h-32 overflow-y-auto border-l-2 border-border pl-3",children:r.body}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.hash")}),(0,n.jsx)("span",{className:"font-mono bg-accent px-1.5 py-0.5 rounded",children:r.hash})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.author")}),(0,n.jsx)("span",{children:r.author}),(0,n.jsxs)("span",{className:"text-slate-9",children:["<",r.authorEmail,">"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.date")}),(0,n.jsx)("span",{children:B}),r.relativeDate&&(0,n.jsxs)("span",{className:"text-slate-9",children:["(",r.relativeDate,")"]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{className:"text-slate-9",children:u("commitDetail.files")}),(0,n.jsx)("span",{children:u("commitDetail.nChanges",{count:m.length})})]})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)("div",{className:"w-72 flex-shrink-0 border-r border-border overflow-y-auto overflow-x-hidden",children:k?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:u("commitDetail.loadingFiles")}):(0,n.jsx)(D,{files:f,selectedPath:v?.path||null,expandedPaths:g,onSelect:e=>e.file&&P(e.file),onToggle:R,cwd:l,showChanges:!0,emptyMessage:u("commitDetail.noFileChanges"),className:"py-1"})}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:C?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:u("commitDetail.loadingDiff")}):w?(0,n.jsx)(T,{oldContent:w.oldContent,newContent:w.newContent,filePath:w.filePath,isNew:w.isNew,isDeleted:w.isDeleted,cwd:l,enableComments:!0,onPreview:!w.isDeleted&&w.filePath.endsWith(".json")?()=>E({content:w.newContent,filePath:w.filePath}):void 0,previewLabel:u("common.readable"),onContentSearch:d}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:u("commitDetail.selectFileToView")})})]})]}),I=L&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>E(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:L.filePath}),(0,n.jsx)("button",{onClick:()=>E(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(et,{search:$}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:M,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(L.content)})})]})});return a?(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsx)("button",{onClick:t,className:"absolute top-2 right-2 z-10 p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",title:u("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),F,I]}):(0,n.jsx)("div",{className:"fixed inset-0 z-[60] bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card w-full h-full flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground",children:u("commitDetail.title")}),(0,n.jsx)("button",{onClick:t,className:"p-1 text-slate-9 hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),F,I]})})}let en={M:{text:"text-amber-11",bg:"bg-amber-9/20"},A:{text:"text-green-11",bg:"bg-green-9/20"},D:{text:"text-red-11",bg:"bg-red-9/20"},"?":{text:"text-slate-9",bg:"bg-slate-9/20"},R:{text:"text-blue-11",bg:"bg-blue-9/20"}},es=s.memo(function({item:e,isSelected:t,isExpanded:r,isLoading:o,onSelect:l,onToggle:a,onContextMenu:i,renderActions:c}){let{node:d,level:u,gitStatus:m,hasChangedChildren:x}=e,h=m?en[m]:null,f=(0,s.useCallback)(()=>{d.isDirectory?a(d.path):l(d.path)},[d.isDirectory,d.path,l,a]),p=(0,s.useCallback)(e=>{i(e,d.path,d.isDirectory)},[d.path,d.isDirectory,i]),g=!d.isDirectory&&(".env"===d.name||d.name.startsWith(".env.")),b=m?h.text:x?"text-amber-11":g?"text-yellow-600 dark:text-yellow-500":t&&!d.isDirectory?"text-brand":"text-foreground";return(0,n.jsxs)("div",{className:`flex items-center gap-1.5 py-0.5 px-2 cursor-pointer hover:bg-accent ${t?"bg-brand/10":""}`,style:{paddingLeft:`${12*u+8}px`},onClick:f,onContextMenu:p,children:[d.isDirectory?o?(0,n.jsxs)("svg",{className:"w-4 h-4 flex-shrink-0 text-muted-foreground animate-spin",viewBox:"0 0 16 16",fill:"none",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.3"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 0 0-6-6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}):(0,n.jsx)("svg",{className:`w-4 h-4 flex-shrink-0 text-muted-foreground transition-transform ${r?"rotate-90":""}`,viewBox:"0 0 16 16",fill:"none",children:(0,n.jsx)("path",{d:"M6 4 L10 8 L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):(0,n.jsx)(B,{name:d.name,size:16,className:"flex-shrink-0 ml-4"}),(0,n.jsx)("span",{className:`text-sm truncate flex-1 ${b}`,"data-tooltip":d.isSymlink&&d.symlinkTarget?`${d.path} → ${d.symlinkTarget}`:d.path,children:d.name}),d.isSymlink&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0",children:"→"}),m&&(0,n.jsx)("span",{className:`text-xs font-mono px-1 rounded ${h.text} ${h.bg} flex-shrink-0`,children:m}),d.isDirectory&&x&&(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-9 flex-shrink-0"}),c?.(d)]})});function eo({files:e,selectedPath:t,expandedPaths:r,matchedPaths:o=null,gitStatusMap:l=null,loadingDirs:a,onSelect:i,onToggle:c,cwd:d,shouldScrollToSelected:u=!1,onScrolledToSelected:m,className:x,renderActions:h,onCreateFile:p,onDelete:g,onRefresh:v,onCopyFile:j,onPaste:w}){let y=(0,s.useRef)(null),{contextMenu:k,showContextMenu:N,hideContextMenu:C}=(0,b.Ee)(),S=(0,s.useMemo)(()=>(function e(t,r,n,s=null,o=0){let l=[];for(let a of t){if(null!==n&&!n.has(a.path))continue;let t=s?.get(a.path),i=a.isDirectory?function(e,t){if(!t)return!1;let r=e+"/";for(let e of t.keys())if(e.startsWith(r))return!0;return!1}(a.path,s):void 0;l.push({node:a,level:o,gitStatus:t,hasChangedChildren:i}),a.isDirectory&&a.children&&r.has(a.path)&&l.push(...e(a.children,r,n,s,o+1))}return l})(e,r,o,l),[e,r,o,l]),L=(0,f.Te)({count:S.length,getScrollElement:()=>y.current,estimateSize:()=>26,overscan:10}),E=(0,s.useRef)(m);return(E.current=m,(0,s.useEffect)(()=>{if(u&&t&&S.length>0){let e=S.findIndex(e=>e.node.path===t);if(e>=0){let t=setTimeout(()=>{L.scrollToIndex(e,{align:"center"}),E.current?.()},150);return()=>clearTimeout(t)}}},[u,t,S,L]),0===S.length)?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No files"}):(0,n.jsxs)("div",{ref:y,className:x||"h-full overflow-y-auto",style:{willChange:"transform"},children:[(0,n.jsx)("div",{style:{height:`${L.getTotalSize()}px`,width:"100%",position:"relative"},children:L.getVirtualItems().map(e=>{let s=S[e.index];return(0,n.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${e.size}px`,transform:`translateY(${e.start}px)`},children:(0,n.jsx)(es,{item:s,isSelected:t===s.node.path,isExpanded:r.has(s.node.path),isLoading:a?.has(s.node.path),onSelect:i,onToggle:c,onContextMenu:N,renderActions:h})},s.node.path)})}),k&&(0,n.jsx)(b.ft,{x:k.x,y:k.y,path:k.path,cwd:d,isDirectory:k.isDirectory,onClose:C,onCreateFile:p,onDelete:g,onRefresh:v,onCopyFile:j,onPaste:w})]})}var el=r(38408),ea=r(82292),ei=r(45048),ec=r(97251),ed=r(47176),eu=r(79968);let em=[ec.W];function ex({content:e,filePath:t,cwd:r,onClose:l,sourceFile:a}){let i=a||(r&&t.startsWith(r)?t.slice(r.endsWith("/")?r.length:r.length+1):t),{t:c}=(0,o.Bd)(),d=(0,b.iN)(),m=(0,v.r)(),{comments:x,addComment:h,updateComment:f,deleteComment:y,refresh:k}=(0,p._)({cwd:r,filePath:t}),[N,C]=(0,s.useState)(!1),[S,M]=(0,s.useState)(null),[T,$]=(0,s.useState)(null),[P,R]=(0,s.useState)(null),B=(0,s.useMemo)(()=>e.split("\n"),[e]);(0,s.useEffect)(()=>{queueMicrotask(()=>C(!0))},[]);let[F,I]=(0,s.useState)(null),D=(0,s.useRef)(null);(0,s.useEffect)(()=>{D.current!==F&&I(D.current)});let{toolbarRef:A,bumpRef:_,clearToolbar:W}=(0,E.L)({enabled:!0,container:F,resolveLineRange:e=>{let t=function(e){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;if(!t||!("closest"in t))return null;let r=t.closest("[data-source-start]");if(!r)return null;let n=r.getAttribute("data-source-start"),s=r.getAttribute("data-source-end");return n&&s?{start:parseInt(n,10),end:parseInt(s,10)}:null}(e);return t?{start:t.start,end:t.end}:null},buildLineSnapshot:({start:e,end:t})=>{let r=Math.max(0,e-1),n=Math.min(B.length,t);return B.slice(r,n).join("\n")}}),z=(0,s.useCallback)(()=>{let e=A.current;e&&(M({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),W())},[W,A]),H=(0,s.useCallback)(()=>{let e=A.current;e&&($({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),W())},[W,A]),O=(0,s.useCallback)(async e=>{S&&(await h(S.range.start,S.range.end,e,S.selectedText),M(null))},[S,h]),q=(0,s.useCallback)(async e=>{if(T&&m)try{let n=await (0,g.$3)(r),s=[];for(let e of n)s.push({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0});s.push({filePath:t,startLine:T.range.start,endLine:T.range.end,codeContent:T.lineSnapshot});let o=(0,g.Gw)(s,e);m.sendMessage(o),await (0,g.RP)(r),k(),$(null)}catch(e){console.error("Failed to send to AI:",e)}},[T,m,t,r,k]),V=(0,s.useMemo)(()=>{if(0===x.length)return[];let e=new Map;for(let t of x){let r=`${t.startLine}-${t.endLine}`;e.has(r)||e.set(r,[]),e.get(r).push(t)}return Array.from(e.entries()).map(([e,t])=>({key:e,startLine:t[0].startLine,endLine:t[0].endLine,comments:t}))},[x]),[K,U]=(0,s.useState)([]);return(0,s.useEffect)(()=>{if(0===V.length||!D.current)return void queueMicrotask(()=>U([]));let e=setTimeout(()=>{let e=D.current;if(!e)return;let t=[],r=e.querySelectorAll("[data-source-start]");for(let n of V){let s=null,o=1/0;for(let e of r){let t=parseInt(e.getAttribute("data-source-start"),10),r=parseInt(e.getAttribute("data-source-end"),10);if(t<=n.startLine&&r>=n.endLine){let n=r-t;n<o&&(o=n,s=e)}}if(s){let r=e.getBoundingClientRect(),o=s.getBoundingClientRect();t.push({key:n.key,top:o.top-r.top+e.scrollTop,comments:n.comments})}}U(t)},100);return()=>clearTimeout(e)},[V,e]),(0,s.useEffect)(()=>{let e=e=>{if("Escape"===e.key){if(T){$(null),e.stopPropagation();return}if(S){M(null),e.stopPropagation();return}if(A.current){A.current=null,_.current(),e.stopPropagation();return}if(P){R(null),e.stopPropagation();return}l()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[T,S,P,l]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:t}),(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(eu.ShareReviewToggle,{content:e,sourceFile:i}),(0,n.jsx)("button",{onClick:l,className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:c("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsx)(ed.l,{content:e,containerRef:D}),(0,n.jsxs)("div",{className:"flex-1 overflow-auto relative",ref:D,children:[(0,n.jsx)("div",{className:"p-6",children:(0,n.jsx)(ei.T,{content:e,rehypePlugins:em})}),K.map(({key:e,top:t,comments:r})=>(0,n.jsx)("div",{className:"absolute right-3 cursor-pointer z-10",style:{top:t},onClick:e=>{e.stopPropagation(),R({comment:r[0],x:e.clientX,y:e.clientY})},children:(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-amber-500/80 text-white text-xs flex items-center justify-center shadow-sm hover:bg-amber-500 transition-colors",children:r.length})},e))]})]}),N&&d&&(0,u.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.f,{floatingToolbarRef:A,bumpRef:_,container:d,onAddComment:z,onSendToAI:H,isChatLoading:m?.isLoading}),S&&(0,n.jsx)(w.t,{x:S.x,y:S.y,range:S.range,lineSnapshot:S.lineSnapshot,container:d,onSubmit:O,onClose:()=>M(null)}),T&&(0,n.jsx)(w.G,{x:T.x,y:T.y,range:T.range,filePath:t,lineSnapshot:T.lineSnapshot,container:d,onSubmit:q,onClose:()=>$(null),isChatLoading:m?.isLoading}),P&&(0,n.jsx)(L.t,{x:P.x,y:P.y,comment:P.comment,container:d,onClose:()=>R(null),onUpdateComment:f,onDeleteComment:y})]}),d)]})}function eh({path:e,matchedIndices:t}){let r=(0,s.useMemo)(()=>new Set(t),[t]),o=e.lastIndexOf("/"),l=o>=0?e.slice(0,o+1):"",a=o>=0?e.slice(o+1):e,i=(e,t,s)=>{let o=[],l="",a=!1;for(let s=0;s<e.length;s++){let i=t+s,c=r.has(i);c!==a&&l&&(o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-${s}`):(0,n.jsx)("span",{children:l},`${t}-${s}`)),l=""),a=c,l+=e[s]}return l&&o.push(a?(0,n.jsx)("span",{className:"text-brand font-medium",children:l},`${t}-end`):(0,n.jsx)("span",{children:l},`${t}-end`)),(0,n.jsx)("span",{className:s,children:o})};return(0,n.jsxs)("span",{className:"truncate",children:[l&&i(l,0,"text-muted-foreground"),i(a,l.length,"text-foreground")]})}function ef({files:e,fileIndex:t,recentFiles:r,onSelectFile:l,onClose:a}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)(""),[u,x]=(0,s.useState)(0),h=(0,s.useRef)(null),f=(0,s.useRef)(null),p=(0,s.useMemo)(()=>{let r,n;return t??(r=[],(n=e=>{for(let t of e)t.isDirectory&&t.children?n(t.children):t.isDirectory||r.push(t.path)})(e),r)},[t,e]),g=(0,s.useMemo)(()=>{if(!c.trim()){let e=new Set(r);return[...r.map(e=>({path:e,score:0,matchedIndices:[]})),...p.filter(t=>!e.has(t)).slice(0,50).map(e=>({path:e,score:0,matchedIndices:[]}))]}let e=[];for(let t of p){let n=function(e,t){let r=e.toLowerCase(),n=t.toLowerCase(),s=[],o=0,l=0,a=-1;for(let i=0;i<r.length&&o<n.length;i++)r[i]===n[o]&&(s.push(i),a===i-1&&(l+=5),(0===i||"/"===e[i-1]||"."===e[i-1]||"-"===e[i-1]||"_"===e[i-1])&&(l+=10),i>e.lastIndexOf("/")&&(l+=3),e[i]===t[o]&&(l+=1),a=i,o++);return o<n.length?null:(l-=.1*e.length,{path:e,score:l,matchedIndices:s})}(t,c.trim());n&&(r.includes(t)&&(n.score+=20),e.push(n))}return e.sort((e,t)=>t.score-e.score),e.slice(0,50)},[c,p,r]),b=(0,s.useCallback)(e=>{d(e),x(0)},[]);(0,s.useEffect)(()=>{h.current?.focus()},[]),(0,s.useEffect)(()=>{if(f.current){let e=f.current.children[u];e?.scrollIntoView({block:"nearest"})}},[u]);let v=(0,s.useCallback)(e=>{l(e),a()},[l,a]),j=(0,s.useCallback)(e=>{if(!e.nativeEvent.isComposing)switch(e.key){case"ArrowDown":e.preventDefault(),x(e=>Math.min(e+1,g.length-1));break;case"ArrowUp":e.preventDefault(),x(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),g[u]&&v(g[u].path);break;case"Escape":e.preventDefault(),a()}},[g,u,v,a]);return(0,n.jsx)(m.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-start justify-center pt-[15vh]",onClick:a,children:(0,n.jsxs)("div",{className:"w-[680px] max-h-[60vh] bg-card border border-border rounded-lg shadow-2xl overflow-hidden flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),(0,n.jsx)("input",{ref:h,value:c,onChange:e=>b(e.target.value),onKeyDown:j,placeholder:i("quickFileOpen.placeholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",autoCorrect:"off",spellCheck:"false"}),(0,n.jsx)("kbd",{className:"text-[10px] text-muted-foreground px-1.5 py-0.5 rounded border border-border bg-secondary",children:"ESC"})]}),(0,n.jsx)("div",{ref:f,className:"flex-1 overflow-y-auto py-1",children:0===g.length?(0,n.jsx)("div",{className:"px-3 py-8 text-center text-sm text-muted-foreground",children:i("quickFileOpen.noMatch")}):g.map((e,t)=>(0,n.jsxs)("div",{className:`px-3 py-1.5 flex items-center gap-2 cursor-pointer transition-colors ${t===u?"bg-brand/15 text-foreground":"hover:bg-accent text-foreground"}`,"data-tooltip":e.path,onClick:()=>v(e.path),children:[(0,n.jsx)(B,{name:e.path.split("/").pop()||"",className:"w-4 h-4 flex-shrink-0"}),(0,n.jsx)(eh,{path:e.path,matchedIndices:e.matchedIndices}),!c.trim()&&r.includes(e.path)&&(0,n.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground px-1.5 py-0.5 rounded bg-secondary flex-shrink-0",children:i("quickFileOpen.recent")})]},e.path))}),(0,n.jsxs)("div",{className:"px-3 py-1.5 border-t border-border flex items-center gap-3 text-[10px] text-muted-foreground",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"↑↓"})," ",i("quickFileOpen.selectHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Enter"})," ",i("quickFileOpen.openHint")]}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)("kbd",{className:"px-1 py-0.5 rounded border border-border bg-secondary",children:"Esc"})," ",i("quickFileOpen.closeHint")]})]})]})})})}var ep=r(2111),eg=r(41474),eb=r(61878),ev=r(33210),ej=r(48368),ew=r(91958),ey=r(45916),ek=r(31794),eN=r(69048),eC=r(97567),eS=r(68806),eL=r(52475);function eE({kind:e,qname:t,className:r}){let s=`${(function(e,t){if("__file__"===t||"__preamble__"===t||t&&t.startsWith("__heading_"))return"text-muted-foreground/60";switch(e){case"function":case"method":return"text-violet-11";case"class":return"text-amber-11";case"interface":return"text-blue-11";default:return"text-muted-foreground/60"}})(e,t)} ${r??""}`.trim();if("__file__"===t)return(0,n.jsx)(ej.A,{className:s});if("__preamble__"===t)return(0,n.jsx)(ey.A,{className:s});if(t&&t.startsWith("__heading_"))return(0,n.jsx)(ek.A,{className:s});switch(e){case"function":case"method":return(0,n.jsx)(eN.A,{className:s});case"class":return(0,n.jsx)(eC.A,{className:s});case"interface":return(0,n.jsx)(eS.A,{className:s});default:return(0,n.jsx)(eL.A,{className:s})}}var eM=r(49433),eT=r(82680);let e$=new Map,eP=new Map;async function eR(e,t,r=!1){let n=`${e}::${t}`;if(r)!function(e){if(!e){e$.clear(),eP.clear();return}let t=`${e}::`;for(let e of e$.keys())e.startsWith(t)&&e$.delete(e);for(let e of eP.keys())e.startsWith(t)&&eP.delete(e)}(e);else{let e=e$.get(n);if(e)return e;let t=eP.get(n);if(t)return t}let s=eM.tryPromise({try:async()=>{let s=new URLSearchParams({cwd:e,path:t});r&&s.set("refresh","1");let o=await fetch(`/api/projectGraph/file-functions?${s}`);if(404===o.status)return"not-found";if(!o.ok)throw Error((await o.json().catch(()=>({error:`HTTP ${o.status}`}))).error||`HTTP ${o.status}`);let l=await o.json();return e$.set(n,l),l},catch:e=>new eT.uV({message:"fetchFileFunctions failed",cause:e})}),o=i.t4.runPromiseExit(s).then(e=>{if("Success"===e._tag)return e.value;let t="Fail"===e.cause._tag?e.cause.error:null,r=t?.cause;if(r instanceof Error)throw r;throw Error(t?.message??"fetchFileFunctions failed")}).finally(()=>eP.delete(n));return eP.set(n,o),o}function eB(e,t){let[r,n]=(0,s.useState)({state:"idle"}),o=(0,s.useRef)(!0);(0,s.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]);let l=(0,s.useCallback)((e,t,r)=>{n({state:"loading"}),eR(e,t,r).then(e=>{o.current&&("not-found"===e?n({state:"notFound"}):n({state:"ready",data:e}))}).catch(e=>{o.current&&n({state:"error",message:e.message})})},[]);return(0,s.useEffect)(()=>{e&&t?l(e,t,!1):n({state:"idle"})},[e,t,l]),{state:r,refresh:(0,s.useCallback)(()=>{e&&t&&l(e,t,!0)},[e,t,l])}}var eF=r(3238),eI=r(50538),eD=r(94287);function eA({entries:e,onSelect:t,onClear:r}){let{t:s}=(0,o.Bd)();return(0,n.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-l border-border flex flex-col","data-testid":"function-history-drawer",children:[(0,n.jsxs)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border flex items-center justify-between gap-1",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground font-mono min-w-0",children:[(0,n.jsx)(eI.A,{className:"w-3 h-3 flex-shrink-0"}),(0,n.jsx)("span",{className:"truncate",children:0===e.length?s("blockViewer.history.title"):`${s("blockViewer.history.title")} \xb7 ${e.length}/15`})]}),e.length>0&&(0,n.jsx)(eD.m,{content:s("blockViewer.history.clear"),children:(0,n.jsx)("button",{onClick:r,className:"flex-shrink-0 text-muted-foreground hover:text-foreground p-0.5 rounded hover:bg-secondary",children:(0,n.jsx)(ev.A,{className:"w-3 h-3"})})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===e.length?(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:s("blockViewer.history.empty")}):e.map((e,r)=>{var s;let o;return(0,n.jsx)(eD.m,{content:`${e.qname} \xb7 ${e.filePath}`,children:(0,n.jsxs)("button",{onClick:()=>t(e),className:"w-full text-left px-2 py-1.5 border-b border-border/50 hover:bg-secondary/60 transition-colors group flex items-start gap-1.5",children:[(0,n.jsx)(eE,{kind:e.kind??"unknown",qname:e.qname,className:"w-3 h-3 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("div",{className:"text-xs font-mono font-medium truncate",children:e.name}),(0,n.jsxs)("div",{className:"text-[10px] text-muted-foreground/70 truncate",children:[(o=(s=e.filePath).lastIndexOf("/"))>=0?s.slice(o+1):s,e.kind&&(0,n.jsxs)("span",{className:"ml-1 opacity-60",children:["\xb7 ",e.kind]})]})]})]})},`${e.filePath}::${e.qname}::${r}`)})})]})}function e_(e,t){let r=e.filter(e=>e.filePath!==t.filePath||e.qname!==t.qname),n=[t,...r];return n.length>15?n.slice(0,15):n}let eW=new Set(["function","class","method"]);function ez(e){return eW.has(e.kind)}function eH({functions:e,currentQname:t,onSelect:r}){let{t:l}=(0,o.Bd)(),a=(0,s.useMemo)(()=>e.filter(ez),[e]);return(0,n.jsxs)("div",{className:"w-56 flex-shrink-0 bg-card border-r border-border flex flex-col","data-testid":"file-toc-section",children:[(0,n.jsx)("div",{className:"flex-shrink-0 px-2 py-1.5 border-b border-border text-xs text-muted-foreground font-mono truncate",children:0===a.length?l("blockViewer.toc.title"):`${l("blockViewer.toc.title")} \xb7 ${a.length}`}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===a.length?(0,n.jsx)("div",{className:"px-3 py-4 text-[10px] text-muted-foreground/60 italic leading-relaxed",children:l("blockViewer.toc.empty")}):a.map(e=>{let s=t===e.qualifiedName;return(0,n.jsx)(eD.m,{content:`${e.qualifiedName} \xb7 L${e.startLine}`,children:(0,n.jsxs)("button",{onClick:()=>r(e.qualifiedName,e.startLine),className:`w-full text-left px-2 py-1 transition-colors flex items-center gap-1.5 min-w-0 ${s?"bg-brand/15 hover:bg-brand/20":"hover:bg-secondary/60"}`,children:[(0,n.jsx)(eE,{kind:e.kind,qname:e.qualifiedName,className:"w-3 h-3 flex-shrink-0"}),(0,n.jsx)("span",{className:`text-xs font-mono truncate ${s?"font-semibold text-brand":""}`,children:e.name})]})},e.qualifiedName)})})]})}var eO=r(96035);function eq({comments:e,startLine:t,endLine:r,lineHeight:s,bodyTopOffset:o,onCommentClick:l}){let a=new Map;for(let n of e){if(n.endLine<t||n.endLine>r)continue;let e=a.get(n.endLine);e?e.push(n):a.set(n.endLine,[n])}return 0===a.size?null:(0,n.jsx)("div",{className:"absolute top-0 right-0 bottom-0 w-6 pointer-events-none",children:Array.from(a.entries()).map(([e,r])=>{let a=o+(e-t)*s,i=r[0],c=r.length-1;return(0,n.jsx)(eD.m,{content:1===r.length?i.content:`${r.length} comments — click to view`,children:(0,n.jsxs)("button",{onClick:e=>l(i,e),className:"pointer-events-auto absolute right-1 w-4 h-4 rounded-full bg-amber-9/70 hover:bg-amber-11 text-white flex items-center justify-center shadow-sm transition-colors",style:{top:`${a+s/2-8}px`},children:[(0,n.jsx)(eO.A,{className:"w-2.5 h-2.5"}),c>0&&(0,n.jsx)("span",{className:"absolute -top-1 -right-1 bg-amber-11 text-white rounded-full text-[8px] leading-none w-3 h-3 flex items-center justify-center",children:c+1})]})},e)})})}function eV(e,t){for(let r=0;r<e.blocks.length;r++){let n=e.blocks[r];if(t>=n.startLine&&t<=n.endLine)return e.prefix[r]+(t-n.startLine)}return null}function eK({addedLines:e,blockRanges:t,viewportRange:r,onJumpToLine:o}){let l,a=(0,s.useRef)(null),i=(0,s.useMemo)(()=>(function(e){let t=[...e].sort((e,t)=>e.startLine-t.startLine),r=[0];for(let e of t){let t=Math.max(0,e.endLine-e.startLine+1);r.push(r[r.length-1]+t)}return{blocks:t,prefix:r,total:r[r.length-1]}})(t),[t]),c=(0,s.useMemo)(()=>{if(i.total<=0||0===e.size)return[];let t=[];for(let r of e){let e=i.blocks.find(e=>r>=e.startLine&&r<=e.endLine);e&&t.push({line:r,qname:e.qname})}t.sort((e,t)=>e.line-t.line);let r=[],n=null;for(let e of t)n&&e.line===n.end+1&&e.qname===n.qname?n.end=e.line:(n&&r.push(n),n={start:e.line,end:e.line,qname:e.qname});return n&&r.push(n),r},[e,i]);if(i.total<=0)return null;let d=(e,t)=>{let r=eV(i,e),n=eV(i,t);return null===r||null===n?null:{top:r/i.total*100,heightPct:(n-r+1)/i.total*100}};return(0,n.jsxs)("div",{ref:a,onClick:e=>{let t=a.current;if(!t)return;let r=t.getBoundingClientRect();if(r.height<=0)return;let n=function(e,t){if(e.total<=0)return null;let r=Math.max(0,Math.min(e.total-1,t));for(let t=0;t<e.blocks.length;t++){let n=e.prefix[t],s=e.prefix[t+1];if(r>=n&&r<s){let s=e.blocks[t];return{qname:s.qname,line:s.startLine+Math.round(r-n)}}}return null}(i,(e.clientY-r.top)/r.height*i.total);if(!n)return;let s=n.line,l=c.find(e=>e.qname===n.qname&&s>=e.start&&s<=e.end);if(l)return void o(l.qname,s);if(c.length>0){let e=Math.max(2,Math.round(.05*i.total)),t=eV(i,s);if(null!==t){let r=null,n=1/0;for(let e of c){let s=eV(i,e.start),o=eV(i,e.end);if(null===s||null===o)continue;let l=t<s?s-t:t>o?t-o:0;l<n&&(r=e,n=l)}if(r&&n<=e){let e=s<r.start?r.start:s>r.end?r.end:s;o(r.qname,e);return}}}let d=i.blocks.find(e=>e.qname===n.qname);d&&o(d.qname,d.startLine)},className:"w-4 flex-shrink-0 bg-secondary border-l border-border relative cursor-pointer",title:"Diff minimap — click to jump",children:[c.map(e=>{let t=d(e.start,e.end);return t?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-green-9 pointer-events-none",style:{top:`${t.top}%`,height:`${t.heightPct}%`,minHeight:"2px"}},`run:${e.qname}:${e.start}-${e.end}`):null}),r&&r.end>=r.start&&((l=d(r.start,r.end))?(0,n.jsx)("div",{className:"absolute left-0 right-0 bg-muted/60 border-y border-border pointer-events-none",style:{top:`${l.top}%`,height:`${Math.max(1.2,l.heightPct)}%`}}):null)]})}function eU(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function eJ({symbol:e,fileSource:t,hasChange:r,onHighlighted:o,comments:l,onCommentClick:a,addedLines:i}){let{resolvedTheme:c}=(0,eF.D)(),d=(0,s.useMemo)(()=>(0,C.sQ)(e.filePath),[e.filePath]),[u,m]=(0,s.useState)(null),[x,h]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!t)return void m(null);let r=!1;return(async()=>{try{let n=t.split("\n").slice(e.startLine-1,e.endLine).join("\n"),s=(await (0,C.kS)()).codeToTokens(n,{lang:d,theme:"dark"===c?"github-dark":"github-light"}).tokens.map((t,r)=>{let n=e.startLine+r,s=i?.has(n)??!1;return`<div class="flex${s?" bg-green-9/15":""}" style="min-width:max-content" data-line="${n}"><span class="select-none pr-3 text-muted-foreground/60 tabular-nums" style="min-width:3.2rem;text-align:right">${n}</span><span class="whitespace-pre">${(0,C.b8)(t)}</span></div>`}).join("");r||(m(s),h(null))}catch(e){r||h(e instanceof Error?e.message:"highlight failed")}})(),()=>{r=!0}},[t,e.startLine,e.endLine,d,c,e.filePath,i]),(0,s.useEffect)(()=>{(null!==u||null!==x)&&o(e.qualifiedName)},[u,x,e.qualifiedName,o]),(0,n.jsxs)("div",{className:"flex-1 min-w-0 bg-card border border-border rounded overflow-hidden relative",children:[(0,n.jsxs)("div",{"data-block-header":!0,className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-border bg-secondary/40 text-xs",children:[(0,n.jsx)(eE,{kind:e.kind,qname:e.qualifiedName,className:"w-3.5 h-3.5 flex-shrink-0"}),(0,n.jsxs)("span",{className:"font-mono truncate min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:e.name}),void 0!==e.params&&(0,n.jsxs)("span",{className:"text-muted-foreground/80",children:["(",e.params.join(", "),")"]})]}),(0,n.jsxs)("span",{className:"text-[10px] text-muted-foreground/70 flex-shrink-0",children:[e.kind," \xb7 L",e.startLine,"-",e.endLine]}),(0,n.jsx)("span",{className:"flex-1"}),r&&(0,n.jsx)("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-amber-11","data-tooltip":"File has uncommitted change"})]}),(0,n.jsxs)("div",{"data-block-body":!0,className:"text-[11px] font-mono px-2 py-2 overflow-auto",style:{lineHeight:`${eX}px`},children:[!t&&(0,n.jsx)("span",{className:"text-muted-foreground",children:"Loading…"}),x&&(0,n.jsx)("span",{className:"text-red-11",children:x}),u&&(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:u}})]}),l&&l.length>0&&a&&(0,n.jsx)(eq,{comments:l,startLine:e.startLine,endLine:e.endLine,lineHeight:eX,bodyTopOffset:eY+eZ,onCommentClick:a})]})}function eQ({side:e,pin:t,accent:r,onClick:s}){let o,l,a,i,c,d,u,m=t.lines.length;"ext"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",l="ext",a="text-muted-foreground/60",i=t.name,c=t.packageSpec,d="external",u=t.packageSpec):"method"===t.kind?(o="bg-secondary/30 border-border/50 hover:border-muted-foreground/60",l="method",a="text-muted-foreground/60",i=`${t.receiverName}.${t.methodName}`,c=null,d="method (unresolved)",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):"self"===t.kind?(o="bg-secondary/40 border-border hover:border-muted-foreground",l="self",a="text-muted-foreground/70",i=t.external.name,c=null,d="same-file",u=m>0?`at line${m>1?"s":""} ${t.lines.join(", ")}`:""):(o="in"===e?"bg-amber-9/15 border-amber-9/40 hover:border-amber-11":"bg-green-9/15 border-green-9/40 hover:border-green-11",l=e,a="in"===e?"text-amber-11":"text-green-11",i=t.external.name,c=eU(t.external.filePath),d="in"===e?"caller":"callee",u=t.external.filePath);let x=r&&"ext"!==t.kind&&"method"!==t.kind?" ring-1 ring-amber-9/70 ring-offset-0":"";return(0,n.jsxs)("button",{onClick:e=>{e.stopPropagation(),s()},className:`${o}${x} w-full text-left border rounded px-1.5 py-0.5 text-[10px] font-mono cursor-pointer transition-colors flex items-center gap-1.5`,"data-tooltip":`${d}${u?" \xb7 "+u:""}`,children:[(0,n.jsx)("span",{className:`${a} text-[9px] uppercase tracking-wider font-semibold flex-shrink-0`,children:l}),(0,n.jsxs)("span",{className:"truncate flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"font-medium",children:i}),c&&(0,n.jsx)("span",{className:"text-muted-foreground/70 ml-1",children:c}),m>1&&(0,n.jsxs)("span",{className:"text-muted-foreground/60 ml-1",children:["\xb7",m,"\xd7"]})]})]})}let eX=18,eY=29,eZ=8;function eG(e,t){switch(t.kind){case"cross":return`${e}:x:${t.external.filePath}::${t.external.qualifiedName}`;case"self":return`${e}:s:${t.external.filePath}::${t.external.qualifiedName}`;case"ext":return`${e}:e:${t.packageSpec}::${t.name}`;case"method":return`${e}:m:${t.receiverName}::${t.methodName}`}}function e0(e,t){return"ext"!==e.kind&&"method"!==e.kind&&(t?.has(e.external.qualifiedName)??!1)}function e1(e){return{filePath:e.filePath,qname:e.qualifiedName,name:e.name,kind:e.kind}}function e2({symbol:e,fileSource:t,hasChange:r,upstream:s,downstream:o,onPinClick:l,onHighlighted:a,comments:i,onCommentClick:c,accentQnames:d,addedLines:u}){let m=function(e,t){if(0===e.length)return[];let r=e.map((e,r)=>{var n,s;return{i:r,line:(n=e.lines[0]??t.startLine,s=t.startLine,Math.max(s,Math.min(t.endLine,n)))}});r.sort((e,t)=>e.line-t.line||e.i-t.i);let n=Array(e.length).fill(0),s=-1/0;for(let{i:e,line:o}of r){let r=Math.max(eY+eZ+(o-t.startLine)*eX,s);n[e]=r,s=r+22}return n}(o,e);return(0,n.jsxs)("div",{"data-block-qname":e.qualifiedName,"data-start-line":e.startLine,"data-end-line":e.endLine,className:"flex gap-2 items-stretch scroll-mt-2",children:[(0,n.jsx)("div",{className:"w-44 flex-shrink-0 flex flex-col gap-1 pt-1",children:0===s.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5",children:"no callers"}):s.map(t=>(0,n.jsx)(eQ,{side:"in",pin:t,accent:e0(t,d),onClick:()=>l(t,e)},eG("in",t)))}),(0,n.jsx)(eJ,{symbol:e,fileSource:t,hasChange:r,onHighlighted:a,comments:i,onCommentClick:c,addedLines:u}),(0,n.jsx)("div",{className:"w-44 flex-shrink-0 relative",children:0===o.length?(0,n.jsx)("div",{className:"text-[10px] text-muted-foreground/40 italic px-1.5 pt-1",children:"no callees"}):o.map((t,r)=>(0,n.jsx)("div",{className:"absolute left-0 right-0",style:{top:`${m[r]}px`},children:(0,n.jsx)(eQ,{side:"out",pin:t,accent:e0(t,d),onClick:()=>l(t,e)})},eG("out",t)))})]})}function e5({cwd:e,onSelect:t,onClose:r}){let{t:l}=(0,o.Bd)(),[a,c]=(0,s.useState)(""),[d,u]=(0,s.useState)({files:[],symbols:[]}),[m,x]=(0,s.useState)(0),[f,p]=(0,s.useState)(!1),g=(0,s.useMemo)(()=>[...d.files,...d.symbols],[d]);(0,s.useEffect)(()=>{let t=a.trim();if(!t)return void u({files:[],symbols:[]});p(!0);let r=setTimeout(async()=>{let r=new URLSearchParams({cwd:e,q:t,limit:"12"}),n=await i.t4.runPromiseExit((0,h.MB)(r));"Success"===n._tag&&(u(n.value),x(0)),p(!1)},120);return()=>clearTimeout(r)},[a,e]);let b=(0,s.useCallback)(e=>{if("Escape"===e.key)return void r();if(0!==g.length){if("ArrowDown"===e.key)e.preventDefault(),x(e=>Math.min(e+1,g.length-1));else if("ArrowUp"===e.key)e.preventDefault(),x(e=>Math.max(e-1,0));else if("Enter"===e.key){e.preventDefault();let r=g[m];r&&t(r)}}},[g,m,r,t]);return(0,n.jsx)("div",{className:"absolute inset-0 bg-background/40 z-20 flex items-start justify-center pt-24",onClick:r,children:(0,n.jsxs)("div",{className:"w-[480px] max-w-[80%] bg-card border border-border rounded shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border",children:[(0,n.jsx)(eb.A,{className:"w-4 h-4 text-muted-foreground"}),(0,n.jsx)("input",{autoFocus:!0,value:a,onChange:e=>c(e.target.value),onKeyDown:b,placeholder:l("blockViewer.search.hint","Start typing to search"),className:"flex-1 bg-transparent border-0 outline-none text-sm"}),f&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"…"}),(0,n.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsxs)("div",{className:"max-h-96 overflow-y-auto",children:[0===g.length&&a&&!f&&(0,n.jsx)("div",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:l("blockViewer.search.noResults","No matches")}),(0,n.jsx)(e4,{label:l("blockViewer.search.files","Files"),hits:d.files,startIdx:0,activeIdx:m,onSelect:t,setActive:x}),(0,n.jsx)(e4,{label:l("blockViewer.search.symbols","Symbols"),hits:d.symbols,startIdx:d.files.length,activeIdx:m,onSelect:t,setActive:x})]})]})})}function e4({label:e,hits:t,startIdx:r,activeIdx:s,onSelect:o,setActive:l}){return 0===t.length?null:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-muted-foreground bg-secondary/40",children:e}),t.map((e,t)=>{let a=r+t,i=a===s;return(0,n.jsxs)("button",{onMouseEnter:()=>l(a),onClick:()=>o(e),className:`w-full text-left px-3 py-1.5 text-xs flex items-start gap-2 ${i?"bg-secondary":"hover:bg-secondary/60"}`,children:["file"===e.target.kind?(0,n.jsx)(ej.A,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0 text-muted-foreground"}):(0,n.jsx)(eE,{kind:e.target.symbolKind,qname:e.target.qualifiedName,className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,n.jsx)("span",{className:"font-mono truncate",children:e.label}),e.hint&&(0,n.jsx)("span",{className:"text-[10px] text-muted-foreground truncate",children:e.hint})]})]},`${e.type}:${e.label}:${t}`)})]})}function e3({cwd:e,highlightedFilePath:t,changedFiles:r,onSwitchToCode:l,enableComments:a=!1,onContentSearch:c,onFocalChange:d,qnameFilter:u,qnameFilterFile:m,accentQnames:h,accentFile:f,addedLines:b,addedLinesFile:y,headerExtraLeft:k,headerExtraRight:N}){let{t:C}=(0,o.Bd)(),[S,M]=(0,s.useState)(null),T=S??t??null;(0,s.useEffect)(()=>{M(null)},[t]),(0,s.useEffect)(()=>{d?.(T)},[T,d]);let{state:$,refresh:P}=eB(e,T),[R,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!T)return void B(null);let t=!1;return B(null),(async()=>{let r=new URLSearchParams({cwd:e,path:T}),n=await i.t4.runPromiseExit((0,x.eA)(r));t||("Success"===n._tag?B({content:n.value.content,mtimeMs:n.value.mtimeMs}):console.error("[BlockViewer] failed to load file source for",T,n.cause))})(),()=>{t=!0}},[e,T]);let F=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!R||"ready"!==$.state)return;let e=$.data.mtimeMs;!e||R.mtimeMs<=e||F.current!==R.mtimeMs&&(F.current=R.mtimeMs,P())},[R,$,P]);let[I,D]=(0,s.useState)([]),[A,_]=(0,s.useState)(!1),[W,z]=(0,s.useState)(null),H=(0,s.useRef)(0),O=(0,s.useRef)(0),[q,V]=(0,s.useState)(()=>new Set),K="ready"===$.state?$.data.filePath:null;(0,s.useEffect)(()=>{V(new Set)},[K]);let U=(0,s.useCallback)(e=>{V(t=>{if(t.has(e))return t;let r=new Set(t);return r.add(e),r})},[]);(0,s.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),_(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let J=(0,s.useCallback)((e,t)=>{if("ext"===e.kind||"method"===e.kind){let e=t.filePath;if(!e)return;H.current+=1,z({filePath:e,qname:"__imports__",nonce:H.current});return}let r=e1(t),n=e1(e.external);D(e=>e_(e_(e,r),n)),M(n.filePath),H.current+=1,z({filePath:n.filePath,qname:n.qname,nonce:H.current})},[]),Q=(0,s.useCallback)(e=>{M(e.filePath),H.current+=1,z({filePath:e.filePath,qname:e.qname,nonce:H.current})},[]),X=(0,s.useCallback)(e=>{_(!1),M(e.target.filePath),"symbol"===e.target.kind&&(H.current+=1,z({filePath:e.target.filePath,qname:e.target.qualifiedName,line:e.target.line,nonce:H.current}))},[]),Y=(0,s.useCallback)((e,t)=>{T&&(H.current+=1,z({filePath:T,qname:e,line:t,nonce:H.current}))},[T]),[Z,G]=(0,s.useState)(null),[ee,et]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!Z)return;let e=null,t=()=>{e=null;let t=Z.getBoundingClientRect();if(t.height<=0)return;let r=Z.querySelectorAll("[data-block-qname]"),n=1/0,s=-1/0;r.forEach(e=>{let r=e.dataset.startLine,o=e.dataset.endLine;if(!r||!o)return;let l=Number(r),a=Number(o);if(!Number.isFinite(l)||!Number.isFinite(a))return;let i=e.getBoundingClientRect();if(i.height<=0||i.bottom<=t.top||i.top>=t.bottom)return;let c=Math.max(0,t.top-i.top),d=Math.min(i.height,t.bottom-i.top),u=a-l+1,m=Math.floor(c/i.height*u),x=Math.ceil(d/i.height*u)-1,h=l+Math.max(0,m),f=l+Math.min(u-1,Math.max(0,x));h<n&&(n=h),f>s&&(s=f)}),n===1/0||s===-1/0?et(null):et(e=>e&&e.start===n&&e.end===s?e:{start:n,end:s})},r=()=>{null===e&&(e=requestAnimationFrame(t))};r(),Z.addEventListener("scroll",r,{passive:!0});let n=new ResizeObserver(r);n.observe(Z);let s=new MutationObserver(r);return s.observe(Z,{childList:!0,subtree:!0}),()=>{Z.removeEventListener("scroll",r),n.disconnect(),s.disconnect(),null!==e&&cancelAnimationFrame(e)}},[Z]);let er=(0,s.useMemo)(()=>{if("ready"!==$.state||!ee)return null;let e=$.data.functions;if(0===e.length)return null;let t=(ee.start+ee.end)/2;for(let r of e)if(r.startLine<=t&&t<=r.endLine)return r.qualifiedName;let r=null;for(let t of e)t.startLine<=ee.start&&(!r||t.startLine>r.startLine)&&(r=t);return r?.qualifiedName??null},[$,ee]),en=a&&!!e&&!!T,es=(0,v.r)(),{comments:eo,addComment:el,updateComment:ea,deleteComment:ei,refresh:ec}=(0,p._)({cwd:e,filePath:T??""}),[ed,eu]=(0,s.useState)(null),{toolbarRef:em,bumpRef:ex,clearToolbar:eh}=(0,E.L)({enabled:en,container:ed,resolveLineRange:e=>{if(!document.contains(e))return null;let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,r=t?.closest("[data-line]");if(!r||!ed||!ed.contains(r))return null;let n=r.getAttribute("data-line");if(!n)return null;let s=parseInt(n,10);return Number.isFinite(s)?{start:s,end:s}:null},buildLineSnapshot:({start:e,end:t})=>{let r=R?.content;return r?r.split("\n").slice(e-1,t).join("\n"):""}}),[ef,ep]=(0,s.useState)(null),[eg,eb]=(0,s.useState)(null),[ev,ej]=(0,s.useState)(null),ew=(0,s.useCallback)(()=>{let e=em.current;e&&(ep({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eh())},[eh,em]),ey=(0,s.useCallback)(()=>{let e=em.current;e&&(eb({x:e.x,y:e.y,range:e.range,selectedText:e.selectedText,lineSnapshot:e.lineSnapshot}),eh())},[eh,em]),ek=(0,s.useCallback)(()=>{let e=em.current;if(!e||!c)return;let t=e.selectedText.trim();eh(),t&&c(t)},[c,eh,em]),eN=(0,s.useCallback)(async e=>{ef&&(await el(ef.range.start,ef.range.end,e,ef.selectedText),ep(null))},[ef,el]),eC=(0,s.useCallback)(async t=>{if(eg&&es&&e&&T)try{let r=(await (0,g.$3)(e)).map(e=>({filePath:e.filePath,startLine:e.startLine,endLine:e.endLine,codeContent:e.codeContent,note:e.content||void 0}));r.push({filePath:T,startLine:eg.range.start,endLine:eg.range.end,codeContent:eg.lineSnapshot});let n=(0,g.Gw)(r,t);es.sendMessage(n),await (0,g.RP)(e),ec(),eb(null)}catch(e){console.error("[BlockViewer] send to AI failed:",e)}},[eg,es,e,T,ec]),eS=(0,s.useCallback)((e,t)=>{t.stopPropagation(),ej({comment:e,x:t.clientX,y:t.clientY}),eh(),ep(null),eb(null)},[eh]);if((0,s.useEffect)(()=>{let e;if(!W||O.current>=W.nonce||"ready"!==$.state||!R||$.data.filePath!==W.filePath)return;if(m&&m===$.data.filePath&&u){let t=0;for(let e of $.data.functions)u.has(e.qualifiedName)&&t++;e=Math.max(1,t)}else e=Math.max(1,$.data.functions.length);if(q.size<e)return;O.current=W.nonce;let t=null,r=requestAnimationFrame(()=>{let e=W.qname.indexOf(">"),r=e>=0?W.qname.slice(0,e):W.qname,n=document.querySelector(`[data-block-qname="${CSS.escape(r)}"]`);if(!n)return;if("number"==typeof W.line){let e=n.querySelector(`[data-line="${W.line}"]`);if(e instanceof HTMLElement){e.scrollIntoView({behavior:"instant",block:"center"}),e.classList.remove("line-flash"),e.offsetWidth,e.classList.add("line-flash"),t=window.setTimeout(()=>{e.classList.remove("line-flash")},1700);return}}n.scrollIntoView({behavior:"instant",block:"start"});let s=n.querySelector("[data-block-header]");s instanceof HTMLElement&&(s.classList.remove("block-flash"),s.offsetWidth,s.classList.add("block-flash"),t=window.setTimeout(()=>{s.classList.remove("block-flash")},1700))});return()=>{cancelAnimationFrame(r),null!==t&&window.clearTimeout(t)}},[W,$,R,q,u,m]),!T)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:null,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,refreshDisabled:!0,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-sm text-muted-foreground gap-2 px-4 text-center",children:[(0,n.jsx)("span",{children:C("blockViewer.empty.body","Select a file in the left tree to see its function call graph.")}),(0,n.jsx)("span",{className:"text-xs",children:C("blockViewer.empty.hint","or press ⌘K to search.")})]}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]});if("idle"===$.state||"loading"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,refreshDisabled:!0,extraLeft:k,extraRight:N}),(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:C("blockViewer.fileMode.loading","Loading…")})]});if("notFound"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground px-4 text-center",children:C("blockViewer.fileMode.notFound","This file is not indexed (unsupported language or beyond the file cap).")}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]});if("error"===$.state)return(0,n.jsxs)("div",{className:"h-full flex flex-col",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:null,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-sm",children:[(0,n.jsx)("span",{className:"text-red-11",children:$.message}),(0,n.jsx)("button",{onClick:P,className:"px-3 py-1 rounded bg-secondary hover:bg-secondary/80",children:C("blockViewer.retry","Retry")})]})]});let eL=$.data,eE=eL.functions;if(0===eE.length&&R){let e=Math.max(1,R.content.split("\n").length);eE=[{filePath:eL.filePath,qualifiedName:"__file__",name:eU(eL.filePath),kind:"unknown",startLine:1,endLine:e}]}let eM=m&&m===eL.filePath,eT=f&&f===eL.filePath,e$=y&&y===eL.filePath;eM&&u&&(eE=eE.filter(e=>u.has(e.qualifiedName)));let eP=eT?h:void 0,eR=e$?b:void 0,eF=e6(eL.upstreamCalls),eI=e6(eL.downstreamCalls),eD=new Map(eE.map(e=>[e.qualifiedName,e])),eW=new Map,ez=new Map;for(let e of eL.intraCalls){let t=eD.get(e.to),r=eD.get(e.from);if(t){let r=eW.get(e.from),n={kind:"self",external:t,lines:e.lines};r?r.push(n):eW.set(e.from,[n])}if(r){let t=ez.get(e.to),n={kind:"self",external:r,lines:e.lines};t?t.push(n):ez.set(e.to,[n])}}let eO=new Map;for(let e of eL.externalCalls??[]){let t=eO.get(e.focalQname),r={kind:"ext",name:e.external.name,packageSpec:e.external.packageSpec,lines:e.lines};t?t.push(r):eO.set(e.focalQname,[r])}let eq=new Map;for(let e of eL.methodCalls??[]){let t=eq.get(e.focalQname),r={kind:"method",receiverName:e.receiverName,methodName:e.methodName,lines:e.lines};t?t.push(r):eq.set(e.focalQname,[r])}let eV=r.has(eL.filePath);return(0,n.jsxs)("div",{className:"h-full flex flex-col relative",children:[(0,n.jsx)(e8,{focalFile:T,fileCount:eL.fileCount,functionCount:eL.functions.length,upstreamCount:eL.upstreamCalls.length,downstreamCount:eL.downstreamCalls.length,onSwitchToCode:l,onSearch:()=>_(!0),onRefresh:P,extraLeft:k,extraRight:N}),(0,n.jsxs)("div",{ref:eu,className:"flex-1 relative min-h-0 flex",children:[(0,n.jsx)(eH,{functions:eE,currentQname:er,onSelect:Y}),(0,n.jsx)("div",{ref:G,className:"flex-1 min-w-0 overflow-auto",children:(0,n.jsx)("div",{className:"flex flex-col gap-3 p-3",children:eE.map(e=>{let t,r,s,o,l,a;return(0,n.jsx)(e2,{symbol:e,fileSource:R?.content??null,hasChange:eV,upstream:(t=eF.get(e.qualifiedName),r=ez.get(e.qualifiedName),[...(t??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...r??[]]),downstream:(s=eI.get(e.qualifiedName),o=eW.get(e.qualifiedName),l=eq.get(e.qualifiedName),a=eO.get(e.qualifiedName),[...(s??[]).map(e=>({kind:"cross",external:e.external,lines:e.lines})),...o??[],...l??[],...a??[]]),onPinClick:J,onHighlighted:U,comments:en?eo:void 0,onCommentClick:en?eS:void 0,accentQnames:eP,addedLines:eR},e.qualifiedName)})})}),en&&ed&&(0,n.jsx)(j.f,{floatingToolbarRef:em,bumpRef:ex,container:ed,onAddComment:ew,onSendToAI:ey,onSearch:c?ek:void 0,isChatLoading:es?.isLoading}),en&&ef&&(0,n.jsx)(w.t,{x:ef.x,y:ef.y,range:ef.range,lineSnapshot:ef.lineSnapshot,container:ed,onSubmit:eN,onClose:()=>ep(null)}),en&&eg&&T&&(0,n.jsx)(w.G,{x:eg.x,y:eg.y,range:eg.range,filePath:T,lineSnapshot:eg.lineSnapshot,container:ed,onSubmit:eC,onClose:()=>eb(null),isChatLoading:es?.isLoading}),en&&ev&&(0,n.jsx)(L.t,{x:ev.x,y:ev.y,comment:ev.comment,container:ed,onClose:()=>ej(null),onUpdateComment:ea,onDeleteComment:ei}),eR&&eR.size>0&&eE.length>0&&(0,n.jsx)(eK,{addedLines:eR,blockRanges:eE.map(e=>({qname:e.qualifiedName,startLine:e.startLine,endLine:e.endLine})),viewportRange:ee,onJumpToLine:Y}),(0,n.jsx)(eA,{entries:I,onSelect:Q,onClear:()=>D([])}),A&&(0,n.jsx)(e5,{cwd:e,onSelect:X,onClose:()=>_(!1)})]})]})}function e6(e){let t=new Map;for(let r of e){let e=t.get(r.focalQname);if(!e){t.set(r.focalQname,[r]);continue}e.some(e=>e.external.filePath===r.external.filePath&&e.external.qualifiedName===r.external.qualifiedName)||e.push(r)}return t}function e8({focalFile:e,fileCount:t,functionCount:r,upstreamCount:s,downstreamCount:l,onSwitchToCode:a,onSearch:i,onRefresh:c,refreshDisabled:d,extraLeft:u,extraRight:m}){let{t:x}=(0,o.Bd)(),h={focalFile:e,blockCount:r??0,upstreamCount:s??0,downstreamCount:l??0};return(0,n.jsxs)("div",{className:"flex-shrink-0 px-3 py-2 border-b border-border flex items-center justify-between bg-secondary/30 gap-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0 text-xs text-muted-foreground font-mono",children:[(0,n.jsx)("span",{className:"truncate min-w-0",children:e?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-foreground",children:e}),"number"==typeof r&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",r," blocks"]}),"number"==typeof s&&"number"==typeof l&&(0,n.jsxs)("span",{className:"ml-2",children:["\xb7 ",s," in \xb7 ",l," out"]})]}):(0,n.jsx)("span",{children:null!==t?`${t} files`:"…"})}),u&&(0,n.jsx)("span",{className:"flex items-center gap-1 flex-shrink-0",children:u(h)})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[m&&(0,n.jsx)("span",{className:"flex items-center gap-1",children:m(h)}),(0,n.jsxs)("button",{onClick:i,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground flex items-center gap-1","data-tooltip":x("blockViewer.search.tooltip","Search (⌘K)"),children:[(0,n.jsx)(eb.A,{className:"w-3 h-3"})," ⌘K"]}),(0,n.jsx)("button",{onClick:c,disabled:d,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:hover:bg-transparent","data-tooltip":x("blockViewer.refresh","Rebuild project graph"),children:(0,n.jsx)(ew.A,{className:"w-3 h-3"})}),a&&(0,n.jsx)("button",{onClick:a,className:"text-xs px-2 py-1 rounded hover:bg-secondary text-muted-foreground hover:text-foreground",children:"Code"})]})]})}function e9(e){let t=0xdeadbeef,r=0x41c6ce57;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);t=Math.imul(t^s,0x9e3779b1),r=Math.imul(r^s,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35),(0x100000000*(2097151&(r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35)))+(t>>>0)>>>0).toString(16)}function e7(e){return e.replace(/\s+/g," ").trim()}function te(e,t){return e?`${e}>${t}`:t}function tt(e){let t=e.childForFieldName("name");if(t)return t.text;for(let t=0;t<e.namedChildCount;t++){let r=e.namedChild(t);if(r&&("identifier"===r.type||"type_identifier"===r.type||"property_identifier"===r.type))return r.text}return"<anonymous>"}function tr(e,t,r,n,s=[],o){return{qualifiedName:te(n,t),name:t,kind:r,startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e9(e7(e.text)),children:s,params:o}}function tn(e){let t=e.childForFieldName("parameter");if(t)return[t.text];let r=e.childForFieldName("parameters");if(!r)return;let n=[];for(let e=0;e<r.namedChildCount;e++){let t=r.namedChild(e);t&&n.push(function e(t){switch(t.type){case"required_parameter":case"optional_parameter":{let r=t.childForFieldName("pattern");return r?e(r):t.text}case"assignment_pattern":{let r=t.childForFieldName("left");return r?e(r):t.text}case"default_parameter":case"typed_default_parameter":{let e=t.childForFieldName("name");return e?e.text:t.text}case"typed_parameter":for(let e=0;e<t.namedChildCount;e++){let r=t.namedChild(e);if(r?.type==="identifier")return r.text}return t.text;default:return t.text}}(t))}return n}function ts(e){let t=e.split("/").pop()?.toLowerCase()??"";switch(t.includes(".")?t.split(".").pop():""){case"ts":return"typescript";case"tsx":case"jsx":return"tsx";case"js":case"mjs":case"cjs":return"javascript";case"py":case"pyi":return"python";case"go":return"go";case"rs":return"rust";default:return null}}var to=r(14066);let tl="/tree-sitter",ta=null,ti=new Map;async function tc(e){let t,r=await (!(t=ti.get(e))&&(t=(async()=>(await (!ta&&(ta=to.iX.init({locateFile:e=>`${tl}/${e}`})),ta),to.TM.load(`${tl}/tree-sitter-${e}.wasm`)))(),ti.set(e,t)),t),n=new to.iX;return n.setLanguage(r),n}function td(e){return e.qualifiedName.startsWith("__code_")||e.qualifiedName.startsWith("__heading_")}function tu(e){return!td(e)&&"__file__"!==e.qualifiedName}async function tm(e,t){if(!e)return[];let r=ts(t);if(!r)return null;let n=(await tc(r)).parse(e);if(!n)return null;try{return function(e){let t=[],r=function(e){let t=[],r=-1,n=-1;for(let s=0;s<e.namedChildCount;s++){let o=e.namedChild(s);if(o){if("import_statement"===o.type||"export_statement"===o.type&&null!==o.childForFieldName("source")||"import_from_statement"===o.type||"future_import_statement"===o.type)t.push(o),r<0&&(r=o.startPosition.row+1),n=o.endPosition.row+1;else if(r>=0)break}}return r<0?null:{qualifiedName:"__imports__",name:"imports",kind:"unknown",startLine:r,endLine:n,contentHash:e9(e7(t.map(e=>e.text).join("\n"))),children:[]}}(e);r&&t.push(r);for(let r=0;r<e.namedChildCount;r++){let n=e.namedChild(r);n&&t.push(...function e(t,r,n=!1){switch(t.type){case"export_statement":case"export_default_declaration":{let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);o&&n.push(...e(o,r,!0))}return n}case"function_declaration":case"generator_function_declaration":case"function_definition":return[tr(t,tt(t),"function",r,[],tn(t))];case"class_declaration":case"abstract_class_declaration":{let e=tt(t),n=te(r,e),s=function(e,t){if(!e)return[];let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(s){if("method_definition"===s.type)r.push(tr(s,tt(s),"method",t,[],tn(s)));else if("public_field_definition"===s.type){let e=s.childForFieldName("value");e&&("arrow_function"===e.type||"function_expression"===e.type)&&r.push(tr(s,tt(s),"method",t,[],tn(e)))}}}return r}(t.childForFieldName("body"),n);return[tr(t,e,"class",r,s)]}case"interface_declaration":return[tr(t,tt(t),"interface",r)];case"type_alias_declaration":return[tr(t,tt(t),"type",r)];case"enum_declaration":return[tr(t,tt(t),"enum",r)];case"lexical_declaration":case"variable_declaration":return function(e,t){let r=[];for(let n=0;n<e.namedChildCount;n++){let s=e.namedChild(n);if(!s||"variable_declarator"!==s.type)continue;let o=s.childForFieldName("name"),l=s.childForFieldName("value");if(!o)continue;let a=o.text,i=l&&("arrow_function"===l.type||"function_expression"===l.type),c=i&&l?tn(l):void 0;if(r.push(tr(e,a,i?"function":"const",t,[],c)),l&&"object"===l.type&&!i){let e=t?`${t}>${a}`:a;for(let t=0;t<l.namedChildCount;t++){let n=l.namedChild(t);if(n){if("pair"===n.type){let t=n.childForFieldName("key"),s=n.childForFieldName("value");if(!t||!s||"property_identifier"!==t.type&&"identifier"!==t.type||"arrow_function"!==s.type&&"function_expression"!==s.type)continue;r.push(tr(n,t.text,"method",e,[],tn(s)))}else if("method_definition"===n.type){let t=tt(n);t&&r.push(tr(n,t,"method",e,[],tn(n)))}}}}}return r}(t,r);case"class_definition":{let e=tt(t),n=te(r,e),s=function e(t,r){if(!t)return[];let n=[];for(let s=0;s<t.namedChildCount;s++){let o=t.namedChild(s);if(o){if("function_definition"===o.type)n.push(tr(o,tt(o),"method",r,[],tn(o)));else if("decorated_definition"===o.type){let t=o.childForFieldName("definition");if(t?.type==="function_definition")n.push({...tr(t,tt(t),"method",r,[],tn(t)),startLine:o.startPosition.row+1,contentHash:e9(e7(o.text))});else if(t?.type==="class_definition"){let s=tt(t),l=te(r,s),a=e(t.childForFieldName("body"),l);n.push({...tr(t,s,"class",r,a),startLine:o.startPosition.row+1,contentHash:e9(e7(o.text))})}}else if("class_definition"===o.type){let t=tt(o),s=te(r,t),l=e(o.childForFieldName("body"),s);n.push(tr(o,t,"class",r,l))}}}return n}(t.childForFieldName("body"),n);return[tr(t,e,"class",r,s)]}case"decorated_definition":{let n=t.childForFieldName("definition");if(!n)return[];return e(n,r,!1).map(e=>({...e,startLine:t.startPosition.row+1,contentHash:e9(e7(t.text))}))}case"expression_statement":{let e=[];for(let n=0;n<t.namedChildCount;n++){let s=t.namedChild(n);if(s?.type==="assignment"){let n=function(e,t,r){let n=t.childForFieldName("left");if(!n||"identifier"!==n.type)return null;let s=n.text;return{qualifiedName:te(r,s),name:s,kind:"const",startLine:e.startPosition.row+1,endLine:e.endPosition.row+1,contentHash:e9(e7(e.text)),children:[]}}(t,s,r);n&&e.push(n)}}return e.push(...function(e,t){let r=null;for(let t=0;t<e.namedChildCount;t++){let n=e.namedChild(t);if(n){if("call_expression"===n.type){r=n;break}if("await_expression"===n.type){for(let e=0;e<n.namedChildCount;e++){let t=n.namedChild(e);if(t?.type==="call_expression"){r=t;break}}break}}}if(!r)return[];let n=r.childForFieldName("function"),s=r.childForFieldName("arguments");if(!n||!s)return[];let o=null,l=[];for(let e=0;e<s.namedChildCount;e++){let t=s.namedChild(e);if(t){if(null===o&&("string"===t.type||"template_string"===t.type)){let e=t.text;o=e.length>=2&&/^["'`]/.test(e)?e.slice(1,-1):e}("arrow_function"===t.type||"function_expression"===t.type)&&l.push(t)}}if(0===l.length||!o)return[];let a=function e(t){if("identifier"===t.type)return t.text;if("member_expression"===t.type){let e=t.childForFieldName("property");return e?.text??""}if("call_expression"===t.type){let r=t.childForFieldName("function");return r?e(r):""}return""}(n),i=a?`${a} ${o}`:o;return l.map((e,r)=>tr(e,l.length>1?`${i} #${r+1}`:i,"function",t,[],tn(e)))}(t,r)),e}default:return[]}}(n,void 0,!1))}return t.push(...function(e,t){let r=e.text.split("\n"),n=r.length;if(0===n)return[];let s=new Uint8Array(n+2);for(let e of t){let t=Math.max(1,e.startLine),r=Math.min(n,e.endLine);for(let e=t;e<=r;e++)s[e]=1}let o=[],l=(e,t)=>{let n=!1;for(let s=e;s<=t;s++){let e=r[s-1];if(e&&e.trim().length>0){n=!0;break}}if(!n)return;let s=r.slice(e-1,t).join("\n");o.push({qualifiedName:`__code_${e}_${t}__`,name:"code",kind:"unknown",startLine:e,endLine:t,contentHash:e9(e7(s)),children:[]})},a=-1;for(let e=1;e<=n;e++)s[e]?a>=0&&(l(a,e-1),a=-1):a<0&&(a=e);return a>=0&&l(a,n),o}(e,t)),t}(n.rootNode)}finally{n.delete()}}async function tx(e,t,r,n,s){let o=new Set;if(e!==t)for(let r of y(n?"":e,s?"":t))"added"===r.type&&void 0!==r.newLineNum&&o.add(r.newLineNum);if(!ts(r))return{addedLines:o};let[l,a]=await Promise.all([tm(n?"":e,r),tm(s?"":t,r)]),i=a??[],c=function(e,t){let r=new Map;for(let t of e)r.set(t.qualifiedName,t);let n=new Map;for(let e of t)n.set(e.qualifiedName,e);let s=[];for(let e of t){let t=r.get(e.qualifiedName);t?t.contentHash!==e.contentHash&&s.push({id:`mod:${e.qualifiedName}`,changeKind:"modified",qname:e.qualifiedName}):s.push({id:`add:${e.qualifiedName}`,changeKind:"added",qname:e.qualifiedName})}for(let t of e)n.has(t.qualifiedName)||s.push({id:`del:${t.qualifiedName}`,changeKind:"deleted",qname:t.qualifiedName});return s}((l??[]).filter(tu),i.filter(tu)),d=new Set;for(let e of c)"deleted"!==e.changeKind&&d.add(e.qname);for(let e of function(e,t){if(0===t.size)return[];let r=[];for(let n of e)if(td(n)){for(let e of t)if(e>=n.startLine&&e<=n.endLine){r.push(n.qualifiedName);break}}return r}(i,o))d.add(e);return{changedQnames:d,addedLines:o}}function th({cwd:e,filePath:t,oldContent:r,newContent:o,isNew:l=!1,isDeleted:a=!1,changedFiles:i,fileGitStatusMap:c,enableComments:d=!1,onContentSearch:u,headerExtraLeft:m,headerExtraRight:x}){let[h,f]=(0,s.useState)(t);(0,s.useEffect)(()=>{f(t)},[t]);let[p,g]=(0,s.useState)(null);return(0,s.useEffect)(()=>{let n=!1;return g(null),(async()=>{try{let s=await tf(h,t,r,o,l,a,i,c,e);if(n||!s)return;let d=await tx(s.oldContent,s.newContent,h,s.isNew,s.isDeleted);if(n)return;g(d)}catch(e){n||console.error("[BlockDiffViewer] projection failed:",e)}})(),()=>{n=!0}},[h,t,r,o,l,a,i,c,e]),(0,n.jsx)(e3,{cwd:e,highlightedFilePath:t,changedFiles:i,enableComments:d,qnameFilter:p?.changedQnames,qnameFilterFile:h,accentQnames:p?.changedQnames,accentFile:h,addedLines:p?.addedLines,addedLinesFile:h,onFocalChange:e=>e&&f(e),onContentSearch:u,headerExtraLeft:m,headerExtraRight:x})}async function tf(e,t,r,n,s,o,l,a,c){if(e===t)return{oldContent:r,newContent:n,isNew:s,isDeleted:o};if(!l.has(e))return null;let d=a?.get(e);if(!d)return null;let u=new URLSearchParams({cwd:c,file:e,type:d}),m=await i.t4.runPromiseExit((0,h.oh)(u));if("Success"!==m._tag)return null;let x=m.value;return{oldContent:x.oldContent,newContent:x.newContent,isNew:x.isNew??!1,isDeleted:x.isDeleted??!1}}function tp(e){let{refreshKey:t,className:r="h-full flex items-center justify-center p-4 bg-secondary",imgClassName:o="max-w-full max-h-full object-contain",alt:l}=e,a="absPath"in e&&"string"==typeof e.absPath,c=a?void 0:e.cwd,d=a?void 0:e.path,u=a?e.absPath:void 0,[m,h]=(0,s.useState)({kind:"loading"}),f=(0,s.useRef)(0);if((0,s.useEffect)(()=>{let e=++f.current;return h({kind:"loading"}),(async()=>{if(a){if(e!==f.current)return;h({kind:"ready",etag:null,size:0});return}let t=await i.t4.runPromiseExit((0,x.r6)(c,d));if(e!==f.current)return;if("Failure"===t._tag){let e="Fail"===t.cause._tag?t.cause.error:null,r=e?.cause;h({kind:"error",message:r instanceof Error?r.message:"Unknown error"});return}let r=t.value;if(!r.ok)return h({kind:"error",message:`stat failed (${r.status})`});let n=r.data;n&&n.exists?"too-large"===n.category?h({kind:"too-large",size:n.size??0}):"image"!==n.category?h({kind:"error",message:`Not an image (${n.category})`}):h({kind:"ready",etag:n.etag||`t-${n.mtimeMs??Date.now()}`,size:n.size??0}):h({kind:"missing"})})(),()=>{f.current++}},[a,c,d,u,t]),"loading"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})});if("missing"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("div",{className:"text-sm text-muted-foreground",children:"File not found"})});if("too-large"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Image too large to preview (",Math.round(m.size/1024/1024)," MB)"]})});if("error"===m.kind)return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("div",{className:"text-sm text-red-11",children:m.message})});let p=a?`/api/file?path=${encodeURIComponent(u)}&raw=true`:`/api/files/read?cwd=${encodeURIComponent(c)}&path=${encodeURIComponent(d)}&v=${encodeURIComponent(m.etag)}`;return(0,n.jsx)("div",{className:r,children:(0,n.jsx)("img",{src:p,alt:l??(d||u),className:o})})}function tg({cwd:e,selected:t,diff:r,showMarkdownPreview:l,setShowMarkdownPreview:a,changedFiles:i,fileGitStatusMap:c,onContentSearch:d,locateInTree:u,jsonPreview:m,setJsonPreview:x,jsonPreviewSearch:h,jsonPreviewPreRef:f}){let{t:p}=(0,o.Bd)(),[g,b]=(0,s.useState)("file"),[v,j]=(0,s.useState)("compact"),w=t.file.path,y=(0,ea.u)(w),{state:N}=eB(e,w),C=(0,s.useMemo)(()=>{if("ready"===N.state)return N.data.functions.filter(ez).map(e=>({name:e.name,startLine:e.startLine,endLine:e.endLine,params:e.params}))},[N]);return(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[y||"map"!==g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs font-mono text-muted-foreground",children:w}),(0,n.jsx)(eD.m,{content:p("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(`${e}/${w}`),(0,k.oR)(p("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(eD.m,{content:p("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(w)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),(0,n.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded ${"staged"===t.type?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===t.type?p("fileBrowser.staged"):p("fileBrowser.unstaged")}),(0,n.jsx)("div",{className:"flex-1"}),!y&&"file"===g&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["compact","full"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),j(e)},className:`px-2 py-0.5 text-xs transition-colors ${v===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("compact"===e?"diffViewer.compact":"diffViewer.full")},e))}),!y&&(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),b(e)},className:`px-2 py-0.5 text-xs transition-colors ${g===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("file"===e?"common.file":"common.codeMap")},e))})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:y?(0,n.jsx)(tp,{cwd:e,path:w,className:"p-4 flex items-center justify-center",imgClassName:"max-w-full max-h-[60vh] object-contain",alt:w}):(0,n.jsx)(T,{oldContent:r.oldContent,newContent:r.newContent,filePath:r.filePath,isNew:r.isNew,isDeleted:r.isDeleted,cwd:e,enableComments:!0,compact:"compact"===v,symbols:C,onPreview:!r.isDeleted&&Z(w)?()=>a(!0):!r.isDeleted&&w.endsWith(".json")?()=>x({content:r.newContent,filePath:r.filePath}):void 0,previewLabel:w.endsWith(".json")?p("common.readable"):p("common.preview"),onContentSearch:d})})]}):(0,n.jsx)(th,{cwd:e,filePath:r.filePath,oldContent:r.oldContent,newContent:r.newContent,isNew:r.isNew,isDeleted:r.isDeleted,changedFiles:i,fileGitStatusMap:c,enableComments:!0,onContentSearch:d,headerExtraLeft:({focalFile:t})=>{if(!t)return null;let r=c.get(t);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eD.m,{content:p("common.copyAbsPath"),children:(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${e}/${t}`),(0,k.oR)(p("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})}),(0,n.jsx)(eD.m,{content:p("fileBrowser.locateInTree"),children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),u(t)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})}),r&&(0,n.jsx)("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${"staged"===r?"bg-green-9/15 text-green-11 dark:bg-green-9/25":"bg-amber-9/15 text-amber-11 dark:bg-amber-9/25"}`,children:"staged"===r?p("fileBrowser.staged"):p("fileBrowser.unstaged")})]})},headerExtraRight:()=>(0,n.jsx)("div",{className:"flex items-center gap-0.5 rounded border border-border overflow-hidden",children:["file","map"].map(e=>(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),b(e)},className:`px-2 py-0.5 text-[11px] transition-colors ${g===e?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,children:p("file"===e?"common.file":"common.codeMap")},e))})}),l&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>a(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(ex,{content:r.newContent,filePath:r.filePath,cwd:e,onClose:()=>a(!1)})})}),m&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>x(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-[90%] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono truncate",children:m.filePath}),(0,n.jsx)("button",{onClick:()=>x(null),className:"p-1 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)(et,{search:h}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4 bg-[#0d1117]",children:(0,n.jsx)("pre",{ref:f,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(m.content)})})]})})]})}function tb({branches:e,selectedBranch:t,onSelect:r,isLoading:l,pinnedBranches:a=[]}){let{t:i}=(0,o.Bd)(),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(""),x=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.useEffect)(()=>{c&&h.current&&h.current.focus()},[c]);let f=u.toLowerCase(),p=new Set([...e?.local||[],...e?.remote||[]]),g=a.filter(e=>p.has(e)&&e.toLowerCase().includes(f)),b=new Set(g),v=e?.local.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],j=e?.remote.filter(e=>!b.has(e)&&e.toLowerCase().includes(f))||[],w=e=>{r(e),d(!1),m("")};return(0,n.jsxs)("div",{className:"relative",ref:x,children:[(0,n.jsxs)("button",{onClick:()=>d(!c),disabled:l,className:"w-full px-3 py-1.5 text-sm border border-border rounded bg-card text-foreground text-left flex items-center justify-between hover:border-slate-6 dark:hover:border-slate-6 transition-colors",children:[(0,n.jsxs)("span",{className:"truncate flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),t||i("git.selectBranch"),e?.current===t&&(0,n.jsxs)("span",{className:"text-xs text-green-11",children:["(",i("git.currentBranch"),")"]})]}),(0,n.jsx)("svg",{className:`w-4 h-4 text-slate-9 transition-transform ${c?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),c&&(0,n.jsxs)("div",{className:"absolute z-50 mt-1 w-full bg-card border border-border rounded-lg shadow-lg max-h-80 flex flex-col",children:[(0,n.jsx)("div",{className:"p-2 border-b border-border",children:(0,n.jsx)("input",{ref:h,type:"text",value:u,onChange:e=>m(e.target.value),placeholder:i("git.searchBranch"),className:"w-full px-2 py-1 text-sm border border-border rounded bg-secondary text-foreground placeholder-slate-9"})}),(0,n.jsxs)("div",{className:"overflow-y-auto flex-1",children:[g.length>0&&g.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},`pinned-${r}`)),v.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:i("git.localBranches")}),v.map(r=>(0,n.jsxs)("div",{onClick:()=>w(r),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${r===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:r}),r===e?.current&&(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:i("git.currentBranch")}),r===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},r))]}),j.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground bg-secondary sticky top-0",children:i("git.remoteBranches")}),j.map(e=>(0,n.jsxs)("div",{onClick:()=>w(e),className:`px-3 py-1.5 text-sm cursor-pointer flex items-center gap-2 ${e===t?"bg-brand/10 text-brand":"hover:bg-accent text-foreground"}`,children:[(0,n.jsx)("span",{className:"truncate flex-1",children:e}),e===t&&(0,n.jsx)("svg",{className:"w-4 h-4 text-brand flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]},e))]}),0===g.length&&0===v.length&&0===j.length&&(0,n.jsx)("div",{className:"px-3 py-4 text-sm text-muted-foreground text-center",children:i("git.noMatchingBranches")})]})]})]})}function tv(e){let t=e.split(".").pop()?.toLowerCase();return t?["ts","tsx","js","jsx","mjs","cjs"].includes(t)?"typescript":["py","pyi"].includes(t)?"python":null:null}let tj=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return await r.json()},catch:t=>new eT.uV({message:`${e} failed`,cause:t})});function tw(e){return e.replace(/^\([^)]+\)\s*/,"")}let ty=(0,s.forwardRef)(function({displayString:e,documentation:t,x:r,y:l,container:a,onMouseEnter:i,onMouseLeave:c,onFindReferences:d,onSearch:u},m){let{t:x}=(0,o.Bd)(),h=(0,s.useRef)(null);(0,s.useImperativeHandle)(m,()=>h.current,[]);let f=a.getBoundingClientRect(),p=r-f.left,g=l-f.top,b=(0,s.useMemo)(()=>tw(e),[e]),v=(0,s.useMemo)(()=>(function(e){let t,r=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b/g,s=[],o=0,l=0,a=/\b(const|let|var|function|class|interface|type|enum|import|export|async|await|return|new|typeof|keyof|extends|implements|readonly|static|public|private|protected|abstract|declare|namespace|module|void|never|undefined|null|true|false|any|unknown|string|number|boolean|bigint|symbol|object)\b|"[^"]*"|'[^']*'|\b\d+\b/g;for(;null!==(t=a.exec(e));){t.index>o&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o,t.index)},l++));let a=t[0];/^["']/.test(a)?s.push((0,n.jsx)("span",{className:"text-green-400",children:a},l++)):/^\d+$/.test(a)?s.push((0,n.jsx)("span",{className:"text-orange-300",children:a},l++)):r.test(a)?(r.lastIndex=0,s.push((0,n.jsx)("span",{className:"text-pink-400",children:a},l++))):s.push((0,n.jsx)("span",{className:"text-foreground",children:a},l++)),o=t.index+a.length}return o<e.length&&s.push((0,n.jsx)("span",{className:"text-foreground",children:e.slice(o)},l++)),s})(b),[b]);return(0,s.useEffect)(()=>{if(!h.current)return;let e=h.current,t=a.getBoundingClientRect(),n=e.getBoundingClientRect(),s=r-t.left,o=l-t.top;s+n.width>t.width-8&&(s=t.width-n.width-8),s<8&&(s=8),o+n.height>t.height-8&&(o=o-n.height-24),e.style.left=`${s}px`,e.style.top=`${o}px`},[r,l,a]),(0,n.jsxs)("div",{ref:h,className:"absolute z-[200] max-w-lg bg-card border border-border rounded-lg shadow-xl px-3 py-2 pointer-events-none",style:{left:p,top:g},children:[(0,n.jsx)("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all leading-relaxed",children:v}),t&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:t})]}),(d||u)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"border-t border-border my-1.5"}),(0,n.jsxs)("div",{className:"flex items-center gap-3 pointer-events-auto",onMouseEnter:i,onMouseLeave:c,children:[d&&(0,n.jsx)("button",{onClick:d,className:"text-[11px] text-brand hover:underline cursor-pointer",children:x("hoverTooltip.findReferences")}),u&&(0,n.jsx)("button",{onClick:()=>u(function(e){let t=tw(e),r=t.match(/^(?:function|const|let|var|class|interface|type|enum|async function)\s+([a-zA-Z_$][\w$]*)/);if(r)return r[1];let n=e.match(/\([^)]+\)\s+(?:[\w$]+\.)*([a-zA-Z_$][\w$]*)/);if(n)return n[1];let s=t.match(/([a-zA-Z_$][\w$]*)/);return s?s[1]:t.split(/[(\s:]/)[0]}(e)),className:"text-[11px] text-brand hover:underline cursor-pointer",children:x("hoverTooltip.search")})]})]})]})});function tk({references:e,loading:t,onSelect:r,onClose:l}){let{t:a}=(0,o.Bd)(),i=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,C.kS)();if(t!==l.current)return;let o=new Map;for(let t=0;t<e.length;t++){let r=e[t];if(!r.lineText)continue;let l=(0,C.sQ)(r.file);if("text"!==l)try{let e=n.codeToTokens(r.lineText,{lang:l,theme:s}),a=(0,C.b8)(e.tokens[0]||[]);a&&o.set(t,a)}catch{}}t===l.current&&r(o)})()},[e,n]),t}(e),c=[],d=new Map;for(let t=0;t<e.length;t++){let r=e[t],n=d.get(r.file);void 0===n&&(n=c.length,d.set(r.file,n),c.push({file:r.file,items:[]})),c[n].items.push({ref:r,idx:t})}return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[a("references.title")," ",!t&&`(${e.length})`]}),(0,n.jsx)("button",{onClick:l,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("references.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:a("references.notFound")}):c.map(({file:e,items:t})=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:e}),t.map(({ref:e,idx:t})=>(0,n.jsxs)("button",{onClick:()=>r(e),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:e.line}),i.has(t)?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:i.get(t)}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:e.lineText||""})]},`${e.line}-${e.column}-${t}`))]},e))})]})}function tN({results:e,loading:t,totalMatches:r,onSelect:l,onClose:a}){let{t:i}=(0,o.Bd)(),c=function(e){let[t,r]=(0,s.useState)(new Map),[n,o]=(0,s.useState)(!1),l=(0,s.useRef)(0);return(0,s.useEffect)(()=>{let e=()=>o(document.documentElement.classList.contains("dark"));e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),(0,s.useEffect)(()=>{if(0===e.length)return void queueMicrotask(()=>r(new Map));let t=++l.current,s=n?"github-dark":"github-light";(async()=>{let n=await (0,C.kS)(),o=new Map;for(let t of e){let e=(0,C.sQ)(t.path);if("text"!==e)for(let r of t.matches){if(!r.content)continue;let l=`${t.path}:${r.lineNumber}`;try{let t=n.codeToTokens(r.content,{lang:e,theme:s}),a=(0,C.b8)(t.tokens[0]||[]);a&&o.set(l,a)}catch{}}}t===l.current&&r(o)})()},[e,n]),t}(e);return(0,n.jsxs)("div",{className:"border-t border-border bg-secondary flex flex-col",style:{height:"300px"},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-1.5 bg-card/50 border-b border-border flex-shrink-0",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[i("searchResults.title")," ",!t&&i("searchResults.nMatches",{count:r})]}),(0,n.jsx)("button",{onClick:a,className:"p-0.5 rounded hover:bg-accent text-muted-foreground",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-auto",children:t?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("searchResults.searching")}):0===e.length?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:i("searchResults.noResults")}):e.map(e=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 py-1 text-xs text-muted-foreground font-medium bg-card/30 sticky top-0",children:e.path}),e.matches.map((t,r)=>{let s=`${e.path}:${t.lineNumber}`,o=c.get(s);return(0,n.jsxs)("button",{onClick:()=>l(e.path,t.lineNumber),className:"w-full text-left px-3 py-0.5 hover:bg-accent/50 flex items-baseline gap-2 group",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground font-mono font-variant-tabular flex-shrink-0 w-10 text-right",children:t.lineNumber}),o?(0,n.jsx)("span",{className:"text-sm font-mono truncate",dangerouslySetInnerHTML:{__html:o}}):(0,n.jsx)("span",{className:"text-sm font-mono text-foreground truncate",children:t.content||""})]},`${t.lineNumber}-${r}`)})]},e.path))})]})}var tC=r(63728);function tS({onClose:e,cwd:t,initialTab:r="tree",tabSwitchTrigger:l,initialSearchQuery:a,searchQueryTrigger:c}){var d;let f,p,g,v,j,w,{t:y}=(0,o.Bd)(),{activeView:N}=(0,tC.R8)(),[C,S]=(0,s.useState)(r),[L,E]=(0,s.useState)("code"),M=(0,s.useRef)(null),$=(0,s.useRef)(!1),[P,R]=(0,s.useState)(null),[B,F]=(0,s.useState)(null),[I,O]=(0,s.useState)(!1),q=(0,s.useRef)(1),V=(0,s.useRef)(null),[K,U]=(0,s.useState)(null),J=(0,s.useRef)(null),[Q,X]=(0,s.useState)({isDirty:!1,isSaving:!1}),[Y,G]=(0,s.useState)(!1),[en,es]=(0,s.useState)(!1),[ei,ec]=(0,s.useState)(null),ed=(0,s.useRef)(null),eu=ee(ed),em=(0,s.useRef)(null),eh=ee(em),eb=function(e){let[t,r]=(0,s.useState)(!1);return{goToDefinition:(0,s.useCallback)(async(t,n,s)=>{r(!0);let o=await i.t4.runPromiseExit(tj("/api/lsp/definition",{cwd:e,filePath:t,line:n,column:s}));return(r(!1),"Success"===o._tag)?o.value.definitions??[]:(console.error("[useLSP] definition error:",o.cause),[])},[e]),loading:t}}(t),ev=function(e){let[t,r]=(0,s.useState)(null),n=(0,s.useRef)(null),o=(0,s.useRef)(null),l=(0,s.useRef)(0),a=(0,s.useRef)(!1),c=(0,s.useRef)(null),d=(0,s.useRef)({x:0,y:0}),u=(0,s.useCallback)(e=>{c.current=e},[]);(0,s.useEffect)(()=>{let e=e=>{d.current.x=e.clientX,d.current.y=e.clientY};return document.addEventListener("mousemove",e),()=>document.removeEventListener("mousemove",e)},[]);let m=(0,s.useRef)(!1),x=(0,s.useRef)(null),h=(0,s.useCallback)(()=>{let e=c.current;e&&m.current&&(e.style.pointerEvents="none"),m.current=!1,x.current&&(c.current?.removeEventListener("mouseleave",x.current),x.current=null)},[]),f=(0,s.useCallback)(()=>{let e=c.current;if(!e||m.current)return;m.current=!0,a.current=!0,e.style.pointerEvents="auto";let t=()=>{a.current=!1,h(),l.current++,r(null)};x.current=t,e.addEventListener("mouseleave",t)},[h]),p=(0,s.useCallback)((t,s,a,c)=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current);let d=++l.current;n.current=setTimeout(async()=>{let n=await i.t4.runPromiseExit(tj("/api/lsp/hover",{cwd:e,filePath:t,line:s,column:a}));if(d!==l.current||"Success"!==n._tag)return;let o=n.value.hover;o&&o.displayString&&r({...o,x:c.x,y:c.y,filePath:t,line:s,column:a})},300)},[e]),g=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),l.current++,o.current=setTimeout(function(){if(a.current)return;let e=c.current;if(e){let t=e.getBoundingClientRect(),{x:r,y:n}=d.current;if(r>=t.left&&r<=t.right&&n>=t.top&&n<=t.bottom)return void f()}r(null)},150)},[f]),b=(0,s.useCallback)(()=>{a.current=!0,o.current&&clearTimeout(o.current)},[]),v=(0,s.useCallback)(()=>{a.current=!1,l.current++,r(null)},[]),j=(0,s.useCallback)(()=>{n.current&&clearTimeout(n.current),o.current&&clearTimeout(o.current),a.current=!1,h(),l.current++,r(null)},[h]);return(0,s.useEffect)(()=>{t||h()},[t,h]),{hoverInfo:t,onTokenMouseEnter:p,onTokenMouseLeave:g,onCardMouseEnter:b,onCardMouseLeave:v,clearHover:j,setTooltipEl:u}}(t),ej=function(e){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(!1),[l,a]=(0,s.useState)(!1);return{references:t,loading:n,visible:l,findReferences:(0,s.useCallback)(async(t,n,s)=>{o(!0),a(!0);let l=await i.t4.runPromiseExit(tj("/api/lsp/references",{cwd:e,filePath:t,line:n,column:s}));"Success"===l._tag?r(l.value.references??[]):(console.error("[useLSP] references error:",l.cause),r([])),o(!1)},[e]),closeReferences:(0,s.useCallback)(()=>{a(!1),r([])},[])}}(t),ew=(f=(0,s.useRef)([]),p=(0,s.useRef)([]),g=(0,s.useCallback)(e=>{f.current.push(e),f.current.length>50&&(f.current=f.current.slice(-50)),p.current=[]},[]),v=(0,s.useCallback)(e=>{if(0===f.current.length)return null;let t=f.current.pop();return p.current.push(e),p.current.length>50&&(p.current=p.current.slice(-50)),t},[]),j=(0,s.useCallback)(e=>{if(0===p.current.length)return null;let t=p.current.pop();return f.current.push(e),f.current.length>50&&(f.current=f.current.slice(-50)),t},[]),{push:g,goBack:v,goForward:j,canGoBack:(0,s.useCallback)(()=>f.current.length>0,[]),canGoForward:(0,s.useCallback)(()=>p.current.length>0,[])}),ey=(0,eg.F)(),ek=function({cwd:e}){let[t,r]=(0,s.useState)([]),[n,o]=(0,s.useState)(null),[l,a]=(0,s.useState)(new Set),[c,d]=(0,s.useState)([]),[u,m]=(0,s.useState)(null),[h,f]=(0,s.useState)(null),[p,g]=(0,s.useState)(new Set),[b,v]=(0,s.useState)(null),[j,w]=(0,s.useState)(""),[y,k]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),[S,L]=(0,s.useState)(!1),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(null),P=(0,s.useRef)(null),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(null),[D,A]=(0,s.useState)("center"),[_,W]=(0,s.useState)(null),[z,H]=(0,s.useState)(null),[O,q]=(0,s.useState)(!1),[V,K]=(0,s.useState)([]),[U,J]=(0,s.useState)(!1),[Q,X]=(0,s.useState)(null),[Y,Z]=(0,s.useState)(null),[G,ee]=(0,s.useState)(!1),[et,er]=(0,s.useState)(!1),en=(0,s.useMemo)(()=>c.map(e=>e.path).filter(Boolean),[c]),es=(0,s.useMemo)(()=>(0,ea.v3)(en),[en]),eo=(0,s.useMemo)(()=>new Set((0,ea.tW)(es)),[es]),el=(0,s.useMemo)(()=>j?n?(0,ea.KH)(n,j,y):(0,ea.q3)(t,j,y):null,[t,n,j,y]);(0,s.useEffect)(()=>{if(!el||0===el.size)return void v(null);let e=new Set;if(n){let t=new Set(n);for(let r of el)t.has(r)||e.add(r)}else{let r=t=>{for(let n of t)n.isDirectory&&n.children&&el.has(n.path)&&(e.add(n.path),r(n.children))};r(t)}v(e)},[el,t,n]);let ei=b??p,ec=(0,s.useRef)(null),ed=(0,s.useCallback)(t=>{ec.current&&clearTimeout(ec.current),ec.current=setTimeout(()=>{i.t4.runFork((0,x.Ft)(e,Array.from(t)).pipe(eM.tapError(e=>eM.sync(()=>console.error("Error saving expanded paths:",e))),eM.orElse(()=>eM.void)))},500)},[e]),eu=(0,s.useCallback)(async()=>{L(!0),$(null),await i.t4.runPromise((0,x.mP)(e).pipe(eM.match({onSuccess:e=>{e.error?$(e.error):(r(e.files??[]),e.expandedPaths&&Array.isArray(e.expandedPaths)&&g(new Set(e.expandedPaths)))},onFailure:e=>{console.error("Error loading files:",e),$("Failed to load files")}}))),L(!1)},[e]),em=(0,s.useCallback)(()=>{i.t4.runPromise((0,x.DZ)(e).pipe(eM.match({onSuccess:e=>{e.paths&&o(e.paths)},onFailure:e=>{console.error("Error loading file index:",e)}})))},[e]),ex=(0,s.useCallback)(async t=>{a(e=>new Set([...e,t])),await i.t4.runPromise((0,x.gZ)(e,t).pipe(eM.match({onSuccess:e=>{e.children&&r(r=>{if(!t){let t=new Map(r.map(e=>[e.path,e]));return e.children.map(e=>{let r=t.get(e.path);return r?.children&&e.isDirectory?{...e,children:r.children}:e})}let n=structuredClone(r),s=(0,ea.MB)(n,t);return s&&(s.children=e.children),n})},onFailure:e=>{console.error("Error loading directory:",e)}}))),a(e=>{let r=new Set(e);return r.delete(t),r})},[e]),eh=(0,s.useRef)(l);eh.current=l,(0,s.useEffect)(()=>{for(let e of b??p){let r=(0,ea.MB)(t,e);r&&r.isDirectory&&!r.children&&!eh.current.has(e)&&ex(e)}},[t,p,b,ex]);let ef=(0,s.useCallback)(async()=>{await i.t4.runPromise((0,x.r9)(e).pipe(eM.match({onSuccess:e=>d(e.files??[]),onFailure:e=>console.error("Error loading recent files:",e)})))},[e]),ep=(0,s.useCallback)(async t=>{d(e=>{let r=e.filter(e=>e.path!==t);return[{path:t},...r].slice(0,15)}),await i.t4.runPromise((0,x.YW)(e,t).pipe(eM.tapError(e=>eM.sync(()=>console.error("Error adding to recent files:",e))),eM.orElse(()=>eM.void)))},[e]),eg=(0,s.useCallback)((t,r,n,s)=>{d(e=>e.map(e=>e.path===t?{...e,scrollLine:r,cursorLine:n,cursorCol:s}:e)),i.t4.runFork((0,x.YW)(e,t,{scrollLine:r,cursorLine:n,cursorCol:s}).pipe(eM.orElse(()=>eM.void)))},[e]),eb=(0,s.useCallback)(e=>c.find(t=>t.path===e),[c]),ev=(0,s.useCallback)(async t=>{let r=t||u;r&&(J(!0),X(null),await i.t4.runPromise((0,x.eE)(e,r).pipe(eM.match({onSuccess:e=>{e.error?X(e.error):K(e.blame??[])},onFailure:e=>{console.error("Error loading blame:",e),X("Failed to load blame info")}}))),J(!1))},[e,u]),ej=(0,s.useCallback)(async t=>{M(!0),f(null),q(!1),K([]),X(null),Z(null);let r=eM.gen(function*(){let r=yield*(0,x.r6)(e,t);if(!r.ok)return{type:"error",message:r.data?.error||"Failed to stat file"};let n=r.data??{};if(!n.exists)return{type:"error",message:"File not found"};if("dir"===n.kind)return{type:"error",message:"Path is a directory"};switch(n.category){case"image":return{type:"image",size:n.size,mtime:n.mtimeMs,...n.isSymlink?{isSymlink:!0,symlinkTarget:n.symlinkTarget}:{}};case"binary":return{type:"binary",message:"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};case"too-large":return{type:"error",message:"File too large to preview",size:n.size,mtime:n.mtimeMs};default:{let r=yield*(0,x.K9)(e,t);if(409===r.status)return{type:"binary",message:r.data?.error||"Cannot preview binary file",size:n.size,mtime:n.mtimeMs};if(!r.ok)return{type:"error",message:r.data?.error||"Failed to load file"};let s=r.data??{};return{type:"text",content:s.content,size:s.size,mtime:s.mtimeMs,...s.isSymlink?{isSymlink:!0,symlinkTarget:s.symlinkTarget}:{}}}}});await i.t4.runPromise(r.pipe(eM.match({onSuccess:e=>f(e),onFailure:e=>{console.error("Error loading file content:",e),f({type:"error",message:"Failed to load file"})}}))),ep(t),ev(t),M(!1)},[e,ep,ev]),ew=(0,s.useCallback)(()=>{O?q(!1):(q(!0),0===V.length&&ev())},[O,V.length,ev]),ey=(0,s.useCallback)((e,t)=>{if(!e)return;if(m(e),I(t??null),null==t){let t=c.find(t=>t.path===e);t?.scrollLine?(I(t.scrollLine),A("start"),W(t.cursorLine??null),H(t.cursorCol??null)):(A("center"),W(null),H(null))}else A("center"),W(null),H(null);ej(e);let r=e.split("/");if(r.length>1){let e=[];for(let t=1;t<r.length;t++)e.push(r.slice(0,t).join("/"));g(t=>{let r=new Set(t),n=!1;for(let t of e)r.has(t)||(r.add(t),n=!0);return n&&ed(r),n?r:t})}},[ej,ed,c]),ek=(0,s.useCallback)(e=>{if(b)v(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r});else{let r=!p.has(e);if(g(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),ed(r),r}),r){let r=(0,ea.MB)(t,e);r&&r.isDirectory&&!r.children&&ex(e)}}},[b,ed,p,t,ex]);return{files:t,setFiles:r,fileIndex:n,setFileIndex:o,loadingDirs:l,expandedPaths:p,setExpandedPaths:g,searchTreeExpandedPaths:b,setSearchTreeExpandedPaths:v,effectiveExpandedPaths:ei,searchQuery:j,setSearchQuery:w,searchExactMatch:y,setSearchDirExact:k,matchedPaths:el,creatingItem:N,setCreatingItem:C,isLoadingFiles:S,fileError:T,searchInputRef:P,shouldScrollToSelected:R,setShouldScrollToSelected:B,targetLineNumber:F,setTargetLineNumber:I,targetScrollAlign:D,setTargetScrollAlign:A,initialCursorLine:_,initialCursorCol:z,setInitialCursorLine:W,setInitialCursorCol:H,selectedPath:u,setSelectedPath:m,fileContent:h,setFileContent:f,isLoadingContent:E,recentFiles:c,recentFilePaths:en,setRecentFiles:d,recentFilesTree:es,recentTreeDirPaths:eo,showBlame:O,setShowBlame:q,blameLines:V,isLoadingBlame:U,blameError:Q,blameSelectedCommit:Y,setBlameSelectedCommit:Z,showMarkdownPreview:G,setShowMarkdownPreview:ee,showEditor:et,setShowEditor:er,saveExpandedPaths:ed,loadFiles:eu,loadFileIndex:em,loadDirectory:ex,loadRecentFiles:ef,addToRecentFiles:ep,updateRecentFilePosition:eg,getRecentFilePosition:eb,loadFileContent:ej,loadBlame:ev,handleToggleBlame:ew,handleSelectFile:ey,handleToggle:ek}}({cwd:t});d=ek.selectedPath,w=(0,s.useRef)(null),(0,s.useEffect)(()=>{d&&d!==w.current&&tv(d)&&(w.current=d,i.t4.runFork(tj("/api/lsp/warmup",{cwd:t,filePath:d}).pipe(eM.asVoid).pipe(eM.orElse(()=>eM.void))))},[t,d]);let eN=function({cwd:e,onSearchComplete:t}){let[r,n]=(0,s.useState)(""),[o,l]=(0,s.useState)([]),[a,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(new Set),[h,f]=(0,s.useState)({caseSensitive:!1,wholeWord:!1,regex:!1,fileType:""}),[p,g]=(0,s.useState)(null),b=(0,s.useRef)(null),v=(0,s.useCallback)(async r=>{let n=r.trim();if(!n){l([]),g(null);return}if(n.length<2)return void u(z.A.t("fileBrowser.searchMinChars"));c(!0),u(null);let s=new URLSearchParams({cwd:e,q:r,caseSensitive:String(h.caseSensitive),wholeWord:String(h.wholeWord),regex:String(h.regex),fileType:h.fileType}),o=eM.tryPromise({try:async()=>{let e=await fetch(`/api/files/search?${s}`),t=await e.json();if(t.error)throw Error(t.error);return t},catch:e=>new eT.uV({message:"content search failed",cause:e})});await i.t4.runPromise(o.pipe(eM.match({onSuccess:e=>{l(e.results),g({totalFiles:e.totalFiles,totalMatches:e.totalMatches,truncated:e.truncated}),x(new Set(e.results.map(e=>e.path))),e.results.length>0&&t?.()},onFailure:e=>{u(e.cause instanceof Error?e.cause.message:"Search failed"),l([])}}))),c(!1)},[e,h,t]);return{contentSearchQuery:r,setContentSearchQuery:n,contentSearchResults:o,isSearching:a,searchError:d,searchExpandedPaths:m,searchOptions:h,setSearchOptions:f,searchStats:p,contentSearchInputRef:b,performContentSearch:v,handleSearchToggle:(0,s.useCallback)(e=>{x(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[])}}({cwd:t,onSearchComplete:()=>G(!0)}),eC=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(!1),[a,c]=(0,s.useState)(null),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(null),[f,p]=(0,s.useState)(!1),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(new Set),[w,y]=(0,s.useState)([]),[N,C]=(0,s.useState)([]),S=(0,s.useMemo)(()=>{let e=new Set(_(w));for(let t of g)e.delete(t);return e},[w,g]),L=(0,s.useMemo)(()=>{let e=new Set(_(N));for(let t of v)e.delete(t);return e},[N,v]),[E,M]=(0,s.useState)(!1),[T,$]=(0,s.useState)(0),P=(0,s.useCallback)(async()=>{l(!0),c(null),await i.t4.runPromise((0,h.lv)(e).pipe(eM.match({onSuccess:e=>{n(e);let t=A(e.staged),r=A(e.unstaged);y(t),C(r)},onFailure:e=>{c(e.cause instanceof Error?e.cause.message:"Unknown error")}}))),l(!1)},[e]),R=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),B=(0,s.useCallback)(e=>{j(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),F=(0,s.useCallback)((e,r)=>{u({file:e,type:r}),t(e.path)},[t]),I=(0,s.useCallback)(async(e,t,r,n)=>{let s=await i.t4.runPromiseExit(e);"Success"===s._tag?(await P(),(0,k.oR)(t,"success")):(console.error(r,s.cause),(0,k.oR)(n,"error"))},[P]),D=(0,s.useCallback)(t=>I((0,h.Iz)(e,[t]),z.A.t("toast.staged"),"Error staging file:",z.A.t("toast.stageFailed")),[e,I]),W=(0,s.useCallback)(t=>I((0,h.X0)(e,[t]),z.A.t("toast.unstaged"),"Error unstaging file:",z.A.t("toast.unstageFailed")),[e,I]),H=(0,s.useCallback)(async t=>{0!==t.length&&await I((0,h.Iz)(e,t),z.A.t("toast.stagedNFiles",{count:t.length}),"Error staging files:",z.A.t("toast.stageFailed"))},[e,I]),O=(0,s.useCallback)(async t=>{0!==t.length&&await I((0,h.X0)(e,t),z.A.t("toast.unstagedNFiles",{count:t.length}),"Error unstaging files:",z.A.t("toast.unstageFailed"))},[e,I]),q=(0,s.useCallback)(async t=>{if(0===t.length)return;let r=t.filter(e=>"untracked"===e.status).map(e=>e.path),n=t.filter(e=>"untracked"!==e.status).map(e=>e.path),s=eM.gen(function*(){r.length>0&&(yield*(0,h.Ub)(e,r,!0)),n.length>0&&(yield*(0,h.Ub)(e,n,!1))});await I(s,z.A.t("toast.discardedNFiles",{count:t.length}),"Error discarding files:",z.A.t("toast.discardFailed"))},[e,I]),V=(0,s.useCallback)(async()=>{r?.unstaged.length&&await I((0,h.Iz)(e,r.unstaged.map(e=>e.path)),z.A.t("toast.stagedNFiles",{count:r.unstaged.length}),"Error staging all files:",z.A.t("toast.stageFailed"))},[e,r,I]),K=(0,s.useCallback)(async()=>{r?.staged.length&&await I((0,h.X0)(e,r.staged.map(e=>e.path)),z.A.t("toast.unstagedNFiles",{count:r.staged.length}),"Error unstaging all files:",z.A.t("toast.unstageFailed"))},[e,r,I]),U=(0,s.useCallback)(async t=>{let r="untracked"===t.status;await I((0,h.Ub)(e,[t.path],r),r?z.A.t("toast.deletedFile"):z.A.t("toast.discardedChanges"),"Error discarding file:",z.A.t("toast.discardFailed"))},[e,I]),J=(0,s.useCallback)(async()=>{if(!r?.unstaged.length||!await (0,k.lJ)(z.A.t("git.discardAllConfirm",{count:r.unstaged.length}),{danger:!0}))return;let t=r.unstaged.filter(e=>"untracked"===e.status).map(e=>e.path),n=r.unstaged.filter(e=>"untracked"!==e.status).map(e=>e.path),s=r.unstaged.length,o=eM.gen(function*(){n.length>0&&(yield*(0,h.Ub)(e,n,!1)),t.length>0&&(yield*(0,h.Ub)(e,t,!0))});await I(o,z.A.t("toast.discardedNFiles",{count:s}),"Error discarding all:",z.A.t("toast.discardFailed"))},[e,r,I]);return(0,s.useEffect)(()=>{d?(p(!0),i.t4.runPromiseExit((0,h.w2)(e,d.file.path,d.type)).then(e=>{"Success"===e._tag?x(e.value):console.error("Error fetching diff:",e.cause),p(!1)})):x(null)},[d,e,T]),{status:r,setStatus:n,statusLoading:o,statusError:a,statusSelectedFile:d,statusDiff:m,statusDiffLoading:f,stagedExpandedPaths:S,unstagedExpandedPaths:L,stagedTree:w,setStagedTree:y,unstagedTree:N,setUnstagedTree:C,showStatusDiffPreview:E,setShowStatusDiffPreview:M,fetchStatus:P,handleStagedToggle:R,handleUnstagedToggle:B,handleStatusFileSelect:F,handleStage:D,handleUnstage:W,handleStageFiles:H,handleUnstageFiles:O,handleDiscardFiles:q,handleStageAll:V,handleUnstageAll:K,handleDiscardFile:U,handleDiscardAll:J,refreshDiff:(0,s.useCallback)(()=>$(e=>e+1),[])}}({cwd:t,addToRecentFiles:ek.addToRecentFiles}),eS=(0,s.useMemo)(()=>{let e=new Set;if(eC.status){for(let t of eC.status.staged)e.add(t.path);for(let t of eC.status.unstaged)e.add(t.path)}return e},[eC.status]),eL=(0,s.useMemo)(()=>{let e=new Map;if(eC.status){for(let t of eC.status.staged)e.set(t.path,"staged");for(let t of eC.status.unstaged)e.set(t.path,"unstaged")}return e},[eC.status]),eE=function({cwd:e,addToRecentFiles:t}){let[r,n]=(0,s.useState)(null),[o,l]=(0,s.useState)(""),[a,c]=(0,s.useState)([]),[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)([]),[f,p]=(0,s.useState)([]),[g,b]=(0,s.useState)(new Set),[v,j]=(0,s.useState)(null),[w,y]=(0,s.useState)(null),[k,N]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(!1),[M,T]=(0,s.useState)(!0),[$,P]=(0,s.useState)(!1),[R,B]=(0,s.useState)(!1),[F,I]=(0,s.useState)(null),D=(0,s.useRef)(null),[W,H]=(0,s.useState)(null),[O,q]=(0,s.useState)(!1),[V,K]=(0,s.useState)(""),[U,J]=(0,s.useState)(""),[Q,X]=(0,s.useState)([]),[Y,Z]=(0,s.useState)([]),[G,ee]=(0,s.useState)(new Set),[et,er]=(0,s.useState)(null),[en,es]=(0,s.useState)(null),[eo,el]=(0,s.useState)(!1),[ei,ec]=(0,s.useState)(!1),ed=(0,s.useCallback)(()=>{N(!0),I(null),i.t4.runPromise((0,h.r4)(e).pipe(eM.match({onSuccess:e=>{e.local&&e.current?(n(e),l(e.current),e.upstream&&K(e.upstream)):(I(z.A.t("git.cannotGetBranches")),n(null))},onFailure:e=>{console.error(e),"NotFoundError"===e._tag?I(z.A.t("git.notGitRepo")):I(z.A.t("git.getBranchesFailed")),n(null)}}))).finally(()=>N(!1))},[e]),eu=(0,s.useCallback)(t=>{S(!0),u(null),x([]),p([]),j(null),y(null),T(!0),i.t4.runPromise((0,h.Bj)(e,t,ea.B_).pipe(eM.match({onSuccess:e=>{let t=e.commits||[];c(t),T(t.length>=ea.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>S(!1))},[e]),em=(0,s.useCallback)(()=>{if(L||!M||!o)return;E(!0);let t=a.length;i.t4.runPromise((0,h.Bj)(e,o,ea.B_,t).pipe(eM.match({onSuccess:e=>{let t=e.commits||[];t.length>0&&c(e=>[...e,...t]),T(t.length>=ea.B_)},onFailure:e=>{console.error(e)}}))).finally(()=>E(!1))},[e,o,a.length,L,M]),ex=(0,s.useCallback)(e=>{let{scrollTop:t,scrollHeight:r,clientHeight:n}=e.target;r-t-n<100&&em()},[em]),eh=(0,s.useCallback)(t=>{u(t),j(null),y(null),P(!0),i.t4.runPromise((0,h.Zi)(e,t.hash).pipe(eM.match({onSuccess:e=>{let t=e.files||[];x(t);let r=A(t);p(r),b(new Set(_(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>P(!1))},[e]),ef=(0,s.useCallback)(r=>{d&&(j(r),t(r.path),B(!0),i.t4.runPromise((0,h.Zi)(e,d.hash,r.path).pipe(eM.match({onSuccess:e=>y(e),onFailure:e=>{console.error(e)}}))).finally(()=>B(!1)))},[e,d,t]),ep=(0,s.useCallback)(e=>{b(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),eg=(0,s.useCallback)(t=>{el(!0),er(null),es(null),i.t4.runPromise((0,h.yy)(e,t).pipe(eM.match({onSuccess:e=>{let t=e.files||[];X(t);let r=A(t);Z(r),ee(new Set(_(r)))},onFailure:e=>{console.error(e)}}))).finally(()=>el(!1))},[e]),eb=(0,s.useCallback)(r=>{er(r),t(r.path),ec(!0),i.t4.runPromise((0,h.yy)(e,U,r.path).pipe(eM.match({onSuccess:e=>es(e),onFailure:e=>{console.error(e)}}))).finally(()=>ec(!1))},[e,U,t]),ev=(0,s.useCallback)(e=>{ee(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ej=(0,s.useCallback)(e=>{if(q(e),e){let e="origin/main";J(e),eg(e)}else X([]),Z([]),er(null),es(null),J("")},[V,eg]);return{branches:r,selectedBranch:o,setSelectedBranch:l,commits:a,setCommits:c,selectedCommit:d,setSelectedCommit:u,historyFiles:m,historyFileTree:f,historyExpandedPaths:g,historySelectedFile:v,historyFileDiff:w,isLoadingBranches:k,isLoadingCommits:C,isLoadingMore:L,hasMoreCommits:M,setHasMoreCommits:T,isLoadingHistoryFiles:$,isLoadingHistoryDiff:R,historyError:F,commitListRef:D,tooltipPos:W,loadBranches:ed,loadCommits:eu,loadMoreCommits:em,handleCommitListScroll:ex,handleSelectCommit:eh,handleSelectHistoryFile:ef,handleHistoryToggle:ep,handleCommitInfoMouseMove:(0,s.useCallback)(e=>{H({x:e.clientX,y:e.clientY})},[]),handleCommitInfoMouseLeave:(0,s.useCallback)(()=>{H(null)},[]),compareMode:O,toggleCompareMode:ej,compareBaseBranch:U,setCompareBaseBranch:J,upstreamBranch:V,compareFiles:Q,compareFileTree:Y,compareExpandedPaths:G,compareSelectedFile:et,compareFileDiff:en,isLoadingCompareFiles:eo,isLoadingCompareDiff:ei,handleSelectCompareFile:eb,handleCompareToggle:ev,loadCompareFiles:eg}}({cwd:t,addToRecentFiles:ek.addToRecentFiles}),e$=(0,s.useRef)(!1),eP=(0,s.useCallback)(e=>{ek.setFileContent(t=>t?.type==="text"?{...t,content:e}:t),ek.showEditor||(e$.current=!0,ek.setShowEditor(!0))},[ek]);(0,s.useEffect)(()=>{ek.showEditor&&e$.current&&(J.current?.markDirty(),e$.current=!1)},[ek.showEditor]);let eR=(0,s.useCallback)(e=>{ek.setShowEditor(!0)},[ek]),eB=(0,s.useCallback)(async()=>{if(!ek.fileContent||"text"!==ek.fileContent.type||!ek.fileContent.content)return;let e=await i.t4.runPromiseExit((0,x.OJ)({cwd:t,path:ek.selectedPath,content:ek.fileContent.content}));try{if("Failure"===e._tag||!e.value.ok)throw Error("Failed to save file");let t=e.value.data?.mtime;t&&ek.setFileContent(e=>e?.type==="text"?{...e,mtime:t}:e),(0,k.oR)(y("toast.savedSuccess"),"success")}catch{(0,k.oR)(y("toast.saveFailed"),"error")}},[t,ek]),eF=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e=q.current,t=V.current;e>0&&ek.updateRecentFilePosition(ek.selectedPath,e,t?t.cursorLine+1:e,t?t.cursorCol+1:1)},[ek]),eI=(0,s.useCallback)(async(e,t)=>{let r=e!==ek.selectedPath;if(r&&ek.showEditor){if(Q.isDirty&&(!await (0,k.lJ)(y("fileBrowser.saveBeforeSwitch"),{confirmText:y("fileBrowser.saveAndSwitch"),cancelText:y("common.cancel")})||(await J.current?.save(),J.current?.isDirty)))return;ek.setShowEditor(!1)}r&&eF(),ek.handleSelectFile(e,t)},[ek,eF,Q.isDirty,y]),eD=(0,s.useMemo)(()=>{let e=eN.contentSearchResults;if(0===e.length)return{files:[],expandDirs:new Set,matchMap:new Map};let t=new Map,r=[];for(let n of e)t.set(n.path,n),r.push(n.path);let n=(0,ea.v3)(r),s=new Set((0,ea.tW)(n));return{files:n,expandDirs:s,matchMap:t}},[eN.contentSearchResults]),[eA,e_]=(0,s.useState)(new Set);(0,s.useEffect)(()=>{e_(eD.expandDirs)},[eD.expandDirs]);let eW=(0,s.useCallback)(e=>{e_(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),ez=(0,s.useCallback)(e=>{if(e.isDirectory)return null;let t=eD.matchMap.get(e.path);return t?(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:t.matches.length}):null},[eD.matchMap]),eH=Y&&eN.contentSearchResults.length>0,eO=!!ek.selectedPath&&null!==tv(ek.selectedPath),eq=(0,s.useCallback)(async(e,r)=>{if(!ek.selectedPath||!eO)return;let n=await eb.goToDefinition(ek.selectedPath,e,r);if(0===n.length)return;let s=n[0],o=t.endsWith("/")?t:t+"/",l=s.file.startsWith(o)?s.file.slice(o.length):s.file;ew.push({filePath:ek.selectedPath,lineNumber:q.current}),l===ek.selectedPath?ek.setTargetLineNumber(s.line):eI(l,s.line)},[ek,t,eO,eb,ew]),eV=(0,s.useCallback)((e,t,r)=>{ek.selectedPath&&eO&&ev.onTokenMouseEnter(ek.selectedPath,e,t,r)},[ek.selectedPath,eO,ev]),eK=(0,s.useCallback)(e=>{let r=t.endsWith("/")?t:t+"/",n=e.file.startsWith(r)?e.file.slice(r.length):e.file;ek.selectedPath&&ew.push({filePath:ek.selectedPath,lineNumber:q.current}),n===ek.selectedPath?ek.setTargetLineNumber(e.line):eI(n,e.line)},[ek,t,ew]),eU=(0,s.useMemo)(()=>{if(!eC.status)return null;let e=new Map,t=e=>{switch(e){case"modified":default:return"M";case"added":return"A";case"deleted":return"D";case"renamed":return"R";case"untracked":return"?"}};for(let r of eC.status.staged)e.set(r.path,t(r.status));for(let r of eC.status.unstaged)e.set(r.path,t(r.status));return e},[eC.status]);(0,s.useEffect)(()=>{R(M.current)},[]),(0,s.useEffect)(()=>{S(r)},[r,l]),(0,s.useEffect)(()=>{a&&(S("search"),eN.setContentSearchQuery(a),eN.performContentSearch(a))},[c]);let eJ=(0,s.useCallback)(e=>{S(e),ek.setBlameSelectedCommit(null),"history"===e&&eE.selectedBranch&&eE.loadCommits(eE.selectedBranch)},[ek,eE.selectedBranch,eE.loadCommits]),eQ=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e={filePath:ek.selectedPath,lineNumber:q.current},t=ew.goBack(e);t&&(t.filePath===ek.selectedPath?ek.setTargetLineNumber(t.lineNumber):eI(t.filePath,t.lineNumber))},[ek,ew]),eX=(0,s.useCallback)(()=>{if(!ek.selectedPath)return;let e={filePath:ek.selectedPath,lineNumber:q.current},t=ew.goForward(e);t&&(t.filePath===ek.selectedPath?ek.setTargetLineNumber(t.lineNumber):eI(t.filePath,t.lineNumber))},[ek,ew]),eY=(0,s.useCallback)(async e=>{let r=e.split("/").pop()||e;"Success"===(await i.t4.runPromiseExit((0,x.__)({cwd:t,paths:[e],op:"copy"})))._tag?(0,k.oR)(y("toast.copiedName",{name:r}),"success"):(0,k.oR)(y("toast.copyFailed"),"error")},[t,y]),eZ=(0,s.useCallback)(async e=>{let r=await i.t4.runPromiseExit((0,x.dt)());if("Success"!==r._tag||!r.value.path)return void(0,k.oR)(y("toast.noFileToPaste"),"info");let n=r.value.path,s=await i.t4.runPromiseExit((0,x.Nn)({cwd:t,targetDir:e,sourceAbsPath:n}));if("Success"===s._tag)(0,k.oR)(y("toast.pastedFile",{name:s.value.newName}),"success"),ek.loadDirectory(e),ek.loadFileIndex();else{let e="Fail"===s.cause._tag?s.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:y("toast.pasteFailed");(0,k.oR)(r,"error")}},[t,ek,y]),eG=(0,s.useRef)(0);(0,s.useEffect)(()=>{let t=t=>{let r="explorer"===N;if(r&&t.ctrlKey&&!t.metaKey&&"Minus"===t.code){t.preventDefault(),t.shiftKey?eX():eQ();return}if(r&&(t.metaKey||t.ctrlKey)&&"p"===t.key){t.preventDefault(),O(e=>!e);return}if(r&&(t.metaKey||t.ctrlKey)&&"c"===t.key&&!t.shiftKey){let e=t.target?.tagName,r=window.getSelection()?.toString();if(("tree"===C||"recent"===C)&&ek.selectedPath&&!r&&"INPUT"!==e&&"TEXTAREA"!==e){t.preventDefault(),eY(ek.selectedPath);return}}if(r&&(t.metaKey||t.ctrlKey)&&"v"===t.key){let e=t.target?.tagName;if(("tree"===C||"recent"===C)&&"INPUT"!==e&&"TEXTAREA"!==e&&!t.target?.isContentEditable){t.preventDefault(),eZ((0,ea.S7)(ek.selectedPath,ek.files));return}}if(r&&(t.metaKey||t.ctrlKey)&&"f"===t.key){if(ei){t.preventDefault(),eh.open();return}if(en&&ek.selectedPath?.endsWith(".json")){t.preventDefault(),eu.open();return}}if(r&&"Escape"===t.key){if(I)return void O(!1);if(eh.isVisible)return void eh.close();if(eu.isVisible)return void eu.close();if(ei)return void ec(null);let t=Date.now();if(t-eG.current<3e3)return;eG.current=t,ej.visible?ej.closeReferences():Y?G(!1):ek.blameSelectedCommit?ek.setBlameSelectedCommit(null):ek.showBlame?ek.setShowBlame(!1):e()}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,ek.showBlame,ek.blameSelectedCommit,ek,I,ej.visible,ej.closeReferences,Y,eQ,eX,en,eu,ei,eh,C,eY,eZ,N]),(0,s.useEffect)(()=>{ek.loadFiles(),ek.loadFileIndex(),ek.loadRecentFiles(),eC.fetchStatus(),eE.loadBranches()},[]),(0,s.useEffect)(()=>{let e=()=>{eC.fetchStatus()};return window.addEventListener("git-status-changed",e),()=>window.removeEventListener("git-status-changed",e)},[eC.fetchStatus]);let e0=(0,s.useRef)(ey);(0,s.useEffect)(()=>{ey&&!e0.current&&(ek.loadFiles(),ek.loadFileIndex(),ek.loadRecentFiles(),eC.fetchStatus(),eE.loadBranches()),e0.current=ey},[ey]),(0,s.useEffect)(()=>{eE.selectedBranch&&eE.loadCommits(eE.selectedBranch)},[eE.selectedBranch,eE.loadCommits]);let e1=(0,s.useRef)(C);(0,s.useEffect)(()=>{let e=e1.current;if(e1.current=C,("tree"===C||"recent"===C)&&ek.recentFiles.length>0){let t=ek.recentFiles[0].path;ek.selectedPath&&("status"!==e&&"history"!==e||ek.selectedPath===t)||(ek.setShouldScrollToSelected(!0),eI(t))}},[C,ek.recentFiles,ek.selectedPath,eI,ek]);let e2=(0,s.useRef)(eE.selectedBranch);e2.current=eE.selectedBranch;let e5=(0,s.useRef)(ek.selectedPath);e5.current=ek.selectedPath;let e4=(0,s.useRef)(ek.fileContent?.type);e4.current=ek.fileContent?.type;let e6=(0,s.useCallback)(async e=>{try{let{data:r}=e;if(!r)return;let n=r.some(e=>"git"===e.type),s=r.some(e=>"file"===e.type),o=[];if((s||n)&&(o.push(i.t4.runPromise((0,x.mP)(t)).then(e=>{e.error||ek.setFiles(t=>(0,ea.HR)(e.files??[],t))}).catch(()=>{})),o.push(i.t4.runPromise((0,x.DZ)(t)).then(e=>{e.paths&&ek.setFileIndex(e.paths)}).catch(()=>{})),o.push(i.t4.runPromise((0,x.r9)(t)).then(e=>{ek.setRecentFiles(e.files??[])}).catch(()=>{}))),n||s){o.push(i.t4.runPromise((0,h.lv)(t)).then(e=>{eC.setStatus(e);let t=A(e.staged),r=A(e.unstaged);eC.setStagedTree(t),eC.setUnstagedTree(r)}).catch(()=>{})),eC.refreshDiff(),n&&eE.loadBranches();let e=e2.current;e&&o.push(i.t4.runPromise((0,h.Bj)(t,e,ea.B_)).then(e=>{let t=e.commits??[];eE.setCommits(t),eE.setHasMoreCommits(t.length>=ea.B_)}).catch(()=>{}))}let l=e5.current,a=e4.current;l&&"text"===a&&o.push(i.t4.runPromise((0,x.K9)(t,l)).then(e=>{let t=e.ok?e.data:null;t&&"string"==typeof t.content&&ek.setFileContent({type:"text",content:t.content,size:t.size,mtime:t.mtimeMs,...t.isSymlink?{isSymlink:!0,symlinkTarget:t.symlinkTarget}:{}})}).catch(()=>{})),await Promise.all(o)}catch(e){console.error("File watch handler error:",e)}},[t]);(0,ep.h)({url:`/ws/watch?cwd=${encodeURIComponent(t)}`,onMessage:e6,enabled:ey});let e8=(0,s.useCallback)(e=>{let t=e.split("/");if(t.length>1){let e=[];for(let r=1;r<t.length;r++)e.push(t.slice(0,r).join("/"));ek.setExpandedPaths(t=>{let r=new Set(t);for(let t of e)r.add(t);return ek.saveExpandedPaths(r),r})}ek.setSelectedPath(e),ek.setShouldScrollToSelected(!0),S("tree")},[ek]);return(0,n.jsxs)(b.SU,{container:P,children:[(0,n.jsxs)("div",{ref:M,className:"bg-card w-full h-full flex flex-col relative",children:[(0,n.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,n.jsxs)("div",{className:"w-80 flex-shrink-0 border-r border-border flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"flex border-b border-border",children:[(0,n.jsx)("button",{onClick:()=>eJ("tree"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"tree"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.directoryTree")}),(0,n.jsx)("button",{onClick:()=>eJ("search"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"search"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.searchTab")}),(0,n.jsx)("button",{onClick:()=>eJ("recent"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"recent"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.recentTab")}),(0,n.jsx)("button",{onClick:()=>eJ("status"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"status"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.changesTab")}),(0,n.jsx)("button",{onClick:()=>eJ("history"),className:`flex-1 px-2 py-2 text-sm font-medium transition-colors ${"history"===C?"text-brand border-b-2 border-brand":"text-muted-foreground hover:text-foreground dark:hover:text-foreground"}`,children:y("fileBrowser.historyTab")})]}),"tree"===C&&(0,n.jsxs)("div",{className:"p-2 border-b border-border flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:ek.searchInputRef,type:"text",value:ek.searchQuery,onChange:e=>ek.setSearchQuery(e.target.value),placeholder:y("fileBrowser.searchFiles"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),ek.searchQuery&&(0,n.jsx)("button",{onClick:()=>ek.setSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>ek.setSearchDirExact(e=>!e),className:`px-1 py-0.5 rounded transition-colors text-xs font-mono font-bold border ${ek.searchExactMatch?"border-brand text-brand bg-brand/10":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,title:ek.searchExactMatch?y("fileBrowser.exactMatchOn"):y("fileBrowser.exactMatchOff"),children:"ab"}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>ek.loadFiles(),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.refreshTree"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:()=>ek.searchTreeExpandedPaths?ek.setSearchTreeExpandedPaths(new Set):ek.setExpandedPaths(new Set),className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.collapseAll"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})]})]}),"search"===C&&(0,n.jsxs)("div",{className:"p-2 border-b border-border space-y-2",children:[(0,n.jsxs)("div",{className:"flex gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:eN.contentSearchInputRef,type:"text",value:eN.contentSearchQuery,onChange:e=>eN.setContentSearchQuery(e.target.value),onKeyDown:e=>{"Enter"===e.key&&eN.performContentSearch(eN.contentSearchQuery)},placeholder:y("fileBrowser.searchFileContent"),className:"w-full px-3 py-1.5 pr-7 text-sm border border-border rounded bg-card text-foreground placeholder-slate-9 focus:outline-none focus:ring-2 focus:ring-ring"}),eN.contentSearchQuery&&(0,n.jsx)("button",{onClick:()=>eN.setContentSearchQuery(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-slate-9 hover:text-foreground rounded-sm transition-colors",title:y("fileBrowser.clear"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("button",{onClick:()=>eN.performContentSearch(eN.contentSearchQuery),disabled:eN.isSearching||!eN.contentSearchQuery.trim(),className:"px-3 py-1.5 text-sm bg-brand text-white rounded hover:bg-brand/90 disabled:opacity-50 disabled:cursor-not-allowed",children:eN.isSearching?"...":y("common.search")})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.caseSensitive,onChange:e=>eN.setSearchOptions(t=>({...t,caseSensitive:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.caseSensitive")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.wholeWord,onChange:e=>eN.setSearchOptions(t=>({...t,wholeWord:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.wholeWord")})]}),(0,n.jsxs)("label",{className:"flex items-center gap-1 cursor-pointer",children:[(0,n.jsx)("input",{type:"checkbox",checked:eN.searchOptions.regex,onChange:e=>eN.setSearchOptions(t=>({...t,regex:e.target.checked})),className:"w-3 h-3"}),(0,n.jsx)("span",{className:"text-muted-foreground",children:y("fileBrowser.regex")})]}),(0,n.jsx)("input",{type:"text",value:eN.searchOptions.fileType,onChange:e=>eN.setSearchOptions(t=>({...t,fileType:e.target.value})),placeholder:y("fileBrowser.fileTypes"),className:"w-24 px-2 py-0.5 text-xs border border-border rounded bg-card text-foreground placeholder-slate-9"})]})]}),"history"===C&&(0,n.jsx)("div",{className:"p-3 border-b border-border",children:eE.compareMode?(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"flex-1 min-w-0 px-3 py-1.5 text-sm border border-border rounded bg-secondary text-foreground flex items-center gap-2",children:[(0,n.jsx)("svg",{className:"w-4 h-4 text-muted-foreground flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),(0,n.jsx)("span",{className:"truncate",children:eE.branches?.current||"HEAD"}),(0,n.jsx)("span",{className:"text-xs text-green-11 flex-shrink-0",children:"HEAD"})]}),(0,n.jsx)("button",{onClick:()=>eE.toggleCompareMode(!1),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors bg-brand text-white",title:y("fileBrowser.compareModeOff"),children:y("fileBrowser.compareMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-shrink-0 pl-1",children:"vs"}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tb,{branches:eE.branches,selectedBranch:eE.compareBaseBranch,onSelect:e=>{eE.setCompareBaseBranch(e),eE.loadCompareFiles(e)},isLoading:eE.isLoadingBranches,pinnedBranches:["origin/main",...eE.upstreamBranch&&"origin/main"!==eE.upstreamBranch?[eE.upstreamBranch]:[]]})})]})]}):(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(tb,{branches:eE.branches,selectedBranch:eE.selectedBranch,onSelect:e=>{eE.setSelectedBranch(e)},isLoading:eE.isLoadingBranches,pinnedBranches:["origin/main",...eE.upstreamBranch&&"origin/main"!==eE.upstreamBranch?[eE.upstreamBranch]:[]]})}),(0,n.jsx)("button",{onClick:()=>eE.toggleCompareMode(!0),className:"flex-shrink-0 px-2.5 py-1.5 text-xs font-medium rounded-lg transition-colors text-muted-foreground hover:text-foreground hover:bg-accent border border-border",title:y("fileBrowser.compareModeOn"),children:y("fileBrowser.compareMode")})]})}),(0,n.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,n.jsxs)("div",{className:`flex-1 flex flex-col min-h-0 ${"tree"===C?"":"hidden"}`,children:[ek.creatingItem&&(0,n.jsxs)("div",{className:"px-2 py-1.5 border-b border-border bg-secondary flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:ek.creatingItem.parentPath?y("fileBrowser.createFileIn",{path:ek.creatingItem.parentPath}):y("fileBrowser.createFile")}),(0,n.jsx)("input",{type:"text",autoFocus:!0,placeholder:y("fileBrowser.fileName"),className:"flex-1 px-2 py-1 text-sm border border-border rounded bg-card text-foreground focus:outline-none focus:ring-2 focus:ring-ring",onCompositionStart:()=>{$.current=!0},onCompositionEnd:()=>{$.current=!1},onKeyDown:async e=>{if("Enter"===e.key){if($.current)return;let r=e.target.value.trim();if(!r)return;let n=ek.creatingItem.parentPath,s=n?`${n}/${r}`:r,o=await i.t4.runPromiseExit((0,x.OJ)({cwd:t,path:s,content:""}));if("Success"===o._tag&&o.value.ok)(0,k.oR)(y("toast.createdFile",{name:r}),"success"),ek.setCreatingItem(null),ek.loadDirectory(n),ek.loadFileIndex(),n&&ek.setExpandedPaths(e=>new Set([...e,n])),eI(s);else if("Success"===o._tag){let e=o.value.data?.error;(0,k.oR)(e||y("toast.createFailed"),"error")}else(0,k.oR)(y("toast.createFailed"),"error")}else"Escape"===e.key&&ek.setCreatingItem(null)},onBlur:()=>ek.setCreatingItem(null)})]}),ek.isLoadingFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("common.loading")}):ek.fileError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:ek.fileError}):(0,n.jsx)(eo,{files:ek.files,selectedPath:ek.selectedPath,expandedPaths:ek.effectiveExpandedPaths,matchedPaths:ek.matchedPaths,gitStatusMap:eU,loadingDirs:ek.loadingDirs,onSelect:e=>{ek.setShouldScrollToSelected(!1),eI(e)},onToggle:ek.handleToggle,cwd:t,shouldScrollToSelected:ek.shouldScrollToSelected,onScrolledToSelected:()=>ek.setShouldScrollToSelected(!1),onCreateFile:e=>ek.setCreatingItem({type:"file",parentPath:e}),onDelete:(e,t,r)=>F({path:e,isDirectory:t,name:r}),onRefresh:()=>ek.loadFiles(),onCopyFile:eY,onPaste:eZ})]}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"search"===C?"":"hidden"}`,children:eN.isSearching?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):eN.searchError?(0,n.jsx)("div",{className:"p-4 text-center text-red-11 text-sm",children:eN.searchError}):0===eN.contentSearchResults.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:eN.contentSearchQuery?y("fileBrowser.noContentSearchResults"):y("fileBrowser.enterKeywordToSearch")}):(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col min-h-0",children:[eN.searchStats&&(0,n.jsxs)("div",{className:"px-3 py-1.5 text-xs text-muted-foreground bg-secondary border-b border-border flex-shrink-0",children:[y("fileBrowser.nFilesNMatches",{files:eN.searchStats.totalFiles,matches:eN.searchStats.totalMatches}),eN.searchStats.truncated&&(0,n.jsxs)("span",{className:"text-amber-11 ml-1",children:["(",y("fileBrowser.resultsTruncated"),")"]})]}),(0,n.jsx)(eo,{files:eD.files,selectedPath:ek.selectedPath,expandedPaths:eA,onSelect:e=>{let t=eD.matchMap.get(e);eI(e,t?.matches[0]?.lineNumber),Y||G(!0)},onToggle:eW,cwd:t,renderActions:ez,className:"flex-1 overflow-y-auto py-1 min-w-max"})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"recent"===C?"":"hidden"}`,children:0===ek.recentFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noRecentFiles")}):(0,n.jsx)(eo,{files:ek.recentFilesTree,selectedPath:ek.selectedPath,expandedPaths:ek.recentTreeDirPaths,onSelect:eI,onToggle:ea.tE,cwd:t})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"status"===C?"":"hidden"}`,children:eC.statusLoading?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):eC.statusError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center p-4",children:(0,n.jsx)("span",{className:"text-red-11 text-sm",children:eC.statusError})}):(0,n.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[(0,n.jsxs)("div",{className:"border-b border-border",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:y("fileBrowser.stagingArea",{count:eC.status?.staged.length||0})}),(0,n.jsx)("button",{onClick:()=>eC.fetchStatus(),className:"p-0.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:y("fileBrowser.refreshChanges"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),(eC.status?.staged.length||0)>0&&(0,n.jsx)("button",{onClick:eC.handleUnstageAll,className:"text-sm text-amber-11 hover:text-amber-10 hover:underline",children:y("fileBrowser.unstageAll")})]}),(0,n.jsx)(D,{files:eC.stagedTree,selectedPath:eC.statusSelectedFile?.type==="staged"?eC.statusSelectedFile.file.path:null,expandedPaths:eC.stagedExpandedPaths,onSelect:e=>e.file&&eC.handleStatusFileSelect(e.file,"staged"),onToggle:eC.handleStagedToggle,cwd:t,emptyMessage:y("fileBrowser.noStagedFiles"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=W(e);return 0===t.length?null:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleUnstageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:y("fileBrowser.unstageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}return(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleUnstage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-amber-11 hover:text-amber-10 hover:bg-amber-9/10 dark:hover:bg-amber-9/20 rounded transition-all",title:y("fileBrowser.unstageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})})}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 bg-secondary",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:y("fileBrowser.workspace",{count:eC.status?.unstaged.length||0})}),(eC.status?.unstaged.length||0)>0&&(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:eC.handleDiscardAll,className:"text-sm text-red-11 hover:text-red-10 hover:underline",children:y("fileBrowser.discardAll")}),(0,n.jsx)("button",{onClick:eC.handleStageAll,className:"text-sm text-green-11 hover:text-green-10 hover:underline",children:y("fileBrowser.stageAll")})]})]}),(0,n.jsx)(D,{files:eC.unstagedTree,selectedPath:eC.statusSelectedFile?.type==="unstaged"?eC.statusSelectedFile.file.path:null,expandedPaths:eC.unstagedExpandedPaths,onSelect:e=>e.file&&eC.handleStatusFileSelect(e.file,"unstaged"),onToggle:eC.handleUnstagedToggle,cwd:t,emptyMessage:y("fileBrowser.noUnstagedChanges"),className:"py-1",renderActions:e=>{if(e.isDirectory){let t=W(e);if(0===t.length)return null;let r=t.map(e=>e.file).filter(Boolean);return(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleDiscardFiles(r)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:y("fileBrowser.discardNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),eC.handleStageFiles(t.map(e=>e.path))},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:y("fileBrowser.stageNFiles",{count:t.length}),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})}return e.file?(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleDiscardFile(e.file)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-red-11 hover:text-red-10 hover:bg-red-9/10 dark:hover:bg-red-9/20 rounded transition-all",title:y("fileBrowser.discardChanges"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h10a8 8 0 018 8v2M3 10l6 6m-6-6l6-6"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),eC.handleStage(e.path)},className:"opacity-0 group-hover:opacity-100 p-0.5 text-green-11 hover:text-green-10 hover:bg-green-9/10 dark:hover:bg-green-9/20 rounded transition-all",title:y("fileBrowser.stageFile"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]}):null}})]})]})}),(0,n.jsx)("div",{className:`flex-1 flex flex-col min-h-0 ${"history"===C?"":"hidden"}`,children:eE.historyError?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,n.jsx)("p",{className:"text-muted-foreground",children:eE.historyError})]})}):eE.compareMode?(0,n.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:eE.isLoadingCompareFiles?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiff")}):0===eE.compareFiles.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noDiffFiles")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"px-3 py-2 border-b border-border",children:(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:y("fileBrowser.nFilesChanged",{count:eE.compareFiles.length,branch:eE.compareBaseBranch})})}),(0,n.jsx)(D,{files:eE.compareFileTree,expandedPaths:eE.compareExpandedPaths,onToggle:eE.handleCompareToggle,selectedPath:eE.compareSelectedFile?.path||null,onSelect:e=>{e.file&&eE.handleSelectCompareFile(e.file)},cwd:t,showChanges:!0})]})}):(0,n.jsx)("div",{ref:eE.commitListRef,className:"flex-1 overflow-y-auto",onScroll:eE.handleCommitListScroll,children:eE.isLoadingCommits?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.loadingCommits")}):0===eE.commits.length?(0,n.jsx)("div",{className:"p-4 text-center text-muted-foreground text-sm",children:y("fileBrowser.noCommits")}):(0,n.jsxs)(n.Fragment,{children:[eE.commits.map(e=>(0,n.jsxs)("div",{onClick:()=>eE.handleSelectCommit(e),className:`px-3 py-2 border-b border-border cursor-pointer hover:bg-accent ${eE.selectedCommit?.hash===e.hash?"bg-brand/10":""}`,children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"font-mono text-xs text-brand",children:e.shortHash}),(0,n.jsxs)("span",{className:"text-xs text-slate-9",title:e.date,children:[e.relativeDate," \xb7 ",(0,ea.r6)(e.date)]})]}),(0,n.jsx)("div",{className:"text-sm text-foreground truncate mt-0.5","data-tooltip":e.subject,children:e.subject}),(0,n.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5",children:e.author})]},e.hash)),eE.isLoadingMore&&(0,n.jsx)("div",{className:"p-3 text-center",children:(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-brand border-t-transparent rounded-full animate-spin"})}),!eE.hasMoreCommits&&eE.commits.length>0&&(0,n.jsx)("div",{className:"p-3 text-center text-xs text-slate-9",children:y("fileBrowser.allLoaded",{count:eE.commits.length})})]})})})]})]}),(0,n.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[("tree"===C||"search"===C||"recent"===C)&&(ek.blameSelectedCommit?(0,n.jsx)(er,{isOpen:!0,onClose:()=>ek.setBlameSelectedCommit(null),commit:ek.blameSelectedCommit,cwd:t,embedded:!0,initialFilePath:ek.selectedPath||void 0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):"map"===L?(0,n.jsx)(e3,{cwd:t,highlightedFilePath:ek.selectedPath,changedFiles:eS,onSwitchToCode:()=>E("code"),enableComments:!0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)},headerExtraLeft:({focalFile:e})=>e&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(`${t}/${e}`),(0,k.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),e8(e)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]})}):ek.selectedPath?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"px-4 py-2 bg-secondary border-b border-border flex-shrink-0 flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[(0,n.jsx)("span",{className:"text-sm text-muted-foreground truncate",children:ek.selectedPath}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(`${t}/${ek.selectedPath}`),(0,k.oR)(y("common.copiedPath"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("common.copyAbsPath"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),e8(ek.selectedPath)},className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors flex-shrink-0",title:y("fileBrowser.locateInTree"),children:(0,n.jsxs)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeWidth:2}),(0,n.jsx)("circle",{cx:"12",cy:"12",r:"3",strokeWidth:2}),(0,n.jsx)("path",{strokeLinecap:"round",strokeWidth:2,d:"M12 2v4m0 12v4M2 12h4m12 0h4"})]})})]}),(0,n.jsx)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:ek.showEditor?(0,n.jsxs)(n.Fragment,{children:[Q.isDirty&&(0,n.jsx)("span",{className:"text-xs text-amber-11",children:y("fileBrowser.unsaved")}),(0,n.jsx)("button",{onClick:()=>J.current?.save(),disabled:!Q.isDirty||Q.isSaving,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${Q.isDirty&&!Q.isSaving?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:Q.isSaving?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full animate-spin"}):y("common.save")}),(0,n.jsx)("button",{onClick:()=>J.current?.close(),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.closeEdit"),children:y("fileBrowser.closeBtn")})]}):(0,n.jsxs)(n.Fragment,{children:[ek.fileContent?.type==="text"&&ek.fileContent.content&&(0,n.jsx)("button",{onClick:()=>{navigator.clipboard.writeText(ek.fileContent.content),(0,k.oR)(y("toast.copiedFileContent"))},className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.copyFileContent"),children:y("common.copy")}),ek.selectedPath?.endsWith(".json")&&ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>es(e=>!e),className:`px-1.5 py-0.5 text-xs rounded transition-colors ${en?"bg-brand text-white":"text-muted-foreground hover:bg-accent"}`,title:y("fileBrowser.toggleJsonReadable"),children:y("common.readable")}),ek.fileContent?.type==="text"&&Z(ek.selectedPath)&&(0,n.jsx)("button",{onClick:()=>ek.setShowMarkdownPreview(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.previewMarkdown"),children:y("common.preview")}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:ek.handleToggleBlame,disabled:ek.isLoadingBlame,className:`px-1.5 py-0.5 text-xs rounded transition-colors ${ek.showBlame?"bg-brand text-white":"text-muted-foreground hover:bg-accent"} disabled:opacity-50`,title:y("fileBrowser.viewBlame"),children:ek.isLoadingBlame?(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-current border-t-transparent rounded-full animate-spin"}):"Blame"}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>E("map"),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("blockViewer.viewerToggle.toBlock"),children:y("common.codeMap")}),ek.fileContent?.type==="text"&&(0,n.jsx)("button",{onClick:()=>ek.setShowEditor(!0),className:"px-1.5 py-0.5 text-xs rounded transition-colors text-muted-foreground hover:bg-accent",title:y("fileBrowser.editFile"),children:y("common.edit")})]})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-hidden",children:ek.isLoadingContent?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):ek.fileContent?"text"===ek.fileContent.type&&"string"==typeof ek.fileContent.content?ek.showBlame&&ek.blameError?(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("p",{className:"text-red-11",children:ek.blameError}),(0,n.jsx)("button",{onClick:()=>ek.setShowBlame(!1),className:"mt-2 text-brand hover:underline text-sm",children:y("fileBrowser.backToPreview")})]})}):ek.showBlame&&0===ek.blameLines.length&&ek.isLoadingBlame?(0,n.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):en&&ek.selectedPath?.endsWith(".json")?(0,n.jsxs)("div",{className:"h-full flex flex-col bg-[#0d1117]",children:[(0,n.jsx)(et,{search:eu}),(0,n.jsx)("div",{className:"flex-1 overflow-auto px-6 py-4",children:(0,n.jsx)("pre",{ref:ed,className:"whitespace-pre-wrap break-words font-mono",style:{fontSize:"0.8125rem",lineHeight:"1.5"},children:H(ek.fileContent.content)})})]}):(0,n.jsx)(el.Cv,{ref:J,content:ek.fileContent.content,filePath:ek.selectedPath,cwd:t,enableComments:!0,scrollToLine:K??ek.targetLineNumber,scrollToLineAlign:null!=K?"start":ek.targetScrollAlign,onScrollToLineComplete:()=>{U(null),ek.setTargetLineNumber(null)},highlightKeyword:"search"===C?eN.contentSearchQuery:null,visibleLineRef:q,viStateRef:V,initialCursorLine:ek.initialCursorLine,initialCursorCol:ek.initialCursorCol,onInitialCursorSet:()=>{ek.setInitialCursorLine(null),ek.setInitialCursorCol(null)},onCmdClick:eO?eq:void 0,onTokenHover:eO?eV:void 0,onTokenHoverLeave:eO?ev.onTokenMouseLeave:void 0,onTokenHoverCancel:eO?ev.clearHover:void 0,blameLines:ek.showBlame&&ek.blameLines.length>0?ek.blameLines:void 0,inlineBlameLines:ek.blameLines.length>0?ek.blameLines:void 0,onSelectCommit:ek.setBlameSelectedCommit,editable:ek.showEditor,initialMtime:ek.fileContent.mtime,onEditorClose:e=>{ek.setShowEditor(!1),U(e)},onSaved:()=>{let e=q.current??1;ek.loadFileContent(ek.selectedPath),ek.setShowEditor(!1),U(e)},onEditorStateChange:X,viMode:!0,onContentMutate:eP,onEnterInsertMode:eR,onViSave:eB,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):"image"===ek.fileContent.type&&ek.selectedPath?(0,n.jsx)(tp,{cwd:t,path:ek.selectedPath,refreshKey:ek.fileContent.mtime,alt:ek.selectedPath}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),(0,n.jsx)("p",{children:ek.fileContent.message||y("fileBrowser.cannotPreview")})]})}):(0,n.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:y("fileBrowser.selectFileToPreview")})})]}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("svg",{className:"w-16 h-16 mx-auto text-slate-7 mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),(0,n.jsx)("p",{children:y("fileBrowser.selectFileToPreview")})]})})),"status"===C&&(eC.statusSelectedFile&&eC.statusDiff?(0,n.jsx)(tg,{cwd:t,selected:eC.statusSelectedFile,diff:eC.statusDiff,showMarkdownPreview:eC.showStatusDiffPreview,setShowMarkdownPreview:eC.setShowStatusDiffPreview,changedFiles:eS,fileGitStatusMap:eL,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)},locateInTree:e8,jsonPreview:ei,setJsonPreview:ec,jsonPreviewSearch:eh,jsonPreviewPreRef:em}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectFileToViewDiff")})})),"history"===C&&!eE.historyError&&(eE.compareMode?eE.isLoadingCompareDiff?(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:y("fileBrowser.loadingDiffContent")}):eE.compareFileDiff?(0,n.jsx)(T,{oldContent:eE.compareFileDiff.oldContent,newContent:eE.compareFileDiff.newContent,filePath:eE.compareFileDiff.filePath,isNew:eE.compareFileDiff.isNew,isDeleted:eE.compareFileDiff.isDeleted,cwd:t,enableComments:!0,onPreview:!eE.compareFileDiff.isDeleted&&eE.compareFileDiff.filePath.endsWith(".json")?()=>ec({content:eE.compareFileDiff.newContent,filePath:eE.compareFileDiff.filePath}):void 0,previewLabel:y("common.readable"),onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:eE.compareFiles.length>0?y("fileBrowser.selectFileToViewDiff"):y("fileBrowser.clickCompareToLoad")})}):eE.selectedCommit?(0,n.jsx)(er,{isOpen:!0,onClose:()=>eE.setSelectedCommit(null),commit:eE.selectedCommit,cwd:t,embedded:!0,onContentSearch:e=>{S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}):(0,n.jsx)("div",{className:"flex-1 flex items-center justify-center text-slate-9",children:(0,n.jsx)("span",{children:y("fileBrowser.selectCommitToView")})}))]})]}),ek.showMarkdownPreview&&ek.fileContent?.type==="text"&&ek.selectedPath&&(0,n.jsx)("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>ek.setShowMarkdownPreview(!1),children:(0,n.jsx)("div",{className:"bg-card rounded-lg shadow-xl w-full max-w-[90%] h-full flex flex-col",onClick:e=>e.stopPropagation(),children:(0,n.jsx)(ex,{content:ek.fileContent.content||"",filePath:ek.selectedPath,cwd:t,onClose:()=>ek.setShowMarkdownPreview(!1)})})}),I&&(0,n.jsx)(ef,{files:ek.files,fileIndex:ek.fileIndex,recentFiles:ek.recentFilePaths,onSelectFile:e=>{eI(e),ek.setShouldScrollToSelected(!0),S("tree")},onClose:()=>O(!1)}),(eH||ej.visible)&&(0,n.jsxs)("div",{className:`flex ${ej.visible&&eH?"":"flex-col"}`,children:[eH&&(0,n.jsx)("div",{className:ej.visible?"flex-1 min-w-0 border-r border-border":"",children:(0,n.jsx)(tN,{results:eN.contentSearchResults,loading:eN.isSearching,totalMatches:eN.searchStats?.totalMatches??0,onSelect:(e,t)=>{ek.selectedPath&&ew.push({filePath:ek.selectedPath,lineNumber:q.current}),eI(e,t)},onClose:()=>G(!1)})}),ej.visible&&(0,n.jsx)("div",{className:eH?"flex-1 min-w-0":"",children:(0,n.jsx)(tk,{references:ej.references,loading:ej.loading,onSelect:eK,onClose:ej.closeReferences})})]})]}),B&&(0,n.jsx)(m.ZL,{children:(0,n.jsx)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center bg-black/50",onClick:()=>F(null),children:(0,n.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h3",{className:"text-sm font-medium text-foreground mb-2",children:y("fileBrowser.confirmDelete")}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:y("fileBrowser.confirmDeleteMessage",{name:B.name}).split(/<\/?file>/g).map((e,t)=>1===t?(0,n.jsx)("span",{className:"font-mono text-foreground",children:e},t):e)}),(0,n.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>F(null),className:"px-3 py-1.5 text-sm rounded border border-border hover:bg-accent transition-colors",children:y("common.cancel")}),(0,n.jsx)("button",{onClick:async()=>{let{path:e,name:r}=B;F(null);let n=await i.t4.runPromiseExit((0,x.VK)({cwd:t,path:e}));if("Success"===n._tag){(0,k.oR)(y("toast.movedToTrash",{name:r}),"success");let t=e.includes("/")?e.substring(0,e.lastIndexOf("/")):"";ek.loadDirectory(t),ek.loadFileIndex(),ek.selectedPath===e&&eI("")}else{let e="Fail"===n.cause._tag?n.cause.error:null,t=e?.cause,r=t instanceof Error?t.message:y("toast.deleteFailed");(0,k.oR)(r,"error")}},className:"px-3 py-1.5 text-sm rounded bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors",children:y("common.delete")})]})]})})}),ev.hoverInfo&&P&&(0,u.createPortal)((0,n.jsx)(ty,{ref:ev.setTooltipEl,displayString:ev.hoverInfo.displayString,documentation:ev.hoverInfo.documentation,x:ev.hoverInfo.x,y:ev.hoverInfo.y,container:P,onMouseEnter:ev.onCardMouseEnter,onMouseLeave:ev.onCardMouseLeave,onFindReferences:()=>{let{filePath:e,line:t,column:r}=ev.hoverInfo;ev.clearHover(),ej.findReferences(e,t,r)},onSearch:e=>{ev.clearHover(),S("search"),eN.setContentSearchQuery(e),eN.performContentSearch(e)}}),P)]})}function tL({isOpen:e,onClose:t,cwd:r}){let c,{t:d}=(0,o.Bd)(),[u,m]=(0,s.useState)([]),[x,f]=(0,s.useState)(null),[p,g]=(0,s.useState)(null),[b,v]=(0,s.useState)(!1),[j,w]=(0,s.useState)(!1),[y,N]=(0,s.useState)(null),[C,S]=(0,s.useState)(!1),[L,E]=(0,s.useState)(""),[M,T]=(0,s.useState)(!1),[$,P]=(0,s.useState)([]),[R,B]=(0,s.useState)(""),[F,I]=(0,s.useState)(!1),D=(0,s.useCallback)((e,t)=>e?._tag==="Fail"&&e.error?.cause instanceof Error?e.error.cause.message:d(t),[d]),A=(0,s.useCallback)(async()=>{v(!0);let e=await i.t4.runPromiseExit((0,h.FK)(r));if("Success"===e._tag){let t=e.value;m(t.worktrees),f(t.nextPath),g(t.nextRandomWord),t.gitUserName&&E(t.gitUserName)}else console.error("Failed to load worktrees:",e.cause),(0,k.oR)(d("toast.worktreeLoadFailed"),"error");v(!1)},[r,d]),_=(0,s.useCallback)(e=>{let{local:t,remote:r}=e;return r.includes("origin/main")?"origin/main":r.includes("origin/master")?"origin/master":t.includes("main")?"main":t.includes("master")?"master":r.length>0?r[0]:t.length>0?t[0]:"main"},[]);(0,s.useEffect)(()=>{e&&(A(),N(null))},[e,A]);let W=async()=>{if(!x)return;let e="origin/main",t=await i.t4.runPromiseExit((0,h.r4)(r));"Success"===t._tag&&(e=_(t.value));let n=p||function(){let e="bcdfghjklmnprstvwz",t=["a","e","i","o","u","ai","au","ea","ee","ia","io","oa","oo","ou","ui"],r="";for(let n=0;n<2;n++)r+=e[Math.floor(Math.random()*e.length)],r+=t[Math.floor(Math.random()*t.length)];return r}(),s=L?`${L}/${n}`:n;w(!0);let o=await i.t4.runPromiseExit((0,h.CM)({action:"add",cwd:r,path:x,newBranch:s,baseBranch:e}));"Success"===o._tag?((0,k.oR)(d("toast.worktreeCreateSuccess",{name:s}),"success"),A()):(console.error("Failed to create worktree:",o.cause),(0,k.oR)(D(o.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},z=async()=>{I(!0),B(""),T(!0);let e=await i.t4.runPromiseExit((0,h.r4)(r));if("Success"===e._tag){let t=e.value,r=t.local??[],n=t.remote??[],s=new Set(u.map(e=>e.branch).filter(Boolean));P([...r.filter(e=>!s.has(e)),...n.filter(e=>!s.has(e)&&!r.includes(e.replace(/^origin\//,"")))])}else(0,k.oR)(d("toast.loadBranchFailed"),"error");I(!1)},H=async e=>{if(!x)return;T(!1),w(!0);let t=await i.t4.runPromiseExit((0,h.CM)({action:"add",cwd:r,path:x,branch:e}));"Success"===t._tag?((0,k.oR)(d("toast.worktreeCreateSuccess",{name:e}),"success"),A()):(console.error("Failed to create worktree:",t.cause),(0,k.oR)(D(t.cause,"toast.worktreeCreateFailed"),"error")),w(!1)},O=async()=>{if(!y)return;S(!0);let e=await i.t4.runPromiseExit((0,h.CM)({action:"remove",cwd:r,path:y.path}));"Success"===e._tag?((0,k.oR)(d("toast.worktreeDeleted"),"success"),N(null),A()):(console.error("Failed to delete worktree:",e.cause),(0,k.oR)(D(e.cause,"toast.worktreeDeleteFailed"),"error")),S(!1)},q=async e=>{let t=e.isLocked?"unlock":"lock",n=await i.t4.runPromiseExit((0,h.CM)({action:t,cwd:r,path:e.path}));"Success"===n._tag?((0,k.oR)(e.isLocked?d("toast.worktreeUnlocked"):d("toast.worktreeLocked"),"success"),A()):(console.error("Failed to toggle lock:",n.cause),(0,k.oR)(D(n.cause,"toast.operationFailed"),"error"))};return e?(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[480px] max-h-[80vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Git Worktrees"}),(0,n.jsx)("button",{onClick:t,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-accent rounded transition-colors",title:d("common.close"),children:(0,n.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,n.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:b?(0,n.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,n.jsx)("span",{className:"inline-block w-6 h-6 border-2 border-brand border-t-transparent rounded-full animate-spin"})}):(0,n.jsx)("div",{className:"space-y-2",children:u.map(e=>{let s=e.path===r;return(0,n.jsxs)("div",{className:`group p-3 rounded-lg border transition-colors ${s?"border-brand bg-brand/5":"border-border hover:bg-accent cursor-pointer"}`,onClick:()=>{e.path!==r&&((0,l.F)(a.n.OpenProject,{cwd:e.path}),t())},children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,n.jsx)("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?"bg-brand":"bg-muted-foreground/30"}`}),(0,n.jsx)("span",{className:"font-medium text-foreground truncate",children:e.branch||(e.isDetached?"detached":"unknown")}),e.isLocked&&(0,n.jsx)("span",{className:"text-amber-11",title:d("git.worktree.locked"),children:"\uD83D\uDD12"}),s&&(0,n.jsxs)("span",{className:"text-xs text-brand",children:["(",d("common.current"),")"]})]}),(0,n.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:!s&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),q(e)},className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-secondary rounded transition-colors",title:e.isLocked?d("git.worktree.unlock"):d("git.worktree.lock"),children:e.isLocked?(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"})}):(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})})}),(0,n.jsx)("button",{onClick:t=>{t.stopPropagation(),N(e)},className:"p-1.5 text-muted-foreground hover:text-red-11 hover:bg-secondary rounded transition-colors",title:d("common.delete"),children:(0,n.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})})]}),(0,n.jsx)("div",{className:"mt-1 text-xs text-muted-foreground truncate pl-4",children:e.path}),e.isDetached&&(0,n.jsx)("div",{className:"mt-1 text-xs text-amber-11 pl-4",children:"(detached HEAD)"})]},e.path)})})}),M&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-3 flex-shrink-0",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,n.jsx)("input",{value:R,onChange:e=>B(e.target.value),placeholder:d("git.worktree.searchBranch"),className:"flex-1 bg-secondary text-sm text-foreground rounded px-2.5 py-1.5 outline-none placeholder:text-muted-foreground",autoFocus:!0,autoComplete:"off",spellCheck:"false"}),(0,n.jsx)("button",{onClick:()=>T(!1),className:"text-xs text-muted-foreground hover:text-foreground px-2 py-1.5",children:d("common.cancel")})]}),(0,n.jsx)("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:F?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("common.loading")}):0===(c=$.filter(e=>e.toLowerCase().includes(R.toLowerCase()))).length?(0,n.jsx)("div",{className:"text-xs text-muted-foreground text-center py-4",children:d("git.worktree.noBranches")}):c.map(e=>(0,n.jsx)("button",{onClick:()=>H(e),className:"w-full text-left px-2.5 py-1.5 text-sm rounded hover:bg-accent transition-colors truncate",children:(0,n.jsx)("span",{className:`${e.startsWith("origin/")?"text-muted-foreground":"text-foreground"}`,children:e})},e))})]}),(0,n.jsxs)("div",{className:"px-4 py-3 border-t border-border flex items-center justify-between flex-shrink-0",children:[(0,n.jsx)("div",{className:"text-xs text-muted-foreground",children:d("git.worktree.count",{count:u.length})}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("button",{onClick:z,disabled:!x||j,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!j?"bg-secondary text-foreground hover:bg-accent":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:d("git.worktree.selectBranch")}),(0,n.jsx)("button",{onClick:W,disabled:!x||j,className:`px-3 py-1.5 text-sm rounded transition-colors ${x&&!j?"bg-brand text-white hover:bg-brand/90":"bg-secondary text-muted-foreground cursor-not-allowed"}`,children:j?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):d("git.worktree.addWorktree")})]})]}),y&&(0,n.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-black/50 rounded-lg",onClick:()=>N(null),children:(0,n.jsxs)("div",{className:"bg-card rounded-lg shadow-xl w-[360px] p-4",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"text-sm font-medium text-foreground mb-3",children:d("git.worktree.confirmDelete")}),(0,n.jsxs)("div",{className:"text-sm text-muted-foreground mb-4",children:[(0,n.jsx)("p",{className:"mb-2",children:d("git.worktree.confirmDeleteMsg")}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:d("git.worktree.path")}),(0,n.jsx)("span",{className:"text-foreground",children:y.path})]}),(0,n.jsxs)("p",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-muted-foreground",children:d("git.worktree.branch")}),(0,n.jsx)("span",{className:"text-foreground",children:y.branch||"detached"})]})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsx)("button",{onClick:()=>N(null),className:"px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:d("common.cancel")}),(0,n.jsx)("button",{onClick:O,disabled:C,className:"px-3 py-1.5 text-sm bg-red-9 text-white rounded hover:bg-red-10 transition-colors disabled:opacity-50",children:C?(0,n.jsx)("span",{className:"inline-block w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin"}):d("common.delete")})]})]})})]})}):null}var tE=r(67635),tM=r(73300),tT=r(20986),t$=r(9921),tP=r(66088),tR=r(42790);function tB(e){let t=function(e){let t=0xffffffff;for(let r=0;r<e.length;r++){t^=e.charCodeAt(r);for(let e=0;e<8;e++)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e),r="",n=t;for(let e=0;e<4;e++)r+=String.fromCharCode(97+n%26),n=Math.floor(n/26);return r}let tF=(0,s.memo)(function({shortId:e,type:t,onRegister:r,onUnregister:l}){let{t:a}=(0,o.Bd)(),[i,c]=(0,s.useState)(!1),d=(0,s.useCallback)(async n=>{if(n.stopPropagation(),i)await l(),c(!1),(0,k.oR)(a("toast.disconnected",{id:e}));else{await r(),c(!0);let n=`${"3456"===window.location.port?"cockpit-dev":"cockpit"} ${t} ${e}`;navigator.clipboard.writeText(n),(0,k.oR)(a("toast.copiedCommand",{command:n}))}},[i,e,t,r,l,a]);return(0,n.jsxs)("button",{onClick:d,className:"inline-flex items-center gap-1 text-[10px] font-mono leading-none px-1.5 py-0.5 rounded flex-shrink-0 transition-colors bg-muted/60 hover:bg-muted text-muted-foreground",title:i?a("shortIdBadge.clickToDisconnect"):a("shortIdBadge.clickToRegister"),children:[(0,n.jsx)("span",{className:`inline-block w-1.5 h-1.5 rounded-full ${i?"bg-green-500":"bg-muted-foreground/40"}`}),e]})});var tI=r(12786);let tD=e=>eM.tryPromise({try:async()=>{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}`);return await t.json()},catch:t=>new eT.uV({message:`fetch ${e} failed`,cause:t})}),tA=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,t);if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:r=>new eT.uV({message:`${t.method} ${e} failed`,cause:r})}),t_=(e,t)=>tA(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),tW=(e,t)=>eM.gen(function*(){let r=new URLSearchParams({cwd:e});return t&&r.set("tabId",t),(yield*tD(`/api/terminal/env?${r}`)).env||{}}),tz=()=>tD("/api/terminal/aliases").pipe(eM.map(e=>e.aliases||{})),tH=(e,t,r)=>t_("/api/terminal/bubble-order",{cwd:e,tabId:t,order:r}),tO=(e,t,r)=>t_("/api/terminal/history",{cwd:e,tabId:t,entry:r}),tq=(e,t,r)=>tA(`/api/terminal/history?cwd=${encodeURIComponent(e)}&tabId=${encodeURIComponent(t)}&commandId=${encodeURIComponent(r)}`,{method:"DELETE"}),tV=e=>tD(`/api/services/config?cwd=${encodeURIComponent(e)}`),tK=(0,s.lazy)(()=>Promise.all([r.e(3888),r.e(1959)]).then(r.bind(r,71959)).then(e=>({default:e.XtermRenderer}))),tU={c:"\x03",d:"\x04",z:"\x1a",l:"\f",a:"\x01",e:"\x05",u:"\x15",w:"\x17"},tJ=/\x1b\[[0-9;]*m/g;function tQ({output:e,query:t,mode:r,currentIdx:o,matchListRef:l}){let a=(0,s.useRef)(null);a.current||(a.current=new tR.v,a.current.use_classes=!0);let i=e.split("\n"),c=t.toLowerCase(),d=0;return l.current=[],(0,n.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap break-words select-text",children:i.map((e,t)=>{let s=e.replace(tJ,""),i=s.toLowerCase().includes(c);if("filter"===r&&!i)return null;if(!i){let r=a.current.ansi_to_html(e);return(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:r}},t)}let u=[],m=0,x=s.toLowerCase(),h=0;for(;h<x.length;){let e=x.indexOf(c,h);if(-1===e)break;e>m&&u.push((0,n.jsx)("span",{children:s.slice(m,e)},`t${m}`));let t=d++,r=t===o;u.push((0,n.jsx)("mark",{ref:e=>{l.current[t]=e},className:r?"bg-brand/40 text-foreground":"bg-yellow-300/40 text-foreground",children:s.slice(e,e+c.length)},`m${e}`)),h=m=e+c.length}return m<s.length&&u.push((0,n.jsx)("span",{children:s.slice(m)},`t${m}`)),(0,n.jsx)("div",{children:u},t)})})}let tX=(0,s.memo)(function({commandId:e,tabId:t,projectCwd:r,command:l,output:a,exitCode:c,isRunning:d,selected:u,onSelect:m,onInterrupt:x,onStdin:h,onDelete:f,onRerun:p,timestamp:g,usePty:b,subscribePtyOutput:v,subscribePtyReset:j,onPtyResize:w,onToggleMaximize:y,maximized:N,expandedHeight:C,bubbleContentHeight:S,onTitleMouseDown:L}){let{t:E}=(0,o.Bd)(),M=(0,s.useRef)(null),T=(0,s.useRef)(null),$=(0,s.useRef)(!0),P=(0,s.useRef)(null),R=(0,s.useRef)(null),B=(e=>{if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let r=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0");return`${r}-${n} ${s}:${o}`})(g),F=e&&t?tB(t+e):void 0,[I,D]=(0,s.useState)(!1),[A,_]=(0,s.useState)(""),W=(0,s.useRef)(null),z=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!v||!e)return;let t=()=>W.current?v(e,W.current.write):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[v,e]),(0,s.useEffect)(()=>{if(!j||!e)return;let t=()=>W.current?j(e,W.current.reset):null,r=t();if(r)return r;let n=setInterval(()=>{(r=t())&&clearInterval(n)},50);return()=>{clearInterval(n),r?.()}},[j,e]);let[H,O]=(0,s.useState)(!1),[q,V]=(0,s.useState)(""),[K,U]=(0,s.useState)("search"),[J,Q]=(0,s.useState)(0),X=(0,s.useRef)([]),Y=(0,s.useRef)(null),Z=(0,s.useRef)(0);(0,s.useEffect)(()=>{Y.current||(Y.current=new tR.v,Y.current.use_classes=!0)},[]),(0,s.useLayoutEffect)(()=>{let e=T.current;if(e&&Y.current){if(a.length<Z.current&&(Y.current=new tR.v,Y.current.use_classes=!0,Z.current=0,e.innerHTML=""),a.length>Z.current){let t=a.slice(Z.current),r=Y.current.ansi_to_html(t);Z.current=a.length,e.insertAdjacentHTML("beforeend",r)}if(M.current){let e=M.current.scrollHeight>M.current.clientHeight;D(e),e&&(M.current.scrollTop=M.current.scrollHeight)}}},[a]),(0,s.useEffect)(()=>(d&&$.current&&M.current&&(null!==P.current&&cancelAnimationFrame(P.current),P.current=requestAnimationFrame(()=>{M.current&&(M.current.scrollTop=M.current.scrollHeight),P.current=null})),()=>{null!==P.current&&cancelAnimationFrame(P.current)}),[a,d]),(0,s.useEffect)(()=>{if(!N)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),y?.())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[N,y]);let G=a?a.split("\n").length:0,ee=(0,s.useCallback)(()=>{O(!0),requestAnimationFrame(()=>z.current?.focus())},[]),et=(0,s.useCallback)(()=>{O(!1),V(""),Q(0),W.current?.clearSearch()},[]),er=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findNext(e):Q(e=>{let t=e+1,r=X.current[t];return r?(r.scrollIntoView({block:"nearest"}),t):(X.current[0]?.scrollIntoView({block:"nearest"}),0)}))},[b]),en=(0,s.useCallback)(e=>{e.trim()&&(b?W.current?.findPrevious(e):Q(e=>{let t=e-1;if(t>=0)return X.current[t]?.scrollIntoView({block:"nearest"}),t;let r=X.current.length-1;return r>=0&&X.current[r]?.scrollIntoView({block:"nearest"}),Math.max(r,0)}))},[b]);(0,s.useEffect)(()=>{if(!u)return;let e=e=>{if((e.metaKey||e.ctrlKey)&&"f"===e.key){e.preventDefault(),e.stopPropagation(),ee();return}if("Escape"===e.key&&H){e.preventDefault(),e.stopPropagation(),et();return}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[u,H,ee,et]);let es=N&&C?C-41:S??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground dark:text-slate-11 relative overflow-hidden border transition-colors cursor-pointer ${N?"rounded-none border-0":"rounded-2xl rounded-bl-md rounded-br-md"} ${N?"":u?"border-brand":"border-brand/30"}`,onClick:m,children:[N?(0,n.jsxs)("div",{onDoubleClick:()=>y?.(),className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41,flexShrink:0},children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded bg-muted text-muted-foreground",children:">_"}),(0,n.jsx)("span",{className:"flex-1 text-xs text-muted-foreground truncate font-mono",children:l}),d&&(0,n.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse"}),E("console.runningText")]}),d&&x&&(0,n.jsx)("button",{onClick:x,className:"text-xs px-3 py-1 rounded-md font-medium bg-destructive text-destructive-foreground transition-all duration-150 hover:bg-destructive/80 hover:shadow-md active:scale-95 active:bg-destructive/70 cursor-pointer select-none",children:"Ctrl+C"}),(0,n.jsx)("button",{onClick:()=>y?.(),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.restoreTooltip",{modKey:(0,tI.Mu)()}),children:(0,n.jsx)(ev.A,{className:"w-4 h-4"})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>L?.(),onDoubleClick:e=>{e.stopPropagation(),y?.()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing ${u?"border-brand":"border-brand/30"}`,children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:">_"}),F&&e&&t&&(0,n.jsx)(tF,{shortId:F,type:"terminal",onRegister:()=>{i.t4.runFork(t_("/api/terminal/register",{tabId:t,commandId:e,command:l,projectCwd:r}).pipe(eM.orElse(()=>eM.void)))},onUnregister:()=>{i.t4.runFork(t_("/api/terminal/unregister",{commandId:e}).pipe(eM.orElse(()=>eM.void)))}}),(0,n.jsx)("span",{className:"font-mono text-foreground truncate",children:l}),(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(l),(0,k.oR)(E("toast.copiedCmd"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.copyCommand"),children:(0,n.jsx)(tE.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("span",{className:"flex-1"}),I&&!d&&(0,n.jsx)("span",{className:"text-muted-foreground flex-shrink-0",children:E("console.totalLines",{count:G})}),a&&(0,n.jsx)("button",{onClick:e=>{let t;e.stopPropagation(),t=a.replace(/\x1b\[[0-9;]*m/g,""),navigator.clipboard.writeText(t),(0,k.oR)(E("toast.copiedOutput"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.copyOutput"),children:(0,n.jsx)(tM.A,{className:"w-3.5 h-3.5"})}),p&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),p()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:E("console.rerun"),children:(0,n.jsx)(tT.A,{className:"w-3.5 h-3.5"})}),f&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),f()},className:"p-0.5 rounded text-destructive hover:text-destructive/80 transition-colors flex-shrink-0",title:E("console.deleteRecord"),children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),H&&(0,n.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-border bg-card",style:{flexShrink:0},children:[(0,n.jsx)(eb.A,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),(0,n.jsx)("input",{ref:z,value:q,onChange:e=>{let t=e.target.value;V(t),Q(0),b&&(t.trim()?W.current?.findNext(t):W.current?.clearSearch())},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.shiftKey?en(q):er(q))},placeholder:E("console.searchPlaceholder"),className:"flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}),!b&&(0,n.jsxs)("div",{className:"flex items-center gap-0.5 text-xs flex-shrink-0",children:[(0,n.jsx)("button",{onClick:()=>U("search"),className:`px-1.5 py-0.5 rounded transition-colors ${"search"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:E("console.searchMode")}),(0,n.jsx)("button",{onClick:()=>U("filter"),className:`px-1.5 py-0.5 rounded transition-colors ${"filter"===K?"bg-brand/20 text-brand":"text-muted-foreground hover:text-foreground"}`,children:E("console.filterMode")})]}),(0,n.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,n.jsx)("button",{onClick:()=>en(q),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.prevShiftEnter"),children:(0,n.jsx)(t$.A,{className:"w-3.5 h-3.5"})}),(0,n.jsx)("button",{onClick:()=>er(q),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",title:E("console.nextEnter"),children:(0,n.jsx)(tP.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsx)("button",{onClick:et,className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-3.5 h-3.5"})})]}),b?(0,n.jsxs)("div",{className:"relative group",style:{height:es,overflow:"hidden"},children:[(0,n.jsx)(s.Suspense,{fallback:(0,n.jsx)("div",{className:"px-4 py-2 text-xs text-muted-foreground",style:{height:es},children:E("console.loadingTerminal")}),children:(0,n.jsx)(tK,{ref:W,output:a,isRunning:d,onInput:h,onResize:w,maximized:N,height:es,directWrite:!!v})}),!d&&p&&(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",onClick:e=>{e.stopPropagation(),p()},title:E("console.rerun"),children:(0,n.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-black/60 text-white text-xs",children:[(0,n.jsx)(tT.A,{className:"w-3.5 h-3.5"}),E("console.rerun")]})})]}):(0,n.jsx)("div",{ref:M,className:"overflow-auto px-4 py-2",style:{height:es},onScroll:()=>{if(M.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=M.current;$.current=t-e-r<50}},children:H&&q.trim()?(0,n.jsx)(tQ,{output:a,query:q,mode:K,currentIdx:J,matchListRef:X}):(0,n.jsx)("pre",{ref:T,className:"text-sm font-mono whitespace-pre-wrap break-words select-text"})}),d&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("span",{className:"inline-block w-2 h-2 bg-green-500 rounded-full animate-pulse flex-shrink-0"}),b?(0,n.jsx)("span",{className:"text-xs text-muted-foreground flex-1",children:E("console.clickToInput")}):h?(0,n.jsx)("input",{ref:R,value:A,onChange:e=>_(e.target.value),onKeyDown:e=>{if(e.ctrlKey&&!e.metaKey&&!e.altKey){let t=tU[e.key.toLowerCase()];if(t){e.preventDefault(),e.stopPropagation(),h(t);return}}"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),h(A+"\n"),_("")),"Tab"===e.key&&(e.preventDefault(),h(" "))},placeholder:E("console.stdinPlaceholder"),className:"flex-1 min-w-0 bg-transparent text-xs font-mono text-foreground outline-none placeholder:text-muted-foreground",autoComplete:"off",spellCheck:"false"}):(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:E("console.runningText")}),x&&(0,n.jsx)("button",{onClick:x,className:"flex-shrink-0 text-xs text-destructive hover:brightness-125 transition-colors cursor-pointer select-none",children:"Ctrl+C"}),B&&(0,n.jsx)("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:B})]}),!d&&void 0!==c&&!N&&(0,n.jsxs)("div",{className:"border-t border-border px-4 py-2 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:`inline-block w-2 h-2 rounded-full ${0===c?"bg-green-500":"bg-red-500"}`}),(0,n.jsx)("span",{children:E("console.exitCode",{code:c})}),(0,n.jsx)("span",{className:"flex-1"}),B&&(0,n.jsx)("span",{className:"text-[11px] flex-shrink-0",children:B})]})]})})});var tY=r(68459),tZ=r(51914);function tG({cwd:e,tabId:t,onClose:r,onSave:l}){let{t:a}=(0,o.Bd)(),[c,d]=(0,s.useState)({}),[u,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(""),[f,p]=(0,s.useState)(!0),g=(0,s.useCallback)(async()=>{p(!0);let r=await i.t4.runPromiseExit(tW(e,t));"Success"===r._tag?d(r.value):console.error("Failed to load env:",r.cause),p(!1)},[e,t]);(0,s.useEffect)(()=>{g()},[g]);let b=()=>{u.trim()&&(d(e=>({...e,[u.trim()]:x})),m(""),h(""))},v=async()=>{let n=await i.t4.runPromiseExit(t_("/api/terminal/env",{cwd:e,tabId:t,env:c}));"Success"===n._tag?(l(c),r()):console.error("Failed to save env:",n.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-lg font-semibold",children:a("envManager.title")}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:t?a("envManager.tabScope"):a("envManager.globalScope")})]}),(0,n.jsx)("button",{onClick:r,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:f?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:a("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(c).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2",children:[(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"flex-1 px-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void d(t=>({...t,[e]:r}))},placeholder:a("envManager.valuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"}),(0,n.jsx)("button",{onClick:()=>{d(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors",children:(0,n.jsx)(tY.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:a("envManager.varNamePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("input",{type:"text",value:x,onChange:e=>h(e.target.value),placeholder:a("envManager.varValuePlaceholder"),className:"flex-1 px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),b())}}),(0,n.jsx)("button",{onClick:b,disabled:!u.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(tZ.A,{className:"w-4 h-4"})})]}),0===Object.keys(c).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:a("envManager.noVars")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:r,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:a("common.cancel")}),(0,n.jsx)("button",{onClick:v,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:a("common.save")})]})]})})}var t0=r(10762);function t1({onClose:e,onSave:t}){let{t:r}=(0,o.Bd)(),[l,a]=(0,s.useState)({}),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(""),[x,h]=(0,s.useState)(!0),f=(0,s.useCallback)(async()=>{h(!0);let e=await i.t4.runPromiseExit(tz());"Success"===e._tag?a(e.value):console.error("Failed to load aliases:",e.cause),h(!1)},[]);(0,s.useEffect)(()=>{f()},[f]);let p=()=>{c.trim()&&u.trim()&&(a(e=>({...e,[c.trim()]:u.trim()})),d(""),m(""))},g=async()=>{let r=await i.t4.runPromiseExit(t_("/api/terminal/aliases",{aliases:l}));"Success"===r._tag?(t(l),e()):console.error("Failed to save aliases:",r.cause)};return(0,n.jsx)("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center z-50",children:(0,n.jsxs)("div",{className:"bg-background border border-border rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] flex flex-col m-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,n.jsxs)("div",{children:[(0,n.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,n.jsx)(t0.A,{className:"w-5 h-5"}),r("aliasManager.title")]}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:r("aliasManager.description")})]}),(0,n.jsx)("button",{onClick:e,className:"p-1 rounded hover:bg-accent transition-colors",children:(0,n.jsx)(ev.A,{className:"w-5 h-5"})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:x?(0,n.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:r("common.loading")}):(0,n.jsxs)("div",{className:"space-y-3",children:[Object.entries(l).map(([e,t])=>(0,n.jsxs)("div",{className:"flex items-start gap-2 group",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:e,disabled:!0,className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-muted text-sm font-mono"})]}),(0,n.jsx)("input",{type:"text",value:t,onChange:t=>{var r;return r=t.target.value,void a(t=>({...t,[e]:r}))},placeholder:r("aliasManager.fullCommandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent"})]}),(0,n.jsx)("button",{onClick:()=>{a(t=>{let r={...t};return delete r[e],r})},className:"p-2 rounded-lg text-destructive hover:bg-destructive/10 transition-colors opacity-0 group-hover:opacity-100",children:(0,n.jsx)(tY.A,{className:"w-4 h-4"})})]},e)),(0,n.jsxs)("div",{className:"flex items-start gap-2 pt-2 border-t border-border",children:[(0,n.jsxs)("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),(0,n.jsx)("input",{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:r("aliasManager.aliasPlaceholder"),className:"w-full pl-7 pr-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("input",{type:"text",value:u,onChange:e=>m(e.target.value),placeholder:r("aliasManager.commandPlaceholder"),className:"w-full px-3 py-2 rounded-lg border border-input bg-background text-sm font-mono focus:outline-none focus:ring-2 focus:ring-brand focus:border-transparent",onKeyDown:e=>{"Enter"!==e.key||e.nativeEvent.isComposing||(e.preventDefault(),p())}})]}),(0,n.jsx)("button",{onClick:p,disabled:!c.trim()||!u.trim(),className:"p-2 rounded-lg bg-brand text-brand-foreground hover:bg-brand/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:(0,n.jsx)(tZ.A,{className:"w-4 h-4"})})]}),(0,n.jsxs)("div",{className:"mt-4 p-3 bg-accent rounded-lg",children:[(0,n.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,n.jsx)("strong",{children:r("aliasManager.usage")}),r("aliasManager.usageDesc")]}),(0,n.jsxs)("div",{className:"mt-2 space-y-1 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ ll"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"ls -la"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"$ gs"}),(0,n.jsx)("span",{children:"→"}),(0,n.jsx)("code",{className:"px-1.5 py-0.5 bg-background rounded",children:"git status"})]})]})]}),0===Object.keys(l).length&&(0,n.jsx)("div",{className:"text-center py-8 text-muted-foreground text-sm",children:r("aliasManager.noAliases")})]})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,n.jsx)("button",{onClick:e,className:"px-4 py-2 rounded-lg text-sm hover:bg-accent transition-colors",children:r("common.cancel")}),(0,n.jsx)("button",{onClick:g,className:"px-4 py-2 rounded-lg text-sm bg-brand text-brand-foreground hover:bg-brand/90 transition-colors",children:r("common.save")})]})]})})}var t2=r(53961),t5=r(15813),t4=r(37595),t3=r(49698),t6=r(20232);let t8=new Map;function t9(e){t8.set(e.type,e)}function t7(e){return t8.get(e)}function re(e){for(let t of t8.values())if(t.match(e))return t;return null}let rt=(e,t)=>eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`)},catch:t=>new eT.uV({message:`POST ${e} failed`,cause:t})}),rr=(e,t)=>i.t4.runPromise(rt(`/api/${e}/disconnect`,{id:t}).pipe(eM.orElse(()=>eM.void))),rn=e=>i.t4.runPromise(rt("/api/browser/unregister",{id:e}).pipe(eM.orElse(()=>eM.void))),rs=e=>i.t4.runPromise(e.pipe(eM.catchAll(e=>eM.sync(()=>{if(e.cause instanceof Error)throw e.cause;throw Error(e.message)})))),ro=(e,t)=>{if(e&&"object"==typeof e&&"error"in e){let t=e.error;if("string"==typeof t&&t.length>0)return t;if(t&&"object"==typeof t){let e=t.message;if("string"==typeof e&&e.length>0)return e;let r=t._tag;if("string"==typeof r&&r.length>0)return r}}return`HTTP ${t}`},rl=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),n=await r.json();if(!r.ok)throw Error(ro(n,r.status));return n},catch:t=>new eT.uV({message:`POST ${e} failed`,cause:t})})),ra=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=new URLSearchParams(t),n=await fetch(`${e}?${r}`),s=await n.json();if(!n.ok)throw Error(ro(s,n.status));return s},catch:t=>new eT.uV({message:`GET ${e} failed`,cause:t})})),ri=(e,t)=>rs(eM.tryPromise({try:async()=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw Error(`HTTP ${r.status}`);return r.blob()},catch:t=>new eT.uV({message:`POST blob ${e} failed`,cause:t})}));var rc=r(53853);function rd(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.set("_cockpit","1"),t.toString()}catch{let t=e.includes("?")?"&":"?";return`${e}${t}_cockpit=1`}}function ru(e){if(!e)return e;try{let t=new URL(e);return t.searchParams.delete("_cockpit"),t.toString()}catch{return e.replace(/[?&]_cockpit=1/,"")}}async function rm(e){let t=(0,rc.f)()?.id??null;return!!t&&new Promise(r=>{try{let n=globalThis.chrome?.runtime;if(!n?.sendMessage)return void r(!1);let s=setTimeout(()=>r(!1),2e3);n.sendMessage(t,{type:"prepare-iframe",url:e},e=>{clearTimeout(s),r(e?.ok??!1)})}catch{r(!1)}})}function rx(e){try{let t=new URL(e).hostname;return"localhost"===t||"127.0.0.1"===t}catch{return!1}}function rh({url:e,id:t,selected:r,maximized:i,expandedHeight:c,bubbleContentHeight:d,onSelect:u,onClose:m,onToggleMaximize:x,onNewTab:h,timestamp:f,onTitleMouseDown:p,initialSleeping:g,onSleep:b,onWake:v}){let{t:j}=(0,o.Bd)(),[w,y]=(0,s.useState)(!1),[N,C]=(0,s.useState)(null),[S,L]=(0,s.useState)(e),[E,M]=(0,s.useState)(null),[T,$]=(0,s.useState)(g??!1),P=(0,s.useRef)(null),R=(0,s.useRef)(null),B=(0,s.useRef)(null);(0,s.useEffect)(()=>{L(e)},[e]);let F=(0,s.useRef)(!0),I=(0,s.useCallback)(()=>{T||($(!0),M(null),b?.(t))},[T,t,b]),D=(0,s.useCallback)(()=>{P.current&&(clearTimeout(P.current),P.current=null)},[]),{shortId:A,connected:_,connect:W,disconnect:z}=function(e,t,r){let n=(0,s.useMemo)(()=>tB(e),[e]),[o,i]=(0,s.useState)(!1),c=(0,s.useRef)(null),d=(0,s.useRef)([]),u=(0,s.useRef)(null),m=(0,s.useRef)(!1),x=(0,s.useRef)(r);(0,s.useEffect)(()=>{x.current=r});let h=(0,s.useRef)([]);(0,s.useEffect)(()=>{let e=e=>{if(e.data?.type==="cockpit:cmd-result"){let{reqId:t,ok:r,data:n,error:s}=e.data,o=c.current;o&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"browser:cmd-result",reqId:t,ok:r,data:n,error:s}));return}if(e.data?.type==="cockpit:prepare-screenshot"){let r=t.current;if(!r?.contentWindow)return;let n=new URLSearchParams(window.location.search).get("cwd")||"";window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!0}})),(0,l.F)(a.n.ScreenshotPrepare,{cwd:n}),requestAnimationFrame(()=>requestAnimationFrame(()=>requestAnimationFrame(()=>{setTimeout(()=>{let t=r.getBoundingClientRect(),n=window.devicePixelRatio||1,s=t.x,o=t.y;try{let e=window;for(;e!==e.top;){let t=e.frameElement;if(t){let e=t.getBoundingClientRect();s+=e.x,o+=e.y}e=e.parent}}catch{}r.contentWindow?.postMessage({type:"cockpit:screenshot-bounds",reqId:e.data.reqId,bounds:{x:Math.round(s*n),y:Math.round(o*n),width:Math.round(t.width*n),height:Math.round(t.height*n),dpr:n}},"*")},150)})));return}if(e.data?.type==="cockpit:screenshot-done"){window.dispatchEvent(new CustomEvent("cockpit-screenshot-state",{detail:{active:!1}})),(0,l.F)(a.n.ScreenshotDone,{});return}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[]);let f=(0,s.useCallback)(e=>{let r=t.current;if(!r?.contentWindow){let t=c.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify({type:"browser:cmd-result",reqId:e.reqId,ok:!1,error:"iframe not available (page may be sleeping)"}));return}r.contentWindow.postMessage({type:"cockpit:cmd",reqId:e.reqId,action:e.action,params:e.params},"*")},[t]);(0,s.useEffect)(()=>{if(!o)return;let r=!1;return m.current=!0,!function n(){if(r||!m.current)return;let s="https:"===window.location.protocol?"wss:":"ws:",o=new WebSocket(`${s}//${window.location.host}/ws/browser?fullId=${encodeURIComponent(e)}`);c.current=o,o.onopen=()=>{for(let e of h.current)e();if(h.current=[],d.current.length>0){for(let e of d.current)f(e);d.current=[]}},o.onmessage=e=>{let r;try{r=JSON.parse(e.data)}catch{return}if("browser:cmd"===r.type){let e=r;t.current?.contentWindow&&x.current?f(e):d.current.push(e)}},o.onclose=()=>{c.current=null,!r&&m.current&&(u.current=setTimeout(n,3e3))},o.onerror=()=>o.close()}(),()=>{r=!0,m.current=!1,u.current&&clearTimeout(u.current),c.current&&(c.current.close(),c.current=null),h.current=[]}},[o,e,t,f]),(0,s.useEffect)(()=>{if(r&&d.current.length>0){for(let e of d.current)f(e);d.current=[]}},[r,f]);let p=(0,s.useCallback)(()=>o&&c.current?.readyState===WebSocket.OPEN?Promise.resolve():new Promise(e=>{h.current.push(e),o||i(!0)}),[o]);return{shortId:n,connected:o,connect:p,disconnect:(0,s.useCallback)(()=>{i(!1)},[])}}(t,B,!!E&&!T&&!w),H=(0,s.useRef)(_);H.current=_,(0,s.useEffect)(()=>{let e=R.current;if(!e||T)return;let t=new IntersectionObserver(([e])=>{F.current=e.isIntersecting,e.isIntersecting||H.current?D():(P.current&&clearTimeout(P.current),P.current=setTimeout(I,3e5))});return t.observe(e),()=>t.disconnect()},[T,I,D]),(0,s.useEffect)(()=>{T?z():_?D():F.current||(P.current&&clearTimeout(P.current),P.current=setTimeout(I,3e5))},[_,T,z,D,I]),(0,s.useEffect)(()=>{g&&M(null)},[]);let O=(0,s.useCallback)(()=>{$(!1),v?.(t);let r=rd(e);rx(e)?M(r):rm(e).then(()=>M(r))},[e,t,v]);(0,s.useEffect)(()=>{if(!e||T){e||M(null);return}let t=rd(e);if(rx(e))return void M(t);let r=!1;return rm(e).then(()=>{r||M(t)}),()=>{r=!0}},[e,T]);let q=(0,s.useCallback)(()=>y(!1),[]);(0,s.useEffect)(()=>{let e=R.current;if(!e)return;let t=null,r=e.parentElement;for(;r;){let{overflowY:e}=getComputedStyle(r);if("auto"===e||"scroll"===e){t=r;break}r=r.parentElement}if(!t)return;let n="",s=0,o=!1,l=()=>{o&&t&&(t.scrollTop=s)},a=()=>{n=t.style.overflow,s=t.scrollTop,o=!0,t.style.overflow="hidden",t.addEventListener("scroll",l)},i=()=>{o=!1,t.removeEventListener("scroll",l),t.style.overflow=n};return e.addEventListener("mouseenter",a),e.addEventListener("mouseleave",i),()=>{e.removeEventListener("mouseenter",a),e.removeEventListener("mouseleave",i),t.removeEventListener("scroll",l),o&&(t.style.overflow=n)}},[]),(0,s.useEffect)(()=>{let e=e=>{if(!e.data||"string"!=typeof e.data.type||!e.data.type.startsWith("cockpit:"))return;let r=R.current?.querySelector("iframe");if(!r||e.source!==r.contentWindow)return;let n=e.data.type;"cockpit:new-tab"===n&&e.data.url?h?.(ru(e.data.url),t):("cockpit:navigate"===n||"cockpit:loaded"===n)&&e.data.url&&L(ru(e.data.url))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[t,h]);let V=(0,s.useCallback)(()=>{y(!1),C(j("browser.pageLoadFailed"))},[]),K=(0,s.useCallback)(()=>{if(T)return void O();let e=R.current?.querySelector("iframe");if(e&&E){y(!0),C(null);let t=e.src;e.src="",setTimeout(()=>{e.src=t},0)}},[T,O,E]);(0,s.useEffect)(()=>{e&&!T&&(y(!0),C(null))},[e,T]);let U=(0,s.useCallback)(()=>{S&&window.open(S,"_blank")},[S]);(0,s.useEffect)(()=>{if(!r&&!i)return;let e=e=>{"Escape"===e.key&&i&&(e.stopPropagation(),x()),"m"===e.key&&(e.metaKey||e.ctrlKey)&&r&&(e.preventDefault(),e.stopPropagation(),x())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[i,r,x]);let J=function(e){if(!e)return"";try{let t=new URL(e);return t.port?`${t.hostname}:${t.port}`:t.hostname}catch{return e}}(S),Q=i&&c?c-41:d??360;return(0,n.jsx)("div",{className:"flex flex-col items-start",children:(0,n.jsxs)("div",{className:`w-full bg-accent text-foreground
2
2
  relative transition-colors cursor-pointer
3
3
  ${i?"rounded-none overflow-visible border-0":"border overflow-hidden rounded-2xl rounded-bl-md rounded-br-md"}
4
4
  ${i?"":r?"border-brand":"border-brand/30"}`,onClick:i?void 0:u,children:[i?(0,n.jsxs)("div",{onDoubleClick:x,className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-card",style:{height:41},children:[(0,n.jsx)("span",{className:"text-[10px] font-mono leading-none px-1 py-0.5 rounded flex-shrink-0 bg-muted text-muted-foreground",children:(0,n.jsx)("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})})}),A&&(0,n.jsx)(tF,{shortId:A,type:"browser",onRegister:()=>W(),onUnregister:async()=>{z(),await rn(A)}}),(0,n.jsx)("span",{className:"text-xs text-muted-foreground truncate font-mono",children:S||j("browser.blankPage")}),S&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(S),(0,k.oR)(j("toast.copiedUrl"))},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:j("browser.copyUrl"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),(0,n.jsx)("span",{className:"flex-1"}),w&&(0,n.jsx)("span",{className:"inline-block w-3 h-3 border border-brand border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,n.jsx)("button",{onClick:K,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:j("common.refresh"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),(0,n.jsx)("button",{onClick:U,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:j("browser.openInNewWindow"),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),(0,n.jsx)("button",{onClick:x,className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors flex-shrink-0",title:j("browser.exitMaximize",{modKey:(0,tI.Mu)()}),children:(0,n.jsx)("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 3v3a2 2 0 01-2 2H3m18 0h-3a2 2 0 01-2-2V3m0 18v-3a2 2 0 012-2h3M3 16h3a2 2 0 012 2v3"})})})]}):(0,n.jsxs)("div",{"data-drag-handle":!0,onMouseDown:()=>p?.(),onDoubleClick:e=>{e.stopPropagation(),x()},className:`flex items-center gap-2 px-4 py-1.5 border-b text-xs transition-colors cursor-grab active:cursor-grabbing