agent-tower 0.7.0 → 0.7.1-beta.1

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 (140) hide show
  1. package/dist/runtime/__tests__/acp-process-manager.test.js +62 -11
  2. package/dist/runtime/__tests__/acp-process-manager.test.js.map +1 -1
  3. package/dist/runtime/__tests__/deepseek-hermes-definition.test.js +6 -3
  4. package/dist/runtime/__tests__/deepseek-hermes-definition.test.js.map +1 -1
  5. package/dist/runtime/__tests__/tool-frame-normalizer.test.d.ts +2 -0
  6. package/dist/runtime/__tests__/tool-frame-normalizer.test.d.ts.map +1 -0
  7. package/dist/runtime/__tests__/tool-frame-normalizer.test.js +120 -0
  8. package/dist/runtime/__tests__/tool-frame-normalizer.test.js.map +1 -0
  9. package/dist/runtime/acp/agents/codex.js +3 -3
  10. package/dist/runtime/acp/agents/codex.js.map +1 -1
  11. package/dist/runtime/acp/agents/deepseek-hermes.d.ts +0 -1
  12. package/dist/runtime/acp/agents/deepseek-hermes.d.ts.map +1 -1
  13. package/dist/runtime/acp/agents/deepseek-hermes.js +7 -10
  14. package/dist/runtime/acp/agents/deepseek-hermes.js.map +1 -1
  15. package/dist/runtime/acp/agents/native-agent.d.ts +3 -1
  16. package/dist/runtime/acp/agents/native-agent.d.ts.map +1 -1
  17. package/dist/runtime/acp/agents/native-agent.js +1 -0
  18. package/dist/runtime/acp/agents/native-agent.js.map +1 -1
  19. package/dist/runtime/acp/agents/tool-frame-normalizer.d.ts +25 -0
  20. package/dist/runtime/acp/agents/tool-frame-normalizer.d.ts.map +1 -0
  21. package/dist/runtime/acp/agents/tool-frame-normalizer.js +192 -0
  22. package/dist/runtime/acp/agents/tool-frame-normalizer.js.map +1 -0
  23. package/dist/runtime/acp/process-manager.js +14 -6
  24. package/dist/runtime/acp/process-manager.js.map +1 -1
  25. package/dist/web/assets/{AgentDemoPage-B_9OhUu7.js → AgentDemoPage-B6pABvRL.js} +1 -1
  26. package/dist/web/assets/{AgentEnvironmentSettingsPage-D7pZQLiC.js → AgentEnvironmentSettingsPage-CqMfdwkM.js} +1 -1
  27. package/dist/web/assets/{AgentLogo-C0bPAxbG.js → AgentLogo-Ntqe3_Mx.js} +1 -1
  28. package/dist/web/assets/{ConversationPage-BkIJfuUB.js → ConversationPage-BINGA8XL.js} +1 -1
  29. package/dist/web/assets/{CreateTaskInput-CS9ktr5a.js → CreateTaskInput-8bLhHYOc.js} +1 -1
  30. package/dist/web/assets/{DemoPage-D5HfzpfS.js → DemoPage-D1Ki6sJ0.js} +1 -1
  31. package/dist/web/assets/{GeneralSettingsPage-CKFLk4bt.js → GeneralSettingsPage-DoAXPabw.js} +1 -1
  32. package/dist/web/assets/{Icons-CqVh1zOu.js → Icons-KJJd6C8K.js} +1 -1
  33. package/dist/web/assets/{LoadingPreviewPage-DWr9Bc06.js → LoadingPreviewPage-BqCKBvgv.js} +1 -1
  34. package/dist/web/assets/{McpSettingsPage-GDNWUFUx.js → McpSettingsPage-QXVD4XCW.js} +1 -1
  35. package/dist/web/assets/{MemberAvatar-BA3zVRhl.js → MemberAvatar-kbJEoyh0.js} +1 -1
  36. package/dist/web/assets/{NotificationSettingsPage-OpJo7zJ4.js → NotificationSettingsPage-BrqSeU--.js} +1 -1
  37. package/dist/web/assets/{ProfileSettingsPage-DYV5Up2y.js → ProfileSettingsPage-BmWgVdnG.js} +1 -1
  38. package/dist/web/assets/{ProjectKanbanPage-DNhv4WcA.js → ProjectKanbanPage-D7RJm4yg.js} +3 -3
  39. package/dist/web/assets/{ProjectSettingsPage-DJ5LIrW5.js → ProjectSettingsPage-BVINN99w.js} +1 -1
  40. package/dist/web/assets/{ProviderSettingsPage-DkKvjXXL.js → ProviderSettingsPage-BlgfQMwe.js} +1 -1
  41. package/dist/web/assets/{SettingsMasterDetail-nkWk1iMZ.js → SettingsMasterDetail-OF28cvPV.js} +1 -1
  42. package/dist/web/assets/{TeamSettingsPage-B6paYIi8.js → TeamSettingsPage-BWGm0m7s.js} +1 -1
  43. package/dist/web/assets/{arc-D6K3W0ZB.js → arc-CqFgRaZU.js} +1 -1
  44. package/dist/web/assets/{architectureDiagram-3BPJPVTR-CnyQ4xAO.js → architectureDiagram-3BPJPVTR-C0PMdIZJ.js} +1 -1
  45. package/dist/web/assets/{blockDiagram-GPEHLZMM-BFL71oe3.js → blockDiagram-GPEHLZMM-SqqtxqkX.js} +1 -1
  46. package/dist/web/assets/{c4Diagram-AAUBKEIU-Cv39zyqp.js → c4Diagram-AAUBKEIU-DYJXB3xL.js} +1 -1
  47. package/dist/web/assets/channel-B8s9dqlX.js +1 -0
  48. package/dist/web/assets/check-C1zWgxFO.js +1 -0
  49. package/dist/web/assets/{chevron-down-F0HaYv4G.js → chevron-down-BZfpVhYr.js} +1 -1
  50. package/dist/web/assets/{chevron-right-CPwvo275.js → chevron-right-D52zUyOF.js} +1 -1
  51. package/dist/web/assets/{chevron-up-DS7W1CS_.js → chevron-up-CFOy5dmW.js} +1 -1
  52. package/dist/web/assets/{chunk-2J33WTMH-o03x4Lwh.js → chunk-2J33WTMH-DQCbv8W_.js} +1 -1
  53. package/dist/web/assets/{chunk-4BX2VUAB-OMTDHlMp.js → chunk-4BX2VUAB-B_68_oNW.js} +1 -1
  54. package/dist/web/assets/{chunk-55IACEB6-BYhGICji.js → chunk-55IACEB6-Bb-pPIxs.js} +1 -1
  55. package/dist/web/assets/{chunk-727SXJPM-DzoqZgN8.js → chunk-727SXJPM-CAiaySk6.js} +1 -1
  56. package/dist/web/assets/{chunk-AQP2D5EJ-RWSpIm7i.js → chunk-AQP2D5EJ-ChCLJ4Wv.js} +1 -1
  57. package/dist/web/assets/{chunk-FMBD7UC4-A8Ezik8l.js → chunk-FMBD7UC4-Kz0Cc0mv.js} +1 -1
  58. package/dist/web/assets/{chunk-ND2GUHAM-l8t1S54b.js → chunk-ND2GUHAM-BttoT7UR.js} +1 -1
  59. package/dist/web/assets/{chunk-QZHKN3VN-CfzOWd9g.js → chunk-QZHKN3VN-BcVhzXXK.js} +1 -1
  60. package/dist/web/assets/{circle-alert-D_JK6Nsk.js → circle-alert-D67xfWMs.js} +1 -1
  61. package/dist/web/assets/classDiagram-4FO5ZUOK-61bPx188.js +1 -0
  62. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-61bPx188.js +1 -0
  63. package/dist/web/assets/{code-block-OCS4YCEC-DOp940bN.js → code-block-OCS4YCEC-CMA1utSp.js} +1 -1
  64. package/dist/web/assets/{confirm-dialog-BOmXWU-c.js → confirm-dialog-BWvZEHpu.js} +1 -1
  65. package/dist/web/assets/{cose-bilkent-S5V4N54A-D2t-do1X.js → cose-bilkent-S5V4N54A-B391zTey.js} +1 -1
  66. package/dist/web/assets/{cssMode-BtqVF1ly.js → cssMode-CNU1q_Gl.js} +1 -1
  67. package/dist/web/assets/{dagre-BM42HDAG-BtYlmBNC.js → dagre-BM42HDAG-CymH_FEZ.js} +1 -1
  68. package/dist/web/assets/{diagram-2AECGRRQ-WDOcMaWr.js → diagram-2AECGRRQ-DXOIiLDr.js} +1 -1
  69. package/dist/web/assets/{diagram-5GNKFQAL-LbMipgIf.js → diagram-5GNKFQAL-B9ocgjdh.js} +1 -1
  70. package/dist/web/assets/{diagram-KO2AKTUF-DsKCSLdx.js → diagram-KO2AKTUF-DLMpk9Wg.js} +1 -1
  71. package/dist/web/assets/{diagram-LMA3HP47-DUkuN6RR.js → diagram-LMA3HP47-BBnF83je.js} +1 -1
  72. package/dist/web/assets/{diagram-OG6HWLK6-DLyJH0mw.js → diagram-OG6HWLK6-AK4FunVI.js} +1 -1
  73. package/dist/web/assets/{erDiagram-TEJ5UH35-kZ9_YLwi.js → erDiagram-TEJ5UH35-B1mryURg.js} +1 -1
  74. package/dist/web/assets/{flowDiagram-I6XJVG4X-CtWP6zim.js → flowDiagram-I6XJVG4X-BjIG_1l5.js} +1 -1
  75. package/dist/web/assets/{folder-picker-ClBdFSv_.js → folder-picker-CaM_drIJ.js} +1 -1
  76. package/dist/web/assets/{freemarker2-Cz_cflgL.js → freemarker2-Dj1C_6Ng.js} +1 -1
  77. package/dist/web/assets/{ganttDiagram-6RSMTGT7-Cpsrbddz.js → ganttDiagram-6RSMTGT7-DjR6lyIQ.js} +1 -1
  78. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-Z2AN7JLu.js → gitGraphDiagram-PVQCEYII-BpW2L4ry.js} +1 -1
  79. package/dist/web/assets/{handlebars-DXQ11OYe.js → handlebars-DNXOgRZc.js} +1 -1
  80. package/dist/web/assets/{html-CPKzsFQJ.js → html-C20FgNS-.js} +1 -1
  81. package/dist/web/assets/{htmlMode-BuLIJ65E.js → htmlMode-CtcV1Ktd.js} +1 -1
  82. package/dist/web/assets/{index-BPuQ0J75.js → index-DaRxJqVy.js} +4 -4
  83. package/dist/web/assets/{index-DJqjl4es.js → index-oC5eh7mZ.js} +3 -3
  84. package/dist/web/assets/{infoDiagram-5YYISTIA-CG5Z1SIw.js → infoDiagram-5YYISTIA-Cu-PA_-6.js} +1 -1
  85. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CI-1kybP.js → ishikawaDiagram-YF4QCWOH-S6Esbkdw.js} +1 -1
  86. package/dist/web/assets/javascript-CFAVZ6Tb.js +1 -0
  87. package/dist/web/assets/{journeyDiagram-JHISSGLW-Yf0W6ar4.js → journeyDiagram-JHISSGLW-wPF9FT9V.js} +1 -1
  88. package/dist/web/assets/{jsonMode-D7mGQAMX.js → jsonMode-D6IoFlQF.js} +1 -1
  89. package/dist/web/assets/{kanban-definition-UN3LZRKU-CSo-Ej3T.js → kanban-definition-UN3LZRKU-C4jl9zOj.js} +1 -1
  90. package/dist/web/assets/{layers-E7xs4_fY.js → layers-hQUUT3Gb.js} +1 -1
  91. package/dist/web/assets/{linear-bYzPbs_W.js → linear-D83xDp0H.js} +1 -1
  92. package/dist/web/assets/{liquid-D1dGDf_h.js → liquid-CuzuRJIN.js} +1 -1
  93. package/dist/web/assets/{lspLanguageFeatures-Fa-E2Zl-.js → lspLanguageFeatures-CUyibjAN.js} +1 -1
  94. package/dist/web/assets/{mdx-CRf_kl0j.js → mdx-C3rxTvel.js} +1 -1
  95. package/dist/web/assets/{mermaid-NOHMQCX5-9Sp0Awb9.js → mermaid-NOHMQCX5-CGCWmHha.js} +5 -5
  96. package/dist/web/assets/{message-square-CQV6Jqyx.js → message-square-B-uYQiTq.js} +1 -1
  97. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DfqJHEQn.js → mindmap-definition-RKZ34NQL-D5v2uvjn.js} +1 -1
  98. package/dist/web/assets/{modal-BUKaDX-v.js → modal-D87uszzb.js} +1 -1
  99. package/dist/web/assets/{monaco-uSRaugmx.js → monaco-B25-2nEB.js} +3 -3
  100. package/dist/web/assets/{pencil-BRpoyX8s.js → pencil-CY2RnQrx.js} +1 -1
  101. package/dist/web/assets/{pieDiagram-4H26LBE5-D6mZqc_7.js → pieDiagram-4H26LBE5-6wdFz_7x.js} +1 -1
  102. package/dist/web/assets/{python-b877PDdg.js → python-BYGLbOzO.js} +1 -1
  103. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DCcabkRn.js → quadrantDiagram-W4KKPZXB-C1CrGMEK.js} +1 -1
  104. package/dist/web/assets/{razor-Bi1FXUoZ.js → razor-m0U9iUAj.js} +1 -1
  105. package/dist/web/assets/{requirementDiagram-4Y6WPE33-CP6GHzII.js → requirementDiagram-4Y6WPE33-mDtZrxpp.js} +1 -1
  106. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-BNJypqP0.js → sankeyDiagram-5OEKKPKP-hBlj0XoH.js} +1 -1
  107. package/dist/web/assets/{select-DQiySo8W.js → select-D7WkUiad.js} +1 -1
  108. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CTceFzh8.js → sequenceDiagram-3UESZ5HK-DsWmMm20.js} +1 -1
  109. package/dist/web/assets/{server-Du56rX8Y.js → server-qlZupTvg.js} +1 -1
  110. package/dist/web/assets/{stateDiagram-AJRCARHV-CW_WR-7F.js → stateDiagram-AJRCARHV-VNyX1L66.js} +1 -1
  111. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DHz3oGyD.js +1 -0
  112. package/dist/web/assets/{switch-Bmbr34G9.js → switch-1pvXCcP-.js} +1 -1
  113. package/dist/web/assets/{textarea-SORnJi9y.js → textarea-D9oaz-Ba.js} +1 -1
  114. package/dist/web/assets/{timeline-definition-PNZ67QCA-YMyJrcx3.js → timeline-definition-PNZ67QCA-DuBxxd9E.js} +1 -1
  115. package/dist/web/assets/{trash-2-BeXtY9XM.js → trash-2-C0P8jNpJ.js} +1 -1
  116. package/dist/web/assets/{tsMode-PVZGxtwF.js → tsMode-ogL-3MSe.js} +1 -1
  117. package/dist/web/assets/{typescript-Lb9pWYyY.js → typescript-rHoDxTY8.js} +1 -1
  118. package/dist/web/assets/{upload-mXU9O8ZR.js → upload-BYgsDplu.js} +1 -1
  119. package/dist/web/assets/{use-profiles-CwhDBM9-.js → use-profiles-BkGnmson.js} +1 -1
  120. package/dist/web/assets/{use-projects-FC2A-qiG.js → use-projects-B4w00h5I.js} +1 -1
  121. package/dist/web/assets/{use-providers-BzZ7Dpm4.js → use-providers-B70-BYNu.js} +1 -1
  122. package/dist/web/assets/{useNormalizedLogs-Cxh15U2o.js → useNormalizedLogs-MsDkcnRQ.js} +1 -1
  123. package/dist/web/assets/{vennDiagram-CIIHVFJN-2FtrQsyg.js → vennDiagram-CIIHVFJN-RbPPOLBo.js} +1 -1
  124. package/dist/web/assets/{wardley-L42UT6IY-DzhpFsrC.js → wardley-L42UT6IY-DXzUbdMF.js} +1 -1
  125. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-SWglvyXQ.js → wardleyDiagram-YWT4CUSO-B0QXobQM.js} +1 -1
  126. package/dist/web/assets/{xml-aN9gPs-U.js → xml-BqnpQrAq.js} +1 -1
  127. package/dist/web/assets/{xychartDiagram-2RQKCTM6-BMScKGN8.js → xychartDiagram-2RQKCTM6-C7bFJItM.js} +1 -1
  128. package/dist/web/assets/{yaml-iYUoM2EE.js → yaml-mz2Zn_K2.js} +1 -1
  129. package/dist/web/index.html +1 -1
  130. package/package.json +1 -1
  131. package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts +0 -4
  132. package/dist/runtime/acp/agents/codex-frame-normalizer.d.ts.map +0 -1
  133. package/dist/runtime/acp/agents/codex-frame-normalizer.js +0 -120
  134. package/dist/runtime/acp/agents/codex-frame-normalizer.js.map +0 -1
  135. package/dist/web/assets/channel-DIRGk9YF.js +0 -1
  136. package/dist/web/assets/check-D0G5G0XX.js +0 -1
  137. package/dist/web/assets/classDiagram-4FO5ZUOK-B7c8qeN5.js +0 -1
  138. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-B7c8qeN5.js +0 -1
  139. package/dist/web/assets/javascript-CWV4KdLq.js +0 -1
  140. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Veali8j7.js +0 -1
@@ -1,3 +1,3 @@
1
- import{u as T,r as g,j as e,S,g as J,v as M,w,I as U,B as E,x as p,l as P}from"./index-DJqjl4es.js";import{u as _,a as z,b as B,c as F}from"./use-profiles-CwhDBM9-.js";import{M as G}from"./modal-BUKaDX-v.js";import{C as $}from"./confirm-dialog-BOmXWU-c.js";import{T as R}from"./textarea-SORnJi9y.js";import{L as H}from"./layers-E7xs4_fY.js";import{C as q}from"./chevron-down-F0HaYv4G.js";import{P as K,T as Q}from"./trash-2-BeXtY9XM.js";import{P as W}from"./pencil-BRpoyX8s.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(K,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx(Q,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=_(),{data:c}=z(),h=B(),j=F(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
1
+ import{u as T,r as g,j as e,S,g as J,v as M,w,I as U,B as E,x as p,l as P}from"./index-oC5eh7mZ.js";import{u as _,a as z,b as B,c as F}from"./use-profiles-BkGnmson.js";import{M as G}from"./modal-D87uszzb.js";import{C as $}from"./confirm-dialog-BWvZEHpu.js";import{T as R}from"./textarea-D9oaz-Ba.js";import{L as H}from"./layers-hQUUT3Gb.js";import{C as q}from"./chevron-down-BZfpVhYr.js";import{P as K,T as Q}from"./trash-2-C0P8jNpJ.js";import{P as W}from"./pencil-CY2RnQrx.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(K,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx(Q,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=_(),{data:c}=z(),h=B(),j=F(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
2
2
 
3
3
  }`),v("")},D=()=>{if(!(!n||!i.trim()))try{const s=JSON.parse(b);v(""),h.mutate({agentType:n.agentType,variant:i.trim().toUpperCase(),config:s},{onSuccess:()=>r(null)})}catch{v(t("JSON 格式错误"))}},L=(s,l)=>{N({agentType:s,variant:l})},A=()=>{o&&j.mutate({agentType:o.agentType,variant:o.variant},{onSettled:()=>N(null)})},I=(s,l)=>!!c?.executors[s]?.[l];if(m)return e.jsx(S,{children:e.jsx(Z,{})});const C=a?.executors??{};return e.jsxs(S,{children:[e.jsx(J,{title:t("Profile 配置"),description:t("管理 Agent 执行器的配置变体。每个变体定义一组运行参数。"),className:"mb-4"}),e.jsx("div",{className:"space-y-3",children:Object.entries(C).map(([s,l])=>e.jsx(Y,{agentType:s,variants:l,isBuiltIn:d=>I(s,d),onEdit:(d,V)=>k(s,d,V),onNew:()=>O(s),onDelete:d=>L(s,d)},s))}),Object.keys(C).length===0&&e.jsx(M,{icon:H,message:t("暂无 Profile 配置")}),e.jsx(G,{isOpen:!!n,onClose:()=>r(null),title:n?.isNew?t("新增 Variant — {agentType}",{agentType:y[n.agentType]??n.agentType}):t("编辑 {variant}",{variant:n?.variant??""}),action:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outline",onClick:()=>r(null),children:t("取消")}),e.jsx(E,{onClick:D,disabled:h.isPending,children:h.isPending?t("保存中..."):t("保存")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{label:t("Variant 名称"),htmlFor:"profile-variant-name",children:e.jsx(U,{id:"profile-variant-name",value:i,onChange:s=>x(s.target.value),disabled:!n?.isNew,placeholder:t("例如: CUSTOM"),className:"font-mono"})}),e.jsxs(w,{label:t("配置 (JSON)"),htmlFor:"profile-variant-json",children:[e.jsx(R,{id:"profile-variant-json",value:b,onChange:s=>{u(s.target.value),v("")},rows:6,className:"resize-none font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:f})]})]})}),e.jsx($,{isOpen:o!==null,onClose:()=>{j.isPending||N(null)},onConfirm:A,title:t("删除 Profile Variant"),description:o?t('确定删除 "{name}"?此操作不可撤销。',{name:`${y[o.agentType]??o.agentType} / ${o.variant}`}):"",confirmText:t("删除"),cancelText:t("取消"),variant:"danger",isLoading:j.isPending})]})}export{de as ProfileSettingsPage};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-uSRaugmx.js","assets/index-DJqjl4es.js","assets/index-dElqH2UR.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{aj as gd,ak as ho,al as vd,am as xd,an as bd,k as Ke,r as b,ao as ue,D as Ss,m as Et,ap as js,n as Wt,p as ye,o as xt,q as ce,u as de,j as t,aa as _t,Z as Pa,_ as _d,l as te,a0 as Us,B as Ae,aq as La,ar as Ia,as as Oa,ah as ks,X as Kt,at as Sn,au as yd,P as _r,av as Sd,E as wd,aw as Cd,ax as kd,ay as Ed,T as Ns,t as at,V as os,W as ut,Y as zs,Q as Be,az as Rs,U as cr,aA as jd,aB as ci,ai as Nd,af as Ba,s as qs,ag as Rd,aC as Fa,aD as wn,a6 as Ad,aE as za,aF as Wa,aG as Ha,aH as $a,aI as Td,aJ as Md,a3 as Dd,aK as Pd,aL as Ld,aM as Id,$ as fo,a9 as mo}from"./index-DJqjl4es.js";import{S as ht,l as rn,u as Cn,A as kn,m as Od,F as Ua,p as Bd,o as Fd,q as zd,Q as En,r as Wd,t as Dt,W as bt,v as qa,C as mr,w as Br,x as Hd,y as $d,z as Ud,T as qd,h as Nt,b as Vr,B as Ka,D as Ut}from"./mermaid-NOHMQCX5-9Sp0Awb9.js";import{C as jn}from"./confirm-dialog-BOmXWU-c.js";import{c as Va,a as Xa,b as Ya,I as Ga,d as Qa,A as po,G as Za}from"./Icons-CqVh1zOu.js";import{e as go,f as Kd,d as Nn,S as Vd,u as Rn,A as pr,c as An,G as Ja,Z as Xd,g as Tn,T as Mn,h as Yd,i as Dn,j as vo,k as Gd,b as el,l as tl,a as sl,m as rl,n as il,R as nl,P as ol,o as Xr,p as Qd,C as xo,B as bo}from"./CreateTaskInput-CS9ktr5a.js";import{C as St}from"./chevron-down-F0HaYv4G.js";import{C as At}from"./chevron-right-CPwvo275.js";import{a as Zd,F as Jd,b as eu}from"./folder-picker-ClBdFSv_.js";import{M as di}from"./message-square-CQV6Jqyx.js";import{L as Ks}from"./layers-E7xs4_fY.js";import{P as Pn,C as tu,u as al,a as ll,L as Yr,T as Gr}from"./useNormalizedLogs-Cxh15U2o.js";import{u as Ys}from"./use-providers-BzZ7Dpm4.js";import{A as ui}from"./AgentLogo-C0bPAxbG.js";import{M as qt}from"./MemberAvatar-BA3zVRhl.js";import{C as cl}from"./chevron-up-DS7W1CS_.js";import{C as Vt}from"./check-D0G5G0XX.js";import{M as fs}from"./modal-BUKaDX-v.js";import{S as as}from"./select-DQiySo8W.js";import{P as ls,T as Ln}from"./trash-2-BeXtY9XM.js";import{T as su}from"./textarea-SORnJi9y.js";import{S as nn,C as _o}from"./server-Du56rX8Y.js";import{F as In,e as ru,d as iu,f as nu,u as ou}from"./use-projects-FC2A-qiG.js";import{U as Qr}from"./upload-mXU9O8ZR.js";import{P as au}from"./pencil-BRpoyX8s.js";var lu=class extends gd{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ho()})}getOptimisticResult(e){return e.behavior=ho(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:x,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,a=x&&n==="forward",h=p&&n==="forward",c=x&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xd(s,r.data),hasPreviousPage:vd(s,r.data),isFetchNextPageError:a,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!h&&!g}}};function On(e,s){return bd(e,lu)}const cu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dl=Ke("arrow-right",cu);const du=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ul=Ke("ban",du);const uu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],hu=Ke("chevron-left",uu);const fu=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],mu=Ke("clipboard-paste",fu);const pu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",pu);const gu=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],hi=Ke("code-xml",gu);const vu=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],yo=Ke("copy-plus",vu);const xu=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],bu=Ke("earth",xu);const _u=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],hl=Ke("ellipsis-vertical",_u);const yu=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Su=Ke("file-braces-corner",yu);const wu=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Zr=Ke("file-code-corner",wu);const Cu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ku=Ke("file-exclamation-point",Cu);const Eu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],fi=Ke("folder-open",Eu);const ju=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Gs=Ke("git-graph",ju);const Nu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Vs=Ke("history",Nu);const Ru=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Au=Ke("maximize",Ru);const Tu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Mu=Ke("panel-left-close",Tu);const Du=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Pu=Ke("panel-left-open",Du);const Lu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Iu=Ke("panel-right-close",Lu);const Ou=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],on=Ke("panel-right-open",Ou);const Bu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Fu=Ke("pen-line",Bu);const zu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ws=Ke("play",zu);const Wu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],fl=Ke("settings-2",Wu);const Hu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],So=Ke("smartphone",Hu);const $u=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Fr=Ke("user-plus",$u);const Uu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qu=Ke("zoom-in",Uu);const Ku=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Vu=Ke("zoom-out",Ku),mi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Bn(e){return"nodeType"in e}function wt(e){var s,r;return e?Qs(e)?e:Bn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Fn(e){const{Document:s}=wt(e);return e instanceof s}function yr(e){return Qs(e)?!1:e instanceof wt(e).HTMLElement}function ml(e){return e instanceof wt(e).SVGElement}function Zs(e){return e?Qs(e)?e.document:Bn(e)?Fn(e)?e:yr(e)||ml(e)?e.ownerDocument:document:document:document}const Jt=mi?b.useLayoutEffect:b.useEffect;function pi(e){const s=b.useRef(e);return Jt(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Xu(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function gr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return Jt(()=>{r.current!==e&&(r.current=e)},s),r}function Sr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Jr(e){const s=pi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function ei(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Pi={};function gi(e,s){return b.useMemo(()=>{if(s)return s;const r=Pi[e]==null?0:Pi[e]+1;return Pi[e]=r,e+"-"+r},[e,s])}function pl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,x)=>{const i=Object.entries(x);for(const[n,a]of i){const h=m[n];h!=null&&(m[n]=h+e*a)}return m},{...s})}}const $s=pl(1),ti=pl(-1);function Yu(e){return"clientX"in e&&"clientY"in e}function zn(e){if(!e)return!1;const{KeyboardEvent:s}=wt(e.target);return s&&e instanceof s}function Gu(e){if(!e)return!1;const{TouchEvent:s}=wt(e.target);return s&&e instanceof s}function si(e){if(Gu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Yu(e)?{x:e.clientX,y:e.clientY}:null}const vr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[vr.Translate.toString(e),vr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),wo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Qu(e){return e.matches(wo)?e:e.querySelector(wo)}const Zu={display:"none"};function Ju(e){let{id:s,value:r}=e;return ue.createElement("div",{id:s,style:Zu},r)}function eh(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function th(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const gl=b.createContext(null);function sh(e){const s=b.useContext(gl);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function rh(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(x=>{var i;return(i=x[p])==null?void 0:i.call(x,m)})},[e]),s]}const ih={draggable:`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-B25-2nEB.js","assets/index-oC5eh7mZ.js","assets/index-dElqH2UR.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
+ import{aj as gd,ak as ho,al as vd,am as xd,an as bd,k as Ke,r as b,ao as ue,D as Ss,m as Et,ap as js,n as Wt,p as ye,o as xt,q as ce,u as de,j as t,aa as _t,Z as Pa,_ as _d,l as te,a0 as Us,B as Ae,aq as La,ar as Ia,as as Oa,ah as ks,X as Kt,at as Sn,au as yd,P as _r,av as Sd,E as wd,aw as Cd,ax as kd,ay as Ed,T as Ns,t as at,V as os,W as ut,Y as zs,Q as Be,az as Rs,U as cr,aA as jd,aB as ci,ai as Nd,af as Ba,s as qs,ag as Rd,aC as Fa,aD as wn,a6 as Ad,aE as za,aF as Wa,aG as Ha,aH as $a,aI as Td,aJ as Md,a3 as Dd,aK as Pd,aL as Ld,aM as Id,$ as fo,a9 as mo}from"./index-oC5eh7mZ.js";import{S as ht,l as rn,u as Cn,A as kn,m as Od,F as Ua,p as Bd,o as Fd,q as zd,Q as En,r as Wd,t as Dt,W as bt,v as qa,C as mr,w as Br,x as Hd,y as $d,z as Ud,T as qd,h as Nt,b as Vr,B as Ka,D as Ut}from"./mermaid-NOHMQCX5-CGCWmHha.js";import{C as jn}from"./confirm-dialog-BWvZEHpu.js";import{c as Va,a as Xa,b as Ya,I as Ga,d as Qa,A as po,G as Za}from"./Icons-KJJd6C8K.js";import{e as go,f as Kd,d as Nn,S as Vd,u as Rn,A as pr,c as An,G as Ja,Z as Xd,g as Tn,T as Mn,h as Yd,i as Dn,j as vo,k as Gd,b as el,l as tl,a as sl,m as rl,n as il,R as nl,P as ol,o as Xr,p as Qd,C as xo,B as bo}from"./CreateTaskInput-8bLhHYOc.js";import{C as St}from"./chevron-down-BZfpVhYr.js";import{C as At}from"./chevron-right-D52zUyOF.js";import{a as Zd,F as Jd,b as eu}from"./folder-picker-CaM_drIJ.js";import{M as di}from"./message-square-B-uYQiTq.js";import{L as Ks}from"./layers-hQUUT3Gb.js";import{P as Pn,C as tu,u as al,a as ll,L as Yr,T as Gr}from"./useNormalizedLogs-MsDkcnRQ.js";import{u as Ys}from"./use-providers-B70-BYNu.js";import{A as ui}from"./AgentLogo-Ntqe3_Mx.js";import{M as qt}from"./MemberAvatar-kbJEoyh0.js";import{C as cl}from"./chevron-up-CFOy5dmW.js";import{C as Vt}from"./check-C1zWgxFO.js";import{M as fs}from"./modal-D87uszzb.js";import{S as as}from"./select-D7WkUiad.js";import{P as ls,T as Ln}from"./trash-2-C0P8jNpJ.js";import{T as su}from"./textarea-D9oaz-Ba.js";import{S as nn,C as _o}from"./server-qlZupTvg.js";import{F as In,e as ru,d as iu,f as nu,u as ou}from"./use-projects-B4w00h5I.js";import{U as Qr}from"./upload-BYgsDplu.js";import{P as au}from"./pencil-CY2RnQrx.js";var lu=class extends gd{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ho()})}getOptimisticResult(e){return e.behavior=ho(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:x,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,a=x&&n==="forward",h=p&&n==="forward",c=x&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:xd(s,r.data),hasPreviousPage:vd(s,r.data),isFetchNextPageError:a,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!h&&!g}}};function On(e,s){return bd(e,lu)}const cu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dl=Ke("arrow-right",cu);const du=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ul=Ke("ban",du);const uu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],hu=Ke("chevron-left",uu);const fu=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],mu=Ke("clipboard-paste",fu);const pu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],cs=Ke("clock-3",pu);const gu=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],hi=Ke("code-xml",gu);const vu=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],yo=Ke("copy-plus",vu);const xu=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],bu=Ke("earth",xu);const _u=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],hl=Ke("ellipsis-vertical",_u);const yu=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Su=Ke("file-braces-corner",yu);const wu=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Zr=Ke("file-code-corner",wu);const Cu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ku=Ke("file-exclamation-point",Cu);const Eu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],fi=Ke("folder-open",Eu);const ju=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Gs=Ke("git-graph",ju);const Nu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Vs=Ke("history",Nu);const Ru=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Au=Ke("maximize",Ru);const Tu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Mu=Ke("panel-left-close",Tu);const Du=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Pu=Ke("panel-left-open",Du);const Lu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Iu=Ke("panel-right-close",Lu);const Ou=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],on=Ke("panel-right-open",Ou);const Bu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Fu=Ke("pen-line",Bu);const zu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ws=Ke("play",zu);const Wu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],fl=Ke("settings-2",Wu);const Hu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],So=Ke("smartphone",Hu);const $u=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],Fr=Ke("user-plus",$u);const Uu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qu=Ke("zoom-in",Uu);const Ku=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Vu=Ke("zoom-out",Ku),mi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Qs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function Bn(e){return"nodeType"in e}function wt(e){var s,r;return e?Qs(e)?e:Bn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Fn(e){const{Document:s}=wt(e);return e instanceof s}function yr(e){return Qs(e)?!1:e instanceof wt(e).HTMLElement}function ml(e){return e instanceof wt(e).SVGElement}function Zs(e){return e?Qs(e)?e.document:Bn(e)?Fn(e)?e:yr(e)||ml(e)?e.ownerDocument:document:document:document}const Jt=mi?b.useLayoutEffect:b.useEffect;function pi(e){const s=b.useRef(e);return Jt(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Xu(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function gr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return Jt(()=>{r.current!==e&&(r.current=e)},s),r}function Sr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function Jr(e){const s=pi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function ei(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Pi={};function gi(e,s){return b.useMemo(()=>{if(s)return s;const r=Pi[e]==null?0:Pi[e]+1;return Pi[e]=r,e+"-"+r},[e,s])}function pl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,x)=>{const i=Object.entries(x);for(const[n,a]of i){const h=m[n];h!=null&&(m[n]=h+e*a)}return m},{...s})}}const $s=pl(1),ti=pl(-1);function Yu(e){return"clientX"in e&&"clientY"in e}function zn(e){if(!e)return!1;const{KeyboardEvent:s}=wt(e.target);return s&&e instanceof s}function Gu(e){if(!e)return!1;const{TouchEvent:s}=wt(e.target);return s&&e instanceof s}function si(e){if(Gu(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Yu(e)?{x:e.clientX,y:e.clientY}:null}const vr=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[vr.Translate.toString(e),vr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),wo="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Qu(e){return e.matches(wo)?e:e.querySelector(wo)}const Zu={display:"none"};function Ju(e){let{id:s,value:r}=e;return ue.createElement("div",{id:s,style:Zu},r)}function eh(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function th(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const gl=b.createContext(null);function sh(e){const s=b.useContext(gl);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function rh(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(x=>{var i;return(i=x[p])==null?void 0:i.call(x,m)})},[e]),s]}const ih={draggable:`
3
3
  To pick up a draggable item, press the space bar.
4
4
  While dragging, use the arrow keys to move the item.
5
5
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -68,7 +68,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
68
68
  .transform-component-module_content__FBWxo img {
69
69
  pointer-events: none;
70
70
  }
71
- `,ha={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};$v(Uv);var qv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,a=n===void 0?{}:n,h=e.contentProps,c=h===void 0?{}:h,g=b.useContext(wi),v=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),l=b.useRef(null);return b.useEffect(function(){var u=w.current,d=l.current;return u!==null&&d!==null&&v&&v?.(u,d),function(){_?.()}},[]),ue.createElement("div",hs({},a,{ref:w,className:"".concat(gn.wrapperClass," ").concat(ha.wrapper," ").concat(o),style:x}),ue.createElement("div",hs({},c,{ref:l,className:"".concat(gn.contentClass," ").concat(ha.content," ").concat(m),style:i}),s))},_c=function(){var e=b.useContext(wi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Kv=function(){var e=_c();return oi(e)};function Vv(e){var s=_c(),r=b.useState(e(vn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(vn(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function Xv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Yv(e,s){return Et({queryKey:ce.files.tree(e||"",s),queryFn:()=>ye.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Gv(e,s){return Et({queryKey:ce.files.content(e||"",s||""),queryFn:()=>ye.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function Qv(e){const s=xt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Zv(){const e=xt();return Wt({mutationFn:s=>ye.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Xv(r.path)})}})}function Jv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function e0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const t0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function s0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&t0.has(s)?qa:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Zr:s==="json"?Su:s==="md"||s==="mdx"||s==="txt"?Ua:Jd}const fa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),yc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=de(),{data:n,isLoading:a,isError:h}=Yv(e,s),c=b.useMemo(()=>n?.items??[],[n?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):h?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const u=Jv(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(fa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(St,{size:14,className:"text-neutral-400"}):t.jsx(At,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(fi,{size:14,className:"text-amber-500"}):t.jsx(In,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(yc,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},u)}const v=e0(s,g.name),_=s0(g),w=x===v,l=_===qa;return t.jsx(fa,{depth:r,active:w,onClick:()=>m(v),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},v)})})},r0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=de(),[x,i]=b.useState(()=>new Set),n=Qv(e),a=b.useCallback(h=>{i(c=>{const g=new Set(c);return g.has(h)?g.delete(h):g.add(h),g})},[]);return t.jsxs("div",{className:te("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Rs,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(Mu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(yc,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},i0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function n0(e){const s=e.split(".").pop()?.toLowerCase();return s?i0.has(s):!1}function o0(e,s){const r=_r(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const a0=({filePath:e})=>{const{t:s}=de(),{zoomIn:r,zoomOut:o,centerView:p}=Kv(),m=Vv(i=>i.state.scale),x=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Vu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(qu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Au,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},l0=({workingDir:e,filePath:s})=>{const{t:r}=de(),[o,p]=b.useState(!1),m=o0(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Hv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(a0,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(qv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function c0(e){const s=e.split("/");return s[s.length-1]||e}function d0(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const u0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=de();return t.jsxs("button",{type:"button",onClick:o,className:te("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Kt,{size:12})})]})},h0=ue.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=de(),[x,i]=b.useState([]),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(0),[l,u]=b.useState(null),d=b.useRef(null),f=Zv();b.useEffect(()=>{let z=!1;return jd(async()=>{const{preloadMonaco:W}=await import("./monaco-uSRaugmx.js").then($=>$.m);return{preloadMonaco:W}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:W})=>W()).then(()=>{z||c(!0)}).catch(()=>{z||v(!0)}),()=>{z=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),P=b.useCallback(()=>{E(z=>(z?C(R.current):R.current=S,!z))},[S]),D=b.useCallback(z=>{z.preventDefault(),j(!0);const W=z.clientX,$=S,N=V=>{const X=V.clientX-W,oe=Math.min(480,Math.max(160,$+X));C(oe)},F=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",F)},[S]);b.useEffect(()=>{i([]),a(null),u(null)},[s]);const T=b.useMemo(()=>x.find(z=>z.path===n)||null,[x,n]),{data:B,isFetching:I,isError:H,error:q}=Gv(s,T?.isImage?null:n);b.useEffect(()=>{!n||!B||i(z=>z.map(W=>W.path!==n||W.isDirty||W.loaded?W:{...W,language:B.language||W.language,content:B.content,savedContent:B.content,isDirty:!1,loaded:!0}))},[n,B]);const A=b.useCallback((z,W,$)=>{i(N=>{if(N.find(X=>X.path===z))return N;const V=n0(z);return[...N,{path:z,name:c0(z),language:d0(z),content:"",savedContent:"",isDirty:!1,loaded:V,isImage:V}]}),a(z),u(W?{path:z,line:W,column:$}:null)},[]);ue.useImperativeHandle(p,()=>({openFile:A}),[A]);const O=b.useCallback(z=>{i(W=>{const $=W.filter(N=>N.path!==z);return a(N=>N!==z?N:$.length?$[$.length-1].path:null),$})},[]),M=b.useCallback(z=>{i(W=>W.map($=>{if($.path!==n)return $;const N=z!==$.savedContent;return{...$,content:z,isDirty:N}}))},[n]),L=b.useCallback(async()=>{o||!s||!T||(await f.mutateAsync({workingDir:s,path:T.path,content:T.content}),i(z=>z.map(W=>W.path===T.path?{...W,savedContent:W.content,isDirty:!1,loaded:!0}:W)))},[T,o,f,s]),K=b.useRef(()=>{});b.useEffect(()=>{K.current=()=>{L().catch(()=>{})}},[L]),b.useEffect(()=>{const z=W=>{o||(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"&&(W.preventDefault(),K.current())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o]);const U=b.useCallback((z,W)=>{d.current=z,w($=>$+1),z.addCommand(W.KeyMod.CtrlCmd|W.KeyCode.KeyS,()=>{K.current()})},[]);return b.useEffect(()=>{if(!l||l.path!==n||!T?.loaded)return;const z=d.current,W=z?.getModel();if(!z||!W)return;const $=Math.min(l.line,W.getLineCount()),N=Math.min(l.column??1,W.getLineMaxColumn($)),F={lineNumber:$,column:N};z.setPosition(F),z.revealPositionInCenter(F),z.focus(),u(null)},[n,T?.loaded,_,l]),t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",r),style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(Pu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(r0,{workingDir:s,onFileSelect:A,selectedFilePath:T?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:D,className:te("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[x.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):x.map(z=>t.jsx(u0,{active:z.path===n,name:z.name,isDirty:z.isDirty,onClick:()=>a(z.path),onClose:W=>{W.stopPropagation(),O(z.path)}},z.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Saving")]}),T?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?T?T.isImage?t.jsx(l0,{workingDir:s,filePath:T.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):h?t.jsxs(t.Fragment,{children:[t.jsx(Dg,{path:T.path,value:T.content,language:T.language,theme:"vs-light",height:"100%",onChange:o?void 0:z=>M(z??""),onMount:U,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!T.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),q instanceof Error?`: ${q.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function Ci(e,s={}){const r=js(p=>p.visibleContext),o=Ll(e,r);return Et({queryKey:ce.git.changes(e||""),queryFn:()=>ye.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Sc(e,s,r){const o=js(m=>m.visibleContext),p=Ll(e,o);return Et({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>ye.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function io(e,s){return Et({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>ye.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function no(e,s,r){return Et({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ye.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const f0=new Set(["STARTING","RUNNING","STOPPING"]);function wc(e){return f0.has(e.runtimeState)||e.runtimeInstanceId!==null}function Cc(e){return e instanceof ci&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function m0({services:e,isLoading:s,isError:r}){const{t:o}=de();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(Ns,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function kc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:x,isCheckingServices:i,serviceCheckFailed:n,error:a,onConfirm:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),v(p??""))},[e]),b.useEffect(()=>{_||!e||v(p??"")},[p,_,e]);const l=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:l,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:l,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>h(g.trim()||void 0,x.length>0),disabled:m||i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m||i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),i?c("正在检查后台服务..."):x.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Qr,{size:14}),x.length>0?c("停止服务并提交"):c("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(dl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:u=>{w(!0),v(u.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(m0,{services:x,isLoading:i,isError:n}),a&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a})]})})}function Bs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Ec(e){if(!(e instanceof ci)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==mr.REBASE&&s.conflictOp!==mr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Bs(s,"sourceBranch"),targetBranch:Bs(s,"targetBranch"),sourceWorktreePath:Bs(s,"sourceWorktreePath"),targetWorktreePath:Bs(s,"targetWorktreePath"),sourceWorkspaceId:Bs(s,"sourceWorkspaceId"),targetWorkspaceId:Bs(s,"targetWorkspaceId")}}function ma(e,s,r,o){const p=Ec(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function jc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:x,onResolveConflicts:i}){const{t:n}=de(),{data:a,isLoading:h}=Xn(e),c=Bl(),g=Ol(),v=Yn(),[_,w]=b.useState(!1),[l,u]=b.useState(null),d=eo(e,_),f=(d.data??[]).filter(wc);if(b.useEffect(()=>{_&&m?.()},[_,m]),h||!a)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const S=a.conflictedFiles.length>0,C=a.operation!=="idle",k=a.hasUncommittedChanges||a.untrackedCount>0,E=a.uncommittedCount+a.untrackedCount,y=!S&&!C&&!k,j=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!k&&!S,R=()=>{u(null),c.mutate(e,{onError:B=>{ma(B,n("更新失败,请稍后重试"),I=>x(I),u)}})},P=()=>{u(null),w(!0)},D=(B,I)=>{u(null),g.mutate({id:e,commitMessage:B,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(Cc(H)){u(n("后台服务仍在运行,请确认停止服务后再提交。"));return}ma(H,n("提交失败,请稍后重试"),q=>{w(!1),x(q)},u)}})},T=()=>{g.isPending||(w(!1),u(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Nd,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[l&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:l}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(ku,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(Ns,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:a.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:n("处理冲突")}),t.jsx("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:v.isPending?n("正在撤销..."):n("撤销操作")})]})]}),C&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:a.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Ba,{size:12}),v.isPending?n("正在撤销..."):n("撤销操作")]})]}),!S&&!C&&(a.behind>0||a.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:a.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Rs,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),a.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??a.ahead})}),a.behind===0&&!k?t.jsxs("button",{onClick:P,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Qr,{size:12}),n("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:n(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Qr,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(kc,{isOpen:_,onClose:T,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:l,onConfirm:D})]})}const Xi=50,Yi=400,pa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},ga={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Nc(e){const s=e.split("/");return s[s.length-1]||e}function p0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function g0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Kr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const bn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:te("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),v0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},Rc=({diff:e})=>{const{t:s}=de(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
71
+ `,ha={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};$v(Uv);var qv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,a=n===void 0?{}:n,h=e.contentProps,c=h===void 0?{}:h,g=b.useContext(wi),v=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),l=b.useRef(null);return b.useEffect(function(){var u=w.current,d=l.current;return u!==null&&d!==null&&v&&v?.(u,d),function(){_?.()}},[]),ue.createElement("div",hs({},a,{ref:w,className:"".concat(gn.wrapperClass," ").concat(ha.wrapper," ").concat(o),style:x}),ue.createElement("div",hs({},c,{ref:l,className:"".concat(gn.contentClass," ").concat(ha.content," ").concat(m),style:i}),s))},_c=function(){var e=b.useContext(wi);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Kv=function(){var e=_c();return oi(e)};function Vv(e){var s=_c(),r=b.useState(e(vn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(vn(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function Xv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Yv(e,s){return Et({queryKey:ce.files.tree(e||"",s),queryFn:()=>ye.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function Gv(e,s){return Et({queryKey:ce.files.content(e||"",s||""),queryFn:()=>ye.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function Qv(e){const s=xt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function Zv(){const e=xt();return Wt({mutationFn:s=>ye.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Xv(r.path)})}})}function Jv(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function e0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const t0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function s0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&t0.has(s)?qa:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?Zr:s==="json"?Su:s==="md"||s==="mdx"||s==="txt"?Ua:Jd}const fa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:te("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),yc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=de(),{data:n,isLoading:a,isError:h}=Yv(e,s),c=b.useMemo(()=>n?.items??[],[n?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):h?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const u=Jv(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(fa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(St,{size:14,className:"text-neutral-400"}):t.jsx(At,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(fi,{size:14,className:"text-amber-500"}):t.jsx(In,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(yc,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},u)}const v=e0(s,g.name),_=s0(g),w=x===v,l=_===qa;return t.jsx(fa,{depth:r,active:w,onClick:()=>m(v),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},v)})})},r0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=de(),[x,i]=b.useState(()=>new Set),n=Qv(e),a=b.useCallback(h=>{i(c=>{const g=new Set(c);return g.has(h)?g.delete(h):g.add(h),g})},[]);return t.jsxs("div",{className:te("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Rs,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(Mu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(yc,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},i0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function n0(e){const s=e.split(".").pop()?.toLowerCase();return s?i0.has(s):!1}function o0(e,s){const r=_r(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const a0=({filePath:e})=>{const{t:s}=de(),{zoomIn:r,zoomOut:o,centerView:p}=Kv(),m=Vv(i=>i.state.scale),x=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Vu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(qu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Au,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},l0=({workingDir:e,filePath:s})=>{const{t:r}=de(),[o,p]=b.useState(!1),m=o0(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Hv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(a0,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(qv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function c0(e){const s=e.split("/");return s[s.length-1]||e}function d0(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const u0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=de();return t.jsxs("button",{type:"button",onClick:o,className:te("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:te("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Kt,{size:12})})]})},h0=ue.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=de(),[x,i]=b.useState([]),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(0),[l,u]=b.useState(null),d=b.useRef(null),f=Zv();b.useEffect(()=>{let z=!1;return jd(async()=>{const{preloadMonaco:W}=await import("./monaco-B25-2nEB.js").then($=>$.m);return{preloadMonaco:W}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:W})=>W()).then(()=>{z||c(!0)}).catch(()=>{z||v(!0)}),()=>{z=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),P=b.useCallback(()=>{E(z=>(z?C(R.current):R.current=S,!z))},[S]),D=b.useCallback(z=>{z.preventDefault(),j(!0);const W=z.clientX,$=S,N=V=>{const X=V.clientX-W,oe=Math.min(480,Math.max(160,$+X));C(oe)},F=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",F)},[S]);b.useEffect(()=>{i([]),a(null),u(null)},[s]);const T=b.useMemo(()=>x.find(z=>z.path===n)||null,[x,n]),{data:B,isFetching:I,isError:H,error:q}=Gv(s,T?.isImage?null:n);b.useEffect(()=>{!n||!B||i(z=>z.map(W=>W.path!==n||W.isDirty||W.loaded?W:{...W,language:B.language||W.language,content:B.content,savedContent:B.content,isDirty:!1,loaded:!0}))},[n,B]);const A=b.useCallback((z,W,$)=>{i(N=>{if(N.find(X=>X.path===z))return N;const V=n0(z);return[...N,{path:z,name:c0(z),language:d0(z),content:"",savedContent:"",isDirty:!1,loaded:V,isImage:V}]}),a(z),u(W?{path:z,line:W,column:$}:null)},[]);ue.useImperativeHandle(p,()=>({openFile:A}),[A]);const O=b.useCallback(z=>{i(W=>{const $=W.filter(N=>N.path!==z);return a(N=>N!==z?N:$.length?$[$.length-1].path:null),$})},[]),M=b.useCallback(z=>{i(W=>W.map($=>{if($.path!==n)return $;const N=z!==$.savedContent;return{...$,content:z,isDirty:N}}))},[n]),L=b.useCallback(async()=>{o||!s||!T||(await f.mutateAsync({workingDir:s,path:T.path,content:T.content}),i(z=>z.map(W=>W.path===T.path?{...W,savedContent:W.content,isDirty:!1,loaded:!0}:W)))},[T,o,f,s]),K=b.useRef(()=>{});b.useEffect(()=>{K.current=()=>{L().catch(()=>{})}},[L]),b.useEffect(()=>{const z=W=>{o||(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"&&(W.preventDefault(),K.current())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o]);const U=b.useCallback((z,W)=>{d.current=z,w($=>$+1),z.addCommand(W.KeyMod.CtrlCmd|W.KeyCode.KeyS,()=>{K.current()})},[]);return b.useEffect(()=>{if(!l||l.path!==n||!T?.loaded)return;const z=d.current,W=z?.getModel();if(!z||!W)return;const $=Math.min(l.line,W.getLineCount()),N=Math.min(l.column??1,W.getLineMaxColumn($)),F={lineNumber:$,column:N};z.setPosition(F),z.revealPositionInCenter(F),z.focus(),u(null)},[n,T?.loaded,_,l]),t.jsxs("div",{className:te("flex h-full overflow-hidden bg-white",r),style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(Pu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(r0,{workingDir:s,onFileSelect:A,selectedFilePath:T?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:D,className:te("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[x.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):x.map(z=>t.jsx(u0,{active:z.path===n,name:z.name,isDirty:z.isDirty,onClick:()=>a(z.path),onClose:W=>{W.stopPropagation(),O(z.path)}},z.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Saving")]}),T?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?T?T.isImage?t.jsx(l0,{workingDir:s,filePath:T.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):h?t.jsxs(t.Fragment,{children:[t.jsx(Dg,{path:T.path,value:T.content,language:T.language,theme:"vs-light",height:"100%",onChange:o?void 0:z=>M(z??""),onMount:U,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!T.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),q instanceof Error?`: ${q.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function Ci(e,s={}){const r=js(p=>p.visibleContext),o=Ll(e,r);return Et({queryKey:ce.git.changes(e||""),queryFn:()=>ye.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Sc(e,s,r){const o=js(m=>m.visibleContext),p=Ll(e,o);return Et({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>ye.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function io(e,s){return Et({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>ye.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function no(e,s,r){return Et({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ye.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const f0=new Set(["STARTING","RUNNING","STOPPING"]);function wc(e){return f0.has(e.runtimeState)||e.runtimeInstanceId!==null}function Cc(e){return e instanceof ci&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function m0({services:e,isLoading:s,isError:r}){const{t:o}=de();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(Ns,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function kc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:x,isCheckingServices:i,serviceCheckFailed:n,error:a,onConfirm:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),v(p??""))},[e]),b.useEffect(()=>{_||!e||v(p??"")},[p,_,e]);const l=()=>{m||s()};return t.jsx(fs,{isOpen:e,onClose:l,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:l,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>h(g.trim()||void 0,x.length>0),disabled:m||i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m||i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),i?c("正在检查后台服务..."):x.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Qr,{size:14}),x.length>0?c("停止服务并提交"):c("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(dl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:u=>{w(!0),v(u.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(m0,{services:x,isLoading:i,isError:n}),a&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a})]})})}function Bs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Ec(e){if(!(e instanceof ci)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==mr.REBASE&&s.conflictOp!==mr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Bs(s,"sourceBranch"),targetBranch:Bs(s,"targetBranch"),sourceWorktreePath:Bs(s,"sourceWorktreePath"),targetWorktreePath:Bs(s,"targetWorktreePath"),sourceWorkspaceId:Bs(s,"sourceWorkspaceId"),targetWorkspaceId:Bs(s,"targetWorkspaceId")}}function ma(e,s,r,o){const p=Ec(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function jc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:x,onResolveConflicts:i}){const{t:n}=de(),{data:a,isLoading:h}=Xn(e),c=Bl(),g=Ol(),v=Yn(),[_,w]=b.useState(!1),[l,u]=b.useState(null),d=eo(e,_),f=(d.data??[]).filter(wc);if(b.useEffect(()=>{_&&m?.()},[_,m]),h||!a)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const S=a.conflictedFiles.length>0,C=a.operation!=="idle",k=a.hasUncommittedChanges||a.untrackedCount>0,E=a.uncommittedCount+a.untrackedCount,y=!S&&!C&&!k,j=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!k&&!S,R=()=>{u(null),c.mutate(e,{onError:B=>{ma(B,n("更新失败,请稍后重试"),I=>x(I),u)}})},P=()=>{u(null),w(!0)},D=(B,I)=>{u(null),g.mutate({id:e,commitMessage:B,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(Cc(H)){u(n("后台服务仍在运行,请确认停止服务后再提交。"));return}ma(H,n("提交失败,请稍后重试"),q=>{w(!1),x(q)},u)}})},T=()=>{g.isPending||(w(!1),u(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Nd,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[l&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:l}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(ku,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(Ns,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:a.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:n("处理冲突")}),t.jsx("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:v.isPending?n("正在撤销..."):n("撤销操作")})]})]}),C&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:a.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Ba,{size:12}),v.isPending?n("正在撤销..."):n("撤销操作")]})]}),!S&&!C&&(a.behind>0||a.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:a.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Rs,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),a.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??a.ahead})}),a.behind===0&&!k?t.jsxs("button",{onClick:P,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Qr,{size:12}),n("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:n(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Qr,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(kc,{isOpen:_,onClose:T,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:l,onConfirm:D})]})}const Xi=50,Yi=400,pa={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},ga={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Nc(e){const s=e.split("/");return s[s.length-1]||e}function p0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function g0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Kr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const bn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:te("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),v0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},Rc=({diff:e})=>{const{t:s}=de(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
72
72
  `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Yi,x=m?p.slice(0,Yi):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[x.map((i,n)=>t.jsx(v0,{line:i,lineNum:n+1},n)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Yi})})]})},x0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=Sc(e,o?s:null,r);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Rc,{diff:m?.diff||""})},b0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=no(e,o?s:null,o?r:null);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Rc,{diff:m?.diff||""})},Gi=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,x]=b.useState(!1),[i,n]=b.useState(!1),a=b.useRef(null),h=Kr(s,e.path);b.useEffect(()=>(p(h,a.current),()=>p(h,null)),[h,p]),b.useEffect(()=>{const v=a.current;if(!v||i)return;const _=new IntersectionObserver(w=>{w.some(l=>l.isIntersecting)&&(n(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(v),()=>_.disconnect()},[i]);const c=pa[e.status]||pa.M,g=p0(e.path);return t.jsxs("div",{ref:a,"data-card-key":h,className:te("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>x(v=>!v),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(At,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(St,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Nc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(bn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(x0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(b0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function _0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const x=o[m];p.dirs.has(x)||p.dirs.set(x,{name:x,path:p.path?`${p.path}/${x}`:x,dirs:new Map,files:[]}),p=p.dirs.get(x)}p.files.push(r)}return Ac(s)}function Ac(e){const s=new Map;for(const r of e.dirs.values()){let o=Ac(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const y0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=b.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(fi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(In,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Tc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Tc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(y0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:te("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:te("w-1.5 h-1.5 rounded-full shrink-0",ga[p.status]||ga.M)}),t.jsx("span",{className:te("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Nc(p.path)})]},p.cardKey)})]}),S0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=de(),{data:p,isLoading:m,fetchNextPage:x,hasNextPage:i,isFetchingNextPage:n}=On({queryKey:ce.git.log(e),queryFn:({pageParam:h=0})=>ye.get("/git/log",{params:{workingDir:e,limit:String(Xi),skip:String(h)}}),initialPageParam:0,getNextPageParam:(h,c)=>h.commits.length<Xi?void 0:c.length*Xi}),a=p?.pages.flatMap(h=>h.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Be,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):a.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[a.map(h=>{const c=s===h.hash;return t.jsxs("button",{type:"button",onClick:()=>r(h),className:te("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:h.message,children:[t.jsx("span",{className:te("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:te("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:h.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:h.shortHash})," · ",h.author," · ",g0(h.timestamp)]})]})]},h.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>x(),disabled:n,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},w0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n})=>{const{t:a}=de(),[h,c]=b.useState({kind:"overview"}),[g,v]=b.useState(""),[_,w]=b.useState(null),[l,u]=b.useState(null),{data:d,isLoading:f,isError:S}=Ci(e),C=h.kind==="commit"?h.commit.hash:null,{data:k,isLoading:E}=io(e,C),y=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),P=b.useCallback((z,W)=>{W?y.current.set(z,W):y.current.delete(z)},[]),{uncommitted:D,committed:T,commitFiles:B}=b.useMemo(()=>{const z=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(h.kind==="commit"){const N={kind:"commit",hash:h.commit.hash},F=(k?.files||[]).filter(z).map(V=>({...V,cardKey:Kr(N,V.path)}));return{uncommitted:[],committed:[],commitFiles:F}}const W=(d?.uncommitted||[]).filter(z).map(N=>({...N,cardKey:Kr({kind:"working",diffType:"uncommitted"},N.path)})),$=(d?.committed||[]).filter(z).map(N=>({...N,cardKey:Kr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:W,committed:$,commitFiles:[]}},[h,d,k,g]),I=h.kind==="commit"?B:[...D,...T],H=b.useMemo(()=>_0(I),[I]),q=b.useMemo(()=>{let z=0,W=0;for(const $ of I)z+=$.additions??0,W+=$.deletions??0;return{additions:z,deletions:W,files:I.length}},[I]),A=b.useCallback(()=>{const z=j.current;if(!z)return;const W=z.getBoundingClientRect().top;let $=null,N=Number.NEGATIVE_INFINITY;for(const[F,V]of y.current){const X=V.getBoundingClientRect().top-W;X<=48&&X>N&&(N=X,$=F)}if(!$){let F=null,V=Number.POSITIVE_INFINITY;for(const[X,oe]of y.current){const J=oe.getBoundingClientRect().top-W;J<V&&(V=J,F=X)}$=F}w($)},[]);b.useEffect(()=>{const z=j.current;if(!z)return;let W=0;const $=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(A)};return z.addEventListener("scroll",$,{passive:!0}),()=>{z.removeEventListener("scroll",$),cancelAnimationFrame(W)}},[A]);const O=b.useCallback(z=>{const W=y.current.get(z.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),w(z.cardKey),u(z.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>u(null),1200))},[]),M=b.useCallback(z=>{c(W=>W.kind==="commit"&&W.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),v(""),w(null),j.current?.scrollTo({top:0})},[]),L=b.useCallback(()=>{c({kind:"overview"}),v(""),w(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:a("未选择工作区")});const K=m&&s&&r&&o,U=h.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&i&&n&&t.jsx(jc,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:h.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Gs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:a("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("{count} 个文件",{count:q.files})}),t.jsx(bn,{additions:q.additions,deletions:q.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(qs,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:L,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(qs,{size:12}),a("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:h.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:h.commit.message}),t.jsx(bn,{className:"ml-auto",additions:q.additions,deletions:q.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:U?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},z))}):S&&h.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:a("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Zr,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?a("没有匹配筛选条件的文件"):h.kind==="commit"?a("该提交没有文件变更"):a("没有待审查的变更")})]}):h.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(z=>t.jsx(Gi,{entry:z,source:{kind:"commit",hash:h.commit.hash},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[D.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:D.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:D.map(z=>t.jsx(Gi,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))})]}),T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(z=>t.jsx(Gi,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(Nn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:z=>v(z.target.value),placeholder:a("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?a("无匹配文件"):a("暂无变更文件")}):t.jsx(Tc,{node:H,depth:0,activeKey:_,onSelect:O})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Vs,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(S0,{workingDir:e,selectedHash:C,onSelectCommit:M})})]})]})]})]})},Qi=50,va={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function C0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function k0(e){const s=e.split("/");return s[s.length-1]||e}function E0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const j0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:te("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:te("pl-2 whitespace-pre",o),children:e})]})},N0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=de(),{data:p,isLoading:m,isError:x}=no(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const n=i.split(`
73
73
  `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((a,h)=>t.jsx(j0,{line:a,lineNum:h+1},h))})},R0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=de(),{data:m,isLoading:x}=io(e,s);if(x)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Be,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const a=va[n.status]||va.M,h=E0(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:te("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:te("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",a),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:k0(n.path)}),h&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:h})]},n.path)})})},A0=({workingDir:e})=>{const{t:s}=de(),r=js(E=>E.visibleContext),o=Pf(e,r),{data:p,isLoading:m,isError:x,fetchNextPage:i,hasNextPage:n,isFetchingNextPage:a}=On({queryKey:ce.git.log(e||""),queryFn:({pageParam:E=0})=>ye.get("/git/log",{params:{workingDir:e||"",limit:String(Qi),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<Qi?void 0:y.length*Qi,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),h=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[v,_]=b.useState(null),[w,l]=b.useState(280),[u,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,R=D=>{const T=Math.min(480,Math.max(180,j+(D.clientX-y)));l(T)},P=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",P)},[w]),S=E=>{c===E?(g(null),_(null)):(g(E),_(null))},C=b.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(h.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Vs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=h.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:u?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Vs,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:h.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[h.map(E=>{const y=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(E.hash),className:te("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",y?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:te("w-2 h-2 rounded-full shrink-0 transition-colors",y?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(At,{size:12,className:te("shrink-0 text-muted-foreground/70 transition-transform",y&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:C0(E.timestamp)})]})]})]}),y&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(R0,{workingDir:e,hash:E.hash,selectedPath:v,onSelectFile:_})]})]},E.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>i(),disabled:a,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:a?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:te("w-1 shrink-0 cursor-col-resize transition-colors",u?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Zr,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:v}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(N0,{workingDir:e,hash:c,filePath:v})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Zr,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},xa=_r();function T0(e){if(!xa)return e;try{const s=new URL(xa);return new URL(e,s.origin).toString()}catch{return e}}function Mc(e){return{...e,viewUrl:e.viewUrl?T0(e.viewUrl):null}}function M0(e,s=!0){return Et({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await ye.get(`/previews/${e}/status`);return Mc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function D0(e){const s=xt();return Wt({mutationFn:async r=>{const o=await ye.put(`/previews/${e}/config`,{target:r});return Mc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function P0(){return window.location.protocol==="https:"?"remote":"local"}function L0(e,s,r=!0){const[o,p]=b.useState(null),[m,x]=b.useState(!1),[i,n]=b.useState(null),[a,h]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),x(!1),n(null);return}let c=!1,g=null,v=null;p(null);const _=l=>{ye.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{x(!0),n(null);try{const l={mode:P0(),localHostname:window.location.hostname},u=await ye.post(`/previews/${e}/sessions`,l);if(c){_(u.id);return}g=u.id,p(u),v=window.setInterval(async()=>{if(g)try{const d=await ye.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),n(null))}catch(d){!c&&d instanceof ci&&d.status===404?h(f=>f+1):c||n(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(l){c||(p(null),n(l instanceof Error?l:new Error("Failed to open preview session")))}finally{c||x(!1)}})(),()=>{c=!0,v!==null&&window.clearInterval(v),g&&_(g)}},[r,a,s?.ready,s?.target,e]),{session:o,isOpening:m,error:i,retry:()=>h(c=>c+1)}}const I0="agent-tower-preview",O0="agent-tower-preview-host";function B0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function F0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function z0(e){return t.jsx(W0,{...e},e.workspaceId??"no-workspace")}function W0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=de(),[m,x]=b.useState(null),n=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:h,refetch:c,isFetching:g}=M0(e,n),v=D0(e),{session:_,isOpening:w,error:l,retry:u}=L0(e,a,n),d=b.useRef(null),f=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(null),E=b.useRef(null),[y,j]=b.useState(0),[R,P]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),D=F0(_?.viewUrl),T=a&&R.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,B=b.useCallback(U=>{P(z=>({...a&&z.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:z,...U}))},[a]);b.useEffect(()=>{if(!_||_.target!==a?.target)return;const U=k.current!==D;k.current=D,P(z=>{const W=r?.source.kind==="web"&&E.current!==r.id?Br(r.source.url,_.target,_.viewUrl):null;if(!U&&z.iframeSrc&&z.target===_.target&&W?.kind!=="proxy")return z;let $=z.iframeSrc;if(W?.kind==="proxy")$=W.url;else if(!$||z.target!==_.target||U){const F=S.current;if(F)$=Hd(_.viewUrl,F);else{const V=Br(z.address||_.target,_.target,_.viewUrl);$=V?.kind==="proxy"?V.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&$&&N.location.replace($),C.current=null,{target:_.target,address:W?.kind==="proxy"?r?.source.kind==="web"?r.source.url:z.address:z.address||_.target,iframeSrc:$,isFrameLoading:!!$}})},[r,_,D,a?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(U,z=!1)=>{const W=Br(U,a?.target??null,_?.viewUrl??null);if(!W||!e)return;if(x(null),W.kind==="proxy"){if(z){window.open(W.url,"_blank","noopener,noreferrer");return}P({target:a?.target??null,address:U,iframeSrc:W.url,isFrameLoading:!0});return}if(s)return;const $=z?window.open("about:blank","_blank"):null;$&&($.opener=null);try{S.current=W.path,C.current=$;const N=await v.mutateAsync(W.target);P({target:N.target,address:U.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(F=>F+1),at.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,S.current=null;const F=N instanceof Error?N.message:p("Failed to save preview target");at.error(F)}},[_?.viewUrl,s,a?.target,p,v,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&h)return;const U=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(x({source:r.source,iframeSrc:$d(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(z=>z+1)):(x(null),I(r.source.url))},0);return()=>window.clearTimeout(U)},[h,I,r,o]),b.useEffect(()=>{if(m)return;const U=z=>{if(z.source!==d.current?.contentWindow)return;const W=z.data;if(!(!W||W.source!==I0)){if(W.type==="location"&&typeof W.href=="string"){const $=Ud(a?.target??null,_?.viewUrl??null,W.href,window.location.href);$&&document.activeElement!==f.current&&B({target:a?.target??T.target,address:$,isFrameLoading:!1});return}W.type==="navigate-loopback"&&typeof W.href=="string"&&I(W.href,W.newTab===!0)}};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[T.target,I,B,_?.viewUrl,a?.target,m]);const H=U=>{d.current?.contentWindow?.postMessage({source:O0,action:U},"*")},q=U=>{U.preventDefault(),I(T.address)},A=async()=>{if(m){x(z=>z&&{...z,isFrameLoading:!0}),j(z=>z+1);return}const U=await c();if(!U.data?.ready){B({target:U.data?.target??T.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!T.iframeSrc){u();return}B({isFrameLoading:!0}),H("reload")},O=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const U=Br(T.address||_.target,_.target,_.viewUrl),z=U?.kind==="proxy"?U.url:_.viewUrl;window.open(z,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:p("No active workspace.")});const M=m?.iframeSrc??T.iframeSrc,L=!!m,K=!L&&(h||g||v.isPending||w);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{L?x(null):H("back")},disabled:!L&&!T.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx(qs,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:L||!T.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(dl,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:!L&&T.isFrameLoading?()=>{H("stop"),B({isFrameLoading:!1})}:A,disabled:!L&&!T.isFrameLoading&&g,title:!L&&T.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!L&&T.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!L&&T.isFrameLoading?t.jsx(Kt,{}):g?t.jsx(Be,{className:"animate-spin"}):t.jsx(Rs,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(bu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:f,value:m?.source.file??T.address,onChange:U=>B({address:U.target.value}),onKeyDown:U=>{U.key==="Enter"&&U.nativeEvent.isComposing&&U.preventDefault()},disabled:L||s||v.isPending,placeholder:B0(),"aria-label":p("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:O,disabled:!M,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(Sn,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:L?p("Viewing agent visualization"):K?p("Checking preview target..."):l?l.message:a?.ready?`${p("Proxying")} ${a.target}`:a?.configured?`${p("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(L?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:M?t.jsx("iframe",{ref:d,src:M,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:L?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{L?x(U=>U&&{...U,isFrameLoading:!1}):B({isFrameLoading:!1})}},y):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?a.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function H0(e){switch(e){case Dt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Dt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Dt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Dt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ba(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function $0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Dc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:x}){const{t:i}=de(),[n,a]=b.useState(!1),h=b.useRef(null),c=b.useMemo(()=>Zn(e,s),[e,s]),g=c.find(v=>v.workspace.id===r)??c[0];return b.useEffect(()=>{if(!n)return;const v=_=>{h.current&&!h.current.contains(_.target)&&a(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),c.length<=1?null:t.jsxs("div",{ref:h,className:te("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>a(v=>!v),disabled:p,className:te("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",x),title:i("Workspace"),children:[t.jsx(Ks,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ba(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:$0(Xs(g.workspace))}),t.jsx(St,{size:13,className:te("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(v=>{const _=v.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(v.workspace.id),a(!1)},className:te("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",_&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:_?t.jsx(Vt,{size:13}):t.jsx(Ja,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(v.displayName)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ba(v.roleLabel)),children:i(v.roleLabel)}),t.jsx("span",{className:te("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",H0(v.workspace.status)),children:v.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Xs(v.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[v.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",v.ownerName]}),v.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",v.parentBranchName]}),t.jsx("span",{children:v.workspace.id.slice(0,8)})]})]})]},v.workspace.id)})})]})}const U0=[{key:"review",label:"Changes",icon:t.jsx(Gs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(hi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(cr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Za,{size:14})}],q0=[{key:"history",label:"History",icon:t.jsx(Vs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(hi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(cr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Za,{size:14})}],K0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:te("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),V0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:te("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Pc=ue.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:x,gitAvailable:i=!0,readOnly:n,repoDeleted:a,teamRun:h,teamStatus:c,gitProps:g,workspaces:v,selectedWorkspaceId:_,onSelectWorkspace:w,variant:l="tabs",expanded:u,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=de(),y=js(se=>se.setVisibleContext),j=l==="rail",[R,P]=b.useState(!1),D=j?u??R:!0,T=b.useCallback(se=>{u===void 0&&P(se),d?.(se)},[u,d]),B=b.useMemo(()=>{const se=x?q0:U0,ie=i?se:se.filter(Se=>Se.key!=="review"&&Se.key!=="history"),le=n?ie.filter(Se=>Se.key!=="terminal"):ie;return h?[{key:"team-status",label:"Team Status",icon:t.jsx(ks,{size:14})},...le]:le},[i,x,n,h]),[I,H]=b.useState(()=>C?"preview":i?x?"history":"review":"editor"),q=b.useRef(null),A=b.useRef(0),[O,M]=b.useState(),L=b.useCallback(se=>{H(se),j&&T(!0)},[j,T]);b.useImperativeHandle(S,()=>({setTab:se=>L(se),openFile:(se,ie,le)=>{L("editor"),requestAnimationFrame(()=>q.current?.openFile(se,ie,le))},openPreview:(se,ie)=>{A.current+=1,M({id:A.current,source:se,workspaceId:ie}),L("preview")}}),[L]);const K=C??O,U=K?.workspaceId&&K.workspaceId!==o?void 0:K,z=b.useCallback(se=>{M(ie=>ie?.id===se?void 0:ie),k?.(se)},[k]),{data:W}=ru(m??""),$=b.useMemo(()=>{if(!W?.quickCommands)return[];try{return JSON.parse(W.quickCommands)}catch{return[]}},[W?.quickCommands]),[N,F]=b.useState([]),V=b.useRef(void 0);b.useEffect(()=>{p&&p!==V.current&&(V.current=p,F(se=>se.includes(p)?se:[...se,p]))},[p]),b.useEffect(()=>{B.some(se=>se.key===I)||H(B[0]?.key??"editor")},[I,B]),b.useEffect(()=>{if(j&&!D)return;const se=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!se){y(null);return}return y({workspaceId:o,workingDir:p,tab:se}),()=>{y(null)}},[I,D,j,y,p,o]);const X=!!w&&Zn(v,h).length>1,oe=B.find(se=>se.key===I)??B[0],J=oe?E(oe.label):"",ve=n?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,me=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[X&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Dc,{workspaces:v,teamRun:h,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&h&&c,I==="editor"&&t.jsx(h0,{ref:q,workingDir:p,readOnly:n}),N.map(se=>{const ie=I==="terminal"&&p===se;return t.jsx("div",{"aria-hidden":!ie,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ie?"block":"none"},children:t.jsx(Cp,{cwd:se,workspaceId:ie?o:void 0,isVisible:ie,quickCommands:$})},se)}),I==="preview"&&t.jsx(z0,{workspaceId:o,readOnly:n,navigationRequest:U,onNavigationRequestHandled:z}),I==="review"&&t.jsx(w0,{workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(A0,{workingDir:p})]})]});return j?t.jsxs("div",{className:te("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:B.map(se=>t.jsx(V0,{active:D&&I===se.key,onClick:()=>L(se.key),icon:se.icon,label:E(se.label)},se.key))}),D&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[ve,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:oe?.icon}),t.jsx("span",{className:"truncate",children:J})]}),t.jsx("button",{type:"button",onClick:()=>T(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(Iu,{size:15})})]}),me]})]}):t.jsxs("div",{className:te("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&ve,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:B.map(se=>t.jsx(K0,{active:I===se.key,onClick:()=>L(se.key),icon:se.icon,label:E(se.label)},se.key))}),me]})}),X0=3e3;function _a(e,s){const r=new Map(e.map(o=>[o.workspaceId,o]));for(const o of s){const p=r.get(o.workspaceId);(!p||o.updatedAt>=p.updatedAt)&&r.set(o.workspaceId,o)}return[...r.values()]}function Lc(e){const s=xt(),r=b.useRef({version:0,values:new Map}),[o,p]=b.useState(0),{data:m=[]}=Et({queryKey:ce.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:a=>a.state.data?.some(h=>h.status==="running")?3e3:!1,queryFn:async({signal:a})=>{const h=r.current.version,c=await ye.get(`/tasks/${e}/setup-progress`,{signal:a}),g=[...r.current.values.values()].filter(v=>v.version>h&&v.progress.taskId===e).map(v=>v.progress);return _a(c,g)}});b.useEffect(()=>{if(!e)return;const a=os.connect(),h=ce.workspaces.setupProgress(e),c=v=>{if(v.taskId!==e)return;const _=r.current.values.get(v.workspaceId);_&&_.progress.updatedAt>v.updatedAt||(r.current.values.set(v.workspaceId,{version:++r.current.version,progress:v}),s.setQueryData(h,w=>_a(w??[],[v])))},g=()=>{s.invalidateQueries({queryKey:h})};return a.on(ut.WORKSPACE_SETUP_PROGRESS,c),a.on("connect",g),()=>{a.off(ut.WORKSPACE_SETUP_PROGRESS,c),a.off("connect",g)}},[e,s]);const x=[...m].sort((a,h)=>h.updatedAt-a.updatedAt),i=x.find(a=>a.status==="running")??x.find(a=>a.status!=="running"&&a.updatedAt>o),n=i?.status!=="running"?i?.updatedAt??null:null;return b.useEffect(()=>{if(n===null)return;const a=setTimeout(()=>p(n),X0);return()=>clearTimeout(a)},[n]),i??null}function Ic({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:x,taskPrompt:i,projectIsGitRepo:n=!0,projectWorktreeReady:a=!0,projectGitReason:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(""),[l,u]=b.useState(bt.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=xt(),j=Il(o),R=Tn(),P=iu(),{data:D,isLoading:T}=Ys(),B=d?.isGitRepo??n,I=d?.worktreeReady??a,H=d?.reason??h,q=B!==!1&&I!==!1;b.useEffect(()=>{if(!e||!D)return;const N=D.find(F=>F.availability.type!=="NOT_FOUND");N&&v(N.provider.id)},[e,D]),b.useEffect(()=>{if(e){const N=[m];x&&N.push(x),w(i?.trim()||N.join(`
74
74
 
@@ -1,2 +1,2 @@
1
- import{u as _,r as o,p as de,j as e,X as se,S as K,a1 as ue,g as $,v as H,l as W,T as me,B as z,a2 as xe,a3 as pe,t as U}from"./index-DJqjl4es.js";import{F as X,u as fe,a as he,b as ge,c as je}from"./use-projects-FC2A-qiG.js";import{F as V,a as ve,b as be}from"./folder-picker-ClBdFSv_.js";import{P as re,T as ye}from"./trash-2-BeXtY9XM.js";import{M as Y}from"./modal-BUKaDX-v.js";import{S as Ne}from"./SettingsMasterDetail-nkWk1iMZ.js";import"./chevron-right-CPwvo275.js";import"./circle-alert-D_JK6Nsk.js";import"./check-D0G5G0XX.js";function Pe({value:t,onChange:y,repoPath:N,placeholder:k,disabled:a,disabledMessage:c}){const{t:d}=_(),[l,j]=o.useState(""),[h,n]=o.useState([]),[u,x]=o.useState(!1),[p,v]=o.useState(-1),b=o.useRef(null),E=o.useRef(null),R=o.useRef(void 0),q=o.useCallback(async s=>{if(a||!N||!s){n([]),x(!1);return}try{const i=await de.get("/filesystem/complete",{params:{basePath:N,prefix:s}});n(i.results),x(i.results.length>0),v(-1)}catch{n([]),x(!1)}},[a,N]);o.useEffect(()=>{if(clearTimeout(R.current),!l){n([]),x(!1);return}return R.current=setTimeout(()=>q(l),200),()=>clearTimeout(R.current)},[l,q]),o.useEffect(()=>{const s=i=>{E.current&&!E.current.contains(i.target)&&b.current&&!b.current.contains(i.target)&&x(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const w=s=>{if(a)return;const i=s.trim();!i||t.includes(i)||(y([...t,i]),j(""),x(!1),b.current?.focus())},S=s=>{a||y(t.filter((i,A)=>A!==s))},D=s=>{a||(s.type==="directory"?(j(s.path),b.current?.focus()):w(s.path))},M=(s,i)=>{a||(i.stopPropagation(),w(s.path.replace(/\/$/,"")))},F=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||a||(u&&h.length>0?s.key==="ArrowDown"?(s.preventDefault(),v(i=>Math.min(i+1,h.length-1))):s.key==="ArrowUp"?(s.preventDefault(),v(i=>Math.max(i-1,-1))):s.key==="Enter"?(s.preventDefault(),p>=0?D(h[p]):w(l)):s.key==="Escape"&&x(!1):s.key==="Enter"&&(s.preventDefault(),w(l)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,i)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(V,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(X,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>S(i),disabled:a,className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0 disabled:cursor-not-allowed disabled:hover:text-neutral-300",children:e.jsx(se,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:b,type:"text",value:l,onChange:s=>j(s.target.value),onKeyDown:F,onFocus:()=>{l&&h.length>0&&x(!0)},placeholder:k??d("输入文件路径..."),disabled:a,className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 disabled:cursor-not-allowed disabled:bg-neutral-50 disabled:text-neutral-400"}),e.jsxs("button",{onClick:()=>w(l),disabled:a||!l.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(re,{size:14}),e.jsx("span",{children:d("添加")})]})]}),u&&e.jsx("div",{ref:E,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:h.map((s,i)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${i===p?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(X,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(V,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:A=>M(s,A),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:d("添加此目录"),children:e.jsx(ve,{size:14})})]},s.path))})]}),a&&c&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:c})]})}function ke({value:t,onChange:y}){const{t:N}=_(),[k,a]=o.useState(""),[c,d]=o.useState(""),l=()=>{const n=k.trim(),u=c.trim();!n||!u||(y([...t,{name:n,command:u}]),a(""),d(""))},j=n=>{y(t.filter((u,x)=>x!==n))},h=n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),l())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((n,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:n.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:n.command}),e.jsx("button",{onClick:()=>j(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(se,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:k,onChange:n=>a(n.target.value),onKeyDown:h,placeholder:N("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:c,onChange:n=>d(n.target.value),onKeyDown:h,placeholder:N("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:l,disabled:!k.trim()||!c.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(re,{size:14}),e.jsx("span",{children:N("添加")})]})]})]})}function Z(t){return t?t.split(",").map(y=>y.trim()).filter(Boolean):[]}function ee(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function te(t){return typeof t.color!="string"||t.color.trim()===""?"bg-muted-foreground":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-muted-foreground"}function ze(){const{t}=_(),{data:y,isLoading:N}=fe({limit:100,includeArchived:!0}),k=he(),a=ge(),c=je(),[d,l]=o.useState(""),[j,h]=o.useState(null),[n,u]=o.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[x,p]=o.useState(!1),[v,b]=o.useState(null),[E,R]=o.useState(!1),[q,w]=o.useState(!1),[S,D]=o.useState(!1),[M,F]=o.useState(!1),[s,i]=o.useState(""),[A,J]=o.useState(!1),C=y?.data??[],g=o.useMemo(()=>C.filter(r=>!r.archivedAt),[C]),I=o.useMemo(()=>C.filter(r=>r.archivedAt),[C]),f=g.find(r=>r.id===d),T=o.useMemo(()=>C.find(r=>r.id===v)??null,[v,C]);if(o.useEffect(()=>{!d&&g.length>0&&l(g[0].id)},[g,d]),o.useEffect(()=>{if(j){g.some(r=>r.id===j)&&(l(j),h(null));return}d&&!g.some(r=>r.id===d)&&(l(g[0]?.id??""),p(!1))},[g,j,d]),o.useEffect(()=>{f&&!x&&u({copyFiles:Z(f.copyFiles),setupScript:f.setupScript??"",quickCommands:ee(f.quickCommands)})},[f,x]),N)return e.jsx(K,{className:"max-w-5xl",children:e.jsx(ue,{})});if(C.length===0)return e.jsxs(K,{className:"max-w-5xl",children:[e.jsx($,{title:t("项目配置")}),e.jsx(H,{message:t("暂无项目,请先创建项目")})]});const ne=()=>{d&&k.mutate({id:d,copyFiles:n.copyFiles.length>0?n.copyFiles.join(", "):null,setupScript:n.setupScript.trim()||null,quickCommands:n.quickCommands.length>0?JSON.stringify(n.quickCommands):null},{onSuccess:()=>p(!1)})},oe=r=>{h(null),l(r),p(!1),J(!0)},ae=()=>{f&&(b(f.id),D(!1),F(!1),R(!0))},O=()=>{a.isPending||(R(!1),b(null),D(!1),F(!1))},ie=async()=>{if(v)try{await a.mutateAsync({id:v,deleteRepo:S}),U.success(t(S?"项目已删除,并清理了本地文件":"项目已删除")),p(!1),O()}catch{}},le=r=>{const m=I.find(P=>P.id===r);b(r),i(m?.repoDeletedAt?m.repoPath:""),w(!0)},L=()=>{c.isPending||(w(!1),b(null),i(""))},ce=async()=>{if(!(!v||T?.repoDeletedAt&&!s.trim()))try{const m=await c.mutateAsync({id:v,repoPath:s.trim()||void 0});U.success(t("项目已恢复"));for(const P of m.warnings)U.warning(P);p(!1),h(m.project.id),l(m.project.id),L()}catch{}},Q=T?.name??t("this project"),G=!!T?.repoDeletedAt,B=f?.isGitRepo!==!1&&f?.worktreeReady!==!1;return e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"max-w-5xl",children:[e.jsx($,{title:t("项目配置")}),g.length===0&&I.length===0?e.jsx(H,{message:t("暂无项目,请先创建项目")}):e.jsx(Ne,{items:g,selectedId:d,onSelectItem:oe,getItemId:r=>r.id,mobileShowDetail:A,onMobileBack:()=>J(!1),renderListItem:(r,m)=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:W("h-2 w-2 rounded-full shrink-0",m?"bg-primary-foreground/60":te(r))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:r.name}),e.jsx("div",{className:W("truncate text-[11px] font-mono",m?"text-primary-foreground/70":"text-muted-foreground"),children:r.repoPath.split("/").pop()})]})]}),renderListFooter:I.length>0?()=>e.jsxs("div",{className:"pt-3 mt-2 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 mb-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:t("已删除")}),e.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:I.length})]}),I.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px]",children:r.name})}),e.jsx("button",{onClick:()=>le(r.id),disabled:c.isPending,className:"shrink-0 text-[11px] hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","aria-label":t("恢复项目"),children:e.jsx(pe,{size:12})})]},r.id))]}):void 0,renderDetail:r=>r?e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:W("h-2.5 w-2.5 rounded-full shrink-0",te(r))}),e.jsx("h3",{className:"text-base font-semibold text-foreground",children:r.name}),r.isGitRepo===!1&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:t("Local project")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono mb-5",children:r.repoPath}),r.isGitRepo===!1&&e.jsx("div",{className:"mb-5 rounded-lg border border-info/25 bg-info/8 px-3 py-2 text-xs leading-relaxed text-info/90",children:t("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun.")}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsxs("div",{className:"py-5 first:pt-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("自动复制文件")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("创建 worktree 时自动从主仓库复制的文件或目录,适用于 .env、node_modules 等不在 git 管理中的文件。支持 glob。")})]}),e.jsx(Pe,{value:n.copyFiles,onChange:m=>{u(P=>({...P,copyFiles:m})),p(!0)},repoPath:r.repoPath,disabled:!B,disabledMessage:t("This setting applies only to Git worktree projects.")})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("创建 worktree 后自动执行的命令,每行一条。在 worktree 目录下执行,单条超时 5 分钟。")})]}),e.jsx("textarea",{value:n.setupScript,onChange:m=>{u(P=>({...P,setupScript:m.target.value})),p(!0)},placeholder:`pnpm install
1
+ import{u as _,r as o,p as de,j as e,X as se,S as K,a1 as ue,g as $,v as H,l as W,T as me,B as z,a2 as xe,a3 as pe,t as U}from"./index-oC5eh7mZ.js";import{F as X,u as fe,a as he,b as ge,c as je}from"./use-projects-B4w00h5I.js";import{F as V,a as ve,b as be}from"./folder-picker-CaM_drIJ.js";import{P as re,T as ye}from"./trash-2-C0P8jNpJ.js";import{M as Y}from"./modal-D87uszzb.js";import{S as Ne}from"./SettingsMasterDetail-OF28cvPV.js";import"./chevron-right-D52zUyOF.js";import"./circle-alert-D67xfWMs.js";import"./check-C1zWgxFO.js";function Pe({value:t,onChange:y,repoPath:N,placeholder:k,disabled:a,disabledMessage:c}){const{t:d}=_(),[l,j]=o.useState(""),[h,n]=o.useState([]),[u,x]=o.useState(!1),[p,v]=o.useState(-1),b=o.useRef(null),E=o.useRef(null),R=o.useRef(void 0),q=o.useCallback(async s=>{if(a||!N||!s){n([]),x(!1);return}try{const i=await de.get("/filesystem/complete",{params:{basePath:N,prefix:s}});n(i.results),x(i.results.length>0),v(-1)}catch{n([]),x(!1)}},[a,N]);o.useEffect(()=>{if(clearTimeout(R.current),!l){n([]),x(!1);return}return R.current=setTimeout(()=>q(l),200),()=>clearTimeout(R.current)},[l,q]),o.useEffect(()=>{const s=i=>{E.current&&!E.current.contains(i.target)&&b.current&&!b.current.contains(i.target)&&x(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const w=s=>{if(a)return;const i=s.trim();!i||t.includes(i)||(y([...t,i]),j(""),x(!1),b.current?.focus())},S=s=>{a||y(t.filter((i,A)=>A!==s))},D=s=>{a||(s.type==="directory"?(j(s.path),b.current?.focus()):w(s.path))},M=(s,i)=>{a||(i.stopPropagation(),w(s.path.replace(/\/$/,"")))},F=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||a||(u&&h.length>0?s.key==="ArrowDown"?(s.preventDefault(),v(i=>Math.min(i+1,h.length-1))):s.key==="ArrowUp"?(s.preventDefault(),v(i=>Math.max(i-1,-1))):s.key==="Enter"?(s.preventDefault(),p>=0?D(h[p]):w(l)):s.key==="Escape"&&x(!1):s.key==="Enter"&&(s.preventDefault(),w(l)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,i)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(V,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(X,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>S(i),disabled:a,className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0 disabled:cursor-not-allowed disabled:hover:text-neutral-300",children:e.jsx(se,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:b,type:"text",value:l,onChange:s=>j(s.target.value),onKeyDown:F,onFocus:()=>{l&&h.length>0&&x(!0)},placeholder:k??d("输入文件路径..."),disabled:a,className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 disabled:cursor-not-allowed disabled:bg-neutral-50 disabled:text-neutral-400"}),e.jsxs("button",{onClick:()=>w(l),disabled:a||!l.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(re,{size:14}),e.jsx("span",{children:d("添加")})]})]}),u&&e.jsx("div",{ref:E,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:h.map((s,i)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${i===p?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(X,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(V,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:A=>M(s,A),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:d("添加此目录"),children:e.jsx(ve,{size:14})})]},s.path))})]}),a&&c&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:c})]})}function ke({value:t,onChange:y}){const{t:N}=_(),[k,a]=o.useState(""),[c,d]=o.useState(""),l=()=>{const n=k.trim(),u=c.trim();!n||!u||(y([...t,{name:n,command:u}]),a(""),d(""))},j=n=>{y(t.filter((u,x)=>x!==n))},h=n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.preventDefault(),l())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((n,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:n.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:n.command}),e.jsx("button",{onClick:()=>j(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(se,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:k,onChange:n=>a(n.target.value),onKeyDown:h,placeholder:N("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:c,onChange:n=>d(n.target.value),onKeyDown:h,placeholder:N("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:l,disabled:!k.trim()||!c.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(re,{size:14}),e.jsx("span",{children:N("添加")})]})]})]})}function Z(t){return t?t.split(",").map(y=>y.trim()).filter(Boolean):[]}function ee(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function te(t){return typeof t.color!="string"||t.color.trim()===""?"bg-muted-foreground":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-muted-foreground"}function ze(){const{t}=_(),{data:y,isLoading:N}=fe({limit:100,includeArchived:!0}),k=he(),a=ge(),c=je(),[d,l]=o.useState(""),[j,h]=o.useState(null),[n,u]=o.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[x,p]=o.useState(!1),[v,b]=o.useState(null),[E,R]=o.useState(!1),[q,w]=o.useState(!1),[S,D]=o.useState(!1),[M,F]=o.useState(!1),[s,i]=o.useState(""),[A,J]=o.useState(!1),C=y?.data??[],g=o.useMemo(()=>C.filter(r=>!r.archivedAt),[C]),I=o.useMemo(()=>C.filter(r=>r.archivedAt),[C]),f=g.find(r=>r.id===d),T=o.useMemo(()=>C.find(r=>r.id===v)??null,[v,C]);if(o.useEffect(()=>{!d&&g.length>0&&l(g[0].id)},[g,d]),o.useEffect(()=>{if(j){g.some(r=>r.id===j)&&(l(j),h(null));return}d&&!g.some(r=>r.id===d)&&(l(g[0]?.id??""),p(!1))},[g,j,d]),o.useEffect(()=>{f&&!x&&u({copyFiles:Z(f.copyFiles),setupScript:f.setupScript??"",quickCommands:ee(f.quickCommands)})},[f,x]),N)return e.jsx(K,{className:"max-w-5xl",children:e.jsx(ue,{})});if(C.length===0)return e.jsxs(K,{className:"max-w-5xl",children:[e.jsx($,{title:t("项目配置")}),e.jsx(H,{message:t("暂无项目,请先创建项目")})]});const ne=()=>{d&&k.mutate({id:d,copyFiles:n.copyFiles.length>0?n.copyFiles.join(", "):null,setupScript:n.setupScript.trim()||null,quickCommands:n.quickCommands.length>0?JSON.stringify(n.quickCommands):null},{onSuccess:()=>p(!1)})},oe=r=>{h(null),l(r),p(!1),J(!0)},ae=()=>{f&&(b(f.id),D(!1),F(!1),R(!0))},O=()=>{a.isPending||(R(!1),b(null),D(!1),F(!1))},ie=async()=>{if(v)try{await a.mutateAsync({id:v,deleteRepo:S}),U.success(t(S?"项目已删除,并清理了本地文件":"项目已删除")),p(!1),O()}catch{}},le=r=>{const m=I.find(P=>P.id===r);b(r),i(m?.repoDeletedAt?m.repoPath:""),w(!0)},L=()=>{c.isPending||(w(!1),b(null),i(""))},ce=async()=>{if(!(!v||T?.repoDeletedAt&&!s.trim()))try{const m=await c.mutateAsync({id:v,repoPath:s.trim()||void 0});U.success(t("项目已恢复"));for(const P of m.warnings)U.warning(P);p(!1),h(m.project.id),l(m.project.id),L()}catch{}},Q=T?.name??t("this project"),G=!!T?.repoDeletedAt,B=f?.isGitRepo!==!1&&f?.worktreeReady!==!1;return e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"max-w-5xl",children:[e.jsx($,{title:t("项目配置")}),g.length===0&&I.length===0?e.jsx(H,{message:t("暂无项目,请先创建项目")}):e.jsx(Ne,{items:g,selectedId:d,onSelectItem:oe,getItemId:r=>r.id,mobileShowDetail:A,onMobileBack:()=>J(!1),renderListItem:(r,m)=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:W("h-2 w-2 rounded-full shrink-0",m?"bg-primary-foreground/60":te(r))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:r.name}),e.jsx("div",{className:W("truncate text-[11px] font-mono",m?"text-primary-foreground/70":"text-muted-foreground"),children:r.repoPath.split("/").pop()})]})]}),renderListFooter:I.length>0?()=>e.jsxs("div",{className:"pt-3 mt-2 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 mb-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:t("已删除")}),e.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:I.length})]}),I.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg px-3 py-2 text-muted-foreground",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px]",children:r.name})}),e.jsx("button",{onClick:()=>le(r.id),disabled:c.isPending,className:"shrink-0 text-[11px] hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60","aria-label":t("恢复项目"),children:e.jsx(pe,{size:12})})]},r.id))]}):void 0,renderDetail:r=>r?e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:W("h-2.5 w-2.5 rounded-full shrink-0",te(r))}),e.jsx("h3",{className:"text-base font-semibold text-foreground",children:r.name}),r.isGitRepo===!1&&e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:t("Local project")})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono mb-5",children:r.repoPath}),r.isGitRepo===!1&&e.jsx("div",{className:"mb-5 rounded-lg border border-info/25 bg-info/8 px-3 py-2 text-xs leading-relaxed text-info/90",children:t("Local projects only support local Solo tasks. Initialize Git to use worktrees and TeamRun.")}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsxs("div",{className:"py-5 first:pt-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("自动复制文件")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("创建 worktree 时自动从主仓库复制的文件或目录,适用于 .env、node_modules 等不在 git 管理中的文件。支持 glob。")})]}),e.jsx(Pe,{value:n.copyFiles,onChange:m=>{u(P=>({...P,copyFiles:m})),p(!0)},repoPath:r.repoPath,disabled:!B,disabledMessage:t("This setting applies only to Git worktree projects.")})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("创建 worktree 后自动执行的命令,每行一条。在 worktree 目录下执行,单条超时 5 分钟。")})]}),e.jsx("textarea",{value:n.setupScript,onChange:m=>{u(P=>({...P,setupScript:m.target.value})),p(!0)},placeholder:`pnpm install
2
2
  pnpm run setup`,rows:4,disabled:!B,className:"w-full rounded-lg border border-input bg-muted/50 px-3 py-2 text-sm font-mono transition-colors focus:border-ring focus:bg-background focus:outline-none resize-none disabled:cursor-not-allowed disabled:opacity-50"}),!B&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("This setting applies only to Git worktree projects.")})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:t("常用命令")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("在终端中可快速执行的命令,不会自动运行。")})]}),e.jsx(ke,{value:n.quickCommands,onChange:m=>{u(P=>({...P,quickCommands:m})),p(!0)}})]})]}),e.jsx("div",{className:"mt-2 rounded-lg border border-destructive/30 bg-destructive/10 p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(me,{size:15,className:"text-destructive mt-0.5 shrink-0","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:t("删除项目")}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:t("项目将从默认列表隐藏,历史记录保留。可选同时删除本地文件。")})]})]}),e.jsxs(z,{size:"sm",variant:"destructive",className:"shrink-0",onClick:ae,disabled:a.isPending||c.isPending,children:[e.jsx(ye,{size:13}),t("删除项目")]})]})}),x&&e.jsx(xe,{saving:k.isPending,onSave:ne,onCancel:()=>{f&&u({copyFiles:Z(f.copyFiles),setupScript:f.setupScript??"",quickCommands:ee(f.quickCommands)}),p(!1)},className:"-mx-5"})]}):e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:g.length>0?t("选择一个项目查看配置"):t("当前没有可配置的项目")})})]}),e.jsx(Y,{isOpen:E,onClose:O,title:t("Delete Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"outline",onClick:O,disabled:a.isPending,children:t("Cancel")}),e.jsx(z,{variant:"destructive",onClick:ie,disabled:a.isPending||S&&!M,children:a.isPending?t("Deleting..."):t("Delete Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t("项目「{title}」将从默认项目列表隐藏,但历史任务、workspace 和会话记录仍会保留。",{title:Q})}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-border bg-muted px-3 py-3",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:r=>{D(r.target.checked),r.target.checked||F(!1)},className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:t("同时删除本地项目文件")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("勾选后会删除项目路径指向的本地目录,并禁用代码/Git 相关能力。")})]})]}),S&&e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:t("勾选后会连项目文件一起删除,请谨慎选择。")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("恢复该项目时需要重新绑定一个有效的项目路径。")}),e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-xs text-foreground",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:r=>F(r.target.checked),className:"mt-0.5 h-4 w-4 rounded border-border accent-primary"}),e.jsx("span",{children:t("我已确认这会删除本地项目文件")})]})]}),a.isError&&e.jsx("p",{className:"text-xs text-destructive",children:a.error instanceof Error?a.error.message:t("Failed to delete project")})]})}),e.jsx(Y,{isOpen:q,onClose:L,title:t("Restore Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"outline",onClick:L,disabled:c.isPending,children:t("Cancel")}),e.jsx(z,{onClick:ce,disabled:c.isPending||G&&!s.trim(),children:c.isPending?t("Restoring..."):t("Restore Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:G?t("项目「{title}」的本地项目文件已删除。恢复前需要重新绑定一个有效的项目路径。",{title:Q}):t("恢复后,项目会重新出现在默认项目列表中。")}),G&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1.5",children:t("Project Path")}),e.jsx(be,{value:s,onChange:i,validationMode:"directory"}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:t("Agent Tower 会尽量校验项目 identity;如果 remote URL 或目录名不同,会给出警告但允许继续。")})]}),c.isError&&e.jsx("p",{className:"text-xs text-destructive",children:c.error instanceof Error?c.error.message:t("Failed to restore project")})]})})]})}export{ze as ProjectSettingsPage};
@@ -1,4 +1,4 @@
1
- import{k as tt,m as Ct,q as St,p as Pt,u as H,r as S,j as n,l as $,a6 as nt,T as Ue,I as oe,B as _,Q as kt,S as We,a1 as At,g as Tt,ae as _t,v as It,C as Ot,t as z,a3 as Dt,i as ke,af as Rt,aa as Ae}from"./index-DJqjl4es.js";import{a as Ut,b as Kt,u as Lt,c as Mt,d as Bt,e as zt,f as Ft,g as $t,h as Jt}from"./use-providers-BzZ7Dpm4.js";import{C as Wt}from"./confirm-dialog-BOmXWU-c.js";import{M as Ke}from"./modal-BUKaDX-v.js";import{S as Te}from"./select-DQiySo8W.js";import{T as qe}from"./textarea-SORnJi9y.js";import{S as it}from"./switch-Bmbr34G9.js";import{i as Le,R as F,h as A,P as ye,U as qt,j as Vt,k as Gt}from"./mermaid-NOHMQCX5-9Sp0Awb9.js";import{A as fe}from"./AgentLogo-C0bPAxbG.js";import{C as rt}from"./chevron-down-F0HaYv4G.js";import{S as Xt}from"./SettingsMasterDetail-nkWk1iMZ.js";import{T as st,P as _e}from"./trash-2-BeXtY9XM.js";import{U as Yt}from"./upload-mXU9O8ZR.js";import{P as Zt}from"./pencil-BRpoyX8s.js";import"./check-D0G5G0XX.js";import"./chevron-right-CPwvo275.js";const Ht=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Qt=tt("flask-conical",Ht);const en=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],tn=tt("key-round",en);function nn(e,t){let r=e.slice(0,t).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function rn(e,t,r){let s=e.split(/\r\n|\n|\r/g),a="",o=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let c=s[i-1];c&&(a+=i.toString().padEnd(o," "),a+=": ",a+=c,a+=`
1
+ import{k as tt,m as Ct,q as St,p as Pt,u as H,r as S,j as n,l as $,a6 as nt,T as Ue,I as oe,B as _,Q as kt,S as We,a1 as At,g as Tt,ae as _t,v as It,C as Ot,t as z,a3 as Dt,i as ke,af as Rt,aa as Ae}from"./index-oC5eh7mZ.js";import{a as Ut,b as Kt,u as Lt,c as Mt,d as Bt,e as zt,f as Ft,g as $t,h as Jt}from"./use-providers-B70-BYNu.js";import{C as Wt}from"./confirm-dialog-BWvZEHpu.js";import{M as Ke}from"./modal-D87uszzb.js";import{S as Te}from"./select-D7WkUiad.js";import{T as qe}from"./textarea-D9oaz-Ba.js";import{S as it}from"./switch-1pvXCcP-.js";import{i as Le,R as F,h as A,P as ye,U as qt,j as Vt,k as Gt}from"./mermaid-NOHMQCX5-CGCWmHha.js";import{A as fe}from"./AgentLogo-Ntqe3_Mx.js";import{C as rt}from"./chevron-down-BZfpVhYr.js";import{S as Xt}from"./SettingsMasterDetail-OF28cvPV.js";import{T as st,P as _e}from"./trash-2-C0P8jNpJ.js";import{U as Yt}from"./upload-BYgsDplu.js";import{P as Zt}from"./pencil-CY2RnQrx.js";import"./check-C1zWgxFO.js";import"./chevron-right-D52zUyOF.js";const Ht=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Qt=tt("flask-conical",Ht);const en=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],tn=tt("key-round",en);function nn(e,t){let r=e.slice(0,t).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function rn(e,t,r){let s=e.split(/\r\n|\n|\r/g),a="",o=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let c=s[i-1];c&&(a+=i.toString().padEnd(o," "),a+=": ",a+=c,a+=`
2
2
  `,i===t&&(a+=" ".repeat(o+r+2),a+=`^
3
3
  `))}return a}class N extends Error{line;column;codeblock;constructor(t,r){const[s,a]=nn(r.toml,r.ptr),o=rn(r.toml,s,a);super(`Invalid TOML document: ${t}
4
4
 
@@ -1 +1 @@
1
- import{u as v,j as r,l as s,s as h}from"./index-DJqjl4es.js";function w({items:o,selectedId:l,onSelectItem:c,getItemId:t,renderListItem:d,renderDetail:u,renderListFooter:g,mobileShowDetail:a,onMobileBack:x,listClassName:m,detailClassName:f}){const{t:p}=v(),b=o.find(e=>t(e)===l)??null;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)] gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[r.jsxs("div",{className:s("min-w-0 space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",a&&"hidden lg:block",m),children:[o.map(e=>{const i=t(e),n=i===l;return r.jsx("button",{onClick:()=>c(i),"aria-current":n?"true":void 0,className:s("flex min-w-0 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",n?"bg-primary text-primary-foreground":"text-foreground hover:bg-muted/50"),children:d(e,n)},i)}),g?.()]}),r.jsxs("div",{className:s("min-w-0 rounded-xl border border-border bg-card lg:overflow-y-auto scrollbar-app-thin",!a&&"hidden lg:block",f),children:[r.jsxs("button",{onClick:x,className:"mb-4 flex items-center gap-1.5 px-5 pt-3 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 lg:hidden",children:[r.jsx(h,{size:14}),p("返回列表")]}),u(b)]})]})}export{w as S};
1
+ import{u as v,j as r,l as s,s as h}from"./index-oC5eh7mZ.js";function w({items:o,selectedId:l,onSelectItem:c,getItemId:t,renderListItem:d,renderDetail:u,renderListFooter:g,mobileShowDetail:a,onMobileBack:x,listClassName:m,detailClassName:f}){const{t:p}=v(),b=o.find(e=>t(e)===l)??null;return r.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)] gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[r.jsxs("div",{className:s("min-w-0 space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",a&&"hidden lg:block",m),children:[o.map(e=>{const i=t(e),n=i===l;return r.jsx("button",{onClick:()=>c(i),"aria-current":n?"true":void 0,className:s("flex min-w-0 w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",n?"bg-primary text-primary-foreground":"text-foreground hover:bg-muted/50"),children:d(e,n)},i)}),g?.()]}),r.jsxs("div",{className:s("min-w-0 rounded-xl border border-border bg-card lg:overflow-y-auto scrollbar-app-thin",!a&&"hidden lg:block",f),children:[r.jsxs("button",{onClick:x,className:"mb-4 flex items-center gap-1.5 px-5 pt-3 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 lg:hidden",children:[r.jsx(h,{size:14}),p("返回列表")]}),u(b)]})]})}export{w as S};